Display Joomla modules outside Joomla Framework
-
- Joomla! Intern
- Posts: 91
- Joined: Sat Oct 27, 2007 12:54 am
- Location: Ireland
- Contact:
Display Joomla modules outside Joomla Framework
I'm wondering what kind of php code i need to write to allow me to display Joomla 1.5 modules outside the Joomla framework, but on the same domain.
Because i don't fully understand how the Joomla framework works, i have extra website software and pages of information installed outside the Joomla framework like this; mywebsite.com/WordPress-Blog or maybe this; mywebsite.com/PHPBB-Forum
So i have Joomla installed on the root domain mydomain.com. But if i use PHPBB or WordPress blogs as an example of extra software, what kind of php code do i need to write to get the standard "Joomla Latest News" module to display on the WordPress blog?
Any tips, links or pointers in the right direction will be a big help to get me started. I have been searching Google for answers but maybe i'm not using the right search words. To learn how to do this, what Joomla stuff do i need to read to teach me how this works so i can write the code to make it work.
Or if i just took the Joomla "Latest news" module as an example and i install the complete code inside a wordpress blog, what changes would i need to make to the latest news module code so that it calls the information from the Joomla MySql and uses the files inside the Main Joomla website?
Thank you,
John.
Because i don't fully understand how the Joomla framework works, i have extra website software and pages of information installed outside the Joomla framework like this; mywebsite.com/WordPress-Blog or maybe this; mywebsite.com/PHPBB-Forum
So i have Joomla installed on the root domain mydomain.com. But if i use PHPBB or WordPress blogs as an example of extra software, what kind of php code do i need to write to get the standard "Joomla Latest News" module to display on the WordPress blog?
Any tips, links or pointers in the right direction will be a big help to get me started. I have been searching Google for answers but maybe i'm not using the right search words. To learn how to do this, what Joomla stuff do i need to read to teach me how this works so i can write the code to make it work.
Or if i just took the Joomla "Latest news" module as an example and i install the complete code inside a wordpress blog, what changes would i need to make to the latest news module code so that it calls the information from the Joomla MySql and uses the files inside the Main Joomla website?
Thank you,
John.
Compute for science and for a better world!
www.unitedboinc.com
www.unitedboinc.com
- jeremywilken
- Joomla! Intern
- Posts: 65
- Joined: Sat Oct 06, 2007 4:28 pm
- Location: Houston
- Contact:
Re: Display Joomla modules outside Joomla Framework
Well the first problem is that any module SHOULD start with a line like this
which means that if the file is run or included on a page outside of the Joomla framework, it quits and outputs the error.
Your best bet is to get the data out using RSS, which can be done with the built in syndicate features or there are extensions which extend that even more. Many of the major add-ons also have the ability to output the data as RSS at least in some way.
Code: Select all
defined('_JEXEC') or die ('No direct access');
Your best bet is to get the data out using RSS, which can be done with the built in syndicate features or there are extensions which extend that even more. Many of the major add-ons also have the ability to output the data as RSS at least in some way.
Jeremy
Gnome on the run
Web Development Studio, Web development, done better
http://www.gnomeontherun.com
Gnome on the run
Web Development Studio, Web development, done better
http://www.gnomeontherun.com
-
- Joomla! Intern
- Posts: 91
- Joined: Sat Oct 27, 2007 12:54 am
- Location: Ireland
- Contact:
Re: Display Joomla modules outside Joomla Framework
Thanks for the reply Jeremy,
Yes, you are correct about the "defined('_JEXEC') or die ('No direct access');", it kills any attempt to directly access the php page.
Your suggestion about extracting the data from an rss feed is a good suggestion. But in this case, i am just using the "Latest news" module as an example.
In general i am referring to any module, especially the ones that people put on the right and left hand sides of the pages like the "Who's online" module or the "Login" module. I cannot extract this data from an rss feed.
So what i am really asking is if i take out this statement from a module;
How would i write a piece of code that would allow this module to work in external pages on the same domain?
***********************
I have been doing something along these lines for a while now, but this method will only allow me to extract data from the MySql database, it WON'T allow me to include many of the files needed for other modules.
This is what i am doing for one particular module i have installed on one website.
External to the joomla framework, i connect to the database;
Then i select the correct "params" from the correct "module" with the correct module "id";
After that, i have 3 specially written php functions that extract the information from the Joomla module params as Joomla has a funny way of storing module parameters in the database.
This works fine for this particular module, but it won't work for all the Joomla includes and libraries and other stuff that many Joomla modules need to work.
John.
Yes, you are correct about the "defined('_JEXEC') or die ('No direct access');", it kills any attempt to directly access the php page.
Your suggestion about extracting the data from an rss feed is a good suggestion. But in this case, i am just using the "Latest news" module as an example.
In general i am referring to any module, especially the ones that people put on the right and left hand sides of the pages like the "Who's online" module or the "Login" module. I cannot extract this data from an rss feed.
So what i am really asking is if i take out this statement from a module;
Code: Select all
defined('_JEXEC') or die ('No direct access');
***********************
I have been doing something along these lines for a while now, but this method will only allow me to extract data from the MySql database, it WON'T allow me to include many of the files needed for other modules.
This is what i am doing for one particular module i have installed on one website.
External to the joomla framework, i connect to the database;
Code: Select all
$username = "XXXXXX";
$password = "XXXXXXX";
$hostname = "XXXXXXX";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
global $mainframe;
//select a database to work with
$selected = mysql_select_db('mydb_sitename',$dbhandle)
or die("Could not select examples");
Code: Select all
//execute the SQL query and return records
$query = mysql_query("SELECT params FROM jos_modules WHERE id='74'");
//Some extra settings
require_once ($_SERVER['DOCUMENT_ROOT'] .'/extras/Special-Modified-Helper.php');
$rowdata = mysql_fetch_assoc($query);
This works fine for this particular module, but it won't work for all the Joomla includes and libraries and other stuff that many Joomla modules need to work.
John.
Compute for science and for a better world!
www.unitedboinc.com
www.unitedboinc.com
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
This code loads the user1 position outside Joomla
Code: Select all
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$modules = JModuleHelper::getModules('user1');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>$style);
$contents = '';
foreach( $modules As $mod ){
$contents .= $renderer->render($mod, $params);
}
echo $contents;
?>
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
- masterchief
- Joomla! Hero
- Posts: 2247
- Joined: Fri Aug 12, 2005 2:45 am
- Location: Brisbane, Australia
- Contact:
Re: Display Joomla modules outside Joomla Framework
Just remember you are loading a new framework on top of an existing one. I'd actually go for providing native modules the chosen application. That's going to be a lot lighter on resources.
Andrew Eddie - Tweet @AndrewEddie
<><
http://eddify.me
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.
<><
http://eddify.me
http://www.kiva.org/team/joomla - Got Joomla for free? Pay it forward and help fight poverty.
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
True, it will be lighter on resources, but it is a lot more work to do it from scratch for someone that doesn't know how to do it. The solution works and it can be improved as I've done with the code below. Now there's a lot less files loading from the framework and instead of showing all modules in the given position, it just shows one module. The performance impact at this point will depend more on the module itself than the loading of the framework. Let's talk some numbers to make this more clear.
Loading the latest news module with this approach takes 130ms. If I empty the module code, so only the framework files and renderer code is run it goes down to 93ms.
I hope this can be useful to someone. Remember you need to load your css stylesheet separately.
Loading the latest news module with this approach takes 130ms. If I empty the module code, so only the framework files and renderer code is run it goes down to 93ms.
I hope this can be useful to someone. Remember you need to load your css stylesheet separately.
Code: Select all
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require( JPATH_LIBRARIES .DS.'joomla'.DS.'import.php');
// Joomla! library imports;
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user');
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$style = '';
$modules = JModuleHelper::getModules('user9');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>'');
$contents = '';
$contents .= $renderer->render(current($modules), $params);
echo $contents;
?>
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
-
- Joomla! Apprentice
- Posts: 5
- Joined: Mon Mar 30, 2009 5:28 pm
Re: Display Joomla modules outside Joomla Framework
Alejo - thank you very much in advance. I actually tried this
on my root I have a splash page and in /content/ I have the joomla installation.
I dont know where in your code i need to change the path.
But for now I placed the splash page in joomla folder trying to check how it works.
I am trying to load a position where I have the joomla login module placed. It throws up an error that cant find JPluginHelper in the Mod_login's tempate file
Fatal error: Class 'JPluginHelper' not found in /content/modules/mod_yoo_login/tmpl/FBquick.php on line 22
Basically I have a yoo login module that I have published at this particular position.
Please help me access this on the root as well. Where should edit the path?
on my root I have a splash page and in /content/ I have the joomla installation.
I dont know where in your code i need to change the path.
But for now I placed the splash page in joomla folder trying to check how it works.
I am trying to load a position where I have the joomla login module placed. It throws up an error that cant find JPluginHelper in the Mod_login's tempate file
Fatal error: Class 'JPluginHelper' not found in /content/modules/mod_yoo_login/tmpl/FBquick.php on line 22
Basically I have a yoo login module that I have published at this particular position.
Please help me access this on the root as well. Where should edit the path?
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
Try changing this:
define('JPATH_BASE', 'path/to/joomla );
define('JPATH_BASE', 'path/to/joomla );
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
-
- Joomla! Apprentice
- Posts: 5
- Joined: Mon Mar 30, 2009 5:28 pm
Re: Display Joomla modules outside Joomla Framework
Okay, good thing is now its actually trying to load my module and it almost does it. But I am getting stuck with the
Fatal error: Class 'JPluginHelper' not found in content/modules/mod_yoo_login/tmpl/FBquick.php on line 22
You are doing a great favor to me! It would be very helpful if you can teach me how to load this class.
Fatal error: Class 'JPluginHelper' not found in content/modules/mod_yoo_login/tmpl/FBquick.php on line 22
You are doing a great favor to me! It would be very helpful if you can teach me how to load this class.
-
- Joomla! Apprentice
- Posts: 5
- Joined: Mon Mar 30, 2009 5:28 pm
Re: Display Joomla modules outside Joomla Framework
Just want to add that I tried loading another user position - that had latest news and it works perfectly.
So I guess its nothing to do with the Code you suggest.
But am trying to get the login form outside joomla and the jPluginHelper class is not being found!
So I guess its nothing to do with the Code you suggest.
But am trying to get the login form outside joomla and the jPluginHelper class is not being found!
-
- Joomla! Apprentice
- Posts: 5
- Joined: Mon Mar 30, 2009 5:28 pm
Re: Display Joomla modules outside Joomla Framework
Sorry to bother you - I managed to break this through. It works fine!
I commented the code that was using jPluginHelper - that was actually checking if OpenID was being enabled. Since I dont have it - I lved to ignored it.
I commented the code that was using jPluginHelper - that was actually checking if OpenID was being enabled. Since I dont have it - I lved to ignored it.
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
Great, I am glad this trick has helped you.
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
-
- Joomla! Intern
- Posts: 91
- Joined: Sat Oct 27, 2007 12:54 am
- Location: Ireland
- Contact:
Re: Display Joomla modules outside Joomla Framework
Thanks for the code guys. I'm still watching this message, i just have not had the time to try out some of the code. But i have this message bookmarked. Once i get the chance to try the code i will report back the results.
Thanks again for the help!
John.
Thanks again for the help!
John.
Compute for science and for a better world!
www.unitedboinc.com
www.unitedboinc.com
-
- Joomla! Intern
- Posts: 77
- Joined: Sun Jun 11, 2006 1:57 pm
Re: Display Joomla modules outside Joomla Framework
If this sort of functionality is to be a basis within a site using Joomla is not the way to go. If you take a gander at Portal's you'll find that any of the truly respectable ones (mainly live in the java world) provide this sort of funcationality to well... everything. Portlets. You can have/assign anything, blog, chat, forum, content, anything to be able to be displayed externally so other web sites can utilize your content direct.
I've been working on a project with Liferay Portal that requires a good deal of the sites capabilities to be "plugged into" other sites. Joomla has alot more in the way of modules etc. that do neato stuff but in looking how to best do this .vs. in my case Liferay, its just night and day. Atop that it has the capability of a complete Access Contol package, groupings and in performance just blows the doors off PHP based Apps. Its simply put a "Real class application" enterprise capable, for example, I know Autozone uses it, www.autozone.com, This is a high traffic venue, GOBS of data, and look at the performance in using it.
I've been working on a project with Liferay Portal that requires a good deal of the sites capabilities to be "plugged into" other sites. Joomla has alot more in the way of modules etc. that do neato stuff but in looking how to best do this .vs. in my case Liferay, its just night and day. Atop that it has the capability of a complete Access Contol package, groupings and in performance just blows the doors off PHP based Apps. Its simply put a "Real class application" enterprise capable, for example, I know Autozone uses it, www.autozone.com, This is a high traffic venue, GOBS of data, and look at the performance in using it.
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Nov 07, 2008 3:35 pm
Re: Display Joomla modules outside Joomla Framework
I have this working on a test page, It loads standard modules fine. However I have a module that uses functions in other files and when the module tries to load I get the message "Restricted Access"
Does anyone have any access on how can get this working? Any help or direction is appreciated,
Thanks!
Does anyone have any access on how can get this working? Any help or direction is appreciated,
Thanks!
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
Whatever other files you are trying to load probably have a check at the top that looks something like this:
defined('_SOMETHING') or die ('Restricted Access to this location');
Make sure you define that constant at the beginning of your code:
define('_SOMETHING',1);
defined('_SOMETHING') or die ('Restricted Access to this location');
Make sure you define that constant at the beginning of your code:
define('_SOMETHING',1);
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
-
- Joomla! Fledgling
- Posts: 3
- Joined: Fri Nov 07, 2008 3:35 pm
Re: Display Joomla modules outside Joomla Framework
At the beginning of each file that the module calls I have defined('_JEXEC') or die('Restricted access');
at the beginning of my code I have define('_JEXEC', 1); and I am still getting the Restricted Access error. Is this a scope issue? do I need to define my constant in another way so that it is passed to all of the files that the module calls?
By the way I am trying to use the YooTools Accordian Menu.
Again thanks for any help or direction.
at the beginning of my code I have define('_JEXEC', 1); and I am still getting the Restricted Access error. Is this a scope issue? do I need to define my constant in another way so that it is passed to all of the files that the module calls?
By the way I am trying to use the YooTools Accordian Menu.
Again thanks for any help or direction.
-
- Joomla! Apprentice
- Posts: 5
- Joined: Mon Mar 30, 2009 5:28 pm
Re: Display Joomla modules outside Joomla Framework
Alejo, my Joomla login outside joomla is perfectly working!
How ever, post login the Joomla landing page is index.php?option=com_user which says "Welcome to the Restricted Area of the site"
Could you tell me how do I alter the landing page post loging as just the index.php?
There's a hidden variable - which sets option=com_user in the login form. But my Form Action = index.php If i remove the hidden variable, i cant login
How ever, post login the Joomla landing page is index.php?option=com_user which says "Welcome to the Restricted Area of the site"
Could you tell me how do I alter the landing page post loging as just the index.php?
There's a hidden variable - which sets option=com_user in the login form. But my Form Action = index.php If i remove the hidden variable, i cant login
-
- Joomla! Apprentice
- Posts: 16
- Joined: Mon Apr 20, 2009 12:07 am
Re: Display Joomla modules outside Joomla Framework
Could it be a solution to make a joombla page where only the module were on and then just imbed it in the other pages using an html iframe tag.
Can you make a joomla page that contains only the module and nothing else at all ?
I need this for something else.
Can you make a joomla page that contains only the module and nothing else at all ?
I need this for something else.
-
- Joomla! Apprentice
- Posts: 9
- Joined: Mon Jan 26, 2009 1:35 pm
Re: Display Joomla modules outside Joomla Framework
Thanks for the tip, I needed to load the Framework in a non-framework file in a module and it's working but I'm having troubles with the paths.
Using this:
I get this error due to the path:
require_once(/home/usr/public_html/modules/mod_test/includes/defines.php) [function.require-once]: failed to open stream: No such file or directory in /home/usr/public_html/modules/mod_test/test.php on line 6
If I change the dirname(__FILE__) to the proper path ('/home/usr/public_html') it all works fine, can't use that though cause I need the path of each individual website. Any ideas on how to fix this?
EDIT: I solved this by using substr() to remove the last 17 characters from the string (/modules/mod_test). It's always gonna be those characters at the end of the path so I guess it will work just fine.
Using this:
Code: Select all
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
/* Required Files */
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once(/home/usr/public_html/modules/mod_test/includes/defines.php) [function.require-once]: failed to open stream: No such file or directory in /home/usr/public_html/modules/mod_test/test.php on line 6
If I change the dirname(__FILE__) to the proper path ('/home/usr/public_html') it all works fine, can't use that though cause I need the path of each individual website. Any ideas on how to fix this?
EDIT: I solved this by using substr() to remove the last 17 characters from the string (/modules/mod_test). It's always gonna be those characters at the end of the path so I guess it will work just fine.
Last edited by vaistik on Fri May 01, 2009 7:02 am, edited 1 time in total.
- fatica
- Joomla! Enthusiast
- Posts: 153
- Joined: Fri Jan 19, 2007 10:32 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
A suggestion,
You could have the module rendered by Joomla then load that html content dynamically via an AJAX call. So, you would create an empty joomla template with one module position in it. That would allow you to render only the module.
In your PHPBB (or whatever) site, load content rendered above into a Div via a traditional AJAX request (innerHTML = content)
You could have the module rendered by Joomla then load that html content dynamically via an AJAX call. So, you would create an empty joomla template with one module position in it. That would allow you to render only the module.
In your PHPBB (or whatever) site, load content rendered above into a Div via a traditional AJAX request (innerHTML = content)
Mike Fatica
https://www.metalocator.com
https://www.metalocator.com
-
- Joomla! Apprentice
- Posts: 6
- Joined: Tue Jul 24, 2007 6:37 am
Re: Display Joomla modules outside Joomla Framework
I know it's a old topic, but looking for something like this for a long time!
It works great, but if someone knows a better way to display my banners on my phpBB forum than I would like to hear that also
(pre.f using a Joomla bannermanager)
It works great, but if someone knows a better way to display my banners on my phpBB forum than I would like to hear that also
(pre.f using a Joomla bannermanager)
-
- Joomla! Apprentice
- Posts: 6
- Joined: Mon Sep 13, 2010 10:47 pm
Re: Display Joomla modules outside Joomla Framework
Solid information, thanks everyone...
Sorry for such a silly questions, where should I put that php code, in the header of the module php page, or on a mock page that calls to the module (like test.html).
Also here is what I have edited on that file, am I missing alot of it??
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('/home2/eyeducom/public_html/joomla', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require( JPATH_LIBRARIES .DS.'joomla'.DS.'/home2/eyeducom/public_html/joomla/modules/mod_fpss/mod_fpss.php');
// Joomla! library imports;
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user');
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$style = '';
$modules = JModuleHelper::getModules('user9');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>'');
$contents = '';
$contents .= $renderer->render(current($modules), $params);
echo $contents;
?>
Honestly if anyone can help, I would be sooo grateful, I am pretty decent with php, just really bad with joomla thus far, and I really need to see this module outside of the framwork.
Sorry for such a silly questions, where should I put that php code, in the header of the module php page, or on a mock page that calls to the module (like test.html).
Also here is what I have edited on that file, am I missing alot of it??
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('/home2/eyeducom/public_html/joomla', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require( JPATH_LIBRARIES .DS.'joomla'.DS.'/home2/eyeducom/public_html/joomla/modules/mod_fpss/mod_fpss.php');
// Joomla! library imports;
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user');
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$style = '';
$modules = JModuleHelper::getModules('user9');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>'');
$contents = '';
$contents .= $renderer->render(current($modules), $params);
echo $contents;
?>
Honestly if anyone can help, I would be sooo grateful, I am pretty decent with php, just really bad with joomla thus far, and I really need to see this module outside of the framwork.
-
- Joomla! Apprentice
- Posts: 6
- Joined: Mon Sep 13, 2010 10:47 pm
Re: Display Joomla modules outside Joomla Framework
Also, if it would be easier to get the module via RSS feed, how can I find the feed info for the module. The module is
Frontpage Slideshow v2
I dont see any info for the RSS feed anywhere frontend or back
Frontpage Slideshow v2
I dont see any info for the RSS feed anywhere frontend or back
-
- Joomla! Fledgling
- Posts: 1
- Joined: Mon Dec 27, 2010 10:21 pm
Re: Display Joomla modules outside Joomla Framework
I can get the module data to display properly...however, this error message displays above it:
(links and directory data removed of course)
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/directory/public_html/directory/file.php:9) in /home/directory/public_html/directory/directory/libraries/joomla/session/session.php on line 423
Warning: Cannot modify header information - headers already sent by (output started at /home/directory/public_html/directory/file.php:9) in /home/directory/public_html/directory/directory/libraries/joomla/session/session.php on line 426
(links and directory data removed of course)
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/directory/public_html/directory/file.php:9) in /home/directory/public_html/directory/directory/libraries/joomla/session/session.php on line 423
Warning: Cannot modify header information - headers already sent by (output started at /home/directory/public_html/directory/file.php:9) in /home/directory/public_html/directory/directory/libraries/joomla/session/session.php on line 426
-
- Joomla! Intern
- Posts: 51
- Joined: Tue Feb 10, 2009 3:40 am
Re: Display Joomla modules outside Joomla Framework
If I am using the below what am I putting in place of the <jdoc:include type="modules" name="menu" /> within the template. Thanks.
Code: Select all
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );
define( 'DS', DIRECTORY_SEPARATOR );
require( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require( JPATH_LIBRARIES .DS.'joomla'.DS.'import.php');
// Joomla! library imports;
jimport( 'joomla.environment.uri' );
jimport( 'joomla.user.user');
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$style = '';
$modules = JModuleHelper::getModules('menu');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>'');
$contents = '';
$contents .= $renderer->render(current($modules), $params);
echo $contents;
?>
-
- Joomla! Intern
- Posts: 92
- Joined: Tue Jul 01, 2008 7:25 pm
Re: Display Joomla modules outside Joomla Framework
I tried this to load a module in a phpbb3 forum but didn't get anything to show up. It displayed the php tag in the index file in dreamweaver but nothing loaded. The only thing I changed was the module position name from user9. The phpbb3 directory is located inside Joomla but it's not running through Joomla as an application. If someone could help me with this, I will relay the solution on to many other Joomla/phpbb users looking to load Joomla modules in phpbb. It would be very helpful.Alejo wrote:True, it will be lighter on resources, but it is a lot more work to do it from scratch for someone that doesn't know how to do it. The solution works and it can be improved as I've done with the code below. Now there's a lot less files loading from the framework and instead of showing all modules in the given position, it just shows one module. The performance impact at this point will depend more on the module itself than the loading of the framework. Let's talk some numbers to make this more clear.
Loading the latest news module with this approach takes 130ms. If I empty the module code, so only the framework files and renderer code is run it goes down to 93ms.
I hope this can be useful to someone. Remember you need to load your css stylesheet separately.
Code: Select all
<?php // Set flag that this is a parent file define( '_JEXEC', 1 ); define('JPATH_BASE', dirname(__FILE__) ); define( 'DS', DIRECTORY_SEPARATOR ); require( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require( JPATH_LIBRARIES .DS.'joomla'.DS.'import.php'); // Joomla! library imports; jimport( 'joomla.environment.uri' ); jimport( 'joomla.user.user'); jimport('joomla.application.module.helper'); $mainframe =& JFactory::getApplication('site'); $style = ''; $modules = JModuleHelper::getModules('user9'); $document = JFactory::getDocument(); $renderer = $document->loadRenderer('module'); $params = array('style'=>''); $contents = ''; $contents .= $renderer->render(current($modules), $params); echo $contents; ?>
-
- Joomla! Fledgling
- Posts: 2
- Joined: Thu Aug 25, 2011 3:20 pm
Re: Display Joomla modules outside Joomla Framework
First off thanks so much for everyone for contributing to this thread it is a great little tutorial and I'm using the code to display several modules outside of joomla.
However I have one that is problematic. I have an article displaying inside of a module using mod_placehere (http://extensions.joomla.org/extensions ... -embed/498).
When I use the code above to display this module position I get the following error on the command line:
PHP Fatal error: Class 'JPluginHelper' not found in /www/snowstar.com/modules/mod_placehere/helper.php on line 35
Line 35 of that file is:
JPluginHelper::importPlugin('content');
My code is as follows:
There is just one module in the "myreport" position.
Does anyone know how to remedy this? Or is there a similar way to just display the article outside of the joomla framework??
Thanks for the help.
However I have one that is problematic. I have an article displaying inside of a module using mod_placehere (http://extensions.joomla.org/extensions ... -embed/498).
When I use the code above to display this module position I get the following error on the command line:
PHP Fatal error: Class 'JPluginHelper' not found in /www/snowstar.com/modules/mod_placehere/helper.php on line 35
Line 35 of that file is:
JPluginHelper::importPlugin('content');
My code is as follows:
Code: Select all
<?php
// Set flag that this is a parent file
define( '_JEXEC', 1 );
define('JPATH_BASE', '/www/snowstar.com');
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.application.module.helper');
$mainframe =& JFactory::getApplication('site');
$modules = JModuleHelper::getModules('myreport');
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$params = array('style'=>$style);
$contents = '';
foreach( $modules As $mod ){
$contents .= $renderer->render($mod, $params);
}
echo $contents;
?>
Does anyone know how to remedy this? Or is there a similar way to just display the article outside of the joomla framework??
Thanks for the help.
-
- Joomla! Enthusiast
- Posts: 220
- Joined: Fri Aug 19, 2005 12:28 pm
- Contact:
Re: Display Joomla modules outside Joomla Framework
Add this line as well before the $mainframe line:
jimport('joomla.plugin.helper');
I hope that helps.
jimport('joomla.plugin.helper');
I hope that helps.
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress
-
- Joomla! Fledgling
- Posts: 2
- Joined: Thu Aug 25, 2011 3:20 pm
Re: Display Joomla modules outside Joomla Framework
Thanks that helped! I had to also add:
ini_set("memory_limit","32M");
As I initially got the following error:
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 122880 bytes) in /www/snowstar.com/administrator/components/com_virtuemart/classes/ps_product_attribute.php on line 318
Seems weird that the mod_placehere tries to load ALL the plugins, not sure what all its using, or why it needs so much memory...line 35 JPluginHelper::importPlugin('content'); doesn't specify what plugin to load, but to load them all.
Thanks.
ini_set("memory_limit","32M");
As I initially got the following error:
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 122880 bytes) in /www/snowstar.com/administrator/components/com_virtuemart/classes/ps_product_attribute.php on line 318
Seems weird that the mod_placehere tries to load ALL the plugins, not sure what all its using, or why it needs so much memory...line 35 JPluginHelper::importPlugin('content'); doesn't specify what plugin to load, but to load them all.
Thanks.