Select custom template in a block problem
Permalink
hi guys, i have figured out how to handle multi tables in edit.php and add.php and is working perfectly fine with my custom save($args) function and ofc inserting all the data i need correctly in each table but i got the weirdest error now.
when go to edit mode and select my block -- click -- custom template -- select my template -- press save it dumps me an SQL error cuz is trying to insert data [which it can't ofc cuz i have an unique index on the table] using the last values of add.php into my $btTable and doing this completely bypassing my custom save($args) function.
i verified my custom template and thereis no controller.php or anything like that could trigger and SQL insert, any of you have idea why in frigging hell select template is triggering a post?
when go to edit mode and select my block -- click -- custom template -- select my template -- press save it dumps me an SQL error cuz is trying to insert data [which it can't ofc cuz i have an unique index on the table] using the last values of add.php into my $btTable and doing this completely bypassing my custom save($args) function.
i verified my custom template and thereis no controller.php or anything like that could trigger and SQL insert, any of you have idea why in frigging hell select template is triggering a post?
![mnakalay](/files/avatars/75201.jpg)
I think you need to show us some code, at least you custom save function. Your whole controller would be even better.
i think you can use code shown below (in view.php of your block):
this should avoid code when site is in edit mode
<?php global $c; if ($c->isEditMode()) { //Do something f.e display <h2>view disabled in edit mode </h2> } else { // do your code } ?>
this should avoid code when site is in edit mode
this is a cool tip for another issue i have but my view php has only render code nothing sql in there.
the issue is selecting a custom template is behaving like im adding the block, aka calling concrete5 automaton version of save() but if i add a block in another page my custom save is called and works fine.
the issue is selecting a custom template is behaving like im adding the block, aka calling concrete5 automaton version of save() but if i add a block in another page my custom save is called and works fine.
here is my custom save function
note that this is the only code where i use sql for updates or insert everywhere else is only selects
note that if i remove all this code and just call i still get the insert error, so for some reason is bypassing the custom save function entirely
function save($args) { $bID = $this->getBlockObject()->getBlockID(); $CampaignName = $this->getValue($args[selectExistingCampaign], $this->getCampaigns()); if($args['update']) { var_dump($args); } else { switch($args[SelectCampaign]){ case 0: $sql = "UPDATE btItemSlideCampaign SET bID = '$bID', fID = '$bID' WHERE CampaignName = '$CampaignName';"; $db = Loader::db(); if ($db->Execute($sql) === false) { print 'error inserting: '.$db->ErrorMsg().'<BR>'; }
Viewing 15 lines of 36 lines. View entire code block.
note that this is the only code where i use sql for updates or insert everywhere else is only selects
note that if i remove all this code and just call
var_dump($args);
how about your template? Do you have more than just a view.php there? What kind of code?
would you mind showing us the whole controller.php? your problem seems to defy logic so it's pretty difficult to figure anything out with just pieces of code.
is driven me insane too cuz my controller is really small and the only sql part is the one i posted and i already debug it in 3 browser including firebug.
i even remove every other functions in controller and disable the CSS code and the issue persist.
the only thing i found weird that firebug show me was this in the custom template form
i think update_information is the culprit or at least is breaking and calling save() somehow.
i even remove every other functions in controller and disable the CSS code and the issue persist.
the only thing i found weird that firebug show me was this in the custom template form
<form id="ccmCustomTemplateForm" class="form-stacked clearfix" action="/index.php?cID=1&bID=210&arHandle=info+area&ccm_token=1347644992:c74c68e803425d75d885bdd8c973304a&btask=update_information&rcID=0" method="post" encoding="multipart/form-data" enctype="multipart/form-data">
i think update_information is the culprit or at least is breaking and calling save() somehow.
???? why do you have a form in the template? What is that form supposed to do?
that is not my code men, is a capture from firebug of the automatic generated concrete5 code
More and more confusing. Could you just upload the whole thing or is it confidential?