1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Template Hook Locations

Discussion in 'Development Tutorials [Archive]' started by Indigo, Dec 4, 2010.

  1. Indigo

    Indigo Active Member

    As of 1.0.0 Beta 4, there are 9 template hooks within the codebase. This is a list of what they are, where they are, their parameters, and what they contain. Some have a quick explanation of how they can be used. I'll try to remember to keep this updated as new releases come out.

    editor_js_setup
    Template: editor_js_setup
    Parameters
    - editorId: The ID of the editor. For example, this area I'm using to write the thread is "ctrl_message"
    Contains all the setup code for tinyMCE. Could theoretically be used to pass more options to tinyMCE, or change existing options, via regular expressions.

    footer_links
    Template: footer
    Contains the HTML for the Contact Us/Home/Top links. Can be used to add more links/data or alter the links in that area.

    footer_links_legal
    Template: footer
    Same as above, but for the Terms/Privacy Policy links that appear directly underneath the previous hook.

    forum_list_sidebar
    Template: forum_list
    Contains the sidebar, basically. Note that this hook currently only works for the forum list's sidebar, not the one that appears on the recent activity page. There are some "sub hooks" in the form of HTML comments that can be hooked into.
    <!-- block: sidebar_online_staff --> is before the Staff Online area.
    <!-- block: sidebar_online_users --> is between staff online and normal members online.
    <!-- block: forum_stats --> is between the online users and statistics.
    <!-- end block: forum_stats --> is after the forum stats.
    <!-- slot: forum_stats_extra --> is at the end of the statistics list, allowing you to add more stats.

    message_user_info_avatar
    Template: message_user_info
    Parameters
    - user: Information about the author of the message.
    Contains the avatar holder div, and the avatar of the postbit. <!-- slot: message_user_info_avatar --> is within the avatar holder, after the avatar itself.

    message_user_info_text
    Template: message_user_info
    Parameters
    - user: Information about the author of the message.
    Contains the username and user title part of the postbit. <!-- slot: message_user_info_text --> is within the <h3 class="userText">, after the user title.

    message_user_info_extra
    Template: message_user_info
    Parameters
    - user: Information about the author of the message.
    Contains extra information in the postbit (if you have it configured to display), like the post count, number of likes, join date, etc. Could be used to add things like a "Points" field, arcade trophies, etc. to the postbit.

    page_container_head
    Template: PAGE_CONTAINER
    Contains the full contents of the <head> tag. Can be used to add data to the <head> of all pages, or modify what is already there.

    page_container_js_body
    Template: page_container_js_body
    Contains all the various "information passing" code for XenForo, like making options and phrases available to the JavaScript. Would generally be used for passing required JS information to your own addon (at least for what I intend to use it for).
     
  2. Floris

    Floris Guest

    Excellent resource, is it ok if I link to this from our xenfans documentation section as a resource to find for people?
     
  3. Indigo

    Indigo Active Member

    Sure, go ahead. :)
     
    Floris likes this.
  4. ragtek

    ragtek Guest

    How would you hook into this one:
     
  5. Indigo

    Indigo Active Member

    You could do
    PHP:
    $slot '<!-- block: sidebar_online_staff -->';
    $contents str_replace($slot$slot ' additional HTML'$contents);
    Make sure to leave the comment untouched in your replacement so other addons which use the same "slot" will still work.
     
    Mike likes this.
  6. ragtek

    ragtek Guest

    that's what i tried, but it's not working for me.
    PHP:
            if ($name == 'forum_list_sidebar'){
                
    $search '<!-- block: sidebar_online_staff --> ';
                
    $replace $search '<h1>new content</h1>';
                
    $contents str_replace($search$replace$contents);

            }
     
  7. Indigo

    Indigo Active Member

    Does your original code have a space at the end of $search? Is $contents being passed by reference to your callback?
     
    ragtek likes this.
  8. ragtek

    ragtek Guest

    thx:D
    time for the second coffee or a red bull
     
    Indigo likes this.
  9. Indigo

    Indigo Active Member

    Just a note, no template hooks were added in Beta 5.
     
  10. Indigo

    Indigo Active Member

    And another note, no additional template hooks were added in Beta 6.
     
  11. ragtek

    ragtek Guest

    And another note, no additional template hooks were added in RC1 ;) ^^
     
  12. Mike

    Mike XenForo Developer Staff Member

    Sorry, lost in the shuffle :)
     
  13. Alluidh

    Alluidh Well-Known Member

    Wrong answer, Mike, wrong answer ;)
     
  14. Floris

    Floris Guest

    RC2 next week? :D

    btw, added to our docs :)
     
  15. Indigo

    Indigo Active Member

    Oh boy, RC3 has 75 of these... Will probably just write a script that runs through and pulls out all the hook names and what template they're in.
     
  16. Indigo

    Indigo Active Member

    account_alert_preferences:
    Line 18: account_alerts_messages_in_threads
    Line 45: account_alerts_messages_on_profile_pages
    Line 76: account_alerts_achievements
    Line 90: account_alerts_extra

    account_contact_details:
    Line 10: account_contact_details_email_password
    Line 48: account_contact_details_messaging
    Line 75: account_contact_details_identities

    account_facebook:
    Line 6: account_facebook_associated
    Line 45: account_facebook_not_associated

    account_following:
    Line 11: account_following_memberlist
    Line 19: account_following_controls

    account_personal_details:
    Line 13: account_personal_details_status
    Line 50: account_personal_details_biometrics
    Line 81: account_personal_details_information
    Line 100: account_personal_details_about

    account_preferences:
    Line 9: account_preferences_appearance
    Line 29: account_preferences_locale
    Line 55: account_preferences_options

    account_privacy:
    Line 9: account_privacy_top
    Line 40: account_privacy_personal_details
    Line 72: account_privacy_news_feed
    Line 95: account_privacy_contact_details
    Line 124: account_privacy_bottom

    account_wrapper:
    Line 6: account_wrapper_sidebar
    Line 10: account_wrapper_sidebar_your_account
    Line 31: account_wrapper_sidebar_conversations
    Line 46: account_wrapper_sidebar_settings
    Line 85: account_wrapper_content

    editor:
    Line 1: editor

    editor_js_setup:
    Line 6: editor_js_setup

    footer:
    Line 20: footer_links
    Line 42: footer_links_legal

    forum_list:
    Line 12: forum_list_nodes
    Line 19: forum_list_sidebar

    forum_view:
    Line 33: forum_view_pagenav_before
    Line 120: forum_view_threads_before

    logo_block:
    Line 4: header_logo

    member_card:
    Line 22: member_card_links
    Line 36: member_card_stats1
    Line 41: member_card_stats2

    member_view:
    Line 38: member_view_sidebar_start
    Line 63: member_view_sidebar_middle1
    Line 109: member_view_sidebar_middle2
    Line 144: member_view_sidebar_end
    Line 204: member_view_tabs_heading
    Line 372: member_view_tabs_content

    message_user_info:
    Line 5: message_user_info_avatar
    Line 13: message_user_info_text
    Line 24: message_user_info_extra

    moderator_bar:
    Line 28: moderator_bar

    navigation:
    Line 56: navigation_tabs_forums
    Line 108: navigation_tabs_members
    Line 131: navigation_tabs_help

    navigation_visitor_tab:
    Line 5: navigation_visitor_tabs_start
    Line 26: navigation_visitor_tab_links1
    Line 37: navigation_visitor_tab_links2
    Line 86: navigation_tabs_account
    Line 129: navigation_visitor_tabs_middle
    Line 163: navigation_visitor_tabs_end

    PAGE_CONTAINER:
    Line 4: page_container_head
    Line 37: page_container_content_top
    Line 43: page_container_notices
    Line 66: page_container_breadcrumb_top
    Line 73: page_container_content_title_bar
    Line 101: page_container_sidebar
    Line 109: page_container_breadcrumb_bottom

    page_container_js_body:
    Line 3: page_container_js_body

    search_form_tabs:
    Line 2: search_form_tabs

    sidebar_visitor_panel:
    Line 11: sidebar_visitor_panel_stats

    thread_create:
    Line 31: thread_create_fields_main
    Line 68: thread_create_fields_extra

    thread_view:
    Line 71: thread_view_pagenav_before
    Line 116: thread_view_form_before
    Line 193: thread_view_qr_before

    xenforo.css:
    Line 599: xenforo_css_extra

    Generation code:
    PHP:
    <?php

    $file 
    $_SERVER['argv'][1];
    if ( !
    file_exists($file) ) {
        exit(
    'File does not exist.');
    }

    $xml simplexml_load_file($file);
    $count count($xml->template);

    $matches = array();
    foreach ( 
    $xml->template as $template ) {
        
    $data  = (string) $template;
        
    $title = (string) $template['title'];
        
    $lines preg_split("/\r\n|\r|\n/"$data);
        foreach ( 
    $lines as $lno => $line ) {
            if ( 
    preg_match('/<xen:hook name="([A-Za-z0-9_]+)"/'$line$match) ) {
                if ( !isset(
    $matches[$title]) ) {
                    
    $matches[$title] = array();
                }
                
    $matches[$title][] = array($match[1], $lno 1);
            }
        }
    }

    foreach ( 
    $matches as $title => $matchList ) {
        echo 
    "[b]$title:[/b]\n";
        foreach ( 
    $matchList as $match ) {
            echo 
    "Line $match[1]$match[0]\n";
        }
        echo 
    "\n";
    }
     
    Fuhrmann, kkm323, DarkSign and 6 others like this.
  17. Onimua

    Onimua Well-Known Member

    Very handy, thanks! :D
     
  18. ragtek

    ragtek Guest

    XF Beta3 Upadate

    Public templates:
    account_alert_preferences:
    Line 18: account_alerts_messages_in_threads
    Line 40: account_alerts_after_posts
    Line 47: account_alerts_messages_on_profile_pages
    Line 73: account_alerts_after_profile_posts
    Line 80: account_alerts_achievements
    Line 94: account_alerts_extra

    account_avatar:
    Line 9: account_avatar

    account_contact_details:
    Line 9: account_contact_details_email_password
    Line 47: account_contact_details_messaging
    Line 74: account_contact_details_identities

    account_facebook:
    Line 6: account_facebook_associated
    Line 45: account_facebook_not_associated

    account_following:
    Line 11: account_following_memberlist
    Line 19: account_following_controls

    account_ignored:
    Line 11: account_following_memberlist
    Line 19: account_ignored_controls

    account_personal_details:
    Line 13: account_personal_details_status
    Line 52: account_personal_details_biometrics
    Line 83: account_personal_details_information
    Line 104: account_personal_details_about

    account_preferences:
    Line 10: account_preferences_appearance
    Line 36: account_preferences_locale
    Line 69: account_preferences_options

    account_privacy:
    Line 9: account_privacy_top
    Line 40: account_privacy_personal_details
    Line 72: account_privacy_news_feed
    Line 95: account_privacy_contact_details
    Line 124: account_privacy_bottom

    account_wrapper:
    Line 6: account_wrapper_sidebar
    Line 10: account_wrapper_sidebar_your_account
    Line 31: account_wrapper_sidebar_conversations
    Line 46: account_wrapper_sidebar_settings
    Line 88: account_wrapper_content

    ad_above_content:
    Line 1: ad_above_content

    ad_above_top_breadcrumb:
    Line 1: ad_above_top_breadcrumb

    ad_below_bottom_breadcrumb:
    Line 1: ad_below_bottom_breadcrumb

    ad_below_content:
    Line 1: ad_below_content

    ad_below_top_breadcrumb:
    Line 1: ad_below_top_breadcrumb

    ad_forum_view_above_node_list:
    Line 1: ad_forum_view_above_node_list

    ad_forum_view_above_thread_list:
    Line 1: ad_forum_view_above_thread_list

    ad_header:
    Line 1: ad_header

    ad_member_view_above_messages:
    Line 1: ad_member_view_above_messages

    ad_member_view_below_avatar:
    Line 1: ad_member_view_below_avatar

    ad_member_view_sidebar_bottom:
    Line 1: ad_member_view_sidebar_bottom

    ad_message_below:
    Line 1: ad_message_below

    ad_message_body:
    Line 1: ad_message_body

    ad_sidebar_below_visitor_panel:
    Line 1: ad_sidebar_below_visitor_panel

    ad_sidebar_bottom:
    Line 1: ad_sidebar_bottom

    ad_sidebar_top:
    Line 1: ad_sidebar_top

    ad_thread_list_below_stickies:
    Line 1: ad_thread_list_below_stickies

    ad_thread_view_above_messages:
    Line 1: ad_thread_view_above_messages

    ad_thread_view_below_messages:
    Line 1: ad_thread_view_below_messages

    conversation_message:
    Line 14: conversation_message_private_controls
    Line 32: conversation_message_public_controls

    editor:
    Line 1: editor

    editor_js_setup:
    Line 6: editor_js_setup
    Line 72: editor_tinymce_init

    footer:
    Line 3: footer
    Line 21: footer_links
    Line 43: footer_links_legal

    forum_list:
    Line 12: forum_list_nodes
    Line 19: forum_list_sidebar

    forum_view:
    Line 38: forum_view_pagenav_before
    Line 52: forum_view_threads_before

    header:
    Line 1: header

    help_wrapper:
    Line 8: help_sidebar_links

    login_bar_form:
    Line 9: login_bar_eauth_set
    Line 18: login_bar_eauth_items

    logo_block:
    Line 5: header_logo

    member_card:
    Line 32: member_card_links
    Line 43: member_card_stats

    member_recent_content:
    Line 19: member_recent_content_search_content_types

    member_view:
    Line 40: member_view_sidebar_start
    Line 45: member_view_info_block
    Line 73: member_view_sidebar_middle1
    Line 119: member_view_sidebar_middle2
    Line 160: member_view_sidebar_end
    Line 227: member_view_tabs_heading
    Line 388: member_view_search_content_types
    Line 414: member_view_tabs_content

    message:
    Line 16: message_notices
    Line 33: message_content

    message_simple:
    Line 24: message_simple_notices

    message_user_info:
    Line 5: message_user_info_avatar
    Line 13: message_user_info_text
    Line 24: message_user_info_extra
    Line 83: message_user_info_custom_fields

    moderator_bar:
    Line 28: moderator_bar

    navigation:
    Line 56: navigation_tabs_forums
    Line 108: navigation_tabs_members
    Line 131: navigation_tabs_help

    navigation_visitor_tab:
    Line 5: navigation_visitor_tabs_start
    Line 26: navigation_visitor_tab_links1
    Line 39: navigation_visitor_tab_links2
    Line 87: navigation_tabs_account
    Line 129: navigation_visitor_tabs_middle
    Line 163: navigation_visitor_tabs_end

    pagenode_container:
    Line 74: pagenode_container_article

    PAGE_CONTAINER:
    Line 4: page_container_head
    Line 31: body
    Line 47: page_container_content_top
    Line 55: page_container_breadcrumb_top
    Line 64: page_container_notices
    Line 68: page_container_content_title_bar
    Line 101: page_container_sidebar
    Line 111: page_container_breadcrumb_bottom

    page_container_js_body:
    Line 3: page_container_js_body

    post:
    Line 21: post_private_controls
    Line 45: post_public_controls

    post_permalink:
    Line 28: share_page_options

    profile_post:
    Line 14: profile_post_private_controls
    Line 41: profile_post_public_controls

    search_bar:
    Line 4: quick_search

    search_form_tabs:
    Line 2: search_form_tabs

    share_page:
    Line 7: share_page_options

    sidebar_share_page:
    Line 7: sidebar_share_page_options

    sidebar_visitor_panel:
    Line 11: sidebar_visitor_panel_stats

    thread_create:
    Line 22: thread_create
    Line 48: thread_create_fields_main
    Line 91: thread_create_fields_extra

    thread_list:
    Line 46: thread_list_stickies
    Line 54: thread_list_threads
    Line 83: thread_list_options

    thread_list_item:
    Line 38: thread_list_item_icon_key

    thread_reply:
    Line 20: thread_reply

    thread_view:
    Line 80: thread_view_pagenav_before
    Line 144: thread_view_form_before
    Line 224: thread_view_qr_before
    Line 234: thread_view_qr_after

    xenforo.css:
    Line 639: xenforo_css_extra




    Admin Templates:

    [appearance_splash:
    Line 13: admin_icons_appearance
    Line 66: admin_sidebar_appearance

    application_splash:
    Line 15: admin_icons_application
    Line 60: admin_sidebar_applications

    development_splash:
    Line 13: admin_icons_development
    Line 74: admin_sidebar_development

    editor_js_setup:
    Line 4: editor_js_setup

    helper_criteria_page:
    Line 24: page_criteria_page_info
    Line 69: page_criteria_extra

    helper_criteria_user:
    Line 5: user_criteria_privs
    Line 59: user_criteria_user_groups
    Line 92: user_criteria_content
    Line 162: user_criteria_profile
    Line 214: user_criteria_specific
    Line 248: user_criteria_extra

    home:
    Line 12: admin_icons_home
    Line 81: admin_sidebar_home

    page_edit:
    Line 77: admin_page_edit_extra

    tools_splash:
    Line 10: admin_icons_tools
    Line 66: admin_sidebar_tools

    user_edit:
    Line 26: admin_user_edit_tabs
    Line 46: admin_user_edit_panes

    user_splash:
    Line 14: admin_icons_users
    Line 87: admin_sidebar_users
     
    Indigo and Fuhrmann like this.

Share This Page