Start
Help
Forum
Addons
Projects
Welcome,
Guest
. Please
login
or
register
.
August 20, 2008, 05:14:13 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Website Baker 2.7.0 (stable) veröffentlicht!
Nähere Informationen findet ihr
hier
.
Das Diskussionsboard findet ihr
hier
.
60556
Posts in
9791
Topics by
5824
Members
Latest Member:
blubb
Website Baker Community Forum
English
Modules
Code Snippets
Would you like a free comic on your site?
Pages:
[
1
]
Author
Topic: Would you like a free comic on your site? (Read 2696 times)
Fratm
Apprentice Baker
Offline
Posts: 96
Would you like a free comic on your site?
«
on:
December 20, 2006, 12:15:51 AM »
There is a comic I enjoy reading at blaugh.com, they released an API that allows you to have a daily comic on your site, so I wrote a little code that you can insert into a Code page, and it will give you a daily comic, and some navigation to view previous comics.
(SEE CODE BELOW..)
Enjoy!!
«
Last Edit: December 20, 2006, 05:58:46 PM by Fratm
»
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #1 on:
December 20, 2006, 07:51:01 AM »
Nice script ... you just forgot to paste the "close" code of the last else-statement. Here is the corrected code (note the last line):
Code:
if (!$number) { $number=0;}
$previous = $_GET['h'] +1;
$next = $_GET['h']-1;
$comic_data = file_get_contents('http://blaugh.com/api/php/1.0/getcomic/'. $_GET['h']);
$comic = unserialize($comic_data);
if ($comic === false) {
die ('Could not get comic');
}
echo "<br><bR><br>";
echo "<center>";
echo "<table border='0'>";
echo "<tr>";
echo "<th>". $comic['title'] ."</th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<a href=\"". $comic['permalink'] ."\" title=\"". $comic['title'] ."\" >";
echo "<img src=\"". $comic['image_url'] ."\" alt=\"". $comic['title'] ."\" >";
echo "</a>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<table border=0 width=100%><tr>";
echo "<td><div style='text-align:left'><a href='/?h=". $previous ."' align=left>Previous </a></td>";
if ($next >= 0) {
echo "<td><div style='text-align: right;'><a href='/?h=". $next ."' align=right> Next </a></td>";
} else {
echo " <td><div style='text-align: right;'>Next</div></td>";
echo "</tr></table>";
echo "</td>";
echo "</tr>";
echo "</table>";
};
[Edit] Ahh ... yes and the previous/next links don't work in your code ..[/Edit]
cheers
Klaus
«
Last Edit: December 20, 2006, 07:56:19 AM by kweitzel
»
Logged
http://www.weitzel.biz
Fratm
Apprentice Baker
Offline
Posts: 96
Re: Would you like a free comic on your site?
«
Reply #2 on:
December 20, 2006, 05:49:49 PM »
Hmm Working on my site (
http://wbtest.adnd.com
)
Here is the exact code I used.. maybe I posted my beta code..
(See Code below..)
«
Last Edit: December 21, 2006, 03:52:14 PM by Fratm
»
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #3 on:
December 20, 2006, 07:03:56 PM »
maybe you did post a beta ... but still in this code the previous link does not work although the comic is beeing displayed ...
cheers
Klaus
Logged
http://www.weitzel.biz
Fratm
Apprentice Baker
Offline
Posts: 96
Re: Would you like a free comic on your site?
«
Reply #4 on:
December 20, 2006, 11:43:53 PM »
Quote from: kweitzel on December 20, 2006, 07:03:56 PM
maybe you did post a beta ... but still in this code the previous link does not work although the comic is beeing displayed ...
cheers
Klaus
The code I posted is exactly what I am using at
http://testweb.adnd.com
and it works there.. So maybe there is something else going on?
-Steve
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #5 on:
December 21, 2006, 09:02:20 AM »
and this is the code I tried ... check out the previous link here:
http://www.weitzel.info/nethome/pages/en/daily-comic.php
cheers
Klaus
Logged
http://www.weitzel.biz
Fratm
Apprentice Baker
Offline
Posts: 96
Re: Would you like a free comic on your site?
«
Reply #6 on:
December 21, 2006, 03:51:29 PM »
I know what's wrong.. And here is the code that fixes it (I hope).
Code:
if (!$number) { $number=0;}
$previous = $_GET['h'] +1;
$next = $_GET['h']-1;
$comic_data = file_get_contents('http://blaugh.com/api/php/1.0/getcomic/'. $_GET['h']);
$comic = unserialize($comic_data);
if ($comic === false) {
die ('Could not get comic');
}
echo "<br>";
echo "<center>";
echo "<table border='0'>";
echo "<tr>";
echo "<th>". $comic['title'] ."</th>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<a href=\"". $comic['permalink'] ."\" title=\"". $comic['title'] ."\" >";
echo "<img src=\"". $comic['image_url'] ."\" alt=\"". $comic['title'] ."\" >";
echo "</a>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
echo "<table border=0 width=100%><tr>";
echo "<td><div style='text-align:left'><a href='". $_SERVER['SCRIPT_NAME'] ."?h=". $previous ."' align=left>Previous </a></td>";
if ($next >= 0) {
echo "<td><div style='text-align: right;'><a href='". $_SERVER['SCRIPT_NAME'] ."?h='". $next ."' align=right> Next </a></td>";
} else {
echo " <td><div style='text-align: right;'>Next</div></td>";
}
echo "</tr></table>";
echo "</td>";
echo "</tr>";
echo "</table>";
The code was assuming 2 things.. 1) that you were calling this up from your first page, and 2) that your first page lived at / I changed it to get the actual script name that called it, and to use.. should work now.. sorry about the mess ups..
By the way, I run a small wiki, which is not publicly editable, I document my projects in there, and for this one I gave a special thanks to you for your help, I also put a link to your web site.. Thanks =)
http://www.fratm.com/index.php/Blaugh_php_api_code
-Steve
«
Last Edit: December 21, 2006, 04:02:12 PM by Fratm
»
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #7 on:
December 21, 2006, 06:40:03 PM »
yep, that is it working now ... ready for release (Ever thought about a pagetype module for this kind of thing?)
cheers
Klaus
Logged
http://www.weitzel.biz
Fratm
Apprentice Baker
Offline
Posts: 96
Re: Would you like a free comic on your site?
«
Reply #8 on:
December 21, 2006, 07:48:24 PM »
Quote from: kweitzel on December 21, 2006, 06:40:03 PM
yep, that is it working now ... ready for release (Ever thought about a pagetype module for this kind of thing?)
cheers
Klaus
Actually, funny that you mentioned it.. I was just thinking about doing that.. Maybe over Xmas break I will write one up.
-Steve
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #9 on:
December 21, 2006, 09:02:46 PM »
Maybe design it from the beginning on, so that other comics can be added. A Friend of mine used to manually parse some sites (like dilbert) in Lotus Notes Script
But I take it, those sites could be parsed with curl (But be aware, that not every serverconfiguration supports CURL ... so in the beginning don't limit your Audience ...
cheers
Klaus
Logged
http://www.weitzel.biz
Fratm
Apprentice Baker
Offline
Posts: 96
Re: Would you like a free comic on your site?
«
Reply #10 on:
December 21, 2006, 09:17:38 PM »
Quote from: kweitzel on December 21, 2006, 09:02:46 PM
Maybe design it from the beginning on, so that other comics can be added. A Friend of mine used to manually parse some sites (like dilbert) in Lotus Notes Script
But I take it, those sites could be parsed with curl (But be aware, that not every serverconfiguration supports CURL ... so in the beginning don't limit your Audience ...
cheers
Klaus
Yeah, maybe in version 2 =) This one is using the Blaugh API at
www.blaugh.com
.. Here is the first attempt at a module. (Works on my test page...)
Logged
kweitzel
Forum Team
A Baker's Baker
Offline
Posts: 4214
Re: Would you like a free comic on your site?
«
Reply #11 on:
December 22, 2006, 06:54:03 AM »
Just had a go on a XAMP System, does everything it needs to
Installation, Page and Deinstalation OK. Will check on a different system (LAMP) later on ...
cheers
Klaus
Logged
http://www.weitzel.biz
Pages:
[
1
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Announcements
===> Security Announcements
=> Guest Area and Off-Topic
=> Website Showcase
-----------------------------
English
-----------------------------
=> Help/Support
===> Help/Support of WB2.7.x core
=> Website Baker Development
===> Website Baker 3
=> Documentation
=> Templates
=> Modules
===> Code Snippets
=> Languages
=> Archive
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
===> Templates, Module & Co.
===> Hilfe/Support von WB2.7.x core
=> Diskussion über WB
=> Off-Topic
=> Archiv
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Help / Support
===> WB Core
===> Templates, Modules & Languages
=> WB Discussie
=> Niet-Terzake (Off Topic)
-----------------------------
French
-----------------------------
=> Help/Support
-----------------------------
Italian
-----------------------------
=> Help/Support
Loading...