Archive

Posts Tagged ‘php’

Strange Behavior with WordPress Pagination, Fix

I was creating a custom theme for a website that I work on – www.f1weekly.com – and I was getting some strange behavior with the default WordPress pagination.

Using the standard code, as found in the "default" theme included with WordPress, I used the following code to create my pagination links in my templates:

 

<div class="navigation">
<div class="alignleft"><?php next_posts_link(‘&laquo; Older Entries’) ?></div>
<div class="alignright"><?php previous_posts_link(‘Newer Entries &raquo;’) ?></div>
</div>

Suddenly I noticed that I was getting some strange results happening with the pagination links. Below is an example:

On a category page like http://www.f1weekly.com/category/podcasts/ the pagination to the second page should be http://www.f1weekly.com/category/podcasts/page/2/ but all my pagination links where going to http://www.f1weekly.com/page/2/ – which is the link for the second page of all posts, like the links on the home page.

This was driving me mad, and I just couldn’t figure it out.  I even rebuilt the theme from scratch.  Still no dice, but it did work correctly when I was loading the "default" theme.

So, I did a comparison of the code I had in my header.php template against the "default" theme header.php.  I had additional JavaScript files link, some additional CSS files linked, and some other code such as Google Webmaster Tools verification Meta tags.

On review of the code, nothing jumped out at me.  So I started again, this time removing anything that I had which the "default" theme did not.  Suddenly the pagination worked like it should.  Success!  Well sort of…

Now I started to add in my extra code one line at a time.  Still working… until I got to the following:

 

<? if($_server['REQUEST_URI'] == "/"){ ?>
<script src="/scripts/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="/scripts/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
<? } ?>

This code was there to only output the Adobe Spry TabbedPanels code on the home page, but this PHP condition was somehow re-setting something that was causing my pagination nightmare.  I have since removed this and I am simply including the SpryTabbedPanels.js and SpryTabbedPanels.css on all pages.  The offset of having those files load on all pages, whether or not they are needed, beats not having working navigation.

My thanks on this fix goes out to Eric Baker, as he gave a helping hand on this one!

 

Categories: php, programming Tags: ,

PHP: PEAR Library and Plesk

I was having an issue with setting up PEAR Library with PHP on my Linux box that runs Plesk, so after some research and a little help from the support team at HostMySite.com I came up with the following.

To run PEAR you obviously have to have it installed, so once you have done that, you will need to create a vhost.conf file for the domain that you wish the library to work with on the Plesk box.  This should look something like the following, and should be put into <account root>/conf/vhost.conf

 

<Directory /var/www/vhosts/my_domain_name.com/httpdocs>
       php_admin_value open_basedir "none"
       php_admin_value include_path "/var/www/vhosts/my_domain_name.com/httpdocs:/usr/local/PEAR:/tmp:"
</Directory>

 

Once you’ve created the vhost.conf file you have to run the following command.  I use Putty, but any SSH/Telnet client should work great.  This tells Plesk to rebuild the configuration files which will update with changes in the vhost.conf.  

  • /usr/local/psa/admin/sbin/websrvmng -v -a

And finally restart apache;

  • service httpd restart

These steps should get you to the right place.  At least they do for me.

 

 

Categories: php Tags: ,

Getting into it…

…with this WordPress stuff.  I’ve added some new plugins that will allow some cooler stuff on the front end of the site.  And I’m moving the main domain to point to the blog.  I’m dumping the old site, and we’re going to go with this one only!

Let us know what you think.  I’m trying to get JoAnn to help out and post.  Should be fun!

Categories: miscellaneous Tags: , ,

CFML to PHP

So, I’ve been working all day to get a site converted from Coldfusion to PHP. This seems like a backwards why to do something, given the power of Coldfusion, but there is a reason to the madness.

But after trying to work on this sporadically all day while trying to look after Charlotte, I have given up and I’m about to install WordPress and use that as a CMS for the site.

Categories: programming Tags: ,