Why is do you just get a blank page when you search for something in concrete5?

Permalink
Am I doing something wrong or are you supposed to get a blank page when you search for something using concrete5? I noticed that most of the concrete5 features seem to work this way. For example.. When you set up a news page that doesn't have any stories it just shows up blank. Is there no way to set it up with a default message ("There are no stories posted right now.") that only shows up if there isn't any content on a page?

getjoel
 
Doki replied on at Permalink Reply
Doki
I can think of one way, but its going to take a fair bit of php coding. I'll give you the quick rundown, let me know if you want or need more details.

For generic page materials:

Create a block that gets default added to the main area on your page (or add it manually). What this block will do is on page load, get the page cID, and access the concrete5 DB table 'CollectionVersions' to get the maximum cvID (aka the id of the current version of your page) where cID equals the page cID found from above. After that, check the table 'CollectionVersionBlocks' to see if there are any blocks associates with the cID and cvID from above that do not share the bID of this newly created block (aka "select bID from CollectionVersionBlocks where cID = ~yourcID~ and cvID = ~yourcvID~ and bID != ~thebIDofthiscreatedblock~"). If there exists other blocks on the page according to this table, have the view do nothing, otherwise, have the view print a statement.

For a newsfeed etc

Same principle applies. Check CollectionVersions for the latest cvID, check the CollectionVersionBlocks for the bID of whatever block you want checked (newsfeed etc) the look at the bt****** table associated with that block to see what content is in there. If its acceptable content, do nothing, if not, print a statement.


Hopefully, there is a better, built-in way of doing this, but if not, this plan might work in a pinch.
olliephillips replied on at Permalink Reply
olliephillips
If I understand you, this might help.

Put some checking code in your themes default.php and page types templates?

Chances are you need a particular block type to be on a page to define it as not empty. In many cases your page type will put blocks on the page - image or autonav, and you probably won't want these to define the page as not empty?

This code is from a block I built that needed similar checking functionality. Try it in your theme?

Replace 'my_block_type_handle' with the handle of the block that will denote a page as having content (probably the content block).

$pageBlocks = $page->getBlocks();
foreach ($pageBlocks as $pageBlock){
  if ($pageBlock->btHandle != 'my_block_type_handle'){
    echo "No Stories yet";
  }   
}


Hope that helps