cakephp-1.3

CakePHP multiple select “selected” is not working

橙三吉。 提交于 2019-12-06 18:58:35
问题 I have a multiple select input in my edit form:- <?php echo $this->Form->input('Article.tags', array('type' => 'select', 'multiple' => true, 'options' => $tags, 'selected' => array($selected))); ?> When echo-ed, the $selected variable will look like this:- "MySQL", "PHP" However, the input does not automatically select the option that matches the tag. However, when I manually put in the selected option, it will automatically select that two option; e.g. <?php echo $this->Form->input('Article

How can I access a GET request in CAKEPHP?

拥有回忆 提交于 2019-12-06 18:58:23
问题 How can I access a GET request in CAKEPHP ? If I am passing a variable in the url http://samplesite.com/page?key1=value1&key2=value2 Should I use $_GET or $this->params to get the values in controller? What is the standard in CAKEPHP ? 回答1: The standard way to do this in Cake is to use $this->params . $value1 = $this->params['url']['key1']; $value2 = $this->params['url']['key2']; According to the CakePHP book, "the most common use of $this->params is to access information that has been handed

How to include javascript in cakephp 1.3?

只谈情不闲聊 提交于 2019-12-06 15:54:05
问题 Wait moment this question not duplicated..it is sample and difficult at the same time. This simple problem make me crazy.. http://www.mediafire.com/?2vi2kc7tpqiw1to This is slide code contain CSS, HTML, jQuery code. This slide works fine, but when I include this slide in cakephp it is not working. I put jQuery files and CSS in webroot and put the code to include in layout/default.ctp like this echo $javascript->link('jcookie.js'); echo $javascript->link('jquery-1.3.2.min.js'); echo

How can I create multiple forms on a single page in CakePHP?

萝らか妹 提交于 2019-12-06 13:54:56
问题 I'm trying to come up with a standard way to create multiple forms for the same model on an index page. Here's a little more detail. I have a list of binders, each with a memo being displayed. I would like the memo fields to be editable from the index page. Obviously it doesn't work to just copy and paste the view for the edit_memo action, like so: <?php echo $this->Form->create('Binder');?> <fieldset> <legend><?php __('Edit Memo'); ?></legend> <?php echo $this->Form->input('id'); echo $this-

how to get Video id from iframe of youtube in php or cakephp

早过忘川 提交于 2019-12-06 13:45:29
问题 i have this iframe <iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe> how to get video id from it by regular expression or any..... 回答1: You can use: $subject = '<iframe width=\"425\" height=\"349\" src=\"http://www.youtube.com/embed/YRUG-Pu7RzE\" frameborder=\"0\" allowfullscreen></iframe>'; $pattern = '!http://(?:www.)?youtube.com/embed/([^"']+)!i'; $result = preg_match($pattern, $subject, $subpattern); $subpattern will

Conditional Component Loading in CakePHP

你。 提交于 2019-12-06 13:32:21
问题 I'm using the DebugKit component in my project but I want to turn it on only on the staging server and have it not load when running from the production server. I know I can turn it off with the debug config value but I want to keep that value at 1 for both servers. I tried conditionally defining a contstant 'DEBUG_KIT' in bootstrap.php as either the component name (ie. 'DebugKit.Toolbar') or null. Then using that constant in the var $component definition at the top of the app_controller file

CakePHP 1.3: Measuring Page Execution Time

此生再无相见时 提交于 2019-12-06 12:49:33
Looking to figure out how to measure the total PHP execution time of a CakePHP site. It looks like in 1.2 this was included in the rendered HTML as a HTML comment when in debug mode, but this is not happening on my 1.3 site, and in any case I want it as an element I can output to the user, not a comment. I can do this easily in regular PHP using microtime() but I'm not sure where to add the code in CakePHP, and I suspect it might have a more robust execution timer anyway. Ideas? Just in case anyone else is curious, I solved this by adding the following code to my layout.ctp. You could also do

CakePHP with Lucene

大憨熊 提交于 2019-12-06 09:35:27
问题 I am trying to implement Lucene with cakephp and following this guide http://jamienay.com/2010/01/zend_search_lucene-datasource-for-cakephp/ Am getting this error ConnectionManager::loadDataSource - Unable to import DataSource class .ZendSearchLuceneSource i have placed the Vendor files in app/vendors/Zend/ Added this in the bootstrap.php ini_set('include_path', ini_get('include_path') . ':' . CAKE_CORE_INCLUDE_PATH . DS . '/vendors'); /** * AutoLoading Zend Vendor Files */ function _

Can Cake Php Validation clear input field value

99封情书 提交于 2019-12-06 09:34:44
Can Cake Php Validation clear input field value var $validate = array( 'name' => array( 'isUnique' => array ( 'rule' => 'isUnique', 'message' => 'This Person name already exists.' ) ) ); If error persist in validation, I want to clear name field value. Is it possible to do so with cake php validation itself ? You can do it with a custom validation rule if you wanted. var $validate = array( 'name' => array( 'isUnique' => array ( 'rule' => 'ifNotUniqueClear', // use custom rule defined below 'message' => 'This Person name already exists.' ) ) ); function ifNotUniqueClear(&$data) { $field = key(

how to create dynamic navigation menu cakephp

て烟熏妆下的殇ゞ 提交于 2019-12-06 09:01:32
问题 How can I build navigation menu from categories and sub categories, like this: http://mysite/categories/view/1/2 I tried menu builder 1.01 but it only works for acl users. I also read this tutorial, but it was not helpful. 回答1: Your first link doesn't work. Frankly, I'm not even sure I understand what you're trying to do. The second link you supplied - I admit I only looked at the first code snippet - doesn't use a database table. If you want your menu to be dynamic, as in based off