PDA

View Full Version : DEFINED GAME URL?


FounderSim
01-26-2016, 01:55 AM
Is there a defined game url in the script somewhere?

A lot of my code uses things such as across multiple pages:


So once this action is submitted

$TableForm = new Form("multiform", "page/action", "post");


I would then be on mygameurl.com/page/action and then form would be shown again:

So if the form gets shown again using:

$TableForm = new Form("multiform", "page/action", "post");



I am now at mygameurl.com/page/action/page/action = ERROR

I rather not hard-code the URL.

Kyttias
01-26-2016, 08:43 AM
Try "../../page/action"? Doing so creates a relative path regardless and will go up two directories (if possible, if not, it'll stop at the root).

If this doesn't work I think there is such a thing that you were asking for (but I can't remember where to find it).

Hwona
01-26-2016, 05:52 PM
Umm? Are you talking about something like DOMAIN.SCRIPTPATH?
I'm taking these from the inc/config.php file. I've never used these before, but if you add include("../inc/config.php"); to each page, you should be able to fetch DOMAIN and SCIPTPATH.
If that doesn't work, you could still try your actual domain... though that's not ideal.

Edit: Also found this $mysidia->path->getAbsolute()
It should work if you've added the $mysidia = Registry::get("mysidia"); to the page.
Try:
$TableForm = new Form("multiform", "{$mysidia->path->getAbsolute()}page/action", "post");

FounderSim
01-27-2016, 01:09 AM
Thanks @Wallie987

Hall of Famer
01-27-2016, 09:55 AM
Yeah Wallie987 is right, the method getAbsolute() on Path object will return the absolute path of your site, and it will be useful for you.