Approximately 80 gabillion support questions would go unasked if we had an example template.php in the default core theme.

Ideally, this template.php file would include:

1. An implementation of the regions hook, to declare a new block region.

2. An example override of a theme function.

3. Doing something with _phptemplate_variables, such as creating a front page template that was only shown on the front page.

4. Copious amounts of inline documentation to describe what was doing what and why (think settings.php).

CommentFileSizeAuthor
#9 template_0.patch3.03 KBwebchick

Comments

jjeff’s picture

Check out the current template.php file. A bunch of this stuff is already in there.

jjeff’s picture

Version: » 6.x-1.x-dev

Whoop... uhhh... maybe not. Nevermind. :-)

m3avrck’s picture

Status: Active » Fixed

Fixed.

Create another issue + patch to tweak the file more / add in more / etc.

Great idea!

zirafa’s picture

Status: Fixed » Active

I've modified this file to reduce and clarify the help text. I think having too much text is just as bad as not enough.

I am not entirely convinced these examples belong in this template.php file however. I don't see how this is an advantage to a good template.php example on drupal.org. That way other themes could also link to this same example and there would be consistency in documentation.

zirafa’s picture

Sorry, I meant to say, I don't see how including these examples is more advantageous than just providing a link to an example on drupal.org.

scroogie’s picture

Well, the thing with documentation is that the people dont read it... having the basic examples in a core theme helps by really _demonstrating_ the possibilities and lets the people try out stuff.

webchick’s picture

Yep. No one reads documentation, and I say this with some authority as someone who spends an awful lot of her time writing documentation for Drupal.org. ;)

Plus it creates a dependency on a) having an Internet connection and b) Drupal.org to be up and running if you're trying to make a custom theme.

There's really no substitute for having self-documenting and easily modifiable code included in the package, imo.

zirafa’s picture

I'm convinced! Leave it in! :)

But please review some of the changes I made to the document. There is always room for improvement and clarity.

webchick’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new3.03 KB

Looking great, guys!!

Here's a patch that contains some minor formatting fixes and some other stuff.

jjeff’s picture

Status: Reviewed & tested by the community » Active

I'd really like to see examples for the 'node' and 'comment' cases of the _phptemplate_variable() function.

Zirafa, would you be okay with bringing back those from this commit:

http://cvs.drupal.org/viewcvs/drupal/contributions/themes/zen/template.p...

I think it's a really important concept for people to understand.

zirafa’s picture

Sure, I just didn't like how the whole function was commented out. I'd prefer them be actual usable examples but I'd be alright if these ones were commented out.

jjeff’s picture

Status: Active » Fixed

committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)