cms_selflink return href

Talk about new features for CMSMS and modules.
Locked
philonor
New Member
New Member
Posts: 7
Joined: Mon Oct 22, 2012 7:37 am

cms_selflink return href

Post by philonor »

The cms_selflink tag offers the argument
href
to only return the href-value itself.

Unfortunately, this works only when specifying an page alias or id like:

Code: Select all

{cms_selflink href='page-xyz'}
I'd like to have always an option to only return the href value:

Code: Select all

{cms_selflink alias='page-xyz' returnhref='1'}
{cms_selflink dir='next' returnhref='1'}
I'm in need of such a functionality, cause I always create image-links like that:

Code: Select all

<a class="next" href="{cms_selflink dir='next' returnhref='1'}">
<span>NEXT</span></a>
With the CSS class .next, I define a background-image.

Code: Select all

.next {display: block; width: 16px; height: 16px; background: url(next.jpg);}
.next span {display: none;}
For SEO, I'd like to have a text within the <a>-Tag. With cms_selflink as it is today, I can't do this, can I?

I would try to implement this myself. How can I contribute to core tags?
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: cms_selflink return href

Post by Wishbone »

You can do something like:

{cms_selflink dir=next text=Next class=next}

This will produce a link pointing to the next page with the class 'next' with the text Next.

You will have to adjust your CSS because you don't have the <span> .. I tried adding the span to the text=, but it is escaped. In your CSS, you can use "text-indent: -9999px" to hide the text, but only works if you set the display to block or inline-block.

I just tested this out, and it seems to work just fine.
philonor
New Member
New Member
Posts: 7
Joined: Mon Oct 22, 2012 7:37 am

Re: cms_selflink return href

Post by philonor »

Thanks for your reply!

This works fine, yes. But since "text-ident: -9999px" forces the browser to render a 9999px box, I prefer using a span inside.

I think a "href only" option would be a good option for several purposes. What if the produced markup does not meet the requirements somebody has?

Since the href-value needs to be generated in any case, it can't be that much work to create a "href only" option, can it?
philonor
New Member
New Member
Posts: 7
Joined: Mon Oct 22, 2012 7:37 am

Re: cms_selflink return href

Post by philonor »

I tried to alter the cms_selflink function:
See the feature request.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: cms_selflink return href

Post by Dr.CSS »

Have you tried using <span> in the text= ..?
Wishbone
Power Poster
Power Poster
Posts: 1369
Joined: Tue Dec 23, 2008 8:39 pm

Re: cms_selflink return href

Post by Wishbone »

cms_selflink escapes everything... > ends up as &gt;
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: cms_selflink return href

Post by rotezecke »

i've been using this since version 1.9

Code: Select all

{cms_selflink id='side_mail' page='contact-us' text='<span>Contact us by email</span>' title='Contact us by email'}
with no problems. i'm currently using 1.11.4. i briefly tested 1.11.5 and i think this still worked (had to revert to 1.11.4 for other reasons).

maybe it's the single quotes vs double quotes that allows <span> to be parsed.
Locked

Return to “Feature ideas”