How do you change value of "nextPageLink"?

9 posts by 2 authors in: Forums > CMS Builder
Last Post: September 30, 2010   (RSS)

I have a blog set up on a site under a directory named "blog" (domain.com/blog/). The index page for the blog is listing 5 posts at a time and then displaying page links to view the older posts. All is working fine with having the blog in it's own directory (e.g., the links to the individual posts are working fine), except for the page links to view the other page(s) of results.

...The code for the nextPageLink is: <a href="<?php echo $listDetails['nextPageLink'] ?>">next &gt;&gt;</a>
...It is returning this link: /blog//page-2/

How do I change the value of "nextPageLink" so I can remove the extra forward slash?

Thanks! -Brian

Re: [rasbro] How do you change value of "nextPageLink"?

By Jason - September 28, 2010

Hi Brian,

Are you using re-writes in your .htaccess file? If so, this could be causing the problem.

Either way, you can get around this by constructing you own nextPageLink.

You can use code that looks like this:
(NOTE: You may need to change some names to match the variables you're using in your file).
<?php

$page=1;
if(@$_REQUEST['page']){
$page=$_REQUEST['page'];
}
if($page<$listingsDetails['totalPages']){
$nextPage=$page+1;
}
else{
$nextPage="";
}
?>


Then, once you can use this code to output your link:

<?php if($nextPage):?>
<a href="/blog/page-<?php echo $nextPage;?>">next &gt;&gt;</a>
<?php endif ?>


Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How do you change value of "nextPageLink"?

Thanks for the post Jason! This is what I have in the .htaccess file...

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.hostdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.hostdomain.com$
RewriteRule ^(.*)$ http://www.domain.com/ [R=301,L]

It seems to me that if the "showme" php code returned some of the results listed below, that the extra "/" would be associated with the tag or some other setting and not a rewrite on the domain itself.

[prevPageLink] => /blog//page-/
[nextPageLink] => /blog//page-2/
[firstPageLink] => /blog//page-1/
[lastPageLink] => /blog//page-2/

I don't know if this sheds any new light on the subject. Any ideas?

Thanks!

Re: [rasbro] How do you change value of "nextPageLink"?

By Jason - September 29, 2010

Hi,

Interesting. If you could email your CMS login and FTP details to jason@interactivetools.com I can take a closer look at this for you.

NOTE: Only email this information, don't post it to the forum.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How do you change value of "nextPageLink"?

Okay Jason, I just sent you that info via email.

Thanks!

Re: [rasbro] How do you change value of "nextPageLink"?

By Jason - September 29, 2010

Hi,

I've got that fixed. What was happening is because you were using the SEO url option, the link uses a "/" instead of a "?" and your URL was www.domain.com/blog/, not www.domain.com/blog/index.php.

If it was the second, your link would look like this:
www.domain.com/blob/index.php/page-2, which would work.

What I did was added this code to your file where you were outputting the links:
<?php $listDetails['nextPageLink']=str_replace("//","/index.php/",$listDetails['nextPageLink']);?>

What this does is put the index.php back into the url if it's not there already. The other option would be to turn off SEO urls.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [rasbro] How do you change value of "nextPageLink"?

By Jason - September 30, 2010

Hi,

The "index" page is always the default page to be shown, so if you just type in www.domain.com/blog/, that's what will show up. The index.php is assumed. You could get the index.php to show up if you added code at the top to get the page to redirect back to itself.

However, this doesn't really seem necessary. The way the page is set up right now, it will work regardless whether or not the index.php is there.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] How do you change value of "nextPageLink"?

That makes sense Jason, thanks for your help with this!