0

I don't think that the parse order would make this code below work

{exp:channel:entries
  entry_id="{embed='common/.get-entry-id-based-on-some-complex-logic'}"
}

Is there a way to make embed tag be parsed first before the {exp:channel:entries} is parsed?

If not, what are alternative ways to this(Snippets can't be used if in this case if I am not mistaken)?

3

Why not do it the other way around, where the template being loaded is what actually contains the complex logic? Then you can embed the rest of the template, passing the entry_id via an embed parameter.

Alternately, write a simple plugin which performs your logic and returns the entry_id, then put your Channel Entries tag inside of that plugin tag pair (related example here).

  • Yeah, after exhausting all options, I simply decided to make it a plugin. – developarvin Nov 28 '13 at 23:54
0

Have you tried adding a parse="inward" to your channel:entries tag?

If that doesn't work, you could possibly use stash to set an entry_id variable as a result of your complex logic, and then use that stash var in your channel:entries tag.

eg (very loosely)

{exp:stash:parse}
    {complex_block}
        {exp:stash:set name="my_entry_id" type="snippet"}{value}{/exp:stash:set}    
    {/complex_block}
{/exp:stash:parse}
...
{exp:channel:entries entry_id="{my_entry_id}"}
  • 1
    I tried using a simple stash set and it didn't work. – developarvin Nov 28 '13 at 23:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.