Page Variables

Register an Account
Pligg Chat Room
 
 
LinkBack Article Tools Display Modes
  #1 (permalink)  
Old 08-13-2008, 03:59 AM
Yankidank's Avatar
Pligg Founder/Coder/Designer
Pligg Version: SVN
Pligg Template: Wistie
 
Join Date: Dec 2005
Location: Ocala, FL
Posts: 3,800
Send a message via AIM to Yankidank Send a message via Skype™ to Yankidank
Reserved for future media.

Now Available: Facebook Connect Module !

Last edited by Yankidank; 08-13-2008 at 04:16 AM.
Reply With Quote
  #2  

Page Variables

What are Page Variables?


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:
// 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.

Code:
{if $pagename eq "story"}
Content to show if it IS a story page
{/if}
Code:
{if $pagename neq "story"}
 Content to show if it's 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.
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.
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.

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.
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)


Contributors: Yankidank
Created by Yankidank, 08-13-2008 at 03:59 AM
Last edited by Yankidank, 06-24-2009 at 03:29 PM
1 Comments , 3317 Views
 

Article Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a Digg-style FAQ page with JavaScript and jQuery mendim Questions and Comments 21 03-04-2010 12:23 AM
Page Title - Instant Need plum Questions and Comments 6 11-16-2009 04:35 PM
Story summary variables different on front page to actual story page innesb Questions and Comments 1 06-11-2009 06:03 AM
Voting works on page 1, not page 2 jrothra Questions and Comments 3 08-02-2007 12:45 AM
Add page nav number to top of page kanedaguy Questions and Comments 1 02-03-2007 11:31 AM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development