We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14556
    • 9 Posts
    Hi:

    Is it possible to create a php script that creates a new MODx page? For example:

    Have a script called add-job.php that you post an XML document to. The XML document might look like this:

    <jobs>
    	<job jid="DE/003">
    		<title>Project Manager</title>
    		<location>London</location>
    		<type>Permanent</type>
    		<salary>£40,000-£46,000 + Benefits</salary>
    		<intro>Wehey... a cool job</intro>
    		<content>A big description, may need to be in CDATA tags.</content>
    	</job>
    	<job jid="DE/004">
    		<title>Some other job</title>
    		<location>London</location>
    		<type>Permanent</type>
    		<salary>£40,000-£46,000 + Benefits</salary>
    		<intro>Wehey... a cool job</intro>
    		<content>A big description, may need to be in CDATA tags.</content>
    	</job>
    </jobs>
    


    For each Job the script creates a new MODx page.

    Is there a prebuilt plugin I can modify to my needs?.. or would I need to create something from scratch?

    Many thanks in advance:


    John
      • 10449
      • 956 Posts
      I am not aware of any pre-built snippet/script that does exactly that.
      However, if you know PHP, it wouldn’t be too hard to create something like this from scratch.

      The Docmanager class would certainly come in handy: http://modxcms.com/Docmanager-881.html

      As for parsing the XML, you should probably use the simpleXML functions that have been added in PHP5.
      http://www.ibm.com/developerworks/library/x-xmlphp1.html

      As for security / handling... it depends if you want people to use this function from the frontend or via the manager.
      If the latter, you’d probably include your script as a MODx module.