For a bunch of reasons, I'd like to be able to switch a CMS page's template based on some PHP.

In config.xml:


in local.xml:

<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
        <reference name="root">
             <action method="setTemplate"><template>page/new_template.phtml</template></action>

In Observer.php:

public function setRootTemplate(Varien_Event_Observer $observer) {
    //some other logic goes here
    $layout = $observer->getEvent()->getLayout()->getUpdate();
    return $this;

Everything is running/working as expected, but the template doesn't switch. what am I missing here? is there some other thing overriding what I do because it runs last?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.