Fishpig_Wordpress Magento extension. Theme a custom category

189 views Asked by At

I have an installed addon for magento called Fishpig. It essentially runs wordpress through magento allowing both to be used on the main website. The WP install is being used for a blog, and i've the whole initial theme set up for it by altering the magento files as required. What i'm looking for though is a way to change the theme if i look under a certain category related to the representative for the site.

Is there a way to set a different template if i were to choose the category? Will i need to add if statements to the category WP layout file?

1

There are 1 answers

0
Ben Tideswell On

If you want to change the whole theme based on the current WordPress category (or any conditions), you would need to listen to for an event and then change the theme programmtically. The most general event that would work would be 'controller_action_predispatch' however if you wanted to only change the theme for WordPress category pages, you would be better suited to use 'controller_action_predispatch_wordpress_post_category_view'.

Attach an event observer method to the event of your choosing and then use the following code:

$_category = Mage::registry('wordpress_category');

if (!$_category) {
    return $this;
}

$_categoryId = (int)$_category->getId();

if ($_categoryId === 1) {
    Mage::getDesign()
        ->setPackageName('default')
        ->setTheme('default');
}
else if ($_categoryId === 2) {
    Mage::getDesign()
        ->setPackageName('default')
        ->setTheme('default');    
}

return $this;

You would need to modify to code to set the correct package/theme (the code below enables the default package and default theme) to match the package/theme you want to set.