Thread Locked This thread is locked - replies are not allowed.


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Pages: 1 - Last Post: 5 Nov 22, 10:08 Last Post By: MarkusD
MarkusD

Posts: 899
Registered: 13-Apr-2006
HTML code for menu, how to?
Posted: 3 Nov 22, 18:25
 
Hi,

titles and comments which are used for the top menu on a created page are striped from any HTML-code, which makes sense, and I do understand why this is happening. On the other hand I really would like to use something like this
<i class="wi wi-sunrise"></i>/<i class="wi wi-sunset"></i>

Instead of a long winding text like "Sonnenauf- und Untergang" ("Sunrise/Sunset").

Or this:
06.03.2022 Tromsø <i class="fas fa-plane-departure"> </i> – <i class="fas fa-plane-arrival"> </i> Longyearbyen

Turns into "06.03.2022 Tromsø – Longyearbyen"

Or this:
12.02.2022 Malmö – <i class="fa fa-ship"> </i> – Hahnstätten

Turns into "12.02.2022 Malmö – – Hahnstätten". See screenshot:
https://www.markus-drueck.de/JA/2022-11-03_1800.png

I'm using Tiger.

Any idea how to solve that? Thanks in advance.
Laza

Posts: 1,550
Registered: 6-Sep-2005
Re: HTML code for menu, how to?
Posted: 4 Nov 22, 07:07   in response to: MarkusD in response to: MarkusD
 
There's no easy way to do this. Basically, you can remove the function call that filters HTML code out, but this is risky. In the Skin directory / lib / util.js find line 3993 (in getDropdownMenu function):
t = shorten(vars.get('title'), 32, true);

and modify it this way:
t = shorten(vars.get('title'), 64, false);

Note, this change will be overwritten with future skin updates.
MarkusD

Posts: 899
Registered: 13-Apr-2006
Re: HTML code for menu, how to?
Posted: 4 Nov 22, 19:24   in response to: Laza in response to: Laza
 
Laza wrote:
There's no easy way to do this. Basically, you can remove the function call that filters HTML code out, but this is risky. In the Skin directory / lib / util.js find line 3993 (in getDropdownMenu function):
t = shorten(vars.get('title'), 32, true);

and modify it this way:
t = shorten(vars.get('title'), 64, false);
That did the trick. But I had to raise that 64 to 120 to make it work even for longer texts.

Note, this change will be overwritten with future skin updates.
Yes, thanks for the hint.

According to Jeff, I'm the only person in the universe who writes comments at all, so it wouldn't be necessary to remove HTML code. I mean this half in jest and half in earnest. Do you really think that it is very dangerous not to remove HTML code?

The problem with the "shorten" function is that it determines the length of the text, including all the HTML code. But this is not really correct.

An example. The Text:
03/06/2022 Tromsø <i class="fas fa-plane-departure"> </i> - <i class="fas fa-plane-arrival"> </i> Longyearbyen

Is 121 characters long, but what results is ultimately:
03/06/2022 Tromsø X - X Longyearbyen

And that is only 37 characters.

I hope I could make clear where the problem lies here. The mechanism that shortens the text may be based on completely wrong assumptions.

Laza, thank you.
JeffTucker

Posts: 8,470
Registered: 31-Jan-2006
Re: HTML code for menu, how to?
Posted: 4 Nov 22, 19:57   in response to: MarkusD in response to: MarkusD
 
MarkusD wrote:
Do you really think that it is very dangerous not to remove HTML code?

I think I can answer that. In my skins, I don't remove HTML tags from user-entered text strings, unless it's guaranteed to cause a problem - used as a tooltip, for example, where HTML is not honored by the browser.

But in Laza's skins, a small error in the HTML in a comment, like an unclosed tag, can cause a catastrophic failure of the entire page, without giving you even a hint about where the problem is. We've seen a lot of "bug reports" where this was the cause.

In the more traditional HTML/CSS layouts produced by my skins, HTML tag errors in captions can produce some ugly results, but a quick run of the page through a good validator, like my personal favorite, Total Validator, will quickly tell you where the trouble is. Much tougher in Laza's skins, with their Javascript-driven layouts.
Laza

Posts: 1,550
Registered: 6-Sep-2005
Re: HTML code for menu, how to?
Posted: 5 Nov 22, 07:44   in response to: MarkusD in response to: MarkusD
 
I agree the length of the visible text should decide, but it's almost impossible to write an algorithm for this. Even if it could find the point where the limit has been reached how it could ensure that this point is not inside a deeply nested structure? If it is, you'd have to provide a way to close all elements, otherwise, the whole page structure would be wrecked.
MarkusD

Posts: 899
Registered: 13-Apr-2006
Re: HTML code for menu, how to?
Posted: 5 Nov 22, 10:07   in response to: JeffTucker in response to: JeffTucker
 
JeffTucker wrote:
MarkusD wrote:
Do you really think that it is very dangerous not to remove HTML code?

I think I can answer that. In my skins, I don't remove HTML tags from user-entered text strings, unless it's guaranteed to cause a problem - used as a tooltip, for example, where HTML is not honored by the browser.

But in Laza's skins, a small error in the HTML in a comment, like an unclosed tag, can cause a catastrophic failure of the entire page, without giving you even a hint about where the problem is. We've seen a lot of "bug reports" where this was the cause.

In the more traditional HTML/CSS layouts produced by my skins, HTML tag errors in captions can produce some ugly results, but a quick run of the page through a good validator, like my personal favorite, Total Validator, will quickly tell you where the trouble is. Much tougher in Laza's skins, with their Javascript-driven layouts.

Thanks Jeff for the helpful explanations.
MarkusD

Posts: 899
Registered: 13-Apr-2006
Re: HTML code for menu, how to?
Posted: 5 Nov 22, 10:08   in response to: Laza in response to: Laza
 
Laza wrote:
I agree the length of the visible text should decide, but it's almost impossible to write an algorithm for this. Even if it could find the point where the limit has been reached how it could ensure that this point is not inside a deeply nested structure? If it is, you'd have to provide a way to close all elements, otherwise, the whole page structure would be wrecked.
OK, as I already thought, it is much more complex than it looks in the first place.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums