Dispatch Template Binding Syntax

For some reason, this binding fails to generate publishing location:

if ($sys.site.id == 315) {"templateX";} else { if ( $type=="A" ){"templateA" ; } else { "templateB" ; } ; }

Error in the console:
“ERROR [PSGeneratePubLocation] Problem while generating a publishing location for variant 754 and contentid 47264
com.percussion.extension.PSExtensionException: The extension call does not have the appropriate number of parameters. 1 parameters were expected, 0 parameters were supplied…”

Probably got the first condition wrong. What would be proper syntax?

Also, how would I include OR in that condition, as in

if ($sys.site.id == 315 OR $sys.site.id == 316) {...

Many thanks.

Hi Sinisa

Do you get this error when previewing?. If not then it’s the location scheme that’s causing the problem not the dispatch template. if you don’t have a location scheme for the template then look at the default location scheme.

You also don’t need the last semi colon in your if statement.

Also

if ($sys.site.id == 315 OR $sys.site.id == 316)

if ($sys.site.id == 315 || $sys.site.id == 316)

Cheers
James

You’re 100% right. A new context was used here, created a bunch of location schemas but for this particular type I forgot to actually add parameter expression.

Many thanks.

This was really helpful info for one of my dipatch templates. I’m adding my post here b/c I think it’s the same subject matter - let me know if a new thread should be created.

I’m running into difficulty with this scenario:

I have a content type that should publish using the binary template if the item_filename is not blank; an HTML page if the body field is not blank; and not publish anything if the URL is not blank. [This content type allows users to upload a pdf or mp3 etc., enter text or provide a URL]

The following binding works for the first two scenarios but it still tries to render URLs as pages (when no publishing is required at all)

if ($sys.item.getProperty(“item_filename”).String != “”) {“B_Binary_v”;} else {if ($body != “NULL”)
{“P_ICAO_Media_Coverage_v”;} }

I’ve tried a few other things such as leaving the {template} blank and that also causes problems.

Is there a way to say “if there is a URL ignore this/don’t use any template”?