Wrapper Component in Joomla Downloads File on Firefox and Chrome Instead of Displaying it

One of the little used Joomla official extensions out there is the wrapper component. The wrapper component has a very simple job to do: it includes a page from another website (or even from your website) into a page on your Joomla website. For example (this is just an example – yes, we know it’s not a great example – but we’ve seen it several times so far), let’s say that you run multiple businesses, and each of these businesses has a website – but they all share the same “Our Company” page. So, instead of creating an “Our Company” page for each and every website, you just create a file called “our-company.html” in one of the websites, and then create a menu item of type wrapper pointing to that page. Once you do that, the external page is loaded into your website (inside an iFrame). As you can see, this is really easy!

There are two advantages to using a wrapper:

  1. Consistency: You will not end up with several versions of the exact same page (one for each website).
  2. Ease of update: If you ever need to update the content of a global page, you will only need to do it in one place.

Of course, you can include any page from any website on your website (the included page doesn’t have to belong to you) – in fact, a very common use of wrappers is to include a form on another website (such as a newsletter form or a customized registration form).

While wrappers do look very interesting and easy to use, they have some disadvantages:

  • Some websites block other websites from displaying their content within iframes: Many system administrators/developers block their websites from being iframed by using a simple JavaScript code. There is also a method to block iframes via the .htaccess file. It is important to mention though that both methods are not 100% efficient.
  • If the included page is hacked, then the host website (e.g. your website) will be considered as hacked: Google not only checks the JavaScript code on your website for cleanliness, it also checks the JavaScript file of all the included files in your page – even if these files reside on totally different servers and do not belong to your website. If you’re including a hacked page from another website on your website, then your website will be flagged in Google’s search engine results and it may be potentially delisted if you don’t remove the wrapper.

  • A wrapper can break the look & feel of your website: Don’t expect Joomla to be that smart and automatically apply your stylesheet to the included page. The page will be included as is, meaning the colors, the layout, the fonts, etc… will be those of the source website and they may or may not match the look & feel on your website (in most cases they won’t).

  • You cannot change the wrapper’s content using Joomla plugins: Joomla system plugins are usually used to modify any content on a Joomla website – however, since the wrapper’s content is usually loaded by the browser and not processed by the server, there is no (easy) way to make system plugins read and modify the content of that wrapper prior to display.

Now after this introduction to wrappers (as well as their advantages and disadvantages), let us talk about the Joomla problem we faced today…

One of our customers called us and told us that he made a wrapper that includes a static HTML page on his website. The wrapper, however, only worked properly on Internet Explorer, but on Firefox and Chrome the HTML file was being downloaded instead (or the user was being prompted to download the file). That was very odd!

We did a lot of experimentation and we eventually discovered that his environment was not setup to read HTML files – it was considering HTML files as non-web files and thus browsers were downloading HTML files instead of displaying them. Easily fixed, we thought… All that needed to be done was to add the following line to the .htaccess (we also included txt files, just in case):

AddType text/html *.html *.htm .txt

The above instructs the server to serve pages with an .html extension as HTML pages. Unfortunately, however, the above code didn’t work, because our client’s hosting environment was very restrictive and didn’t allow of such changes in the .htaccess file.

So what we did to solve the problem is that we renamed the file from included_file.html to included_file.php – essentially forcing the webserver to treat the file as a PHP file and serve it normally to the browser.

Now – if you’re someone who pays attention to details, you might be wondering how come Internet Explorer was displaying the file properly while the other two major browsers didn’t? The answer is simple: Internet Explorer simply doesn’t care what the webserver tells it about the nature of the file – it just looks at the extension and the content-header. Of course, this is considered to be a violation to the server rules – but on the bright side, it did work!

Now if you’re using Joomla’s wrapper component and you feel you need help then we’re here for you! Just contact us and you will see how friendly, motivated, fast, and efficient we are! We also have the most affordable rates out there!

2 Responses to “Wrapper Component in Joomla Downloads File on Firefox and Chrome Instead of Displaying it”
  1. Comment by Glenn — January 30, 2015 @ 9:48 am

    I am having the issue addressed in this article. Where do I go to change included_file.html to included_file.php ? I am using Joomla 2.5.

  2. Comment by Fadi — February 5, 2015 @ 9:51 am

    Hi Glenn,

    First you will need to rename the file in the filesystem (using FTP) – you will then need to change the URL pointing to that file (in the iFrame Wrapper menu item) to point to the new (PHP) file.

Leave a comment