I inherited a Drupal website from previous "developers". After my initial sweep of the website, I found out they did a very very "interesting" job when creating the website.

As you can see, for reason beyond my understanding, they coded INTO the php files, instead of implementing through the drupal system.

My question is, what do you recommend in this situation?: Re-write the whole page from scratch, or should I try implement these "stray codes" into proper blocks, code them into php etc.

(The thing is there are several other different node files, each of them have the menu system coded into them as html. As result of that, to change the order of the menus I would need to change the code in 17 different php files. Way too many chances to screw up...)

Your thoughts and advices are appriciated!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="hu" lang="hu">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="home" href="http://www.htconsulting.hu/" title="Home" />
<title><?php print $head_title ?></title>
<?php print $head ?>
<?php print $styles ?>
<?php print $scripts ?>
<link rel="stylesheet" href="<?php print base_path() . path_to_theme(); ?>/zoli.css" type="text/css" media="screen" charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js" type="text/javascript"></script>
<script src="<?php print base_path() . path_to_theme(); ?>/javascripts/main.js" type="text/javascript"></script>
<!--[if lt IE 7]>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>
<div id="container_outer">
<div id="container">
<div id="header">
<div id="lang-selector-container">
<div id="lang-selector">
<span class="lang-active">HUN</span>
<span id="lang-sep">|</span>
<a href="/en" class="lang-link">ENG</a>
</div><!-- lang-selector -->
</div><!-- lang-selector-container -->
<!--<a href="#" id="header-search"><span></span>keresés</a>  -->
</div> <!-- header -->
<div id="content">
<div id="top-menu">
<ul class="top-menu-left">
<li><a href="/elerhetoseg" class="first">Elérhetőség</a></li>
<li><a href="/search">Keresés </a></li>        
<li><a href="/magunkrol" class="first">Magunkról</a></li>
<li><a href="/referenciak">Referenciák</a></li>
<li><a href="/partnereink">Partnereink</a></li>
</div> <!-- top-menu -->
<div class="clear"></div>
<div id="left-menu">
<li class="org-dev"><span id="org-dev"><img src="<?php print base_path() . path_to_theme(); ?>/images/fogaskerekek.png" /></span>  
<?php print l("Szervezetfejlesztés", 'node/6', array('attributes' => array('class' => 'org-dev'))) ?> </li>
<li class="training"><span id="training"><img src="<?php print base_path() . path_to_theme(); ?>/images/figurak.png" /></span>  
<?php print l("Tréningek", 'node/7', array('attributes' => array('class' => 'training'))) ?> </li>
<li class="training-tools"><span id="training-tools"><img src="<?php print base_path() . path_to_theme(); ?>/images/disk.png" /></span>  
<?php print l("Képzési eszközök", 'node/8', array('attributes' => array('class' => 'training-tools'))) ?> </li>
<li class="methodology"><span id="methodology"><img src="<?php print base_path() . path_to_theme(); ?>/images/page.png" /></span>  
<?php print l("Módszertan", 'node/80', array('attributes' => array('class' => 'methodology'))) ?> </li>
<a href="http://flowcsoport.hu/" target="_blank">
<img id="flowlogo" src="/sites/all/themes/htc/pictures/flowlogo_120px.png" border="0">
<?php include "randomimage.php"; ?>
<br />
<br />
<div id="intro-video" style="visibility: visible">
<script type="text/javascript" style="visibility: visible">
            flashplayer: "/flash/jw_html5/player.swf",
            file: "/videok/ian.mp4",
            height: 260,
            width: 195
<br />
<br />
<!-- <?php print $left; ?> -->
</div> <!-- left-menu -->
<div id="content-main">
<?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?>
<?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
<?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
<?php if ($show_messages && $messages): print $messages; endif; ?>
<?php print $help; ?>
<div id="content-inner" class="front">
<?php print $content ?>             
<?php print $footer ?>
<div id="content-banner">
<?php print $right; ?>
</div> <!-- content-main -->    
<div class="clear"></div>
<!-- <a href="http://flowcsoport.hu/" target="_blank">
<img id="flowlogo_old" src="/sites/all/themes/htc/pictures/flowlogo_120px.png" border="0">
</a> -->
</div> <!-- content -->
<div id="footer">
<li class="company-name">Human Telex Consulting Kft.</li>
<li class="company-address">1015 Budapest, Toldy F. u. 16/c.</li>
<li class="company-tel">Tel.: 214-0204, 225-1576</li>
<li class="right">KMRMK: 01-0122-04; FAT: AL-1416</li>
<!-- <li class="customer-gate"><a href="#">Ügyfélkapu</a></li> -->
</div><!--  footer -->
</div><!-- container -->
</div><!-- container outer -->
<?php print $closure ?>
  • Just out of interest - is that whole thing the page.tpl.php file or is it just and example of the code top to bottom?
    – SpaceBeers
    Commented Feb 22, 2012 at 13:34
  • This is page-front.tpl.php, there are other page.tpl, all of them messed up
    – Gergely Csata
    Commented Feb 22, 2012 at 13:39
  • I've amended my answer below but I'd gut it personally.
    – SpaceBeers
    Commented Feb 22, 2012 at 13:56
  • 3
    I am not going to defend what was done here, but the biggest problem with "inheriting" sites is that you typically only get the end product. You don't have any insight into what happened during the development process. Very often, requirements, specs, graphic treatments, etc, take left turns during the process. I would start out by trying to figure out why the site ended up the way it did. Based on that code, I wouldn't be surprised to find out that the site started out as something other than Drupal, was mostly themed and working, and then was "ported" to Drupal with minimal effort.
    – mpdonadio
    Commented Feb 22, 2012 at 14:34
  • 2
    Am I missing something here? Is the whole issue that there are some hard-coded menus items? Commented Feb 22, 2012 at 16:08

3 Answers 3


Providing they haven't changed the core you should be fine to just add a new theme and do things properly in there.

If it were up to me I would install a clean version of Drupal somewhere (to make sure the core hasn't been messed with), then start a new theme from scratch. You can probably reuse the CSS file but I would completely gut it.

Either way it's a bit of work now to avoid a potential lot of pain later on.

  • What in this tpl file leads you to think core may have been modified? Commented Feb 22, 2012 at 16:09
  • Nothing but if it's a case of "lazy coding" or just not understanding how Drupal works, I would make sure nothing's been altered that shouldn't have been...
    – SpaceBeers
    Commented Feb 22, 2012 at 16:12
  • 3
    I'm trying to figure out why this is a big deal. Some hard-coded menu links and such doesn't trigger any red flags to me, even if it is a bit sloppy and warrants some cleanup and consolidation. OP seems very bothered that they "coded INTO the php files". I'd hate for him to see the tpl files for whitehouse.gov, there just might be a line or two of PHP in them. Commented Feb 22, 2012 at 16:16
  • 2
    I think the point is, if a previous dev created this mess of a template, then logic has it that many other atrocities could have been committed as well as yet unknown, "booby traps" if you will waiting to go off. But yes, as mentioned here, The Hacked module is a good way to find out at least if core has been hacked. Commented Feb 23, 2012 at 15:55

I cannot see any big problems in the posted code. Moving the menu entries into a custom block might be a good thing if it's reused in multiple places.

If you want to check whether core or contrib modules have been changed, you can use the Hacked! module.

  • 2
    I agree with this one. Sure, it's a messy template. Feel free to find the common denominator amongst the menus and get them all sorted out via menus / blocks. Commented Feb 22, 2012 at 20:04

You should re-implement everything using the Drupal system. It is a lot of work, but you must consider future updates of the website, etc. You put a bit of effort now, but then you'll look back and congratulate yourself for the good decision.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.