Excluding (hiding) content based on URL parameters

Permalink
Hi guys, I have 2 main questions:

1.) Can I use C5 to hide content (pages, blocks and search results) from visitors that access the site through a URL that contains a parameter.
e.g. www.mysite.com?group=pear


2.) Can I create a single block of content that I distribute throughout the site on multiple pages, where if I edit it once, it updates all the instances?

Here is my simplified explanation of what I would like to accomplish. I'm trying to determine if C5 is able to handle these requirements.

### Simplified Explanation ###

Lets say I have a web site that displays recipes for baking pies. The audience for this site is broken up into groups:
- apple pie lovers
- pear pie lovers
- strawberry pie lovers
etc.

The groups do not have a login or account, nor would they ever. They can however, access the web site by clicking a link with a URL that contains a parameter that identifies the group they are in:
www.mysite.com?group=pear


Now, most of the instructions for baking any type of pie is the same. There are only a handful of differences that pertain to adding the main ingredient. I would like to reuse as much information as possible without retyping it for every pie filing type. (see question #2 above).

I would like to be able to use blocks that can be edited at a central source and have all instances update. For example, if I choose to change the temp of the oven in one instruction, it should cascade to all filling type instruction pages.

Now, the other quirky thing about this site is that the groups are mutually exclusive. They love their preferred type of pie and would never, ever want to see information about any pie other than their preferred favorite. Like I said, they're quirky.

Now I should clarify that this is not a security issue. It wouldn't be the end of the world if pear lovers discovered the instructions for making an apple pie. Or if they accessed that information by simply changing or stripping out the parameter in their URL.

That said, it would be helpful if pear lovers could come to the site with a url parameter identifying them as part of the pear group, and subsequently only have them see pear pages, and pear related search results with no other filling option presented to them.

Is this possible?

 
Juha replied on at Permalink Reply
Juha
For number 2, you can do this:
<?php $area = new GlobalArea('My Global Area'); $area->display($c); ?>


Though I'm not sure if you can use it quite the way you intended.

For number 1 I'm not quite sure if there is a NATIVE way to do it in Concrete5, but you CAN do it. For example (untested, may contain typos):

<?php
// No group by default
$group = null;
// Groups that actually exist. Prevents people from passing
// silly things in the url. You can fetch this from somewhere else, of course.
$validGroups = array( 'pear', 'apple', 'strawberry' );
// Check if a valid group is already in the session variable
if ( !isset( $_SESSION['group'] ) || !in_array( $_SESSION['group'], $validGroups ) ) {
   // If not, reset it and check if it's in the URL
   $_SESSION['group'] = null;
   if ( isset( $_GET['group'] ) && in_array( $_GET['group'], $validGroups ) ) {
      $group = $_GET['group'];
      $_SESSION['group'] = $group;
   }
} else {


There may be native ways to access session variables and url parameters in Concrete5, I haven't really looked into it so I'm not sure.
tpalombo replied on at Permalink Reply
Thanks for the reply Juha.

I appreciate the response.

Thanks!
Juha replied on at Permalink Reply
Juha
Just a word of caution: I'm not sure how well this plays with Concrete5's caching. It is possible that C5 may ignore the url parameters and fetch the page from cache in some cases, meaning that someone accesses the page via ?group=pear but still gets the raspberries because C5 considers them a same page.