views:

125

answers:

3

How can I hide our main nav and use it as the home page but only for logged in users?

The following is the code for the slideshow. The MENU is an element though. Should they both be in the element file together? Before I attempt to hide when logged in? File /elements/nb_menu_home.ctp reads:

<script src="/js/loopedslider.js" type="text/javascript" charset="utf-8"></script>

<div id="loopedSlider">    <!--Beginning of slideshow-->
    <div class="container">
        <?php $session->flash(); ?>
            <div class="slides">
                <div id="slide_one" class="bg"><!--slide #1-->
                    <div class="slide-content">
                        <div class="nhome">
                            <div class="nhhleft">
                                Borrow a car for the weekend, textbooks, and other stuff you need from other students. Free or super cheap! <br />
                                Save money and resources @ USAFA.<br />
                                All users and transactions "Validated by REPIFY"   <br />
                                <strong></strong>

                                <br clear="all" />
                                <iframe src="http://www.facebook.com/plugins/like.php?href=www.neighborrow.com&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; text-align: center;margin-top: 20px;"></iframe>
                                <br />
                                <?= $form->create('Item', array('action' => 'indextest')); ?>
                            </div>

                            <div id="nhhright">
                                <img src="/images/items/cars.jpg" border="0" width="90" height="90">Cars<a href="#more">View more</a>
                                <br/>
                                <img src="/images/items/games electronics.jpg" border="0" width="90" height="90">games electronics<a href="#more">View more</a>
                                <br/>
                                <img src="/images/items/textbooks.jpg" border="0" width="90" height="90">textbooks<a href="#more">View more</a>
                                <img src="/images/items/gear.jpg" border="0" width="90" height="90">outdoor gear and uniforms<a href="#more">View more</a>
                            </div>

                            <div id="captureBlock">
                                <div id="index_headertop"><text><strong><!--Request Item--></strong></text>
                                    <div id="index_close" onclick="divToggle('captureBlock');divToggle('fadedbg');"><img src="/images/Index_close.jpg">
                                    </div>
                                </div>

                                <div id="index_capturecontent">
                                    <div id="index_logoheader"><br/><img src="/images/index_pupupheader.png"></div>
                                    <br/>

                                    <div id="indexinput_email">
                                            <strong><text>Please Enter Your E-Mail To Continue</text></strong>
                                            <?= $form->input('User.emailindex', array('label' => ' ')); ?>
                                            <br/>
                                            <input type="image" src="/images/index_continue.jpg" />
                                    </div>
                                </div>
                            </div>

                            <!--  <div id="index_searchblock">
                                      <div id="index_search">
                                          <?= $form->input('Item.itemindex',array('label'=>'')); ?>
                                          <?= $form->end(); ?>

                                          <?= $form->create('user', array('action' => 'login')); ?>
                                          <?= $form->input('session.have',array('label'=>''));?>
                                      </div>

                                      <div id="index_listButton" style="cursor: pointer;"><input type="image" src="/images/listbutton.png" /></div>
                                      <?= $form->end(); ?>
                                      <div id="index_requestButton" onclick="divToggle('captureBlock');divToggle('fadedbg');" style="cursor: pointer;"></div>
                                  </div>-->
                        </div><!-- capture block ends here -->
                    </div>
                </div><!--end of slide #1-->

                <div id="slide_two" class="bg"><!--slide #2-->
                    <div class="slide-content">
                        <div class="nhhleft">
                                </a>
                               (1) Click on the item you want <br />
                                  (2) Tell us when you want it<br />
                                   (3) Provide your email address for confirmation and REPIFY<br />
                                   (4) Use and return<br />
                               <iframe src="http://www.facebook.com/plugins/like.php?href=www.neighborrow.com&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; text-align: center;margin-top: 20px;"></iframe>
                               <br clear="all" />
                        </div>

                        <div id="nhhright">
                            <br clear="all" />
                        </div>
                    </div><!-- SLIDE CONTENT ENDS HERE-->
                </div><!--end of slide #2-->

                <div id="slide_three" class="bg"><!--slide #3-->
                    <div class="slide-content">
                        <div class="nhhleft">
                              <br /><br />SAVE Money, Time, Space, the Earth<br/>
                              MAKE Money, Friends, Space, a Difference
                                <br /><br />
                               <iframe src="http://www.facebook.com/plugins/like.php?href=www.neighborrow.com&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; text-align: center;margin-top: 20px;"></iframe>
                               <br clear="all" />
                        </div>
                        <div id="nhhright">
                            <br clear="all" />
                            <br/><br/><br/>
                            <img src="/images/save.gif"><br /><img src="/images/make.gif">
                        </div>
                    </div><!-- SLIDE CONTENT ENDS HERE-->
                </div><!--end of slide #3-->

                <div id="slide_four" class="bg"><!--slide #4-->
                    <div class="slide-content">
                        <div class="nhhleft">
                            USAFA!!!
                            <br>
                            If you want to bring us to another school <?= $html->link('contact us', '/contact'); ?>
                            <br /><br />
                            <iframe src="http://www.facebook.com/plugins/like.php?href=www.neighborrow.com&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; text-align: center;margin-top: 20px;"></iframe>
                               <br clear="all" />
                        </div>

                        <div id="nhhright">
                            <img src="/images/skyline_3.jpg" />
                        </div>
                    </div><!-- SLIDE CONTENT ENDS HERE-->
                </div><!--end of slide #4-->

                <div id="slide_five" class="bg"><!--slide #5-->
                    <div class="slide-content">
                        <div class="nhhleft">
                               <br /><br />LOCAL AND NATIONAL MEDIA!<br />
                               <iframe src="http://www.facebook.com/plugins/like.php?href=www.neighborrow.com&amp;amp;layout=standard&amp;amp;show_faces=false&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 30px; text-align: center;margin-top: 20px;"></iframe>
                               <br clear="all" />
                        </div>

                        <div id="nhhright">
                            <br clear="all" />
                                <br/><br/><br/>
                                <a href="http://www.myfoxny.com/dpp/good_day_ny/tech_it_out/091002_neighborrow_tech_it_out" target="_blank"><img src="http://www.beta.neighborrow.com/images/nbmedia/fox.png" border="0" alt="Fox News" /></a>
                                <a href="http://www.msnbc.msn.com/id/15484490/"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/msn.png" border="0" alt="MSNBC" /></a>
                                <a href="http://www.thrillist.com/new-york/neighborrow"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/thrillist.png" border="0" alt="thrillist" /></a>
                                <a href="http://online.wsj.com/article/SB121322069979265767.html?mod=RealEstateMain_1"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/wsj.png" border="0" alt="WSJ" /></a>
                                <br/>
                                <a href="http://www.msnbc.msn.com/id/21134540/vp/27160813#27160813"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/today.png" border="0" alt="Today" /></a>
                                <a href="http://www.wnbc.com/news/16765259/detail.html"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/wnbc.png" border="0" alt="WNBC" /></a>
                                <a href="http://159.54.226.237/08_issues/080601/080601thinksmart-vinegar-lighthouse-trade.html"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/usa.png" border="0" alt="USA" /></a>
                                <a href="http://www.nydailynews.com/money/2008/07/08/2008-07-08_borrow_items_from_neighbors_through_new_.html"&gt;&lt;img src="http://www.beta.neighborrow.com/images/nbmedia/dailynews.png" border="0" alt="Daily News" /></a>
                            </center>
                        </div>
                    </div><!-- SLIDE CONTENT ENDS HERE-->
                </div><!--end of slide #5-->
            </div>

           <?php print $this->element('nbmenu_home'); ?>
       </div>
    </div>

    <script type="text/javascript" charset="utf-8">
        $(function(){
            $('#loopedSlider').loopedSlider({
                });
        });
    </script>
+1  A: 

One method is to have your elements check if the user is logged in.

Alternately, have the view do that check before including the element.

Kalium
is there a resource to see exactly what code to use to check if logged in and tell it not to display if they are? in view
adam
See the answer from Anders S. Yes, there is. Also, try reading the Cake documentation. It's very useful.
Kalium
yup been reading it recently- hard to get code in the exact right spots even when i understand the relationships and the power etc... will keep reading:) sorry if its a homework question...
adam
@adam I'd recommend you code the view to include elements (assuming that you want to show/not show large blocks, rather than just small sections) based on a variable. In your controller, set the $loggedIn var, then conditionally include your elements based on that.
Travis Leleu
+6  A: 

You could do something like this in your app_controller.php:

function beforeRender()
{
    if($this->Session->read('Auth.User'))
    {
        $this->set('loggedIn', true);
    }
}

And check for $loggedIn in your view.

Anders S
Or simply `if ($session->read('Auth.User'))` in the view. No need to pepper your view with extra variables and your controller with more code.
deceze
+1  A: 

Like Anders, I use beforeRender, but couple it with ACL. Here is a fragment of the code I use:

function beforeRender()
{
    if($this->layout=='admin')
    {
        $user = ($this->Auth->user())?$this->Auth->user():array('User'=>array(
                                'username' => 'anonymous',
                                'group_id' => null
                                ));
        if(!$user['User']['group_id']) $this->redirect('/');
        $usersIndexAllowed = $this->Acl->check($user,"users/index");
    }
    $this->set(compact('user','usersIndexAllowed','configureAllowed','moduleTypesAllowed'));
}

You can then use conditionals in the view to hide or display blocks of HTML.

Leo
thanks everyone
adam