Code Snippet: Display news items, anywhere

Argos

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.
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!

lepracaun

#176
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

<!-- 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 -->

Ruud

In the AnyNews "include.php" find the line:

// OUTPUT NEWS ITEMS WITH NEWS TITLE, SHORT NEWS TEXT AND READ MORE LINK

Below that line the output is created.
Depending on the location where you need the date/time to appear you could add:

$output .= "<p class=\"dateformat\">".gmdate("d M Y, H:i", $data['posted_when']+TIMEZONE)."</p>\n";
(class "dateformat" is added so you can use CSS to position and size things.)

Cheers,

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

babsy

now its perfect, thanks for your help :)

i read in the thread that someone had found out how to show the date (posted when) with the anynews! but i can´t find the code for that in the forum, can anyone point me to the post for that?

Ruud

A bit risky.. but looks good


#mynews h2 {
  text-align: right;
  margin-top: -20px;
}


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

babsy

#172
yesssssssssssssss thank you thank you thank you, thats just what i have been looking for :)

ubs, exept i wanted the "read more" to be at the end of the text,... but this is still much better  :) then before!

Ruud

Try adding
#mynews p {
overflow:auto;
}


Is that what you want?

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

babsy

#170
www.hfhmagazine.com

my problem is the anynews " on the left", when i use pictures in the short text!!, you see the second, third nr. news and so on, i have used "enter" to regulate is, but it does not look good, i want the ...read more, to come right after the text and even if i use a big picture i want the line (hr) to come at the bottom, not to the right (even if i choose "left" in the picture edit)!!

hobe you know what i mean, i know this is css question, but i just can´t figure it out??!!

Ruud

Quote from: babsy on August 01, 2008, 10:24:39 PM
is there anyone who can help me in the right direction with this... or tell me where to change it!

Can we have a look somewhere?

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

babsy

hi, i know i have asked about this before, but i have tried to change the css anyway i know, but i still can´t get the line between the news to show right (i still have to make "enter" until it´s below the image i use, and then the "read more" text goes to far down, looks a bit weird!...

is there anyone who can help me in the right direction with this... or tell me where to change it! i have tried to change the css file... but no luck there, ???? :mrgreen:

DarkMaster3960

Ohhhh I LOVE YOU!!!

Its so weird, it was right in front of me and i didnt see this... ahh awfull...
everything i need is already integrated in WebsiteBaker and is didnt see this...

Cruel world...

ARGH, im so sorry that is wasted your time with this kiddieshit...
but, just as i said, its early in the morning and the first walk i made was to the computer and straight into this forum. as i got up this morning i thought i had THE idea...

Ok, remember, first FAQ then google, then the forumsearch and then POST...

Thank you... -.-'

Ruud

Please have a look here:
WebsiteBaker Help Project - News

That will help creating a news page.

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

DarkMaster3960

ok, i think ive understod but could you give me an example please?

Thanks a lot, i think any news is exactly what i looked for...  :-D

Ruud

You don't need to create the news-page in the same place.

You need a page (anywhere) to input (and display the full article).
The AnyNews snippet could be used in a code-section (if you need it on a single page) or in your template/index.php (if you need it on every page).

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

DarkMaster3960

thanks, but

if i use a code page, how can i create news items there? i thought it uses the database for news?

Ruud

First create a news page (you can hide from the menu if you want).
In there you can create the news items. AnyNews will see the created items automatically.

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

DarkMaster3960

Heya,

ok, its early morning and it was a very sleepless night, so please excuse my question, but i dont know where or how to add news with this very nice snipped.

So far ive added a custom code to one of my pages but theres always shown: there are no news available yet.

And are there any options in the backend where i could change anything?

Thanks for your help...

Ruud

#160
Despite the existing bug and workaround that might be needed, I made a small modification in the last version.

In this post the problem was reported there is no translation for internal links in the snippet.

In this version (v0.14) this is fixed.

Ruud

EDIT: Attachment removed. Newer version available through addons repository.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

doc

Hello Ruud,

I know about the short comings of the version I posted.

Unfortunatelly there is a bug in the news module of WB 2.7, which needs an additional workaround to get anynews working with 2.6.x, 2.7 RC1 to final and any future 2.7.x.

Therefore no update of the anynews snippet is available so far on the addons repository. Best thing would be to check for database fields instead of version numbers to make sure anynews works on all platforms. Will have a closer look on this issue once time does free up in the future.

Regards Christian

Ruud

That's fine Christian.

The fix you referred cannot be used in 2.6.7 sites, so you cannot use this in a download version.
My version will do the same (ofcourse), but only when > 2.7 is used. 2.6.x will use the old query.

Just have a look at it when you have got time.

Cheers,

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

doc

Thanks, a bugfix was already postet in reply #142 of this thread. Will add a working solution to the addons repository if my time allows to do it.

Regards Christian

Ruud

#156
For all WB2.7 users of any_news..

I modified the snippet so it now respects start and end dates of the posts.
The modification was done because someone had a problem with posts being showed where they should not be showed anymore. https://forum.WebsiteBaker.org/index.php/topic,10233.msg60019.html#msg60019

The solution tests for the WB version, and is compatible with the WB 2.6.7 version.

Cheers,

Ruud

EDIT: Attachment removed. Newer version available through addons repository.

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

babsy

hi... ok, thanks.. for your help... i´m going to try to make it look good :)

marathoner

Display differences between browsers is, um, a browser issue and not an issue with the Anynews module. Simply play with your CSS to achieve the desired results. I would guess that this is related to float (or in your case image align since you didn't use float). I also noticed a bunch of empty DIV's in the news item that doesn't display the HR correctly.

babsy

hi... if you look at www.vagaportal.com in IE, and then look at it in Firefox, you will see what i mean... it´s the bottom line, that is between the news..  :-)