We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Nested module tags

Development and Programming

bmds's avatar
bmds
8 posts
14 years ago
bmds's avatar bmds

I have got stuck while building a new module at the template tag point. I want to achieve something similar to this:

<ul>
{exp:module:method1}
  <li id="Handle{entry_id}">
    <ul class="subentries">
      {exp:module:method2 entry_id="{entry_id}"}
      <li>
        <h2>{title}</h2>
        {other_data}
      </li>
      {/exp:module:method2}
      </ul>
    </li>
{/exp:module:method1}
</ul>

I have followed the instructions on the module tutorial located here: http://ellislab.com/expressionengine/user-guide/development/module_tutorial.html

My code is similar to the following:

public function method1() {
        //Do database query to fill up the $variables var

        $output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables);
        return $output;
    }

    public function method2() {
        if (($entry_id = $this->EE->TMPL->fetch_param('entry_id')) === FALSE) return;

        //Do database query to fill up the $variables var

        $output = $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $variables);
        return $output;
    }

However when this runs the second method only gets passed pure HTML in the $this->EE->TMPL->tagdata var, all of the tags have already been parsed out. Is there a way round this or is ExpresionEngine restricted to only supporting custom template tags one level deep?

Thanks Barney

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

If the nested tag contains a similar or identical set of variables then you will have issues with conflicts. You can get around this with embeds, but using embeds in a scenario like this can be a performance killer.

       
bmds's avatar
bmds
8 posts
14 years ago
bmds's avatar bmds

I can alter the names of the tags easily enough, although the ExpressionEngine native ones don’t seem to have this problem. The main problem i have so far is that the second method isn’t being passed any tags at all. When it runs it receives HTML with no tags in it. E.g:

<li>
        <h2></h2>
        
      </li>

So there is nothing for it to parse and insert tags in.

       
bmds's avatar
bmds
8 posts
14 years ago
bmds's avatar bmds

I have ended up merging the tags into one and using a view to achieve the result that i need. This means that i use just the one query as well which sould lighten the load of the page a bit.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.