Page 1 of 1

Hyperlink to page with include from php script

Posted: Tue Apr 01, 2008 2:34 pm
by Lucy
I have a news page that dynamically updates from an RSS feed using php.
I want each blog entry to generate on a template page if I click on a link from the entry's title.


At the moment it links to a page outside of my website - so I want a template that will <? include the external html page*.

However, the link format from the new page is wrong - so I've written a php script that converts the incorrect link to a correct one (looked over code for the RSS php and I'm pretty sure it's a Google thing and not something I can fix through that script).


So, what I need is:

A link that will send a static value (generated by the RSS php) to the conversion script and then bring up an html page with the result of the conversion script included in it.


That probably makes very little sense. 8O


*It's not actually an html page, it's the link to the RSS entry.
I will think about how to actually display the RSS later!
And I have tried adding the conversion to the RSS php but failed with that.

Re: Hyperlink to page with include from php script

Posted: Tue Apr 01, 2008 2:38 pm
by John Cartwright
That probably makes very little sense. 8O
Correct. :P

maybe if you posted an example

Re: Hyperlink to page with include from php script

Posted: Tue Apr 01, 2008 2:48 pm
by Lucy
Mmmm, it's quite complicated and messy, you see!

Give me a few minutes to figure how to explain. :?

Re: Hyperlink to page with include from php script

Posted: Tue Apr 01, 2008 3:00 pm
by Lucy
Well I have two RSS feeds that are merged into one and converted into HTML via a php script. The php script uses an HTML template and is included into my news.php page.

The HTML template looks like this:

<BODY>
<H1>~~~FeedTitle~~~</H1>
<H2>This feed is a combination of our News blog and the best bits from our Technology blog. To see the two blogs separately</H2>
<TABLE width="100%">
~~~BeginItemsRecord~~~
<TR>
<TD>
~~~ItemPubShortDate~~~ ~~~ItemPubShortTime~~~
</TD>
</TR>
<TR>
<TD>
<B><A href="~~~ItemGuid~~~">~~~ItemTitle~~~</A></B>
</TD>
</TR>
<TR>
<TD>
~~~ItemDescription~~~
<BR><br><br>
</TD>
<BR>
</TR>
~~~EndItemsRecord~~~
</TABLE>
</BODY>


As you can see, the php script inserts the different bits of RSS into the template (everything inbetween ~~~BeginItemsRecord~~~ and ~~~EndItemsRecord~~~ is duplicated for each entry).


At the moment the ItemGuid taken from the RSS script can't be used as a hyperlink as it's in this format:
tag:blogger.com,1999:blog-7429518092685469770.post-961602106155280416

So I have a script that converts it into this:
http://www.blogger.com/feeds/8726257680 ... 4040822617


Script is as follows:

Code: Select all

<?php 
 
$link = "tag:blogger.com,1999:blog-7429518092685469770.post-961602106155280416";
 
$blogID = substr($link, 26, 19);
$postID = substr($link, 51);
 
$orgstring = "http://www.blogger.com/blogID/posts/default/postID";
 
$string1 = str_replace("blogID", $blogID, $orgstring);
$string = str_replace("postID", $postID, $string1);
 
?>

$string is the new hyperlink.
$link I need to be taken from the news.php page.


So I need to edit the above template HTML file (it can't have any php in it, by the way, or the RSS > HTML script won't work) so that the ~~~ItemTitle~~~, when clicked, posts the ~~~ItemGuid~~~ to my php script and opens a new page with an <? include for $string.


Hope that's more clear.
Does that sound at all possible?