Support » Plugins » How can I set a Widget’s title in for use in the Dashboard?

  • Resolved ancawonka

    (@ancawonka)


    Hello,

    I am making a custom Links widget, and I would like to be able to set the title of the widget (when in the dashboard) to be the name of the Links Catgory that I’m displaying. The result should be the same as when you’re using a text widget, and you’ve set a title.

    I’m a little bit confused about how to accomplish this.

    Does the widget title automatically get set if there is a “title” field?

    It looks like the appended title is being set in widgets.dev.js, near line 244:

    appendTitle : function(widget) {
    		var title = $('input[id*="-title"]', widget);
    		if ( title = title.val() ) {
    			title = title.replace(/<[^<>]+>/g, '').replace(/</g, '<').replace(/>/g, '>');
    			$(widget).children('.widget-top').children('.widget-title').children()
    				.children('.in-widget-title').html(': ' + title);
    		}
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Okay, so it looks like the way to make this happen is to have a “title” field in your widget. I made mine hidden so that people wouldn’t be able to set it on their own, but it gets updated when a category is chosen.

    Thanks for this! I was wondering the same thing myself.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I set a Widget’s title in for use in the Dashboard?’ is closed to new replies.