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.

Detect page (url) to apply conditional code

May 24, 2010 10:53am

Subscribe [2]
  • #1 / May 24, 2010 10:53am

    bmdstinky

    4 posts

    Hi All,

    I’m sure this has been asked before but can’t find anything via a search.

    I’ve got a Google Map template group which needs a specific javascript file (which is generated via looping through a weblog). This script looks for a div with an id of ‘map’ to attach the map too. I’ve got an embed template for my header code but don’t want this script file to apply to every page.

    Can I do something like

    {if my-page-is-from-template-group'map'}
    // add my javascript file link
    {/if}

    Thanks,
    Brett

  • #2 / May 24, 2010 12:18pm

    Focus Lab Dev Team

    1129 posts

    Hi Brett

    You could use segment variables in a conditional like this:

    {if segment_1 == 'map'}
    // your javascript code here
    {/if}

    I do that all the time.

  • #3 / May 25, 2010 7:44am

    bmdstinky

    4 posts

    Erik,

    Thanks for the reply, I’ll check that page out.

    Thanks again,
    Brett

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

ExpressionEngine News!

#eecms, #events, #releases