Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-02-02 11:56:49

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Hyphens allowed in custom field names?

The documentation states…

“Custom names may include letters (uppercase or lowercase), numbers and under_scores, but no spaces or other special characters.”

Sounds like hyphens should be OK to use, too?!

Last edited by masa (2008-02-02 11:57:19)

Offline

#2 2008-02-02 17:21:26

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

Re: Hyphens allowed in custom field names?

i use hyphens since day one and I’m yet to hit a wall with them


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 2008-02-02 17:29:12

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Hyphens allowed in custom field names?

Thanks Yiannis!

Offline

#4 2011-07-14 12:47:51

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Hyphens allowed in custom field names?

On that note, I’m using custom field names with spaces (quite by accident) and they are working just fine in 4.4.1. Is this a glitch or should the documentation be changed to reflect the more flexible nature?

Offline

#5 2011-07-14 12:52:39

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

Re: Hyphens allowed in custom field names?

Knowing that custom field names are used as column names in a database, makes me think it’s not really a good idea to use spaces.

Offline

#6 2011-07-14 13:06:23

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: Hyphens allowed in custom field names?

ruud wrote:

Knowing that custom field names are used as column names in a database, makes me think it’s not really a good idea to use spaces.

Yes Ruud is absolutely right, consider also that using spaces raises an issue with the “article_custom” tag because it prevents you from using:

<txp:article_custom customfieldname="value" /> 

P.S.
As far as the admin side is concerned that’s why I wrote a plugin for this a long time ago. I think it needs an update though and I have no time now :(

Offline

#7 2011-07-14 18:44:36

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Hyphens allowed in custom field names?

Thanks, guys.

Because it is possible, but not a good idea, I think the docs still need some clarification on the issue. Though admittedly, redbot, I don’t understand what you mean by the article_custom example.

Your plugin looks useful, however, because it’s a basic app design no-no to allow code syntax to appear to the user (headers, form labels, whatever). I think IBM wrote something about this in their app guidelines in the early 90s.

I’m assuming it’s a stickler to fix in Txp or it would be by now, but it’s too bad a plugin is needed for something at this level.

Offline

#8 2011-07-14 19:02:15

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

Re: Hyphens allowed in custom field names?

Destry wrote:

Though admittedly, redbot, I don’t understand what you mean by the article_custom example.

Custom fields can be used as attributes in article_custom tag to select specific articles with specific custom field value. Only A-z0-9_- can be used in attribute name, which means that only those character can be used in the custom field’s name if you fancy using the custom field as an attribute. This means no spaces.

As far as I see, the docs are fine. The instructions are valid and required to everything to work properly. If someone uses different characters set of core features won’t work.

ruud wrote:

Knowing that custom field names are used as column names in a database

Did you really mean column names? I bet there is a typo. The ID numbers are used as the column names. The names user can define are only stored in preferences table and are used later on to populate article data.

Offline

#9 2011-07-14 19:17:38

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: Hyphens allowed in custom field names?

Gocom wrote:

As far as I see, the docs are fine. The instructions are valid and required to everything to work properly. If someone uses different characters set of core features won’t work.

I wouldn’t say they are fine, or I would never have had to dig up this thread and ask the question. :)

They say you can’t use spaces. While that may not be advisable (or encouraged), you can actually use them (as I’ve discovered by accident). So I’d say the docs do need a modification to say something to the affect that even if using spaces seems functional, you should not do it for xyz reason. That would have been enough for me, and saved me some trouble.

Offline

#10 2011-07-14 20:51:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Hyphens allowed in custom field names?

Destry wrote:

So I’d say the docs do need a modification

I’d say TXP itself needs the modification as leaving blanks in cf names on saving is really error prone and isn’t even consistent behavior: see sections and categories.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2011-07-14 21:57:38

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

Re: Hyphens allowed in custom field names?

^^ right. TXP could easily enforce it’s policy on what’s acceptable for a custom field name.

PS. Gocom, you’re right about the database columns. It’s because of the attribute names that custom field names cannot contain spaces.

Offline

#12 2011-07-14 22:16:04

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

Re: Hyphens allowed in custom field names?

ruud wrote:

^^ right. TXP could easily enforce it’s policy on what’s acceptable for a custom field name.

Only problem are current installations. If we were to change that, current sites using spaces and what not would have to change their code.

PS. Gocom, you’re right about the database columns. It’s because of the attribute names that custom field names cannot contain spaces.

As RedBot and I already said. ;-) /me takes a sip Kool-Aid.

Offline

Board footer

Powered by FluxBB