Page 2 of 2
Posted: Thu Dec 08, 2005 2:51 pm
by MySchizoBuddy
ok cool counter works
![Smile :)](./images/smilies/icon_smile.gif)
phew I was freaking out, cause without the counter my cool new blog was broken , I also found a smarty random function {1|rand:5} that will generate random number between 1 and 5 and i can use this to randomly show the blocks
![Smile :)](./images/smilies/icon_smile.gif)
Now the random number should not generate the same number again. lets see what it does
sanku garvin
Posted: Thu Dec 08, 2005 4:34 pm
by MySchizoBuddy
ok problem. counter cannot be used inside an if statement. So i cannot check the counter.
Posted: Thu Dec 08, 2005 4:38 pm
by garvinhicking
I think that can be done by accessing the $smarty array somehow, or using {assign}...?
REgards,
Garvin
Posted: Thu Dec 08, 2005 4:48 pm
by MySchizoBuddy
yeah i'm trying the assign function
{assign var="inc" value={counter}}
but that won't work cause u cannot have {} inside {}
{assign var="inc" value=counter}
this assigns the word counter not the value
![Confused :?](./images/smilies/icon_confused.gif)
i tried this
<?php
$smarty->assign('inc', '{counter}');
?>
doesn't work either
Posted: Thu Dec 08, 2005 5:02 pm
by garvinhicking
Yeah, that's all right. But Smarty stores the current counter value somehwere in a $smarty array. You may need to ask the smarty people/documentation for more info on that, at Least I don't know much about it.
Something like
http://smarty.php.net/manual/en/languag ... smarty.php.
Regards,
Garvin
Posted: Thu Dec 08, 2005 5:21 pm
by MySchizoBuddy
ok this worked
{counter assign=inc print=false}
{assign var="allow" value=0|rand:1}
{if $inc gt 1 and $inc lt 6 and $allow==1}
{$entry.plugin_display_dat}
{/if}
now i can randomly place the ads between post 1 and 6
plus i'm noticing on smarty forum, people don't like to use {counter} rather they seem to use {section}
Posted: Fri Dec 09, 2005 2:37 am
by MySchizoBuddy
btw the smarty version we have is 2.5.0 the version the latest version is 2.6.10. Should i upgrade the smarty or is it something i should not fiddle with
Posted: Fri Dec 09, 2005 12:53 pm
by garvinhicking
We should have Smarty 2.6.9, I think!
Regards,
Garvin
Posted: Fri Dec 09, 2005 1:18 pm
by MySchizoBuddy
ok the release notes in the smarty folder says 2.5.0
its ok i guess.
Posted: Fri Dec 09, 2005 1:19 pm
by garvinhicking
I think they didn't update that release file in their release for quite some time. But I know we have 2.6.9, and that 2.6.10 doesn't have that required changes for us, so I decided to stay with a working smarty
Regards,
Garvin
Posted: Mon Dec 12, 2005 7:13 pm
by MySchizoBuddy
one more thing, do the blocks have unique Ids. So i can call them specifically from my entries.tpl file
Posted: Tue Dec 13, 2005 10:40 am
by garvinhicking
Uh, can you be more specific on your block-ID question? The have unique IDs in the database, yes...
Regards,
Garvin
Posted: Tue Dec 13, 2005 1:47 pm
by MySchizoBuddy
what i meant was is that if i have like 5 blocks, and i only want to display 2 of them. So can i in my entries.tpl file directly call them. like {$entry.plugin_display_block2} or something. right now all the blocks are shown randomly, but i want to select which ones get shown randomly and whch one not random
Posted: Tue Dec 13, 2005 2:40 pm
by garvinhicking
Hm, I don't know, you'll need to try. I think it must be done within the Plugin PHP code, you can build a smarty function that prints a block yourself there.
Regards,
Garvin