Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-12-23 18:21:38

jstur8jv
Member
Registered: 2006-12-23
Posts: 23

How do I return a category's name instead of its title?

I’d like to use the txp:category tag to return a category’s name instead of its title (i.e., with spaces instead of dashes).

However, whenever I use just the category tag, such as follows:

<txp:category />

The title is what is returned (for example, category “photo album 1” is displayed as “photo-album-1”)

If I use <txp:category title=“1” />, nothing at all is displayed. That doesn’t seem right, and is not what the documentation (http://textbook.textpattern.net/wiki/index.php?title=Txp:category_/) led me to believe would happen.

Any thoughts?

Offline

#2 2006-12-23 19:13:52

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: How do I return a category's name instead of its title?

The name would have the hyphens, whereas the title would not. So what you want is <txp:category title="1" />, which would display the title. Do you have <txp:category /> in an article form?

Offline

#3 2006-12-23 21:25:38

jstur8jv
Member
Registered: 2006-12-23
Posts: 23

Re: How do I return a category's name instead of its title?

You’re right, my terminology was backwards in my post. Apologies.

I don’t think <txp:category /> is in an article form. I have it as part of the page displayed when viewing an image category.

Whenever I insert title=“1”, the text doesn’t come up at all—that is, there’s nothing in the source, nothing on the screen-the tag doesn’t output anything.

Should I put it into a form and call the form?

I just did my first line of php earlier today, so I don’t really think I’m up to figuring out a way to pull the category from the url and then changing the dashes to spaces =)

Any textpattern magic to address this would be greatly appreciated. I have a sinking feeling that it may be choking because I’m not using it in an article, per-say, which is the whole point of what I’m trying to do.

Last edited by jstur8jv (2006-12-24 04:26:51)

Offline

#4 2006-12-23 23:01:38

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

Re: How do I return a category's name instead of its title?

<txp:category type="image" title="1" />

Offline

#5 2006-12-24 00:20:59

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I return a category's name instead of its title?

You need to check your category, and make sure it’s name is all lowercase, and that you have entered something for its title.

Offline

#6 2006-12-24 03:43:41

jstur8jv
Member
Registered: 2006-12-23
Posts: 23

Re: How do I return a category's name instead of its title?

type=“image” fixed it!

Thanks so much. I never singled that one out as being important. Perhaps someone could mention its effects in the wikki?

Anyway, it works beautifully now.

Offline

#7 2006-12-24 06:37:26

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: How do I return a category's name instead of its title?

Offline

#8 2006-12-24 07:15:35

jstur8jv
Member
Registered: 2006-12-23
Posts: 23

Re: How do I return a category's name instead of its title?

From the Wikki: “type=“category type” Available values: article, image, link, file. Default is article.”

The wikki totally mentions the parameter “type,” but I totally didn’t grok that defining the category type would have any effect on the tag’s ability to print the title. Particularly since even though it was the wrong category type by default, it was still able to print the name.

If the tag had broken completely regardless of the title declaration, I probably would have realized the category type needed to be declared. As it was, it returned the name with no title being declared; with title=1, it returned nothing; with title=0, it returned the name.

A note in the wikki about the importance of assigning the correct category to the tag might be helpful for someone like myself, who gets half-a-result that misleads them. But that’s just a suggestion, and it’s far more important to me that the forums have been helpful and quick to respond when I haven’t been able to muddle through the documentation on my own. Thanks again.

Offline

Board footer

Powered by FluxBB