$btIncludeAll

Permalink
I have the following coding on page that shows a particular block using the Bid.

<?php
 $block = Block::getByID(83);  
 if( is_object($block) ) $block->display();  
?>


The problem is that every edit made on the block increases the Bid leaving the code above showing old data. So I found that updating the controller.php with protected $btIncludeAll = 1; should stop this from happening. Unfortunately Bid still increases so have I misunderstood the attribute or is there another way?

Responsive
 
foiseworth replied on at Permalink Reply
foiseworth
It is correct that the block ID increases each time you edit it, this part of how page versions work. So essentially every time you edit the block (and thus the page) a new version is created, thus resulting in a new ID for the block. There is more to it than that but I'll try not to overcomplicate it (and please someone step in if I'm getting this all wrong!).

I think a solution would be to get the page the block is on, then get area, match for block with correct handle then display... but there is probably a better way?
jordanlev replied on at Permalink Best Answer Reply
jordanlev
I think the explanation by @foiseworth is correct. What you should do instead is use a global scrapbook block. To do this, go to Dashboard -> Scrapbook, add a global scrapbook (or click on one that already exists if there is one), and add a block to that. Then name the block something (for example, "My Block"). Then in your code, do this:
<?php Block::getByName('My Block')->display(); ?>
Responsive replied on at Permalink Reply
Responsive
yep this works so many thanks for the help. I have noticed though that it does not update when an edit it done and I have to disable the cache to make it work. Is this correct or a better way ?
jordanlev replied on at Permalink Reply
jordanlev
Depends on the block -- some will cache things more than others. You don't have to turn caching off necessarily -- you can click the "clear cache" button in Dashboard -> Sitewide Settings instead.
Responsive replied on at Permalink Reply
Responsive
its the content block that i'm experimenting with. Unfortunately the user does not have access to the Dashboard but switching off the cache does not seem to affect the performance for the moment :-)
jordanlev replied on at Permalink Reply
jordanlev
Yeah, the built-in C5 cache doesn't actually seem to do much in terms of real-world performance. What does help a lot is compressing and combining js/css assets, which you can do with MISER:
http://www.concrete5.org/community/forums/customizing_c5/miser-web-...
(It's free for non-commercial sites, reasonable fee for commercial ones)

There's also another one that is totally free for all uses called "Tinifier", which does some of what MISER does but not all of it:
https://github.com/12345j/Tinifier-Concrete5-Optimiser...