Learn Success With Randy Brown

Do it right the first time, stoopit.

Fix “Smells Like Facebook” theme URL Funkyness

I’ve been using this new “Smells Like Facebook” theme for a few days now, and one annoying problem that it has is munging-up the URL as you browse the site.  As you click around the site, the URLs get a “#” stuck in them, and if you ever click the “Home” link, all links you click after that have not only a stray “#”, but they also have your base-URL doubled-up.  For example, my URL looked like this after clicking around a few pages:

http://success.grownupgeek.com/#/index.php/2009/07/page/http://success.grownupgeek.com

The easy fix for this problem is to disable the “java and AJAX effects” in the theme settings.  The trouble with this though, is that it seems to break the ability for anyone to leave any comments!

After tinkering around a bit, I think I’ve fixed it up by adding two simple lines to SCRIPT.JS.  This will disable java/ajax for everything except the comment sections.

WARNING:: I am not a coder.  I do not know what I am doing.  Before you attempt the changes below, back up your files, your Wordpress database, your Microsoft Word Documents and all the porn on your C: drive!  If you find that this ‘fix’ of mine breaks something else, please post a comment here.  I’ve been testing this fix for a few hours and as far as I can tell, it’s working – but I make no guarantees.

Find script.js located in wp-content\themes\smells-like-facebook

Find this section:
$(id + " a").not(".nextpost").not(".notajax").each(function() {
site = $("meta[name='home']").attr("content");
dashboard = $("meta[name='url']").attr("content") + "/wp-admin";
wplogin = $("meta[name='url']").attr("content") + "/wp-login.php";
if (
$(this).attr('href') != '#' && //it's not a '#' only link
$(this).attr('href').indexOf(site) == 0 && //it's an internal link
$(this).attr('href').indexOf(dashboard) == -1 && //it's not a link to dashboard
$(this).attr('href').indexOf(wplogin) == -1 //it's not a link to wp-login.php

Immediately AFTER the line that reads:

dashboard = $(”meta[name='url']“).attr(”content”) + “/wp-admin”;

add the following line:

thehome = $(”meta[name='url']“).attr(”content”)

Then, immediately AFTER the line that reads:

$(this).attr(’href’).indexOf(site) == 0 && //it’s an internal link

Add the following line:

$(this).attr(’href’).indexOf(thehome) == -1 &&

The new section should look like this:

$(id + " a").not(".nextpost").not(".notajax").each(function() {
site = $("meta[name='home']").attr("content");
dashboard = $("meta[name='url']").attr("content") + "/wp-admin";
thehome = $("meta[name='url']").attr("content");
wplogin = $("meta[name='url']").attr("content") + "/wp-login.php";
if (
$(this).attr('href') != '#' && //it's not a '#' only link
$(this).attr('href').indexOf(site) == 0 && //it's an internal link
$(this).attr('href').indexOf(thehome) == -1 &&
$(this).attr('href').indexOf(dashboard) == -1 && //it's not a link to dashboard
$(this).attr('href').indexOf(wplogin) == -1 //it's not a link to wp-login.php

Save the new script.js file back to your server, load up your blog, hit REFRESH or RELOAD to reload the JS, and see if it works any better.  If it does, or if it breaks something else, please leave a comment and let me know.  I know this isn’t the most elegant fix, but hey, it’ll do the job until the theme author comes up with a ‘real’ fix.

Applies to “Smells Like Facebook” Version 2.4

7 people like this post.

Categories: Blogging
Coz (7 comments)

No luck for me. It does fix the navigation, but all my pages’ content disappears. Pages are blank. If I then do disable ajax, content shows up again on pages, but commenting appears impossible.

2 August 09 at 13:38
Coz (7 comments)

Ok ok ok, nevermind. It seems when I copy and paste your code, it’s in a different character set. So the quote marks and apostrophes do not show appropriately in my code, therefore, they’re not treated as code…. but I fixed that. It’s working. I’ll let you know if I encounter any glitches, but so far so good!

2 August 09 at 13:45
Rob Patton (2 comments)

Thanks, Randy. Your fix appears to be working well on my site. I was also having problems with IE 6, which apparently cannot handle the strange # problem at all – any page with a form on it just did not show up.


Your fix solved that problem, too. Thanks!

2 August 09 at 21:00
Rob Patton (2 comments)

Oh…your fix also made it so permalinks work! Thanks again!

2 August 09 at 21:07
xander (1 comments)

nice facebook site

11 August 09 at 11:09
n0chase (1 comments)

i really would like to activate the FB theme to my site could you help me please the 3 column is what i need

19 August 09 at 16:50
Randy Brown (119 comments)

@n0chase – Ok – download the them, activate it, and you’re 99% there! Then, make the changes i’ve posted here in my blog, and you’re pretty much done. Where exactly are you having trouble?

19 August 09 at 16:53
MOGmartin (2 comments)

Hey Randy, Im using the layout for a new site in pre alpha at the moment – your fix is GREAT – but my comments on the post pages arent working, although they do work on the category pages.


both are calling #respond on their respective pages, but the blog post template isnt working – any idea whats happening mate?


cheers! (by the way, looks like you are now the unofficial support for this template ;-) )

20 August 09 at 05:43
Randy Brown (119 comments)

@MOGmartin; hmm.. not sure why it’s working for everyone else, and not you.. double-check that you did everything right i guess, and make sure you are using Smells Like Facebook v2.4
??

20 August 09 at 05:51
Anonymous (3 comments)

This worked great… thx

22 August 09 at 17:35
MOGmartin (2 comments)

will check through it all again mate and let you know if it resolves it, or if I need to change any code I will post it up…


cheers!

24 August 09 at 01:33
Marcel (2 comments)

Even with the fix I get this error in the error console. And the annoying # in the url. Anyone an idea?


Error: $(”textarea”).not(”.respondtext”).autogrow is not a function
Source File: http://www.vakantie-in-ameland.nl/wp-content/themes/smells-like-facebook/script.js?ver
Line: 133

10 November 09 at 03:04
Marcel (2 comments)

Looks like disabling javascript option in theme-options and enabling it again solved the annoying # URL but the error in javascript remains…..


Great theme! Nice to use it!

10 November 09 at 03:26