cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Node of a custom type in PHP

dallinns
Champ on-the-rise
Champ on-the-rise
I want to create a node that has a custom type but when I call the createChild function with the type specified I get an error with anything other than "cm_content". The following works fine:
$upload = $home->createChild('cm_content', 'cm_contains', $file_name);
But for example, when I try the following:
$upload = $home->createChild('ls_document', 'cm_contains', $file_name);
it gives me an error when $session->save() is called.

I edited the namespace map to include ls and using ls for the namespace works in other instances e.g.:
$upload->ls_classID = "ENGL316001";
works fine and is defined in a model file as
<type name="ls:document">
         <title>Lesson</title>
         <parent>cm:content</parent>
         <properties>
            <property name="ls:filename">
               <title>File Name</title>
               <type>d:text</type>
            </property>
            <property name="ls:classID">
               <title>Section Number</title>
               <type>d:text</type>
            </property>
            <property name="ls:description">
               <title>Description</title>
               <type>d:text</type>
            </property>
            <property name="ls:custom">
               <title>Custom data</title>
               <type>d:text</type>
               <multiple>true</multiple>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>cm:titled</aspect>
         </mandatory-aspects>
      </type>
the ls:[property] properties here can be successfully applied to a document of type cm:content (which confuses me, but I guess it works) but I can't figure out how to give a node a type of ls:document. Any tips?
1 REPLY 1

ddanninger
Champ in-the-making
Champ in-the-making
Well,

to see the Error would be useful….

but the fastest test to see if it is a problem with the namespace mapping is if you upload with the complete Namespace of the Model:


$upload = $home->createChild('{http://www.example.org/model/content/1.0}document', 'cm_contains', $file_name);