Building URLs

Since there are quite a few different ways to configure URLs in Agile Toolkit, there is also a way to produce links. For example, if you want to figure out how the URL would look for the page 'preferences/user', you can use one of the following methods:

Result

 

Code

The output of url() is actually an object, which produces proper URL when converted into string

To pass information between pages, a convenient way is to use arguments in the URL, as in a GET form request. If you wish to complicate things by creating URLs such as /book/39/delete you are free to spend some time building them, however in most cases such presentation might not be important. Agile Toolkit provides a convenient way to pass arguments as GET URLs to any page:

Result

 

Code

GET URL Arguments are always properly escaped / encoded. Setting an argument's value to "false" or "null" will exclude it from the list of arguments.

Sticky GET Arguments

Some views (such as Paginator or Form) produce links. They can't know, however, if you want any certain arguments included in these links. Typically you would want some arguments to be preserved, such as ID of the record which is being currently edited.

Agile Toolkit introduces a mechanism called Sticky GET arguments. Once argument is marked as "sticky" it will appear on all generated URLs.

Result

 

Code

Relative Pages

Another handy feature in Agile Toolkit is the ability to generate URLs from relative paths.

Page Generated URL Notes
/ /index Using "/" generates URL to index page.
. /learn/understand/page/link Single dot refers to the current page. You can also pass "null" as 1st argument to url() to assume current page
.. /learn/understand/page Parent page in page hierarchy.
../object /learn/understand/page/object Adjacent page is specified as a sub-page of the parent page.
./test /learn/understand/page/link/test Finally you can link to a sub-page of a current page like this.

Try your own examples

Result

 

Code

As you might have noticed, no extra checks or escaping is performed on the page name. You should never display a link, where the user may directly affect the "page". It is, however, perfectly secure to pass user-supplied data through GET arguments.