delete method in controller not working.
Permalink
I have this delete method in a blocks controller.php:
Doesn't seem to be working. Can anybody see any problems with it?
public function delete() { $db = Loader::db(); $q = 'DELETE FROM btMyBlock WHERE bID=?'; $v = array($this->bID); $db->Execute($q,$v); parent::delete(); }
Doesn't seem to be working. Can anybody see any problems with it?
I'll have a look but I'm pretty sure that the AddEvent / Event List blocks from SimpleEvents will not work then. As the Event List block getCurrentEvents method it its library calls:
So if I delete an event, it would still show in list. I'm probably wrong but I'll look.
$db = Loader::db(); if ($ctID == 'All Categories'){ $r = $db->Query("SELECT * FROM btAddEvent WHERE sdt>=CURDATE() ORDER BY sdt $ordering,st_a $ordering,st_h +0 $ordering, st_m $ordering"); }else{ $r = $db->Query("SELECT * FROM btAddEvent WHERE sdt>=CURDATE() AND ctID = '$ctID' ORDER BY sdt $ordering,st_a $ordering,st_h +0 $ordering, st_m $ordering"); }
So if I delete an event, it would still show in list. I'm probably wrong but I'll look.
Hmm – yeah someone might want to double-check that. Unless they've got that block set up to ignore versioning by including $btIncludeAll in the block controller, it will cause problems. We've gotten around this by joining SQL calls like this to CollectionVersions.cvIsApproved = 1 (which only includes blocks on approved pages.)
Well, it's a job for monday for me now. I'm OUTA HERE! Thanks for the help.
2. Blocks in concrete5 only get deleted when they aren't used anywhere – including in any old versions of the page. That's likely why you're not seeing this method run – the block is still active in an old version of the page. Try deleting all versions or deleting the page and see if it runs.