Question

When cache is disabled, Mage::getSingleton('cms/page')->getIdentifier(); is working fine and i am getting correct page identifier for all pages.

But when cache is enabled, it is always returning the page identifier that's loaded first.

I am calling it in phtml files. Should it work fine in block classes?

Any workaround?


Update:

Actually all code are being cached somehow AND I cant see any output of new code unless I flush or disable cache. So this does not seem to be an issue of this particular singleton object. On same server, another magento installation/project is fine with cache enabled and I can see uptodate immediately. I am looking into the issue. It might be any other setting or the theme that has come up with some extensions.

Was it helpful?

Solution

My entire navigation block was being cached and any changes I was making did not reflect on the frontend at all unless the cache are being cleared. But other phtml files were fine.

In my navigation block class I added the following code and it is now working as expected:

protected function _construct()
{
    parent::_construct();

    $this->addData(array(   'cache_lifetime' => null ));
}

The following link helped me to fix the issue: https://stackoverflow.com/a/25032002/1302297

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top