Add new item to admin sidebar

edited January 2014 in Feature Requests
Hi, I want to add a custom items to the admin sidebar. I realized that the sidebar view is nav.php in /modules/fuel/views/_blocks. Also I saw that in modules/fuel/config/fuel_modules.php are some links of that sidebar.

My question is what is the correct configuration or the correct form to add an item to the admin sidebar?

Comments

  • edited 6:08PM
    It depends a little bit on where you want to insert the item. If you create an advanced module, you can add the following to your advanced module's config:
    $config['nav']['site']['my_module'] = 'My Module';
    This will be inserted under the SITE heading.

    For more control, you can set the 'nav_auto_arrange' property to FALSE:
    // will auto arrange the navigation into the normal order $config['nav_auto_arrange'] = FALSE;
    Then you could simply create your own navigation array:
    $config['nav'] = array(); $config['nav']['mysite'] = array( 'mysite/item1' => 'Item 1', 'mysite/item2' => 'Item 2', 'mysite/item3' => 'Item 3', );
  • edited 6:08PM
    Oh, thank you!! That worked, so far I don't need a submenu in the sidebar, so I didn't make my own navigation array, but If someday I'll need it, where should I create the navigation array?
  • edited 6:08PM
    You can create the navigation array in your MY_fuel.php file (or in an advanced modules config file).
  • edited 6:08PM
    Hi admin hope you are good and fine !
    i want to ask something how can i hide the related item window,i am using the location module and have done many customization in it ,i have a map on admin site which i showed when admin enters any address or location that map automatically pointing to that location and i have put the code in admin_main in modules/fuel/views/_layout/admin_main but the problem i am facing i have some other form doing different work and that map as well appears and i want to hide it ...i have looked for related_items but no success!
    please guide me thanks
  • edited November 2014
    let me show you admin_main...


    <?php
    // set some render variables based on what is in the panels array
    $no_menu = (!$this->fuel->admin->has_panel('nav')) ? TRUE : FALSE;
    $no_titlebar = (!$this->fuel->admin->has_panel('titlebar')) ? TRUE : FALSE;
    $no_actions = (!$this->fuel->admin->has_panel('actions') OR empty($actions)) ? TRUE : FALSE;
    $no_notification = (!$this->fuel->admin->has_panel('notification')) ? TRUE : FALSE;
    ?>

    <?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_header'); ?>














    function codeAddress() {


    g'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {

    //Latitude = results[0].geometry.location.lat();
    //Longitude = results[0].geometry.location.lng();

    var Latitude = results[0].geometry.location.lat();
    var Longitude = results[0].geometry.location.lng();
    var latlngPos = new google.maps.LatLng(latitude, longitude);

    $('#longitude').val(Longitude);
    $('#latitude').val(Latitude);

    //map show code goes here. . .
    //alert();
    var mapCanvas = document.getElementById('map');
    var mapOptions = {
    center: new google.maps.LatLng(Latitude,Longitude),
    zoom: 14,
    mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(mapCanvas, mapOptions);


    }


    function pakmap() {

    var latlngPos = new google.maps.LatLng(30.032776, 70.640759);


    var myOptions = {

    google.maps.event.addDomListener(window, 'load', initialize);






    fuel->admin->ui_cookie('leftnav_hide') === '1') ? ' class="nav_hide"' : ''; ?>>


    <?php if ($this->fuel->admin->has_panel('top')) : ?>

    <?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_top'); ?>
    <?php endif; ?>

    <?php if ($this->fuel->admin->has_panel('nav')) : ?>

    <?php $this->load->module_view(FUEL_FOLDER, '_blocks/nav'); ?>
    <?php endif; ?>


    ">

    <?php if ($this->fuel->admin->has_panel('titlebar')) : ?>

    <?php $this->load->module_view(FUEL_FOLDER, '_blocks/titlebar')?>
    <?php endif; ?>

    <?=$this->form->open('action="'.$form_action.'" method="'.((!empty($form_method)) ? $form_method : 'post').'" id="form" enctype="multipart/form-data"')?>

    <?php if ($this->fuel->admin->has_panel('actions') AND !empty($actions)) : ?>



    <?php /* ?><?=$this->form->open('action="'.$form_action.'" method="post" id="form_actions" enctype="multipart/form-data"')?><?php */ ?>
    <?php if (!empty($actions)) : ?>
    <?=$actions?>
    <?php endif; ?>
    <?php /* ?><?=$this->form->close()?><?php */ ?>


    <?php endif; ?>


    <?php if ($this->fuel->admin->has_panel('notification')) : ?>


    <?php if (!empty($notifications)) : ?>
    <?=$notifications?>
    <?php endif; ?>
    <?php if (!empty($pagination)): ?>

    <?php endif; ?>

    <?php endif; ?>


    <?php
    $main_content_class = '';
    if($no_actions AND $no_notification) :
    $main_content_class = 'noactions_nonotification';
    elseif($no_actions AND $no_titlebar) :
    $main_content_class = 'noactions_notitlebar';
    elseif ($no_titlebar) :
    $main_content_class = 'notitlebar';
    elseif ($no_actions) :
    $main_content_class = 'noactions';
    endif;
    ?>


    "<?=(!empty($main_content_class)) ? ' class="'.$main_content_class.'"' : ''?>>

    <?php /* ?><?=$this->form->open('action="'.$form_action.'" method="post" id="form" enctype="multipart/form-data"')?><?php */ ?>


    <?=$body?>

    <?=$this->form->hidden('fuel_inline', (int)$this->fuel->admin->is_inline())?>

    <?=$this->form->close()?>






    <?php $this->load->module_view(FUEL_FOLDER, '_blocks/fuel_footer'); ?>





    all things are working properly only the map div appears on different section of admin on right side not every where but like in category create etc
  • edited 6:08PM
    The related items are controlled in the locations_model::related_items method on the model. You can overwrite the model by extending that model and then specifying your new model in a module overwrite. The below is an example if you were to extend the locations_model and place your new model in fuel/applications/models/my_locations_model.php:
    $module_overwrites['locations_points']['model_location'] = 'app'; $module_overwrites['locations_points']['mode_name'] = 'my_locations_model';

    Then your my_locations_model.php file could look like the following:
    require_once(FUEL_PATH.'models/base_module_model.php'); class Locations_model extends Base_module_model { function related_items($values = array()) { return ''; } }
Sign In or Register to comment.