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

    Default PHP and Javascript embedded within

    I was wondering if it's possible to add a JavaScript to the 'application_top.php file?

    I have a few little scripts I've tried this with, and not really knowing PHP at all, and not knowing Java much better, I've gotten terrible results.

    Mostly error messages....

    I did get one script to work, but the site text was all mis-sized after that, until I took the script out of the application_top.php file.

    I know the " (double quote) is messing things up, but I did escape the char using \ and the script still didn't work.

    I tried using the echo statement in the application_top.php file, and nothing except the most basic printing to the screen worked at all.

    Is it possible to mix a JavaScript into a PHP file, or am I way off?

    If so, then can echo be used to execute a script in this manner?

    Is the application_top.php page a good place to place a small script that I intend to have active on all pages?

    This is my new 1.3.8 install....just set it up this week.

    New databases, no addons....yet.

    PS Has anyone ever added Javascript to a ZC php file?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: PHP and Javascript embedded within

    Making *any* edits to application_top.php is unadvisable unless you know exactly why you're doing it.

    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.

    There is documentation on the built-in support for javascript handling available here: http://www.zen-cart.com/wiki/index.p...s_-_Javascript
    .

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

    Default Re: PHP and Javascript embedded within

    Quote Originally Posted by DrByte View Post
    Making *any* edits to application_top.php is unadvisable unless you know exactly why you're doing it.

    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.

    There is documentation on the built-in support for javascript handling available here: http://www.zen-cart.com/wiki/index.p...s_-_Javascript
    From the above URL:

    Site-Wide jscript's

    jscript*.js files -- to be "linked" by your site

    Any file in the includes/templates/{template_directory}/jscript/ directory with the following filename format will be loaded globally on every page of your shop:




    OK....would {template_directory} then be the:

    CLASSIC
    (I am using the Classic template, and customizing as I go along)

    or

    TEMPLATE DEFAULT

    folder?

    Thanks to any forum members responding to this!!!!
    Last edited by Donn; 6 Feb 2009 at 01:04 AM.

  4. #4
    Join Date
    Jun 2003
    Posts
    33,721
    Plugin Contributions
    0

    Default Re: PHP and Javascript embedded within

    Don't use template_default. Thus, use the Classic - but make sure you read the FAQs on how to create your own custom template override so you won't lose your changes when you upgrade in the future.
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

 

 

Similar Threads

  1. Javascript product pages and php basket?
    By mattjb in forum General Questions
    Replies: 2
    Last Post: 9 Oct 2014, 10:42 AM
  2. Javascript help with embedded video
    By rottiejoe in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 2 Feb 2011, 03:11 AM
  3. Javascript within blank_sidebox mod
    By skyegospel in forum Addon Sideboxes
    Replies: 5
    Last Post: 29 Oct 2008, 06:18 PM
  4. Embedded Javascript inside an EZ-Page
    By dcarrith in forum General Questions
    Replies: 4
    Last Post: 10 Jun 2008, 04:47 AM
  5. Replies: 7
    Last Post: 24 Nov 2007, 05:39 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