Is it possible to turn off layout only for ajax request?
Is it possible to turn off layout only for ajax request?
Hi,
I got few pages that I'd like to make accessible for ajax and non-ajax clients. If user with js enabled clicks a link, I'd like to fetch a page (content *without* the layout) and display it in a div. However, if user has js disabled, it should normally return the whole page (content *with* layout).
Is it possible to do wth CMS MS?
Regards
I got few pages that I'd like to make accessible for ajax and non-ajax clients. If user with js enabled clicks a link, I'd like to fetch a page (content *without* the layout) and display it in a div. However, if user has js disabled, it should normally return the whole page (content *with* layout).
Is it possible to do wth CMS MS?
Regards
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Is it possible to turn off layout only for ajax request?
try adding showtemplate=false to the url, or cntnt01showtemplate=false
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Is it possible to turn off layout only for ajax request?
for example
:
$this->CreateLink($id, 'action', $returnid, '', array('showtemplate' => 'false'), '', true);

$this->CreateLink($id, 'action', $returnid, '', array('showtemplate' => 'false'), '', true);
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Is it possible to turn off layout only for ajax request?
No, this solution should work in 1.2.x as well.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Is it possible to turn off layout only for ajax request?
My solution work in 1.0.5 too 

Re: Is it possible to turn off layout only for ajax request?
So far...
But what about Modules in the backend?
I try to create a simple mailer module that sends emails to users of the FrontendUsers module.
To prevent a server timeout I try to send the mails in multiple requests with ajax (similar to the NewsletterMadeSimple module).
My ajax request does not call an external php-file to send the mails. I'm using the moduleinterface.php with an action.sendMail.php instead. (e.g. the url that will be requested by the ajax script is moduleinterface.php?mact=MyModule,m1_,sendMail,0...) I believe this makes it more secure.
My problem is, that the response of the server contains the whole backend template.
But I just need an id...
The "showtemplate" param seems only to work for the frontend.
Is there any possibilty to realize an ajax request via backend without opening a new window? (like NMS)
(By the way: I don't want to use AJAX MadeSimple 'cause i've got my own very simple ajax request and i don't want my module to depend on more than the CMSMailerModule and FrontendUsers.)
Any ideas?
But what about Modules in the backend?
I try to create a simple mailer module that sends emails to users of the FrontendUsers module.
To prevent a server timeout I try to send the mails in multiple requests with ajax (similar to the NewsletterMadeSimple module).
My ajax request does not call an external php-file to send the mails. I'm using the moduleinterface.php with an action.sendMail.php instead. (e.g. the url that will be requested by the ajax script is moduleinterface.php?mact=MyModule,m1_,sendMail,0...) I believe this makes it more secure.
My problem is, that the response of the server contains the whole backend template.
But I just need an id...
The "showtemplate" param seems only to work for the frontend.
Is there any possibilty to realize an ajax request via backend without opening a new window? (like NMS)
(By the way: I don't want to use AJAX MadeSimple 'cause i've got my own very simple ajax request and i don't want my module to depend on more than the CMSMailerModule and FrontendUsers.)
Any ideas?
Last edited by NaN on Fri Jul 18, 2008 8:08 pm, edited 1 time in total.
Re: Is it possible to turn off layout only for ajax request?
Looking in the moduleinterface.php i found this:
So i just need to add the param disable_theme to my ajax request.
Quite simple.
But the response from the server still contains some comments, , and .
I have to modify the response via the javascript function replace().
So my request seems to work now.
But this cannot be a proper solution.
Is there any way to get just a single value as response from the moduleinterface.php?
Code: Select all
$USE_THEME = true;
if( isset( $_REQUEST[$id . 'disable_theme'] ))
{
$USE_THEME = false;
}
else if( isset( $_REQUEST['disable_theme'] ))
{
$USE_THEME = false;
}
Quite simple.
But the response from the server still contains some comments, , and .
I have to modify the response via the javascript function replace().
So my request seems to work now.
But this cannot be a proper solution.
Is there any way to get just a single value as response from the moduleinterface.php?
Last edited by NaN on Sat Jul 19, 2008 11:16 am, edited 1 time in total.
Re: Is it possible to turn off layout only for ajax request?
When searching for that output i found some "issues" in the moduleinterface.php, header.php and footer.php.
It is hardcoded there:
moduleinterface.php line 139:
header.php line 10:
footer.php line 2 and 28-33:
I just uncommented/modified it:
moduleinterface.php:
header.php/footer.php:
Dunno if this is usefull but just in case...
It is hardcoded there:
moduleinterface.php line 139:
Code: Select all
if (!$suppressOutput)
{
echo '</div>';
}
Code: Select all
if (isset($USE_THEME) && $USE_THEME == false)
{
echo '<!-- admin theme disabled -->';
}
Code: Select all
if (isset($USE_THEME) && $USE_THEME == false)
{
echo '<!-- admin theme disabled -->';
}
...
?>
<__body>
</__html>
<?php
...
I just uncommented/modified it:
moduleinterface.php:
Code: Select all
# modified by NaN since we don't want ANY output from the admintheme if $USE_THEME == false
if (!$suppressOutput && isset($USE_THEME) && $USE_THEME!=false)
{
echo '</div>';
}
Code: Select all
if (isset($USE_THEME) && $USE_THEME == false)
{
# commented out by NaN since we don't want ANY output from the
# admintheme if $USE_THEME == false
# echo '<!-- admin theme disabled -->';
}
...
if (isset($USE_THEME) && $USE_THEME != false)
{
# modified by NaN since we don't want ANY output from the admintheme
# if $USE_THEME == false
echo "<__body>\n</html>";
}
Re: Is it possible to turn off layout only for ajax request?
Here's how I did it:
file: modules/FEUsers/ajax_cities_for_country.php
file: modules/FEUsers/ajax_cities_for_country.php
Code: Select all
<?php
while(ob_get_level()>0) ob_end_clean();
header('Content-type: text/javascript');
die(json_encode($cities));