Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default PHP, JacaScript, & HTML areas on pages

    Good day Zen Cart users!

    Recently, I inquired on this forum about embedding JavaScripts into PHP files.

    Dr. Byte's Reply:



    If you need to add javascript to your site for some reason, it belongs somewhere in the template logic, not in the core intelligence of the overall site.
    http://www.zen-cart.com/forum/showthread.php?p=681116

    OK...I understand that to keep the code neat and sensible, I should keep everything in its place.

    I was wondering, though....

    Some pages have an HTML area, such as product info pages, as well as the various EZPages and info pages.

    Some JavaScripts seem to only work when embedded within an HTML area on the cart, and do not work when executed as JavaScript .JS files.

    So, what I was wondering...as the Footer appears on every page of the cart , and since not all pages have an HTML area, is there a way to make the Footer an 'html area', instead of merely being echo'ed PHP code?

    A related question: How are the pages featuring an area with an 'HTML area' handled?
    It isn't through a PHP echo statement, I am guessing...

    As always, any help would be greatly appreciated.

    Donn

  2. #2
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: PHP, JacaScript, & HTML areas on pages

    If you need to put specific HTML into your footer only, then make a custom tpl_footer.php file in your override folder, and put it there ... it will then appear on all pages.

    The same concept works with all template files ... put things where you need them, in the files that they relate to.
    .

    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.

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

    Default Re: PHP, JacaScript, & HTML areas on pages

    Embedding behaviours (javascript) into content (HTML) would still be bad practise though. Although older scripts often encourage this embedding to avoid the need to tell people how to do it properly, there's no reason for scripts not to run when loaded via the Zen Cart javascript framework.
    Kuroi Web Design and Development | Twitter

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

  4. #4
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: PHP, JacaScript, & HTML areas on pages

    Quote Originally Posted by DrByte View Post
    If you need to put specific HTML into your footer only, then make a custom tpl_footer.php file in your override folder, and put it there ... it will then appear on all pages.

    The same concept works with all template files ... put things where you need them, in the files that they relate to.
    Ok, Dr. Byte....

    I'm still shaky on overrides, just re-read posts and other info...

    https://www.zen-cart.com/tutorials/i...hp?article=143



    Is this the proper directory to place the override file into?

    /includes/languages/english/extra_definitions/

    AND


    How would I go about putting 'real' HTML into the footer?

    I notice that some of the other pages that permit raw HTML entry are .PHP files, yet have nothing but HTML....
    Last edited by Donn; 10 Feb 2009 at 02:38 AM.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: PHP, JacaScript, & HTML areas on pages

    Quote Originally Posted by Donn View Post
    Is this the proper directory to place the override file into?

    /includes/languages/english/extra_definitions/
    No.

    You can read up on overrides in the FAQ area:
    https://www.zen-cart.com/tutorials/index.php?category=4
    http://www.zen-cart.com/index.php?ma...roducts_id=298

    Quote Originally Posted by Donn View Post
    How would I go about putting 'real' HTML into the footer?
    Open your /includes/templates/NAME_OF_YOUR_TEMPLATE/common/tpl_footer.php file and paste it there.

    Quote Originally Posted by Donn View Post
    I notice that some of the other pages that permit raw HTML entry are .PHP files, yet have nothing but HTML....
    That's because PHP files like to load other PHP files, even if they're only loading them to display their contents where needed.
    .

    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.

  6. #6
    Join Date
    Oct 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: PHP, JacaScript, & HTML areas on pages

    Quote Originally Posted by DrByte View Post
    Open your /includes/templates/NAME_OF_YOUR_TEMPLATE/common/tpl_footer.php file and paste it there.
    After posting that last msg, I realized it's probably always going to be something like this: override files ALWAYS go into the folder in my custom template that has the same name as the folder in the 'Classic' template. That seems easy enough.

    I must admit, I have been editing the Classic template PHP files directly.

    I see now I should have used overrides 100% of the time.

    I didn't define a custom template, though. Besides being poor practice, is this bad in any way?


    Quote Originally Posted by DrByte View Post
    That's because PHP files like to load other PHP files, even if they're only loading them to display their contents where needed.
    I looked at the tpl_Footer.PHP file.

    OK...

    Code:
    <!--bof- site copyright display -->
    <div id="siteinfoLegal" class="legalCopyright"><?php echo FOOTER_TEXT_BODY; ?></div>
    <!--eof- site copyright display -->
    I notice that FOOTER_TEXT_BODY is defined in the English.php file, and I've already edited that text block.

    It seems replacing this block of code with something that points to another HTML file would be the way to do this, instead of referring to the string that was defined in the English.PHP file.

    Is there another file that does this that I can use as a reference to try to figure this out??

    Thanks,
    Donn
    Last edited by Donn; 10 Feb 2009 at 02:54 AM.

  7. #7
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: PHP, JacaScript, & HTML areas on pages

    Well, I have no idea what HTML or javascript code you're trying to dump onto your site. And I'm not about to rewrite all the FAQ articles and forum discussions here. Without knowing what exactly you're hoping to do, all I'm doing is talking theory.

    I've already told you to put footer-specific HTML into tpl_footer.php, and now you're talking about english.php instead.

    If you need examples of how overrides work, go and download several addon templates and look at how they've implemented various things, how files are located and where, and what's in them, and so on. Sometimes that's easier than trying to read documentation.
    The best way is to just try it and see what happens. If it doesn't work, undo your changes (you do make backups of things before you change them, right?) and try another approach after studying some more examples and reading FAQs and asking questions. But when you ask your additional questions, be sure to explain what you *have* tried, and what you've done differently since your last question and the answers offered.

    I hope I haven't sounded rude ... I don't mean to be. I'm just trying to help you help yourself. I understand you have some confusion. Hopefully some examples will help sort that out too :)
    .

    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 2007
    Posts
    241
    Plugin Contributions
    0

    Default Re: PHP, JacaScript, & HTML areas on pages

    I hope I haven't sounded rude ... I don't mean to be. I'm just trying to help you help yourself. I understand you have some confusion. Hopefully some examples will help sort that out too :)
    I really DO appreciate ALL the help from everyone on here!!

    I enjoy figuring cart stuff out on my own. So I don't think it's rude. I am learning....though slowly!

    I know that the development team is busy with 2.0 and probably lots else. Sorry; not trying to waste the time of others.

    I figured out how to 'put' HTML into a PHP file.

    I tried, and it's simple:

    Just stick the HTML in there, and it displays!!!!
    I was unaware that this would happen, but the other PHP files that were purely HTML made me wonder...

    As far as templates & overrides, I have to review all the info again....

    I usually am 100% confused until I get something 100%


  9. #9
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: PHP, JacaScript, & HTML areas on pages

    If you have done all of your template customization in /classic/, you can simply copy all /classic/ folders and their files to parallel /your_template/ folders. Change /includes/templates/your_template/template_info.php to reflect your new template name etc., select it in admin, reset the sideboxes, and you're good to go!

 

 

Similar Threads

  1. v155 How to auto load jacascript for all pages in the backend?
    By su35 in forum Customization from the Admin
    Replies: 5
    Last Post: 8 Aug 2016, 06:10 AM
  2. HTML with EZ & Category Pages
    By tstanley83 in forum General Questions
    Replies: 3
    Last Post: 30 Oct 2012, 04:29 PM
  3. HTML pages & SSL
    By adnimas5 in forum General Questions
    Replies: 2
    Last Post: 11 Dec 2006, 08:11 AM
  4. Adding HTML content to sidebox areas
    By shackle in forum Templates, Stylesheets, Page Layout
    Replies: 13
    Last Post: 21 Aug 2006, 07:44 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