I’ve got a template that is behaving really weirdly, different things that happen are listed below. I’m on EE 2.1.3.
Template code is as follows:
{exp:channel:entries channel="study|funding|advice" limit="10" paginate = "top"}
{paginate}
Page {current_page} of {total_pages} pages {pagination_links}
{/paginate}
<div class="post">
{embed="pages/entry_header" title="{title}" entry_date="{entry_date format="%F %d %Y"}"
author="{author}" channel="{channel_short_name}" entry="{entry_id}"}
<div class="entry">
{exp:char_limit total="150"}
{if "{channel_short_name}" == "study"}
{description}
{if:elseif "{channel_short_name}" == "advice"}
{exp:textile}
{advice_article_body}
{/exp:textile}
{if:else}
{expenses_covered} - {amount} - {requirements}
{/if}
{/exp:char_limit}
{embed="pages/entry_footer" channel="{channel_short_name}" entry="{entry_id}"}
</div>
</div>
{/exp:channel:entries}At the moment the only entries in the database are in the study channel, so that’s the only conditional that should be activating, although from the template debugging output I can see that the others are being evaluated on empty content. The description field of the study channel is a textarea, with formatting set to auto br.
If I comment out the char_limit tag everything is happy. Weird stuff occurs when I uncomment (I guess there could be others, this is just what I’ve identified so far) -
If the text of the field is 105 characters or more (I counted) but less than 150 I get an error when I view the page:
Parse error: syntax error, unexpected '&' in /var/www/system/expressionengine/libraries/Functions.php(650) : eval()'d code on line 59 Call Stack: 0.0004 670968 1. {main}() /var/www/ictd2/index.php:0 0.0013 750856 2. require_once('/var/www/system/codeigniter/system/core/CodeIgniter.php') /var/www/system/index.php:198 0.1223 7996288 3. call_user_func_array() /var/www/system/codeigniter/system/core/CodeIgniter.php:297 0.1223 7996424 4. EE->index() /var/www/system/codeigniter/system/core/CodeIgniter.php:297 0.1224 7996504 5. EE_Core->_generate_page() /var/www/system/expressionengine/controllers/ee.php:67 0.1286 9786320 6. EE_Template->run_template_engine() /var/www/system/expressionengine/libraries/Core.php:634 0.1295 9789840 7. EE_Template->fetch_and_parse() /var/www/system/expressionengine/libraries/Template.php:192 0.1456 10230056 8. EE_Template->parse() /var/www/system/expressionengine/libraries/Template.php:248 0.5059 18387144 9. EE_Template->advanced_conditionals() /var/www/system/expressionengine/libraries/Template.php:541 0.5089 18415104 10. EE_Template->parse_template_php() /var/www/system/expressionengine/libraries/Template.php:3312 0.5089 18456880 11. EE_Functions->evaluate() /var/www/system/expressionengine/libraries/Template.php:1678If the field content is less than 105 characters but greater than 80 it prints no errors but ends the page immediately, printing none of the entries that would appear below, and beginning the template debugging output.
If the description is a single word (aaaaaaaaaaaaa etc) with no spaces but greater than 150 characters, the char limit does nothing, but other entries are displayed properly.
The entry displays properly if the field content is less than 80 characters or the field triggers the char limiter plugin by going over 150 characters. The next entry that “breaks the rules” causes the same errors.
This is not a case of weird characters in the field - at first I thought someone had copied from Word - I’m typing the field contents myself and just using strings that look like ‘aaaa aa a aaa’.