Jump to content

sitemap with dynamically created Pagination


MichaPau
 Share

Recommended Posts

Hello

I am using a dynamically created Pagination like:

$allImages = $page->VitrineImages;
$limit = $page->VitrineImageCount;
$start = ($input->pageNum - 1) * $limit;
$images = $page->VitrineImages->slice($start, $limit);
$total = count($page->VitrineImages);

$a = new PageArray();
foreach($images as $unused) $a->add(new Page());

$a->setTotal($total);
$a->setLimit($limit);
$a->setStart($start);

this works fine in the template file to create Pagination in relation to the number of images for that field in the page.

But I have problems to include that inside a sitemap template (I am using the code from here -> https://processwire.com/talk/topic/3846-how-do-i-create-a-sitemapxml/?page=1 )

It doesn't create anything when I use the same code in the sitemap.php only replacing the $page variable with $homepage which is defined in _init.php (which is prepended for the sitemap template - and it's inside the $homepage page where I use the pagination in that way)

It seems I am missing something (kind of new to processwire) because $a is always 0 when using this code in my sitemap.php file...

 

 

Link to comment
Share on other sites

I think typically a sitemap does not include paginated pages. You can include a "view all" page if you have one, or the first page of results (make use of rel="next" and rel="prev" in your pagination links).

Google says:

Quote

If you paginate content on your site, and you want that content to appear in search results, we recommend one of the following three options.

  • Do nothing. Paginated content is very common, and Google does a good job returning the most relevant results to users, regardless of whether content is divided into multiple pages.
  • Specify a View All page. Searchers commonly prefer to view a whole article or category on a single page. Therefore, if we think this is what the searcher is looking for, we try to show the View All page in search results. You can also add a rel="canonical" link to the component pages to tell Google that the View All version is the version you want to appear in search results.
  • Use rel="next" and rel="prev" links to indicate the relationship between component URLs. This markup provides a strong hint to Google that you would like us to treat these pages as a logical sequence, thus consolidating their linking properties and usually sending searchers to the first page.

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...