[Helma-user] Collection items dependent of logged-in user? Not satisfied...

Michael Platzer michael.platzer at knallgrau.at
Mon Aug 28 12:33:13 CEST 2006


Andy Hessling schrieb:
> // from Page's type.property:
> tags = collection(Tag)
> tags.filter.additionalTables = PAGETAGMAPPING
> tags.filter = PAGETAGMAPPING.PageID = ${ID} AND PAGETAGMAPPING.TagID = TAGS.ID
>
> That works all nicely, I can select a Page in JavaScript, and loop
> over its attached tags. Note that Pages and Tags are independent of
> the user, only the PageTagMapping is dependent of it. Now, what I'd
> like to do is to loop over a page's tags that were created by a
> specific user (say, the currently logged-in user):
>
> var samplePage = root.pages.get(0); // get some page
> var samplePageTag = samplePage.tags.get(0); // this works, get the first tag
> var samplePageTagOfCurrentUser = samplePage.currentUserTags.get(0); //
> that's what I'd like to be able to do.
>
>
> so, is there any way to insert a JS variable's content into the
> type.properties file? Like:
> currentUserTags.filter = PAGETAGMAPPING.UserID = ${session.user}
>   
no.

but you could try the following:

// add the following collection to Page/type.properties:
tagsByUser = collection(Tag)
tagsByUser.filter.additionalTables = PAGETAGMAPPING
tagsByUser.filter = PAGETAGMAPPING.PageID = ${ID} AND PAGETAGMAPPING.TagID = TAGS.ID
tagsByUser.group = PAGETAGMAPPING.UserID

// and then access the tags via:
var tagsOfCurrentUser = this.tagsByUser.get(session.user._id + "");


  michi



More information about the Helma-user mailing list