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

Unmaintained XenForo Connector 1.0

Integrate XF data on your website

  1. Benjy

    Benjy Well-Known Member

    dwdmadmac, RickM and Fuhrmann like this.
  2. electrogypsy

    electrogypsy Active Member

    um, im a little unclear what this addon is supposed to do. what data does it pull into your website from the message board?
     
  3. Benjy

    Benjy Well-Known Member

    Any data you can pull off XenForo as it basically loads the whole system (including Zend).
     
    RickM likes this.
  4. RickM

    RickM Well-Known Member

    I'm trying to use this to pull some posts. I've got all the post data, but cant seem to run the parser on it, I just get the message with its BBCode tags - how would I go about converting it to HTML using XenForo's parser?

    Thanks :)
     
  5. Benjy

    Benjy Well-Known Member

    Here is a demo for a post array and how I use it; there are other formatters and options available, you will have to dive a bit in the code :)
    PHP:
    $bbCodeParser = new XenForo_BbCode_Parser(new XenForo_BbCode_Formatter_Base());
     
    $bbCodeOptions = array(
      
    'noFollow' => true,
      
    'showSignature' => false,
      
    'states' => array(
        
    'viewAttachments' => false
      
    )
    );
     
    echo 
    XenForo_ViewPublic_Helper_Message::getBbCodeWrapper($post$bbCodeParser$bbCodeOptions);
     
    dwdmadmac, Jarod and RickM like this.
  6. RickM

    RickM Well-Known Member

    Fantastic - that worked really well - Thanks very much Benjy, you've made my day :D
     
  7. Matthew2D

    Matthew2D Active Member

    Can this integrate with another xenforo install? Like xenforo to xenforo.
     
  8. Benjy

    Benjy Well-Known Member

    I don't understand your question?
     
  9. Matthew2D

    Matthew2D Active Member

    Can you login with one xenforo info on another xenforo install, with this?
     
  10. Benjy

    Benjy Well-Known Member

    No, this is for an external website, not an XF2XF bridge.
     
  11. craigiri

    craigiri Well-Known Member

    Is there a sample to pull off the "X" most recent posts from "Y" forums and then display them in a plain (external to XF) PHP page on the same site? Dynamically, of course, and with links to the posts....
    (my posts are visible to guests, so that part is not a problem).
     
  12. RickM

    RickM Well-Known Member

    Here's some code I use to do just that on a PyroCMS widget. Basically where I've got $options['xfexclude'] that contains a list of forums ids to exclude, and then obviously $options['xflimit'] is the number of results to return. In my code I've got it returning the query results into an array as this then goes off to my view file, however the function should give you the basic structure for a basic non-xf php page.

    PHP:
        public function run($options)
        {
            
    $excludeForums = array();
            if(!isset(
    $options['xflimit']) || $options['xflimit'] < 1)
            {
                
    $options['xflimit'] = 10;
            }
         
            if(!empty(
    $options['xfexclude']))
            {
                if(
    strstr($options['xfexclude'], ','))
                {
                    
    $excludeForums explode(','$options['xfexclude']);
                }
                else
                {
                    
    $excludeForums[] = $options['xfexclude'];
                }
            }
     
            
    $threadModel XenForo_Model::create('XenForo_Model_Thread');
            
    $sql 'SELECT thread.* FROM xf_thread AS thread WHERE node_id NOT IN("'.$options['xfexclude'].'") ORDER BY last_post_date DESC LIMIT '.$options['xflimit'].'';
         
            
    $where "NOT IN('".$options['xfexclude']."')";
            
    $query $this->db->query($sql);
            
    $result $query->result();
            return array(
    'threads' => $result);
        }
    If you take a look at the link in my signature, on the homepage near the bottom you'll see it using the data from the above function in a 'widget' box showing the latest threads.
     
  13. craigiri

    craigiri Well-Known Member

    Thanks for that!
    I see what you are doing, but my coding is pretty rusty - I'll fiddle with it when I have a chance. As mentioned, I just want to insert it in a stand alone php page. I assume I will make another php page to fiddle with this and then include that one in the home page...or something like that.
     
  14. Benjy

    Benjy Well-Known Member

    For the sake of example, here's how I do it:

    PHP:
    $nodeModel XenForo_Model::create('XenForo_Model_Node'); // Retrieve the default viewable forums
    $nodes $nodeModel->getViewableNodeList();
     
    unset(
    $nodes[X], $nodes[Y]); // X, Y are the IDs of publicly viewable forums but I don't want to retrieve threads from them
     
    $latestthreads = array();
     
    // Here I use XF's own $db connector (Zend_Db), but you can do it another away
    $db XenForo_Application::getDb();
     
    $threads $db->query("
        SELECT thread_id, title, reply_count, post_date
        FROM xf_thread
        WHERE node_id IN (" 
    implode(',',  array_keys($nodes)) . ")
            AND discussion_state = 'visible'
            AND discussion_open = 1
            AND sticky = 0
        ORDER BY post_date DESC
        LIMIT 10
    "
    );
     
    while (
    $thread $threads->fetch())
    {
        
    $latestthreads[$thread['thread_id']] = array(
            
    'id' => $thread['thread_id'],
            
    'title' => $thread['title'],
            
    'url' => XenForo_Link::buildPublicLink('canonical:threads'$thread),
            
    'replycount' => $thread['reply_count'],
            
    'dateline' => $thread['post_date']
        );
    }
     
    // $latestthreads contains all your threads data
     
  15. craigiri

    craigiri Well-Known Member

    Thanks...the only question I have is whether these template examples need to be created where they "know" XF is there - for instance, inside the XF system.

    That is, are the references to XF in the code just created php objects, and if not, how do they know XF is even there?
    (XenForo_Model, etc.)
     
  16. Benjy

    Benjy Well-Known Member

    That's what the connector is for :)
     
  17. craigiri

    craigiri Well-Known Member

    Ah now I get it. Thanks...
     
  18. craigiri

    craigiri Well-Known Member

    Dang, I am rusty.....can't get it to work....

    Firstly, is the path to XF setting in the connector from the web root or server root? In other words, if my XF main directory is /talk , is that all I need there? Or do I point deeper into XF or from the server root?

    Secondly, is there any easy way of testing to see if the connector works? Just a one or two line php to include it and return that everything is found and connected?

    I tried putting the connector in a php file and then including it in another php file using the above code examples (tried each separately) and got no results (redirect or empty screen).
     
  19. Benjy

    Benjy Well-Known Member

    When you define XF_ROOT, the path should be from the server root. You can use dirname(__FILE__) or __DIR__ to set the path from the current file. Be careful, don't include any trailing slash.
    I guess you can try var_dump($visitor).
     
  20. Brendon Meynell

    Brendon Meynell Active Member

    Okay I don't know whether I am stupid or not really understanding this.

    Where abouts do we put the connector code - do we make a new php file and include it somewhere?
    All I am attempting to do is like many others get the last couple of forum posts and display them on the front page of my php coded website.
     

Share This Page