Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 02:55:52 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149621 Posts in 21098 Topics by 7537 Members
Latest Member: lotte2
* Home Help Search Login Register
Pages: 1 ... 18 19 [20] 21   Go Down
Print
Author Topic: Code Snippet: Display news items, anywhere  (Read 100194 times)
kleo

Offline Offline

Posts: 11


« Reply #475 on: June 14, 2010, 07:28:16 PM »

I have more pages (and sections) with the module News. But I use not Groups by News module.

How can I use Anynews to display newsitems from certain pages or section?
How can I change the code?

Earlier in this thread VotreEspace posted an excellent solution for section_ID support: http://www.websitebaker2.org/forum/index.php/topic,409.msg95799/topicseen.html#msg95799

Thank YOU!
I think this feature should be added as a built-in option to the module!

I use now a Droplett:
http://www.websitebakers.com/pages/droplets/official-library/navigation/getnewsheads.php

Can you help me to change this droplett with this code?
From your Link:
http://www.websitebaker2.org/forum/index.php/topic,409.msg95799/topicseen.html#msg95799
Logged
BlackBird

Offline Offline

Posts: 1937



WWW
« Reply #476 on: June 23, 2010, 11:10:32 AM »

Yesterday, I was asked for a solution to show the group image with AnyNews. So I created this solution:

File include.php, find line 256 ff:

Code:
                               // replace the news article dependend template placeholders
$tpl->set_var(array(
'WB_URL'    => WB_URL,
...more code going here...

BEFORE, add:

Code:
       $group_id = $row['group_id'];
        $image = '';
        if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'))
        {
            $image = '<img src="'.WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'.'" alt="" />';
        }

AFTER, add:

Code:
'GROUP_IMAGE'     => $image,

Add the {GROUP_IMAGE} markup to the template (.htt file) you're using and you're done.

Edit: You may edit the <img> attribute to suit your needs. (Add a CSS class or something.)
Logged

Alle großen Veränderungen beginnen im Kleinen
macsmet

Offline Offline

Posts: 230


« Reply #477 on: June 27, 2010, 01:53:32 PM »

Hi there,

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

greetings,

MacSmet
Logged
Nyborg

Offline Offline

Posts: 7


« Reply #478 on: July 13, 2010, 02:33:28 PM »

Hi there,

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

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
Logged
snark
Guest
« Reply #479 on: July 13, 2010, 06:45:30 PM »

have a look at the anynews languagefile

Logged
kirk
WebsiteBaker Org e.V.

Offline Offline

Posts: 204



WWW
« Reply #480 on: July 24, 2010, 09:58:46 AM »

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
Logged
kirk
WebsiteBaker Org e.V.

Offline Offline

Posts: 204



WWW
« Reply #481 on: July 25, 2010, 03:54:27 PM »

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

Code:
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
Logged
D72

Offline Offline

Posts: 239


« Reply #482 on: September 19, 2010, 01:01:09 PM »

Is there any trick to get something like:
Code:
$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.
Logged
Xagone
AddOn Development
*
Offline Offline

Posts: 453



WWW
« Reply #483 on: October 01, 2010, 04:44:12 PM »

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 :
Code:
(strtoupper($lang_id) == 'AUTO')?$asked_language=LANGUAGE:$asked_language=strtoupper($lang_id);
after the line
Code:
loadLanguageFile($lang_id);

and the change the lines :
Code:
   $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 :
Code:
   $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
« Last Edit: October 01, 2010, 04:47:02 PM by VotreEspace » Logged

Xagone Inc. (formerly VotreEspace)
http://www.xagone.com/
Xagone
AddOn Development
*
Offline Offline

Posts: 453



WWW
« Reply #484 on: October 09, 2010, 05:04:50 PM »

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

Xagone Inc. (formerly VotreEspace)
http://www.xagone.com/
bisun

Offline Offline

Posts: 2


« Reply #485 on: October 12, 2010, 09:25:06 PM »

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:  grin

Before:
Code:
...
$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:
Code:
...
$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?
Logged
tkche

Offline Offline

Posts: 12


« Reply #486 on: April 12, 2011, 02:43:21 PM »

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.
Logged
mikejd

Offline Offline

Posts: 140


« Reply #487 on: May 05, 2011, 12:43:35 PM »

I am trying to change the template for this snippet. I have created a new file custom_output_displ ay_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
« Last Edit: May 05, 2011, 12:46:32 PM by mikejd » Logged
nick0

Offline Offline

Posts: 2


« Reply #488 on: July 05, 2011, 11:12:45 AM »

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 Smiley
Logged
dbs
WebsiteBaker Org e.V.

Offline Offline

Posts: 3262


WWW
« Reply #489 on: July 05, 2011, 12:20:26 PM »

there is a way to show the content_short if the conten_long is empty.
http://www.websitebaker2.org/forum/index.php/topic,21671.msg145787.html#msg145787
Logged

maverik

Offline Offline

Posts: 1541



WWW
« Reply #490 on: July 05, 2011, 12:22:55 PM »

news modul > view.php

search for

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

replace with

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


######

dbs was faster  grin
Logged

Signatur wird geladen...
lausianne
WebsiteBaker Org e.V.

Offline Offline

Posts: 139


WWW
« Reply #491 on: September 05, 2011, 03:13:48 PM »

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.
Logged
picas2012

Offline Offline

Posts: 11


« Reply #492 on: January 16, 2012, 11:13:45 PM »

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
Logged
Ruud
Board member
WebsiteBaker Org e.V.

Offline Offline

Posts: 2093



WWW
« Reply #493 on: January 16, 2012, 11:57:31 PM »

Not without php knowledge.
You would need to modify AnyNews to do that.
Logged

Professional WebsiteBaker Developer
jacobi22
Betatester
*
Offline Offline

Posts: 651


WWW
« Reply #494 on: January 17, 2012, 04:20:58 AM »

Quote
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 ?

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

Look at this code

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

and change the LIMIT to 1

Code:
ORDER BY $sql_order_by $sql_sort_order
                        LIMIT 1, $max_news_items";
Logged

LG Uwe

Wer sagt, Reichtum ist alles, hat nie ein Kind lächeln gesehen.
picas2012

Offline Offline

Posts: 11


« Reply #495 on: January 17, 2012, 05:46:05 PM »

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
Logged
jacobi22
Betatester
*
Offline Offline

Posts: 651


WWW
« Reply #496 on: January 17, 2012, 06:17:40 PM »

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

Code:
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

Code:
$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.



Logged

LG Uwe

Wer sagt, Reichtum ist alles, hat nie ein Kind lächeln gesehen.
carfreak

Offline Offline

Posts: 11


« Reply #497 on: January 23, 2012, 11:44:51 AM »

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.
Code:
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
Logged
picas2012

Offline Offline

Posts: 11


« Reply #498 on: January 25, 2012, 01:14:04 AM »

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
Logged
jacobi22
Betatester
*
Offline Offline

Posts: 651


WWW
« Reply #499 on: January 25, 2012, 01:21:05 AM »

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

change the code in modules/news/add.php
Logged

LG Uwe

Wer sagt, Reichtum ist alles, hat nie ein Kind lächeln gesehen.
Pages: 1 ... 18 19 [20] 21   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!