Syntax error unrecognized tag

Smarty error unrecognized tag I am trying to add Wow-Slider and Juicebox functionality to our websites but am getting an error each time, both highlighting an ‘Unrecognized Tag’. For Wow-Slider I am inserting the following: And getting the following error: Fatal error: Smarty error: [in evaluated template line 51]: syntax error: unrecognized tag: display:none […]

Содержание

  1. Smarty error unrecognized tag
  2. Как добавить код счётчика яндекс метрики в шаблон Smarty
  3. Smarty error unrecognized tag
  4. Smarty error unrecognized tag

Smarty error unrecognized tag

I am trying to add Wow-Slider and Juicebox functionality to our websites but am getting an error each time, both highlighting an ‘Unrecognized Tag’.

For Wow-Slider I am inserting the following:

And getting the following error:

Fatal error: Smarty error: [in evaluated template line 51]: syntax error: unrecognized tag: display:none (Smarty_Compiler.class.php, line 436) in /homepages/15/d387446348/htdocs/httpdocs/htlib/Smarty/libs/Smarty.class.php on line 1088

And getting the following error:

Fatal error: Smarty error: [in evaluated template line 51]: syntax error: unrecognized tag ‘baseUrl’ (Smarty_Compiler.class.php, line 580) in /homepages/15/d387446348/htdocs/httpdocs/htlib/Smarty/libs/Smarty.class.php on line 1088

Any guidance would be gratefully received. Back to top

mohrt
Administrator

Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

Posted: Fri Jun 28, 2013 1:10 pm Post subject:
Put tags around blocks of code that have <> braces in them that are not Smarty tags.

http://www.smarty.net/forums/viewtopic.php?t=4501

Back to top

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group

Источник

Как добавить код счётчика яндекс метрики в шаблон Smarty

Достался на продвижение и обслуживание корпоративный сайт, работающий под управлением HOST-CMS одной из самых первых версий. Возникла необходимость установить на сайт счётчик яндекс-метрики. Но при его установке возникла ошибка: «syntax error: unrecognized tag ‘var’«. Почему возникает эта ошибка и как её побороть, расскажу в этом посте. Как известно, ранние версии движка HOST-CMS работают на шаблонах Smarty. Одной из особенностей этого шаблонизатора является его особенная обработка фигурных скобок, которые включены непосредственно в шаблон. Компилятор Smarty обрабатывает эти скобки «как свои», в результате чего возникают ошибки вида

  • Fatal error: Uncaught exception ‘SmartyCompilerException’ with message ‘Syntax Error in template «…/
  • string(92) «Smarty error: [in tpl_head:12 line 36]: syntax error: unrecognized tag ‘var’ (Smarty_Compiler.class.php, line 261)»

а также нарушается целостность html-вёрстки сайта. В исходном коде же яндекс-метрики как раз содержатся фигурные скобки и «просто так» вставить код счётчика не получится.

Что делать? Нужно всего лишь обернуть код счётчика в специальные теги

где вместо многоточия — ваш код.

Также для эранирования фигурных скобок в скриптах можно использовать и конструкцию

Важный момент: смотрите внимательно, какой именно шаблон отвечает за вывод кода счётчика Метрики. Для неподготовленного пользователя это не всегда очевидно.

Источник

Smarty error unrecognized tag

I moved a website (running on smarty) to a new server today. So far it runs fine but when I included a new (analytics)javascript to index.tpl, which resulted in a

Fatal error: Smarty error: [in index.tpl line 290]: syntax error: unrecognized tag ‘var’ (Smarty_Compiler.class.php, line 590) in /home/lyriczz/domains/lyriczz.com/public_html/libs/Smarty.class.php on line 1113

I reverted index.tpl back to what it was, which removed the error, but now I am kinda lost.

What can I do to be able to change the index.tpl file? I am «kinda» technical, but I’m not a linux guru, so I hope somebody has some (easy to understand) tips.. Back to top

ricky12
Smarty n00b

Joined: 09 Dec 2010
Posts: 3

Posted: Thu Dec 09, 2010 7:40 pm Post subject:
Ok. I now found out that the error is caused by analytics. Around line 290 (as the error says) it looked like this:

var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-xxxxxxxxx’]);
_gaq.push([‘_trackPageview’]);

(function() <
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async =

The line with «(function() <» is line 290. Does anybody have any idea what the problem could be here?

Back to top

U.Tews
Administrator

Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

Posted: Thu Dec 09, 2010 8:05 pm Post subject:
The < of the javascript code in line 290 is interpreted as Smarty delimiter.

See http://www.smarty.net/docsv2/en/language.function.literal.tpl how to turn Smarty parsing of for javascript sections.

Back to top

ricky12
Smarty n00b

Joined: 09 Dec 2010
Posts: 3

Posted: Fri Dec 10, 2010 12:15 am Post subject:
That is indeed the solution to my problem!

Thanks you so much!

Back to top

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group

Источник

Smarty error unrecognized tag

I’m trying to update the header template and when I try to call the page, I get

Fatal error: Smarty: [in header.tpl line 16]: syntax error: unrecognized tag: //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i/home/virtual/site49/fst/var/www/html/lib/Smarty/Smarty_Compiler.class.php on line 2066

Does anyone know what could be the problem?

Sylvia Back to top

messju
Administrator

Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

Posted: Tue May 11, 2004 5:06 pm Post subject:
it looks like you edited the template with dreamweaver and dreamweaver inserted javascript containing «<» and «>» into the template.
«<» and «>» are the smarty delimiters, so smarty falsely wants to interpret the javascript-code in the template.
enclose the javascript-block in a . block to prevent smarty from parsing it. that should help.

Back to top

kguerrero
Smarty Rookie

Joined: 08 Apr 2007
Posts: 9

Originally I had:

So, I eliminated the <> . but I received the following error both times .
Fatal error: Smarty error: [in header.tpl line 11]: syntax error: unrecognized tag: //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i/mysite/home directory/smarty/libs/Smarty.class.php on line 1088

The code when using a basic image with no rollover function works just fine:

Any help or feed back is greatly appreciated.

Thanks,

Posted: Sun Apr 08, 2007 4:45 pm Post subject: Similar issue
I have a similar issue.

My main goal is to create the mouse rollover effect. I have used fireworks for the buttons and dreamweaver for integration.

My Code Currently Looks like this:

Back to top

Poper
Smarty Rookie

Joined: 17 Mar 2006
Posts: 24
Location: Niefern, Germany

Posted: Mon Apr 09, 2007 12:03 pm Post subject:
Hi,

already messju said it: Use javascript.

Code:
onMouseOut=»MM_swapImgRestore()» onMouseOver=»MM_swapImage(‘Home’,»,’images/home_f2.gif’,1)«>

_________________

Back to top

kguerrero
Smarty Rookie

Joined: 08 Apr 2007
Posts: 9

Posted: Mon Apr 09, 2007 12:20 pm Post subject: Got it
thanks. I completely, misunderstood. I guess that’s what I get for working on a Sunday .

It makes sense now that I see it . I don’t know what I was thinking when I read the previous posts

Back to top

aniket.agl
Smarty n00b

Joined: 07 Mar 2008
Posts: 1

Posted: Fri Mar 07, 2008 6:02 pm Post subject: My Shopping cart is not working
Hello,

I am facing a strange problem.. When I click on add to cart, on local host it works fine but on my web server, it displays the cart is empty..

The same page it would display when u click on shopping cart without purchasing any items, but on local host it works fine..

Can anyone tell me what I have to do.

Back to top

jstewart
Smarty n00b

Joined: 26 Feb 2010
Posts: 2

Posted: Fri Feb 26, 2010 11:18 pm Post subject:
Also, if you don’t want to use the tag, you can always change the delimeters smarty uses for parsing. Check out «Chapter 3: Escaping Smarty Parsing» in the Smarty manual.

This is useful when you have large portions of javascript code in your page. But keep in mind that it is a better idea to link the javascript to an external file, rather than embedding it into your html.

Back to top

achugg
Smarty n00b

Joined: 19 Mar 2010
Posts: 1

Posted: Fri Mar 19, 2010 3:30 am Post subject:
i still dont understand, im having the same problem. How can i fix it?

Back to top

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group

Источник

  • #1

Проблемы со SMARTY

Всем привет.
Использую смарти.
Пишу в шаблон вот такую вещь на яве:

PHP:

......
<script language=JavaScript><!--
var submit_pressed = false;
function check_validity (s,m)
	{ 
	var d;s = s.replace (",", ".");d = parseFloat ( s );
	if ( isNaN (d) )
		{
		alert (m);
		return false;
	      }
      	else return true;
	}
.......

Пытаюсь открыть этот шаблон в браузере выдает такое:

Fatal error: Smarty error: [in add.tpl line 18]: syntax error: unrecognized tag ‘var’ (Smarty_Compiler.class.php, line 551) in g:s_libsSmarty.class.php on line 1102

Смарти думает что я ему даю функцию его, которой у него нет. Как это можно испраить? Как смарти заставить не обращать внимание на такие вещи?

  • #2

Заключать такие вещи в {literal}

nw

nw

Новичок


  • #3

А еще можно заменить открывающий и закрывающий ограничитель (делимитер) с { и } на <{ и }>
Так например в xoops сделано. Я сам так делаю. Переустановить можно в файле Smarty.class.php

Demiurg

Guest


  • #4

nw
или на <%$#({ для верности.

nw

nw

Новичок


  • #5

Demiurg
Я признаю, что {literal} это более правильное решение и конечно по возможности лучше привыкать к нему, но подход с заменой делимитеров на <{ и }> во многих случаях позволяет не париться при подготовке шаблонов и не искать что нужно указать literal, а что из этого еще и исключать например с помощью {ldelim}{rdelim}. Imho.

  • #7

не думаю что человек юзающий смарти может не знать разницы

Member Avatar

12 Years Ago

im building a clone youtube site and the templates have smarty code every-time i try to add a style to it or even change the bg color of the template i get this error. could someone show me an example on what im supposed to do. and how it should look in the code.

here what i did

mohrt
can you should me an example with the top code

the was in a style tag on the php page.

Now the login page in login.php i tried to put html code above it like so:

<!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" />
<title>Poetry Battles</title>
<script language="javaScript" src="main.php"></script> 
<style type="text/css">
<!--
#header {
	position:absolute;
	left:87px;
	top:0px;
	width:800px;
	height:20px;
	z-index:1;
	background-color: #0d0600;
}
#content {
	position:absolute;
	left:3px;
	top:29px;
	width:1000px;
	height:1300px;
	z-index:-1;
	background-image: url(intro%20bg.png);
	background-repeat: no-repeat;
}
#footer {
	position:absolute;
	left:9px;
	top:1346px;
	width:990px;
	height:50px;
	z-index:3;

then

>?php


info


?>

thats when i got the error and had to take the style out. thats what happens when i try to modify any of the templates with a style i want my site to be a browish color

Edited

12 Years Ago
by kvprajapati because:

Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).


Recommended Answers

What is going on with these lines?

z-index:3;

then

>?php


info


?>

Doesn’t really look right.
You have not closed the <style type="text/css"> or <!-- , you are missing a } to indicate that you have finished the styles for #footer and PHP is opened …

Jump to Post

It might be helpful to post the actual code you used when you got the error.

Jump to Post

If this code is in a default smarty template then the curly brackets (from the stylesheet) denote a template variable. Either change the curly brackets, use {literal} or put the CSS in a separate file. Note that using javascript in a smarty template has the same issue.

Jump to Post

All 11 Replies

Member Avatar

12 Years Ago

What is going on with these lines?

z-index:3;

then

>?php


info


?>

Doesn’t really look right.
You have not closed the <style type="text/css"> or <!-- , you are missing a } to indicate that you have finished the styles for #footer and PHP is opened with <?php not >?php I also have no idea why you have a random then and info in there either…

Member Avatar

12 Years Ago

that wasn’t my actual code because when i got the error message i changed it back. it was just an example but in the code i did code the tags and i put the word then to just show you that after my html code i put my php script.

Member Avatar

12 Years Ago

It might be helpful to post the actual code you used when you got the error.

Member Avatar


pritaeas

2,130



¯_(ツ)_/¯



Moderator



Featured Poster


12 Years Ago

If this code is in a default smarty template then the curly brackets (from the stylesheet) denote a template variable. Either change the curly brackets, use {literal} or put the CSS in a separate file. Note that using javascript in a smarty template has the same issue.

Member Avatar

12 Years Ago

my bad !! okay this is the error
Fatal error: Smarty error: [in login.tpl line 3]: syntax error: unrecognized tag: font-family: Trebuchet MS; font-size: 14px; color: #996633; (Smarty_Compiler.class.php, line 455) in /home/poetryba/public_html/include/smarty/libs/Smarty.class.php on line 1092

this is my code

<style type="text/css">
<!--
body,td,th {
	font-family: Trebuchet MS;
	font-size: 14px;
	color: #996633;
}
body {
	background-color: #0d0600;
}
a:link {
	color: #996633;
}
a:visited {
	color: #996633;
}
a:hover {
	color: #00FFFF;
}
a:active {
	color: #996633;
}
--></style>

{if $inactive_user eq '1'}

<div align="center">
     <a href="{$base_url}/resend_activation_mail.php">Resend activation e-mail</a>
</div>

{else}

<div id="login_box1">

    <div class="section bg2">
    
        <div class="hd">
            <div class="hd-l">
                Information of {$site_name}
            </div>
        </div>
        
        <div class="margin-1em">
            
            {literal}<h2>What is {$site_name}?</h2>                 
            
            <p>{$site_name} is a way to get your videos to the people who matter to you. With {$site_name} you can:</p>
            
            <ul>
                <li>Show off your favorite videos to the world</li>
                <li>Blog the videos you take with your digital camera or cell phone</li>
                <li>Securely and privately show videos to your friends and family around the world</li>
                <li>... and much, much more!</li>                
            </ul>
            
            <p class="signup"><a href="{$base_url}/signup/">Sign up Now</a> and open a new account.</p>
            
            <p>To learn more about our service, please see our <a href="{$base_url}/pages/help.html">Help</a> section.</p>
        </div>
    
    </div>

</div> <!-- login_box1 -->

<div id="login_box2">
  
    <div class="section bg2">
    
        <div class="hd">
            <div class="hd-l">
                  {$site_name} Log In
            </div>
        </div>
        
        <form method="post" action="{$base_url}/login/" id="login-form">
        
            <div>
                <label for="user_name">User Name:</label>
                <input type="text" id="user_name" size="22" name="user_name" value="{$user_name}" />
            </div>
             
            <div>
                <label for="password">Password:</label>
                <input type="password" id="password" size="22" name="user_password" />
            </div>

            <div class="forget-passsword">
                <a href="{$base_url}/recoverpass.php">Forgot your password?</a>
            </div>
            
            <div class="submit">
                <input type="submit" value="Log In" name="action_login" />
                <input type="checkbox" name="autologin" />Remember
           </div>
        
        </form>
    
    </div> 
    
</div> <!--login_box2 -->

{/if}

im trying to change the look of my login.tpl

they have all these special tags it will not let my make changes to the templates.

this is a youtube clone script that uses smarty tags.

thanks
jamika

Member Avatar


pritaeas

2,130



¯_(ツ)_/¯



Moderator



Featured Poster


12 Years Ago

Member Avatar

12 Years Ago

this is the php script in the error line 455 is the red color
(Smarty_Compiler.class.php, line 455)

/* Split tag into two three parts: command, command modifiers and the arguments. */
        if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
                . '|/?' . $this->_reg_obj_regexp . '|/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
                      (?:s+(.*))?$
                    ~xs', $template_tag, $match)) {
          line 455  $this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
        }
        
        $tag_command = $match[1];
        $tag_modifier = isset($match[2]) ? $match[2] : null;
        $tag_args = isset($match[3]) ? $match[3] : null;

        if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) {
            /* tag name is a variable or object */
            $_return = $this->_parse_var_props($tag_command . $tag_modifier);
            return "<?php echo $_return; ?>" . $this->_additional_newline;
        }

        /* If the tag name is a registered object, we process it. */
        if (preg_match('~^/?' . $this->_reg_obj_regexp . '$~', $tag_command)) {
            return $this->_compile_registered_object_tag($tag_command, $this->_parse_attrs($tag_args), $tag_modifier);
        }

        switch ($tag_command) {
            case 'include':
                return $this->_compile_include_tag($tag_args);

            case 'include_php':
                return $this->_compile_include_php_tag($tag_args);

            case 'if':
                $this->_push_tag('if');
                return $this->_compile_if_tag($tag_args);

            case 'else':
                list($_open_tag) = end($this->_tag_stack);
                if ($_open_tag != 'if' && $_open_tag != 'elseif')
                    $this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
                else
                    $this->_push_tag('else');
                return '<?php else: ?>';

            case 'elseif':
                list($_open_tag) = end($this->_tag_stack);
                if ($_open_tag != 'if' && $_open_tag != 'elseif')
                    $this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
                if ($_open_tag == 'if')
                    $this->_push_tag('elseif');
                return $this->_compile_if_tag($tag_args, true);

            case '/if':
                $this->_pop_tag('if');
                return '<?php endif; ?>';

            case 'capture':
                return $this->_compile_capture_tag(true, $tag_args);

            case '/capture':
                return $this->_compile_capture_tag(false);

            case 'ldelim':
                return $this->left_delimiter;

            case 'rdelim':
                return $this->right_delimiter;

            case 'section':
                $this->_push_tag('section');
                return $this->_compile_section_start($tag_args);

            case 'sectionelse':
                $this->_push_tag('sectionelse');
                return "<?php endfor; else: ?>";
                break;

            case '/section':
                $_open_tag = $this->_pop_tag('section');
                if ($_open_tag == 'sectionelse')
                    return "<?php endif; ?>";
                else
                    return "<?php endfor; endif; ?>";

            case 'foreach':
                $this->_push_tag('foreach');
                return $this->_compile_foreach_start($tag_args);
                break;

            case 'foreachelse':
                $this->_push_tag('foreachelse');
                return "<?php endforeach; else: ?>";

            case '/foreach':
                $_open_tag = $this->_pop_tag('foreach');
                if ($_open_tag == 'foreachelse')
                    return "<?php endif; unset($_from); ?>";
                else
                    return "<?php endforeach; endif; unset($_from); ?>";
                break;

            case 'strip':
            case '/strip':
                if (substr($tag_command, 0, 1)=='/') {
                    $this->_pop_tag('strip');
                    if (--$this->_strip_depth==0) { /* outermost closing {/strip} */
                        $this->_additional_newline = "n";
                        return '{' . $tag_command . '}';
                    }
                } else {
                    $this->_push_tag('strip');
                    if ($this->_strip_depth++==0) { /* outermost opening {strip} */
                        $this->_additional_newline = "";
                        return '{' . $tag_command . '}';
                    }
                }
                return '';

            case 'php':
                /* handle folded tags replaced by {php} */
                list(, $block) = each($this->_folded_blocks);
                $this->_current_line_no += substr_count($block[0], "n");
                /* the number of matched elements in the regexp in _compile_file()
                   determins the type of folded tag that was found */
                switch (count($block)) {
                    case 2: /* comment */
                        return '';

                    case 3: /* literal */
                        return "<?php echo '" . strtr($block[2], array("'"=>"'", "\"=>"\\")) . "'; ?>" . $this->_additional_newline;

                    case 4: /* php */
                        if ($this->security && !$this->security_settings['PHP_TAGS']) {
                            $this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
                            return;
                        }
                        return '<?php ' . $block[3] .' ?>';
                }
                break;

            case 'insert':
                return $this->_compile_insert_tag($tag_args);

            default:
                if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {
                    return $output;
                } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
                    return $output;
                } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
                    return $output;                    
                } else {
                    $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
                }

Member Avatar

12 Years Ago

now is the last part of the error message
Smarty.class.php on line 1092
line 1092 in highlighted green

/**
     * trigger Smarty error
     *
     * @param string $error_msg
     * @param integer $error_type
     */
    function trigger_error($error_msg, $error_type = E_USER_WARNING)
    {
        trigger_error("Smarty error: $error_msg", $error_type);
    }

Member Avatar

12 Years Ago

Hi — put a {literal}before <script> tag and {/literal} after </script>
It should work then.
Reason for problem: in css u use {} curly braces for your styles, but the curly braces means a lot to our smarty engine…..it might think thats a smarty tag….but no its our css code…hence we have to tell smarty that this code is not smarty code and it can just ignore it…

Hope this helps
Thanks
Prabhakar
Web Developer — Trainee

Member Avatar

12 Years Ago

thanks i will try this right now

Member Avatar

12 Years Ago

it finally worked . there is a css folder with about 7 different style sheets and i had to go in and change them with the {literal} code you gave me. thanks everyone for all your help i really appreciate.


Reply to this topic

Be a part of the DaniWeb community

We’re a friendly, industry-focused community of developers, IT pros, digital marketers,
and technology enthusiasts meeting, networking, learning, and sharing knowledge.

Понравилась статья? Поделить с друзьями:
  • Syntax error in config file pf rules not loaded
  • Sqlite near autoincrement syntax error
  • Sql как изменить порядок столбцов
  • Sql как изменить значение счетчика
  • Sql error data truncated for column