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.

Reuse a variable from within an EE tag pair outside that tag pair?

August 26, 2010 8:50pm

Subscribe [2]
  • #1 / Aug 26, 2010 8:50pm

    Rick Jolly

    729 posts

    Without using php, is it possible to reuse a variable from within an EE tag pair outside that tag pair? In the example below, I’d like to reuse {title} outside the scope of the {exp:channel:entries} tag pair

    {exp:channel:entries channel="test" entry_id="1" limit="1"}
       <?php $title = {title}; ?>
    {/exp:channel:entries}
    
    <?php echo $title; ?> // works
    {title} // doesn't work

    As a work around, I’ve moved the tag pair into a snippet, but I have no way of passing in parameters like the channel or entry_id. I could put the tag pair into an embed, but then I couldn’t use the returned result in a conditional if need be.

  • #2 / Aug 28, 2010 11:05am

    e-man

    1816 posts

    For 1.6 you had a plugin called Reeposition http://devot-ee.com/add-ons/reeposition/
    no 2 version I know of.
    What exactly are you trying/need to achieve?

  • #3 / Aug 31, 2010 11:00pm

    Rick Jolly

    729 posts

    Hi e-man, thanks for your response.

    Ha, I’m trying to achieve so many different things. One example: on an article page I want to highlight a category menu item corresponding to the current article. So I get the article’s category within the {exp:channel:entries} tag pair, then store it in a php variable so that I can use it to determine the category to highlight within the {exp:channel:categories} tag pair that I use to construct the navigation menu.

    I’m discovering the limits of EE templating. Like every EE tag or tag pair is its own isolated function that returns a static string of text. It’s much less powerful than using just php or a template engine that compiles into php (like smarty).

  • #4 / Sep 01, 2010 7:34am

    e-man

    1816 posts

    For EE2, also have a look at http://expressionengine-addons.com/nsm-transplant
    But yeah, some php will get you there too 😊

  • #5 / Sep 01, 2010 1:58pm

    Rick Jolly

    729 posts

    Thanks so much. NSM Transplant is my new best friend.

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

ExpressionEngine News!

#eecms, #events, #releases