Jump to content

Get field icon on frontend


tpr
 Share

Recommended Posts

Is it possible to retrieve the icon of a field set in the admin? Eg. setting a "phone" icon to a "Phone" field in the admin, and then use this icon (name) in the templates?

Link to comment
Share on other sites

This should do the trick!

$f = $fields->get("body");
echo '<i class="fa '.$f->icon.'"></i>';

PS make sure you load this on the page:

<link rel="stylesheet" href="/wire/templates-admin/styles/font-awesome/css/font-awesome.min.css" type="text/css">
  • Like 7
Link to comment
Share on other sites

Thanks, it really did! Could have thought about the $fields variable myself :)

This is a great way to add icons using the admin, without any additional stuff.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...