ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

ExpressionEngine 1.6.9: display DIV at particular pages generated by same template

September 07, 2010 6:24am

Subscribe [3]
  • #1 / Sep 07, 2010 6:24am

    art.mania

    12 posts

    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!!!

    [Mod Edit: Moved to the EE 1 Technical Support forum]

  • #2 / Sep 07, 2010 7:17am

    Benjamin

    116 posts

    Hi art.mania,

    I don’t think this really is a pre-sales question, but here goes;

    You could use conditional variables. Lets say you have a custom field called “info_box”, then you can use this in your template:

    {if info_box !=""}
    <div id="extra-div">
    {info_box}
    </div>
    {/if}

    The template system will then check to see if your custom field is empty or not, if the custom field is empty, it will not show anything in between the {if} and {/if} variables. If your custom field has content it will show:

    <div id="extra-div">
    info_box custom field content
    </div>

    Check out the user guide for more info: http://expressionengine.com/legacy_docs/templates/globals/conditionals.html

  • #3 / Sep 07, 2010 7:54am

    art.mania

    12 posts

    I could not post to anywhere else at the forum :/ I was allowed to post only here.

    Appreciate for your time to reply. So I can check the current url in if. I have been researching the variable to get url, could not find yet. :/

    http://www.blabla.com/xxx/yyy/

    how to get xxx and yyy in a variable? {site_url} gives http://www.blabla.com but how to get others?

  • #4 / Sep 07, 2010 7:56am

    Benjamin

    116 posts

    You can check on those with URL segment variables:
    {segment_1}
    {segment_2}
    etc.. etc..

    See: http://expressionengine.com/legacy_docs/templates/globals/url_segments.html

  • #5 / Sep 07, 2010 8:06am

    art.mania

    12 posts

  • #6 / Sep 07, 2010 4:26pm

    Ingmar

    29245 posts

    Glad to see that works for you, art.mania! Thanks for the assist, Benjamin. Please post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases