Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-11 00:04:30

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

how do I display one link from a link id entered in custom field?

I am trying to put an individual link into each article on an artists group site.
I would like to have the link id entered in a custom field.
I don’t think there is a need for a link list as each link is alone in it’s own article – maybe I’m wrong. I just need to display one link with an article along with all the other attributes based on only on an id.
So I can create my links form and the custom field but am not sure how to pull in the right link based on the id from the custom field.

Thanks

Last edited by kvnmcwebn (2009-12-11 01:16:38)


its a bad hen that wont scratch itself.
photogallery

Offline

#2 2009-12-11 01:21:23

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: how do I display one link from a link id entered in custom field?

I use one of my plugins: adi_link

For example, in an article form:

<txp:adi_link id='<txp:custom_field name="article link"/>' />

Offline

#3 2009-12-11 01:53:55

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: how do I display one link from a link id entered in custom field?

Thanks Adi. Works perfectly.


its a bad hen that wont scratch itself.
photogallery

Offline

#4 2009-12-11 01:59:30

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: how do I display one link from a link id entered in custom field?

Hi Adi,
Couple Questions, is there a way i could put a target=“blank” in there?
no problem if not.

Also is there a way I could get rid of the no Url that displays on articles without an id in the custom field?

-thanks again

Last edited by kvnmcwebn (2009-12-11 02:16:48)


its a bad hen that wont scratch itself.
photogallery

Offline

#5 2009-12-11 02:40:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: how do I display one link from a link id entered in custom field?

kvnmcwebn wrote:

Couple Questions, is there a way i could put a target=“blank” in there?

Not at the moment. I assume you mean target="_blank"? Because this doesn’t work in XHTML I never implemented it – the equivalent functionality here to use a bit of Javascript. Let me know if it’s HTML you’re using & I’ll see what I can do.

Also is there a way I could get rid of the no Url that displays on articles without an id in the custom field?

Funny you should ask that one – not more than 4 days ago I had a requirement for just such a thing. I haven’t offically released an update to adi_link yet but you can download version 0.3beta & use attribute quiet="1" to suppress the “no URL” message. There’re some wraptag attributes in there as well, which come in handy in this scenario.

Offline

#6 2009-12-11 20:41:25

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: how do I display one link from a link id entered in custom field?

Thanks Adi, Now that you mention it populating links in new windows is probably to old fashioned to do these days. Regarding hiding the no url message I ended up using css to make it the same color as the background. But I’m going to try the quiet attribute on another site that I’m working on today as well. I’ll let you know how i get on with it. Thanks a million.
-kevin


its a bad hen that wont scratch itself.
photogallery

Offline

#7 2009-12-11 21:16:34

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: how do I display one link from a link id entered in custom field?

kvnmcwebn wrote:

Thanks Adi, Now that you mention it populating links in new windows is probably to old fashioned to do these days.

But if you still want to do it, you can do it with couple lines of JavaScript. Instructions are mentioned in the adi_link’s docs (ext_link="1" to the tag) and couple lines of JS.

With jQuery library syntax managing the code is real easy:

$('a[rel="external"]').each(function() {
	$(this).attr('target', '_blank');
});

If you don’t use jQuery, Sitepoints tut is as easy.

Offline

#8 2009-12-12 02:36:08

kvnmcwebn
Member
From: Ireland
Registered: 2007-01-27
Posts: 724
Website

Re: how do I display one link from a link id entered in custom field?

Right then I will do that as I am using jquery in that site anyway.
Cheers GoCom.


its a bad hen that wont scratch itself.
photogallery

Offline

#9 2009-12-13 13:18:02

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: how do I display one link from a link id entered in custom field?

Gocom wrote:

Sitepoints tut is as easy.

wierd, but not working in my site

Offline

#10 2009-12-13 20:29:20

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: how do I display one link from a link id entered in custom field?

Gallex wrote:

wierd, but not working in my site

Weird, indeed as you didn’t read the instructions. The script applies to links with rel="external". You have no external links on your pages.

If you want it to change all of your links, remove the anchor.getAttribute("rel") conditional from the code.

Offline

#11 2009-12-14 09:04:34

Gallex
Member
Registered: 2006-10-08
Posts: 1,315

Re: how do I display one link from a link id entered in custom field?

Gocom wrote:

Weird, indeed as you didn’t read the instructions. The script applies to links with rel="external". You have no external links on your pages.

how so? but they all link to another domain. or are you saying they all lack the attribute rel="external", that’s why?

If you want it to change all of your links, remove the anchor.getAttribute("rel") conditional from the code.

removed. didn’t help.

Offline

#12 2009-12-14 11:16:20

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: how do I display one link from a link id entered in custom field?

Gallex wrote:

how so? but they all link to another domain. or are you saying they all lack the attribute rel="external", that’s why?

The script just adds target="_blank" to links with rel="external". And if haven’t added rel="external" to your links, it does nothing.

removed. didn’t help.

The thing that you did, aka below, ain’t going to work:

if (anchor.getAttribute("href") &&   
         anchor.target = "_blank";

Remove the ands (&&) and close ()) the conditional.

Offline

Board footer

Powered by FluxBB