[[ previousentry ]] / [[ nextentry ]] not working

Get help with installation and running PivotX 2.0.x here. Please do not post Extension or Theme related questions here.

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Wed Feb 12, 2014 7:57 pm

[[ subweblog name="entry" ]][[ literal ]] block doesn't work either. The weblog name for the frontpage is "normal." This was an attempt to try a different name for the entry template.

Currently, the latest entry ID is 714. I tested this by looking at entry ID 708. Even though parameter e is 708, entry 714 is displayed. The link for "older" directs to 713, and there is no "newer" link. So, this works as my original problem, with the added issue of displaying the latest entry instead of the desired entry.

My goal is to set up previous and next as I am doing the pagination links at the bottom of frontpage and archivepage, though I am content not to have previous and next links on the entries.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby hansfn » Thu Feb 13, 2014 8:56 pm

Thanks for sending me your the templates. I don't see anything wrong in particular, but I think I might be on to something. In your new design the sidebar is coming before the content. I'm guess that something you do in the sidebar is messing up the PivotX internal state. I'm further guessing that the guilty one is your blogstats extension. Before I tell you why, I would like you to confirm my guessing. First comment out the sidebar include. If that solves it, include it again and comment out the blogstats tag.

PS! When I say comment out, I mean Smarty commenting so the code isn't parsed - HTML commenting wouldn't help. I guess you knew this, but to be 110% sure ...
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Thu Feb 13, 2014 11:40 pm

hans,

You're right, but not completely so. [[ blogstats ]] is one of the tags causing the issue. The other is [[ calendar ]] (for the Entry Calendar widget that comes with PivotX).

Does it have something to do with widgets and extensions? The regular PivotX tags work in the floating sidebar.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Fri Feb 14, 2014 12:38 am

Now here's the really fun one.

For grins and giggles I decided to use [[ category_list ]] in place of [[ blogstats ]], and no matter what entry I looked at (and I looked at a few with IDs in the 700s), "older" would point to 555 (or something like that), and "newer" to 571 (or something like that). So, [[ category_list ]] is having an adverse affect on these two tags, too, and I can't figure the logic behind that one.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby hansfn » Fri Feb 14, 2014 8:32 am

OK, I don't immediately see the problem with category_list, but blogstats and calendar does the same mistake - using the global PivoX db object. In stead of

Code: Select all
$blog_array = $PIVOTX['db']->read_entries($entries_params);

use

Code: Select all
$mydb = new db();
$blog_array = $mydb->read_entries($entries_params);

I'll fix the calendar extension and you'll fix the blogstats extension, and then I have to look at category_list. Slightly embarrassing that it has such side-effects ...

ADDED: The new version of the (Entry) Calendar extension has been released - download from http://extensions.pivotx.net/entry/23/calendar (I just fixes this single bug.)

ADDED: I'm not able to reproduce the problem with category_list (and I don't see how the code for that tag can cause any problem like this). Are you 110% it was category_list alone causing the problem?
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Fri Feb 14, 2014 1:41 pm

I'm not sure that [[ category_list ]] alone is responsible for the issue, but it does happen after only adding the tag to the sidebar. I'm using it right now: click. The links are now at the bottom of the page, as I intend them to be (but the error appeared when I had them next to the entry, too). At entry 716, newer should appear greyed-out and unclickable, older goes to 715, but I'm getting links to 571 and 555 respectively. As an aside, the order in which categories are listed by the tag does not follow the sorting order set in the PivotX backend.

I'll get to the fix for blogstats when I get back home.

Thanks!
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby hansfn » Fri Feb 14, 2014 1:58 pm

So you have replaced blogstats with category_list in the sidebar (compared to the templates you sent me)? Hm, very annoying that I can't reproduce it myself. If it is an option to give me FTP access, I can debug it on your site.

PS! I have tested that the fix I suggested above for blogstats actually works.
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Fri Feb 14, 2014 4:09 pm

I used [[ category_list ]] only temporarily as I continued to develop the templates for layout purposes. I intend not to use it permanently. So, the sidebar template that I sent you is only marginally different from the one being used at the moment. I've smarty tag commented out the entire calendar block and the entire blogstats block and added a block for category list in which the output looks similar to blog stats.

I could set you up for FTP access, but I'll have to get to that later, too. I have to move on to my real work for the rest of today, though I'll sneak in some time to fix blogstats officially.

Thanks for the info! I suppose this also serves as the impetus to look at all of the extensions so that they don't break things like this. I've got another one that I've developed just for myself (you can see it in action if you click on the Sermons, Poems, or Hymns links in the menu on my page, that it lists the entries in those categories by year) that I'm sure uses the same method of grabbing the DB.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby Stingray » Fri Feb 14, 2014 6:54 pm

I had a little time and took a look at module_smarty.php. I noticed this bit of code in function smarty_category_list (lines 869-872):
Code: Select all
            if (strpos($format, '%count%')>0) {
               $this_output = str_replace("%count%", $PIVOTX['db']->get_entries_count(
                   array('cats' => $catinfo['name'], 'status' => 'publish')), $this_output);
            }   

Sure enough, I took %count% out of the format param, and previous and next worked correctly. [[ category_list ]] is also using $PIVOTX['db'], but only there, and that breaks previous and next when placed in a floating sidebar like mine.
Stingray
 
Posts: 107
Joined: Wed Oct 28, 2009 2:40 pm

Re: [[ previousentry ]] / [[ nextentry ]] not working

Postby hansfn » Sun Feb 16, 2014 10:01 am

Thx for spotting the get_entries_count usage. I was looking for read_entries. Anyway, this made me realize that read_entries should not change the current entry / the internal state of the database. It's a actually a huge bug that no one has reported before now ... (This bug is only present if you use a flat file database.)

I have already committed a simple fix to our code repository - see revision 4340. It will be part of PivotX 2.3.9 whenever it gets released.

NB! This fix makes it unnecessary to use your own database object (as I recommended above) when using read_entries in PivotX 2.3.9. However, to support older versions of PivotX we still need to use that trick in extensions.
hansfn
Developer
 
Posts: 3280
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Previous

Return to 2.x Support Forum

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron