MirageLab :: Hacking pnTitle Into Xanthia Themes

News Articles

CMS Development + Articles
Browse in : All > Topics > CMS Development
All > Categories > Articles
Any of these categories - All of these categories

Hacking pnTitle Into Xanthia Themes

CMS Development
Are you using a Xanthia theme? While the basic installation, insertion of pntitle.php (note little "t") in the directory of the modules, insertion of pnTitle.php (note capital "T") in the includes directory, and header modification are the same, calling the title hack function will be done differently.

It's also important to note that each pntitle.php is for a specific module. They are not interchangeable.

Once you get each of the pntitle.php files in their proper directories and pnTitle.php in the includes directory, back up your header.php file. It's at the root level. Remember, it's always a good idea to work on a copy, rather than the only copy of any file.

In your editor, open your copy of header.php. Find the following:

<code> echo '<title>'.pnConfigGetVar('sitename').' :: '.pnConfigGetVar('slogan')."</title>\n";
</code>

and replace it with this:


<code> include 'includes/pnTitle.php';
if ($pagetitle = pnModTitle()) {
echo '<title>'.$pagetitle.'</title>';
} else {
echo '<title>'.pnConfigGetVar('sitename').' :: '.pnConfigGetVar('slogan')."</title>\n";
}
</code>


That's all you need to do if you're using a classic (non-Xanthia and non-AutoTheme) theme.

For the hack to work with Xanthia, copy the following and paste it into a blank page. Name it "function.titlehack.php".

<code><?php
// File: $Id: function.titlehack.php,v 1.1 2004/05/07 12:13:42 jnapp Exp $
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
/**
* PostNuke Title Hack
*
* Show individual titles at your PostNuke pages.
*
* This file is a plugin for pnRender, the PostNuke implementation of Smarty
*
* @package TitleHack
* @version $Id: function.titlehack.php,v 1.1 2004/05/07 12:13:42 jnapp Exp $
* @author Joerg Napp <jnapp@users.sourceforge.net>
* @link http://lottasophie.sourceforge.net Official Support Site
* @copyright Copyright (C) 2003 Joerg Napp
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
*
*/

/**
* Smarty function to obtain the title of a page.
*
* Note that the plugin prints out a standard header if no
* special header has been set.
* If the assign parameter is set, the return will be empty in
* this case.
*
* Available parameters:
* - assign: If set, the results are assigned to the corresponding
* variable instead of printed out
* - default: The default title
*
* Example
* <title></title>
*
* @author Joerg Napp
* @since 07.05.04
* @param array $params All attributes passed to this function from the template
* @param object &$smarty Reference to the Smarty object
* @return string the title of the page
*/
function smarty_function_titlehack($params, &$smarty)
{
// get the parameters
extract($params);

include_once 'includes/pnTitle.php';
$pagetitle = pnModTitle();

if (isset($assign)) {
// return the results
$smarty->assign($assign, $pagetitle);
return;
}

if ($pagetitle) {
// the title hack returned a parameter
return pnVarPrepHTMLDisplay($pagetitle);
}

if (isset($default)) {
// a default header was passed
return $default;
}
return pnConfigGetVar('sitename') . ' :: ' . pnConfigGetVar('slogan');
}
?></code>

Save the function.titlehack.php file and upload it to your plugins directory in the directory for your Xanthia module. (modules/Xanthia/plugins)

You're almost home...

The last thing you'll need to do is modify your Xanthia templates. You'll need to do this for each theme you want to use the hack with.

We're going to work on a template called master.htm and one called home.htm. Custom themes may have more templates or may give them different names but, once you get the hang of it, you'll have no problem making the changes if that's the case. master.htm can be found in the templates directory in your theme's directory. home.htm can be found in the templates/modules directory.

In your Xanthia templates, replace where it says,

<code><title></title>
</code>

with

<code><title>






</title></code>

That's it!

-Slugger

There are no comments attached to this item.

Ratings
Options:
View Article Map
View Archives