Latest news area
Permalink 2 users found helpful
Hi would anyone be able to suggest the best way to display latest news simple links on the home page that would update auotomaticaly when new content is added to the blog or from another area in the site 1 line would be fine as per attached screen shot
all you need to do is add a page attribute or just us the existing is_featured attribute then make a custom template for the page list block
Cheerso!
Do you know if there is any documentation on this in the forums?
Do you know if there is any documentation on this in the forums?
This kind of goes over it:
http://www.concrete5.org/help/building_with_concrete5/developers/un...
However, you probably don't need to read that whole thing. I'd do this.
1. Add a page list block to that area. Set it up to show most recent (or use the "show featured only" option in the page list block, if you have a really recent version of concrete5. ). Set this block to only show 1 item, and set it to show most recent first.
2. Make a new directory in your local blocks directory:
blocks/page_list/templates/one_line_summary.php
3. Copy concrete/blocks/page_list/view.php into that file.
4. Go into the one_line_summary.php file and remove the DIV with the class "ccm-page-list-description" (since you don't want the description here.)
5. Make sure your stylesheet styles the h3 inside this area appropriately.
I believe that would do it.
http://www.concrete5.org/help/building_with_concrete5/developers/un...
However, you probably don't need to read that whole thing. I'd do this.
1. Add a page list block to that area. Set it up to show most recent (or use the "show featured only" option in the page list block, if you have a really recent version of concrete5. ). Set this block to only show 1 item, and set it to show most recent first.
2. Make a new directory in your local blocks directory:
blocks/page_list/templates/one_line_summary.php
3. Copy concrete/blocks/page_list/view.php into that file.
4. Go into the one_line_summary.php file and remove the DIV with the class "ccm-page-list-description" (since you don't want the description here.)
5. Make sure your stylesheet styles the h3 inside this area appropriately.
I believe that would do it.
I've adapted your advice to my own needs and it works great, but I was wondering if it's possible to add the date of the item to the template.
Any thoughts?
Any thoughts?
on the day created or edited or what?
I guess the date created, as most news items won't be edited once they're 'live'. Something like this:
NEWS ITEM HEADING
News item content. Lorem ipsum dolor sit amet.
15 Jan 2010
My template is fine, I just need a function to display the date below each item.
NEWS ITEM HEADING
News item content. Lorem ipsum dolor sit amet.
15 Jan 2010
My template is fine, I just need a function to display the date below each item.
No dice I'm afraid:
Fatal error: Call to undefined method PageStatistics::getversiondatecreated()
Yeah that works to show the last edit date of the entire site (I'm using that successfully on my homepage), but not the individual edit dates of the news item pages.
I'm actually looking to have the last edit date on every page of the site, as well as the news column, so this could be a useful one two counts!
I'm actually looking to have the last edit date on every page of the site, as well as the news column, so this could be a useful one two counts!
Any thoughts? This is the last feature I need for my homepage news area :)
Try this:
Note that the 'F j, Y' thing is to format the date as "January 19, 2010" -- if you want a different format, seehttp://us.php.net/manual/en/function.date.php... for all the options.
BTW, if you also want to output the author name, you can use this:
<?php echo $cObj->getCollectionDateAdded('F j, Y'); ?>
Note that the 'F j, Y' thing is to format the date as "January 19, 2010" -- if you want a different format, seehttp://us.php.net/manual/en/function.date.php... for all the options.
BTW, if you also want to output the author name, you can use this:
<?php echo $cObj->getVersionObject()->getVersionAuthorUserName(); ?>
Thanks for the reply!
Unfortunately that doesn't work. I see this:
:(
Thanks for the heads-up about the date() function - I am used to using that, but alas it's just the concrete5 API that is a bit of a mystery!
Unfortunately that doesn't work. I see this:
Call to a member function getCollectionDateAdded() on a non-object in /public_html/concrete5/blocks/page_list/templates/newsitem.php on line 26
:(
Thanks for the heads-up about the date() function - I am used to using that, but alas it's just the concrete5 API that is a bit of a mystery!
Hmm... can you paste the entire code of that page? Perhaps it's not being put in the right spot? (It needs to be inside the "for ($i = 0; $i < count($cArray); $i++ ) {" loop and after the "$cobj = $cArray[$i];" line).
Also, I just realized that my $cObj is capitalized, but in the original template it's not, so perhaps that is the problem -- so try this instead:
Also, I just realized that my $cObj is capitalized, but in the original template it's not, so perhaps that is the problem -- so try this instead:
Thanks, that worked! The problem was 'cObj' instead of 'cobj'.
Works great now :)
Works great now :)
so where can we view an example of this in action???
thx!
thx!
I have it running on my sitehttp://www.gothinkdesign.com
Thanks for this info, prints dates as it should be but.
Is there way to change day names to another language? Im developing Finnish site, so Enlish dates are not ok.
Thanks in forehand!
---- Update ----
Thanks for Fernandos, right way would be to set up php locale (http://php.net/manual/en/function.setlocale.php... ).
I anyway did it like this:
..so i took month by number (1,2,3...) and translated them directly to Finnish (Tammikuu, Helmikuu, Maaliskuu...),saved it to variable $month and then printed $month.
Is there way to change day names to another language? Im developing Finnish site, so Enlish dates are not ok.
Thanks in forehand!
---- Update ----
Thanks for Fernandos, right way would be to set up php locale (http://php.net/manual/en/function.setlocale.php... ).
I anyway did it like this:
<?php switch ($cobj->getCollectionDateAdded('n')) { case '1': $month = 'Tammikuu'; break; case '2': $month = 'Helmikuu'; break; case '3': $month = 'Maaliskuu'; break; case '4': $month = 'Huhtikuu'; break; case '5': $month = 'Toukokuu'; break; case '6'; $month = 'Kesäkuu'; break; case '7'; $month = 'Heinäkuu'; break; case '8'; $month = 'Elokuu'; break; case '9'; $month = 'Syyskuu'; break; case '10'; $month = 'Lokakuu'; break; case '11'; $month = 'Marraskuu'; break; case '12'; $month = 'Joulukuu'; break; } echo $month . $cobj->getCollectionDateAdded(' j, Y'); ?></div>
..so i took month by number (1,2,3...) and translated them directly to Finnish (Tammikuu, Helmikuu, Maaliskuu...),saved it to variable $month and then printed $month.
Hey,
That's a great looking website! You implemented this block really well!
That's a great looking website! You implemented this block really well!
What about the simple news add-on?
Great site by the way!
Great site by the way!
I needed to do something similar, pulling 'latest news' items from a news section using the page list block. The only custom work needed was a template to format the styling of the block to suit.