hashstar Posted April 17, 2012 Share Posted April 17, 2012 Hi there, I am trying to add a spry menu bar to my smarty based website. I have the menu working fine on a standalone page www.organicgrowshop.co.uk/email_form.php but when i try to add the code to a .tpl file it doesn't work ! Am i missing something major here? I have other javascript working fine in the same .tpl i am trying to add this to, so i don't understand why it will not work??! Can anyone shed any light on this for me? Many thanks, Hash {if $smarty.server.REQUEST_URI == '/product/vermiculite.html'} {config_load 'config.conf' section='vermiculite'} {elseif $smarty.server.REQUEST_URI == '/product/Perlite.html'} {config_load 'config.conf' section='Perlite'} {elseif $smarty.server.REQUEST_URI == '/product/Guano.html'} {config_load 'config.conf' section='Guano'} {elseif $smarty.server.REQUEST_URI == '/product/claypebbles.html'} {config_load 'config.conf' section='claypebbles'} {elseif $smarty.server.REQUEST_URI == '/product/coir.html'} {config_load 'config.conf' section='coir'} {else} {config_load 'config.conf' section=$configs} {/if}<!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <META NAME="DESCRIPTION" CONTENT="{#description#}"> <META NAME="KEYWORDS" CONTENT="{#keywords#}"> <title>{#shop_name#} - {#title#}</title> <style type="text/css"> /* The outermost container of the Menu Bar, a fixed width box with no margin or padding */ ul.MenuBarVertical { margin: 0; padding: 0; list-style-type: none; font-size: 100%; cursor: default; width: 0em; } /* Set the active Menu Bar with this class, currently setting z-index to accomodate IE rendering bug: http://therealcrisp.xs4all.nl/meuk/IE-zindexbug.html */ ul.MenuBarActive { z-index: 1000; } /* Menu item containers, position children relative to this container and are same fixed width as parent */ ul.MenuBarVertical li { margin: 0; padding: 0; list-style-type: none; font-size: 100%; position: relative; text-align: left; cursor: pointer; width: 178px; } /* Submenus should appear slightly overlapping to the right (95%) and up (-5%) with a higher z-index, but they are initially off the left side of the screen (-1000em) */ ul.MenuBarVertical ul { margin: -5% 0 0 95%; padding: 0; list-style-type: none; font-size: 100%; position: absolute; z-index: 1020; cursor: default; width: 180; left:-1000em; top: 0; } /* Submenu that is showing with class designation MenuBarSubmenuVisible, we set left to 0 so it comes onto the screen */ ul.MenuBarVertical ul.MenuBarSubmenuVisible { left: 0; } /* Menu item containers are same fixed width as parent */ ul.MenuBarVertical ul li { width: 180; } /******************************************************************************* DESIGN INFORMATION: describes color scheme, borders, fonts *******************************************************************************/ /* Outermost menu container has borders on all sides */ ul.MenuBarVertical { border: 1px solid #CCC; } /* Submenu containers have borders on all sides */ ul.MenuBarVertical ul { border: 1px solid #CCC; } /* Menu items are a light gray block with padding and no text decoration */ ul.MenuBarVertical a { display: block; cursor: pointer; background-color: #EEE; padding: 0.5em 0.75em; color: #333; text-decoration: none; } /* Menu items that have mouse over or focus have a blue background and white text */ ul.MenuBarVertical a:hover, ul.MenuBarVertical a:focus { background-color: #76b1b2; color: #FFF; } /* Menu items that are open with submenus are set to MenuBarItemHover with a blue background and white text */ ul.MenuBarVertical a.MenuBarItemHover, ul.MenuBarVertical a.MenuBarItemSubmenuHover, ul.MenuBarVertical a.MenuBarSubmenuVisible { background-color: #76b1b2; color: #FFF; } /******************************************************************************* SUBMENU INDICATION: styles if there is a submenu under a given menu item *******************************************************************************/ /* Menu items that have a submenu have the class designation MenuBarItemSubmenu and are set to use a background image positioned on the far left (95%) and centered vertically (50%) */ ul.MenuBarVertical a.MenuBarItemSubmenu { background-image: url(../SpryAssets/SpryMenuBarRight.gif); background-repeat: no-repeat; background-position: 95% 50%; } /* Menu items that are open with submenus have the class designation MenuBarItemSubmenuHover and are set to use a "hover" background image positioned on the far left (95%) and centered vertically (50%) */ ul.MenuBarVertical a.MenuBarItemSubmenuHover { background-image: url(../SpryAssets/SpryMenuBarRightHover.gif); background-repeat: no-repeat; background-position: 95% 50%; } /******************************************************************************* BROWSER HACKS: the hacks below should not be changed unless you are an expert *******************************************************************************/ /* HACK FOR IE: to make sure the sub menus show above form controls, we underlay each submenu with an iframe */ ul.MenuBarVertical iframe { position: absolute; z-index: 1010; filter:alpha(opacity:0.1); } /* HACK FOR IE: to stabilize appearance of menu items; the slash in float is to keep IE 5.0 from parsing */ @media screen, projection { ul.MenuBarVertical li.MenuBarItemIE { display: inline; f\loat: left; background: #FFF; } </style> <script type="text/javascript" src="{#url#}SpryAssets/SpryMenuBar.js"></script> {if isset($friendly)}<link href="{#url#}{$friendly}.css" rel="stylesheet" type="text/css" />{else}<link href="{#url#}{$configs}.css" rel="stylesheet" type="text/css" />{/if} <link href="{#url#}print.css" rel="stylesheet" type="text/css" media="print" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="{#url#}scripts/site.js"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-27276661-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> {if $configs=='contact'} <script src="{#url#}SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="{#url#}SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script> <link href="{#url#}spry.css" rel="stylesheet" type="text/css" /> {/if} <script type="text/javascript"> function getCount(){ $.ajax( { url: '{#url#}cart.php', type: 'GET', data:{ 'count':'true' }, success: function( response ) { var countCart = parseFloat(response); if(countCart=='0'){ $('#checkoutTop').empty(); $('#shopping').hide(); }else{ $('#checkoutTop').html(' | <a href="{#url#}Cart.html">Checkout</a>'); $('#shopping').show(); } } }); } function updateMiniCart(){ $.ajax( { url: '{#url#}cart.php', type: 'GET', data:{ 't':'mini_cart' }, success: function( response ) { getCount(); $('#myMiniCart').html(response); } }) } function updateCart(a){ $.ajax( { url: '{#url#}cart.php', type: 'GET', data: a, success: function( response ) { updateMiniCart(); getCount(); } }) } $(document).ready(function() { getCount(); updateMiniCart() setInterval ( "getCount()", 20000 ); }); </script> </head> <body> <div class="container"> <p style="display:inline;"> </p> <p><a href="{#url#}"><img border="0" src="{#url#}images/{$style[0].logo}" width="135" height="185" alt="Organic Grow Shop Logo" title="Welcome to The Organic Grow Shop" /></a></p> <div id="tagline">Bringing you Earth's natural goodness</div> <div id="date"> {'dS F Y'|date:$smarty.now} </div> <div id="yourbasket"> <a href="{#url#}cart.html"><image src="{#url#}images/{$style[0].view}" border="0" alt="View Basket" /></a> <div class="my_cart"> <div class="block-content" id="myMiniCart"> <p class="empty"></p> </div> </div> </div> <div id="h-navbar"> <a href="{#url#}home.html">Home </a>| <a href="{#url#}Aboutus.html">About Us</a> | <a href="{#url#}contactus.html">Contact Us</a> | <a href="{#url#}wormcasttea.html">FAQ</a><span id="checkoutTop"></span>{if $loggedIn=='in'} | <a href="{#url#}admin.php">Admin</a> | <a href="{#url#}admin.php?logout">Logout</a>{elseif $loggedIn=='out'} | <a href="{#url#}login.html">Login</a>{/if} </div> <div class="sidebar1"> <div id="v-navbarheader">Grow Shop</div> <ul id="MenuBar1" class="MenuBarVertical"> <li><a href="../product/Guano.html">Guano</a></li> <li><a href="../product/Wormcastings.html">Worm Castings</a></li> <li><a href="../product/Perlite.html">Perlite</a></li> <li><a href="../product/vermiculite.html">Vermiculite</a></li> <li><a href="../product/claypebbles.html">Clay Pebbles</a></li> <li><a href="../product/coir.html">Coir</a></li> <li><a class="MenuBarItemSubmenu" href="../product/ladybirds.html">Natural Pesticides</a> <ul> <li><a href="ladybirds.html">Ladybirds</a></li> </ul> </li> <li><a class="MenuBarItemSubmenu" href="../product/biopots1.html">Biodegradable pots</a> <ul class="MenuBarHorizontal"> <li><a href="biopots1.html">Short life 3.5"</a></li> <li><a href="biopots2.html">Short life 6.5"</a></li> <li><a href="biopots3.html">Long life 3.5"</a></li> <li><a href="biopots4.html">Long life life 6.5"</a></li> </ul> </li> </ul> </div> {if $configs=='about'} <div id="apDiv1"><img src="{#url#}images/wind-energy-emblem.gif" width="140" height="138" alt="wind energy logo" title="Our web host is powered by wind energy" /></div> {elseif $configs=='home'} <div id="apDiv1"> <div id="grow-mail"> <form action="subscribe.php " method="post" name="emailsignup" id="emailsignup"> <span class="rotateit1"> <span id="sprytextfield1" > <label for="signup"><br /> Sign up to Grow Mail<br /></label></span></span> <br /> <span class="rotateit2"> <label>We will keep you informed of new products, gardening advice and much more!<br /></label></span> <br /> <span class="line-2"><label><br /> Email address:</label></span> <input name="signup" type="text" id="signup" size="18" /> <input name="subscribe" type="submit" id="subscribe" value="Subscribe" /> </form> <span> </span></div><p> </p> <iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FThe-Organic-Grow-Shop%2F229793147037672&width=180&colorscheme=light&show_faces=false&border_color&stream=false&header=true&height=70" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:180px; height:70px;" allowTransparency="true"></iframe></div> {/if} <div class="content"> Quote Link to comment https://forums.phpfreaks.com/topic/261116-javascript-and-smarty/ Share on other sites More sharing options...
kicken Posted April 17, 2012 Share Posted April 17, 2012 { and } are special to smarty so if you want to use them otherwise (like in JS or CSS code) you have to surround those blocks with the {literal} {/literal} tags. Quote Link to comment https://forums.phpfreaks.com/topic/261116-javascript-and-smarty/#findComment-1338163 Share on other sites More sharing options...
hashstar Posted April 17, 2012 Author Share Posted April 17, 2012 Hi, Thanks for getting back to me! I had found that much but and have tried that but it doesn't work.... also doesn't explain why the js and css that i have in the template file is working??? Cheers, Hash Quote Link to comment https://forums.phpfreaks.com/topic/261116-javascript-and-smarty/#findComment-1338169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.