Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

como este code php a smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish
View previous topic :: View next topic  
Author Message
Fernandore19
Smarty n00b


Joined: 12 Apr 2014
Posts: 1

PostPosted: Sat Apr 12, 2014 11:53 pm    Post subject: como este code php a smarty Reply with quote

Code:
$Genre= $row['Genre'];

   $Genre = ereg_replace( "([ ]+)", "", $Genre );

   $Genre = explode(',', $Genre);

   for($j=0;$j<count($Genre);$j++)
   
   echo '<a class="grande" href="../categoria/'.$Genre[$j].'/">'.$Genre[$j].'</a>, ';


ya lo e intentado con {php} pero no funciona
Back to top
View user's profile Send private message
mostaza
Smarty n00b


Joined: 31 Aug 2014
Posts: 2

PostPosted: Sun Aug 31, 2014 5:46 pm    Post subject: Reply with quote

estem, habria que ver como esta el tpl al que esta pasando el bucle,

lo que se me ocurre, (aclaro que no se demasiado) Confused

primero hay muchas formas de hacerlo, incluso puede utilizar replace y el coun en el mismo tpl, pero yo le doy una idea:

en su archivo php:

Code:

$Genre= $row['Genre'];
$Genre = ereg_replace( "([ ]+)", "", $Genre );
$Genre = explode(',', $Genre);

$count_cantidad = count($Genre);

$smarty->assign("numero", $count_cantidad);



en el tpl:

Code:
{if isset($numero)}

{section name=foo start=0 loop={$numero|strip|strip_tags:false} step=1}

<a class="grande" href="../categoria/{$smarty.section.foo.index}">{$smarty.section.foo.index}</a>

{/section}

{/if}


en teorķa deberķa de funcionar


salu2!! Rolling Eyes
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Spanish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP