The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 26 posts ] 
Author Message
 Post subject: SVN 9311 $this->baseurl
PostPosted: Tue Nov 06, 2007 3:03 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
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:
<?php echo "baseurl"; ?><?php echo $this->baseurl; ?>


Thanks!
Amy :)

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Tue Nov 06, 2007 3:51 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 17370
Location: **Translation Matters**
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
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Tue Nov 06, 2007 4:10 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
JM -

To confirm, with the rhuk_milkyway template, there is the following CSS statement in the delivered template index.php file:
Code:
<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:
<link rel="stylesheet" href="http://example.com/templates/system/css/system.css" type="text/css" />


Now (SVN 9311), the result is:
Code:
<link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />


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

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Tue Nov 06, 2007 9:45 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
qson reported the same problem today.

qson wrote:
I found out that the call that sets $this->baseurl is
Code:
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 :)

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Tue Nov 06, 2007 10:19 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Wed Oct 05, 2005 7:25 am
Posts: 1109
Location: Amsterdam
The same here. I to revert to a
Quote:
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!


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 6:34 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 17370
Location: **Translation Matters**
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
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 8:23 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Wed Oct 05, 2005 7:25 am
Posts: 1109
Location: Amsterdam
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!


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 9:15 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu Aug 18, 2005 6:58 am
Posts: 1468
Location: Tønsberg, Norway
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/


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 10:57 am 
Joomla! Intern
Joomla! Intern

Joined: Sun Mar 05, 2006 9:02 pm
Posts: 84
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)  ;)


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 1:03 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
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.

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


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

Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 1:35 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu Aug 18, 2005 6:58 am
Posts: 1468
Location: Tønsberg, Norway
$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/


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 2:28 pm 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
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 :)

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Wed Nov 07, 2007 4:33 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Wed Oct 05, 2005 7:25 am
Posts: 1109
Location: Amsterdam
@ 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!


Top
 Profile  
 
PostPosted: Sat Nov 17, 2007 5:03 am 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Fri Aug 12, 2005 12:47 am
Posts: 6569
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


Top
 Profile  
 
PostPosted: Sat Nov 17, 2007 5:37 am 
Joomla! Champion
Joomla! Champion

Joined: Wed Nov 22, 2006 3:35 pm
Posts: 7056
Location: Nebraska
Thanks, Johan. I pretty much knew I was in trouble when JM said "works here." Appreciate all you do,
Amy :)

_________________
http://Twitter.com/AmyStephen
http://www.alltogetherasawhole.org/


Top
 Profile  
 
PostPosted: Sun Nov 18, 2007 7:31 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Wed Oct 05, 2005 7:25 am
Posts: 1109
Location: Amsterdam
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!


Top
 Profile  
 
PostPosted: Mon Dec 03, 2007 7:36 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Sep 14, 2006 11:41 am
Posts: 225
Location: Berlin
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


Top
 Profile  
 
PostPosted: Tue Dec 04, 2007 4:27 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Fri Aug 12, 2005 12:47 am
Posts: 6569
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


Top
 Profile  
 
PostPosted: Sun Dec 09, 2007 8:22 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Tue Nov 08, 2005 9:32 am
Posts: 146
Location: Malaysia
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:
<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:
<a href="<?php echo $this->baseurl; ?>/">Logo</a>


Hope this helps somebody some day.


Top
 Profile  
 
PostPosted: Sun Dec 09, 2007 11:19 am 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Wed Oct 05, 2005 7:25 am
Posts: 1109
Location: Amsterdam
Thanks very much for this bit of information. It gives an extra dimension to
Quote:
$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!


Top
 Profile  
 
PostPosted: Thu Feb 21, 2008 2:29 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Apr 18, 2007 12:37 pm
Posts: 144
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.


Top
 Profile  
 
PostPosted: Thu Feb 21, 2008 2:49 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 17370
Location: **Translation Matters**
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
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Thu Feb 21, 2008 4:33 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Wed Apr 18, 2007 12:37 pm
Posts: 144
Turning off SEF seemed to work. Did anyone else try this?


Top
 Profile  
 
PostPosted: Mon Jan 26, 2009 1:36 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jan 26, 2009 1:35 pm
Posts: 9
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.


Top
 Profile  
 
PostPosted: Sun Jan 03, 2010 10:48 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Oct 29, 2008 11:46 am
Posts: 5
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:
<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.


Top
 Profile  
 
PostPosted: Mon Aug 23, 2010 7:28 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sat Aug 07, 2010 11:41 am
Posts: 1
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....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 26 posts ] 



Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group