Get rid of the same boring title on every page...

1356

Comments

  • ivarivar Registered Users Posts: 8,395 Major grins
    edited April 12, 2006
    Ok problem, my site was doing that before I added the code.

    I thought that this code was so the BLUE title Bar on Internet explorer co-displayed what page you were on.

    I'm not talking about the url box.

    When I go here I see in the url http://photos.exposethemoment.com/Portraits but in the blue title area I see Expose The Moment - Microsoft Internet Explorer
    Isn't that what it is doing in the image i attached? it is showing "Expose the moment - Weddings" in the blue top part of the browser?

    It could be IE, because it works fine in FF.
  • ExposeTheMomentExposeTheMoment Registered Users Posts: 271 Major grins
    edited April 12, 2006
    I need someone to look at my code, and tell me if I should remove anything. I guess thats not needed. Or not working
    Gary Harfield
    Owner/Photographer
    Expose The Moment

    Had a list of gear, now its to long, so lets say I have 2 bags and 15,000 worth of stuff.
  • ExposeTheMomentExposeTheMoment Registered Users Posts: 271 Major grins
    edited April 12, 2006
    ivar wrote:
    Isn't that what it is doing in the image i attached? it is showing "Expose the moment - Weddings" in the blue top part of the browser?

    Click this link

    http://photos.exposethemoment.com/Portraits
    Gary Harfield
    Owner/Photographer
    Expose The Moment

    Had a list of gear, now its to long, so lets say I have 2 bags and 15,000 worth of stuff.
  • ivarivar Registered Users Posts: 8,395 Major grins
    edited April 12, 2006
    it works in FF, haven't checked IE yet.
  • ExposeTheMomentExposeTheMoment Registered Users Posts: 271 Major grins
    edited April 12, 2006
    When I click the link, it very quicky shows it, but goes back to what I posted.
    Gary Harfield
    Owner/Photographer
    Expose The Moment

    Had a list of gear, now its to long, so lets say I have 2 bags and 15,000 worth of stuff.
  • ExposeTheMomentExposeTheMoment Registered Users Posts: 271 Major grins
    edited April 13, 2006
    Is there Anyone Who
    Knows why this is not working?
    Gary Harfield
    Owner/Photographer
    Expose The Moment

    Had a list of gear, now its to long, so lets say I have 2 bags and 15,000 worth of stuff.
  • ExposeTheMomentExposeTheMoment Registered Users Posts: 271 Major grins
    edited April 14, 2006
    Anyone?
    Gary Harfield
    Owner/Photographer
    Expose The Moment

    Had a list of gear, now its to long, so lets say I have 2 bags and 15,000 worth of stuff.
  • DilipDilip Registered Users Posts: 7 Beginner grinner
    edited December 8, 2006
    I can't seem to get categories and gallery names to be appended
    I tried this at dilipb.smugmug.com but get a constant title. Also, is it possible to add the smuggy icon to the left of the title? Thanks.

    Dilip
    MikeFried wrote:
    ***************
    MOD Edit: Adding in the Dummy's way of doing this - same title for EVERY PAGE:
    put this in your HEAD TAG section of your customization:

    [php]******** language="javascript">document.title="YOUR PAGE TITLE INFO"</******** p php]< [> ****************


    A little while ago, I wrote, wondering how to do a number of things. Well, today, I share the fruits of my labor with you.

    The story is that I was navigating my site, touching up a keyword here and a keyword there on a photo in this gallery and a photo in that gallery, and after switching pages a bunch of times, I hit the back button to look at where I had been... "Mike Fried's Photography, Mike Fried's Photography, Mike Fried's Photography, etc". I had a new mission. Whereas before I had learned the Zen of changing the title in a single line of JavaScript, now I needed to master the Zen of changing the title with some DHTML (Dynamic HTML) to make it appropriate to the page the user was viewing.

    So I grabbed a web search, and looked around at the source to my site in my handy second web browser (I use Firefox and IE -- IE was logged into my site so I could work on the customization and I reload the site logged out in Firefox at the same time to view the results and search through source pages for interesting things to work with). After about a half hour of searching, learning, and tweaking, I had achieved my goal.

    Here's how you make the title follow your current page:
    1) In the co-branding section of your site, insert the following code into the JavaScript (Replace My Site's Title with something more appropriate):

    * Note: This has been updated to attempt to address some issues below in this thread.
    document.title = "[B]My Site's Title[/B]";
    function RelevantTitle()
    {
       var baseTitle = "[B]My Site's Title[/B]";
       var separator = " - ";
       var albumTitle = document.getElementById("albumTitle");
       var galleryTitle = document.getElementById("galleryTitle");
       if( albumTitle && albumTitle.textContent )
          document.title = baseTitle + separator + albumTitle.textContent;
       else if( galleryTitle && galleryTitle.textContent )
       {
          var galleryTitleText = galleryTitle.textContent;
          // Strip " sub-categories" off the end of the category text
          var finalPositionCategory = galleryTitleText.search(" sub-categories");
          if( finalPositionCategory >= 0 )
             galleryTitleText = galleryTitleText.substr( 0, finalPositionCategory );
          else
          {
             // Strip " galleries" off the end of the category/sub-category text
             var finalPositionSubCategory = galleryTitleText.search(" galleries");
             if( finalPositionSubCategory >= 0 )
                galleryTitleText = galleryTitleText.substr( 0, finalPositionSubCategory );
          }
          document.title = baseTitle + separator + galleryTitleText;
       }
       else // Not Gallery, Category, or Subcategory
       {
          // Set title on homepage
          document.title = baseTitle;
       }
    }
    

    2) In the BODY tag, add:
    <body onload="RelevantTitle();">
    

    Now after your page finishes loading, the title will add the appropriate indication of your gallery title, category name, or sub-category name. Nothing will be added on your home page, or other kinds of pages (keyword, etc) -- that is an exercise I leave to the reader who wishes it. I will likely update the script on my site to do this in the near future.

    Now if only I didn't have to spend an hour re-classifying all my photos last night because I only just figured out how to get a space in a keyword (use double quotes), I would have uploaded more than one new gallery from my backlog of about 60GB of photos and almost 6 years... I feel like I should install the C# SDK on my Media Center PC this weekend and write some individual photo keyword entering code for send to smugmug...
    -Mike "I like to tinker with my new smugmug account" Fried
  • gwynethgwyneth Registered Users Posts: 36 Big grins
    edited March 7, 2007
    Thanks for doing this! I was wondering if there was a way to get rid of "powered by smugmug"...I love smugmug, but the bit down the bottom of the page is good enough for me!
  • JcMax200JcMax200 Registered Users Posts: 9 Beginner grinner
    edited March 19, 2007
    It would be nice if the latest script was added to the first post via URI... and maybe even the latest of each different script that's on here, possibly with descriptions, and known bugs? I'm having a hard time sorting through all this to find what I was looking for.....
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited March 19, 2007
    JcMax200 wrote:
    It would be nice if the latest script was added to the first post via URI... and maybe even the latest of each different script that's on here, possibly with descriptions, and known bugs? I'm having a hard time sorting through all this to find what I was looking for.....

    Yeah, or even better maybe some brave soul would put it on the wiki.
  • richterslrichtersl Registered Users Posts: 3,322 Major grins
    edited April 7, 2007
    I just glanced through this entire thread and there's some really great info in here, but I'm a bit confused as to which snippet has the most recent and stable code in it. headscratch.gif Can someone please point me to it?

    Thanks!
  • denisegoldbergdenisegoldberg Administrators Posts: 14,369 moderator
    edited May 4, 2007
    Did something change?
    I installed this hack on my site a while back, and I made a slight change to it earlier this week to remove the "- powered by SmugMug" from the title bar. Everything was working fine.

    That is, the title in my browser reflected the category or gallery name in addition to my title. Then today, I noticed that the title bar was back to "from the eyes of Denise Goldberg - powered by SmugMug" - and the name of the category and gallery no longer shows.

    I don't remember touching my JavaScript between when it worked and now. I've included my title bar javascript below.
    addEvent(window, "load", ContextualizeTitle);
    var titleSettings = new Array();
    /*
    --------------------------------------------------
        customize page title settings
    --------------------------------------------------
    */
    titleSettings.separator   = ": "; // text to insert between parts of title
    titleSettings.maxLength   = -1;   // limits length of title (-1 == no limit)
    titleSettings.doPhotos    = false; // true == append photo captions
    titleSettings.doAlbums    = true; // true == append album names
    titleSettings.doGalleries = true; // true == append gallery names
    titleSettings.doSubCats   = true; // true == append sub category names
    function ContextualizeTitle() {
      var re1 = /([\s\S]*)( - powered by smugmug)/;
      var re2 = /([\s\S]*) (galleries|sub-categories)/;
      var newTitle = document.title;
      var newText = null;
      if(IsHomePage())
      {
         newTitle = newTitle.replace(re1, "$1");
         document.title = newTitle;
      }
      if(!IsHomePage()) 
      {
        // add gallery title
        if(titleSettings.doGalleries)
        {
          var galleryTitle = document.getElementById("galleryTitle");
          var subCatTitle = document.getElementById("subCatGalleryTitle");
          if(galleryTitle)
          {
            var galleryTitleText = GetTextContent(galleryTitle);
            if(galleryTitleText.length > 0)
            {
              galleryTitle = galleryTitleText.replace(re2, "$1")
              newText = titleSettings.separator + galleryTitle;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
        // add sub category title
        if(titleSettings.doSubCats)
        {
          var subCatTitle = document.getElementById("subCatGalleryTitle");
          if(subCatTitle)
          {
            var subCatTitleText = GetTextContent(subCatTitle);
            if(subCatTitleText.length > 0)
            {
              subCatTitle = subCatTitleText.replace(re2, "$1")
              newText = titleSettings.separator + subCatTitle;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
     
        // add album title
        if(titleSettings.doAlbums)
        {
          var albumTitle = document.getElementById("albumTitle");
          if(albumTitle)
          {
            var albumTitleText = GetTextContent(albumTitle);
            if(albumTitleText.length > 0)
            {
              newText = titleSettings.separator + albumTitleText;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
        // add photo title
        if(titleSettings.doPhotos)
        {
          var photoTitleText = GetPhotoCaption();
          if(photoTitleText.length > 0)
          {
            newText = titleSettings.separator + photoTitleText;
            newTitle = newTitle.replace(re1, "$1" + newText);
          }
        }
        if(titleSettings.maxLength > -1)
          newTitle = newTitle.substr(0, titleSettings.maxLength);
        document.title = newTitle;
      }
    }
    function GetPhotoCaption() {
      var photoTitle = document.getElementById("caption_bottom");
      if(!photoTitle)
        photoTitle = document.getElementById("caption_top");
      if(!photoTitle)
        return "";
     
      return GetTextContent(photoTitle);
    }
    function GetTextContent(node) {
      var text = "";
      if(node) {
        if(node.children) {
          text = GetTextContent(node.firstChild);
        } else {
          if(node.nodeValue) {
            text = node.nodeValue; // IE
          } else {
            text = node.textContent; // mozilla
          }
        }
      }
      text = Trim(text);
      return text;
    }
    function Trim(text) {
        var regexp = /^\s+|\s+$/g;
        text = text.replace(regexp, "");
        return text;
    }
     
    function IsHomePage() {
      var classStr = document.body.className;
      var re = /homepage /;
      if (!classStr)
        return false;
      return re.test(classStr);
    }
    


    There must be an error somewhere, but I just can't see it. Can someone help me solve this puzzle?
    A quick update (5/4/2007 @ 5:18PM EST) - I just checked Content by Titles on Google Analytics. Yesterday there were hits on titles - like "from the eyes of Denise Goldberg: Emerging colors - Spring 2007", and today's hits all show as "from the eyes of Denise Goldberg - powered by smugmug". I've lost the title, and "powered by smugmug" has returned. So I am having a hard time believing that it's caused by something in my JavaScript. I could be mistaken of course.

    Can anyone tell me what happened? Or what I need to fix?
    Thanks!
    --- Denise
  • AndyAndy Registered Users Posts: 50,016 Major grins
    edited May 6, 2007
    I installed this hack on my site a while back, and I made a slight change to it earlier this week to remove the "- powered by SmugMug" from the title bar. Everything was working fine.

    That is, the title in my browser reflected the category or gallery name in addition to my title. Then today, I noticed that the title bar was back to "from the eyes of Denise Goldberg - powered by SmugMug" - and the name of the category and gallery no longer shows.

    I don't remember touching my JavaScript between when it worked and now. I've included my title bar javascript below.
    addEvent(window, "load", ContextualizeTitle);
    var titleSettings = new Array();
    /*
    --------------------------------------------------
        customize page title settings
    --------------------------------------------------
    */
    titleSettings.separator   = ": "; // text to insert between parts of title
    titleSettings.maxLength   = -1;   // limits length of title (-1 == no limit)
    titleSettings.doPhotos    = false; // true == append photo captions
    titleSettings.doAlbums    = true; // true == append album names
    titleSettings.doGalleries = true; // true == append gallery names
    titleSettings.doSubCats   = true; // true == append sub category names
    function ContextualizeTitle() {
      var re1 = /([\s\S]*)( - powered by smugmug)/;
      var re2 = /([\s\S]*) (galleries|sub-categories)/;
      var newTitle = document.title;
      var newText = null;
      if(IsHomePage())
      {
         newTitle = newTitle.replace(re1, "$1");
         document.title = newTitle;
      }
      if(!IsHomePage()) 
      {
        // add gallery title
        if(titleSettings.doGalleries)
        {
          var galleryTitle = document.getElementById("galleryTitle");
          var subCatTitle = document.getElementById("subCatGalleryTitle");
          if(galleryTitle)
          {
            var galleryTitleText = GetTextContent(galleryTitle);
            if(galleryTitleText.length > 0)
            {
              galleryTitle = galleryTitleText.replace(re2, "$1")
              newText = titleSettings.separator + galleryTitle;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
        // add sub category title
        if(titleSettings.doSubCats)
        {
          var subCatTitle = document.getElementById("subCatGalleryTitle");
          if(subCatTitle)
          {
            var subCatTitleText = GetTextContent(subCatTitle);
            if(subCatTitleText.length > 0)
            {
              subCatTitle = subCatTitleText.replace(re2, "$1")
              newText = titleSettings.separator + subCatTitle;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
     
        // add album title
        if(titleSettings.doAlbums)
        {
          var albumTitle = document.getElementById("albumTitle");
          if(albumTitle)
          {
            var albumTitleText = GetTextContent(albumTitle);
            if(albumTitleText.length > 0)
            {
              newText = titleSettings.separator + albumTitleText;
              newTitle = newTitle.replace(re1, "$1" + newText);
            }
          }
        }
        // add photo title
        if(titleSettings.doPhotos)
        {
          var photoTitleText = GetPhotoCaption();
          if(photoTitleText.length > 0)
          {
            newText = titleSettings.separator + photoTitleText;
            newTitle = newTitle.replace(re1, "$1" + newText);
          }
        }
        if(titleSettings.maxLength > -1)
          newTitle = newTitle.substr(0, titleSettings.maxLength);
        document.title = newTitle;
      }
    }
    function GetPhotoCaption() {
      var photoTitle = document.getElementById("caption_bottom");
      if(!photoTitle)
        photoTitle = document.getElementById("caption_top");
      if(!photoTitle)
        return "";
     
      return GetTextContent(photoTitle);
    }
    function GetTextContent(node) {
      var text = "";
      if(node) {
        if(node.children) {
          text = GetTextContent(node.firstChild);
        } else {
          if(node.nodeValue) {
            text = node.nodeValue; // IE
          } else {
            text = node.textContent; // mozilla
          }
        }
      }
      text = Trim(text);
      return text;
    }
    function Trim(text) {
        var regexp = /^\s+|\s+$/g;
        text = text.replace(regexp, "");
        return text;
    }
     
    function IsHomePage() {
      var classStr = document.body.className;
      var re = /homepage /;
      if (!classStr)
        return false;
      return re.test(classStr);
    }
    


    There must be an error somewhere, but I just can't see it. Can someone help me solve this puzzle?
    A quick update (5/4/2007 @ 5:18PM EST) - I just checked Content by Titles on Google Analytics. Yesterday there were hits on titles - like "from the eyes of Denise Goldberg: Emerging colors - Spring 2007", and today's hits all show as "from the eyes of Denise Goldberg - powered by smugmug". I've lost the title, and "powered by smugmug" has returned. So I am having a hard time believing that it's caused by something in my JavaScript. I could be mistaken of course.

    Can anyone tell me what happened? Or what I need to fix?
    Thanks!
    --- Denise
    Bump.
  • denisegoldbergdenisegoldberg Administrators Posts: 14,369 moderator
    edited May 7, 2007
    Problem resolved
    ********************* DO NOT USE ***********************
    * This hack has been replaced by native functionality within smugmug. *
    ******************************************************

    This morning I went back through this entire thread, clicking on galleries to see if anyone else's customization still worked. I found that most of the people who posted in this thread are back to the standard title bar with no indication of where the viewer is in the site. The only person who had a changing title bar was Mike Fried. So, I changed my customization from the one I posted in this entry - http://www.dgrin.com/showpost.php?p=544195&postcount=74 - to one that looks like Mike's. I just needed to add in some code for subcategories.
    added at 3:14PM EDT - Gary Glass's title bar also still shows the gallery name; somehow I missed it on my initial wander through the different galleries referenced in this thread.
    The code that is currently working for me:
    // On IE/FF set the title before the Document OnLoad takes place
    document.title = "from the eyes of Denise Goldberg";
    addEvent( window, "load", CustomizeTitle );
    function CustomizeTitle()
    {
        var baseTitle = "from the eyes of Denise Goldberg";
        var separator = " - ";
        var albumTitle = GetText( document.getElementById("albumTitle") );
        var galleryTitle = GetText( document.getElementById("galleryTitle") );
        var subCatTitle = GetText ( document.getElementById("subCatGalleryTitle") );
        var singleImage = document.body.className && document.body.className.indexOf("singleImage") > -1 ? true : false;
        var pageTypeDefined = typeof( pageType ) != "undefined";
        var pageTypeDetailsDefined = typeof( pageTypeDetails ) != "undefined";
    // Don't change the title from the above document.title on the homepage
        if( document.body.className && document.body.className.indexOf("homepage") > -1 )
        {
            document.title = baseTitle + separator + "Home";
            return;
        }
     
    // An album page (holds a bunch of photos, could be "zoomed in" on a specific photo)
        if( albumTitle )
        {
            var photoTitle = GetPhotoTitle();
            if( photoTitle )
                document.title = baseTitle + separator + albumTitle + separator + photoTitle;
            else
                document.title = baseTitle + separator + albumTitle;
            return;
        }
    // A gallery page (holds a bunch of albums and/or a bunch of sub categories)
        if( galleryTitle )
        {
    // Strip " sub-categories" off the end of the category text
            var finalPositionCategory = galleryTitle.indexOf(" sub-categories");
            if( finalPositionCategory > -1 )
                galleryTitle = galleryTitle.substr( 0, finalPositionCategory );
            else
                {
    // Strip " galleries" off the end of the category/sub-category text
                  var finalPositionSubCategory = galleryTitle.indexOf(" galleries");
                  if( finalPositionSubCategory > -1 )
              galleryTitle = galleryTitle.substr( 0, finalPositionSubCategory );
                 }
     
                document.title = baseTitle + separator + galleryTitle;
        return;
        }
    // Pick up sub-category
        if( subCatTitle )
        {
    // Strip " sub-categories" off the end of the category text
            var finalPositionCategory = subCatTitle.indexOf(" sub-categories");
            if( finalPositionCategory > -1 )
                galleryTitle = subCatTitle.substr( 0, finalPositionCategory );
            else
                {
    // Strip " galleries" off the end of the category/sub-category text
                  var finalPositionSubCategory = subCatTitle.indexOf(" galleries");
                  if( finalPositionSubCategory > -1 )
              galleryTitle = subCatTitle.substr( 0, finalPositionSubCategory );
                 }
     
                document.title = baseTitle + separator + galleryTitle;
        return;
        }
     
    // A single image (like the kind you get when you click an image in a keyword page)
        if( singleImage )
            {
     var photoTitle = GetPhotoTitle();
     if( photoTitle )
                document.title = baseTitle + separator + photoTitle;
     else
         document.title = baseTitle + separator + "untitled photo";
     return;
     }
    // A single keyword page
        if( pageTypeDefined && pageType == 'Keyword' && pageTypeDetailsDefined )
     {
    // Keyword page
                 document.title = baseTitle + separator + "Keyword: " + pageTypeDetails;
         return;
     }
    // A multiple keyword page
        if( pageTypeDefined && pageType == 'Keywords' && pageTypeDetailsDefined )
     {
    // Multiple keywords page
    // Put " + " between each keyword instead of -
                 var keywordList = pageTypeDetails;
         keywordList = keywordList.replace(/\-/g, " + ");
         document.title = baseTitle + separator + "Keywords: " + keywordList;
         return;
     }
    // The main keywords page. Note: single image takes precedence over this type
        if( document.body.className && document.body.className.indexOf("keywordPage") > -1 )
            {
    // Main Keywords Page
                document.title = baseTitle + separator + "Keywords";
                return;
     }
    // None of the rules above set the title! Oh well, fall back on the base title.
        document.title = baseTitle;
    } // CustomizeTitle
    function Trim( text )
    {
        text = text.replace(/(^\s+)|(\s+$)/g, ""); // trim leading and trailing white space
        return text;
    } // Trim
    function GetText( node )
    {
        if( !node )
            return "";
        if( node.innerText )
            return Trim( node.innerText ); // For IE
        if( node.textContent )
            return Trim( node.textContent ); // For others
        return "";
    } // GetText
    function GetPhotoTitle()
    {
    // If the photo title is set, it starts with the breadcrumb.
        var breadCrumbStart = "Denise Goldberg > ";
        var mainPhoto = document.getElementById("mainPhoto");
        if( !mainPhoto || !mainPhoto.title || mainPhoto.title.indexOf( breadCrumbStart ) != 0 )
     return "";
        return Trim( mainPhoto.title.substr( breadCrumbStart.length ) );
    } // GetPhotoTitle
    

    I'd love to know why my previous code (basically copied from devbobo's entry) stopped working. But for now I guess I just have to accept reality...

    --- Denise
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited May 7, 2007
    This morning I went back through this entire thread, clicking on galleries to see if anyone else's customization still worked. I found that most of the people who posted in this thread are back to the standard title bar with no indication of where the viewer is in the site. The only person who had a changing title bar was Mike Fried.

    Mine still works.
  • denisegoldbergdenisegoldberg Administrators Posts: 14,369 moderator
    edited May 7, 2007
    Gary Glass wrote:
    Mine still works.
    Wow - I missed that, probably because the "- powered by smugmug" is sitting in between your title "Gary Glass / Photography" and the gallery name. I'll attach a screen shot so you can see what I see in IE7.

    I just looked at a couple of the other people's galleries and saw a change there too. But there were a few others that either didn't work or that had the customization removed.

    I guess mine was a very odd case. In my case, the gallery / category names that should have been showing were not there. Well, they were there as of last Thursday and missing as of last Friday. A mystery...

    Thanks for responding!

    --- Denise
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited May 7, 2007
    It'd be easy to strip the " - power by Smugmug" bit out of the string. Now that you've brought it up maybe I'll do that...
  • davidweaverdavidweaver Registered Users Posts: 681 Major grins
    edited August 10, 2007
    Gary Glass wrote:
    It'd be easy to strip the " - power by Smugmug" bit out of the string. Now that you've brought it up maybe I'll do that...

    Could you post that updated please?

    Thanks!
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited August 10, 2007
    This is the version I'm using:
    var titleSettings = new Array();
    /*
    --------------------------------------------------
    	customize page title settings
    --------------------------------------------------
    */
    titleSettings.separator    = ": "; // text to insert between parts of title
    titleSettings.maxLength    = -1;   // limits length of title (-1 == no limit)
    titleSettings.doPhotos     = true; // true == append photo captions
    titleSettings.doAlbums     = true; // true == append album names
    titleSettings.doGalleries  = true; // true == append gallery names
    titleSettings.stripSmugmug = true; // true == remove " - powered by SmugMug" from title bar text
    
    function ContextualizeTitle()
    {
    	var smugmugSuffix = " - powered by SmugMug";
    	var insertAt = document.title.indexOf(smugmugSuffix);
    	var newTitle = document.title;
    	var newText = null;
    	if(!IsHomePage())
    	{
    		// add photo title
    		if(titleSettings.doPhotos)
    		{
    			var photoTitleText = GetPhotoCaption();
    			if(photoTitleText.length > 0)
    			{
    				newText = titleSettings.separator + photoTitleText;
    				newTitle = InsertString(newTitle, newText, insertAt);
    			}
    		}
    		// add album title
    		if(titleSettings.doAlbums)
    		{
    			var albumTitle = document.getElementById("albumTitle");
    			if(albumTitle)
    			{
    				var albumTitleText = GetTextContent(albumTitle);
    				if(albumTitleText.length > 0)
    				{
    					newText = titleSettings.separator + albumTitleText;
    					newTitle = InsertString(newTitle, newText, insertAt);
    				}
    			}
    		}
    		// add gallery title
    		if(titleSettings.doGalleries)
    		{
    			var galleryTitle = document.getElementById("galleryTitle");
    			if(galleryTitle)
    			{
    				var galleryTitleText = GetTextContent(galleryTitle);
    				if(galleryTitleText.length > 0)
    				{
    					var index = galleryTitleText.indexOf(" galleries");
    					if(index > -1)
    					{
    						galleryTitleText = galleryTitleText.substr(0, index);
    					}
    					newText = titleSettings.separator + galleryTitleText;
    					newTitle = InsertString(newTitle, newText, insertAt);
    				}
    			}
    		}
    		if(titleSettings.maxLength > -1)
    		{
    			newTitle = newTitle.substr(0, titleSettings.maxLength);
    		}
    		if(titleSettings.stripSmugmug)
    		{
    			var regexp = / - powered by SmugMug/g;
    			newTitle = newTitle.replace(regexp, "");
    		}
    		document.title = newTitle;
    	}
    }
    
    function GetPhotoCaption()
    {
    	var caption = "";
    	var photoTitle = document.getElementById("caption_bottom");
    	if(!photoTitle)
    	{
    		photoTitle = document.getElementById("caption_top");
    	}
    	if(photoTitle)
    	{
    		caption = GetTextContent(photoTitle);
    	}
    	return caption;
    }
    
    function GetTextContent(node)
    {
    	var text = "";
    	if(node)
    	{
    		if(node.children)
    		{
    			text = GetTextContent(node.firstChild);
    		}
    		else
    		{
    			if(node.nodeValue)
    			{
    				text = node.nodeValue; // IE
    			}
    			else
    			{
    				text = node.textContent; // mozilla
    			}
    		}
    	}
    	text = Trim(text);
    	return text;
    }
    
    function InsertString(text, insertText, index)
    {
    	var newText = "";
    	if(index > -1 && index < text.length)
    	{
    		newText = text.substring(0, index) + insertText + text.substring(index);
    	}
    	else
    	{
    		newText = text + insertText;
    	}
    	return newText;
    }
    
    function Trim(text)
    {
    	var regexp = /^\s+|\s+$/g;
    	text = text.replace(regexp, "");
    	return text;
    }
    
    function IsHomePage()
    {
    	var isHomePage = false;
    	// test for the "homepage" class name in the <BODY> tag
    	var classStr = document.body.className;
    	if (classStr && (classStr.indexOf("homepage") != -1))
    	{
    		isHomePage = true;
    	}
    	return isHomePage;
    }
    
  • tmchowtmchow Registered Users Posts: 3 Beginner grinner
    edited September 24, 2007
    Gary, despite you using this update version, your site still shows the suffix "- powered by SmugMug" in it. I tried your jscript out on my site and it's also got the same problem.


    Gary Glass wrote:
    This is the version I'm using:
    var titleSettings = new Array();
    /*
    --------------------------------------------------
        customize page title settings
    --------------------------------------------------
    */
    titleSettings.separator    = ": "; // text to insert between parts of title
    titleSettings.maxLength    = -1;   // limits length of title (-1 == no limit)
    titleSettings.doPhotos     = true; // true == append photo captions
    titleSettings.doAlbums     = true; // true == append album names
    titleSettings.doGalleries  = true; // true == append gallery names
    titleSettings.stripSmugmug = true; // true == remove " - powered by SmugMug" from title bar text
    
    function ContextualizeTitle()
    {
        var smugmugSuffix = " - powered by SmugMug";
        var insertAt = document.title.indexOf(smugmugSuffix);
        var newTitle = document.title;
        var newText = null;
        if(!IsHomePage())
        {
            // add photo title
            if(titleSettings.doPhotos)
            {
                var photoTitleText = GetPhotoCaption();
                if(photoTitleText.length > 0)
                {
                    newText = titleSettings.separator + photoTitleText;
                    newTitle = InsertString(newTitle, newText, insertAt);
                }
            }
            // add album title
            if(titleSettings.doAlbums)
            {
                var albumTitle = document.getElementById("albumTitle");
                if(albumTitle)
                {
                    var albumTitleText = GetTextContent(albumTitle);
                    if(albumTitleText.length > 0)
                    {
                        newText = titleSettings.separator + albumTitleText;
                        newTitle = InsertString(newTitle, newText, insertAt);
                    }
                }
            }
            // add gallery title
            if(titleSettings.doGalleries)
            {
                var galleryTitle = document.getElementById("galleryTitle");
                if(galleryTitle)
                {
                    var galleryTitleText = GetTextContent(galleryTitle);
                    if(galleryTitleText.length > 0)
                    {
                        var index = galleryTitleText.indexOf(" galleries");
                        if(index > -1)
                        {
                            galleryTitleText = galleryTitleText.substr(0, index);
                        }
                        newText = titleSettings.separator + galleryTitleText;
                        newTitle = InsertString(newTitle, newText, insertAt);
                    }
                }
            }
            if(titleSettings.maxLength > -1)
            {
                newTitle = newTitle.substr(0, titleSettings.maxLength);
            }
            if(titleSettings.stripSmugmug)
            {
                var regexp = / - powered by SmugMug/g;
                newTitle = newTitle.replace(regexp, "");
            }
            document.title = newTitle;
        }
    }
    
    function GetPhotoCaption()
    {
        var caption = "";
        var photoTitle = document.getElementById("caption_bottom");
        if(!photoTitle)
        {
            photoTitle = document.getElementById("caption_top");
        }
        if(photoTitle)
        {
            caption = GetTextContent(photoTitle);
        }
        return caption;
    }
    
    function GetTextContent(node)
    {
        var text = "";
        if(node)
        {
            if(node.children)
            {
                text = GetTextContent(node.firstChild);
            }
            else
            {
                if(node.nodeValue)
                {
                    text = node.nodeValue; // IE
                }
                else
                {
                    text = node.textContent; // mozilla
                }
            }
        }
        text = Trim(text);
        return text;
    }
    
    function InsertString(text, insertText, index)
    {
        var newText = "";
        if(index > -1 && index < text.length)
        {
            newText = text.substring(0, index) + insertText + text.substring(index);
        }
        else
        {
            newText = text + insertText;
        }
        return newText;
    }
    
    function Trim(text)
    {
        var regexp = /^\s+|\s+$/g;
        text = text.replace(regexp, "");
        return text;
    }
    
    function IsHomePage()
    {
        var isHomePage = false;
        // test for the "homepage" class name in the <BODY> tag
        var classStr = document.body.className;
        if (classStr && (classStr.indexOf("homepage") != -1))
        {
            isHomePage = true;
        }
        return isHomePage;
    }
    
  • carolinecaroline Registered Users Posts: 1,302 Major grins
    edited September 27, 2007
    Not working for me either
    I know nothing about JS, all my customization has been pasted in from examples & suggestions given. I would really like this to work but have no idea where to start beyond beyond pasting in this code.
    Have I already got some code that is overriding this ?
    Any help would be much appreciated, thanks.

    Caroline
    Mendip Blog - Blog from The Fog, life on the Mendips
    www.carolineshipsey.co.uk - Follow me on G+

    [/URL]
  • denisegoldbergdenisegoldberg Administrators Posts: 14,369 moderator
    edited September 27, 2007
    caroline wrote:
    I know nothing about JS, all my customization has been pasted in from examples & suggestions given. I would really like this to work but have no idea where to start beyond beyond pasting in this code.
    Have I already got some code that is overriding this ?
    Any help would be much appreciated, thanks.

    Caroline
    Caroline -
    There are several versions of the code floating through this thread. For some reason I couldn't get the initial versions to work for me. I kept trying though, and finally ended up with a version that worked. If you want to try the version I am using, you can find it posted in this entry: http://www.dgrin.com/showpost.php?p=546098&postcount=76. There are a couple of changes you will need to make because the code in that entry does have my name in it in a couple of places.

    I don't know if this will help you or will cause more confusion. Hopefully it will help.

    --- Denise
  • carolinecaroline Registered Users Posts: 1,302 Major grins
    edited September 27, 2007
    Caroline -
    There are several versions of the code floating through this thread. For some reason I couldn't get the initial versions to work for me. I kept trying though, and finally ended up with a version that worked. If you want to try the version I am using, you can find it posted in this entry: http://www.dgrin.com/showpost.php?p=546098&postcount=76. There are a couple of changes you will need to make because the code in that entry does have my name in it in a couple of places.

    I don't know if this will help you or will cause more confusion. Hopefully it will help.

    --- Denise

    Thanks Denise,
    I'll have a try with your new code, I remember you posting about this when it occured. I'm going to call it a day now, its been a good 'website' day today but I've run out of steam now. No doubt will have a few more questions tomorrow.

    C
    Mendip Blog - Blog from The Fog, life on the Mendips
    www.carolineshipsey.co.uk - Follow me on G+

    [/URL]
  • Gary GlassGary Glass Registered Users Posts: 744 Major grins
    edited September 27, 2007
    Gary, despite you using this update version, your site still shows the suffix "- powered by SmugMug" in it. I tried your jscript out on my site and it's also got the same problem.

    Only on the homepage. My version ignores the homepage. I guess I could fix that. This is another script we should get onto the wiki. My sources tell me SM is going to change wiki software, though I don't know when, so I've sort of been ignoring the wiki for now.
  • carolinecaroline Registered Users Posts: 1,302 Major grins
    edited September 28, 2007
    caroline wrote:
    Thanks Denise,
    I'll have a try with your new code, I remember you posting about this when it occured. I'm going to call it a day now, its been a good 'website' day today but I've run out of steam now. No doubt will have a few more questions tomorrow.

    C

    Your code seems to be working in the main Denise but I have a couple of questions -
    Any thoughts on why when I am here : - http://www.carolineshipsey.co.uk/galleries
    The title bar shows with 'home' at the end ?

    Re the whole Mendip drop down galleries, don't think I've got the hierarchy quite right here, as when I'm in the 'Galleries' nothing at all shows at the end of the title?

    Caroline
    Mendip Blog - Blog from The Fog, life on the Mendips
    www.carolineshipsey.co.uk - Follow me on G+

    [/URL]
  • denisegoldbergdenisegoldberg Administrators Posts: 14,369 moderator
    edited September 28, 2007
    caroline wrote:
    Your code seems to be working in the main Denise but I have a couple of questions -
    Any thoughts on why when I am here : - http://www.carolineshipsey.co.uk/galleries
    The title bar shows with 'home' at the end ?

    Re the whole Mendip drop down galleries, don't think I've got the hierarchy quite right here, as when I'm in the 'Galleries' nothing at all shows at the end of the title?

    Caroline
    Hmm... I'm not sure. But I just looked at my http://denise.smugmug.com/galleries page, and it has home appended to it too. I think that's probably something left over from creating essentially a second home page when we put the slideshow on the "home" page. I remember looking at that a long time ago, and I finally just chose to ignore it.

    I'll take a look at your Mendip drop-down galleries, but I think it will need to wait until after work - too detailed to focus on when I'm supposed to be doing something else (like doing my "real" work!)... Are you using subcategories there? That took a while for me to get working, and I did something that you may or may not want. That is, I showed the subcategory name if that's where I am positioned, but when I am in a gallery for that subcategory, I show only the gallery name. I felt that showing the whole hierarchy in the title bar was too much. (Of course you might have a different desire for what shows there.)
    --- Denise
  • carolinecaroline Registered Users Posts: 1,302 Major grins
    edited September 28, 2007
    Hmm... I'm not sure. But I just looked at my http://denise.smugmug.com/galleries page, and it has home appended to it too. I think that's probably something left over from creating essentially a second home page when we put the slideshow on the "home" page. I remember looking at that a long time ago, and I finally just chose to ignore it.

    I'll take a look at your Mendip drop-down galleries, but I think it will need to wait until after work - too detailed to focus on when I'm supposed to be doing something else (like doing my "real" work!)... Are you using subcategories there? That took a while for me to get working, and I did something that you may or may not want. That is, I showed the subcategory name if that's where I am positioned, but when I am in a gallery for that subcategory, I show only the gallery name. I felt that showing the whole hierarchy in the title bar was too much. (Of course you might have a different desire for what shows there.)
    --- Denise

    Looking closer at the possibilites here whatever the choice there is bound to be some compromise. When I'm in the sub-category that is what is showing in the title bar, and like you I can live with the extra 'home'. This has taken things a long way from the original 'powered by smugmug' etc and I'm happy with it as is.

    Thanks for all you thoughtful help.

    Caroline
    Mendip Blog - Blog from The Fog, life on the Mendips
    www.carolineshipsey.co.uk - Follow me on G+

    [/URL]
  • sbresslersbressler Registered Users Posts: 148 Major grins
    edited October 3, 2007
    Is there a way using YUI to change the title before the original title loads so that it's there from the start rather than changing a few moments after loading the rest?

    -Scott
  • nardynardy Registered Users Posts: 7 Beginner grinner
    edited October 18, 2007
    title code
    I've tried every code I could find in these forums to get my titles to change and none of them work. Can I please get an updated version and where to copy and paste it?

    nardy
    Gary Glass wrote:
    This is the version I'm using:
    var titleSettings = new Array();
    /*
    --------------------------------------------------
        customize page title settings
    --------------------------------------------------
    */
    titleSettings.separator    = ": "; // text to insert between parts of title
    titleSettings.maxLength    = -1;   // limits length of title (-1 == no limit)
    titleSettings.doPhotos     = true; // true == append photo captions
    titleSettings.doAlbums     = true; // true == append album names
    titleSettings.doGalleries  = true; // true == append gallery names
    titleSettings.stripSmugmug = true; // true == remove " - powered by SmugMug" from title bar text
     
    function ContextualizeTitle()
    {
        var smugmugSuffix = " - powered by SmugMug";
        var insertAt = document.title.indexOf(smugmugSuffix);
        var newTitle = document.title;
        var newText = null;
        if(!IsHomePage())
        {
            // add photo title
            if(titleSettings.doPhotos)
            {
                var photoTitleText = GetPhotoCaption();
                if(photoTitleText.length > 0)
                {
                    newText = titleSettings.separator + photoTitleText;
                    newTitle = InsertString(newTitle, newText, insertAt);
                }
            }
            // add album title
            if(titleSettings.doAlbums)
            {
                var albumTitle = document.getElementById("albumTitle");
                if(albumTitle)
                {
                    var albumTitleText = GetTextContent(albumTitle);
                    if(albumTitleText.length > 0)
                    {
                        newText = titleSettings.separator + albumTitleText;
                        newTitle = InsertString(newTitle, newText, insertAt);
                    }
                }
            }
            // add gallery title
            if(titleSettings.doGalleries)
            {
                var galleryTitle = document.getElementById("galleryTitle");
                if(galleryTitle)
                {
                    var galleryTitleText = GetTextContent(galleryTitle);
                    if(galleryTitleText.length > 0)
                    {
                        var index = galleryTitleText.indexOf(" galleries");
                        if(index > -1)
                        {
                            galleryTitleText = galleryTitleText.substr(0, index);
                        }
                        newText = titleSettings.separator + galleryTitleText;
                        newTitle = InsertString(newTitle, newText, insertAt);
                    }
                }
            }
            if(titleSettings.maxLength > -1)
            {
                newTitle = newTitle.substr(0, titleSettings.maxLength);
            }
            if(titleSettings.stripSmugmug)
            {
                var regexp = / - powered by SmugMug/g;
                newTitle = newTitle.replace(regexp, "");
            }
            document.title = newTitle;
        }
    }
     
    function GetPhotoCaption()
    {
        var caption = "";
        var photoTitle = document.getElementById("caption_bottom");
        if(!photoTitle)
        {
            photoTitle = document.getElementById("caption_top");
        }
        if(photoTitle)
        {
            caption = GetTextContent(photoTitle);
        }
        return caption;
    }
     
    function GetTextContent(node)
    {
        var text = "";
        if(node)
        {
            if(node.children)
            {
                text = GetTextContent(node.firstChild);
            }
            else
            {
                if(node.nodeValue)
                {
                    text = node.nodeValue; // IE
                }
                else
                {
                    text = node.textContent; // mozilla
                }
            }
        }
        text = Trim(text);
        return text;
    }
     
    function InsertString(text, insertText, index)
    {
        var newText = "";
        if(index > -1 && index < text.length)
        {
            newText = text.substring(0, index) + insertText + text.substring(index);
        }
        else
        {
            newText = text + insertText;
        }
        return newText;
    }
     
    function Trim(text)
    {
        var regexp = /^\s+|\s+$/g;
        text = text.replace(regexp, "");
        return text;
    }
     
    function IsHomePage()
    {
        var isHomePage = false;
        // test for the "homepage" class name in the <BODY> tag
        var classStr = document.body.className;
        if (classStr && (classStr.indexOf("homepage") != -1))
        {
            isHomePage = true;
        }
        return isHomePage;
    }
    
Sign In or Register to comment.