how to move search bar into header under logo

https://elgg.org/discussion/view/844566/move-the-search-box  (how to move search bar from header to sidebar)

 

I want to move the search bar which is in the sidebar to the header please, i found the opposite in a search (link above), i use aalborg theme.

 

How do i do this please ? 

 

thank you 

 

 

  • In function init{} of your start.php of your custom plugin/theme:

    //Search in Header
    
    elgg_extend_view('page/elements/header', 'search/header');
    
    // Remove search from Sidebar if you use Aarborg theme
    
    elgg_unextend_view('page/elements/sidebar', 'search/header');

    Your plugin should be after the activated aarborg_theme.

    BTW, you can use My plugin for these customizations

  • ok thank you, but i just want to grab it and move it, are you saying here i need to make a whole new theme ? i'm not quite understanding you sorry.

     

    i'll give the plugin a go thank you :) 

  • i need to make a whole new theme ?

    Yep. And this good practice to add your customizations (including future ones) in this plugin/theme.

  • i can't do a new theme sorry i'm far to busy and i don't really fully know how, i'm old, poorly and too busy to take on any more learning sorry.

     

     

     

  • what is that ?

    Sorry, man. I can't you help when you are:

    old, poorly and too busy to take on any more learning

     Of course, LOL.

  • it's a trouble, i am busy, i actually payed out over £400 to a coder friend past 2 months for fixes and help, he understands, i'll go ask him.

     

    thanks anyways, god bless you 

  • If you are using the Aalborg theme currently, there's a quick and dirty solution. The Aalborg theme does it the other way round by moving the search field from the header (Elgg default) to the sidebar by the following two lines in the aalborg_theme_init() function in it's start.php:

    elgg_unextend_view('page/elements/header', 'search/header');
    elgg_extend_view('page/elements/sidebar', 'search/header', 0);

    Commenting out these two lines and flushing the cache of Elgg via admin area should move the search field back to the header.

    Alternatively, you can create a simple plugin where you add as start.php (e.g. named "my_theme"):

    <?php
    
    elgg_register_event_handler('init','system','my_theme_init');
    
    function my_theme_init() {
    
        elgg_register_event_handler('pagesetup', 'system', 'aalborg_theme_pagesetup', 1000);
    
        // theme specific CSS
        elgg_extend_view('elgg.css', 'aalborg_theme/css');
    
        elgg_unextend_view('page/elements/sidebar', 'search/header', 0);
        elgg_extend_view('page/elements/header', 'search/header', 0);
    }

    and add also a manifest.xml (you can take a manifest.xml file from another plugin and modify it a little bit - you would need to adjust at least what's in the <name> and <id> tags).

    Then just place this plugin at the bottom of the plugin list, enable it and your done. If you already have a plugin that contains customization code for your site, you can add the two lines of code of the init function to the init function of this plugin of course. And you have no such plugin yet, you can create it now and use it to add any customizations you want to make in future to it.

  • thank you @iionly 

    i found the line in the start.php, what is 'commenting' ?

     

    elgg_unextend_view('page/elements/header', 'search/header');
    elgg_extend_view('page/elements/sidebar', 'search/header', 0);

    Commenting out these two lines and flushing the cache of Elgg via admin area should move the search field back to the header.