Page variables are used to define what page a user is on. Variables are used in Pligg templates to determine whether or not you should display content by using {if} tags, this method is similar to many programming languages such as PHP.
Pagename variables are defined in .php files to determine what page you are currently viewing. If you open up index.php, for example, you will find the code below which assigns the pagename variable "index" and "published" to the Pligg published pages (homepage).
PHP Code:
PHP Code:
// pagename
define('pagename', 'index');
$main_smarty->assign('pagename', pagename);
Below are example codes that you can use with these variables, in these examples "story" is the page name that can be replaced with one of the variables listed lower on this page.
PHP Code:
{if $pagename eq "story"}
Content to show if it IS a story page
{/if}
PHP Code:
{if $pagename neq "story"}
Content to show if its NOT a story page
{/if}
Advanced Pagename Use
To shorten the amount of code needed you can use this more advanced method for specifying AND (represented by && ) and OR (represented by || ). By using these symbols between pagenames you can combine them in a variety of ways, for example the code below will show the content on BOTH upcoming and published pages by using the || symbols to combine the rules. I then will use {else} to display the content after that on any pages that don't match the pagename criteria.
PHP Code:
{if $pagename eq "upcoming" || $pagename eq "published" || $pagename eq "index" }
Content that goes on BOTH the upcoming AND published pages.
{/else}
This content will only go on pages that ARE NOT upcoming and published pages.
{/if}
In the below example I will demonstrate content that will show on the story page BUT NOT on the live page.
PHP Code:
{if $pagename eq "story" || $pagename neq "live"}
Content to show on a story page, but not on a live page
{/if}
In this final example I am going to make use of the AND symbols, meaning that the page would have to qualify as BOTH variables. Because you can't have 2 pagenames on the same page (it will cause the pagename variable to become blank if there is more than 1) I will be using a combination of pagename AND modulename variables. Modulenames operate in the same fasion as pagenames, but are applied to modules.
PHP Code:
{if $pagename eq "register" && $modulename eq "captcha"}
This content will only show if you are on the registration page and the captcha module is enabled
{/if}
My final example is probably the most popular, this code will demonstrate how to only show something on the index.php homepage.
PHP Code:
{if $pagename == 'index' && count($templatelite.get) == 0}
Homepage Content
{/if}
Pligg Page Variable List
Below is a list of variables that can be used to define the page. Next to each variable is an equal sign ( = ) followed by a description. Typically variables are identical to the name of the php file they are declared in. There are only a few examples that contradict this pattern, including the user.php and index.php files.
- admin_index = Main Admin Page
- cloud = Tag cloud
- edit_page = Editing a Page
- editlink = Editing an Article
- groups = All Groups list page (groups.php)
- group_story = A specific group's upcoming, published, shared and member pages.
- live = Main live page (live.php)
- live_comments = Comment live page
- live_unpublished = Unpublished live page
- live_published = Published live page
- login = Log in page (login.php)
- profile = User profile page (profile.php)
- register = Registration page (register.php)
- search = Search Results (search.php)
- story = Story page (story.php)
- submit = Submission pages (steps 1-3) (submit.php)
- tools = ?
- topusers = Top User page
- user = User profile page when logged in and able to modify (user.php)