i m newbie for cakephp and i want to log in with different MySQL table name "registrations". as according to cakephp book a users named table is needed to log in and registration and its User controller and model. but my question is. is there any way to login with registrations table ? Here i difine you what all pages for it.
Controller
AppController.php
OnlineController.php(this page is main controller for my site.)
Model
AppModel.php
Registrations.php
View
register.ctp
login.ctp
And here my login view page
<?php echo $this->Form->create('Registrations'); ?>
<table width="450" border="0" align="center" id="login_form">
<tr align="center">
<td colspan="2" align="left"><h3 style="padding-top:10px; padding-left:0px;">Login In</h3>
<hr /></td>
</tr>
<tr><td><?php echo $this->Session->flash(); ?></td></tr>
<tr>
<td width="245"><?php echo $this->Form->input('email'); ?></td>
<tr>
<td><?php echo $this->Form->input('password', array('type'=>'password')); ?></td>
</tr>
<tr>
<td align="right">Lost Username/Password</td>
</tr>
<tr>
<td align="right"><? echo $this->Form->end('Submit'); ?></td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
</table>
And Controller >> OnlineController.php >> Code here
class OnlineController extends AppController {
/**
* Controller name
*
* #var string
*/
public $name = 'Online';
//component
public $components=array('Session','Paginator','Auth');
public $uses = array('Registrations','Contacts','User','RegistrationsModel');
function beforeFilter(){
parent::beforeFilter();
}
public function index(){
//$students=$this->Student->find('all');
}
public function login(){
if($this->request->is('post'))
{
// pr($_POST);
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
// Prior to 2.3 use `return $this->redirect($this->Auth->redirect());`
}
else {
$this->Session->setFlash(__('Username or password is incorrect'));
}
}
}
public function logout() {
$this->redirect($this->Auth->logout());
}
public function profile()
{
}
Model Part>> Registrations.php and code is
class Registrations extends AppModel {
public $name='Registrations';
function beforeSave() {
if(isset($this->data['Registrations']['password']))
$this->data['Registrations']['password'] = Security::hash($this->data['Registrations']['password'], null, true);
return true;
}
public $validate = array(
'first_name'=>array(
'rule'=>'alphaNumeric',
'required'=> true,
'allowEmpty'=>false,
'message'=>'Please Enter Your Name'
),
'last_name'=>array(
'rule'=>'alphaNumeric',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your Last Name."
),
'email'=>array(
'rule'=>'email',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your Email address."
)
,
'password'=>array(
'rule'=>'alphaNumeric',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your Password."
),
'phone'=>array(
'rule'=>'Numeric',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your Phone No.."
)
,
'state'=>array(
'rule'=>'alphaNumeric',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your Sate"
)
,
'city'=>array(
'rule'=>'alphaNumeric',
'required'=>true,
'allowEmpty'=>false,
'message'=>"Please Enter Your City"
)
);
}
In last i useed some logic for Appcontroller
class AppController extends Controller {
public $components = array(
'Auth' => array(
'loginAction' => array(
'controller' => 'Online',
'action' => 'login'),
'loginRedirect' => array(
'controller' => 'Online',
'action' => 'profile'),
'logoutRedirect ' => array(
'controller' => 'Online',
'action' => 'login'),
'authenticate' => array(
'Registrations' => array(
'userModel' => 'RegistrationsModel',
'fields' => array(
'username' => 'email',
'password' => 'password'
)
)
)
)
);
function beforeFilter() {
$this->Auth->allow('register','index','contact','quiz_zone','about','packages','online_test','test_gen','login');
}
}
Please give me a correct solution..Thanks in Advance
The name of the table for login is irrelevant. CakePHP doesn't empose a name for that.
This is a setting. When configuring your AuthComponent in AppController for example do:
$this->Auth->authenticate = array('Form' => array('userModel' => 'Registration'));
In your example you're passing the wrong name: RegistrationsModel.
So in your example this is very WRONG:
'authenticate' => array(
'Registrations' => array(
'userModel' => 'RegistrationsModel',
'fields' => array(
'username' => 'email',
'password' => 'password'
)
)
The first level key should be the authentication type (Form, Basic, Digest) not Registrations. Then as I explained you can do:
'authenticate' => array(
'Form' => array(
'userModel' => 'Registration',
'fields' => array(
'username' => 'email',
'password' => 'password'
)
)
This is all very well explained in the book - here and here.
Another very bad thing that you're NOT DOING is following the CakePHP Conventions!
Cake follows the philosophy of "Convention over configuration".
For example your models should be singular not plural... Read the book. Start with the turotioals.
Related
My 'Reservation' model and 'Profile' model have hasAndBelongsToMany association.
Here is my Reservation Model.
class Reservation extends AppModel {
.
.
var $hasAndBelongsToMany = array(
'Profile' => array(
'className' => 'Profile',
'joinTable' => 'profiles_reservations',
'foreignKey' => 'reservation_id',
'associationForeignKey' => 'profile_id',
'unique' => true,
)
);
And Here is my Profile Model.
class Profile extends AppModel {
var $name = 'Profile';
}
And here is my controller .
function prac3($lname, $fname) {
$profiles = $this->Profile->find('all', array(
'conditions' => array(
'Profile.lname LIKE' => $lname.'%',
'Profile.fname LIKE' => '%'.$fname.'%'
),
'order'=>array( 'Profile.created DESC' ),
));
$this->set('profiles', $profiles);
}
And here is my view.
<?php
if($profiles) {
foreach($profiles as $key => $profile): ?>
<tr>
<td><?= $profile['Profile']['id'] ?></td>
<td><?= $profile['Profile']['lname'] ?></td>
<td><?= $profile['Profile']['fname'] ?></td>
<td><?= $profile['Profile']['home_phone'] ?></td>
</tr>
endforeach;
echo '</table>';
}
?>
I wanna get ['Reservation']['name'] in the view using Profile model. How can I do this?
Update Your Profile class
class Profile extends AppModel {
var $name = 'Profile';
var $hasAndBelongsToMany = array(
'Reservation' => array(
'className' => 'Reservation',
'joinTable' => 'profiles_reservations',
'foreignKey' => 'profile_id',
'associationForeignKey' => 'reservation_id',
'unique' => true, // More about update below
)
}
In Your find() method shoud use recursive:
$profiles = $this->Profile->find('all', array(
//...
'recursive' => 2,
));
or Containable behavior:
$this->Profile->Behaviors->load('Containable');
$profiles = $this->Profile->find('all', array(
//...
'contain' => array(
'Reservation',
),
'recursive' => -1,
));
and Your reservetion will be in array like $profiles['Reservation'][n]['name'].
Additional, in Your comment You wrote "When I add new reservation and profile, the rows that has the profile id were disappeared in the profiles_reservations Table."
Because You are using 'unique' => true in $hasAndBelongsToMany property. The cookbook says:
If true (default value) CakePHP will first delete existing relationship records in the foreign keys table before inserting new ones. Existing associations need to be passed again when updating.
See: https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm
Try this
class ReservationsTable extends Table
{
public function initialize(array $config)
{
$this->belongsToMany('Profiles', [
'joinTable' => 'reservation_profiles',
]);
}
}
class ProfilesTable extends Table
{
public function initialize(array $config)
{
$this->belongsToMany('Reservations', [
'joinTable' => 'reservation_profiles',
]);
}
}
Then as you can see ReservationsTable is the model that relate Reservation to Profiles using reservation_profiles table to do that Profiles does the same. You don't need to have a model for reservation_profiles, but you must have this table on your databse, I sugest you to use migration to create them. Finally in your controller, this could be in your ReservationController you call
$this->Reservation->Profiles->find()->where(['condition'=> 'param']);
This may solve your problem, explainning ($this) refer to the Controller class, ->REservation refer to the model Reservation -> Profiles refer to related model to the class Reservation model, ->find()... refer to the query executed. If you need more https://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-associations
I am wrestling with CakePHP trying to create a basic login functionality. So far CakePHP is winning. I followed the basic Blog tutorial and based on that I am try to create a similair login thingy.
The only difference I have is that I not using an Users model, but a custom Employers model and I use email/password instead of username/password.
Yet all I get is "Your username or password was incorrect."
AppController.php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'schedules',
'action' => 'index'
),
'logoutRedirect' => array(
'controller' => 'employers',
'action' => 'login',
'home'
),
'authenticate' => array(
'Form' => array(
'fields' => array(
'username' => 'email',
'password' => 'password'
),
'userModel' => 'Employer',
'passwordHasher' => 'Blowfish'
)
)
)
);
}
EmployersController.php
<?php
App::uses('AppController', 'Controller');
class EmployersController extends AppController {
public $helpers = array('Form');
public function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('login');
}
public function login()
{
$layout = 'login';
$this->layout = $layout;
if($this->request->is('post'))
{
debug($this->Auth->login());
if($this->Auth->login())
{
return $this->redirect($this->Auth->redirect());
}
else
{
$this->Session->setFlash('Your username or password was incorrect.');
}
debug($this->request->data['Employers']['password']);
}
}
}
Login.ctp
<div id="login-container">
<h1>Login</h1>
<?php
echo $this->Form->create('Employers');
echo $this->Form->input('email', array('label' => false, 'placeholder' => 'Email'));
echo $this->Form->input('password', array('label' => false, 'placeholder' => 'Password'));
echo $this->Form->submit();
echo $this->Form->end();
?>
When I debug $this->request->data, the data is structered like data["Employers"]['email'] & data["Employers"]['password']. This is propably not right, since my model is called Employer.
Is this correct and does the login functionality break on this and if so, how can I fix that?
Or is there something else I am overlooking.
In your login.ctp,
It should be echo $this->Form->create('Employer'); not with s, so remove s and try it.
Hope it helps.
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.
I have tried to set up a login page, but when I try to log in, even with a wrong username/password, cake redirects to the login page (the logout function redirects correctly). Even if I plug in the wrong info, I get no error flashes at all, I don't get it. Here is my controller code:
class UsersController extends AppController {
public $name='Users';
public $layout='pagelayout';
public $uses=array('User');
public function beforeFilter() {
parent::beforeFilter();
$this->Auth->allow('add', 'logout', 'overview');
}
public function login() {
$this->set('title', 'Log in to your Gulf Shores 4 Less account');
if ($this->request->is('post')) {
if ($this->Auth->login()) {
return $this->redirect($this->Auth->redirect());
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
and here is my model:
<?php
App::uses('AuthComponent', 'Controller/Component');
class User extends AppModel {
public $name='User';
public $hasMany=array('Unit', 'Complex', 'Coupon', 'Location', 'Image', 'Charter', 'Course', 'Nightclub', 'Store');
public function beforeSave() {
if (isset($this->data[$this->alias]['password'])) {
$this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
}
return true;
}
public $validate = array(
'username' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A username is required'
)
),
'password' => array(
'required' => array(
'rule' => array('notEmpty'),
'message' => 'A password is required'
)
),
'role' => array(
'valid' => array(
'rule' => array('inList', array('admin', 'advertiser')),
'message' => 'Please enter a valid role',
'allowEmpty' => false
)
)
);
}
?>
Here is the code from AppController:
<?php
class AppController extends Controller {
public $components = array(
'Session',
'Auth' => array(
'loginRedirect' => array('controller' => 'users', 'action' => 'overview'),
'logoutRedirect' => array('controller' => 'pages', 'action' => 'index')
)
);
function beforeFilter() {
$this->Auth->allow('login','index', 'view', 'condos', 'houses', 'hotels_and_motels', 'print_all_coupons', 'print_coupon', 'search', 'golf', 'charters', 'events', 'nightlife', 'shopping', 'visitors_info', 'contact_us');
}
}
?>
and here is the view code:
<div class="users form">
<?php echo $this->Session->flash('auth'); ?>
<?php echo $this->Form->create('User');?>
<fieldset>
<legend><?php echo __('Please enter your username and password'); ?></legend>
<?php
echo $this->Form->input('username');
echo $this->Form->input('password');
?>
</fieldset>
<?php echo $this->Form->end(__('Login'));?>
</div>
As you can see, I pretty much copy and pasted what was in the Cakephp-2.0 manual for this. The only difference between my db table and the manual's is that my password is stored as an MD5 hash in my users table. i can't figure out where this has derailed.
Make sure that your passwords are stored using the Auth component hash. AFAIK, there is no support for 'plain' md5 passwords. The hashes Cake generates are more complex than md5.
See the documentation for info on how to hash your passwords. If you are migrating from an app that used md5 hashing, you'll have to reset all the passwords to something random for all your users.
You can try to use the following codes on your AppController.php file
AppController.php
$this->Auth->authenticate = array(
AuthComponent::ALL => array('userModel' => 'User'),
'Form' => array(
'fields' => array('username' => 'email')
)
);
$this->Auth->authorize =false;
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->fields = array('username' => 'email', 'password' => 'password');
$this->Auth->loginRedirect = array('controller' => 'media', 'action' => 'index/');
$this->Auth->logoutRedirect = '/logout';
$this->Auth->loginError = 'Invalid e-mail / password combination. Please try again';
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. :)