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.

Setting Variable for use in exp:channel:entries tags

December 13, 2011 4:44pm

Subscribe [2]
  • #1 / Dec 13, 2011 4:44pm

    BPeddle

    31 posts

    I am trying to set a variable for the entry id for use in:

    {exp:channel:entries channel="channelname" entry_id="{embed:foo}” dynamic=“no” require_entry=“yes” limit=“1” disable=“pagination|member_data|categories|category_fields”}<title>{title}</title>{/exp:channel:entries}

    I can use {segment_3} for example without issue.

    I try to set

    {preload_replace:foo="12345"} and it doesnt worked with {embed:foo} or just {foo}

    I wrote a plugin that returns the value—{exp:entryid}

    That will output the number but it doesn’t seem to stick on the entry_id variable.

    I suspect its something simple I am doing wrong but at this point I am just going in circles.

    In the plugin I return the value—$this->return_data = “12345”;

    Any tips or insight is much appreciated.

    Thanks!

  • #2 / Dec 14, 2011 11:48am

    tidy

    196 posts

    {preload_replace:foo="12345"} should work once this is just text (not plugin output etc) and above your channel entries tag and in the same template:

    {preload_replace:foo="12345"}
    ...
    {exp:channel:entries channel="channelname" entry_id="{foo}"...}

    If you put your channel entries tag in an embed, then you can pass a variable to it in the embed call and reference this within the embed:

    {!--main template calls embed--}
    {embed src="myembed" foo="12345}
    
    {!--myembed embedded template code--}
    {exp:channel:entries channel="channelname" entry_id="{embed:foo}"...}

    If you want to use the output of a plugin as a parameter in a channel tag, I think this should work. The parse inward bit is needed to have things parsed in the right order:

    {exp:channel:entries channel="channelname" entry_id="{exp:entryid}" parse="inward" ...}

    If this general info does not help, if you can outline exactly what you are trying to do, someone should be able to help.

     

  • #3 / Dec 14, 2011 12:15pm

    BPeddle

    31 posts

    Tried a few ways you recommend


    {exp:channel:entries channel="channelname" entry_id="{exp:entryid}” parse=“inward” dynamic=“no” require_entry=“yes” limit=“1” disable=“pagination|member_data|categories|category_fields”}<title>{title}</title>{/exp:channel:entries}

    When I view debug code it becomes

    {exp:channel:entries channel="channelname" entry_id="M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr" parse="inward" dynamic="no" require_entry="yes" limit="1" disable="pagination|member_data|categories|category_fields"}

  • #4 / Dec 14, 2011 12:31pm

    tidy

    196 posts

    I think you might be coming up against this weirdness:
    http://blog.ericlamb.net/2011/05/expressionengine-and-the-mystery-of-m00o93h7pq09l8x1t49chy01z5j4tt91fgfr/

    Do you also output {exp:entryid} elsewhere in the same template?
    It could be using it multiple times at different levels that is causing this - not sure, have not come up against this before myself.

    If that;s the case, to debug, could you try removing all other references to {exp:entryid} apart from the one in the channel entries tag parameters and see if that works?

  • #5 / Dec 14, 2011 12:36pm

    BPeddle

    31 posts

    I removed the {exp:entryid} as output as I was debugging and it worked.  I actually use it twice in the exp:channel tag without issue now.  It just didn’t like the output.

    Thanks!

  • #6 / Dec 14, 2011 12:38pm

    tidy

    196 posts

    great glad you got sorted 😊

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

ExpressionEngine News!

#eecms, #events, #releases