PDA

View Full Version : Page outside Squirrelcart


KingRich
May 24th, 2005, 12:07 AM
OK...
I have my store & cart, and everything is working lovely...

But I want to add a few pages like Terms of Sale, FAQ, Contact Us, etc etc...

However, I still want the squirrelcart to function, with the Product catalog, account options, view cart etc on the left side, & breadcrumbs on top, just no products in the middle of the page.

What code will I need to keep the breadcrumbs, left navigation, but not products?

KingRich

The cart is available at: http://www.beautyAndSpaConcepts.com/index2.php
The OTHER page is available at:
http://www.beautyAndSpaConcepts.com/terms.php (Missing the breadcrumbs)

pbxcom
May 24th, 2005, 12:44 PM
You will have to handle this via a dynamic include. In this post http://www.ldev.com/forums/showthread.php?t=1965 I give the exact code and link structure for doing this. You just have to change two things to make additional links work.

One is the link it self has to be modified for each new page. At the end of the link in that post you see a ?page=help added to the normal index.php, all you have to do here is change the "help" to your newpage name. i.e. contact, faq, terms, ect.

Second for those new names to work you have to have them entered in this array
$menu_array = array( "help" , "alink" , "morelinks" );
as you can see there is two junk items in this array just replace them and follow the logic to add more.

After that just make sure that each page has the same name as the items in the array. Example contact is equal to contact.php

As for changing what is in the main content area of the cart this is all controled by one of two thing. The page that is being dynamically included is home.php you could just modify that file. Or you could also change this code

<?
if ($SC['show_home_page']) {
include "home.php";
} else {
?>

in the index.php to call a differnet file instead of home.php

On the mater of missing bread crumb navigation if you use my information above that should solve it but just so you have an understanding of how the cart works here how the bread crumb navigation is called up.

First, at he very top of the index.php you should see something with this code
<? include "squirrelcart/config.php";?>
This obviously impements the your settings in the config.php but if you look at the config.php file it includes a file called cart.php which calls up all the files need to run the Squirrelcart. Now why is that imortant, beacuse without a certain function that is included in the cart.php file this code
<? include "$cart_isp_root/crumb_navigation.php" ?>
which in the index.php file wouldn't work and you can probaly guess what this code does.

KingRich
May 24th, 2005, 02:37 PM
pbxcom... you're not just an ordinary Client are ya?

Anyway... I wanted something I could control from the inside of the shopping cart administration, so this is what I did... It works excellently, but I still want your opinion.

STEP 1.
I created a new box in the Left Navigation container: (I called my new box Miscellaneous)
hxxp://www.YOURSITE.com/squirrelcart/index.php?show_record_links=1&table=Content
STEP 2.
In the content of the box, I added the following code:
<a href="index3.php?page=terms&name=Terms%20and%20Conditions">Terms & Conditions</a><br>
<a href="index3.php?page=privacy&name=Privacy%20Policy">Privacy Policy</a><br>
I am doing 2 things in these links.
1. I am using the same page (index3.php) to include any additional pages using the ?page=PAGENAME. As long as PAGENAME you use is the same as your include file... PAGENAME.php. Example:
page=privacy - I use privacy.php to be included
page=terms - I use terms.php to be included

2. I give it the name I want to be used in the breadcrumbs navigation using the &name=NAME. Example:
If I want my breadcrumbs to read: PRIVACY POLICY I make the value
name=PRIVACY%20POLICY

So the whole Link would now be:
index3.php?page=privacy&name=PRIVACY%20POLICY

(%20 is used to indicate a SPACE)
STEP 3.
Now I created a NEW Breadcrumb file. I loaded the OLD breadcrumb file (crumb_navigation.php), and renamed it (crumb_navigation2.php).
I took out the following code (lines 9-13):
if($show_products_mode == "cat_click") {
$Crumb_Nav = get_crumb_nav($crn,"category");
}
if($action == "show_detail") $Crumb_Nav = get_crumb_nav($rn,"product");
if($Crumb_Nav) print "<div class=\"bread_crumb_nav\">$home_link $sep $Crumb_Nav</div>";
and replaced it with:
if (isset($_GET['name']))
{$name = $_GET['name'];}
print "<div class=\"bread_crumb_nav\">$home_link $sep $name</div>";Remember to NOT save this as the Original Breadcrumb file!

STEP 4.
Now, I take my index.php (or store.php) and rename that to index3.php.
I replace the following code (so you will load the new version of your breadcrumbs):
<? include "$cart_isp_root/crumb_navigation.php" ?>
With this code (use whatever you named your file in Step 3 above)
<? include "$cart_isp_root/crumb_navigation2.php" ?>

STEP 5.
Now, I replace the following code in the same file (index.php or store.php now called index3.php):
<?
// Cart Content section
include "$cart_isp_root/cart_content.php" ;
?>
with THIS code (Courtesy of PBXCom):
<?
if (isset($_GET['page']))
{$page = $_GET['page'];}
include($page . '.php');
?>

DONE!
This will allow me to add pages on the 'fly' so to speak, just add it to the Miscellaneous box, and save the include page. It will also allow me to stay within the Squirrelcart framework.

STEP 6. OPTIONAL!
For the sake of making this complete... I will add a sample PRIVACY POLICY page here. Please save it as privacy.php (or whatever you will name your link in Step 2.):
<table width="100%">
<tr>
<td class="content">
<p align="left"><strong><? print "$name" ?></strong></p>
<p align="left"> <strong>Information We Collect </strong><br>
We recognize your right to confidentiality and are committed to protecting your privacy. We use the information that we collect on our Web sites to provide you with a superior shopping experience and to communicate with you about products, services, and promotions. </p>
</td>
</tr>
</table>
See how the FIRST <P> tag includes the <? print "$name" ?> ? This will automatically take your page name that is also listed in the breadcrumbs. Of course, you do not need this specific information. You can just replace this code with PRIVACY POLICY or whatever text you like.

Now, I am pretty sure, that with some extra code, and handywork, you could just bake this into the original index.php or store.php file, but think it would add more code, and not making it so simple for our fellow n00bs...
Besides, I like keeping these 2 files separate...
Now check out my Privacy Policy etc at: h__p://www.beautyandspaconcepts.com/index3.php?page=privacy&name=Privacy%20Policy

pbxcom
May 24th, 2005, 06:53 PM
Ordinary???

I don't know, define ordinary, if it's not ordinary to like help people in area that I am good at and enjoy doing I would lean towards ordinary as being a bad thing and will gladly take on the title of "not ordinary". But I think that ordinary behavour should be wanting to help people as one is able to. :)

And on to the meat of your post. It will take me a while to full study your post. It appears you have a good grasp of manipulating SquirrelCart. But the first thing I noticed is there may be a security risk in how you are seting up files to be included just making it so that it will include the value of page into the present cart maybe a problem because a good hacker could just retype the link in the address bar to include any file from the server. Here's two post that discuss it in more depth http://www.ldev.com/forums/showthread.php?t=1429 (this is post is from my earlier days in php :doh: ) http://www.ldev.com/forums/showthread.php?t=224 (this one gives more specifics to the problem). From reading in several differnet forums, on the web, the use of an array eliminates the security risk. I included an example of how to use the array with the code I gave you originally, and I stongly encourge you to use it. I will most likely fibnish looking over everything later and post again with my thoughts.

On a side not, it appears that you know how to use the vBulletin icons at the top. The QUOTE works ok for code segment but its easier to read code if you use PHP for all code including standard html. The colors make it a lot easier to read.

harryk
June 27th, 2005, 12:56 AM
Hello,
I followed this link http://www.ldev.com/forums/showthread.php?t=1965 to add links to static text pages. The resulting code looks like this:
<?
$menu_array = array("contact","articles","link");
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
if (in_array("$page", $menu_array)) {
include($page.'.html');
}
else {
include "home.php";
}
if ($SC['show_home_page']) {
include "home.php";
} else {
?>

The links are in the banner area on top of the page.
You can see it at:http://northpoletoyshop.com/store2.php.

If you click on one of my added tabs, it seems to work fine. However, if I try to search ("corolle" as an example), I no longer get results after clicking on one of those links.

The major difference I see here is that I am including to html. Is this causing the problem? Is there something I should be passing along? Does anyone have any other clues I can look into?

If you try the link, be aware that if you click anywhere else, you will be taken to "store.php" instead of "store2.php". "store.php" does not have the changes.

Finally, is there a debugger of some sort for php?

Thanks!

harryk
June 27th, 2005, 11:57 PM
I fixed it.
It seems the lines:
else {
include "home.php";
}

are calling home.php when sometimes they should not be.


Thanks!