Plugin

Archived
Forum
(read-only)

Entries List

ExpressionEngine 1.x, ExpressionEngine 2

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

     

No output from plugin when trying to use for next / previous links with structure & freebie

Support Request

Laisvunas
# 16
Laisvunas

Hi,

It seems that variable {freebie_3} and {segment_3} should output the same, i.e. “74”, isn’t it? If this is correct, then use variable {segment_3}:

<div id="postNav">
  <
class="next">  
  
{exp:entries_list entry_id="{segment_3}" channel="news" category="9|14"}  
   {if next_entry_id 
!= ""}
    
<a href="{path='weddings/article'}/{next_entry_id}">
     
{next_entry_title}
    
</a>
   
{/if}
  {
/exp:entries_list}
  
</p>
  <
class="prev">
  
{exp:entries_list entry_id="{segment_3}" channel="news" category="9|14"}  
   {if previous_entry_id 
!= ""}
    
<a href="{path='weddings/article'}/{previous_entry_id}">
     
{previous_entry_title}
    
</a>
   
{/if}
  {
/exp:entries_list}
  
</p>
 </
div
Neil D
# 17
Neil D

Hi,

Freebie stops EE seeing the segment after “article” so it only sees two segments. Only freebie can see the third segment, ie:

EE sees

{segment_1} = “sub_section”
{segment_2} = “article”
NB: there simply is no {segment_3} as far as EE is concerned when freebie has finished it’s work on the URL

Freebie sees:

{freebie_1} = “sub_section”
{freebie_2} = “article”
{freebie_3) = “74”

But, I’ve solved this problem and run into a new one.

I’m using MSM and I had not set the ‘site’ parameter to the correct site ID.

I now get output which is great, the code is:

<div id=“postNav”>
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” category=“9|14” site=“3” limit=“1” status=“open”}
  {if next_entry_id != “”}
  [url=”https://devot-ee.com/sub_section/article/{next_entry_id}”]
    {next_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” category=“9|14” site=“3” limit=“1” status=“open”}
  {if previous_entry_id != “”}
  [url=”https://devot-ee.com/sub_section/article/{previous_entry_id}”]
    {previous_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 
</div>

...but I get two previous links and two ‘next’ links and one of the next links seems to point to the current post every time. Actually, one of the previous links is also to the current post.

If I replace limit=“1” with per_page=“1” then I get only one link but the ‘next’ link is always the current post, except when I’m on the first post of the blog and then it actually is the next post.

Neil D
# 18
Neil D

Okay, latest version…

<div id=“postNav”>
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” category=“9|14” site=“3” per_page=“1” status=“open” sort=“asc”}
  {if next_entry_id != “”}
  N[url=”https://devot-ee.com/weddings/article/{next_entry_id}”]
    {next_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” category=“9|14” site=“3” per_page=“1” status=“open” sort=“asc”}
  {if previous_entry_id != “”}
  P[url=”https://devot-ee.com/weddings/article/{previous_entry_id}”]
    {previous_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 

...this works better, but I now seem to get some next links being the current post, some not. Previous always seems correct and next only shows if there actually is a next post but the link is not always correct (ie sometimes is the next, sometimes is the current post).

On the small blog I have, oldest to newest (the order I’ve tested)

post 1 - no previous (correct), next shown (correct) but points to post 1 not post 2 (the actual next)
post 2 - previous shown (correct) and correct link, ie post 1, next shown (correct) but post 2 not post 3 (the actual next)
post 3 - previous shown (correct) and correct link, ie post 2, next shown (correct) and this time is correct, ie post 4

post 4 & post 5 are wrong (as per post 2)

post 5 - prevous shown (correct) and correct link, ie post 4, no next show (correct)

It’s all a bit odd and I have no idea what’s going wrong.

Laisvunas
# 19
Laisvunas

Hi,
Check this.

In exp:channel:entries tag there is parameter

status="open|closed" 

but in exp:entries_list tag there is parameter

status="open" 

It seems that the values should be identical.

Neil D
# 20
Neil D

Currently, all posts are open. The example code is for super-admins to show posts which are not yet made open.

As all posts have a status of “open” so I would expect the same list of entries to be processed but I’ll give it a go…

  { off to edit code & test }

...okay, tried it. Oddly, I do get different results but it’s still wrong on some posts with ‘next’ being the current post. Previous is still correct on all posts.

I’ve also checked the dates of the posts and the sorting would be different if I used entry_id instead of data. With the posts in *date* order the entry_ids are in the following order (most recent to oldest)...

96 = post 6 (by date)
95 = post 5 (by date)
94 = post 4 (by date)
74 = post 3 (by date)
88 = post 2 (by date)
20 = post 1 (by date)

...which might explain why some posts have the correct next and other don’t?

Neil D
# 21
Neil D

FYI, I’ve tried editing the date of post 2 (id=88) so that it’s in date order, that is the date and entry_id orders are the same.

It doesn’t make it work though…

entry_id=20 has wrong next
entry_id=74 has correct next
entry_id=88 has correct next
entry_id=94 has wrong next
entry_id=95 has wrong next
entry_id=96 has no next (correct)

all previous links are still correct.

I need to change the date back, as order is important in the blog.

Incidentally this is with status=“open|closed”

Laisvunas
# 22
Laisvunas

Hi,

Try to add “orderby” and “sort” parameters having the same values to both exp:channel:entries and exp:entries_list tags.

Neil D
# 23
Neil D

Hi,

tried setting both to orderby=“date” and sort=“asc”, no difference.

FYI, two more tests…

a) if I put this code a the top of the blog article page (single post)...


{exp:entries_list channel=“news” category=“9|14” site=“3” status=“open|closed” sort=“asc”}
{title}<br>
{entry_id}<br>
{/exp:entries_list}

with a URL of “weddings/article/95” then I get…

New storybook and digital packages
95
New storybook and digital packages
95

...surely this should appear once?

2) if I put this code on the blog listing page…

{exp:entries_list channel=“news” category=“9|14” site=“3” status=“open|closed” sort=“asc” orderby=“date”}
P= {previous_entry_title}<br>
P= {previous_entry_id}<br>
C= {title}<br>
C= {entry_id}<br>
N= {next_entry_title}<br>
N= {next_entry_id}<br>
<hr>
{/exp:entries_list}

...I get…

P=
P=
C= Welcome to the blog
C= 20
N= Welcome to the blog
N= 20
—————
P= Welcome to the blog
P= 20
C= Welcome to the blog
C= 20
N= Wedding questions answered, plus sharing
N= 88
—————
P= Welcome to the blog
P= 20
C= Wedding questions answered, plus sharing
C= 88
N= Wedding Photography, another point-of-view
N= 74
—————
P= Wedding questions answered, plus sharing
P= 88
C= Wedding Photography, another point-of-view
C= 74
N= Royal Photographic Society Qualification
N= 94
—————
P= Wedding Photography, another point-of-view
P= 74
C= Royal Photographic Society Qualification
C= 94
N= Royal Photographic Society Qualification
N= 94
—————
P= Royal Photographic Society Qualification
P= 94
C= Royal Photographic Society Qualification
C= 94
N= New storybook and digital packages
N= 95
—————
P= Royal Photographic Society Qualification
P= 94
C= New storybook and digital packages
C= 95
N= New storybook and digital packages
N= 95
—————
P= New storybook and digital packages
P= 95
C= New storybook and digital packages
C= 95
N= Website changes - easier to use contact forms
N= 96
—————
P= New storybook and digital packages
P= 95
C= Website changes - easier to use contact forms
C= 96
N=
N=
—————

which is clearly wrong:

loop 1, next = current
loop 2, repeated entry - same entry (current) as loop 1 (entry 20) but previous now = current
loop 3, okay
loop 4, okay
loop 5, next = current
loop 6, repeated entry - same entry (current) as loop 5 but previous now = current and next is correct
loop 7, next = current
loop 8, repeated entry - same entry (current) as loop 7 but previous new = current and next is correct
loop 9, okay

and I only have 6 entries - ie why 9 not 6 loops?

I know you are concerned that it’s a disparity between the EE sorting and the sorting of your code but it seems clear from this second test that there is something seriously amiss here. Unless I am totally misunderstanding what {previous_entry_title}, {previous_entry_id}, {next_entry_title} and {next_entry_id} are supposed to do.

Doing the same with EE’s code…

{exp:channel:entries channel=“news” category=“9|14” site=“3” status=“open|closed” sort=“asc” orderby=“date” dynamic=“no”}
C= {title}<br>
C= {entry_id}<br>
<hr>
{/exp:channel:entries}

...gives…

C= Welcome to the blog
C= 20
—————
C= Wedding questions answered, plus sharing
C= 88
—————
C= Wedding Photography, another point-of-view
C= 74
—————
C= Royal Photographic Society Qualification
C= 94
—————
C= New storybook and digital packages
C= 95
—————
C= Website changes - easier to use contact forms
C= 96
—————

...which is the correct 6 entries, in the correct order.

Neil D
# 24
Neil D

Looking at the blog posts for all channels something interesting appears. When I look at *all* channels (in date order) I have…

96 - news
95 - news
93 - qanda
94 - news
74 - news
88 - news
87 - qanda
70 - qanda
...
a few more non-news posts
...
34 - qanda
20 - news

...so there are non-news posts between 20 & 88, 94 and 95. Could this be accounting for why 20 is repeated and 94 is repeated? No idea why 95 is repeated though. If there were an issue stopping the non-news posts from being entirely pruned from the sorted list of entries, could this cause duplication in the entry list presented by the code in the previous example?

ie

20
20 (duplicated because of non-news ID 34)
88
74
94
94 (duplcated because of non-news ID 93, which is after it in *date* order)
95
95 (duplicated for some completely different reason)
96

While I’ll be the first to admit it doesn’t exactly fit perfectly, it is a big co-incidence.

Neil D
# 25
Neil D

It occurred to me that 95 could be explained if the problem exists if there is a gap before or after the entry. That way….

20
20 (duplicated as non-news after & before)
88 (no gaps, no duplication)
74 (no gaps, no duplication)
94
94 (duplicated as non-news after)
95 (duplicated as non-news before)
95
96

...perhaps I’m just trying to make a pattern fit. Since this fails for 88 (it has a non-news before and so should be duplicated too).

Neil D
# 26
Neil D

Okay, tried a few variations to see if it makes any difference…

{exp:entries_list category=“9|14” site=“3” status=“open|closed” sort=“asc”}
P= {previous_entry_title}<br>
P= {previous_entry_id}<br>
C= {title}<br>
C= {entry_id}<br>
N= {next_entry_title}<br>
N= {next_entry_id}<br>
<hr>
{/exp:entries_list}

categories in but channel left out, get a list of entries with duplicates as before.

However, if use this code…

{exp:entries_list channel=“news” site=“3” status=“open|closed” sort=“asc”}
P= {previous_entry_title}<br>
P= {previous_entry_id}<br>
C= {title}<br>
C= {entry_id}<br>
N= {next_entry_title}<br>
N= {next_entry_id}<br>
<hr>
{/exp:entries_list}


...with channel but no categories, I get…

P=
P=
C= Welcome to the blog
C= 20
N= Wedding questions answered, plus sharing
N= 88
————-
P= Welcome to the blog
P= 20
C= Wedding questions answered, plus sharing
C= 88
N= Wedding Photography, another point-of-view
N= 74
————-
P= Wedding questions answered, plus sharing
P= 88
C= Wedding Photography, another point-of-view
C= 74
N= Royal Photographic Society Qualification
N= 94
————-
P= Wedding Photography, another point-of-view
P= 74
C= Royal Photographic Society Qualification
C= 94
N= New storybook and digital packages
N= 95
————-
P= Royal Photographic Society Qualification
P= 94
C= New storybook and digital packages
C= 95
N= Website changes - easier to use contact forms
N= 96
————-
P= New storybook and digital packages
P= 95
C= Website changes - easier to use contact forms
C= 96
N=
N=

...which is a perfect list. So it seams there is a problem if both categories and channel is specified. Incidentally, this channel has 4 categories and “not using categories” is a bit of a problem for me (not immediately but it will be in the near future).

I will try this on the single listing ‘article’ page too.

Neil D
# 27
Neil D

Right, tried this on the article page…

<div id=“postNav”>
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” site=“3” per_page=“1” status=“open” sort=“asc” orderby=“date”}
  {if next_entry_id != “”}
  [url=”https://devot-ee.com/weddings/article/{next_entry_id}”]
    {next_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 
 
  {exp:entries_list entry_id=”{freebie_3}” channel=“news” site=“3” per_page=“1” status=“open” sort=“asc”}
  {if previous_entry_id != “”}
  [url=”https://devot-ee.com/weddings/article/{previous_entry_id}”]
    {previous_entry_title}
  [/url]
  {/if}
  {/exp:entries_list}
 
</div>

...and it works - well it doesn’t because I loose my categories which is a problem for me (or will be).

It also works if I use limit=1 instead of per_page=1 (which is what I would expect, the previous duplication issue was not what I expected).

Incidentally, if I enable more categories, ie category=‘9|16|15|14’ then I get more duplication of entries (as least in previous & next with limit=‘1’).

What’s more, if I examine the categories something interesting appears…

post id 20 has 2 categories (and is duplicated in above examples)
post id 88 has 1 category (and is *not* duplicated)
post id 74 has 1 category (and is *not* duplicated)
post id 94 has 3 categories (and is duplicated in above examples)
post id 95 has 2 categories (and is duplicated in above examples)
post id 96 has 1 category (and is *not* duplicated)

...which I believe is a perfect fit for the listing issue.

Laisvunas
# 28
Laisvunas

Hi,

It seems that there is some mysterious bug.

To fix it I need:

1) category Id numbers of all categories of the channel “news”

2) list of all entries of channel “news” ordered by date ascendingly together with category Ids each entry is posted into.

Then I will create on my server such channel, such entries posted in such categories and investigate what’s happenning when next/previous links are being outputted.

Laisvunas
# 29
Laisvunas

Hi,

I reproduced and fixed the bug in the version 4.2.2

Install this version and tell me if something goes wrong.

Neil D
# 30
Neil D

Hi,

Just installed 4.2.2, re-run the above tests and checked my blog’s single entry page to check the previous / next links (both with category=“9|14” option in).

Result - everything works perfectly.

I’ve also tried changing around a few categories on the entries and changing the open / closed status.

Again, everything appears to be working perfectly.

Thank you for the fix and the very rapid support - excellent work.