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

Inserting a PHP include - is it possible?

Discussion in 'XenForo Pre-Sales Questions' started by Thom Tyler, Jun 16, 2011.

  1. Thom Tyler

    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,
     
  2. ragtek

    ragtek Guest

    It's very similar.

    get the data and use the template hooks http://xenforo.com/community/threads/how-to-use-template-hooks.13167/ for the output
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

    The troubleshooting and installing forums are for customers who are having problems with their actual installs/forums.

    I've moved your thread to pre-sales which is the best place for questions from prospective customers.
     
  4. Thom Tyler

    Thom Tyler Well-Known Member

    Sorry Brogan,

    what I meant was, there doesn't seem to be the right section. Normally Pre-sales is massively overlooked, but if that's not the case....then great!
     
  5. Marc

    Marc Well-Known Member

    Not overlooked over here m8 .. Asks ur questions and ye shall answer :)
     
  6. Thom Tyler

    Thom Tyler Well-Known Member

    Hi,

    I just followed that video....but it wasn't the most straight forward thing in the world....but here's a go I've had. I'm going to get a friend to test it for me, but before I break his forum.....is this right?

    I'm aware it's set to the footer, I can correct the hook once ive got my own install (Don't know their names) as long as the rest works

    PHP:
    <?php

    class Demo_Listener
    {
      public static function 
    templatehook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
        {
            if (
    $hookname == 'footer_links')
                {
                    
    $content .- '
                <?php

                /* Frontpage Slideshow: Setup Steps */
                /* Please refer first to the online documentation here: http://www.joomlaworks.gr/content/view/74/41/ */

                // 1. Enter the name of your slideshow
                $slideshow = "demo";

                // 2. Enter your site'
    s URL (without trailing slash)
                
    $siteURL "/localhost/devforum"// e.g. http://www.site.com or http://www.site.com/folder if your site is in a subfolder

                // 3. Enter the absolute path of your site on the server (without trailing slash)
                
    $sitePath "X:/localhost/devforum/"// e.g. /home/user/public_html or /home/user/public_html/folder if your site is located in a subfolder

                // Include the slideshow
                
    include_once($sitePath."/fpss/fpss.php"); // DO NO EDIT THIS LINE

                
    ?>';

            }

        }

    }

    Obviously if it works, I'll make the switch as everything else seems much better than vBulletin, apart from this which is bothering me!
     
    Shamil likes this.
  7. Thom Tyler

    Thom Tyler Well-Known Member

    Hoping someone can answer my query today, as I need to get moving if I don't want to get left behind by others with my upcoming project, so need to make a decision as to go with Xenforo or renew vB ASAP.

    Also, tried it on my friends dev board. it comes back as saying there's an unparsed error T_STRING at line 18.

    Not sure what's wrong, so awaiting advice before I make a decision today about the ordering process of which CMS software.

    Thanks..
     
  8. ragtek

    ragtek Guest

    C'mon your code is full of errors;)

    Line 7: if ($hookname == 'footer_links') should be $hookName because that's your param
    Line 9: $content .- ' should be $contents .=



    Line 10: wtf?? why do you start the php tag once again?
    Line 18: your string ends here because your comment includes '
    etc...
     
    Marc likes this.
  9. whynot

    whynot Well-Known Member

    Ask your friend with the XF licence to ask the same question here.
     
  10. Thom Tyler

    Thom Tyler Well-Known Member

    Cheers for the replies, I guess I was very tired lol.

    I'll take a look at that. And Whynot, It's my question. If I'd seen a demo of it on someone elses site, there would be no such thread asking to see that it works. However, I'm yet to see another XF with the slideshow running, so I feel I'm entitled to ask if it works before shelling out $140 of my hard earnt cash. I'm 25 years old, so I can clearly see you're undercover method of suggesting I'm trying to circumvent things, which isn't the case.

    If anything, I'm doing a good thing. I'm willing to learn something new and support the developers for the future. And if anything, that's a leap of faith especially as IB want to rip xF a new one, so I could be investing $140 of my cash into a product that may not be here this time next year, which I've invested time and money into......

    So, forgive me for wanting to make sure it's worth my while and works as expected?

    As i mentioned earlier, if it followed the vB rule of a mods section seperate from the customers section, I could of asked a dev directly if it would work. However, as I cannot post in this section, I've had to do it arse about face and put it in here.

    Ragtek, you're reply was greatly appreciated. I'll have another look at it ;)
     
  11. Thom Tyler

    Thom Tyler Well-Known Member

    Hi all,

    Well it looks like it works to an extent, but it''s killed my friends dev server via RDP.

    states

    Non-static method JWFrontpageSlideshowHelper::ampReplace() should not be called statically

    This is obviously caused by the public static call at the beginning. is there a public active call or something along those lines?
     
  12. Luke F

    Luke F Well-Known Member

    It's technically possible by all means - I included legacy scripts before I had any idea what I was doing.
     
  13. Thom Tyler

    Thom Tyler Well-Known Member

    Have you used something like FPSS?

    I've tried calling it using the above method, but it won't allow me and gives me tonnes of errors on my friends localhost dev board. It comes up with the error above, saying it should be called as a non-static. looking into that, I then have to name the class etc?

    I've also tried embedded the <php? code for the slideshow above onto a file call ss.php, then adding the following:
    PHP:
    <?php

    class Demo_Listener
    {
      public static function 
    templatehook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
        {
            if (
    $hookName == 'footer_links')
                {
                    
    $contents .= <?php include('ss.php'); ?>
          }

        }

    }
    (That's not the exact code i used, but as an example) But that doesn't look right nor work either.... if i removed the <?php before the include, nothing showed at all, but if i left it, it returned an error.

    This does seem a fair bit more complicated than it needs to be in my opinion, but I gotta say i do like xF .

    Can anyone show me where I'm going wrong? If I can't get it working on my friends dev board in the next few hours, schedule commitments will mean I have to go with vB4.

    Thanks,
    Thom
     
  14. ragtek

    ragtek Guest

    Without php knowledge you will have the same problems in your vB, because you're having stupid php mistakes in your code(if not even much more problems, because of vB4...)
    my 0.02$
     
  15. Thom Tyler

    Thom Tyler Well-Known Member

    I've already got it working on my vB4 dev board.....got no such conflict after creating a plug in, it just worked.

    As for the bit about my errors, I'knew I made some last night and to be honest, when it came to the include tag, I was just taking shots in the dark.

    I'm not a coder, nor do I claim to be.

    But thanks for that.....some pointers would have been nice....and in fact, as i said to you, i got it to display but with errors with this code.

    it then states that I can't call it as a static function (So, in fact, despite fixing the code and following the Video it still didn't work...

    anyway, here's the code I used.

    PHP:
    <?php

    class Demo_Listener
    {
      public static function 
    templatehook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template)
        {
            if (
    $hookName == 'footer_links')
                {
                    
    $contents .=

                
    $slideshow "demo";

                
    $siteURL "\localhost\devforum";

                
    $sitePath "X:\localhost\devforum";

                include_once(
    $sitePath."\fpss\fpss.php");

            }

        }

    }
    With that code above, I can see the slideshow, it works etc....but it's got like 30 errors below it, which all seem linked to the same thing.

    Template Errors: PAGE_CONTAINER

    1. Creating default object from empty value in \localhost\devforum\fpss\fpss.php, line 66:
      65: </script>'; 66: } 67: $__compilerVar1 .= $__compilerVar2;
    2. Non-static method JWFrontpageSlideshowHelper::ampReplace() should not be called statically in \localhost\devforum\fpss\fpss.php, line 73:
      72: $__compilerVar3 .= ' <script type="text/javascript" src="' . htmlspecialchars($jQuerySource) . '"></script> 73: '; 74: if ($jQuerySource != $jQuerySourceLocal)
    3. Non-static method JWFrontpageSlideshowHelper::wordLimiter() should not be called statically in \localhost\devforum\fpss\fpss.php, line 115:
      114: $__compilerVar4 .= ' 115: <script type="text/javascript" src="' . XenForo_Template_Helper_Core::styleProperty('imagePath') . '\xenforo\js\toggle_simple.min.js"></script> 116: ';
    4. Creating default object from empty value in \localhost\devforum\fpss\fpss.php, line 66:
      65: </script>'; 66: } 67: $__compilerVar1 .= $__compilerVar2;
    5. Non-static method JWFrontpageSlideshowHelper::ampReplace() should not be called statically in \localhost\devforum\fpss\fpss.php,line 73:
      72: $__compilerVar3 .= ' <script type="text/javascript" src="' . htmlspecialchars($jQuerySource) . '"></script> 73: '; 74: if ($jQuerySource != $jQuerySourceLocal)
    6. Non-static method JWFrontpageSlideshowHelper::wordLimiter() should not be called statically in \localhost\devforum\fpss\fpss.php,, line 115:
      114: $__compilerVar4 .= ' 115: <script type="text/javascript" src="' . XenForo_Template_Helper_Core::styleProperty('imagePath') . '\xenforo\js\toggle_simple.min.js"></script>
      116: ';
    As I stated before, the EXACT same slideshow works just fine in vB4 using the below

    PHP:
    ob_start();

      include(
    "../header.php");

      
    $globalHeader ob_get_contents();

    ob_end_clean();

    $preRegister['globalHeader'] = $globalHeader;

    vB_Template::preRegister('header'$preRegister);  
    as a plugin, then adding the pre-registered tag.

    Code:
    {vb:raw globalHeader}
    So no, vB was MUCH EASIER!

    Seems no-one from the official xF team is interested either, as I've not had a peep out of them. Thanks to everyone else who contributed, but seeing as my purchase relies on this feature, I thought I may of heard something from them by now..

    oh well.....
     
  16. Mike

    Mike XenForo Developer Staff Member

    XenForo uses strict coding standards and throws errors when it runs into things that are not optimal. It seems like the code you're integrating may not be coded to that level, which may cause some problems. All of those errors are being triggered by your code. You could try dropping the error_reporting down at the beginning of your code.

    I will say that we can't really provide official support for any code modifications. Regarding the location of this thread, your friend with a license can add you via the customers area, and you'd be able to post in the development forums then.
     
  17. Thom Tyler

    Thom Tyler Well-Known Member

    Hi Mike,

    Cheers for the reply. I've looked up the function it was saying was at fault, and oddly enough it appears it's a joomla function (This slideshow was originally designed for Joomla, but this was meant to be the standalone version for any PHP site). Secondly, how does my friend add me to the customer section (Does it add me as a joint user?)

    All i need is to see a working slideshow and know its obtainable and I'll make the switch (Got the cash ready for the license) just need it to be confirmed.

    With that in mind, has anyone tried anything with a slider and had any luck - if so, can they show me?
     
  18. Brogan

    Brogan XenForo Moderator Staff Member

  19. Thom Tyler

    Thom Tyler Well-Known Member

    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 $hookParamsXenForo_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>';
      
            }

        }

    }
     
  20. ragtek

    ragtek Guest

    once again:p
    check your code and use a real IDE which shows you automatic the errors;)

    xml_location : 'CU3ER-config.xml',
    swf_location: '
    CU3ER.swf'
    },
    params: {
    bgcolor : '
    #ffffff'
    },
     

Share This Page