#3695 closed (fixed)
duplicate html id's in doc pages
Reported by: | Owned by: | simeon | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | admin, docs, xhtml | |
Cc: | dev@…, sf@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Whilst trying to fix #2411 (Validation errors in template filters/tags documentation) I came across this minor issue. The templates loop over each tag/filter, and title them with something like <h3 id="{{ tag.name|escape }}">{{ tag.name|escape }}</h3>
.
When there are two template tags named the same, then there will be an id clash, causing an (x)html validation error (and the anchor tags won't work properly for the two duplicate id's):
# Error Line 525 column 12: ID "filter" already defined. <h3 id="filter">filter</h3> An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).
Currently, this is only an issue in template_tag_index.html, where we have a filter
tag in the defaulttags section and in the admin_list section.
It can be fixed by prepending the library name to the id, so that each one will be unique. I'll add a patch once I've finished up #2411
Attachments (2)
Change History (18)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 17 years ago
Has patch: | set |
---|
by , 17 years ago
comment:4 by , 17 years ago
Cc: | added |
---|
comment:5 by , 16 years ago
milestone: | → 1.0 |
---|
comment:6 by , 16 years ago
milestone: | 1.0 |
---|
As best I understand it, this doesn't create a display problem, it doesn't cause Django to crash, it doesn't prevent anything from actually working. It's a slight annoyance in some edge-cases creating invalid output at the markup level on the documentation page (only). If that's all correct, it can wait until after 1.0.
comment:7 by , 16 years ago
I'll grant it's pretty minor, but there is one thing that doesn't work: linking to a particular tag/filter when more than one exists in the page. In most browsers, links will always go to the first occurrence of the id.
comment:8 by , 15 years ago
Patch needs improvement: | set |
---|
All of admin_doc has been refactored - either this is no longer an issue or at the least the patch needs to be redone.
comment:9 by , 15 years ago
Actually, I was looking at the wrong admin_doc directory (Which should be deleted). The patch still needs to be updated though to apply to the new location of admin_doc.
comment:10 by , 15 years ago
Ok - I updated the patch to apply to latest trunk - I also added the same fix to the filters template. However in testing it I noticed that in current trunk built-in filters and tags are being shown, only tags and filters that belong to modules. I'll open (or find an existing) ticket for this...
comment:11 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:12 by , 15 years ago
Patch needs improvement: | unset |
---|
comment:13 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Ok, just to be clear on how to replicate the bug and verify that it is fixed:
Start a Django project with admin. Login to the Admin area and click on the "documentation" link and then on the "Tags" link to load the doc page for template tags.
On the left the index lists the tags for various modules with links that jump to the relevant tag based on ID. This works as long at there are no duplicate tag names - the admin_list module, however, defines a "filter" tag that then uses the same ID as the built in filter tag. Clicking on either link entitled filter in the index brings you to the built in filter tag (and as mentioned the page is now not valid HTML).
I applied the fix Simon G recommended by prefixing the ID and link target with the relevant module name (or built_in for the built in filters). See 3695.diff. Upon applying navigation ought to work properly and ID/link target elements should be inspected (yea firebug) to verify that they are constructed properly.