Task description
This task is to modify the FAQ module so that it uses theme templates instead of 4 of its theme functions.
Modules in Drupal have the ability to allow their HTML presentation to be overridden by the theme layer. This gives a huge amount of flexibility and allows greater customisation of Drupal sites. In Drupal 5, "theme" functions were used to contain chunks of HTML output which could be overridden. This method is still supported in Drupal 6 but there is now an alternative and better way of implementing it using template files.
The FAQ module has a number of theme functions. To complete this task, you need to create a template file (.tpl.php) and a corresponding preprocessor function for each of the theme functions listed below. See the resources section for more information, particularly "Using the theme layer in Drupal 6".
Theme functions:
- theme_faq_new_page()
- theme_faq_hide_answer()
- theme_faq_questions_inline()
- theme_faq_questions_top()
The final deliverable will be a patch against the 6.x version of the FAQ module posted to the issue queue that has been reviewed and marked "Ready to be Committed".
Resources
- FAQ project page - http://drupal.org/project/faq
- Using the theme layer in Drupal 6 - http://drupal.org/node/165706
- List of existing drupal templates - http://drupal.org/node/190815
- Drupal Coding Standards - http://drupal.org/coding-standards
Primary contact
Stella Power (http://drupal.org/user/66894 - snpower)
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | faq_templates_09_templates.zip | 2.02 KB | cwgordon7 |
| #18 | faq_templates_08.patch | 10.55 KB | cwgordon7 |
| #18 | faq_templates_08_templates.zip | 2.03 KB | cwgordon7 |
| #16 | faq_templates_07.patch | 10.59 KB | cwgordon7 |
| #16 | faq_templates_07_templates.zip | 1.95 KB | cwgordon7 |
Comments
Comment #1
stella commentedComment #2
cwgordon7 commentedThis needs review. Sorry that the template files are zipped, but my patcher program was giving me trouble :(.
Any feedback would be appreciated.
-cwgordon7
Comment #3
cwgordon7 commentedUpdated version, rerolled.
Comment #4
cwgordon7 commentedSorry, windows line endings.
Comment #5
aclight commentedAs I mentioned in IRC, I really know nothing about D6 theming, so what I write below may or may not be helpful. I also didn't have time to actually test this to confirm that it works. Most of these are pretty minor points, but probably should be addressed.
A.) You change several comments to have a capital letter. You might as well fully comply with the Drupal coding standards and add a period at the end to make it a sentence. :)
B.) Looks like you kept a comment that's unnecessary:
C.) It seems to me that this:
would be better as:
but I could be wrong.
D.) In faq-questions-inline.tpl.php, you have this:
Shouldn't you just apply a style in the tpl.php file and then include a separate .css file that defines the style's attributes?
Also, as discussed on IRC, this really should be made into one patch if possible so that it's easier to review.
Comment #6
cwgordon7 commentedOk.
(a) is easy enough, done.
(b) Grr. I hate it when I do that :(.
(c) Ugh. How could I not see that?
(d) The point of a template file is to make it easy to edit; html is user-friendly (ish), while css is not. The
<font color="#6e0dd3">could easily be replaced with<strong>, or whatever the admin wants.And, I'm still having trouble getting it into one patch. I'm really sorry, but the template files still have to be zippified. Since I made no updates to them, the older version of the templates will work fine. New patch is attached.
Comment #7
aclight commentedI don't see how css is not user friendly, and personally I wouldn't commit code with specific styles in the tpl.php file, but since I'm not committing anything here, so it's up to the module's maintainer as far as what to do about that.
Comment #8
cwgordon7 commentedNew templates attached in response to aclight's post.
Comment #9
stella commentedSorry for the delay in responding, I've been internet-less since Christmas.
So I've done a quick test of the patch and the initial feedback is below. However I did find one bug in the original checked-in code! There was a missing closing " for a class name which broke the faq node links in the questions inline mode. I've checked in the fix and attached a patch for your version.
My initial tests just involved testing of (a) the functionality and (b) the layout, i.e. basically that it behaves and looks the same as the previous version.
<h4>...</h4>tags in this file as it messes up the font size.<hr>tag on line 18 which shouldn't be present.<strong>...</strong>tags around the question text which cause it to display incorrectly.<hr>tag on line 12.I'll conduct a more in-depth set of tests next. However, it's looking great! Thanks a mill!
Cheers,
Stella
Comment #10
stella commentedHi,
I've had another look at the patch, at the code this time. I quite like what you've implemented with the different variables available to the themer in the template file, especially the way that they're clearly documented. However, I would prefer if all of the html divs could be moved out of the module file and into the template files.
Here's an example:
could change to something like:
See the way all of the
<div>tags have been removed. It could be that the themer doesn't want to use div tags around the answer text and instead wants to use<p>tags instead. You will need to modify the template files as appropriate. It will probably involve the use of aforeachloop but I think that's an acceptable amount of php code in a template file. See some of the forum module's template files for examples.Cheers,
Stella
Comment #11
cwgordon7 commentedThanks for the review :)
New re-rolled patch and templates attached. The extra formatting in the templates was supposed to be an example of what you can do with templates for the user, but it seems that it is not necessary, so I removed the extra html.
Comment #12
cwgordon7 commentedWhoops, I posted the comment while you were reviewing. This was in response to #9. Give me a few minutes to respond to #10.
Comment #13
cwgordon7 commentedOk, new patch & templates attached. :)
Comment #14
dmitrig01 commentedCouple of comments:
foreach() {...}structure in a template. That's just plain BAD.Instead, use
That's the syntax most often used in Drupal
That shoulud be on the same line, like this:
?><div>Why que and ans? why not question and answer?
<dl>?I don't get that. Could you make it more clear?
theme_faq_category_questions_topa template? it seems to be a lot of html mixed with php.[/review]
Comment #15
stella commenteddmitrig01: answers to some questions below:
Q.1, good point, though I'm not sure that it's done that way in the forum module, maybe we need to add a minor bug report for that, or add a check to the coder module so it can check for it in future?
Q.3, again good point, I think it was probably inherited from the original version of the code, but the variable name should be made clearer.
Q.5, users can choose between ordered lists (
<ol>) and unordered lists (<ul>). The $list_style variable probably contains ul or ol.Q.7, display_vars stuff is inherited from the original version of code. I don't think modifying this should fall into the scope of this GHOP task.
Q.8, theme_faq_category_questions_top isn't a template because we haven't gotten that far yet. I thought it was too many functions to port to a template for one GHOP task. As soon as this task is completed, I'll open a 2nd task that ports this function, and others, to templates.
Cheers,
Stella
Comment #16
cwgordon7 commentedOk, new stuff attached.
Comment #17
stella commentedHi,
Did another review of the patch. It's almost there. The only things left are minor layout and coding standards changes.
faq-new-page.tpl.php
Perfect!
faq-hide-answer.tpl.php
<div class="faq_answer faq_dd_hide_answer">...</div>.!empty($node['more_link'])function rather than checking$node['more_link'] != ''.faq-questions-inline.tpl.php
<div class="faq_answer">...</div>.<strong>...</strong>pair of tags in order to match the original layout.empty()function instead ofisset().faq-questions-top.tpl.php
<div class="faq_answer">section instead of it's own<div class="faq_question">section.<div class="faq_answer">...</div>section.<br />or something similar just to add a wee bit of blank space between the question list and the Q&A text further down. This is only a minor thing though.Here's what the html structure of the resulting faq page should follow:
Each of the template files also need to have the CVS keyword $Id$ included in each file, e.g.
/* $Id$ */.You're pretty much there at this point. There's only a few minor changes left to make at this point. Well done!
Cheers,
Stella
Comment #18
cwgordon7 commentedThanks, revised stuff attached.
Comment #19
dmitrig01 commentedOk, my turn for a review
In templates, with $Id$ tags, those go (a) in comments marked by //, (b) in the same block of PHP as the other comments/docs
Example:
/* $Id$ */should be
That IMO is the only outstanding issue!
Comment #20
stella commentedYep, the issue dmitrig01 identified above is the only outstanding issue! Everything else is perfect.
Cheers,
Stella
Comment #21
cwgordon7 commentedOk, revised templates attached.
Comment #22
stella commentedPerfect! It's great! Thanks for all your hard work. I really appreciate it. Good luck with your other GHOP tasks.
aclight, dmitrig01: would one of you mind updating the Google issue: Issue 108.
Cheers,
Stella
Comment #23
add1sun commentedGHOP issue is closed. Thanks cwgordon7!
Comment #24
stella commentedAll checked in! Thanks again.
Cheers,
Stella
Comment #25
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #26
stella commentedReleased in FAQ 6.x-1.3.
Cheers,
Stella