Create CMS Website

Protected pages

The Beginner's Tutorial
How To Create Own Website with CMS Made Simple

Create protected pages

Protected pages can be viewed only by registered members and as you have already installed membership management module you can proceed with creating protected pages.

In some modules, like Forum Made Simple the protection is built in automatically so that different content is displayed dependent on whether the user is logged in or not. For the normal content pages you have to install additional module called CustomContent. Go to Extensions → Module Manager and select on the tab for available modules the letter "C", look for the module CustomContent and click on "Download & Install". The module is installed.

Now, create a new content page that can be only viewed by registered members. Go to Content → Pages and click on "Add New Content". Add the content that has to be only available to the registered users. It is an ordinary page and the only slight difference to other pages is set on the Option tab. The page should not be cachable!

Non-cashable page

Save the page. As expected it can be viewed for all visitors now. To make protection of the pages simple in the admin panel go to Content → Global Content Blocks and click on "Add Global Content Block". In new content block will be checked if the user is registered or not. If not the page is immediately redirected to the page with login form, so that not registered user has no chance to see the content.

In the content field switch of WYSIWYG editor first, then copy the line below into the field:

{if empty($customcontent_loggedin)} {redirect_page page="login"} {/if}

Pay attention to the page alias where the visitor is redirected if he is not registered. In my example, the login form created in the last step is placed on the page with alias "login". If your page with the login form has another alias you have to change it in the code line above. Before save your new global content block looks like this:

Protected pages

Press "Submit". In the list of global content blocks you can now see the new content block created. In the second column you see the "Tag to Use this Block". Now in every page that you would like to protect you have to add this tag in the first line of your content. Open the page you would like to protect and add the tag at the first line:

Protect page

Test it now. The page can be only displayed if you are registered and logged in, if not the login form is displayed. From now for every page you would like to protect add the tag above at the first line of the protected content.


Comments to "Create protected pages"

  1. cray December 18, 2010, 7:12 am

    for my site, I had to change the line
    {if empty($customcontent_loggedin)} {redirect_page page="login"} {/if}

    to

    {if !$ccuser->loggedin()}{redirect_page page='login'}{/if}

    in order it right


del.icio.us digg stumbleupon buzzup BlinkList mixx myspace linkedin facebook reddit.com ma.gnolia.com newsvine.com furl.net google yahoo technorati.com

CMS Made Simple Beginner's Guide
Loading...