Hi guys,
I just started a new project and was trying to add a
AnyLink Drop Down Menu into my header.tpl file.
When I add the script into <head> section on my header.tpl page.
I get an error:
Fatal error: Smarty error: [in header.tpl line 149]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 583) in /home/test/public_html/include/smarty/Smarty.class.php on line 1095
header.tpl Code:
Code:
{html_doctype omitxml=true xhtml=false}
<html>
<head>
<title>test</title>
<base href='{$url->url_base}'>
<link rel="stylesheet" href="./templates/styles.css" title="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{* CODE FOR POPUP TIPS, DO NOT REMOVE *}
<!--[if gte IE 5.5]>
<![if lte IE 6]>
<iframe id="shim" src="" style="position:absolute;display:none;filter:progid:DXImageTransform.Microsoft.Chroma(Color='#ffffff');" scrolling="no" frameborder="0"></iframe>
<iframe id="shim2" src="" style="position:absolute;display:none;filter:progid:DXImageTransform.Microsoft.Chroma(Color='#ffffff');" scrolling="no" frameborder="0"></iframe>
<![endif]>
<![endif]-->
{* CODE FOR VARIOUS JAVASCRIPT-BASED FEATURES, DO NOT REMOVE *}
<script type="text/javascript" src="./include/js/tips.js"></script>
<script type="text/javascript" src="./include/js/showhide.js"></script>
<script type="text/javascript" src="./include/js/suggest.js"></script>
<script type="text/javascript" src="./include/js/status.js"></script>
{* ASSIGN PLUGIN MENU ITEMS AND INCLUDE NECESSARY STYLE/JAVASCRIPT FILES *}
{section name=header_loop loop=$global_plugins}{include file="header_`$global_plugins[header_loop]`.tpl"}{/section}
{array var="global_plugin_menu" value=''}
{* INSERT USER'S CUSTOM CSS IF ANY *}
<style type='text/css'>{$global_css}</style>
<script type="text/javascript">
/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a>'
menu1[1]='<a href="http://www.freewarejava.com">Freewarejava.com</a>'
menu1[2]='<a href="http://codingforums.com">Coding Forums</a>'
menu1[3]='<a href="http://www.cssdrive.com">CSS Drive</a>'
//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="http://cnn.com">CNN</a>'
menu2[1]='<a href="http://msnbc.com">MSNBC</a>'
menu2[2]='<a href="http://news.bbc.co.uk">BBC News</a>'
var menuwidth='165px' //default menu width
var menubgcolor='lightyellow' //menu bgcolor
var disappeardelay=250 //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?
/////No further editting needed
var ie4=document.all
var ns6=document.getElementById&&!document.all
if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}
function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}
function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}
function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}
function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)
if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}
return clickreturnvalue()
}
function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}
function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}
function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}
function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}
function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}
function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
if (hidemenu_onclick=="yes")
document.onclick=hidemenu
</script>
</head>
<body>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1038982-9";
urchinTracker();
</script>
{* START PAGE *}
<table cellpadding='0' cellspacing='0' width='950' align='center'>
<tr>
<td align='center'>
{* SHOW PAGE TOP ADVERTISEMENT BANNER *}
<div class='ad_top' style='display: block; visibility: visible;'>{$ads->ad_top}</div>
<table cellpadding='0' cellspacing='0' align='center' width='100%'>
<tr>
<td class='topbar1'><img src='./images/logo.png' border='0'></td>
<td class='topbar1' align='right'>
<form action='search.php' method='POST'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>{$header1} </td>
<td><input type='text' name='search_text' class='text' size='25'> </td>
<td><input type='submit' class='button' value='{$header2}'></td>
</tr>
</table>
<input type='hidden' name='task' value='dosearch'>
<input type='hidden' name='t' value='0'>
</form>
</td>
</tr>
<tr>
<td class='topbar2'>
<a href='home.php' class='top_menu_item'>{$header3}</a>
<a href='search.php' class='top_menu_item'>{$header4}</a>
{if $setting.setting_signup_invite != 1} <a href='{if $user->user_exists != 0}user_{/if}invite.php' class='top_menu_item'>{$header5}</a> {/if}
{* IF USER IS LOGGED IN, SHOW 'FIND FRIENDS' MENU ITEM *}
{if $user->user_exists != 0}
<a href='user_invite.php?findfriends=1' class='top_menu_item'>{$friendsinviter_global1}</a>
{/if}
<a href='help.php' class='top_menu_item'>{$header6}</a>
</td>
<td class='topbar2_right'>
{* IF USER IS LOGGED IN, SHOW APPROPRIATE TOP MENU ITEMS *}
{if $user->user_exists != 0}
{$header7} <a href='user_home.php' class='top_menu_item'>{$user->user_info.user_username}</a>
<b><a href='user_logout.php' class='top_menu_item'>{$header8}</a></b>
{* IF USER IS NOT LOGGED IN, SHOW APPROPRIATE TOP MENU ITEMS *}
{else}
<b><a href='signup.php' class='top_menu_item'>{$header9}</a>
<a href='login.php' class='top_menu_item'>{$header10}</a></b>
{/if}
</td>
</tr>
{* SHOW MENU IF USER IS LOGGED IN AND ACCESSING USER AREA *}
{if $user->user_exists != 0}
<tr>
<td class='menu' colspan='2'>
<table cellpadding='0' cellspacing='0'>
<tr>
{* SHOW PROFILE MENU ITEM *}
<td class='menu_item'>
<a href='user_home.php' class='menu_item'><img src='./images/icons/menu_home.gif' border='0' class='icon'>{$header11}</a>
</td>
{* SHOW PROFILE MENU ITEM *}
<td class='menu_item'>
<a href='{$url->url_create('profile', $user->user_info.user_username)}' class='menu_item'><img src='./images/icons/menu_profile.gif' border='0' class='icon'>{$header12}</a> [<a href='user_editprofile.php'>{$header13}</a>]
</td>
{* SHOW FRIENDS MENU ITEM IF ENABLED *}
{if $setting.setting_connection_allow != 0}
<td class='menu_item'>
<a href='user_friends.php' class='menu_item'><img src='./images/icons/menu_friends.gif' border='0' class='icon'>{$header16}</a>
</td>
{/if}
{* SHOW ANY PLUGIN MENU ITEMS *}
{section name=menu_loop loop=$global_plugin_menu}
{if $global_plugin_menu[menu_loop] != ''}
<td class='menu_item'>
<a href='{$global_plugin_menu[menu_loop].0}' class='menu_item'><img src='./images/icons/{$global_plugin_menu[menu_loop].1}' border='0' class='icon'>{$global_plugin_menu[menu_loop].2}</a>
</td>
{/if}
{/section}
{* SHOW MESSAGES MENU ITEM IF ENABLED *}
{if $user->level_info.level_message_allow != 0}
<td class='menu_item'>
<a href='user_messages.php' class='menu_item'><img src='./images/icons/menu_messages.gif' border='0' class='icon'>{$header18}{if $user_unread_pms != 0} ({$user_unread_pms}){/if}</a>
</td>
{/if}
{* SHOW SETTINGS *}
<td class='menu_item'>
<a href='user_account.php' class='menu_item'><img src='./images/icons/menu_account.gif' border='0' class='icon'>{$header19}</a>
</td>
</tr>
</table>
</td>
</tr>
{/if}
<tr><td class='shadow' colspan='2'><img src='./images/shadow.gif' border='0'></td></tr>
</table>
{* BEGIN PAGE CONTENT *}
<table cellpadding='0' cellspacing='0' width='100%' align='center'>
<tr>
{* SHOW LEFT-SIDE ADVERTISEMENT BANNER *}
{if $ads->ad_left != ""}<td class='ad_left' width='1' style='display: table-cell; visibility: visible;'>{$ads->ad_left}</td>{/if}
<td class='content'>
{* SHOW BELOW-MENU ADVERTISEMENT BANNER *}
{$ads->ad_belowmenu}
This is the code from header.tpl that I want to add the dropdown links:
For Example: More (rest of the plugin links will display as a dropdown).
Code:
{* SHOW ANY PLUGIN MENU ITEMS *}
{section name=menu_loop loop=$global_plugin_menu}
{if $global_plugin_menu[menu_loop] != ''}
<td class='menu_item'>
<a href='{$global_plugin_menu[menu_loop].0}' class='menu_item'><img src='./images/icons/{$global_plugin_menu[menu_loop].1}' border='0' class='icon'>{$global_plugin_menu[menu_loop].2}</a>
</td>
{/if}
{/section}
I Have also added the following, into my style.css file:
Code:
#dropmenudiv{
position:absolute;
border:1px solid black;
border-bottom-width: 0;
font:normal 12px Verdana;
line-height:18px;
z-index:100;
}
#dropmenudiv a{
width: 100%;
display: block;
text-indent: 3px;
border-bottom: 1px solid black;
padding: 1px 0;
text-decoration: none;
font-weight: bold;
}
#dropmenudiv a:hover{ /*hover background color*/
background-color: yellow;
}
I spend lot of time to get this working but I am not very good with smarty code. I can provide more info if needed to understand the error.
I would really appreciate the help. Thanks in advance.