Hi Zen,
we solved one shortcoming of the current quote.module and changed the quote rendering code so a theme-function is used for the *rendering* of quotes (if available). This means, with the attached patch the quote.module's output of one quote is now themed via the call
... theme('quote', $quote_content, $quote_author) ...
of a theme-function like:
function phptemplate_quote($quote_content, $quote_author) { ... }
If no such theme-function is defined, the module's default rendering will be used.
The patch was created against: quote.module,v 1.29.2.8 2007/08/11 19:51:20 karthik
It should be ready to be commited against the current dev-version, too.
Please try and commit the patch :)
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | quote.module.patch | 2.37 KB | danielnolde |
| quote.module.patch | 1.48 KB | danielnolde |
Comments
Comment #1
Zen commentedWhy not just make _quote_filter_process a themeable function?
Please don't set patches to "ready to be committed" directly - chalk it up for review first. Please also follow Drupal's coding standards.
Thanks :)
Comment #2
danielnolde commented> Why not just make _quote_filter_process a themeable function?
_quote_filter_process includes some of the modules *logic*, that has nothing to do with theming but with handling the [quote]-parsing - that's not theming. Logic and Theming should be seperated as good as possible and/or suitable, and in this case the way the patch achieves it is suitable and get's the module to the goal of logic/theming seperation.
> Please don't set patches to "ready to be committed" directly - chalk it up for review first.
Okay.
> Please also follow Drupal's coding standards.
I can modify the code to adhere to the standards if i get a little hint where it lacks those... (would be the fastest way).
Comment #3
junyor commentedA couple suggestions for the coding style:
* Use two spaces for indenting (don't use tabs)
* Use meaningful variable names ($s isn't meaningful)
* Use "{" and "}" in if statements, even if they're only one line
The full coding standards are available at http://drupal.org/node/318.
Comment #4
junyor commentedAlso, it would say that the logic and themeing aren't suitably separated. I'd rather see theme_quote() and theme_quote_author() added and used within _quote_filter_process(). I think that would mean not using regular expression replacement, though.
Comment #5
danielnolde commentedHere's a reworked patch for current 6.x-1.x-dev release of quote.module (2008-Oct-07), including:
- proper adherence to code drupal standards
- D6 specific adustments (theme function is declared)
- the abstraction of now themable quote rendering form the quote parsing
- a reworked and simplyfied quote parsing method with a different, simplyfied and solid regexp (source given in code)
- nested quotes are handled correctly via recursive parsing
One thing: Rendering filter output through a theming function enables to smoothly seperate the filter's function from the rendering of its output - on a single theme site. On a multi-theme-site, this will be working correctly only, if the theme('quote', ... ) theming-function would be synchronized/identical throughout the different themes used.
However, since many many drupal projects involve heavy customizing via a single custom theme, the introduction of themabe output for the quote.module is a great help for themers/developer and at the moment the only way to avoid hacking this module for achieving custom quote rendering. So, anyway, the patch should be adding significant value.
Hope this patch gets tested by others, too, and will be finalley committed.
thanks,
daniel
Comment #6
NorthPort commentedSorry, noob question, but how to import the patch or replace the existing file?
cheers,
David.
Comment #7
danielnolde commentedhttp://en.wikipedia.org/wiki/Patch_(Unix)
http://drupal.org/node/60108
Comment #8
Kripsy commentedThis tests well for me.
Comment #9
Zen commentedCOmmitted slightly modified patch to 6-1.
Would it be possible to improve the regex to validate the quote tags more rigorously? Currently,
[quotemenot]and[quote[quote=zen]both pass validation. Checking for the=and loose whitespace around it would also be good.Setting to patch needs work. I'm also looking to backport this to D5.
Many thanks for your work on this, Daniel :)
Cheers,
-K
Comment #10
Zen commentedThis has also been backported to D5.
Comment #11
Zen commented