Forums / Templates, Stylesheets, Page Layout / Understanding the Code

Understanding the Code

Locked

Started by dunawayjt on 29 Jul 2006, 6:24 PM · Views: 3,463

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
29 Jul 2006, 6:24 PM
#1
dunawayjt avatar

dunawayjt

New Zenner

Join Date:
Jul 2006
Posts:
8
Plugin Contributions:
0

Understanding the Code

Ok. I’ve just got this software and am a bit like everyone else. Frustrated with all the coding and the work needed to customize your page. My problem is that I never worked with PHP. So it’s like me flying over to China and not knowing how to speak Chinese. Yeah. Well going through the forums I see people asking for help and a lot of the times they just get sent to another page. And the page that tells you how to make a new template tells you simply how to make a stupid folder to start your template. And a little CSS helper with changing colors and crap. And saying well find the page you want to edit and go from there. Well you don’t really say how to edit the page. Anyways make a webpage is easy enough but when you are reading this php code included it’s confusing so this is a my newbie understanding of some of the code possibly to help others gain an understanding. I believe this is all correct and I believe it’s best to understand how something works before just jumping in and playing around. Noting I used the developers tool kit to search for the definitions and putting my own knowledge to this. This is a portion of the tpl_header.php and a stab at understanding it.

<div id="navMain"> <ul class="back"> <li><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">'; ?><?php echo HEADER_TITLE_CATALOG; ?></a></li>

HTTP_SERVER is my domain name https://www.mydomain.com and is located in public_html/shoppingcart/includes/configure.php

DIR_WS_CATALOG is the shopping cart location http://www.mydomain.com/shoppingcart and is located in public_html/shoppingcart/includes/configure.php

HEADER_TITLE_CATALOG is the text “Home” and is located in
public_html/shoppingcart/includes/languages/english/header.php
(note this is where it defines the text home go here to change)

<?php if ($_SESSION['customer_id']) { ?>
<li><a href="<?php echo zen_href_link(FILENAME_LOGOFF, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGOFF; ?></a></li>
<li><a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>"><?php echo HEADER_TITLE_MY_ACCOUNT; ?></a></li>
<?php } else { if (STORE_STATUS == '0') { ?>
<li><a href="<?php echo zen_href_link(FILENAME_LOGIN, '', 'SSL'); ?>"><?php echo HEADER_TITLE_LOGIN; ?></a></li>
<?php } } ?>

FILENAME_LOGOFF is the command “Logoff” which entails a command to logoff when a customer is logged in. The IF implies these statements occur when the customer is logged in. This is defined in /public_html/shoppingcart/includes/filenames.php

HEADER_TITLE_LOGOFF is the text “Log out” defined in /public_html/shoppingcart/includes/languages/english/header.php

FILENAME_ACCOUNT is defined as “account” sending this command. It is located in
public_html/shoppingcart/includes/filenames.php

HEADER_TITLE_MY_ACCOUNT is the text “My Account” defined in public_html/shoppingcart/includes/languages/english/header.php

Now this is an if…else.. statement <?php if ?> <?php }else { which implies that if a user is logged in then these statements will be available for execution whereas if not logged in these statements are ignored.. Simple way to understand.. Login to an account. Notice how Log Out and My Account now show up on your pages. Log Off and they are no longer there =P

FILENAME_LOGIN is also the command to Login or goto the login page to login which is also defined in /public_html/shoppingcart/includes/filenames.php
(note that when a user logs in it sends the command post filename_login to send the command to login)

HEADER_TITLE_LOGIN is the text “Log In” defined in public_html/shoppingcart/includes/languages/english/header.php

<?php if ($_SESSION['cart']->count_contents() != 0) { ?>
<li><a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'); ?>"><?php echo HEADER_TITLE_CART_CONTENTS; ?></a></li>
<li><a href="<?php echo zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'); ?>"><?php echo HEADER_TITLE_CHECKOUT; ?></a></li>
<?php }?> </ul> </div> <div class="navMainSearch forward"><?php require(DIR_WS_MODULES . 'sideboxes/search_header.php'); ?></div> <br class="clearBoth" /> </div>

FILENAME_SHOPPING_CART is for the command “shopping_cart” to send you to the shopping cart. This is defined in
public_html/shoppingcart/includes/filenames.php

29 Jul 2006, 6:40 PM
#2
theoracle avatar

theoracle

Suspended

Join Date:
Aug 2004
Posts:
3,180
Plugin Contributions:
1

Re: Understanding the Code

Most of these technical questions / solutions are already mentionned from the wiki documentation of this site. You can easily seek for the answers from that huge manual, by using the wiki's search engine, as results will be detailedly returned to you on how to operate these codes (may be not all of them but most of them). :wink2:

29 Jul 2006, 6:42 PM
#3
Kim avatar

Kim

Obaa-san

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

Re: Understanding the Code

Looks like you have understood - Do you have a question?

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.

29 Jul 2006, 6:58 PM
#4
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,890
Plugin Contributions:
20

Re: Understanding the Code

I realize that you are trying to be helpful but, just as there is more than one door on a house, there are many ways to "get ZenCart going."

Some of your directory examples will not work for those on different operating systems. And, most of the items in the tpl_header are set at installation. If not, they are configured through the admin.

I'm not sure that most who come to the forum for help are ready to enter the house through the second floor window. No, I'm not calling you a "second-story man." Just pointing out that you may be trying to start from the inside and work out versus build the foundation and go from there to the "second floor" of code manipulation. Especially if you are, as you say, not familiar with PHP. Good news is that you really don't have to be.

When helping someone use a software or program, I always tell them to take the time to look at the menu bar at the top. The same should be done on a newly installed ZenCart. Time will be better spent if the installer dives into the admin control panel and goes item by item through the list.

When (notice I didn't say if:D ) the need arises to change items you have listed, the user would best be suited to use the Developer's Tool Kit in the Admin under tools.

Using a simple text editor, they would know which file and what words to change.

Since this is your first post, is there something you need answered?

TO THE DEVS - One thing on my mind for some time is that most cannot see the docs when first loading ZenCart. How's about a two-option addition to the ZC_Install homepage giving options to install or read the docs. Easier than noobies having to "stumble across" mycart.com/docs.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

29 Jul 2006, 7:01 PM
#5
Kim avatar

Kim

Obaa-san

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

Re: Understanding the Code

DblToe-

There are links on the install success page to the Docs, the forum and the FAQs.

Unfortunately, you can lead the horse to water, but can not make him drink.:smile:

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.

29 Jul 2006, 7:06 PM
#6
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,890
Plugin Contributions:
20

Re: Understanding the Code

OR... You can lead a horse to water but, you can't make 'em pull the bird out of the bush.:D

Most are so delighted at having installation success that they don't see the docs, form, etc.

I think some would appreciate the opportunity to read before they leap.

JMHO

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

29 Jul 2006, 8:48 PM
#7
Kim avatar

Kim

Obaa-san

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

Re: Understanding the Code

:smile: We have given serious thought to making a "next" button for the install success that goes directly to the /docs/ index instead of having buttons to the catalog and admin ...

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.

29 Jul 2006, 10:33 PM
#8
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,890
Plugin Contributions:
20

Re: Understanding the Code

Guess I'm a strange duck. All my installation guides are out of the shrink wrap.:D

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com