Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-09-16 11:02:06

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Case-sensitivity categories

After pulling my hair out a several times why my beautiful forms weren’t working, I discovered that the handling of names of categories is inconsistent. An example:

<txp:if_category name="Text">bla bla bla</txp:if_category>

doesn’t output the bla bla bla, although I named the category ‘Text’ (pay attention to the capital T).

The following does work, even though I used a capital T under the Categories-tab.

<txp:if_category name="text">bla bla bla</txp:if_category>

Is this a bug?


Prrrrrrrr

Offline

#2 2009-09-16 11:13:53

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Case-sensitivity categories

This dempends on two things.

  • Is your db cs(case sensitive)?
  • Category title might be in capitals (this appears on the front end), category name is normally lower case (this appears in the url)

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2009-09-16 11:30:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Case-sensitivity categories

TNT wrote:

the handling of names of categories is inconsistent

It’s not a bug. Category names are generated from whatever you type at creation time. As colak says, since they are used in URLs, the names have to be sanitized for correct web URL usage. Thus spaces become hyphens, ‘odd’ characters like apostrophes and accents are ignored and whatever you type is converted to lower case (for consistencies sake).

So now it is actually very consistent, it’s just not consistent with what you typed! Check the Categories tab and click one of your cats to see the name that you should use in all relevant tags.

Textbook is, however, a little nebulous on this matter so I’m just going through and making it more explicit.

Last edited by Bloke (2009-09-16 11:32:01)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#4 2009-09-16 12:00:43

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Case-sensitivity categories

I think it’s relatively easy to make the categories and sections in URLs case sensitive. If the URL is treated case sensitive, then you’ll never have 2 different URLs (differing in case only) that point to the same page.

The way we store the categories/section in MySQL, it is treated as a case-insensitive string when doing a query, but if you fetch the actual category/section from the database, you do see how it was originally entered and can compare it to what’s in the URL… and decide to reject it because the case differs.

[note that if url handling was case sensitive, that doesn’t necessarily mean it’s possible to have two categories “Test” and “test” as completely separate categories.]

Offline

#5 2009-09-16 13:00:46

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: Case-sensitivity categories

OK, I understand. But I’m wondering why the conversion to lower case is also done inside forms. That’s what was causing me headaches (and bold spots on my head… ;-)


Prrrrrrrr

Offline

#6 2009-09-16 13:28:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: Case-sensitivity categories

Hi Arjan,

If by forms you mean tha category tag, it is because it requires the name not the title of the category


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2009-09-16 13:47:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
Website GitHub

Re: Case-sensitivity categories

I’ve updated all the textbook tags that use category to explicitly mention the fact they need to be lower case names not titles that you may have typed. I’ve also updated the Admin Side -> Categories page to mention the fact that the Title you type is converted to lower case to create the category name when you hit the Create button.

As colak implies, the conversion to lower case is done at category create time. From that point on you always refer to the category using its name, not Title in TXP tags. Umm, I hope!

(go to the Categories tab and add an Article Category called Mr O'Flannery; note that TXP reports Article category mr-oflannery created.)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB