WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 R24 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • hidding page content when empty
  • Print
Pages: [1]   Go Down

Author Topic: hidding page content when empty  (Read 5661 times)

mtcook01

  • Guest
hidding page content when empty
« on: April 27, 2008, 07:20:31 PM »
Hi all I am having a php issue and I simply cannot figure it out.  I am using the water and stone green template and trying not to show the center boxes if they are empty.  The code in index.php is as follows.

  <?php if (!empty page_content(2))  {  ?>
                    <div id="content_top1">
                        <table cellpadding="0" cellspacing="0" class="moduletable">
                            <tr>
                                <th valign="top">
                                    Popular News
                                </th>
                            </tr>
                            <tr>
                                <td>
                                    <ul class="mostread">
                                        <li class="mostread">

                                            <?php page_content(2); ?>

                                        </li>
                                    </ul>
                                </td>
                            </tr>
                        </table>
                    </div>
                       <?php }    ?>


This is mostly due to my VB knowledge and little to no php skills.  I also tried the 

if page_content(2) <> ""   then show the content...

and that did not work at all.  I have to guess that this is a coding issue and would greatly appreciate any help with the matter.  Thanks for your time.

Logged

doc

  • Guest
Re: hidding page content when empty
« Reply #1 on: April 27, 2008, 07:34:53 PM »
Hello,

please search the forum for ob_start, ob_get_contents which can be used to check if there is content in blocks or not.

Regards Christian
Logged

mtcook01

  • Guest
Re: hidding page content when empty
« Reply #2 on: April 27, 2008, 07:49:31 PM »
Yes very sorry, I did a prior search but my brain dead self did not find the answer.  After further investigation I found it and have fixed the problem.  I have attached the code here just for anyone else's future use.  Thanks for your time .

    <!-- start content top 1.  -->
                <!--  added by Michael Cook to check for block content before dispalying   -->

                    <div id="content_top1">
            <?php
                ob_start();

                echo page_content(2);

                $content2 = ob_get_contents();

                ob_end_clean();

            if ($content2<>"") { ?>

                        <table cellpadding="0" cellspacing="0" class="moduletable">
                            <tr>
                                <th valign="top">
                                    Popular News
                                </th>
                            </tr>
                            <tr>
                                <td>
                                    <ul class="mostread">
                                        <li class="mostread">

                                            <?php page_content(2); ?>

                                        </li>
                                    </ul>
                                </td>
                            </tr>
                        </table>
                    </div>
         <?php }    ?>
                    <!-- end content top 1 -->pre]
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • hidding page content when empty
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2