那么。我想知道。有什么办法。可以让smarty很好的调用css呢。我一直没找到好的办法

解决方案 »

  1.   

    <style>
    .f { font-size:3px }
    </style>或
    <style>
    .f {
     font-size:3px
    }
    </style>或修改smarty分界标记
      

  2.   

    把css定义写在css文件里。用时调用过来.
    类似<link href="css文件路径" rel="stylesheet" type="text/css">
    上面的问题是.f { font-size:3px }的大括号与smarty默认分界符冲突了.
      

  3.   

    /**
     * 装载Smarty.class.php,并实例化对象,在这里将设置Smarty的左右分界符号为<{ 与 }>
     */
    include_once('Smarty.class.php');
    $tpl = new Smarty();                                           //建立smarty实例对象$smarty
    $tpl->debugging = true;
    $tpl->template_dir   = Templates."/".$templates;                    //设置模板目录
    $tpl->compile_dir    = Templates."/".$templates."/templates_c";     //设置编译目录
    $tpl->cache_dir      = $doc_root."/cache";                     //设置缓存目录
    //$tpl->cache_lifetime = 60 * 60 * 24;                           //设置缓存时间
    $tpl->cache_lifetime = 0;                           //设置缓存时间
    $tpl->caching        = false;                                  //这里是调试时设为false,发布时请使用true
    $tpl->left_delimiter = '<{';
    $tpl->right_delimiter= '}>';
      

  4.   

    css的标记与smarty的语法标记冲突了.两种方法,要么改下smarty的模板标记.
    $tpl->left_delimiter = '<{';
    $tpl->right_delimiter= '}>';要么把css代码放在{literal}里面,不仅css,javascript代码也应该放在{literal}里面