Hi,
Is there a way to include a php code into a product description from the admin panel? It looks as including jscript works fine, but tags <?....?> are ignored.
Any suggestions?
Thanks
Hi,
Is there a way to include a php code into a product description from the admin panel? It looks as including jscript works fine, but tags <?....?> are ignored.
Any suggestions?
Thanks
I need to include a flash object with dynamic flashvars parameters. Instead of adding the code to each product description, it would be more elegant to include a call to a php function, which generates the flash structure
I could do it with jscript,, but would prefer php
You can not do that, because PHP is server side, so it is executed BEFORE sending to your browser. If you put it inside desc, it will be treated not as php code but just plain text.
There is one way to use php tho: in your product_info template file, you can put the php code there to echo the flash. (say if your product name is abc, then echo flash abc.swf, not so hard rite?)
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
No, i cannot do this. There is a single flash file, where I pass parameters (xml file) different for different products. In other words, each product has its own xml file, which is a variable for flash.
I can include the whole object code, but it would be easier to call it as a function of the passed variables.
I cannot understand your statement that " You can not do that, because PHP is server side". Of course, it should be done on a server side, but each product description is included by php include statement anyway
Your product description is saved into database, and when Zen display that product it does something like this:
echo $product_description; (just an example).
$product_description; is a string, and treated as so.
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
From "Similar Threads" at the bottom of this page:
http://www.zen-cart.com/forum/showthread.php?t=59826 ... see post #4
Or, since you're wanting to add a specific element common to all products, you could just alter your template to display the element where needed, and name your object based on the product id or model etc.
Or, you could add another field in the database to store specific object filename which you call separately, via the template.
It really depends on exactly what you want to accomplish.
Be careful not to think of the solution before you fully define the need/problem.
.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole
Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.
There are many ways to get around without putting php code inside product description. Please provide these info:
1. Does this flash appear on all product desc, or just some?
2. Do you currently use product model (or have plan to use)? (I ask this question for a specific reason)
3. Can you provide a sample description? (with flash)
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
Here is the whole story.
1) I am using tabbed products, while one of the tabs is the flash movie with the specific xml file (different for different products) here is an example of such a code via object tag:
here is the "flash/sample.xml" variable, which is unique for each productCode:<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="test3" align="middle"> <param name="allowScriptAccess" value="sameDomain" /><param name="flashVars" value="currxml=flash/sample.xml" /> <param name="movie" value="flash/~main.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="flash/~main.swf" quality="high" flashVars="currxml=flash/sample.xml" bgcolor="#ffffff" width="550" height="400" name="test3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
2) What I need is to make it more simple on the end-user side - just to include something like "myfunction('flash/sample.xml')" instead of the whole object
3) the easiest way woud be to make a jscript function, which writes the whole object, but I cannot use jscript directly, because each priduct page is loaded via ajax. This means that all the jscript write directive are not executed before the browser renders the ajax generated code
One of the solutions would be to delay that jscript execution (what I have to do for other functions) or do it on a server-side via php.
NOTE. I do not use a product model. What is your idea? to use that field?
Yes, to use that field.
Say you have product A, and we give that product the model: abc.xml.
Now in your product_info template:
We can do something like this (Im writing in pseudo code here)PHP Code:
// checking if the product has model
if(exist($pmodel) && strlen(trim($pmodel))>0){
$flash_obj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="test3" align="middle">
<param name="allowScriptAccess" value="sameDomain" /><param name="flashVars" value="currxml=XML_LINK" />
<param name="movie" value="flash/~main.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="flash/~main.swf" quality="high" flashVars="currxml=XML_LINK" bgcolor="#ffffff" width="550" height="400" name="test3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>';
$flash_obj = str_replace('XML_LINK', $pmodel, $flash_obj);
echo $flash_obj;
}
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