Plugin

Developer
Supported

EE 1
EE 2
Entry linking

Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy

     

You must be logged in to post.

Can’t get conditionals to work

Support Request

Visiluna
Visiluna

I just bought your plugin and I can’t get conditionals to work.

Here is my code (nested inside the {exp:channel:entries} tag for a single entry).

{exp:entry_linking entry_id="{entry_id}" link="prev" channel="my_channel" orderby="entry_order" sort="ASC" status="open" mode="short" no_results="empty"}
{if no_prev_link}
    No Prev
{if
:else}
    
<a href="{path=template_group/template/{link_url_title}}">Prev</a>
{/if}
{
/exp:entry_linking}
{exp
:entry_linking entry_id="{entry_id}" link="next" channel="my_channel" orderby="entry_order" sort="ASC" status="open" mode="short" no_results="empty"}
{if no_next_link}
    No Next
{if
:else}
    
<a href="{path=template_group/template/{link_url_title}}">Next</a>
{/if}
{
/exp:entry_linking} 

Despite the check for “no_next_link” and “no_prev_link”, nothing at all is output when these are empty.

Please advise,
Philip Jones

Yuri Salimovskiy
# 1
Developer
Yuri Salimovskiy

Hello Philip,

did you try setting no_results=“cycle” (or simply removing it)?

Also, plugin will not return any results if you have less that 3 entries.

If you want to change that behaviour, edit line 159,
checnge
if ($result->num_rows()<=2)
to
if ($result->num_rows()==0)

Visiluna
# 2
Visiluna

no_results=“empty” and I have 32 entries. Are you saying that ‘no_results’ has to be set to cycle for the conditionals to work? I’ll give that a try.

Here is the tag I used:

{exp:entry_linking 
   entry_id
="{entry_id}" 
   
link="prev" 
   
channel="my_channel" 
   
orderby="custom_order" 
   
sort="ASC" 
   
status="open" 
   
mode="short" 
   
no_results="empty"
Yuri Salimovskiy
# 3
Developer
Yuri Salimovskiy

Can you tell me what it outputs with and without the conditionals?

Visiluna
# 4
Visiluna

It outputs exactly the same thing either way.

Without conditionals:

If there is a valid “prev” link, it correctly displays the HTML within the tags. If there is no “prev” link, it displays nothing.

With conditionals:

If there is a valid “prev” link, it correctly displays the HTML within the tags. If there is no “prev” link, it ignores the conditionals and displays nothing.

NOTE: Here I reference a ‘prev’ link, but the behavior is the same whether I have requested a ‘prev’ link or a ‘next’ link.

Yuri Salimovskiy
# 5
Developer
Yuri Salimovskiy

This is expected behaviour with no_results=“empty”. Try removing this parameter.

Visiluna
# 6
Visiluna

That fixed it! Thanks for the help.