zend-framework

select queries with Zend_DB_Table

只谈情不闲聊 提交于 2019-12-10 10:49:51
问题 I have a code something like following class Application_Model_Company extends Zend_Db_Table_Abstract { protected $_name = 'companies'; private $id; private $name; private $shortName; private $description; public static function getAllCompanies() { $companyObj = new self(); $select = $companyObj->select()->order(array('name')); $rows = $companyObj->fetchAll($select); if($rows) { $companies = array(); foreach($rows as $row) { $company = new self(); $company->id = $row->id; $company->name =

In Zend Framework applications, what purpose does the /views/filters serve?

妖精的绣舞 提交于 2019-12-10 10:49:43
问题 I have an idea of what view helpers do (/view/helpers), but I have no idea what a view filter (/view/filters) is, or what its used for, can some one please shed some light on the matter? Thank You =) 回答1: At the end of rendering a view, Zend_View passes the output to any filter(s) you have registered, by calling the filter() method on the filter object. One use of a filter could be to minify HTML output, stripping comments and whitespace to reduce the size of the content to send over the

Inject URL parameters into Zend_Navigation menu

跟風遠走 提交于 2019-12-10 10:49:34
问题 Is anyone using Zend Navigation in conjunction with URLs that require dynamic parameters? Zend_Navigation seems really easy when dealing with static routes, but I can't figure out any way to make it play nice with dynamic URL parameters. A route like: routes.editUser.route = '/users/:id/edit' routes.editUser.defaults.controller = 'user' routes.edutUser.defaults.action = 'edit' In this navigation: <pages> <editUser> <controller>users</controller> <action>edit</action> <route>editUser</route> <

Including a javascript file outside of doc root using zend framework

与世无争的帅哥 提交于 2019-12-10 10:47:59
问题 I'm trying to include a javascript file in a phmtl view script file using the zend framework. Both the javascript file and the phtml file are part of a php library and located outside the doc root folder of my project. So the file structure looks like /var/www/vhosts/project/ /var/www/vhosts/libraries/my-lib/view/viewscript.phtml /var/www/vhosts/libraries/my-lib/js/javascript.js /var/www/vhosts/libraries/my-lib has been added to the PHP paths using set_include_path. In viewscript.phtml, I use

How to use custom 404 page on not found controller/action

让人想犯罪 __ 提交于 2019-12-10 10:07:31
问题 I have wrote a custom 404 Page Not Found page. But where I have to put it in my Zend Application structure and how to show it? When a controller couldn't be found I receive an Invalid controller specified (dsa) error. And when an action couldn't be found I receive an Action "wqe" does not exist and was not trapped in __call() error. Shortly, I don't want these errors. How can I detect if the page is not found before rendering? And when I detect it, how can I show my custom error page. At the

Autoloading Zend Framework classes

爷,独闯天下 提交于 2019-12-10 10:05:20
问题 Here I am getting this error whenI tried to run a downloaded zend project what is this error and how it can be solved Warning: require_once(Zend/Application.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\sandbox\public\index.php on line 18 index.php <?php // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined(

Zend: How to add webpage title in all my views?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 10:04:52
问题 For now I have to add title in all my views separately like this: <head> <title>TestProject - Home</title> </head> and <head> <title>TestProject - Dashboard</title> </head> Now if I want to change TestProject part of title then I have to change it in all my views. How can I mentioned this in BootStrap.php and add it in all views? And whenever I have to change this, I will change this in one place. 回答1: You should look into the headTitle view helper. You can put this snippet below in your

Zend 1.12: Append javascript to bottom of view

ε祈祈猫儿з 提交于 2019-12-10 09:37:30
问题 What do I use in the controller to append a javascript file to the end of a view? I do not want to put it in the head, so headScript() and headLink() are out, but I cannot find a working example of what I'm looking for in either the Zend documentation or elsewhere. I've tried using $this->inlineScript()->appendFile('/js/myfile.js'); , but it throws an error saying inlineScript() doesn't exist. I'm assuming its Zend 2 only. Can someone point me in the right direction to a method that does what

zend form validation

可紊 提交于 2019-12-10 09:37:08
问题 I wonder how Zend_Form validates inputs, I mean how does it know which input fields to validate. I looked to php globals($_POST, $_GET) and I didn't see anything set as an identifier(for example ) in order to know how validate. Can anyone suggest me any guide for this stuff? 回答1: Well, the best option to find out is to look at the code of Zend_Form: /** * Validate the form * * @param array $data * @return boolean */ public function isValid($data) { if (!is_array($data)) { require_once 'Zend

Pass variable into Zend Form

别等时光非礼了梦想. 提交于 2019-12-10 09:34:07
问题 I have a zend form instantiated $form = Form_Example(); Now I want to pass an ID from my controller to my form. So I did this: $form = Form_Example(array('id' => $id)); Inside the form I try to call it through: $this->id But it isn't there. Anybody knows how to get that id into the form? Thanks 回答1: Make sure you have setter for the the element, in your case public function setId($id) . Zend_Form constructor checks if setter method exists for the property, if it exists then it is called,