croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Stash not parsing all tags? #43

Closed chadcrowell closed 11 years ago

chadcrowell commented 11 years ago

I have this code: http://pastie.org/private/6undc80rwmfwkmd1ynl1g (note I've tried all kinds of parse_depth's, this one is extreme, obviously)

Which is resulting in this in the db: http://pastie.org/private/g3u6d6ri6sdn5on2bw8lda (note some parsed tags, many not parsed)

I am grabbing the above stored stash out of the db via an extension and inserting it into the body of a freeform email. I need all tags to be parsed (meaning I need stash to parse everything and store just the resulting HTML in the db). Here is what I see when I test output what should be going into the email body: http://cl.ly/image/1c1z0h2m0Z0j

I can't figre out why all the tags won't parse before the stash is stored. Can you tell me where I am doing it wrong?

croxton commented 11 years ago

Stash won't parse EE embeds, this is by design. You can use Stash embeds, or snippets or low variables instead.

I'd guess your lv_ prefixed vars are low variables, if you use them like that make sure you have ticked the 'early parsed' checkbox.

chadcrowell commented 11 years ago

Thanks Mark. I got the lv_ variables taken care of, but the embeds have been giving be nothing but trouble. It seems to be coming down to one thing: one of the variables I am passing to stash:embed is from a playa within a matrix cell. That var ia retrieved using {mx_product_options_component:entry_ids}, which playa auto turns into

{exp:playa:child_ids entry_id="376" field_id="35" col_id="24" row_id="1060" var_prefix="playaQ8i4IB7I"}{/exp:playa:child_ids}

during parsing. So what I am seeing when I use this test code: http://pastie.org/private/nclcipeorpwli1rfjprwq

is this in the rendered template: http://pastie.org/private/ynzeswdkaafff31blupsmw (you can see here that the set_list option_id does contain the correct playa child_id but for some reason when I try to use {option_id} within the same get_list loop to pass option_id to the embed vars it doesn't work. This is where the problem is.

and this in the template debugging: http://pastie.org/private/id3vy1vlvlcgcjdwv3zaq

even when the embed template just contains {stash:option_id}

I've tried parse_tags yes and no in the set_list.

chadcrowell commented 11 years ago

bump

croxton commented 11 years ago

You have a typo with parse _tags="yes". You need to parse a bit deeper to parse the nested playa tag so add parse_depth="2" to the set.

chadcrowell commented 11 years ago

Thanks Mark. I fixed the typo and added various parse_depth from 2 to 20 to 200 with no change in the result.


Chad

On Saturday, March 30, 2013 at 12:05 AM, Mark Croxton wrote:

You have a typo with parse _tags="yes". You need to parse a bit deeper to parse the nested playa tag so add parse_depth="2" to the set.

— Reply to this email directly or view it on GitHub (https://github.com/croxton/Stash/issues/43#issuecomment-15670732).

croxton commented 11 years ago

Ah yes, looking at your debug output it looks like EE is caching the value. This happens when an identical tag is used multiple times. Either add process="inline" to the stash embed or construct the playa tag pair yourself and append the word 'random' to the parameters of the tag pair.

chadcrowell commented 11 years ago

Thank you Mark. None of this seems to be changing anything. I also searched for "random" in the playa files and the web and don't see anything about it so I don't have any other info about it other than what you noted.

Here is my current template: http://pastie.org/private/cqzmy21nzwkjhxfz82pn8a Here is the page output: http://pastie.org/private/9psokxgf1uc1aoec1ccedw Here is the debug: http://pastie.org/private/k4jqref4jhgwhl2aaewgg

I guess I don't understand why the string option_description|=||&|option_id|=|98|&|option_required|=||&|option_default|=|2|&|option_hidden|=||&|option_e_id|=|376|&|option_type|=|group is even showing up in this output. If I remove the embed call, it disappears. If I leave the embed call in place, but put anything or nothing in the embed, the string still appears. Why does calling the embed make that string show in the output?


Chad

On Saturday, March 30, 2013 at 1:44 AM, Mark Croxton wrote:

Ah yes, looking at your debug output it looks like EE is caching the value. This happens when an identical tag is used multiple times. Either add process="inline" to the stash embed or construct the playa tag pair yourself and append the word 'random' to the parameters of the tag pair.

— Reply to this email directly or view it on GitHub (https://github.com/croxton/Stash/issues/43#issuecomment-15671446).

croxton commented 11 years ago

In the debug output you can see that Stash is capturing a placeholder string M0.... instead of a value. This is why: http://blog.ericlamb.net/2011/05/expressionengine-and-the-mystery-of-m00o93h7pq09l8x1t49chy01z5j4tt91fgfr/

And this is how 'random' can help: http://www.emarketsouth.com/add-ons/string-plugin/template-tags/#random-parameter

croxton commented 11 years ago

You need this to be fully parsed:
{mx_product_options_component:entry_ids}

You could try to replace it with the tag pair:

{exp:playa:children entry_id="{entry_id}" field_id="35" col_id="24" var_prefix="nested" limit="1" random}{nested:entry_id}{/exp:playa:children}

Make sure to use parse_depth="2" when you set the list so this tag is parsed before being captured, and verify that it is indeed parsed by checking the debug output.

chadcrowell commented 11 years ago

I don't know how I am missing it but I am not seeing M0 anywhere in the output. Can you direct me to it? I understand why its happening but am not seeing it.


Chad

On Saturday, March 30, 2013 at 1:49 PM, Mark Croxton wrote:

In the debug output you can see that Stash is capturing a placeholder string M0.... instead of a value. This is why: http://blog.ericlamb.net/2011/05/expressionengine-and-the-mystery-of-m00o93h7pq09l8x1t49chy01z5j4tt91fgfr/
And this is how 'random' can help: http://www.emarketsouth.com/add-ons/string-plugin/template-tags/#random-parameter

— Reply to this email directly or view it on GitHub (https://github.com/croxton/Stash/issues/43#issuecomment-15681618).

croxton commented 11 years ago

Ah, I'm sorry I was getting your first debug output mixed up with your second. The problem is obvious to me now, you are simply using the same name for your list as for your embed: 'product_options'. Embeds, lists, variables - these are all the same thing as far as Stash is concerned - a variable with a given name. When you try to embed 'product_options' Stash gets the existing variable called 'product_options', which happens to be a list! Simply use a different name for your embed or list, or use a context for either to namespace them.

chadcrowell commented 11 years ago

Oh Mark thank you so much. I was about to go jump off a bridge! Its all falling into place now.


Chad

On Tuesday, April 2, 2013 at 1:13 PM, Mark Croxton wrote:

Ah, I'm sorry I was getting your first debug output mixed up with your second. The problem is obvious to me now, you are simply using the same name for your list as for your embed: 'product_options'. Embeds, lists, variables - these are all the same thing as far as Stash is concerned - a variable with a given name. When you try to embed 'product_options' Stash gets the existing variable called 'product_options', which happens to be a list! Simply use a different name for your embed or list, or use a context for either to namespace them.

— Reply to this email directly or view it on GitHub (https://github.com/croxton/Stash/issues/43#issuecomment-15799494).