Refresh Full page cache for autonav when updates from backend

Permalink
Hello All,
I am using concrete5.7.5.2. I have enabled all cache settings from the 'Cache & Speed Settings'. Now the issue is when i change the 'name' attribute of autonav from sitemap, it will not reflect on front side. so i have made some custom code to refresh the cache.

For refresh cache i have made changes in core file.
Concrete\Core\Block\BlockController.php
/**
     * Call custom function using event listener
     */
    public function on_start()
    {
        parent::on_start(); // TODO: Change the autogenerated stub
        Events::addListener('on_page_version_approve', array($this, 'CacheBlockClearOn'));
    }



Here is my custom function code for 'CacheBlockClearOn'.

public function CacheBlockClearOn() {
        $bt = BlockType::getByHandle('autonav');
        $db = Loader::db();
      // Get the collection ID, collection version ID, And handler from the block ID
        $bRows=$db->getAll('select cvb.cID, cvb.cvID, cvb.arHandle, cvb.bID FROM CollectionVersionBlocksOutputCache cvb inner join blocks bks on bks.bID = cvb.bID where cvb.btCachedBlockOutputExpires !=0 AND bks.btID='.$bt->getBlockTypeID().' AND bks.btCachedBlockRecord !="" AND bks.bFilename !="" ');
        foreach($bRows as $row){
            //Get the latest version of current collection
            $cvRows=$db->GetRow('select cv.cvID FROM collectionversions cv where cvIsApproved = 1 AND cv.cID='.$row['cID'].' ORDER BY cv.cvID DESC LIMIT 1');
            $cIDs[] = $row['cID'];
            //check for the current version is greater than cache version
            if($cvRows['cvID'] > $row['cvID']){
                //if current version is greater than cache version update expiration date for all blocks
                $v = array(  $row['arHandle'], $row['bID']);
                $db->Execute(
                    'update CollectionVersionBlocksOutputCache set btCachedBlockOutputExpires = 0 where cID IN ('.implode(',', $cIDs).')  and arHandle = ? and bID = ?',



Here i have used 'on_page_version_approve' event and call my custom function 'CacheBlockClearOn'. But the problem is, i have enabled full page caching, so on_start does not run. If i disable full page caching my custom function is work.

So I want to know place which is always called to get this event work. Or is there something that i missed?

Any help and suggestion would be appreciated.

Thanks.

 
mnakalay replied on at Permalink Reply
mnakalay
Not 100% certain but you might have better luck putting all this in a package's controller
avdevs replied on at Permalink Reply
No-buddy to help here.

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.