getSlotContents not working during publish

I have a puzzling problem with the PSO toolkit’s getSlotContents() function.

In a preview context, the following code works fine:

#set($video_count = $user.psoSlotTools.getSlotContents($sys.assemblyItem,'nsm_Video',null).size())##
<!--Video count: $video_count -->

However, when I publish this page, the value is always 0. And if I try to get() the first node from the slot, it will display correctly in a preview context, but fail during publishing.

Has anyone else experienced this problem, or (oh please!) know the solution?

I will assume that you’ve checked whether the item in the slot is in a publishable state?

In this case I had checked, but it’s not always a fair assumption that I’d do the obvious :slight_smile:

That is what is so puzzling – the function call works perfectly on Preview, but not Publish.

I figured there must be some obvious thing I’m missing.

Well I think it is more of trying to make sure it isn’t the easy stuff before troubleshooting further :wink:

In the url to preview the item in question, if there is a parameter set to “preview” and you change it to “public” do you get the same error? What about if you change your context from 0 to 301? If switching the context creates the problem, then you know that there is something going on with your location schemes…

Thanks to your suggestion, I figured out the problem. The page was published using Publish Now. This sets a sys_itemfilter of sitefolder. In testing the URL, if I change that to public, it works as expected.

The solution, I guess, is to avoid using Publish Now on templates that employ that getSlotContents function.

I’ve logged an internal Toolkit bug on this so that we can try to track this down [PSO-4 getSlotContent fails when item filter is set to Site Folder]. Can you give me the date and time and file size on the PSO Toolkit jar you are using?


Here’s the info:

12/15/2008 11:20AM
Size: 119654 bytes

Hi there

Is there any update on this issue? We’ve recently upgraded to 7.1, and I’ve noticed that since then, I’m getting problems with a macro that uses this function. I hadn’t noticed it when we were on 6.52.

It’s quite a key macro and is used on a whole range of pages, so I’d rather not add additional assembly time by actually assembling a slot to see if it’s populated.