[support] Solved: Re: node titles - move "the", numbers to the end

Benjamin Jacob ben4asterisk at yahoo.com
Tue Aug 17 15:36:28 UTC 2010


I built upon the suggestion given by Domenic below.

I added a CCK text field called My Title in my node type.
Setup Automatic File generation using Automatic Node titles module. Selected "Automatically generate the title (default node element) and hide the title field" and setup PHP (selected "Evaluate PHP in pattern.") code for the auto generation of the title using My Title's value entered by the user.

<?php 
$customTitle="[field_my_title-raw]";
$customTitle=trim(preg_replace("/\s\s+/"," ",$customTitle));
$customTitle=preg_replace("/^(the|a|an)\b\ (.*)/i","$2, $1",$customTitle);
print "$customTitle";
?>

cheers
- Ben

--- On Mon, 8/2/10, Benjamin Jacob <ben4asterisk at yahoo.com> wrote:

> From: Benjamin Jacob <ben4asterisk at yahoo.com>
> Subject: Re: [support] node titles - move "the", numbers to the end
> To: support at drupal.org
> Date: Monday, August 2, 2010, 4:11 PM
> 
> :-)
> 
> I get the picture. I agree... somewhat.
> Thanks. This definitely does help.
> 
> - Ben
> 
> --- On Mon, 8/2/10, Domenic Santangelo <domenics at gmail.com>
> wrote:
> 
> > From: Domenic Santangelo <domenics at gmail.com>
> > Subject: Re: [support] node titles - move "the",
> numbers to the end
> > To: support at drupal.org
> > Date: Monday, August 2, 2010, 3:51 PM
> > On Aug 2, 2010, at 8:23 AM, Benjamin
> > Jacob wrote:
> > 
> > > This is pretty common in different listings, e.g.
> book
> > listing, video/movie listing, etc.
> > > e.g. The Final Frontier = Final Frontier, The
> > > 24 Chowringee Lane = Chowringee lane, 24
> > > etc.
> > 
> > The common pattern is to move articles (A/An/The) to
> the
> > end, and to decide what to do with numbers separately
> --
> > some places just have a "#" section, others
> alphabetize the
> > title as if the number were spelled out (twenty-four).
> In
> > your example, "24" is a useful part of the title and
> not
> > just a formality required by the syntax of the
> language; I
> > wouldn't move those numbers to the end. Also, what
> about
> > movies that spell out their numbers? Would you list
> them as,
> > for example, "Element, The Fifth"? "Days Seven Nights,
> Six"?
> > You're getting into some complicated territory here
> :)
> > 
> > As far as doing what you want to do, I think auto
> nodetitle
> > will work fine. It has the option to generate the
> title with
> > custom php if you want; that should be more than
> enough.
> > 
> > HTH,
> > -D
> > -- 
> > [ Drupal support list | http://lists.drupal.org/ ]
> > 
> 
> 
>       
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]
> 


      


More information about the support mailing list