Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / PHP includes to save time?

PHP includes to save time?

Locked

Views: 7,928

Results 1 to 19 of 19
This thread is locked. New replies are disabled.
5 Jul 2006, 3:06 AM
#1
rowan avatar

rowan

Zen Follower

Join Date:
May 2006
Location:
Australia
Posts:
107
Plugin Contributions:
2

PHP includes to save time?

I have a few products that share a particular body of text and I'd rather not copy+paste it each and every time. Is it possible to use a simple PHP include in the description, or is there another way to achieve this?

I haven't tried simply using PHP in the description, would this work?

9 Jul 2006, 4:33 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: PHP includes to save time?

embedded PHP is not supported at the present time

as an alternative (depending on its suitability), perhaps you might embed an A HREF link to an HTML page where you have additional info

10 Jul 2006, 1:17 AM
#3
rowan avatar

rowan

Zen Follower

Join Date:
May 2006
Location:
Australia
Posts:
107
Plugin Contributions:
2

Re: PHP includes to save time?

Thanks for clearing that up, this would be a great feature to have in the future though.

I don't think I'll include a link to another page in this case.

30 Jul 2006, 7:44 PM
#5
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: PHP includes to save time?

swguy:

You can indeed do this. The process is described on

http://www.thatsoftwareguy.com/zencart_php_in_description.html

Good luck,
Scott

Thats really a great link!
Thanks

30 Jul 2006, 11:29 PM
#6
rowan avatar

rowan

Zen Follower

Join Date:
May 2006
Location:
Australia
Posts:
107
Plugin Contributions:
2

Re: PHP includes to save time?

swguy:

You can indeed do this. The process is described on

http://www.thatsoftwareguy.com/zencart_php_in_description.html

Good luck,
Scott

Thanks heaps for that, this will help a lot.

25 May 2008, 1:13 PM
#7
anniti avatar

anniti

New Zenner

Join Date:
May 2008
Posts:
33
Plugin Contributions:
0

Re: PHP includes to save time?

The "Boilerplate text Adding"- feature is exactly what I need and works fine in the Product details page, but
what file should I edit to display the Description in the index page or in any of the other lists (Product Listing, New Listing, Featured Listing, All Listing) pages
Regards, anna

25 May 2008, 1:17 PM
#8
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: PHP includes to save time?

anniti:

The "Boilerplate text Adding"- feature is exactly what I need and works fine in the Product details page, but
what file should I edit to display the Description in the index page or in any of the other lists (Product Listing, New Listing, Featured Listing, All Listing) pages
Regards, anna
http://www.zen-cart.com/forum/showpost.php?p=287105&postcount=8
Thread above should help.. code varies dependant on where you
require description to show.

25 May 2008, 1:23 PM
#9
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,684
Plugin Contributions:
56

Re: PHP includes to save time?

Anniti, I'll update my documentation too to add these instructions.

26 May 2008, 6:57 AM
#10
anniti avatar

anniti

New Zenner

Join Date:
May 2008
Posts:
33
Plugin Contributions:
0

Re: PHP includes to save time?

thank you both for your very (very!) fast reply.
Of course an instructions-update by SWGuy would be highly appreciated, but in the meantime I'll insist on my quest.
thanks, anna

27 May 2008, 7:20 AM
#11
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,684
Plugin Contributions:
56

Re: PHP includes to save time?

The documentation now describes how to do this for new, all, featured and product listing pages.

http://www.thatsoftwareguy.com/zencart_php_in_description.html

27 May 2008, 7:26 AM
#12
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: PHP includes to save time?

swguy:

The documentation now describes how to do this for new, all, featured and product listing pages.

http://www.thatsoftwareguy.com/zencart_php_in_description.html
Excellent work.. thanks for sharing.
:clap:

30 May 2008, 4:16 PM
#13
anniti avatar

anniti

New Zenner

Join Date:
May 2008
Posts:
33
Plugin Contributions:
0

Re: PHP includes to save time?

Hi,
I followed the instructions of swguy on
http://www.thatsoftwareguy.com/zencart_php_in_description.html,
and it works fine for the featured-, new-, and all product pages.
But it won't show up in the product listing pages.
I just see my 'boilerplate strings'
Any clues?
Thanks, anna

30 May 2008, 5:23 PM
#14
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,684
Plugin Contributions:
56

Re: PHP includes to save time?

Remember that includes/modules/product_listing.php is a template file - so if you've overridden it in includes/modules/<your template>/product_listing.php, then this is the file you want to edit.

30 May 2008, 7:01 PM
#15
anniti avatar

anniti

New Zenner

Join Date:
May 2008
Posts:
33
Plugin Contributions:
0

Re: PHP includes to save time?

:oops:
that was it, thank you so much for all your help.
regards, anna

24 Jun 2008, 8:37 PM
#17
steveyork136 avatar

steveyork136

New Zenner

Join Date:
Nov 2005
Posts:
84
Plugin Contributions:
0

Re: PHP includes to save time?

this is really cool, thanks swguy, I have found a little quirk though, which caused me a little problem.
Now I've found a solution, I'll post incase anyone else comes across the same issue.

I have quite a few categories with only one product in them, when this snippet was installed, the category would appear but clicking on it took you to a totally blank page.

It seems zen didn't like the extra defines file when theres only one product in a category.

To fix this I placed the defines code supplied by swguy in another extra defines file, I used document_general.php, its only got one other define in it.

This seems to have fixed my error, hope this helps someone else
:cheers:

25 Jun 2008, 1:47 AM
#18
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,684
Plugin Contributions:
56

Re: PHP includes to save time?

Best to just create an extra_defines file especially for this; no need to overload the document file. Thanks for this catch.

6 Oct 2010, 9:26 PM
#19
fireflyz avatar

fireflyz

New Zenner

Join Date:
May 2007
Location:
Los Angeles
Posts:
89
Plugin Contributions:
0

Re: PHP includes to save time?

Hi SWguy,

I have followed your directions and the boilerplate is still not showing up on the product description. I'm trying to add this to category ID 39. It seems so simple.. what am I doing wrong?

Here is the code from override tpl_product_info_display.php:

<?php if (($products_description != '') || ($current_category_id == 39) ) { ?>
<div id="productDescription" class="productGeneral biggerText">
<?php 
   $stripped_products_description = $products_description;
   if ($current_category_id == 39)  {
      $stripped_products_description = $stripped_products_description . CAT39_DESC;
   }
   echo stripslashes($stripped_products_description); 
   echo '</div>';
?>
<?php } ?> 

and here is the code for my_defines.php:

<?php

$descr_stringlist = array("CAT39_DESC", "CAT40_DESC"); 

define('CAT39_DESC', '10 Percent Rebate for xxxxx<br>You will receive your refund within 7 days. If you have any questions, please contact us.');

?>

Thank you for your help!