I've been trying to look for the bit of code that does this but alas, I am not knowledgable enough. I've read multiple sites on RSS and none really say how to "decode" RSS into a webpage, they just tell you to get a reader.
I know nuke can "decode" it because its an option of the blocks. Reason I want to know where the piece of code (pieces of code) are is because I am interested in adding RSS elsewhere on the site (In a Content Page) without having to use blocks. I've asked that question before but no answer or at least an answer I could identify as a solution hence maybe if someone knows where the code is I could fiddle with it myself?
Any help at all would be appreciated. Thanks for your time.
Ok lets back up. You wanted to insert some java Scr+pt to echo out rss feeds into Content pages.
You won't be able to do this without hacking the content module because nuke doesn't allow java to be inserted through the control panel for security purposes.
To echo out the code Raven gave you one example of how to do that. Is there some reason you have to use the content module for this? If would be much simpler for you to create a genric module of your own.
Something like this:
Code:
if (!eregi("modules.php", $_SERVER['Scr+pt_NAME'])) {
die ("You can't access this file directly...");
}
$mycontent .= "
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=5\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=2\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=3\"></Scr+pt>
<Scr+pt language=JavaScr+pt src=\"./modules.php?name=Syndication&file=index&ac=box&ac2=5&ac3=4\"></Scr+pt>
";
echo "$mycontent";
The same concept could be used in the content modules pages too but how you connect to what feeds on what pages would take some more code. As would the code Raven directed you to originally.
Ok I formatted everything safely and still sentinel won't let me post BBcoded scripts etc.. This issue is very important to me. If not to get it to work to at least understand more of the problem. Is there ANY way we could communicate aside from this board? Anyone? I simply have been unable to post the reply. I still have it on a text document.
hmmmm I've tried wording this like if I was talking to a child and still it won't let me post.. saying that I am attacking the site.. What on earth is the problem? Could I maybe post the file or perhaps give a link to it for someone to help me? I am just trying to have a discussion about this and the d***ed forum isn't letting me.
I have typed a text file that has the post I've been trying to get in here for who knows how long today.... of course.. right click and save target as since it will probably process the some of the code examples if you just click on it.
Only registered users can see links on this board! Get registered or login to the forums!
SRC="http://eqlive.station.sony.com/includes/js_news/eq_headlines.jsp"></scr+pt>
<noscr+pt>The EverQuest Live news requires you to have Javascr+pt turned on.</noscr+pt>
_JSCODE_;
echo$someVarName;
?>
Is that syntax correct? I tried it and says html tags not allowed.
So, I am in a bind I am unsure of whats wrong. Was I supposed to edit the Content Module
php file to have that in it? If I did that, wouldn't every content page do the program?
The rest of that post goes onto explain how to do it in a block, which at this time I am
not interested in.
Moving onto me HAVING to use the content module for this. No, I don't have to use that
specific module. The reason I had, was that when you create content pages, it dispalys it
exactly how I'd like my RSS feeds to be dispalyed. One big table on the righ of the left
blocks. So that moves me to your example.
Code:
if (!eregi("modules.php", $_SERVER['Scr+pt_NAME'])) {
die ("You can't access this file directly...");
}
$mycontent .= "
<Scr+pt language=JavaScr+pt
<?php // Turns php parser on
//These 3 lines are as you say security
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
$mycontent .= "
// Use any html content here escape all double quotes like this \"
<Scr+pt language=JavaScr+pt
src=\"./modules.php?name=Syndication\"></Scr+pt>
"; // ends mycontent
OpenTable(); // Opens a genric table
echo "$mycontent"; //Prints content above to browser
CloseTable(); // Closes the genric table
?>
Put this into its own directory modules/Your_module_name/ as index.php and if you had the syndication module it would print out in a table in the middle of your page.
I hope this helps a little. If you are still confused you should check out the
Only registered users can see links on this board! Get registered or login to the forums!
pages there is really very little not covered there.
well I'll be a rock... that alone helped immensly... gonna try it out and post results so you can be proud of me... and seriously.. thx for your help! Did not mean to be such a burden. Now, lets see if I can post results.. BUWAHAHAHAHA
Ok let me get this straight.. this module above is basically a module made to display another module? which means I'd have to build a module that could take an RSS link feed and and decipher it? If that is so then I understand. I do not however understand how in either HTML or php to "decipher" an RSS. Is there any "generic" php or html code to do that? Or am I not getting it?
Ok I found something about Displaying an RSS feed with PHP. Can someone take a look and tell me if this is something that would be compatible to do with nuke in a self made module?
Code:
Parsing an RSS document
Now that you have an understanding of RSS document structure, let's take a look at some code that will parse and display it.
The following code is a collection of five functions that were added to the Code Gallery by uncleozzy. We will take a look at them one by one and examine how they work.
Globals
The functions we are about to look at require some variables in the global scope. The first thing that must be done is to declare and initialize those variables.
$_item = array();
$_depth = array();
$_tags = array("dummy");
/* "dummy" prevents unecessary subtraction
* in the $_depth indexes */
Function initArray()
This function initializes the $_item array by ensuring that all the proper keys are in place and that they all point to an empty string. The author makes very liberal use of this function.
This function will be called each time an opening tag is found for an image, item, or channel. It is also used after the closing tag of each and at the onset of the entire parsing routine. (This may be tending towards overkill.)
Function startElement()
When using the XML functionality of PHP, you must specify a function to be called each time an opening tag is encountered. This function serves that purpose.
As you can see by examining this function, if an opening tag is found for an item, channel, or image element, the initArray is called. Then, whether one of those opening tags was found or not, the $_depth array is incremented and the name of the opening tag is pushed onto the $_tags array.
Function endElement()
Just as you must specify a function to be called for opening tags, you must also specify a function that is called when a closing tag is found. The endElement function handles the actual display of our data. As each closing tag is encountered, this function displays the data that corresponds to that tag. First though, it pops the top element off of the $_tags array, then it decrements the $_depth array. As mentioned earlier, it also calls the initArray function after displaying the pertinent data.
case "CHANNEL":
echo "<h3>{$_item['TITLE']}</h3>\n";
initArray();
break;
}
}
Function parseData()
This function is where the data is actually stored into the $_item array. When there is data that needs to be parsed, this function is invoked. Data is basically anything that is not an element tag.
The first thing this function does is determine if the data is only whitespace. If it is, it does not bother to store it in the array. If the data does contain useful information, it is stored in the $_item array.
{
global $_depth, $_tags, $_item;
$crap = preg_replace ("/\s/", "", $text);
/* is the data just whitespace?
if so, we don't want it! */
if ($crap) {
$text = preg_replace ("/^\s+/", "", $text);
/* get rid of leading whitespace */
if ($_item[$_tags[$_depth[$parser]]]) {
$_item[$_tags[$_depth[$parser]]] .= $text;
} else {
$_item[$_tags[$_depth[$parser]]] = $text;
}
}
}
Function parseRDF()
This function is the wrapper function for all the others. When using this function, you do not need to worry about calling any others.
It starts off by creating the parser, and then it calls the initArray function. The functions for handling the opening and closing tags, and the data itself, are then registered. Next, the function proceeds to open the file specified, parse it, and verify that it is a valid RSS document. The file is then closed and the memory from the parser freed.
{
global $_depth, $_tags, $_item;
$xml_parser = xml_parser_create();
initArray();
/* Set up event handlers */
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "parseData");
/* Open up the file */
$fp = fopen ($file, "r") or die ("Could not open $file for 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)));
}
}
fclose($fp);
xml_parser_free($xml_parser);
}
Example Use
As I mentioned earlier, using this set of functions is as easy as calling the parseRDF function. All you need to do is pass a URL for the RSS document, or a path to a local file..
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum