Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-03-27 19:58:49

unipus
Member
Registered: 2004-03-10
Posts: 18

Linking to common custom tag

I’m putting together a site that will basically show a lot of movies. Call it a mini-YouTube if that makes it easier. So there will be a bunch of movies created by different people (not a huge number: about 50 right now, maybe 100-200 someday), but all of the actual pages on the site will of course be created by an internal editor or admin. However, I want to give credit to the creators of course and provide an easy way to see all of the movies created by those people.

So if I’ve got a link that looks like this:

Fake Link to Movie by Exciting Team of Filmmakers

how do I set up that second link? I created a Custom Tag called CreatedBy that successfully pulls that info from the pages into the link… but how do I generate the link itself so that it takes me to a page all about “Exciting Team of Filmmakers”. I gather I could do it with keywords, but that means entering the same data both in my CreatedBy field and as a keyword, which feels wrong.

Sorry if I’m not being too clear about this, my head’s in a thousand different places at once and I’m fairly new to TXP.

Offline

#2 2007-03-28 01:13:06

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

Hmm, anyone at all?

Offline

#3 2007-03-28 15:45:28

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Linking to common custom tag

I’m not sure, but maybe you could do something with chs_if_urlvar? (Don’t ask me how, because I don’t use it myself.)

Offline

#4 2007-03-28 16:54:33

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

Hmm. Alternately, is there a way to check for the presence of a keyword when displaying the article?

Offline

#5 2007-03-28 18:17:38

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Linking to common custom tag

Not that I know of, but there is one for custom fields: txp:if_custom_field

I’m still not sure what you want to do exactly, e.g. where do you want the Exiting Team of Filmmakers link to lead to? A specific article about this team, or a list of all movies by this team?

Offline

#6 2007-03-28 22:48:17

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

Either, really. The first would be preferable, but the second would also be acceptable. I can certainly see how it would be easier (although I still don’t know how to do it!)

Offline

#7 2007-03-29 16:22:37

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Linking to common custom tag

Okay, now I understand. The first is actually easier to accomplish :)

Install and activate the asy_wondertag plugin.
Create another custom field named CreatorArticleID (or whatever).
So, you have a movie (which is an article I suppose), and in the CreatedBy custom field of that article you enter the name of the movie’s creator. You already have created an article about the creator as well, and you know it’s article ID. Enter the article ID in custom field CreatorArticleID. Now you can create the link to the article about the creator in your article form like this:

<txp:asy_wondertag><txp:permlink id="<txp:custom_field name="CreatorArticleID" />"><txp:custom_field name="CreatedBy" /></txp:permlink></txp:asy_wondertag>

This only has the slight inconvenience that you’ll have to look up the ID of the article about the creator before you create the movie article.

Offline

#8 2007-03-29 18:51:07

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

Great, that’s no problem. BUT… would it be possible to have that ID pull the CreatedBy data itself, so all I have to enter is the CreatorArticleID and it will pull the name of that creator (it could, and likely would, be the name of the article anyway) automagically?

Offline

#9 2007-03-29 21:55:32

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Linking to common custom tag

Try this instead of my code example above:

<txp:asy_wondertag><txp:permlink id="<txp:custom_field name="CreatorArticleID" />"><txp:article_custom id="<txp:custom_field name="CreatorArticleID" />" form="creator_name" /></txp:permlink></txp:asy_wondertag>

Article form ‘creator_name’:

<txp:title />

Offline

#10 2007-03-29 23:11:32

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

All right, I’ll give that a try a bit later. Thanks, you’ve been a huge help!

Offline

#11 2007-03-30 06:42:07

unipus
Member
Registered: 2004-03-10
Posts: 18

Re: Linking to common custom tag

Well, I finally got to messing with it an unfortunately it breaks down in your second example:

tag_error <txp:article_custom id="<txp:custom_field name="CreatorArticleID" /> -> Textpattern Notice: Unknown tag attribute: name on line 582

It’s able to pull the ID easily enough, but it’s not able to take that ID and return the title. I created and populated the CreatorArticleID for the item in question, as well as a titled article for it to refer to.

Offline

#12 2007-03-30 13:28:03

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Linking to common custom tag

Can you post the exact code you are using? At first sight I don’t see what could be wrong.

Offline

Board footer

Powered by FluxBB