使用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进行了两次更改以达到这一点:
Kohana::config('smarty')
所有实例都替换为Kohana::$config->load('smarty')
; 据我所知,这是Kohana版本更改的问题。- 注释掉
$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:
- All instances of
Kohana::config('smarty')
replaced withKohana::$config->load('smarty')
; as far as I can tell, this is a matter of a version change in Kohana.- 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 toFALSE
anyway.
原文:https://stackoverflow.com/questions/22032670
其他回答
你如果有java模拟器只是没有按键的话就上网查下"虚拟轨迹球"可以调上下左右及左软键右软键.前提是应用必须全屏(网上有教程改)
相关问答
更多-
求一个安卓java模拟器!自带虚拟键盘的![2022-10-27]
android-sdk 自带键盘,用来android开发的时候调试用的。。。 使用的时候应该还要安装个eclipse大概。。。 教程按照网上 android 开发教程来,所有的前几章应该都是教别人怎么安装这个的。。 = = 你是要模拟安卓程序么? 模拟器卡的一B 不支持多点触控,模拟短信和电话,除了调试安卓程序其他基本无用。。 -
求安卓触屏手机JAVA模拟器 带虚拟键盘的,,我是小米手机[2021-10-10]
没有带虚拟键盘的,要自己安装虚拟键盘,有一个『java虚拟机』可以用,要找论坛里的,有教程的,要把so文件放的手机里的,这种才能用,百度应用里的限安卓2.2 -
有不用安装安卓模拟器就能下载的电脑版全民k歌吗[2023-07-06]
没有吧,你想在电脑上玩都是需要下载模拟器的呀,你可以用“说玩模拟器”来玩的呀,这个还是不错的呀。 说玩模拟器是一款占用资源很少的安卓模拟器。说玩模拟器采用采用国内最先进的引擎技术,稳定运行多开无障碍。说玩模拟器还有着海量游戏库,以及针对各种游戏、区域、排行、测试、新服等各种礼包领取 -
安卓java模拟器触屏版[2022-09-22]
现在比较好的JAVA模拟器JAVA模拟器绿色版,你在论坛里搜索“JAVA模拟器”就可以找到,支持VGA、MIDP2.0、3D、触摸!支持本地安装和网络安装!本人一直在用,觉得不错! -
java模拟器安卓版怎么用[2024-05-15]
现在大部分用户都已经选择了智能手机,过去老款的机子都已经被淘汰了,但是还是有不少用户是很怀旧的,他们很怀念以前使用按键的手机去玩java游戏和软件,所以,为了方便广大用户体验过去的感觉,小编找到了这款安卓4.0版本的java模拟器,安卓4.0以上都可以使用,现将安装方法写下来,给各位怀旧的机友们。 java模拟器安装方法: 把下载后的压缩文件解压到SD存储卡,然后用 Root Explorer (或者 EStrongs 文件,或者R。E管理器)把三个so文件及1个jar复制到对应目录: libD ... -
跪求安卓版java模拟器带虚拟按键的,安卓2.3版本的,黑20分[2022-03-30]
拿虚拟按键来玩Java游戏吗?我有个调用手机输入法的,不过想要告诉你安卓手机分辨率太大装Java应用只能显示在一部分屏幕上不能全屏 除非你装自适应屏的应用不然画面太小了 没法玩,自适应屏的应用很少的几乎没游戏。所以安卓的Java模拟器很鸡肋不像塞班才导致后面的安卓版本不支持Java模拟器的。 -
java模拟器带虚拟键盘的安卓版[2023-08-18]
下个小鸡模拟器 所有游戏都能玩 有虚拟键盘 可以玩安卓游戏 java游戏 所有街机游戏 psp游戏 世嘉游戏 game boy游戏 -
安卓系统java模拟器[2022-04-24]
你好。安卓系统的最新版QQ其实也不怎么费流量。不用特意去安装java模拟器。这个java模拟器你可以用wifi去安卓市场下载,里面附带有一个java浏览器,在那里,你可以选择你喜欢的应用程序下载安装。 -
有没有安卓手机java模拟器触屏版[2023-02-08]
java软件的分辨率一般都是240×320.360×640.所以即使中兴V880支持java实际意义也不大,而且java一般都是要键盘的,所以没什么意义 -
求一个安卓手机模拟器中文版[2022-04-28]
中文版的现在很多了,不过也有好有坏的,最开始的安卓模拟器安装之类的都非常的麻烦要自己一个个环境去安装,现在的话很多助手类的安卓模拟器出来了,安装都是一键全自动的非常方便!我用的是小皮助手安卓模拟器http://pc.xiaopi.com/就是这样的安装使用都非常的简单也是中文的操作一看就懂!