Web Design Forum: CS-Cart how to add additional scripts to head section - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CS-Cart how to add additional scripts to head section Rate Topic: -----

#1 User is offline   gfxpixeldesigns 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 495
  • Joined: 29-October 07
  • Reputation: 1
  • Gender:Male
  • Location:United Kingdom, Mossley
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 15 November 2009 - 07:17 PM

Working with CS-Cart at the moment but cant seem to figure out how to add additional scripts to the <head> section just wondered if anyone on here knows how ? Ive tried placing my scripts in the index.tpl just before the </head> but on preview the scripts arent loaded :/? Ive also tried adding them to scripts.tpl and meta.tpl which gives the same result. Im lost, never guessed it would be this difficult to add a couple scripts.

Heres the scripts im adding:
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {$('#tabs').tabify();});(function($){$.fn.extend({tabify:function(){function getHref(a){hash=$(a).find('a').attr('href');if(hash)return hash.substring(0,hash.length-4);else return false}function setActive(a){$(a).addClass('active');if(getHref(a))$(getHref(a)).show();else return false;$(a).siblings('li').each(function(){$(this).removeClass('active');$(getHref(this)).hide()})}return this.each(function(){var a=this;$(this).find('li a').each(function(){$(this).attr('href',$(this).attr('href')+'-tab')});function handleHash(){if(location.hash)setActive($(a).find('a[href='+location.hash+']').parent())}if(location.hash)handleHash();setInterval(handleHash,100);$(this).find('li').each(function(){if($(this).hasClass('active'))$(getHref(this)).show();else $(getHref(this)).hide()})})}})})(jQuery);
</script>
<script type="text/javascript">
function profile_menu(id) {
  var d = document.getElementById(id);
  if(d.style.display == 'none') {
    d.style.display = 'block';
  } else {
    d.style.display = 'none';
  }
}
</script>


Any help is appreciated, thanks.
0

#2 User is online   BlueDreamer 

  • Web Guru
  • Group: Moderators
  • Posts: 5,802
  • Joined: 23-October 07
  • Reputation: 202
  • Gender:Male
  • Location:Northampton (where?)
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 15 November 2009 - 07:55 PM

Look for meta.tpl or at the top of index.tpl :)

This post has been edited by BlueDreamer: 15 November 2009 - 07:56 PM

0

#3 User is offline   gfxpixeldesigns 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 495
  • Joined: 29-October 07
  • Reputation: 1
  • Gender:Male
  • Location:United Kingdom, Mossley
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 15 November 2009 - 08:03 PM

Thanks BlueDreamer but i tried both those suggestions already to no avail, if i add the scripts to my index.tpl i get the following smarty error "Fatal error: Smarty error: [in index.tpl line 18]: syntax error: unrecognized tag: $('#tabs').tabify(); (Smarty_Compiler.class.php, line 445) in /home/tigeris/public_html/lib/templater/Smarty.class.php on line 1095" and if i add the scripts to the meta.tpl nothing at all changes, the scripts dont load nor are they listed. Im really lost with this, just cant figure it out :/

My edited index.tpl (the head section)
{* $Id: index.tpl 7454 2009-05-14 08:42:13Z angel $ *}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="{$smarty.const.CART_LANGUAGE|lower}">
<head>
{strip}
<title>
{if $page_title}
	{$page_title}
{else}
	{foreach from=$breadcrumbs item=i name="bkt"}
		{if !$smarty.foreach.bkt.first}{$i.title}{if !$smarty.foreach.bkt.last} :: {/if}{/if}
	{/foreach}
	{if !$skip_page_title}{if $breadcrumbs|count > 1} - {/if}{$lang.page_title_text}{/if}
{/if}
</title>
{/strip}
<script type="text/javascript">
$(document).ready(function () {$('#tabs').tabify();});(function($){$.fn.extend({tabify:function(){function getHref(a){hash=$(a).find('a').attr('href');if(hash)return hash.substring(0,hash.length-4);else return false}function setActive(a){$(a).addClass('active');if(getHref(a))$(getHref(a)).show();else return false;$(a).siblings('li').each(function(){$(this).removeClass('active');$(getHref(this)).hide()})}return this.each(function(){var a=this;$(this).find('li a').each(function(){$(this).attr('href',$(this).attr('href')+'-tab')});function handleHash(){if(location.hash)setActive($(a).find('a[href='+location.hash+']').parent())}if(location.hash)handleHash();setInterval(handleHash,100);$(this).find('li').each(function(){if($(this).hasClass('active'))$(getHref(this)).show();else $(getHref(this)).hide()})})}})})(jQuery);
</script>
<script type="text/javascript">
function profile_menu(id) {
  var d = document.getElementById(id);
  if(d.style.display == 'none') {
    d.style.display = 'block';
  } else {
    d.style.display = 'none';
  }
}
</script>
{include file="meta.tpl"}
<link href="{$images_dir}/icons/favicon.ico" rel="shortcut icon" />
{include file="common_templates/styles.tpl" include_dropdown=true}
{include file="common_templates/scripts.tpl"}

</head>


0

#4 User is offline   gfxpixeldesigns 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 495
  • Joined: 29-October 07
  • Reputation: 1
  • Gender:Male
  • Location:United Kingdom, Mossley
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 15 November 2009 - 08:46 PM

Got it, for some reason the scripts only work if your linking to them so you cant include the script itself you've gotta create a new .js file and inlude it that way.
0

#5 User is offline   gfxpixeldesigns 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 495
  • Joined: 29-October 07
  • Reputation: 1
  • Gender:Male
  • Location:United Kingdom, Mossley
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 15 November 2009 - 09:43 PM

Ok, so ive got my scripts loaded now however the tabs ive been trying to add now wont work. Ive basically copied the code from my own site re-design here http://gfxpixeldesig...gnsnewdesign09/ (tabs under what i do) so cant understand why it wont work. Basically its powered by jquery along with another little jquery script to switch the tabs but on the site ive added this to its just listing them all so to me its like the scripts ive added are not being loaded ? See the page im working on here http://www.tigeris.c...ew&product_id=2

and the full code for my tabs ( if you test this you'll need the jquery library )
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function () {$('#tabs').tabify();});(function($){$.fn.extend({tabify:function(){function getHref(a){hash=$(a).find('a').attr('href');if(hash)return hash.substring(0,hash.length-4);else return false}function setActive(a){$(a).addClass('active');if(getHref(a))$(getHref(a)).show();else return false;$(a).siblings('li').each(function(){$(this).removeClass('active');$(getHref(this)).hide()})}return this.each(function(){var a=this;$(this).find('li a').each(function(){$(this).attr('href',$(this).attr('href')+'-tab')});function handleHash(){if(location.hash)setActive($(a).find('a[href='+location.hash+']').parent())}if(location.hash)handleHash();setInterval(handleHash,100);$(this).find('li').each(function(){if($(this).hasClass('active'))$(getHref(this)).show();else $(getHref(this)).hide()})})}})})(jQuery);
</script>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
#tabs{
	margin:0;
	padding:0;
	width:460px;
	float:left;
	display:inline;
	background-attachment: scroll;
	background-image: url(images/seperator.gif);
	background-repeat: no-repeat;
	background-position: right center;
}
#tabs h3{
	margin: 0px;
	color:#BF0000;
	font-size: 36px;
	padding-top: 0;
	padding-right: 0;
	padding-bottom: 20px;
	padding-left: 0;
	font-weight: normal;
}
#tabs ul{margin:0;padding:0;}
#tabs li{padding:0;margin:5px 0;list-style-type:none;}
#tabs li a {
	color:#000;
	margin:0;
	padding:3px 40px;
	display:block;
	text-decoration:none;
}
#tabs li a:hover{color:#BF0000; text-decoration: underline;}
#tabs li.active a{color:#BF0000; text-decoration: underline;}
.tabcontent {
	width:461px;
	border-left:none;
	padding:0 10px;
	margin:0;
	float:right;
	display:inline;
}
.tabcontent h3{padding: 0 0 10px 0; margin: 0px; color:#2080D0;}
-->
</style>
</head>

<body>
<div class="tab-container">
  <div id="tabs">
    <h3>What i <strong>do</strong></h3>
    <ul>
      <li class="web-design-thumb active"><a href="#tabs-1">Web Design and Development</a></li>
      <li class="cms-thumb"><a href="#tabs-2">Content Management Systems</a></li>
      <li class="ecommerce-thumb"><a href="#tabs-3">eCommerce</a></li>
      <li class="logo-design-thumb"><a href="#tabs-4">Logo Design</a></li>
      <li class="print-design-thumb"><a href="#tabs-5">Print Design</a></li>
      <li class="illustration-thumb"><a href="#tabs-6">Illustration</a></li>
      <li class="web-hosting-thumb"><a href="#tabs-7">Web Hosting and Domain Names</a></li>
      <li class="seo-thumb"><a href="#tabs-8">Search Engine Optimisation</a></li>
    </ul>
    <div class="clear"></div>
  </div>
  <div id="tabs-1" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Web Design and Development</h3>
    <p>I have been designing and developing websites for the past 4 years. Working closely with my clients im able to create fantastic professional looking websites.</p>
    <p><a href="">Read More</a></p>
  </div>
  <div id="tabs-2" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Content Management Systems</h3>
    <p>If your looking for a web site where the content is easy to manage and update then my hosted cms is for you. Its as easy as writing an email !</p>
  </div>
  <div id="tabs-3" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>E-commerce</h3>
    <p>If your looking for a way to sell your products online, then you'll need an ecommerce site. I will work closely with you, helping you decide which ecommerce solution to go for.</p>
  </div>
  <div id="tabs-4" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Logo Design</h3>
    <p>Using my creative design skills i will create numerous logo mockups until we arrive at something your happy with.</p>
  </div>
  <div id="tabs-5" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Print Design</h3>
    <p>From brochures about herbal teas to flyers advertising white elephants ! I do just about everything.</p>
  </div>
  <div id="tabs-6" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Illustration</h3>
    <p>I enjoy the odd bit of pencil work too.</p>
  </div>
  <div id="tabs-7" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Web hosting</h3>
    <p>As well as being a designer i have a passion for web hosting, running my own dedicated server im able to offer my clients with reliable shared hosting and its cheap as chips at just £1.50 per month !</p>
  </div>
  <div id="tabs-8" class="tabcontent">
    <div style="height:65px;"></div>
    <h3>Search engine optimisation</h3>
    <p>I include basic seo with all my web design's, it wont get you on the first page of google but it certainly raises your chances. With the nature of the internet improving your search engine rankings is the most difficult step, submitting your site to various search engines and optimising your meta tags i can get you started but if you want fast results that are guaranteed to work go to an seo expert. They'll charge you an arm and a leg but atleast the results are guaranteed !</p>
  </div>
  <div class="clear"></div>
</div>
</body>
</html>


0

#6 User is offline   DustinSievers43 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 26-November 11
  • Reputation: 0

Posted 26 November 2011 - 09:14 AM

You have to put your script call inside of these tags {literal} {/literal}

{literal}
<script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript">$(document).ready(function () {$('#tabs').tabify();});(function($){$.fn.extend({tabify:function(){function getHref(a){hash=$(a).find('a').attr('href');if(hash)return hash.substring(0,hash.length-4);else return false}function setActive(a){$(a).addClass('active');if(getHref(a))$(getHref(a)).show();else return false;$(a).siblings('li').each(function(){$(this).removeClass('active');$(getHref(this)).hide()})}return this.each(function(){var a=this;$(this).find('li a').each(function(){$(this).attr('href',$(this).attr('href')+'-tab')});function handleHash(){if(location.hash)setActive($(a).find('a[href='+location.hash+']').parent())}if(location.hash)handleHash();setInterval(handleHash,100);$(this).find('li').each(function(){if($(this).hasClass('active'))$(getHref(this)).show();else $(getHref(this)).hide()})})}})})(jQuery);</script>
{/literal}

I am positive this works. Be prepared for your popup larger images to no longer work as this is what happened to me. There must be a conflict between cs cart's lightbox javascript and the new javascript I place in my index.tpl

Check out my work at my temporary URL http://ecbiz60.inmot...llyb7/index.php
We are currently using this website www.billybobproducts.com
0

#7 User is offline   rallport 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 3,813
  • Joined: 03-January 10
  • Reputation: 266
  • Gender:Male
  • Location:England, UK
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 27 November 2011 - 11:19 AM

Doesn't sound like a very good cart if adding some of your own simple JavaScript is such a pain in the ass.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users