{guest}

Renders its content when nobody is logged in, and its else half for a user.

Users and access Tag pairs

Syntax

{guest} ... {/guest}
{guest} ... {else} ... {/guest}

Description

{guest} renders its content when nobody is logged in to this application, and the part after its own {else} - or the @else@ half - when someone is. It is {auth} turned round, without the user's row: the fields of the user are {auth}'s to give.

Like {auth} it never starts a session to find out: a visitor without a session cookie is a guest at once. The pair must close - a lone {guest} is an error under the strict check.

Examples

Only for a guest

Nobody is logged in here, so the content renders; for a user the else half would.

Templateexamples/guest/1-guest.pad
{guest}
  <p><a href="#register">Create an account</a> or <a href="#login">log in</a>.</p>
{else}
  <p><a href="#logout">Log out</a></p>
{/guest}

A header for both

{guest} and {auth} side by side: {guest} hands over no data, {auth} hands over the user's row.

Templateexamples/guest/2-header.src
<header>
  {guest}<a href="?login">Log in</a>{/guest}
  {auth}<span>{$name}</span> <a href="?logout">Log out</a>{/auth}
</header>

See also

  • {auth} Renders its content when a user is logged in, with the user's row as its data, and its else half for a guest.
  • {can} Renders its content when the user may do something a gate decides, and its else half when not.