[theme-reviewers] To Chip; examples default widgets
Philip M. Hofer (Frumph)
philip at frumph.net
Fri Oct 29 02:42:13 UTC 2010
Example of adding defaults widgets using the_widget:
<?php
if ( !dynamic_sidebar('right-sidebar') ) :
if (is_cp_theme_layout('standard,v')) {
the_widget('comicpress_calendar_widget');
}
if (comicpress_themeinfo('disable_comic_frontpage')) {
the_widget('comicpress_latest_thumbnail_widget','title=Latest
Comic&thumbcat='.comicpress_themeinfo('comiccat'));
}
the_widget('WP_Widget_Pages');
the_widget('WP_Widget_Categories','hierarchical=1&count=1&dropdown=0');
endif;
?>
example of adding a 'add widgets here' message:
if ( !dynamic_sidebar('sidebar-right-sidebar') ) { ?>
<div style="margin: 0 auto; padding: 5px; width: 180px; background: #eee;
height: 440px;border: dotted 1px #ccc;">
<?php _e('There are currently no widgets assigned to the right-sidebar,
place some!','easel'); ?><br />
<br />
<?php _e('Once you add widgets to this sidebar, this default information
will go away.','easel'); ?><br />
<br />
<?php _e('This theme also uses the WordPress 3.0 Menu system. You
probably see the default stuff you have in the menubar. Go to Appearance ->
Menu in the
wp-admin (dashboard) and create a new menu.','easel'); ?><br />
<br />
<h2><?php _e('Recommended Plugins','easel'); ?></h2>
<ol>
<li><a
href="http://wordpress.org/extend/plugins/vipers-video-quicktags/">Viper's
Video Quicktags</a></li>
<li><a href="http://wordpress.org/extend/plugins/audio-player/">Audio
Player</a></li>
<li><a
href="http://wordpress.org/extend/plugins/comicpress-companion/">Theme
Companion</a></li>
</ol>
</div>
<?php }
----- Original Message -----
From: "Otto" <otto at ottodestruct.com>
To: "theme-reviewers" <theme-reviewers at lists.wordpress.org>
Sent: Thursday, October 28, 2010 3:23 PM
Subject: Re: [theme-reviewers] Need a theme for testing
> On Thu, Oct 28, 2010 at 5:10 PM, Chip Bennett <chip at chipbennett.net>
> wrote:
>> That reminds me, though (don't ask how; can't explain my
>> train-of-thought):
>> I'm wanting to come up with a best-practice way of implementing "default"
>> widgets to display if no widgets are added by the user to the defined
>> sidebar(s).
>> I'm thinking of using the_widget() inside of the conditional for the
>> sidebar. Any issues/problems with this approach, or anything I need to
>> consider?
>> (Sorry if this is a dumb question; I've had a really long week...)
>> Chip
>
> Using the_widget there is no different than simply hardcoding
> something, really. Everything inside the conditional goes poof when
> the user puts a widget into place.
>
> In theory you could add code to a) detect the case where there's no
> widgets in the sidebar and b) put some there. I'm not sure it'd be
> worth it.
>
> If it were me, I'd leave the sidebars blank. Widgets only, no fall
> through default case. At least that way, when the user activates the
> theme and sees an empty sidebar, then they can go put some widgets in
> it.
>
> You could go a step further and, for the default case, detect if the
> viewing user is an administrator and put a message there saying "You
> don't have any widgets defined, why not go put some in?" and give them
> a link to the widgets screen. That'd be the best UX I can think of.
> Displaying something by default that magically goes away when they
> configure it is a pretty poor experience, but giving them a helpful
> hint and telling them where to go is much better.
>
> -Otto
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
More information about the theme-reviewers
mailing list