2

The {count} variable is completely not working in my entries. It is just returning 1.

The last thing we installed for plugins was the structure_url_alias module.

Is this a known ee bug?

Here is the requested code. It was working right before we installed structure_url_alais. We have over 100 aliases now running so we are hesitant to uninstall the module and see if it is the reason {count} stopped working.

{exp:channel:entries channel="news" limit="6" category="not 20"}
{if count < 4}
Count {count}
<div class="content_{count}">
<div class="date date_1">
<h4 align="center" style="margin-top:16px">
<span class="month">{entry_date format="%M"}</span>
<span class="day">{entry_date format="%d"}</span>
</h4>
</div>
<div class="text_1">
<h3 style="margin-left:13px;">
<a href="{page_url}">{title}</a>
</h3>
{exp:char_limit total="160"}
{news_excerpt}
{/exp:char_limit}
</div>
</div>  
<!-- News and Events End -->
{if:else}
{if count==4}
<!-- Older News Articles -->
<h1 style="margin-top:10px; margin-bottom:1px;">OLDER NEWS:</h1>
<div class="news_box" style="padding-top:5px;">{/if}
<div class="news_{count}">
<h6>
<a href="{page_url}">{title}</a>
</h6>
<div class="excerpt">
<span class="date">{entry_date format="%M. %d"} - </span> {exp:char_limit total="200"}{news_excerpt}{/exp:char_limit}
</div>
</div>
<!-- Older News Articles End -->
{if count == total_results}</div>{/if}
{/if}
{/exp:channel:entries}

Edit....

We narrowed the problem down to the structure alais plugin, but we don't want to uninstall it to see for sure because we already have over 100 alaises set up. Any suggestions?

11
  • 1
    If you post some template code it will give you a much better chance of getting a helpful answer.
    – Alex Kendrick
    Mar 14 '13 at 1:37
  • 1
    Just added the code. Mar 14 '13 at 1:56
  • I don't see anything in there that shouldn't work and it works fine in my test. What version of EE are you using? Also, since you suspect this error coincides with the installation of the Structure URL Alias module/extension try disabling extensions to see if that removes the issue or make a backup and uninstall it as a test.
    – Alex Kendrick
    Mar 14 '13 at 2:24
  • This is a core problem. On my server {count} does not increment. It echoes "1" only. Mar 14 '13 at 2:46
  • So if you put in the same entries loop and strip everything else out other than maybe an entry ID and count, what is returned? Mar 14 '13 at 11:40
1

Just confirm that the Structure URL Alias break the native EE Tags. Structure URL Alias v1.3.1 fix this problem.

Can you download the latest version and test it, there are no databases changes, just code changes.

http://devot-ee.com/add-ons/structure-url-alias

Please let me know if there are any troubles.

0

I can't see why {count} isn't working but there is something that's wrong:

{if:else}
{if count==4}
{/if}

This should be:

{if:elseif count == 4}<-- Code Here -->{/if} or {if:else}<-- Code here -->{/if}

2
  • I thought so too at first but if you look closely the conditional actually is properly closed. Look on the line that has div class="news_box" style="padding-top:5px;">
    – Alex Kendrick
    Mar 14 '13 at 14:28
  • Yeah, I probably just copied the code wrong. The page was working perfectly until I installed the structure_url_alias plugin. Mar 14 '13 at 16:43
0

Try writing the conditional like this:

{if "{count}" == "4"}
2
  • I did. Still {count} returns "1" for every iteration of the channel loop. Mar 14 '13 at 16:43
  • Place this in a blank EE template... {exp:channel:entries channel="news" limit="6" category="not 20"}{count}{/exp:channel:entries} Same thing? try removing category paramter... same?
    – Anna_MediaGirl
    Mar 14 '13 at 23:50
0

It sounds like there is an outer module tag being parsed first — with a {count} variable equal to 1. (So, the inner Channel Entries tag doesn't ever have a chance to parse its own {count} variables, because all it sees is "1" in the tagdata.)

It would be easier to help you troubleshoot if you could post enough of your template that we could see the opening and closing of all EE tags...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.