Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Hide things until Logged in

Hide things until Logged in

Locked

Views: 1,971

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
31 Jan 2007, 3:29 PM
#1
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

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'); ?>

}*

31 Jan 2007, 4:23 PM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,604
Plugin Contributions:
0

Re: Hide things until Logged in

Your syntax is bad. You need to have some <?php and ;?> in there ...

31 Jan 2007, 4:58 PM
#3
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

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! :lol:
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'); } **?>

3 Feb 2007, 2:52 PM
#4
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

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

14 Mar 2008, 9:39 PM
#5
cntgifts avatar

cntgifts

Totally Zenned

Join Date:
Sep 2005
Posts:
836
Plugin Contributions:
0

Re: Hide things until Logged in

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

17 Mar 2008, 12:42 PM
#6
arpeggio avatar

arpeggio

Zen Follower

Join Date:
Dec 2006
Location:
Tokyo, Melbourne, Shanghai
Posts:
102
Plugin Contributions:
0

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.