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?
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."
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
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
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.
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 :)
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.
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
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
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.
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?
Sorry been away for the weekend, yes or rename the .txt to .php
Either way its possible you could create a custom template and then
truncate the page name,
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