All add-ons currently require PHP 7.4 or greater.

On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.

Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Pagination issue with non-default languages

Status Resolved
Add-on / Version Publisher 3.2.4
Severity
EE Version 5.4.2

Hop Studios

Jun 22, 2021

I saw similar tickets but I actually created a brand new site with only Publisher installed. When the pagination appends the /P{\d} to the URL rather than replacing the existing number offset.

https://publisher.hopexperiment.com/es/P10
Click page 2 and you’ll go to https://publisher.hopexperiment.com/es/P10/P5

I’d prefer not to have to resolve this with URL Helper, if possible.

- Gilbert

#1

BoldMinded (Brian)

Gilbert, can you please share the template code containing the pagination. Also screenshots of the url translation settings for publisher.

#2

BoldMinded (Brian)

Is ES your default or secondary language? I see you provided a CP login, but I don’t login to CP’s unless it’s a absolute last resort. I’d prefer details and screenshots in a ticket.

#3

Hop Studios

Here’s the code:

{exp:publisher:languages}
 <a href="http://{switch_language_url}">{short_name}</a> |
{/exp:publisher:languages}

Site URL: {site_url}

{exp:channel:entries publisher_fields="y" channel="blog" limit="5" paginate="bottom"
 disable="categories|category_fields|member_data"
}
 <h2>{title}</h2>
 
 {paginate}
    {pagination_links}
 {/paginate}
{/exp:channel:entries}

es is the secondary language The only thing I modified is the URL Settings:

Enable URL translations NO

Add URL Prefix YES

Add URL prefix to the homepage YES

Hide the prefix for default language YES

#4

BoldMinded (Brian)

First thing you should do is upgrade to the latest version… I just noticed you are a few versions behind.

#5

Hop Studios

Just upgraded to v3.3.1 and it’s still appending the P{\d} instead of replacing just the offset.

#6

BoldMinded (Brian)

I just tested locally with the same URL Translation settings and wasn’t able to replicate. What else about your environment have you changed config wise? Is this a fresh EE install setup just to demonstrate the issue?

#7

BoldMinded (Brian)

Does it work if you paginate on something other than the home page?

#8

Hop Studios

Same thing: https://publisher.hopexperiment.com/es/testing/P10 Yeah, this is a fresh installation with no other add-ons. All I did was: 1. Install Publisher 2. Added the languages (en as default and es, cn for other languages) 3. Create the default .htaccess file from EE docs 4. Create a bunch of blog entries with just the title 5. Create the template and use the basic pagination file

#9

BoldMinded (Brian)

Is this a Windows environment? -Nevermind, disregard this question.

#10

BoldMinded (Brian)

Can you package up the entire site, including the db, so I can run this locally and debug it? It could be a few days before I can get to it though.

#11

Hop Studios

Comment has been marked private.

#12

BoldMinded (Brian)

You’re going to have to create a detailed video of this behavior. I just setup the site locally with docker containers using ddev and it’s creating the pagination urls correctly.

#13

Hop Studios

When you go to https://publisher.hopexperiment.com/es/P10 and click page 2 you don’t get https://publisher.hopexperiment.com/es/P10/P5 ?

I don’t know what video I can produce to demonstrate this other than that link… You’d like to see my publisher settings or server settings?

Are you using the same .htaccess file that’s in the archive?

#14

Hop Studios

Some more notes on this… in ee/legacy/libraries/Pagination.php around line 617

// Determine the offset
   if ($this->offset === 0)
   {
    $query_string = (ee()->uri->page_query_string != '') ? ee()->uri->page_query_string : ee()->uri->query_string;
    if (preg_match("#^{$this->prefix}(\d+)|/{$this->prefix}(\d+)#", $query_string, $match))
    {
     $this->offset = (isset($match[2])) ? (int) $match[2] : (int) $match[1];
     $this->basepath = reduce_double_slashes(
      str_replace($match[0], '', $this->basepath)
     );
    }
   }

This removes the /P\d+ from the $this->basepath.

In your extension pagination_create, you are setting the $pagination->offset which will make the above logic not run and my $this->basepath never got the /P\d+ removed. Now I’m not sure why only I’m experiencing this… in your case, if you print the $this->basepath in Pagination.php after line 629, do you get the already-cleaned URL or with the pagination offset still?

I can add the basepath sanitization script into your extension or just suppress the offset from being set by that extension to get the pagination links generated correctly. What do you think?

#15

BoldMinded (Brian)

The only thing I changed is set the domain to https://hop-studios-publisher.vm so it works locally, and set the following 2 values in my config.php file to override whatever is in the database since the url is different. I don’t see any duplicate Px segments in the url, pagination works as expected in EN and ES.

$config['site_url'] = 'https://hop-studios-publisher.vm/';
$config['site_index'] = '';
$config['cp_url'] = 'https://hop-studios-publisher.vm/admin.php';
#16

BoldMinded (Brian)

I can add the basepath sanitization script into your extension or just suppress the offset from being set by that extension to get the pagination links generated correctly. What do you think?

I’m not convinced anything needs to be changed in Publisher to affect that basepath. I haven’t had any other reports of pagination issues in ages.

#17

BoldMinded (Brian)

I did make this change after you reported the issue. It didn’t affect my normal local dev environment, which still paginated fine even without this change, but I did notice the offset value wasn’t being set correctly when paginating on the home page (which isn’t a very common scenario). Try making the change in your environment and see if it works. I did not make this change in the environment running the files you sent me, and as mentioned the pagination is working.

https://www.dropbox.com/s/pra94sb7hk75r3x/ticket-2299.png?dl=0

#18

Hop Studios

Comment has been marked private.

#19

BoldMinded (Brian)

Did you try setting the same config values that I did? If it works in 1 env but not another, then we need to figure out why. I don’t think that base_path treatment is the answer, otherwise I’d be able to replicate the issue.

#20

Hop Studios

I just did and the pagination is still /P10/P5.

$config['site_url'] = 'https://publisher.hopexperiment.com/';
$config['site_index'] = '';
$config['cp_url'] = 'https://publisher.hopexperiment.com/admin.php';

What about your .htaccess file. Did you make any changes to it and/or your apache/nginx config files?

Can you please replace your ee/legacy/libraries/Pagination.php with this one https://drive.google.com/file/d/1-jSijBdD1tTqIh_Yk1IvM_3XNLrdeLTb/view?usp=sharing and let me know what you see on https://hop-studios-publisher.vm/es/P5?

I did see similar reports in your other support tickets before I submit this one. I think you had suggested setting the paginate_base parameter but I was able to recreate the issue with a fresh install with almost no config changes. The site that I’m testing on and the site that I noticed the issue are all hosted on Nexcess so could it be a server thing?

#21

BoldMinded (Brian)

Comment has been marked private.

#22

BoldMinded (Brian)

Comment has been marked private.

#23

Hop Studios

Yep, that does it. I’m assuming this fix doesn’t break the Nginx sites?

#24

BoldMinded (Brian)

I’ll double check but I don’t expect it to. Super weird that this behaves differently on Apache and Nginx.

#25

BoldMinded (Brian)

Anyway, glad this is sorted out… sorry for doubting you 😊

#26

Hop Studios

Hey, I’m just glad that I’m not crazy :D Thanks for the fix. When will this get launched? Or should I just proceed with the build you provided?

#27

BoldMinded (Brian)

Just use that build, which has everything in it that’ll be in the next release. You’re ahead of the game.

Login to reply