Page List Block - How to show the date?
Permalink 1 user found helpful
Hello Concrete5 forum! I'm building this website here for a organization, and i'm having a problem!
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! :)
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! :)
I have never edited in any Page List template. So i'm not quite sure where to find it?
Have you tried the different custom templates already there? Like "Blog Index"? Go into edit mode, click on your page list and select Custom Templates.
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...
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...
Alright heres the Pastie link.
http://pastie.org/6241743
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.
Any suggestions?
http://pastie.org/6241743
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.
Any suggestions?
It is definitely doable to have this going, but I just remembered jordanlev has a free add-on doing this for you correctly. Have a look at this link: http://www.concrete5.org/marketplace/addons/page-list-teasers/...
Hmm..
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.
//Stenkilde
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.
//Stenkilde
Adding three lines to the teaser template solves your problem.
See this pastie (edits highlighted): http://pastie.org/6274213#15-16,25...
See this pastie (edits highlighted): http://pastie.org/6274213#15-16,25...
Oh wonderful!
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!
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!
Sure, no problem.
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:
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:
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.
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.
Thanks adajad!
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!
//Stenkilde
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!
//Stenkilde
http://www.concrete5.org/documentation/developers/pages/overview/...
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.