Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 29
  1. #11
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

    Default Re: Using javascript and a separate css for the header.

    Sorry all...brain fart

    The url for the ZC installation is http://www.oceanabyssaquatics.ca/store/ I have done nothing but trying to skin this thing. As u see I have the background image in place and the overall width is where it should be. I did also make a new template called abyss and followed the directions in the tutorials. I did find some discrepancies between the tutorials and advice in other threads. That is why when you view source on the main ZC page you will see two of the same javascript instances in two different locations....arg.

    Another Note: the bar above (what is now the zc logo) with the home and login links will stay there. The header/logo/js combo will be where the ZC logo and the "TagLine Here" text is. The header should be 100px x 150px (which it is).

    I know CSS well as well as HTML....I can loosely follow php and javascript (and I do emphasis loosely)

    I believe the onload should be in the "logowrapper" and not the body tag.

    Thanks for looking
    Last edited by Tantirx; 26 Nov 2010 at 03:42 AM.

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

    Default Re: Using javascript and a separate css for the header.

    There are a few ways to tackle this situation:

    a) use javascript, as you're doing. The downside is that this creates a (brief) slowdown in page execution while the javascript processes. And, since it doesn't process until the page has fully loaded, the actual desired image doesn't get loaded until after the rest of the page has finished loading (when the javascript tells the browser which image to load).
    If that's what you want to do, you'll need to move the onload() out of the place you've put it, and into the actual image code inside your template file.
    (The onload functionality you're hooking into is for page-wide onloads, not element-specific onloads like images.)

    tpl_header.php (your custom version of it):
    Code:
        <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT, '', '', ' onload="setImgByDate(this,holiday)"') . '</a>'; ?></div>
    b) Or you could just write the logic into PHP code to select the right image immediately before the page is even sent to the browser.
    Same line of code from the template, with a different change:
    Code:
        <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . $selectedSeasonalImage, HEADER_ALT_TEXT) . '</a>'; ?></div>
    Then create another new file for the calculation: /includes/extra_configures/select_seasonal_header_image.php
    Code:
    <?php
    // convert your javascript logic for calculating the right image here
    // and set $selectedSeasonalImage to that image filename as the last thing you do in this file.
    
    blah 
    blah
    blah
    $selectedSeasonalImage = [the new logo_xyz.jpg filename]
    Last edited by DrByte; 26 Nov 2010 at 05:15 AM. Reason: added missing apostrophe
    .

    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. #13
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

    Default Re: Using javascript and a separate css for the header.

    tried your first suggestion page went blank (only page background showing)

    Second suggestion just simply did not work. As you can see the page is completely blank with NO CODE AT ALL. Here is the code I uses for the selected_seasonal_image.php file (which is located in /includes/extra_configures)

    Code:
    <?php
    // convert your javascript logic for calculating the right image here
    // and set $selectedSeasonalImage to that image filename as the last thing you do in this file.
    
    
    function disable(){return false}
    function setImgByDate(imgRef,dateList) {
    imgRef.onload = disable;
    var today = new Date();
    var month = 1+today.getMonth();
    if (month<10) month = "0"+month;
    var date = today.getDate();
    if (date<10) date = "0"+date;
    var MMDD = ""+month+date;
    for (var i=0; i<dateList.length; i++) {
    if (MMDD>=dateList[i][0] && MMDD<=dateList[i][1]) {
    imgRef.src = dateList[i][2];
    return;
    }
    }
    }
    
    $selectedSeasonalImage = [
    [ "1025", "1030", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logohalow.jpg" ],
    [ "1101", "1111", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logoremem.jpg" ],
    [ "1112", "1130", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logoautumn.jpg" ],
    [ "1201", "1209", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logowinter.jpg" ],
    [ "1210", "1223", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logogreetings.jpg" ],
    [ "1224", "1226", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logoxmas.jpg" ],
    [ "1227", "1230", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logowinter.jpg" ],
    [ "1231", "1231", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logonewyear.jpg" ],
    [ "0101", "0103", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logonewyear.jpg" ],
    [ "0104", "0206", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logowinter.jpg" ],
    [ "0207", "0214", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logovalen.jpg" ],
    [ "0215", "0309", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logowinter.jpg" ],
    [ "0310", "0317", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logostpatty.jpg" ],
    [ "0318", "0319", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logowinter.jpg" ],
    [ "0320", "0331", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logospring.jpg" ],
    [ "0401", "0401", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logofool.jpg" ],
    [ "0402", "0421", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logospring.jpg" ],
    [ "0422", "0423", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logogood.jpg" ],
    [ "0424", "0425", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logoeaster.jpg" ],
    [ "0426", "0523", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logospring.jpg" ],
    [ "0524", "0525", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logovictor.jpg" ],
    [ "0526", "0620", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logospring.jpg" ],
    [ "0621", "0630", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logosummer.jpg" ],
    [ "0701", "0702", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logocanada.jpg" ],
    [ "0703", "0921", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logosummer.jpg" ],
    [ "0922", "1001", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyssimages/logoautumn.jpg" ],
    [ "1002", "1010", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logothanks.jpg" ],
    [ "1011", "1024", "http://www.oceanabyssaquatics.ca/store/includes/templates/abyss/images/logoautumn.jpg" ],
    As you can see I used the fullpath to the images in the code (just to be sure.

  4. #14
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

    Default Re: Using javascript and a separate css for the header.

    What next?

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

    Default Re: Using javascript and a separate css for the header.

    1. Probably a typo of some sort. Or an error on my part. mismatched quotation marks and apostrophes?
    Reference: https://www.zen-cart.com/tutorials/index.php?article=82

    2. You can't just dump javascript code into a PHP file and have it magically work as PHP. You'll have to rewrite your logic into PHP format.




    Edit: yup, missing apostrophe at the end of my suggested change.
    .

    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. #16
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

    Default Re: Using javascript and a separate css for the header.

    Quote Originally Posted by DrByte View Post
    1. Probably a typo of some sort. Or an error on my part. mismatched quotation marks and apostrophes?
    Reference: https://www.zen-cart.com/tutorials/index.php?article=82

    2. You can't just dump javascript code into a PHP file and have it magically work as PHP. You'll have to rewrite your logic into PHP format.




    Edit: yup, missing apostrophe at the end of my suggested change.
    Rewriting the logic is completely alien to me

    Like I mentioned before my thing is HTML, XHTML, CSS ...javascript and php are like Chinese to me. I can implement scripts (and I have done so hundreds of times with pre-made scripts). But trying to implement them into a complex language like php is completely foreign.

  7. #17
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Using javascript and a separate css for the header.

    Like I mentioned before my thing is HTML, XHTML, CSS ...javascript and php are like Chinese to me. I can implement scripts (and I have done so hundreds of times with pre-made scripts). But trying to implement them into a complex language like php is completely foreign.
    Have you has success with this in just a html page??

    Edited:
    I believe that your demo page might have been this??
    Zen-Venom Get Bitten

  8. #18
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

    Default Re: Using javascript and a separate css for the header.

    Quote Originally Posted by kobra View Post
    Have you has success with this in just a html page??

    Edited:
    I believe that your demo page might have been this??
    Yes the demo page shows how it should work. The top part (logo banner with the fall leaves) is the script I am workin on now. The part below is the ad banner (this will eventually be at the very top of the main content column) and uses jquery and 3 js files.

    As you can see from my mockup (demo) page...the design is sound...it's just a matter of implementation into a language I have almost no clue about; namely php.
    Last edited by Tantirx; 26 Nov 2010 at 06:33 AM.

  9. #19
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: Using javascript and a separate css for the header.

    Looking at your 2 pages I did not see alignment in the js being used??
    The ZenCart is using jscript_seasons.js and seasons is not seen on your mockup page??

    If this is square and correct try entering in a COPY for your template in the tpl_header.php file and change from
    Code:
    <!--bof-branding display-->
    <div id="logoWrapper">
        <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div>
    And replace with this and see what results
    Code:
    <!--bof-branding display-->
    <div id="logoWrapper">
        <div id="logo"><a href="http://www.oceanabyssaquatics.ca/store/"><img src="./logo.jpg" onload="setImgByDate(this,holiday)"></div>
    If this works should later add the html ALT entry
    Last edited by kobra; 26 Nov 2010 at 07:00 AM.
    Zen-Venom Get Bitten

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

    Default Re: Using javascript and a separate css for the header.

    Quote Originally Posted by Tantirx View Post
    Rewriting the logic is completely alien to me

    Like I mentioned before my thing is HTML, XHTML, CSS ...javascript and php are like Chinese to me. I can implement scripts (and I have done so hundreds of times with pre-made scripts). But trying to implement them into a complex language like php is completely foreign.
    Fine.
    Use the corrected code I posted for approach #1, and live with the consequences of using javascript to accomplish what you're after.
    .

    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.

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. v154 Need a javascript expert! Can't trigger css class using href...
    By Feznizzle in forum General Questions
    Replies: 10
    Last Post: 27 May 2016, 05:45 PM
  2. Loss of CSS styles images and main header logo on SSL when using the server's browser
    By oldwolfe in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 13 Oct 2009, 02:13 PM
  3. Using Separate Image for Shopping Cart Header
    By Craig Robbo in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 5 Feb 2009, 11:06 AM
  4. Using a CSS Navigation Menu for the top NAV bar
    By spikeycactus in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 30 Oct 2008, 10:59 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