I have 4 tables named customers, calls, employees and companies. Customers belong to a company and an employee. Calls belong to a customer and an employee. At the moment in my call index file it shows the relevant customer name and employee name. I want to display, for a call the relevant customer name, the customers company name they belong to and the employee name. I don't know how to display the relevant company name based on the customer. Can someone help? This is my code:
call/ index.ctp
<?php
$usertype=$this->SESSION->read('User.usertype');
?>
<div class="calls index">
<h2><?php echo __('Call Details'); ?> </h2>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Call Time'); ?></th>
<th><?php echo $this->Paginator->sort('Comments'); ?></th>
<th><?php echo $this->Paginator->sort('Next Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Customer Name'); ?></th>
<th><?php echo $this->Paginator->sort('Employee Name'); ?></th>
<th class="actions"><?php echo __(''); ?></th>
</tr>
<?php foreach ($calls as $call): ?>
<tr>
<td><?php echo h($call['Call']['id']); ?> </td>
<td><?php echo h($call['Call']['call_date']); ?> </td>
<td><?php echo h($call['Call']['call_time']); ?> </td>
<td><?php echo h($call['Call']['comments']); ?> </td>
<td><?php echo h($call['Call']['next_call_date']); ?> </td>
<td>
<?php echo $this->Html->link($call['Customers']['customer_name'], array('controller' => 'customers', 'action' => 'view', $call['Customers']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Employees']['employee_name'], array('controller' => 'employees', 'action' => 'view', $call['Employees']['id'])); ?>
</td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $call['Call']['id'])); ?>
</td>
</tr>
callsController:
class CallsController extends AppController {
/**
* Components
*
* #var array
*/
public $components = array('Paginator');
/**
* index method
*
* #return void
*/
public function index() {
$this->Call->recursive = 0;
$this->set('calls', $this->Paginator->paginate());
}
/**
* view method
*
* #throws NotFoundException
* #param string $id
* #return void
*/
public function view($id = null) {
if (!$this->Call->exists($id)) {
throw new NotFoundException(__('Invalid call'));
}
$options = array('conditions' => array('Call.' . $this->Call->primaryKey => $id));
$this->set('call', $this->Call->find('first', $options));
}
/**
* add method
*
* #return void
*/
public function add() {
if ($this->request->is('post')) {
$this->Call->create();
if ($this->Call->save($this->request->data)) {
$this->Session->setFlash(__('The call has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The call could not be saved. Please, try again.'));
}
}
$customers= $this->Call->Customers->find('list',array('order'=>'customer_name ASC','fields'=>array('id','customer_name')));
$employees= $this->Call->Employees->find('list',array('order'=>'employee_name ASC','fields'=>array('id','employee_name')));
$this->set(compact('customers', 'employees'));
}
/**
* edit method
*
* #throws NotFoundException
* #param string $id
* #return void
*/
public function edit($id = null) {
if (!$this->Call->exists($id)) {
throw new NotFoundException(__('Invalid call'));
}
if ($this->request->is(array('post', 'put'))) {
if ($this->Call->save($this->request->data)) {
$this->Session->setFlash(__('The call has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The call could not be saved. Please, try again.'));
}
} else {
$options = array('conditions' => array('Call.' . $this->Call->primaryKey => $id));
$this->request->data = $this->Call->find('first', $options);
}
$customers= $this->Call->Customers->find('list',array('order'=>'customer_name ASC','fields'=>array('id','customer_name')));
$employees= $this->Call->Employees->find('list',array('order'=>'employee_name ASC','fields'=>array('id','employee_name')));
$this->set(compact('customers', 'employees'));
}
/**
* delete method
*
* #throws NotFoundException
* #param string $id
* #return void
*/
public function delete($id = null) {
$this->Call->id = $id;
if (!$this->Call->exists()) {
throw new NotFoundException(__('Invalid call'));
}
$this->request->onlyAllow('post', 'delete');
if ($this->Call->delete()) {
$this->Session->setFlash(__('The call has been deleted.'));
} else {
$this->Session->setFlash(__('The call could not be deleted. Please, try again.'));
}
return $this->redirect(array('action' => 'index'));
}}
the array looks like this:
Array
(
[Call] => Array
(
[id] => 7
[call_date] => 2013-04-27
[call_time] => 08:31:00
[comments] => Require installation
[next_call_date] => 2014-04-27
[customers_id] => 2
[employees_id] => 3
)
[Customers] => Array
(
[id] => 2
[customer_name] => Snith Jams
[customer_address] => 192 Waverley Road
[customer_suburb] => Caulfield East
[customer_state] => VIC
[customer_postcode] => 3145
[customer_dob] => 2014-04-09
[customer_anniversary] => 2014-04-10
[customer_phone1] => 0492832921
[customer_phone2] => 0392817894
[customer_phone3] => 0482938281
[customer_fax] =>
[customer_email] => tsmith#hotmail.com
[customer_gender] => M
[customer_type] => Silver
[customer_PW] => a1c680c2bfcca40816dd81eff3980cc9828c9088
[customer_username] => samman
[companies_id] => 3
[employees_id] => 11
)
[Employees] => Array
(
[id] => 3
[employee_name] => Jones
[date_hired] => 2013-02-04
[employee_phone_number] => 0449997582
[employee_email] => indianajones#gmail.com
[employee_address] => 22 Queens street Melbourne CBD
[employee_dob] => 1966-01-31
[access_level] => staff
[employee_username] => jones12
[employee_pw] => 603fce7dcbec3c9cba24e87d058a3341e37779b8
)
)
callsController:
public $components = array('Paginator');
public function index() {
$this->Call->recursive = 2;
$this->set('calls', $this->Paginator->paginate());
}
calls/index.ctp:
<div class="calls index">
<h2><?php echo __('Call Details'); ?> </h2>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Call Time'); ?></th>
<th><?php echo $this->Paginator->sort('Comments'); ?></th>
<th><?php echo $this->Paginator->sort('Next Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Customer Name'); ?></th>
<th><?php echo $this->Paginator->sort('Company Name'); ?></th>
<th><?php echo $this->Paginator->sort('Employee Name'); ?></th>
<th class="actions"><?php echo __(''); ?></th>
</tr>
<?php foreach ($calls as $call): ?>
<tr>
<td><?php echo h($call['Call']['id']); ?> </td>
<td><?php echo h($call['Call']['call_date']); ?> </td>
<td><?php echo h($call['Call']['call_time']); ?> </td>
<td><?php echo h($call['Call']['comments']); ?> </td>
<td><?php echo h($call['Call']['next_call_date']); ?> </td>
<td>
<?php echo $this->Html->link($call['Customers']['customer_name'], array('controller' => 'customers', 'action' => 'view', $call['Customers']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Customers']['Companies']['company_name']); ?>
</td>
<td>
<?php echo $this->Html->link($call['Employees']['employee_name'], array('controller' => 'employees', 'action' => 'view', $call['Employees']['id'])); ?>
</td>
<?php echo pr($call); ?>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $call['Call']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
just set recursive to 2
$this->Call->recursive = 2;
(or $this->Calls->recursive = 2 it depends if your model is Call or Calls)
and you can access to Company information like this
$call['Customer']['Company']['name']
Because it seems you are not following cake naming conventions (you are using plural for Models' names) maybe you'll need to use
$call['Customers']['Companies']['name']
I suggest you to follow the conventions, anyway if you print your array doing pr($call); you'll see how the array is structured and how to access your data
Related
i have two tables with the following columns, guardians(id,student_no) and student(id,admission_no). student_no is foreign to admision_no. students has a hasMany association with guardians, guardians has a belongsTo association with students.
here are my models
STUDENT
public $hasMany = array(
'Guardian' => array(
'className' => 'Guardian',
'foreignKey' => 'student_no',
'dependent' => true,
)
)
GUARDIAN
public $belongsTo = array(
'Student' => array(
'className' => 'Student',
'foreignKey' => 'student_no',
)
)
Guardian controller
public function view($id = null) {
if (!$this->Guardian->exists($id)) {
throw new NotFoundException(__('Invalid guardian'));
}
$options = array('conditions' => array('Guardian.' . $this->Guardian->primaryKey => $id));
$this->set('guardian', $this->Guardian->find('first', $options));
}
Guardian view.ctp
(truncated to view only the associated student from within the Guardian model)
<h3><?php echo __('Associated Students'); ?></h3>
<?php if (!empty($guardian['Student'])): ?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php echo __('Admission No'); ?></th>
<th><?php echo __('First Name'); ?></th>
<th><?php echo __('Last Name'); ?></th>
<th><?php echo __('Gender'); ?></th>
<th><?php echo __('Date Of Birth'); ?></th>
<th><?php echo __('Join Date'); ?></th>
<th><?php echo __('Form'); ?></th>
<th><?php echo __('Student Class'); ?></th>
<th><?php echo __('Middle Name'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php foreach ($guardian['Student'] as $student): ?>
<tr>`
<td><?php echo $student['admission_no']; ?></td>
line(115) <td><?php echo $student['first_name']; ?></td>
<td><?php echo $student['last_name']; ?></td>
<td><?php echo $student['gender']; ?></td>
<td><?php echo $student['date_of_birth']; ?></td>
<td><?php echo $student['join_date']; ?></td>
<td><?php echo $student['form']; ?></td>
<td><?php echo $student['student_class']; ?></td>
<td><?php echo $student['middle_name']; ?></td>
</tr>
<?php endforeach; ?>
</table>
i can view associated parent details from students view with above similar code,
however in guardians view i get error for the associated guardian
ERROR:Warning (2): Illegal string offset 'first_name' [APP/View/Guardians/view.ctp, line 115]
and for three lines below it.what exactly is going wrong
Do some debugging: debug($guardian)
In your belongsTo assocaition, a guardian can only have a single student, so you are iterating over the columns of that one single student, ie consequently the $student variable will be a string, hence the error.
See also Cookbook > Models > Associations > belongsTo
I have the following code in my calls/index.ctp. At the moment it is showing all records in one page. I want to limit 20 records per page. When I baked the project, the pagination was provided, but I'm still a beginner and doesn't know how to change the pagination. Can someone please help?
calls/index.ctp:
<div class="callsIndex">
<h2><?php echo __('Call Details'); ?> </h2>
<div class="bottomButtonnew"><?php echo $this->Html->link(__('Add Calls'), array('action' => 'add')); ?></div>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Call Time'); ?></th>
<th><?php echo $this->Paginator->sort('Comments'); ?></th>
<th><?php echo $this->Paginator->sort('Next Call Date'); ?></th>
<th><?php echo $this->Paginator->sort('Customer Name'); ?></th>
<th><?php echo $this->Paginator->sort('Company Name'); ?></th>
<th><?php echo $this->Paginator->sort('Employee Name'); ?></th>
<th class="actions"><?php echo __(''); ?></th>
</tr>
<?php foreach ($calls as $call): ?>
<tr>
<td><?php echo date("d-m-Y", strtotime($call['Call']['call_date'])); ?> </td>
<td><?php echo h($call['Call']['call_time']); ?> </td>
<td><?php echo h($call['Call']['comments']); ?> </td>
<td><?php echo date("d-m-Y", strtotime($call['Call']['next_call_date'])); ?> </td>
<td>
<?php echo $this->Html->link($call['Customers']['customer_name'], array('controller' => 'customers', 'action' => 'view', $call['Customers']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Companies']['company_name'], array('controller' => 'companies', 'action' => 'view', $call['Companies']['id'])); ?>
</td>
<td>
<?php echo $this->Html->link($call['Employees']['employee_name'], array('controller' => 'employees', 'action' => 'view', $call['Employees']['id'])); ?>
</td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('action' => 'view', $call['Call']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total')
));
?> </p>
<div class="paging">
<?php
echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers(array('separator' => ''));
echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
?>
</div>
<br>
</div>
callsController:
<?php
App::uses('AppController', 'Controller');
class CallsController extends AppController {
public $components = array('Paginator');
public $paginate = array(
'limit' => 10
);
public function index() {
$userid=$this->Session->read('User.userid');
if(isset($userid)&&$userid!=null)
{
$this->Call->recursive = 0;
$this->set('calls', $this->Paginator->paginate());
$result=$this->Call->getcalls($userid);
$this->set('result', $result);
}
else{
$this->set('loggedout',"loggedout");
$this->render("../Pages/home");
$this->layout = '../Pages/home';
}
}
//some code
}
You can do it easily by using pagination component.You should do it in your AppController.In your AppController you can type below code
Public $components =array('paginator');
public function beforeFilter()
{
parent::beforeFilter();
$this->Paginator->settings=array(
'limit'=>10
);
}
Than in you index method just change this line
$this->set('calls', $this->Paginator->paginate());
I think that will work fine now.This code will work for all controller.But if you want to change this only your CallsController. Do this code.
<?php
App::uses('AppController', 'Controller');
class CallsController extends AppController {
public $components = array('Paginator');
public function index() {
$this->Paginator->settings = array(
'limit' => 10
);
$userid=$this->Session->read('User.userid');
if(isset($userid)&&$userid!=null)
{
$this->Call->recursive = 0;
$this->set('calls', $this->Paginator->paginate());
$result=$this->Call->getcalls($userid);
$this->set('result', $result);
}
else{
$this->set('loggedout',"loggedout");
$this->render("../Pages/home");
$this->layout = '../Pages/home';
}
}
//some code
}
Note : There is two way to apply pagination one is by using component another is in controller.
The correct call in your example should be like this:
$this->set('calls', $this->paginate());
So your code is:
<?php
App::uses('AppController', 'Controller');
class CallsController extends AppController {
public $components = array('Paginator');
public $paginate = array(
'limit' => 10 //Here can you change the default limit
);
public function index() {
$userid=$this->Session->read('User.userid');
if(isset($userid)&&$userid!=null)
{
$this->Call->recursive = 0;
$this->set('calls', $this->paginate());
$result=$this->Call->getcalls($userid);
$this->set('result', $result);
}
else{
$this->set('loggedout',"loggedout");
$this->render("../Pages/home");
$this->layout = '../Pages/home';
}
}
//some code
}
<?php
App::uses('AppController', 'Controller');
class CallsController extends AppController {
public $components = array('Paginator');
public $paginate = array(
'limit' => 20
);
}
I am currently trying to solve a problem which I just noticed since the property didn't actually have a main_image allocated to it.
But as soon as I allocated a main image to it. The Related images caused problems.
Property table has a belongsTo relation
public $belongsTo = array( 'Image' => array(
'className' => 'Image',
'foreignKey' => 'main_image_id'
));
and also a hasMany
public $hasMany = array(
'Image' => array(
'className' => 'Image',
'foreignKey' => 'property_id'
)
);
the problem is when I am populating the related images I am receiving multiple errors similar to the below
Illegal string offset 'id'
my data is like so
property(array)
Image(array)
id1
descriptionPainted Brick Design
imageuploads/properties/3/Amazing-Painted-Brick-Houses-Design.jpeg
property_id3
0(array)
id1
descriptionPainted Brick Design
imageuploads/properties/3/Amazing-Painted-Brick-Houses-Design.jpeg
property_id3
and the view was generated like so
<div class="related">
<h3><?php echo __('Related Images'); ?></h3>
<?php if (!empty($property['Image'])): ?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php echo __('Id'); ?></th>
<th><?php echo __('Description'); ?></th>
<th><?php echo __('Image'); ?></th>
<th><?php echo __('Property Id'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
<?php foreach ($property['Image'] as $image): ?>
<tr>
<td><?php echo $image['id']; ?></td>
<td><?php echo $image['description']; ?></td>
<td><?php echo $image['image']; ?></td>
<td><?php echo $image['property_id']; ?></td>
<td class="actions">
<?php echo $this->Html->link(__('View'), array('controller' => 'images', 'action' => 'view', $image['id'])); ?>
<?php echo $this->Html->link(__('Edit'), array('controller' => 'images', 'action' => 'edit', $image['id'])); ?>
<?php echo $this->Form->postLink(__('Delete'), array('controller' => 'images', 'action' => 'delete', $image['id']), null, __('Are you sure you want to delete # %s?', $image['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $this->Html->link(__('New Image'), array('controller' => 'images', 'action' => 'add')); ?> </li>
</ul>
</div>
</div>
I am not sure if maybe the relations are setup incorrectly or that maybe I would have to include an if to see if there is data before the array and then implement a for loop.
I will answer it rather then comment. You will get all the properties and their main image like this (place this in your controller action eg. index()):
$properties= $this->Property->find('all', array(
'contain' => array(
'Image' => array(
'conditions' => array(
'main_image' => true
)
)
)
));
$this->set('properties', $properties);
and in your view:
<img src='<?php echo '/realestateagencyadministration/img/' . $property['Image'][0]['main_image'] ?>' style='max-width: 100%;height:150px;;'>
Don't take my for sure on this last one, I am wrinting this out of my head, I think you need [0], but you can easily fix that.
Our group create a database for patron to attend an event (booking) which has lots of entities.
We have three tables: patron, booking, booking_patron (join table).
We want to create 2 pages in the view (add.ctp and add2.ctp) of booking_patron.
Page add.ctp has a drop down box which lists booking ID and a submit button.
Page add2.ctp should appear the booking ID that we chose before (in add.ctp). Also in add2.ctp, we did make a function that user can create a patron and assign that patron to the booking ID.
BookingsPatronsController.php
public function add() {
$bookings = $this->BookingsPatron->Booking->find('list');
$this->set(compact('bookings', 'patrons'));
}
public function add2($booking_id = null) {
$patrons = $this->BookingsPatron->Patron->find('list');
$bookings = $this->BookingsPatron->Booking->find('list');
$this->set(compact('bookings', 'patrons'));
if ($this->request->is('post')) {
$this->BookingsPatron->Patron->create();
if ($this->BookingsPatron->Patron->save($this->request->data)) {
$this->Session->setFlash("Sign In Successful");
$this->BookingsPatron->create();
$this->Session->setFlash(__('Well.... done'));
$this->redirect(array('action' => 'add3'));
} else {
$this->Session->setFlash(__('We can not add your information. Please, try again.'));
}
}
}
The problem is: we don't know how to get the booking ID from add.ctp to add2.ctp.
At the moment, we use a drop down box that list booking ID in add2.ctp to choose the booking; we want to change that to a static text field that appears the booking ID from add.ctp.
We also have a function that can create a new patron in add2.ctp. We want to assign the new patron to the chosen booking ID from add.ctp
add.ctp
<?php echo $this->Form->input('Booking.booking_id');?>
<?php echo $this->Html->link(__('Create'), array('action' => 'add3')); ?>
add2.ctp
<?php echo $this->Form->create('BookingsPatron'); ?>
<fieldset>
<?php echo $this->Form->input('Booking.booking_id');?>
<table cellpadding="3" cellspacing="3">
<tr>
<td class="heading">Name: </td>
<td><?php echo $this->Form->input('Patron.patrons_name', array('label' => '', 'div' => 'formLabel'));?></td>
<td></td><td></td>
<td class="heading">E-mail: </td>
<td><?php echo $this->Form->input('Patron.patrons_email', array('label' => '', 'div' => 'formLabel'));?></td>
</tr>
<tr>
<td class="heading">Age: </td>
<td><?php echo $this->Form->input('Patron.patrons_age', array('label' => '', 'div' => 'formLabel'));?></td>
<td></td><td></td>
<td class="heading">Company: </td>
<td><?php echo $this->Form->input('Patron.patrons_company', array('label' => '', 'div' => 'formLabel'));?></td>
</tr>
<tr>
<td class="heading">Postcode: </td>
<td><?php echo $this->Form->input('Patron.patrons_postcode', array('label' => '', 'div' => 'formLabel'));?></td>
<td></td><td></td>
<td class="heading">Gender: </td>
<td><?php echo $this->Form->input('Patron.patrons_gender', array('label' => '', 'div' => 'formLabel', 'type' => 'select', 'options' => array('Male' => 'Male', 'Female' => 'Female')));?></td>
</tr>
<tr>
<td colspan="2">PH: 1300 7 34726</td>
<td colspan="3"></td>
<td><?php echo $this->Form->submit('Submit', array('class' => 'classSubmitButton', 'title' => 'Sbumit')); ?></td>
</tr>
</table>
</fieldset>
This should work
public function add() {
if ($this->request->is('post')) {
$this->Session->write('booking_id', $this->request->data['Booking']['booking_id']);
$this->redirect(array('action' => 'add2')); // Line added
}
$bookings = $this->BookingsPatron->Booking->find('list');
$this->set(compact('bookings', 'patrons'));
}
And to retreive the ID use this in your add2() function
$booking_id = $this->Session->read('booking_id');
Update
edit add.ctp -- This needs to be a form, not just a link, otherwise you don't submit the booking ID
<?php
echo $this->Form->create('Booking');
echo $this->Form->input('Booking.booking_id');
echo $this->Form->end(__('Create'));
?>
I don't know if I'm going the right way with the tree behavior but I'm trying to build a comment system for a blog. I would like to have an indentation of 5 level depth.
The generatetreelist method looks like it would be the fastest way to accomplish this but it doesn't look like you can add fields to the query. Am I right ? Is there a way to modify the method ?
Thanks
This is how I do it for categories. You could modify accordingly.
In controller:
$categories = $this->Category->generatetreelist(null,null,null,"|-- ");
$categories_array = array();
foreach($categories as $k => $v)
{
$categories_array[$k] = $this->Category->find('first', array('conditions' => array('Category.id' => $k)));
$categories_array[$k]["Category"]["path"] = $v;
}
$this->set(compact('categories','categories_array'));
In view:
<table>
<thead>
<tr>
<th><?php __('Id');?></th>
<th><?php __('Name');?></th>
<th><?php __('Status');?></th>
<th><?php __('Action');?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($categories_array AS $categoryId => $category):
$class = 'even';
if ($i++ % 2 == 0) {
$class = 'odd';
}?>
<tr class="<?php echo $class;?>">
<td><?php echo $category['Category']['id']; ?></td>
<td><?php echo $category["Category"]["path"];?></td>
<?php if ($category['Category']['status'] == '1'){
$published = 'Active';
}else {
$published = 'Inactive';
} ?>
<td><?php echo $published;?></td>
<td>
<?php echo $html->link($html->image("icons/16_icon_view.png"), array('action' => 'view', $category['Category']['id']), array('title'=>'View','escape' => false));?>
<?php echo $html->link($html->image("icons/16_icon_edit.png"), array('action' => 'edit', $category['Category']['id']), array('title'=>'Edit','escape' => false));?>
<?php echo $html->link($html->image("icons/16_icon_delete.png"), array('action' => 'delete', $category['Category']['id']), array('class'=>'delete_trigger','rel'=>'#error','title'=>'Delete','escape' => false));?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
If it was me, I would just do this in the result set. As you get a numeric array in the first dimension of the results you could use that when outputting the data to indent or add a class to your comments as you needed.