ACF Widgets › Support › Feature Requests › Specify widget ID or Class
Tagged: class
- This topic has 10 replies, 3 voices, and was last updated 6 years ago by
Daron Spence.
-
AuthorPosts
-
December 1, 2014 at 3:32 PM #478
Jason Rosewell
ParticipantWould be cool to see a custom widget ID or Class option when adding/editing a new widget, instead of having this generated for you:
<div id="acf_widget_30418-2" class="widget Acf_Widget_30418">
Cheers.
December 1, 2014 at 3:47 PM #479Daron Spence
KeymasterThis is a good idea. I was privately emailing with one of the beta testers about something like this. Definitely a possibility. I’ll look into it for sure.
What about just using the widget slug as a classname? Or would user defined classes/id’s be more useful?
December 1, 2014 at 3:51 PM #480Jason Rosewell
ParticipantYeah, I’m definitely going to use what’s available for now, but my anal self wants more control over the selectors!
For example, in the above code snippet, that widget div is preceded by:
<div id="mc_newslettersignup" class="widget widget_mc_newslettersignup">
I’d love to give the widget generated by your plugin its own custom ID or class. Of course it isn’t necessary for it to work; just a nice perk, and my CSS will make more sense to me.
December 1, 2014 at 3:54 PM #481Daron Spence
KeymasterOk. I’ll see what I can do. Hopefully I can work on it later tonight.
December 3, 2014 at 1:07 PM #745Daron Spence
KeymasterHey Jason, just wanted to note, that until you activate your copy of ACFW you won’t see any updates. I highly recommend activating it!
December 3, 2014 at 1:11 PM #746Jason Rosewell
ParticipantHey Daron – thanks for the heads up. After working on this for several hours, my client decided they didn’t like their idea for this widget so it’s now on the shelf. 😐 I got paid, but it’s still a bummer. Thanks for all your help – I’ll implement this again the first chance I get.
December 3, 2014 at 1:15 PM #747Daron Spence
KeymasterAh. All good! Save it then! I may send out a couple preliminary emails about updates for the first few until I can implement something more like ACF that notifies users that their version is outdated even before they activate their license.
December 7, 2014 at 5:41 PM #928bpartch
ParticipantCouldn’t you add a class field to the widget then just wrap it in a div in the widgets template file?
<div class="<?php $class = get_field('class', $acfw); echo $class; ?>"> <h3><?php $title = get_field('title', $acfw); echo $title; ?></h3> <p><?php $description = get_field('description', $acfw); echo $description; ?></p> <img src="<?php $image = get_field('image', $acfw); echo $image['url']; ?>" width="100%" alt="" /> </div>
-
This reply was modified 6 years, 2 months ago by
bpartch. Reason: add more text
December 7, 2014 at 5:43 PM #929Daron Spence
KeymasterYou could, but then you have to specify if for each new instance of that widget. Not efficient if the client has to enter that stuff and they mispell the class or change it.
December 7, 2014 at 5:46 PM #931bpartch
Participant^^ hadn’t thought of that, i vote my response down. 😛
March 1, 2015 at 6:28 PM #1891Daron Spence
KeymasterIf either of you is watching this, I just did a major refactor for how widgets are formed in v1.4
This will make adding this feature a piece of cake (more so than before).
If you got any other ideas, let me know!
-
This reply was modified 6 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.