Resource icon

HowTo: Add a dynamic footer to XenForo 1.0

No permission to download

LPH

Well-known member
lph submitted a new resource:

HowTo: Add a dynamic footer to XenForo - Add title and links to the latest five resources and community threads to the bottom of XF

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.
View attachment 48931

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

Step 1: Create the file...

Read more about this resource...
 
That's pretty cool and would be good to use for example in Russ's Core footer.

Can I ask why this isn't packaged as a normal addon (i.e. an XML file that we can install)? Is there a technical reason or is it just how you've done it?
 
That's pretty cool and would be good to use for example in Russ's Core footer.

Can I ask why this isn't packaged as a normal addon (i.e. an XML file that we can install)? Is there a technical reason or is it just how you've done it?

Because I didn't know how ;)

If someone can tell me how then I can try ...
 
I'm pretty sure when you have debug on you can export the addon and it will create the xml file for you. Then just put the files in proper directories, zip it up.
 
hi got Error any help on thees :cry:

PHP:
An exception occurred: Invalid model 'XenResource_Model_Resource' specified in C:\xampp\htdocs\x\library\XenForo\Model.php on line 192

XenForo_Model::create() in TuxFooter/Listener/Footer.php at line 26
TuxFooter_Listener_Footer::includeTuxFooter()
call_user_func_array() in XenForo/CodeEvent.php at line 54
XenForo_CodeEvent::fire() in XenForo/Template/Abstract.php at line 285
XenForo_Template_Abstract->callTemplateHook() in XenForo/Template/Abstract.php(265) : eval()'d code at line 873
eval() in XenForo/Template/Abstract.php at line 265
XenForo_Template_Abstract->_renderInternal() in XenForo/Template/Abstract.php at line 191
XenForo_Template_Abstract->render() in XenForo/Template/Public.php at line 110
XenForo_Template_Public->render() in XenForo/ViewRenderer/HtmlPublic.php at line 135
XenForo_ViewRenderer_HtmlPublic->renderContainer() in XenForo/FrontController.php at line 568
XenForo_FrontController->renderView() in XenForo/FrontController.php at line 156
XenForo_FrontController->run() in C:/xampp/htdocs/x/index.php at line 13
 
Did you modify the file location for your XenForo installation?

Check the Footer.php file you created and make sure the locations are correct.
 
oh got it I think ... the problem i don't have resource manager install... :cry:

do i need it ? :whistle:

Yes, for the complete code to work then you must own the resource manager. You are welcome to strip out that portion of the code.

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="pageWidth">

       <div class="forum_posts_leftside">

       <h3>Put A Meaningful Headline Here</h3>

       <?php


/* Add in some code to your liking */


       ?>

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

           <div class="forum_posts">

             <h3>The following posts are 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.DOMAIN.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();
       }

   }

}
?>
 
Top Bottom