[wp-hackers] Sidebar widget HTML/DOM

// ravi ravi-lists at g8o.net
Fri Jun 25 03:07:44 UTC 2010


On Jun 24, 2010, at 3:11 PM, Andrew Nacin wrote:
>> 
>> Fair enough. You can use after_title and after_widget to wrap the
> contents of the widget in a div. That's the best way, although as you
> pointed out, it's not 100% reliable.
> 
> If you want to include extra (and potentially unnecessary) HTML markup
> instead of going the fully jQuery route:
> 
> before_widget - <div class="widget-notitle-content-container">
> before_title - </div><h4>
> after_title - </h4><div class="widget-content-container">
> after_widget - </div>
> 

Ah, that’s brilliant. (I would expand on that, for my needs, to add another wrapper div in ‘before_widget’ and a corresponding closing div in ‘after-widget’ so I can style the widget itself).


> I however would recommend using JavaScript, considering you are after all
> looking to implement a JavaScript effect with show/hide of content on title
> click.


What makes me queasy with my jQuery “hack”, is that DOM manipulation of this sort — not triggered by some user action — is IMO a poor substitute for generating the HTML the right way at the server end. Call it a [dubious] philosophical preference!

	—ravi




More information about the wp-hackers mailing list