Auto Nav: shorten page names (truncate)?

Permalink
I have a client that wants to use ridiculously long names for the pages for SEO reasons. I need to use an Auto Nav for organizing some inner sections and would like the Auto Nav to truncate some of the Page Names. Is it possible? And, if so, is it possible to truncate by word count rather than character count?

 
TheRealSean replied on at Permalink Reply
TheRealSean
Page names can be as long or as short as you like I assume your client is referring to the URL? Or do you just want to display a shorter Name in the navigation?

Either way its possible you could create a custom template and then
truncate the page name,

$shortName= substr($cobj->getCollectionName(),0,55)

I think one of the helpers also allows you to truncate
I think thats something like

$textHelper->truncate($cobj->getCollectionName(),55);
not sure of the syntax here it may be ->shortenText? its in the pagelist block though
zoinks replied on at Permalink Reply
There has to be a Heading dynamically created from the Page Names, which have several long names. Additionally, there is an autonav which dynamically is generated from the Page Names as well, but I don't want the Auto Nav to have a 7-word long link. For example, one page is something like Great Expectations Limited Partnership Program and I would like the menu to simply say "Great Expectations."
TheRealSean replied on at Permalink Reply
TheRealSean
A Reg expression may help try this

preg_replace('/([a-zA-Z-]+)\s([a-zA-Z-]+)\s(.*)/i', '$1 $2', '$cobj->getCollectionName()');

This should take the Name and take the first two words
zoinks replied on at Permalink Reply
Thanks for trying to help me out here. Unfortunately, I'm barely php literate, so I have no idea how to apply that in order to make it work in the middle of an Auto Nav.
TheRealSean replied on at Permalink Reply
TheRealSean
upload the version of the autonav you are using, or post the code, and Ill edit it and paste it back in for you hows that :)
zoinks replied on at Permalink Reply 1 Attachment
That is incredibly charitable is what that is! Thanks! It's just the basic autonav block from 5.4.1.1, but I've attached it zipped to this message.
TheRealSean replied on at Permalink Reply 1 Attachment
TheRealSean
Upload into your root folder

root>blocks>autonav>templates

dont put this into the conrete dir

Then where you include you nav select autonav and choose custom template Then choose header Truncate

its not tested but should do the job
zoinks replied on at Permalink Reply
Thank you... I'm going to have to try to implement this a little later, but I will let you know how it worked out, so you're not left wondering! This was really kind of you. I really appreciate it.
zoinks replied on at Permalink Reply
So, it looks like you put your altered view.php code in a view.txt file. I should copy the contents of that into the view.php file, right?
TheRealSean replied on at Permalink Reply
TheRealSean
Sorry been away for the weekend, yes or rename the .txt to .php