Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
mystic error: Unexpected """, expected one of

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: Russian
View previous topic :: View next topic  
Author Message
CrazyPHP
Smarty n00b


Joined: 28 Oct 2013
Posts: 4

PostPosted: Mon Oct 28, 2013 7:10 pm    Post subject: mystic error: Unexpected """, expected one of Reply with quote

Привет. Вобщем написал я плагин, чтобы подключаемые на странице файлы брались из нужной директории в зависимости от установленной темы, вот сам плагин:

Code:

/**
 * Smarty plugin
 * @package GML
 * @subpackage PluginsFunction
 */

/**
 * Smarty {asset} function plugin
 *
 * Type:     function<br>
 * Name:     asset<br>
 * Purpose:  get path for current theme (for putting .css .js etc.)
 *
 * @author lol
 * @param array $file_string local path to file resource
 * @return string
 */
 
use \kernel\Service\ServiceHelper;

function smarty_function_asset($params){
   
    $service = new ServiceHelper();

    if(!array_key_exists('type',$params)){
        $params['type'] = 'file';
    }
    if(!array_key_exists('theme',$params)){
        $params['theme'] = false;
    }
   
    if($params['theme'] === false){
        $current_theme = $service->theme->current_theme;
    }else{
        $current_theme = $params['theme'];
    }
   
    if($params['type']=='file'){
        $done_string = $service->config->system->themes_path.'/'.$current_theme.'/'.$params['file'];
    }
   
    return $done_string;
}

он отлично работал и делал своё дело. Но вот я взялся за новый проект, с последней версией @version 3.1.15, и платной темой http://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469

и вот значит пишу я такой нормальный код в шаблоне:
Code:

{block name="js_load"}
        <!-- Load javascripts at bottom, this will reduce page load time -->
        <!-- BEGIN CORE PLUGINS(REQUIRED FOR ALL PAGES) -->
        <!--[if lt IE 9]>
        <script src="{asset file="plugins/respond.min.js"}"></script> 
        <![endif]--> 
        <script type="text/javascript" src="{asset file="plugins/jquery-1.10.2.min.js"}"></script>
        <script type="text/javascript" src="{asset file="plugins/jquery-migrate-1.2.1.min.js"}"></script>
        <script type="text/javascript" src="{asset file="plugins/bootstrap/js/bootstrap.min.js"}"></script>     
        <script type="text/javascript" src="{asset file="plugins/hover-dropdown.js"}"></script>
        <script type="text/javascript" src="{asset file="plugins/back-to-top.js"}"></script>   
        <!-- END CORE PLUGINS -->

        <!-- BEGIN PAGE LEVEL JAVASCRIPTS(REQUIRED ONLY FOR CURRENT PAGE) -->
        <script type="text/javascript" src="{asset file="plugins/fancybox/source/jquery.fancybox.pack.js"}"></script> 
        <script type="text/javascript" src="{asset file="plugins/revolution_slider/rs-plugin/js/jquery.themepunch.plugins.min.js"}"></script>
        <script type="text/javascript" src="{asset file="plugins/revolution_slider/rs-plugin/js/jquery.themepunch.revolution.min.js"}"></script>
        <script type="text/javascript" src="{asset file="plugins/bxslider/jquery.bxslider.min.js"}"></script>
        <script type="text/javascript" src="{asset file="js/app.js"}"></script>   
        <script type="text/javascript">
            jQuery(document).ready(function() {
                App.init();   
                App.initBxSlider();
                Index.initRevolutionSlider();                   
            });
        </script>
        <!-- END PAGE LEVEL JAVASCRIPTS -->
    {/block}


а оно мне выдаёт ошибку:
Code:

Syntax error in template "\www\themes\default\base.tpl"  on line 286 "<script type="text/javascript" src="{asset file="plugins/back-to-top.js"}"></script>"  - Unexpected """, expected one of: "identifier";

после чего я в любом месте шаблона добавляю скажем 10 любых символов и ошибка исчезает! Потом в процессе вёрстки добавляется ещё пару символов и ошибка возвращается! Это что за бред?
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 104
Location: Germany

PostPosted: Mon Nov 04, 2013 10:39 am    Post subject: Reply with quote

Hey,

the problem is, that you use " in an attribute-value (i. e. your html looks like this: src=""yourfile"").

Plase try this:



Code:
<script type="text/javascript" src="{asset file='plugins/fancybox/source/jquery.fancybox.pack.js'}"></script> 


or this:

Code:
<script type="text/javascript" src='{asset file="plugins/fancybox/source/jquery.fancybox.pack.js"}'></script> 

_________________
BASE4U - Deine Meinung ist Wichtig!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: Russian All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP