942,967 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1501
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 16th, 2010
0

Smarty templates

Expand Post »
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:

PHP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Poetry Battles</title>
  6. <script language="javaScript" src="main.php"></script>
  7. <style type="text/css">
  8. <!--
  9. #header {
  10. position:absolute;
  11. left:87px;
  12. top:0px;
  13. width:800px;
  14. height:20px;
  15. z-index:1;
  16. background-color: #0d0600;
  17. }
  18. #content {
  19. position:absolute;
  20. left:3px;
  21. top:29px;
  22. width:1000px;
  23. height:1300px;
  24. z-index:-1;
  25. background-image: url(intro%20bg.png);
  26. background-repeat: no-repeat;
  27. }
  28. #footer {
  29. position:absolute;
  30. left:9px;
  31. top:1346px;
  32. width:990px;
  33. height:50px;
  34. z-index:3;
  35.  
  36. then
  37.  
  38. >?php
  39.  
  40.  
  41. info
  42.  
  43.  
  44. ?>

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
Last edited by adatapost; Mar 16th, 2010 at 12:54 pm. Reason: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
jhowel03 is offline Offline
36 posts
since Mar 2010
Mar 16th, 2010
0
Re: Smarty templates
What is going on with these lines?
PHP Syntax (Toggle Plain Text)
  1. z-index:3;
  2.  
  3. then
  4.  
  5. >?php
  6.  
  7.  
  8. info
  9.  
  10.  
  11. ?>

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...
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Mar 16th, 2010
0
Re: Smarty templates
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.
Reputation Points: 10
Solved Threads: 1
Light Poster
jhowel03 is offline Offline
36 posts
since Mar 2010
Mar 16th, 2010
0
Re: Smarty templates
It might be helpful to post the actual code you used when you got the error.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Mar 17th, 2010
0
Re: Smarty templates
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.
Sponsor
Featured Poster
Reputation Points: 546
Solved Threads: 716
Bite my shiny metal ass!
pritaeas is offline Offline
4,142 posts
since Jul 2006
Mar 17th, 2010
0
Re: Smarty templates
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

PHP Syntax (Toggle Plain Text)
  1. <style type="text/css">
  2. <!--
  3. body,td,th {
  4. font-family: Trebuchet MS;
  5. font-size: 14px;
  6. color: #996633;
  7. }
  8. body {
  9. background-color: #0d0600;
  10. }
  11. a:link {
  12. color: #996633;
  13. }
  14. a:visited {
  15. color: #996633;
  16. }
  17. a:hover {
  18. color: #00FFFF;
  19. }
  20. a:active {
  21. color: #996633;
  22. }
  23. --></style>
  24.  
  25. {if $inactive_user eq '1'}
  26.  
  27. <div align="center">
  28. <a href="{$base_url}/resend_activation_mail.php">Resend activation e-mail</a>
  29. </div>
  30.  
  31. {else}
  32.  
  33. <div id="login_box1">
  34.  
  35. <div class="section bg2">
  36.  
  37. <div class="hd">
  38. <div class="hd-l">
  39. Information of {$site_name}
  40. </div>
  41. </div>
  42.  
  43. <div class="margin-1em">
  44.  
  45. {literal}<h2>What is {$site_name}?</h2>
  46.  
  47. <p>{$site_name} is a way to get your videos to the people who matter to you. With {$site_name} you can:</p>
  48.  
  49. <ul>
  50. <li>Show off your favorite videos to the world</li>
  51. <li>Blog the videos you take with your digital camera or cell phone</li>
  52. <li>Securely and privately show videos to your friends and family around the world</li>
  53. <li>... and much, much more!</li>
  54. </ul>
  55.  
  56. <p class="signup"><a href="{$base_url}/signup/">Sign up Now</a> and open a new account.</p>
  57.  
  58. <p>To learn more about our service, please see our <a href="{$base_url}/pages/help.html">Help</a> section.</p>
  59. </div>
  60.  
  61. </div>
  62.  
  63. </div> <!-- login_box1 -->
  64.  
  65. <div id="login_box2">
  66.  
  67. <div class="section bg2">
  68.  
  69. <div class="hd">
  70. <div class="hd-l">
  71. {$site_name} Log In
  72. </div>
  73. </div>
  74.  
  75. <form method="post" action="{$base_url}/login/" id="login-form">
  76.  
  77. <div>
  78. <label for="user_name">User Name:</label>
  79. <input type="text" id="user_name" size="22" name="user_name" value="{$user_name}" />
  80. </div>
  81.  
  82. <div>
  83. <label for="password">Password:</label>
  84. <input type="password" id="password" size="22" name="user_password" />
  85. </div>
  86.  
  87. <div class="forget-passsword">
  88. <a href="{$base_url}/recoverpass.php">Forgot your password?</a>
  89. </div>
  90.  
  91. <div class="submit">
  92. <input type="submit" value="Log In" name="action_login" />
  93. <input type="checkbox" name="autologin" />Remember
  94. </div>
  95.  
  96. </form>
  97.  
  98. </div>
  99.  
  100. </div> <!--login_box2 -->
  101.  
  102. {/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
Reputation Points: 10
Solved Threads: 1
Light Poster
jhowel03 is offline Offline
36 posts
since Mar 2010
Sponsor
Featured Poster
Reputation Points: 546
Solved Threads: 716
Bite my shiny metal ass!
pritaeas is offline Offline
4,142 posts
since Jul 2006
Mar 17th, 2010
0
Re: Smarty templates
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__);
                }
Reputation Points: 10
Solved Threads: 1
Light Poster
jhowel03 is offline Offline
36 posts
since Mar 2010
Mar 17th, 2010
0
Re: Smarty templates
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);
    } 
Reputation Points: 10
Solved Threads: 1
Light Poster
jhowel03 is offline Offline
36 posts
since Mar 2010
Mar 17th, 2010
0

Try this out

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
yesiknowjava is offline Offline
1 posts
since Mar 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Rewrite URL in PHP
Next Thread in PHP Forum Timeline: effect on seo if i change my index file from .html to .php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC