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


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


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 ... 13 14 [15] 16 17 ... 21   Go Down

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

aldus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #350 on: September 02, 2009, 09:51:17 AM »
Hello bikerider

I'm pretty sure that there are error-messages if you try to set the PHP-Error-Reporting-Level to "E_ALL".

Some copy and paste errors, as the function is named "displayNewsItems" ..

Code: [Select]
<?php 
if(function_exists(&#39;displayNewsItems&#39;)) {
    
displayNewsItems( 0, 5, 50, 1, "", "mehr lesen", "aktuell gibt es keine news...", false);
} else {
    echo &
#39;Requires code snippet anynews (WB addons repository) to display news here.&#39;;
}
?>



Regards
Aldus
Logged

Offline bikerider

  • Posts: 21
Re: Code Snippet: Display news items, anywhere
« Reply #351 on: September 02, 2009, 11:27:43 AM »
 :oops: sorry - twice...

thank you so much!!!
Logged

snark

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #352 on: September 05, 2009, 12:44:50 AM »
Anyone who knows wether I can use the anynews for the mediablog module
Logged

micklan

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #353 on: September 05, 2009, 12:35:20 PM »
Hi!

Why i receive the "&rsquo;" syntax in news instead of  " ' " character ?

Thanks you!
« Last Edit: September 05, 2009, 01:11:47 PM by micklan »
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #354 on: September 11, 2009, 11:21:04 AM »
I´ve a problem with allowed tags and didn´t find a solution:

The tag-brackets (<,>) will be replaced with "&lt;" or "&gt;". So, if I allow some tags, the sourcecode is shown in the output.

I use wb2.8 and the newest version of anynews.
 
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #355 on: September 11, 2009, 11:28:05 AM »
Have you tried the 'strip_tags' and 'allowed_tags' options of the displayNewsItems() method?

Code: [Select]
strip_tags...         true:=remove tags from short and long text (default:=true); false:=don´t strip tags
allowed_tags...        tags not striped off (default:='<p><a><img>')

See included help files for details.
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #356 on: September 11, 2009, 01:04:45 PM »
Hi WebBird!

Yes, I did. This is my snippet in a code-section:

if (function_exists('displayNewsItems')) {
    displayNewsItems(2, 2, 200, 5, DE, true,'<p><a><img>', 1, 0);
}

I also tried "false" instead of "true". The problem is the same.

Do you see any mistake?
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #357 on: September 11, 2009, 01:40:14 PM »
Cannot reproduce this error. Use "false" instead of "true" and wrap DE in quotes, please.

Code: [Select]
if (function_exists('displayNewsItems')) {
   displayNewsItems(2, 2, 200, 5, 'DE', false,'<p><a><img>', 1, 0);
}

Also, you use a custom template, so please try to replace 5 with 1 for testing. (Which means "details".)
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #358 on: September 11, 2009, 04:30:17 PM »
Hi,

maybe consider to write your anynews function calls as follows (helps to keep track of the various parameters).

Code: [Select]
<?php
if (function_exists(&#39;displayNewsItems&#39;)) {
   
displayNewsItems($group_id = 2, 
      
$max_news_items = 2, $max_news_length = 200, 
      
$display_mode = 5, $lang_id = &#39;DE&#39;,
      
$strip_tags = false, $allowed_tags = &#39;<p><a><img>&#39;, 
      
$custom_placeholder = false, 
      
$sort_by = 4, $sort_order = 1, $not_older_than = 0
   
);
}
?>

You should check $display_mode (5 uses a custom template) and the last two parameters.

Doc
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #359 on: September 11, 2009, 05:56:44 PM »
Hi Doc & WebBird,

thanks for your help. I´ve tested your solutions, changed true to false, but the problem stays on. Could it have something to do with the installed php-version?
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #360 on: September 14, 2009, 12:55:35 PM »
Quote from: tiesy on September 11, 2009, 05:56:44 PM
Could it have something to do with the installed php-version?

Which is...?

Is the HTML correct on the News page itself?
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #361 on: September 15, 2009, 09:47:36 AM »
Yes, I´ve made no changes in the html-code on news-section. It´s a fresh wb-installation. The php-version is 4.3.9.
I know, that php5 is required for wb 2.8., but exept of anynews it works without any problems.
Logged

joep

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #362 on: September 15, 2009, 11:16:04 AM »
I have a question.

I use this code:
Code: [Select]
displayNewsItems(array(10,11, 12, 13, 14), 5, 0, 0, false);I don't know much abouth anynews yet!!

What i trie to achief is a block with new items from several groups, showing only the title of the post.

So not the date, or the dots on the bottom. And not the title (Latest News).

It worked with this code:
Code: [Select]
$group = 9; // 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 position DESC LIMIT 0, 3;";

/*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;
  echo '<li><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'">'.$title.'</a>'.$short.'</li>'; // the loop

}
echo "</ul>"; // end of the loop

the problem with this code is that it only works with one group.

the link to my page is :
http://www.studiozi.com/wb

Thanq in advanced



Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #363 on: September 15, 2009, 12:48:29 PM »
Yes, it works only for one group. (Or use 0 for "get from all groups".)

What is the question? :roll:
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #364 on: September 15, 2009, 12:49:05 PM »
Quote from: tiesy on September 15, 2009, 09:47:36 AM
Yes, I´ve made no changes in the html-code on news-section. It´s a fresh wb-installation. The php-version is 4.3.9.
I know, that php5 is required for wb 2.8., but exept of anynews it works without any problems.

I've tried with PHP 4.4.9, but I still can't reproduce the error. Can you show us?
Logged

joep

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #365 on: September 15, 2009, 06:17:55 PM »
My question is.

Is it possible to use multiple groups. for example group 3 and 4.
I have 8 groups.
7 of them i want to use.

Maybe i can use somkind of array??
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #366 on: September 15, 2009, 06:30:31 PM »
@joep:
You can define all groups ($group_id = 0), a single group ($group_id = x) or a collection of groups ($group_id = array(3,4)). Details about the possible function parameters are provided in the Readme file of the module. A function call with two groups can be found in section "Example for a customized call:" of the Readme.

Please make sure you are using the latest version of anynews.

Doc
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #367 on: September 16, 2009, 09:32:38 AM »
Hi WebBird,

no, I can´t for the moment, it´s not public yet. But I made some screenshots, where you can see, what happens.


[gelöscht durch Administrator]
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #368 on: September 16, 2009, 10:10:09 AM »
Well, on the screenshot the strip_tags param is set to true, which means "strip all tags", and the lang_id is still not enclosed in quotes. ;)
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #369 on: September 16, 2009, 10:34:19 AM »
It makes no difference, if I change the parameter from true to false. Language in quotes or not is all the same. I think it has to do with the server-setup.
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #370 on: September 16, 2009, 10:50:00 AM »
Yes, I'd say it's the most probable explanation. Anyway, I don't know what to look for. :|
Logged

aldus

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #371 on: September 16, 2009, 11:41:03 AM »
Hello

As far as i can reproduce this bug it has to do within the max-char restriction, e.g. 200 chars,
in the short-message as the function "wordwrap2" converts htmlentities ... so the brakets became
"&lt;" and "&gt;" - also the quotes to &quote ...

To avoid this i've add
Code: [Select]
<?php
 $restore 
= array (
    &
#39;&lt;&#39; => "<",
    
&#39;&gt;&#39; => ">",
    
&#39;&quote;&#39; => "\""
);
$temp[0] = str_replace(array_keys($restore), array_values($restore), $temp[0]);
?>

to the function "wordwrap2" in the bottom of the include.php,
but i'm pretty sure that were are more elegant ways to solve this.

Kind regards
Aldus


[gelöscht durch Administrator]
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #372 on: September 16, 2009, 12:27:06 PM »
Ah. This also explains the problem "micklan" has with &rsquo;. Funny that I can't reproduce it... I'll try to find a solution. Thank you very much Aldus!!!
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #373 on: September 16, 2009, 01:49:33 PM »
I also found that it is ... uhm ... "not nice" if there are any opening HTML tags in the remaining text, so I worked on a solution to close these tags, too. I'm not very happy with the code, but if it works, it's better than leaving it as is.

Can someone please do some tests with the include.php attached?

Edit: Removed attachment
« Last Edit: September 24, 2009, 07:34:35 PM by WebBird »
Logged

Offline tiesy

  • Posts: 125
    • Wir in Wallenhorst
Re: Code Snippet: Display news items, anywhere
« Reply #374 on: September 22, 2009, 10:19:54 AM »
Hi WebBird,
I have tested your include.php an it works as you explained. Many thanks for that.
It´s better than before, but not a real solution for the problem. Now it cuts all news-entries even if to long html-commands found in only one news-entry.

I don´t know how to make it, but the anynews-function "max_news_length" should not count the characters of html-tags and not replace the brackets in principle.
Logged

  • Print
Pages: 1 ... 13 14 [15] 16 17 ... 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