No outro dia investigando um pouco eu encontrei uma função muito boa que podemos usar para ver quais variáveis nós temos no nosso smf .... Obviamente podemos criar algumas novas .. Por que não usar as que já temos para não gerarmos mais consultas para o banco de dados?
Por exemplo, abrimos o display.template.php e antes:
// Show the anchor for the top and for the first message. If the first message is new, say so.
Eu coloco
echo '<pre>'; print_r($context); echo '</pre>';
e deixei todas as variáveis disponíveis para usar nos tópicos sem precisar gerar nenhum tipo de consulta:
Array
(
[user] => Array
(
[id] => 1
[is_logged] => 1
[is_guest] =>
[is_admin] => 1
[is_mod] =>
[can_mod] => 1
[username] => lucas-ruroken
[language] => english
[email] => [email protected]
[ignoreusers] => Array
(
)
[name] => lucas-ruroken
[smiley_set] => default
[started] =>
[messages] => 0
[unread_messages] => 0
[popup_messages] =>
[avatar] => Array
(
[href] => http://127.0.0.1/project/smf2theme/avatars/Musicians/Avril_Lavigne.jpg
[image] =>
)
[total_time_logged_in] => Array
(
[days] => 0
[hours] => 8
[minutes] => 22
)
)
[linktree] => Array
(
[0] => Array
(
[url] => http://127.0.0.1/project/smf2theme/index.php
[name] => Smf 2 Themes
)
[1] => Array
(
[url] => http://127.0.0.1/project/smf2theme/index.php#c1
[name] => General Category
)
[2] => Array
(
[url] => http://127.0.0.1/project/smf2theme/index.php?board=1.0
[name] => General Discussion
)
[3] => Array
(
[url] => http://127.0.0.1/project/smf2theme/index.php?topic=1.0
[name] => Welcome to SMF!
[extra_before] =>
)
)
[current_topic] => 1
[current_board] => 1
[open_mod_reports] => 0
[html_headers] =>
[menu_separator] =>
[session_var] => ceb45b0b9baa
[session_id] => 96da1098483442cc9e9a51c59ca6b5d5
[forum_name] => Smf 2 Themes
[forum_name_html_safe] => Smf 2 Themes
[current_action] =>
[current_subaction] =>
[show_login_bar] =>
[server] => Array
(
[is_iis] =>
[is_apache] => 1
[is_lighttpd] =>
[is_cgi] =>
[is_windows] => 1
[iso_case_folding] => 1
[complex_preg_chars] => 1
[needs_login_fix] =>
)
[browser] => Array
(
[is_opera] =>
[is_opera6] =>
[is_opera7] =>
[is_opera8] =>
[is_opera9] =>
[is_opera10] =>
[is_ie4] =>
[is_webkit] =>
[is_mac_ie] =>
[is_web_tv] =>
[is_konqueror] =>
[is_firefox] => 1
[is_firefox1] =>
[is_firefox2] =>
[is_firefox3] => 1
[is_iphone] =>
[is_chrome] =>
[is_safari] =>
[is_gecko] => 1
[is_ie8] =>
[is_ie7] =>
[is_ie6] =>
[is_ie5.5] =>
[is_ie5] =>
[is_ie] =>
[ie_standards_fix] => 1
[needs_size_fix] => 0
[possibly_robot] =>
)
[insert_after_template] =>
[template_layers] => Array
(
[0] => html
[1] => body
)
[theme_variant] =>
[character_set] => ISO-8859-1
[utf8] =>
[right_to_left] =>
[tabindex] => 1
[admin_features] => Array
(
[0] => ps
)
[theme_loaded] => 1
[messages_per_page] => 15
[robot_no_index] => 1
[num_replies] => 1
[topic_first_message] => 1
[total_visible_posts] => 2
[oldTopicError] =>
[previous_next] => « previous next »
[show_spellchecking] =>
[require_verification] =>
[signature_enabled] => 1
[disabled_fields] => Array
(
)
[page_title] => Welcome to SMF!
[is_marked_notify] =>
[page_index] => [1]
[start] => 0
[page_info] => Array
(
[current_page] => 1
[num_pages] => 1
)
[links] => Array
(
[first] =>
[prev] =>
[next] =>
[last] =>
[up] => http://127.0.0.1/project/smf2theme/index.php?board=1.0
)
[moderators] => Array
(
)
[link_moderators] => Array
(
)
[is_locked] => 0
[is_sticky] => 0
[is_very_hot] =>
[is_hot] =>
[is_approved] => 1
[is_poll] =>
[class] => normal_post
[extended_class] => normal_post
[topic_starter_id] => 0
[subject] => Welcome to SMF!
[num_views] => 5
[mark_unread_time] => 3
[canonical_url] => http://127.0.0.1/project/smf2theme/index.php?topic=1.0
[response_prefix] => Re:
[first_message] => 1
[first_new_message] =>
[jump_to] => Array
(
[label] => Jump to
[board_name] => General Discussion
[child_level] => 0
)
[get_message] => prepareDisplayContext
[can_approve] => 1
[can_ban] => 1
[can_sticky] => 1
[can_merge] => 1
[can_split] => 1
[calendar_post] => 0
[can_mark_notify] => 1
[can_send_topic] => 1
[can_send_pm] => 1
[can_report_moderator] => 1
[can_moderate_forum] => 1
[can_issue_warning] => 0
[can_restore_topic] => 0
[can_restore_msg] => 0
[can_move] => 1
[can_lock] => 1
[can_delete] => 1
[can_add_poll] => 1
[can_remove_poll] => 0
[can_reply] => 1
[can_reply_unapproved] => 0
[can_reply_approved] => 1
[can_mark_unread] => 1
[can_remove_post] => 1
[form_sequence_number] => 3521820
[name] =>
[email] =>
[page_title_html_safe] => Welcome to SMF!
[in_maintenance] =>
[current_time] => April 01, 2010, 09:31:03 am
[show_quick_login] =>
[news_lines] => Array
(
[0] => SMF - Just Installed!
)
[fader_news_lines] => Array
(
[0] => SMF - Just Installed!
)
[random_news_line] => SMF - Just Installed!
[unapproved_members] => 0
[show_open_reports] => 1
[allow_search] => 1
[allow_admin] => 1
[allow_edit_profile] => 1
[allow_memberlist] => 1
[allow_calendar] =>
[allow_moderation_center] => 1
[allow_pm] => 1
[menu_buttons] => Array
(
[home] => Array
(
[title] => Home
[href] => http://127.0.0.1/project/smf2theme/index.php
[show] => 1
[sub_buttons] => Array
(
)
[is_last] =>
[active_button] => 1
)
[help] => Array
(
[title] => Help
[href] => http://127.0.0.1/project/smf2theme/index.php?action=help
[show] => 1
[sub_buttons] => Array
(
)
[active_button] =>
)
[search] => Array
(
[title] => Search
[href] => http://127.0.0.1/project/smf2theme/index.php?action=search
[show] => 1
[sub_buttons] => Array
(
)
[active_button] =>
)
[admin] => Array
(
[title] => Admin
[href] => http://127.0.0.1/project/smf2theme/index.php?action=admin
[show] => 1
[sub_buttons] => Array
(
[featuresettings] => Array
(
[title] => Features and Options
[href] => http://127.0.0.1/project/smf2theme/index.php?action=admin;area=featuresettings
[show] => 1
)
[packages] => Array
(
[title] => Packages
[href] => http://127.0.0.1/project/smf2theme/index.php?action=admin;area=packages
[show] => 1
)
[errorlog] => Array
(
[title] => Error Log
[href] => http://127.0.0.1/project/smf2theme/index.php?action=admin;area=logs;sa=errorlog;desc
[show] => 1
)
[permissions] => Array
(
[title] => Permissions
[href] => http://127.0.0.1/project/smf2theme/index.php?action=admin;area=permissions
[show] => 1
)
)
[active_button] =>
)
[moderate] => Array
(
[title] => Moderate
[href] => http://127.0.0.1/project/smf2theme/index.php?action=moderate
[show] => 1
[sub_buttons] => Array
(
[reports] => Array
(
[title] => Reported Posts
[href] => http://127.0.0.1/project/smf2theme/index.php?action=moderate;area=reports
[show] => 1
)
)
[active_button] =>
)
[profile] => Array
(
[title] => Profile
[href] => http://127.0.0.1/project/smf2theme/index.php?action=profile
[show] => 1
[sub_buttons] => Array
(
[summary] => Array
(
[title] => Summary
[href] => http://127.0.0.1/project/smf2theme/index.php?action=profile
[show] => 1
)
[account] => Array
(
[title] => Account Settings
[href] => http://127.0.0.1/project/smf2theme/index.php?action=profile;area=account
[show] => 1
)
[profile] => Array
(
[title] => Forum Profile
[href] => http://127.0.0.1/project/smf2theme/index.php?action=profile;area=forumprofile
[show] => 1
)
)
[active_button] =>
)
[pm] => Array
(
[title] => My Messages
[href] => http://127.0.0.1/project/smf2theme/index.php?action=pm
[show] => 1
[sub_buttons] => Array
(
[pm_read] => Array
(
[title] => Read your messages
[href] => http://127.0.0.1/project/smf2theme/index.php?action=pm
[show] => 1
)
[pm_send] => Array
(
[title] => Send a message
[href] => http://127.0.0.1/project/smf2theme/index.php?action=pm;sa=send
[show] => 1
)
)
[active_button] =>
)
[mlist] => Array
(
[title] => Members
[href] => http://127.0.0.1/project/smf2theme/index.php?action=mlist
[show] => 1
[sub_buttons] => Array
(
[mlist_view] => Array
(
[title] => View the memberlist
[href] => http://127.0.0.1/project/smf2theme/index.php?action=mlist
[show] => 1
)
[mlist_search] => Array
(
[title] => Search For Members
[href] => http://127.0.0.1/project/smf2theme/index.php?action=mlist;sa=search
[show] => 1
)
)
[active_button] =>
)
[logout] => Array
(
[title] => Logout
[href] => http://127.0.0.1/project/smf2theme/index.php?action=logout;ceb45b0b9baa=96da1098483442cc9e9a51c59ca6b5d5
[show] => 1
[sub_buttons] => Array
(
)
[is_last] => 1
[active_button] =>
)
)
[show_news] => 1
[show_pm_popup] =>
[common_stats] => Array
(
[total_posts] => 2
[total_topics] => 1
[total_members] => 1
[latest_member] => Array
(
[id] => 1
[name] => lucas-ruroken
[href] => http://127.0.0.1/project/smf2theme/index.php?action=profile;u=1
[link] => lucas-ruroken
)
)
[meta_keywords] => PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum
)
Honestamente com isso você pode fazer muito.
Espero que sirva para você