Adding list of records to “User” section

15 posts by 3 authors in: Forums > CMS Builder
Last Post: September 21, 2011   (RSS)

Re: [nmsinc] Adding list of records to “User” section

By gkornbluth - September 18, 2011

Hi nmsinc,

Could you be a little more specific about what you're actually trying to do?

Thanks.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Adding list of records to “User” section

By nmsinc - September 19, 2011 - edited: September 19, 2011

Hi Jerry,[/#000000]

[/#000000]

I have a listing page that I want to sort records based on a preference that I will set up in the USER section if it is permissible to do so. My concern is, I do not want to set this preference up if it will cause problems to the USER section![/#000000]

[/#000000]

Thanks[/#000000]

Ray[/#000000]
nmsinc

Re: [nmsinc] Adding list of records to “User” section

By gkornbluth - September 19, 2011

Hi Ray,

That shouldn't be a problem.

Do you mean sort ( which group of records displays first) or filter (Show different records for different groups of users)?

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Adding list of records to “User” section

By nmsinc - September 19, 2011

Filter!
nmsinc

Re: [nmsinc] Adding list of records to “User” section

By gkornbluth - September 19, 2011

Hi Ray,

This is a fairly standard implementation of the website membership plugin.
http://www.interactivetools.com/add-ons/detail.php?Website-Membership-1012

Here's the excerpt from the readme for that plugin.

- You can access the current users login record in the $CURRENT_USER variable on
any page that calls viewer_functions.php. To see what fields are available use
this debug code: <?php showme($CURRENT_USER); ?>

- This allows you to show content based on the current users record values. For
example, if you had a user field called 'premium', and some users had that field
checked, you could show different content to them with this code:
<?php if ($CURRENT_USER['premium']): ?>
Only premium members would see this.
<?php endif ?>

The field in the user account record can be either a single value pull down or radio button list field.

That field can get its values (num) and labels (title) from another multi-record table that has only one field called "title" if that's more convenient. Just use the advanced options to get list values from database when you set up the list field in the user accounts editor and choose the 'num' field for option values and the 'title' field for option labels.

In your viewer, if you want to display the titles you'll have to add :label to the echo code. So if the list field in the 'accounts' table was called 'allowed' you'll have to add ['allowed:label'] or all you'll echo is the record number.

Hope that points you in the right direction.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Adding list of records to “User” section

By nmsinc - September 19, 2011

Hi Jerry,[/#000000]

[/#000000]

I have created a new field within the User Section and will populate it from values (num) from another multi-record table – see below:[/#000000]



Table(1) = records of “users” that now includes a choice from Table(2) value(num)



Table(2) = records of “company names and addresses”



Table(3) = records that include a choice from Table(2) value(num)



Using a listing page, how would I use the “Membership” plugin to restrict listing of records in Table(3) to those that only match the new field value(num) in Table(1)?[/#000000]



Thanks

Ray
nmsinc

Re: [nmsinc] Adding list of records to “User” section

By gkornbluth - September 19, 2011

Not sure, but have a look at this post

http://www.interactivetools.com/forum/gforum.cgi?post=61466#61466

It might give you some ideas.

There have been many posts on searches searches in multiple tables

There's also relatedRecords that are worth searching through.

Good luck,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Adding list of records to “User” section

By nmsinc - September 19, 2011 - edited: September 19, 2011

Hi Jerry,

That thread did not help - anyone else with any ideas?
nmsinc

Re: [nmsinc] Adding list of records to “User” section

By Jason - September 20, 2011

Hi,

So to make sure I understand, your "Table 1" is the user accounts table. It has a field that takes a value from Table 2 (company table). And Table 3 also has a field that takes its value from the company table. You want to then get all the records in table 3 where the table 3 field has the same value as the field in the accounts table. Does that sound right?

If so, once the website membership plugin is installed and the user is logged in we can use the $CURRENT_USER array to find the value of the field in accounts table. Here is an example of what we can do.

Because I don't know the names of all your fields/tables, I'll have to make some assumptions. Let's assume that table 3 is called "listings". Let's also assume that the field that is in both the accounts and listings tables that comes from the company table (table 2) is called "company".

Assuming this, we can get a list of all listings where the company field matches the company field in the accounts table like this:

list($listingsRecords, $listingsMetaData) = getRecords(array(
'tableName' => 'listings',
'allowSearch' => false,
'where' => "company = '".intval($CURRENT_USER['company'])."'",
));


Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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