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.

Strange behaviour of PHP variables

April 17, 2012 6:32am

Subscribe [2]
  • #1 / Apr 17, 2012 6:32am

    Giraffentoast

    152 posts

    PHP variables set inside an EE loop are reset to a EEish value… kinda… when the loop ends?

    Example:

    <?php
    
    $aaa = 1;
    
    ?>
    
    {exp:channel:categories channel="gallery"}
     {if active}
      <?php
      
      $aaa = "{category_id}";
      echo 'AAA: '.$aaa;
      
      ?>
     {/if}
    {/exp:channel:categories}
    
    <?php
    
    echo 'BBB: '.$aaa;
    
    ?>

    ...will return:

    AAA: 3 
    BBB: {category_id}

    Why is this so?
    And how are we supposed to work around it?

  • #2 / Apr 18, 2012 10:01pm

    Man With A Peg

    124 posts

    Is PHP running on Input or Output? I’d wager that you have it set to Input. You should try Output:

    http://loweblog.com/downloads/ee-parse-order.pdf

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

ExpressionEngine News!

#eecms, #events, #releases