Inserting a PHP include - is it possible?

Thom Tyler

Well-known member
Hi there,

Haven't seen any information on this. Basically, want to know if it's possible to insert PHP into the page. for example, I'm currently using vBulletin and they totally changed their plugin system which made it a nightmare for simple include tags.

I use frontpage slideshow, which i control from an external php file, for example. ss.php.

in vBulletin, I had to add a plugin and embed the code there for it to call the ss.php, then inserted the plugin name into the vB template and voila....the slideshow appeared at the top of the page.

I've had a quick play with my friends install of Xenforo, and it seems like a world of pain to do anything similar. Can someone point me to a guide to see if it's possible.

I've gotta say, it's not very good that i can't comment in the troubleshooting or install sections because I'm not a customer....vBulletin.org allowed this, it just simply didn't allow me to the customer area. It doesn't allow me to ask the questions I want answering before I buy.

$140 is a lot to fork out if it doesn't do what I expect....

hope to hear from someone in the know.

Cheers,
 
Cheers Brogan, I'll ask him to sort it when he's on.

Just been trying Cu3er if any of you know it, instead of my joomla show. It tells me the exact code I need to embed, yet I still get a T_STRING error. Am I missing a tag?

PHP:
<?php

class Demo_Listener
{
  public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if ($hookName == 'footer_links')
            {
                $contents .= '<div id="CU3ER">
<p>If you do not see content of CU3ER slider here try to enable JavaScript and reload the page</p>
</div>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/jquery.cu3er.js"></script>
<script type="text/javascript">

  jQuery(document).ready(function($) {
    $("#CU3ER").cu3er({
      vars: {
        width: 640,
        height: 480,
        flash_version : "10.0.0",
        xml_location : 'CU3ER-config.xml',
        swf_location: 'CU3ER.swf'
      },
      params: {
        bgcolor : '#ffffff'
      },
      attributes: {
        id: "CU3ER",
        name: "CU3ER"
      }
    });
  });

</script>';

        }

    }

}
Also don't include jQuery & SWFObject's JS, XenForo already includes them.
 
Cheers man , I'm using Notepad at the moment....which is half the problem. Got Dreamweaver at work, so I'll take a look!

James - how should the code look then? As I say, I'm not a coder and Xenforo being so new, there's no tutorials from 3rd parties on how to get their scripts to work!
 
Code:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>

If you remove them two, it should still function just fine.
 
I get a T_STRING error at Line 24, which seems odd as the code is exactly as the output from Cu3er's webpage.

If you can help me get it working, I'll make a donation (If you're a coder or have a donation pot) as it means I will have a working slider which means I can convert to XenForo tomorrow.

Thanks in advance.

Edit: Could the error be that it can't find the .xml file? Cu3er tells me to put it in the site root (X:\Localhost\devforum) is this right, or will it look for it in X:\localhost\devforum\library\Demo ?
 
Your problem is this line:
bgcolor : '#ffffff'
because the single quote is causing the PHP to stop, hence why the #ffffff is a different colour.

Try using heredocs instead.
 
Try this:
PHP:
Try this:
<?php

class Demo_Listener
{
  public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if ($hookName == 'footer_links')
            {
                $contents .= <<<HTML
<p>If you do not see content of CU3ER slider here try to enable JavaScript and reload the page</p>
</div>

<script type="text/javascript" src="js/jquery.cu3er.js"></script>
<script type="text/javascript">

  jQuery(document).ready(function($) {
    $("#CU3ER").cu3er({
      vars: {
        width: 640,
        height: 480,
        flash_version : "10.0.0",
        xml_location : 'CU3ER-config.xml',
        swf_location: 'CU3ER.swf'
      },
      params: {
        bgcolor : '#ffffff'
      },
      attributes: {
        id: "CU3ER",
        name: "CU3ER"
      }
    });
  });

</script>
HTML;

        }

    }

}
 
No T_STRING, Good on that front mate, in fact...awesome.

However, It doesn't display in the footer. It simply displays the "If you do not see content of CU3ER slider here try to enable JavaScript and reload the page"

any ideas?
 
Try adding this:
Code:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
above this:
Code:
<script type="text/javascript" src="js/jquery.cu3er.js"></script>

If this doesn't work, view the HTML and look at the directory its looking in for the JS.
 
Cheers for your continued assistance James.

Just to confirm, this is where the output tells me to put things if it were a normal website. How this relates to Xenforo's directories and where the plugin looks, I'm unsure?

Step 1→ Upload your files to server.




File/folder
Target Destination
CU3ER.swf
Configuration XML file
"js" folder
"CSS" folder
"images" folder
"fonts" folder
Step 2→ Open your article/section and insert following in HTML Source editor:


<div id="CU3ER"> <p>If you do not see content of CU3ER slider here try to enable JavaScript and reload the page</p> </div> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript" src="js/swfobject.js"></script> <script type="text/javascript" src="js/jquery.cu3er.js"></script> <script type="text/javascript"> jQuery(document).ready(function($) { $("#CU3ER").cu3er({ vars: { width: 640, height: 480, flash_version : "10.0.0", xml_location : 'CU3ER-config.xml', swf_location: 'CU3ER.swf' }, params: { bgcolor : '#ffffff' }, attributes: { id: "CU3ER", name: "CU3ER" } }); }); </script>

Step 3→ Upload your page to server and you are done!
 
It's not online at the moment. It's on a friends dev PC which I RDP into (He has a License, I'm testing his to see if I can get the slider to work, which if I can I ditch vB and get xF tomorrow!) It's odd,
 
Hi mate. if you can get the cu3er thing working ill give ya a £20 Donation. if you can test it on your own board to see if you can get it to work. just use the free version of cu3er. cu3er.com. I bloody need a slideshow before i can get onto XenForo! :(
 
Top Bottom