Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / change the category page

change the category page

Locked

Views: 1,661

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
1 Mar 2007, 10:30 AM
#1
mex avatar

mex

Zen Follower

Join Date:
Feb 2007
Posts:
176
Plugin Contributions:
0

change the category page

hi,

I want to change around the category page i have on my main page on startup.

I have 3 initial level categories eg default hardware,software,dvd

How can i change the display around because i have the files it calls in myoverride. It isn't simple and it calls itself tpl_index_categories without using POST but zen_link (which i don't get).

I want a table display with another section in 1 column and I know php well enough to get the data from mysql but ZC logic is hard to follow..
Where can i get more information on changing the display on main page?

1 Mar 2007, 10:43 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: change the category page

If you look at line 73 of tpl_index_categories.php you'll see that it calls tpl_modules_category_row.php to display the categories content. This in turn calls a common routine tp_columnar_display.php.

As a first step, I would recommend that you create a tpl_modules_category_table.php file that in turn calls tpl_tabular_display.php, and then edit line 73 of your tpl_index_categories.php over-ride to call your new tpl_modules_category_table.php.

1 Mar 2007, 11:56 AM
#3
mex avatar

mex

Zen Follower

Join Date:
Feb 2007
Posts:
176
Plugin Contributions:
0

Re: change the category page

Hi,

I have already done something similar. My problem was not the file management of such a problem but creating my own code to display the data rather than edit the ZC stuff (in those required files). BY creating my own code required me to call again my display categories file with paramters (I use POST) but ZC uses a whole diferent system with zen_link.

Is this too ambitious with ZC ? would I miss out on setting other variables eg session or hiden stuff? do I need to use zen_link for links? If I create display files in the right areas as suggested with my code calling mysql and links using <a ref would this crash the system?

2 Mar 2007, 5:09 AM
#4
mex avatar

mex

Zen Follower

Join Date:
Feb 2007
Posts:
176
Plugin Contributions:
0

Re: change the category page

Ok I can change it from where you said and it seems to work.
This sts the layout as you want exactly and is easy to change the look.

<?php $mpid=$_GET['cPath']; if (!isset($mpid)) $mpid='0'; //calls tpl modules cat row ->category row ->tplcolumnar display $sql2="select categories_name,categories_description.categories_id,categories_image from categories_description,categories where parent_id=$mpid and categories.categories_id= categories_description.categories_id"; $result2 = mysql_query("$sql2") or die("Invalid query: " . mysql_error()); $myrow=0; echo "<h1 id='catheading'>".$breadcrumb->last()."</h1>"; echo "<br><br>  ".$current_categories_description."<br><br>"; echo "<table border='0' cellspacing='0' cellpadding='10' id='cattable'>"; echo "<tr>"; while($nt=mysql_fetch_array($result2)) { //echo "<br><br>"; $name= $nt['categories_name']; $cid= $nt['categories_id']; $cimg= $nt['categories_image']; // $mypath="http://localhost/ecommerce/zen/index.php?main_page=product_info&cPath=1_4&products_id=2"; $mypath="index.php?main_page=index&cPath=".$cid; $imgpath='images/'. $cimg; echo "<td width='80px' align='right'>"; echo "<a href='".$mypath."'> ".$name."</a>"; echo "</td>"; echo "<td width='100px' align='left'>"; echo "<img src='".$imgpath."' />"; echo "</td><td width='40px'></td> "; $myrow++; if ($myrow==2) { echo "</tr>"; $myrow=0; } } echo "</table>"; $sql2="select parent_id from categories where categories_id=$mpid "; // $sql2="select parent_id from categories where categories_id='4'"; $result2 = mysql_query("$sql2") or die("Invalid query: " . mysql_error()); //$name2= $nt['categories_name']; $cid2= mysql_result($result2, 0, "parent_id"); //echo $mpid."...".$cid2; //$num_rows=mysql_num_rows($result); if ($cid2=='0') { $mypath="index.php"; } else $mypath="index.php?main_page=index&cPath=".$cid2; echo "<br><a href='".$mypath."' id='catback'>   Back</a>"; echo "<br>  "; ?>
2 Mar 2007, 9:21 AM
#5
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: change the category page

All credit to you mex for getting something working. I wouldn't personally do it this way, but appreciate the frustrations at trying to get something working using complex and largely undocumented Zen Cart structures and facilities.

To help with your future developments and for others who may be looking at this thread, I would have:1. preserved Zen Cart's layered model by putting the database extracts in the relevant modules/pages/ directory
2. maintained database abstraction by using Zen Cart's database access class
3. used the zen_href_link function (which once understood is both straightforward and powerful as it takes care of a lot of the template and SSL stuff for you)
4. preserved XHTML transitional compliance by using compliant markup
5. not hard-coded in the inline CSS but put it instead into the stylesheet
6. not used a table (personal preference)
But credit to you again for getting this far.

2 Mar 2007, 12:35 PM
#6
mex avatar

mex

Zen Follower

Join Date:
Feb 2007
Posts:
176
Plugin Contributions:
0

Re: change the category page

It was a rush job, and kind of not really zen cart friendly .
Once i get more experience I can then do things are more zen cart way.

Also I think eventually I should put up instructions about integrating an exisiting website or wanting a different look than default layout.
This will take care of the 'why use a ZC shopping cart when they all look the same'.

Not true , as i have found the relelvant files to add your own code to make it look as you want. I can change home page, sidebox,header ,footersub-categories, product list, product info pages, and add your own. I kind of leave the shopping cart area as I don't need to tamper with it.

I think it was you who said try it and see, and I was thinking maybe don't tamper with a default layout other than admin small changes.

I will need a good test of the cart when finished , as it appears to work atm.