Use word_limit within preparse variable?
I am converting a site from using embeds to low variables and have hit a bit of a bump with preparse variables.
I'm using the EllisLab word limit plugin/
This is the previous embed code for a html head block:-
{embed="embeds/_head"
{exp:channel:category_heading channel="products"}
{if category_description} meta_description="{exp:word_limit total="35"}{category_description}{/exp:word_limit}"{/if}
{/exp:channel:category_heading}
}
This works without the limit tags but a lot of the category descriptions are way too long:-
{exp:channel:category_heading channel="products"}
{exp:low_variables:parse
var='lv_snp_html_head'
preparse:meta_description="{category_description}"
}
{/exp:channel:category_heading}
Cant seem to get the following working at all - no doubt due to the parse order involved with word limit?
{exp:channel:category_heading channel="products"}
{exp:low_variables:parse
var='lv_snp_html_head'
preparse:meta_description="{exp:word_limit total="35"}{category_description}{/exp:word_limit}"
}
{/exp:channel:category_heading}
Any ideas if this is possible or not?
If not I can always create an alternate html_head for this template.
Replies
Low 14 Jun 2016 07:03
As you suspected: parse order.
Using preparse:meta_description="{category_description}" can fail when there are quotes inside the category description.
When using a tag inside another tag's parameter value, you will need to add parse="inward" to the outer tag. Also, use single quotes inside the param value instead of double ones, to avoid conflict. Finally, I'm not sure tag pairs will even work inside a parameter value, so you'll have to try that out.
Damien 14 Jun 2016 07:21
Yep, this totally works hah!
preparse:meta_description="{exp:word_limit total='35' parse='inward'}{category_description}{/exp:word_limit}"
Thanks mate