I have been customizing the GenericMenu -template and I was planning to replace those (?)-images and pop-ups with a CSS/JS-based tooltip.
The problem is how I could get the help language pack loaded into my template so I could use the language-variables to generate the tooltip?
In a template file it is supposed that the adequate language strings are already loaded. So you only need to globalize $txt
Quote from: margarett on April 23, 2014, 11:52:11 AM
In a template file it is supposed that the adequate language strings are already loaded. So you only need to globalize $txt
In this case the help language file isn't loaded by default for the GenericMenu -template.
Anyway, I found this kind of solution by myself:
At first I added
loadLanguage('Help');
in the
index.template.php -file inside the
template_init() -function.
And then I globalized the
$helptxt in the
template_generic_menu_tabs() -function in
GenericMenu.template.php -file.
After this I was able to get the help-text by using
$helptxt[$tab_context['help']] -variable in my template.
It seems to be working but I am not sure if there would have been some easier and more efficient way to achieve this.
That's not really a "clean" solution.
- If you search the default theme file contents, there is not a single "loadLanguage" call --> always called from Sources
- Doing it like you did causes contents to be loaded even when not needed.
Can you point a specific location of what you are trying to change?
I'm working with the GenericMenu.template.php and by default it makes the help-icon in front of the section title and by clicking it opens a pop-up which contains help about that spesific page.
What I am trying to do is getting rid of the pop-up and replacing that functionality with a CSS-based tooltip where the help is shown when the icon is hovered.
To get the help shown in a CSS-based tooltip is why I need the spesific helptxt-variable contents from the language file.
Default code:
if (!empty($selected_tab['help']) || !empty($tab_context['help']))
echo '<a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqWin(this.href);" class="help">
<img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" class="icon" /></a>';
What I am trying:
// Show a help item as a tooltip
if (!empty($selected_tab['help']) || !empty($tab_context['help'])) {
echo ' (<span data-tooltip class="has-tip" title="', $helptxt[$tab_context['help']] ,'">?</span>)';
}
($helptxt is the variable I got by the method I described earlier)
Are you talking about Admin pages?
If so, perform the loadLanguage in Sources/Admin.php