Code Generator > List Page: see only the records created by the user
I have created the List page of a section with the code generator tool and made all the additions described in the Website Membership plugin so that each user should log in to have access to this page. And this works fine. So when a user logs in with his username/password he/she has access to this specific section list page. However, he/she has access to the full set of records and not only to those records he/she has created. This is something I want to avoid as each user should have access only to his/her records.
Can you give me some hints on how to carry on? (Just to remind that each user can have one of three different distinct types of access to records - own, hospital, all-).
And an extra question. As this List page will contain a very large number of records, how could I add a search tool (either at the beginning of the page or on a different page) to filter the retrieved records according to some criteria?
I've not tried this myself, but the last post on the following forum thread might help.
Looks like basically this might do it:
'where' => mysql_escapef('createdByUserNum = ?', $CURRENT_USER['num']),
Thank you for your reply.
It seems it works.
// load records from 'aortic_aneurysm_disease' list($aortic_aneurysm_diseaseRecords, $aortic_aneurysm_diseaseMetaData) = getRecords(array( 'tableName' => 'aortic_aneurysm_disease', 'perPage' => '10', 'loadUploads' => false, 'allowSearch' => true, 'where' => mysql_escapef('createdByUserNum = ?', $CURRENT_USER['num']), ));
What about a search query to search within the file?
Unfortunately, I have not been able to manage it as I expected. I am thinking of adding some PHP code inside this list-page (already filtered to contain only records created by the logged in user) that will allow users to search within it using various criteria. Is there some code available?
There's some examples here for creating search fields: https://www.interactivetools.com/docs/cmsbuilder/viewer_search.php
What fields do you want to search on and what do you want it to look like?