Help pop-ups to tooltips

Started by whitewall, April 23, 2014, 10:34:22 AM

Previous topic - Next topic

whitewall

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?


margarett

In a template file it is supposed that the adequate language strings are already loaded. So you only need to globalize $txt
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

whitewall

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.

margarett

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?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

whitewall

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)

margarett

Are you talking about Admin pages?
If so, perform the loadLanguage in Sources/Admin.php
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: