Convert a Word Press theme to Drupal

paddy's picture

The example WP theme I am trying to use is sodelicious_black.

page.tpl.php

Combine header.php, page.php and footer.php into on new file called page.tpl.php. In this new page.tpl.php file:

  • Replace your DOCTYPE and HTML lines with
    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;<br />
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  • Replace the TITLE with
    &lt;title&gt;&lt;?php print $head_title ?&gt;&lt;/title&gt;
  • Replace the links to style sheets, RSS news feeds and the such with
    &lt;?php print $head ?&gt;<br />
    &lt;?php print $styles ?&gt;<br />
    &lt;?php print $scripts ?&gt;
  • Clean up the page.tpl.php by removing the obsolete calls to get_header() and get_footer()
  • Replace echo get_settings('home') with print base_path()
  • Replace bloginfo('name') with print $site_slogan ? $site_slogan : $site_name
  • Drupal uses syntax such as
    &lt;?php if (isset($primary_links)) {
      print theme('links', $primary_links, array('class' =&gt; 'navmenu primary-links'));<br />
    } ?&gt;<br />
    &lt;?php if (isset($secondary_links)) {
      print theme('links', $secondary_links, array('class' =&gt; 'navmenu secondary-links'));<br />
    } ?&gt;<br />
    for navigation, so replace the navigation block with this code
  • At the beginning of the main content block, Drupal customarily has a bunch of information such as
    &lt;div class="post-main"&gt;
      &lt;?php if ($breadcrumb) { print $breadcrumb; } ?&gt;
      &lt;?php if ($mission) { print '&lt;div id="mission"&gt;'. $mission .'&lt;/div&gt;'; } ?&gt;
      &lt;?php if ($tabs) { print '&lt;div id="tabs-wrapper" class="clear-block"&gt;'; } ?&gt;
      &lt;?php if ($title) { print '&lt;h2'. ($tabs ? ' class="with-tabs"' : '') .'&gt;'. $title .'&lt;/h2&gt;'; } ?&gt;
      &lt;?php if ($tabs) { print $tabs .'&lt;/div&gt;'; } ?&gt;
      &lt;?php if (isset($tabs2)) { print $tabs2; } ?&gt;
      &lt;?php if ($help) { print $help; } ?&gt;
      &lt;?php if ($show_messages &#38;&#38; $messages) { print $messages; } ?&gt;<br />
    &lt;/div&gt;<br />
    &lt;?php print $content; ?&gt;<br />
  • The Search blocks are created by Drupal, so remove any code builds a search block – just remember where it was located (top, left, centre, right, footer regions)
  • Replace get_sidebar(); with print $sidebar_left . $sidebar_right;
  • The Recent Posts blocks are created by Drupal, so remove any code that builds a Recent Posts block – just remember where it was located
  • Clean up the code and balance all your DIV’s and SPAN’s

node.tpl.php

The single.php will get trimmed to become the node template – node.tpl.php

  • Start off by removing everything that is already in the page template – page.tpl.php – basically everything before and including the while (have_posts()) loop
  • Replace the_ID() with print $node-&gt;nid;
  • Replace permalink() with print $node_url;
  • Replace the_title() with print $title;
  • Replace the Author block with &lt;?php if ($submitted) { print '&lt;span class="submitted"&gt;' . $submitted . '&lt;/span&gt;'; } ?&gt;
  • Replace the Category block with &lt;?php if ($taxonomy) { print '&lt;div class="terms"&gt;' . $terms . '&lt;/div&gt;'; } ?&gt;
  • Replace the Comments block with &lt;?php if ($links) { print '&lt;div class="post-tags"&gt;' . $links . '&lt;/div&gt;'; } ?&gt;
  • Add &lt;?php print $picture ?&gt; before the content to support user pictures
  • Replace the_content('Read more'); with print $content;

comment.tpl.php

The comment.php will get trimmed to become the comment template – comment.tpl.php

  • As before, start off by removing everything that is already in the page template – page.tpl.php – basically everything before and including the foreach ($comments) loop
  • Replace comment_ID() with print $comment-&gt;cid;

Results

And there you should have an almost working Drupal theme closely relating the previous WP theme.

  • Sodelicious homepage
  • Sodelicious content
  • Sodelicious edit
  • Sodelicious gallery
  • That’s all folks.
Get Firefox W3C Markup Validation Service W3C CSS Validation Service drupal.org | Community Plumbing Taylor McKnight  -  //gtmcknight Creative Commons License Irish

Syndicate

Syndicate content

Who's online

There are currently 0 users and 1 guest online.

pair Networks