|
|
Thread Tools | Display Modes |
|
#141
|
|
|
Major grins
|
Here is a simpler alternative approach for those with a limited number of pages...
Hi -
This approach is simpler and a bit more manual, but provides great flexibility.... This enables you to specifically title any page. Top Javascript function UpdatedPageTitle() { var baseTitle = "YOUR BASE PAGE TITLE"; var separator = " - "; var updatedPageTitle = document.getElementById("updatedPageTitle"); if( updatedPageTitle && updatedPageTitle.innerHTML ) {document.title = baseTitle + separator + updatedPageTitle.innerHTML;} else {document.title = baseTitle;} } Body Tag <body onload="UpdatedPageTitle();"> CSS #updatedPageTitle {display:none;} Anywhere on a page that you want to title a specific way <div id=updatedPageTitle>YOUR UPDATED TITLE</div> Note: If you do NOT implement the <div id=updatedPageTitle> statement on a given page, that page will display the base title that is set in the Javascript section. Thanks, Tom K. |
|
|
|
|
#142
|
||
|
Big grins
|
Quote:
__________________
[FONT=Fixedsys]PixelPie Photography[/FONT] [FONT=Lucida Sans Unicode]Weddings | Portraits[/FONT] [FONT=Lucida Sans Unicode]Site[/FONT] [FONT=Fixedsys]&[/FONT] [FONT=Lucida Sans Unicode]Blog[/FONT] [FONT=Lucida Sans Unicode]heather@pixelpiephotos.com[/FONT] |
|
|
|
||
|
#143
|
|
|
Grinner NOOOBie
|
Phew
Hi All,
For the last three hours I have been working away on this trying to get it to work. I have finally managed to get one of the versions working which is: Code:
/*
--------------------------------------------------
ContextualizeTitle Settings
--------------------------------------------------
*/
var titleSettings = {
separator : ": ", // Text to insert between parts of title.
maxLength : -1, // Limits length of title (-1 == no limit).
doPhotos : true, // true == append photo captions
doAlbums : true, // true == append album names
doGalleries : true, // true == append gallery names
stripSmugmug : true, // true == remove " - powered by SmugMug" from title bar text
inverse : true, // true == reverse order of home/gallery/album/photo
siteTitle : null // null == use normal site title. "" == suppress site title. "Any Value" == replaces normal site title.
};
/*
--------------------------------------------------
ContextualizeTitle Class
--------------------------------------------------
*/
function ContextualizeTitle ()
{
var pieces = new TitlePieces();
var newTitle = "";
if (titleSettings.inverse)
{
newTitle = MakeTitleBackward();
}
else
{
newTitle = MakeTitleForward();
}
if (titleSettings.maxLength > -1)
{
newTitle = newTitle.substr(0, titleSettings.maxLength);
}
if (titleSettings.stripSmugmug == false)
{
newTitle += " - powered by SmugMug";
}
document.title = newTitle;
// METHODS
function MakeTitleBackward ()
{
var title = "";
title += pieces.Photo
if (title.length > 0
&& pieces.Album.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Album;
if (title.length > 0
&& pieces.Gallery.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Gallery;
if (title.length > 0
&& pieces.Main.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Main;
return title;
}
function MakeTitleForward ()
{
var title = "";
title += pieces.Main;
if (title.length > 0
&& pieces.Gallery.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Gallery;
if (title.length > 0
&& pieces.Album.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Album;
if (title.length > 0
&& pieces.Photo.length > 0)
{
title += titleSettings.separator;
}
title += pieces.Photo
return title;
}
// CLASSES
function TitlePieces ()
{
this.Main = GetMainTitle();
this.Gallery = GetGalleryTitle();
this.Album = GetAlbumTitle();
this.Photo = GetPhotoTitle();
function GetMainTitle ()
{
var value = titleSettings.siteTitle;
if (value == null)
{
var index = document.title.indexOf("- powered by SmugMug");
value = document.title.substr(0, index);
}
return value;
}
function GetGalleryTitle ()
{
var value = "";
if (titleSettings.doGalleries)
{
var element = document.getElementById("galleryTitle");
if (element)
{
value = GetTextContent(element);
if (value.length > 0)
{
// remove " galleries" from title
var index = value.indexOf(" galleries");
if (index > -1)
{
value = value.substr(0, index);
}
}
}
}
return value;
}
function GetAlbumTitle ()
{
var value = "";
if (titleSettings.doAlbums)
{
var element = document.getElementById("albumTitle");
if (element)
{
value = GetTextContent(element);
}
}
return value;
}
function GetPhotoTitle ()
{
var value = "";
if (titleSettings.doPhotos)
{
var element = document.getElementById("caption_bottom");
if (!element)
{
element = document.getElementById("caption_top");
}
if (element)
{
value = GetTextContent(element);
}
}
return value;
}
}
} // end of ContextualTitle class
/*
--------------------------------------------------
Utility Methods
--------------------------------------------------
*/
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 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;
}
Cheers Stuart |
|
|
|
|
#144
|
||
|
Picture Reality
|
Quote:
__________________
[FONT="Garamond"]Gary Glass[/FONT] [FONT="Tahoma"]ShutterGlass.com[/FONT] [FONT="Tahoma"]OnlyBegotten.com[/FONT] |
|
|
|
||
|
#145
|
||
|
Beginner grinner
|
Title Bar Help
I used this method by Mohamed Ghuloom on http://www.photos.nixielee.com.
All is well exept one small bug. On the Catagories "Glitz" and "SledgeHammer" the catagory name is not displayed in the title bar. I use a different theme for these catagories could that be what is affecting the display and how so?? Many Thanks- ultimae goal examples Nixielee Photography (Home Page) Glitz - Nixielee Photography (Glitz Catagory) Glitz - Blue Haven Lounge - Nixielee Photography (Blue Haven Sub Catagory) ect... It's not a huge deal when they are on an album the album name shows up and the Powered by Smug Mug is gone which is my main goal. But if you have any ideas for what I may have done wrong let me know Many Thanks! Quote:
|
|
|
|
||
|
#146
|
||
|
I like to shoot people!
|
Quote:
Does anyone know if using this code will change the gallery titles in a google search or will they all still be the same? Thanks
__________________
|
|
|
|
||
|
#147
|
|
|
Big grins
|
So I have been reading multiple threads and have just gone in circles over what exactly to put. I believe I have put everything that Gary has said to put, and I would just like to have someone possibly take a look at my site and see if i've goofed anything up or mixed up codes. I have put everything in my bottom Javascript instead of my top which might be causing a problem. Also, I did insert my title into the "" (that is what I was supposed to do right?) But I don't believe it is working with what I have so I messed something up for sure. Any help would be greatly appreciated!
![]() Thank you in advance! Rachael Ritchie http://www.rachaelritchiephotography.com |
|
|
|
|
#148
|
|
|
Picture Reality
|
It doesn't look like you're actually invoking the ContextualizeTitle method anywhere. There's different ways to do it:
You can add it to your body tag: onload="ContextualizeTitle();" You can add an event handler anywhere in your javascript: addEvent(window, "load", ContextualizeTitle);
__________________
[FONT="Garamond"]Gary Glass[/FONT] [FONT="Tahoma"]ShutterGlass.com[/FONT] [FONT="Tahoma"]OnlyBegotten.com[/FONT] |
|
|
|
|
#149
|
|
|
Big grins
|
I am new here and in need of some help
I have been following this thread for the last couple days and I can't make heads or tails out of what is happening. I don't even know if this is what I was looking for so if someone answer this I would be so greatful. All I want to do is remove the words sub-categories, categories and galleries from the page title. Simple put I would like to see: CategoryName not CategoryName + categories Sub-CategoryName not Sub-CategoryName + sub-categories Can someone please point me in the right direction? http://www.joedecluette.smugmug.com Thank you so much,
|
|
|
|
|
#150
|
|
|
Picture Reality
|
Big_D, this hack is about modifying the text displayed in the titlebar of the browser, not what's shown on the page itself.
I understand your frustration, and again, I renew my call to Smugmug to provide a better way for all of us to maintain and document user-contributed hacks. User-contributed hacks add real value to SM. But they are not being well utilized.
__________________
[FONT="Garamond"]Gary Glass[/FONT] [FONT="Tahoma"]ShutterGlass.com[/FONT] [FONT="Tahoma"]OnlyBegotten.com[/FONT] |
|
|
|
|
#151
|
|
|
Big grins
|
I've been looking through this and trying to implement it but I need a real dummy's guide step by step set of instructions to get it working.
I put this code in the Top JavaScript section: document.title = "Black Shadow Photography – Richard Sharman a photographer in Melbourne";function RelevantTitle(){ var baseTitle = " Black Shadow Photography – Richard Sharman a photographer in Melbourne"; 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; }} And I put this in the Body Tag section <body onload="RelevantTitle();"> But it wouldn't accept my changes. What am I doing wrong? |
|
|
|
|
#152
|
|
|
Big grins
|
Could someone please help me do this for my site. I am just starting out with the whole SEO thing and know I have a LONG way to go!!! Here is what I would like it to say
<script language="javascript">document.title="Got Grins Photography - Lakeland, FL Premiere Children's, Teen and Senior Portrait Photgrapher"</script> I tried to put that in and it wouldnt let me. Thanks! www.GotGrins.com |
|
|
|
|
#153
|
|
|
panasonikon
|
You don't need this technique any more. Just use NiceNames for your Galleries and Categories and we do it automagically for you.
|
|
|
|
|
#154
|
|
|
Big grins
|
I am starting WAY at the beginning. I was just reading about keywords and BEGAN to add them.... I need to see examples of steps for SEO. It there a post that does that. Like a step by step of importance:
examples of a good caption (should they all be different?) I think I found keyword examples then this started with a good header title? I dont need that? What is a nicename for a gallery? Ive never even hear of that!! UGH! I am sorry!!! |
|
|
|
|
#155
|
||
|
"tweak 'til it squeaks"
|
Quote:
title="Got Grins Photography - Lakeland, FL Premiere Children's, Teen and Senior Portrait Photgrapher"
__________________
Al My Website my Blog Mozilla Firefox Web Developer Firebug Customization FAQ Banner/Navbar/Slideshow Tutor |
|
|
|
||
|
#156
|
|
|
Big grins
|
Could you please go to this page: http://gotgrins.smugmug.com/gallery/...7071&k=MNkfMgZ and look at my nicename etc and tell me why the url looks like that and not the way I want it to?? Im totally confused!
THANK YOU :) |
|
|
|
|
#157
|
||
|
Scripting dude-volunteer
|
Quote:
You could further clean up the URL by removing the subcategory (in gallery settings) and only using a category since you aren't actually showing the category/sub-category hierarchy on your site.
__________________
--John Homepage • Popular JFriend's javascript customizations • Secrets for getting fast answers on Dgrin Always include a link to your site when posting a question |
|
|
|
||
|
#158
|
||
|
"tweak 'til it squeaks"
|
Quote:
<li><a href="/gallery/23200203_frfPj8">Seniors</a></li> Change the link to this <li><a href="/LakelandFL-1/Senior-Portrait-Photographer/Senior-Portraits/23200203_frfPj8">Seniors</a></li> /gallery/ is normally used to hide the path for info type unlisted galleries.
__________________
Al My Website my Blog Mozilla Firefox Web Developer Firebug Customization FAQ Banner/Navbar/Slideshow Tutor |
|
|
|
||
| Tell The World! | |
| Thread Tools | |
| Display Modes | |
|
|