WBCE CMS – Way Better Content Editing.
You are not logged in.
I have a site which uses the "has_block_content" snippet to hide the sidebar if there is no section appointed to "block 2".
<?php if (has_block_content(2)) { ?>
<div class="sidebar">
<?php globalBlock(17, true, true, array(6,12,24,25,26,27) ); ?>
<?php page_content(2); ?>
</div>
<?php } ?>
As you might notice, I am also trying to use the globalblock module to show section 17 on select pages. I'm eventually going to have multiple global block entries for different sections on dozens of pages.
<?php globalBlock(17, true, true, array(6,12,24,25,26,27) ); ?>
The problem is, most of the pages where I want the globalblock to appear do not have any Block 2 content... so the sidebar does not appear, and therefore the globalblock section content does not appear.
Is there a way to check for "has_block_content" AND to see if the page is in the globalblock array?
I know another option is to add a section picker to every page, but there are dozens of pages, so I was trying to find a more economical solution.
Any help would be appreciated.
Offline
I guess it could work to buffer the output, put it together in one variable and then write it on the page, something like
<?php
ob_start();
globalBlock(17, true, true, array(6,12,24,25,26,27) );
page_content(2);
$content = ob_get_contents();
ob_end_clean();
if (strlen($content) > 50) {
echo '<div class="sidebar">';
echo $content;
echo '</div>';
}
Sorgen sind wie Nudeln: man macht sich meist zu viele.
Offline
You're the best! Thanks for giving me the inspiration I needed to put the pieces together.
Since the globalBlock module already has buffering capabilities, I implemented the following:
<?php $buffer = globalBlock ( 17, true, true, "6,12,24,25,26,27" ); ?>
<?php if (has_block_content(2) || (strlen($buffer) > 50)) { ?>
<div class="sidebar">
<?php echo $buffer; ?>
<?php page_content(2); ?>
</div>
<?php } ?>
Thank you again!
Offline