Creating my first cutome theme

ljCharlie - November 21, 2005 - 21:32

I just got my drupal 4.6 up and running. I'm very new to this drupal let alone creating themes and modules. I have gone through the secontion on Developing for Drupal, but I still have no clue why I would need the engine and once I have the engine and downloaded, how do I use it? I can understand the part about modifying an existing theme...but to create new theme with the engine is where I got confused. What's the purpose of the engine, why need them, and how to use to help me create new theme? I'm currently using Dreamweaver Studio 8 to edit my website...but like to try Drupal. I want to create my own theme because the default and many of those I downloaded doesn't exactly fit what I'm looking for. Your help is much appreciated.

Theme engines

styro - November 21, 2005 - 22:43

Each theme engine has a different method for generating HTML from Drupal content. Each theme is written for a specific theme engine. The engine is how the themes slot into Drupal.

By default Drupal 4.6 ships with the XTemplate theme engine. Drupal 4.7 will ship with the PHPTemplate engine as the default theme engine.

Most 3rd party themes are PHPTemplate ones, and most theme designers seem to prefer working on PHPTemplate themes. You can use PHPTemplate themes on Drupal 4.6, but because Drupal 4.6 didn't ship with an engine for PHPTemplate themes you have to install the PHPTemplate engine to use PHPTemplate themes.

The popularity and flexibility of PHPTemplate is why it will be the new default engine in 4.7. I'd recommend learning it if you want to start creating your own themes. More popular also means that it is easier to get support for.

--
Anton

hopefully this info helps.

mork - November 21, 2005 - 22:46

Drupal is highly modular - indluding the template 'engine'. I'm not sure if your familiar with other CMS's, but usually they employ a single template engine and when producing a theme you must accomodate it.

With drupal, you have some options. One way to evaluate your needs would be to download a handful of themes done with the various engines and have a look at the templates and what style seems best suited to you.

My advice, partially tainted by personal preference, would be to develop your theme using the phpTemplate engine. I would recomend downloading it and a theme or two which use it and start there.

Then, to create your very own theme, create your own subdirectory in the /themes/ directory and plunk in the neccesary files (use existing themes as a guideline).

File like page.php.tpl and node.php.tpl control the presentation. I'm not sure how well this will work with Dreamweaver as I have no experience with it.. maybe someone else can comment.

Once you've got those files in your theme's directory, it will show up under 'themes' in the administration area of your Drupal install. You can then enable it and use it. This, of course, is usually a circular process (i.e. dont expect to develop a full theme without ever having enabled it during the process to see how it works/looks).

I agree witht he above

eferraiuolo - November 21, 2005 - 23:46

I agree witht he above comments, build your theme using PHPTemplete engine, and use this as a reference:
http://drupal.org/phptemplate

I also use Dreamwaever Studio 8 as my editor for drupal themes, but I use it as a text editor not a WYSIWYG editor because of all the PHP calls required to make the template files work. By using the templates posted in the handbook (linked above) you will have an unstyled but working theme, start with that.

Good knowledge of XHTML and CSS (with all its tweaks and work-arounds for IE) you can produce a standards compliant output from drupal really easy with a ton of control when using PHPTemplate

Thank you for your

ljCharlie - November 22, 2005 - 05:33

Thank you for your responses. I'll give that template a try and see what happens.

Again, thank you.

Okay, I gave it a try but

ljCharlie - November 22, 2005 - 20:43

Okay, I gave it a try but still have no clue. I have downloaded the phptemplate and created my own theme name under the theme folder but how do I use the template from the phptemplate engine? If it is a bunch of code and no WYSIWYG then how do I know what it will look like? I have modified the box_rey theme and save the page.tpl to page.tpl.php and node.tpl.php and uploaded whole folder to my webspace and refresh the administer>>theme page and nothing happens. I do not see the new modified theme name. It seemed that anything has .tpl.php will not show up in my administer>>theme page including this theme, argeebee, gworks and the box-grey, that I downloaded. These threethemes does not show up in my theme page but the rest theme such as slash, goofy, chameleon, pushbutton and so on. When I look closer, all of these themes that show up in my theme page does not have a .tpl.php file. They user .theme, .xtmpl and CSS.

I guess my biggest problem right now is how do I use the engine to create my custome page. Second, if I do not see what I'm designing, how do I know what to design?

Well, I'm making progress.

ljCharlie - November 22, 2005 - 20:52

Well, I'm making progress. The .tpl.php theme does show up in my theme page now. I'm still unsure how to design when I don't see what it looks like before I uploaded into my webspace.

Well, I do see the theme

ljCharlie - November 22, 2005 - 20:56

Well, I do see the theme available in my administer>>theme page but when I enable and set it to default, all I get from the site is a bunch of codes...nothing as showing in the administer>>theme thumbnail. What else do I need to do?

When learning how themes work

styro - November 22, 2005 - 22:31

its best to start off by changing an existing theme.

I don't recommend coping the PHPTemplate files to make your theme (PHPTemplate is an engine not a theme), copy the files from an existing PHPTemplate based theme.

--
Anton

Many thanks for all your

ljCharlie - November 23, 2005 - 02:57

Many thanks for all your patient and help. I think I am getting somewhere now. However, after enable one of the module called ajax I received the folllowing error:

Fatal error: Call to undefined function: drupal_add_js() in /home/myDomain/public_html/drupal/modules/ajax_spellcheck/ajax_spellcheck.module on line 31

My website does not work anymore since I tried to enable the ajax_spellchecker module. How do I fix this problem?

You might want to start a new thread for this

styro - November 23, 2005 - 04:41

Looking through http://drupaldocs.org it looks like drupal_add_js() isn't part of Drupal 4.6, and only in later versions. It looks like that ajax module (I've never used it myself) was mistakenly tagged for 4.6.

Because your site isn't working anymore, you'll have to disable the modulebehind the scenes.

I can think of two approaches a) change the database to disable it, or b) delete the module from the filesystem.

a) is probably 'cleaner' but trickier than b). But I don't think deleting it could cause any real problems - no promises though.

If you do want to try editing the database, using phpmyadmin browse through the system table for a record containing the modules filename and change its status to 0.

If you don't use phpmyadmin, this is the SQL statement that phpmyadmin used to do the same thing (it should work):

UPDATE `system` SET `status` = '0' WHERE CONVERT( `filename` USING utf8 ) = 'modules/ajax_spellcheck/ajax_spellcheck.module' LIMIT 1 ;

I don't know how necessary that CONVERT bit is. As I said, you'll probably prefer to just delete the modules directory :)

--
Anton

Many thanks for your help. I

ljCharlie - November 23, 2005 - 13:45

Many thanks for your help. I think what happened was when I found out there is a problem, I already disabled the module in the administer/module page but have not deleted the files. So I deleted the file and it works fine now.

Okay, maybe I should start a

ljCharlie - November 23, 2005 - 14:09

Okay, maybe I should start a new thread because it is getting quite long. But thanks to all your generous help, I'm finally getting somewhere. What I need to know now is all the available variables. How do I find out all the available variables? For example, top and bottom menu, left side navigational menu, footer, and so on.

The docs

Michelle - November 23, 2005 - 14:57

Check this for variables: http://drupal.org/node/11812
Check this for general PHPTemplate theming help: http://drupal.org/phptemplate

Michelle

Michelle, thank you so much

ljCharlie - November 23, 2005 - 21:35

Michelle, thank you so much for the links. One addtional question, how do I edit or put links in the Navigation Left sidebar? When I click configure in the module, I don't see a place where I can type in the name and URL.

Menu module

Michelle - November 27, 2005 - 23:15

You need to enable to menu module and then you can edit the menu, which is what that navigation block is.

Michelle

Thor warned us ...

bmargulies - February 20, 2006 - 16:45

According to the description, ajax_spellchecker in 4.6 requires a set of Ajax support code from 'his private CVS tip.' I have not yet succeeded in locating it.

 
 

Drupal is a registered trademark of Dries Buytaert.