pers0n Posted January 6, 2012 Posted January 6, 2012 $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
apeisa Posted January 6, 2012 Posted January 6, 2012 http://processwire.com/api/variables/config/ You probably need these: <?php $config->httpHost $config->https Of course everything what you get from PHP is also available: http://www.php.net/manual/en/reserved.variables.server.php
Nico Knoll Posted January 7, 2012 Posted January 7, 2012 I think there's something like "$page->httpUrl"...
Pete Posted January 7, 2012 Posted January 7, 2012 It's actually: $page->httpUrl and that gives you the full URL to a given page, with http prefix.
ryan Posted January 8, 2012 Posted January 8, 2012 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... 2
baba_mmx Posted April 16, 2015 Posted April 16, 2015 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 . '/'; 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now