I've got some pages such as the user-agreement that I want to appear with or without the layout (extends
tag) depending on how it is called. I'm using jQuery Fancybox
to load up these pages in iframes. If JS is disabled, the links should open in a new window w/ the full layout, otherwise, if they're in an iframe, they don't need the layout.
As of now, I'm doing using jQuery to strip out the header/footer (replacing the body with just the content portion)
if(window.location != window.parent.location) {
$('body').html($('#content'));
}
But it doesn't seem right to load stuff that will never be displayed (or worse, will be displayed for a half second until the JS kicks in). I guess what I could do is create a partial template containing only the content, and then two container pages, one with the header/footer and one without; they both include the partial. Then use JS to modify the link... which would have to point to different views, which would in turn call the different templates... seems like an awful lot of work. There's gotta be a better way?
@ZeissS:
Something like this is not possible in Django:
{% if not iframe %}
{% extends "layouts/default.html" %}
{% endif %}
The {% extends %}
tag must be the first tag in the template, thus it cannot be conditionally commented out. I guess maybe I could do it in the layout itself...and then it'd apply to all my pages.... let's try that.