Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Smarty.class.php vs JavaScript
#1
This thing is consuming my patience and my nerves. Could anyone tell me how to fix this thing, beocuse every time i try to add jd script to the index page, its give me errors like this:

Code:
Fatal error: Smarty error: [in ../templates/index.tpl line 67]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 583) in D:\Documents and Settings\Andrei\Desktop\dslan_v1.4\htdocs\lib\smarty\Smarty.class.php on line 1095
[Image: whc49f1c81d81bfb.jpg]
Reply
#2
Then it obviously tries to interpret JavaScript code as Smarty.
Please show your index.tpl.

Regards
Molt
Reply
#3
Thats the script that i want to use ... Smile

Code:
<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="snob.png"
myimages[2]="spear.png"
myimages[3]="spy.png"
myimages[4]="paladin.png"
myimages[5]="sword.png"
myimages[6]="archer.png"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://www.javascriptkit.com"
imagelinks[2]="http://www.netscape.com"
imagelinks[3]="http://www.microsoft.com"
imagelinks[4]="http://www.dynamicdrive.com"
imagelinks[5]="http://www.freewarejava.com"
imagelinks[6]="http://www.cnn.com"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>
[Image: whc49f1c81d81bfb.jpg]
Reply
#4
(10.11.2013, 20:48)Molt Wrote: Please show your index.tpl.

I mean the whole file.
Reply
#5
PHP Code:
<!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" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
    <
head>
        <
title>Tribal Wars</title>

        <
meta id="og_title" property="og:title" content="Triburile"/>
        <
meta id="og_type" property="og:type" content="game"/>
        <
meta id="og_url" property="og:url" content="http://www.triburile.ro/index.php"/>
        <
meta id="og_image" property="og:image" content="http://www.die-staemme.de/graphic/reports/support_arrives.jpg"/>
        <
meta id="og_site_name" property="og:site_name" content="Triburile"/>
        <
meta id="fb_app_id" property="fb:app_id" content="110344252415324"/>

                    <
meta id="og_description" property="og:description" content="Triburile - Jocul online"/>
        
        <
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <
meta name="description" content="Triburile este un joc online bazat pe un Browser. Fiecare jucător este stăpânul unui mic sat, pe care îl aduce la faimă şi putere." />
        <
meta name="keywords" content="joc browser, Browsergame, joc online, jocuri online, Multiplayer, gratis, strategie, evul mediu" />
        <
link rel="stylesheet" type="text/css" href="http://www.triburile.ro/merged/index.css?1383645284" />

        <
script type="text/javascript" src="http://www.triburile.ro/merged/index.js?1383645284"></script>

                        

    </
head>

    <
body>
    





<
div class="pb-tab"></div></div>


        <
div id="index_body">
            <
div id="main">
                        <
div id="header">
                <
h1>
                    <
a href="/index.php" style="background:url(http://cdn2.tribalwars.net/8.16/18968/graphic/lang/ro/bg-logo.jpg?f1c2c) no-repeat 100% 0;">
                        <
p style="position: absolute; top: -300px">Triburile Jocul online</p>
                    </
a>
                </
h1>
                <
div class="navigation">
                    <
div class="navigation-holder">
                        <
div class="navigation-wrapper">
                            <
div id="navigation_span">
                                <
a href="http://help.triburile.ro">Ajutor</a> - <a href="rules.php">Reguli joc</a>  - <a href="http://forum.triburile.ro/">Forum</a>  - <a href="ticket.php">Suport</a>  -  <a href="sds_rounds.php">Speed</a>  - <a href="team.php">Echipa</a>  - <a href="stat.php">Statistică</a>  -  <a href="hall_of_fame.php">Hall of Fame </a>  - <a href="sds_masters.php">Turneu speed</a> - <a href="http://www.tribalwars.net/wallpapers.php"target="_blank">Wallpapers</a>


                            </
div>
                        </
div>
                </
div>
                </
div>
                <
span class="paladin"><img src="http://ts4.tribalwarsmasters.net/graphic/unit_popup/archer.png" alt="" /></span>            </div>
                            <
div id="content">
                    <
div class="container-block">
                        <
div class="container-top"></div>
                        <
div class="container">
                                                    <
div class="info-block">
                                <
h2>Tribal Wars</h2>
                                <
p>Welcome to Tribal Wars!!!</p>

                                                                        <
class="btn-kostenlos-anmelden" href="register.php">Register now for free!</a>
                                                                        <
strong align="center">~ Already {$playersplayers! ~</strong>
                                    
                                <
div>
                                                                        
                                                                       </
div>
                                   <
div class="clear"></div>
                            </
div>
                        
                        <!--  
tracking_snipping_landing -->
                        
                        
                        <!--  
tracking_snipping_inno -->
                        
                        
                        
<
div class="login-block">
    <
h2 style="text-align:left;margin-bottom:15px;">Login</h2>
    
    <
div id="world_selection" class="ar_login" style="display: none;">
        <
a href="#" onclick="$('#world_selection').hide();return false;" class="login_close">
            <
img src="graphic/login_close.png" alt="Închide" style="border:none" />
        </
a>
        <
div class="servers-list-top"></div>
        <
div id="servers-list-block"></div>
        <
div class="servers-list-bottom"></div>
    </
div>

    <
noscript>
        <
div id="nojs_warning">
            <
class="error" style="color: #b40000">Pentru a putea juca triburile trebuie să activezi Javascript.</p>
                        <
p>
                <
a href="http://help.triburile.ro/wiki/Activare_JavaScript">&raquoCum se activează Javascript?</a>
            </
p>
                    </
div>
    </
noscript>

    <
form action="index.php?action=login" method="post" >
        <
div>
            <
label for="user">
                <
strong >User name:</strong>
                <
span >
                    <
input id="user" name="user" class="text" type="text" value="" onkeydown="if((e=window.event||event) && e.keyCode == 13 && $('#user').val() && $('#password').val()) $('#login_form').submit()"/>
                </
span>
            </
label>
            <
label for="password">
                <
strong >Password:</strong>
                <
span >
                    <
input name="clear" type="hidden" value="true" />
                    <
input id="password" name="password" class="text" type="password"
                           
onkeydown="if((e=window.event||event) && e.keyCode == 13 && $('#user').val() && $('#password').val()) $('#login_form').submit()"/>
                </
span>
            </
label>
            
            <
input type="submit" id="login_submit_button" style="display: none" />

            <
label for="cookie" style="text-align:right;">
                <
input id="cookie" type="checkbox" name="cookie" value="true"  />
                    {
$lang->get("login_permanent")}
            </
label>

            <
div id="login-buttons">
                                <
a id="fb-login-button" class="social-login-button" href="http://ipp-facebook.innogames.de/?game=staemme&market=ro" title="Joacă prin Facebook"></a>
                            
                <
div id="js_login_button">
                    <
a href="#" onclick="$('#login_submit_button').click()" class="login_button">
                        <
span class="button_left"></span>
                        <
span class="button_middle">Login</span>
                        <
span class="button_right"></span>
                    </
a>
                </
div>            
            </
div>

            <
br style="clear:both;"/>
        </
div>
    </
form>
    <
div style="position: absolute; bottom: 10px">
        <
a href="http://www.triburile.ro/lost_pw.php">Recuperarea parolei:</a>
            </
div>
</
div>



                        </
div>
                        <
div class="container-bottom"></div>
                    </
div>
                </
div><!-- content -->
                            
                            
            
                            <
div class="closure">
                &
copy2003 2013
                
<a target="_blank" href="http://www.innogames.com/ro">InnoGames GmbH</a> &middot;                <a href="http://legal.innogames.de/staemme/ro/imprint" target="_blank">Impresum</a> &middot;
                <
a href="http://legal.innogames.de/staemme/ro/privacy" target="_blank">Protecţie de date</a>
                &
middot; <a href="http://legal.innogames.de/staemme/ro/agb" target="_blank">Termeni şi condiţii generale</a>
                &
middot; <a href="http://www.triburile.ro/news.php?type=rss2.0"><img src="http://cdn2.tribalwars.net/8.16/18968/graphic/index/icon_rss.png?ed0e8" alt="RSS" border="0" style="vertical-align:text-bottom;" /></a><br />

                                

                
                            </
div>
            </
div><!-- main -->

            <
div id="screenshot" style="display:none" onclick="Index.hide_screenshot();">
                <
div id="screenshot_image"></div>
            </
div>
        </
div>
                
    </
body>
</
html
[Image: whc49f1c81d81bfb.jpg]
Reply
#6
(10.11.2013, 20:50)tero20051 Wrote: Thats the script that i want to use ... Smile

Code:
<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="snob.png"
myimages[2]="spear.png"
myimages[3]="spy.png"
myimages[4]="paladin.png"
myimages[5]="sword.png"
myimages[6]="archer.png"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://www.javascriptkit.com"
imagelinks[2]="http://www.netscape.com"
imagelinks[3]="http://www.microsoft.com"
imagelinks[4]="http://www.dynamicdrive.com"
imagelinks[5]="http://www.freewarejava.com"
imagelinks[6]="http://www.cnn.com"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>

Why don´t you do that with php?

PHP Code:
$imgs[0]="snob.png";
$imgs[1]="spear.png";
$imgs[2]="spy.png";
$imgs[3]="paladin.png";
$imgs[4]="sword.png";
$imgs[5]="archer.png";

$links[0]="http://www.javascriptkit.com";
$links[1]="http://www.netscape.com";
$links[2]="http://www.microsoft.com";
$links[3]="http://www.dynamicdrive.com";
$links[4]="http://www.freewarejava.com";
$links[5]="http://www.cnn.com";

$rand rand(0count($imgs) - 1);
print 
'<a href="' $links[$rand] . '"><img src="' $imgs[$rand] . '" border="0"></a>'

MfG Manuel
Reply
#7
I'm not sure, i dont use Smarty, but i think its not allowed to put "{" and "}" in a .tpl file with smarty. You need to save your javascript to a .js file and then load it in HTML with the Script tag like this:
PHP Code:
<script src="yourJsFile.js"></script
✝ RiP 
Weiter geht's  Cool
Reply
#8
{literal}
<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="snob.png"
myimages[2]="spear.png"
myimages[3]="spy.png"
myimages[4]="paladin.png"
myimages[5]="sword.png"
myimages[6]="archer.png"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://www.javascriptkit.com"
imagelinks[2]="http://www.netscape.com"
imagelinks[3]="http://www.microsoft.com"
imagelinks[4]="http://www.dynamicdrive.com"
imagelinks[5]="http://www.freewarejava.com"
imagelinks[6]="http://www.cnn.com"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>
{/literal}
Reply
#9
(11.11.2013, 17:02)delacurtais Wrote: {literal}
<script language="JavaScript">
<!--

/*
Random Image Link Script- By JavaScript Kit(http://www.javascriptkit.com)
Over 200+ free JavaScripts here!
Updated: 00/04/25
*/

function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="snob.png"
myimages[2]="spear.png"
myimages[3]="spy.png"
myimages[4]="paladin.png"
myimages[5]="sword.png"
myimages[6]="archer.png"

//specify corresponding links below
var imagelinks=new Array()
imagelinks[1]="http://www.javascriptkit.com"
imagelinks[2]="http://www.netscape.com"
imagelinks[3]="http://www.microsoft.com"
imagelinks[4]="http://www.dynamicdrive.com"
imagelinks[5]="http://www.freewarejava.com"
imagelinks[6]="http://www.cnn.com"

var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=0></a>')
}
random_imglink()
//-->
</script>
{/literal}

You sir is an genius, thanks you verry mutch ...
[Image: Give-That-man-a-Medal.jpg]
[Image: whc49f1c81d81bfb.jpg]
Reply




Users browsing this thread: 4 Guest(s)