Code Snippet: Display news items, anywhere

kweitzel


cwsoft

Hello,

I try to revive the support of the Codesnippet "Anynews". As this thread is quite old, long and somewhat confusing, I started a new one.

Maybe a forum admin may want to make this old thread read only, to highlight the revive of Anynews in the new thread ... Lets see if and how this will work.

Cheers
cwsoft

jacobi22

do you mean the Code fields under NEWS-> Option?

change the code in modules/news/add.php

picas2012

Hi

It´s possible to personalize automatic the configuration when i create a page news ?

header, post loop, footer, etc...

I have to change everytime i created a page

Thanks

Paulo

carfreak

Geetings all.

i have on the homepage an anynews item with primary news. ( and other groups to put the items in when it is not primary any more )

On several other pages i have put some code to list sertain items.

if (function_exists('displayNewsItems')) {
displayNewsItems(
$group_id = 9 );
}


I have several of them.

Now the problem is that on the home page everyting works just fine, when i click "read more" it shows the long content.

now on all other pages when i click "read more" this will appear on the page.


[TITLE] [GROUP_IMAGE]
[PUBLISHED_DATE]
[PAGE_TITLE] >> [GROUP_TITLE]

[TEXT_LAST_CHANGED]: [MODI_DATE] [TEXT_AT] [MODI_TIME]

[TEXT_BACK]

Can someone explane what is going wrong.

Greetings

Adriaan

jacobi22

only one resolution: a new parameter "$min_news_items"  in the function " displayNewsItem()"  in modules/anynews/include.php
the new Parameter is "$min_news_items" at the End - standard is 0

here the "new" function

if (!function_exists('displayNewsItems')) {
        function displayNewsItems(
                $group_id           = 0,
    $max_news_items     = 10,
    $max_news_length    = -1,
    $display_mode       = 1,
    $lang_id            = 'AUTO',
                $strip_tags         = true,
    $allowed_tags       = '<p><a><img>',
    $custom_placeholder = false,
                $sort_by            = 1,
    $sort_order         = 1,
    $not_older_than     = 0,
    $min_news_items     = 0
  )        {


and in the mysql-Order

$sql = "SELECT $fields FROM `$table` AS t1 $join
                        WHERE `active` = '1'
                        AND $sql_group_id
                        AND (`published_when` = '0' OR `published_when` <= '$server_time')
                        AND (`published_until` = '0' OR `published_until` >= '$server_time')
                        AND $sql_not_older_than
                        $group
                        ORDER BY $sql_order_by $sql_sort_order
                        LIMIT $min_news_items, $max_news_items";


(changed in the last row -> LIMIT $min_news_items, $max_news_items

Now you have a new parameter like

displayNewsItems(array(7,4), 4, 200,1 ,auto,'<img>','<p><a>',false, 1, 2, 0, 1);

if you use 0 or nothing, it shows

news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

if you use 1, it shows

news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

and if you use 2, it shows

news 3 in 13/11/2012
news 4 in 12/11/2012

etc.




picas2012

Hi

Thanks for the replys to my problem

in this case i have another problem...i have news in 2 parts of the site...

if i change the include.php the tag LIMIT, i change in all anynews the LIMIT


one section must be
news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

and in other section must be
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012


Please help me

Thanks

jacobi22

QuoteI need to show the last news...ok...it´s easy, but if i need to show not the last news, but starting with the last before the last one...understand ?

change the LIMIT in the MYSQL-Order in modules/anynews/include.php - Row 170

Look at this code

ORDER BY $sql_order_by $sql_sort_order
                       LIMIT 0, $max_news_items";


and change the LIMIT to 1

ORDER BY $sql_order_by $sql_sort_order
                       LIMIT 1, $max_news_items";

Ruud

Not without php knowledge.
You would need to modify AnyNews to do that.
[url=https://dev4me.com/modules-snippets/]Dev4me - WebsiteBaker modules[/url] - [url=https://wbhelp.org/]WBhelp.org[/url]

picas2012

Hi

Have a problem...i make a website with anynews module and the news are displayed in home page.

I need to show the last news...ok...it´s easy, but if i need to show not the last news, but starting with the last before the last one...understand ?

EX:
i have 4 news
news 1 in 16/11/2012
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

but i want to display only
news 2 in 13/11/2012
news 3 in 13/11/2012
news 4 in 12/11/2012

NEVER SHOWS THE FIRST (THEL MOST RECENT)

It´s possible ?

Thanks

Paulo

lausianne

Hi,

A bug! Yes, I found one! Probably.

Maybe this helps s.o. else who encounters this problem, maybe s.o. knows a real solution:

With any code such as &auml; in the text, the displayed code "lost" its surrounding <p> tags. Other special characters, like &#269; are no problem. Only "friendly" codes.

Finally, this problem disappeared, when I set $max_news_length to -1, i.e. turned it off.

Cheers,
Ralf.

maverik

news modul > view.php

search for

$post_long = ($post['content_long']);

replace with

$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];


######

dbs was faster  :-D

dbs

[url="https://onkel-franky.de"]https://onkel-franky.de[/url]

nick0

This has been asked before but through all my searching I haven't found an answer to it.

Is there a way to only display the "Read More" if something is entered in the long news box?

I have mostly short news snippets that don't require a long version, so clicking the read more just goes to a blank-ish page.

Many thanks to anyone who can help :)

mikejd

#488
I am trying to change the template for this snippet. I have created a new file custom_output_display_mode_5.htt and changed the call in the $display_mode to 5. But it doesn't change the display on the page. I have tried reloading with no effect.

Any suggestions to make it work?

Mike

tkche

Hi, Part of my users on the website use Hebrew names which.
whenever using the {DISPLAY_NAME} on anynews template it results in some odd symbols instead of Hebrew characters.
I assume it has something to do with utf8 encoding error. does anyone has an idea of how to fix this?

thanks.

bisun

Just wanted to notify... I use Anynews 1.16a and had problems getting the value of the {COMMENTS} for all sort modes except mode 5. Any other mode showed an empty string as value for number of comments. It seems as the field 'comment_count' only is set for sort mode 5. I fixed this problem on my page by simply remove the if condition in include.php:  :-D

Before:

...
$join   = NULL;
$fields = '*';
$group  = NULL;

if ( $sort_by == 5 ) {
    $join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
    $fields = 't1.*, count(comment_id) AS comment_count';
    $group  = 'GROUP BY t1.post_id';
}

/**
* Perform SQL database query for Anynews
*/
$table = TABLE_PREFIX . 'mod_news_posts';
...

After:

...
$join   = NULL;
$fields = '*';
$group  = NULL;

$join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
$fields = 't1.*, count(comment_id) AS comment_count';
$group  = 'GROUP BY t1.post_id'; 
   
/**
* Perform SQL database query for Anynews
*/
$table = TABLE_PREFIX . 'mod_news_posts';
...


Don't know if only I had a problem with this?

Xagone

next update need a french language update, the old one is mistranslated.


[gelöscht durch Administrator]
Xagone Inc. (formerly VotreEspace)
[url="http://xagone.com/"]http://xagone.com/[/url]

Xagone

#484
i know language is used for the display, but is there a way taht only news in that language be displayed too ?

that's what I asked my self, and then modify version 1.16a like this :

in include.php
i've added the line :
(strtoupper($lang_id) == 'AUTO')?$asked_language=LANGUAGE:$asked_language=strtoupper($lang_id);
after the line
loadLanguageFile($lang_id);

and the change the lines :
   $join   = NULL;
   $fields = '*';
   $group  = NULL;

   if ( $sort_by == 5 ) {
       $join = ' LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id ';
       $fields = 't1.*, count(comment_id) AS comment_count';
       $group  = 'GROUP BY t1.post_id';
   }

to :
   $join   = 'JOIN `'.TABLE_PREFIX.'pages` AS t3 ON t3.`page_id` = t1.`page_id`';
   $fields = 't1.*, t3.`language`';
   $group  = "AND t3.`language`  = '".$asked_language."'";

   if ( $sort_by == 5 ) {
          $join = 'LEFT JOIN '.TABLE_PREFIX.'mod_news_comments AS t2 ON t1.post_id=t2.post_id JOIN `'.TABLE_PREFIX.'pages` AS t3 ON t3.`page_id` = t1.`page_id`';
          $fields = 't1.*, t3.`language`, count(comment_id) AS comment_count';
  $group  = "AND t3.`language`  = '".$asked_language.'\' GROUP BY t1.post_id';
   }


and it worked! now if you ask displaynews in auto on a french page, only news distributed on french pages will display!
I've attach the modified include.php of version 1.16a

modify this post to change the zip file

[gelöscht durch Administrator]
Xagone Inc. (formerly VotreEspace)
[url="http://xagone.com/"]http://xagone.com/[/url]

D72

Is there any trick to get something like:
$max_title_lenght = 20,
Or any given number of course, not just 20 characters.
There is an option $max_news_lenght = 20,
But it would be nice to truncate the title as well so it fits neat in a certain div element.

kirk

because i find the same issue in the simple page head modul which passed the unwanted empty tag &nbsp; i looked around and find the function str_replace

With this function i can remove selected tags.

So i extended in the simple page head modul include.php the line 103

102       $the_description = str_replace('"', '', $the_description);
103       $the_description = str_replace('&nbsp;', '', $the_description);


i couldn't find a matching place in the any news modul to achieve the result like in simple page head.

Is  some one around here who take a look in the any news modul and help me out?


Kirk

kirk

Hello folks,

i looking for that place where the strip_tag function located.

Especially i need to remove an empty tag: &nbsp; from the short message content of the news modul.

any suggestions?

kirk

snark

have a look at the anynews languagefile


Nyborg

Hi there,

This is a GREAT module of which I am sad I did not find it before now .. :roll:

In the custom .htt files, is it possible to rearrange the {PUBLISHED_WHEN}-{PUBLISHED_UNTIL}, so that they ONLY display the dates in question "(STARTDATE - ENDDATE)" and not as i my case "(STARTTIME, STARTDATE)- (ENDTIME, ENDDATE)"?

Currently it shows: "(11:15 AM, 07/12/2010)- (12:00 AM, 07/25/2010)" and I want to get rid of the time code.

Regards,

Nyborg

macsmet

Hi there,

There is an error in the latest Anynews (1.16) in the include.php
See this thread: https://forum.WebsiteBaker.org/index.php/topic,18600.0.html
Solved thanks to Alexandra!!

greetings,

MacSmet