Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorkokuda
    • CommentTimeApr 9th 2010
     
    Below are some changes I made to generate_title() in plog-functions.php for my own site that I thought I would share.

    Based on how wp_title() works in Wordpress, I wanted to have plogger generate a page title with a different separator and in reverse order (The page name on the left and the category/album name on the right).

    Here is my full, updated, generate_title. Note that, by default, it works exactly the same way as the original function in RC1. Also note that, in order to use this in my theme, I disabled the automatic title generation done by Plogger. I believe that it should be defined in the theme.


    /*
    * kokuda: Added $sep and $seplocation to mimick wordpress' ability to generate a title in any order with any separators.
    *
    * @param string $sep Optional, default is ' » '. How to separate the various items within the page title.
    * @param string $seplocation Optional. Direction to display title, 'right'.
    */
    function generate_title($sep = ' » ', $seplocation = '') {
    switch ($GLOBALS['plogger_level']) {
    case 'collection':
    $row = get_collection_by_id($GLOBALS['plogger_id']);

    $breadcrumb_array[] = SmartStripSlashes($row['name']);
    if ($GLOBALS['plogger_mode'] == 'slideshow') {
    $breadcrumb_array[] = plog_tr('Slideshow');
    }

    break;
    case 'slideshow':
    case 'album':
    $row = get_album_by_id($GLOBALS['plogger_id']);
    $album_name = SmartStripSlashes($row['name']);

    $row = get_collection_by_id($row['parent_id']);

    if ($GLOBALS['plogger_mode'] == 'slideshow') {
    $breadcrumb_array[] = SmartStripSlashes($row['name']);
    $breadcrumb_array[] = $album_name;
    $breadcrumb_array[] = ' '.plog_tr('Slideshow');
    } else {
    $breadcrumb_array[] = SmartStripSlashes($row['name']);
    $breadcrumb_array[] = $album_name;
    }

    break;
    case 'picture':
    $row = get_picture_by_id($GLOBALS['plogger_id']);
    $picture_name = get_caption_filename($row);

    $row = get_album_by_id($row['parent_album']);
    $album_name = SmartStripSlashes($row['name']);

    $row = get_collection_by_id($row['parent_id']);
    $collection_name = SmartStripSlashes($row['name']);

    $breadcrumb_array[] = $collection_name;
    $breadcrumb_array[] = $album_name;
    $breadcrumb_array[] = $picture_name;

    // Hmm, slideshow on picture level, how does that make sense?
    if ($GLOBALS['plogger_mode'] == 'slideshow') {
    $breadcrumb_array[] = plog_tr('Slideshow');
    }

    break;
    case '404':
    $breadcrumb_array[] = ' '.plog_tr('404 Error - Not Found');
    break;
    default:
    $breadcrumb_array[] = ' '.plog_tr('Collections');
    }

    if ($GLOBALS['plogger_level'] != '404' || $GLOBALS['plogger_level'] != 'search' || $GLOBALS['plogger_level'] != 'slideshow') {
    if (isset($_GET['plog_page'])) {
    $breadcrumb_array[] = plog_tr('Page').' '.$_GET['plog_page'];
    }
    }

    if ( 'right' == $seplocation ) { // sep on right, so reverse the order
    $breadcrumb_array = array_reverse( $breadcrumb_array );
    $breadcrumbs = implode( $sep, $breadcrumb_array );
    } else {
    $breadcrumbs = implode( $sep, $breadcrumb_array );
    }

    return $breadcrumbs;
    }
    •  
      CommentAuthorsidtheduck
    • CommentTimeApr 9th 2010
     
    Thanks for posting your code, kokuda.

    We have been working on something similar as well. You can view the patch file from ticket #170 that was submitted for testing. I'll take a look at your code to see if we can combine the two to get something into the core code.