Recent Topics

1 Nov 26, 2006 07:02    

Hello

just want to include my ebay auction @ b2evo:


<?php 
   /* 
    * This is the template that displays myEbay for a blog 
    * 
    * This file is not meant to be called directly. 
    * It is meant to be called by an include in the _main.php template. 
    * To display the stats, you should call a stub AND pass the right parameters 
    * For example: /blogs/index.php?disp=impressum 
    */ 
   if(substr(basename($_SERVER['SCRIPT_FILENAME']),0,1)=='_') 
      die("Please, do not access this page directly."); 
    
   if( $disp == 'auction' ) 
   { ?> 

   <h1 id="pageTitle" align="left"><font color="#4081B7">Meine eBay Auktionen</font></h1> 


<?PHP 
	
	$ebayname="xankele"; 
	
	$file="http://rss.api.ebay.com/ws/rssapi?FeedName=SearchResults&siteId=77&language=de-DE&output=RSS20&fsop=1&fsoo=1&sass=".$ebayname;
?>

<body>
<div align="center">
<table width="728" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
	<td colspan="2"><h1>Meine Artikel bei eBay</h1></td>
</tr>

<tr valign="top">
	<td colspan="2"><?php include("rss.inc"); ?></td>
</tr>
<tr>

</table>

   <div class="clear"></div> 
       
   <?php 
   } 
?> 

File rss.inc:


<?php
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;
function startElement($parser, $name, $attrs) {
   	global $rss_channel, $currently_writing, $main;
   	switch($name) {
   		case "RSS":
   		case "RDF:RDF":
   		case "ITEMS":
   			$currently_writing = "";
   			break;
   		case "CHANNEL":
   			$main = "CHANNEL";
   			break;
   		case "IMAGE":
   			$main = "IMAGE";
   			$rss_channel["IMAGE"] = array();
   			break;
   		case "ITEM":
   			$main = "ITEMS";
   			break;
   		default:
   			$currently_writing = $name;
   			break;
   	}
}
function endElement($parser, $name) {
   	global $rss_channel, $currently_writing, $item_counter;
   	$currently_writing = "";
   	if ($name == "ITEM") {
   		$item_counter++;
   	}
}
function characterData($parser, $data) {
	global $rss_channel, $currently_writing, $main, $item_counter;
	if ($currently_writing != "") {
		switch($main) {
			case "CHANNEL":
				if (isset($rss_channel[$currently_writing])) {
					$rss_channel[$currently_writing] .= $data;
				} else {
					$rss_channel[$currently_writing] = $data;
				}
				break;
			case "IMAGE":
				if (isset($rss_channel[$main][$currently_writing])) {
					$rss_channel[$main][$currently_writing] .= $data;
				} else {
					$rss_channel[$main][$currently_writing] = $data;
				}
				break;
			case "ITEMS":
				if (isset($rss_channel[$main][$item_counter][$currently_writing])) {
					$rss_channel[$main][$item_counter][$currently_writing] .= $data;
				} else {
					$rss_channel[$main][$item_counter][$currently_writing] = $data;
				}
				break;
		}
	}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r"))) {
	die("could not open XML input");
}
while ($data = fread($fp, 4096)) {
	if (!xml_parse($xml_parser, $data, feof($fp))) {
		die(sprintf("XML error: %s at line %d",
					xml_error_string(xml_get_error_code($xml_parser)),
					xml_get_current_line_number($xml_parser)));
	}
}
xml_parser_free($xml_parser);
// output HTML
// print ("<div class=\"channelname\">" . $rss_channel["TITLE"] . "</div>"); 
if (isset($rss_channel["ITEMS"])) {
	if (count($rss_channel["ITEMS"]) > 0) {
		for($i = 0;$i < count($rss_channel["ITEMS"]);$i++) {
			if (isset($rss_channel["ITEMS"][$i]["LINK"])) {
			print ("\n<div class=\"itemtitle\"><a href=\"" . $rss_channel["ITEMS"][$i]["LINK"] . "\" target=\"_blank\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</a></div>");
			} else {
			print ("\n<div class=\"itemtitle\">" . $rss_channel["ITEMS"][$i]["TITLE"] . "</div>");
			}
			 print ("<div class=\"itemdescription\">" . $rss_channel["ITEMS"][$i]["DESCRIPTION"] . "</div><br />"); 		}
	} else {
		print ("<b>There are no articles in this feed.</b>");
	}
}
?>

Link http://www.snigles.de/index.php?disp=auction

It makes my skin completly damaged :( What could be wrong?

2 Nov 26, 2006 08:24

I don't know what happens when you do this, but you've got two body tags in there. Plus a table laying on top of background images might be part of it too. It might be that the forced table width is why the sidebar is popping down, but rather than fix that how about going a different way? Check out http://forums.b2evolution.net/viewtopic.php?t=9981 and see if that'll work for you. You can still read the feed, only dress them up like they were posts in a blog instead of cells in a table.

3 Nov 27, 2006 06:53

alright EdB ... sounds logical to me, but I do not know how to handle it in detail :(

4 Nov 28, 2006 00:58

I don't know if there are hooks to do this as a plugin - add a "disp=foo" page - so if not this is a good idea for a hook. Anyway if you want to try it as a hack then check out the hack post and see if you can't put together a simple "disp=auction" page using "auction_test" where that hack uses "something". In your _main.php file don't share the link publicly so you can test it. Instead do like this:

<?php if( is_logged_in() ) { ?>
<li><a href="<?php $Blog->disp( 'something', 'raw' ) ?>" title="link to something page"><strong><?php echo T_('Something') ?></strong></a></li>
<?php } ?>


Then follow the link and see if you get the "auction_test" page. If so we should be able to make it use your rss file to fill in content.

5 Nov 29, 2006 10:58

my file auction has the name: _auction.php
where in your code must I put that?

6 Nov 29, 2006 15:20

Assuming you hacked the three files you'll need to hack then it goes where I said to put "_something.php", which is in your skins/your_skin folder.

Your _auction.php file should not have all the stuff that web pages have. No header and no body tag. JUST the stuff of a post. Typically that means something like this:

<div class="bPost">
<h3>Here is my title</h3>
<p>Here is my content.  It is about whatever it might be about.</p>
</div>


Your situation will be slightly different in that you are converting an rss read into a webpage, but the basics will remain the same: your rss file needs to provide a page that looks like posts in a blog.


Form is loading...