Reassign page variables values
basicaly i have a custom template field"whatsnew" with two field values as "link" and "weight". So they are stored as page_variables. Now i want to rearrange weight base on another values "wn_articles" array order. everything is fine. The only problem is that after save, i am not able to save the updated value to the field. So i think that may because i did not assign the modified value to the $post array, so the page variables are not saved. I reassign the modified values to $this->normalzed_save_data, but not working, what can i do in this case.
// class extended from page_model
function on_after_update($v)
{
$values=$this->normalized_save_data;
$id=$v['id'];
if(!empty($values['wn_articles'])){
$total=count($values['wn_articles'])*2+1;
$new_order=array();
foreach($values['wn_articles'] as $k=>$v){
$new_order[$v]=$total-$k*2;
}
foreach($values['whatsnew'] as $a){
if(isset($a['link']))
$a['weight']=$new_order[$a['link']];
}
$this->normalized_save_data=$values;
}
return $v;
}
Comments
http://docs.getfuelcms.com/general/layouts#layouts_custom_classes
public function post_process_saved_values($values){ $CI =& get_instance(); $CI->load->module_model(FUEL_FOLDER, 'fuel_pages_model'); $CI->load->module_model(FUEL_FOLDER, 'fuel_pagevariables_model'); //... your code here }
Does that make sense?