Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Is it EASY to enable PHP in product description?


jdstraughan

Recommended Posts

I simply want to free my database of 300+ products from keeping a redundant and very large chunk of HTML in the product description when it could be holding a link to a html file. Also, I could edit this file and affect several products at a time.

 

This is what I have tried:

 

Instead of putting the description in html, i used this line:

 

<?php include('external_html'); ?>

 

This results in a blank description. Is there a method of removing the description and replacing it with a link for each product or enabling php so my above code would work?

 

Or should I quit banging my head against this wall and move on to another method of solving this?

 

Please help! and THANKS!

Link to comment
Share on other sites

I don't think you can insert a php command into the database. Here is an idea. The product that you want to link to an external html insert a 3 for the product description.

 

Find this code in the product_info.php:

<p><?php echo stripslashes($product_info['products_description']); ?></p>

You could try something like this:

if ($product_info['products_description'] == "3") {

include('external_html');

} else {

?>

<p><?php echo stripslashes($product_info['products_description']); ?></p>

<?php

}

Other great Open Source (Free) programs: (Free as in free speech not free beer)

The Gimp - An image program. | Firefox - All you have to do is add the Web Developer add-on to make this web browser complete. | FileZilla - An ftp program. | Inkscape - A good program to create images with. | Thunderbird - An email program. | Openoffice.org - An office suite that is compatible with MS Office. | Abiword - Another office suite. | Audacity - A sound recording tool. | ddp's Picks | Wordpress - An easy to use blogging software. | Joomla - An easy to use CMS that has ecommerce plug-ins. | Drupal - Another CMS

How do I find these programs? Google Search!

Link to comment
Share on other sites

I simply want to free my database of 300+ products from keeping a redundant and very large chunk of HTML in the product description when it could be holding a link to a html file. Also, I could edit this file and affect several products at a time.

 

This is what I have tried:

 

Instead of putting the description in html, i used this line:

 

<?php include('external_html'); ?>

 

This results in a blank description. Is there a method of removing the description and replacing it with a link for each product or enabling php so my above code would work?

 

Or should I quit banging my head against this wall and move on to another method of solving this?

 

Please help! and THANKS!

 

Yes, you can do it actually!

 

Find this code:

 

<p><?php echo stripslashes($product_info['products_description']); ?></p>

 

replace with

 

<p><?php echo stripslashes(eval($product_info['products_description'])); ?></p>

 

Note: each product description must start with "?>" no quotes in order to avoid a fatal error while displaying the product description. This is basically a "stop PHP parsing until I need it" command. The best way to do it for multiple products is to export the database table with your products to a file and the do a search & replace (search for 'product description starts here', replace with '?>product description starts here').

 

Now you can use any PHP code in your product description. For example, you could output any PHP variable that was previously declared like this <?=variable_name?>. Any other code can be included using <?php your_code_here ?> just you would in any php file.

 

Also note that any WYSIWYG editors like HTMLArea, FCKeditor, TinyCME WILL REMOVE any PHP code automatically (because they are HTML editors). That basically means you have to use an external editor to modify your product descriptions.

 

Good luck!

 

Dan G.

 

Notebook Solutions Inc.

 

Link to comment
Share on other sites

<p><?php echo stripslashes(eval($product_info['products_description'])); ?></p>

 

Note: each product description must start with "?>" no quotes in order to avoid a fatal error while displaying the product description. This is basically a "stop PHP parsing until I need it" command. The best way to do it for multiple products is to export the database table with your products to a file and the do a search & replace (search for 'product description starts here', replace with '?>product description starts here').

 

or just do this...

 

<p><?php echo stripslashes(eval('?>'.$product_info['products_description'])); ?></p>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...