Hiding and showing parts of an html with PHP? -


the example have in html:

<div id="red-nav-warp">   <ul id="red-nav-logo">     <li><img class="sponsors" id="sponsorone" src="media/img/logosmall.png" /></li>   </ul>   <ul class="clearfix" id="red-nav-list-member" >     <li><?php $themesys->href('logout',$langsys->get('logout')); ?></li>     <li><?php $themesys->href('settings',$langsys->get('settings')); ?></li>   </ul>       <ul class="clearfix" id="red-nav-list" >     <li><?php $themesys->href('home',$langsys->get('home')); ?></li>     <li><?php $themesys->href('why',$langsys->get('why')); ?></li>     <li><?php $themesys->href('register',$langsys->get('register')); ?></a></li>     <li><?php $themesys->href('account',$langsys->get('member')); ?></a></li>     <li><?php $themesys->href('community',$langsys->get('community')); ?></a></li>     <li><?php $themesys->href('blog',$langsys->get('blog')); ?></a></li>     <li><?php $themesys->href('partners',$langsys->get('partners')); ?></a></li>   </ul>     <div class="clearfix"></div>     </div><!-- end red-nav-warp --> 

what want show portion of html if logged in user.

<div id="red-nav-warp">   <ul id="red-nav-logo">     <li><img class="sponsors" id="sponsorone" src="media/img/logosmall.png" /></li>   </ul>    <!-- hidden or no output -->     <ul class="clearfix" id="red-nav-list" >     <li><?php $themesys->href('home',$langsys->get('home')); ?></li>     <li><?php $themesys->href('why',$langsys->get('why')); ?></li>     <li><?php $themesys->href('register',$langsys->get('register')); ?></a></li>     <li><?php $themesys->href('account',$langsys->get('member')); ?></a></li>     <li><?php $themesys->href('community',$langsys->get('community')); ?></a></li>     <li><?php $themesys->href('blog',$langsys->get('blog')); ?></a></li>     <li><?php $themesys->href('partners',$langsys->get('partners')); ?></a></li>   </ul>     <div class="clearfix"></div>     </div><!-- end red-nav-warp --> 

anyone have idea or example class can hide things can write ( better class if it's possible.)

<div id="red-nav-warp">   <ul id="red-nav-logo">     <li><img class="sponsors" id="sponsorone" src="media/img/logosmall.png" /></li>    </ul>    <?php $hidesys->hiddenbelow(); ?> <!-- hide class or magic -->    <ul class="clearfix" id="red-nav-list-member" >      <li><?php $themesys->href('logout',$langsys->get('logout')); ?></li>      <li><?php $themesys->href('settings',$langsys->get('settings')); ?></li>    </ul>    <?php $hidesys->stop(); ?> <!-- end hide class or magic -->       <ul class="clearfix" id="red-nav-list" >      <li><?php $themesys->href('home',$langsys->get('home')); ?></li>      <li><?php $themesys->href('why',$langsys->get('why')); ?></li>      <li><?php $themesys->href('register',$langsys->get('register')); ?></a></li>      <li><?php $themesys->href('account',$langsys->get('member')); ?></a></li>      <li><?php $themesys->href('community',$langsys->get('community')); ?></a></li>      <li><?php $themesys->href('blog',$langsys->get('blog')); ?></a></li>      <li><?php $themesys->href('partners',$langsys->get('partners')); ?></a></li>    </ul>      <div class="clearfix"></div>     </div><!-- end red-nav-warp --> 

what have done, , yes know it's epic fail @ least i'm trying :)

<?php   /** * trying hide part of html * useing if $_session['login'] = true; */ class hideing {   function __construct()   {    }    function hiddenbelow()   {     return "if($_session['login']){"; // epic fail   }    function stop()   {     return "}";   } }  $hidesys = new hideing; ?> 

thanks looking in,

adam ramadhan

your code returns string. php not execute automatically.

you need

 </ul>  <?php if($_session['login']) { ?> <!-- hide class or magic -->  <ul class="clearfix" id="red-nav-list-member" >   <li><?php $themesys->href('logout',$langsys->get('logout')); ?></li>   <li><?php $themesys->href('settings',$langsys->get('settings')); ?></li>  </ul>  <?php } ?> <!-- end hide class or magic -->     <ul class="clearfix" id="red-nav-list" > 

you may have read wisdom of seperating model view , controller logic , want encapsulate logic class, still need ifs in php code.

 </ul>  <?php if($hidesys->isloggedin()) { ?> <!-- hide class or magic -->  <ul class="clearfix" id="red-nav-list-member" >   <li><?php $themesys->href('logout',$langsys->get('logout')); ?></li>   <li><?php $themesys->href('settings',$langsys->get('settings')); ?></li>  </ul>  <?php } ?> <!-- end hide class or magic -->     <ul class="clearfix" id="red-nav-list" > 

where isloggedin() method returns boolean true or false variable.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -