Page List Block - How to show the date?1 user found helpful
I have created a Page Type called "News" which is supposed to work like a Blog entry thingy, then i made a Page List Block, on my front page to showcase the 4 newest "news". But my problem is, i really want it to showcase the dates aswell!
Heres a screenshot of what it looks like -http://i.imgur.com/or2Zefd.png
And heres what i WANT it to look like -http://img546.imageshack.us/img546/4866/c95322b9373a4645b680ecd.png...
But my problem is, i can't get it to show those dates, i know from looking through the "Composer" menu, that it actually generates a date. So how do i get it to display in <p> tag as an example?
I hope this is good enough info for you guys to help me!
// Stenkilde peace! :)
If you could supply your page list template code, it would be easier to help you out. You can post it on http://www.pastie.org and supply a link or paste it in here using the ['code'] (minus ') tags.
If that isn't exactly what you want, you can then create your own custom template for the Page List block and edit the code a bit. Please see this how-to on custom templates: http://www.concrete5.org/documentation/how-tos/designers/change-how...
I took a blog thing, and remade it abit. I just have a problem with truncate. It doesn't quite seem to work, i have it set to 20, both in the PHP file and in the edit mode of the Page list block. But it still doesn't do it.
The plugin did fix the truncate problem! :)
But, i'm still missing the date and author, which is quite important for my site. I will personally, trade the truncate for the date and author.
See this pastie (edits highlighted): http://pastie.org/6274213#15-16,25...
Thanks mate, if you have the time. A quick run down of what you did to fix it, would be mostly appreciated, so next time i understand it my self!
In the foreach loop you loop through all pages and single out each page object. There are already predefined methods you can use, and a list of the most common can be found here: http://www.concrete5.org/documentation/developers/pages/overview...
So first of all I fetched the publication date of the page:
$date = $page->getCollectionDatePublic('M j, Y');
There are many ways in how you can display the date so if the display doesn't suit your needs you can check out the date() function in the php manual. ( http://php.net/manual/en/function.date.php... )
I also wanted to find the last user who edited the page:
$poster = $page->getVersionObject()->getVersionAuthorUserName();
getVersionObject() gets the approved version of the page and getVersionAuthorUserName() gets the username of the user who edited the page.
Then in the <h4> tag (change to <p>, <span> or whatever you want) I just echoed out the information now stored in the the variables $date and $poster:
Since all of this is inside a foreach loop, this is done for every page.
Edit: In the beginning of c5 pages were called 'collections' since they were a collection of blocks, hence the naming of functions and db tables.
I appreciate your help, and i have marked your post as a best answer!
You have given me alot of input and a good walkthrough.
Again thank you, and have a nice day!