Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Anchor tag attribute for TXP tags - I'm not missing anything am I?
I love DRY implementations in all good places where DRY is appropriate.
Am I missing something—I sometimes accept there’s no way to state a target ID/anchor in a link and so use the nice DRY:
<txp:section name="news" title="0" link="1">breaking news, in our news section</txp:section>
…when I really want to use:
<txp:section name="news" title="0" link="1" target="breaking">breaking news, in our news section</txp:section>
… target="breaking"
being the new bit.
Other times I accept I’ll loose the DRY and go back to:
<a href="/news-items#breaking">breaking news, in our news section</a>
I assume that this is simply a case of TXP being brilliant (it is) but not 100%, only 99.N% and that adding a target="xyz"
attribute to TXP tags that form links is something that falls in the last 1%?
I’m guessing I’m not the first to ask this, but couldn’t see a ref’ to it anywhere else, so I thought I’d show my probable ignorance and ask the question—can this be done now or is it something that might make a later ver of TXP?
Thanks again all TXPers for this superb product.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Txp doesn’t do target
. Not surprising, given that target
, like frames, is deprecated. So I wouldn’t expect it in a future version.
It would be trivially easy to make a customized version of section
as a plugin.
But given that all you are getting from section
is the URL, it would be even easier to write this in straight HTML.
Code is topiary
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Tks Jeff.
oUCH!
>_<
…I didn’t realise target
was deprecated.
But worse than that, I probably used the wrong name, when I typed target
I was thinking about anchor tags — sorry, my bad.
So my ‘new attribute’ should have been anchor="xyz"
.
But given that all you are getting from section is the URL, it would be even easier to write this in straight HTML.
Yes, probably. My love for DRY has lead me to using stuff like the section
tag so that, in case the location of the section changes, my code will remain correct — I’ve just realised that this example is invalid as in this case the name of the section would change and the code would need maintaining anyway…
But there is still value for some other link tags, isn’t there, in something that allows an anchor to be specified? Or am I missing something else — which would not surprise me.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
OK, I’m not sure I’m following you. I think you want this:
<a href="<txp:section url="1" name="news" />#breaking">breaking news</a>
Just noticed that url
is not included in section
’s TextBook listing. I’ll correct it.
Code is topiary
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Yes! That is what I was looking for — I was actually thinking the anchor could be an attribute of the TXP tag, but that might be too weak a reason for adding an attribute, no worries, the code you noted will do what I want if I’m guessing correctly what url="1"
does.
Before, when I tired that without the url
attribute I was getting a <a><a></a></a>
situations, I’m guessing that lovely looking url="1"
will cure that! Thanks!
Just noticed that url is not included in section’s TextBook listing. I’ll correct it.
I have that site as a ‘book’ in Coda and refer to it often — thanks for updating it (that’ll save my feeble memory).
I’m glad I asked the wrong question to find the right answer courtesy your kind posts — thanks again.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Glad to be of help — you didn’t ask the wrong question, I just didn’t parse it correctly. Got misled by target
.
IMO your request for a new attribute is not unreasonable, but a little specialized for a core feature. Check out wet_link.
Code is topiary
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
My target
ting was bad in my initial question ;)
Tks re wet_link — yes, I love it — I’ve not used it for section
links, I’ll go look back and look at it’s attributes.
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
After a closer look I don’t think wet_link
will do this for you either. (Got confused by its linkid
and target
attributes, but neither does what you want.) Again, trivial to make your own plugin for this, by forking either section
or wet_link
.
Code is topiary
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Ok, thanks Jeff — if I ever try to write a plugin, I’ll start with that one. For now, the url=1
is a great solution.
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#10 2010-07-13 21:35:54
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Would adi_link help at all?
Offline
Re: Anchor tag attribute for TXP tags - I'm not missing anything am I?
Hey Adi — YES! Thanks, I missed that option, I see it support anchor
links — brilliant.
Thanks!
Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline