A sort of roundabout way of doing this, but you could create a macro that returns the $sys.currentslot.relresults.size(). Of course, this still initializes the slot
The difference between #initSlot and psoSlotTools, is that psoSlotTools creates the new Assembly Items, but stops one step short of actually assembling the items.
If the items in question are small snippets (links, etc), then the difference between the 2 is pretty minimal. I think Jitendra’s method is probably superior in this case. If the templates are really large and complex (or have slot on them), then you might save something by not assembling them.
The macro method mentioned here is interesting, but I’d rather count the slot contents in the bindings. I’ve tried every variation of the above code I can think of and get nothing but cryptic errors. What would the correct syntax be?
Here are examples of what I’ve tried:
$user.psoSlotTools.getSlotContents($sys.assemblyItem, “slotName”, “”).size
$user.psoSlotTools.getSlotContents($sys.assemblyItem, “slotName”, “”).size()
$user.psoSlotTools.getSlotContents($sys.assemblyItem, “slotName”, “template=templateName”).size
$user.psoSlotTools.getSlotContents($sys.assemblyItem, “slotName”, “template=templateName”).empty
$user.psoSlotTools.getSlotContents($sys.assemblyItem, “slotName”, “template=templateName”).isEmpty()
etc.
I’m pulling my hair out. This is my first big project using Percussion CM System. Is there any documentation for the psoSlotTools, or something akin to Javadoc for these methods?
A heads up for other less experienced users like me: Jitendra’s numslotitems macro creates problems with Active Assembly.
I used the macro and the slot on the same page (the number of items in the slot is used to help format the contents of the slot, e.g. to divide into two equal columns). In Active Assembly, trying to add or remove items from the slot generates an index out of bounds exception, and prevents the page from refreshing automatically. According to Alex in tech support, there were two problems:
The issue is primarily caused by the fccc_numslotitems macro. The macro is not properly written/marked for page active assembly. If you intend to use this macro for active assembly, it will need to be re-implemented.
Same slot twice on a page. Solution: Make only one instance of that slot as Active Assembly.
I replaced the macro with jimbo’s psoSlotTools code in the bindings, and now Active Assembly is happy.