Hi, I need to set the limit in a channel entries tag with the value of a select – show 6|9|12 entries – field.
{exp:channel:entries channel="channelname" limit="{newscount}” {newscount} is a template partial with an entries tag and is rendered correctly when used outside the above entries tag. Looks like the channel entries tags are rendered at the same time and the limit variable is alway empty.
Thanks for any suggestion!
You’re correct in what the issue is. What you need to use is an embed vs a partial. A partial’s code is basically copied and pasted in the parent template and then the template is parsed. So you essentially end up with something like this the following, which is invalid.
{exp:channel:entries
channel="channelname"
limit="{exp:channel:entries channel="anotherchannel"}...{/exp:channel:entries}"
}
...
{/exp:channel:entries}
An embed is parsed first, then the output of that will be parsed when the parent template is parsed.
Hi Andy, thank you for your suggestion, unfortunately it does not work for me.
{embed="index/newscount"}
will return 12, but
{exp:channel:entries channel="news | otherchannel" search:show_in_news="not IS_EMPTY" limit='{embed="index/newscount"}' orderby="date" sort="desc" disable="category_fields|member_data|pagination|relationships"}
returns all entries for news | otherchannel.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.