Facebook Canvas pointing to subdirectory instead of root

20 views
Skip to first unread message

Reid Curley

unread,
Oct 17, 2009, 9:52:35 PM10/17/09
to ScholarPress Dev
Hi there. Great app, but I seem to have one problem.

I installed the WP files to a subdirectory of my domain
(reidcurley.com/_SubDir_WP), but I located my blog in the root
(reidcurley.com).

My canvas page is http://apps.facebook.com/reidcurleysite/. It is
pulling the posts into FB correctly, but the links back to my blog
include the path to the subdirectory where my WP files are located
instead of just the root.

In other words, when I click on "View post on reidcurley.com" it links
to

http://reidcurley.com/_SubDir_WP/permalink

instead of

http://reidcurley.com/permalink.

Any thoughts on how to fix this?

Many thanks.

John Eckman

unread,
Oct 20, 2009, 5:00:54 AM10/20/09
to scholarp...@googlegroups.com
Hi Reid - as I replied in private email to your contact on my blog,
you're hitting a known WPBook issue.

To work around it, you'd need to find the spot in the PHP where the
permalinks are calculated and change the formula -

Lines 126 to 139 of index.php inside wp-content/plugins/wpbook/theme/
is where you need to look, and you basically need to change the
external link url.

(Because all of this takes place inside facebook, the permalink
returned by get_permalink() at 129 is the Facebook version, from which
the app url - http://apps.facebook.com/reidcurleysite/ - is then cut
off, and the blogurl added back.)

You may just want to cut the appropriate number of characters (for the
subdirectory) off of $external_post_permalink after it has had the app
url removed from it.

Sorry if this is unclear but it gets confusing quicky. You can always
echo the output of these variables to an html comment and then see
what they are as you test different versions.

The other route would be to create an .htaccess rewrite rule which
maps the permalink urls from the subdomain up, but that's kind of a
hack not a solution.
----------------------------------------
John Eckman
eckma...@gmail.com
http://www.johneckman.com/





Reid Curley

unread,
Oct 20, 2009, 12:17:25 PM10/20/09
to ScholarPress Dev
John,

Thanks for the helpful response and for the great plugin. I will hack
away and let you know how it works.

Reid

Reid Curley

unread,
Oct 21, 2009, 10:34:52 PM10/21/09
to ScholarPress Dev
John,

I thought I would post the solution that I settled upon on the off
chance someone else has the exact same problem and finds this post.

It is not elegant, but it works and was quick to implement. Here are
lines 138 and 139 with 139 changed to construct my string correctly:

//break apart the external site address and get just the "site.com"
part
$external_site_url = $external_site_url_peices[host];
$exteral_post_url = "http://".$external_site_url."/".
$external_post_permalink;

I was also thinking of looking into whether using siteurl rather than
wpurl would have worked, but I just dabble in PHP and am not that
familiar with the guts of Wordpress.

Thanks again for the great plugin and the help in resolving this one
issue.

On Oct 20, 5:00 am, John Eckman <eckman.j...@gmail.com> wrote:
> Hi Reid - as I replied in private email to your contact on my blog,  
> you're hitting a known WPBook issue.
>
> To work around it, you'd need to find the spot in the PHP where the  
> permalinks are calculated and change the formula -
>
> Lines 126 to 139 of index.php inside wp-content/plugins/wpbook/theme/  
> is where you need to look, and you basically need to change the  
> external link url.
>
> (Because all of this takes place inside facebook, the permalink  
> returned by get_permalink() at 129 is the Facebook version, from which  
> the app url -http://apps.facebook.com/reidcurleysite/- is then cut  
> off, and the blogurl added back.)
>
> You may just want to cut the appropriate number of characters (for the  
> subdirectory) off of $external_post_permalink after it has had the app  
> url removed from it.
>
> Sorry if this is unclear but it gets confusing quicky. You can always  
> echo the output of these variables to an html comment and then see  
> what they are as you test different versions.
>
> The other route would be to create an .htaccess rewrite rule which  
> maps the permalink urls from the subdomain up, but that's kind of a  
> hack not a solution.
>
> On Oct 18, 2009, at 2:52 AM, Reid Curley wrote:
>
>
>
>
>
> > Hi there.  Great app, but I seem to have one problem.
>
> > I installed the WP files to a subdirectory of my domain
> > (reidcurley.com/_SubDir_WP), but I located my blog in the root
> > (reidcurley.com).
>
> > My canvas page ishttp://apps.facebook.com/reidcurleysite/.  It is
> > pulling the posts into FB correctly, but the links back to my blog
> > include the path to the subdirectory where my WP files are located
> > instead of just the root.
>
> > In other words, when I click on "View post on reidcurley.com" it links
> > to
>
> >http://reidcurley.com/_SubDir_WP/permalink
>
> > instead of
>
> >http://reidcurley.com/permalink.
>
> > Any thoughts on how to fix this?
>
> > Many thanks.
>
> ----------------------------------------
> John Eckman
> eckman.j...@gmail.comhttp://www.johneckman.com/

John Eckman

unread,
Oct 22, 2009, 12:54:13 PM10/22/09
to scholarp...@googlegroups.com
Thanks Reid - it might indeed.

What I need to think through - and I'm just looking for the time
really - is all the potential combinations of permalink structure,
blog installation, and home page.

In your case permalinks build off of just the site domain (www.example.com
) but in other cases they build off of the subdirectory into which
WordPress has been installed (www.example.com/wordpress/)

Then I need to figure out what "siteurl" and "wpurl" return in all
these cases as well as what the permalink url returns, when in the FB
context.

Maybe I'm over-complicating it but I want to make sure it doesn't
break for anyone, as it will break fairly dramatically if it does. ;)

Reid Curley

unread,
Oct 22, 2009, 4:42:07 PM10/22/09
to scholarp...@googlegroups.com
John,

The possibilities are endless, so I don't envy you having to test them all out.  As an FYI, I also got it to work by changing line 139 to:

$exteral_post_url = get_bloginfo('siteurl')."/".$external_post_permalink;

While this is a more robust fix than than my first effort, as you point out, it still may not work in all instances.

Thanks again.
Reply all
Reply to author
Forward
0 new messages