However I soon needed to create a very different front page and found it hard to start from scratch and wanted an easy way to work out what was going on. Thanks to Drupal user Sym , I was able to get my foot on the ladder and offer this quick tutorial to other that are still staring up at the bottom rung!
|
First take a test site with Garland theme and in the theme folder create two new files page-front.tpl and page-front.css. Type in the text opposite or copy/paste from here. <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" * { If you now browse to your home page it should look something like this. Don't worry it hasn't altered your real homepage and deleting or renaming the files above will restore the original. The only styling instructions the page currently has is to have no margin or padding, black text and Arial font. |
![]() ![]() |
| Now we create the main area (<div>)
that will hold all the elements of the page and call it "total", in the
.php file we wrap the existing text within it and in the .css file we
give "total" a background of powderblue, a pink border and a width of
765px. As we are not setting a height it collapses to the height
required by the text within it. Although I would usually use hex values for colours I have tried to use colour names in this tutorial to make it easier to identify and follow. As a useful aside a list of html colours can be found at http://support.blog-city.com/html_colors.htm |
![]() ![]() |
| Next step is to create the main
sections within "total". These are called (helpfully) "top", "middle"
and "bottom". Each of these <div>s hold within it the elements that
relate to it (in this case just relevant text).
In the .css file we give "top", "middle" and "bottom" different background colours, a full width and a depth of 160px. The result are the full width pink, yellow and green strips below. |
![]() ![]() |
| Now we come to the subsections which
are the ones that will contain the actual content. Starting just with
the top section we seperate out the text elements and wrap each one in
its own div. All of which is still contained within the original "top"
div. In the css file we give "topleft", "topcenter" and "topmiddle" different backgrounds a width of 255px (765/3) and float each one left to ensure they appear side by side. To keep thing simple I have not put any borders on. Bare in mind that if you do, you need to reduce the width value accordingly. For example imagine if we wanted a border around each subsection of 5px, therefore left+right borders would equal 10px and top+ bottom borders would also equal 10px together therefore to fit in the new css settings would be: width:245px;
|
![]() ![]() |
| We repeat the instructions above
with the sub-sections within the "middle" and "bottom" sections.
as before in the css we will give each of the new sub-sections a different colour background to help follow what is happening. The result can be seen below. |
![]() ![]() |
| Finally we replace some of the
holding text with dynamic elements from our drupal site - in this case a
listing of the five most recent articles and also the current date.
I hope this is of use to those wishing to go beyond the standard themes and I look forward to hearing how you get on. I apologise to all you Drupal Gods but we all have to start somewhere!
best wishes
Joe |
![]() ![]() |