A node title might be called "Cat In the Hat, The" so that it sorts as one would expect and not by the "The". I'm trying to use this module in D5 to reassemble the titles as we would expect them to read– "The Cat in the Hat"

I'm finding that the following PHP works:

<?php 
$title = $data->node_title;
$nURL = 'node/'. $data->nid;

if (substr($title, -5)==", The"){
	print l("The ".substr($title, 0, -5), $nURL);
} else {
	print l( $title, $nURL);
}
?>

But this does not:

<?php 
$title = $data->node_title;
$nURL = 'node/'. $data->nid;

if (substr($title, -5)==", The"){
	print l("The ".substr($title, 0, -5), $nURL);
} elseif (substr($title, -3)==", A"){
	print l("A ".substr($title, 0, -3), $nURL);
} else {
	print l( $title, $nURL);
}
?>

I'm scratching my head to understand why that would be. Is it possible that the PHP field rejects code beyond a certain length? From what I can see the added condition is written correctly?

Comments

ecksley’s picture

I almost forgot... Thank you!!!

casey’s picture

casey’s picture

Status: Active » Closed (won't fix)

D5 version is no longer supported (wasn't for a long time to be honest).