get base url to use in external script
Moderator: General Support Moderators
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.
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.
-
- Joomla! Apprentice
- Posts: 12
- Joined: Sat Dec 06, 2008 5:53 am
get base url to use in external script
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
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
- MyJC
- Joomla! Enthusiast
- Posts: 219
- Joined: Fri Aug 19, 2005 2:39 am
- Location: Burbank, CA, USA
- Contact:
Re: get base url to use in external script
Code: Select all
baseurl()
"A fool takes no pleasure in understanding, but only in expressing his opinion." Proverbs 18:2
-
- Joomla! Apprentice
- Posts: 13
- Joined: Fri Jul 11, 2008 8:09 am
Re: get base url to use in external script
Or better yet use...
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...
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
Code: Select all
JURI::base();
Code: Select all
$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
*/
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.
-
- Joomla! Apprentice
- Posts: 12
- Joined: Sat Dec 06, 2008 5:53 am
Re: get base url to use in external script
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()?rfriedel wrote:Or better yet use...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: Select all
JURI::base();
Code: Select all
$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 */
-
- Joomla! Apprentice
- Posts: 13
- Joined: Fri Jul 11, 2008 8:09 am
Re: get base url to use in external script
If it's not part of the Joomla! framework then you could use the predefined variable $_SERVERademc 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()?
http://us3.php.net/manual/en/reserved.v ... server.php
- or -
You may also be able to use the magic constant __FILE__ like this
http://us3.php.net/manual/en/language.c ... efined.php
Code: Select all
$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
-
- Joomla! Apprentice
- Posts: 12
- Joined: Sat Dec 06, 2008 5:53 am
Re: get base url to use in external script
The script is included in joomla at some points, but is also accessed directly as well
- Big D
- Joomla! Apprentice
- Posts: 6
- Joined: Mon Feb 25, 2008 3:03 pm
Re: get base url to use in external script
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.
The scripts that my site is trying to access are located at "pagead2.googlesyndication.com/pagead/show_ads.php".
Thanks in advance.
-
- Joomla! Apprentice
- Posts: 48
- Joined: Mon Jan 16, 2006 10:43 am
- Location: Australia
- Contact:
Re: get base url to use in external script
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 which file needs to be imported in order to use.
JURI::base()
cheers
Ed
-
- Joomla! Guru
- Posts: 828
- Joined: Thu Mar 15, 2007 6:23 pm
- Contact:
Re: get base url to use in external script
I would also like to know too.juicyfruit wrote:Hi,
I would also like to know which file needs to be imported in order to use.
JURI::base()
cheers
Ed
Joomla Extensions: https://www.mindphp.com/en/download-en/ ... on-en.html
Free Joomla Extension: https://www.mjform.com/
Free Joomla Extension: https://www.mjform.com/