ie http://www.mysite.com/index.php for an internal page for an etomite site.
From the miscellaneous API documentation.
Quote
makeUrl($id, $alias=0, $args='')
// Modified by mikef
// returns a properly formatted URL as of 0.6.1 Final
// $id is a valid document id
// $alias is now an unused parameter because it is now calculated based on $id
// $args is a URL compliant text string of $_GET key=value pairs
// Example: makeURL(45,'','?cms=Etomite')
// Modified by mikef
// returns a properly formatted URL as of 0.6.1 Final
// $id is a valid document id
// $alias is now an unused parameter because it is now calculated based on $id
// $args is a URL compliant text string of $_GET key=value pairs
// Example: makeURL(45,'','?cms=Etomite')
$id can be passed by using $etomite->documentIdentifier, by passing a numeric value for a page id, or by passing an alias for the page by using [~alias~].
$args will accept key=>value pairs to pass in the URL as GET values eg:
$etomite->makeURL(12,'','?param1=one¶m2=two');will result in:
Quote
http://www.mysite.co...ndex.php?id=12param1=one¶m2=two
Things to notice...The $args are prefixed by a "?", now if a "?" already exists (like in the example above), the API is smart enough to work out that another "?" will break the URL, so it adds an amperstand "&" instead.
Another implementation is:
$etomite->makeURL($etomite->documentIdentifier,'','');
This will create a URL to the page where it was generated.
You could also use it like this with the sendRedirect() function:
return $etomite->sendRedirect($etomite->makeURL($etomite->documentIdentifier,'',''), $count_attempts=3, $type='');
Or with templated variables like this:
$etomite->makeURL([~sitemap~],'','');
or with internal snippet variables like this:
$etomite->makeURL($page,'',"?var1=".$varOne."&var2=".$varTwo);
makeURL also works well with javascript implementations, and is also my perferred method of creating a form action:
$output="<form id=\"myform\" action=\"".$etomite->makeURL($etomite->documentIdentifier,'','')."\" method=\"get / post\" > <<<SNIP>>>> </form>";This method is much more reliable than form action="" (especially for many localhosts or when the form submits to an error 404 (page not found).
makeURL also handles friendly aliases and FURL (Friendly URLs). That means that if your site is using these options, you can pass a page number or alias and the FURL will be returned.
ie $etomite->makeURL('12','',''); will return
http://yoursite.com/yourpage.html depending on the settings you have chosen to use in your site configuration settings.
Edited by Cris D., 03 March 2009 - 06:09 PM.











