$PAGE
Overview
The page object is accessed using the $PAGE variable. This object contains information pertaining to the current network level page or user or group page.
Common Uses
Here are some common ways the $PAGE object is used.
Logged In State
1 2 |
$PAGE->UID will be true if the user is logged in, or false if they're logged out {if $PAGE->UID} Welcome back, {$VIEWER_PROFILE->name}! {else} You should signup! {/if} |
Show a Warning
The ‘alert’ method allows you to show a note in the common DIV at the top of the page.
1 |
{if $ohNo} {$PAGE->alert('Whoops! What did you do?!?', 'warning', 'block')} {/if} |
Attributes
Variable | Description |
---|---|
NODE_ID | The numeric id for the current node of the social network |
NETWORK_ID | The numeric id for the current network of the social network |
BLOG_ID | The numeric id for the current user/group site on the network |
UID | The numeric id for the logged in user, or 0 for logged out users |
ORIGIN_URL | The requested URL (i.e. www.domain.com/user/blog?value=1) |
CURRENT_DOMAIN_FULL | www.domain.com |
CURRENT_DOMAIN | domain.com |
CURRENT_SITE | domain.com/subdirectory |
CURRENT_SITE_URL | www.domain.com/subdirectory |
CURRENT_REQUEST_URI | http(s)://www.site.com/go/page/current |
NODE_HOME | domain.com |
NODE_NAME | The name of the current node |
NETWORK_NAME | The name of the current network |
BLOG_OWNER | The numeric id for the user who owns the current site |
SUBDIR | subdirectory |
TIERS | The numeric id (or CSV string) of the tiers the current site is in |
IS_HTTPS | Is the page loading on a secure connection. |
SESSION_ID | The unique session identifier for the page viewer |
IS_FRIEND | 1 if the page viewer is friends with the page owner, 0 if otherwise |
IS_GROUP | 1 if the page is a group, 0 if otherwise |
USER_RELATION | owner, moderator, group_member, friend, member, or non_member |
CLIENT_VERSION | The version id of the site itself (used for breaking the CDN cache of all user facing resources such as CSS, Javascript and images) |
CURRENT_VERSION | The version id of all static resources (used for breaking CDN cache) |
LANG | The language of the currently browsing user |
Page Control Methods
Adjusting Meta Information
1 2 3 4 5 6 7 8 |
{$PAGE->add_constant($name, $value)} {$PAGE->add_javascript($js_array, $cache_bust)} {$PAGE->add_css($css_array, $cache_bust)} {$PAGE->set_title($title)} {$PAGE->set_sub_title($sub_title)} {$PAGE->add_head_html($html)} {$PAGE->set_body_id($body_id)} {$PAGE->set_body_class($class_name)} |
Important: If you put in the values directly, you must wrap them in quotes.
1 2 |
{$PAGE->add_constant('A_NAME', 'A VALUE')} {$PAGE->set_sub_title('A Sub Title')} |
Page Code
1 |
{page_code name=page_code_name} **You should always send a name to your page code!** Here is my page code stuff. {/page_code} |
Note: you cannot use a variable to define the page code name.
1 |
{* does not work *}{page_code name=$pc_name} |