Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Posts
    56
    Plugin Contributions
    0

    Default Entering PHP Code with FCKEditor

    This has been discussed at length for EZpages but not for general usage.

    I want to enter some PHP into a product listing. I can get around the issue, but I'd love to be able to do it My site uses the Zen Cart catalogue and product_book features. it contains almost 800 listings (or products to eCommerce users) and it seems to be working fine. I want to insert a newsletter registration form that requires nothing more than an email address to register, so I'll be using a program called Pomo which requires PHP to update a database.

    This link will take you to the listing in question: http://trainzresources.com/directory...roducts_id=812

    I've read a lot about adding PHP into a FckEditor listing, but I can't get it to work.

    I've uncommented this line in fckconfig.js, the PHP code is no longer truncated but it still doesn't work. FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code

    I've tried entering some simple test code: <?php echo "TEST"; ?> When I save the listing and go to the online catalogue, the word TEST does not appear.

    I've heard a couple of things:
    You can't add PHP to a product listing. But it doesn't work in Categories listings either.
    Others outside Zen Cart have experienced the same problem with the FCKConfig change, whilst others have said it works.

    One guy who said it didn't work also said that he had found a solution. This is what he said:

    "Solved! Ahh! The joys of API!"

    Code:
    function InsertHTML(){
    var oEditor = FCKeditorAPI.GetInstance('content') ;
    if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ){
    oEditor.InsertHtml('WHAT YOU WANT? WHERE YOU WANT IT?') ;
    }else alert('You must be on WYSIWYG mode!');}

    //How to use it;
    <input type="button" value="InsertHTML" onclick="InsertHTML();" />

    Comment:

    "I see that FCKeditor's API demo isn't there, it's all CK... something. (you could've seen it on their site)"

    ------------------------

    All that is mumbo jumbo to me. Has anyone here actually been successfull in adding PHP? If so what is the trick?

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Entering PHP Code with FCKEditor

    This is a very circuitous and unnecessary approach to adding php to a product page.

    The FCKEditor is designed for adding static HTML to a page, rather than dynamic PHP (or any other language). Hence the need to jump through hoops to stop something not supposed to be there from getting stripped out out on its way into or out from the database.

    If you want to run additional PHP on your product page, why not simply add it to the page's template?
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Feb 2005
    Posts
    56
    Plugin Contributions
    0

    Default Re: Entering PHP Code with FCKEditor

    Surely that would mean that the membership registration form would then appear on "all" 700 pages? I just want it to appear on one.

  4. #4
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Entering PHP Code with FCKEditor

    That would depend on what limitations you choose to include in your php.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  5. #5
    Join Date
    Feb 2005
    Posts
    56
    Plugin Contributions
    0

    Default Re: Entering PHP Code with FCKEditor

    I'm sorry, but to me that's a very vague answer.

    Are you suggesting that in my mainpage php code I could write something along the lines of (roughly speaking):

    if products_id=826;
    include membership form;
    else
    don't;
    endif

    If that's the case, I think I'd rather get drunk :)

    As I said, I have other options. However, my question has been raised hundreds of times by others on the Internet, so I hardly think I'm alone here.

    Thanks for your reply.

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

    Default Re: Entering PHP Code with FCKEditor

    There's a MUCH more important issue you're overlooking entirely.

    Even if you were to add PHP code to the product description, Zen Cart isn't going to RUN that PHP code anyway. It'll just echo it out to your browser.
    To make it execute the code, you'd need to edit the core code that outputs the description and have it check whether there's any embedded PHP, have it run that PHP, and include it in the output.

    So, rather than beat your head against the wall about a fancy text editor, why not get your core PHP logic working first?
    ie:
    1. Turn OFF all your rich-text editors ... just use "Plain Text" or "NONE" as your product-description editor. Put your PHP in there. That way the editor is no longer a factor.
    2. Work on the logic to make that PHP code actually run as you intend it.
    3. Then you'll probably find that turning on the rich-text editor may actually have no negative impact at all.

    I would suggest that maybe some alternative approaches be explored, as they would negate all issues related to FCKeditor or other editors:
    a) some sort of boilerplate approach
    b) a hard-coded approach such as you've been discussing with kuroi
    c) maybe use product-attributes instead ... but that might necessitate a lot more coding, essentially building a custom product-type ...... which might not be a bad idea if you wanted to share it
    d) or maybe rethink whether you want this done as a "product" at all ... cuz technically it really isn't a product, as far as I can tell.
    .

    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.

  7. #7
    Join Date
    Feb 2005
    Posts
    56
    Plugin Contributions
    0

    Default Re: Entering PHP Code with FCKEditor

    Hi DrByte.

    I don't think I'm overlooking anything because I just don't know. All I was looking for was an alternative to Plan A, but it seems that the alternative - to include PHP code in FckEditor isn't an option.

    Quite seriously, I really think I've wasted your time because Plan A is still acceptable, and the one I will use. Hopefully others with a similar need, will discover this thread and stop wasting their time, or follow the suggestions you have all come up with.

    Thanks to all for taking time out to reply. it was very kind of you.

 

 

Similar Threads

  1. Can I require entering a referral code to create account?
    By tamadrummer1975 in forum General Questions
    Replies: 1
    Last Post: 2 Aug 2011, 12:36 AM
  2. html code in fckeditor
    By wowemall in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 11 May 2010, 10:44 AM
  3. HTMLAREA problems with entering <?php code
    By g.nencini in forum General Questions
    Replies: 10
    Last Post: 18 Sep 2009, 10:42 AM
  4. Multiple entering Redemption Code.
    By kamoljan in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 6
    Last Post: 25 Jul 2009, 03:42 PM
  5. Entering HTM Code into PHP Files - Adding Live Search to search_header.php
    By Jump Network in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Sep 2007, 02:47 PM

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