I am working on a project currently where the Index.php file basically acts as a layout page and basically uses tables for the layout.
Please have a look at it’s contents below. This is just a small part of the code, there’s much more like this.
I need to pass on this file to a Front End Developer/ Designer so that he could change the layout as well as change the code to use CSS instead of Tables for the layout. But I think this is a mess and the designer might have issues understanding and modifying this.
What’s the best way to structure and organize this code so that
1)The code becomes much more cleaner, structured and organized.
2)It’s easier for the Designer to understand and change the layout.
<table width="770" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td colspan="3"><?php include("header.inc.php"); ?>
</td></tr>
<tr>
<?php
if ($xview == "main" || $show_sidebar_always)
{
?>
<td width="185" id="sidebar_left" valign="top">
<table width="90%" class="buttons" cellpadding="0" align="center">
<tr>
<td>
<!-- Begin Version 5.0 -->
<a href="index.php?cityid=0"><?php echo $lang['HOME_LINK']; ?></a>
<!-- End Version 5.0 -->
</td>
</tr>
<tr>
<td>
<a href="<?php echo $postlink; ?>"><?php echo $lang['POST_LINK']; ?></a>
</td>
</tr>
<?php if($enable_calendar) { ?>
<tr>
<td>
<a href="<?php echo $posteventlink; ?>"><?php echo $lang['POST_EVENT_LINK']; ?></a>
</td>
</tr>
<?php } ?>
<?php if($enable_images) { ?>
<tr>
<td>
<a href="<?php echo $postimagelink; ?>"><?php echo $lang['POST_IMG_LINK']; ?></a>
</td>
</tr>
<?php } ?>
<?php if($forum_dir) { ?>
<tr>
<td>
<a href="<?php echo $forum_dir; ?>" target="_blank"><?php echo $lang['FORUM_LINK']; ?></a>
</td>
</tr>
<?php } ?>
<tr>
<td>
<?php if($auth->id) { ?>
<a href="index.php?view=myaccount" title="">My Account</a>
<a href="index.php?view=bookmarks" title="">Watch List</a>
<a href="index.php?view=login&logout" title="">Logout</a>
<?php }else{ ?>
<a href="index.php?view=login" title="">Login</a>
<a href="index.php?view=register" title="">Sign up</a>
<?php } ?>
</td>
</tr>
</table>
<br>
It would be better to let the designer create a completely new layout and then add the PHP logic into into. If you rewrite this I strongly suggest using a template engine.