WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
  • Print
Pages: 1 ... 6 7 [8] 9 10 ... 21   Go Down

Author Topic: Code Snippet: Display news items, anywhere  (Read 374953 times)

lepracaun

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #175 on: September 15, 2008, 11:44:05 AM »
Hi, I have been trying to add the cde snippet to my page under my menu on the left, as soon as I paste the code into my index.php file and want to preview it, the page is blank. I have set up the news module in admin, and created a few sample news articles, any idea why it will be doing this?
This is the code I have tried to paste into index.php

Code: [Select]
<!-- NEWS READER -->
<?php
$group 
= 0; // Specify the Group&#38;#40;id&#38;#41; you want to read the news from

global $database;

$query = "SELECT post_id,title,group_id,link 
          FROM "
.TABLE_PREFIX."mod_news_posts
          WHERE group_id = 
$group
          ORDER BY posted_when DESC 
          LIMIT 0, 5;"
; // This limits the results to max 5, so if you want it to be 10, make it LIMIT 0, 10.
          // The first number defines the starting point, and the second the max/end of the results
$error = mysql_error&#38;#40;&#38;#41;;
if &#38;#40;!$result = mysql_query&#38;#40;$query&#38;#41;&#38;#41; &#38;#123;
    
print "$error";
    exit;
    &
#38;#125;

while&#38;#40;$data = mysql_fetch_object&#38;#40;$result&#38;#41;&#38;#41;&#38;#123;
  
$title = $data->title;
  
$id = $data->post_id;
  
$link = $data->link; ?>

        <p>
        <a href="<?php echo WB_URL; ?><?php echo $link ?><?php echo PAGE_EXTENSION; ?>"><?php echo $title; ?></a>
        </p>
        <?php
    
&#38;#125;
?>

<!-- END NEWS READER -->
« Last Edit: September 15, 2008, 11:45:51 AM by lepracaun »
Logged

Argos

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #176 on: September 15, 2008, 11:52:53 AM »
Somehow your code is polluted by stuff like #38;#41;
They prevent the script from working. Please download the latest version on the bottom of page 8 and try again.
Logged

lepracaun

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #177 on: September 15, 2008, 12:02:45 PM »
Thanks Argos
That was the problem  :-)
Logged

ghost06

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #178 on: September 28, 2008, 01:30:13 PM »
hi boys,
how I can make in order to visualize the list of the existing groups?

sorry for my english :lol:
Logged

Argos

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #179 on: September 28, 2008, 01:34:48 PM »
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.
Logged

doc

  • Guest
Code snippet anynews v0.21 released
« Reply #180 on: October 20, 2008, 12:16:43 PM »
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
« Last Edit: October 20, 2008, 02:42:54 PM by doc »
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code snippet anynews v0.21 released
« Reply #181 on: October 20, 2008, 02:39:38 PM »
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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #182 on: October 21, 2008, 02:12:34 PM »
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? 
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #183 on: October 21, 2008, 02:28:55 PM »
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.

Code: [Select]
<?php
$url 
= $_SERVER[&#39;REQUEST_URI&#39;];
if (function_exists(&#39;display_news_items&#39;))  {
  
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
« Last Edit: October 21, 2008, 02:34:34 PM by Ruud »
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #184 on: October 21, 2008, 02:31:31 PM »
Thnx Ruud will try it out..
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #185 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 ;-)
Code: [Select]
$url = $_SERVER['REQUEST_URI'];
Ruud


Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #186 on: October 22, 2008, 01:26:22 PM »
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
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #187 on: October 22, 2008, 01:42:02 PM »
You can use the function strftime() instead of gmdate().

Code: [Select]
$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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #188 on: October 22, 2008, 01:54:47 PM »
thanks :)  :-D
Logged

Offline babsy

  • Posts: 337
Re: Code Snippet: Display news items, anywhere
« Reply #189 on: October 23, 2008, 03:53:04 PM »
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
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #190 on: October 23, 2008, 08:41:06 PM »
The snippet needs to be adjusted for that function to work. Currently it does not consider the times and/or dates.

cheers

Klaus
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #191 on: October 23, 2008, 10:52:37 PM »
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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #192 on: October 24, 2008, 05:20:29 AM »
Should have done some better research then :-D didn't actually check. Sorry about that ...

cheers

Klaus
Logged

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #193 on: October 28, 2008, 05:59:45 PM »
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 ;-)
Code: [Select]
$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..
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #194 on: October 28, 2008, 10:02:57 PM »
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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #195 on: October 30, 2008, 09:00:28 AM »
Code: [Select]
<?php
$url 
= $_SERVER[&#39;REQUEST_URI&#39;];
if (function_exists(&#39;display_news_items&#39;))  {
  
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 =)
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #196 on: October 30, 2008, 09:51:18 AM »
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
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #197 on: November 04, 2008, 11:44:19 AM »
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?
Logged

Offline Ruud

  • Posts: 3671
  • Gender: Male
  • Do not use PM for help! Please use the forum!
    • Dev4Me - Professional WebsiteBaker Development
Re: Code Snippet: Display news items, anywhere
« Reply #198 on: November 04, 2008, 11:58:27 AM »
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



Logged
Dev4me - WebsiteBaker modules - WBhelp.org

Lotus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #199 on: November 04, 2008, 12:06:57 PM »
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.
Logged

  • Print
Pages: 1 ... 6 7 [8] 9 10 ... 21   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Code Snippet: Display news items, anywhere
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2