The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Thu Jan 15, 2009 10:52 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 06, 2008 5:53 am
Posts: 12
Hi guys,

I need the joomla 1.5 base url to use as a path in an external script, but I'm not sure what I need to include to get access to the variable.

Thanks in advance


Top
 Profile  
 
PostPosted: Thu Jan 15, 2009 3:43 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Fri Aug 19, 2005 2:39 am
Posts: 219
Location: Burbank, CA, USA
Code:
baseurl()

_________________
"A fool takes no pleasure in understanding, but only in expressing his opinion." Proverbs 18:2


Top
 Profile  
 
PostPosted: Thu Jan 15, 2009 5:53 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jul 11, 2008 8:09 am
Posts: 13
Or better yet use...
Code:
JURI::base();


So if you wanted to output a full url to the clock image named clock.jpg that is located in the images/stories/ you could do so like this...
Code:
$path = 'images/stories/';
$filename = 'clock.jpg';
$myImgUrl = JURI::base() . $path . $filename;

echo $myImgUrl;
/*
 * Assuming your Joomla! install is in the topmost directory the output would be
 * http://yoursite.com/images/stories/clock.jpg
 */


Some cavets here...
The class is JURI not JURL
JURI::base() has the trailing slash so you need to leave it out of the beginning of your path

Edit: misspelled JURI lol


Last edited by rfriedel on Thu Jan 15, 2009 10:37 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Jan 15, 2009 10:07 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 06, 2008 5:53 am
Posts: 12
rfriedel wrote:
Or better yet use...
Code:
JURI::base();


So if you wanted to output a full url to the clock image named clock.jpg that is located in the images/stories/ you could do so like this...
Code:
$path = 'images/stories/';
$filename = 'clock.jpg';
$myImgUrl = JURI::base() . $path . $filename;

echo $myImgUrl;
/*
 * Assuming your Joomla! install is in the topmost directory the output would be
 * http://yoursite.com/images/stories/clock.jpg
 */



Thanks for the reply, I'd like to do what you suggest, but the script is external and not part of joomal so what do I need to import in order to get access to JURI::base()?


Top
 Profile  
 
PostPosted: Thu Jan 15, 2009 10:30 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Jul 11, 2008 8:09 am
Posts: 13
ademc wrote:
Thanks for the reply, I'd like to do what you suggest, but the script is external and not part of joomal so what do I need to import in order to get access to JURI::base()?


If it's not part of the Joomla! framework then you could use the predefined variable $_SERVER
http://us3.php.net/manual/en/reserved.variables.server.php

- or -

You may also be able to use the magic constant __FILE__ like this
http://us3.php.net/manual/en/language.constants.predefined.php
Code:
$myPath = dirname(__FILE__);
echo $myPath;
// This will output the absolute path to the CURRENT file excluding the filename
// Also there is NO trailing slash
// This is actually the method that Joomla uses to get the constant JPATH_BASE in the index.php file line 17


Edit: I may have jumped the gun a bit... is the code which you are referring to included at any point in Joomla? If so then you can use the earlier method that I mentioned.


Top
 Profile  
 
PostPosted: Thu Jan 15, 2009 10:50 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sat Dec 06, 2008 5:53 am
Posts: 12
The script is included in joomla at some points, but is also accessed directly as well


Top
 Profile  
 
PostPosted: Wed Jan 21, 2009 2:13 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Feb 25, 2008 3:03 pm
Posts: 6
I have a module that is also trying to access outside scripts from google. I get an error on my page that says (URL file-access is disabled). Would this method also help me out in accessing outside scripts. I read these posts and followed the recommendations, but I am not sure how to implement. Can someone please explain?

The scripts that my site is trying to access are located at "pagead2.googlesyndication.com/pagead/show_ads.php".

Thanks in advance.


Top
 Profile  
 
PostPosted: Tue Feb 10, 2009 10:53 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jan 16, 2006 10:43 am
Posts: 46
Location: Australia
Hi,

I would also like to know which file needs to be imported in order to use.

JURI::base()

cheers
Ed

_________________
http://www.geeksupport.com.au


Top
 Profile  
 
PostPosted: Tue Oct 13, 2009 11:30 am 
Joomla! Guru
Joomla! Guru

Joined: Thu Mar 15, 2007 6:23 pm
Posts: 714
juicyfruit wrote:
Hi,

I would also like to know which file needs to be imported in order to use.

JURI::base()

cheers
Ed

I would also like to know too.

_________________
รับดู,แก้ปัญหา Joomla, Extensions(Component, Module, Plugin) T- 086-703-1560
http://www.mindphp.com/forums/
อบรมการสร้างเว็บไซต์หลายภาษาด้วย Joomla 3.x ฟรี โฮสติ้ง 1ปี
http://www.mdsoft.co.th/service/trainin ... a-3-x.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 



Who is online

Users browsing this forum: No registered users and 60 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