Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
March 21, 2010, 01:50:30 AM
1 Hour
1 Day
1 Week
1 Month
Forever
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
.
110564
Posts in
15967
Topics by
9310
Members
Latest Member:
stevenris10
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderators:
Argos
,
BerndJM
)
Code Snippet: Display news items, anywhere
Pages:
1
...
17
18
[
19
]
Author
Topic: Code Snippet: Display news items, anywhere (Read 65531 times)
WebBird
Offline
Posts: 1714
Re: Code Snippet: Display news items, anywhere
«
Reply #450 on:
February 01, 2010, 10:33:39 AM »
Do you use "return" to return the content, or just the call? The call does an "echo", what's not what you're after when using a droplet.
Logged
I wanna go back to find the innocent days that I left behind... I still believe they're holding ground... behind the battle lines... (John Wetton)
Harry P.
Offline
Posts: 38
Re: Code Snippet: Display news items, anywhere
«
Reply #451 on:
February 01, 2010, 10:38:28 AM »
Just the call, as shown in my code quote.
What would the droplet syntax look like with a return?
Logged
WebBird
Offline
Posts: 1714
Re: Code Snippet: Display news items, anywhere
«
Reply #452 on:
February 01, 2010, 10:41:29 AM »
You will have to "catch" the output with ob_start()... etc and return it.
Logged
I wanna go back to find the innocent days that I left behind... I still believe they're holding ground... behind the battle lines... (John Wetton)
WebBird
Offline
Posts: 1714
Re: Code Snippet: Display news items, anywhere
«
Reply #453 on:
February 01, 2010, 10:45:50 AM »
Try:
Code:
$output = NULL;
if (function_exists('displayNewsItems')) {
ob_start();
displayNewsItems(
$group_id = 2,
$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
);
$output = ob_get_clean();
}
return $output;
You may set $output to something else but NULL, if you wish to print out an error message if the Anynews call fails, for example.
Edit: Fixed code.
«
Last Edit: February 01, 2010, 11:17:52 AM by WebBird
»
Logged
I wanna go back to find the innocent days that I left behind... I still believe they're holding ground... behind the battle lines... (John Wetton)
Harry P.
Offline
Posts: 38
Re: Code Snippet: Display news items, anywhere
«
Reply #454 on:
February 01, 2010, 11:01:49 AM »
Thanks! But...
I copied your code 1:1 to a droplet, but when used on a page, it doesn't return anything....
Logged
WebBird
Offline
Posts: 1714
Re: Code Snippet: Display news items, anywhere
«
Reply #455 on:
February 01, 2010, 11:16:49 AM »
Woops, sorry, it's ob_get_clean(), not ob_end_clean().
Logged
I wanna go back to find the innocent days that I left behind... I still believe they're holding ground... behind the battle lines... (John Wetton)
Harry P.
Offline
Posts: 38
Re: Code Snippet: Display news items, anywhere
«
Reply #456 on:
February 01, 2010, 11:23:59 AM »
Ah, now it's working. Thanks a lot, WebBird!
Logged
seagull
Offline
Posts: 61
Re: Code Snippet: Display news items, anywhere
«
Reply #457 on:
February 01, 2010, 09:03:55 PM »
@WebBird
Quote
Maybe i overlooked it, but when i use displayanynews with displaymode=2(only the newstitle as link) and having newsitems with only shorttext the resulting page displays the longtext wich is empty, so only the header and the footer are displayed.
Am i doing something wrong or is this the way the snippet should work?(only with long text)
It's not Anynews that causing this but the newsmodule itself.
For now i modified view.php(at line 450) of the news so that if the $post_long is empty the $post_short is printed otherwise the $post_long should be printed.
thanks, Jan
Logged
WebBird
Offline
Posts: 1714
Re: Code Snippet: Display news items, anywhere
«
Reply #458 on:
February 02, 2010, 10:00:13 AM »
Ah. I misunderstood "resulting page". You meant the page Anynews links to, right? You can open a bug ticket for the news module if you wish. But take a look if it is an already known problem before opening a ticket.
Logged
I wanna go back to find the innocent days that I left behind... I still believe they're holding ground... behind the battle lines... (John Wetton)
tiesy
Offline
Posts: 86
Re: Code Snippet: Display news items, anywhere
«
Reply #459 on:
February 02, 2010, 05:32:41 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?
More thanks!
This is easy to solve: You have to relace "$group_id" to "$page_id" on every position of the snippet. Tools like "InfoRapid Suchen & Ersetzen" will do this in a few seconds. If you don´t want to overwrite the original-snippet, simply rename it in the info.php to something like "anypagenews".
Logged
Pages:
1
...
17
18
[
19
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
Loading...