Developing new assets - Error message:Parent is different between


(P Lau) #1

Hi,


I wonder whether somebody here could bring some light into this…

I am trying to get my head around creating a new packacke 'eharvest' for MySource Matrix. I simply followed what I found in the 'news' package, and modified 'package_manager_news.inc' and 'package.xml' accordingly to make them right for my new package. (Or at least what I believe is right…)



After that I created a folder 'Reports' for my new reports asset. I tried to follow the tutorial 'better_user' on the Matrix website and changed the stuff around to suit my new package. Running the command 'sudo php install/step_03.php . --package=eharvest' produces the following error message:

    'Unable to update "reports". Parent is different between asset.xml, reports.inc and reports_edit_fns.inc [SYS0254] |
.

Here is code from the following files in my asset 'Reports:

asset.xml
    <?xml version='1.0' encoding='UTF-8' ?>
    <?xml-stylesheet href="../../asset.xsl" type="text/xsl"?>
<asset_info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../asset.xsd">
		<package>eharvest</package>
		<type_code>reports</type_code>
		<version>0.1</version>
		<name>eHarvest Reports</name>
		<description>A Simple asset to retrieve eharvest reports</description>
		<instantiable>yes</instantiable>
		<allowed_access>backend_user</allowed_access>
		<parent_type>page</parent_type>

		<flash_menu_path>Pages</flash_menu_path>
</asset_info></pre><br />

'report.inc'
    <?php
	// include the parent type, the user asset
	require_once SQ_CORE_PACKAGE_PATH.'/page/page.inc';


	class Reports extends Page
	{
			/**
			* Constructor
			*
			* @param int	$assetid		the asset id to be loaded
			*
			*/
			function __construct($assetid=0)
			{
					parent::__construct($assetid);

			}//end constructor
			
			function printBody($print_form_tags=TRUE, $submit_buttons=TRUE, $form_action='') {
				?>
				<h1>Eharvest Reports</><?php 
				
			}

	}//end class


?></pre><br />

'reports_edit_fns.inc

    <?php
    	require_once SQ_CORE_PACKAGE_PATH.'/page/page_edit_fns.inc';
    	
    	class Report_Edit_Fns extends Page_Edit_Fns
    	{
    			function __construct()
    			{
    					parent::__construct();
    					$this->static_screens['details']['force_lock'] = 'false';
    
    			}//end constructor
    
    
    	}//end class
    ?>

Has anyone an idea what is going wrong with my code?





Thanks for your help,

Uwe


(Nic Hubbard) #2

The first thing that I see is that you named some of your files report and other reports, this also happens with your class names. Make sure they are all consistent by using something like Report for the file names and classes.


(Greg Sherwood) #3

Your edit fns class should be called: Reports_Edit_Fns (missing the S)


EDIT: And what Nic said. That report.inc should be reports.inc


(P Lau) #4

Thanks a lot, as simple as that, it seems to work now!

(P Lau) #5

Hi Guys,


Thanks so much for your help so far!



I was able to install the asset 'Reports' now. That's one step in the right direction :slight_smile: . No when I try add the asset to my site within the Matrix admin site, it looks like that it does that, too. However, when I click on 'refresh all assets' matrix comes back with the following error:

     Error While Requesting: error while parsing: The markup in the document following the root element must be well-formed


What am I missing now?

Thanks a lot,
Uwe




[quote]Your edit fns class should be called: Reports_Edit_Fns (missing the S)

EDIT: And what Nic said. That report.inc should be reports.inc[/quote]

(Greg Sherwood) #6

Do all the screens of your asset work and show no errors?


(P Lau) #7

Thanks for answering so quickly...

No - They don't work.

When I try to add my asset, it comes up with the first screen asking me for a name for my page. I can enter the name and submit the page, but then straight after that it fails. I can see a little 'failed!' on the bottom of the navigation bar, and when I try to refresh the navigation bar this is when the error message comes up.


Thanks for being patient with me. I just would really like to understand this whole process.
Uwe

(P Lau) #8

[quote]Thanks for answering so quickly…


No - They don't work.



When I try to add my asset, it comes up with the first screen asking me for a name for my page. I can enter the name and submit the page, but then straight after that it fails. I can see a little 'failed!' on the bottom of the navigation bar, and when I try to refresh the navigation bar this is when the error message comes up.





Thanks for being patient with me. I just would really like to understand this whole process.

Uwe[/quote]



In addition to that:

I just added my asset. The navigation bar has the issue as described but I actually can reach the asset on the front end. ( I set up a test domain www.matrix.niwa) So if go the address www.niwa.matrix/reports I can see my asset showing the correct content. The admin site is unhappy with me though…


(Greg Sherwood) #9

Do you see any errors in data/private/logs/error.log ?


(P Lau) #10

hmmm… Had a look and here is the output:

    [2009-02-25 18:28:41][12:Root User][2:php warning][R] (/core/lib/asset_map/asset_map.inc:514) - Cannot modify header information - headers already sent by (output started at /packages/eharvest/reports/reports.inc:2)
    [25-Feb-2009 20:28:41] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/user/workspace/matrix/packages/eharvest/reports/reports.inc:2) in /home/user/workspace/matrix/core/include/general.inc on line 115
    [2009-02-25 18:30:22][12:Root User][2:php warning][R] (/core/lib/asset_map/asset_map.inc:514) - Cannot modify header information - headers already sent by (output started at /packages/eharvest/reports/reports.inc:2)
    [25-Feb-2009 20:30:22] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/user/workspace/matrix/packages/eharvest/reports/reports.inc:2) in /home/user/workspace/matrix/core/include/general.inc on line 115

(Greg Sherwood) #11

Make sure there is no whitespace (no newline or spaces) before the opening PHP tag in all your asset's source files and no whitespace after the closing tag.


(P Lau) #12

Well, thank you very much! That's done, no problems any more. Great help and really appreciated!

Uwe :)