What would I do with this PHP?

Alexander Firth

Active member
Some of my users want to install MathJax on our site for their maths courses etc, we have a homework/coursework help section. I got MathJax working successfully, but this added a full second to all page load times, so I dropped it. The users are still very much demanding it, and one of them wrote this for me:

PHP:
<?php
    unset($out);
    $out = "";
    if(preg_match("#mathjax#",$_SERVER['REQUEST_URI'])){
        $out = '<script type="text/javascript"src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>';
    }
    print $out
?>

Apparently this would only make the relevant files load in subforums with 'MathJax' in the forum URL something. I'm personally baffled. Would this work without wrecking page load times elsewhere, and if so where do I stick it?

I don't know PHP yet :p
 
It checks if mathjax is in the URI somewhere, and then loads that script. However, you would need to create some sort of small add-on to pass that to the template as you cannot use PHP in templates with XenForo.

-Jake
 
It checks if mathjax is in the URI somewhere, and then loads that script. However, you would need to create some sort of small add-on to pass that to the template as you cannot use PHP in templates with XenForo.

-Jake
Thanks, I figured as much. To the add-on request forum I go.
 
It checks if mathjax is in the URI somewhere, and then loads that script. However, you would need to create some sort of small add-on to pass that to the template as you cannot use PHP in templates with XenForo.

-Jake
Actually, could I just get this moved to add-on requests? Thanks :)
 
Back
Top Bottom