Error installing a block

Permalink
I'm working on an add on, the first time I try to add the block to a page, it adds in OK but when I publish the page I get a white screen and a message:

{"message":null,"title":null,"time":"2014-09-29 10:43:46","redirectURL":"http:\/\/mydomain.com\/index.php\/team"}

When I go back to the page the block is all installed and working, and if I add additional blocks of the same type the error does not happen. I don't think it has anything to do with my blocks db table, I don't use 'table' or 'time' anywhere.

Thanks
Has anyone seen an error like this or know where it is coming from?

pvernaglia
 
pvernaglia replied on at Permalink Reply
pvernaglia
If I use $this->addHeaderItem in the view() function of a block controller to insert javascript I get some problems, before I could initiate a script from the controller on_view function, something like:

$this->addHeaderItem('<script type="text/javascript"> $(document).ready(function() { $("a.fancybox").fancybox({"titleShow":false, "hideOnOverlayClick":false});}) </script>, $controller');


I think we should be able to do this from view() now, but I kept getting that funny error message when adding a block the first time to a page. The rest of the time it all worked fine. I don't know if there is something buggy or if I am doing this wrong in a controller, or is there a new way to do it now? Injecting CSS like that works fine, just seems to be with javascript.

thanks
rockface replied on at Permalink Reply
rockface
Still having this issue with my block installs. Anyone else seeing this?
SEE ATTACHEMENTS in my previous post (below)
rockface replied on at Permalink Reply 2 Attachments
rockface
Did you ever find the solution to this error?

I'm sure it's in my code, but If I add my block and click publish it shows the same error you got. But, if i refresh the page before publishing, it works fine.

Error: {"message":null,"title":null,"time":"2015-08-14 14:19:36","redirectURL":"http:\/\/localhost\/index.php\/art-market","pages":[{"name":null,"cID":null}]}

The attached images show the page in edit mode before and after doing a page refresh. Seems like Concrete5 is not placing the block inside the block area at first.

NOTE: This is on the latest 5.7.5 version, but it's been happening (with only my blocks) since i started developing in the 5.7 platform (about 3 months).
pvernaglia replied on at Permalink Reply
pvernaglia
I forget what this was, it might be a cache problem, try clearing your cache then installing the block and see if it goes away. Or it might be a javascript conflict, watch your console for errors when installing the block.
rockface replied on at Permalink Reply 2 Attachments
rockface
Well, I am getting ready to submit the package to the marketplace and this problem is still kicking my butt. It only happens when I publish the page after installing the block.

{"message":null,"title":null,"time":"2015-12-02 20:21:52","redirectURL":"http:\/\/localhost\/concrete5.7.5.3\/index.php\/members\/profile","pages":[{"name":null,"cID":null}]}

I tried uninstalling the package, clearing cache, reinstalling the package and the block... same problem.

NOTE:
If I install the block, refresh the page before clicking publish, no error massage!
I then noticed, the page does not actually place the block into the page area, but puts it BELOW the page area. Then correctly places the block when the page is refreshed. (See attached). After this refresh, I can Publish Changes without error.

ALSO:
If i install the block, and it looks like it did not install correctly. I tried to "Discard Changes" and still got the error!?!?

FINALLY:
When the block installs below the selected area, I can drag it up to the correct area, but publishing that page, still produces the error:
rockface replied on at Permalink Reply
rockface
If the scripting engine crashes, due to errors in the block's js, C5 cannot complete the block install action correctly. The block ends up being partially installed on the page.

I needed to pass variables to view.js file, so I set them in a script block (in the view.php)... Problem was, during block install the view.js is opened BEFORE the view.php is.

To fix the problem, I had to check for missing elements on the page before running the scripts.