Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add theme wrapper, re-organize template files
- Implement scribu’s Theme Wrapper (see base.php) - Move templates, comments.php, and searchform.php to templates/ folder - Rename loop- files to content- - Remove all hooks except roots_head and roots_footer - Use templates/page-header.php for page titles - Use head.php for everything in <head>
- Loading branch information
Showing
34 changed files
with
274 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,24 +1,15 @@ | |||
<?php get_header(); ?> | <?php get_template_part('templates/page', 'header'); ?> | ||
<?php roots_content_before(); ?> |
|
||
<div id="content" class="<?php echo CONTAINER_CLASSES; ?>"> | <div class="alert alert-block fade in"> | ||
<?php roots_main_before(); ?> | <a class="close" data-dismiss="alert">×</a> | ||
<div id="main" class="<?php echo FULLWIDTH_CLASSES; ?>" role="main"> | <p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p> | ||
<div class="page-header"> | </div> | ||
<h1><?php _e('File Not Found', 'roots'); ?></h1> |
|
||
</div> | <p><?php _e('Please try the following:', 'roots'); ?></p> | ||
<div class="alert alert-block fade in"> | <ul> | ||
<a class="close" data-dismiss="alert">×</a> | <li><?php _e('Check your spelling', 'roots'); ?></li> | ||
<p><?php _e('The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.', 'roots'); ?></p> | <li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li> | ||
</div> | <li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li> | ||
<p><?php _e('Please try the following:', 'roots'); ?></p> | </ul> | ||
<ul> |
|
||
<li><?php _e('Check your spelling', 'roots'); ?></li> | <?php get_search_form(); ?> | ||
<li><?php printf(__('Return to the <a href="%s">home page</a>', 'roots'), home_url()); ?></li> | |||
<li><?php _e('Click the <a href="javascript:history.back()">Back</a> button', 'roots'); ?></li> | |||
</ul> | |||
<?php get_search_form(); ?> | |||
</div><!-- /#main --> | |||
<?php roots_main_after(); ?> | |||
</div><!-- /#content --> | |||
<?php roots_content_after(); ?> | |||
<?php get_footer(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
<?php get_template_part('templates/head'); ?> | |||
<body <?php body_class(); ?>> | |||
|
|||
<!--[if lt IE 7]><div class="alert">Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</div><![endif]--> | |||
|
|||
<?php | |||
// Use Bootstrap's navbar if enabled in config.php | |||
if (current_theme_supports('bootstrap-top-navbar')) { | |||
get_template_part('templates/header-top-navbar'); | |||
} else { | |||
get_template_part('templates/header'); | |||
} | |||
?> | |||
|
|||
<div id="wrap" class="container" role="document"> | |||
<div id="content" class="row"> | |||
<div id="main" class="<?php roots_main_class(); ?>" role="main"> | |||
<?php include roots_template_path(); ?> | |||
</div> | |||
<?php if (roots_sidebar()) { ?> | |||
<aside id="sidebar" class="<?php roots_sidebar_class(); ?>" role="complementary"> | |||
<?php get_template_part('templates/sidebar'); ?> | |||
</aside> | |||
<?php } ?> | |||
</div><!-- /#content --> | |||
</div><!-- /#wrap --> | |||
|
|||
<?php get_template_part('templates/footer'); ?> | |||
|
|||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks nice - a lot less code!
But I'm wondering, if you've put the sidebar stuff in the base.php file, and we want to change the front-page.php file, to not have any sidebar, but still being able to do it on the other pages, are we still able to do this? And how?
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, based off the current code you'll just open up
config.php
and addis_front_page()
to the firstif
statement inroots_sidebar()
you can also override
base.php
withbase-{template}.php
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the sudden hatred of theme hooks? Is there no longer any impetus on making Roots the perfect parent theme? Hooks are a key part of that.
Granted the lovely addition of scribu's theme wrapper makes it easy enough to reintroduce my own hooks or those of the Theme Hook Alliance, but is this the only logic behind such a major change?
The rest of the changes look fantastic. Thanks for all the hard work.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, i've always hated theme hooks (and child themes) so it's nothing sudden. they've been brought up a few times recently by users not understanding what the purpose of them is. what's really lost by taking out all the hooks? i didn't think removing the hooks was that big of a change, but i don't really use them that much. when i do use them it's something that could have been done just as easy by editing a template file (and now, not in so many places).
do we really need all those hooks all over the place?
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My interest with WordPress started with Thematic, a theme heavily reliant upon child themes and hooks, hence my bias.
I can completely understand why the questions on hooks would frustrate you, but I disagree with removing a feature just because some people don't understand it. I actually think many would start using hooks if they realised how useful they can be.
When used properly hooks and child themes allow you to transparently upgrade to the latest version of the parent theme, great for new features, bug fixes or security. They also help you change from one theme to another simply by editing the hook prefix, especially useful when transitioning a client's site to a new Roots based responsive design. You can also easily reposition elements on the page simply by changing the hook suffix. Maintaining hooks also means that if you have several custom post templates and need to add something new to all of them you can do it with one new function, instead of changing all the custom templates.
Granted most of this can be done by editing the wrapper's base.php but it's not as straightforward, as flexible or as well documented as using hooks.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hooks weren't removed just because some people don't understand it. also, thematic is a perfect example of a theme i'd want roots to be nothing like.. the amount of hooks in that theme is insane and it's very difficult to work with.
also, there's no way that you can upgrade your parent roots theme without running into issues all the time, which is why we've never recommended the use of child themes. we don't keep backwards compatibility functionality, we're always re-arranging the hell out of things and completely removing/adding different features.
when the documentation is re-done (#264 - which i'd like to knock out soon) we can provide examples on how to extend
base.php
roots is a starting theme at heart. i understand some people use it as a framework and use child themes (and we do our best to make that work smoothly), but that's really not how it's meant to be used.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that Thematic went overkill with hooks, but you only need to look at premium themes like Genesis to see that they do have a place within WordPress frameworks. It won't stop me using Roots, I'll just adopt and incorporate the hooks from the Theme Hook Alliance.
I also respect your decision to be a starter theme instead of a framework, as I wouldn't like to deal with the additional hassle either. Such is the quality and simplicity of the code, it's not a big leap to use Roots as a framework.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my part a few weeks ago I am developing child themes to keep updated my theme father and with this new update be quite desconsertado not serve because older versions and already done. Anyway this update seems unbelievable to me and then giving me a while to realize that to achieve the realization of new issues has no problem children, the creation of new base-{template}.php, add my own hook and let your imagination. Congratulations and sorry for my English.
PD: the simplicity and the small number of files I'm thinking of leaving child themes.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to get my head around this new theme wrapping stuff. If I wanted a certain page to have a different sidebar or different header or footer etc, then the base.php file is useless for that page. How do I override the base.php for an individual page? I tried using base-page-{slug}.php and base-{slug}.php but they both do not work. Thanks.
db41099
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you can't figure it out after reviewing http://scribu.net/wordpress/theme-wrappers.html then please post a question on the google group