Hello eveyone havent posted in a while but i have a quick question for you guys.
You know P2L's articles. Is that a rss feed from the fourms.
If so how do you do it.
I have rss comming off of my forum but i cant get it like yours.
Mine i can either just have the topic title and make that a link to the topic.
Or i can have the topic title and then underneath it has the entire article.
So my real question is how do i make it so that it has the article title followed by a short summary of the topic, then a read more link / button.
Very simialr to P2L
Thanks everyone
Pixel2life's Article RSS Feed question...
Started by blinek, Oct 07 2005 07:44 PM
5 replies to this topic
#1
Posted 07 October 2005 - 07:44 PM
#2
Posted 07 October 2005 - 08:09 PM
Make a function to get the posts text, then limit it to how ever many characters you want. And then just add an <a> tag with a link to the rest of the post after the limited text.
Put that all into the <description> of the RSS feed...
If you need help with RSS feed in general, a google search wouldn't hurt. And you can look at php.net for more info on limiting text (more specifically the strlen and substr functions).
I also hear that invisionize might have a mod/hack to do the RSS feeds for you, i'm sure that's where they got theres (if not, jay wrote it himself).
Put that all into the <description> of the RSS feed...
If you need help with RSS feed in general, a google search wouldn't hurt. And you can look at php.net for more info on limiting text (more specifically the strlen and substr functions).
I also hear that invisionize might have a mod/hack to do the RSS feeds for you, i'm sure that's where they got theres (if not, jay wrote it himself).
#3
Posted 08 October 2005 - 03:50 PM
alright thanks for you help rc69
I dont 100 percent under stand what you said but ill take a looks around at those sites you gave me
Im still open to suggestions though
ok this is what i have:
articles_feed.php
xmlparser.php
Now as you guys already know im looking to shorten the lenght of the articles output
somewhere between 100-120.
Jay and rc69 have both given me some help but i have not understood what to do with it or where it goes. So can you please show me.
Thanks
~aeiko
I dont 100 percent under stand what you said but ill take a looks around at those sites you gave me
Im still open to suggestions though
ok this is what i have:
articles_feed.php
<?php
$xmlParser = xml_parser_create();
xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE);
xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, TRUE);
xml_set_element_handler($xmlParser, "opening_element", "closing_element");
xml_set_character_data_handler($xmlParser, "c_data");
$fp = file("http://www.domain.com/forums/index.php?act=rssout&id=1");
foreach($fp as $line){
if(!xml_parse($xmlParser, $line)){
die("Could not parse file.");
}
}
?>
<html>
<head>
<title><?php echo $channelInfo["title"]; ?></title>
</head>
<body>
<?php
foreach($itemInfo as $items){
echo "<img src='http://www.domain.com/images/bbcode/icon_10.gif'></img> <b><a href='".$items["link"]."'>".$items["title"]."</a></b><br />";
echo "<br> ".$items["description"]."<br /><br>";
}
?>
xmlparser.php
[QUOTE]
<?php
$counter = 0;
$type = 12;
$tag = "";
$itemInfo = array();
$channelInfo = array();
function opening_element($xmlParser, $name, $attribute){
global $tag, $type;
$tag = $name;
if($name == "CHANNEL"){
$type = 1;
}
else if($name == "ITEM"){
$type = 2;
}
}//end opening element
function closing_element($xmlParser, $name){
global $tag, $type, $counter;
$tag = "";
if($name == "ITEM"){
$type = 0;
$counter++;
}
else if($name == "CHANNEL"){
$type = 0;
}
}//end closing_element
function c_data($xmlParser, $data){
global $tag, $type, $channelInfo, $itemInfo, $counter;
$data = trim(htmlspecialchars($data));
if($tag == "TITLE" || $tag == "DESCRIPTION" || $tag == "PUBdATE" || $tag == "LINK"){
if($type == 1){
$channelInfo[strtolower($tag)] = $data;
}//end checking channel
else if($type == 2){
$itemInfo[$counter][strtolower($tag)] .= $data;
}//end checking for item
}//end checking tag
}//end cdata funct
?>
Now as you guys already know im looking to shorten the lenght of the articles output
somewhere between 100-120.
Jay and rc69 have both given me some help but i have not understood what to do with it or where it goes. So can you please show me.
printf("%s\n", substr($message, 0, 100));
if (strlen($message) > 99) {
printf(" ...");
}
Thanks
~aeiko
Edited by aeiko, 09 October 2005 - 07:34 AM.
#4
Posted 10 October 2005 - 06:16 PM
I've been looking into this also for one of my design sites. We recently updated our website and have to add articles and quick news manualy. This would be great to know if anyone can help do it.
Brom
Brom
Edited by Brom, 10 October 2005 - 06:17 PM.
#5
Posted 10 October 2005 - 06:32 PM
aeiko, on Oct 8 2005, 01:44 PM, said:
You know P2L's articles. Is that a rss feed from the fourms.
I'd hold off if I was you.
#6
Posted 10 October 2005 - 09:40 PM
Within articles_feed.php
<body>
<?php
foreach($itemInfo as $items){
echo "<img src='http://www.domain.com/images/bbcode/icon_10.gif'></img> <b><a href='".$items["link"]."'>".$items["title"]."</a></b><br />";
echo "<br> ".substr($items['description'], 0, 100)."<br /><br>"; // This line
}
?>
Look closely at $items['description'] for what i changed. It's a much simpler version of what you posted.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
