Resource icon

Unmaintained HowTo: Add a dynamic footer to XenForo 1.0

No permission to download
The footer on XenForo forum software may be modified to include the latest five resources to the resource manager and the latest five threads added to the community.

Constraints: You must own the resource manager and have it installed.

Tools:
  • Text editor
  • FTP software
This is the look of the final work.
Screen Shot 2013-06-14 at 1.40.59 PM.webp


WARNING: Create this add-on locally first. Do not edit on a live site.

Step 1: Create the file /library/TuxFooter/Listener/Footer.php

Step 2: Add the following into the Footer.php file


PHP:
<?php

class TuxFooter_Listener_Footer {

    public static function includeTuxFooter($hookName, &$contents, array $hookParams, XenForo_template_Abstract $template) {

        if($hookName == 'ad_below_bottom_breadcrumb') {

            ob_start();

            ?>

            <div class="forum_footer">

            <div class="forum_posts_leftside">

            <h3>latest tux reports network resources</h3>

            <?php

            /* Script to pull the latest updated resources from the XF Resource Manager */

            /** @var $resModel  XenResource_Model_Resource */

            $resModel = XenForo_Model::create('XenResource_Model_Resource');

            $fetchOptions = array('limit' => 5, 'order' => 'resource_date', 'direction' => 'desc');

            $rmupdates = $resModel->getResources(array(), $fetchOptions);

            foreach ($rmupdates AS $rmupdate) {

                echo ("<div class='entry-meta'><a href='http://community.tuxreportsnetwork.com/" . XenForo_Link::buildPublicLink('resources', $rmupdate) . "' >" . XenForo_Helper_String::wholeWordTrim($rmupdate['title'], 55) . "</a> <br /></div>"); // Echo the title with a link.

            }

            ?>

                    </div><!-- Close forum_posts_leftside -->

                    <div class="forum_posts">

                        <h3>latest posts from our community</h3>

                        <?php

                        /* Script to pull the latest posts from the XF Forum */

                        $db = XenForo_Application::getDb();

                        if ( !$db ) {

                            die( 'This script did not connect to the database' . mysql_error() );

                        }

                        $thread_qry = "

                                    SELECT * FROM `xf_thread`

                                    ORDER BY `last_post_date` DESC

                                    LIMIT 5

                                    ";


                        $threads = XenForo_Application::get('db')->fetchAll($thread_qry);

                        foreach (    $threads AS $thread ) {

                            echo ("<div class='entry-meta'><a href='http://community.tuxreportsnetwork.com/" . XenForo_Link::buildPublicLink('threads', $thread) . "' >" . XenForo_Helper_String::wholeWordTrim($thread['title'], 48) . "</a> <span style='float:right; margin-right:60px'>Viewed: " . $thread['view_count']

                                    . "</span><br /></div>"); // Echo the title with a link.

                        }

                        ?>

                    </div><!-- Close forum_posts -->

                </div><!-- Forum Footer -->

<?php

                $contents .= ob_get_contents();

                ob_end_clean();

            }

    }

}

?>


Adjust the hyperlinks so that they match your website.


Step 3: Enable development for your community

Edit the /library/config.php

Add the line

PHP:
$config['debug'] = true;

Save the file


Step 4: Log into your community's admin panel.

Step 5: Create the add-on

development > Create Add-on


Screen Shot 2013-06-14 at 1.49.32 PM.webp


Step 6: Create the listener

Add the information as shown in the image. Save Event Listener.


Screen Shot 2013-06-14 at 1.52.13 PM.webp


Step 7: Test the loading of your site. Did the footer now show?

Step 8: Add the CSS information to your liking.

Step 9: Comment out the debug line in the /library/config.php file.

If you are able to do this work locally then complete the same steps on your live site.

This is my first add-on modification. I am not an expert but learning. Please do not PM me for help but ask in the discussion. ;)
Author
LPH
Downloads
47
Views
1,047
First release
Last update

Ratings

5.00 star(s) 1 ratings

More resources from LPH

Latest reviews

Excellent
LPH
LPH
Glad this is working for you. Please don't forget to add a link to your work so others can see it in action.
Top Bottom