Jump to content
Peter Troeger

[SOLVED - kind of] Pagintion Link redirects

Recommended Posts

Hello 🙂

I have set up pagination on a mulitlanguage site.
I've done this before, but this time I have a problem I can't solve.
Pagination is activated on 'parent-template' and 'child-template' just to be sure 🙂

This is my code:

$children = $page->children('limit=1');
		
foreach($children as $child) {
	$title = $child->title;
	echo $title;
}
		
echo $children->renderPager();

The navigation is output correctly and the link look correct as well 'parent-page/page2/'.
But when I click the link, the site seems to redirect back to 'parent-page/

Any help would be greatly appreciated 🙂

- Peter

Share this post


Link to post
Share on other sites

Just a few thoughts...

  • Are there enough children/pages?
  • The selector needs limit AND start if I remember correctly.
  • Home (id=1) needs correct url settings for each language (for example: blank, de, fr, ...)
  • Enable config->debug to see if there are warnings and take a look at the logs - just to make sure.

Just looked into Pagination in ProcessWire but didn't find anything special you could try in addition to that.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for your reply!

  • I have 32 child pages, and it generates the navigation correctly with multiple pages.
  • I added a start, but that didn't change it.
  • URL settings are set to blank for the default and pt for the second language. I tried changing the default to de, just in case but the problem still exists.
  • debug is already enabled. No errors are logged.

I only have menubuilder and the login/register plugin for sitewide modules installed. Could it have anything to do with PagePathHistory?

Share this post


Link to post
Share on other sites

Ok... those modules you mentioned shouldn't interfere here in any kind. Even PagePathHistory shouldn't kick in there but you can check if there is anything set in the settings tab.

Could you post the whole page could or more than just that snippet? Maybe there is something in it.

Share this post


Link to post
Share on other sites

I found out that, if I remove uikit from my site, the page is not redirected, but stays on ' .parent-page/page2/ '.
It doesn't show the content from page 2 though. It still shows page 1 content.

This is the complete template page.

<?php namespace ProcessWire; 

?>

<div id="body_text">

	<?php
	
		$children = $page->children('start=0, limit=2');
		
		foreach($children as $child) {
			$title = $child->title;
			$body = $child->body;
			$file = $child->file;
			$file_url = $file['url'];
			$image = $child->single_images;
			if ($file=='') $file='#'; 
			
			
			?>
			
			<section class="mitteilung">
			
			<?php
			
			echo '<h2><a href="'.$file_url.'">'.$child->title.'</a></h2>
			<p>'.$body.'</p></section>';
			
		}
	?> 
			
			
			<?php echo $children->renderPager(); ?>
</div>

In the init file I add the uikit file.

Share this post


Link to post
Share on other sites

When I keep the uikit file, but remove the usage of uikit (I've had two instances af ukBlogPosts(pages()->get('/aktuelles/')->children, 1) included in the page),
the redirect doesn't happen anymore either. The content still doesn't change 🙂

Share this post


Link to post
Share on other sites

ok, I also removed the start=0, and now it works. Now I only have to find out, why it doesn't work when I use ukBlogPosts(pages()->get('/aktuelles/')->children, 1 ) and $children->renderPager(); on the same page 🙂

Share this post


Link to post
Share on other sites

Ok... so start is not necessary. Good to know. My fault. 😄 

Where does this ukBlogPosts() come from? Are you using one of the included profiles (Regular or how it is called)?
If so... I'm out... never used it. 😂 

If you don't need it there, you can just go on from here.

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By carlitoselmago
      I'm building a fieldtype/inputfield to visually select a grid like Bootstrap since it's the first time coding such thing, I'm basing my code in FieldtypeColorPicker since the base structure is the same, a graphical UI helper to finally output a string as value.
      The problem is I try to save the value as something like "1,2,3" referencing the index of each column selected but it gets converted as an int value so "1,2,3" becomes "1" if input random text it gets converted as "0".
      Here is the code:
      https://github.com/carlitoselmago/FieldtypeGridSpace
      Here's an screenshot of how it looks

    • By jacmaes
      I have a series of videos, and the following search form (translated into English here) that allows to filter these videos on the frontend:

      I've built a few of these search forms, but only with text fields, selects and radio buttons. Here I'm using an array with checkboxes ("Level" field above), and it's causing me grief when I try to paginate these results. I've done a lot of searching in the forum and spent too many hours to try to get it to work. Here's how I'm building the selector:
      <?php if(count($input->get)): // Level is an array. Code adapted from Ryan's snippet here: // https://processwire.com/talk/topic/3472-enable-pagination-for-search-results/?tab=comments#comment-38042 if($input->get->level) { $level = array(); foreach($input->get->level as $id) $level[] = (int) $id; // sanitize to INTs $level = implode('|', $level); // convert to 123|456|789 string, ready for selector } else { $level = ''; } $data = array( 'training_type' => array('=', (int) $input->get->training_type), 'duration' => array('=', (int) $input->get->duration), 'level' => array('=', $level), 'limit' => array('=', (int) $input->get->limit) ); $selector = ''; // iterate through the $data we made above to create a selector string foreach($data as $field => $a) { list($operator, $value) = $a; if(empty($value)) continue; // send value to the whitelist so that it can be used in pagination $input->whitelist($field, $value); // append to our selector string $selector .= "$field$operator$value, "; } $videos = $page->children("$selector"); When I hit search, I get the expected results. So far so good. The GET parameters are the following with the options selected in the screenshot above:
      videos/?level[]=1476&level[]=1477&training_type=1473&duration=1485&limit=10 $selector echoes the following as the "level" field is an array with a pipe character:
      level=1476|1477, training_type=1473, duration=1485, limit=10 Now, when paginating these results, the following page (page 2) shows these GET parameters:
      videos/page2/?level=1476|1477&training_type=1473&duration=1486&limit=10 And I think that's where the problem lies. The "level" field is "lost" and I'm getting more results than expected on subsequent pages. If I manually add "page2" to the initial results in the URL, just to test, everything works fine:
      videos/page2/?level[]=1476&level[]=1477&training_type=1473&duration=1486&limit=10 But how can I achieve this in code? Do I need to revert to "level[]=1475&level[]=1477" instead of "level=1476|1477" for the pagination to work correctly, and can you PHP gods illuminate me?
      Any help would be really appreciated, really.
    • By bramwolf
      Hi Guys,

      I found that my site is producing this notice on the front end, even when $config->debug = false and also when admin is
      not even logged in. How do I keep the site from displaying this message to front end users? The notice is about a few vars
      being tested, which in this case aren't defined, how would I stop that from happing all together when testing vars? if I for instance
      wrap the $discountCode = blabla in a if($order) { ...  } statement than I'm again testing for $order which isn't a object in this case
      which throws another notice..

      This is the notice:


      Here is my current code:
      // PAD DISCOUNT CODE HOOK // First we see if we have active discount code if ($this->session->orderId) { $order = $this->pages->get($this->session->orderId); } if($product->geen_korting == 1) { $nodisc = $product->geen_korting; } else { $nodisc = $product->parent->geen_korting; } $discountCode = $this->sanitizer->selectorValue($order->pad_discount_code); $dc = $this->pages->get("template=paddiscount, title=$discountCode"); if ($dc->id) { if ($nodisc) { $discount = 0; } elseif ($dc->pad_percentage) { $discount = $newprice * ($dc->pad_percentage / 100); } } $event->return = $newprice - $discount;
      Thanks in advance 🙂
    • By shadowkyogre
      [EDIT]: After sitting down and planning out my site according to the ragged hierarchy information, I settled on the following schematics.
      /$world/$template/$content_of_template_type/... for my pretty URLs /roster/$character for my characters a generic Repeater field with depth on most content types for custom positions for child pages to connect to instead of it directly a few Repeater fields on each content that have (PageReference[1], other fields) to establish associations A few FieldsetGroups to help me manage the fields that I needed to copy across a bunch of content types. Kept the original post below for context and tagged the OP for searchability.
      ---
      Hi everyone! I'm working on a personalized worldbuilding wiki to host my art and story stuff.
      Right now my site architecture looks like...
      /$world/cosmology/$cosmology /$world/locations/$location /$world/factions/$faction /$world/history/$history /$world/species/$species /roster/$character So far the layout works, but there's one problem. I need to make sub-sections for an organization. Organizations can appear under cosmology, locations, and factions. Sounds straightforward until... I run into the problem of figuring out how to represent subfactions.
      Key factors in this are...
      Characters should be able to be part of multiple organizations Characters should have an explicit role assigned to their membership. Character pages should be able to query the organization pages to display their ranks across organizations. Editing an organization's hierarchical layout should be visible while editing the root organization page. From what I've read of the ProcessWire documentation, the best use case for each way of representing the organization's subsections are...
      Child Pages:: Works best for menu presentation and dedicated editing. PageTables:: Works if you want control over where to place the PageTable fields, but requires opening a modal for the pages you want to edit. It's also kind of like normal pages. Repeaters:: Works great for inline editing and easy control over hierarchy, but the page urls become obscure. Sections in the body field:: Works for copypasting from my note files. But it doesn't expose relationships for easy querying. It looks like my best case for this is child pages since it allows displaying suborganization in the URL easily. But also I lose out on quickly reordering and editing the child pages. Any advice for people running into similar use cases?
    • By a.masca
      Goodmorning everyone,
      sorry for the inconvenience but I have a problem that I can't find in any other post.
      Strange things happen on a site:
      - despite everything being configured correctly (as already done in dozens of other sites) only superusers can create new pages
      - if I insert in a selector "include = all" the result is always 0
      - I should restore a series of pages incorrectly inserted in the trash, but I cannot select them with the selector "status = Trash"
      Some idea?
      Thanks so much for your valuable support.
×
×
  • Create New...