Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-04-2004, 05:16 PM   PM User | #1
akumanz
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
akumanz is an unknown quantity at this point
Question editing a script

Heya.

Atm I'm running a site selling comp products and stuff right.

Basically I'm trying to make it so I can like edit the products through admin rather than editing the page for the listing of products.

I found this script and dloaded the free version. Fulls like $300 -_-!!

http://www.siliconsys.com/content/ap...ns/phpcatalog/

Only problem is I can't get the products onto the next line! Like I can list the products going down the page but if I want to list them like this the | | on the sides represent the visible page limit ->

| product - product - product - product |
| product - product - product - product |
| product - product - product - product |

Thats how I wanna list them but I can't because in the template file you can only specify the layout of one product listing and it then repeats that for as many products as you specify per the page.

Like in the template file it has {product_img} {product_price} & {product_name} If I could just specify like {product_img_1} etc I could then create one template file with like 5 column table and put the product_1 etc in each field to achieve the above thing.

Problem is I don't really know php/mysql which is what the scripts based on -_- Just wondering if anyone is able to edit it to achieve this????

Thanks.
akumanz is offline   Reply With Quote
Old 06-04-2004, 05:19 PM   PM User | #2
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 528
Thanks: 8
Thanked 8 Times in 8 Posts
Taylor_1978 is on a distinguished road
In other words you want someone to do the work for you? LOL

Wouldn't this be the perfect time for you to learn PHP?
Taylor_1978 is offline   Reply With Quote
Old 06-04-2004, 05:20 PM   PM User | #3
akumanz
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
akumanz is an unknown quantity at this point
hmm yea but I sorta needa do this soon lol.

else if you know a script that can split into columns please do mention.

cheers.
akumanz is offline   Reply With Quote
Old 06-04-2004, 05:23 PM   PM User | #4
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 528
Thanks: 8
Thanked 8 Times in 8 Posts
Taylor_1978 is on a distinguished road
I need many things done soon lol...

The problem is, what is requird here is for someone to download the program you require and change it... What I would suggest is copying and pasting the template script here so that we can look at it and suggest changes.

:-)
Taylor_1978 is offline   Reply With Quote
Old 06-04-2004, 05:25 PM   PM User | #5
akumanz
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
akumanz is an unknown quantity at this point
Post

Oh yea sure lol.

Code:
<!-- START list --> 
<table cellpadding="0" cellspacing="0" border="0" width="100%"> 
{search_msg} 


<tr> 
<!-- BEGIN row --> 
<td width="100%" align="center"> 

<table cellpadding="0" cellspacing="0" width="100%"><tr> 
<td align="center" valign="center" height="166" width="200"> 
<img src="{thumb_path}" title="{product_name}" align="middle" border="1">&nbsp;&nbsp; 
</td></tr> 

<tr background="images/newbg2.jpg"><td background="images/newbg2.jpg"> 

<table cellpadding="0" cellspacing="0" border="0" width="100%" background="images/newbg2.jpg" style="border-top:1px #000000 solid;border-bottom:1px #000000 solid;border-right:0px #000000 solid;border-left:0px #000000 solid;"> 
<tr background="images/newbg2.jpg"><td class="listvalue" background="images/newbg2.jpg" valign="top" align="center" height="36" width="100%"><b>{product_name}<br>{f_product_price}</b></td></tr> 
</table> 

</td></tr> 

</table></td> 
<!-- END row --> 
<tr></table> 
</tr> 


</table> 
<!-- FINISH list -->

Last edited by akumanz; 06-04-2004 at 05:29 PM..
akumanz is offline   Reply With Quote
Old 06-04-2004, 05:35 PM   PM User | #6
Taylor_1978
Regular Coder

 
Join Date: Jun 2003
Location: Australia
Posts: 528
Thanks: 8
Thanked 8 Times in 8 Posts
Taylor_1978 is on a distinguished road
Ummm... Need the php script that calls for this template page as well.
Taylor_1978 is offline   Reply With Quote
Old 06-04-2004, 05:37 PM   PM User | #7
akumanz
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
akumanz is an unknown quantity at this point
Post

K but it's pretty long -> this is the code for index.php. Theres only one main central page in the script along with others for templates and other stuff but I'm pretty sure this is is the one you're after.

Code:
<?php
/*
**	$Id: index.php,v 1.3 2003/09/16 20:31:48 damonp Exp $
**
** Copyright (C) 2002 siliconsys.com <dev@siliconsys.com>
** See LICENSE file in root directory of this installation for
** licensing information.
*/

	require_once('./include/config.inc');

 	$cat_id 			= passed_var('cat_id', 'get', 'integer');
 	$catalog_id		= passed_var('catalog_id', 'both', 'integer');

	$category = isset($sel_category) ? $sel_category:'%';
	$_SESSION['category'] = $category;
	$d_category = $category == '%' ? 'All Categories':$category;
	$cat_id = $sel_category == '' ? $cat_id:$sel_category;

	if(isset($cat_id)) $cat = get_category_name($cat_id);
	set_default($CFG->tmpl_header, $CFG->libdir . '/template/header.inc');
	set_default($CFG->tmpl_footer, $CFG->libdir . '/template/footer.inc');
	set_default($CFG->tmpl_prev_next, $CFG->libdir . '/template/tmpl.prev_next.inc');
	set_default($CFG->tmpl_detail, 'tmpl.detail.inc');
	set_default($CFG->tmpl_image_view, 'tmpl.image_view.inc');
	set_default($CFG->tmpl_list, 'tmpl.list.inc');
	set_default($CFG->tmpl_page, 'tmpl.page.inc');

	$T->set_file('page', $CFG->tmpl_page);

	$CFG->color_tbl1	= '#cccccc';
	$CFG->color_tbl2	= '#eeeeee';

	$T->set_var(array(
							  	'me'			=>	me(),
								'base'		=> $CFG->wwwroot,
								'currency'	=> $_SESSION['config']['currency_sym'],
								'category'	=> $d_category,
								'select_category'	=> select_category($cat_id, true)));

	if($id != '' && $function == '') $function = 'detail';
	elseif(($cat_id != '' || $start != '' || $query != '') && $function == '') $function = 'list';

	if($_SESSION['config']['catalog_name'] == '')	throw_error('internal configuration error, rebuild config table');

/*****************************
 * main
 ****************************/
	include($CFG->tmpl_header);
	switch($function) {
/****************
 * detail
 ***************/
		case('detail'):
			$CFG->dbh->Query("SELECT phpc.*, cat.category_name AS product_category
									FROM $CFG->phpc_table AS phpc
									LEFT JOIN phpcatalog_categories AS cat USING (category_id)
									WHERE product_id = '$id'");
			if($CFG->dbh->RowCount > 0) {
				$T->set_file('content', $CFG->tmpl_detail);
				$r	= $CFG->dbh->FetchObject('', 1);
				format_product_row($T, $r, $function);
				$T->set_var(array(
										'bottom'	=> "<tr height=\"70\"><td colspan=\"2\" align=\"center\" valign=\"bottom\"><a href=\"javascript:history.go(-1)\" class=\"bold\">back</a></td></tr>\n",
										'select_category'	=> select_category($r->category_id, true)));
				stats_log_hit($id);
			}	else {
				$T->set_var('content', 'Item not found');
			}
			break;
/****************
 * image_view
 ***************/
		case('image_view'):
			$T->set_file('content', $CFG->tmpl_image_view);
			$T->set_var('bottom', "<tr height=\"70\"><td colspan=\"2\" align=\"center\" valign=\"bottom\"><a href=\"javascript:history.go(-1)\" class=\"bold\">back</a></td></tr>\n");
			$CFG->dbh->Query("SELECT image_path
									FROM $CFG->phpc_table
									WHERE product_id = '$id'");
			$r = $CFG->dbh->FetchObject();
			$T->set_var('image_path', $r->image_path);
			break;
/****************
 * list
 ***************/
		case('list'):
			$T->set_file('content', $CFG->tmpl_list);
			catalog_list($query, $start, $cat_id);

			if($show_msg) {
				$T->set_var('msg', $msg);
				$T->parse('msg', 'msg');
			}
			$T->set_var('pagetitle', $d_category);
			break;
/****************
 * price
 ***************/
		case('price'):
			$T->set_file('content', $CFG->tmpl_price);
			catalog_list($query, $start, $cat_id);

			if($show_msg) {
				$T->set_var('msg', $msg);
				$T->parse('msg', 'msg');
			}
			$T->set_var('pagetitle', $d_category);
			break;
/****************
 * image
 ***************/
		case('image'):
			$T->set_file('content', $CFG->tmpl_image);
			catalog_list($query, $start, $cat_id);

			if($show_msg) {
				$T->set_var('msg', $msg);
				$T->parse('msg', 'msg');
			}
			$T->set_var('pagetitle', $d_category);
			break;
/****************
 * index
 ***************/
		default:
			$T->set_file('page', $CFG->tmpl_page);
			$T->set_file('content', 'tmpl.index.inc');
			$T->set_var('pagetitle', '');
			break;
	}

	push_template();
	include($CFG->tmpl_footer);

/*****************************
 * functions
 ****************************/
	function catalog_list($query, $start, $cat_id) {
		global $CFG, $T;

		set_default($start, 0);
		$num_items_page = $_SESSION['config']['num_items_page'] != '' ? $_SESSION['config']['num_items_page']:10;
		$db_cat_id = $cat_id == '' ? '%':$cat_id;
		if($query != '') {
			$msg = "<tr><td colspan=\"6\" height=\"30\" valign=\"top\">Searching for &lt;<b>$query</b>&gt; returned ";
			$search_string = '%' . $query . '%';
			$like 		= $CFG->dbh->Ident() == "DBI_PG" ? "ILIKE":"LIKE";
			$db_query 	= "AND (product_name $like '$search_string'";
			$db_query 	.= " OR product_sku $like '$search_string'";
			$db_query 	.= " OR product_desc $like '$search_string')";
			$show_msg 	= true;
			$db_limit 	= '';
		}	else {
			$db_limit = ($CFG->dbh->Ident() == "DBI_PG") ? $num_items_page. ", $start":"$start, " . $num_items_page;
			$db_limit = "LIMIT $db_limit";
			$db_query = '';
		}

		$CFG->dbh->Query("SELECT count(product_id) as num_rows
								FROM $CFG->phpc_table as phpc
								LEFT JOIN phpcatalog_categories as cat USING(category_id)
								WHERE cat.catalog_id = $CFG->catalog_id
									AND phpc.category_id LIKE '$db_cat_id'
									$db_query
								ORDER	BY	product_name ASC",
								__FILE__, __LINE__);

		$r = $CFG->dbh->FetchObject('', 1);
		$num_items	= $r->num_rows;
		set_default_null($num_items, 0);
		$num_pages = ceil($num_items / $num_items_page);

		if(isset($msg)) {
			$product = $num_items > 1 ? 'products':'product';
			$msg .= "$num_items $product.</td></tr>";
		}

		$T->set_block('content', 'row', 'rows');
		if($num_items > 0) {
			$CFG->dbh->Query("SELECT *
									FROM $CFG->phpc_table as phpc
									LEFT JOIN phpcatalog_categories as cat USING(category_id)
									WHERE cat.catalog_id = $CFG->catalog_id
										AND phpc.category_id LIKE '$db_cat_id'
										$db_query
									ORDER	BY	product_name ASC
									$db_limit",
									__FILE__, __LINE__);

			while($r	= $CFG->dbh->FetchObject()) {
				format_product_row($T, $r, 'list');
				$T->parse('rows', 'row', true);
			}
			if(isset($msg))
				$T->set_var('search_msg', $msg);
			if($num_items > $num_items_page && $query == '')
				show_prev_next($num_items, $num_pages, $start, $db_cat_id);
		}	else {
			$T->set_var('rows', '<tr><td align="center">No Products Found</td></tr>');
			$T->implodeBlock('row');
		}
	}


	function show_prev_next($num_items, $num_pages, $start, $category) {
		global $CFG, $T;

		$T->set_file('bottom', $CFG->tmpl_prev_next);
		$category = ($category == '' || $category == '%') ? '':"cat_id=$category&";
		$num_items_page = $_SESSION['config']['num_items_page'] != '' ? $_SESSION['config']['num_items_page']:10;
		if($start >	0) {
			$prev = "<a href=\"./?".$category."start=" . ($start - $num_items_page) . "\">&lt;prev</a> | ";
		}	else $prev = "&lt;prev | ";
		$i	= 0;
		while($i	< $num_pages) {
			$page	= $i * $num_items_page;
			$i++;
			if($page	!=	$start) {
				$pages .= "<a href=\"./?".$category."start=$page\">$i</a> | \n";
			}	else $pages .= "<b>$i</b> | \n";
		}
		if($start <	(($num_pages - 1) * $num_items_page)) {
			$next .= "<a href=\"./?".$category."start=" . ($start + $num_items_page) . "\">next&gt;</a>";
		}	else $next .= "next&gt;";
		$T->set_var(array(
							'prev' => $prev,
							'next' => $next,
							'pages'=> $pages));
		array_push($CFG->page_arr, 'bottom');
	}
?>
akumanz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:56 AM.


Advertisement
Log in to turn off these ads.