how to make site logo inline editable

edited February 2012 in Modules
Hi,
I want to make an editable site logo so the user can use inline_edit to upload and select an image from specified asset folder.

How should I approach this?

Comments

  • edited 3:08PM
    You can create a layout in your fuel/application/config/MY_fuel_layouts.php file like so (note the site_logo and site_logo_upload fields respectively):
    $config['layout_fields']['main'] = array( 'copy' => array('copy' => lang('layout_field_main_copy')), 'site_logo' => array('class' => 'asset_select'), 'site_logo_upload' => array('type' => 'file'), 'page_title' => array('label' => lang('layout_field_page_title')), 'meta_description' => array('label' => lang('layout_field_meta_description')), 'meta_keywords' => array('label' => lang('layout_field_meta_keywords')), 'body' => array('label' => lang('layout_field_body'), 'type' => 'textarea', 'description' => lang('layout_field_body_description')), 'body_class' => array('label' => lang('layout_field_body_class'),) );
    In your layout view file you can add the following to be able to select from the asset folder a new logo inline:
    <?php echo fuel_var('site_logo') ?>
    Uploading inline does not work as well at the moment however (which will be fixed in the next release).
  • edited 3:08PM
    Thanks a lot,

    I tried that, and uploading was the issue for me. I'll lookout for your pushes to the repo.

    also we have to assign site_logo page_var for every page then, right?
    can we use blocks for this?
    can we make layouts for blocks?
  • edited February 2012
    You're right Lance site_variables is for this.

    I tried to change the `value` field type for the site variables based on their name when editing and it's working.

    so how should I finalize this? I don't want to mess with David's code.
    create an advanced module based on sitevariables and define the field type in it's config file?
    add another controller and model to the fuel module and override the `form_fields` method?

    I commented out value_upload field, because it's not working in inline editing mode yet.

    MY_config.php
    $config['sitevar_fields']['logo_image'] = array('class' => 'asset_select');

    fuel/sitevariables_model.php
    function form_fields($values = array()){ $fields = parent::form_fields(); $fields['value']['class'] = 'markitup'; $CI =& get_instance(); $sitevar_fields = $CI->config->item('sitevar_fields'); if (isset($values['name']) AND isset($sitevar_fields[$values['name']])) { $myfield = $sitevar_fields[$values['name']]; $defaults = array('value' => '', 'type' => 'string'); $myfield = array_merge($defaults, $myfield); if ($myfield['type'] == 'string' AND substr($values['name'], -5) == 'image' OR substr($values['name'], -3) == 'img') { $upload_path = assets_server_path('', 'images'); $img = ''; if (!empty($values['id'])) { if (!empty($values['value'])) $img = '<div class="img_display"><img src="'.img_path($values['value']).'" style="float: right;"/></div>'; } // $fields['value'.'_upload'] = array('after_html' => $img, 'label' => '... OR upload an image', 'upload_path' => $upload_path, 'type' => 'file', 'overwrite' => TRUE); } $fields['value'] = array_merge($fields['value'], $myfield); } return $fields; }

    am I on the right track?
  • edited 3:08PM
    You should be able to overwrite the sitevariables_model without having to do it in the actual code by creating your own model that extends the sitevariables_model and then overwriting it in the config using the $config['module_overwrites'] in your fuel/application/config/MY_fuel_modules.php config file like so:
    .... $config['module_overwrites']['sitevariables'] = array('model_name' => 'my_sitevariables_model');
Sign In or Register to comment.