Page 1 of 1

SVN 9311 $this->baseurl

Posted: Tue Nov 06, 2007 3:03 pm
by AmyStephen
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 :)

Re: SVN 9311 $this->baseurl

Posted: Tue Nov 06, 2007 3:51 pm
by infograf768
works here.

Re: SVN 9311 $this->baseurl

Posted: Tue Nov 06, 2007 4:10 pm
by AmyStephen
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 :)

Re: SVN 9311 $this->baseurl

Posted: Tue Nov 06, 2007 9:45 pm
by AmyStephen
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 :)

Re: SVN 9311 $this->baseurl

Posted: Tue Nov 06, 2007 10:19 pm
by pvh123
The same here. I to revert to a
define("JURL_BASE", JURI::base());
to get the correct path.

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 6:34 am
by infograf768
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)

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 8:23 am
by pvh123
The discussion was that $this-> baseurl delivered an empty string, so nopath is set.

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 9:15 am
by jenscski
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.

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 10:57 am
by qson
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)  ;)

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 1:03 pm
by AmyStephen
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.

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 1:35 pm
by jenscski
$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.

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 2:28 pm
by AmyStephen
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 :)

Re: SVN 9311 $this->baseurl

Posted: Wed Nov 07, 2007 4:33 pm
by pvh123
@ 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.

Re: SVN 9311 $this->baseurl

Posted: Sat Nov 17, 2007 5:03 am
by Jinx
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.

Re: SVN 9311 $this->baseurl

Posted: Sat Nov 17, 2007 5:37 am
by AmyStephen
Thanks, Johan. I pretty much knew I was in trouble when JM said "works here." Appreciate all you do,
Amy :)

Re: SVN 9311 $this->baseurl

Posted: Sun Nov 18, 2007 7:31 am
by pvh123
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.

Re: SVN 9311 $this->baseurl

Posted: Mon Dec 03, 2007 7:36 pm
by hsm
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

Re: SVN 9311 $this->baseurl

Posted: Tue Dec 04, 2007 4:27 pm
by Jinx
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

Re: SVN 9311 $this->baseurl

Posted: Sun Dec 09, 2007 8:22 am
by secteur
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.

Re: SVN 9311 $this->baseurl

Posted: Sun Dec 09, 2007 11:19 am
by pvh123
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.

Re: SVN 9311 $this->baseurl

Posted: Thu Feb 21, 2008 2:29 pm
by richrc1131
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.

Re: SVN 9311 $this->baseurl

Posted: Thu Feb 21, 2008 2:49 pm
by infograf768
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.

Re: SVN 9311 $this->baseurl

Posted: Thu Feb 21, 2008 4:33 pm
by richrc1131
Turning off SEF seemed to work. Did anyone else try this?

Re: SVN 9311 $this->baseurl

Posted: Mon Jan 26, 2009 1:36 pm
by vaistik
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.

Re: SVN 9311 $this->baseurl

Posted: Sun Jan 03, 2010 10:48 pm
by haneef95
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....

Re: SVN 9311 $this->baseurl

Posted: Mon Aug 23, 2010 7:28 am
by yuvraj_jain
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....