Ok I copied exactly as described in the book.
My default layout has : <?php echo $this->element('footer_feature_product',
array('cache' => '+1 hour'));?>
The element is:
<?php $product = $this->requestAction(array('controller' => 'products'
,'action' => 'feature'));?>
<?php echo $this->Html->image('footer_block_1.jpg', array('alt' => 'Featured
Product'));?>
<div class="copy">
<h5>Featured Product</h5>
<p><?php echo
h($this->Text->truncate($product['Product']['description'],$length=100,array
()));?> read more</p>
</div>
Controller:
public function feature() {
if (empty($this->request->params['requested'])) {
throw new ForbiddenException();
}
return $this->Product->find('first', array(
'Product.featured' => 1,
'contain' => false));
}
Now on the index page no issues. Click login (hover over the link =>
users/login) but when I click login I get directed to products/feature with
error message
Forbidden
Error: The requested address '/products/feature?url=products%2Ffeature' was
not found on this server. And whats with the crazy url?
From: [email protected] [mailto:[email protected]] On Behalf
Of Piotr Beschel
Sent: Monday, December 10, 2012 5:31 AM
To: [email protected]
Subject: Re: Un-related models / functions
read about Controller::requestAction(string $url, array $options)
http://book.cakephp.org/2.0/en/controllers.html
W dniu poniedziałek, 10 grudnia 2012 03:35:05 UTC+1 użytkownik advantage+
napisał:
I have a footer which has a featured product and recent news.
What is the best way to call these actions getFeatured(), and getNews() when
there is no related model to use as they are permanent "blocks" in the
footer in default.ctp layout?
Thanks,
Dave
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.