Editing integrity

Hi Themeco,

Which PHP file do I have to copy from X into the x-child theme to be able to create a second widget bar on the top left in Integrity?

Hi Wilfried,

Please consider that the theme code customization is outside of our support scope and we will not be able to implement such a functionality for you. but we will do our best to show you what is the standard way of doing the customization in X.

You do not need to copy a file, you need to open up the functions.php file of your Child Theme and add the function below there:

if ( ! function_exists( 'x_legacy_header_widget_areas' ) ) :
  function x_legacy_header_widget_areas() {

    $n = x_get_option( 'x_header_widget_areas' );

    if ( ! apply_filters( 'x_legacy_cranium_headers', true ) || $n == 0 || x_is_blank( 3 ) || x_is_blank( 6 ) || x_is_blank( 7 ) || x_is_blank( 8 ) ) {
      return;
    }

    ?>

    <div id="x-widgetbar" class="x-widgetbar x-collapsed" data-x-toggleable="x-widgetbar" data-x-toggle-collapse="1" aria-hidden="true" aria-labelledby="x-btn-widgetbar">
      <div class="x-widgetbar-inner">
        <div class="x-container max width">

          <?php

          $i = 0; while ( $i < $n ) : $i++;

            $last = ( $i == $n ) ? ' last' : '';

            echo '<div class="x-column x-md x-1-' . $n . $last . '">';
              dynamic_sidebar( 'header-' . $i );
            echo '</div>';

          endwhile;

          ?>

        </div>
      </div>
    </div>

    <a href="#" id="x-btn-widgetbar" class="x-btn-widgetbar collapsed" data-x-toggle="collapse-b" data-x-toggleable="x-widgetbar" aria-selected="false" aria-expanded="false" aria-controls="x-widgetbar">
      <i class="x-icon-plus-circle" data-x-icon="&#xf055;"><span class="visually-hidden"><?php _e( 'Toggle the Widgetbar', '__x__' ); ?></span></i>
    </a>

    <?php

  }
  add_action( 'x_after_site_end', 'x_legacy_header_widget_areas' );
endif;

The function above is responsible for adding the widgetbar. You can edit the function as you wish to do the changes there.

As a general rule of thumb, please read the articles below if you are interested in customizing the code of the theme:

https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x/208

Thank you.

1 Like

Thank you, Christopher,

Just to clarify, Is it the same function I’d use to add another widget bar if I already have one existing?

Hi @wmmajaliwa,

You can’t add it multiple times, but you can modify the code to add more widget areas. You’ll have to customize that code and not add the same code.

Plus, the above code only implements the default header widget areas which are built-in to the theme. If you’ll add more then it has no connection with the theme’s pre-registered sidebar. Hence, you’ll have to register another sidebar too for your custom widgets to work. I recommend contacting a developer since it’s complex.

Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.