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

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

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Code Snippet: Display news items, anywhere
« Reply #400 on: December 11, 2009, 02:27:35 PM »
Could you please explain a little further?
Where to see and how to change in the snippet.

I hardcoded a change for myself in the inlcude.php of the snippet and produced a new PLACEHOLDER for the output. It works good for me, but I think there is a better way without changing the snippet files?

Regards,
Stefek
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #401 on: December 11, 2009, 03:55:35 PM »
There are language modules (DE.php, ...) in the languages subfolder of the module. Just open one of your choice and set the array key DATE_FORMAT to the format you wish to use.

There is no parameter.
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Code Snippet: Display news items, anywhere
« Reply #402 on: December 11, 2009, 04:57:31 PM »
Thanks Bianka!
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Mirens

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #403 on: December 12, 2009, 08:19:30 PM »
Hello people, I just downloaded this snippet and made it work like I want. Since I will be using this mostly in Serbia I made language modification because of clients. So here it is... name the file RS.php (Republic of Serbia) our internet domain is .rs and because of our characters save it as UTF-8 or whatever.
Thank you again!

Code: [Select]
<?php
/**
 * Serbian language file for the code snippet: anynews
 *
 * This code snippets grabs news from the WB news module database
 * and displays them on any page you want by invoking the function
 * displayNewsItems() via a page of type code or the index.php 
 * file of the template.
 *
 * This file contains the Serbian language output.
 * 
 * LICENSE: GNU General Public License 3.0
 * 
 * @author        Christian Sommer
 * @copyright    Christian Sommer (c) 2007-2009
 * @license        http://www.gnu.org/licenses/gpl.html
 * @version        1.00
 * @platform    WebsiteBaker 2.7
*/

// Serbian module description
$module_description    = &#39;WebsiteBaker modul za prikazivanje novosti na bilo kojoj stranici vašeg web site-a. Funkcija modula može biti implementirana u sam template ili putem code sekcije. Detalji i pomoć oko korišćenja ovog modula mogu se naći u samom modulu na linku <a href="{WB_URL}/modules/anynews/help/help_en.html" target="_blank">README</a>&#39;;

// declare module language array
$LANG = array();

// Tekstualni prikaz izlazne forme modula
$LANG[0] = array(
    &
#39;TXT_HEADER&#39;        => &#39;Najnovije vesti&#39;, 
    
&#39;TXT_READMORE&#39;        => &#39;detaljnije&#39;, 
    
&#39;TXT_NO_NEWS&#39;        => &#39;Vesti ne postoje u bazi.&#39;,
    
&#39;TXT_NEWS&#39;        => &#39;Novosti&#39;, 
    // English date/time format: (9:12 PM, 10/20/2008)
    
&#39;DATE_FORMAT&#39;        => &#39; | d.m.Y. - H:i&#39;,        
    
&#39;TXT_REQUIREMENTS&#39;    => &#39;Greška, Anynews možete koristiti samo sa WebsiteBaker verzijom 2.7 ili novijom.&#39;,        
);

?>

Logged

Mirens

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #404 on: December 13, 2009, 12:29:08 AM »
Hm I maybe have a problem  :| its probably something easy but...

This is my code
Code: [Select]
$group_id = 0, $max_news_items = 10,$max_news_length = 251, $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)
with $max_news_length = 251, whole message is there no nead for cutting even image from short story is there, and everything is nice like on next picture (I put this psichedelic colors for easyer understanding)
Gray color is background color for all the <p> in div anynews.

After that I made a change in $max_news_length = 250 , so the script have to cut the message and make it shorter. I change setting just for 1 character! from 251 to 250.
The image disapear from short story.
Link of that image is counted in that 250 characters (you can see there is no 1 character missing but the half of text), and gray zone iz gone, so I guess <p> disapered somehow.

I take back the maxlength setting to fit the whole short story or put it to -1 and everything is like on picture 1 nice and clean.

Is there some way I can make this to work or I'm just stupid :)
Sorry for long post but I wanted to bring as more info as I can.
Logged

Mirens

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #405 on: December 14, 2009, 12:47:35 AM »
Ok, I'm trying to fix this I never used PHP, I saw today the output part of html. When script is using new added code for shortening the long text:
// New code; break at word boundary
html output is displayed like this
Code: [Select]
&lt;img width=&quot;220&quot; height=&quot;60&quot;only text is displayed no image because html dont understand this...

When script doesnt shorten the txt i got the code like this and everything is fine
Code: [Select]
<p><img width="220" height="60"So... I figured out that decoding is somewhere lost, I searched on google for PHP decode... and added one line of code in script
Code: [Select]
function wordwrap2( $str, $width = 75, $break = '\n', $cut = true ) {
  $str = html_entity_decode( $str ); //first decode
  $out = wordwrap( $str, $width, $break, $cut ); //now wordwrap
  $out = htmlentities( $out ); //re-encode the entities
// I added
//  $out = html_entity_decode( $out );
// end of my adding
  $out = str_replace( htmlentities( $break ), $break, $out ); //put back the break
  // return the first line
  $temp = explode( $break, $out );
  return $temp[0];
}

?>
Now everything is nice BUT now when there is &nbsp; in html code it is displayed with some strange ascii black and white questionmark. And now I'm stuck again...
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #406 on: December 14, 2009, 10:42:36 AM »
Thank you very much for the serbian language file. I will include it with the next release.


You may want to try the truncate() method you can find at

http://209.85.135.132/search?q=cache:byzMdc5_BK8J:https://trac.cakephp.org/ticket/2306+php+truncate+string+html&cd=2&hl=de&ct=clnk&gl=de&client=firefox-a

(Google cache, as the ticket seems to be not available anymore.)

Please note that you will have to edit the truncate()-call, too. (Line 222 ff)
Logged

Mirens

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #407 on: December 14, 2009, 01:57:52 PM »
Thank you for your answer, oh... I'm not so familiar with PHP jet, what I manage do to is delete this line from the include.php code
Code: [Select]
$str = html_entity_decode( $str ); //first decode
and add this line
Code: [Select]
$out = html_entity_decode( $out );
&nbsp; is now converted in blank space, all lattin characters are there, all cyrilic characters are there all pictures from short story are there.
But I dont think I can just like that delete some line of the code and everything work.
So please tell me if this what I did is not safe or something.
Logged

hansis

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #408 on: December 19, 2009, 11:24:28 AM »
Hello!

I manage my events with module "Event Calendar". At the entry site I want to display the next 3 events.
Is this possible with Any news Item?

thx.
hansi
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #409 on: December 20, 2009, 03:40:23 PM »
No. It's not called NextEvents. :-D

Edit: You may want to try this droplet. It creates a month calendar and takes/links the events from Event Calendar 1.8c.

https://forum.WebsiteBaker.org/index.php/topic,15895.msg105131.html#msg105131

See it in action:

http://www.bonsai-nrw.de/cms/
« Last Edit: December 20, 2009, 03:54:35 PM by WebBird »
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #410 on: December 20, 2009, 03:41:12 PM »
Quote from: Mirens on December 14, 2009, 01:57:52 PM
But I dont think I can just like that delete some line of the code and everything work.
So please tell me if this what I did is not safe or something.

Well, if it works for you, just leave it. :-D
Logged

hansis

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #411 on: December 21, 2009, 11:00:12 AM »
recht herzlichen Dank

jetzt spiele ich noch mit CSS :)
Logged

Offline dbs

  • Betatester
  • **
  • Posts: 8914
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Code Snippet: Display news items, anywhere
« Reply #412 on: December 21, 2009, 12:39:38 PM »
@webbird: auf der bonsai-seite scheint die foldergallery schön sortierbar zu sein.
sind da schon neuerungen in verwendung?

dbs
Logged
https://onkel-franky.de

geasy

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #413 on: December 27, 2009, 03:02:54 PM »
Hi all

Just installed anynews and I'm astonished by all the functionalities includes: Cool! Congratulation to this great module.

Now, I have two little questions regarding this module:

1. Parameters
I have opened a "code section" on one of my pages. If I put in the code:

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems();
}

everything works fine. As soon as I change to eg.

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(display_mode = 1,);
}

it is not working anymore (means there is no news shown on the page anymore). What am I doing wrong here?  :?

2. No long content

Some of my news do not have a long content but the "read more" link is shown in any case. Is there a possibility that the "read more" link is only shown if there is a long content for this particular news?

Many thanks in advance for your help.

Claudio

Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #414 on: December 28, 2009, 09:48:38 AM »
Quote from: dbs on December 21, 2009, 12:39:38 PM
@webbird: auf der bonsai-seite scheint die foldergallery schön sortierbar zu sein.
sind da schon neuerungen in verwendung?

Nö. Von Hand in der Datenbank gefummelt. :-D
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #415 on: December 28, 2009, 09:57:41 AM »
Quote from: geasy on December 27, 2009, 03:02:54 PM
As soon as I change to eg.

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(display_mode = 1,);
}

it is not working anymore (means there is no news shown on the page anymore).

There are two errors in that code:

1. The parameters are positional. This means you will have to add all parameters _before_ $display_mode, too.
2. You missed the $ in front of display_mode.

See here:

Code: [Select]
displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 5,
       $lang_id = 'DE',
       $strip_tags = false,
       $allowed_tags = '<p><a><img>',
       $custom_placeholder = false,
       $sort_by = 1,
       $sort_order = 1,
       $not_older_than = 0
   );

So, in your case, the correct code would be:

Code: [Select]
if (function_exists('displayNewsItems')) {
    displayNewsItems(
       $group_id = 0,
       $max_news_items = 2,
       $max_news_length = 200,
       $display_mode = 1
   );
}

Just use the default values for the params you do not wish to set explicitly. (See docs for defaults.)

Quote from: geasy on December 27, 2009, 03:02:54 PM
2. No long content

Some of my news do not have a long content but the "read more" link is shown in any case. Is there a possibility that the "read more" link is only shown if there is a long content for this particular news?

This is hardcoded in the output template. So there's no simple way to do this at the moment. You could only remove that part from the template, but it will be missing then if there's long content, too.
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #416 on: December 28, 2009, 03:53:14 PM »
So here's v1.14 for testing. :-D

* fix: replaced function to truncate long text with a (hopefully) better one
* added Serbian language file (RS.php) contributed by forum member "Mirens"
* no "read more" link shown if there's no "long text" in the news entry

Note: If you wish the "read more" link to appear in any case, remove the <!-- BEGIN readmore_link_block --> and <!-- END readmore_link_block --> block markers from the template.

I will upload this version to AMASP when I'm sure it works, so please check it out. :-D

[gelöscht durch Administrator]
Logged

geasy

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #417 on: December 29, 2009, 11:39:28 AM »
Wow, cool, herzlichen Dank für's schnelle Anpassen!

That looks perfect to me.

Regarding the missing "$" in my code: I just copied the code from the http://www.websitebakers.com/media/amasp_uploads/anynews_help_en.html. There are no "$" in the code. 
However, many thanks for your help with that!

Claudio
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #418 on: December 29, 2009, 12:52:34 PM »
Hm, maybe they (the $) are not really important, while the position of the param is, anyway. :-D
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #419 on: December 29, 2009, 01:02:52 PM »
I've upgraded AnyNews at AMASP.

http://www.websitebakers.com/pages/code-snippets/listings/anynews.php?lang=EN
Logged

erpe0812

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #420 on: January 21, 2010, 03:32:34 PM »
Hi Bianka

after registration on a site I get the following parsing error::
Fatal error: Call to undefined method wb::preprocess() in /var/www/web128/html/modules/anynews/include.php on line 194   

WB 2.8
Anynews 1.12

It is curious, that this happens only after registration, the site is running well on all other pages (seems that the page stops while redirectimg, the registration is successful).

Any idea?

rgds

erpe
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #421 on: January 21, 2010, 04:05:18 PM »
Uhm, what do you mean saying "registration"?
Logged

erpe0812

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #422 on: January 21, 2010, 04:24:44 PM »
mmhh

use the registration function with a droplet login box.

Hope this helps.

rgds

erpe
Logged

WebBird

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #423 on: January 22, 2010, 11:04:06 AM »
I tried to reproduce this error, but it works for me. Tested with "All CSS" template. If you have a non-production copy of the site, try to use another template.

You can also try to add this code to include.php:

Code: [Select]
       // register outside variables
        global $wb, $database;

// AFTER ADD
                if ( ! is_object( $wb ) ) {
                    require_once(WB_PATH.'/framework/class.frontend.php');
                    // Create new frontend object
                   $wb = new frontend();
                }
Logged

erpe0812

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #424 on: January 22, 2010, 12:46:04 PM »
Included posted code in include.php of anynews (1.14.) but no effect.
Same error appears.

Any additional idea?

rgds

erpe
Logged

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