Jump to content

Pagination in Pages pages is broken for non-database pages


Martin A.

Recommended Posts

Ever since the introduction of the SEO friendly pagination \IPS\Request::i()->page has been empty.

In \IPS\cms\Databases\Dispatcher::run you extract this data, and adds it to the request object. You mind doing this for other pages too, not just pages that use the {database} template tag?

Link to comment
Share on other sites

4 hours ago, bfarber said:

I'm not sure I'm following - I don't see anywhere in that method where we're pulling out pagination information.

image.thumb.png.fc41ae2552306472d305afabc2d0cf96.png

4 hours ago, bfarber said:

Do you have an example of a page not working or something that did in previous versions?

After SEO pagination was introduced, the pagination in the URL is considered a part of the SEO title in Pages. For a page titles "123test", the path in \IPS\Request::$_data is "123test/page/1".

{{$featuredNewsRecordsClass = '\IPS\cms\Records1';}}
{{$featuredNewsWhere = array( array( 'record_locked=?', 0 ) );}}

{{$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . \IPS\cms\Pages\Page::$currentPage->full_path, 'front', 'content_page_path', \IPS\cms\Pages\Page::$currentPage->full_path );}}

{{$count = 0;}}
{{$page = isset( \IPS\Request::i()->page ) ? intval( \IPS\Request::i()->page ) : 1;}}
{{$limit = 11 * ( $page - 1 );}}

{{$articles = $featuredNewsRecordsClass::getItemsWithPermission( $featuredNewsWhere, 'record_featured DESC, record_publish_date DESC', array( $limit, 11 ), 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE, FALSE, FALSE, FALSE );}}

{{$count = $featuredNewsRecordsClass::getItemsWithPermission( $featuredNewsWhere, 'record_featured DESC, record_publish_date DESC', array( $limit, 11 ), 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );}}

{{$pagination = array( 'page'  => $page, 'pages' => ( $count > 0 ) ? ceil( $count / 11 ) : 1 );}}

{{if $page > $pagination['pages']}}
	{{\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setQueryString( 'page', 1 ), NULL, 303 );}}
{{endif}}

It looks something like this. If I var_dump the request object I get this:

[data:protected] => Array
        (
            [app] => cms
            [module] => pages
            [controller] => page
            [path] => 123test/page/2
        )

I copied the code in the screenshot above into a method in my app which I call before the page code in order to temporarily solve this.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...