On an article page, I'm trying to output "more from this author" using the User add-on from Solspace.
Unfortunately, there's a bug in the current version that prevents this from working:
{exp:user:entries channel="articles" status="open" user_author_id="1" entry_id="not 344"}
{if count == "1"}
// header and opening ul
{/if}
// list items with links to articles
{if count == total_results}
// closing ul
{/if}
{/exp:user:entries}
The bug means that entry_id
doesn't work with the "not" in there, so I can't exclude the current entry.
The workaround is to use PHP, and so I have something like this:
<?php $c = 0; ?>
{exp:user:entries channel="articles" status="open" user_author_id="1" limit="4"}
{if entry_id != "344"}
<?php $c++; ?>
<?php if($c == 1): ?>
<h3>More from this Author</h3>
<ul class="author-more">
<?php endif ?>
<li><?php echo $c ?> <a href="/article/{url_title}">{title}</a></li>
{/if}
{/exp:user:entries}
<?php if($c != 0) :?>
</ul>
<?php endif ?>
Unfortunately, the results I'm getting are odd. I'm getting a list of three articles — the article with the id of 344 is being correctly omitted — but I'm not getting the header and open ul
tag.
I'm echoing $c
in there, and what results is a list of three articles numbered 2, 3, 4. It seems like $c
is skipping straight from 0 to 2.
Hopefully I'm just doing something dumb...
{if entry_id != "344"}
required you to switch to PHP inside the loop? The workaround for being unable to usenot
in theentry_id
param is theif
statement, yes?{if entry_id != "344"}
will eliminate the entry I don't want to include, it won't affect the main loop, and EE's count will still iterate as normal. One result being if the article I want to eliminate is the only article by this author, even though theif
statement will prevent it from being displayed, the EE count is still "1", and I get a header and emptyul
.