Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-11-24 04:24:21

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

custom_fields case sensitive?

Is it still necessary to use lowercase Custom Field names?

I have used Title case and all seems good – just wondering if there is a reason still?

Offline

#2 2010-11-24 08:06:47

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

Re: custom_fields case sensitive?

From Textbook:

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

The ‘don’t use uppercase’ rule is for section and category names, as far as I know.

Offline

#3 2010-11-24 11:06:29

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: custom_fields case sensitive?

Ah – should have looked harder at that :)

In the TXP FAQ it does mention “It’s a good idea to use a name that is lowercase and contains no spaces.”

Kind of confusing – even though its only a suggestion

Offline

#4 2010-11-24 11:40:06

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

Re: custom_fields case sensitive?

Stick to lower case if possible.

Offline

#5 2010-11-24 12:01:46

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

Re: custom_fields case sensitive?

tye wrote:

Is it still necessary to use lowercase Custom Field names?

ruud wrote:

Stick to lower case if possible.

Hi,
if you need to show custom fields with spaces and upper case in the “write” tab I wrote a minimal plugin for this

Offline

#6 2010-11-24 12:51:13

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

Re: custom_fields case sensitive?

redbot wrote:

if you need to show custom fields with spaces and upper case in the “write” tab I wrote a minimal plugin

That’s great redbot, poifick. As an alternative if you DON’T use glz_cf you can do it the non-javascript way with this fragment of code:

if( @txpinterface == 'admin' ) {
   register_callback('smd_retitle', 'article_ui', 'custom_fields');
}

global $smd_titles;

// EDIT THESE TO TASTE OR ADD OTHERS
$smd_titles["custom-1"] = "First CF title";
$smd_titles["custom-4"] = "Another title with a "quoted" word";
// END EDITING HERE

function smd_retitle($evt, $stp, $data, $rs) {
   global $smd_titles;
   foreach ($smd_titles as $key => $val) {
      $pat = '/\<label for\=\"'.$key.'"\>.*\<\/label\>/';
      $rep = '<label for="'.$key.'">'.$val.'</label>';
      $data = preg_replace($pat, $rep, $data);
   }
   return $data;
}

For reasons best known to Gerhard (or maybe I’ve overlooked something as it was a quick hack), the code above duplicates the list of custom fields if glz_custom_fields is enabled. I think this is to do with the fact that Gerhard is injecting the extra fields into the markup directly instead of using pluggable_ui() (at least in version 1.2.4 which I have). But if you’re using the built-in vanilla 10 CFs then the above code is another way of doing it.

The code is presented raw so you’ll have to pluginise it yourself and set up your CF replacements just as you do in redbot’s plugin, as I have no intention of supporting it in this state :-)

All this stuff should keep you ticking over until we can improve CFs in later TXP versions to remove this odd policy of not allowing you to have a separate name and title.


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

#7 2010-11-24 17:52:56

hcgtv
Archived Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: custom_fields case sensitive?

tye wrote:

I have used Title case and all seems good – just wondering if there is a reason still?

I use custom fields with the first letter being uppercase and all seems fine.

Wonder what the reason is to keep all the letters lowercase?

Offline

#8 2010-11-24 18:19:16

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

Re: custom_fields case sensitive?

hcgtv wrote:

Wonder what the reason is to keep all the letters lowercase?

Nothing much really. If it works for you then it all good. There is just that the queries can be in- or -case-sensitive and TXP uses locale based lowercasing, instead of multibyte safe functions. But it doesn’t really cause anything.

Btw, why does TXP lowercase custom fields? Was there a specific reason back then?

Offline

#9 2010-11-26 04:47:45

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: custom_fields case sensitive?

Great plugin redbot :) I seem to be using lots of yours lately :)

Good news CF’s are on the core developers radar – I’m starting to use them more and more

Offline

Board footer

Powered by FluxBB