Error in http master-error log when page loads.
Permalink
With the following code in my site_events.php file, when my page loads, I get this errer in the httpd/master-error.log; undefined method View::getCollectionHandle() in /var/www/html/mc-hosts/config/site_events.php on line 19.
I assume that it's because the page object doesn't exist yet while the page is loading but after wrapping it in an "if(is_object())" the error is still being thrown. Also, what doesn't make sence is that the error is about the view class and the getCollectionHandle() is a method in the page class.
Is this really an error or should I be worried about it?
I assume that it's because the page object doesn't exist yet while the page is loading but after wrapping it in an "if(is_object())" the error is still being thrown. Also, what doesn't make sence is that the error is about the view class and the getCollectionHandle() is a method in the page class.
Is this really an error or should I be worried about it?
This is created based on the document,http://www.concrete5.org/documentation/developers/system/events.... I am using the on_render_complete method in Events. The discription of this is;
"Fires immediately after rendering the entire page. If a function hooks into this event, the function is passed the page being rendered as the argument." This is supposed to be the object of the current page that is being rendered. Correct me if I'm wrong but shouldn't I be able to get the collection handle from it?
When I have a chance, maybe I'll try a dump to see what it is.
"Fires immediately after rendering the entire page. If a function hooks into this event, the function is passed the page being rendered as the argument." This is supposed to be the object of the current page that is being rendered. Correct me if I'm wrong but shouldn't I be able to get the collection handle from it?
When I have a chance, maybe I'll try a dump to see what it is.
I took a dump with the page object that is passed from the page event I am monitoring. It is an object of all the objects that relate to the page being rendered. I see now why the c5 core development team called a page a collection. Looking at a page this way, that is exactly what it is.
I see now, I need help with how to extract the page or view object from this so I can get the actual handle of the page that is about to be rendered.
I see now, I need help with how to extract the page or view object from this so I can get the actual handle of the page that is about to be rendered.
I have it figured out and posting my findings for those who are dealing with the same issue.
The page object that is passed from the events handler is a full page object that was meant to be handled from within a page controller. Since I am not trying to us this object in a controller, I get the Object Undefined error. So, what I did is write a tool myself to search for the page object's cID, cvHandle, and a dump method to dump the object to the browser for perusal.
I made this a class and stuck it in the root methods directory because there is no root tools directory.
This is my code;
The page object that is passed from the events handler is a full page object that was meant to be handled from within a page controller. Since I am not trying to us this object in a controller, I get the Object Undefined error. So, what I did is write a tool myself to search for the page object's cID, cvHandle, and a dump method to dump the object to the browser for perusal.
I made this a class and stuck it in the root methods directory because there is no root tools directory.
This is my code;
<?php defined('C5_EXECUTE') or die("Access Denied."); class CollectionAttribs { public static function getCollectionID($c) { foreach ($c as $key=>$value) { if (is_object($value) && $key == 'c') { foreach ($value as $akey=>$avalue) { if ($akey == 'cID') return $avalue; } } } return false; } public static function getCollectionHandle($c) { foreach ($c as $key=>$value) { if (is_object($value) && $key == 'c') {
Viewing 15 lines of 74 lines. View entire code block.
You could try inserting a dump of the object and then 'exit' so the dump comes straight to the browser before anything else renders.
http://www.concrete5.org/documentation/how-tos/developers/concrete5...