Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Oct 2006
    Posts
    149
    Plugin Contributions
    0

    Default How to include php code into a product description

    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

  2. #2
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: How to include php code into a product description

    Of course it will be ignored, why do you want to do so?
    Quote Originally Posted by andy1234 View Post
    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 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

  3. #3
    Join Date
    Oct 2006
    Posts
    149
    Plugin Contributions
    0

    Default Re: How to include php code into a product description

    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

  4. #4
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: How to include php code into a product description

    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?)
    Quote Originally Posted by andy1234 View Post
    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
    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

  5. #5
    Join Date
    Oct 2006
    Posts
    149
    Plugin Contributions
    0

    Default Re: How to include php code into a product description

    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

  6. #6
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: How to include php code into a product description

    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

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: How to include php code into a product description

    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.

  8. #8
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: How to include php code into a product description

    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

  9. #9
    Join Date
    Oct 2006
    Posts
    149
    Plugin Contributions
    0

    Default Re: How to include php code into a product description

    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:

    Code:
    <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>
    here is the "flash/sample.xml" variable, which is unique for each product

    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?

  10. #10
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default Re: How to include php code into a product description

    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

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. How do I insert PHP code into 'define_page_x.php'?
    By oavs in forum General Questions
    Replies: 1
    Last Post: 7 Nov 2011, 09:46 AM
  2. How Do I Format A Product Description to include line breaks and bullet points?
    By mike373 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 21 Apr 2011, 07:44 PM
  3. Input PHP into Product Description
    By todoonada in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 23 Jun 2009, 12:08 PM
  4. Using PHP "include" in category & product description
    By g6enterprises in forum General Questions
    Replies: 4
    Last Post: 30 Jan 2009, 09:14 PM
  5. How to include other page to product description
    By marksu in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 11 Dec 2008, 12:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg