Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 12, 2012, 07:16:41 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
149621
Posts in
21098
Topics by
7537
Members
Latest Member:
lotte2
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
Code Snippet: Display news items, anywhere
Pages:
1
...
6
7
[
8
]
9
10
...
21
Go Down
Author
Topic: Code Snippet: Display news items, anywhere (Read 100221 times)
lepracaun
Offline
Posts: 23
Re: Code Snippet: Display news items, anywhere
«
Reply #175 on:
September 15, 2008, 10:44:05 AM »
Hi, I have been trying to add the cde snippet to my page under my menu on the left, as soon as I paste the code into my index.php file and want to preview it, the page is blank. I have set up the news module in admin, and created a few sample news articles, any idea why it will be doing this?
This is the code I have tried to paste into index.php
Code:
<!-- NEWS READER -->
<?php
$group
=
0
;
// Specify the Group&#40;id&#41; 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 posted_when DESC
LIMIT 0, 5;"
;
// 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
&
#38;#40;&#41;;
if &
#38;#40;!$result = mysql_query&#40;$query&#41;&#41; &#123;
print
"
$error
"
;
exit;
&
#38;#125;
while&
#38;#40;$data = mysql_fetch_object&#40;$result&#41;&#41;&#123;
$title
=
$data
->
title
;
$id
=
$data
->
post_id
;
$link
=
$data
->
link
;
?>
<p>
<a href="
<?php
echo
WB_URL
;
?>
<?php
echo
$link ?>
<?php
echo
PAGE_EXTENSION
;
?>
">
<?php
echo
$title
;
?>
</a>
</p>
<?php
&
#38;#125;
?>
<!-- END NEWS READER -->
«
Last Edit: September 15, 2008, 10:45:51 AM by lepracaun
»
Logged
Argos
Moderator
Offline
Posts: 2084
Re: Code Snippet: Display news items, anywhere
«
Reply #176 on:
September 15, 2008, 10:52:53 AM »
Somehow your code is polluted by stuff like #38;#41;
They prevent the script from working. Please download the latest version on the bottom of page 8 and try again.
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
lepracaun
Offline
Posts: 23
Re: Code Snippet: Display news items, anywhere
«
Reply #177 on:
September 15, 2008, 11:02:45 AM »
Thanks Argos
That was the problem
Logged
ghost06
Offline
Posts: 53
Re: Code Snippet: Display news items, anywhere
«
Reply #178 on:
September 28, 2008, 12:30:13 PM »
hi boys,
how I can make in order to visualize the list of the existing groups?
sorry for my english
Logged
Argos
Moderator
Offline
Posts: 2084
Re: Code Snippet: Display news items, anywhere
«
Reply #179 on:
September 28, 2008, 12:34:48 PM »
Quote from: ghost06 on September 28, 2008, 12:30:13 PM
how I can make in order to visualize the list of the existing groups?
This is not possible with this snippet, because it shows latest news per group, or all groups together. To show the groups themselves, just use the normal news page.
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
doc
Guest
Code snippet anynews v0.21 released
«
Reply #180 on:
October 20, 2008, 11:16:43 AM »
Hi,
just released
version 0.21
of the anynews snippet on the addons repository. The module is based up on v0.14 published by Ruud E and hence includes the fixes for the publish by date function and for internal WB links.
Version v0.21 introduces two new options.
option to specify tags which will not be removed by the strip_tags option (default: anchor tag)
option to display the publish date/time to the title of each news entry (default: off)
Apart from that, some code cleaning, language support and a
HTML help file
was added to v0.21.
Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?
Regards Christian
«
Last Edit: October 20, 2008, 01:42:54 PM by doc
»
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code snippet anynews v0.21 released
«
Reply #181 on:
October 20, 2008, 01:39:38 PM »
Quote from: doc on October 20, 2008, 11:16:43 AM
Ruud can you please remove your zip files (v0.13 and v0.14) from this thread as v0.21 includes all your changes?
Done,
Ruud
Logged
Professional WebsiteBaker Developer
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #182 on:
October 21, 2008, 01:12:34 PM »
Trying to make a templete were "Any News", depending of language set on the page, list news from one of two sources. Is it hard to do this?
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #183 on:
October 21, 2008, 01:28:55 PM »
I've done this by using 2 news groups. Dutch / English
I didn't set the language in the pages, but used a /pages/en/ or /pages/nl/ page structure.
Code:
<?php
$url
=
$_SERVER
[
'REQUEST_URI'
];
if (
function_exists
(
'display_news_items'
)) {
if (
strrpos
(
$url
,
"/en/"
)) {
display_news_items
(
1
,
3
,-
1
,
1
,
"Latest news"
,
"read more"
,
"No news available"
,
false
);
} else {
display_news_items
(
2
,
3
,-
1
,
1
,
"Laatste nieuws"
,
"verder lezen"
,
"geen nieuws beschikbaar"
,
false
);
}
}
?>
Ruud
«
Last Edit: October 21, 2008, 01:34:34 PM by Ruud
»
Logged
Professional WebsiteBaker Developer
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #184 on:
October 21, 2008, 01:31:31 PM »
Thnx Ruud will try it out..
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #185 on:
October 21, 2008, 01:33:30 PM »
I missed one line you will need to have too:
Before testing the $url variable, it needs to be defined with something
Code:
$url = $_SERVER['REQUEST_URI'];
Ruud
Logged
Professional WebsiteBaker Developer
babsy
Offline
Posts: 311
Re: Code Snippet: Display news items, anywhere
«
Reply #186 on:
October 22, 2008, 12:26:22 PM »
hi... again
i was wondering where if you know where i can change the month name
i use this extra line in the include.php
$output .= "<p class=\"dateformat\">".gmdate("d M Y", $data['posted_when']+TIMEZONE)."</p>\n";
but the date comes out in english, ex. 23 oct. ... and i want to change it to 23. okt.
i have looked in the language files, but can´t find it there - is it possible to change it
otherwise everything is working perfect now
......
www.sudurras1.com
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #187 on:
October 22, 2008, 12:42:02 PM »
You can use the function strftime() instead of gmdate().
Code:
$output .= "<p class=\"dateformat\">" . strftime("%d %B %Y",$data['published_when'])."</p>\n";
(example is using WB2.7
published_when
instead of WB2.6
posted_when
)
By default, it uses the locale settings of your php configuration.
For more info on how to tweak strftime and local languages, see:
http://www.php.net/strftime
Ruud
Logged
Professional WebsiteBaker Developer
babsy
Offline
Posts: 311
Re: Code Snippet: Display news items, anywhere
«
Reply #188 on:
October 22, 2008, 12:54:47 PM »
thanks
Logged
babsy
Offline
Posts: 311
Re: Code Snippet: Display news items, anywhere
«
Reply #189 on:
October 23, 2008, 02:53:04 PM »
there is one small problem with the wb 2.7 and anynews
the clock possibility in the news, does not work with anynews - meaning even if i choose that the a certain news, should not be shown until 8 pm .... it comes out in the anynews right away?
but it works fine on the news page, and dosn´t show up until 8 pm....
So if anyone has a solution, i would love to hear about it
Logged
kweitzel
Forum administrator
Offline
Posts: 6819
Re: Code Snippet: Display news items, anywhere
«
Reply #190 on:
October 23, 2008, 07:41:06 PM »
The snippet needs to be adjusted for that function to work. Currently it does not consider the times and/or dates.
cheers
Klaus
Logged
WebsiteBaker Org e.V. - for WebsiteBaker
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #191 on:
October 23, 2008, 09:52:37 PM »
Klaus is wrong here,
The current version of Anynews will respect the published date
and
time. Using exactly the same rules as the news service itself.
Check the version you are running.
Version 2.1
is the current one.
Ruud
Logged
Professional WebsiteBaker Developer
kweitzel
Forum administrator
Offline
Posts: 6819
Re: Code Snippet: Display news items, anywhere
«
Reply #192 on:
October 24, 2008, 04:20:29 AM »
Should have done some better research then
didn't actually check. Sorry about that ...
cheers
Klaus
Logged
WebsiteBaker Org e.V. - for WebsiteBaker
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #193 on:
October 28, 2008, 05:59:45 PM »
Quote from: Ruud on October 21, 2008, 01:33:30 PM
I missed one line you will need to have too:
Before testing the $url variable, it needs to be defined with something
Code:
$url = $_SERVER['REQUEST_URI'];
Ruud
Works like charm!
If you want to have the first 3 news with heading and short text
display_news_items(0,3,40,1)
and the next 10 wit just heading like
display_news_items(3,10,0,1)
, is it possible?
Anyway thanx alot for the code..
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #194 on:
October 28, 2008, 10:02:57 PM »
Quote from: Lotus on October 28, 2008, 05:59:45 PM
If you want to have the first 3 news with heading and short text
display_news_items(0,3,40,1)
and the next 10 wit just heading like
display_news_items(3,10,0,1)
, is it possible?
No, not without changing the any_news snippet code.
The snippet will always show the last n messages, it will not skip the first n.
Ruud
Logged
Professional WebsiteBaker Developer
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #195 on:
October 30, 2008, 09:00:28 AM »
Code:
<?php
$url
=
$_SERVER
[
'REQUEST_URI'
];
if (
function_exists
(
'display_news_items'
)) {
if (
strrpos
(
$url
,
"/en/"
)) {
display_news_items
(
1
,
3
,-
1
,
1
,
"Latest news"
,
"read more"
,
"No news available"
,
false
);
} else {
display_news_items
(
2
,
3
,-
1
,
1
,
"Laatste nieuws"
,
"verder lezen"
,
"geen nieuws beschikbaar"
,
false
);
}
}
?>
I noticed a small problem as the URL changes when you read a newspost the /en/ part dissapears. Then the script then shows the default news parts. Is trere any variable not shown in the URL that one can locate to know what newsgroup that you read from? When will I be able to do some PHP magic like you Ruud =)
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #196 on:
October 30, 2008, 09:51:18 AM »
You could decide to not show the anynews at all on the page where you are reading.
Replace the
} else {
with
} else if (strrpos($url,"/nl/")) {
.
(also a searchpage would not show a wrong language newsblock that way)
For the rest I cant tell what is in your URL unless I can see it
Ruud
Logged
Professional WebsiteBaker Developer
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #197 on:
November 04, 2008, 11:44:19 AM »
Nice! Got it to work..but when i view the page with all news "they" are back ofcource so doday I was thinking if the ?lang=SE part in the URL can be useful. So pages with ?lang=SE see this news and pages with ?lang=GB se that news? Possible?
Logged
Ruud
Board member
WebsiteBaker Org e.V.
Offline
Posts: 2093
Re: Code Snippet: Display news items, anywhere
«
Reply #198 on:
November 04, 2008, 11:58:27 AM »
I would just create a news page for every language. You can define per language-newspage where links will be linking to.
The lang=SE parameter is only available as a parameter when switching languages. There is a static variable LANGUAGE available within your template. That will hold the same value as the lang= parameter when switching languages.
Ruud
Logged
Professional WebsiteBaker Developer
Lotus
Offline
Posts: 184
Re: Code Snippet: Display news items, anywhere
«
Reply #199 on:
November 04, 2008, 12:06:57 PM »
I realize that this is vital information but I can not do anything with it, frustrating. Will RTFM =)
Thank you for pointing me in the right direction though but for now I stick with your code..it is the best thing I got.
Logged
Pages:
1
...
6
7
[
8
]
9
10
...
21
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
-----------------------------
English
-----------------------------
=> Help & Support
-----------------------------
General
-----------------------------
=> WebsiteBaker Website Showcase
-----------------------------
English
-----------------------------
=> Modules
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
-----------------------------
General
-----------------------------
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
-----------------------------
General
-----------------------------
=> Security Announcements
-----------------------------
Deutsch (German)
-----------------------------
=> Hilfe/Support
-----------------------------
General
-----------------------------
=> Documentation
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
=> Module & Snippets
-----------------------------
English
-----------------------------
=> Archive (posts up to 2007)
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Deutsch (German)
-----------------------------
=> jQuery
=> Tutorials
=> Templates & Design
-----------------------------
English
-----------------------------
=> jQuery
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
===> Suggestions
-----------------------------
Deutsch (German)
-----------------------------
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
===> Vorschläge
-----------------------------
English
-----------------------------
===> Software bugs
-----------------------------
Deutsch (German)
-----------------------------
===> Softwarefehler
=====> Module / Extensions
-----------------------------
English
-----------------------------
=====> Modules / Extensions
-----------------------------
Deutsch (German)
-----------------------------
===> Erfahrungs und Testberichte
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...