Display images in CakePHP

Today I face a problem as a beginner of CakePHP …How can I display image button with link in Cake. I wanted to use images as my buttons to edit and delete records and  navigate the admin pages.

1. Have to use HTML Helpers Image and Link, and we shall combine this 2. The CakePHP link helper is a handy tool to create links in your application. Here is the basic syntax:

<?php echo $html->link(’help!’,’/help’); ?>

And there’s a helper for creating images, too:

<?php echo $html->image(’add.gif’); ?>

Show HTML code of the image as the link:

<?php echo $html->link($html->image(’add.gif’),’/customers/add’)?>

2. For Image,
Syntax:

$html->image(string $path, array $htmlAttributes, boolean $return = false);

Example:

$html->image(’/img/images/cancel.png’, array(’class’ => ’save_button’));
3. For Link, the Syntax:

$html->link(string $title, string $url, array $htmlAttributes, string $confirmMessage = false, boolean $escapeTitle = true, boolean $return = false);

Example:

$html->link(’SAVE’, ‘/registers’, array(), false, false, false);

4. So to make an image clickable,

<?php echo $html->link($html->image(’/img/images/cancel.png’,array(’class’ => ’save_button’)), ‘/registers’, array(), false, false, false); ?>

And the best code is:
<?php echo $html->link($html->image(’add.gif’),’/customers/add’,array(’escape’=>false))?>

Hope it will help you to save time.

Top sites in CakePHP

CakePHP is a rapid development framework for PHP that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORM within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code. Wanna learn CakePHP…..You have to find best sites on it. Given below are some of them:

1. CakeForge: CakeForge is a free service provided to Open Source developers offering easy access to the best in SVN, mailing lists, bug tracking, message boards/forums, task management, site hosting, permanent file archival, full backups, and total web-based administration.

2. CakePHP :It is most popular site for download, install and learn CakePHP.

3. Cakebaker:a rich site on Cake to bake. Learning a new framework should help me to grow as a developer.

4. CakePHP Bakery: Here u find resources, articles and much more… dont miss it.

5. Cakephp.nu:have some tutorials on Cake.

6. Cake for Beginners: article on style sheets.

7. 21 Things I Learned About CakePHP: Its really a nice one to learning.

8. The CakePHP Framework: A SitePoint Tutorial:

Can know the CakePHP’s Approach to the MVC Architecture

9. Cake.Insert Design Here: its features are:

10. Moving To CakePHP: another resource on Cakephp.

Lets enjoy the tour….

Using Style sheets in CakePHP

https://i0.wp.com/squio.nl/blog/wp-content/2008/02/cake12b.png

Recently I’m start working with CakePHP for one of my official project ‘The Bangabhaban website’. This is my second local project. First one was ‘votebd.com’ developed with CodeIgniter. I’m very happy to being developer of such a project. Lets happy starting.
I had to develop a template for demo purpose. here I discussed some CSS related problem solving tricks:
1. External Style Sheets: For access all images and style sheets you have to add following codes into .htaccess file.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ – [L]

2. AssetHelper: is a great  helper for
CSS and JS compression. You can find it in http://www.pseudocoder.com .

3. CSS Tidy: is an opensource CSS parser and optimiser. CSSTidy has full CSS2 support and a higher reliability. Any way to configure the helper and/or CSS Tidy to just combine all of
my CSS files into one:

$this->settings[‘remove_bslash’] = false;
$this->settings[‘compress_colors’] = false;
$this->settings[‘compress_font-weight’] = false;
$this->settings[‘lowercase_s’] = false;
$this->settings[‘optimise_shorthands’] = 0;
$this->settings[‘remove_last_;’] = false;
$this->settings[‘case_properties’] = 0;
$this->settings[‘sort_properties’] = false;
$this->settings[‘sort_selectors’] = false;
$this->settings[‘merge_selectors’] = 0;
$this->settings[‘discard_invalid_properties’] = false;
$this->settings[‘css_level’] = ‘CSS2.1’;
$this->settings[‘preserve_css’] = true;
$this->settings[‘timestamp’] = false;