Code Snippet: Display news items, anywhere

spida

Wow, cool design! There's a forum called showcase here in the community forum. Maybe you want to introduce your website there.

Cheers,
spida

testdriver2

I would like to thank the website baker community for providing excellent modules. I have used the latest version of the module provided on this site and I have integrated it into my website www.auyana.de.

Lotus

I realize that this is vital information but I can not do anything with it, frustrating. Will RTFM =)
Thank you for pointing me in the right direction though but for now I stick with your code..it is the best thing I got.

Ruud

I would just create a news page for every language. You can define per language-newspage where links will be linking to.

The lang=SE parameter is only available as a parameter when switching languages. There is a static variable LANGUAGE available within your template. That will hold the same value as the lang= parameter when switching languages.

Ruud



[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Lotus

Nice! Got it to work..but when i view the page with all news "they" are back ofcource so doday I was thinking if the ?lang=SE part in the URL can be useful. So pages with ?lang=SE see this news and pages with ?lang=GB se that news? Possible?

Ruud

You could decide to not show the anynews at all on the page where you are reading.

Replace the } else { with } else if (strrpos($url,"/nl/")) {.
(also a searchpage would not show a wrong language newsblock that way)

For the rest I cant tell what is in your URL unless I can see it ;-)

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Lotus

<?php
$url 
$_SERVER['REQUEST_URI'];
if (
function_exists('display_news_items'))  {
  if (
strrpos($url,"/en/"))  {
    
display_news_items(1,3,-1,1,"Latest news","read more","No news available",false); 
  } else {
    
display_news_items(2,3,-1,1,"Laatste nieuws","verder lezen","geen nieuws beschikbaar",false); 
  }

?>


I noticed a small problem as the URL changes when you read a newspost the /en/ part dissapears. Then the script then shows the default news parts. Is trere any variable not shown in the URL that one can locate to know what newsgroup that you read from? When will I be able to do some PHP magic like you Ruud =)

Ruud

Quote from: Lotus on October 28, 2008, 05:59:45 PM
If you want to have the first 3 news with heading and short text display_news_items(0,3,40,1) and the next 10 wit just heading like display_news_items(3,10,0,1), is it possible?

No, not without changing the any_news snippet code.
The snippet will always show the last n messages, it will not skip the first n.

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Lotus

Quote from: Ruud on October 21, 2008, 02:33:30 PM
I missed one line you will need to have too:

Before testing the $url variable, it needs to be defined with something ;-)

$url = $_SERVER['REQUEST_URI'];


Ruud


Works like charm!

If you want to have the first 3 news with heading and short text display_news_items(0,3,40,1) and the next 10 wit just heading like display_news_items(3,10,0,1), is it possible?

Anyway thanx alot for the code..

kweitzel

Should have done some better research then :-D didn't actually check. Sorry about that ...

cheers

Klaus

Ruud

Klaus is wrong here,

The current version of Anynews will respect the published date and time. Using exactly the same rules as the news service itself.

Check the version you are running. Version 2.1 is the current one.


Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

kweitzel

The snippet needs to be adjusted for that function to work. Currently it does not consider the times and/or dates.

cheers

Klaus

babsy

there is one small problem with the wb 2.7 and anynews :)

the clock possibility in the news, does not work with anynews - meaning even if i choose that the a certain news, should not be shown until 8 pm .... it comes out in the anynews right away?
but it works fine on the news page, and dosn´t show up until 8 pm....

So if anyone has a solution, i would love to hear about it  :-D


Ruud

You can use the function strftime() instead of gmdate().


$output .= "<p class=\"dateformat\">" . strftime("%d %B %Y",$data['published_when'])."</p>\n";

(example is using WB2.7 published_when instead of WB2.6 posted_when)

By default, it uses the locale settings of your php configuration.
For more info on how to tweak strftime and local languages, see: http://www.php.net/strftime

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

babsy

hi... again :)
i was wondering where if you know where i can change the month name :)

i use this extra line in the include.php
$output .= "<p class=\"dateformat\">".gmdate("d M Y", $data['posted_when']+TIMEZONE)."</p>\n";

but the date comes out in english, ex. 23 oct. ... and i want to change it to 23. okt.
i have looked in the language files, but can´t find it there - is it possible to change it :)

otherwise everything is working perfect now :)...... www.sudurras1.com

Ruud

I missed one line you will need to have too:

Before testing the $url variable, it needs to be defined with something ;-)

$url = $_SERVER['REQUEST_URI'];


Ruud


[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Lotus


Ruud

#184
I've done this by using 2 news groups. Dutch / English
I didn't set the language in the pages, but used a /pages/en/ or /pages/nl/ page structure.


<?php
$url 
$_SERVER['REQUEST_URI'];
if (
function_exists('display_news_items'))  {
  if (
strrpos($url,"/en/"))  {
    
display_news_items(1,3,-1,1,"Latest news","read more","No news available",false); 
  } else {
    
display_news_items(2,3,-1,1,"Laatste nieuws","verder lezen","geen nieuws beschikbaar",false); 
  }

?>



Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

Lotus

Trying to make a templete were "Any News", depending of language set on the page, list news from one of two sources. Is it hard to do this? 

Ruud

Quote from: doc on October 20, 2008, 12:16:43 PM
Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?

Done,

Ruud
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

doc

#181
Hi,

just released version 0.21 of the anynews snippet on the addons repository. The module is based up on v0.14 published by Ruud E and hence includes the fixes for the publish by date function and for internal WB links.

Version v0.21 introduces two new options.

  • option to specify tags which will not be removed by the strip_tags option (default: anchor tag)
  • option to display the publish date/time to the title of each news entry (default: off)

Apart from that, some code cleaning, language support and a HTML help file was added to v0.21.

Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?

Regards Christian

Argos

Quote from: ghost06 on September 28, 2008, 01:30:13 PM
how I can make in order to visualize the list of the existing groups?
This is not possible with this snippet, because it shows latest news per group, or all groups together. To show the groups themselves, just use the normal news page.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

ghost06

hi boys,
how I can make in order to visualize the list of the existing groups?

sorry for my english :lol:

lepracaun