Hi all
Im a newb to modx so go easy with me.
I’d like to know the easiest way to use php global variables/constants within a template?
my specific issue is with the minimal default template which creates a
<base href="[(site_url)]" />
based on the value set within the administrator/at install time I assume?
I think this is an odd thing to do as each client may browse to your site through differing urls
(due to, hostfile over ride, clustering, dev to live work)
Id suggest that the base url for each page should be based on
$_SERVER[’SERVER_NAME’]
thanks in advance for your advice on how to access these within a template.
You can look at manager/includes/config.inc.php to see how site_url and base_url variables are constructed.
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
curious looking at config.inc.php
suggests that if base_path or base_url ==""
then it will automagically assign them based on script_name (which is pretty much what Im suggesting).
However on my install its using localhost no matter how I access the site (via IP or virtual hostname)
odd odd odd.
Cheers peeps for the pointers, is there somewhere I could’ve accidentaly set my base/site url so that config.inc.php doesnt over ride it?
wouldnt it make sense to ship modx with snippets that mirror most of phps constants, most of your users will be php savvey, is it because we want to promote a different way of doing things or just a yeah maybe we should do that someday?
What do you have in your apache httpd.conf as ServerName? I’m guessing localhost.
Quote from: stewski at Sep 11, 2006, 10:06 AM
wouldnt it make sense to ship modx with snippets that mirror most of phps constants, most of your users will be php savvey, is it because we want to promote a different way of doing things or just a yeah maybe we should do that someday?
I’m thinking just the opposite. MODx should be released just as the core framework as light as possible and all not essential resources should be in resource repository available for download (some client preferably in modx to download and install the resource straight from modx manager). In future, it’s possible that you will see multiple different modx "distros" available, like developers modx, bloggers modx, gallerists modx... etc. where all are built onto core modx framework, but may have some additional resources on top of that.. like linux distros.
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
OK decided the tidiest/quickest on this is to remove base url from my templates.
if you think there are any issues with doing this let me know...
Quote from: stewski at Sep 11, 2006, 10:37 AM
yep I can see that is sensible indeed, if I work on snippets to mirror php values/constants how can we share them?
Put it in the
resource repository, while it’s in developement, you can discuss about it
here and get testers etc..
Quote from: stewski at Sep 11, 2006, 10:37 AM
any idea on why this install may be locking base/site url to localhost?
It takes the site url from $_SERVER[’HTTP_HOST’] (I was wrong in the reply before, I thougt it used $_SERVER[’SERVER_NAME’] what would of come from apache http.conf)
$_SERVER[’HTTP_HOST’] comes from the current request Host: header, so it should take what you have typed in your browser. I just tried it my self and for me [(site_url)] prints "
http://localhost.." if I access the site using localhost and "
http://85.157..." if I access via IP.
"He can have a lollipop any time he wants to. That's what it means to be a programmer."
-
☆ A M B ☆
- 24,524 Posts
check the config.inc.php file.