Fuel Pages Hooks...can I register for them?
I've written an Image Slider module. I want to be able to add multiple instances to a page and be able to reorder them. I have a "Widgets" tab that I created in the MY_Fuel_Layouts.php, but how would I go about populating that tab with a list of available widgets?
I was hoping I could do it through a module or model hook for the Fuel Pages. Is this possible?
Comments
.... 'widgets' => array('type' => 'multi', 'model' => 'widgets', 'sorting' => TRUE)
This field will give you a multi select field and the sorting option will allow you to drag and drop the ordering. The end result is a set of saved IDs in order. Then in your view/layout/block (where ever you are rendering it), you can use your model's "find_within" method like so to grab those records:
$CI->load->model('widgets'); $widgets = $CI->widgets->find_within($widgets);
I have no errors on the page and I can manually add draggable/droppable to other elements.
---
Ok, we must have had an error somewhere because the multi-select/sorting UI element is present now, BUT when I save the page the values aren't being saved properly. The value is always 1 in the DB. When the edit page reloads all of my selections are gone.
'mode' => 'multi'
Without it, it will default to checkboxes if there are less then or equal to 5 options and the sorting doesn't work with that.
'model' => array('widgets' => 'my_options_list');
When I move one of the items to the right column, the respective option gets selected="selected"
Thanks for your assistance BTW. I'm loving FuelCMS
The span "_val" is the index to the corresponding value. The select widget looks correct as well. The next step would be to see what that looks like in the post or right before it's getting saved. To do that we'll have to get our hands a little dirty. Do you see the proper values being passed in the post if you add something like this to the fuel/modules/fuel/controllers/pages.php file right after line 117 or so?
echo '<pre>'; print_r($_POST); echo '</pre>';
Is there perhaps another field named "widgets" that's overwriting the value?
--
There is a hidden input on the edit page form as such:
foreach($posted as $key => $val) { if (strncmp('vars--', $key, 6) === 0) { $new_key = end(explode('--', $key)); $vars[$new_key] = $val; } }
If I filter it out where $vars is being set, everything is fine.
When $key is either 'vars--widgets_on_page' or 'vars--exists_vars--widgets_on_page' this end(explode('--', $key)); returns 'widgets_on_page'
'exists_'.$params['name'];
TO
'exists_'.$params['orig_name'];
does that work?