What you can do is write code in the beforeFilter() function of 
AppController. For example

<?php
public function beforeFilter() {
  $this->loadModel('Post');
  $this->set('recentPosts', $this->Post->findRecent());
}
?>

and on Model/Post.php

<?php
public function findRecent() {
  if(($recent = Cache::read('posts_recent')) == null) {
    $recent = $this->find('all',['limit'=>4]);
    Cache::write('posts_recent',$recent);
}
?>

This helps if you place recent post to some part of your site (ie a widget, 
posts/index, aboutus, etc). You cache the results so next time it loads 
quickly. Remember this code will run every time you access your site. So if 
you just want posts in aboutus page you can do the above in the 
PagesController.

On Wednesday, August 13, 2014 3:23:30 PM UTC+3, Matthew Smart wrote:
>
>
> now on the about us page i will have content and a section i want to be 
> the posts that i created as seen in the examples above. However to do this 
> i want to be able to have: Controller/AboutsController.php, Model/About.php 
> view/Abouts/about.ctp and kind of require/include the whole Posts MVC.
>
> and if i was to just make my about us page the Posts MVC then the names 
> wouldnt be really what i wont them to, meaning the pages would be called 
> posts instead of about, due to cakephp naming conventions.
>
> I hope this makes sense, can any one help please?
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to