<![CDATA[ [Revolution, solved] Quick Question: Standard way to retrieve the base url - My Forums]]> https://forums.modx.com/thread/?thread=31534 <![CDATA[Re: [Revolution] Quick Question: Is there a standard way to retrieve the base ur]]> https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170575
regards,
JB]]>
jbjoe Mar 03, 2010, 11:37 AM https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170575
<![CDATA[Re: [Revolution] Quick Question: Is there a standard way to retrieve the base ur]]> https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170574
In content:
[[!++site_url]] <!-- This returns the site_url setting and the ! indicates this is not cacheable -->


In code:
<?php
/* gets the site_url setting */
$site_url = $modx->getOption('site_url');
?>


Generally, the only place you ever need this is in the HEAD of your MODx Template( s ), e.g.:
<head>
    <base href="[[!++site_url]]" />
    ....
</head>

That way you can use relative paths in all your content and it will always respect the absolute location defined by your site_url, regardless of where/how it is deployed.]]>
opengeek Mar 03, 2010, 11:30 AM https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170574
<![CDATA[Re: [Revolution] Quick Question: Is there a standard way to retrieve the base url?]]> https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170573 Quote from: jbjoe at Mar 03, 2010, 05:14 PM

Long ago I created a joomla template and there was a way to get the url of the site. This function simply returns "http://www.example.com/". Is there a function similar to this in modx to? I couldn’t find a system setting for this and I always use absolute paths to avoid trouble. So how? laugh

In MODx Tags:

[[++site_url]]


In PHP:

$modx->getOption('site_url');


Note that base_url is not equal to site_url.]]>
splittingred Mar 03, 2010, 11:29 AM https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170573
<![CDATA[ [Revolution, solved] Quick Question: Standard way to retrieve the base url]]> https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170572
Long ago I created a joomla template and there was a way to get the url of the site. This function simply returns "http://www.example.com/". Is there a function similar to this in modx to? I couldn’t find a system setting for this and I always use absolute paths to avoid trouble. So how? laugh

regards,
JB]]>
jbjoe Mar 03, 2010, 11:14 AM https://forums.modx.com/thread/31534/revolution-solved-quick-question-standard-way-to-retrieve-the-base-url#dis-post-170572