Passing max results to a slot as a variable

I would like to submit to a slot the maximum results it should return. See below.

select rx:sys_contentid,rx:sys_revisionid from rx:hartArticle WHERE rx:category=:exp ORDER BY rx:sys_contentstartdate Desc

and set the max_results field in the slot to :num the following bindings were set.

Bindings.
$techreport.exp = techcenter
$techreport.num = 10

I’m not sure I follow what you’re asking completely, but when assembling a slot, you pass the “maxresults” parameter in the last argument to the slot macro:

#slot(“myslot” “” “” “” “” “template=xyz&maxresults=20” )

you can also specify a “map” of values: this process is shown on page 198 of the Rhythmyx Implementation Guide for 6.5

Dave

Thanks, i just set $techreport.max_results = 10.

#slot(“AutoEPFeature” “” “” “” “” $techreport)

The documentation is a little unclear if the parameter is maxresults or max_results, but one or the other should work

Dave

Hello,

I have been having similar problems with passing a variable to a slot in order to set the order in which results are displayed by a slot. Unlike the template and max_results, there doesn’t seem to be a magic parameter name that has the desired results simply by setting the bindings in the template that calls the slot. I’ve followed the instructions on p189 of the Implementation Guide, which work for setting the value to use in the WHERE clause of the jsr-170 SQL-like query. But the same does not work in the ORDER BY clause. If I set up a parameter called foo, setting the clause to

ORDER BY :foo

it fails, with error messages about “expecting IDENTIFIER”, presumably “rx:”. So it must be checking the syntax of the query before replacing the parameter names with their values. Setting the clause to

ORDER BY rx::foo

gets rid of the error messages, but it still doesn’t return results in the order specified by a content type fieldname which is the value of the foo parameter.

Thanks,

Andrew.

I suggest that rather than trying to add an “ORDER BY” clause in the query, that you pass an ORDER_BY parameter to the slot parameters. The slot content finder knows how to add this parameter to the query.

Dave

Sorry, I should have mentioned that the slot I am using is an automated slot, using the sys_AutoSlotContentFinder content finder, which doesn’t have an order_by parameter as does sys_RelationshipContentFinder, for example. Hence simply passing a parameter called ‘order_by’ does not work.

I guess I could use the “raw slot” (i.e. #initslot) but I cannot find any documentation on how to use that. It sets up a variable, $sys.currentslot.relresults, that can be stepped through using #foreach, but is there any way to sort it first? I’ve played around with $tools.sorter.sort() but that appears to need a property of each array element to sort on, so won’t sort on the contents of a field of the content type (e.g. $relresult.node.getProperty(“rx:cms_loc_firstname”).string)

Thanks,

Andrew.

Automated slot or non-Automated slot should not make any difference.

The “order_by” and “max_results” processing is done in the base class (PSBaseSlotContentFinder) and is the same for ALL finders that we ship.

You can supply these parameters in 2 different ways: in the “slot definition”, and at runtime via a variable (e.g. $techreport) as discussed earlier in this thread.

Not all of the finders expose the parameters to the slot definition, but they all support them at runtime.

Dave

I looked up PSBaseSlotContentFinder, and the Java Docs on our Rhythmyx 6.5.2 server says it is protected. Won’t this prevent specifying the order_by at runtime?

Presumably sys_RelationshipContentFinder overrides this with a public field of the same name, but the sys_AutoSlotContentFinder doesn’t. I can’t find the Java Docs for those to check, but I have tried all variations on passing an order_by parameter to an automated slot, and none have worked for me.

Andrew.

I have found a solution to this. The entire JSR-170 query can be passed in as a parameter to the slot, and hence to the content finder. So I have written a macro to build queries, and accept other parameters, which it then passes to a placeholder slot.

I still do not think sys_AutoSlotContentFinder will accept an order_by parameter on our system. Dave, if you are convinced it should then there may be a bug here. FYI, I’ve raised it with the Percussion Technical Support UK, TAR# UK-08-03-0055. But we are happy with the workaround we have found.

Thanks,

Andrew.

I want to clear up a few issues here that arose in this thread:
The max results parameter name is max_results
The order by parameter name is order_by
Both are case-sensitive.

You can only use variables in the WHERE clause of the query, not the ORDER BY clause.

The order_by property only works for 2 slot finders we ship: sys_RelationshipContentFinder and sys_TranslationContentFinder. It does not work w/ the AutoSlotContentFinder.
PSBaseSlotContentFinder performs the work of ordering, but it is the derived class’ responsibility to call it. It would be trivial to write a class that extends the auto slot finder that adds support for the order_by param.