views:

14

answers:

1

Hi friends,

I'm a EE newbie. I have a template for subpage. all subpages use same subpage template. But for some sub pages I need to put an extra div (kinda info box), how can I put a condition? do I have to create a separate template only for a small div difference?

urls are consistent, so if i can make a url check and display div for right urls, it would work out for me, but can I put any php if {} condition into template?

Appreciate helps so much!!!

A: 

You can use ExpressionEngine conditionals.

See the documentation here: http://expressionengine.com/legacy_docs/templates/globals/conditionals.html

Based on your description, I think you could do this based on the URL. You can read URLs using segment variables. So if your URL is http://www.foo.com/bar/test and you only want to show the box on the /bar/test page, use a conditional like this:

{if segment_2 == 'test'}
<div id="foobar">Lorem Ipsum</div>
{/if}
pstinnett