I have this site and I want to put some in header for SEO purposes. The H1 must contain manufacturer name (brand) and product code (model).
So the problem is that I'm not sure how to put this variables in controller's file so I could call them in template file next.
Any ideas? :)
The best way around this would be to edit the product controller
catalog/controller/product/product.php
and change the heading there. It's set with
$this->document->setTitle($product_info['name']);
so you just need to prepend/append the manufacturer name there, such as
$this->document->setTitle($product_info['name'] . ' ' . $product_info['manufacturer']);
Did it! Added this code to controller/common/header.php
if (isset($this->request->get['product_id'])) {
$product_id = $this->request->get['product_id'];
} else {
$product_id = 0;
}
$this->load->model('catalog/product');
$product_info = $this->model_catalog_product->getProduct($product_id);
$this->data['product_info'] = $product_info;
if ($product_info) {
$this->data['manufacturer'] = $product_info['manufacturer'];
$this->data['model'] = $product_info['model'];
}
And this to theme/default/template/common/header.tpl
<?php echo $product_info['manufacturer']; ?> <?php echo $product_info['model']; ?>
Related
Good day. Please help me to display units of measurement for goods. OcStore 2.3 engine.
By default, units of measurement are not displayed next to the product, they helped me to display them on the product page in this way:
In
catalog/model/catalog/product.php
Find line:
public function getProduct($product_id) {
Before the line mentioned above add the following code:
public function getProductWeightWithUnit($product_id) {
$product_info = $this->getProduct($product_id);
$query = $this->db->query("SELECT unit FROM `" . DB_PREFIX . "weight_class_description` WHERE
weight_class_id='".$product_info['weight_class_id']."'");
if ($query->num_rows) {
return number_format($product_info['weight'],2) . " " . $query->row['unit'];
} else {
return false;
}
}
Save changes and close the file.
Now, open file
catalog/controller/product/product.php
Find line:
if ($product_info['minimum']) {
Before the line mentioned above add the following code:
if ($product_info['weight']) {
$data['weight'] = $this->model_catalog_product->getProductWeightWithUnit($this->request->get['product_id']);
} else {
$data['weight'] = false;
}
Now, the backend code is ready. Based on the theme that you use, you need to edit the correct product.tpl file from your theme. For example if you use the default theme, then the file to edit is the following:
catalog/view/theme/default/template/product/product.tpl
Find the line:
<li><?php echo $text_stock; ?> <?php echo $stock; ?></li>
and add the following code after:
<li><?php echo $weight; ?></li>
Fine! Everything works on the product page. But you need it to work the same in modules (for example Featured Products).
I do all the same steps for the module
Backend:
catalog/controller/extension/module/featured.php
and front end:
catalog/view/theme/default/template/extension/module/featured.tpl
But I get the error:
Notice: Undefined index: product_id in C:\OSPanel\domains\mywebsite.com\catalog\controller\extension\module\featured.php on line 43
That's what it says:
if ($product_info['weight']) {
LINE 43 $data['weight'] = $this->model_catalog_product->getProductWeightWithUnit($this->request->get['product_id']);
} else {
$data['weight'] = false;
}
Why not seen product_id in ??
Open catalog/controller/extension/module/featured.php.
Find
if ($this->config->get('config_tax')) {
Add before
if ($product_info['weight']) {
$weight = $this->model_catalog_product->getProductWeightWithUnit($product_info['product_id']);
} else {
$weight = false;
}
Basically, here I've replaced $this->request->get['product_id'] with $product_info['product_id'], like #K.B. said in his answer, but made more accurate example.
Then, in the same file find
'tax' => $tax,
Add after
'weight' => $weight,
Now go to catalog/view/theme/default/template/extension/module/featured.tpl
Find
<?php if ($product['tax']) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
Add after
<?php if ($product['weight']) { ?>
<span><?php echo $product['weight']; ?></span>
<?php } ?>
You must use $product_info['product_id'] or just $product_id instead $this->request->get['product_id'] Because you can't get product_id's for several products using this expression, which are in this loop foreach ($products as $product_id) {
I have a sidebar menu on a WordPress site that simply outputs all the child pages under that parent. I'm trying to highlight (or hopefully add an arrow) the current child page that is selected. I've run into a wall with my limited PHP experience to figure out how to do that.
Any help would be greatly appreciated. The relevant code is below:
<?php
/* if the current pages has a parent, i.e. we are on a subpage */
if($post->post_parent){
/* $children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); // list the parent page */
$children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); // append the list of children pages to the same $children variable
}
/* else if the current page does not have a parent, i.e. this is a top level page */
else {
//$children = wp_list_pages("title_li=&include=".$post->ID."&echo=0"); // include the parent page as well
$children .= wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&"); // form a list of the children of the current page
}
/* if we ended up with any pages from the queries above */
if ($children) { ?>
<ul class="submenu">
<?php echo $children; /*print list of pages*/ ?>
</ul>
<?php } ?>
I'm assuming it would be in the output section, but I simply don't know how to target the current child page that's being browsed and highlight that accordingly.
I had a little fun with this one. And my result might not be exactly what you were looking for, but I think it might be better. In short, the below snippet allows you to easily identify the page hierarchy (parent/children) for the current page. As such, you can then do all sorts of wonderful things to your heart's desire. For the purposes of your specific request, I made the custom function "custom_list_child_pages(...)" return a full list of links from the page hierarchy related to the "current page".
There is tons of logic, all related to the key situations you were trying to tackle. You should be able to identify when you are in a sub-page or parent page, you should be able to call out that little function and modify it to make it do whatever you need it to do with all the relevant players (current, parent [or self if no other], child pages, etc).
Let me know if this helps you and if you get stuck with the code or any other aspects regarding what you are trying to achieve let me know as well and I will see how I can assist you further.
Code:
<?php
//die(var_dump($foo)); // Quickly check a variable value.
function custom_list_child_pages($the_current_page_id, $the_parent_page_id, $child_pages){
$html_page_listing = '';
// Get creative with the parent page.
$the_parent_page = get_page( $the_parent_page_id );
$html_page_listing .= "<h3>" . "<a href='$the_parent_page->guid'>$the_parent_page->post_title</a>" . "</h3>";
// Get creative with the child pages.
$html_page_listing .= "<h3>" . "Child pages:" . "</h3>";
$html_page_listing .= "<ul>";
// Iterate through child pages as desired.
foreach ($child_pages as $key => $page) {
$current_page = get_page_by_title( $page->post_title );
$current_page_id = $page->ID;
if ($current_page_id == $the_current_page_id) {
// Do something great.
$html_page_listing .= "<li> ->" . "<a href='$page->guid'>$page->post_title</a>" . "</li>";
} else {
$html_page_listing .= "<li>" . "<a href='$page->guid'>$page->post_title</a>" . "</li>";
}
}
$html_page_listing .= "</ul>";
return $html_page_listing;
}
global $post; // If outside the loop.
// Set up the objects needed.
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => '-1'));
if ( is_page() && $post->post_parent ) {
// This is a subpage.
$the_current_page_id = $page_id;
$the_parent_page_id = wp_get_post_parent_id( $post_ID );
$the_child_pages = get_page_children( $the_parent_page_id, $all_wp_pages ); // Form a list of the children of the current page.
$the_parent_page_id = wp_get_post_parent_id( $post_ID ); // Include the parent page as well.
$menu = custom_list_child_pages($the_current_page_id, $the_parent_page_id, $the_child_pages); // ~append the list of children pages to the same $children variable
echo $menu; // Print list of pages.
} else {
// This is not a subpage.
$the_current_page_id = $page_id;
$the_parent_page_id = $page_id;
$the_child_pages = get_page_children( $page_id, $all_wp_pages ); // Form a list of the children of the current page.
$the_parent_page_id = $page_id; // Include the parent page as well.
$menu = custom_list_child_pages($the_current_page_id, $the_parent_page_id, $the_child_pages);
echo $menu; // Print list of pages.
}
?>
Regards,
Arty
In my Magento store I have added downloadable products and if user want to download this product user need to subscribe our newsletter. for that I have added newsletter subscriber block in view.phtml file.code is below.
<?php $download = Mage::registry('current_product')->getTypeId();?>
<?php
if($download == 'downloadable')
{ ?>
<div class="pop-upss">
<input type="button" onclick="showMrnlePopup();" value="To Download This Product You Need To Subscribe Our Newsletter" name="submit"/>
</div>
<?php } ?>
so I have set onclick function and when user will click on this button newsletter pop-up will open.
in newsletter PHTML file I get current product's id using below code
<input type="hidden" name="pro_id" value="<?php echo Mage::registry('current_product')->getId();?>">
ok now we go to SubscriberController.php file and it's newAction(). I get current product id in newAction() using below code.
$product_id = $this->getRequest()->getPost('pro_id');
Now what I want using this product Id is :
1). I want all data about current product. -> I got this is using below code :
if($product_id) {
$obj = Mage::getModel('catalog/product');
$_product = $obj->load($product_id);
echo '<pre>';
print_r($_product->getData());
die;
}
2). if this product is downloadable then I want it's sample data and it's link to download product but I can not get current product's download link.my code for get download link is below.
if($_product->hasSamples()) {
$_samples = $this->getSamples();
foreach ($_samples as $_sample){
echo $samplePath = $_sample->getBasePath();
echo $sampleFile = $_sample->getSampleFile();
}
} else {
echo 'not getting anything here...';
}
when I run above code it's go into else part and echo 'not getting anything here...'.
so please anyone who know that how can I get downloadable product link please help me.
Thanks.
Getting these links is a bit complicated. I prepared a little snippet how to get the sample files and the normal links.
public function indexAction()
{
$product_id = $this->getRequest()->getPost('pro_id');
if($product_id) {
/** #var Mage_Catalog_Model_Product $product */
$product = Mage::getModel('catalog/product')->load($product_id);
if($product->getTypeId() == 'downloadable') {
/** #var Mage_Downloadable_Model_Resource_Sample_Collection $samples */
$samples = Mage::getModel('downloadable/sample')->getCollection()->addProductToFilter($product_id);
if($samples->count() > 0) {
foreach($samples as $sample) {
/** #var Mage_Downloadable_Model_Sample $sample */
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'downloadable/files/samples' . $sample->getSampleFile();
echo 'Sample URL: ' . $url . "<br>";
}
}
/** #var Mage_Downloadable_Model_Resource_Link_Collection $links */
$links = Mage::getModel('downloadable/link')->getCollection()->addProductToFilter($product);
if($links->count() > 0) {
foreach($links as $link) {
/** #var Mage_Downloadable_Model_Link $link */
$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'downloadable/files/links' . $link->getLinkFile();
echo 'Link URL: ' . $url;
}
}
}
}
}
You need to load collections of downloadable/sample and downloadable/link and pass a product model or a product id to it. That's the Magento way ;-)
I've just build shopping cart here
The add to cart button work perfectly adding the product to the cart without refreshing the entire page.
My question is, how to make the basket update the content after hit the add to cart link without refresh the pages
I have code to handle adding a product to the cart and to show the cart content.
<?php
if($what=="addtocart")
{
if ($cart)
{
$cart .= ','.$_GET['product_id'];
}
else
{
$cart = $_GET['product_id'];
}
$_SESSION['cart'] = $cart;
}
echo writeShoppingCart();
?>
and here are the writeShoppingCart() function
function writeShoppingCart() {
$cart = $_SESSION['cart'];
if (!$cart) {
return '<p>You have no items in your shopping cart</p>';
} else {
echo "<table class=table cellpadding=5 cellspacing=0 width=87% border=0>";
echo "<tr class=bold>";
echo "<td width=65>ID Product</td>";
echo "<td>Pattern</td>";
echo "<td>Inst Type</td>";
echo "</tr>";
include "config.php";
global $dbhost,$dbusername,$dbpassword;
$id_mysql = mysql_pconnect($dbhost,$dbusername,$dbpassword);
mysql_select_db($dbname, $id_mysql);
$cart = $_SESSION['cart'];
$items = explode(',',$cart);
$contents = array();
foreach ($items as $item) {
$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
}
foreach ($contents as $id=>$qty) {
$view2 = "SELECT * FROM $table_product WHERE id='$id'";
$result2 = mysql_query($view2);
while
($baris=mysql_fetch_row($result2))
{
echo "<tr>";
echo "<td>$baris[1]</td>";
echo "<td>$baris[2]</td>";
echo "<td>$baris[3]</td>";
echo "</tr>";
}
}
echo "</table>";
echo "<span class=\"go_cart\">ยป View Complete Basket</span>";
}
}
is there any clue to make the echo writeShoppingCart(); reload after adding a product to the cart?
you forgot to add session_start() after opening your <?php tag
so I think you're referencing an empty variable when you do this: $_SESSION['cart'] = $cart;
$_SESSION['cart'] stays empty
to use the session variable you ALWAYS have to put session_start right at the top of the page;
<?php session_start();
//your stuff here
?>
I just checked your page out now and I noticed you're working within wordpress, wordpress doesn't support using session variables, so you'll have to look for the page in your theme that receives first control, it's usually the header.php inside your theme directory: /yourroot/wp-content/themes/yourthemename/header.php, you'll have to add the code above right at the top of that page.
also: I alerted the resp returned from the "add-link" and it returns an entire webpage, the php script you call should be outside of wordpress, prefereably in a file you access directly, so that when the result is returned you have only the output of the function you're echo-ing
Please comment if you're still having errors
//code to dynamically change item table;
$(document).ready(function(){
$('a#add-link').bind("click", function(event) {
event.preventDefault();
var url = $(this).attr("href");
$.get(url, function (resp) {
jAlert('Product Has Been Added to Shopping Cart');
//to do the following you have to put your shoppingcart table in a div with the id="shoppingcart"
$("#shoppingcart").html(resp)
});
});
});
PS: because I think you'll forget about this since I'm doing all your code for you.
right now your post page: "http://ksul.kittenpile.com/product.php" is return an entire webpage, which you will notice if you add the line alert(resp); above your jAlert() function.
It shouldn't return an entire webpage, so it shouldn't be printed to the browser the same way your other pages are printed! only the result of writeShoppingCart() should be echoed and NOTHING ELSE!
I'm trying to create a website that allows for easy theme adding/manipulation like wordpress and other CMS systems do. To do this I'd like to make it so the theme file that delivers the content uses as little php code as possible. At the moment this is the (extremely simplified) class
class getparents {
var $parentsarray;
function get_parents() {
$this->parentsarray = array();
$this->parentsarray[] = array('Parent0',3,1);
$this->parentsarray[] = array('Parent1',8,2);
$this->parentsarray[] = array('Parent2',2,3);
return $this->parentsarray;
}
}
And retrieving it like this:
$parents = new getparents();
?><table><?php
foreach($parents->get_parents() as $rowtable)
{
echo "<tr><td>$rowtable[0] has category ID $rowtable[1] and is on level $rowtable[2] </td></tr>";
}
?></table><?php
But I want to make the retrieving more like this:
<table>
<tr><td><?php echo $cat_title; ?> has category ID <?php echo $cat_id; ?> and is on level <?php echo $cat_level; ?> </td></tr>
</table>
Which basically mean the class would just return the value in an understandable way and automatically keep on looping without the user having to add *foreach($parents->get_parents() as $rowtable)* or something similar in their theme file.
Here's an example wordpress page to (hopefully) illustrate what I mean. This page retrieves all posts for the current wordpress category which is what I'm trying to mimic in my script, but instead of retrieving posts I want to retrieve the category's parents, but I don't think it's important to explain that in detail.
<?php
/**
* The template for displaying Category Archive pages.
*
* #package WordPress
* #subpackage Twenty_Ten
* #since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<h1 class="page-title"><?php
printf( __( 'Category Archives: %s', 'twentyten' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>
<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="archive-meta">' . $category_description . '</div>';
/* Run the loop for the category page to output the posts.
* If you want to overload this in a child theme then include a file
* called loop-category.php and that will be used instead.
*/
get_template_part( 'loop', 'category' );
?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Note: My actual question doesn't have anything to do with wordpress at all so I didn't add it as a tag.
UPDATE: I think my question may have been unclear. Here's a messy example (that works nevertheless)
index.php
<?php
include_once("class.php");
include_once("config.php");
if(isset($_GET['catid']))
{
$getproducts = new getproducts($_GET['catid']);
$catproductsarray = $getproducts->getarray();
$indexxx = 0;
foreach($catproductsarray as $rowtable)
{
include("templates/$template/all_products.php");
$indexxx++;
}
}
class.php
class getproducts {
var $thearrayset = array();
public function __construct($indexx) {
$this->thearrayset = $this->makearray($indexx);
}
public function get_id($indexxx) {
echo $this->thearrayset[$indexxx]['id'];
}
public function get_catID($indexxx) {
echo $this->thearrayset[$indexxx]['catID'];
}
public function get_product($indexxx) {
echo $this->thearrayset[$indexxx]['name'];
}
public function makearray($indexx) {
$thearray = array();
if(!is_numeric($indexx)){ die("That's not a number, catid."); };
$resulttable = mysql_query("SELECT * FROM products WHERE catID=$indexx");
while($rowtable = mysql_fetch_array($resulttable)){
$thearray[] = $rowtable;
}
return $thearray;
}
public function getarray() {
return $this->thearrayset;
}
}
templates/default/all_products.php
<!-- The below code will repeat itself for every product found -->
<table>
<tr><td><?php $getproducts->get_id($indexxx); ?> </td><td> <?php $getproducts->get_catID($indexxx); ?> </td><td> <?php $getproducts->get_product($indexxx); ?> </td></tr>
</table>
So basically, index.php gets loaded by user after which the amount of products in mysql database is taken from the class. For every product, all_products.php gets called with $indexxx upped by one.
Now the only thing the user has to do is edit the HTML all_products.php and the products will all be displayed differently. This is what I'm going for, but in a clean, responsible way. Not like this, this is a mess!
UPDATE2: I found a better way to do it, but added it as an answer. Seemed more fitting and pevents this question from getting any longer/messyer than it already is.
Ok I'm getting a little bit closer to what I want, so I'm adding this as an answer.
The template:
<?php include("templates/$template/header.php"); ?>
<!-- [product][description][maxchars=##80##][append=##...##] -->
<!-- [categories][parents][name][append= ->] --><!-- maxchars=false means dont cut description -->
<!-- [categories][children][prepend=nothing] --><!-- prepend=nothing means no prepend -->
<div id="middle-left-section">
<table>
{start-loop-categories-parents}
<tr><td><!-- [categories][parents][name] --></td><td>
{end-loop-categories-parents}
</table>
<table>
<tr><td><!-- [categories][current] --></tr></td>
{start-loop-categories}
<tr><td> <!-- [categories][children] --></td><td>
{end-loop-categories}
</table>
</div>
<div id="middle-right-section">
<table id="hor-minimalist-a">
<thead>
<th scope="col"> </th>
<th scope="col">Name</th>
<th scope="col" width="200px">Description</th>
<th scope="col">Price</th>
</thead>
<tbody>
{start-loop-product}
<tr><td><img src="fotos/<!-- [product][thumb] -->"></img></td><td><!-- [product][name] --></td><td><!-- [product][description] --></td><td><!-- [product][price] --></td></tr>
{end-loop-product}
</tbody>
</table>
</div>
<div style="clear: both;"/>
</div>
<?php include("templates/$template/footer.php"); ?>
The class:
<?php
///////////////////////////
//Includes and functions//
/////////////////////////
include_once("config.php");
include_once("includesandfunctions.php");
function get_between($input, $start, $end)
{
$substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1));
return $substr;
}
function get_between_keepall($input, $start, $end)
{
$substr = substr($input, strlen($start)+strpos($input, $start), (strlen($input) - strpos($input, $end))*(-1));
return $start.$substr.$end;
}
class listproducts {
var $thearrayset = array();
var $file;
var $fp;
var $text;
var $products;
var $productskeepall;
var $done;
var $returnthisloopdone;
public function __construct() {
global $template;
//Get items from mysql database and put in array
$this->thearrayset = $this->makearray();
//Read file
$this->file = "templates/$template/all_products.php";
$this->fp = fopen($this->file,"r");
$this->text = fread($this->fp,filesize($this->file));
//Set other vars
$this->products = '';
$this->productskeepall = '';
$this->returnthisloopdone = '';
$this->done = ''; //Start $done empty
}
public function makearray() {
$thearray = array();
$resulttable = mysql_query("SELECT * FROM products");
while($rowtable = mysql_fetch_array($resulttable)){
$thearray[] = $rowtable; //All items from database to array
}
return $thearray;
}
public function getthumb($indexxx) {
$resulttable = mysql_query("SELECT name FROM mainfoto where productID=$indexxx");
while($rowtable = mysql_fetch_array($resulttable)){
return $rowtable['name']; //Get picture filename that belongs to requested product ID
}
}
public function listproduct()
{
global $template;
$this->products = get_between($this->done,"{start-loop-product}","{end-loop-product}"); //Retrieve what's between starting brackets and ending brackets and cuts out the brackets
$this->productskeepall = get_between_keepall($this->done,"{start-loop-product}","{end-loop-product}"); //Retrieve what's between starting brackets and ending brackets and keeps the brackets intact
$this->returnthisloopdone = ''; //Make loop empty in case it's set elsewhere
for ($indexxx = 0; $indexxx <= count($this->thearrayset) - 1; $indexxx++) //Loop through items in array, for each item replace the HTML comments with the values in the array
{
$this->returnthis = $this->products;
$this->returnthis = str_replace("<!-- [product][thumb] -->", $this->getthumb($this->thearrayset[$indexxx]['id']), $this->returnthis);
$this->returnthis = str_replace("<!-- [product][catid] -->", $this->thearrayset[$indexxx]['catID'], $this->returnthis);
$this->returnthis = str_replace("<!-- [product][name] -->", $this->thearrayset[$indexxx]['name'], $this->returnthis);
preg_match('/(.*)\[product\]\[description\]\[maxchars=##(.*)##\]\[append=##(.*)##\](.*)/', $this->done, $matches); //Check if user wants to cut off description after a certain amount of characters and if we need to append something if we do (like 3 dots or something)
$maxchars = $matches[2];
$appendeez = $matches[3];
if($maxchars == 'false'){ $this->returnthis = str_replace("<!-- [product][description] -->", $this->thearrayset[$indexxx]['description'], $this->returnthis);
}else{ $this->returnthis = str_replace("<!-- [product][description] -->", substr($this->thearrayset[$indexxx]['description'],0,$maxchars).$appendeez, $this->returnthis);
}
$this->returnthis = str_replace("<!-- [product][price] -->", $this->thearrayset[$indexxx]['price'], $this->returnthis);
$this->returnthisloopdone .= $this->returnthis; //Append string_replaced products section for every item in array
}
$this->done = str_replace($this->productskeepall, $this->returnthisloopdone, $this->done);
//Write our complete page to a php file
$myFile = "templates/$template/cache/testfile.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $this->done;
fwrite($fh, $stringData);
fclose($fh);
return $myFile; //Return filename so we can include it in whatever page requests it.
}
} //End class
?>
The php requested by the website visitor, which will call the current template's all_products.php
include_once("class.php");
$listproducts = new listproducts();
include_once($listproducts->listproduct());
So what this really is, is just string_replacing the HTML comments in the template file with the PHP result I want there. If it's a loop, I Single out the html code I want to loop -> Start an empty string variable -> Repeat that HTML code, appending each loop to the string variable -> Use this string variable to replace the HTML comment
The newly built page is then written to an actual file, which is then included.
I'm completely new to OOP, so this is pretty elaborate stuff for me. I'd like to know if this is a good way to tackle my problem. And also, is it possible to prevent having to rewrite that entire class for every page?
As an example, if I also wanted to build a guestbook I'd like to rewrite the class in a way that it can accept passed variables and build the page from there, rather than pre-setting alot of stuff limiting it to one 'task' such as retrieving products. But before I go any further I'd like to know if this is an a-okay way to do this.