[SOLVED] Formbrowser output filtered by logged in Front End User

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
tosd
Forum Members
Forum Members
Posts: 52
Joined: Thu Jan 11, 2007 1:02 am

[SOLVED] Formbrowser output filtered by logged in Front End User

Post by tosd »

Hello all,

I am using CMSMS v 1.7.1, Formbuilder v 0.62 and Formbrowser v 0.3. I have set these up along with the Frontend Users and Custom Content modules and they are working well together. Many thanks to those involved in the module developments, they give CMSMS amazing flexibility.

I have set up one common form that all fe users access, with the results stored in a common Formbrowser table. This is working nicely.

However, I need to display the results to logged in users (on the Front End) using the {FormBrowser browser='myform'} tag, but each user must only see their own records.

I have scoured the forum and found others with a similar need, but I can find no clear resolution. Is this possible? If anyone can help I would be very grateful . . . and I think a few others might be also. It would seem to be a reasonably common need.
Last edited by tosd on Thu Aug 12, 2010 12:39 pm, edited 1 time in total.
tosd
Forum Members
Forum Members
Posts: 52
Joined: Thu Jan 11, 2007 1:02 am

[SOLVED] Re: Formbrowser output filtered by logged in Front End User

Post by tosd »

I found the answer to my problem spread across several posts, so I will try and collate it here. There are essentially four steps:

1. I started by fetching the userID
I used a UDT for the fetch {return_feu_uid}

Code: Select all

global $gCms;
$feusers = $gCms->modules['FrontEndUsers']['object'];
if( $feusers )
  {
      $uid = $feusers->LoggedInId();
      $smarty->assign('uid',$uid);
      echo $uid;
  }
2. I created a field in my form called AdvisorID to store the UID of the logged in user. This will be stored in FormBrowser when the form is submitted, along with the other data, and will be user to filter the FormBrowser by Advisor (logged in user).

3. In the page template that called FormBuilder, and the FormBrowser User List report, I have this:

Code: Select all

{capture assign='AdvisorID'}{return_feu_uid}{/capture}
{FormBuilder form='training-register' value_AdvisorID=$AdvisorID }<br /><br />
{FormBrowser browser='training-register-summary'}
Note: the 'value_AdvisorID=$AdvisorID' parameters in the FormBuilder tag preload the AdvisorID field with the users ID

4. I then modified the FormBrowser User list template as follows with the lines marked (new). These added lines extract just those records that match the logged in user's ID

Code: Select all

{foreach from=$list item=entry}
 (new)            {foreach from=$entry->fields item=advisor}
 (new)            {if $advisor == $uid}

		<tr>
			<td>{$entry->viewlink}</td>
			<td width="100px">{$entry->submitted}</td>
			{section name=vals start=0 loop=$count}
{if isset($entry->fields[$smarty.section.vals.index])}
  				<td width="140px">{$entry->fields[$smarty.section.vals.index]}</td>
{/if}
  			{/section}
			{if $allow_user_edit}<td>{$entry->editlink}</td>{/if}
			{if $allow_user_delete}<td>{$entry->deletelink}</td>{/if}
		</tr>
(new)             {/if}
(new)          {/foreach}
	{/foreach}
Note: if you copy and paste remove the (new) indicators.

I don't imagine for a moment that this is an elegant solution (I am not a programmer), but it got me out of trouble and if it can help anyone else then that's great :)
wms
Forum Members
Forum Members
Posts: 204
Joined: Mon Feb 13, 2006 7:26 pm

Re: [SOLVED] Formbrowser output filtered by logged in Front End User

Post by wms »

Hi,

Thanks so much for laying this out like this.  I have to do exactly this.  Get logged in users to edit only their forms.  I'm having difficulty though getting this work.  I show you what I did, and perhaps you can correct the error of my ways.

1) I created the UDT
2) I then created a form field called AdvisorID (in the FormBuilder).  I make that a "User Defined Tag Call" and point it to the UDT just created.
3) This step I'm not too sure, where to put those three lines.  I put it in my page that is calling the form browser??
4) I added the new lines to the form browser user list template.

If you can help me out on step #3, I think this is were I get messed up.

Thanks so much.
wms
Forum Members
Forum Members
Posts: 204
Joined: Mon Feb 13, 2006 7:26 pm

Re: [SOLVED] Formbrowser output filtered by logged in Front End User

Post by wms »

HI,

Does anyone have a solution to this.  I'm trying to filter the formbrowser on the logged in user.  I tried this solution and my formbrowser shows nothing.

Any help would be appreciated.  I'm using the latest versions of everything.

Thanks,
wms
Forum Members
Forum Members
Posts: 204
Joined: Mon Feb 13, 2006 7:26 pm

Re: [SOLVED] Formbrowser output filtered by logged in Front End User

Post by wms »

Ok..I finally figured it out after days of trying.

The steps above worked.  I was just not clear exactly how to go about.  I'll explain what I did in hopes it will help someone else that may be a little less technical at this kind of stuff.

1) Create a User Define Tag as described above
2) Create a text field in your form called:  AdvisorID
3) Create a form builder/browser page as described above (copy and paste that into your page or template)
4) Just add the "new" lines in your user list template of your form browser.

Create a couple of account to test and it should work.

Thank you so much tosd for your post.  This is what I was looking for.  I was trying other solutions out there on the forum, but they were just not working until I found this one.  I'm guessing because the modules have been updated quite a bit compared to the posts I was looking at that were over a year old.
tosd
Forum Members
Forum Members
Posts: 52
Joined: Thu Jan 11, 2007 1:02 am

Re: [SOLVED] Formbrowser output filtered by logged in Front End User

Post by tosd »

Glad you got it sorted out WMS. I found it confusing at first too but it is a very useful thing to get on top of isn't it?
Post Reply

Return to “Modules/Add-Ons”