TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 12, 2024, 07:29:29 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,188
  • Total Topics: 21,220
  • Online today: 109
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 1
  • Guests: 107
  • Total: 108
  • tino

Latest Comic

Started by onicat, August 04, 2008, 01:18:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

onicat

Is there a php script to pull the lastest comic from a comicpress website and display it on the front page of a smf/tp website?

I wam wanting to put a comic up on my website. I have it set up on http://akcommunity.com is the test site we are working with, and http://akcommunity.com/Comic is the site for comic.

We have tried the rss feed option. But that pulls ALL. If there was a way to only pull the most recent comic posted that would be cool.

Does any body have any suggestions as to how I could pull the most recent comic from the /Comic site to the akcommunity.com site and display it on the front page?

IchBin

Only if the comic site has given you an RSS feed or something to grab the latest comic with.

onicat

Could you go into more detail on your response please.

IchBin

The comic site has to give you a way to get the information. The way its done today is usually through some time of interface or webservice. RSS feeds provide this information IF, and only if the website you want to pull the information from GIVES you an RSS feed. The RSS feed (a link they give you) can then be added as an RSS type block in TP which will automatically display what they put in the RSS feed.

onicat

Yeah, I understand how the RSS feed function works.  The specifics of the problem I'm trying to surmount are as follows:

I have a SMF+TP community web site, and the community in question is now producing its own webcomic.  So, I installed a subdirectory to the main site that contains a WordPress+ComicPress site that I intend to use to archive and display the comics in a reasonable fashion.  ComicPress does support a RSS feed, but by default the feed pulls ALL of the archived comics, orders them in descending order by date, and then outputs them.  If you use the RSS function of TP to display this feed, you end up with one long post with every single comic displayed in it.

That's nice, but not what I'm after.  All I want is to display the most recent comic at the top of the front page of the TP+SMF site.  I have absolutely no experience with RSS, and only minimal experience with PHP, so I'm here looking for help with this.  After scouring the internet (mostly this site), I've found one mod that supports WordPress blogs as an inline frame, but because its meant to display just a text blog, it naturally only displays text and not the image associated with it.

So, I need some help.  Either I need to create a modified RSS feed for ComicPress that only displays the latest comic, or I need to come up with a PHP block that does the same.  Re-using the PHP from the ComicPress theme just doesn't work because it draws on functions from like a dozen other files, and I can't figure out how to incorporate all that in a PHP block in a manner that works.   I understand the functions its using (it converts the post into a date, then uses the date to look for the image file and display it), but I can't figure out how to bring them together in the right way to make it work.

I understand that this is TinyPortal support and not ComicPress/WordPress support, but does anyone have any suggestions I can try?

JPDeni

The rss feed is usually an xhtml file. I don't have any experience with them exactly, but I know they're in a specific format. The trick is to read the format.

I'm in the process of moving four websites at the moment, but I'll take a look at the code for reading rss and see if I can figure out how to adapt it to just read one entry.

IchBin

Can you show us the RSS feed? You can possibly use a third party RSS feed reader to parse the RSS feed for you, and control the results. Just a couple to look at if you'd like.
http://www.tinyportal.net/index.php?topic=14424

onicat

WordPress uses a PHP script to generate the feed.  The feed itself is here.  This is the code that generates it:

<?php
/**
 * RSS2 Feed Template for displaying RSS2 Posts feed.
 *
 * @package WordPress
 */

header('Content-Type: text/xml; charset=' get_option('blog_charset'), true);
$more 1;

?>

<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'?>

<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
<?php do_action('rss2_ns'); ?>
>

<channel>
<title><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
<link><?php bloginfo_rss('url'?></link>
<description><?php bloginfo_rss("description"?></description>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000'get_lastpostmodified('GMT'), false); ?></pubDate>
<?php the_generator'rss2' ); ?>
<language><?php echo get_option('rss_language'); ?></language>
<?php do_action('rss2_head'); ?>
<?php while( have_posts()) : the_post(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php the_permalink_rss() ?></link>
<comments><?php comments_link(); ?></comments>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000'get_post_time('Y-m-d H:i:s'true), false); ?></pubDate>
<dc:creator><?php the_author() ?></dc:creator>
<?php the_category_rss() ?>

<guid isPermaLink="false"><?php the_guid(); ?></guid>
<?php if (get_option('rss_use_excerpt')) : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php else : ?>
<description><![CDATA[<?php the_excerpt_rss() ?>]]></description>
<?php if ( strlen$post->post_content ) > ) : ?>
<content:encoded><![CDATA[<?php the_content() ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss() ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
<wfw:commentRss><?php echo get_post_comments_feed_link(); ?></wfw:commentRss>
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
<?php endwhile; ?>
</channel>
</rss>


Obviously that's drawing on a bunch of functions that are defined in another file.  I can list its contents if you feel like it will help. 

I have the option of writing my own feed.php and using that (via the Feed Wrangler plugin), but I don't know the first thing about how to go about doing that.

Ianedres

O-cat,

There are ways to get daily images from a website besides RSS, if you understand the naming scheme used- keyword being 'daily'.

However, it may violate the owner's copyright and licensing terms should you use something like this script, unless you have some type of agreement with the site. This is a very rudimentary script I wrote years ago while trying to learn php.

<?php

function image_get($comic$divname$imagetype)
{
echo $comic '<br />';

$imagedir 'http://images.ucomics.com/comics/';

$currentyear date("Y");
$currentday date("ymd");

$link $imagedir $divname '/' $currentyear '/' $divname $currentday '.' $imagetype;

echo '<img src="' $link '" \><hr />';
}


// Non-Sequitor
$comic 'Non-Sequitor';
$divname 'nq';
$imagetype 'gif';

image_get($comic$divname$imagetype);

// Nine To Five
$comic '9 To 5';
$divname 'tmntf';
$imagetype 'gif';

image_get($comic$divname$imagetype);
?>

onicat

Copyright has nothing to do with it this time, I own both sites and the images in question.

Your script, as you pointed out, only works for daily updates.  This comic is updated...kinda weekly.  We're still hammering that one down.  =)

I'm working with SimplePie and the Dynamic Drive DHTML script right now, but darned if I can get it to work!