Is it possible to dynamically load a function within a template file without loading the header and footer?
Assuming that the URL loads:
website.com/index.php?action=xyz
I've managed to work it by using exit(); at the very end, but in case there's a better method, I'd like to know.
Set $context['template_layers'] to an empty array to skip them.
On a similar note, how do I stop Google from crawling these AJAX-based pages?
Don't link to them in the first place?
Failing that there is a directive you can set in $context to emit a no index, but I don't remember what it is offhand.
Quote from: Arantor on August 10, 2018, 02:59:00 AM
Don't link to them in the first place?
Failing that there is a directive you can set in $context to emit a no index, but I don't remember what it is offhand.
It's hard not to, and even if I don't via some javascript code, search engines still get to them
One more question based on my original inquery, I tried this:
function search()
{
global $context;
$context['template_layers'] = array();
echo'My Text';
}
It comes up as a white screen with "my text" then underneath: An Error Has Occurred! Unable to load the 'main' template.
What does that suggest?
That suggests you haven't set up $context['sub_template'] to point to the template_ function that should be handling your output because separating out the logic of processing from its output is great.
If you need to spit out JSON and no other stuff, echo the json_encode then call obExit(false) to send without any other processing.
Thank you