Path Variables

The Path variable is one of the most commonly used variables within templates.  It's purpose is to enable you to easily create links to other templates within your site.  Here is the basic format:

{path='template_group/template'}

Make sure you substitute "template_group" and "template" with the name of an actual template group and template.

When the path variable is rendered it will automatically include your site URL, as you've defined in your General Configuration.

For example, a variable like this:

{path='weblog/comments'}

Will be rendered like this:

http://www.example.com/index.php/weblog/comments/

The path variable is most commonly used to create a link, like this:

<a href="{path='weblog/archives'}">My Archives Page</a>

Why not hard code URLs instead?

The biggest advantage to using the path variable whenever you must create a link is that if your site URL ever changes you can simply update your General Configuration page with the new URL and every link in your templates will update accordingly.  Using the path variable is also less prone to errors since you only need to know two pieces of information: The Template Group name and the template name.

Other Path Variables

There are several other "path" variables for specific purposes:

Site Index

You can use site_index in your path to point to your main site index:

{path="site_index"}

Log-out

Using logout in your path variable will let you create a link that logged-in members can used to log out with:

{path="logout"}

Member Related Links

The path variable can be used to create a number of different links that point to areas with the Member Profile pages. You'll find more information regarding these in the Member Links page.

Top of Page

User Contributed Notes

Posted by: ruraldreams on 24 April 2008 5:27pm
no avatar

Path variables that occur within the weblog:entries pair are mixed in with the list here

You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide