Category Archives: Linux Servers and Software

General Linux server and software information.

WordPress and child page listing

Sometimes I want a listing of the child pages to be embedded in the text of a page. This could be done manually but then maintenance of the site is a nightmare (unless it is a really static site!)

So adding the following code into the relevant page template for the WordPress site works a treat.

[php]
<?php
$children = wp_list_pages(‘title_li=&child_of=’.$post->ID.’&echo=0′);
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
[/php]

While it is not a rule, this related page listing is probably going to appear underneath any of the page text content, so look for the following in the page template and place the child page code below this line.

[php]
<?php the_content(); ?>
[/php]

cPanel and 451 Temporary local problem

This was a new cPanel server and I was setting up the first account for email but tests via the webmail client were not being sent. The error was similar to the title of the post with a ‘Try again later’ message.

So I went trawling through the account settings and came up with nothing. So I read somewhere the the /etc/localdomains may be the issue, so I checked that file and the appropriate domain was there in all its glory so that was not the issue.

More Google searching and I wind up at the appropriate cpanel forum with a post that appeared relevant.

http://forums.cpanel.net/f5/451-temporary-local-problem-14251.html

The post that caught my eye was the one that suggested to run script to fix /etc/localdomains

You can run /scripts/mailperm and it will add all domains to the /etc/localdomains

So I ran this and despite the being no apparent change to /etc/localdomains the email is now working. My guess without looking at the mailperm script, is that it does something more than just set the localdomains list. No time to investigate further and its working.

osCmax svn and reporting which revision is in use

So I started this morning looking to download the latest svn version of osCmax. I am sure the elves have been grinding at the various parts of osCmax providing general users with an improved system for ecommerce.

So I go to http://code.google.com/p/oscmax2/source/checkout and grab the svn command line and use it on my dev linux server to get the latest version.

Start up a fresh site and run the Installer. Which politely informs me that I am using osCMax Power E-Commerce v2.0.25.

WTF? It is 2.5RC2 in the latest download release, why is it still displaying v2.0.25? Hummphhh! I’ve got multiple svn versions and I try to use the code and templates that I develop across the latest public release and more recent svn’s in order to get the best from my sites.

EDIT: The above 2.0.25 was correct because the oscmax2 svn source page gives the latest release version information resulting in that version being downloaded by svn. The more appropriate command line is for a linux testing svn download is
[text]
#svn checkout https://oscmax2.googlecode.com/svn/branches/dev/2.1/ oscmax2-read-only
[/text]

So is there a better way? How about getting the svn version number and publish it alongside the PROJECT_VERSION.

To keep this as a short post this was my way around this:

Create a new file in catalog/includes/svn.php and paste in the following code:

[php]
<?php
/*
$Id: svn.php

osCMax Power E-Commerce
http://howden.net.au/thowden/

Released under the GNU General Public License
*/
// A quick’n’dirty test of publishing to a developer the svn version that is being used

// svn numbering if .svn directory exists then assume that the developer would like to see
// the current version in addition to the PROJECT_VERSION which is consistently out of date
if (!defined(‘REVISION’)) {
if (file_exists(‘.svn/entries’)) {
$svn = file(‘.svn/entries’);
if (is_numeric(trim($svn[3]))) {
$version = $svn[3];
} else { // pre 1.4 svn used xml for this file
$version = explode(‘"’, $svn[4]);
$version = $version[1];
}
define (‘REVISION’, trim($version));
unset ($svn);
unset ($version);
} else {
define (‘REVISION’, 0); // default if no svn data avilable
}
}

?>
[/php]
Save the file and change to edit the install/includes/application.php:
At line 37 which shows

[php]
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0’);
[/php]

and change or insert the following in place of line 37, noting that this is a if else wrap around for the line.

[php highlight=”3″]
require(‘../includes/svn.php’);
if (REVISION == 0) {
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0’);
} else {
define(‘PROJECT_VERSION’, ‘osCmax v2.5.0 svn: ‘.REVISION);
}
[/php]

Then repeat for the main admin application catalog/admin_dir/includes/application_top.php at line 32.

Then repeat again for the main application edit catalog/includes/application_top.php at line 45 except that you removed the ../ from the require() so it is
[php]
require(‘includes/svn.php’);
[/php]

What this does is check for the .svn directory to exist. It will not(should not?) exist in a packaged install like 2.5RC2 but will exist in an svn download. Appending the REVISION to the PROJECT_VERSION constant means that it will appear in all the relevant places in the osCmax site.

Thanks to AD7six at the Bakery for the svn code snippet.

Edit: Thanks to Michael for correcting my understanding of the release version being available from the svn by default and not the latest dev version. However, since writing this post version 2.5 has been released !!

WordPress and Breadcrumbs

Some WordPress themes that I like don’t have a breadcrumb option. So the next best thing is a plug-in and the one I like is Breadcrumbs Plus.

The first thing to do to use this, after installation, is confirm which file you need to edit and I’ll guess it will be header.php for the theme but it could be somewhere else depending on your theme and where you want the breadcrumb to appear.

Once you know where, just add this section of code to the appropriate file, and magic will happen.

[php]
<?php if ( function_exists( ‘breadcrumbs_plus’ ) ) breadcrumbs_plus( array( ‘singular_post_taxonomy’ => ‘category’ ) ); ?>
[/php]