Forum Moderators: open
and it is working fine. Using this method, I install two "subpages" which support the eventual public page, the feed.php and itemlist.html pages.
Now I want to install different feeds on 7 different pages on my site. Do I need to make pages feed1.php through feed7.php and itemlist1.html through itemlist7.html to support these individual feeds or is there a more effective way to accomplish this objective?
Thanks for the help so far. Finally I am making progress and it feels great!
Create one feed.php page to handle multiple feeds when requested. You might need to pass an appropriate value to it via a GET method (URL query) however that would be the way I'd do it. It would save a lot of recoding the same thing but changing a few specific values.
Would I enter the entire feed.php code into my public page instead of accessing it in the current way? If no, how would I set it up? Also, what about the "itemlist.html" page. That has a title I need to change with each page. Can I make it with a query too?
As far as modifications go for the feed.php file, I would do the following:
Remove this line:
$url = "http://rss.example.com";
Change this line:
$feedhtml = $tpl->fetch($_SERVER["DOCUMENT_ROOT"].$mydir."/templates/itemlist.html");
To something like this:
$feedhtml = $tpl->fetch($_SERVER["DOCUMENT_ROOT"].$mydir."/templates/" . [b]$template[/b]);
Now, in whatever page you are going to be including this feed.php file from, you have to first make sure to define a few variables. Now, statically it would look something like this:
# Declare the variables before the include
$url = 'http://rss.example.com';
$template = 'temp.html';
include_once('feed.php');
For multiple feeds, however, you are going to want both the template and the URL to be changeable. From what I've read, you are going to be submitting a form for this, so maybe out of a few possible RSS feed options, you could have something like the following:
$feeds = array('example1' => array('http://rss.example1.com', 'temp1.html'),
'example2' => array('http://rss.example2.com', 'temp2.html'),
'example3' => array('http://rss.example3.com', 'temp2.html')
);
# Then, assuming the POSTed data comes in at $_POST['feed']
# check to see if the submitted feed is in array
if(in_array($_POST['feed'], $feeds)) {
$url = $feeds[$_POST['feed']][0];
$template = $feeds[$_POST['feed']][1];
include_once('feed.php');
} else { # error
echo 'You have submitted an incorrect feed. Please try again.';
}
This should at least get you started if nothing else. I just wrote this up real quick without testing it so I hope it does actually work. good luck :)
if(in_array($_POST['feed'], $feeds)) {
To this:
if(array_key_exists($_POST['feed'], $feeds)) {
Posting at 5am does that to ya ;)