Author Topic: New module - Latest News (last full news post)  (Read 27851 times)

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
New module - Latest News (last full news post)
« on: October 25, 2008, 11:25:22 PM »
Some time ago I read a request for a module to show the last post from the news module on another page (i.e. homepage). This is common for weblogs.

This module will do just that.
It finds the last post (from a selected group, or from all groups) and displays it.

Other than the news module the post is written within <div>'s, and using a frontend.css (editable in backend > WB2.7) you can style it to your wishes.

version 0.2.2 - 22-12-2010
- fix that enables multiple instances on a single page.

version 0.2.1 - 26-10-2008
- added - the time part of posted_by is not displayed when there is no TIMEFORMAT defined in the language file. (by default)
- added Germand language - thanks to Vyni
- fixed showing posts before their published date/time
- autodetects WB2.6 /2.7 for the functions above (the module will still work on WB2.6)

version 0.2 - 26-10-2008
- added extra pagetitle (allows "Latest post.." message above the news post)
- added choice to display posted_by line
- added choice to display short text
- added choice to display long text
- date and time format strings in language files. (translators, add your locale settings too)

version 0.1 - 25-10-2008
- initial version

Ruud


[gelöscht durch Administrator]
« Last Edit: December 22, 2010, 11:00:35 PM by Ruud »

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #1 on: October 25, 2008, 11:47:46 PM »
Wow, again a really good Idea by yours, Ruud.

I needed exactly that for a Project.

It's so nice, because with this you're able to keept your Site fresh.

 :-P
Best Regards,
Stefek

P.S. I'm really satisfied about this one
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #2 on: October 26, 2008, 12:04:47 AM »
Dear Ruud.

I translated the DE.php

But I don't seem to find the function for "loading images"

Code: [Select]
<?php
//Modul Description
$module_description = &#39;Mit diesem Modul ist es m&ouml;glich, die zuletzt ver&ouml;ffentlichte News (des NEWS MODULS) einer ausgew&auml;hlten Kategorie (oder aller Kategorieren) auf einer beliebiegen Seite auszugeben.&#39;;

//Variables for the Frontend
$MOD_LATESTNEWS[&#39;LOADING_IMAGES&#39;] = &#39;Loading images&#39;;

//Variables for the Backend
$MOD_LATESTNEWS[&#39;BACK_TITLE&#39;]            = &#39;Latest News Section&#39;;
$MOD_LATESTNEWS[&#39;BACK_DESCRIPTION&#39;]        = &#39;Dieses Modul gibt die zuletzt ver&ouml;ffentlichte News des News-Moduls aus.&#39;;
$MOD_LATESTNEWS[&#39;BACK_GROUP&#39;]            = &#39;Kategorie ausw&auml;hlen&#39;;
$MOD_LATESTNEWS[&#39;BACK_ANY_GROUP&#39;]        = &#39;aus allen Kategorien&#39;;
$MOD_LATESTNEWS[&#39;POSTED_BY&#39;]            = &#39;Ver&ouml;ffentlicht von&#39;;
$MOD_LATESTNEWS[&#39;ON&#39;]                    = &#39;am&#39;;
$MOD_LATESTNEWS[&#39;AT&#39;]                    = &#39;um&#39;;


?>

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

vyni

  • Guest
Re: New module - Latest News (last full news post)
« Reply #3 on: October 26, 2008, 01:28:20 AM »
Hi Ruud,

I´m missing the most important part of the news, when I display it with this module - I miss the short-text.
Is it because You don´t like to read too much?  :-D
Or is it because You don´t like to find a complete passage twice in the HP ?  :-D

So please have a look, sir!

And than I was fed up of the english date, the month-name was in english. After some searching I discovered every dates, if there are month-names (news) are shown in english. And I found the reason: no locale is set in the language-file. So I searched and found:
Insert setlocale(LC_TIME, "de_DE"); in Your language-file - best file for that is DE.php in folder WB_PATH/languages so You have it WB-wide.
Change it to Your country-code.
Than I inserted "Uhr" in the view.php [ strftime("%H:%M Uhr"... ]
And now I get a line like this:
Veröffentlicht von Webmaster am Sonntag, 26. Oktober 2008 um 02:54 Uhr


@Stefek
loading images =>  lade Bilder
BACK_TITLE = neueste Nachricht

Edit:
This belongs to version v.0.1 only
I found the reason and a solution. Open view.php and change the code a little bit as follows
Go to line (51 and 52)

Code: [Select]
       $wb->preprocess($post['content_long']);
        $post_long = $post['content_long'];
and insert this 2 lines
Code: [Select]
       $wb->preprocess($post['content_short']);
        $post_short = $post['content_short'];

than keep this unchanged
Code: [Select]
       ?>
        <div id="latestnews">
            <div id="title"><h1><?php echo $post[&#39;title&#39;];?></h1></div>
            <div id="postedby"><?php echo $MOD_LATESTNEWS[&#39;POSTED_BY&#39;]; ?> <?php echo getUserFromId($post[&#39;posted_by&#39;]); ?> <?php echo $MOD_LATESTNEWS[&#39;ON&#39;]; ?> <?php echo $post_date?> <?php echo $MOD_LATESTNEWS[&#39;AT&#39;]; ?> <?php echo $post_time?><br/></div>
now change the line
Code: [Select]
<div id="news"><?php echo $post_long?></div>
to the following 2 lines
Code: [Select]
           <div id="news_s"><?php echo $post_short?></div>
            <div id="news_l"><?php echo $post_long?></div>

save.
Now open frontend.css, rename #nesw to #news_l and insert new ID #news_s with Your preferred definitions.

Ready. Short content shows up.


PS: I enclosed the modified view.php - just rename the txt to php and (remove Uhr if You like) and replace it in the server.

[gelöscht durch Administrator]
« Last Edit: October 26, 2008, 04:05:49 AM by vyni »

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #4 on: October 26, 2008, 02:16:04 AM »
@Stefek
loading images =>  lade Bilder
Yes, I know, but I don't seem to find the function itself.

The another suggestion (short Description), yes your'reright Vyni. I would preffere a possibility to choose if I want to display it or not though.

Best Regards,
Stefek
« Last Edit: October 26, 2008, 02:58:16 AM by Stefek »
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

vyni

  • Guest
Re: New module - Latest News (last full news post)
« Reply #5 on: October 26, 2008, 02:25:26 AM »


Because this is the opening of each article it is a must! No way to let it away.

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #6 on: October 26, 2008, 03:16:18 PM »
Hello Ruud.

Please would you explain where the
$MOD_LATESTNEWS[&#39;LOADING_IMAGES&#39;] = &#39;Loading images&#39;;
belongs to.

 :-)

Best Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #7 on: October 26, 2008, 04:33:07 PM »
@stefek
Please would you explain where the
$MOD_LATESTNEWS[&#39;LOADING_IMAGES&#39;] = &#39;Loading images&#39;; belongs to.

Oops, sorry.
That belongs to the Imageflow module. I used that file as a start for the latestnews language file.
I took it out of the NL.php, but forgot the EN version.

No need to translate that one

@vyni
I´m missing the most important part of the news, when I display it with this module - I miss the short-text.
Is it because You don´t like to read too much?  :-D
Or is it because You don´t like to find a complete passage twice in the HP ?  :-D

So please have a look, sir!
.

I simulated the standard newspage settings (without the links to groups and the "back" to the overview).
The standard news does not display the short text, it is used in the overview page only (where is no long text).
Whenever I use Newspages in a site the short news has a summary of the article and the long news has the full article.

Next version I will add a checkbox where you can select the short and/or the long text (and the posted by line). That way everyone can decide for themselves how your output is built.

Quote
And than I was fed up of the english date, the month-name was in english. After some searching I discovered every dates, if there are month-names (news) are shown in english. And I found the reason: no locale is set in the language-file. So I searched and found:
Insert setlocale(LC_TIME, "de_DE"); in Your language-file - best file for that is DE.php in folder WB_PATH/languages so You have it WB-wide.
Change it to Your country-code.

In the EN.php/NL.php there are examples for the setlocale settings.
Your setting works on *nux OS. For windows you need an extra setting.
Quote
// set the date names to other languages. See:  http://www.php.net/manual/en/function.setlocale.php
//setlocale(LC_ALL, 'nl_NL', 'nld_nld');
//setlocale(LC_ALL, 'de_DE', 'deu_deu');
In this case the 'deu_deu' is valid for Windows (WAMP) platforms.
Note that this only works when the date is built using the strftime() php function.
Typically WB uses the gmdate() function. That one does not respect the setlocale setting.
The strftime function will not respect the dateformat setting you do in WB.

Maybe for WB2.7.1 all gmdate() should be replaced for strftime() with the corresponding formats?


Ruud

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #8 on: October 26, 2008, 04:41:00 PM »
@stefek
Please would you explain where the
$MOD_LATESTNEWS[&#39;LOADING_IMAGES&#39;] = &#39;Loading images&#39;; belongs to.
...
That belongs to the Imageflow module. I used that file as a start for the latestnews language file.
....
No need to translate that one
Thank Ruud.

Quote
Next version I will add a checkbox where you can select the short and/or the long text (and the posted by line). That way everyone can decide for themselves how your output is built.
Thanks again, Ruud.
This is a great thing.

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #9 on: October 26, 2008, 04:46:37 PM »
Wow, again a really good Idea by yours, Ruud.
I needed exactly that for a Project.
It's so nice, because with this you're able to keept your Site fresh.
 :-P
Best Regards,
Stefek
P.S. I'm really satisfied about this one

Thanks again, Ruud.
This is a great thing.

Regards,
Stefek

I assume you like this module?  8-)

Ruud

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #10 on: October 26, 2008, 06:05:27 PM »
A new version (v0.2) is available.

Added several extra options:

- added extra pagetitle (allows "Latest post.." message above the news post)
- added choice to display posted_by line
- added choice to display short text
- added choice to display long text
- date and time format strings in language files. (translators, add your locale settings too)



Note: The module is upgradeable. No need to uninstall first.

Ruud
« Last Edit: October 26, 2008, 06:09:42 PM by Ruud »

vyni

  • Guest
Re: New module - Latest News (last full news post)
« Reply #11 on: October 26, 2008, 06:52:40 PM »
Great,

but what do You think of using the posted_when entry instead of published_when - I think this published date will be mostly set to 0:00 because tis is by default 00:00. but posted date is set automatic.

regards

ps: find enclosed the german language file

[gelöscht durch Administrator]

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #12 on: October 26, 2008, 10:41:50 PM »
but what do You think of using the posted_when entry instead of published_when - I think this published date will be mostly set to 0:00 because tis is by default 00:00. but posted date is set automatic.

The posted_when also changes whenever you change something in an existing message, and is not changeable.
Published_when is at least settable. That way you can decide yourself what is displayed.
Also the anynews snippet and the WB2.7 newspage itself also use published_when by default.

The only "bug" I found myself is that if the post is not yet published, it sill is displayed in this module.
I will change that in the next version.

Ruud


Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #13 on: October 26, 2008, 11:08:00 PM »
version 0.2.1 is now available. (download from the first post of this thread)

Added: if there is no setting in the language file for the TIMEFORMAT, that part of the "posted_by" line will not be displayed anymore.

Added: German language, thanks to Vyni.

Fixed: Posts that are not yet published are not shown anymore. The newest unpublished is shown.
This will allow you to schedule your homepage content. (i.e. Display a different homepage on Christmas day only)

Ruud

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: New module - Latest News (last full news post)
« Reply #14 on: October 26, 2008, 11:14:11 PM »
I assume you like this module?  8-)

Your conclusion is correct, Sir.


Stefek
 :-)


« Last Edit: November 24, 2008, 03:50:40 PM by Stefek »
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline spida

  • Posts: 203
Re: New module - Latest News (last full news post)
« Reply #15 on: November 24, 2008, 03:41:45 PM »
Hi Ruud,

I get the page title displayed additionally with the page's first header (I am using SimplePageHead). How can I get rid of the title?

Cheers,
spida

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #16 on: November 24, 2008, 03:59:15 PM »
SimplePageHead will set the title (in the browser caption) to whatever is set in the page title field of the page your are watching.
Only for "virtual pages" like a "full news page" or "bakery shop" pages it will try to display something more relevant.

A page created with this module is a normal page, and will have the normal page title, not the title of the news.
I don't think there is much you can do about that.

Ruud


Offline spida

  • Posts: 203
Re: New module - Latest News (last full news post)
« Reply #17 on: November 24, 2008, 04:06:39 PM »
Hi Ruud,

maybe I misunderstood which title that is exactly. So, displayed is the news' title as you type it into the field "Title" of a new news. This title, as far as I understand the concept, is otherwise only used to be displayed in the backend list of news, in order to discriminate the news (else, you would just see that you have a number of news, but wouldn't know which one to edit ;-) )

This title is displayed by your module, then follows the original news' header (<h1> as is in my code), and I would like to not have the title shown, only the header.

I hope you can help me :-)

Cheers,
spida
« Last Edit: November 24, 2008, 04:10:23 PM by spida »

Offline spida

  • Posts: 203
Re: New module - Latest News (last full news post)
« Reply #18 on: November 24, 2008, 04:14:19 PM »
OK, I got it:

This line
Code: [Select]
<div id="title"><h1><?php echo $post[&#39;title&#39;];?></h1></div>on apprix. line 74 needs to be commented out.

Cheers,
spida

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #19 on: November 24, 2008, 04:14:58 PM »
That title is meant to be displayed.
The original settings for the newspage, but also the overview page and the anynews snippet output will by deafult display that.

The simple way to hide it from browsers is to use the css.
There is a "Edit css" button in the backend part.

Change the existing setting for the title to this:
Code: [Select]
#latestnews #title {
    display:none;
}
and the title will be hidden.

Ruud

Ruud

Offline spida

  • Posts: 203
Re: New module - Latest News (last full news post)
« Reply #20 on: November 24, 2008, 04:19:04 PM »
Yeah, you're right, this is another possible approach. Only that I have to add the styles to my template's stylesheet, since the module's css is ignored when the page is rendered.

Thanks for your help, Ruud!

Good day,
spida
« Last Edit: November 24, 2008, 04:26:23 PM by spida »

Offline spida

  • Posts: 203
Re: New module - Latest News (last full news post)
« Reply #21 on: November 28, 2008, 01:25:20 PM »
Hi Ruud,

if you ever find some time again to work on this really nice mod, I would like to suggest to include the commenting function.

Currently it is possible to display either the news short or long text, in neither cases the commenting function is added though.

Maybe this is different with chios upcoming module "news2" (or whatever the name will be). But with the current core news module the commenting function seems to be ignored by your module.

Best regards,
spida

Offline tost

  • Posts: 7
  • Gender: Male
  • Don't fix it if it ain't broken....
    • SteenWeb
Re: New module - Latest News (last full news post)
« Reply #22 on: February 18, 2009, 06:55:40 PM »
Hello Ruud.

Thanks for a great module. Using it on two sites already.

Here is the Norwegian translation (NO.php) with the date and time setup we use in Norway.


Tost

[gelöscht durch Administrator]
« Last Edit: February 18, 2009, 06:58:32 PM by tost »

daydreamer

  • Guest
Re: New module - Latest News (last full news post)
« Reply #23 on: March 03, 2009, 11:46:00 AM »
How to link to main news item should there be a link?

Offline Ruud

  • Posts: 3649
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: New module - Latest News (last full news post)
« Reply #24 on: March 03, 2009, 11:51:10 AM »
No, this will only display the latest news post (the full post).

If you wat to create a link, the AnyNews snippet will be a better option.
http://addons.WebsiteBaker.org/pages/modules/code-snippets.php

Ruud