General Joomla php include question
Posted: Sat Jan 26, 2008 9:57 am
I am already frustrated, as I can't find a solution to my question
I need to include a php file into my 'module project'. But because this file is somehow outside the joomla framework, I can't call the Joomla methods in this file.
Is there an easy way, how can I do this?
--
This is the usuall structure of a module in J!1.5
/mod_customname
|
|--tmpl
| |
| |--default.php
|
|--problem_directory
| |
| |--problem_file.php
|
|--helper.php
|--mod_customname.php
The problem_file.php is called from default.php. I generate an AJAX request and the problem_file.php should generate a response, which will be included in my
I need to include a php file into my 'module project'. But because this file is somehow outside the joomla framework, I can't call the Joomla methods in this file.
Is there an easy way, how can I do this?
--
This is the usuall structure of a module in J!1.5
/mod_customname
|
|--tmpl
| |
| |--default.php
|
|--problem_directory
| |
| |--problem_file.php
|
|--helper.php
|--mod_customname.php
The problem_file.php is called from default.php. I generate an AJAX request and the problem_file.php should generate a response, which will be included in my
tag in default.php again.
The problem_file.php contains something like this:
$db = JFactory::getDBO();
....
?>
But I get the error, that the JFactory is not known. How can I properly use Joomla framework methods in this file? Btw. everything works fine, if the problem_file.php is a pure php file, e.g:
echo "works ..";
....
?>
Thx a lot in advance !! I am really stuck here.
The problem_file.php contains something like this:
$db = JFactory::getDBO();
....
?>
But I get the error, that the JFactory is not known. How can I properly use Joomla framework methods in this file? Btw. everything works fine, if the problem_file.php is a pure php file, e.g:
echo "works ..";
....
?>
Thx a lot in advance !! I am really stuck here.
Re: General Joomla php include question
Posted: Sat Jan 26, 2008 10:58 am
I would also like to know that the best way is to include or require files. So far I have always had trouble trying it.
Re: General Joomla php include question
Posted: Sun Jan 27, 2008 1:18 am
I want to keep the article index there i just wanna know how
to RENAME it...not the ARTICLE
I WANNA RENAME THAT LIST OR TEXT IN THE ARTICLE INDEX BOX THINGY!!!!
to RENAME it...not the ARTICLE
I WANNA RENAME THAT LIST OR TEXT IN THE ARTICLE INDEX BOX THINGY!!!!
Re: General Joomla php include question
Posted: Wed Jan 30, 2008 10:42 pm
Ditto. I have the same problem.
Looks like this is a much needed feature - being able to include php files from outside the Joomla framework.
In my case, it's to included a Simple Pie coded rss parser because there isn't a good one yet for Joomla 1.5 and I need to show multiple news feeds on my front page (in one area, not only one per module like is default in Joomla).
Thanks.
Looks like this is a much needed feature - being able to include php files from outside the Joomla framework.
In my case, it's to included a Simple Pie coded rss parser because there isn't a good one yet for Joomla 1.5 and I need to show multiple news feeds on my front page (in one area, not only one per module like is default in Joomla).
Thanks.
Re: General Joomla php include question
Posted: Thu Jan 31, 2008 4:43 am
Create a simple component to support your module that will handle the ajax request.
Ian
Ian
Re: General Joomla php include question
Posted: Sun Feb 03, 2008 8:50 am
ianmac wrote:Create a simple component to support your module that will handle the ajax request.
Ian
Hi Ian,
could you be pls more specific, what do you mean? It's not clear, why should I mix here with component ..
Thx
Re: General Joomla php include question
Posted: Sun Feb 03, 2008 11:56 pm
durino13 wrote:ianmac wrote:Create a simple component to support your module that will handle the ajax request.
Ian
Hi Ian,
could you be pls more specific, what do you mean? It's not clear, why should I mix here with component ..
Thx
Components can be called "raw" from the query string to render without any of the site template or modules. This makes them good for producing data to be retrieved from AJAX. Go to any component in your joomla site and try adding &tmpl=component to the query string to see what I mean.
I started a module which I intended to be AJAX enabled, and ended up making a component that would deliver this data to the module. The problem is that modules cannot be called to the browser directly, but components can.
It's not the "cleanest" solution in the world, but it works fine and lets you stay within the Joomla framework. A better solution should certainly be developed in the future for people who want to develop AJAX data providers from within the framework.
Re: General Joomla php include question
Posted: Mon Feb 04, 2008 9:38 pm
Hi Skipdog ..
Thank you for your answer .. I understand what you want to say with the tmpl=component parameter .. I've tested it and I see, that only the component is returned instead of everything (template, modules .. ). Now, I am thinking, how this could help me with my issue.
Am I correct, if I say following?
1. I send an AJAX request from my module (the requested file will be a 'php' file of my component) ..
2. I will be able to use all methods in the php file, as it will be a standart component (withing Joomla framework)
3. As a response, I'll receive an HTML file from the server, which i can include back into my module ..
Do I understand it correctly?
Thank you for your answer .. I understand what you want to say with the tmpl=component parameter .. I've tested it and I see, that only the component is returned instead of everything (template, modules .. ). Now, I am thinking, how this could help me with my issue.
Am I correct, if I say following?
1. I send an AJAX request from my module (the requested file will be a 'php' file of my component) ..
2. I will be able to use all methods in the php file, as it will be a standart component (withing Joomla framework)
3. As a response, I'll receive an HTML file from the server, which i can include back into my module ..
Do I understand it correctly?
Re: General Joomla php include question
Posted: Mon Feb 04, 2008 9:43 pm
You can't call the php file of the component directly. Your AJAX call will be to index.php?option=com_[yourcomponent]&tmpl=component
This calls the component properly through the framework, and returns just the data you need to update your module.
This calls the component properly through the framework, and returns just the data you need to update your module.
Re: General Joomla php include question
Posted: Tue Feb 05, 2008 7:26 am
Now I think I know everything I needed to know !!
Thank you guys for your time !
Thank you guys for your time !
Re: General Joomla php include question
Posted: Tue Feb 05, 2008 4:21 pm
You might also use format=raw so that you don't get any extra HTML around your component.
Ian
Ian
Re: General Joomla php include question
Posted: Tue Feb 05, 2008 4:43 pm
The only problem with that is that you need to develop a raw view for the component and most (or all the ones I've seen at least) of the core or community components don't have a raw view implemented. If he's developing the component specifically as a data provider for his module, his template can ensure it doesn't include anything more than the module needs in terms of HTML.ianmac wrote:You might also use format=raw so that you don't get any extra HTML around your component.
Ian
Re: General Joomla php include question
Posted: Tue Feb 05, 2008 5:03 pm
I think you only need to implement a raw view if you are using MVC... if you are not using MVC, then you should be okay I think.
Ian
Ian