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.8 is now available!


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 ... 18 19 [20] 21   Go Down

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

kleo

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #475 on: June 14, 2010, 08:28:16 PM »
Quote from: Argos on June 14, 2010, 01:11:53 PM
Quote from: kleo on January 25, 2010, 07:42:48 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: https://forum.WebsiteBaker.org/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:
https://forum.WebsiteBaker.org/index.php/topic,409.msg95799/topicseen.html#msg95799
Logged

Offline BlackBird

  • Posts: 2573
Re: Code Snippet: Display news items, anywhere
« Reply #476 on: June 23, 2010, 12:10:32 PM »
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: [Select]
                               // replace the news article dependend template placeholders
$tpl->set_var(array(
'WB_URL'    => WB_URL,
...more code going here...

BEFORE, add:

Code: [Select]
       $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: [Select]
'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
http://wbaddons.webbird.de Don't miss this

Offline macsmet

  • Posts: 255
Re: Code Snippet: Display news items, anywhere
« Reply #477 on: June 27, 2010, 02:53:32 PM »
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
Logged

Offline Nyborg

  • Posts: 8
Re: Code Snippet: Display news items, anywhere
« Reply #478 on: July 13, 2010, 03:33:28 PM »
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
Logged

snark

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #479 on: July 13, 2010, 07:45:30 PM »
have a look at the anynews languagefile

Logged

kirk

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #480 on: July 24, 2010, 10: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

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #481 on: July 25, 2010, 04: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: [Select]
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

Offline D72

  • Posts: 295
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #482 on: September 19, 2010, 02:01:09 PM »
Is there any trick to get something like:
Code: [Select]
$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

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Re: Code Snippet: Display news items, anywhere
« Reply #483 on: October 01, 2010, 05: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: [Select]
(strtoupper($lang_id) == 'AUTO')?$asked_language=LANGUAGE:$asked_language=strtoupper($lang_id);after the line
Code: [Select]
loadLanguageFile($lang_id);
and the change the lines :
Code: [Select]
   $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: [Select]
   $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]
« Last Edit: October 01, 2010, 05:47:02 PM by VotreEspace »
Logged
Xagone Inc. (formerly VotreEspace)
http://xagone.com/

Offline Xagone

  • Posts: 482
  • Gender: Male
  • Developper
    • Xagone Inc
Re: Code Snippet: Display news items, anywhere
« Reply #484 on: October 09, 2010, 06:04:50 PM »
next update need a french language update, the old one is mistranslated.


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

Offline bisun

  • Posts: 2
Re: Code Snippet: Display news items, anywhere
« Reply #485 on: October 12, 2010, 10: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:  :-D

Before:
Code: [Select]
...
$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: [Select]
...
$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

Offline tkche

  • Posts: 12
Re: Code Snippet: Display news items, anywhere
« Reply #486 on: April 12, 2011, 03: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

Offline mikejd

  • Posts: 251
Re: Code Snippet: Display news items, anywhere
« Reply #487 on: May 05, 2011, 01: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, 01:46:32 PM by mikejd »
Logged

Offline nick0

  • Posts: 2
Re: Code Snippet: Display news items, anywhere
« Reply #488 on: July 05, 2011, 12:12:45 PM »
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 :)
Logged

Offline dbs

  • Betatester
  • **
  • Posts: 8920
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Code Snippet: Display news items, anywhere
« Reply #489 on: July 05, 2011, 01:20:26 PM »
there is a way to show the content_short if the conten_long is empty.
https://forum.WebsiteBaker.org/index.php/topic,21671.msg145787.html#msg145787
Logged
https://onkel-franky.de

Offline maverik

  • Posts: 1572
  • Gender: Male
  • ..:: viva los tioz ::..
Re: Code Snippet: Display news items, anywhere
« Reply #490 on: July 05, 2011, 01:22:55 PM »
news modul > view.php

search for

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

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

######

dbs was faster  :-D
Logged

Offline lausianne

  • Posts: 206
    • Webdesign Burgdorf
Re: Code Snippet: Display news items, anywhere
« Reply #491 on: September 05, 2011, 04: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

Offline picas2012

  • Posts: 13
Re: Code Snippet: Display news items, anywhere
« 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

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 #493 on: January 16, 2012, 11:57:31 PM »
Not without php knowledge.
You would need to modify AnyNews to do that.
Logged
Dev4me - WebsiteBaker modules - WBhelp.org

jacobi22

  • Guest
Re: Code Snippet: Display news items, anywhere
« 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: [Select]
ORDER BY $sql_order_by $sql_sort_order
                        LIMIT 0, $max_news_items";

and change the LIMIT to 1

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

Offline picas2012

  • Posts: 13
Re: Code Snippet: Display news items, anywhere
« 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

  • Guest
Re: Code Snippet: Display news items, anywhere
« 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: [Select]
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: [Select]
$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

carfreak

  • Guest
Re: Code Snippet: Display news items, anywhere
« 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: [Select]
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

Offline picas2012

  • Posts: 13
Re: Code Snippet: Display news items, anywhere
« 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

  • Guest
Re: Code Snippet: Display news items, anywhere
« 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

  • Print
Pages: 1 ... 18 19 [20] 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