0
我有一个任务:Magento。从自定义表单保存静态块。无法保存商店
从前端静态块保存。
,我试过的代码是
public function savebannerAction(){
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$post = $this->getRequest()->getPost();
$block_id = $post['block_id'];
$content = $post['content'];
$data = Mage::getModel('cms/block')->load($block_id)->getData();
$data['content'] = $content;
Mage::getModel('cms/block')->load($block_id)->setData($data)->save();
$this->_redirectUrl($_SERVER['HTTP_REFERER']);
}
,只需
public function savebannerAction(){
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$post = $this->getRequest()->getPost();
$block_id = $post['block_id'];
$content = $post['content'];
Mage::getModel('cms/block')->load($block_id)->setContent($content)->save();
$this->_redirectUrl($_SERVER['HTTP_REFERER']);
}
但在这两个方面是我得到的是:内容被保存,但商店都DROP掉空。所以阻止从当前选定的商店中删除。或者我还应该将form_key包含到数据中?