X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   How do I add Javascript? (https://forum.x-cart.com/showthread.php?t=41047)

boomobile 07-31-2008 12:28 PM

Re: How do I add Javascript?
 
OK, so I tried to place it, but it breaks the code somewhere. I took out all extra spaces, and extra hard returns, but still won't display. It actually wipes out everything below that point. any suggestions?

boomobile 07-31-2008 12:36 PM

Re: How do I add Javascript?
 
Ok, so I placed the js file in my "scripts" folder with the other js. Copied page code directly from dynamic drive and placed it in the correct area that I want the marquee to display, but it breaks the code somewhere and everything after the code is blank.

Quote:

<div id="tempholder"></div>
<script language="JavaScript" src="../scripts/dhtmllib.js"></script>
<script language="JavaScript" src="../scripts/scroller.js"></script>
<script language="JavaScript">

/*
Mike's DHTML scroller (By Mike Hall)
Last updated July 21st, 02' by Dynamic Drive for NS6 functionality
For this and 100's more DHTML scripts, visit http://www.dynamicdrive.com
*/

//SET SCROLLER APPEARANCE AND MESSAGES
var myScroller1 = new Scroller(0, 0, 480, 32, 1, 5); //(xpos, ypos, width, height, border, padding)
myScroller1.setColors("#006600", "#ccffcc", "#009900"); //(fgcolor, bgcolor, bdcolor)
myScroller1.setFont("Verdana,Arial,Helvetica", 2);
myScroller1.addItem("<b>Click here for <a href='http://dynamicdrive.com'>Dynamic Drive</a>, the net\'s #1 DHTML site!</b>");
myScroller1.addItem("<b>Visit <a href='http://www.brainjar.com'>Brain Jar</a>, Mike\'s great coding site!</b>");
myScroller1.addItem("<b>Looking for free JavaScripts? Visit <a href='http://javascriptkit.com'>JavaScript Kit.</a>");
myScroller1.addItem("<b>Discuss and get help on web coding, at <a href='http://www.codingforums.com'>CodingForums.com</a></b>");

//SET SCROLLER PAUSE
myScroller1.setPause(2500); //set pause beteen msgs, in milliseconds

function runmikescroll() {

var layer;
var mikex, mikey;

// Locate placeholder layer so we can use it to position the scrollers.

layer = getLayer("placeholder");
mikex = getPageLeft(layer);
mikey = getPageTop(layer);

// Create the first scroller and position it.

myScroller1.create();
myScroller1.hide();
myScroller1.moveTo(mikex, mikey);
myScroller1.setzIndex(100);
myScroller1.show();
}

window.onload=runmikescroll
</script>
<div id="placeholder" style="position:relative; width:420px; height:32px;"> </div>
-----END SCROLLING MARQUEE---------------------------*}

Group Imaging 07-31-2008 12:40 PM

Re: How do I add Javascript?
 
Um, I think you may have this put in the wrong place? If that code is all within the <head> tags then you shouldn't have a <div> in there. If you have this in the <body> tags then you will need to move it before the </head> tag.

boomobile 07-31-2008 01:09 PM

Re: How do I add Javascript?
 
This is not in the head, this is the code for the actual marquee scroller. I can get it working just fine alone, but when I place it in the homepage.tpl it breaks the rest of the page.

Group Imaging 07-31-2008 01:15 PM

Re: How do I add Javascript?
 
Quote:

<script language="JavaScript" src="../scripts/dhtmllib.js"></script>
<script language="JavaScript" src="../scripts/scroller.js"></script>

Those need to be in the <head>

boomobile 07-31-2008 01:30 PM

Re: How do I add Javascript?
 
hmmm, I don't have any other refrences to java in my head.tpl , any other suggestions?
What about my common_js.tpl ? would I copy the js files I have into this? There's got to be a way to refrence it...

Group Imaging 07-31-2008 01:31 PM

Re: How do I add Javascript?
 
Sorry, it wouldn't be in head.tpl it would be in customer/home.tpl the head tags in there.

boomobile 07-31-2008 01:50 PM

Re: How do I add Javascript?
 
there aren't any head tags in any of my tpl files. I didn't create this shop, so I have no idea how things were modified. The person who did is of no help, he can't remember that far back... :(

Group Imaging 07-31-2008 01:55 PM

Re: How do I add Javascript?
 
Code from skin1_original/customer/home.tpl:

Quote:

{* $Id: home.tpl,v 1.88.2.10 2007/06/18 12:38:57 max Exp $ *}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{if $printable ne ''}
{include file="customer/home_printable.tpl"}
{else}
{config_load file="$skin_config"}
<html>
<head>
<title>{strip}
{capture name=title}
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{if not %position.first%}&nbsp;::&nbsp;{/if}
{$location[position].0|strip_tags|escape}
{/section}
{else}
{section name=position loop=$location step=-1}
{if not %position.first%}&nbsp;::&nbsp;{/if}
{$location[position].0|strip_tags|escape}
{/section}
{/if}
{/capture}
{if $config.SEO.page_title_limit <= 0}
{$smarty.capture.title}
{else}
{$smarty.capture.title|replace:"&nbsp;":" "|truncate:$config.SEO.page_title_limit|replac e:" ":"&nbsp;"}
{/if}
{/strip}</title>
{include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}" />




</head>







<body{$reading_direction_tag}{if $body_onload ne ''} onload="javascript: {$body_onload}"{/if}>
{include file="rectangle_top.tpl" }
{include file="head.tpl" }
{if $active_modules.SnS_connector}
{include file="modules/SnS_connector/header.tpl"}
{/if}
<!-- main area -->
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="VertMenuLeftColumn">
{if $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{include file="customer/categories.tpl" }
<br />
{/if}
{if $active_modules.Bestsellers ne "" and $config.Bestsellers.bestsellers_menu eq "Y"}
{include file="modules/Bestsellers/menu_bestsellers.tpl" }
{/if}
{if $active_modules.Manufacturers ne "" and $config.Manufacturers.manufacturers_menu eq "Y"}
{include file="modules/Manufacturers/menu_manufacturers.tpl" }
{/if}
{include file="customer/special.tpl"}
{if $active_modules.Survey && $menu_surveys}
{foreach from=$menu_surveys item=menu_survey}
{include file="modules/Survey/menu_survey.tpl"}
<br />
{/foreach}
{/if}
{include file="help.tpl" }
<img src="{$ImagesDir}/spacer.gif" width="150" height="1" alt="" />
</td>
<td valign="top" width="100%">
<!-- central space -->
{include file="location.tpl"}

{if $gcheckout_enabled and $main ne "cart" and $main ne "checkout" and $main ne "anonymous_checkout" and $main ne "order_message"}
<div align="right">{include file="modules/Google_Checkout/gcheckout_button.tpl"}</div>
{/if}

{include file="dialog_message.tpl"}

{if $active_modules.Special_Offers ne ""}
{include file="modules/Special_Offers/customer/new_offers_message.tpl"}
{/if}

{include file="customer/home_main.tpl"}
<!-- /central space -->
&nbsp;
</td>
<td class="VertMenuRightColumn">
{if $active_modules.SnS_connector && $config.SnS_connector.sns_display_button eq 'Y' && $sns_collector_path_url ne ''}
{include file="modules/SnS_connector/button.tpl"}
<br />
{/if}
{if $active_modules.Feature_Comparison ne "" && $comparison_products ne ''}
{include file="modules/Feature_Comparison/product_list.tpl" }
<br />
{/if}
{include file="customer/menu_cart.tpl" }
<br />
{if $login eq "" }
{include file="auth.tpl" }
{else}
{include file="authbox.tpl" }
{/if}
{include file="news.tpl" }
{if $active_modules.XAffiliate ne "" && $config.XAffiliate.partner_register eq 'Y'}
<br />
{include file="partner/menu_affiliate.tpl" }
{/if}
{if $active_modules.Interneka ne ""}
<br />
{include file="modules/Interneka/menu_interneka.tpl" }
{/if}
<br />
{include file="poweredby.tpl" }
<br />
<img src="{$ImagesDir}/spacer.gif" width="150" height="1" alt="" />
</td>
</tr>
</table>
{include file="rectangle_bottom.tpl" }
{if $active_modules.Google_Analytics ne "" && $config.Google_Analytics.ganalytics_code ne ""}
{include file="modules/Google_Analytics/ga_code.tpl"}
{/if}
</body>
</html>
{/if}


That's how the original is so you can try using that if there's not too much of a difference in what they have in there now. All you should really need is the top part that I separated out. I purposely included a bunch of extra line breaks in the code so you could where I'm talking about easily.

But all of that said, you should just be able to include those 2 lines of js reference right above the </head> tag even if you just created your own <head></head> tags. If you still aren't sure maybe you could post the code from customer/home.tpl

boomobile 07-31-2008 02:12 PM

Re: How do I add Javascript?
 
AHHH! home.tpl yes I see the head tags, will try it now...


All times are GMT -8. The time now is 01:04 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.