The last 2 weeks I got to use Skellie in action, in order to build a new wordpress project from scratch.
The results are encouraging.
The code seems cleaner and readable and partials are easily reusable.
The main layout file is just so clear:
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
<?php echo $this->partial('header'); ?> | |
<body <?php body_class('layout-'.$this->layout); ?>> | |
<header class="container_16 clearfix" role="banner"> | |
<div class="grid_3"><h1 class="ir siteTitle"><a href="/"><?php echo bloginfo('name'); ?></a></h1> | |
</div> | |
<div class="grid_9"> | |
<?php echo $this->partial('menu', 'utility'); ?> | |
</div> | |
<div class="grid_4"> | |
<?php echo $this->partial('search-form', null, array('id' => 'headerSearchForm')); ?> | |
</div> | |
<div class="grid_16"> | |
<?php echo $this->partial('menu', 'main'); ?> | |
</div> | |
</header> | |
<div id="wrapper" class="container_16 clearfix" role="main"> | |
<div class="grid_3"><aside role="complementary"><?php echo $this->partial('sidebar', 'left'); ?></aside></div> | |
<div class="grid_9"><?php | |
echo $this->partial('menu', 'breadcrumbs'); | |
echo $this->content(); | |
?></div> | |
<div class="grid_4"><aside role="complementary"><?php echo $this->partial('sidebar', 'right'); ?></aside></div> | |
</div> | |
<?php echo $this->partial('footer'); ?> | |
</body> | |
</html> |
During development I came accross two dark corners of wordpress, namely the search and comment forms.
Search form
By default wordpress prints the same id in the search form which ends up in invalid html if you need 2 instances of it (e.g. repeating the search form within the search results page). The solution was to ignore the search form and come up with a new partial in partials/search-form.php
Comment form
The comment form was less of a hassle. Hiding the tips and title was enough to get going.
Using 2 partials to loop through the comments and print them finishes up the story.
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
<h2>Leave a comment</h2> | |
<?php | |
comment_form(array('comment_notes_after'=>'', 'title_reply' => '')); | |
echo $this->partial('list', 'comments'); |
Future development:
Some things that could be changed also became apparent during the building process.
I was thinking about the possibility of having the partial methods return the render result as a string instead of directly printing it like wordpress used to.
It makes sense. It allows for more flexibility and adjustment of output. You can cache it, alter it (if you have to), decorate it or just print it.
Also with the 5.4 short tag re-entering the game the overhead of manually printing will be minimal.
Get_template_part of wordpress used to directly print but get_template_part sucked anyway.
No comments:
Post a Comment