Django

Code

Ticket #3695 (assigned)

Opened 1 year ago

Last modified 6 months ago

duplicate html id's in doc pages

Reported by: Simon G. <dev@simon.net.nz> Assigned to: simeon (accepted)
Component: Admin interface Version: SVN
Keywords: admin, docs, xhtml Cc: dev@simon.net.nz, sf@simeonfranklin.com
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

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

3695.diff (1.3 kB) - added by simeon on 12/01/07 13:21:06.

Change History

03/11/07 14:00:42 changed by SmileyChris

  • needs_better_patch changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • needs_docs changed.

12/01/07 12:36:27 changed by simeon

  • owner changed from nobody to simeon.
  • status changed from new to assigned.

12/01/07 13:20:31 changed by simeon

  • has_patch set to 1.

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.

12/01/07 13:21:06 changed by simeon

  • attachment 3695.diff added.

12/01/07 13:29:10 changed by simeon

  • cc changed from dev@simon.net.nz to dev@simon.net.nz, sf@simeonfranklin.com.

Add/Change #3695 (duplicate html id's in doc pages)




Change Properties
Action