Code Snippet: Display news items, anywhere

Olli

Quote from: babsy on June 02, 2008, 09:46:35 AM
Hi, has anyone a solution for the bottom line, it "jumbs around", my client has to press enter until its below the text... Is there a way to make it automatic going to the bottom :)  :? without using enter :) :?

i'm not quite sure what you mean. please tell a bit more about your problem. i'm sure there is a solution - does not sound that spectacular ;-)

regards

babsy

Hi, has anyone a solution for the bottom line, it "jumbs around", my client has to press enter until its below the text... Is there a way to make it automatic going to the bottom :)  :? without using enter :) :?

doc

Hello,

just and idea, disable the output filter (if used) and check again.

Christian

Olli

@marathoner: when displaying the news the regualar way (looking at the news page directly) everything is fine. all tags are there and nothing is broken.

but when using the anynews script all images are destroyed no matter if it set the strip-tag flag to true or false. i'm a bit stuck now i must admit. i can't get any progess into this.

using the old snipped from pc wacht does not help either. this is really confusing because it used to work in the past on another installation...

maybe this is a PHP5 concerned problem? hmm...

thanks for your help marathoner, will look at it all over again and will do a reinstall just to see if that helps...

greetings

marathoner

#148
@Olli-

I have to apologize. I had commented out line 92 in the example that I listed above and that you looked at. It worked just fine; however, it wasn't until just now when I went back to see what the line number was did I realize that the display_news_items function already has this functionality built into it as the last (8th) parameter. You can simply call the display_news_items function as is with the 8th parameter set to FALSE (it's set to TRUE by default).

I've modified my example links above so that you can see the function called with default parameters and with the STRIP_TAGS parameter set to FALSE.

If this doesn't fix your problem, take a look at the data stored in your mod_news_posts table and see if the posting has your IMG tags in it.

Olli

hello marathoner,

thanks for digging into this!
could you please tell me where exactly you commented out the stripping tags? i guess this is the point where i went wrong...

bye

marathoner

The module is intended to be customized to meet your needs. By default, the 'content_short' field is displayed after it is stripped of tags (including IMG tags) but this can be changed so that they are not stripped. It sounds like you've done that. The script should then output whatever is stored in your database. Have you checked your database to see what is stored for your news postings?

It may be an encoding issue such as the database and your web page being encoded differently.

I did a test myself by creating a posting with an image in it and the module displays it fine once I comment out the strip_tags.

Here is the regular news posting and the same posting using Anynews module.
http://www.mohican100.org/pages/registeredpage/test-news.php
http://www.mohican100.org/pages/registeredpage/test-anynews-module.php

Olli

#145
hello everybody,

i just read through the whole thread again but i don't know where to look for for a solution.

just to get a basic understanding what is needed: is the anynews module able to display <img>-tags properly that were inserted inside a news entry? right now all img tags and paths are destroyed when using anynews and i don't know why...

it does not matter if i turn stripping tags on or off... the img path is always broken/not there...

the path looks something like
http://local...%3c/p%3E%3Cp%3E%3Ca%20href=

can someone lend a helping hand? :-)

greetings

shlack

Quote from: knert on May 06, 2008, 11:52:30 AM
Hi,


How can I remove the 'read more' function if there is no long text placed?

I checked the doc and the forum but could not find a solution.

Grtz
Knert

According to a Readme file you should use the following function:

display_news_items($group_id, $max_news_items, $max_news_length, $display_mode,
$header_text, $readmore_text, $no_news_text, $strip_tags);

Example for customized call:

<?php display_news_items(0, 5, 50, 2, "The latest news", "show full news text", "uups, no news available", false); ?>

So just use empty string instead of "show full news text":

<?php display_news_items(0, 5, 50, 2, "The latest news", "", "uups, no news available", false); ?>


Nowis

Quote from: falkena on March 16, 2008, 10:26:17 PM
Hallo,
I have installed the new wb 2.7.
with the new news module i can put an start date an end dat to the news.
the problem is that anynews wil show it anyway.
Is there a way to fix this?


I can be done quite easily. You just have to edit modules/anynews/include.php


// query to obtain news items for the selected group
if ($group_id < 1) {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE active=1 ORDER BY position DESC LIMIT 0, $max_news_items;";
} else {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE group_id=$group_id AND active=1 ORDER BY position DESC LIMIT 0, $max_news_items;";
}


must be changed to


// query to obtain news items for the selected group
$t = time();
if ($group_id < 1) {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE active=1 AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) ORDER BY position DESC LIMIT 0, $max_news_items;";
} else {
$query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE group_id=$group_id AND active=1 AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) ORDER BY position DESC LIMIT 0, $max_news_items;";
}

Boudi

Hi Matthias,

I use the anynews snippet for use on the homepage. I already checked the include.php but could not find where to change it.  :x

It's not that I completely want to remove the read more on the homepage, only when there's no long text written.

But I noticed just a few seconds away that you cannot click the text to go to the news function on the newspage itself. Only if there's a read more link.

So I adviced the client to use the short as the long text as well. Problem solved. Thnq for taking the time to respond.

Grtz
Knert  :-)
...:: Bake the Unbakable ::...

ruebenwurzel

Hello,

where did you wanna remove it?

In the news modul itself? look at the options of the news modul
or in the any news snippet? look at include.php in modules/anynews directory

Matthias

Boudi

Hi,

How can I remove the 'read more' function if there is no long text placed?

I checked the doc and the forum but could not find a solution.

Grtz
Knert
...:: Bake the Unbakable ::...

doc

Hello,

habe you tried the original code snippet module AnyNews from the Addons repostiory?

Regards Christian

vanbemmel

Hello,

when i paste this code in my template i don't see any news.
What can i do wrong?


Quote from: fienieg on February 27, 2005, 06:50:48 PM
I made very rough code, that makes a listing of a specific group(id)
With the option of setting a "max results", and order them by date added. etc..

Just read the code, play with it. Refine it, restyle it.

Have fun..


<!-- NEWS READER -->
<?php
$group 
0// Specify the Group(id) 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();
if (!
$result mysql_query($query)) {
    print 
"$error";
    exit;
    }

while(
$data mysql_fetch_object($result)){
  
$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
    
}
?>

<!-- END NEWS READER -->


spida

Quote from: babsy on February 11, 2008, 01:48:32 PM
but its still bugging me that the "line" under the text is overlapping if i have a picture in the small text.... the line "jumbs around"..... and it doesn´t look nice.... and the only solution i can figure out it so "enter" until it looks nice, but thats not a very smart solution... so  :?

i have tried to change it, but no luck, so if anyone has a solution, please post it here!! :?

Hi,
this is not a problem with the code snippet. You should specify stylesheet definitions for the appearance.

Regards,
spida.

marathoner

The snippet allows you to customize the output any way you want on any page you want. It's simply a tool to extract fields from the news table. In order to be 'aware' of the start/end date you will need to customize the output to do this (just like someone may want to ignore the start/end date). Simply modify the query to only extract those records that fit your criteria and then display whichever fields you want in whatever way you want.

kweitzel

The anynews snipet was not written for this functionality (checking the on and off times). it will need to be rewritten for that purpose.

cheers

Klaus

falkena

Hallo,
I have installed the new wb 2.7.
with the new news module i can put an start date an end dat to the news.
the problem is that anynews wil show it anyway.
Is there a way to fix this?

diodak

Quote from: dbrorlando on February 12, 2008, 07:24:18 PM
I've used news anywhere several times, but I need to use it for a specific layout which includes the "published date", "news title" and "display name".  Can someone please help me?... I've spent most of the past few days trying to make it work.  I did find the post showing how to add the date, and was able to change it to show the published date, but when I add multiple news items, the dates don't display correctly.

Here's an example of what I'm looking for:

02.12.2008 - Name of Article - Author's Display Name
02.11.2008 - News Title Here - Author's Display Name

I dont know what method you are using, try mine:

if ($data['posted_when'] != "") {
$output .= "<div class=\"any-date\">".date("M d, Y",$data['posted_when'])."</div>\n";


near line 108 in include.php
Buchsbaum

dbrorlando

I've used news anywhere several times, but I need to use it for a specific layout which includes the "published date", "news title" and "display name".  Can someone please help me?... I've spent most of the past few days trying to make it work.  I did find the post showing how to add the date, and was able to change it to show the published date, but when I add multiple news items, the dates don't display correctly.

Here's an example of what I'm looking for:

02.12.2008 - Name of Article - Author's Display Name
02.11.2008 - News Title Here - Author's Display Name

babsy

Hi ...

it works fine.. i have updatet wb...

Its a great module... :-D

but its still bugging me that the "line" under the text is overlapping if i have a picture in the small text.... the line "jumbs around"..... and it doesn´t look nice.... and the only solution i can figure out it so "enter" until it looks nice, but thats not a very smart solution... so  :?

i have tried to change it, but no luck, so if anyone has a solution, please post it here!! :?

ruebenwurzel

Hello,

Quoteon an old webpage

Wich WB version is running there. Code snippets are only supported from 2.6.5 and higher.

Cause the permissions please look on our help page. There is all explained.

Matthias

babsy

hi again  :-) it works fine here, but i have one question!

i have just installed it on an old webpage i had, but when i install it, it just says, "update successful" but it doesn´t show up when i look through my modules?? then i went in to my ftp to just delete it... but it wont allow me to delete, and i can´t un-install it, because it doesn´t show up on my add-ons list  :? any ideas?

marathoner

You didn't provide very much information. Are you using the snippet in a template or in a code section?

A 501 is "Not Implemented"...could it be that you are trying to use a service not supported by your host? You say that you get a 501 at other times...what other times?