Database Queries
Permalink
I am trying to get the numRows returned for how many blocks there are on a specific page.
In my custom block, in view.php, I want to count the number of entries and then in display show 5 on one row 5 on next etc.
So if I can look in the DB or check a variable that already exists, then I can do a for...loop on them.
Anyone have any ideas?
WJ
In my custom block, in view.php, I want to count the number of entries and then in display show 5 on one row 5 on next etc.
So if I can look in the DB or check a variable that already exists, then I can do a for...loop on them.
Anyone have any ideas?
WJ
I would say something to the effect of:
This approach wouldn't be all that efficient since all the blocks would be created in your function, then again when c5 renders them.
Also you'd have to know what areas are within the certain page template.
Or you could query the db directly for all of the areas in a given cID:
http://www.concrete5.org/documentation/developers/blocks/working-wi...
Also you'd have to know what areas are within the certain page template.
Or you could query the db directly for all of the areas in a given cID:
$db = Loader::db(); $cPage = Page::getCurrentPage(); $cID = $cPage->getCollectionID(); $areas = $db->getCol('SELECT arHandle FROM Areas WHERE cID = ?,array($cID)); // then loop through the area handles and get the blocks..
http://www.concrete5.org/documentation/developers/blocks/working-wi...
Well I have the block name I want to loop over and the cID. The code throws a variable error. [Parse error: syntax error, unexpected T_STRING]
Is it cause I am running it on view.php?
I will take out the cID=?,Array($cID) line and input the known cID value and see what i get.
Good answer so far !
**Update**
I am trying to use the $blockType->getCount() method but its choking, and I do get hte block object first yes. Any ideas how to count certain blocks on a page?
Is it cause I am running it on view.php?
I will take out the cID=?,Array($cID) line and input the known cID value and see what i get.
Good answer so far !
**Update**
I am trying to use the $blockType->getCount() method but its choking, and I do get hte block object first yes. Any ideas how to count certain blocks on a page?