Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Product description template?

Product description template?

Views: 1,528

Results 1 to 10 of 10
11 Dec 2013, 5:52 PM
#1
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Product description template?

So, I've just installed the "Tabbed Products Pro" mod ( http://www.zen-cart.com/downloads.php?do=file&id=646 ).

To make things easier, I'm trying to add a product description "template", so when I add a new product, the product description box in the admin area is partially filled with a "template" ( i.e, tables with information in ) which then shows in front end.

I've already commented out the zen_clean_html in /product_listing.php

Does anyone know how I can achieve what I am trying to do?

Regards

Jake

11 Dec 2013, 6:27 PM
#2
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Product description template?

The product description is stored in the database, so to have a new product automatically populate its description with your template, you would have to write code that would see if the description field for the product being displayed is empty and if so enter the template HTML in the textarea.

If you are not comfortable doing that, the easiest method would be to store the template code in notepad or somewhere quickly accessible, and paste it into the description of each new product.

11 Dec 2013, 6:50 PM
#3
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Re: Product description template?

Thanks for the reply.

I realise the easiest option would be just to copy and paste, but that'd be too easy lol

I don't think the coding is beyond me, so will give it a go.

The way I understand it;
"start script"
Connect to mySQL database
check description field using "if" command
if nothing there, "echo"? template code I want
"end script"

Now, I know that's very basic, but any idea's if I'm missing anything major? ( PHP isn't my strongest point, but I have a little experience )

:D

11 Dec 2013, 6:52 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,066
Plugin Contributions:
56

Re: Product description template?

Another possibility ... you can use the built-in Zen Cart "Copy/Duplicate Product" function. Once you've got a product with your "template", when you're going to create a new product you:

  1. Click Catalog->Categories/Products and click through the categories until you are displaying a list of products (one of which is your "template").
  2. Click the dark blue icon with a C in it (Copy to) that is associated with the "template" product
  3. Choose the category in which the new product should be created
  4. Choose "Duplicate Product"
  5. If the "template" has attributes, you probably want to copy them too!
  6. Click the "Copy" button
    You now have a (disabled) new product in the selected category that looks just like your template.
11 Dec 2013, 7:40 PM
#5
snowgoose avatar

snowgoose

New Zenner

Join Date:
Jul 2011
Posts:
21
Plugin Contributions:
0

Re: Product description template?

<?php
$con=mysqli_connect(host,username,password,dbname);;
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$result = mysqli_query($con,"SELECT * FROM zen_products_description")
WHERE products_description='NULL'");

echo "<table border='0'>
<tr>
<th>Origin</th>
<th>Suitability</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row[''] . "</td>";
  echo "<td>" . $row[''] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysqli_close($con);
?> 

That's what I have so far. Of course the red will be edited with my info.

Now, I guess the major question is, will that work or am I missing something?

( Should create blank "cells" under, "origin" & "Suitability" where I will add that info in the add product page description )

11 Dec 2013, 7:59 PM
#6
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Product description template?

lat9:

Another possibility ... you can use the built-in Zen Cart "Copy/Duplicate Product" function. Once you've got a product with your "template", when you're going to create a new product you:

  1. Click Catalog->Categories/Products and click through the categories until you are displaying a list of products (one of which is your "template").
  1. Click the dark blue icon with a C in it (Copy to) that is associated with the "template" product
  1. Choose the category in which the new product should be created
  1. Choose "Duplicate Product"
  1. If the "template" has attributes, you probably want to copy them too!
  1. Click the "Copy" button

You now have a (disabled) new product in the selected category that looks just like your template.

THIS was going to be my suggestion and it's EXACTLY how my clients have created products "templates"

11 Dec 2013, 8:52 PM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Product description template?

It has been so long since I did it that I forgot, but I did exactly that too, in making product listings for medieval coin reproductions. All of the info wants to be in the same format, and the template makes it easy and quick.

11 Dec 2013, 8:59 PM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Product description template?

If you did want to code it in, there is no need to query the database independently. The product description is among the info retrieved from the db in building the page, and you can just test the value of the appropriate retrieved field and proceed from there. It may be as simple as updating that object/array element with your template code if it is blank, before letting the page proceed to display.

11 Dec 2013, 9:04 PM
#9
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Product description template?

There's a number of simple scripts online to add text to the textarea box... some are hard coded, others reference a file that would hold the template neatly.

11 Dec 2013, 10:16 PM
#10
divavocals avatar

divavocals

Totally Zenned

Join Date:
Jan 2007
Location:
Los Angeles, California, United States
Posts:
10,011
Plugin Contributions:
3

Re: Product description template?

Seems like a LOT of effort for not much gain when there are built in ways to do this already a part of Zen Cart.. Seems like coding for the sake of coding IMHO..