phpshop modification help/advice

2 views
Skip to first unread message

Sifu87

unread,
Mar 14, 2009, 6:26:18 PM3/14/09
to phpShop
Hi All

Just finished downloading and installing phpshop and I must say its a
great software! I've managed to implement some of it into my website
but still having a go trying to finish it off. Anyways I was wondering
if you gurus could help me with the rest, I have a few items I still
need to sort out and its listed below;

1. At the top of my page I have a big "header" picture. In this header
picture I have used different "areas" for different links like cart/
log in etc....

Is there a way to make it so that if the user is logged in it will
show one set of header picture and area links and when they're logged
out another??

Ie; Logged In = Header Pic 1 + Link 1, Link 2
Logged Out = Header Pic 2 + Link 3, Link 4

2. There seems to be a issue with the sub category page listing, I was
searching through the old forum and it seemed like there was a few
people with the issue however I cant seem to get forum post messages
to display properly to get the "fix code". Can someone please re-
upload these code if possible? Basically the problem is outline as
follow;

I have say 2 top level categories and 1 sub category. Now when I click
the top level category everything is ok but when I click the sub one
it shows all items, which I suspect is the browse page? How do I go
about fixing it so that it only displays items which are in the sub
category?

3. Is it possible to display a different custom "browsa.ihtml" page
for each category? All items listed in my store are on a sub level
categories, what I want is that when a person clicks on a top level
category it shows a page with a full sized ad and on the left the sub
level menu. They then have to click the sub menu links to go to the
products display page.

4. Lastly how do I go about displaying multiple images on the fly
page? basically I want something similar in the lines of 1 normal
sized picture and multiple thumbnails below it. Clicking on the normal
sized picture would pop up a enlarged view and clicking the thumbnails
will change the normal sized picture and again clicking on that would
bring up an enlarged view.

Also if possible if selecting the different colour in the drop down
menu will automatically change the "group" of images.


Apologies for the long wish list! :D Hopefully most of them has been
done before and not much logic has to be put in place to figure when I
have asked!

Again many thanks!!!

Jeff Newman

unread,
Mar 14, 2009, 7:51:37 PM3/14/09
to php...@googlegroups.com
i'm assuming you are using the 0.8.1 version - if not, then ignore this
post.

1. yes, use the same logic that's used to display either the "Logout" or
"Login" href links. essentially, it checks to see if the PERMS exist or
not. very simple to do - it's around line 59 of the s_header.ihtml template
file.

2. the code i use will show all items in the desired category and all those
below it - drill down approach.

[code]
function get_recursive_categories($category_id) {
$s = "";
$q = "select category_child_id from category_xref where
category_parent_id = '" . $category_id . "' ";
$db = new ps_DB;
$db->query($q);
if ($db->num_rows()) {
while ($db->next_record()) $s .= get_recursive_categories
($db->f("category_child_id"));
}
$s .= "OR (product_category_xref.category_id = '" . $category_id . "' AND
product_category_xref.product_id = product.product_id) ";
return $s;
}

$list = "select * from product, product_category_xref where ";
$count = "select count(*) as num_rows from product, product_category_xref
where ";
$q = "((product_category_xref.category_id = '" . $category_id . "' AND
product_category_xref.product_id = product.product_id) ";
$q .= get_recursive_categories($category_id) . ") ";
$q .= "AND product.product_publish='Y' ";
$list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
$count .= $q;
[/code]

it goes in the "if ($category_id)" section...

3. there is a category_flypage field in the category form - i believe its
supposed to do just this (or pull it in at the top of the page) but i don't
think it's actually implemented. you could just add it as an "include" at
the top of the browse page (as an include, referencing that field contents),
then make sure those pages are created in the shop/html folder.

4. this requires custom fields and code - that option is there now. i
believe i posted something about it in the past. essentially, create X
number of new fields in the product table, then modify the product_form
page, and the ADD/UPDATE functions in the product.inc lib file to reference
those new fields. then find yourself a gallery script that will do your
bidding, and pull from those new fields. i don't have code handy, but i've
done something similar in the past.
--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.237 / Virus Database: 270.11.13/2001 - Release Date: 03/14/09
06:54:00

Sifu87

unread,
Mar 15, 2009, 7:42:36 AM3/15/09
to phpShop
Thanks for the reply Jeff! Sorry to sound like such a dumbass but
would you be willing to post up some of the php code for these
answers? I have never worked with php before, really only html at a
begineer/intermediate level. Anyways to go further with what was
posted above;

1. I tried changing the part what I think is the right one but its
still throwing up an error, this is what I did; I found this part:

<?php
if ($auth["perms"]) {
echo "<A cl

and changed the text after echo "< and put in a normal html image tag
<img src= .. .. . .

Is there anything special I have to do when it is used with php? im
guessing usually just normal php here doesnt work??

2. I think there might be a mix up in the exchange of words here, what
I meant to say was that there seems to be an error in the category
display links as every time I click on the "sub level" category link,
instead of showing me just the products in that category it shows me
every single item in the whole store. Looking back at the old forum
posts it seemed like a few other people had this problem too??

3. I understand that you can use a custom fly page for each category
but what I wanted to know was if it was possible to display a
different "product display" page for each category. As an example
only, on the shirts category page I want to show a large ad only and
customers must click on the sub category found on the menu on the left
to go and actually see the products. I dont want any products to be
displayed in the category page, only shown when the click the sub
category.

4. I have read an earlier post that you posted but as mentioned Im
having a hard time understanding this. If its not a problem can you
please post the php code or even a summarized example up?

Sorry to be a pain in the butt! Love the work everyone has done so far
with this script. Keep it up! Thanks!!!

Jeff Newman

unread,
Mar 16, 2009, 10:42:03 PM3/16/09
to php...@googlegroups.com
i haven't forgotten your request - just a little swamped at the moment.
hopefully, in a day or two i'll be able to find some code that should help
you along. let me know if you resolve some of them on your own.

----- Original Message -----
From: "Sifu87" <tha...@hotmail.com>
To: "phpShop" <php...@googlegroups.com>

Sifu87

unread,
Mar 19, 2009, 6:56:25 AM3/19/09
to phpShop
Hi there jeff, much appreciated if you could do that! Im slowly making
me way through some php tutorial sites an hour or two a day after
work. Would really appreciate it if you code post up the details!

Many thanks

Jeff Newman

unread,
May 19, 2009, 11:27:44 AM5/19/09
to php...@googlegroups.com
without seeing your actual code, i'm going to do a little guessing, but this
should get you started. feel free to ask followup questions.

1. different header image and links based on log in status:

this example is based on the default 0.8.1 s_header file. it will change
the image and links based on login status.

original code
[code]
<table width="100%" height="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="1" valign="top"><table width="100%" border="0"
cellpadding="6" cellspacing="0" class="header">
<tr>
<td align=center><?php echo $vendor_image ?>&nbsp;</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
class="mainmenu">
<tr>
<td align=center><table width="400" border="0" cellpadding="4"
cellspacing="0">
<tr>
<td align="center">&nbsp;&nbsp;<a class="wLink" href="<?php
$sess->purl(URL . "?page=shop/index");?>"><?php echo $home_title ?></a></td>
<td align="center" nowrap="nowrap"><a
class="wLink"href="<?php $sess->purl(URL . "?page=shop/cart");?>"><?php echo
$cart_title ?></a></td>
<td align="center" nowrap="nowrap"><a class="wLink"
href="<?php $sess->purl(SECUREURL . "?page=checkout/index");?>"><?php echo
$checkout_title ?></a></td>
<td align="center" nowrap="nowrap"><?php
if ($auth["perms"]) {
echo "<A class=\"wLink\" HREF=";
$sess->purl(URL . "?page=$modulename/index&func=userLogout");
echo ">$logout_title</A>";
} else {
echo "<A class=\"wLink\" HREF=";
$sess->purl(SECUREURL . "?login=1&$QUERY_STRING");
echo ">$login_title</A>";
} ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
[/code]

could be changed to:
[code]
<table width="100%" height="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="1" valign="top"><table width="100%" border="0"
cellpadding="6" cellspacing="0" class="header">
<tr>
<td align=center>
<?php
if ($auth["perms"]) {
echo $vendor_image; // this is a preformatted IMG html string
created in global.inc
} else {
echo "<img src='images/not_logged_in.jpg' border=0>"; // substitute
your image name here
}
?>&nbsp;
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0"
class="mainmenu">
<tr>
<td align=center><table width="400" border="0" cellpadding="4"
cellspacing="0">
<tr>
<td align="center">&nbsp;&nbsp;<a class="wLink" href="<?php
$sess->purl(URL . "?page=shop/index");?>"><?php echo $home_title ?></a></td>
<td align="center" nowrap="nowrap"><a
class="wLink"href="<?php $sess->purl(URL . "?page=shop/cart");?>"><?php echo
$cart_title ?></a></td>
<td align="center" nowrap="nowrap"><a class="wLink"
href="<?php $sess->purl(SECUREURL . "?page=checkout/index");?>"><?php echo
$checkout_title ?></a></td>
<td align="center" nowrap="nowrap"><?php
if ($auth["perms"]) {
echo "<A class=\"wLink\" HREF=";
$sess->purl(URL . "?page=$modulename/index&func=userLogout");
echo ">$logout_title</A>";
} else {
echo "<A class=\"wLink\" HREF=";
$sess->purl(SECUREURL . "?login=1&$QUERY_STRING");
echo ">$login_title</A>";
} ?>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
[/code]

if you're using image maps, then you won't need the lower PERMS section, but
instead put all your image and mapping informtion in the the top PERMS
section.



2. as soon as you click on any category, you're activating the "browse"
page.

not sure what exact issue you're seeing with the category browse, but there
is an issue with the current category listing method, as it will only show
you the products assigned to a category, and not all the products listed in
sub cats under that category (so if the main cat is empty, but the sub cats
have products, clicking on the main will show you nothing).

i created a revised category product listing that recursively searches the
current category (and sub cats) to pull all the products assigned and
display them - its a drill-down approach. as you click down the
subcategories, you narrow your list of products. it's below.

original code in browse.ihtml (from 0.8.1):
[code]
<?php
$ps_product_category->print_child_list($category_id);
?>
<br />
<?php
$list = "SELECT * FROM product, category, product_category_xref WHERE
";
$count = "SELECT count(*) as num_rows FROM product,
product_category_xref, category WHERE ";
$q = "product_category_xref.category_id='$category_id' ";
$q .= "AND category.category_id=product_category_xref.category_id ";
$q .= "AND product.product_id=product_category_xref.product_id ";
$q .= "AND product.product_parent_id='' ";
$q .= "AND product.product_publish='Y' ";
$q .= "ORDER BY category.category_name ASC";
$list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
$count .= $q;
}
[/code]


change it to:
[code]
<?php
$ps_product_category->print_child_list($category_id);
?>
<p>
<?php
function get_recursive_categories($category_id) {
$s = "";
$q = "select category_child_id from category_xref where
category_parent_id = '" . $category_id . "' ";
$db = new ps_DB;
$db->query($q);
if ($db->num_rows()) {
while ($db->next_record()) $s .= get_recursive_categories
($db->f("category_child_id"));
}
$s .= "OR (product_category_xref.category_id = '" . $category_id . "' AND
product_category_xref.product_id = product.product_id) ";
return $s;
}

$list = "select * from product, product_category_xref where ";
$count = "select count(*) as num_rows from product, product_category_xref
where ";
$q = "((product_category_xref.category_id = '" . $category_id . "' AND
product_category_xref.product_id = product.product_id) ";
$q .= get_recursive_categories($category_id) . ") ";
$q .= "AND product.product_publish='Y' ";
$list .= $q . " LIMIT $offset, " . SEARCH_ROWS;
$count .= $q;
}
[/code]



3. to answer your question about having multiple browse pages (one for each
category) - yes, could be done. you could reuse the category_flypage field
in the category table to enter/store the name of the browse page you'd like
that category to use, then just make sure to update the navigation code
(modify the navigation_list function in ps_product_category and the
s_header/c_header pages) to pull that field and use it in place of the
static browse name.

for example, in the navigation_list function in ps_product_category, change
this line:
[code]
$link .= $sess->url(URL .
"?page=shop/browse&category_id=$category_id");
[/code]

to this:
[code]
$link .= $sess->url(URL .
"?page=shop/" . $db->f("category_flypage") .
"&category_id=$category_id");
[/code]

where you might store the word "browse_a" in that field to reference the
file browse_a.ihtml


4. storing multiple images for a product or category is relatively simple -
just add more fields to the respective tables, then duplicate the code that
allows them to be entered and displayed (entered/updated:
product/product_form and category/category_form, displayed: browse and
flypage). for the "gallery" that you're describing, you'll need to find a
version that you like, and just implement it in the respective pages (they
are generally javascript to prevent page updates from being necessary).
just replace the static SRC images with the images pulled from the database
(that sounds easy, and should be pretty straightforward).

here's a real rough, but working, javascript gallery example.
http://www.newmanit.com/untitled.htm

it's all rollover based, but when you click on the left-hand thumbs, the
bottom thumbs change and stick. roll over the bottom thumbs to update the
main image.

and here's how it might look with the db references pulled in

http://www.newmanit.com/untitled.txt

not tested, but you should be able to see where and how the db references
would be put in instead.

concerning "Also if possible if selecting the different colour in the drop
down menu will automatically change the "group" of images."

i think the above example will do as you were thinking with the function of
the upper thumbnails.

how's that for a stab at what you were asking for?


----- Original Message -----
From: "Sifu87" <tha...@hotmail.com>
To: "phpShop" <php...@googlegroups.com>
Sent: Saturday, March 14, 2009 6:26 PM
Subject: [phpshop] phpshop modification help/advice


>

Sifu87

unread,
May 27, 2009, 9:09:43 AM5/27/09
to phpShop
Hi Jeff

First off I would like to give you a big thanks for taking your
time to help me out with the script! its definitely not going un-
noticed! I've been busy for the past week or so and havent had the
time to try out the scripts yet but will give it a go this weekend and
see how it performs! (which will almost certainly be 100% perfect!)

Again thanks alot! I'll try it when Im free and report back to see how
things are !

CHeers

Jeff Newman

unread,
May 27, 2009, 7:55:50 PM5/27/09
to php...@googlegroups.com
no problem. just let me know.

----- Original Message -----
From: "Sifu87" <tha...@hotmail.com>
To: "phpShop" <php...@googlegroups.com>
Sent: Wednesday, May 27, 2009 9:09 AM
Subject: [phpshop] Re: phpshop modification help/advice


>
--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.40/2135 - Release Date: 05/26/09
08:53:00

Sifu87

unread,
Jun 23, 2009, 4:47:49 AM6/23/09
to phpShop
Sorry for the late reply Jeff!!

I actually tried all the script about 2-3 weeks ago and everything
seems to work well! The image script took a bit of fiddling around
with but now seems perfect.

Two extra questions though if you dont mind?!

No.2 as above, now this works great but the "result" is all scrambled
up. Is there a way to list/order them in say ascending order depending
on what category it is? Right now I have products from different
categories displayed in no particular order or anything and it looks
rather "messy".

Second question, is it possible to have a different "sub menu" based
on what category you're in? I tried adding another field value in the
table called submenu and listing a different ".txt" file for each
category but how do you pull this up? I would like it if possible if
all of a certain "category" in the browse and flypage display an
assigned submenu and all other pages like home, log/in log/out to all
display one submenu if possible?

Thanks

Jeff Newman

unread,
Jun 29, 2009, 7:32:26 AM6/29/09
to php...@googlegroups.com
i just got back into town after a 10 day vacation, so i'll look into this
shortly.

sorry for the delay.

----- Original Message -----
From: "Sifu87" <tha...@hotmail.com>
To: "phpShop" <php...@googlegroups.com>
Version: 8.5.339 / Virus Database: 270.12.94/2207 - Release Date: 06/28/09
17:54:00

Reply all
Reply to author
Forward
0 new messages