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

15 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 (158 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 (158 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 (5 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
af3 (3 comments)

Hi randy, tried this on smfb2.4 and wp2.8.6; but unable to make it work. I uploaded the new edited script.js; disable AJAV/Javascript in smfb option; reloaded page — but comment link is still not opening up? **??? not sure what is wrong.

3 December 09 at 20:49
Randy Brown (158 comments)

@AF3 – huh.. i dunno.. double check that you made the changes correctly be sure to clear your browser cache and try clearing your blog cache and try again.

3 December 09 at 20:52
soner Kay (1 comments)

Great! Thanks. I’ve been pulling my hair out over this one all afternoon. The fix works great. Keep up the good work.

6 January 10 at 07:13
Blackito (1 comments)

Thank you very much for this fix… The fix works great. good job..

16 January 10 at 09:38
Rico (5 comments)

The theme broke in Internet Explorer browser?How can i can fix it?Please help!

19 January 10 at 20:42
Rico (5 comments)

the menu dropdown didn’t work in IE how can i fix this bug’ssss..help

19 January 10 at 20:44
Randy Brown (158 comments)

@Rico – I’m not sure how much help i can give – but, have you tried disabling the JavaScript and Ajax in the Smells Like Facebook Theme Settings?

19 January 10 at 20:45
Rico (5 comments)

yes i already disabled the JS and AJ but nothing’s happen.Best viewed in mozilla firefox but in IE the dropdownmenu doesnt work..

19 January 10 at 22:17
Rico (5 comments)

Helow randy Please help how to solve the dropdown menu in smells like facebook themes.The dropdown menu is not working in IE and the themes is broken.

24 January 10 at 05:51
Randy Brown (158 comments)

@Rico – is it broken on just your site, or other sites like mine? iiRC, this might be a limitation in how IE handles javascript – if this is the case, the fix is beyond my capabilites.

24 January 10 at 10:16
Rico (5 comments)

Tnx randy..

26 January 10 at 01:22
af3 (3 comments)

Hi randy, thanks for the fix.
Any idea how to fix the “Show older posts” links that will keep repeating the same url (page/2) if viewed under IE? I noticed this is also seen in yr website if viewed on IE8. rgds

26 February 10 at 03:42
Randy Brown (158 comments)

@AF3 – I’m afraid that issue is over my head.

26 February 10 at 08:49
Syahid (1 comments)

howdy pals! can you teach me on how to remove the login button at the header?

3 March 10 at 10:22
af3 (3 comments)

Randy: wow.. i thought i screwed up my css on my site. Browsing yours on IE8, if you click on the + category button, the dropdown menu of cateories is shown on the far left rather !! Duh… ie is *&%$^% (in a good way) hahaha.

6 March 10 at 05:05
Tom (3 comments)

Never worked for me… I added those 2 lines of code, and turned off ajax / js effects via WP-Admin, but then comments stopped working completely so reverted back. (WP-2.9.2 & SMFB- 2.4.1).

10 March 10 at 13:43
Calle (1 comments)

I used the facebook theme for an internal site and had the same problem. This fix works great!
Had some troubles at first with the quotation marks being in some strange format when trying a copy paste action. Typing in your two lines of code manually worked great though!

14 March 10 at 04:27
Mal Gordon (1 comments)

Works fine, thanks Randy!

16 March 10 at 02:15
Debra (2 comments)

Hi, thanks for posting this fix, but I’m having problems. I added the two lines to the script exactly as you stated below, but then all the content on my site was invisible. I then unchecked “Enable Javascript & AJAX effect (using Wordpress jQuery)” and that brought back my content, but now I’m unable to post comments on the blog posts. Any ideas? thanks
I’m using Firefox.

17 March 10 at 14:14
Tom (3 comments)

That’s exactly what happened with me Debra. No fix so far im afraid.

17 March 10 at 14:16
Debra (2 comments)

That’s unfortunate; it’s such a nice looking theme.

17 March 10 at 14:43
MC (1 comments)

Thanx man ..It’s working fine for me..

7 April 10 at 04:34
ds1970 (2 comments)

Hi, just wondering how you edited the js file. Did you just open it in notepad? I attempted to edit it in notepad, but it doesn’t seem to be working. the content on my website disappears. Did you use a special editor? thanks

19 April 10 at 10:08
Randy Brown (158 comments)

I dont use Windows (yech!) but any simple text editor like Notepad should work just fine (DONT use Wordpad or MS Word!). I used “Text Edit” on my Mac which is very similar to Notepad. You might want to check/change the “encoding” option that you are using… and, be sure to keep a backup of the original file before futzing with it.

19 April 10 at 10:12
ds1970 (2 comments)

So, I figured out why it wasn’t working. I’ve been using notepad and after making the changes and saving it, the formatting goes out of wack. I downloaded a free javascript editor, made the changes you suggest and everything’s working. thank you

19 April 10 at 15:53
DaChiliHeads (1 comments)

Woo hoo cheers! just the thing I needed!

20 May 10 at 15:59
Steve (5 comments)

I would really like to know why I am having trouble with getting my comments to display now after all these edits. Brand new install of wordpress, i fixed the quotes deal (encoding).

27 May 10 at 21:23
Randy Brown (158 comments)

I dunno Steve .. Try reverting the edits and verify that your comments display. Then, redo the edits manually and see if that helps.

28 May 10 at 16:35
Stefan (1 comments)

Really thank you!

1 July 10 at 06:03