Embedding the Forum phpBB3 into an iFrame on my website

Do you want to share WYSIWYG Web Builder tips, tricks, tutorials or useful HTML code? You can post it here...
(no questions or problems please, this section is not monitored by support).
Forum rules
This section is to share tips, tricks and tutorials related to WYSIWYG Web Builder.
Please do not post questions or problems here. They will not be answered.

PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
Post Reply
User avatar
alex4orly
 
 
Posts: 558
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Embedding the Forum phpBB3 into an iFrame on my website

Post by alex4orly » Fri Jun 01, 2018 10:55 pm

I will start by saying, Thank-you Pablo...

I don't say it is the ONLY way to do this, nor the best... but this is the way I figured out, after a lot of trial and error, and it works. So, I thought maybe someone else here on the forum can benefit from it.

Firstly, I renamed the page called "viewtopic.php" to "showtopic.php" so that I can have control of the actions taken when a forum member clicks on the link in his email - for example:

http://beleuramyhome.org.au/phpBB3/view ... ead#unread

If you click on such a link in your email, it will take you to the relevant page, BUT - outside of your website...
My challenge was to embed it - within... and I used an iFrame for that

// In the replacement page - viewtopic.php at the top

Code: Select all

<?php
   session_start();
   
   // Get the URL passed into the page
   $uri    = $_SERVER['REQUEST_URI'];

   // I just need the URL arguments, so strip off the URL itself
   $str    = substr($uri, 22);  
 
   // Feed the arguments into a session variable
   // I tried using the $str, but didn't work for some reason
   $_SESSION['params'] = substr($uri, 22);
   
   // Prepare for a redirect to my website page - with the iFrame in it
   $newpage = "http://www.beleuramyhome.org.au/iframeurl.php?";

   // Add the URL arguments
   $newpage .= $str;
   
   // Use this to redirect, because the URL is an argument and can't 
   // be hard coded. That's why I couldn't use the header() function...
   echo '<META HTTP-EQUIV="Refresh" Content="2; URL='.$newpage.'">';   
?>
// In the target page - iframeurl.php, where the iFrame is, at the top of the page

Code: Select all

<?php
   session_start();
   
   // Get the URL passed in from the first step
   $uri    = $_SERVER['REQUEST_URI'];   
   // Strip the URL itself, I need only the arguments
   $_SESSION['params'] = substr($uri, 15);
?>
// In the same page, between the <head> section, I inserted this Javascript function

Code: Select all

<script>   
   
   // This function is called on page load
   window.onload = function()
   {
	  // I will redirect the content into the iFrame, pointing to the 
	  // new page created at the begining 
      var url = "http://beleuramyhome.org.au/phpBB3/showtopic.php?"; 
	  // Get the Session arguments
      var args = "<?php echo $_SESSION['params'] ?>";
	  // Add those to the URL
      url += args; 
      // The actual job of inserting it into the iFrame
      document.getElementById("InlineFrame1").setAttribute("src", url);
	  
	  // Try this URL to see how it works
	  // http://beleuramyhome.org.au/phpBB3/viewtopic.php?f=6&t=3&e=1&view=unread#unread
   }
</script>
Last edited by alex4orly on Sat Jun 02, 2018 8:49 pm, edited 1 time in total.

User avatar
BaconFries
 
 
Posts: 4189
Joined: Thu Aug 16, 2007 7:32 pm

Re: Embedding the Forum phpBB3 into an iFrame on my website

Post by BaconFries » Fri Jun 01, 2018 11:13 pm

Since this is a 'Tip' for others on how to achieve I have moved to the following: WYSIWYG Web Builder Tips, Tricks, Tutorials and Code Examples

User avatar
alex4orly
 
 
Posts: 558
Joined: Mon Jan 20, 2014 8:17 am
Location: Australia
Contact:

Re: Embedding the Forum phpBB3 into an iFrame on my website

Post by alex4orly » Fri Jun 01, 2018 11:14 pm

Thank you,
I was looking for that forum and d it

Cheers

User avatar
BaconFries
 
 
Posts: 4189
Joined: Thu Aug 16, 2007 7:32 pm

Re: Embedding the Forum phpBB3 into an iFrame on my website

Post by BaconFries » Fri Jun 01, 2018 11:16 pm

Thanks for sharing this Alex. I think others will find it useful... it might even be possible to skin it with a simliar colour theme to there own sites so that it blends nicely.

User avatar
Pablo
 
Posts: 14514
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: Embedding the Forum phpBB3 into an iFrame on my website

Post by Pablo » Sat Jun 02, 2018 6:47 am

Thanks for sharing your solution!

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests