Do page assets created by web services apply default values from data definitions?
I am using web services to import a large number of page assets from an external XML file. The data definition I'm using to create the pages has a number of fields with default values, some of which are not included in the XML file and will be entered manually at a later time. The import is working fine for all the fields I specifically capture from XML, but for additional fields I do not explicitly set a value for, the value is always blank as opposed to using the default value set in the data definition.
Is this an expected result from web services or am I missing something on the asset creation? I could always set the default values directly in my code but it would be cleaner to have them pick up from the data definition if possible.
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Wing Ming Chan on 10 Aug, 2016 07:43 PM
Yes, this behavior is expected, because there is no direct communication between the process of creating/editing a page and the page's associated data definition. You have to manually read the default value of a field and use it to set the value of the corresponding node.
Wing
2 Posted by b.leblanc on 10 Aug, 2016 07:48 PM
Ok that makes sense.
Thanks Wing. Big fan of your library!
3 Posted by Wing Ming Chan on 10 Aug, 2016 07:50 PM
Inspired by your question, I have just added a recipe on github: https://github.com/wingmingchan/php-cascade-ws-ns-examples/blob/mas...
I also plan to enhance the
DataDefinition
class by adding methods to deal with default values.Wing
4 Posted by b.leblanc on 10 Aug, 2016 08:23 PM
Thanks again! I think I can get it working from the recipe. I also have a few questions about batch creation/editing with your library. Should I create a new thread for that?
5 Posted by Wing Ming Chan on 10 Aug, 2016 09:15 PM
Please go ahead and post your questions. If you state your questions with keywords, the search engine will find them.
Wing
6 Posted by b.leblanc on 11 Aug, 2016 01:21 PM
My import is creating/updating a data set of about 17k records so I'd really like to do the operation in batches. I see there's a batch operation function in the AssetOperationHandlerService but I didn't see a current method for batching a large number of operations leveraging the other classes.
Is my best bet to extend the Cascade class and override the createAsset function batch the operations or is there a better way in the library that I've missed? I suppose that would work for create but editing, if I'm not mistaken, is controlled individually by descendants of the Asset class, so there may not be a single point of override there.
Thanks for all your help with this.
7 Posted by Wing Ming Chan on 11 Aug, 2016 03:37 PM
Yes, you are right on all points.
I did not provide a batch operation because I did not see the need of it. The most I have to tolerate is execution time. I can afford that when I need a coffee or do a cron job.
Each
Asset
subclass can be used to deal with a single asset. There is no batch mode, so to speak.You can definitely subclass
Cascade
to add the functionality. If you succeed, please share your code. I will be more than happy to add your code to my class, and add your name to the file to acknowledge your contribution.Wing
8 Posted by b.leblanc on 11 Aug, 2016 03:54 PM
Thanks Wing. I'll see what I can put together and post it up here for you.