Not signed in (Sign In)

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

    • CommentAuthorkocaarslan
    • CommentTimeApr 29th 2006
     
    Hi;
    Does anyone has any idea about custimizing the head part of the script? The script has a static title for all pages, how can we define the title of the page as the current folder or the photo name, this can help us on search engine ranking.
    • CommentAuthorT2
    • CommentTimeMay 3rd 2006
     
    Excellent point. I would like to be able to do this as well.

    T2
    •  
      CommentAuthormike
    • CommentTimeMay 3rd 2006 edited
     
    We've got this integrated into Beta 3 already. But if you want to try to modify your copy of 2.1, do the following:

    Copy and paste this function into plog-functions.php


    function generate_title(){
    switch ($GLOBALS['plogger_level']) {
    case 'collection':
    $row = get_collection_by_id($GLOBALS['plogger_id']);

    $breadcrumbs = SmartStripSlashes($row["name"]);
    if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= ' » 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") {
    $breadcrumbs = SmartStripSlashes($row["name"]) . ' » ' . $album_name.' » ' . ' Slideshow';
    } else {
    $breadcrumbs = SmartStripSlashes($row["name"]) . ' » ' . $album_name;
    }

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

    $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"]);

    $breadcrumbs = $collection_name . ' » ' . $album_name . ' » ' . $picture_name;

    if ($GLOBALS['plogger_mode'] == "slideshow") $breadcrumbs .= ' » Slideshow';

    break;
    default:
    $breadcrumbs = ' Collections';
    }

    return $breadcrumbs;
    }


    It's just a modified version of the generate breadcrumbs function, minus the links.

    Now, to add the generated title to the markup, go into gallery.php and change the following:

    Right after this code:

    $inHead = <<<EOT
    <link rel="stylesheet" type="text/css" href="${baseurl}css/gallery.css" />
    &lt;script type="text/javascript" src="${baseurl}dynamics.js"&gt;</script>
    EOT;


    Add something like:

    $inHead .= '&lt;title&gt;'.generate_title().'&lt;/title&gt;';


    That should do the trick.
    • CommentAuthorT2
    • CommentTimeMay 3rd 2006
     
    Thank you Mike. Do you have a release date for Beta 3?

    Best Regards,
    T2
    •  
      CommentAuthormike
    • CommentTimeMay 4th 2006
     
    When it's done =)
    • CommentAuthorjonih
    • CommentTimeJul 31st 2006
     
    I have a heavily customized version of Plogger 2.1b and I'd like to get the title thing to work. However, the mod above is based on the Beta 3 version and calls for functions that are not in the 2.1b version.

    I hesitate to upgrade the gallery.php and plog-functions.php files as I've spent a lot of time modifying them. Can you give some advice how to deal with this? Should I upgrade?
    • CommentAuthordime
    • CommentTimeJul 31st 2006
     
    I inserted this function at the end of plog-functions.php file , but on every page title is "Colections" What i am doing wrong?
  1.  
    I'm using an earlier version of the generate_title function which fits better in 2.1. I have customized it, so make sure you back up your gallery.php, plog-functions.php and read through this post before adding it in. I don't use slideshow in my gallery, so that level isn't considered here. This will take a little work to avoid some errors and get it working right, but isn't too difficult. You can see it in action at:
    http://www.solemnchaos.net/gallery/

    You'll need to add 2 additional functions to plog-functions.php (or remove the references to them in the generate_title function). Here are the 2 additional functions and the generate_title function:

    //quote_smart shown in ex. 3 at http://us3.php.net/mysql_real_escape_string
    // Quote variable to make safe
    function quote_smart($value)
    {
    // Stripslashes
    if (get_magic_quotes_gpc()) {
    $value = stripslashes($value);
    }
    // Quote if not integer
    if (!is_numeric($value)) {
    $value = "'" . mysql_real_escape_string($value) . "'";
    }
    return $value;
    }
    //sc strip filename extension from breadcrumbs, title, album
    function strip_ext($fext)
    {
    return substr($fext, 0, strrpos($fext, '.'));
    }

    function generate_title($level, $id){
    global $TABLE_PREFIX;
    switch ($level){

    case 'collection':
    $query = "SELECT id, name FROM plogger_collections WHERE id= '".$id."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);

    $titlebar = $row["name"];

    break;

    case 'album':
    $query = "SELECT id, name, parent_id FROM plogger_albums WHERE id = '".$id."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);

    $album_name = $row["name"];

    $query = "SELECT id, name FROM plogger_collections WHERE id ='".$row["parent_id"]."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);

    $titlebar = $row["name"] . ' &raquo; ' . $album_name;

    break;

    case 'picture':
    $query = "SELECT id, path, parent_album FROM plogger_pictures WHERE id = '".$id."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);
    $picture_name = basename($row["path"]);

    $query = "SELECT id, name, parent_id FROM plogger_albums WHERE id ='".$row["parent_album"]."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);

    $album_name = $row["name"];

    $query = "SELECT id, name FROM plogger_collections WHERE id ='".$row["parent_id"]."'";
    quote_smart($query);
    $result = run_query($query);
    $row = mysql_fetch_assoc($result);

    $collection_name = $row["name"];
    $picture_name = strip_ext($picture_name);
    $titlebar = $collection_name . ' &raquo; ' . $album_name . ' &raquo; ' . $picture_name;

    break;

    default:
    $titlebar = ' Gallery';
    }

    return $titlebar;
    }


    OK, now in your gallery.php file, around line 23 you will see these lines (don't add them):
    if (is_array($resolved_path)) {
    $_GET["level"] = $resolved_path["level"];
    $_GET["id"] = $resolved_path["id"];

    Add this line right after them (we're adding it here to make sure level and id are defined before using the generate_title function):

    $title = generate_title($_GET["level"], $_GET["id"]);

    Now around line 37, you will see this line:
    if ($_GET["level"] == "slideshow")

    ABOVE this line add:

    if (empty($title)) $title = ' Gallery';

    and move the $inHead lines here next (currently at lines 12-15):
    $inHead = <<<EOT
    <link rel="stylesheet" type="text/css" href="${baseurl}css/gallery.css" />
    <script type="text/javascript" src="${baseurl}dynamics.js"></script>
    EOT;

    finally, change the $inHead lines, so they look like this (we are adding the title here):
    $inHead = <<<EOT
    <link rel="stylesheet" type="text/css" href="${baseurl}css/gallery.css" />
    <script type="text/javascript" src="${baseurl}dynamics.js"></script>
    <title>$title</title>
    EOT;
    • CommentAuthorjonih
    • CommentTimeAug 1st 2006
     
    Thank you very much! Very good job.
    • CommentAuthordime
    • CommentTimeAug 3rd 2006
     
    solemnchaos: this code doesn't doing job for me, on every page i now don't have title. What to do?
  2.  
    dime,

    are you getting any errors? what are they? is there no title at all now?

    if you aren't using mod rewrite (cruft-free urls), then this won't work and results in every page being titled 'Gallery'.
    • CommentAuthordime
    • CommentTimeAug 3rd 2006
     
    Thank you for answer!
    I have no errors, just title is not showing, and yes i use cruft-free urls. I read somewhere that this is included in beta3. Will i loose something by going on beta3?
    • CommentAuthorsolemnchaos
    • CommentTimeAug 3rd 2006 edited
     
    you shouldn't lose any of your content moving to beta3, but beta3 has not been officially released. Features and code are changing and not yet ready for release. Unless you are comfortable working with the code directly, I would recommend waiting for the official release.

    --
    just out of curiosity, did you turn on the error_reporting to check for errors?

    near the top of the gallery.php file, you will see this line:
    #error_reporting(E_ALL);

    just remove the #, so it looks like this:
    error_reporting(E_ALL);

    put the # back after you are done checking for errors.

    (you may also need to turn on display errors in your php.ini file temporarily)