All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

How to preparse with a character limit

Damien 31 Jul 2014 02:14 question, complete

I have a variables pair setup to embed the document head in a program listing as follows:

{exp:channel:entries channel="program" disable="{lv_disable_default}" require_entry="yes" limit="1"}

{if no_results}{redirect="404"}{/if}

{exp:low_variables:parse
var='lv_snp_html_head'
preparse:page_title="{title}"
preparse:meta_description="{cf_program_description}"
preparse:copyright_date="{current_time format="%Y"}"
}

This works fine however if I try to use the EllisLab Character Limit plugin as follows I get white-screened:

{exp:channel:entries channel="program" disable="{lv_disable_default}" require_entry="yes" limit="1"}
{if no_results}{redirect="404"}{/if}
{exp:low_variables:parse
var='lv_snp_html_head'
preparse:page_title="{title}"

preparse:meta_description="
{exp:char_limit total="160" exact="no"}
{cf_program_description}
{/exp:char_limit}"

preparse:copyright_date="{current_time format="%Y"}"
}

Any ideas how I can get around this. Also double-points if theres a simple way to strip the HTML from cf_program_description - its an Expresso field ; )

Replies

  1. Low 31 Jul 2014 06:44

    It's generally not a good idea to use tags inside another tag's parameters like that. If you're doing that, you're going to run into parse order problems, like here.

    You have to make sure all the tags are in 1 line, no double quotes exist in the {cf_program_description} field, and add parse="inward" to the LV tag. And even then, I cannot guarantee it will work. You might have to look at a Stash-based solution for that.

  2. Damien 31 Jul 2014 06:50

    Thanks Low. If its likely to cause issues its not that critical - easier to just add another custom field for the meta-description. I've used LV's for the meta-title & meta-desc on landing pages. This is for the actual entry pages. Just wanted to check incase I was missing something.

    LV has worked out beautifully on this site build btw - nice work. Got a lovely combo of Low Events & Joel's Shortlist working for the program too. Will put it on Twitter when I get it sorted.

    Cheers

  3. Low 31 Jul 2014 06:52

    Yeah, a dedicated field would be much better. Site sounds great!

  4. Damien 2 Aug 2014 02:24

    Just an update for anyone following this - I feel like a right muppet having just realised that the cf_program_description I'm trying to character limit is an Expresso field and has parameters to limit characters and strip html... Duh

    This is the (working) block now

    {exp:low_variables:parse
    var='lv_snp_html_head'
    preparse:page_title="{title}"
    preparse:meta_description="{cf_program_description strip_tags="true" character_limit="160" strip_line_breaks="true"}"
    preparse:copyright_date="{current_time format="%Y"}"
    }