首页 \ 问答 \ 使用Smarty 3.1和Kohana 3.3(Using Smarty 3.1 with Kohana 3.3)

使用Smarty 3.1和Kohana 3.3(Using Smarty 3.1 with Kohana 3.3)

KSmarty是一个Kohana模块,旨在将Smarty与Kohana整合。 我正在尝试将我当前的项目(已经使用Smarty)迁移到使用Kohana。

我正在尝试设置KSmarty,但是我很难让模板工作。 这是KSmarty的“hello world”示例:

应用/类/控制器/的welcome.php

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller_Template
{
    public $template = 'welcome';

    public function action_index()
    {
        // Assign a value to the variable 'intro'
        $this->template->intro = 'Hello world!';

        // Create a nested view by loading a different template
        $this->template->content = View::factory('content');
    }
}
// End Welcome

应用/视图/ welcome.tpl

<html>
    <body>
        <h1>{$intro}</h1>
        <p>
            {$content}
        </p>
    </body>
</html>

应用/视图/ content.tpl

Yes, this works!

但是,对我来说,控制器/视图组合不能按预期工作。 以下是我尝试过的action_index()变体:

public function action_index()
{
    echo 'foo';
}
// Output: foo

public function action_index()
{
    // Assign a value to the variable 'intro'
    $this->template->intro = 'Hello world!';

    // Create a nested view by loading a different template
    $this->template->content = View::factory('content');
}
// No output
// No error in apache log, php log, or kohana log

public function action_index()
{
    Ksmarty::instance()->assign(array(
        'intro' => 'Hello world!',
        'content' => APPPATH.'/views/content.tpl'
        // Note: also changed {$content} in template to {include $content}
    ));
    Ksmarty::instance()->display(APPPATH.'/views/welcome.tpl');
}
// Expected HTML output

可以简单地使用像这样的Ksmarty::instance()并让我的网站工作,但这不是Kohana Views系统的设计方式,它感觉像是一个kludge,特别是因为KSmarty示例与Kohana使用Views相匹配。

我正在把我的头发拉出来试图把它钉住,这令人印象深刻考虑到Kohana在初次安装时给我的拔毛量。 我究竟做错了什么?

哦,我已经对KSmarty进行了两次更改以达到这一点:

  1. Kohana::config('smarty')所有实例都替换为Kohana::$config->load('smarty') ; 据我所知,这是Kohana版本更改的问题。
  2. 注释掉$s->security = Kohana::$config->load('smarty')->security; ; 据我所知,这是Smarty版本更改的问题,KSmarty无论如何都配置为FALSE

KSmarty is a Kohana module meant to integrate Smarty with Kohana. I'm trying to migrate my current project (already using Smarty) to using Kohana.

I'm trying to get KSmarty set up, but I'm having difficulties getting the templates to work. This is the "hello world" example from KSmarty:

application/classes/Controller/Welcome.php

<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Welcome extends Controller_Template
{
    public $template = 'welcome';

    public function action_index()
    {
        // Assign a value to the variable 'intro'
        $this->template->intro = 'Hello world!';

        // Create a nested view by loading a different template
        $this->template->content = View::factory('content');
    }
}
// End Welcome

application/views/welcome.tpl

<html>
    <body>
        <h1>{$intro}</h1>
        <p>
            {$content}
        </p>
    </body>
</html>

application/views/content.tpl

Yes, this works!

However, for me, the controller/view combo does not work as expected. Here are the variants of action_index() that I've tried:

public function action_index()
{
    echo 'foo';
}
// Output: foo

public function action_index()
{
    // Assign a value to the variable 'intro'
    $this->template->intro = 'Hello world!';

    // Create a nested view by loading a different template
    $this->template->content = View::factory('content');
}
// No output
// No error in apache log, php log, or kohana log

public function action_index()
{
    Ksmarty::instance()->assign(array(
        'intro' => 'Hello world!',
        'content' => APPPATH.'/views/content.tpl'
        // Note: also changed {$content} in template to {include $content}
    ));
    Ksmarty::instance()->display(APPPATH.'/views/welcome.tpl');
}
// Expected HTML output

I could simply use Ksmarty::instance() like this and get my website working, but this isn't how the Kohana Views system was designed, and it feels like a kludge, especially since the KSmarty example matches up with Kohana's use of Views.

I'm pulling my hair out trying to pin this one down, which is impressive considering the amount of hair-pulling Kohana gave me on the initial install. What am I doing wrong?

Oh, I have make two changes to KSmarty to reach this point:

  1. All instances of Kohana::config('smarty') replaced with Kohana::$config->load('smarty'); as far as I can tell, this is a matter of a version change in Kohana.
  2. Commented out $s->security = Kohana::$config->load('smarty')->security;; as far as I can tell, this is a matter of a version change in Smarty, and KSmarty is configured to FALSE anyway.

原文:https://stackoverflow.com/questions/22032670
更新时间:2022-10-11 08:10

最满意答案

下个小鸡模拟器
所有游戏都能玩
有虚拟键盘
可以玩安卓游戏
java游戏
所有街机游戏
psp游戏
世嘉游戏
game boy游戏

其他回答

你如果有java模拟器只是没有按键的话就上网查下"虚拟轨迹球"可以调上下左右及左软键右软键.前提是应用必须全屏(网上有教程改)

相关问答

更多
  • android-sdk 自带键盘,用来android开发的时候调试用的。。。 使用的时候应该还要安装个eclipse大概。。。 教程按照网上 android 开发教程来,所有的前几章应该都是教别人怎么安装这个的。。 = = 你是要模拟安卓程序么? 模拟器卡的一B 不支持多点触控,模拟短信和电话,除了调试安卓程序其他基本无用。。
  • 没有带虚拟键盘的,要自己安装虚拟键盘,有一个『java虚拟机』可以用,要找论坛里的,有教程的,要把so文件放的手机里的,这种才能用,百度应用里的限安卓2.2
  • 没有吧,你想在电脑上玩都是需要下载模拟器的呀,你可以用“说玩模拟器”来玩的呀,这个还是不错的呀。 说玩模拟器是一款占用资源很少的安卓模拟器。说玩模拟器采用采用国内最先进的引擎技术,稳定运行多开无障碍。说玩模拟器还有着海量游戏库,以及针对各种游戏、区域、排行、测试、新服等各种礼包领取
  • 现在比较好的JAVA模拟器JAVA模拟器绿色版,你在论坛里搜索“JAVA模拟器”就可以找到,支持VGA、MIDP2.0、3D、触摸!支持本地安装和网络安装!本人一直在用,觉得不错!
  • 现在大部分用户都已经选择了智能手机,过去老款的机子都已经被淘汰了,但是还是有不少用户是很怀旧的,他们很怀念以前使用按键的手机去玩java游戏和软件,所以,为了方便广大用户体验过去的感觉,小编找到了这款安卓4.0版本的java模拟器,安卓4.0以上都可以使用,现将安装方法写下来,给各位怀旧的机友们。   java模拟器安装方法:   把下载后的压缩文件解压到SD存储卡,然后用 Root Explorer (或者 EStrongs 文件,或者R。E管理器)把三个so文件及1个jar复制到对应目录:   libD ...
  • 拿虚拟按键来玩Java游戏吗?我有个调用手机输入法的,不过想要告诉你安卓手机分辨率太大装Java应用只能显示在一部分屏幕上不能全屏 除非你装自适应屏的应用不然画面太小了 没法玩,自适应屏的应用很少的几乎没游戏。所以安卓的Java模拟器很鸡肋不像塞班才导致后面的安卓版本不支持Java模拟器的。
  • 下个小鸡模拟器 所有游戏都能玩 有虚拟键盘 可以玩安卓游戏 java游戏 所有街机游戏 psp游戏 世嘉游戏 game boy游戏
  • 你好。安卓系统的最新版QQ其实也不怎么费流量。不用特意去安装java模拟器。这个java模拟器你可以用wifi去安卓市场下载,里面附带有一个java浏览器,在那里,你可以选择你喜欢的应用程序下载安装。
  • java软件的分辨率一般都是240×320.360×640.所以即使中兴V880支持java实际意义也不大,而且java一般都是要键盘的,所以没什么意义
  • 中文版的现在很多了,不过也有好有坏的,最开始的安卓模拟器安装之类的都非常的麻烦要自己一个个环境去安装,现在的话很多助手类的安卓模拟器出来了,安装都是一键全自动的非常方便!我用的是小皮助手安卓模拟器http://pc.xiaopi.com/就是这样的安装使用都非常的简单也是中文的操作一看就懂!

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)