Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2006
    Location
    Tokyo, Melbourne, Shanghai
    Posts
    102
    Plugin Contributions
    0

    Default Hide things until Logged in

    Good evening zenners. I'm trying to have a wholesale site whereby viewers can only see products and various pages if logged in. To do this i intend to use some code i found in the forum archive. I'm trying to apply the following "IF" condition to a line in the tpl_header.php to prevent the categories navBar being shown unless logged in but it's not workin!! (I dont need an "else" clause do I? ) Can anyone tell me why it's not working? many thanks in advance.

    <!--bof-optional categories tabs navigation display-->
    if ($_SESSION['customer_id']) {
    // display this link for logged in user
    <?php require($template->get_template_dir('tpl_modules_categories_tabs.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_categories_tabs.php'); ?>
    }

  2. #2
    Join Date
    Jun 2003
    Posts
    33,721
    Plugin Contributions
    0

    Default Re: Hide things until Logged in

    Your syntax is bad. You need to have some <?php and ;?> in there ...
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

  3. #3
    Join Date
    Dec 2006
    Location
    Tokyo, Melbourne, Shanghai
    Posts
    102
    Plugin Contributions
    0

    Default Re: Hide things until Logged in

    hey ya right there Kim san!! arigato!! actually walkin' on the way home in the cold cause the subway had stopped gave me plenty of time to think!! so all i did is take the "<?php" & "?>" of the if statement (as you suggest) and put them on the outside of the entire "IF" statement. Ima totemo yoi desu! (now it's great!!) xie xie ni!
    for anyone looking at doing this in the future, do this instead (notice posi of the red "<?php" & "?>" parts:

    <!--bof-optional categories tabs navigation display-->
    <?php if ($_SESSION['customer_id']) {
    // display this link for logged in user
    require($template->get_template_dir('tpl_modules_categories_tabs.php ',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_categories_tabs.php');
    }
    ?>

  4. #4
    Join Date
    Dec 2006
    Location
    Tokyo, Melbourne, Shanghai
    Posts
    102
    Plugin Contributions
    0

    Default Re: Hide things until Logged in

    Dear zenners, I'm struggling with php. If anyone can offer some advice, please do: what i wanna do is only show the "categories" SideBox heading when a "logged in" condition is true. So i wrote this in tpl_box_default_left.php:

    <?php if ($title="Categories" and $_SESSION['customer_id']) { ?>
    <h3 class="leftBoxHeading" id="<?php echo str_replace('_', '-', $box_id) . 'Heading'; ?>"><?php echo $title; ?></h3>
    <?php } ?>

    <?php if ($title!="Categories" ) { ?> // if title doesnt = Categories
    <h3 class="leftBoxHeading" id="<?php echo str_replace('_', '-', $box_id) . 'Heading'; ?>"><?php echo $title; ?></h3>
    <?php } ?>


    The result of this is:
    Logged Out: No headings above any LeftHand Sidebox!!
    Logged In: every SideBox has "Categories" for a heading instead of the real heading!!

    It is as though the "IF" statement has totally ig
    Why isnt php ignoring the first "IF" when $title doesnt = "Categories" ?
    Why is php writing each heading = "Categories"??

    If i reverse the order of "IF" statements i get:
    Logged Out: All Headings( including "Categories" are correctly above their LeftHand Sideboxes!! Great!!
    Logged In: every SideBox has "Categories" and other Sideboxes have their own heading AND "Categories" for a heading!!

    Could somebody please help with this. Thank you so much in advance.

    Arpeggio

  5. #5
    Join Date
    Sep 2005
    Posts
    912
    Plugin Contributions
    1

    Default Re: Hide things until Logged in

    Did you figure this out, as this is what i am wanting to do

  6. #6
    Join Date
    Dec 2006
    Location
    Tokyo, Melbourne, Shanghai
    Posts
    102
    Plugin Contributions
    0

    Default Re: Hide things until Logged in

    Hi CnTGifts!

    Now ya really takin' me back in time!! I had a little look and sorry to say that i didnt take that route. I have Catergories on all pages (except Top page) and my mind is too rusted with a million other things since that it"s impossible for me to offer you any more practical advice than "please keep on searchin'!" The answer will appear. ZenCart is vast and very flexible and help is teriffic. best of luck.

    arpeggio.

 

 

Similar Threads

  1. hiding prices until logged in - I'm VERY new
    By rattimoth in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 5 Jun 2012, 03:39 AM
  2. Hiding Pages/Sideboxes Until Logged In
    By khopek in forum General Questions
    Replies: 6
    Last Post: 16 Jul 2010, 08:04 PM
  3. Hide Price until logged in
    By picard1701 in forum General Questions
    Replies: 3
    Last Post: 8 May 2009, 03:03 PM
  4. Hiding products/categories until logged on.
    By FishD in forum Customization from the Admin
    Replies: 4
    Last Post: 13 Jun 2008, 06:17 PM
  5. Hide product until Logged In
    By lonehorseend in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 29 Feb 2008, 05:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg