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.

char_limit not evaluating within checkbox field

February 09, 2011 1:13am

Subscribe [2]
  • #1 / Feb 09, 2011 1:13am

    Mitch Cohen

    12 posts

    I’m finding that exp:char_limit isn’t evaluating when within a checkbox field loop.

    In the following code, h_displayoptions is the name of a checkbox field, where “Top Headline” is one of the options:

    {exp:channel:entries channel="News" orderby="date" show_future_entries="no" limit="10" dynamic="no" show="1|13|12|9|4|24" }
    {h_displayoptions}
        {if item=="Top Headline"}
            
            <a href="http://{title_permalink=/newsevents/news_detail}">{title}</a>
            {entry_date format="%l, %F %d, %Y, %g:%i %A"}
            {exp:char_limit total="100"}
                {h_details}
            {/exp:char_limit}
            
    <a href="http://{title_permalink=/newsevents/news_detail}">full story</a>
            
        {/if}
    {/h_displayoptions}
    {/exp:channel:entries}

    The above works fine, except that the output contains the {exp:char_limit total="100"} code, followed by the full (multi-paragraph) h_details, followed by {/exp:char_limit}.

    If I remove the checkbox field loop (and fake the if/then to function):

    {exp:channel:entries channel="News" orderby="date" show_future_entries="no" limit="10" dynamic="no" show="1|13|12|9|4|24" }
        {if item!="Top Headline"}
            
            <a href="http://{title_permalink=/newsevents/news_detail}">{title}</a>
            {entry_date format="%l, %F %d, %Y, %g:%i %A"}
            {exp:char_limit total="100"}
                {h_details}
            {/exp:char_limit}
            
    <a href="http://{title_permalink=/newsevents/news_detail}">full story</a>
            
        {/if}
    {/exp:channel:entries}

    The char_limit works as expected, trimming h_details to 100 characters.  Of course I’m then ignoring the checkbox, which I don’t want to do.

    Any suggestions?  Thanks!

  • #2 / Feb 09, 2011 3:26pm

    Ingmar

    29245 posts

    Have you tried specifying a parse order explicitly?

  • #3 / Feb 09, 2011 9:32pm

    Mitch Cohen

    12 posts

    I have, with no change.

    There’s definitely something odd happening within checkbox loops.  Key to the above is that the {exp:char_limit total=“100”} code appears in the generated HTML.  It’s not a problem with char_limit; same happens with third-party truncating plugins I’ve found.  Just spits the EE code back out again.  Tried in a standalone template, fails there too.

    I’m really wracking my brain on this one. Seems very straight-forward, and I really need this to work.  I’d be fine using PHP but I can’t get that sorted out here either.  Any suggestions appreciated.

  • #4 / Feb 09, 2011 9:48pm

    Mitch Cohen

    12 posts

    As additional followup…  I created a template with nothing but this code:

    {exp:channel:entries channel="News" orderby="date" show_future_entries="no" limit="10" dynamic="no" show="1|13|12|9|4|24"}            
        {h_displayoptions}
            {exp:char_limit total="10"}
                Now is the time for something whatever hip hip hooray.
            {/exp:char_limit}
        {/h_displayoptions}
    {/exp:channel:entries}

    There are two entries in the News channel with options set for the h_displayoptions entry checkbox.

    You’d think the browser would display something like:

    Now is the time for 
    Now is the time for

    But the results are (from a browser’s View Source):

    
            {exp:char_limit total=“10”}
    
                Now is the time for something whatever hip hip hooray.
    
            {/exp:char_limit}
    
                
        
            {exp:char_limit total=“10”}
    
    
                Now is the time for something whatever hip hip hooray.
    
            {/exp:char_limit}
    

    It’s looking like the checkbox parsing is converting everything to entities, preventing char_limit from reading its “limit” parameter.

  • #5 / Feb 10, 2011 10:24am

    Sue Crocker

    26054 posts

    Sounds buggy to me too.. Can you tell us which version/build of EE2.x you’re using? See EEWiki:// HowTo Determine My EE Version

  • #6 / Feb 10, 2011 10:27am

    Mitch Cohen

    12 posts

    v2.1.3, Build:  20101220

    Thanks.

  • #7 / Feb 10, 2011 3:46pm

    Ingmar

    29245 posts

    Could you try upgrading to 2.1.4? Or, perhaps, in the meantime try one of the other available limiter plugins, like TruncHTML?

  • #8 / Feb 11, 2011 3:15am

    Mitch Cohen

    12 posts

    I tried TruncHTML and Power Truncate.  Same results as shown above.  The issue appears to be the conversion of contents of the checkbox loop to HTML entities and lack of EE processing.  Note the markers in the source; that’s not from the EE code or my HTML.

    I’m near deadline so can’t try the beta.  I’ll try it on a test server when I have a few minutes.

  • #9 / Feb 11, 2011 12:18pm

    Ingmar

    29245 posts

    Thanks Mitch, please let us know how it goes. I’m trying to reproduce as well.

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

ExpressionEngine News!

#eecms, #events, #releases