Newbie: Problem extending BlockController

Permalink
I have clearly done something stupid. I experimented with a simple package creation/installation and it worked ok.

Now I am working on integrating some javascript from another source and although I thought I followed the same principles I must have messed up.

I get the following error:

Fatal error: Block::getInstance() [<a href='block.getinstance'>block.getinstance</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "fbwallBlockController" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /home/andym/public_html/test01/concrete/models/block.php on line 329

I have attached my controller.php file

Any help would be really great.

I know how to do this stuff in other CMS packages but I think yours looks very useful so I'd like to understand how to use it...

1 Attachment

 
Landson replied on at Permalink Reply
Landson
Howdy,

I don't recognize that error message, but I noticed in your on_page_view() method you're adding jQuery to the header. You shouldn't have to do this, as C5 already calls in/includes jQuery (1.7.1 I believe).
Andym2009 replied on at Permalink Reply
Thanks, I removed that but as you might expect it made no difference.

I know the Add Block is working and the form is being displayed to get the values ok.

The problem seems to arise after that - so I thought it must be to do with the View Block, but I can't seem to get that to work in a basic way either.
Landson replied on at Permalink Reply
Landson
Looked at your controller again here, and I would remove these lines from your view() and on_page_view() methods.

$this->addHeaderItem($html->css('jquery.ui.css'));
$this->addHeaderItem($html->css('ccm.dialog.css'));
$this->addHeaderItem($html->javascript('jquery.ui.js'));
$this->addHeaderItem($html->javascript('ccm.dialog.js'));


c5 already includes jquery.ui.css and jquery.ui.js and I'm going to assume it includes the ccm.dialog.js/css where it's needed. You can also remove:

$html = Loader::helper('html');


from the view() method as well. If you want to include js in your view put it into a file at blocks/your_block/js/view.js and it will be auto-loaded in. You can do the same thing for any css for your view, except it'll be at blocks/your_block/css/view.css

Could you attach your view.php file, or paste it into a reply?
mkly replied on at Permalink Reply
mkly
change
fbwallBlockController extends BlockController {

to
FbwallBlockController extends BlockController {

This may be why you are getting that error. BlockController names and other controller names need to have full camel case because of how they are included and loaded.

Second remove
// in on_page_view
$this->addHeaderItem($html->javascript('jquery-1.6.1.min.js');

It will conflict with the already loaded jquery and it will still work fine without it.

Anyhow, it looks pretty good, seems like you're off to a nice start.
Andym2009 replied on at Permalink Best Answer Reply
Thanks for those tips. I think I must have created a really persistent problem because even simple experiments after this resulted in the same error when I KNOW they should have worked. Have now cleared and am reinstalling complete web site.

With these guidelines you guys have provided I will take things step by step and hopefully avoid messing up like I did the first time.

What I am going to try and do is include some code someone has developed to put your fb wall on your website. I think it will be useful to others if it works out.
Andym2009 replied on at Permalink Reply
I have been repeatedly testing and getting the same problem but finally I think I have the answer.
I kept calling my block test01 or andy02 or whatever. The use of the number in the block name seems to be what caused the crashes in my tests. AndyTest worked just fine :-)

Onwards and upwards.
Andym2009 replied on at Permalink Reply
I think that (not the use of 01) was the cause of my problem.... the lack of the capital at the start of the name!