Cakephp syntax for some html tag part(2)

Published on : April 27, 2026

Author:

Category: CakePHP


Html:
background:#633; border-bottom:1px solid #000; padding:10px;

Cake php:
<?php echo $this->Html->style(array(
‘background’ => ‘#633’,
‘border-bottom’ => ‘1px solid #000’,
‘padding’ => ‘10px’
)) ;?>

Html:
<img src="/img/cake_logo.png" alt="CakePHP" />

Cake php:
<?php echo $this->Html->image(‘cake_logo.png’, array(‘alt’ => ‘CakePHP’)); ?>

Html:
<a href="/recipes/view/6">
    <img src="/img/recipes/6.jpg" alt="Brownies" />
</a>

Cake php:
<?php echo $this->Html->image("recipes/6.jpg", array(
    "alt" => "Brownies",
    'url' => array('controller' => 'recipes', 'action' => 'view', 6)
)); ?>

Html:
<a href="/pages/home" target="_blank">Enter</a>

Cake php: 
<?php echo $this->Html->link(‘Enter’,’/pages/home’,array(‘class’=>’button’,’target’=>’_blank’)); ?>

Html:
<a href="/recipes/delete/6" onclick="return confirm('Are you sure you wish to delete this recipe?');">Delete</a>

Cake php:
<?php echo $this->Html-link(
‘Delete’,
Array(‘controller’=>’recipe’,’action’=>’delete’,6),
Array(),
“Are you sure you wish to delete this recipe?”
) ;?>

Html:
<a href="/images/view/1?height=400&width=500">View image</a>

Cake php:
<?php echo $this->Html->link(
‘View image’,
Array(‘controller’=>’images’,’action’=>’view’,1,
‘?’=>array(‘height’=>400,’width’=>500))
); ?>

Html:
<a href="/recipes/view/6">
    <img src="/img/recipes/6.jpg" alt="Brownies" />
</a>

Cake php:
<?php echo $this->Html->link($this->Html->image(“recipes/6.jpg”,array(“alt”=>”Brownies”)),
“recipies/view/6”,
Array(“escape”=>false)
); ?>

Html:
<span>Hello World</span>

Cake php:
<?php echo $this->Html->tag(‘span’,’Hello World’,array(‘class’=>’welcome’)); ?>

Html:
<span class='welcome'>

Cake php:
<?php echo $this->Html-tag(‘span’,null,array(‘class’=>’welcome’)); ?>

Html:
<div>Please enter your credit card number.</div>

Cake php:
<?php echo $this->Html->div(‘error’,’Please enter your credit card number’); ?>

Html:
<div id="register">

Cake php:
<?php echo $this->Html->div(‘register’,null,array(‘id’=>’register’)); ?>

Html:
<p>Hello World.</p>

Cake php:
<?php echo $this-Html->para(null,’Hello World.’) ?>

Html:
<script type="text/javascript" href="/js/scripts.js"></script>

Cake php:
<?php echo $this->Html->script(‘scripts’); ?>

Html:
<script type="text/javascript" href="/js/jquery.js"></script>
<script type="text/javascript" href="/js/wysiwyg.js"></script>
<script type="text/javascript" href="/js/scripts.js"></script>

Cake php:
<?php echo $this->Html->script(‘jquery’,’wysiwyg’,’scripts’); ?>

Html:
<tr>
    <th>Date</th>
    <th>Title</th>
    <th>Active</th>
</tr>

Cake php:
<?php echo $this->Html->tableHeaders(array(‘Date’,’Title’,’Active’)); ?>

Html:
<tr>
     <th>Date</th>
     <th>Title</th>
     <th>Active</th>
</tr>

Cake php:
<?php echo $this->Html->tableHeaders(
array(‘title’,’data’,’active’),
array(‘class’=>’status’),
array(‘class’=>’product_table’)
); ?>

Html:
<tr><td>Jul 7th, 2007</td><td>Best Brownies</td><td>Yes</td></tr>
<tr><td>Jun 21st, 2007</td><td>Smart Cookies</td><td>Yes</td></tr>
<tr><td>Aug 1st, 2006</td><td>Anti-Java Cake</td><td>No</td></tr>

Cake php:
<?php echo $this->Html->tableCells(array(
Array(‘Jul 7

th

, 2007’,’Best Brownies’,’Yes’),
Array(‘Jun 21

st

, 2007’,’Smart Cookies’,’Yes’),
Array(‘Aug 1

st

, 2006’,’Anti-Java Cake’,’No’)
)); ?>

Html:
<tr><td>Jul 7th, 2007</td><td>Best Brownies</td><td>Yes</td></tr>
<tr><td>Jun 21st, 2007</td><td>Smart Cookies</td><td>Yes</td></tr>
<tr><td>Aug 1st, 2006</td><td>Anti-Java Cake</td><td id="special">No</td></tr>

Cake php:
<?php echo $this->Html->tableCells(array(
Array(‘Jul 7

th

, 2007’,array(‘Best Brownies’,array(‘class’=>’highlight’)),’Yes’),
Array(‘jun 21

st

,2007’,’Smart Coookies’,’Yes’),
Array(‘Aug 1

st

, 2006’,’Anti-Java Cake’,array(‘No’,array(‘id’=>’special’)))
)) ?>

Html:
<tr><td>Red</td><td>Apple</td></tr>
<tr><td>Orange</td><td>Orange</td></tr>
<tr><td>Yellow</td><td>Banana</td></tr>

Cake php:
<?php echo $this->Html->tableCells(array(
Array(‘Red’,’Apple’),
Array(‘Orange’,’Orange’),
Array(‘Yellow’,’Banana’)
),array(‘class’=>’darker’)); ?>

Html:
/posts/view/bar

Cake php:
<?php echo $this->Html->url(array(
‘controller’=>’posts’,
‘action’ => ‘view’,
‘bar’
)); ?>

Html:
/posts/view/foo:bar

Cake php:

<?php echo $this->Html->url(array(

‘controller’=>’posts’,

‘action’ => ‘view’,

‘foo’ => ‘bar’

)); ?>

Html:

/posts/list.rss

Cake php:

<?php echo $this->Html-url(array(

‘controller’ => ‘posts’,

‘action’ => ‘list’,

‘ext’ => ‘rss’

)); ?>

Html:
http://somedomain.com/posts

Cake php:

<?php echo $this->Html->url(‘/posts’,true); ?>

Html:
/posts/search?foo=bar#first

Cake php:
<?php echo $this->Html->url(array(
‘controllrer’ => ’posts’,
‘action’ => ‘search’,
‘?’ => array(‘foo’=>‘bar’),
‘#’=>’first’
)); ?>

Html:

<a href=’#’><img src=’image.jpeg’ alt = ‘image’ style=’float:left; padding-left:25px;’ /></a>

Cake php:
<?php echo $this->Html->link($this->Html->image(‘image.jpeg’,array(‘alt’ =>’image’,’style’=>’float:left;padding-left:25px;’))); ?>


Leave a Reply

Your email address will not be published. Required fields are marked *