i m developing site in Joomla, meanwhile i stuck in a problem,please help me in below problem
here is my folder structure for component
htdocs/Joomla
In joomla 1.7 and up you can close it like this
$app = &JFactory::getApplication();
$app->close();
I found the solution. You must prevent the joomla to attach the templates and modules and ... to your output ajax data. for this you must add this code after displaying your data
//after $this->display($tpl);
global $mainframe;
$mainframe->close();
use format=raw
in the ajax url, as this would just show the output without any template.
1 - copy main index.php
(joomlaRoot/index.php
) of joomla and rename it to any name (for example: joomlaRoot/ajax.php
).
2 - disable render method ($mainframe->render();
)
3 - copy this code under the render method line:
/***/
$document =& JFactory::getDocument();
$content=$document->getBuffer();
foreach($content as $var){
foreach($var as $var2){
echo $var2;
}
}
/**/
All front end code should be in your tmpl, so your Ajax stuff should be in there too. Check this tutorial out on how to make MVC components for Joomla http://www.joomladevuser.com/tutorials/components (deadlink).
That is right, Joomla will load modules, component, whatewer Your default template and Joomla core requires... Change this behavior by using "&format=raw" (this will force Joomla to include Joomla`s "nothing") or "&template=your_own_template_for_ajax" (this will force Joomla to include Your own "nothing").
I didn`t knew about "&format=raw" so I use my own empty template for ajax. Empty tamplate makes sense for me - I can customize it the way I want (e.g. to include something by default). "&format=raw" is the good option, but not the only one. The decision depends on what You wanna do/get by default.
How to make such ajax template in front-end?
You must create a new directory (e.g. "ajax") inside front-end \templates\ directory. Then put 3 files inside:
index.php:
<jdoc:include type="component" />
templateDetails.xml:
...XML content..
Instructions on how to properly create templateDetails.xml can be found here:
http://docs.joomla.org/Creating_a_basic_templateDetails.xml_file
index.php:
<!DOCTYPE html><title></title>
That is all You need for the front-end solution.
Test it by calling like this: http://www.example.com/index.php?template=ajax
This is 100% working solution for the front-end. Back-end is not tested by me. I believe You would have to create a separate template for back-end also. Or reach the front-end template somehow (currently have no ideas on how to)...