SVN 9311 $this->baseurl

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

SVN 9311 $this->baseurl

Postby AmyStephen » Tue Nov 06, 2007 3:03 pm

I believe baseurl is no longer working. I am seeing problems in my templates with CSS and Javascript, again. When I echo the value of baseurl, it is empty. Anyone else having this issue? I can reproduce it in a number of sites.

Code: Select all

<?php echo "baseurl"; ?><?php echo $this->baseurl; ?>


Thanks!
Amy :)

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 18079
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SVN 9311 $this->baseurl

Postby infograf768 » Tue Nov 06, 2007 3:51 pm

works here.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: SVN 9311 $this->baseurl

Postby AmyStephen » Tue Nov 06, 2007 4:10 pm

JM -

To confirm, with the rhuk_milkyway template, there is the following CSS statement in the delivered template index.php file:

Code: Select all

<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css" type="text/css" />


Before, (I believe) the baseurl would yield the following result:

Code: Select all

<link rel="stylesheet" href="http://example.com/templates/system/css/system.css" type="text/css" />


Now (SVN 9311), the result is:

Code: Select all

<link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />


Or, am I misunderstanding? Appreciate your help and patience, as always,
Amy :)

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: SVN 9311 $this->baseurl

Postby AmyStephen » Tue Nov 06, 2007 9:45 pm

qson reported the same problem today.

qson wrote:I found out that the call that sets $this->baseurl is

Code: Select all

JURI::base(true);
and this returns an empty string. I don't know why it doesnt work. Did not study the JURI::base()-function. Though if called with no arguments it works, so for the moment I use in the template instead of $this->baseurl
Maybe this should be considered a bug? ( I mean the JURI::base(true); returns an empty string while JURI::base(); returns correct base)


Thanks!
Amy :)

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1119
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: SVN 9311 $this->baseurl

Postby pvh123 » Tue Nov 06, 2007 10:19 pm

The same here. I to revert to a
define("JURL_BASE", JURI::base());
to get the correct path.
Joomla Bug Squad

Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 18079
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SVN 9311 $this->baseurl

Postby infograf768 » Wed Nov 07, 2007 6:34 am

Hmmm
In case of subfolder, it adds the subfolder in the relative path.

i.e if joomla is in a sub called "myfolder", it adds "/myfolder"
Therefore I see no issue when using the baseurl; ?> in a template for example.

Does that create a problem to get a relative path in the output for other extensions? (non-coder question)
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1119
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: SVN 9311 $this->baseurl

Postby pvh123 » Wed Nov 07, 2007 8:23 am

The discussion was that $this-> baseurl delivered an empty string, so nopath is set.
Joomla Bug Squad

Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

User avatar
jenscski
Joomla! Ace
Joomla! Ace
Posts: 1468
Joined: Thu Aug 18, 2005 6:58 am
Location: Tønsberg, Norway

Re: SVN 9311 $this->baseurl

Postby jenscski » Wed Nov 07, 2007 9:15 am

pvh123 wrote:The discussion was that $this-> baseurl delivered an empty string, so nopath is set.


If Joomla! is installed on the root of you domain ( http://domain.com/ ), then $this->baseurl is empty, and that is correct.
Jens-Christian Skibakk
MMS Blog - http://mms.pipp.no/
Joomla! i Norge / Joomla! in Norway - http://www.joomlainorge.no/

qson
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Sun Mar 05, 2006 9:02 pm

Re: SVN 9311 $this->baseurl

Postby qson » Wed Nov 07, 2007 10:57 am

jenscski wrote:If Joomla! is installed on the root of you domain ( http://domain.com/ ), then $this->baseurl is empty, and that is correct.

But some paths in templates, components etc. is relative (not starting with "/"), which kills the SEF url (eg. /component/contact/component/contact/index.php?option=com_contact)
I might use pvh123's solution with constant, but I think it would be nice with some kind of base-url (like old $mosConfig_live_site)  ;)

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: SVN 9311 $this->baseurl

Postby AmyStephen » Wed Nov 07, 2007 1:03 pm

I think what has happened is that the meaning of $this->baseurl has changed. It used to contain the domain name (and folder, if existing). In the rhuk_milkyway template (see my 2nd post above for this example) the inclusion of that code snippet created a complete URL. It was my understanding, and I believe it is correct, that this was added to the template as a result of this Developer Google discussion entitled 1.5 Routing / Base href issues.

After that change, we encountered MANY problems in the forums with Javascript, Image and Template issues. Finally, someone dropped a link to the developer discussion in a thread and we started noticing Andy's change. We began instructing community members to add that command, as well, for their Javascript, Image and Template issues. There were even v 1.5 extensions with errors.

Now, it's blank. So, are we are doing something different now? And, if so, does anyone know what? And, where do you find the domain name, now? Is there a thread or discussion on this somewhere that we can read?

Thanks much,
Amy :)

Edit: fixed link.
Last edited by AmyStephen on Wed Nov 07, 2007 1:06 pm, edited 1 time in total.

User avatar
jenscski
Joomla! Ace
Joomla! Ace
Posts: 1468
Joined: Thu Aug 18, 2005 6:58 am
Location: Tønsberg, Norway

Re: SVN 9311 $this->baseurl

Postby jenscski » Wed Nov 07, 2007 1:35 pm

$this->baseurl have always been empty, AFAIK, if Joomla! is installed on root on domain, and will include the folder, e.g. /joomla.

And you should use JURI::root() to find the root of your site. e.g. http://www.domain.com/ , if installed on root, and http://www.domain.com/joomla/ if installed in folder named joomla.
Jens-Christian Skibakk
MMS Blog - http://mms.pipp.no/
Joomla! i Norge / Joomla! in Norway - http://www.joomlainorge.no/

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: SVN 9311 $this->baseurl

Postby AmyStephen » Wed Nov 07, 2007 2:28 pm

jenscski -

I know I am old and forgetful. And, I have been wrong more times than I care to admit. But, I am reasonably confident that $this->baseurl *used to* provide http://example.com . I'd bet a US dollar on it, even, I am THAT confident! ;)

Anyway, thanks for the better syntax. Your help is much appreciated!
Amy :)

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1119
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: SVN 9311 $this->baseurl

Postby pvh123 » Wed Nov 07, 2007 4:33 pm

@ Amy: Not THAT old, come on :)
But you are quite right. The "$this->baseurl " construct has been published by devs around the first RC I believe,and I am forgetfull as well, for the reason you described. I am 100% sure because at that time I had to change a lot of 1.5 code in my template to get it right again. :)
Anyway, the way I use it (see above) does work.
Joomla Bug Squad

Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: SVN 9311 $this->baseurl

Postby Jinx » Sat Nov 17, 2007 5:03 am

Hehe, confusion all around it seems. The $this>->baseurl was added right before RC3 and hold the site basepath, or subdirectory for non developers among you. If you site is installed in the root then it's empty indeed.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: SVN 9311 $this->baseurl

Postby AmyStephen » Sat Nov 17, 2007 5:37 am

Thanks, Johan. I pretty much knew I was in trouble when JM said "works here." Appreciate all you do,
Amy :)

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1119
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: SVN 9311 $this->baseurl

Postby pvh123 » Sun Nov 18, 2007 7:31 am

Jinx wrote:Hehe, confusion all around it seems. The $this>->baseurl was added right before RC3 and hold the site basepath, or subdirectory for non developers among you. If you site is installed in the root then it's empty indeed.


Thanks, Johan. Since this comes from "the horses mouth" I can at least advice the complete answer next time.
Joomla Bug Squad

Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

User avatar
hsm
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 225
Joined: Thu Sep 14, 2006 11:41 am
Location: Berlin

Re: SVN 9311 $this->baseurl

Postby hsm » Mon Dec 03, 2007 7:36 pm

Hi,
can anybody explain why we have 3 methods/vars to get an URI-Basis:

* JDocument::base
* JDocument::baseurl
* JURI::base()

Why exists baseurl only for a joomla-template and not for a module-template?

hsm

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6569
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: SVN 9311 $this->baseurl

Postby Jinx » Tue Dec 04, 2007 4:27 pm

hsm wrote:Why exists baseurl only for a joomla-template and not for a module-template?


If you use JView to render your module templates you can use baseurl too .This would be the adviced approach.

Johan
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

secteur
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 146
Joined: Tue Nov 08, 2005 9:32 am
Location: Malaysia

Re: SVN 9311 $this->baseurl

Postby secteur » Sun Dec 09, 2007 8:22 am

Hi all,

I wanted the logo on top of my website to link to the home page as is often the case, and therefore used

Code: Select all

<a href="<?php echo $this->baseurl; ?>">Logo</a>


As mentioned in earlier posts $this->baseurl correctly returns an empty string if Joomla! is installed on the root of the server.
So the code above looked like (and was) a link with an empty reference: href="" which HTML interprets as "stay on this page". So wherever I was on the site, this would only reload the same page.

By adding a slash in the href after the PHP code, which doesn't harm since $this->baseurl returns a directory anyway, the link is changed to href="/" which means go to the root of this site.

Code: Select all

<a href="<?php echo $this->baseurl; ?>/">Logo</a>


Hope this helps somebody some day.

User avatar
pvh123
Joomla! Ace
Joomla! Ace
Posts: 1119
Joined: Wed Oct 05, 2005 7:25 am
Location: Amsterdam
Contact:

Re: SVN 9311 $this->baseurl

Postby pvh123 » Sun Dec 09, 2007 11:19 am

Thanks very much for this bit of information. It gives an extra dimension to
$this->baseurl

It does at least work for me :) . Because I am linking 2 or 3 templates together, depending on the subject of that part of the site,  I was struggling "to find the way home' again.
Joomla Bug Squad

Note: Sending me private messages for personal support, without this been requested, would lead to ignoring any of your posts in future!

richrc1131
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 150
Joined: Wed Apr 18, 2007 12:37 pm

Re: SVN 9311 $this->baseurl

Postby richrc1131 » Thu Feb 21, 2008 2:29 pm

Where can I find the baseurl parameter? I am building a site within a folder on the original site and need to get the css working, but I don't know where to set the base url.

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 18079
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SVN 9311 $this->baseurl

Postby infograf768 » Thu Feb 21, 2008 2:49 pm

richrc1131 wrote:Where can I find the baseurl parameter? I am building a site within a folder on the original site and need to get the css working, but I don't know where to set the base url.

The baseurl should find its proper path automatically relative to the root of the site, whether in a folder or not.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

richrc1131
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 150
Joined: Wed Apr 18, 2007 12:37 pm

Re: SVN 9311 $this->baseurl

Postby richrc1131 » Thu Feb 21, 2008 4:33 pm

Turning off SEF seemed to work. Did anyone else try this?

vaistik
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Mon Jan 26, 2009 1:35 pm

Re: SVN 9311 $this->baseurl

Postby vaistik » Mon Jan 26, 2009 1:36 pm

Ressurecting this topic for a small problem.

Joomla! 1.5.9
Virtuemart 1.1.2
SEF404

When I enable SEF404 the $this->baseurl variable on every page but the home page gets the value "index.php". This of course causes the css, images etc to not work as there is no path like "/index.php/images/...".

I have no problems with the default non-SEF urls nor with the homepage where the baseurl returns empty.

Any ideas on how to solve this? I tried hard coding the paths but that didn't really help as it appears in various part of content. I could probably set it to null (empty) but I don't know how to.

Thanks in advance.

haneef95
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Wed Oct 29, 2008 11:46 am

Re: SVN 9311 $this->baseurl

Postby haneef95 » Sun Jan 03, 2010 10:48 pm

HI,
I am having a similar problem.
And that is ; i am using JTP Horizontal login. Recently i've moved my joomla base from "www" to "www/portal". But the problem is that my user and pass icon still uses the old joomla base dir and the base directory.
I've checked the codings and it looks like this

Code: Select all

<img src="<?php echo $this->baseurl ?>/modules/mod_JTPlogin/manicon.gif" alt="<?php echo JText::_('Username') ?>" width="25" height="25" border="0" />


Thanks....
Forum rules: Maximum font size cannot be larger than normal.

yuvraj_jain
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Aug 07, 2010 11:41 am

Re: SVN 9311 $this->baseurl

Postby yuvraj_jain » Mon Aug 23, 2010 7:28 am

how it can be possible if we want to add images through the tiny mce editor or another editor.
my actual problem is that i had added one article that has images with images/image1.png now it is working ok but if i am going to url rewriting then this images are not going to be showed. what to do for that....


Return to “Joomla! 1.5 Coding”

Who is online

Users browsing this forum: No registered users and 6 guests