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.

Issues with module in weblog entries loop

November 24, 2010 12:45pm

Subscribe [7]
  • #1 / Nov 24, 2010 12:45pm

    Tom Jaeger

    497 posts

    I have recently finished developing a new module.  However I’m hitting a weird issue.

    If I place a call to the module with in a template (not inside of a weblog entries loop) it works fine

    {exp:modname:function id="8"}

    If I call the module within a weblog entries loop and pass it a new id it also works fine

    {exp:weblog:entries weblog="test" dynamic="off" show_expired_entries="yes" show_future_entries="yes" cache="no"}
    <entry_id>{entry_id}</entry_id>
    <content>{exp:modname:function id="7"}</content>
    {/exp:weblog:entries}

    However if I call the module within a weblog entries loop and pass it an ID from a tag thats already been called in the template I get a random string as output.

    {exp:modname:function id="8"}
    {exp:weblog:entries weblog="test" dynamic="off" show_expired_entries="yes" show_future_entries="yes" cache="no"}
        <entry_id>{entry_id}</entry_id>
        <content>{exp:modname:function id="8"}</content>
    {/exp:weblog:entries}

    This results in

    <entry_id>35</entry_id>
    <content>M10o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr</content>


    After digging a little deeper I think this might be a DB cache reference. 

    I hope I’m missing something simple, any help or ideas would be greatly appreciated.

  • #2 / Nov 24, 2010 3:32pm

    Rob Sanchez

    335 posts

    I’ve seen this one, it’s a template parser issue. I’ve seen it happen when you use the exact same instance of a plugin/module tag. If you added random, unique parameter to the 2nd instance, I bet it would work.

    {exp:modname:function id="8"}
    {exp:weblog:entries weblog="test" dynamic="off" show_expired_entries="yes" show_future_entries="yes" cache="no"}
        <entry_id>{entry_id}</entry_id>
        <content>{exp:modname:function id="8" whatever="blah"}</content>
    {/exp:weblog:entries}
  • #3 / Nov 24, 2010 3:38pm

    Tom Jaeger

    497 posts

    If you added random, unique parameter to the 2nd instance, I bet it would work.

    It sure does.  While tracing things through the template parser I did notice that it uses a different DB cache reference if I do that.

    The weird thing is that I have turned off all the DB caching that I can think of and it still seems to be caching it in some fashion or another.

    Is that the route you ended up taking in the end?

  • #4 / Nov 24, 2010 3:41pm

    Rob Sanchez

    335 posts

    I don’t think it’s technically caching, it’s that the templater parse temporarily encodes these nested tags and decodes them later. I never did get to the bottom of why subsequent instance don’t get decoded. This is the best solution I’ve found, mostly because digging around the template class makes my head spin.

  • #5 / Nov 24, 2010 3:51pm

    Tom Jaeger

    497 posts

    Good deal.

    I don’t think it’s technically caching, it’s that the templater parse temporarily encodes these nested tags and decodes them later

    Yeah, your correct for sure. I noticed it seems to do it memory. Guess I didn’t really know how to refer to it otherwise.

    This is the best solution I’ve found, mostly because digging around the template class makes my head spin.

    Totally hear you there. That’s what caused me to post here 😊


    I’d really like to get to the bottom of this, but might end up just going this route as well.

    Thanks!

  • #6 / Nov 24, 2010 3:52pm

    Rob Sanchez

    335 posts

    If you ever do figure it out, let me know in this thread 😊 That being said, if you google “M10o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr” you’ll see that this has gone unanswered for many years.

  • #7 / Nov 25, 2010 1:52am

    John Henry Donovan

    12339 posts

    Tom,

    I glad Rob was able to give some insight. Another thread here with a solution like Robs.

    This thread is more appropriate for the COdeShare Corner so moving it there.

  • #8 / Dec 01, 2010 5:05pm

    Jack McDade

    425 posts

    John, i think this thread is grossly inappropriate to move into the “codeshare corner”. This is a serious flaw in ExpressionEngine, not a “how to do something non-standard”. I also am having this issue with an add-on.

  • #9 / Dec 02, 2010 11:34am

    Brandon Jones

    5500 posts

    Hi Jack,

    Ultimately this thread is about approaches for working around a limitation of the template parser. Keep in mind EE tags are not a scripting language and this behavior is a reflection of that. While it’s not a bug, we do want to let you continue the conversation and CodeShare Corner is the best place for that.

  • #10 / Dec 02, 2010 12:09pm

    Jack McDade

    425 posts

    Well, EE tags aren’t a scripting language, but the PHP we use to write them is. We’re (add-on devs) looking for a solution that would allow us, using said scripting language, to account for the caching behavior (or whatever specifically is the issue) of the parser. Would a bug post be the most appropriate next step?

    The parser replaces the tag with the memory “caching” type reference but never swaps it back to the outputted content.

  • #11 / Dec 02, 2010 1:06pm

    Brandon Jones

    5500 posts

    Just to clarify, Rob is correct in that this is not a caching issue, it’s just a side-effect of the way template parsing works.

    Can you point me to a sample template and add-on that reproduces the issue? That will help me ping the developers to make sure. Thanks.

  • #12 / Dec 02, 2010 1:11pm

    Rob Sanchez

    335 posts

    Here’s a really simple example using only native EE tags:

    {exp:xml_encode}TEST{/exp:xml_encode}
    {exp:query sql="SELECT member_id FROM exp_members LIMIT 1"}
    {exp:xml_encode}TEST{/exp:xml_encode}
    {/exp:query}

    Output:

    TEST
    
    M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
  • #13 / Dec 02, 2010 1:24pm

    Brandon Jones

    5500 posts

    Thanks Rob and Jack, I’ll double-check with the devs on this one. Thanks for your patience as well!

  • #14 / Dec 03, 2010 12:36pm

    Robin Sowell

    13255 posts

    Agreed it’s an odd one to run into, but the behavior is intentional (see here for an excellent overview and links).  The core behavior we don’t want to change, but the issue is on our radar for either a new param or simply documenting the random behavior.  (I lean toward a param myself).

    So while it isn’t considered a bug, and using ‘random’ as a param is a solid workaround, it’s a known source of some confusion and on our mental list as such.

  • #15 / Jun 15, 2011 9:59am

    Arazmus

    4 posts

    Hi

    Is it possible that someone can help me with a similar issue to this…

    I have a template and all it does is this:

    {exp:payment:GetPay}
    {pay}
    {/exp:payment:GetPay}

    this pings a custom module that i wrote and the module returns the following:

    $tag_data = $TMPL->tagdata;
    $tag_data = str_replace(LD."pay".RD,"some data",$tag_data);
    $this->return_data .= $tag_data;
    return $this->return_data;

    however when i go to the url of this file with some parameters in the Query string (the module uses them to send and recieve and XML request/response), for example:

    <a href="https://www.example.com/index.php/_ajax_files/getPay?bid=447100&surname=123">https://www.example.com/index.php/_ajax_files/getPay?bid=447100&surname=123</a>

    i get the following output:

    M00o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr

    there are no other tags on that template so i cant see hows its a template parser issue, i have also tried renaming the tags, module function and the template name to no avail..

    any help is really appreciated.

    EDIT

    I have managed to get this to work.. somehow, and am no loger getting the encoded tag returned..

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

ExpressionEngine News!

#eecms, #events, #releases