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

Sven Decabooter sdecabooter at gmail.com
Mon Aug 2 15:39:53 UTC 2010


If you want to use this within the context of a Views listing, you should
have a look at the Views Natural Sort module (
http://drupal.org/project/views_natural_sort). That module might be able to
help you out of the box.
This won't change the node title on the detail page though...

Sven


On Mon, Aug 2, 2010 at 5:23 PM, Benjamin Jacob <ben4asterisk at yahoo.com>wrote:

>
> Thanks guys for your responses.
> Will try the regex thing for sure.
> I am not sure if either page title or automatic nodetitles solve my problem
> off-the-shelf.
>
> 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.
>
> Quite surprising that (as I say) off-the-shelf modules are not available
> with Drupal. I am not a PHP/Drupal expert (as of yet) but can write this in
> C/C++ in a jiffy. I hope some of you experts take note :-)
>
> This can be an added feature in the existing modules you described, where
> the user can specify different tokens (extracted from the title) he/she
> wants to be appended to the title.
>
> Thanks again.
> - Ben
>
>
> --- On Mon, 8/2/10, Joe CodeWaggle <joe at codewaggle.com> wrote:
>
> > From: Joe CodeWaggle <joe at codewaggle.com>
> > Subject: Re: [support] node titles - move "the", numbers to the end
> > To: support at drupal.org
> > Date: Monday, August 2, 2010, 4:45 AM
> > Had another thought:
> >
> > You can use a PHP regex function to manipulate the title,
> > try
> > preg_replace().
> >
> > Assuming that your template is based on phptemplate (the
> > Drupal default
> > template engine), you can work in the "template.php" file
> > in your theme
> > folder (you can create one if none exists).
> >
> > Use the hook for _preprocess_page():
> > phptemplate_preprocess_page(&$vars) or ( "your
> > template
> > name"_preprocess_page(&$vars) ).
> >
> > Work with $vars['title'].
> >
> > Code Example:
> > phptemplate_preprocess_page(&$vars) {
> >   // Manipulate the Page Title
> >   $current_title = $vars['title'];
> >   $searchPattern = '/(.*)(\sthe\s)(.*)/';
> >
> >   $new_title = preg_replace($searchPattern, '$1 $3$2',
> > $current_title);
> >   $vars['title'] = $new_title;
> > }
> >
> > The search pattern looks for " the ". It keeps track of the
> > parts of the
> > title, so you can rearrange the pieces.
> >
> > If $current_title was 'where is the yummy candy',
> > $new_title would be 'where is yummy candy the'.
> >
> > Part one($1) contains 'where is', part two($2) contains '
> > the ' and part
> > three($3) contains 'yummy candy'.
> >
> > Regular Expressions can get pretty involved, so if you
> > haven't used them
> > before you'll need to spend some time learning how to
> > create the search
> > pattern that you need.
> >
> > Here are a few links to the PHP manual:
> > http://www.php.net/manual/en/book.pcre.php
> > http://www.php.net/manual/en/function.preg-replace.php
> > http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
> >
> > A quick Google for "regular expression" or regex will turn
> > up tons of info.
> >
> > Joe
> >
> >
> > -----Original Message-----
> > From: support-bounces at drupal.org
> > [mailto:support-bounces at drupal.org]
> > On
> > Behalf Of Benjamin Jacob
> > Sent: Sunday, August 01, 2010 2:08 PM
> > To: Drupal Support MailList
> > Subject: [support] node titles - move "the", numbers to the
> > end
> >
> >
> > Hi,
> >
> > Any way in drupal to manipulate titles so as to have words
> > like "the"/"a",
> > and numbers to the end?
> >
> >
> > Thanks in advance.
> > - Ben
> >
> >
> >
> > --
> > [ Drupal support list | http://lists.drupal.org/ ]
> >
> > --
> > [ Drupal support list | http://lists.drupal.org/ ]
> >
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20100802/53a21b93/attachment.html 


More information about the support mailing list