Hey All,
I am currently implementing Lightwindow (
http://www.stickmanlabs.com/lightwindow/) into my website,
part of the features I wanted to use was to load a piece of content into the lightbox without the template surrounding it.
Of course I want my users to easily let a specific url load through Ajax or normal (Unobtrusive behavior) by just specifying the class "lightwindow" on the link, so the url looks something like this "<a class="lightwindow" href="general-terms-and-conditions">General Terms & Conditions</a>".
I couldn’t find any posts related this / nor any solutions to this, so I created something fast myself and was wondering if this is the right way (or that there is some feature I missed in MODx?).
I know that alot of librarys provide a "X-Requested-With" in the header so that the destination knows if it is from an Ajax request or not,
so I created a plugin to handle this on the "OnWebPagePrerender" event from MODx.
Here is the code of the plugin.
// Checks if in an Ajax call is made by checking if the value in X-Requested-With is given in the header.
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']))
{
$content = '';
if (isset($modx->documentObject['content']))
$content = &$modx->documentObject['content'];
// Set the event output
$modx->documentOutput = $content;
}
Any feedback on this /or pointing to a place where a same / better solution is provided would be nice.
If not it might be interesting to implemented this into MODx or make this a plugin? Any naming suggestions?
Grz,
Stefan