Create a field with a key and two values

13 views
Skip to first unread message

Alex

unread,
Jan 30, 2023, 11:52:30 PM1/30/23
to dotCMS User Group
Dear Community:

I hope everyone is having a great time! 

I am facing a new challenge.  I have key/value fields that work outstandingly.  However, I now need to associate or an icon (html) to the key so when I display the key I can pull its icon. The icon will be just a html code or href reference that displays the key.

Something like this in the front end.

Icon Key:  value

Is there a field that I can use for this?  I really do not want to migrate all my key/value fields to a new field type, but if I have to, I will.

I welcome any suggestions any of you can bring to assess this issue.

Thanks,

Alex

Nathan Keiter

unread,
Jan 31, 2023, 8:57:22 AM1/31/23
to dot...@googlegroups.com
I haven't really used key/value fields much, but would any of these be possible for you?

  • Make the value map to the name of the icon. Ie. value=party, where icon is party.gif
  • Make the value be a comma separated list, where value is in the first position, icon in the second position. Ie. value=party,party-hat

Nathan I. Keiter | Network Applications Programmer
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993

https://www.gettysburg.edu

From: dot...@googlegroups.com <dot...@googlegroups.com> on behalf of Alex <tech....@gmail.com>
Sent: Monday, January 30, 2023 11:52 PM
To: dotCMS User Group <dot...@googlegroups.com>
Subject: [dotcms] Create a field with a key and two values
 

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.


--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/fc221446-8aa1-46d2-bfe5-7ebc4414317dn%40googlegroups.com.

Jameson Mauro

unread,
Jan 31, 2023, 9:40:02 AM1/31/23
to dotCMS User Group
In the same spirit as Nathan's suggestions, if you're comfortable with bloating your key list, you could do something like KEY=value, and then add a separate entry for KEY_icon=graphic.png

Though that seems less efficient overall than the idea of mapping icon names to values (or keys, if the icons need to be enforced as unique).

Lex Medeiros

unread,
Jan 31, 2023, 6:33:23 PM1/31/23
to dot...@googlegroups.com
Thank you for the great idea!  I will give it a try.  But I think it may be cumbersome for the content editor since every time the key or values need to be updated, he or she has to put HTML on it and I would have to explain everything over and over again to every new content editor.

You received this message because you are subscribed to a topic in the Google Groups "dotCMS User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dotcms/Pbkz6Rno2xo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/8c1cc575-34fc-4229-8c58-d0c5abcf55fcn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages