I need insert php code in template

Discussion corner for Developers of Serendipity.
Post Reply
Stefano

I need insert php code in template

Post by Stefano »

I need insert php code for include adsense banner in home page

{if not $is_single_entry }


i want only view banner in 2 post (i use 4 display article for page)

i have try this solution :

Code: Select all


 <? $pippo_baudo = $this->_tpl_vars['entry']['id']/2;
if(is_float($pippo_baudo) && ! $this->_tpl_vars['is_single_entry']){echo $this->_tpl_vars['entry']['id'];} ?>

But i need help for write with smarty
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Sorry, I'm not really certain what you want.

Are you trying to achieve:

(On frontpage only)
Article
Article
Adsense Banner
Article
Article
Adsense Banner

If so, you could use the Static Blocks plugin. Define a static block with the Adsense Banner URL, and define it to repeat every 2 articles.

If you want something else, describe it and I'll try again.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need insert php code in template

Post by garvinhicking »

You shouldn't ever modify the .tpl.php files. Always only edit the .tpl files in the templates directory (NOT templates_c).

Inside the entries.tpl you can do your Smarty checking code like

Code: Select all

{if not $is_single_entry and $entry.id == 4711}
ADCODE
{/if}
HTH,
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