Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
February 04, 2012, 06:31:06 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
.
149021
Posts in
21045
Topics by
7522
Members
Latest Member:
ThomasFrank
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
]
2
3
...
20
Go Down
Author
Topic: Code Snippet: Display news items, anywhere (Read 99622 times)
fienieg
Guest
Code Snippet: Display news items, anywhere
«
on:
February 27, 2005, 06:50:48 PM »
I made very rough code, that makes a listing of a specific group(id)
With the option of setting a "max results", and order them by date added. etc..
Just read the code, play with it. Refine it, restyle it.
Have fun..
Code:
<!-- NEWS READER -->
<?php
$group
=
0
;
// 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 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
&
#40;);
if &
#40;!$result = mysql_query($query)) {
print
"
$error
"
;
exit;
&
#125;
while&
#40;$data = mysql_fetch_object($result)){
$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
&
#125;
?>
<!-- END NEWS READER -->
Logged
mightofnight
Offline
Posts: 153
Code Snippet: Display news items, anywhere
«
Reply #1 on:
February 28, 2005, 10:27:17 PM »
Good Idea!
Logged
-Travis
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #2 on:
March 07, 2005, 12:19:55 PM »
I would LOVE to use this snippet, but I don't know how
When I copy the code into a Code module, it doesn't work. So I guess that is not the way it should be used... What is the right way to use this snippet?
And how do I have to use the Code module anyway? Can you just paste any HTML, JS, or PHP into it? I guess not, but I don't know how to use it properly...
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!
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #3 on:
March 07, 2005, 02:10:44 PM »
just place the snippet into your template... any where you want to display the latest news items...
Logged
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #4 on:
March 07, 2005, 02:14:53 PM »
So no code page thing....
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #5 on:
March 07, 2005, 03:36:39 PM »
OK, thanks. So snippets are template based, not page based? Is it possible to convert a snippet to a module? That way you can add it to pages without having to create another template for it, if you don't want to have it on every 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!
Argos
Moderator
Offline
Posts: 2083
YES!!!!
«
Reply #6 on:
March 07, 2005, 03:39:58 PM »
Very cool!! I tried it, and it works like a charm. I am very happy!!!
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!
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #7 on:
March 08, 2005, 02:00:19 AM »
Hm... I'm still happy, but I noticed a small problem. The listing in the snippet is chronological, in order of input. When I change the order of the items in the backend, the order on the news page changes too, so that is correct. But the order of the snippet listing isn't affected by the back end change. Can this be changed? I know the snippet listing is a light version of the normal news listing, but I would like it to be just bit heavier, so that it listens to changes in the back end...
You can see it on
http://www.bereikbaarheid.nl/cms
.
This is a site I am working on for a client. It is not operational yet, and a number of things are not finished yet. But the news listing is working. It's a Dutch site, but that shouldn't be problem to see what mean.
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!
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #8 on:
March 08, 2005, 07:28:00 PM »
Quote from: Argos
Hm... I'm still happy, but I noticed a small problem. The listing in the snippet is chronological, in order of input. When I change the order of the items in the backend, the order on the news page changes too, so that is correct. But the order of the snippet listing isn't affected by the back end change. Can this be changed? I know the snippet listing is a light version of the normal news listing, but I would like it to be just bit heavier, so that it listens to changes in the back end...
You can see it on
http://www.bereikbaarheid.nl/cms
.
This is a site I am working on for a client. It is not operational yet, and a number of things are not finished yet. But the news listing is working. It's a Dutch site, but that shouldn't be problem to see what mean.
Damn that template is looking nice... it's a beauty...
(and i'm dutch so i can read it
)
I made the news script, so all news items added to the database, and only the latest 5 are displayed... you can also make it, replacing, ORDER BY posted_when by ORDER BY position, then it's affected by the admin back end.
But this is just a little snippet i'll try to build one with more options...
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #9 on:
March 08, 2005, 08:23:55 PM »
Fienieg, you made my day by saying nice things (thanks!) and solving my little problem. Great, I appreciate it!!
Most of the times I can tweak scripts here and there, but I don't really understand why it works or not. Creating something myself is out of my league. What I do is based on limited insight, and much trial and error. I don't have real knowledge and skills, which is annoying. I really should learn at least the basics of PHP... If only I had the time
I will create some templates in the near future to give something back to the community. I have some designs from projects that didn't make it to the end, and some tryouts for myself. I can customize them into WSB templates.
By the way, your News script is in fact very useful, and I use it not only for posting news and events, but also as a FAQ. The FAQ Baker module is not very useful I think, because it's just a long list of entries. That's only useful if you have only a few questions. Your News module is perfectly usable for a FAQ that can grow larger over time. If you keep updating it, it will be a very powerful module indeed!
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!
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #10 on:
March 09, 2005, 12:51:11 AM »
your welcome...
we all contribute to WB, you may send me your works, and maybe i can turn them into some templates
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #11 on:
March 09, 2005, 03:41:32 PM »
Well, I will create them myself because they are not generally usable yet. They refer to clients, aren't really finished yet, or dont have the proper quality.
But you can also take a look at [
url removed becasue no longer in use
] where I sell templates memberships. If you can pick a few (no, not all!) that you feel may be usable as a basis for WSB templates, please let me know and I'll send them to you. But only for use as WSB templates that will be published freely! And I want my name/website mentioned in the html source.
By the way, I did not create these templates myself. Half of them were created by someone for me exclusively, and the other half were made by someone who I have made a template swapping deal with.
Only this one I created myself: [
url removed becasue no longer in use
] which I will transform into a WSB templaet myself.
«
Last Edit: July 15, 2008, 09:02:33 PM by Argos
»
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!
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #12 on:
March 09, 2005, 03:52:23 PM »
yeah i only
publish templates freely... and i leave name in the credits.
I'll just mention you in the credits section
these templates
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=108
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=81
http://www.templateserver.com/index.php?action=detail&cat_id=17&image_id=80
these 3 a could make into templates, for general use...
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #13 on:
March 09, 2005, 04:01:44 PM »
PM'd you...
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!
Stefan
Guest
Code Snippet: Display news items, anywhere
«
Reply #14 on:
March 15, 2005, 12:33:31 PM »
Quote from: Argos
You can see it on
http://www.bereikbaarheid.nl/cms
Do I see it correctly that you have written a Javascript menu that uses the WebsiteBaker page tree? If so, would you be willing to release it to the general public?
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #15 on:
March 15, 2005, 01:27:39 PM »
Quote from: Stefan
Quote from: Argos
You can see it on
http://www.bereikbaarheid.nl/cms
Do I see it correctly that you have written a Javascript menu that uses the WebsiteBaker page tree? If so, would you be willing to release it to the general public?
I wish I could do that
No, it's just a seperate DHTML menu I included in the template. All links must be made manually. In this case that is okey, because the client doesn't need to create pages or change the structure of the site. Only modify existing pages. And if he needs to have other pages, he can create them, but I have to add them to the menu...
Too bad it isn't a dynamically created menu, ain't it?
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!
Stefan
Guest
Code Snippet: Display news items, anywhere
«
Reply #16 on:
March 15, 2005, 02:22:12 PM »
Yeah, too bad really.
I've had a look at your javascript code - quite confusing with all the numbers, spacers and what not.
To make an automatically maintained menu, it is necessary to have a way of writing the entries without any individual hacks. So say, I give you a menu structure:
Top1
---T1Sub1
---T1Sub2
Top2
---T2Sub1
---T2Sub2
can you (manually) make a nice-looking dhtml menu out of that without any further information, hacks, etc. No tweaking allowed!
If so, it's no problem to make the transition to a true WB dynamical menu. I've just not looked into dhtml menus at all, otherwise I would've done it already.
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #17 on:
March 15, 2005, 02:35:19 PM »
Quote from: Stefan
Yeah, too bad really.
I've had a look at your javascript code - quite confusing with all the numbers, spacers and what not.
To make an automatically maintained menu, it is necessary to have a way of writing the entries without any individual hacks. So say, I give you a menu structure:
Top1
---T1Sub1
---T1Sub2
Top2
---T2Sub1
---T2Sub2
can you (manually) make a nice-looking dhtml menu out of that without any further information, hacks, etc. No tweaking allowed!
If so, it's no problem to make the transition to a true WB dynamical menu. I've just not looked into dhtml menus at all, otherwise I would've done it already.
Yeah, I know the code looks terribly complicated, but it is generated by the program I use:
http://www.sothink.com/webtools/dhtmlmenu/index.htm
Actually, it has the built-in option of creating menu's dynamically with PHP or other methods, but I am not a programmer so I don't really understand how I should do that
I like this software very much, I use it a lot. It's powerful and very user friendly, using a drop and drag, WYSIWYG way of creating menus. Rather cheap too: only 35 dollars. Maybe you could check it out...
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!
Stefan
Guest
Code Snippet: Display news items, anywhere
«
Reply #18 on:
March 15, 2005, 02:37:25 PM »
Well, it's not a solution for a standard WB dynamical menu if it's not free, but still, thanks for the tip.
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #19 on:
March 15, 2005, 02:48:27 PM »
Ah! I didn't realize you were looking for a free script to include in WSB
There are free dhtml menu available though, but I haven't tried them.
I've got
http://www.dynamicdrive.com/
in my bookmarks. They have some I know. And Google knows some as well
http://www.google.nl/search?hl=nl&q=free+dhtml+menu&lr=
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!
Stefan
Guest
Code Snippet: Display news items, anywhere
«
Reply #20 on:
March 15, 2005, 02:53:30 PM »
It's just that I don't have time to play around with it. Something is always the problem - either its compatibility or looks or whatever.
I was hoping you had found a good one that could be used. I would have just written the php part, which should be no big deal.
Logged
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #21 on:
March 15, 2005, 03:14:55 PM »
i also got one or two of those javascripts...
i'm fine tunning them...
Logged
Craig
Offline
Posts: 112
Code Snippet: Display news items, anywhere
«
Reply #22 on:
March 26, 2005, 02:41:09 AM »
Just a little update to the snippet...
If you want to put it into a Code section - you can, use this code below:
Code:
$group = 2; // 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, 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();
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 '<p><a href="'.WB_URL.$link.PAGE_EXTENSION.'">'.$title.'</a></p>';
}
It simply removes the <?php and ?> tags, and echos the link properly
Logged
Craig Rodway, IT Support, Bishop Barrington School.
fienieg
Guest
Code Snippet: Display news items, anywhere
«
Reply #23 on:
March 26, 2005, 05:34:30 AM »
thanks craig, but some level of understanding of WB is needed with the code snippets...
(dont make to easie for them
)
Logged
Argos
Moderator
Offline
Posts: 2083
Code Snippet: Display news items, anywhere
«
Reply #24 on:
March 26, 2005, 11:36:04 AM »
Quote from: fienieg
thanks craig, but some level of understanding of WB is needed with the code snippets...
(dont make to easie for them
)
What do you mean by that?
I tried this code snippet, and it works allright.
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!
Pages: [
1
]
2
3
...
20
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...