Difference between "label" and "title"

2,499 views
Skip to first unread message

Michael Sharman

unread,
Jan 19, 2011, 10:41:13 PM1/19/11
to farcry-dev
Are there differences between these 2 properties as they seem to
always be the same (in dmNavigation, dmHTML etc).

I wonder if one should be deprecated for future releases?

Jeff Coughlin

unread,
Jan 19, 2011, 10:56:18 PM1/19/11
to farcr...@googlegroups.com
The label's suggested use is for webtop display while title is generally used for a generic title (it's more of a best practice).  It doesn't often become apparent until you start customizing the label when using something like afterSave().

Example:  Say you have a product.  Its title is called "Latex Gloves".  However, you have 15 different types of latex gloves in your inventory.  Sure, you'd have some other identifier field to help differentiate them apart (say a category field), and maybe for this particular item the category is "Powder FRee", but when displayed on the site you only want the title for each item to say "Latex Gloves".  However sorting and finding the item easily in the webtop now becomes a multi-step process.  A simple solution is to have afterSave() overwrite the label to be "Latex Gloves - Powder Free" or "Latex Gloves - ABC123" (where ABC123 is the product ID).  Now when you use the array picker or object admin listing page, you can find, sort, and filter easier (depending on your needs).

That is just one example, but I use it often.

Another example is concatenating names.  If you have, say, a title field for a person and his title is "Professor", his first name is John, last name field is Doe, and his title prefix field is "Dr.", you can use afterSave() to set the label field to say "Dr. John Doe, Professor".

Hope that helps,

--
Jeff Coughlin
Web Application Developer

--
You received this message cos you are subscribed to "farcry-dev" Google group.
To post, email: farcr...@googlegroups.com
To unsubscribe, email: farcry-dev+...@googlegroups.com
For more options: http://groups.google.com/group/farcry-dev
--------------------------------
Follow us on Twitter: http://twitter.com/farcry

Geoffrey Bowers

unread,
Jan 24, 2011, 2:34:02 AM1/24/11
to farcr...@googlegroups.com

label is a property that belongs to the types abstract class. Its basic purpose is a human readable name for an object instance, as opposed to just having an objectid (UUID)

It's purely coincidental that dmnavigation, dmhtml, dmnews, etc have a "title" which is essentially the same. As far as the framework is concerned it needs something it can guarantee is always there for any object type -- hence label in types. The CMS content types could have used label instead of having their own property of "title". However, we generally try and leave label for administrative purposes only, as its not uncommon for the internal human readable label of an instance to differ considerably from the way it might be presented on the website.

So for an "out of the box" vanilla FarCry CMS based site there's little difference but in many custom apps the distinction is entirely appropriate.

-- geoff
http://www.daemon.com.au/
skype. gb.daemon

Geoffrey Bowers

unread,
Jan 24, 2011, 2:37:42 AM1/24/11
to farcr...@googlegroups.com

On 20/01/2011, at 2:56 PM, Jeff Coughlin wrote:
> Example: Say you have a product. Its title is called "Latex Gloves". However, you have 15 different types of latex gloves in your inventory. Sure, you'd have some other identifier field to help differentiate them apart (say a category field), and maybe for this particular item the category is "Powder FRee", but when displayed on the site you only want the title for each item to say "Latex Gloves". However sorting and finding the item easily in the webtop now becomes a multi-step process. A simple solution is to have afterSave() overwrite the label to be "Latex Gloves - Powder Free" or "Latex Gloves - ABC123" (where ABC123 is the product ID). Now when you use the array picker or object admin listing page, you can find, sort, and filter easier (depending on your needs).

I'd add that you can also change the behaviour of the label creation by using the blabel="true" attribute within any CFPROPERTY tag to have the value concatenated into the label.

From memory, the framework looks for blabel, and failing that concatenates property names containing the keywords title and name. In the absence of any title/name properties you get the objectid or (incomplete).

For complete control you can always modify the before/afterSave functions.

Reply all
Reply to author
Forward
0 new messages