Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > User Contribution View modes: 
User avatar
Member
Member
lwhittemore-emh - 6/13/2013 8:02:01 AM
   
User Contribution
I have a user contribution webpart on a page and I want to make it so that when as user adds a file it adds it a to a folder with there user name.

I added this to the "Path for new documents" field
/{%UserName%}


but unless that folder already exists it doesn't allow the user to add a new document.

User avatar
Member
Member
Swainy - 6/13/2013 8:44:44 AM
   
RE:User Contribution
Hi,

You could alter the webpart so that before it saves the file it checks if the folder exists first? If not then create the folder?

Thanks,

Matt

User avatar
Kentico Support
Kentico Support
kentico_radekm - 6/16/2013 5:53:50 AM
   
RE:User Contribution
Hello.

Correct context macro would be {%CurrentUser.UserName%}. However, it will not be resolved in Path expression, therefore, you cannot use it for this purpose.

Instead, I would recommend using custom macro, where you can compose any path dynamically in code-behind, including current user's name. You can find more info about custom macros here.

Best Regards,
Radek Macalik