Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
4 Oct 2007 at 07:15 UTC
Updated:
23 Nov 2007 at 16:14 UTC
Jump to comment: Most recent file
A term's description is output in RSS feeds, but not in the corresponding page view of taxonomy/term/foo. Attached patch fixes this for Drupal 6.
Equally to the feed output, only the first term's description is output if more than one term is requested. No UI or API changes involved. However, I have added a theme function to let themers be able to override as much as possible.
This bug has been the primary cause for people migrating from other CMSs having to install Category module or implement dirty hacks of Drupal core.
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | changelog.patch | 1.28 KB | catch |
| #38 | changelog.patch | 731 bytes | catch |
| #32 | drupal-HEAD.taxonomy-page.patch | 3.37 KB | sun |
| #30 | taxonomy-page-4.patch | 3.22 KB | JirkaRybka |
| #28 | taxonomy-page-3.patch | 3.21 KB | JirkaRybka |
Comments
Comment #1
sunQuick clarification: check_markup() is used here, so wysiwyg editors can be used for the term description, thus allowing images and stuff in the term description (DB field is already from the type 'longtext').
Comment #2
sunRevised patch, adding missing initialization of $descriptions and check_markup() for term description in feed output.
Comment #3
sunmissed the patch
Comment #4
cburschkaThe patch applies fine (though the relative path is off, it has to be applied inside modules/taxonomy, but it should be applicable from the root folder), but I'm not seeing a difference.
Namely, I created a new term with a description and am seeing its page at taxonomy/term/1. But there is no description there besides "There are currently no posts in this category." Only the corresponding feed page has the description...
Comment #5
sun@Arancaytar: You need to manually clean your site's cache, see http://drupal.org/node/179248
Comment #6
cburschkaThanks for that info. After clearing the cache table, the description shows up as intended. So far so good. :)
I'm afraid this still doesn't happen on my test site though:
When displaying more than one term, as in taxonomy/term/1+2, I see no description at all, regardless of the cache.
Comment #7
sunNew patch; outputs always the first term's description on a page view (equally to the feed output). It's also much cleaner now.
However, I would consider it a bug if only the first term's description is output. If completely different terms are requested, the description will most likely be confusing for the reader. Anyhow, that may be another issue.
I searched through a bunch of contrib modules to ensure that no other module depends on plain text term descriptions (or no term description output at all). All modules I found are either outputting the description as is or trying to turn them into rich-text / HTML markup by themselves. So, this slight change won't affect something.
Furthermore, I've double-checked that the feed output is still valid (using http://www.feedvalidator.org).
Comment #8
sunwhere did my attachment go?
Comment #9
catchHaving just one description on /1,2 and 1+2 seems like a bug to me.
Also I'm wondering if this should be a theme setting similar to the "submitted" option for node types - I probably have about ten dodgy descriptions of taxonomy terms out of 2,500 terms, so it'd at least need to be documented in theme upgrade etc. to stop nasty surprises.
Comment #10
sunSorry, I did not make my point clear: I would argue that there should not be any description at all, if multiple terms are requested.
- Displaying the first term's description is confusing, if completely different terms are selected.
- Displaying all descriptions from all terms would clutter up the output with term descriptions. Those unrelated, but concatenated term descriptions are most likely even more confusing for the reader.
So, +1 to remove the description from both the page view and feed output if more than one term is selected.
Re: theme setting to enable/disable the term description: Don't know if that would be a feature (for D7) or could still hit D6 in terms of being a .
Comment #11
catch+1 to no description for more than one term, makes sense to me.
An extra setting (per vocabulary?) on having the description display I think would be usability for D6 personally - it's arguably less of a change than this bug fix will be in terms of user experience.
Comment #12
sunAs suggested, attached patch does not display a description if multiple terms are selected.
Additionally, I have moved taxonomy_render_nodes() to the theme function, so the output of taxonomy term pages can be overriden like any other Drupal page. So we are actually fixing 3 bugs in here.
I know that FILTER_FORMAT_DEFAULT is hard-coded here, however, that is a separate bug in the taxonomy system at all. Taxonomy did not even clean the output using check_plain() before. So this is a step in the right direction. Turning taxonomy term (and eventually also vocabulary) pages into "real" pages using a selectable input format looks like a valuable feature for D7 to me.
I would like to repeat: the included fixes in this patch finally allow Drupal users to use core's taxonomy system to create similar "category pages" like they are used to from other content management systems (f.e. Joomla!). All of this is achieved by fixing some long outstanding bugs in the taxonomy module.
Although I've tested it thoroughly and think it's RTBC, this patch needs review and testing by others now. Please bear in mind, that you have to truncate all cache tables after applying it. Additionally, you probably want to extend the list of allowed HTML tags of your default input format to insert f.e. an image.
Comment #13
sdecabooter commentedNice work.
I have applied this patch, and after clearing the cache tables, it does show the description on the page.
However i noticed some weird behaviour.
Steps i took:
- created a vocabulary, assigned to Story nodes and with a description
- created 3 terms within the vocabulary (World, Business, Sports) with a description for each term
- created 3 Story nodes, and assigned to first two to 'World', and the last to 'Sports'.
- applied the patch
- checked to see the description on the pages taxonomy/term/1 (and 2 & 3 afterwards) -> is fine
- Next i added the feed for Sports (taxonomy/term/3/0/feed) to my newsreader. It showed the 1 item in that category.
- Next i added the feed for Business (taxonomy/term/2/0/feed) to my newsreader. This should be empty, but shows all 3 content items instead!
Also when refreshing the admin pages i get the following error:
I'm not 100% sure if this is related to the patch, but when i reversed the patch, it seemed to work.
Comment #14
sdecabooter commentedHmm i must still be half asleep...
In fact i get this behaviour without having applied the patch, so this seems unrelated. You can forget my comment :)
Now i should try to find what causes this error, and if it's already been reported...
Comment #15
sunNow, does anyone feel strong enough to mark this RTBC?
Comment #17
sunAnyone? I really do not want to set my own patches to RTBC!
Comment #18
Jaza commentedI like what this patch is doing: I agree, this is a long-overdue feature in the taxonomy module!
However, -1 to hard-coding the default input format for outputting the description. Even though it's in a themable function, and it's only intended as a temporary solution, it's still very ugly. I'd prefer to let this patch wait until D7, when we can add a new 'format' field to the 'term_data' db table, and thus allow the input format to be configurable per-term by the user. Of course, it's too late in the D6 release cycle for a schema change such as that.
Otherwise — as an alternate D6-ready solution — I'd prefer to pass the description through filter_xss_admin(), instead of check_markup(), thus outputting it safely while avoiding the filter system. According to the page on how to handle text in a secure fashion, filter_xss_admin() would seem to be the best outputting mechanism to use here. Plus, themers can always override the function, if they do actually want to use check_markup() and to force the default input format.
Also, I think that the output of theme_taxonomy_term_page() should wrap the description in some kind of special container, e.g. a div with class 'term-description'.
Comment #19
sun@Jaza: Thanks for your valuable input!
Applied all proposed changes.
Comment #20
JirkaRybka commented+1
I really like this small addition to Taxonomy module. Patch applies cleanly, works well, and seems OK to me. So setting RTBC.
Indeed, if Taxonomy should be used for categorization in Drupal by everyone (as quite a few people said to me that Category module is bound to be dropped one day), then we need to improve Taxonomy's navigational/user-experience greatly. This patch is an important part of that, which I believe is non-intrusive enough for 6.x.
I'm starting a new issue on the next part I believe is needed: http://drupal.org/node/185146 Obviously, that's a D7 stuff...
Comment #21
gábor hojtsyIndeed, t is quite unfortunate that we have quite a few textareas in Drupal, which don't have an input format associated. Taxonomy descriptions are of those kind. So using filter xss seems like the best we can do for now.
What's to do with this patch still IMHO:
- doesn't taxonomy already has a themeable function group, where this function could go?
- a comment would be great at both places with something like:
// Only display the description if we have a single term, to avoid clutter and confusion.These are not major things though.
Comment #22
JirkaRybka commented- Themable functions group: No, there isn't one. I checked - 'taxonomy.pages.inc' is a tiny file with only just 3 functions in it (including the one added by this patch), and there's no explicit functions grouping in the whole Taxonomy module. I also searched for other themable functions, and found only one (
theme_taxonomy_term_select()in taxonomy.module - i.e. other file), which is no more than a wrapper around another theme() call. So our new function is the only one in the file, and only *real* one in the whole module, so it's only natural to have it near it's usage IMO.- Along the way, I noticed that the file taxonomy.pages.inc had an incorrect comment at the top (someone probably pasted it accidentally from taxonomy.admin.inc while splitting the module) - these page callbacks are certainly *not* administrative. It's so tiny issue (one word in a comment), so I added it to this patch too.
- Suggested comments are now added. Really useful IMO.
New patch attached, with NO changes done to the code, only comments changed. Still, I tested it successfully.
Comment #23
gábor hojtsyOh, I nearly committed this patch, but then decided to look up what happens with 'description' after all.
- node_feed is called with $channel (http://api.drupal.org/api/function/node_feed/6)
- node_feed passes on the description to format_rss_channel (http://api.drupal.org/api/function/format_rss_channel/6)
- which strips all HTML and escapes what's remaining
So after all it was not bad that the description was not filtered for XSS here when passing on for feed display. When passing on for page display, it needs to be filtered though. So seems like we are fine by removing the filtering and adding a comment there that HTML will be removed from the description later.
Comment #24
catchMarking as needs work for that comment.
Comment #25
JirkaRybka commentedI did the change, but as the attached file is just untested edit to the previous patch file, it needs a bit review again. (Also sorry about the extension - I'm currently sitting on my boss' outdated Windows, unable to change settings here.)
Comment #26
catchThird hunk doesn't apply, "malformed patch".
Comment #27
JirkaRybka commentedHmm, perhaps it's not OK to add lines to a patch file by just editing it, or the Windows CR/LF environment is a problem... Sorry about that, but unfortunately I've not access to my patch-rolling setup now (until evening).
Comment #28
JirkaRybka commentedOK, I've just returned to my home machine, and re-created the change. Attaching the same patch again, but rolled properly now. I've also tested it (including the feed output), but another review would be nice, obviously.
Comment #29
catchPatch applies ok but I get a WSOD on all taxonomy/term pages with or without a description entered after applying.
Comment #30
JirkaRybka commented- Re-rolling, applied with fuzz today.
- catch: Please explain a bit more, I have no clue what is "WSOD" supposed to mean (I'm rather new to these abbreviations, yes). I tested the patch again, and works fine for me. But all my testing is on fresh 6.x-dev installs with just few terms/nodes created (my production site doesn't run Taxonomy).
Thanks in advance for more info.
Comment #31
JirkaRybka commentedOh, after a bit more testing I seem to get it at last: You mean 'White Screen Of Death', right? ;-)
I managed to reproduce that, but only by targetting it specifically:
- Did an unpatched 6.x-dev install, created a few terms and nodes. All OK.
- Applied the patch to this existing install, WITHOUT flushing cache.
- Now, indeed, all Term pages show just white screen. There's a new themable function in the patch, which needs to register in the new theme system properly.
- Flushed the 'cache' table.
- Now all fine, and patch works as expected.
So setting back to 'Needs Review', because the above is not a fault of the patch. If your problem was different, feel free to change status again.
Comment #32
sunThis looks *very* good!
I have removed the additional parameter type definition in theme_taxonomy_term_page()'s PHPdoc, because I saw another patch rejected to PNW due to that.
Marking as RTBC.
Comment #33
JirkaRybka commentedAgreed.
Comment #34
gábor hojtsyThanks, committed.
Comment #35
sunJust one quick note:
Although this was a small and straightforward bug fix, I think it is really noteworthy and should be highlighted in the Drupal 6 announcement. As mentioned before, users were forced to install one of the contributed modules Category, Taxonomy context and perhaps others (or develop a custom solution using CCK and probably custom theme templates) to achieve simple section/category pages like they are provided in almost all other content management systems out there. If they did not have these ideas or found them too complicated, I'm sure they left Drupal and stuck to another web-application. It may be of no interested for people using Drupal to build community sites, but for those of us using Drupal to build also simple and lightweight personal or commercial sites, this patch finally bridged a logical gap in Drupal's core categorization system.
I would even say, for me this fix is one of the most effective changes in Drupal 6. It's one of the things, new and novice Drupal users are able to perceive and benefit from.
Comment #36
catchsun, in that case I'm setting back to active so this can be added to CHANGELOG.txt, where such announcements are usually drawn from. I agree that it'll make a big difference to new drupal users - we've used things like sticky nodes to have something up top (which means they always appear at the top of feeds as well, not great).
Comment #37
catchComment #38
catchhere's a patch.
Comment #39
sunLooks good - however, I'm afraid that someone reading this would not understand what it actually means. Shouldn't we also mention the simple use-case?
Comment #40
catchWell next to it is:
- Added support for OpenID.
- Added support for triggering configurable actions.
These will also need translating into plain English, possibly with links to more information, when they get into the announcement itself. If we could keep it suitably short though I don't see why not.
Comment #41
gábor hojtsyWhile I don't think this warrants its own CHANGELOG item, I am not strongly against it either. Anyway, we already have a taxonomy versioning item, so we can fold it under this "heading" to make some use of this being a list.
Comment #42
catchWell here's a patch with that change anyway.
Comment #43
gábor hojtsyOK, modified rss to be RSS, fixed wrapping and wrapped first item as it was past 80 columns. Committed. Now let's move on to fixing bugs :)
Comment #44
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.