One way to approach this is to use a virtual field (http://book.cakephp.org/2.0/en/models/virtual-fields.html). In your Post model, create a virtual field called year that gets the year out of the created field.
On Tuesday, July 30, 2013 4:19:54 PM UTC-7, Helder Lucas wrote:
I'm building and application with cakePHP and I'm trying to achieve something like a Wordpress blog archive.
Let's imagine that i have this table in my database:
- Posts
- id
- title
- body
- created
- modified
and i want the output something like this:
<h1>2013</h1>
<p>Post Title</p>
<p>Post Title</p>
<p>Post Title</p><h1>2012</h1>
<p>Post Title</p>
<p>Post Title</p>
<p>Post Title</p>etc etc
I have searched and tried by myself but unfortunately with no success.
Thanks in advance.
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+unsubscribe@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/groups/opt_out.
No comments:
Post a Comment