Create an asset with a Page chooser in the data definition using web services

ediego's Avatar

ediego

02 Mar, 2016 01:58 PM

I'm using web services to create some page assets in the CMS. One of the pages has a Page chooser in the data definition. I am using PHP web services to create the page. I can get all the text values to populate correctly, but I can't figure out how to populate the Page chooser (supervisor) field.

Ex: Here is the data definition.
<text identifier="position-title" label="Position Title"/>
      <text identifier="additional-positions" label="Additional Positions" multiple="true"/>
      <asset type="page" identifier="supervisor" label="Supervisor"/>
      <text identifier="division" label="Division"/>
      <text identifier="division-folder" label="Folder" restrict-to-groups="comm-admins"/>
      <text identifier="dean" label="Dean"/>
      <text identifier="dean-folder" label="Folder" restrict-to-groups="comm-admins"/>
      <text identifier="department" label="Department"/>
      <text identifier="department-folder" label="Folder" restrict-to-groups="comm-admins"/>

Ex of the PHP code for setting up the data
// Organization Information Group - Title, Supervisor, Division, Dean, Department
array (
'type' => 'group',
'identifier' => 'organization-information',
'structuredDataNodes' => array (
'structuredDataNode' => array (

// Employee Type
array (
'type' => 'text',
'identifier' => 'employee-type',
'text' => $aProfileData['employeeType']
),
// Position Title
array (
'type' => 'text',
'identifier' => 'position-title',
'text' => $aProfileData['title']
),
// Supervisor
array (
'type' => 'asset',
'asset-type' => 'Page',
'identifier' => 'supervisor',
'path' => '/index'
),
// Division
array (
'type' => 'text',
'identifier' => 'division',
'text' => $aProfileData['division']
),
// Division Folder
array (
'type' => 'text',
'identifier' => 'division-folder',
'text' => $aProfileData['divisionFolder']
),

//Dean
array (
'type' => 'text',
'identifier' => 'dean',
'text' => $aProfileData['dean']
),

  1. 1 Posted by Wing Ming Chan on 02 Mar, 2016 02:28 PM

    Wing Ming Chan's Avatar

    Hi,

    You should know of my library by now. To use my library:

    $page->setPage( 
        "group;page-chooser",
        $cascade->getAsset( a\Page::TYPE, "87e6d0cf8b7f0856002a5e11c8e6bd21" ) )->edit();
    

    To use raw code, you should set both the pageId and pagePath properties:

                object(stdClass)#29 (14) {
                  ["type"]=>
                  string(5) "asset"
                  ["identifier"]=>
                  string(12) "page-chooser"
                  ["structuredDataNodes"]=>
                  NULL
                  ["text"]=>
                  NULL
                  ["assetType"]=>
                  string(4) "page"
                  ["blockId"]=>
                  NULL
                  ["blockPath"]=>
                  NULL
                  ["fileId"]=>
                  NULL
                  ["filePath"]=>
                  NULL
                  ["pageId"]=>
                  string(32) "87e6d0cf8b7f0856002a5e11c8e6bd21"
                  ["pagePath"]=>
                  string(4) "test"
                  ["symlinkId"]=>
                  NULL
                  ["symlinkPath"]=>
                  NULL
                  ["recycled"]=>
                  bool(false)
    

    Wing

  2. 2 Posted by ediego on 02 Mar, 2016 02:30 PM

    ediego's Avatar

    We are aware of the library and started migrating some of our web services to use it. thanks for the library and the response :)

  3. 3 Posted by Wing Ming Chan on 02 Mar, 2016 02:48 PM

    Wing Ming Chan's Avatar

    For your information, these are the upcoming hangout events:

    1. Web Services Online Tutorials

    2. One Template, One Region, and Lots of Velocity Tricks

    Wing

  4. Tim closed this discussion on 23 Mar, 2016 06:42 PM.

Comments are currently closed for this discussion. You can start a new one.

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