1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Anchor links to mainpage

Discussion in 'Troubleshooting and Problems' started by Sukrams, Jun 22, 2012.

  1. Sukrams

    Sukrams Member


    I edited the terms and rules phase and uses some anchors in the text. But the link doesn't jump to the anchor, but to the mainpage of the forum. Has someone a solution for that?

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Which phrase? And what code did you use?
  3. Sukrams

    Sukrams Member

    The terms_rules_text-phrase. I have a table of content first, like

      <li style="list-style-type:none;"><a href="#kap0">Vorwort</a></li>
    and in the text i define the anchor:

    <h3><a name="kap0">Vorwort</a></h3>
  4. Arty

    Arty Well-Known Member

    Use id instead of name:
    <a id="kap0">...
  5. ragtek

    ragtek Guest

    probably this will work

    <li style="list-style-type:none;"><a href="{$tosUrl}#kap0">">Vorwort</a></li>
  6. Sukrams

    Sukrams Member

    With an id there is the same result, I tested it before.

    The solution of ragtek gives only a new site, that the site can not found.
  7. ragtek

    ragtek Guest

    OK, i've played a little bit with this and found the problem:)

    It's because of xenforos base

    e.g. on this site:
    <base href="http://xenforo.com/community/" />

    so if you have only an link with an anchor tag "href="#foo" it will link to http://xenforo.com/community/#foo"

    and that's why it's always redirecting to the index page:)

    You could change

    <a href="#kap0">Vorwort</a></li>

    <a href="{$requestPaths.requestUri}#kap0">Vorwort</a></li>
  8. Sukrams

    Sukrams Member

  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    {$requestPaths.requestUri} works in the templates but not in the phrases unless you pass in the value:

    Admin CP -> Appearance -> Templates -> help_terms

    Add the red code:

    <xen:title>{xen:phrase terms_of_service_and_rules}</xen:title>
    <div class="baseHtml">
    {xen:phrase terms_rules_text, 'requestUri={$requestPaths.requestUri}'}
    Now you can use {requestUri} when you edit the phrase.
    Sukrams likes this.
  10. Sukrams

    Sukrams Member

    That works, thanks for your help!

Share This Page