Select Page

Add category ID as a class to the body tag in Prestashop

Within CategoryController.php’s initContent() function find “$this->context->smarty->assign(array(” and add a new line:

'parent_category_chain' => $this->category->getParentsCategories(),

In your header.tpl you can use a foreach loop to only add a category id number where the level_depth of categories is equal to 2 (which would all have a parent category of “home” respectively).

<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $category->id}{if $category->level_depth eq 2} class="cat{$category->id}"{elseif $category->level_depth > 2}{foreach $parent_category_chain as $parent_category_node}{if $parent_category_node.level_depth eq 2} class="cat{$parent_category_node.id_category}"{/if}{/foreach}{/if}{/if}>

Code from Prestashop forum

Use Shortcode in WordPress Template with Custom Fields

This PHP allows you to use Shortcode in a WordPress template but also pull in a value from a custom field.
This was used to add a shortcode for a slider to a specific page.

<?php $slider = get_post_meta($post->ID, 'slider', true);
echo do_shortcode(''.$slider.''); ?>

Use Shortcode in WordPress Template

If you need to run a plugin which uses shortcodes in your template, this can be done with the following code.

<?php echo do_shortcode("[shortcode]"); ?>

OpenCart (VQMod) Replace Logo With Text

This can be used to replace the default logo with text in OpenCart. This uses VQMod so no core files are changed.

        <id>Replace Logo with Text</id>
        <author>Nick Shaw</author>
<file name="catalog/view/theme/*/template/common/header.tpl">
   <operation error="log">
      <search position="after"><![CDATA[<div id="header">]]></search>
      <add><![CDATA[<div id="logo"><p class="textlogo" style="color: #333333; font-size: 35px; font-weight: bold; margin:0px 0px 5px 0px;"><?php echo $this->config->get('config_name'); ?></p> <p>Company Tag Line</p></div>]]></add>

Clear the Logo area for this to work
System > Settings > Edit > Image > Store Logo > Clear Image

Download the VQMod here.

Target a specific page in Joomla

This can be used in your Joomla template to target a specific page, use the menu Joomla menu ID.

   $menuID = JSite::getMenu()->getActive()->id ;
  if ($menuID == '6')
    echo '';

Set rel=”nofollow” on all pages but the homepage

Set the rel=”nofollow” on all pages apart from the homepage.

 if(is_front_page() ) {
 echo "<p class='websiteby'>website by <a href='' target='_blank'>Nick Shaw</a></p>";
 } else {
 echo "<p class='websiteby'>website by <a rel='nofollow' target='_blank' href=''>Nick Shaw</a></p>";

How to use the page class feature in Joomla

This code can be used to target pages based on the page class property in the Menu area.
$app = JFactory::getApplication('site');
$params =  & $app->getParams('com_content');
$pageclass = $params->get('pageclass_sfx');

class="<?php echo $pageclass ? $pageclass : 'default'; ?>"

Email Cloaking for Joomla

Simple Joomla code to cloak an email address.

$email = '';
$cloaked = JHTML::_('Email.cloak',$email);
echo $cloaked;

Set WordPress custom menu per page/post using a custom field

Add this to your template where you want the menu to appear

$menu_slug = get_post_meta($post->ID,'menu',true);
if(is_nav_menu($menu_slug)) {
		'menu' => $menu_slug

Within each post or page add the custom field menu and set the value to the same as the name of the custom menu you want to appear.

Start using Google News Keywords Meta Tag in WordPress using a Custom Field

To make use of the new Keywords Meta Tag for Google News do the following:

Add this to your header.php within the <head> tag

<meta name="news_keywords" content="<?php $news_keywords = get_post_meta($post->ID, 'news_keywords', true); echo $news_keywords;?>">

Add a custom field called “news_keywords” to each of your news posts.