Members: 16,996
Threads: 38,846
Posts: 159,391
Online: 20

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Archive > Mambo 4.5 > Mambo 4.5 'How Do I' Questions

 
 
LinkBack Thread Tools Display Modes
Old 22.11.2004, 21:05   #1 (permalink)
Junior Mamber
 
Join Date: Nov 2004
Posts: 41
marcnyc is on a distinguished road
Arrow TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your site

Hello there, ever since I installed Mambo a few weeks ago for the first time I wanted to find a way to have MOS modules in my existing website (which had its existing template, scripts etc).

This tutorial is intended for those who don't want to make modifications to the core but want to be able to "pull" Mambo modules into non-Mambo pages. In the same way you can actually pull mambo content (ie componets) into non-Mambo pages.

There are a few different ways to achieve this but I will go with the easiest one, that requires the least amount of coding.

What I'll be discussing here is how to achieve such an integration without changing a single line of code in the Mambo core. I have done this on Mambo 4.5.1a. I have never used previous versions nor tested 4.6 or other later beta versions but I am pretty sure this method would be compatible with all versions because it relies on Mambo's very own features, not on external tricks/code/hacks etc. Basically I like to think of it this way: I am using Mambo's potential to trick Mambo itself into complying with my non-Mambo content pages...

For the sake of the example we will assume that you want to have the 'left' column of your Mambo pages in non-Mambo pages as well... Obviously if you want the right column you'll replace 'left' with 'right' or if you want your custom 'user1' column you'll replace 'left' with 'user1'. The way this method is conceived it won't allow you to pull only a few selected site modules into your non-MOS pages individually, but you can pull all the modules within a position (be it 'left', 'right', 'user1' or whatever).
You will notice I have colored the word left anywhere in this post to make this replacement easy for you.

Here we go:

First, you must create a new template. To do this go in your MOS installation folder, then navigate to 'templates' and create a new folder called, let's say, 'left'.
Inside this folder you will have to place ONLY two files (if you have security concerns you might want to also copy the blank index.html from any other template as a third file, but it is not mandatory at all).
These two files will have to be named: index.php and templateDetails.xml.
NO OTHER FILE or subfolder IS NEEDED.
The content of your index.php will be the following:
PHP Code:
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
mosLoadModules('left');
?>
Please note: the above word 'left' in the mosLoadModules('left'); should really be coloured in red (to be compliant with this post's standard conventions, where I would color red all the instances of the word 'left' to later be replaced by right or user1 or whatever the column is that you want to show/pull in your static non-MOS pages) but I had to leave it black because this board's BBC code wouldn't work within the php tags, that's all. Thanks to dylan for pointing it out.
The content of the templateDetails.xml file will be the following:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="template" version="4.5.1">
	<name>left column</name>
	<creationDate>11/01/04</creationDate>
	<author>you</author>
	<copyright>GNU/GPL</copyright>
	<authorEmail>you@yourdomain.tld</authorEmail>
	<authorUrl>http://www.yourdomain.tld</authorUrl>
	<version>1.0</version>
	<description>Your description.</description>
	<files>
		<filename>index.php</filename>
	</files>
</mosinstall>
Upload all of this if you have done it locally.
Please note you will have to create one template for every column that you want to add into your non-MOS pages. If you want a column on the left and one on the right, you'll have to create two templates. For my site http://www.chaindlk.com I have created 6 templates to achieve the 6 boxes in the left and right column that you see... And, needless to say, anything that is said from here on after will have to be repeated for every column that you want to have in your non-MOS pages as well.

Ok, great. Now that this is done, you're practically done with any code you'll have to deal with for this. Easy right? The next step will be to create a new menu item. You won't want this menu item to appear in your regular menus so I suggest that you first go to your 'Menu Manager' in Mambo's administration. Create a new menu and call it for example 'external un-necessary menu' or whatever. This menu won't have to be showed anywhere on your site, it's just needed for the next step. Within this new meny create a new menu item, select the 'Wrapper' component and then give it the title 'left', insert a dummy url in the Wrapper Link field (can be your website's url or whatever). Actually you could even leave it blank, I haven't tested it but none of these settings are really needed, we just need to create a new dummy menu item to trick Mambo into thinking that there is a new menu item (you'll understand why later). On the same note I just realized that you could also simply NOT publish this menu item instead of doing the above (create a new 'external un-necessary menu' menu and then create a new menu item within that... If I had thought of this when I developed this method I would have done just this: choose the 'No' radio button next to the 'Published:' option, but I just thought of it right now myself. Save the menu item.

Now the important thing. Once you save you are brought back to the menu manager. Now you have to click on the menu you have just created and read the URL that wasn't there before (because Mambo has created it upon your previous save action). This URL will look something like this: index.php?option=com_wrapper&Itemid=XX where XX is a number. You must copy or remember this number for later use.

Anyway, off to the next step. The core of the method, thanks to which all of this is possible (courtesy of Mambo ). Go to Site > Templates Manager > Site Templates. If you have done everything correctly in step 1 then you should now see your template called 'left column' (as per xml <name> tag). Click on its radio button (on its left) and then click on the Assign image/button at the top-right corner of your Mambo administration. Now you will want to pick your dummy previously created left menu item from the select list and then click on the Save button.
As for Mambo administration, you are now done, and you can close or log out from its control panel.

Step 4 consists of putting some code in your non-MOS pages to recall your left column in them. Open your php page and wherever you want to see your MOS column, add the following code:
PHP Code:
<?
include('http://www.yoursite.tld/yourMOSinstallationFolder/index.php?option=com_wrapper&Itemid=XX');
?>
where:
- www.yoursite.tld is the url of your site
- yourMOSinstallationFolder is where your MOS installation is (if you have installed Mambo in the root simply adjust the url/path removing it alltogether, along with one of the forward slashes of course)
- XX is the number you should still have in your clipboard memory (or in your human memory).
Please note that this must be a full URL. You can NOT use neither a relative URL nor a path starting with $_SERVER['DOCUMENT_ROOT'] or anything like that because that will not send the query string along with the include.

Now you are 99% done.
If you have done everything correctly and if navigate to the non-MOS php page that you have just edited and then uploaded, you will now see your non-Mambo php page with the contents of your Mambo pages' left column in it. Magic!

Because of the stupid 10000 characters limitation for this forum's posts (wow I didn't realize I have written this much, sorry if I am boring you, I am just trying to be precise so everybody can follow) I will have to continue this in the next post (see below).

Last edited by marcnyc; 02.12.2004 at 11:48.
marcnyc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Sponsored Links
Old 22.11.2004, 21:07   #2 (permalink)
Junior Mamber
 
Join Date: Nov 2004
Posts: 41
marcnyc is on a distinguished road
Arrow Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your si

When I said 99% I was referring to the fact that you need to make a small change to some of your files to fix the URLs that the browser will follow... When you are in a Mambo page all the URLs that appear in the modules point to Mambo's index.php (courtesy of the Mambo team) and append an option variable to the url. This gives us great power and potential but when you pull Mambo content into a non-Mambo page that resides ourside of Mambo's folder then you need to adjust this URL.
Let me explain:
- if your mambo installation folder is 'mambo' (hence you see your mambo home by going to www.yoursite.tld/mambo) and you want to pull your mambo pages' left column into a page that is contained within a root folder for example called 'products' (hence you see your products page by going to www.yoursite.tld/products) all the links generated by Mambo in the left column that you see in the products page will point to an index.php file contained in the products folder (whether this index.php file exists or not).
- the same is true if you have installed your copy of Mambo in the root folder (hence you access your mambo pages by going to www.yoursite.tld). If you want to insert Mambo's left column in a page that is inside a different folder, the links in the column will point to an index.php file contained in the products folder (whether this index.php file exists or not).
It is easy to fix this, but you will have to make this adjustment for EVERY folder on your site that contains non-Mambo pages where you want Mambo content such as our beloved left column to appear. Ok? This is very important, or your site will break.
Here is the adjustment (I'll stick with the above cases to make it easy):
- if your products page is called index.php and is found inside the 'products' folder then you must modify this file and add the following code AT THE VERY VERY VERY TOP of the page:
PHP Code:
<?
if ( isset($_GET['option']) )
Header('Location: http://'.$_SERVER['SERVER_NAME'].'/yourMOSinstallationFolder/?'.$_SERVER['QUERY_STRING'].'');
?>
where:
- yourMOSinstallationFolder is where your MOS installation is (if you have installed Mambo in the root simply adjust the url/path removing it alltogether, along with one of the forward slashes of course - you can remove the one you prefer but leave one and leave the question mark so that it will look like this: http://'.$_SERVER['SERVER_NAME'].'/?'.$_SERVER['QUERY_STRING'].'')
If on the other hand your products page is called index.php3 (instead of index.php) or products.php or anything other than index.php you will have to create a dummy file called index.php, place it in the folder and put the code above in the file. The same is true and applicable for ANY other folder where you have files that will be displaying Mambo content.

Please note: if you are on an Apache server and you are good enough to know RegExp, .htaccess files, ReWrite/ModWrite rules and things like that you can achieve the same thing by creating just ONE .htaccess file in your site's root (instead of having to create all these dummy index.php in non-Mambo folders or having to modify all non-mambo folders' index.php files) but I am not good enough to do this myself so please don't ask becuase I don't know, and if I had known I would have done it for my site. Don't you think?

Now you are really done.

Was pretty easy, wasn't it?
It might sound complicated and intricated, and your mind might bend and enter into a headache-generating loop, but once you get over it you'll enjoy having the possibility to have your MOS content in non-MOS php pages.
I have tested this on my site (which you can see at http://www.chaindlk.com) and it works smooth. I can't think of any security issues or any other issues whatsoever so it's recommended in my book. It works, and you know how they say: if it ain't broken, why fix it?

Remember: ANYTHING is possible with PHP, you just need to believe it, have fantasy, be creative and study PHP well enough (which doesn't have to be 'that' well)...

PS: If for some reason you want MOS components (not modules) in non-MOS pages the method is the same except that you'll be calling 'main' instead of 'left' in your custom template and when you go to assign the type of the new menu instead of choosing wrapper you'll have to choose the component you want to integrate!
marcnyc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 23.11.2004, 05:30   #3 (permalink)
Baby Mamber
 
Join Date: Nov 2004
Posts: 5
dylanm@mac.com is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your si

I was posting that I ran into trouble, but it turns out to have only been a minor error in your code above (which isn't so much an error as an attempt to clarify the 'left' variable which didn't render on the forum the way you probably expected). Anyhow, this technique works if you change:
Code:
?php 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
mosLoadModules('left'); 
?>
to

Code:
?php 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
mosLoadModules('left'); 
?>
Now it's actually working, which makes me very happy! If only you'd posted this a day ago (I was up 'til 2am painstakingly recreating the Mambo content as static HTML on the blogs-- and now I can include it the right way). Anyhow, this is much better because our site is still getting it's act together and the menu's, etc. are certainly going to change.

Also, just to clarify for other readers. The final step in the above tutorial is telling you to create a special index.php file with that snippet of code in the directory that your Mambo content is linking to (otherwise your links lead nowhere). It acts as a traffic cop and quickly re-directs the user to the proper Mambo location.

Thank you very much, and great work!
-Dylan

Last edited by dylanm@mac.com; 23.11.2004 at 10:47.
dylanm@mac.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 23.11.2004, 13:19   #4 (permalink)
Junior Mamber
 
Join Date: Nov 2004
Posts: 41
marcnyc is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your si

Hi Dylan, I don't see any difference between the code you are suggesing should be replaced and the code you are suggesting as a replacement, except for the fact that the word 'left' is coloured in left. Bu I did say that I would color every instance of the word 'left' that might have to be replaced by the word 'right' or 'user1' etc according to which column you want to have... I don't see how copying from the browser and pasting into your text/html editor could be any different if the text in the browser is coloured, but maybe I am missing something...
What is wrong with your code is the absence of the '<' in the opening '<?php' tag, but I hope/doubt that anybody would notice this before copying code...

Sorry you had to stay up late. If you had followed the development you would have seen that I was about to publish this, I just didn't have any time...

BTW, You are very welcome. ;-)
marcnyc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 24.11.2004, 05:27   #5 (permalink)
Baby Mamber
 
Join Date: Nov 2004
Posts: 5
dylanm@mac.com is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your si

Quote:
Originally Posted by marcnyc
Hi Dylan, I don't see any difference between the code you are suggesing should be replaced and the code you are suggesting as a replacement, except for the fact that the word 'left' is coloured
Oops, it just isn't showing in my post the way I intended it to. If you scroll back up to your original post you'll see that your code block has a bit of BBC code in it - which is showing - the color red command. That bit of code does bad things to the PHP apparently.

Again, your code was essentially perfect, it's just the way its showing on this board. When I attempted to re-create it, it executed the BBC code (turned the word 'left' red), instead of showing! Doh! I'm afraid my clarification just makes it more confusing.

I was kidding when I complained about staying up late. It's the dozen future late nights that have been avoided with your trick that matter. This is a HUGE trick you've found for us-- and thanks again.
dylanm@mac.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 02.12.2004, 11:50   #6 (permalink)
Junior Mamber
 
Join Date: Nov 2004
Posts: 41
marcnyc is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your si

I now see what you are talking about and I fixed the post.
Thanks. I had missed it.
You are welcome.
This really is a neat trick, I wonder how many have figured it out before me but never took the time to post about it... Hopefully those in need will find this topic when searching these boards
marcnyc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 23.02.2005, 02:26   #7 (permalink)
Baby Mamber
 
Join Date: Feb 2005
Posts: 12
koolaid is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your site

is this still working in mambo 4.5.2?

i`m only getting:
Warning: main(): URL file-access is disabled in the server configuration in /var/www/localhost/htdocs/stoneinnovation/osloreisesenter/staticfiles/index.php on line 15

Warning: main(http://www.stoneinnovation.no/oslore...page&Itemid=73): failed to open stream: no suitable wrapper could be found in /var/www/localhost/htdocs/stoneinnovation/osloreisesenter/staticfiles/index.php on line 15

Warning: main(): Failed opening 'http://www.stoneinnovation.no/osloreisesenter/index.php?option=com_frontpage&Itemid=73' for inclusion (include_path='.:/usr/lib/php') in /var/www/localhost/htdocs/stoneinnovation/osloreisesenter/staticfiles/index.php on line 15


Tanks for any help
koolaid is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 23.02.2005, 04:36   #8 (permalink)
Junior Mamber
 
Join Date: Nov 2004
Posts: 41
marcnyc is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your site

I sure hope it will work in 4.5.2 but I haven't updated to know yet... sorry... has anybody else tried this on 452?
marcnyc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 24.11.2005, 10:07   #9 (permalink)
Baby Mamber
 
Join Date: Nov 2005
Posts: 1
bsuttis is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your site

Hi, sorry to bump an old thread.

I followed this tutorial and it was very helpful.

But I've run into a problem.

Everything is great until it's time to include the php file on my regular (non-mambo) .php page.

http://gregorythomas.ca/index-test.php << Top Left (Light blue box) is where the module is supposed to be. But when going to the site, I get 'Direct Access to this location is not allowed'

However, when I visit the wrapper by its url (http://gregorythomas.ca/mambo/index....pper&Itemid=82). I get the form. I tried putting the php file inside a plan old iframe, but the same thing happened.

Why can I view this module by its url, but including it isn't working?

My index.php file is as follows:

Code:
<?php 
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
mosLoadModules('toolbar'); 
?>
And my TemplateDetails.xml file:

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="template" version="4.5.1">
<name>toolbar column</name>
<creationDate>11/23/05</creationDate>
<author>Brian Suttis</author>
<copyright>GNU/GPL</copyright>
<authorEmail>bsuttis@shaw.ca</authorEmail>
<authorUrl>http://www.gregorythomas.ca</authorUrl>
<version>1.0</version>
<description>Login form</description>
<files>
<filename>index.php</filename>
</files>
</mosinstall>
I'm using mambo 4.5.2 if that matters. Please help. Thanks
bsuttis is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 27.01.2006, 10:56   #10 (permalink)
Baby Mamber
 
Join Date: Jan 2006
Posts: 1
arkitekt is on a distinguished road
Default Re: TUTORIAL: How to INTEGRATE Mambo modules into non-MOS static php pages in your site

Does anyone have tips for doing the same thing in Joomla? I attempted to follow the steps but was having trouble figuring out how to have a specific component or module set to a position or to fill my new pages.

Basically what i want to do is use an events module and have it product a page let's call it events.php where this module upComing gigCalendar can be used in a non-static page of my site.

Here's the output of one part of the module ... I want to have a page that doesn't show the left menu and only shows the events calendar that can be used with the above php include method

http://tekture.com/cms2/component/option,com_gigcal

Any thoughts or help would be appreciated
arkitekt is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Useful Links -> Embeding php scripts into mambo content afru Mambo 4.5 'How Do I' Questions 36 20.07.2006 22:44
How to integrate a custom php script into Mambo TheEdge Component 'How Do I' Questions 6 11.08.2004 11:52
Mambo and Custom php pages? clayb Mambo 4.5 General Talk 5 14.06.2004 08:53
Hide/Show modules tutorial for Mambo template ahkane Template Discussions 3 07.06.2004 22:32


All times are GMT +2. The time now is 05:50.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.