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 2 3 [4] 5 6 ... 21   Go Down

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

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #75 on: February 19, 2007, 04:53:03 PM »
@YeShakka
I am thinking to implement a feature which let you control how the news will be displayed.
Possible options:
 - display as list (only news header and read more link)
 - display as table (allow choice of columns to be used)

In addition I want some feedback first, before moving that snippet to the completed section.

Regards Christian
Logged

hr_d

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #76 on: February 19, 2007, 08:09:55 PM »
Hello,

I install and tested the "display news items modul" without any problems. It will be nice to show also the short-text of the news.

Thanks to Christian for his good work.

Regards Hermann



« Last Edit: February 19, 2007, 08:11:54 PM by hr_d »
Logged

doc

  • Guest
Anynews snippet module v0.11
« Reply #77 on: February 19, 2007, 09:35:49 PM »
Hello,

please find attached the updated version of the anynews snippet module. To upgrade, just install it over the previous one.

Have added the additional parameter $display_mode which allows you to output a detailed list (news title, short text, link to news item), or a simple unsorted list (link to news item, link text = news title). In addition I added the option to display the full short text ($max_news_length=-1, which is now the default) or no short text at all ($max_news_length=0). The latest version creates now valid (X)HTML output (forgot the closing slash in the <hr /> element).

Code: [Select]
<?php display_news_items($group_id, $max_news_items, $max_news_length,
$display_mode, $header_text, $readmore_text, $no_news_text); ?>


Optional parameters:
group_id...  group from which you want to read news from (default:= 0 for all groups)
max_news_items...  max number of news shown (default:= 10, no value >10 accepted)
max_news_length... max length of the short news text shown (default:=-1 for full news length)
display_mode... 1:=details (default); 2:=unsorted list
header_text...  heading text shown (default:="Latest news")
readmore_text... text displayed for readmore link (default:=read more)
no_news_text...   text shown if no news available (default:="no news avaialbe yet...")

[Edited 18.2.07, 22:38]
Example for customised call:
display_news_items(0, 5, 50, 2, "The latest news", "show full news text", "uup, no news available");

Troubleshooting:
 - pass over either no argument, or all arguments in expected order
 - mask text with "your text " or 'your text '
 - within your template index.php file use: <?php display_news_items(); ?>
 - within a code module use: display_news_items();
 - remind the ; at the end of the code line

Custom formating:
The output can be customized to your needs without touching the code itself. This is realised by the use of CSS definitions. Open a code page and enter the following code:
Code: [Select]
echo "<div id=\"mynews\">";
display_news_items(0, 3, 15, 1, "Last news", "more...", "no news yet");
echo "</div>";

The additional div section is used to restrict the style defintions to the news only, without influencing the rest of your layout. The following CSS examples needs to be added to the CSS file of your template.

The font size of the news text is too big?
Code: [Select]
#mynews p {font-size:80%; }
You want the news title to show up in brown?
Code: [Select]
#mynews strong {color:brown; }
The news header should have a left brown border?
Code: [Select]
#mynews h2 {border:1px dotted brown; margin:5px; padding:0;}
Please keep in mind: I will not aks any questions on CSS formating.
A lot of pages are available for free in the internet. http://www.css4you.de/, http://glish.com/css/

Regards Christian

Removed file. Any news is now available in the section Additional Functions on addons repository
« Last Edit: February 20, 2007, 07:10:27 PM by doc »
Logged

Offline Hans

  • Posts: 914
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #78 on: February 19, 2007, 09:58:26 PM »
Hi Doc
thanks!
One problem though: when adding a space in $header_text or $readmore_txt I get this message:
Parse error: syntax error, unexpected T_STRING in /home/dernjen/public_html/modules/code/view.php(30) : eval()'d code on line 1

(I replaced $header_text and $readmore_txt with normal text (Dutch: Lees meer = English: Read more), maybe I have it the wrong way? When I replace it with one word or two with an underscore I get no errormessage (although the underscore is visible in the link).
Hans


« Last Edit: February 19, 2007, 10:01:06 PM by Hans »
Logged
Hans - Nijmegen - The Netherlands

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #79 on: February 19, 2007, 10:03:24 PM »
Hello Hans,

you need to pass over text in " " or ' ' like shown below:
display_news_items(0, 10, -1, 1, "Test test", "test tesset", " no test");
display_news_items(0, 10, -1, 1, 'Test test', 'test tesset', ' no test');

Have tested this and it works. If you forget the " ", the number of arguments will not fit the expected number.

Regards Christian
Logged

Offline Hans

  • Posts: 914
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #80 on: February 19, 2007, 10:08:12 PM »
Yes! That worked.
Thank you!
Hans
Logged
Hans - Nijmegen - The Netherlands

hr_d

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #81 on: February 20, 2007, 09:34:51 PM »
Hello,

works very well.

I have small pictures in the short text news!. It is possible to show these also?

Have a look: http://www.frettchen.raith.ws/pages/news.php

Thank you!
Hermann
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #82 on: February 20, 2007, 09:42:35 PM »
Hello Hermann,

not possible with the latest version, as I am using the PHP command strip_tags() to remove all HTML tags from the short text. So in your case, image tags like <img> will be striped from the short news text.

Try to remark the strip_tags command for short news text in line 83 in anynews/include.php
Code: [Select]
//$data['content_short'] = strip_tags($data['content_short']);
Regards Christian
Logged

hr_d

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #83 on: February 20, 2007, 11:04:20 PM »
Hello Christian,

that worked fine. Thank you! http://www.frettchen.raith.ws/

Perhaps you can make a parameter in the next version.

Regards Hermann
Logged

doc

  • Guest
Anynews v0.12 available
« Reply #84 on: February 21, 2007, 05:00:53 PM »
Have added the option to suppress striping off tags from news title, and short news text. In addition I removed all inline CSS styles, as they can“b be overwritten via external CSS definitions.

Added a README file to the zip file in the addons repository which explains all possible functions.

Regards Christian
Logged

hr_d

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #85 on: February 22, 2007, 10:44:40 PM »
Hello Christian,

I tested it, very good job!

Thank you. http://www.frettchen.raith.ws/

Regards Hermann
Logged

Offline G4

  • Posts: 91
Re: Code Snippet: Display news items, anywhere
« Reply #86 on: March 09, 2007, 11:54:12 AM »
Is it possible to show 2 newsitems on the frontpage from 2 different news pages. In the module i can not find a page ID. Or is there some other way to do this.

NEWSPAGE 1
item A
item B
item C

NEWSPAGE 2
item X
item Y
item Z


On the frontpage I want to show
LATEST
item A
and
item X
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code Snippet: Display news items, anywhere
« Reply #87 on: March 09, 2007, 12:17:32 PM »
you can only (with the default setup) generate the different groups. Otherwise you will need to change the script, so it checkes the page_id as reference for the postings ...

cheers

Klaus
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #88 on: March 11, 2007, 02:10:08 PM »
@G4
You could try the following workaround:
Put all news items of Newspage 1 into a group (e.g. news1), all news items of Newspage 2 into another group (e.g. news2). Assuming that group news1 has the number 5, news2 the number 6, try the following code:

Code: [Select]
display_news_items(5, 1, -1, 1, "Latest News", "read more", "no news available yet...", true);
display_news_items(6, 1, -1, 1, "Latest News", "read more", "no news available yet...", true);

Regards Christian
Logged

Offline Olli

  • Posts: 291
Re: Code Snippet: Display news items, anywhere
« Reply #89 on: March 15, 2007, 12:29:14 PM »
hello everyone,
i tried the snipped a while back and i love it :-)

but there is one thing, that's not working properly. let's say you've got a WB-link inside the short-text area.

this WB-link does not get "translated" to the real URL.
it says "www.mydomain.com/pages/[wblink2]" or something like this.

is this fixed already?

thanks guys
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #90 on: March 28, 2007, 06:13:13 PM »
@Olli:
I dont think that this is related to the anynews snippet, but to the news module itself.

Regards Christian
Logged

Offline propelled

  • Posts: 16
Re: Code Snippet: Display news items, anywhere
« Reply #91 on: April 13, 2007, 11:19:23 AM »
Hello.

Module anynews works perfect. I dont have experience with php and I need two things to get work this module correctly. Both thing with multilingual site.

First is: I want show texts Lastest News and Read More at language file, to make finnish or russian page fully finnish or russian. I tried replace it with [READ_MORE] but it dont work.

Second is: I have made multilingual site with tree what was explained on multilingual site wiki. It is right now this:
fin
- page1
- page2
- news (news on finnish language)
eng
- page1
- page2
- news (news on english)
rus
- page1
- page2
- news (news on russian)

How to make possible show with anynews module on russian page news on russian language and etc (same with other languges)?
Logged

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8544
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Code Snippet: Display news items, anywhere
« Reply #92 on: April 13, 2007, 11:25:49 AM »
Hello,

a few days ago a read a post where a user solved this with adding the language variable to the requests. Cannot find the thread, but maybe you have mor luck when you search yourself  :wink:

Matthias
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #93 on: April 13, 2007, 01:10:54 PM »
Hello,

the code below assumes that you have sticked to the tutorial for multi language pages. Languages specific pages must be stored in directories like:
DE: ../wb/de/home.php
EN: ../wb/en/home.php

Add the following code (without start <?php and ending ?> tags) into a page of the type code.

Code: [Select]
<?php
// getting the calling page URL (../webserver/en/home.php)
$current_page = $_SERVER[&#39;PHP_SELF&#39;];

// using regular expression to extract the language part from the URL (/en/, /ge/, /it/...)
$language_used = "";
if(
preg_match(&#39;#/(..)/#i&#39;, $current_page, $language)) {
  
$language_used = $language[1];
}

// define text output depending on choosen language
switch ($language_used) {
  case 
"DE":  // german language
     
$news_header = "Letzte Nachrichten";
     
$news_more = "mehr...";
     
$news_no = "keine Nachrichten vorhanden...";
     break;
  
  case 
"EN": // english language
    
$news_header = "Latest News";
    
$news_more = "read more";
    
$news_no = "no news available yet...";
    break;
  
  default:  
// if LANGUAGE could not be detected
    
$news_header = "Your heading text";
    
$news_more = "Your more text";
    
$news_no = "your no new text";
    break;
}   

// call the anynews snippet
display_news_items(0, 10, -1, 1, $news_header, $news_more, $news_no, true);
?>


If someone knows a better way of extracting the page language, please post it here.

Regards Christian
Logged

4bizmedia

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #94 on: June 12, 2007, 03:23:31 AM »
Hi, just wondering if there was an easy way to eliminate the <hr> that is displayed at the end of each snippet, instead having just a blank space.  CSS can make the <hr> small, but can't eliminate it completely.
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #95 on: June 12, 2007, 07:19:01 AM »
Hello,

set the visibility of HR to none or set the color of HR to your background color or remove the HR from the code in include.php.

Regards Christian
Logged

kida

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #96 on: July 03, 2007, 01:24:03 AM »
Hey - works well,

I need it for like an online daily diary..

Anyway to include the date the item was posted with anynews?

Cheers

Darren
Logged

doc

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #97 on: July 03, 2007, 03:50:31 AM »
Hello,

this is not supported, but you can implement that function by your own.

You need to modify the include.php of the anynews snippet. The output is generated between lines 92 and 121. The following code would extract the date from the database and convert it into human readable format (English style). Only place it within the while loop (lines 92-121).

Code: [Select]
echo date("m/d/Y", $data[posted_when]);
To style the output format of the date, have a look to the PHP function code (google)  :-)

Regards Christian
« Last Edit: July 03, 2007, 03:53:13 AM by doc »
Logged

kida

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #98 on: July 03, 2007, 04:53:53 AM »
Hey

That's great - nice solution

Cheers

Darren
Logged

sHsIkuA

  • Guest
Re: Code Snippet: Display news items, anywhere
« Reply #99 on: July 26, 2007, 03:40:24 PM »
Hello need some help here

The snippet only work when I put the group id to 0 , other than that its not working at all

Where can I get my group_id ?

Logged

  • Print
Pages: 1 2 3 [4] 5 6 ... 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