glFusion Wiki

Site Tools


glfusion:staticpages

Static Pages (also Known As Pages)

The Static Pages plugin allows you to do all sorts of things from creating a static page to embedding auto tags and PHP to create very flexible pages.

Features include:

  • Can allow PHP to be used on the page
  • static pages can be displayed on glFusion's index and topic pages and can even replace it entirely (“splash screen”)
  • makes use of glFusion's URL rewrite feature -
  • Provides [staticpage:] and [staticpage_content:] auto tags
  • Supports glFusion's security / permission model to allow and restrict access based on permissions
  • Can create menu entries

Pages give you the flexibility to create almost anything you can imagine when it comes to a web page. It can be as simple as presenting some text to your users, or it can be as complex as combining Media Gallery images with text, video, story content, blocks, etc. An excellent example of how you can bring multiple types of content together is the glFusion Dashboard Page (https://www.glfusion.org/page.php/dashboard). Here we bring in the Forum center block, recent news, with a few blocks on the right hand side of the page. Through the combination of a little HTML and glFusion auto tags, we merged content from several sources into our dashboard.

Creating a Page

You begin the Pages Administration screen located in Command & Control. Here you see the list of current pages, with the ability to create new or edit existing pages.

To create a new page, select the Create New menu option.

The Pages Editor provides a tabbed interface, where you can enter the content, set specific attributes for the page, setup whether the page should be a center block and control the permissions.

The initial tab - Page Editor is where we enter our page content.

Page Editor Tab

Title
Every page must have a title. The title isn't always displayed - we'll look into this further when we review the Centerblock tab
ID
Every page must have a unique ID. The ID is how you reference the page.
When creating a new static page, it will be assigned a page ID automatically. This ID consists of the date and time and up to three random digits. You may want to change this automatic ID to something a bit more user friendly.
The static pages editor will let you change the page ID. For example, you may want to rename the ID for your “about” page from “20030313100131123” to “about”, thus creating a URL like:
http://www.yourdomainhere.com/page.php/index.php?page=about
which looks much nicer when quoted (and is easier to remember). You could further improve this by making use of glFusion's Enable URL Rewrite feature.
There are some rules on the ID format:
  • IDs must be unique
  • IDs cannot contain spaces - if you enter spaces in the ID, they will be removed automatically when you save
  • IDs should not contain special characters such as *, !, quotes (both single and double), parenthesis
  • IDs can contain underscores (_) and dashes (-)
Enabled
This controls whether the page is active or not. If a page is not enabled, you cannot view it outside of the administrative interface. Think of this as a draft flag - if not enabled, it is considered in draft mode and not published.
Page Content
Here is where you enter the content of the page. It can contain text, HTML, PHP (if configured), images, auto tags, etc. There are 2 types of editors available for creating your content. Which one you use really depends on what you are creating.
HTML Editor
This is a text based editor where you can have full control over what the page will contain. This is the default mode. It allows you to enter HTML directly, so you have full control over the layout. It allows you to enter PHP (if allowed). You can enter pretty much anything you want using the HTML editor.
Visual Editor
This is the WYSIWYG (What You See Is What You Get) editor - similar to a word processor. The visual editor is great for creating text based pages. For example, every glFusion site has a standard Terms of Use page and a Privacy Policy page. The visual editor is perfect for editing these pages since they only contain text, no embedded HTML or PHP code. With the visual editor, you can include images and auto tags.

NOTE: The Visual Editor will filter out or modify any embedded HTML code. Since the Visual Editor is in full control over the behind the scenes HTML, if you create a page with the HTML Editor and later edit it with the Visual Editor, it is possible the Visual Editor might reformat or remove some of your embedded HTML. You cannot enter PHP code using the Visual Editor.

Attribute Tab

The Attributes tab allows you to control certain behaviors of the page. For example, you can control whether the navigation blocks are displayed (the right blocks in the CMS theme). Whether you allow comments, etc.

Page Format
This controls what blocks are displayed when the page is viewed. You can have just the Navigation (left) blocks display, both right and left or no blocks.

NOTE: This setting is ignored if the page is setup to display as a 'center block' or displayed as an auto tag.
Mode
Controls whether comments are enabled, disabled or closed.
Make Searchable
If this options is not selected (not checked), the contents of this page will not be included in any search results. Many times we may use a static page as a splash page, or content for other pages, so having them show up in search results would not be appropriate.
Add to Menu
If you have a Menu Element setup in Menu Builder for StaticPages, by checking this box, this page will be one of the menu options displayed in that menu. You must have a menu element setup on one of your menus with the following attributes:
  • Type: glFusion Menu
  • glFusion Menu: Static Pages Menu
As of glFusion v1.6.5, the default behavior is to not include pages with Add to Menu enabled to display on the Plugin Menu, they will only display on the Static Page Menu type. If you want to have the pages also included on the Plugin Menu (as they used to), you can set $_SYSTEM['sp_pages_in_plugin_menu'] to true in siteconfig.php.
Label
The menu label to use when Add to Menu is enabled. This field is disabled if the Add to Menu option is not checked.
PHP
This controls how this page should handle PHP.
  • Do not execute PHP - any embedded PHP code will be displayed as text
  • Execute PHP with a return - glFusion expects the 'output' to be returned (as opposed to echo'ed to the screen). glFusion will then handle displaying the output to the browser. An example would be where you build the page using PHP code and the final statement is return $content;
  • Execute PHP - This will execute the PHP code on the page, expecting the PHP code to display the content to the browser - for example using PHP echo statements or print statements.
For a more in-depth look at how to use PHP with Pages, see the PHP section below.

Centerblock

The Centerblock tab controls whether the page will be displayed as a center block. It also has a few other settings that control page display both when used as a center block and in general as well.

Centerblock
When checked, this Page will be displayed as a center block on the index page. An example of how a center block can be used is to create a Splash area on a page. The main page at glFusion.org uses a Static Page as a center block to display the Gears image with the intro text and the links to the download and demo.
Position
This controls where the center block is displayed. This setting only applies if the Centerblock option is checked. Options include:
  • Top of Page - Display before any other content (but after the main navigation area)
  • After Featured Story - The featured story will display first, then the static page. If there is no featured story, the page will display at the top.
  • Bottom of Page - Will display after all other content, but before the footer area.
  • Entire Page - will replace all other content and display between the header / footer
  • Only if No Other News - Will display only if there are no stories to display
Topic
Restrict the display of a page to only a certain topic, the homepage only, or all pages (i.e. all topic pages and the homepage). This is the same as the options you have for blocks.
Wrap in a block
This setting applies regardless of the Center Block setting. It controls whether or not the page content is wrapped in a glFusion start / end block HTML. This also determines if the title is displayed. When wrapped in a block, the title will display. If not wrapped, no title.
Help File URL (Depreciated)
You can specify a URL to another page that would provide additional information. This page will be linked on the static page with a small ? icon. This is generally not used any longer.

Access Rights

The Access Rights tab controls who has the ability to see and edit this specific page. It also sets things like the author and the owner.

Author
This is the user that is credited as being the Author of the page. It does not control any access.
Owner
This is the user that is the owner of the page. Owner's always have full read / write / delete access to the page.
Group
Specifies the group ownership of the page. Group ownership may or may not have edit capabilities, depending on how the access matrix is configured. Groups can also be used to control who can view the page.
Exit Type
This field controls whether a user who does not have permission to see the page will be presented with a Not Found error message or a You Must Login message. If this is checked, a user that does not have permissions to see the page will be asked to login as a user with the proper permissions. A good example of when to enable this setting is if you have a page that is only available to Logged In Users. You could check this option and when a anonymous (not logged in) user navigates to the page, they will get a login prompt.
Permissions
The standard glFusion Permission matrix that defines what capabilities a:
  • Owner of the Page
  • Members of the Group that is associated with the page
  • Logged in Users (Members)
  • Anonymous Users (Not Logged In)

Using PHP in Pages

There is a security feature in glFusion where you can globally disable the use of PHP in pages. If you allow non-trusted or non-admin users the ability to create or edit pages, you may consider disabling PHP execution.

On a standard glFusion Installation PHP execution in Pages is enabled.

Enabled / Disabling PHP Execution in Pages

PHP execution in Pages is enabled or disabled based on whether the 'staticpages.PHP' right is assigned to the Static Pages Admin group. You can change this assignment in the Group Administration section.

To allow PHP use to all users who have permission to create and edit static pages, you will need to add the 'staticpages.PHP' permission to the “Static Page Admin” security group. To do so, first make sure you are logged in as Admin (or as a user with Root access). Click on the “Groups” icon in Command & Control. Find the “Static Page Admin” group and edit it by clicking on the pencil icon to the left of the group name.

At the bottom of the page, you will find a list of “Rights” (permissions) that can be granted to all members of this group. Note that 'staticpages.delete' and 'staticpages.edit' are checked, while 'staticpages.PHP' is not checked. To allow members of the Static Page Admin group to use PHP in static pages, you will have to check the 'staticpages.PHP' checkbox and save your changes.

If you have several users who will be editing static pages but do not wish to grant PHP access to all of them, you can accomplish this by creating a new security group with PHP permissions. From the Admin's Only block, select “Groups” (or click on the “Groups” icon in Command & Control). Click “Create New,” then enter a group name (for example, Static Pages PHP) and a short description. Select the 'staticpages.PHP' permission under the Rights section, and then click “Save.”

As the Admin user, you will automatically be added to the new Static Pages PHP security group and will be able to use PHP in static pages. Any user you add to the Static Pages PHP group you created will also be granted access, while other users who simply have Static Page Admin rights will still have PHP usage disabled.

In addition to the 'staticpages.PHP' permission discussed above, there is also a global option to disable the use of PHP in static pages entirely. That option “Allow PHP?” can be found in the Command & Control → Configuration → Static Pages configuration page. When set to “False”, that option will override the 'staticpages.PHP ' permission and disable all use of PHP in static pages.

Entering PHP in Pages

The use of PHP has to be enabled for each individual static page. Under the Attributes Tab, you will find the PHP field with a drop-down menu with the following options:

do not execute PHP
When you select this option, any PHP code in the static page will not be executed but will instead be printed out as-is.
execute PHP (return)
If you select this option, PHP code in static pages will be executed. The 'return' indicates that the code should return any output it generates, using a PHP return statement, instead of printing it out directly.
execute PHP
This option will enable execution of PHP. Only this time, the PHP code can actually use echo and print statements without having the output interfere with the page layout. This allows switching back and forth between PHP and (x)HTML.

Please note that when embedding PHP code in a static page, your code should not be enclosed in the PHP <?php and ?> tags. Instead, it is assumed that the static page contains the PHP code that would normally go between those two tags.

When selecting “execute PHP” you can switch back and forth between PHP and plain HTML like this:

echo "Hello"; ?>, <b>world</b>, <?php echo "how are you?";

The above example would print out “Hello, world, how are you?”.

Using Static Pages on the Index Page

glFusion's center blocks concept allows plugins to place blocks in the center area of a glFusion site, (i.e. among the stories).

When you check the “Centerblock” option for a static page, you can use the “Position” and “Topic” drop-downs to choose where this static page will be displayed. For “Position”, the options are “Top Of Page”, “After Featured Story”, “Bottom Of Page” (which should be self-explanatory) and “Entire Page”. That last option, “Entire Page”, will tell glFusion that this static page will replace the entire index page - it will not display any stories, but only the contents of this static page. This is useful for “splash” screens or Welcome pages.

When using a static page as a “splash” screen, you may need a link that takes your visitors to the normal index page, (i.e. the list of current stories). To do this, create a link to http://yoursite/index.php?display=all

The second drop-down, “Topic”, lets you restrict the display of a static page to only a certain topic, the homepage only, or all pages (i.e. all topic pages and the homepage). This is the same as the options you have for blocks.

You can combine these options with the permission settings. For example, this will let you create a “welcome” page that is only displayed to anonymous users.

Cloning Static Pages

When you have a lot of similar static pages you may want to make a copy of an existing page and then edit that copy. This can easily be done by clicking on the [C] from the list of static pages. Doing so will create a copy of that page with a new page ID.

Deleting Pages with their Owner

As with all objects in glFusion, static pages have an owner (the user that created the static page). When that user's account is deleted for some reason, any static pages owned by that user can either be deleted as well or they can be assigned to another user in glFusion's Root group.

In the Configuration admin panel for the static pages plugin, you can set the “Delete Pages with Owner?” option to either “False” (which is also the default), meaning that static pages will not be deleted with their owner, but assigned to a member of the Root group instead (the user with the lowest user ID, most likely the Admin). Setting the option to “True” means that static pages will be deleted when their owner's account is deleted.

Auto Tags

The Pages plugin provides 2 auto tags; staticpage and staticpage_content.

staticpage
Displays a link to a static page. The link text will be the static page title if not specified with the auto tag.
staticpage_content
Displays the content of a static page

staticpage auto tag

To provide a link to a static page, you can use the [staticpage:#ID# Link Text] auto tag. This will simply create a link the the static page with the ID specified. The Link Text can be omitted and the static page title will be used. For example:

Follow this link to see our [staticpage:terms-and-conditions Terms & Conditions].

This will print Follow this link to see our Terms & Conditions

staticpage_content auto tag

This auto tag allows you to embed the contents of a static page into other content. For example, you might have a standard disclaimer you put on all your stories. You could create a static page with the disclaimer text and the use:

[staticpage_content:disclaimer]

At the end of each story. This would embed the contents of the Static Page with ID disclaimer into the story.

glfusion/staticpages.txt · Last modified: 2017/04/12 21:09 (external edit)

Page Tools