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

    help question Using javascript and a separate css for the header.

    Basic info

    - I am using v 1.3.9h
    - this is a brand new install
    - No add ons

    OK I am doing a redesign of a site for the client and if you look at my mockup page at http://www.oceanabyssaquatics.ca/redo you will see that the header uses a javascript that changes the header to match the season or holiday (to see what I mean just just change the date on your computer to - let's say Jan 1 and then refresh the page). All together there are 21 different headers.

    QUESTION 1: How can I implement this into the header of ZC?
    QUESTION 2: Where is the best place to store the js files and the 21 images?


    As you will see on the same page above, I also have a carousel type javascript at the very top of the main body of the page (Scrolling Ads) this also uses it's own css. If possible; I would like to implement this ad scroller at the top of the main body of ZC on ALL PAGES.

    QUESTION 3: How can I implement this into the header of ZC?
    QUESTION 4: Where is the best place to store the images, css and javascript?

    Thank you all in advance for your assistance.

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

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

    Seperate the logo from the head image as a transparent gif & name it logo.gif - - remainder is applied as a background image in css
    I don't know what your js is but review the tutorial about adding/naming js files - - and for all pages it is in the js dir inside of your template dir
    https://www.zen-cart.com/tutorials/index.php?article=36
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

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

    Thank you for your assistance Let's deal with the first issue first. I cant do it like you suggested for a few reasons:

    1. The logo uses more than 256 colors therefore a transparent gif is out of the question.

    2. The logo itself will change on occasion. What you have described to me is fine if the logo itself is static and the only the background behind the logo changes.

    That being said; if you have not actually looked at the mock up and the source as well as changed dates on your computer and refreshed your web browser in order to see the changes then I suggest you do so. Then I believe you will understand what I am asking.

    If you have checked it out then you have likely misunderstood what I want...Let me know if you need more clarification.

    BTW here is the javascript and the call is below it...in case you want to see it:
    Code:
    var holiday = [
    [ "1025", "1030", "logohalow.jpg" ],
    [ "1101", "1111", "logoremem.jpg" ],
    [ "1112", "1130", "logoautumn.jpg" ],
    [ "1201", "1209", "logowinter.jpg" ],
    [ "1210", "1223", "logogreetings.jpg" ],
    [ "1224", "1226", "logoxmas.jpg" ],
    [ "1227", "1230", "logowinter.jpg" ],
    [ "1231", "1231", "logonewyear.jpg" ],
    [ "0101", "0103", "logonewyear.jpg" ],
    [ "0104", "0206", "logowinter.jpg" ],
    [ "0207", "0214", "logovalen.jpg" ],
    [ "0215", "0309", "logowinter.jpg" ],
    [ "0310", "0317", "logostpatty.jpg" ],
    [ "0318", "0319", "logowinter.jpg" ],
    [ "0320", "0331", "logospring.jpg" ],
    [ "0401", "0401", "logofool.jpg" ],
    [ "0402", "0421", "logospring.jpg" ],
    [ "0422", "0423", "logogood.jpg" ],
    [ "0424", "0425", "logoeaster.jpg" ],
    [ "0426", "0523", "logospring.jpg" ],
    [ "0524", "0525", "logovictor.jpg" ],
    [ "0526", "0620", "logospring.jpg" ],
    [ "0621", "0630", "logosummer.jpg" ],
    [ "0701", "0702", "logocanada.jpg" ],
    [ "0703", "0921", "logosummer.jpg" ],
    [ "0922", "1001", "logoautumn.jpg" ],
    [ "1002", "1010", "logothanks.jpg" ],
    [ "1011", "1024", "logoautumn.jpg" ],
    ];
    
    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;
    }
    }
    }
    Code:
    <img src="./logo.jpg" onload="setImgByDate(this,holiday)">
    Thanks again
    Last edited by Tantirx; 25 Nov 2010 at 06:18 AM.

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

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

    1. The logo uses more than 256 colors therefore a transparent gif is out of the question.
    My photoshop can export to a 256 color gif...

    2. The logo itself will change on occasion. What you have described to me is fine if the logo itself is static and the only the background behind the logo changes.
    All the more reason to seperate it - then you only need change one image and not the dozen that you are talking about
    Zen-Venom Get Bitten

  5. #5
    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
    My photoshop can export to a 256 color gif...


    All the more reason to seperate it - then you only need change one image and not the dozen that you are talking about
    I'm not trying to be difficult but I am aware of how Photoshop works. Not to mention the whole idea of the script is AUTOMATION and the ability to eliminate changing that part of the site...ever.

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

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

    Then just add the js according to the Zen convention I linked earlier and add the rotator code to your header
    Zen-Venom Get Bitten

  7. #7
    Join Date
    Nov 2010
    Posts
    52
    Plugin Contributions
    0

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

    I have added the javascript according to the Zen convention you linked earlier. But it's not working...it's showing up when you view source on the page but there is one more html line that needs to be added...namely:

    Code:
    <img src="./logo.jpg" onload="setImgByDate(this,holiday)">
    This code is placed in the spot where header logo would go. The img src loads the "default logo header image" and the "onload" command overrides the "default logo header image" and the java script looks at the date on the users computer and loads the logo banner according to the date. The img src="./logo.jpg" is simply a fail safe in case the js fails.

    More suggestions please.

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

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

    Ok I found how to add and onload command :)

    It still doesn't work Someone must have the expertise to assist me with more to get this to work. I chose Zen Cart for the huge amount of options available.

    But; if I can't get this damn thing skinned then I will go back to another cart system with less options but I can get it to look the way it needs to look. I really hate CubeCart.

    Can someone assist?

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

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

    This code is placed in the spot where header logo would go.
    How
    about the actual file name and more of the surrounding code
    Zen-Venom Get Bitten

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

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

    You posted a URL which you said is your mockup page.
    What's the URL to your Zen Cart page where this alleged problem can be seen in action?
    .

    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 1 of 3 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