Jump to content

Recommended Posts

Posted

$config->urls->root

just gives me '/'

I need to get the domainname (with http://) and possibly port# my site is on, so I can create some full link URLS

Posted

It's actually:

$page->httpUrl 

and that gives you the full URL to a given page, with http prefix.

Posted

This is correct, $page->httpUrl is what you are looking for, and it will include the port as well. It will also account for https if the page in question is configured to use https from its template settings.

The equivalent of $config->urls->root that you are looking for then would be:

$pages->get('/')->httpUrl; 

Just note that it has to be accessed at it's URL in order for it to know it. So if you are working with the command line API, it's not going to know it...

  • Like 2
  • 3 years later...
Posted

Old topic but maybe can be useful.

What about adding a global variable? Like this:

$port = ($_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443) ? '' : ':' . $_SERVER['SERVER_PORT'];
$protocol = ($_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
if(!$config->siteURL) $config->siteURL = $protocol . $_SERVER['SERVER_NAME'] . $port . '/';
  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...