detecting latest 3 posts

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post by MySchizoBuddy »

ok cool counter works :)
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 :) :) :)
Now the random number should not generate the same number again. lets see what it does
sanku garvin
Image
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post by MySchizoBuddy »

ok problem. counter cannot be used inside an if statement. So i cannot check the counter.
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

I think that can be done by accessing the $smarty array somehow, or using {assign}...?

REgards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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
:?
i tried this
<?php
$smarty->assign('inc', '{counter}');
?>

doesn't work either
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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}
Image
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

We should have Smarty 2.6.9, I think!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post by MySchizoBuddy »

ok the release notes in the smarty folder says 2.5.0
its ok i guess.
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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 :-D

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post by MySchizoBuddy »

one more thing, do the blocks have unique Ids. So i can call them specifically from my entries.tpl file
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Uh, can you be more specific on your block-ID question? The have unique IDs in the database, yes...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
MySchizoBuddy
Regular
Posts: 340
Joined: Sun Jun 12, 2005 5:28 am

Post 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
Image
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply