Way to determine pages' title length

matthew.wren's Avatar

matthew.wren

15 Aug, 2014 02:15 PM

We've been working on making a dynamic title region on the template level in our test instance but I was wondering if there is a way to see if the titles themselves will be too long. I know some of our pages are buried deeply in folders and Google recommends a certain title length so we are trying to determine how best to handle it if titles become too long.

Is there a way in Cascade to figure this out?

  1. 1 Posted by Wing Ming Chan on 15 Aug, 2014 02:30 PM

    Wing Ming Chan's Avatar

    This will be a good candidate for my Report class. We just need to look at the title field and count the number of characters, and report a page if the number exceeds a predefined max.

    Wing

  2. 2 Posted by Ryan Griffith on 15 Aug, 2014 02:39 PM

    Ryan Griffith's Avatar

    Also, depending on your needs, you could adjust your Velocity Format to pass the title string through the Display Tool's truncate method. This would allow you to control the length of the title based on either characters or words as well as append something onto the end, such as ellipses.

  3. 3 Posted by Ryan Griffith on 15 Aug, 2014 02:39 PM

    Ryan Griffith's Avatar

    Also, depending on your needs, you could adjust your Velocity Format to pass the title string through the Display Tool's truncate method. This would allow you to control the length of the title based on either characters or words as well as append something onto the end, such as ellipses.

  4. 4 Posted by matthew.wren on 15 Aug, 2014 02:40 PM

    matthew.wren's Avatar

    Can you tell me about this Report class? Is this something I can use now or is it in a newer update?

  5. 5 Posted by Wing Ming Chan on 15 Aug, 2014 03:20 PM

    Wing Ming Chan's Avatar

    I have just added a reportLongTitle method to the Report class. To generate such a report, use code of the following type:

        $site_name   = 'about';
        $folder_path = '/';
        $max         = 40;
        $results = $report->
            setRootContainer( 
                $cascade->getAsset( 
                    Folder::TYPE, $folder_path, $site_name )
            )->reportLongTitle( $max );
        DebugUtility::dump( $results );
    
    Wing
  6. 6 Posted by matthew.wren on 15 Aug, 2014 06:02 PM

    matthew.wren's Avatar

    Where do I need to go to generate this report?

  7. 7 Posted by Wing Ming Chan on 15 Aug, 2014 06:25 PM

    Wing Ming Chan's Avatar

    Matt,

    You will need to set up the library first, if you haven't. Try these steps:

    1. Download the library cascade_ws.zip on Building Classes
    2. Install and configure the library: How to Use the Library
    3. Put the code in one of your test pages and load the page in a browser.

    Updated: see Working With Wired Fields of Metadata.

    Wing

  8. Ryan Griffith closed this discussion on 03 Sep, 2014 07:49 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac