Page 1 of 2

detecting latest 3 posts

Posted: Mon Nov 07, 2005 1:47 pm
by MySchizoBuddy
basically this is what i want

detect the latest 3 posts.
put ad below the third one.

So no matter what happens the ad always appears after the 3 latest post

Perhaps this feature can be added to Html nugget. where a nugget can be placed after a specified number of posts

Re: detecting latest 3 posts

Posted: Mon Nov 07, 2005 4:41 pm
by garvinhicking
Look at serendipity_event_includeentry. It's basic usage was documented/announced on blog.s9y.org some time. It does what you want. :)

Best regards,
Garvin

Posted: Mon Nov 07, 2005 10:01 pm
by MySchizoBuddy
you are talking about this
http://blog.s9y.org/archives/49-Include ... lugin.html

I don't get how it will do what i want it to do.

I installed it. It can install a block under my entries and stuff by copying other body or extended entry.

How do i use it to add ads. :?

Posted: Tue Nov 08, 2005 11:53 am
by garvinhicking
You just put your adds into a content block, and then include your content block :)

A content block can contain any HTML/Javascript code, so Ads in there are no problem.

Regards,
Garvin

Posted: Tue Nov 08, 2005 5:25 pm
by MySchizoBuddy
where is the content block.
can u explain it a bit more

Posted: Tue Nov 08, 2005 6:37 pm
by garvinhicking
Yes, but the includeentry plugin works like that!

It adds a new item like the static pages menu item to your blog: "Template Blocks".

This panel from the plugin is broken up in two sections: Templates and Blocks. Templates can be used to create a new entry based from a template. Something like a draft article you can re-use for creating entries.

The rightmost section is where you maintain Blocks. Create a block and insert content (= your Ad-Code).

In the config of the includeentry plugin you can define "Show random blocks" to "Yes". This will show a random block after X entries in your blog. Of course you can also only have one random block with Ads, which will always be shown.

One can do it with templating as well, but I think the easier approach is the plugin.

It's hard to explain the plugin (I'm not a writer), but once you use it, it should get obvious.

Regards
Garvin

Posted: Wed Nov 09, 2005 10:37 am
by garvinhicking
Hi!
<rant>
This is one of MY biggest complaints about S9Y - how chaotic the plugin organization is !! :)
Yes, we need people to code spartacus.s9y.org (like pear.php.net) with a detailed plugin overview!
I don't know why the "entry templates and random nuggets" plugin is a part of the include entry plugin. From my viewpoint they are completely unrelated functions. I would never think to try something called "Markup: Include entry data/templates/blocks" if I needed to insert stuff BETWEEN entries.
Hm, well I think then we have different opinions on that - I find it very related ;) A main reason of course was not to clutter up the plugin repository too much by creating another plugin that has 50% of the needed functionality duplicated. If you look at the code, the two ways the plugin works are technically very related...
I assume that there is a reason to have them bundled like this....maybe you can include these "blocks" in actual entries by using include markup syntax?
Yes, you can do that with [s9y-include-block:....] inside the markup... :)

Best regards,
Garvin

Posted: Mon Dec 05, 2005 8:18 pm
by MySchizoBuddy
how can i modify the includeentry plugin so that i can assign the max times a particular block can be used.
For eg I'm using google ads, SO i want a max of 1 ad only. while the chitika ads i want 2 max.
It will be a good feature to have. :D

PLus I don't want any ads after 5 posts.

Posted: Tue Dec 06, 2005 1:26 pm
by garvinhicking
MSB: You can modify the plugin with PHP code *g*

It sounds like nice features, but it really not little work to implement that.

Best regards,
Garvin

Posted: Wed Dec 07, 2005 3:30 pm
by MySchizoBuddy
For not allowing ads after 5 posts i can use what roba said

Code: Select all

{foreach name=entryloop from=$entries item="dategroup"} 
    {if $smarty.foreach.entryloop.index<5 and $smarty.foreach.entryloop.index!=0} 
      		{$entry.plugin_display_dat}
    {/if}
then the same method to display 1 google ad after the first post and then randomly place chitika between 2 to 4 th post using include entry and skipping 2 entries.

not an elegant solution but should do the job

Posted: Thu Dec 08, 2005 6:05 am
by MySchizoBuddy
Roba it doesn't seem to work. the index goes back to 0. I cannot figure out why. I have placed it inside the inner forloop. so i guess the inner loop ends and then starts again. the loop is date dependent. any way to change it so it isn't date dependent
The outer forloop is stuck at (-1) why is it minus

Also garvin It doesn't randomly place the blocks. It randomly selects which blocks to place. but not randomly select where to place. right now its is showing one single block after all the entries.

Posted: Thu Dec 08, 2005 11:39 am
by garvinhicking
Hi!
Also garvin It doesn't randomly place the blocks. It randomly selects which blocks to place. but not randomly select where to place. right now its is showing one single block after all the entries.
I never said it would randomly place blocks. With "random placement" I mean exactly what you describe: The block to show is randomized. The position where it appears is fixed.

I'm sorry, but I have no time or intention to fix this at least within the next 4 weeks...I think in most cases this is just extra flexibility that isn'T so much needed. And you might get it to work with extra Smarty coding...

Regards,
Garvin

Posted: Thu Dec 08, 2005 2:11 pm
by MySchizoBuddy
garvin can u give me a counter that counts from 0 to end of all the posts and doesn't reset. right now the counter runs per day and resets for next day. So if i have 2 post today and 3 yesterday, the the counter goes from 0 to 1 and resets back to zero and goes from 0 to 2, it doesn't go from 0 to 4

Posted: Thu Dec 08, 2005 2:27 pm
by garvinhicking
MSB: You can add that yourself in your entries.tpl or whatever template. Check the Smarty documentation for {counter} and/or for {foreach}, which always sets running indices.

The entries.tpl has two loops, so you need to get the counter value of the outmost loop, not the inner loop.

Regards,
Garvin

Posted: Thu Dec 08, 2005 2:33 pm
by MySchizoBuddy
the outer most loop is stuck on -1. i'm not sure why
Ok let me try the {counter} and see what it does.
I guess I'll have to read up on random number generation and how to create smarty tags of it.
thanks.