Forums / Templates, Stylesheets, Page Layout / How can PHP be inserted into the Products Description area?

How can PHP be inserted into the Products Description area?

Locked

Views: 1,573

Results 1 to 13 of 13
This thread is locked. New replies are disabled.
23 Feb 2009, 1:54 AM
#1
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

How can PHP be inserted into the Products Description area?

Recently, I tried adding a few lines of PHP to the product description.

Instead of executing the code, the whole string of PHP commands was outputted to the screen, as though it were just plain text.

I included the customary

<?php and ?>

at the beginning, and end, of the PHP code I wished to include.

Is what I was trying to do at all possible? And if not, would someone who knows the answer kindly explain?

Thank you,
Donn

23 Feb 2009, 2:05 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How can PHP be inserted into the Products Description area?

Product description area only parses html code as you have noticed

Zen-Venom Get Bitten

23 Feb 2009, 2:13 AM
#3
donn avatar

donn

Zen Follower

Join Date:
Oct 2007
Posts:
241
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

kobra:

Product description area only parses html code as you have noticed

Thanks for the answer....

:( I was hoping that this wasn't the case...........

In simple terms, why can't PHP be executed from the products description HTML?

Is there any way to change this, and permit the PHP to be parsed? Is this a server-side control?

Would Java work any differently?

23 Feb 2009, 2:19 AM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: How can PHP be inserted into the Products Description area?

In simple terms, why can't PHP be executed cfrom the description?
I only know that this is how it functions due to how it is coded.
Is there any way to hange this, and permit the PHP to be parsed?
I would suspect not with out a huge amount of re-coding

Maybe a dev will happen by with a better explanation or possible solution

Zen-Venom Get Bitten

23 Feb 2009, 2:59 AM
#5
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

You can, it will be probably 1 single line of code change, you will have to eval the description instead of echoing it, and you will have to do something like this

eval("?>$products_description<?php");

Remember, anyone has access to your admin now can run whatever php code he wants using the description of the product, either it's worth it or not is up to you.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

23 Feb 2009, 12:02 PM
#6
swguy avatar

swguy

Administrator

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

Re: How can PHP be inserted into the Products Description area?

Donn, if what you're looking to do is display certain messages over and over again, you can use my Boilerplate Tips:

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

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

HTH,
Scott

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

31 Oct 2010, 7:20 PM
#7
etilyeti avatar

etilyeti

New Zenner

Join Date:
May 2009
Posts:
20
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

yellow1912:

You can, it will be probably 1 single line of code change, you will have to eval the description instead of echoing it, and you will have to do something like this

eval("?>$products_description<?php");

Remember, anyone has access to your admin now can run whatever php code he wants using the description of the product, either it's worth it or not is up to you.

Has someone tried this?

v1.3.8a - Cherry Zen - English, French, German, Slovak, Czech -
Admin Login as a customer v2.1, FastAndEasyCheckout 1.7.3, improved_attributes_controller_1-1b2, recover_cart_sales_300B, supertracker_1-0_Fix_20090925, testimonial_manager_v1-5-0

31 Oct 2010, 7:32 PM
#8
etilyeti avatar

etilyeti

New Zenner

Join Date:
May 2009
Posts:
20
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

I have tried replacing

echo stripslashes($products_description);

by

eval("?>$products_description<?php");

in /includes/templates/cherry_zen/templates/tpl_product_info_display.php

but it just deletes the whole product description. I imagine that I would have to do something so the code in my product description do not interfere with ZenCart's code. Somehting like stripslashes? However my knowledge of php is null.

v1.3.8a - Cherry Zen - English, French, German, Slovak, Czech -
Admin Login as a customer v2.1, FastAndEasyCheckout 1.7.3, improved_attributes_controller_1-1b2, recover_cart_sales_300B, supertracker_1-0_Fix_20090925, testimonial_manager_v1-5-0

31 Oct 2010, 7:36 PM
#9
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,684
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

The real question is why do you think you need php in the product description?

Please do not PM for support issues: a private solution doesn't benefit the community.

Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

31 Oct 2010, 8:04 PM
#10
etilyeti avatar

etilyeti

New Zenner

Join Date:
May 2009
Posts:
20
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

Because part of my product description is almost always the same. Therefore I would like to add an include

v1.3.8a - Cherry Zen - English, French, German, Slovak, Czech -
Admin Login as a customer v2.1, FastAndEasyCheckout 1.7.3, improved_attributes_controller_1-1b2, recover_cart_sales_300B, supertracker_1-0_Fix_20090925, testimonial_manager_v1-5-0

1 Nov 2010, 12:50 AM
#12
etilyeti avatar

etilyeti

New Zenner

Join Date:
May 2009
Posts:
20
Plugin Contributions:
0

Re: How can PHP be inserted into the Products Description area?

gjh42:

Then use swguy's boilerplate tips in post 6.
If I understand it correctly, it replaces the whole description. However, I still need to customize the top of the description for each product.

v1.3.8a - Cherry Zen - English, French, German, Slovak, Czech -
Admin Login as a customer v2.1, FastAndEasyCheckout 1.7.3, improved_attributes_controller_1-1b2, recover_cart_sales_300B, supertracker_1-0_Fix_20090925, testimonial_manager_v1-5-0

1 Nov 2010, 12:54 AM
#13
swguy avatar

swguy

Administrator

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

Re: How can PHP be inserted into the Products Description area?

You don't understand it correctly.

The idea behind it is to add a common block of text at the end of the description.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.