|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Fernandore19 Smarty n00b
Joined: 12 Apr 2014 Posts: 1
|
Posted: Sat Apr 12, 2014 11:53 pm Post subject: como este code php a smarty |
|
|
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 |
|
mostaza Smarty n00b
Joined: 31 Aug 2014 Posts: 2
|
Posted: Sun Aug 31, 2014 5:46 pm Post subject: |
|
|
estem, habria que ver como esta el tpl al que esta pasando el bucle,
lo que se me ocurre, (aclaro que no se demasiado)
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!! |
|
Back to top |
|
|
|
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
|