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 Loops

August 11, 2011 10:03am

Subscribe [3]
  • #1 / Aug 11, 2011 10:03am

    k0rhal

    2 posts

    Hi guys,

    I am using the template controls to loop through a channel as follows:

    <ul>
    {exp:channel:entries category_group="1" orderby="date" limit="15" }
      <li>{title} {channel_name}</li>
    {/exp:channel:entries}
    </ul>

    Within this template loop I would like to use PHP to alter one of the variables with an explode, extracting part of the data.
    I understand that PHP executes first, then the template code.. so how would you suggest I manipulate channel data?

    Thanks

  • #2 / Aug 11, 2011 1:38pm

    the3mus1can

    426 posts

    In template preferences for that template set PHP to run on output.

  • #3 / Aug 11, 2011 2:03pm

    Korhal

    3 posts

    I’ve done that, but how can PHP modify a expression engine var.. Its out of execution order as far as i understand..

  • #4 / Aug 11, 2011 2:17pm

    the3mus1can

    426 posts

    By setting it to output you are changing when the PHP gets evaluated in the template. For instance:

    <ul>
    {exp:channel:entries category_group=“1” orderby=“date”  limit=“15” }
      <li>{title} {channel_name} 
        <?php 
          $keywords = explode(', ', '{keywords}');
          ... do something with the keywords array ...
          echo implode(', ', $keywords);
        ?>
      </li>
    {/exp:channel:entries}
    </ul>
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases