Cakephp Undefined Index - cakephp

When creating a view I am getting a undefined index error: Account on the line with $senderName['Account']['company_name']but when debugging the variable the array prints out
array(
(int) 0 => array(
'Account' => array(
'id' => '0',
'street' => 'SYSTEM',
'city' => 'SYSTEM',
'postcode' => '0',
'state' => 'SYS',
'country' => 'SYS',
'active' => true,
'company_name' => 'SYSTEM',
'abn' => '0'
),
'Template' => array(),
'User' => array(),
'Invoice' => array()
),
here is the code for my view
<?php foreach($invoice as $invoices):?>
<?php foreach($senderName as $senderName):?>
<?php foreach($receiverName as $receiverName):?>
<tr>
<tr>
<td align='center'><?php echo $senderName['Account']['company_name']; ?></td>
<td align='center'><?php echo $receiverName['Account']['company_name']; ?></td>
<td align='center'><?php echo $this->Form->Html->link($invoices['Invoice']['id'],
array('controller' => 'Invoices','action'=>'viewinvoice',$invoices['Invoice']['id'])); ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
and just in case here is my related function
$accounts2=$this->User->find('list', array(
'fields'=>array('account_id'),
'conditions' => array(
'id' => $this->Auth->user('id'))));
$invoices=$this->Invoice->find('all', array(
'conditions' => array(
'Invoice.receiver_id' => $accounts2)));
$sender=$this->Invoice->Find('list', array('fields'=>('sender_id')));
$receiver=$this->Invoice->Find('list', array('fields'=>('receiver_id')));
$senderName=$this->Account->Find('all', array(
'conditions' => array(
'id'=>array_values($sender))));
$receiverName=$this->Account->find('all', array(
'conditions' => array(
'id'=>array_values($receiver))));
debug($senderName);
$this->set('senderName', $senderName);
$this->set('accounts2', $accounts2);
$this->set('receiverName', $receiverName);
$this->set('sender',$sender);
$this->set('receiver',$receiver);
$this->set('invoice', $invoices);
}

You're computer is right. :)
$senderName['Account']['company_name']
does not exists.
$senderName['0']['Account']['company_name']
does.
The data comes in this format as they may be several account liked to senderName.
Edit:
Could you give the relationship in your models too?

I think you should review your code in view :
<?php foreach($senderName as $senderName):?>
<?php foreach($receiverName as $receiverName):?>
in foreach array_expression and value variable should be different but you have used same variable name, please use different names for this.

Related

how to add search by date cakePHP

I have the following code that displays a list of details from my Database.
It is paginated as well.
I want to add a search function that someone can search the provided data using " Date From - Date To "
Currenty source :
$tapplicant= $this->paginate = array(
'fields' => array(
'Tapplicant.*',
'Toutcome.*'
),
'joins' => array(
array(
'table' => 'toutcome',
'alias' => 'Toutcome',
'type' => 'INNER',
'conditions' => array('Tapplicant.AppID = Toutcome.AppID' )
)
),
'conditions' => array(
'Tapplicant.AppDate >=' => date('y-m-d')
),
'order' => array('Tapplicant.AppDate' => 'DESC'),
'limit' => 15
);
$this->set('tapplicant', $this->paginate());
I display the data as followed :
<?php foreach ($tapplicant as $tapplicant) : ?>
<tr>
<td><?=$tapplicant['Tapplicant']['AppID']; ?></td>
<td><?=$tapplicant['Tapplicant']['AppAffID']; ?></td>
<td><?=$tapplicant['Tapplicant']['FirstName']; ?></td>
<td><?=$tapplicant['Tapplicant']['LastName']; ?></td>
<td><?=$tapplicant['Tapplicant']['AppDate']; ?></td>
<td><?=$tapplicant['Tapplicant']['AppDomain']; ?></td>
<td>£<?=$tapplicant['Toutcome']['LenderCommission']; ?></td>
<td><?=$tapplicant['Toutcome']['LenderName']; ?></td>
</tr>
After doing some research and trying things like :
$this->Post->find('all', array('conditions'=>array('AppID'=>5, 'DATE(AppDate)'=>'CURDATE()')));
I cant get it to work.
If someone could please assist on help with the controller and view side.
Use BETWEEN:
$conditions = array(
'Tapplicant.AppDate BETWEEN ? AND ?' => array(
$start,
$end,
)
);
Read more about complex find conditions in CakePHP 2 here: http://book.cakephp.org/2.0/en/models/retrieving-your-data.html#complex-find-conditions

How cakePHP build form data

i've created a form that loop in my table and give me some images:
id1: ->Image path, title etc
id2: -> Image path title etc
i've created my view in this way:
<div>
<?php echo $this->Form->create('Gallery',
array( 'action' => 'save')); ?>
<table cellpadding="0" cellspacing="0">
<?php foreach($images as $image): ?>
<tr>
<td>
<?php echo $this->PhpThumb->thumbnail($image['medias']['file'], array('w' => 75, 'h' => 75)); ?>
</td>
<td><?php echo $this->Form->input('title'.$image['medias']['id'], array('value' => $image['medias']['title']));?></td>
<td><?php echo $this->Form->input('description'.$image['medias']['id'], array('value' => $image['medias']['description']));?></td>
</tr>
<?php endforeach; ?>
</table>
<?php echo $this->Form->end(__('Submit')); ?>
After submit, i have an array like this:
array(
'Gallery' => array(
'title19' => 'test',
'description19' => '',
'title20' => '',
'description20' => '',
'title21' => '',
'description21' => '',
'title22' => '',
'description22' => ''
)
)
For sure, i cant use the save() method because the array isnt well formatted. I think the right format should be:
array(
'Gallery' => array(
array('id' => 19,
'title => 'test',
'description => ''),
array( 'id' =>20,
title => '',
description => '')
)
)
but, how can i get this ? Or some array that is right formatted?
When you iterate over them put the iterator or id in the right place:
$this->Form->input('Model.' . $i . 'field');
$this->Form->input('Model.' . $i . 'other_field');
References:
Saving your data
Form Helper

Cakephp foreach data for options in select (form)

in my project I have database
"Products" hasAndBelongsToMany "Sizes"
"ProductsSize" belongsTo "Products"
"ProductSize" belongsTo "Size"
In ProductsSize, one product_id may have many size_id.
hence, i want to do a form that have a select type input that list down all the size_id where the product_id = $id.
What i have done is:
in controller:
$size = $this->Product->ProductsSize->find('all', array(
'conditions' => array('ProductsSize.product_id' => $id),
'fields' => array('ProductsSize.size_id'),
));
in view:
<?php echo $this->form->create('Cart', array('action' => 'add')); ?>
<?php echo $this->form->input('size_id', array('label' => 'Size', 'options' => $size)); ?>
then i got error: Undefined index: ProductsSize
but when i put foreach, the data shown:
<?php foreach ($size_apparel as $size): ?>
<?php echo $size['ProductsSize']['size_id'];?><br/>
<?php endforeach; ?>
can anyone please help me to do the foreach in options.
The problem is that you are using an invalid array for the options. You are requesting:
$size = $this->Product->ProductsSize->find('all', array(
'conditions' => array('ProductsSize.product_id' => $id),
'fields' => array('ProductsSize.size_id'),
));
What you should be requesting is:
$size = $this->Product->ProductsSize->find('list', array(
'conditions' => array('ProductsSize.product_id' => $id),
));
This will return the options for the form field in the format it expects which is:
array(
{id} => {size},
{id} => {size},
{id} => {size},
{id} => {size},
...
)
I think you meant to say
<?php echo $this->form->input('size_id', array('label' => 'Size', 'options' => $size)); ?>
note 'options' instead of 'value'
$List = Set::classicExtract($size, '{n}.ProductSize.product_id');
$List will contain key value(ProductSize.product_id) pair.
OR you can change your query as
$size = $this->Product->ProductSize->find('list', array(
'conditions' => array('ProductSize.product_id' => $id),
));
Hope it will work for you

CakePHP 2.3: Save multiple forms in multiple tables all at once in 1 page

I'm trying to set up a commercial proposal system using CakePHP 2.3.
It has 5 tables which are associated (see details below).
This system will have 1 page on which are 5 forms for each table. (see details below).
Form 1: table proposals
Form 2: table clients FK proposal_id
Form 3: table products FK client_id
Form 4: table specifications FK product_id (of the product)
Form 5: table appendices FK product_id (of the product)
WHERE:
proposals hasOne clients.
----------v----------
clients beongsTo proposals AND hasMany products.
----------v----------
products belongsTo clients AND hasMany specifications & appendices.
----------v----------
specifications belongsTo products.
appendices belongsTo products.
The form 4 can have multiple row so it's inside a foreach loop to generate more input. Same for the form 5. Because 1 product can have multiple specifications and appendices.
I admit, it's pretty tricky :)
This is the solution I finally chose, but maybe there is better. For exemple, I could make a multi-step form but it seems quite difficult to put in place. Anyway, i'm open to suggestion.
Meanwhile, I'm sure we can make this work so here are the details. For each table, I have created a model and made the appropriated connections. In each model I have enable the containable behaviour: public $actsAs = array('Containable');.
Now here is the ProposalsController.php:
function admin_edit($id=null){
$this->loadModel('Proposal','Client','Product', 'Specification', 'Appendice');
$this->Proposal->contain('Proposal','Client','Product', 'Specification', 'Appendice');
if ($this->request->is('put') || $this->request->is('Post')) {
$data = $this->request->data;
if (!empty($data)) {
// Use the following to avoid validation errors:
// unset($this->Proposal->Client->validate['proposal_id']);
// $this->Proposal->saveAssociated($data);
// $this->Session->setFlash("Le contenu a bien été édité");
// $this->redirect(array('action' => 'index', $data['Product']['id']));
debug($data);
}
}
elseif($id){
$this->Proposal->id = $id;
$this->request->data = $this->Proposal->read(null,$id);
}
}
This edit action has many errors because I don't know how to set it up correctly in that case. So forgive me but I give you a raw code :). I would like this admin_function to add or edit, but again, in this case I don't know how to handle it.
And the view admin_edit.ctp :
<hr/>
<h1>Proposition</h1>
<hr/>
<?php echo $this->Form->create('Product'); ?>
<?php echo $this->Form->input('Proposal.name', array('label' => "Nom de la proposition")); ?>
<?php echo $this->Form->input('Proposal.created', array('label' => "Date de création")); ?>
<?php echo $this->Form->input('Proposal.due', array('label' => "Date d'échéance")); ?>
<?php echo $this->Form->input('Proposal.content', array('label' => "Termes & conditions")); ?>
<hr/>
<h1>Client</h1>
<hr/>
<?php echo $this->Form->input('Client.name', array('label' => "Nom du client")); ?>
<?php echo $this->Form->input('Client.project', array('label' => "Nom du projet")); ?>
<?php echo $this->Form->input('Client.address', array('label' => "Adresse")); ?>
<?php echo $this->Form->input('Client.phone', array('label' => "Téléphone")); ?>
<?php echo $this->Form->input('Client.email', array('label' => "Email")); ?>
<?php echo $this->Form->hidden('Client.proposal_id'); ?>
<hr/>
<h1>Produit</h1>
<hr/>
<?php echo $this->Form->input('Product.0.name', array('label' => "Nom du produit")); ?>
<?php echo $this->Form->input('Product.0.reference', array('label' => "Référence")); ?>
<?php echo $this->Form->input('Product.0.image', array('label' => "Image")); ?>
<?php echo $this->Form->input('Product.0.pu', array('label' => "Prix Unitaire")); ?>
<?php echo $this->Form->input('Product.0.quantity', array('label' => "Quantité")); ?>
<?php echo $this->Form->input('Product.0.ce', array('label' => "CE")); ?>
<?php echo $this->Form->input('Product.0.nf', array('label' => "NF")); ?>
<?php echo $this->Form->input('Product.0.rohs', array('label' => "RoHS")); ?>
<?php echo $this->Form->hidden('Product.0.client_id'); ?>
<hr/>
<h1>Spécifications :</h1>
<hr/>
<?php
foreach (range(0,1) as $i):
$a=$i+1;
echo '<p>Spécification '.$a.'</p>';
echo $this->Form->input('Specification.'.$i.'.name', array('label' => "Nom de la spécification"));
echo $this->Form->input('Specification.'.$i.'.value', array('label' => "Valeur de la spécification"));
echo $this->Form->hidden('Specification.'.$i.'.product_id');
endforeach;
?>
<hr/>
<h1>Annexes :</h1>
<hr/>
<?php
foreach (range(0,1) as $j):
$b=$j+1;
echo '<p>Annexe '.$b.'</p>';
echo $this->Form->input('Appendice.'.$j.'.name', array('label' => "Image"));
echo $this->Form->input('Appendice.'.$j.'.content', array('label' => "Description de l'annexe"));
echo $this->Form->hidden('Appendice.'.$j.'.product_id');
endforeach;
?>
<?php echo $this->Form->end('valider'); ?>
And finally, here is the array result of the debug($data):
array(
'Proposal' => array(
'name' => 'Proposition 3',
'created' => array(
'month' => '02',
'day' => '19',
'year' => '2013',
'hour' => '08',
'min' => '27',
'meridian' => 'am'
),
'due' => array(
'month' => '02',
'day' => '19',
'year' => '2013',
'hour' => '08',
'min' => '27',
'meridian' => 'am'
),
'content' => 'Termes & conditions'
),
'Client' => array(
'name' => 'Client 3',
'project' => 'Projet Client 3',
'address' => 'Adresse Client 3',
'phone' => 'Téléphone Client 3',
'email' => 'Email#test.com',
'proposal_id' => ''
),
'Product' => array(
(int) 0 => array(
'name' => 'Produit 3',
'reference' => 'Référence Produit 3',
'image' => 'Image Produit 3',
'pu' => '100.77',
'quantity' => '1000',
'ce' => '1',
'nf' => '0',
'rohs' => '0',
'client_id' => ''
)
),
'Specification' => array(
(int) 0 => array(
'name' => 'Specification 1',
'value' => 'Valeur 1',
'product_id' => ''
),
(int) 1 => array(
'name' => 'Specification 2',
'value' => 'Valeur 2',
'product_id' => ''
)
),
'Appendice' => array(
(int) 0 => array(
'name' => 'Image annexe 1',
'content' => 'Description de l'annexe',
'product_id' => ''
),
(int) 1 => array(
'name' => 'Image annexe 2',
'content' => 'Description de l'annexe',
'product_id' => ''
)
)
)
So in this array, everything is there. I just need to take these data and save them all in the corresponding tables. The first problem is to manage with the table's associations. Then the 2 foreach loops that generate multiple row.
I would like to save it all at once but is it even possible?
After trying many ways to get it work, I've gone completely crazy and I just lost myself. I'm really desperate on that one, i mix up everything between the saving method and the request->data that contains everything but cannot get it saved. Anyway, i'm desperately in need for help!
Thank you very much in advance for all the help you can give me, I really appreciate!
[EDIT]
I add my model to the present post for more detail.
Proposal.php:
<?php
class Proposal extends AppModel {
public $actsAs = array('Containable');
public $validate = array(
'name' => array(
'rule' => 'notEmpty',
'message' => "Veuillez préciser un titre"
)
) ;
public $hasOne = array(
'Client' => array(
'className' => 'Client',
'foreignKey' => 'proposal_id',
'dependent' => true
)
);
}
Client.php:
<?php
class Client extends AppModel {
public $actsAs = array('Containable');
public $belongsTo = array(
'Proposal' => array(
'className' => 'Proposal',
'foreignKey' => 'proposal_id'
)
);
public $hasMany = array(
'Product' => array(
'className' => 'Product',
'foreignKey' => 'client_id',
'conditions' => '',
'order' => '',
'limit' => '',
'dependent' => true
)
);
}
Product.php:
<?php
class Product extends AppModel {
public $actsAs = array('Containable');
public $belongsTo = array(
'Client' => array(
'className' => 'Client',
'foreignKey' => 'client_id'
)
);
public $hasMany = array(
'Specification' => array(
'className' => 'Specification',
'foreignKey' => 'product_id',
'conditions' => '',
'order' => '',
'limit' => '',
'dependent' => true
),
'Appendice' => array(
'className' => 'Appendice',
'foreignKey' => 'product_id',
'conditions' => '',
'order' => '',
'limit' => '',
'dependent' => true
)
);
}
Specification.php:
<?php
class Specification extends AppModel {
public $actsAs = array('Containable');
public $belongsTo = array(
'Product' => array(
'className' => 'Product',
'foreignKey' => 'product_id'
)
);
}
Appendice.php:
<?php
class Appendice extends AppModel {
public $actsAs = array('Containable');
public $belongsTo = array(
'ProductAppend' => array(
'className' => 'Product',
'foreignKey' => 'product_id'
)
);
}
What's the output when you save the data?
if (!empty($this->data)) {
$this->Proposal->save($this->data);
}
You should also check the sql-output
echo $this->element('sql_dump');
edit:
Well after your edit, on the first look it seems that your relations are wrong.
Check out the examples in the book: http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
For example hasOne: the other model contains the foreign key.
As I said earlier, you should try to start with just one relation, getting it to work. Afterwords, it'll be much easier to get the other working. So try to comment-out everything except your Proposal and Client model. Then try saving just those two.

cakephp: search page giving http 404 webpage cannot be found

When I click the search link in the cupcake forum plugin, enter the search criteria and click submit, I get a blank page in firefox and http 404 website cannot be found in IE.
I have no idea on what i'm doing wrong. Can someone help me? Thank you.
the following is the search_controller:
class SearchController extends ForumAppController {
/**
* Controller Name
* #access public
* #var string
*/
public $name = 'Search';
/**
* Models
* #access public
* #var array
*/
public $uses = array('Forum.Topic');
/**
* Pagination
* #access public
* #var array
*/
public $paginate = array(
'Topic' => array(
'order' => 'LastPost.created DESC',
'contain' => array('ForumCategory.title', 'User.id', 'User.username', 'LastPost.created', 'LastUser.username', 'Poll.id', 'FirstPost.content')
)
);
/**
* Search the topics
* #access public
* #param string $type
*/
public function index($type = '') {
$searching = false;
print_r($this->params['named']);
// Build
if (!empty($this->params['named'])) {
foreach ($this->params['named'] as $field => $value) {
$this->data['Topic'][$field] = urldecode($value);
}
}
if ($type == 'new_posts') {
$this->data['Topic']['orderBy'] = 'LastPost.created';
$this->paginate['Topic']['conditions']['LastPost.created >='] = $this->Session->read('Forum.lastVisit');
}
echo '<br/>';
print_r($this->data);
// Search
if (!empty($this->data)) {
$searching = true;
$this->paginate['Topic']['limit'] = $this->Toolbar->settings['topics_per_page'];
if (!empty($this->data['Topic']['keywords'])) {
if ($this->data['Topic']['power'] == 0) {
$this->paginate['Topic']['conditions']['Topic.title LIKE'] = '%'. $this->data['Topic']['keywords'] .'%';
} else {
$this->paginate['Topic']['conditions']['OR'] = array(
array('Topic.title LIKE' => '%'. $this->data['Topic']['keywords'] .'%'),
array('FirstPost.content LIKE' => '%'. $this->data['Topic']['keywords'] .'%')
);
}
}
if (!empty($this->data['Topic']['category'])) {
$this->paginate['Topic']['conditions']['Topic.forum_category_id'] = $this->data['Topic']['category'];
}
if (!empty($this->data['Topic']['orderBy'])) {
$this->paginate['Topic']['order'] = $this->data['Topic']['orderBy'] .' DESC';
}
if (!empty($this->data['Topic']['byUser'])) {
$this->paginate['Topic']['conditions']['User.username LIKE'] = '%'. $this->data['Topic']['byUser'] .'%';
}
$this->set('topics', $this->paginate('Topic'));
}
$this->Toolbar->pageTitle(__d('forum', 'Search', true));
$this->set('menuTab', 'search');
$this->set('searching', $searching);
$this->set('forums', $this->Topic->ForumCategory->getHierarchy($this->Toolbar->getAccess(), $this->Session->read('Forum.access'), 'read'));
}
}
?>
topic.php model:
class Topic extends ForumAppModel {
/**
* Belongs to
* #access public
* #var array
*/
public $belongsTo = array(
'ForumCategory' => array(
'className' => 'Forum.ForumCategory',
'counterCache' => true
),
'User' => array(
'className' => 'Forum.User'
),
'FirstPost' => array(
'className' => 'Forum.Post',
'foreignKey' => 'firstPost_id'
),
'LastPost' => array(
'className' => 'Forum.Post',
'foreignKey' => 'lastPost_id'
),
'LastUser' => array(
'className' => 'Forum.User',
'foreignKey' => 'lastUser_id'
)
);
/**
* Has one
* #access public
* #var array
*/
public $hasOne = array(
'Poll' => array(
'className' => 'Forum.Poll',
'dependent' => true
)
);
/**
* Has many
* #access public
* #var array
*/
public $hasMany = array(
'Post' => array(
'className' => 'Forum.Post',
'exclusive' => true,
'dependent' => true,
'order' => 'Post.created DESC',
)
);
index.ctp view:
<?php // Search orderbY
$orderBy = array(
'LastPost.created' => __d('forum', 'Last post time', true),
'Topic.created' => __d('forum', 'Topic created time', true),
'Topic.post_count' => __d('forum', 'Total posts', true),
'Topic.view_count' => __d('forum', 'Total views', true)
); ?>
<h2>Search</h2>
<?php echo $form->create('Topic', array('url' => array('controller' => 'search', 'action' => 'index'))); ?>
<div id="search">
<?php
echo $form->input('keywords', array('div' => false, 'label' => false, 'style' => 'width: 300px'));
echo $form->label('power', __d('forum', 'Power Search?', true));
echo $form->input('category', array('div' => false, 'label' => false, 'options' => $forums, 'escape' => false, 'empty' => true));
echo $form->input('orderBy', array('div' => false, 'label' => false, 'options' => $orderBy));
echo $form->label('byUser', __d('forum', 'By User (Username)', true) .':');
echo $form->input('byUser', array('div' => false, 'label' => false, 'style' => 'width: 150px'));
?>
</div>
<?php echo $form->end(__d('forum', 'Search Topics', true));
pr($this->validationErrors);
?>
<?php // Is searching
if ($searching === true) { ?>
<div class="forumWrap">
<?php echo $this->element('pagination'); ?>
<table cellspacing="0" class="table">
<tr>
<th colspan="2"><?php echo $paginator->sort(__d('forum', 'Topic', true), 'Topic.title'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Forum', true), 'Topic.forum_category_id'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Author', true), 'User.username'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Created', true), 'Topic.created'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Posts', true), 'Topic.post_count'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Views', true), 'Topic.view_count'); ?></th>
<th><?php echo $paginator->sort(__d('forum', 'Activity', true), 'LastPost.created'); ?></th>
</tr>
<?php if (empty($topics)) { ?>
<tr>
<td colspan="8" class="empty"><?php __d('forum', 'No results were found, please refine your search criteria.'); ?></td>
</tr>
<?php } else {
$counter = 0;
foreach ($topics as $topic) {
$pages = $cupcake->topicPages($topic['Topic']); ?>
<tr<?php if ($counter % 2) echo ' class="altRow"'; ?>>
<td class="ac" style="width: 35px"><?php echo $cupcake->topicIcon($topic); ?></td>
<td>
<?php if (!empty($topic['Poll']['id'])) {
echo $html->image('/forum/img/poll.png', array('alt' => 'Poll', 'class' => 'img'));
} ?>
<?php echo $cupcake->topicType($topic['Topic']['type']); ?>
<strong><?php echo $html->link($topic['Topic']['title'], array('controller' => 'topics', 'action' => 'view', $topic['Topic']['id'])); ?></strong>
<?php if (count($pages) > 1) { ?>
<br /><span class="gray"><?php __d('forum', 'Pages'); ?>: [ <?php echo implode(', ', $pages); ?> ]</span>
<?php } ?>
</td>
<td class="ac"><?php echo $html->link($topic['ForumCategory']['title'], array('controller' => 'categories', 'action' => 'view', $topic['Topic']['forum_category_id'])); ?></td>
<td class="ac"><?php echo $html->link($topic['User']['username'], array('controller' => 'users', 'action' => 'profile', $topic['User']['id'])); ?></td>
<td class="ac"><?php echo $time->niceShort($topic['Topic']['created'], $cupcake->timezone()); ?></td>
<td class="ac"><?php echo number_format($topic['Topic']['post_count']); ?></td>
<td class="ac"><?php echo number_format($topic['Topic']['view_count']); ?></td>
<td>
<?php // Last activity
if (!empty($topic['LastPost'])) {
$lastTime = (!empty($topic['LastPost']['created'])) ? $topic['LastPost']['created'] : $topic['Topic']['modified']; ?>
<em><?php echo $time->relativeTime($lastTime, array('userOffset' => $cupcake->timezone())); ?></em><br />
<span class="gray"><?php __d('forum', 'by'); ?> <?php echo $html->link($topic['LastUser']['username'], array('controller' => 'users', 'action' => 'profile', $topic['Topic']['lastUser_id'])); ?></span>
<?php echo $html->image('/forum/img/goto.png', array('alt' => '', 'url' => array('controller' => 'topics', 'action' => 'view', $topic['Topic']['id'], 'page' => $topic['Topic']['page_count'], '#' => 'post_'. $topic['Topic']['lastPost_id']))); ?>
<?php } else {
__d('forum', 'No latest activity to display');
} ?>
</td>
</tr>
<?php ++$counter;
}
} ?>
</table>
<?php echo $this->element('pagination'); ?>
</div>
<?php } ?>
I added:
if (isset($this->Security)){
$this->Security->enabled=false;
}
to the beforeFilter function of search_controller.php and i'm able to get the search results now. No more HTTP 404 website not found error. :)

Resources