Guest
02 Jan 2013 00:38

HI Sergey,

I think a good idea is to offer a way to put some field description or instructions into a tooltip (small text popup, visible on mouse over event), somewhere in front of or behind the field label.

Maybe such thing is already possible, but I don't know how.

Thank you!

Marius

Last Modified: 09 Feb 2015

Tags Developer


Sergey
Total posts: 13,748
02 Jan 2013 01:20

Yes it is possible. Every field had description parameter.

If you add it it will create tooltip in the form


pepperstreet VIP
Total posts: 3,837
14 May 2013 11:06

BTW, is description/tooltip translatable? Should I use the usual text constant and language overrides?


klox7 VIP
Total posts: 914
06 Jan 2015 19:47

pepperstreet BTW, is description/tooltip translatable? Should I use the usual text constant and language overrides?

At the moment I'm dealing with this. I guess field description doesn't support language constants.

@Sergey @Konstantin could you make this possible?


Sergey
Total posts: 13,748
08 Jan 2015 06:04

Did you try? In the code I have it $this->description = JText::_($field->params->get('core.description'));. Should be translatable.


klox7 VIP
Total posts: 914
08 Jan 2015 07:40

I tried but it didn't translate constant because I had another text in it.

So if you have "normal entered text" + language constant it won't work. If you have just language constant it is working.


Sergey
Total posts: 13,748
12 Jan 2015 06:46

Show me what you have as a value of the field?


klox7 VIP
Total posts: 914
12 Jan 2015 07:52

Do you mean this

field-description


pepperstreet VIP
Total posts: 3,837
13 Jan 2015 06:53

klox7 field-description

You simply can't mix a regular text with a CONSTANT. Simply because the whole description content is parsed and then replaced. In your case, the "translation function" tries to find the whole content in your language file... but certainly can't find it: Your language file does only have the CONSTANT.

So, just use the CONSTANT as the field value. This applies to all translatable areas/fields.

(PS: Don't confuse [PLACEHOLDERS] in Cobalt email texts and messages with a LANGUAGE_CONSTANT )


klox7 VIP
Total posts: 914
13 Jan 2015 08:22

pepperstreet You simply can't mix a regular text with a CONSTANT.

Yes I fugured that out. But it would still be great to be able to use mixed version. Simply because you may have a portion of description different on each field and another portion same. Maybe you could first search if there is constant (maybe as ::CONSTANT::) and then parse description.


Sergey
Total posts: 13,748
13 Jan 2015 11:45

That would creaye load on perfomance. Ther are 10 000 constnats loaded with languages. If i have to parse the same amount of text on presence of any of those, that would be long.


klox7 VIP
Total posts: 914
13 Jan 2015 11:50

Sergey That would creaye load on perfomance.

Even for form?


Sergey
Total posts: 13,748
13 Jan 2015 12:43

For form may be not. But this is out of general concept. Although I see advantage of this. That would be easy to add feature into Joomla JText processor. But I do not see how I could add this behaviour only for single parameter.


klox7 VIP
Total posts: 914
13 Jan 2015 13:21

Sergey For form may be not.

Tooltip for field description says: "Hint for user during submission". So this is used only for forms, right?

Sergey But I do not see how I could add this behaviour only for single parameter.

What do you mean "single parameter"?


Sergey
Total posts: 13,748
13 Jan 2015 15:18

klox7 What do you mean "single parameter"?

I mean if text eneterd in field description is going to work this way, all other text inputs has too. BEcause it is inconsistent. If you may use it in one text box why cannot you do the same in the other? So I cannot to make this feature jest for the single field parameter called Descritpion. If I do it have to work for all text parameters.


klox7 VIP
Total posts: 914
05 Feb 2015 16:23

Is there any hack for inserting multiple language constants in field description?


Sergey
Total posts: 13,748
09 Feb 2015 11:01

klox7 Is there any hack for inserting multiple language constants in field description?

Yes. You can insert those lang leys but insert them in brackets like [LANG_KEY]. Then in custom form template parse descritpion, extract all placeholders and update with translations.

if(preg_match_all("/\[([^\]]*)\]/iU", $description, $matches, PREG_SET_ORDER))
{
    foreach($matchaes AS $match)
    {
        $description = str_replace('['.$match[1].']', JText::_($match[1]), $description);
    }
}

Somethign like this.

Powered by Cobalt