Conditional additions to a detail page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: November 24, 2010   (RSS)

By steve_e - November 16, 2010

I'm trying to create an 'articles' section, where some visitors will have access to the articles and others will not, depending on whether they belong to certain categories of membership (which is all specified within some forum software which pretty much controls our site).

So the way we do this at present is to have the whole page consisting of an if-then-else PHP statement:

"If this person is logged in and falls into this category of member, then generate the whole of the rest of the page (the article), otherwise re-direct to an apology page"

I'm having trouble fitting this into the CMS-B system, but hopefully I'm just not seeing it right. What I'd like to do is have the person preparing the article be able to select from a drop down, 'Visitor's article' or 'Member's article', and for the page to be generated with or without the PHP if-then-else code at the top and bottom of the detail page.

Is it possible to do that?

Regards, Steve

Re: [steve_e] Conditional additions to a detail page

By Jason - November 16, 2010

Hi Steve,

Yes, this shouldn't be a problem. You can put this drop down in your article section. I'm assuming that if it's a "Visitor's Article" then anyone can see it (ie, no check necessary) and if it's a "Member's Article" you need to see if the person logged in has the appropriate permissions.

Since I don't know how your forum software works, I can't give you a specific example, however, it would probably work something like this:

<?php

if($record['article_type']=="Member's Article"){
//Check if user can view the article.
//If "Yes" then dispaly
// else, redirect.
}
else{ //Visitors article, display normally
}
?>


Hope this helps get you started. Let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/