[5.3.8.4] Setting Site or Folder default value

13 views
Skip to first unread message

Mark Orciuch

unread,
Apr 22, 2021, 3:21:33 PM4/22/21
to dotCMS User Group
Hello,

I am trying to initialize Site or Folder field to a default folder using the Rest API. This the syntax I am using:

dataObj.siteOrFolder = "+inode: 371f7333-4738-47fc-91d7-3462ab08504a +identifier: 371f7333-4738-47fc-91d7-3462ab08504a";

The contentlet is saved but the Site or Folder is always set to default host.

So I tried using a custom field with the following code:

<div id="HostSelector" name="HostSelector" dojoType="dotcms.dijit.form.HostFolderFilteringSelect" onChange="updateHostFolderValues('$fieldAux.getVelocityVarName()');" includeAll="true" value="$!fieldDefaultValue"></div>
<input type="hidden" name="$fieldAux.getVelocityVarName()" id="$fieldAux.getVelocityVarName()" value="$!fieldDefaultValue"/>
<input type="hidden" name="hostId" id="hostId" value=""/>
<input type="hidden" name="folderInode" id="folderInode" value=""/>
<br />
<script>
function updateHostFolderValues(field){
if(!isInodeSet(dijit.byId('HostSelector').attr('value'))){
dojo.byId(field).value = "";
dojo.byId('hostId').value = "";
dojo.byId('folderInode').value = "";
}else{
var data = dijit.byId('HostSelector').attr('selectedItem');
if(data["type"]== "host"){
dojo.byId(field).value = dijit.byId('HostSelector').attr('value');
dojo.byId('hostId').value = dijit.byId('HostSelector').attr('value');
dojo.byId('folderInode').value = "";
}else if(data["type"]== "folder"){
dojo.byId(field).value = dijit.byId('HostSelector').attr('value');
dojo.byId('folderInode').value = dijit.byId('HostSelector').attr('value');
dojo.byId('hostId').value = "";
}
}
}
function isInodeSet(x){
return (x && x != undefined && x!="" && x.length>15);
}
</script>

However, $fieldAux.getVelocityVarName() and $fieldDefaultValue do not resolve. 

Any help to achieve Site or Folder default would be greatly appreciated.

Mark Orciuch

unread,
Apr 26, 2021, 8:40:32 PM4/26/21
to dotCMS User Group
To initialize Site or Folder,  set it to the folder identifier like this:

dataObj.siteOrFolder = "371f7333-4738-47fc-91d7-3462ab08504a";

Mark Pitely

unread,
Apr 27, 2021, 9:28:18 AM4/27/21
to dot...@googlegroups.com
Thanks.I appreciate that you answered your own question,as this may come in handy in the future.
I absolutely search the forum on my own questions and often get an answer - and sadly, sometimes the answer is one I wrote and then forgot.
Mark Pitely
Marywood University

--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/2ac9ecab-5203-4112-ad7a-0c55a17554a1n%40googlegroups.com.

Mark Orciuch

unread,
Apr 27, 2021, 11:41:59 AM4/27/21
to dotCMS User Group
Sure thing. I am hoping to start contributing back more in the future.
Reply all
Reply to author
Forward
0 new messages