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 parser problem

November 08, 2012 1:53am

Subscribe [2]
  • #1 / Nov 08, 2012 1:53am

    FiSt

    40 posts

    Hello again.

    Again and again I’ve a problems with a EE template parser. Now I can’t use custom field as a parameter on pair tag of another custom field.

    I use Grid Lite fieldtype and try to pass another custom field to specify row_id of grid.
    It looks like:

    {grid_field row_id='{row_id_field}'}
    <!--content-->
    {/grid_field}

    As a result I’ve got incorrect parsing of this tag. There is some prioritization of template tags parsing?
    How can I use one custom field as a parameter of pair tag of another custom field? Why it’s so hard to drive?

  • #2 / Nov 08, 2012 3:34pm

    Dan Decker

    7338 posts

    Hi FiSt,

    I’m sorry you’re frustrated with the order the Template Parsing Engine executes.

    This is an odd expectation, give that each channel field would be replaced at the same time in the parsing order.

    One way to work around the limitation is to pass one field’s value to another template with an embed variable:

    {embed='templates/grid-field' my_row="{row_id_field}"}
    
    then the child template
    {grid_field row_id='{embed:my_row}'}
    <!--content-->
    {/grid_field}

    Cheers,

  • #3 / Nov 08, 2012 10:55pm

    FiSt

    40 posts

    Hi Dan. Thank you for reply.

    Your solution is really expensive work around, because both fields belong to one channel entry. In your case, I expect that wide code will be something like this:

    {!-- Main Template --}
    {exp:channel:entries channel='my_channel'}
        {embed='templates/grid-field' entry_id='{entry_id}' row_id='{row_id_field}'}
    {/exp:channel:entries}
    
    {!-- Embed Template --}
    {exp:channel:entries channel='my_channel' entry_id='{embed:entry_id}'}
        {grid_field row_id='{embed:row_id}'}
        <!--content-->
        {/grid_field} 
    {/exp:channel:entries}

    So, I’ll need to fetch each entry twice and it’s very expensive to me. I’ll try to find another solution.

    Anyway, do you know that EE template parser is cause of most complications in all EE? Many many problems I’ve got just with it. Maybe your developers need take more care about this area? Or your guys should use some specialized open-source solution like Smarty, Twig etc. ?

  • #4 / Nov 12, 2012 4:58pm

    Dan Decker

    7338 posts

    Anyway, do you know that EE template parser is cause of most complications in all EE? Many many problems I’ve got just with it.

    I’m sorry you feel that way and I can understand your frustrations. Have you ever read Low’s ExpressionEngine’s Parse Order?

    It gives a great rundown on how EE handle tags and when they are processed.

    But I’m not really sure of any other way to get the value on one channel field to work as a parameter on another field in the same channel.

    This might a situation where the Query Module is a better fit for what you need, or perhaps a custom plug-in?

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases