Grabbing all blocks of type X on whole website
Permalink
Hi all
I'm wondering if it's possible to get every block of a particular type, anywhere on the website, then output them in a single place.
I've created a custom map/address block which is used on several branch pages. I'd like to programmatically extract the fields from each of these blocks to display on a separate, summary contact page.
Pseudocode would be something like this:
Is this possible? I had a look throughhttp://www.concrete5.org/documentation/developers/blocks/working-wi... but it seems to refer to specific instances of an individual block on an individual page.
I'm wondering if it's possible to get every block of a particular type, anywhere on the website, then output them in a single place.
I've created a custom map/address block which is used on several branch pages. I'd like to programmatically extract the fields from each of these blocks to display on a separate, summary contact page.
Pseudocode would be something like this:
Is this possible? I had a look throughhttp://www.concrete5.org/documentation/developers/blocks/working-wi... but it seems to refer to specific instances of an individual block on an individual page.
I'd like to know this too. It'd be useful on big sites where you have content in lots of different places and want a page that summarises all that content, or provides links to where that content can be found.
This is probably back-to-front to what you want, but there is a 'Where's my Block' addon. Maybe it would serve as a starting point.
Thanks for the reply John. I had seen that add-on, but it seemed quite complex to pick apart and as all the blocks I needed were of the same type, I ended up writing some code to pick out the block information directly out of the database. I know it's bad to directly query the database, but it did the job and I'll revisit it the next time I come across the situation.
It's easy enough to grab all the data from a block's database table, but that doesn't filter out only the published versions of those blocks -- it includes all versions of the blocks.