Chris Elliott

Hide container if no results

7 posts in this topic

Hi

I love your work and use BTCS on many sites so thanks!

Meanwhile, I suspect this is not possible as this relates to the parent selector DIV.

You will be familiar with the general behaviour for returning no results: the PHP script proivides:



if(count($list)>0){?>
...
...
else
{
echo '<div>No result...</div>';
} ?>

And in the site HTML output I get


<section data-uk-grid-margin="" data-uk-grid-match="{target:'> div > .uk-panel'}" class="tm-spotlight uk-width-1-1 uk-clearfix">
<div class="">
<div>No result...</div>
</div>
</section>

It works in that if there is no data returned to BTCS, the site presents "No results" but I wanted to make the parent container [section in this case] hidden if BTCS returns no results.

I know I can use a message such as "No results" but I would rather hide the module altogether.

Any suggestions?

Chris

Share this post


Link to post
Share on other sites

Hi there. this is solution

You can change

if(count($list)>0){?>
...
...
else
{
echo '<div>No result...</div>';
} ?>

to


if(count($list)>0){?>
...
...
else
{
?>
<div class="bt-cs-no-result">No result...</div>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".bt-cs-no-result").parents("section").hide();
});
</script>
<?php } ?>

Good luck :D

Share this post


Link to post
Share on other sites

Wow! That's perfect!

Can I suggest that in a future version of BTCS you include an admin option to "Hide container on no results"? Would that work? Maybe not?

Many many thanks!

Chris

Share this post


Link to post
Share on other sites

Thank you for taking the time to write this solution.

However, I was wondering if you could tell me where to find the file with this in as I cannot find it.

Thank you

Share this post


Link to post
Share on other sites

Hi

I created  this by creating and editing an override.

1. In your templates/[templatename]/html fiolder, create a new folder called mod_bt_contentslider

2. Now go to the /modules/ master folder and copy the file called /modules/mod_bt_contentslider/tmpl/default.php

3. Place the copy in your newly created templates/[templatename]/html/mod_bt_contentslider folder and call the copy default.php

3. Edit this default.php file as noted above.

 

Cheers!

Chris

Chris Ash likes this

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now