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.

Simple recursion/inheritance question

June 04, 2013 8:05pm

Subscribe [1]
  • #1 / Jun 04, 2013 8:05pm

    antiuser

    44 posts

    I’m using the Structure module for this site which is quite large (over 2000 pages), and the client has requested that some sections should have their own analytics tracking code. Seems easy enough, right? Create a field for it, drop it in the template. The issue is that the child pages of those sections should also have the same code, and sometimes those sections begin at segment_2, sometimes at segment_3, sometimes at segment_4. The sections are spread across 3 separate channels, but they share the same channel fields.

    So I’m trying to come up with a piece of code that will do the following:

    1. Check whether the depth of the current page is above 4 ({if segment_4 != ""})
    2. Check whether the current page has its own tracking code
    3. If the current page has a tracking code, output it. Otherwise, check if the parent page (segment_3) has one.
    4. If the parent (segment_3) has a tracking code, output it. Otherwise, check if segment_2 has one.

    You get the idea. Seems like something that would be pretty simple to do, but I can’t figure out any way of doing this without nesting {exp:channel:entries} tags, which doesn’t seem to work.

    Any assistance would be helpful…

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

ExpressionEngine News!

#eecms, #events, #releases