Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > K# help needed View modes: 
User avatar
Member
Member
Dlglsh - 7/30/2012 8:03:50 AM
   
K# help needed
Hi,

I need a little help with k# if possible? In a custom layout for a 'Notification e-mail' under CMS Desk > Forms, I am trying to output n/a if a given field is empty. (The field is an upload file field). So if no file has been selected for upload, display "n/a", else display the filename.

This is what I am using, but it isn't working. It either shows the filename or nothing at all.

{% display = "n/a"; if (Fieldname != "") {display = Remove(Fieldname, 0, LastIndexOf(Fieldname, "/") + 1)} display %} is put in there by Kenitco CMS, not me.

Thanks,

Matt

User avatar
Member
Member
nicolas.juteau-nexun - 7/30/2012 8:33:07 AM
   
RE:K# help needed
Hi Matt,

I already ran with this problem before (Fieldname != "" comparison).

You can evaluate if something is empty with the IsEmpty() method. Use it as follows:

{% IfEmpty(Fieldname, "n/a", Remove(Fieldname, 0, LastIndexOf(Fieldname, "/") + 1) %}


First parameter is the object to evaluate if empty. Second parameter is what is returned if evaluated object is null. Third parameter is what is returned if evaluated object is not empty.

I suggested you take a look at this. Really helpful :)

Regards,
Nicolas

User avatar
Member
Member
nicolas.juteau-nexun - 7/30/2012 8:48:03 AM
   
RE:K# help needed
I am sorry, I wrote IsEmpty but it is IfEmpty, just like in the example :)

My bad. :)

User avatar
Member
Member
Dlglsh - 7/30/2012 9:24:41 AM
   
RE:K# help needed
Hi Nicolas,

Thanks for your help (again!).

I've put the line of code in, there was a missing ')' but it's working now!

Thanks (again) for your help! :)

Matt

User avatar
Member
Member
nicolas.juteau-nexun - 7/30/2012 9:27:00 AM
   
RE:K# help needed
Yes, you are right.

Sorry, had no coffee this morning x)

Glad it is working !

Nicolas