Portal Engine
Version 3.x > Portal Engine > Repeater with Custom Query question View modes: 
User avatar
Member
Member
neil-fourmangos - 10/23/2009 7:43:28 AM
   
Repeater with Custom Query question
hi,

I have a user who has a specific "role" and a specific numeric value that is populated automatically in a custom column in the user table.

I have a site with many members - some who might have a value in the custom column and some who will have a null value in that column.

I'd like to display content specific to the value in that custom column.

This all sounds easy and I think I'm on the right path here.

I created a repeater with custom query and I'm trying to get the where clause so that it says something like "Where user.customcolumn is not null". If that works I'd like to do another custom query with a where clause that reads "where article.agencyid = user.customcolumn"

Can I do this out of the box with the repeater query or do I have to do something a little more custom with a new web part.

Thanks!

User avatar
Member
Member
neil-fourmangos - 10/23/2009 7:56:42 AM
   
RE:Repeater with Custom Query question
Update - I just realized how I failed on my logic there.

Okay so updated question.

User logs into site - they have a certain value in their user table that is a custom value.

Can I use that in my query where statement so that the viewer shows all articles which pertain to that specific user? I'm assuming the answer is "yes".

-Neil

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 10/27/2009 5:26:01 AM
   
RE:Repeater with Custom Query question
Hi Neil,

you can use following macro to get value of custom field of 'User' system table for current user in WhereCondition property of repeater (you can use it both in CMSRepeater and QueryRepeater web parts):

{%currentuser.NameOfYourCustomField%}

Best Regards,

Martin Dobsicek

User avatar
Member
Member
neil-fourmangos - 10/30/2009 7:07:02 PM
   
RE:Repeater with Custom Query question
Okay clearly doing something wrong here.

In my WhereCondition section on the web part (as in go to configure on the web part and go to the Where box) I have {%currentuser.StateAgencyId%}

In my Select query I have the following:
SELECT CMS_stateagencycontent.*
FROM CMS_stateagencycontent
WHERE cms_stateagencycontent.stateagencyid = ##WHERE##

I don't think I'm using the Where properly.

I'm using version 3.1a fyi.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 11/3/2009 9:07:47 AM
   
RE:Repeater with Custom Query question
Hello,

Regrettably, custom fields are not supported in macros in version 3.1a. I would recommend upgrading to latest version or version 4.0 at least.

Also the where condition should be specified in your query this way:

SELECT CMS_stateagencycontent.*
FROM CMS_stateagencycontent
WHERE (##WHERE##)


And then you should specify whole condition in 'WhereCondition' property:

cms_stateagencycontent.stateagencyid = {%currentuser.StateAgencyId%}

Best Regards,

Martin Dobsicek