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.

Template If Statement limit? Or segment access limit?

June 03, 2010 9:21am

Subscribe [1]
  • #1 / Jun 03, 2010 9:21am

    WDBookassist

    26 posts

    Hi folks,

    Just a slightly odd problem I’ve come across that I can’t seem to find anything about in the documentation. Maybe you can explain this.

    I’m writing out translation flags at the top of my site. Within the link I check to see if segments are available present, allowing me to link to the same page in another language.

    My page structure may be up to 4 segments deep. So I don’t end up with /test/// this is what I’m doing:

    <a href="/de/{if" title="Translate language" class="active">/images/stylesheet/flags/de.png</a> 


    THE PROBLEM:
    This approach has worked for other sites with less languages, but when I try it with all 9 languages, only a few of the links are written. The template effectively stops after writing 4 or 5 (depending on the number of segments actually there).

    <div id="translate">
    
    <a href="/{if" title="Translate language" class="active">/images/stylesheet/flags/en.png</a> 
    <a href="/cs/{if" title="Translate language" class="active">/images/stylesheet/flags/cs.png</a> 
    <a href="/de/{if" title="Translate language" class="active">/images/stylesheet/flags/de.png</a> 
    <a href="/fr/{if" title="Translate language" class="active">/images/stylesheet/flags/fr.png</a> 
    <a href="/es/{if" title="Translate language" class="active">/images/stylesheet/flags/es.png</a> 
    <a href="/it/{if" title="Translate language" class="active">/images/stylesheet/flags/it.png</a> 
    <a href="/ru/{if" title="Translate language" class="active">/images/stylesheet/flags/ru.png</a> 
    <a href="/jp/{if" title="Translate language" class="active">/images/stylesheet/flags/jp.png</a> 
    <a href="/pl/{if" title="Translate language" class="active">/images/stylesheet/flags/pl.png</a>
    
    
    </div>

    It’s like there’s a limit on how many of these checks I’m allowed do. I can change the number of links written by changing the number of segments. Weird?

    I tried to move the segment collection to a single PHP variable which i would then reuse, but I can only get this to work when PHP Parsing Stage is input and then I run into exactly the same problem.

  • #2 / Jun 03, 2010 9:46am

    ender

    1644 posts

    I’ve run into a sort of “conditional limit” before in the past.  Since you’re building the identical URI segment in each case, I’d recommend either using PHP to access the full url ($IN->URI, more info here) or if you’d rather keep it in EE template tags I’d use the string plugin to build your URI chunk and then print it multiple times.

    Something like this ought to work:

    {exp:string:set name="page_uri"}{segment_1}{/exp:string:set}
    {exp:string:append name="page_uri" separator="/" glue="NONE"}{segment_2}{/exp:string:append}
    {exp:string:append name="page_uri" separator="/" glue="NONE"}{segment_3}{/exp:string:append}
    {exp:string:append name="page_uri" separator="/" glue="NONE"}{segment_4}{/exp:string:append}
    {exp:string:append name="page_uri" separator="/" glue="NONE"}{segment_5}{/exp:string:append}
    {exp:string:append name="page_uri" separator="/" glue="NONE"}{segment_6}{/exp:string:append}
    ... more if you need ...
    
    <a href="/{exp:string">english</a>
    <a href="/cs/{exp:string">czech</a>
    ... etc ...
  • #3 / Jun 03, 2010 10:46am

    WDBookassist

    26 posts

    That sounds like the solution I’m looking for ender. Thanks for the pointer. I will look into both those approaches.

    thanks,
    Pierce

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

ExpressionEngine News!

#eecms, #events, #releases