List Info

Thread: base_path() not returning path to Drupal root




base_path() not returning path to Drupal root
country flaguser name
Belgium
2007-09-21 05:30:13
I have one other question I am pondering for a crazy long
time - I 
wonder if it's a bug in the core...?

An user has Drupal installed in
www.example.com/foldera/folderb/ and in 
there a files folder ( thus
www.example.com/foldera/folderb/files/ )

In my module, I need to determine the path to the 'files'
folder 
relative to the domain name (example.com)

So I've used file_directory_path() .. that gave me just
'files'.
Then I've used base_path() hoping that it would give me 
/foldera/folderb/ this way
base_path() . file_directory_path()
but the result was
/files

I see this issue was discussed at length at 
http://lists.drupal.org/archives/support/2006-03/m
sg00042.html but there 
are no clear conclusions, and anyway, that's a thread from
March 2006. 
So I wonder whether there is a clean solution for this.

I'm on Drupal 5.2, btw.

Tomas


Re: base_path() not returning path to Drupal root
country flaguser name
Belgium
2007-09-21 06:30:22
More about this - I thought perhaps the user could manually
set 
$base_url in his settings.php file.

He did that -- but it did not solve the issue!

See the messages from fuzzion at http://drupal.org/node/
176939

Seems like a serious issue also for other users that have
Drupal 
installed in subfolder(s), so I hope somebody comes back to
me on this.

Best regards,

Tomas



Tomas J. Fulopp wrote:
> I have one other question I am pondering for a crazy
long time - I 
> wonder if it's a bug in the core...?
>
> An user has Drupal installed in
www.example.com/foldera/folderb/ and 
> in there a files folder ( thus
www.example.com/foldera/folderb/files/ )
>
> In my module, I need to determine the path to the
'files' folder 
> relative to the domain name (example.com)
>
> So I've used file_directory_path() .. that gave me just
'files'.
> Then I've used base_path() hoping that it would give me

> /foldera/folderb/ this way
> base_path() . file_directory_path()
> but the result was
> /files
>
> I see this issue was discussed at length at 
> http://lists.drupal.org/archives/support/2006-03/m
sg00042.html but 
> there are no clear conclusions, and anyway, that's a
thread from March 
> 2006. So I wonder whether there is a clean solution for
this.
>
> I'm on Drupal 5.2, btw.
>
> Tomas
>
>

Re: base_path() not returning path to Drupal root
user name
2007-09-21 09:23:24
On 9/21/07, Tomas J. Fulopp <tomivacilando.org> wrote:
> I have one other question I am pondering for a crazy
long time - I
> wonder if it's a bug in the core...?
>
> An user has Drupal installed in
www.example.com/foldera/folderb/ and in
> there a files folder ( thus
www.example.com/foldera/folderb/files/ )
>
> In my module, I need to determine the path to the
'files' folder
> relative to the domain name (example.com)
>
> So I've used file_directory_path() .. that gave me just
'files'.
> Then I've used base_path() hoping that it would give
me
> /foldera/folderb/ this way
> base_path() . file_directory_path()
> but the result was
> /files

file_directory_path() is a disk file path relative to
drupal, and
base_path() is an URL path. So, using base_path() .
file_directory_path()

- when I access the site as http://example.com
/foldera/folderb it
gives me "/foldera/folderb/files"
- when I access the site as http://subdomain.example
.com it give me "/files"

But because it is an URL path, it is the same place and it
works in
both cases as far as the web browser is concerned. Is there
a reason
for your module to know the physical disk paths?


> I see this issue was discussed at length at
> http://lists.drupal.org/archives/support/2006-03/m
sg00042.html but there
> are no clear conclusions, and anyway, that's a thread
from March 2006.
> So I wonder whether there is a clean solution for
this.
>
> I'm on Drupal 5.2, btw.
>
> Tomas
>
>

Re: base_path() not returning path to Drupal root
user name
2007-09-21 09:28:11
On 9/21/07, Tomas J. Fulopp <tomivacilando.org> wrote:
> More about this - I thought perhaps the user could
manually set
> $base_url in his settings.php file.
>
> He did that -- but it did not solve the issue!


$base_url can't help with anything except fixing the
internal paths
and the menu links if they were wrong. If you change it,
either the
internal paths will break or you changed it to something
equivalent.


> See the messages from fuzzion at http://drupal.org/node/
176939
>
> Seems like a serious issue also for other users that
have Drupal
> installed in subfolder(s), so I hope somebody comes
back to me on this.
>
> Best regards,
>
> Tomas
>
>
>
> Tomas J. Fulopp wrote:
> > I have one other question I am pondering for a
crazy long time - I
> > wonder if it's a bug in the core...?
> >
> > An user has Drupal installed in
www.example.com/foldera/folderb/ and
> > in there a files folder ( thus
www.example.com/foldera/folderb/files/ )
> >
> > In my module, I need to determine the path to the
'files' folder
> > relative to the domain name (example.com)
> >
> > So I've used file_directory_path() .. that gave me
just 'files'.
> > Then I've used base_path() hoping that it would
give me
> > /foldera/folderb/ this way
> > base_path() . file_directory_path()
> > but the result was
> > /files
> >
> > I see this issue was discussed at length at
> > http://lists.drupal.org/archives/support/2006-03/m
sg00042.html but
> > there are no clear conclusions, and anyway, that's
a thread from March
> > 2006. So I wonder whether there is a clean
solution for this.
> >
> > I'm on Drupal 5.2, btw.
> >
> > Tomas
> >
> >
>

Re: base_path() not returning path to Drupal root
user name
2007-09-22 02:21:13
 url(file_directory_path(), NULL, NULL, TRUE)

but the usual case is that you have a path all the way to a
file in
which case you do

url(file_create_path($path), NULL, NULL, TRUE)

or somesuch. just working from memory.

On 9/21/07, Cog Rusty <cog.rustygmail.com> wrote:
> On 9/21/07, Tomas J. Fulopp <tomivacilando.org> wrote:
> > I have one other question I am pondering for a
crazy long time - I
> > wonder if it's a bug in the core...?
> >
> > An user has Drupal installed in
www.example.com/foldera/folderb/ and in
> > there a files folder ( thus
www.example.com/foldera/folderb/files/ )
> >
> > In my module, I need to determine the path to the
'files' folder
> > relative to the domain name (example.com)
> >
> > So I've used file_directory_path() .. that gave me
just 'files'.
> > Then I've used base_path() hoping that it would
give me
> > /foldera/folderb/ this way
> > base_path() . file_directory_path()
> > but the result was
> > /files
>
> file_directory_path() is a disk file path relative to
drupal, and
> base_path() is an URL path. So, using base_path() .
> file_directory_path()
>
> - when I access the site as http://example.com
/foldera/folderb it
> gives me "/foldera/folderb/files"
> - when I access the site as http://subdomain.example
.com it give me "/files"
>
> But because it is an URL path, it is the same place and
it works in
> both cases as far as the web browser is concerned. Is
there a reason
> for your module to know the physical disk paths?
>
>
> > I see this issue was discussed at length at
> > http://lists.drupal.org/archives/support/2006-03/m
sg00042.html but there
> > are no clear conclusions, and anyway, that's a
thread from March 2006.
> > So I wonder whether there is a clean solution for
this.
> >
> > I'm on Drupal 5.2, btw.
> >
> > Tomas
> >
> >
>

Re: base_path() not returning path to Drupal root
country flaguser name
Belgium
2007-09-29 12:00:09
Cog,

That was not a solution.
For http://example.com/foldera/folderb
base_path() . file_directory_path()
returns /foldera/folderb/files
only if Drupal is installed in the root of example.com

If Drupal is installed in folderb then
base_path() . file_directory_path()
returns /files
and that means that the full link (in browser) is
http://example.com/files
which is the problem I described.

I am trying Moshe's suggested solution that uses
url(file_directory_path(), NULL, NULL, TRUE)
which generates absolute http paths, which is a drawback, but I think it will be the solution.

Cheers,

Tomas



Cog Rusty wrote:
mail.gmail.com" type="cite">
On 9/21/07, Tomas J. Fulopp vacilando.org"><tomivacilando.org> wrote:
  
I have one other question I am pondering for a crazy long time - I
wonder if it's a bug in the core...?

An user has Drupal installed in www.example.com/foldera/folderb/ and in
there a files folder ( thus www.example.com/foldera/folderb/files/ )

In my module, I need to determine the path to the 'files' folder
relative to the domain name (example.com)

So I've used file_directory_path() .. that gave me just 'files'.
Then I've used base_path() hoping that it would give me
/foldera/folderb/ this way
base_path() . file_directory_path()
but the result was
/files
    

file_directory_path() is a disk file path relative to drupal, and
base_path() is an URL path. So, using base_path() .
file_directory_path()

- when I access the site as http://example.com/foldera/folderb it
gives me "/foldera/folderb/files"
- when I access the site as http://subdomain.example.com it give me "/files"

But because it is an URL path, it is the same place and it works in
both cases as far as the web browser is concerned. Is there a reason
for your module to know the physical disk paths?


  
I see this issue was discussed at length at
http://lists.drupal.org/archives/support/2006-03/msg00042.html but there
are no clear conclusions, and anyway, that's a thread from March 2006.
So I wonder whether there is a clean solution for this.

I'm on Drupal 5.2, btw.

Tomas


    

  
Re: base_path() not returning path to Drupal root
user name
2007-09-29 16:39:49
On 9/29/07, Tomas J. Fulopp <tomivacilando.org> wrote:
>
>  Cog,
>
>  That was not a solution.
>  For http://example.com
/foldera/folderb
>  base_path() . file_directory_path()
>  returns /foldera/folderb/files
>  only if Drupal is installed in the root of
example.com


Yes, that was clearly wrong. Probably just file_create_url()
would be better.


>  If Drupal is installed in folderb then
>  base_path() . file_directory_path()
>  returns /files
>  and that means that the full link (in browser) is
>  http://example.com/files

>  which is the problem I described.
>
>  I am trying Moshe's suggested solution that uses
>  url(file_directory_path(), NULL, NULL, TRUE)
>  which generates absolute http paths, which is a
drawback, but I think it
> will be the solution.


This looks good, but don't forget to try it without Clean
URLs.


>  Cheers,
>
>  Tomas
>
>
>
>  Cog Rusty wrote:
>  On 9/21/07, Tomas J. Fulopp <tomivacilando.org> wrote:
>
>
>  I have one other question I am pondering for a crazy
long time - I
> wonder if it's a bug in the core...?
>
> An user has Drupal installed in
> www.example.com/foldera/folderb/ and in
> there a files folder ( thus
> www.example.com/foldera/folderb/files/ )
>
> In my module, I need to determine the path to the
'files' folder
> relative to the domain name (example.com)
>
> So I've used file_directory_path() .. that gave me just
'files'.
> Then I've used base_path() hoping that it would give
me
> /foldera/folderb/ this way
> base_path() . file_directory_path()
> but the result was
> /files
>
>  file_directory_path() is a disk file path relative to
drupal, and
> base_path() is an URL path. So, using base_path() .
> file_directory_path()
>
> - when I access the site as
> http://example.com
/foldera/folderb it
> gives me "/foldera/folderb/files"
> - when I access the site as http://subdomain.example
.com it give me "/files"
>
> But because it is an URL path, it is the same place and
it works in
> both cases as far as the web browser is concerned. Is
there a reason
> for your module to know the physical disk paths?
>
>
>
>
>  I see this issue was discussed at length at
> http://lists.drupal.org/archives/support/2006-03/m
sg00042.html
> but there
> are no clear conclusions, and anyway, that's a thread
from March 2006.
> So I wonder whether there is a clean solution for
this.
>
> I'm on Drupal 5.2, btw.
>
> Tomas
>
>
>
>
>

[1-7]

about | contact  Other archives ( Real Estate discussion Medical topics )