Search

Hello,

I am desperately trying to link to a simple anchor element within the same page. Is this not supported by Symphony?

This is what my code looks like:

<a>
   <xsl:attribute name="href">
     <xsl:value-of select="concat($current-url, '#image', @id)"/>
   </xsl:attribute>
   <img src="{$workspace}/images/image.jpg" />
</a>

The link in the output looks good:

 <a href="http://localhost:8888/project/foo-project#image1">
     <img src="http://localhost:8888/workspace/images/image.jpg"/>
 </a>

However, when I click on it the #image1 bit is not appended to the URL!

Can anybody tell me what I'm missing here?

P.S.: The URL parameters I set in my page settings are: category/entry

Thanks for any help.

Hi @tintin81, try changing:

<xsl:value-of select="concat($current-url, '#image', @id)"/>

to:

<xsl:value-of select="concat($current-url, '/#image', @id)"/>

see if that helps.

Alternatively, if you are using anchor element to navigate on the exisitng page I usually do the following:

<a href="#image{@id}">anchor text</a>

Is there a reason for using the complete URL for that anchor link? You could simply just take the anchor-id-part ( href="#image1" ) as long as you're staying within the same page.

If you want to use the full link you could try to add an additional '/' before your anchor. As far as I can remember that once did the trick for me.

or simply follow the much faster advice from dave ;)

Thanks for your help but it's not getting any better.

Roman's suggestion is what I started out with:

<a href="#image{@id}">anchor text</a>

The problem remains that when I click on the link I get:

http://localhost:8888/project/foo-project/#image1

rather than

http://localhost:8888/project/foo-project#image1

(The difference being just one forward slash here.)

Dave's suggestion doesn't work either :-(

@Tintin81, can you explain a bit more of the context as to why you don't want the forward slash at the end of the last url parameter?

If you are using the anchor link to navigate to a different part of the page it should work just fine with the slash in there.

I believe the slash is introduced by a rule in the .htaccess file which adds a trailing slash to urls e.g if you point your browser to:

http://localhost:8888/project/foo-project

it wil redirect to:

http://localhost:8888/project/foo-project/

Ah yes, I get the idea now.

Sorry, you're absolutely right. It doesn't matter if there's a trailing slash between the last segment of the URL and the anchor. I figured that out myself in the meantime.

I am trying to get a css image viewer to work here and I thought they require the anchors without any trailing slashes. But it turns out it works both ways!

So these two do exactly the same thing:

http://localhost:8888/project/foo-project/#image1

http://localhost:8888/project/foo-project#image1

So thanks again for pointing me in the right direction.

Let's hope this thread will help some other clueless fella in the future.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details