Blog Theme for Expression Engine convert to Drupal

paddy's picture

I have never used the Expression Engine (EE) before, so this is a complete experiment. Let's see how it goes...

page.tpl.php

From what I can see, EE has a file called index.txt that displays almost everything. This file is our page.tpl.php candidate.

  • Remove the
    {assign_variable:master_weblog_name="journal"}
    {assign_variable:main_template_group="bartelme"}
    from the beginning of the index.txt file
  • In the html definition, replace @{lang}@ with @en@ - this is just a fix for en web sites - a proper i18n solution should be implemented for production sites
  • Replace {exp:weblog:info weblog="{master_weblog_name}"}{blog_title}{/exp:weblog:info} with @ print $head_title; @
  • Drupal adds metadata itself, so you don't have to worry about it - so remove it
  • Remove links to stylesheets and javascripts and add
      <?php print $head; ?>
      <?php print $styles; ?>  
      <?php print $scripts; ?>
  • Replace @{homepage}@ with @ print $base_url; @
  • Replace @{exp:weblog:info weblog="{master_weblog_name}"}{blog_title}{/exp:weblog:info}@ with @ print $site_name; @
  • Replace @{exp:weblog:info weblog="{master_weblog_name}"}{blog_description}{/exp:weblog:info}@ with @ print $site_slogan; @
  • Replace the navigation block with
    <?php if (isset($primary_links)) {
      print theme('links', $primary_links, array('class' => 'navmenu primary-links'));
    } ?>
    <?php if (isset($secondary_links)) {
      print theme('links', $secondary_links, array('class' => 'navmenu secondary-links'));
    } ?>
  • Replace the search code @{exp:search:simple_form search_in="everywhere" result_page="search/results"}...{/exp:search:simple_form}@ with @ print $header; @ we will assign the search form to the header block to appear here
  • In the About section, replace the paragraph text with the mission statement @ print $mission; @
  • In the posts section, add the Drupal messages, help, tabs and the rest
    <div class="post-main">
      <?php if ($breadcrumb) { print $breadcrumb; } ?>
      <?php if ($mission) { print '<div id="mission">'. $mission .'</div>'; } ?>
      <?php if ($tabs) { print '<div id="tabs-wrapper" class="clear-block">'; } ?>
      <?php if ($title) { print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; } ?>
      <?php if ($tabs) { print $tabs .'</div>'; } ?>
      <?php if (isset($tabs2)) { print $tabs2; } ?>
      <?php if ($help) { print $help; } ?>
      <?php if ($show_messages && $messages) { print $messages; } ?>
    </div>
  • Copy the text to print the posts and paste it to node.tpl.php
  • Replace the code @{exp:weblog:entries weblog="{master_weblog_name}" limit="1" sort="desc" orderby="date"}...{/exp:weblog:entries}@ and @{exp:weblog:entries weblog="{master_weblog_name}" limit="2" offset="1" sort="desc" orderby="date"}...{/exp:weblog:entries}@ with
    <?php if ((strlen($content) > strlen('<div class="post-meta">')) && (substr($content, 0, strlen('<div class="post-meta">')) == '<div class="post-meta">')) {
      print $content;
    } else {
      print '<div class="post-main">' . $content . '</div>';
    } ?>
    <div class="clear-block clear"></div>
  • Remove the Comments block as this is also managed by Drupal
  • Replace the code inside the sidebar-wrapper with @
    @</li>
    <li>Replace the code inside the footer section with @<?php print $footer_message; ?>@</li>
    </ul>

    The final page.tpl.php file looks like
    <code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      <head>
      <title><?php print $head_title; ?></title>
      <?php print $head; ?>
      <?php print $styles; ?>  
      <?php print $scripts; ?>
      <!--[if lt ie 7]><link rel="stylesheet" type="text/css" media="screen" href="ie_win_css" /><![endif]-->
    </head>
    <body id="bhome">
      <p id="skip"><a href="#content">Skip to main content</a></p>
      <div id="header">
        <h1><a href="<?php print base_path() ?>"><?php print $site_name; ?></a></h1>
        <h2><?php print $site_slogan; ?></h2>
      </div>
      <div id="navigation">
        <?php if (isset($primary_links)) {
          print theme('links', $primary_links, array('class' => 'navmenu primary-links'));
        } ?>
        <?php if (isset($secondary_links)) {
          print theme('links', $secondary_links, array('class' => 'navmenu secondary-links'));
        } ?>
        <div id="search">
          <?php print $header; ?>
        </div>
      </div>
      <div id="wrapper">
        <div id="content-wrapper">
          <div id="content">
            <div class="about">
              <h3><a href="#.vcf" class="vcard"><?php print t('About'); ?></a></h3>
              <p><?php print $mission; ?></p>
            </div>
            <div class="posts">
              <div class="post-main">
                <?php if ($breadcrumb) { print $breadcrumb; } ?>
                <?php if ($mission) { print '<div id="mission">'. $mission .'</div>'; } ?>
                <?php if ($tabs) { print '<div id="tabs-wrapper" class="clear-block">'; } ?>
                <?php if ($title) { print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; } ?>
                <?php if ($tabs) { print $tabs .'</div>'; } ?>
                <?php if (isset($tabs2)) { print $tabs2; } ?>
                <?php if ($help) { print $help; } ?>
                <?php if ($show_messages && $messages) { print $messages; } ?>
              </div>
              <?php if ((strlen($content) > strlen('<div class="post-meta">')) && (substr($content, 0, strlen('<div class="post-meta">')) == '<div class="post-meta">')) {
                print $content;
              } else {
                print '<div class="post-main">' . $content . '</div>';
              } ?>
              <div class="clear-block clear"></div>
            </div>
          </div>
        </div>
        <div id="sidebar-wrapper">
          <?php print $sidebar_left . $sidebar_right; ?>
        </div>
      </div>
      <div id="footer">
        <?php print $footer_message; ?>
        <div id="meta">
          <p>
            Design Copyright &copy; 1999 &ndash; 2006 <a href="http://www.bartelme.at/">Wolfgang Bartelme</a> |
            Theme Ported by <a href="http://www.nikhedonia.com/" title="SimplyGold">Sadhana Ganapathiraju</a>
          </p>
          <ul>
            <li><a href="http://validator.w3.org/check/referer" title="Xhtml 1.0 Strict"><span>Xhtml Happy</span></a></li>
            <li><a href="http://jigsaw.w3.org/css-validator/check/referer" title="Css 2.0 Strict"><span>Css Happy</span></a></li>
            <li><a href="http://www.contentquality.com/fulloptions.asp?Url1=http://www.example.com/"><span>508</span></a></li>
          </ul>
        </div>
      </div>
    </body>
    </html></code>

    <h2>node.tpl.php</h2>

    As mentioned above, strip out the part of the index.txt file that deals with posts (or nodes in Drupal-talk) and put it into a node.tpl.php file.
    <ul>
    <li>The new node.tpl.php file should contain <code><div class="post">
      <h2 class="post-title"><a href="{entry_id_path=bartelme/comments}" title="Read '{title}'">{title}</a></h2>
      <div class="post-meta">
        <em>{entry_date format="%d %M %Y"}</em>
        <a class="comments" href="{permalink}#comments">{comment_total} Comments</a>
      </div>
      <div class="post-content">
        {exp:markdown}{summary}{/exp:markdown}
        <a href="{entry_id_path=bartelme/comments}" class="more">continue reading "{title}"</a>
      </div>
    </div></code> and all this needs to be converted</li>
    <li>Replace @{entry_id_path=bartelme/comments}@ with @<?php print $node_url; ?>@</li>
    <li>Replace @{title}@ with @<?php print $title; ?>@</li>
    <li>Replace @{entry_date format="%d %M %Y"}@ with @<?php print date('d M Y', $node->created); ?>@</li>
    <li>Replace the comments section with @<?php if ($links) { print '<div class="comments">' . $links . '</div>'; } ?>@</li>
    <li>Replace @{exp:markdown}{summary}{/exp:markdown}@ with @<?php if ($page == 0) { print '<h2><a class="post-title" href="' . $node_url . '" title="' . $title . '">' . $title . '</a></h2>'; } ?>@</li>
    <li>Replace @<a href="{entry_id_path=bartelme/comments}" class="more">continue reading "{title}"</a>@ with <code><div class="post-entry">
      <?php print $content ?>
    </div>
    <div class="clear-block clear"></div></code></li>
    <li>Add a line to print the taxonony terms @<?php if ($taxonomy) { print '<div class="terms">' . $terms . '</div>'; } ?>@</li>
    </ul>

    The final node.tpl.php file should look something like the following
    <code><div class="post">
      <h2 class="post-title"><a href="<?php print $node_url; ?>" title="<?php print $title; ?>"><?php print $title; ?></a></h2>
      <div class="post-meta">
        <span class="submitted"><?php print date('d M Y', $node->created); ?></span>
        <?php if ($taxonomy) { print '<div class="terms">' . $terms . '</div>'; } ?>
        <?php if ($links) { print '<div class="comments">' . $links . '</div>'; } ?>
      </div>
      <div class="post-content">
        <?php if ($page == 0) { print '<h2><a class="post-title" href="' . $node_url . '" title="' . $title . '">' . $title . '</a></h2>'; } ?>
        <div class="post-entry">
          <?php print $content ?>
        </div>
        <div class="clear-block clear"></div>
      </div>
    </div></code>

    <h2>comment.tpl.php</h2>

    Copy the node.tpl.php file to comment.tpl.php.
    <ul>
    <li>Update it a bit to suit comments and you have something like
    <code><div class="post">
      <h3><?php print $title; ?></h3>
      <div class="post-meta">
        <span class="submitted"><?php print date('d M Y', $comment->timestamp); ?></span>
        <?php if ($comment->new) { print '<a id="new"></a>' . '<span class="new">' . drupal_ucfirst($new) .'</span>'; } ?>
        <?php if ($links) { print '<div class="post-tags">' . $links . '</div>'; } ?>
      </div>
      <div class="post-content">
        <div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print (isset($comment->status) && $comment->status  == COMMENT_NOT_PUBLISHED) ? ' comment-unpublished' : ''; print ' '. $zebra; ?>">
          <?php print $picture ?>
          <div class="post-entry">
            <?php print $content ?>
          </div>
          <div class="clear-block clear"></div>
        </div>
      </div>
    </div></code></li>
    </ul>

    <h2>style.css</h2>

    The rest of the work is CSS related - find out what does not work, update the CSS to use the Drupal names and fix the problems one at a time.

    <h2>The result</h2>
    <ul>
    <li>Home page<br />
    <img src="/files/images/fresh-1.png" /></li>
    <li>Node<br />
    <img src="/files/images/fresh-2.png" /></li>
    <li>Node edit<br />
    <img src="/files/images/fresh-3.png" /></li>
    </li>

    <h2>What it should look like</h2>
    <ul>
    <li><img src="/files/images/fresh_theme.PNG" /></li>
    <li><img src="/files/images/fresh-4.png" /></li>
    </ul>

    <h2>To do</h2>

    There is still a lot to do - CSS mostly - but the core is there.

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