Skip Navigation

[Resolved] Is there a way to display a Custom Field in a Tooltip?

This thread is resolved. Here is a description of the problem and solution.

Problem:
Client wants to add Bootstrap tooltips where the content comes from a Types field, but what is rendered on the front-end looks broken.

The client is adding the tooltips like so:

<a href="#" data-toggle="tooltip" data-placement="top" title='[types field="role-description" id="$role"][/types]'>[types field="role-picture" id="$role"][/types]</a>

Solution:
The problem was that the Types custom field used to insert the tooltip text is a Wysiwyg field, which inserts HTML markup, and needs to be a simple text field that inserts plain text.

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 7 replies, has 2 voices.

Last updated by Furlan 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#622407

Hi,

I found this solution to create Bootstrap Tooltip in Toolset Types:
https://toolset.com/forums/topic/bootstrap-tooltip-with-toolset-maps/

I am trying to use the same function to display a Custom Field in a view using this code:

<a href="#" data-toggle="tooltip" data-placement="top" title='[types field="role-description" id="$role"][/types]'>[types field="role-picture" id="$role"][/types]</a>

But it displays inconsistent results in the front-end. Is there another solution, maybe you know a better approach?

#622471

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-03-06 at 08.46.31.png

Hi Juan Manuel

What do you mean by inconsistent results?

I just tried this according to the Bootstrap documentation for Tooltips (hidden link) and it worked as expected.

See the screenshot for my View Loop Output, and the custom JS required to initialise the tooltips.

Either your theme or Toolset needs to load Bootstrap. Check Toolset > Settings to confirm.

#622561
2018-03-06_06-03-51.png

Hi Nigel,

For some reason tooltip text is not displayed properly. Maybe it could be caused by the plugin that I use for display the view in a popup window.

The current result is in the attached file.

Thanks.

#622564

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, that sounds like the problem, because it works in a normal View.

Try changing the markup so that instead of using Types fields in the tooltip you display just static text, e.g. "some test text".

Do the tooltips work correctly then?

#622623

Indeed when a static text is displayed, no problem occurs and it works perfectly.
The problem here is that the tooltip text is not static, it may change depending on the information in the view.
That's why I am trying to insert the value of the Custom Field in the Tooltip Text.

Thanks.

#622636

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Yes, well it works fine in a normal View, so I will need to know more about the View you have a problem with.

Perhaps I should look at it on your site.

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to break anything.

Can you also confirm which View we are talking about, and whatever I need to know about how you are displaying that View.

#622913

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Juan Manuel

Yes, that's pretty complicated.

I managed to understand your set up and do some testing and I think the problem is that you are using a Types field for the title attribute which includes HTML and is not simple text, so it breaks the page markup.

If you abstract away from your complicated set up and simply tried to create a tooltip on a standalone page generating the title attribute using the same Types shortcode but setting a specific post (e.g. id="125") you will find it won't work.

You need to use a simple multiline text field for the description, not a WYSIWYG field.

#622927
2018-03-07_05-09-07.png

Hi Nigel,

The problem was exactly as you described it. Using a text field instead of WYSIWYG field fixed the problem. Thank you very much for your time and help.

Best Regards.