This topic is locked
[SOLVED]

 hide data dependent on database value

5/14/2008 10:57:46 PM
PHPRunner General questions
W
willjob author

I am setting up a site that displays user's profiles with data including name, email, phone, address, interests, summary of background, etc. I have set a field in the database to keep the users contact info confidential to yes or no. If set to yes then the users name, email, phone, and address is displayed as confidential while showing the rest of the information and if set to no then it simply displays it.
Question is how can I do this within PHPRunner? My first thought is to set an event before view and then use smarty to block or show the contact info. I have searched the smarty site and docs but do not have a clue how to do this. Any ideas in detail how to make this work?
Thanks
Tripp Castell

Alexey admin 5/15/2008

Tripp,
the easiest way to achieve this is to modify your SQL query.

Add some calculated fields to it:

select

...

(case when hide_details=1 then '' else email end) as view_email,

(case when hide_details=1 then '
' else address end) as view_address

from ...



where hide_details, email and address are your actual field names.
Then proceed to the Choose fields tab in PHPRunner and choose to display view_email, view_address etc fields on the View, List and other pages instead of emailand address

W
willjob author 5/15/2008

Worked like a charm!
THANK YOU!