Standard Page asset content - populate from a script?


(James) #1

Hi,


I can create an unpopulated standard page asset using the PHP import scripts available but I need some way of populating the page content at the same time. There doesn't appear to be an asset attribute way of doing this? Would there be any way of populating the meta data for the page at the same time too?



Thanks in advance if anyone can help.


(Nic Hubbard) #2

Which import script are you using?


If you use the export asset as XML script you can see the format needed to use the import from xml script, which includes metadata.


(James) #3

[quote]
Which import script are you using?



If you use the export asset as XML script you can see the format needed to use the import from xml script, which includes metadata.

[/quote]



Many thanks that's given me a good place to start :slight_smile: I'm guessing this is what you mean't (below)…



php …/export_to_xml.php /var/www/matrix/ 1645:1661 1 > import_page_asset.xml



Shows…



<?xml version="1.0" encoding="utf-8"?>

<actions>

<action>

<action_id>create_Page_Standard_1645</action_id>

<action_type>create_asset</action_type>

<type_code>Page_Standard</type_code>

<link_type>1</link_type>

<parentid>1661</parentid>

<value></value>

<is_dependant>0</is_dependant>

<is_exclusive>0</is_exclusive>

</action>



<action>

<action_id>add_Page_Standard_1645_path</action_id>

<action_type>add_web_path</action_type>

<asset>[[output://create_Page_Standard_1645.assetid]]</asset>

<path>example</path>

</action>



<action>

<action_id>create_Bodycopy_1646</action_id>

<action_type>create_asset</action_type>

<type_code>Bodycopy</type_code>

<link_type>2</link_type>

<parentid>[[output://create_Page_Standard_1645.assetid]]</parentid>

<value></value>

<is_dependant>1</is_dependant>

<is_exclusive>1</is_exclusive>

</action>



<action>

<action_id>create_Bodycopy_Div_1647</action_id>

<action_type>create_asset</action_type>

<type_code>Bodycopy_Div</type_code>

<link_type>2</link_type>

<parentid>[[output://create_Bodycopy_1646.assetid]]</parentid>

<value></value>

<is_dependant>1</is_dependant>

<is_exclusive>0</is_exclusive>

</action>



<action>

<action_id>create_Content_Type_WYSIWYG_1648</action_id>

<action_type>create_asset</action_type>

<type_code>Content_Type_WYSIWYG</type_code>

<link_type>2</link_type>

<parentid>[[output://create_Bodycopy_Div_1647.assetid]]</parentid>

<value>div_contents</value>

<is_dependant>1</is_dependant>

<is_exclusive>1</is_exclusive>

</action>



<action>

<action_id>set_Page_Standard_1645_name</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Page_Standard_1645.assetid]]</asset>

<attribute>name</attribute>

<value><![CDATA[example]]></value>

</action>



<action>

<action_id>set_Page_Standard_1645_short_name</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Page_Standard_1645.assetid]]</asset>

<attribute>short_name</attribute>

<value><![CDATA[example]]></value>

</action>



<action>

<action_id>set_Bodycopy_1646_name</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Bodycopy_1646.assetid]]</asset>

<attribute>name</attribute>

<value><![CDATA[Page Contents]]></value>

</action>



<action>

<action_id>set_Bodycopy_Div_1647_shadow_links</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Bodycopy_Div_1647.assetid]]</asset>

<attribute>shadow_links</attribute>

<value><![CDATA[array (

);]]></value>

</action>



<action>

<action_id>set_Bodycopy_Div_1647_name</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Bodycopy_Div_1647.assetid]]</asset>

<attribute>name</attribute>

<value><![CDATA[Content DIV 1647]]></value>

</action>



<action>

<action_id>set_Bodycopy_Div_1647_attributes</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Bodycopy_Div_1647.assetid]]</asset>

<attribute>attributes</attribute>

<value><![CDATA[array (

'layout_type' => 'div',

);]]></value>

</action>



<action>

<action_id>set_Content_Type_WYSIWYG_1648_name</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Content_Type_WYSIWYG_1648.assetid]]</asset>

<attribute>name</attribute>

<value><![CDATA[DIV Content]]></value>

</action>



<action>

<action_id>set_Content_Type_WYSIWYG_1648_html</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Content_Type_WYSIWYG_1648.assetid]]</asset>

<attribute>html</attribute>

<value><![CDATA[test data

]]></value>

</action>



<action>

<action_id>set_Content_Type_WYSIWYG_1648_htmltidy_status</action_id>

<action_type>set_attribute_value</action_type>

<asset>[[output://create_Content_Type_WYSIWYG_1648.assetid]]</asset>

<attribute>htmltidy_status</attribute>

<value><![CDATA[pass]]></value>

</action>



<action>

<action_id>set_Page_Standard_1645_metadata_schema_1650</action_id>

<action_type>set_metadata_schema</action_type>

<asset>[[output://create_Page_Standard_1645.assetid]]</asset>

<schemaid>1650</schemaid>

<granted>1</granted>

<cascades>1</cascades>

</action>



<action>

<action_id>set_Page_Standard_1645_metadata_field_1652</action_id>

<action_type>set_metadata_value</action_type>

<asset>[[output://create_Page_Standard_1645.assetid]]</asset>

<fieldid>1652</fieldid>

<value><![CDATA[my first metadata]]></value>

</action>



</actions>



Then manipulate this to include new metadata and content and re-import it to another folder…



php …/import_from_xml.php /var/www/matrix/ import_page_asset.xml



Thanks again for the clue.