ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Remove whitespace to validate page anchors

October 20, 2008 8:05am

Subscribe [2]
  • #1 / Oct 20, 2008 8:05am

    mmmdreg

    6 posts

    I have a sidebar populated with elements with more than one token (eg. “John Doe”, “Jane Doe” etc..). They’ve been set to link to an anchor further down the page and as it is all dynamic, I felt the easiest method was to set href=”#{title}” and name (or id) to “{title}”. These would evaluate to John Doe and so on.

    This works fine. However, it does not validate under strict XHTML 1.0 as name/id only permit single tokens. Thus, my solution is to remove all the spaces and turn each part into a single token (eg “#JohnDoe”).

    I thought using Find and replace plugin would work with the syntax:

    <h3 id="{exp:replace find=“SPACE”}{title}{/exp:replace}"></h3>

    (It specifies leaving out the second argument will replace “SPACE” by nothing)

    However, it doesn’t seem to do anything at all..

    Any ideas?

    Cheers, George

  • #2 / Oct 20, 2008 1:18pm

    silenz

    1651 posts

    Use {url_title} instead?

  • #3 / Oct 20, 2008 8:06pm

    mmmdreg

    6 posts

    Use {url_title} instead?

    Sorry I messed up my initial post. The links are coming from a bunch of custom fields so I’m using {custom_field_title} as the #href. The actual anchor points are hardcoded into the body section.

    It’s so an entry can have optional sub-headings in the body, which if they exist, would have corresponding titles in the custom fields that would allow the user to jump to that sub-heading.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases