using getTotalBlocksInArea
Permalink
I'm working on a theme where I'd like to hide an area depending on the number of the blocks in an area.
What I'm trying to this is this:
Problem is however, that getTotalBlocksInArea only works after you've called display. But this is exactly what I'm trying to avoid. I don't want to display anything, especially not the div if there's no block in the area..
(I would have to check whether the page is in the edit mode or not as well, it's just a simplified example)
Thanks!
What I'm trying to this is this:
Problem is however, that getTotalBlocksInArea only works after you've called display. But this is exactly what I'm trying to avoid. I don't want to display anything, especially not the div if there's no block in the area..
(I would have to check whether the page is in the edit mode or not as well, it's just a simplified example)
Thanks!
Could you post this in the bugs tracker? This really should work regardless..
Did you found a temp. workaround for that?
greets Marv
greets Marv
I thought Andrew fixed that method in the 5.3 release?
I didn't check tho...
I didn't check tho...
I just came across this today!
Same issue, so no it isn't fixed in 5.3.1.1
Would really appreciate it if it would work somehow.
(and no I didn't found a workable workaround, manually coding each time for a new page isn't really what I had in mind.)
Same issue, so no it isn't fixed in 5.3.1.1
Would really appreciate it if it would work somehow.
(and no I didn't found a workable workaround, manually coding each time for a new page isn't really what I had in mind.)
reading trough the area.php i found the hint for passing the page object. So the only little correction on Remo's code is:
greets, Marv
... if ($pic->getTotalBlocksInArea($c) > 0) { ...
greets, Marv
tho >.< yeah..
I also tried $a->totalBlocks, but that returned nothing usable. Now it works for me too.
I also tried $a->totalBlocks, but that returned nothing usable. Now it works for me too.
cool! thanks for sharing
Looking at the code, it would make much more sense if the page object is mandatory in the getTotalBlocksInArea() method, because then there wouldn't be any confusion. It makes sense to us as developers that it should be mandatory, because the area object doesn't know which page its supposed to be querying, but it should then just be made mandatory in this call.
Will get that in there for the next release - but in the meantime yeah, just pass the page object into this method and it should be accurate.
Will get that in there for the next release - but in the meantime yeah, just pass the page object into this method and it should be accurate.
I'm going to backpedal on this. There's a lot of code out there that assumes that the page object is not passed - and in many cases it doesn't need to be (since the getAreaBlocksArray method has already been run.)
So this method is probably going to stay the same as it has been. We'll just make a note that, when theme and template builders are using this method, they really need to pass the page object through.
So this method is probably going to stay the same as it has been. We'll just make a note that, when theme and template builders are using this method, they really need to pass the page object through.
In case anyone comes across this in the future, I've posted a fix here:
http://www.concrete5.org/community/forums/usage/layout-makes-blocks...
http://www.concrete5.org/community/forums/usage/layout-makes-blocks...