When we provide the error message in a particular model, then after validating, CakePHP automatically displays that error message below the respective input control, by creating their own div and error message class. But we can also show the error message in our own style using error function of form helper ($form->error()). Suppose there is… Continue reading Displaying Customized Error Message CakePHP 1.2
Tag: PHP
Write MySQL Database Query in Magento
If you need to execute a MySQL query anywhere in Magento (in the .php code files or .phtml template files), the following steps are required – $conn = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’); $conn->query(“insert into table name (fields) values (values) “);
Zen Cart debugmode – how to show errors on screen
To show the PHP errors on screen for debugging Zen-Cart follow these steps – 1. In folder /includes/local/ , create file configure.php 2. On it write – define(‘STRICT_ERROR_REPORTING’, true); That would show you the PHP errors on screen. To turn it off simple replace the true with false.
Creating a new page in Zen Cart
To create a new page in Zen Cart follow the below steps. We will be creating a new page called new_page and it will be accessible via browser using the following link http://www.your-zen-cart.com/index.php?main_page=new_page 1. Go to includes\modules\pages\ Create a folder new_page (the folder name should be same as the name of the page) Inside it… Continue reading Creating a new page in Zen Cart
How to import a controller in CakePHP
Suppose we have a controller named pages_controller.php, in which there is a function named index(). Now we are working in an another controller named users_controller.php, and we want to use the index function defined in Pages Controller. App::import(‘Controller’, ‘Pages’); class UsersController extends AppController { var $Pages; function beforeFilter() { $this->Pages =& new PagesController; /*Loads the… Continue reading How to import a controller in CakePHP
Remove unwanted menu from Joomla Administrator
In Joomla Administrator, for removing the quick icons from the control panel :Go to the \administrator\modules\mod_quickicon\mod_quickicon.php and comment out the quickiconButton. For removing the menus and submenus from the Administrator main menu tab :Go to the \administrator\modules\mod_menu\helper.php and comment out the unwanted menu or submenu sections.
Omit PHP end tag – "header already send" Error
If a page contains only PHP code, best practice is to omit the PHP end tag ( ?> ). PHP does not require the end tag on PHP only pages. Including the end tag can cause unwanted injection of trailing white spaces which can cause header already sent errors.
Creating a simple form and custom validation rules in CakePHP 1.2
Note: In CakePHP 1.2, form related methods have been deprecated from the HtmlHelper and moved to the new FormHelper. Now we have to use FormHelper instead of HtmlHelper. Also the tagErrorMsg is removed in the current version. Our Controller Class:For validating the given input, we need to write this in our controller function: class PagesController… Continue reading Creating a simple form and custom validation rules in CakePHP 1.2
Turn off phpBB cache
While creating phpBB templates or during development it can be really irritating to delete the contents of the cache folder repeatedly after each change. For that it is better to ask phpBB to recompile the updates. For that follow these steps – 1. From admin panel choose the “General” tab2. Choose “Load settings” from the… Continue reading Turn off phpBB cache
Dynamic conditions in PHP
The below example demonstrates how we can check dynamic conditions in PHP. $var1 = 11; $var2 = 110; $cond1 = ‘$var1 > $var2’; $cond2 = ‘$var1 < $var2'; if(eval("return $cond1;")){ echo $cond1; } if(eval("return $cond2;")){ echo $cond2; }