Is there a work around for the problems mentioned in this topic:
http://www.getfuelcms.com/forums/discussion/comment/2799/#Comment_2799I have the same issues. How do other people do it when they want the customer to be able to upload images when they create pages in the admin.
Another question that I have. Is it possible to have the same option of choosing a picture like in you can do in a model when you use fields that end with image?
Comments
... 'file' => array(), 'file_upload' => array('type' => 'file') ...
For the second question, you can use the class "asset_select" in your form field like so:
$fields['my_image']['class'] = 'asset_select';
To have the images select from a different folder you can do the following
$fields['my_image']['class'] = 'asset_select images/blog';
If I use $file in my layout than it the picture shows up even if the page was saved with an empty upload field, because the picture name remains in the file field.
However the problem with inline editing is not resolved. If I use
fuel_var('file_upload','')
then I can still not upload a new picture from within inline editing mode. Maybe I understood you wrong.
Where do I put the:
$fields['my_image']['class'] = 'asset_select';
Also in the MY_fuel_layout? Because that did not work for me.
Then the last question.. If I try to upload an image from another folder than the assets folder I get the error "The filetype you are attempting to upload is not allowed." The assets map is writable. What could this mean?
This is not possible with a page that is created via the admin. How could I do this? Can you combine models with pages that are created in the admin?
By the way. Every side-block should be able to be different per page.
Because these pages have a fixed amount of input fields as defined in MY_fuel_layouts.php they are 'static' in a way that it is never possible to make something where you do not know how much pictures someone is going to upload?
... $options = array(); if (defined('FUEL_ADMIN')){ $CI =& get_instance(); $options = $CI->drop_down_lists_model->options_list(); } $config['layout_fields']['main']['my_images'] = array('type' => 'multi', 'options' => $options, 'class' => 'add_edit side_block');
All the managing and uploading is done in your side-block simple module outside of the pages module. In the pages module, you are just associating the images for that page.
I realize this may not be ideal. However, we will have a much better solution for this in the next release.
I changed my approach a little. This is what I am doing know. I have my simple module and I added an extra column to the table. This extra column contains the page name of the page (the body_var) when you create a page in the admin.
I added an on_before_save() hook:
function on_before_save() { $data = array( 'page' => 'test' ); $this->db->insert('test_banner_rechts', $data); }
What I want is to dynamically insert the body_class in the table. So if you are the a page projects than I want to add 'projects' to my column called page. My problem is that I don't how I could send the body_class, which is available in the view off course, to the on_before_save hook.
Is this possible at all?
I use session control to store the $body_var variable in the view so that the model can use this session variable. This is the same solution as in http://www.getfuelcms.com/forums/discussion/722 .
This works fine. But I hope another solution is available some time?
Now I can add content via a simple module with fueledit('create'. Adding pictures is also not a problem. BUT when I try to change a picture nothing happens. I know that the model is loaded when I click the button but after that nothing happens. This is my code in the view:
$this->session->set_userdata('test_session', $body_class); $CI =& get_instance(); $model_name = 'test_banner_rechts_model'; $tabel_name = 'test_banner_rechts'; $CI->load->model($model_name); $CI->$model_name->set_page_variable($body_class); $kolom = $CI->$model_name->find_all(array('page' => $body_class), 'page desc'); echo fuel_edit('create', 'Voeg een plaatje toe', $tabel_name);?> <?php foreach ($kolom as $value) : ?> <?php echo fuel_edit($value->id, 'Pas het plaatje aan', $tabel_name); ?> <div class="banner"><h2><?php echo $value->titel ?></h2> <img src="<?php echo $this->asset->img_path('banner/'.$value->image); ?>" alt="" /> <a href="<?php echo $value->link ?>"> <?php echo $value->linktext ?> </a> </div> <?php endforeach ?>
So my question is Admin do you know a way around this bug?
fuel_edit('create|body_class=myval', 'Create', 'test_banner_rechts')?>
We are still working out some bugs and documentation but need to find some time to wrap things up and release it as a beta.
rotate the gripper but anyway I'm looking for opportunities to select from a list of assets for a particular page
any idea
'header_image' => array ('description' => 'Header Image', 'class' => 'asset_select images', 'upload_path' => assets_server_path ('', 'images')), 'header_upload_image' => array ('type' => 'file', 'description' => 'Header Image'),
I have also been looking at the new fuel_edit but I do not see what you mentioned. There is one sentence: "Alternatively, you can now also just pass the entire object and it will generate the id, label, module and published values automatically". But this is not clear to me.
My question is (how) can I pass initialization parameters?
<?php $widgets = fuel_model('widgets'); ?> <ul> <?php foreach($widgets as $widget) : ?> <li> <?=fuel_edit($widget->id, 'Edit Widget:'.$widget->name, 'widgets')?> <?=$widget->name?>: <?=$widget->description?> </li> <?php endforeach;?>
Now you can just do the following:
<?php $widgets = fuel_model('widgets'); ?> <ul> <?php foreach($widgets as $widget) : ?> <li> <?=fuel_edit($widget)?> <?=$widget->name?>: <?=$widget->description?> </li> <?php endforeach;?>