Actions

Difference between revisions of "JURI/setPath"

From Joomla! Documentation

(New page: Sets the path part of the URI represented by the JURI object. ===Syntax=== void setPath( $path ) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$path |string |...)
 
m (See also: re-categorisation)
 
Line 36: Line 36:
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setPath JURI->setPath on api.joomla.org]
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setPath JURI->setPath on api.joomla.org]
 
* [[JURI/getPath|JURI->getPath]]
 
* [[JURI/getPath|JURI->getPath]]
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JURI]]</noinclude>
+
<noinclude>[[Category:JURI]]</noinclude>

Latest revision as of 11:42, 9 August 2012

Sets the path part of the URI represented by the JURI object.

Syntax

void setPath( $path )

where:

Argument Data type Description Default
$path string Path to be added to the URI. This will replace any existing path.

Note that the path is cleaned before it is placed in the URI object. For example, these transformations would be done:

  • /foo/bar/../boo.php => /foo/boo.php
  • /foo/bar/../../boo.php => /boo.php
  • /foo/bar/.././/boo.php => /foo/boo.php

Example

In this example, a URI object is created and the path is then changed.

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
echo 'Before: ' . $u->toString() . "\n";
$u->setPath( '/administrator/components/com_contact/controller.php' );
echo 'After : ' . $u->toString();

would output

Before: http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthat
After : http://fredbloggs:itsasecret@www.example.com:8080/administrator/components/com_contact/controller.php?task=view&id=32#anchorthat

See also