Nov 25, 2011

Core Helpers in Cakephp


Helpers
Helpers represent component-like classes for the presentation layer of your application, which contain presentational logic shared between many views, elements or layouts.

The CakePHP framework needs a controller in order to make usage of helpers. Each controller has a $helpers property that lists the helpers to be made available in the view. To enable a helper in your view, add the name of the helper to the controller’s $helpers array.


Example


<?php
class ExampleController extends AppController {
var $name = 'Example';
var $helpers = array('Html','Ajax','Javascript');
}

CakePHP features a number of helpers that aid in view creation. They assist in creating well-formed markup (including forms), aid in formatting text, times and numbers, and can even speed up Ajax functionality. Here is a summary of the built-in helpers.
CakePHP Helper
Description
Ajax
Used in tandem with the Prototype JavaScript library to create Ajax functionality in views. Contains shortcut methods for drag/drop, ajax forms & links, observers, and more.
Cache
Used by the core to cache view content.
Form
Creates HTML forms and form elements that self populate and handle validation problems.
Html
Convenience methods for crafting well-formed markup. Images, links, tables, header tags and more.
Js
Used to create Javascript compatible with various Javascript libraries. Replaces JavascriptHelper and AjaxHelper with a more flexible solution.
Used to escape values for use in JavaScripts, write out data to JSON objects, and format code blocks.
Number
Number and currency formatting.
Model data pagination and sorting.
Convenience methods for outputting RSS feed XML data.
Session
Access for reading session values in views.
Text
Smart linking, highlighting, word smart truncation.
Time
Proximity detection (is this next year?), nice string formatting(Today, 10:30 am) and time zone conversion.
Xml
Convenience methods for creating XML headers and elements.

 *if any type of help is needed regarding prog or concept contact me on dadhich.priyank@gmail.com


No comments:

Post a Comment