1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What would I do with this PHP?

Discussion in 'XenForo Development Discussions' started by Alexander Firth, Mar 4, 2015.

  1. Alexander Firth

    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
     
  2. Jake B.

    Jake B. Well-Known Member

    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
     
    Alexander Firth likes this.
  3. Alexander Firth

    Alexander Firth Active Member

    Thanks, I figured as much. To the add-on request forum I go.
     
  4. Alexander Firth

    Alexander Firth Active Member

    Actually, could I just get this moved to add-on requests? Thanks :)
     
  5. Brogan

    Brogan XenForo Moderator Staff Member

    You could probably do it with a very basic xen:callback.
     

Share This Page