Results 1 to 10 of 15

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Charlottesville VA
    Posts
    1,192
    Plugin Contributions
    18

    Default Including jquery with ready doc statements

    I've found myself with a number of jquery based contributions at this point and am now working on streamlining adding in jquery mods that use the ready document statements in the header or footer.

    Doing one mod only requires the addition of a small bit of script into the html_header.php file and is simple for install purposes.

    However, if someone wants to have several jquery mods installed they have to combine 2 statements together and it's just not a simple thing.

    So I was wanting to set up something to control that without the html_header.php /footer being edited. I'm heading towards figuring out how to best do it thru admin configuration setting.

    But I wanted to see if anyone would talk about how jquery might be added in the next version of zen cart. Since jquery is supposed to be added in, I don't really want to do something that doesn't work well with the next version or has to be totally redone.

    If that gets no answer, then I'm open to suggestions.

    What I'm looking at doing would be to:
    1. have the ready doc statements added to a config group for jquery
    2. each would then have an activate / no activate setting
    3. choice of header or footer placement
    4. ability to edit settings inside the each statement
    5. ability to limit that setting to only certain pages

    Am I leaving out anything? Does this sound like an easy / straight forward way of doing it? I dislike have to fancy up coding or add new files just to accomplish a goal and want to keep it as simple as possible so that installation becomes a slam dunk.

  2. #2
    Join Date
    May 2006
    Location
    Charlottesville VA
    Posts
    1,192
    Plugin Contributions
    18

    Default Re: Including jquery with ready doc statements

    Muddling through this myself for the first mod which is pretty simple.

    So far I have created the configuration group and configuration setting which are only 2, 1 to activate the mod and 1 for the page is it needed on which is the product_info page.

    I created a define statement that contains the actual javascript for the document ready statement.

    In the the html_header then, I have placed the enclosing script and now have to create the php that goes inside.
    Code:
    <script type="text/javascript">
    $(document).ready(function() {
    <?php 
    code to be entered here.
    ?>
    });
    </script>
    So now, I need to call up all the jquery mods that are in the database.

    The php comes next:

    The gist of it is if it has the configuration_group_title of 'jQuery Document Ready', then echo each active one here.

    A loop and array are required obviously. I don't remember seeing a loop to pull from configuration settings like that. Trying to follow zen cart code here and or going for efficiency.

    What the best way to do this?

  3. #3
    Join Date
    May 2006
    Location
    Charlottesville VA
    Posts
    1,192
    Plugin Contributions
    18

    Default Re: Including jquery with ready doc statements

    and one more thing - since this will require a select statement, should that be included there in the html header or separated out into another file or place?

  4. #4
    Join Date
    Jan 2004
    Posts
    58,249
    Blog Entries
    3
    Plugin Contributions
    106

    Default Re: Including jquery with ready doc statements

    You don't want to be putting a bunch of javascript statements into configuration settings. That'll start flagging things under PCI/PA-DSS inspections.

    Better to follow something like the existing on_load stuff already in core ... esp since it's essentially the same task, but done differently.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donations always welcome: www.zen-cart.com/donate

    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.

  5. #5
    Join Date
    May 2006
    Location
    Charlottesville VA
    Posts
    1,192
    Plugin Contributions
    18

    Default Re: Including jquery with ready doc statements

    Great, thanks for the advice and direction. I had veered away from that but still didn't hit on that.

  6. #6
    Join Date
    May 2006
    Location
    Charlottesville VA
    Posts
    1,192
    Plugin Contributions
    18

    Default Re: Including jquery with ready doc statements

    One of the things I was trying to do is be able to activate/deactivate this by not having the ready doc statement included. So I can definitely have the statement added in by creating a jscript file for the pages/product_info folder, but that's too automatic. Is there a way to flag it off and on 'cause I don't think there is.

    Normally the js and the document ready function are separate with jQuery - of course, I'm no expert at jQuery. I just know this is the way the jQuery is done normally.

 

 

Similar Threads

  1. Statements skipped during the upgrade from 1.38a to 1.3.9h
    By musicfreer in forum Upgrading from 1.3.x to 1.3.9
    Replies: 1
    Last Post: 13 Jan 2011, 08:40 PM
  2. Skipped Upgrade Statements
    By twofair in forum Upgrading from 1.3.x to 1.3.9
    Replies: 3
    Last Post: 7 Nov 2010, 10:29 PM
  3. SQL statements
    By jasonsmith991 in forum General Questions
    Replies: 3
    Last Post: 30 Sep 2010, 09:32 PM
  4. Meta statements
    By rdcast in forum General Questions
    Replies: 1
    Last Post: 14 Mar 2010, 07:56 PM
  5. Privacy & Conditions Statements
    By tweakage in forum General Questions
    Replies: 2
    Last Post: 5 Jun 2006, 01:21 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
  •