Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2008
    Posts
    51
    Plugin Contributions
    0

    customer issue How do I include a file with text or images into an EZ page or a Define Page?

    I have products that require a lot of the same text and images (like the warranty information, colors, etc.). I am currently adding this information to each page individually. Updating this is a hassle, since I have to go each page and change it one-by-one.

    I am looking for a better way. I want to store this common information in a file and then include that file into each product that it is appropriate for.

    I have tried inserting a good ol' php include statement, but it doesn't seem to work. I am sure there must be a way to do this. Can anyone help with a specific example showing the exact format or a link to a reference page?

    tia

  2. #2
    Join Date
    Nov 2008
    Posts
    51
    Plugin Contributions
    0

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Clarification: the title of my post mentioned EZ pages and Define Pages, but I want to include common info into the Product Detail pages as well.

  3. #3
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Unfortunately I don't have ready access to some of the pages to which you are referring, but essentially, if every such product is located in a specific category for example, then if you used a category lookup function for the product_id and the return was your "designated" category, then you could include your text file that contains all of the html coded information where the file begins with ?> And ends with <?php

    This is somewhat reverse of "normal" includes files, but if all you are including is "text" then it becomes easier than using echo commands, print commands, etc... for each and every line.
    So text file might look like this:
    Code:
    ?>Display this text everywhere it is included.<?php
    Then where you want to include the text,

    Code:
    if (includespecialtexthere) {
    include('pathtotextfile/textfile.txt');
    }
    This is untested code, but seems appropriate based on understanding and history of working with php and ZC.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Nov 2008
    Posts
    51
    Plugin Contributions
    0

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Thanks for your reply. However, that doesn't seem to help. It looks to me like the php include statement is being commented out by Zen Cart so that my common code is not even being brought in.

    For example, when the code below is placed within the Product Description, what starts out as:
    Code:
    <?php include('commonfile.php');?>
    it ends up displayed in a browser window (which is visible using view source) as the following. Notice the html comment code that is wrapped around it:
    Code:
    <!--?php include('commonfile.php');?-->

    The above code will work fine as long as the file is called directly from a browser (for example, http://mydomainname.com/myfile.php).
    Here is the code for myfile.php:
    Code:
    <body>
    <?php include('commonfile.php');?></p>
    </body>
    Here is the code for the included file called commonfile.php:
    Code:
    common text to be included
    Here are the results it produces when invoked directly from a browser with http://mydomainname.com/myfile.php), which is what I need:
    common text to be included
    So, the question is, how do I get Zen Cart to NOT comment out my php include statement? Or is there some other way to do an include on a Product Description page?

    Surely, I am not the first or only person to want/need this, but I have searched all over the forums and the FAQs and Wiki, but all to no avail. Perhaps I just am searching for the wrong keywords/phrases? If anyone knows how to do, please share!

  5. #5
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Okay, so this is a little different than first explained. Thought you were looking for the proper format to call the extra code from within code, not from within the description box. So, no one can not directly call/execute php code from within the description, but there is a way to have the description basically parsed and to therefore execute/include other information. Btw, and just to ensure that others are clear, you wouldn't want to call a file from within the main body of the ZC page that adds addition body tags to the existing page. I'll hhave to find it again. - think I tagged it in one of my favorites in case I ever had to desperately use that feature.

    Realize, this option will require modifying the descriptions of multiple products as well, though hopefully just one more time. :)
    Last edited by mc12345678; 28 Jul 2014 at 06:09 PM.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    There's a part of what I remember that can be found at: http://www.zen-cart.com/showthread.p...736#post936736

    From that link is some code to implement and a link to some more code that might help out. Predominantly it looks like swguy had worked through it several years ago. Might find more by searching for boilerplate in the forum, but hoping that the. Software is still available from his site as well.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    I may be wrong but I suspect the php command should be "require" or "require_once", instead of "include".

    Use Developers Tool Kit for examples of use.

    Hope this helps

  8. #8
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Quote Originally Posted by dw08gm View Post
    I may be wrong but I suspect the php command should be "require" or "require_once", instead of "include".

    Use Developers Tool Kit for examples of use.

    Hope this helps
    Any of the three work for bringing code into a php program. Require means that the code must be included or else a failure/error will occur, include means to bring it in, but if it is unsuccessful execution can continue. Each has a once option, that basically prevents the file from being brought in mmore than once which would cause an error of it's own.

    In this situation, at least with the code above, the attempt has been to incorporate code into the description instead of "before" or "after" it in the code itself.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Quote Originally Posted by mc12345678 View Post
    Any of the three work for bringing code into a php program. Require means that the code must be included or else a failure/error will occur, include means to bring it in, but if it is unsuccessful execution can continue. Each has a once option, that basically prevents the file from being brought in mmore than once which would cause an error of it's own.

    In this situation, at least with the code above, the attempt has been to incorporate code into the description instead of "before" or "after" it in the code itself.
    Thanks for clarity.

  10. #10
    Join Date
    Nov 2008
    Posts
    51
    Plugin Contributions
    0

    Default Re: How do I include a file with text or images into an EZ page or a Define Page?

    Well, I have found a kinda kludgy way to do what I want, but it seems to work. Below is an example, in case someone else wants/needs it, too.

    1. First, create a file containing the common code that you want to insert on multiple products. Here is a simplified example where I want multiple products to all say the same thing about the colors that are available. For this example, this code will be stored in the file called [myfilename.html]

    HTML Code:
    <br>It comes in 3 lovely colors:  red, green, and blue. blah blah blah.<br>
    2. Next, login to your Zen Cart Admin, go to Categories/Products, and edit each Product one-by-one in Plain Text mode. Insert an iframe in the description field where you want the common code to appear. Be sure to set the height, width, and specify the name of the file with the common code on the iframe statement:

    HTML Code:
    <p>
    	This widget is really great! 
    
    	<iframe frameborder="0" seamless width="xxx" height="yyy" src="http://[mydomainname.com]/[myfilename.html]"></iframe>
    
    	You will just love it!
    </p>
    So this produces the following output when viewed in a browser:

    This widget is really great!
    It comes in 3 lovely colors: red, green, and blue. blah blah blah.
    You will just love it!
    You should probably also do one more thing and that is add a link statement to a css definition file at the top of the included file. This because the iframe doesn't pass along css definitions to its contents. No worries, though, as you can easily do this with a statement that looks like this:

    HTML Code:
    <link rel="stylesheet" type="text/css" href="/includes/templates/css/[stylesheetname.css]" />
    If you want to see a working example, browse on over to http://keylessentrylocks.com/index.p...products_id=98. Click on #5. Lock Colors in the accordion-style control to see some stuff that was included as described above. And while you are there, if you see something you like, feel free to buy it! (sorry, couldn't resist a bit of shameless site promotion )

    One problem with this method is that you need to specify a height and width or you will get scroll bars. Sometimes that is ok, but sometimes not. Another problem is that I want to use a Dreamweaver jQuery tab control (which is similar to the accordion control on the page now), but that one doesn't seem to work. Not sure why yet. Enlighten me if you know!

    This example shows how to insert common code elements into a Product Description file, but I would expect it will also work with EZ Pages and Define Pages. I just haven't tested that yet.

    If you know of an easier way, please do let us all know.

    Good luck and hope this is helpful to someone.

 

 

Similar Threads

  1. How to import SWF file into the page?
    By Lazar in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 14 Apr 2011, 11:52 PM
  2. how to include a defined page file to pick up my template name?
    By weber in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 1 Jan 2009, 12:34 AM
  3. New file into "Config.->Define Page Status"
    By jamieboulder in forum Basic Configuration
    Replies: 2
    Last Post: 12 Apr 2008, 12:27 PM
  4. Replies: 14
    Last Post: 29 Sep 2007, 03:07 AM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR