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?

 
mnakalay replied on at Permalink Reply
mnakalay
I think you need to show us some code, at least you custom save function. Your whole controller would be even better.
grosik replied on at Permalink Reply
grosik
i think you can use code shown below (in view.php of your block):
<?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
jrch2k10 replied on at Permalink Reply
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.
jrch2k10 replied on at Permalink Reply
here is my custom save function
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>';
               }


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);
i still get the insert error, so for some reason is bypassing the custom save function entirely
mnakalay replied on at Permalink Reply
mnakalay
how about your template? Do you have more than just a view.php there? What kind of code?
jrch2k10 replied on at Permalink Reply
basically like 800 LOC of CSS nothing more

my view.php is
<?php
defined('C5_EXECUTE') or die("Access Denied.");
$aBlocks = $controller->getSlider();
?>


and that function just do selects and print html code
mnakalay replied on at Permalink Reply
mnakalay
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.
jrch2k10 replied on at Permalink Reply
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

<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.
mnakalay replied on at Permalink Reply
mnakalay
???? why do you have a form in the template? What is that form supposed to do?
jrch2k10 replied on at Permalink Reply
that is not my code men, is a capture from firebug of the automatic generated concrete5 code
mnakalay replied on at Permalink Reply
mnakalay
More and more confusing. Could you just upload the whole thing or is it confidential?