*

mheston

  • ***
  • 48 posts
Trying to customize search drop down menu
« on: December 08, 2021, 11:24:08 AM »
When I click on select category drop down menu it shows all categories. I would like to be able to click on a category and it takes me to that category without using search button. can this code be modified to do that.

<?php osc_categories_select('sCategory', null, __('Select a category', 'sigma')) ; ?>
« Last Edit: December 08, 2021, 11:26:40 AM by mheston »

*

MB Themes

Re: Trying to customize search drop down menu
« Reply #1 on: December 08, 2021, 01:02:34 PM »
@mheston
This can be achieved via jQuery, try this one:
Code: [Select]
<script>
$(document).ready(function() {
  $('#cat_id').on('change', function() {
    window.location.href = "https://yoursite.com/index.php?page=search&sCategory=" + $(this).val();
 });
});
</script>

Selector (#cat_id) and redirect url (yoursite.com) should be updated.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mheston

  • ***
  • 48 posts
Re: Trying to customize search drop down menu
« Reply #2 on: December 08, 2021, 04:08:15 PM »
k thanks, ill try that if i can find where to put it.

*

MB Themes

Re: Trying to customize search drop down menu
« Reply #3 on: December 09, 2021, 09:38:55 AM »
With script tags to any HTML file, without script tags to any .js file.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mheston

  • ***
  • 48 posts
Re: Trying to customize search drop down menu
« Reply #4 on: December 09, 2021, 11:48:05 AM »
Thank you very much. I also have another mod I am trying to figure out. In search sidebar I removed "your search" and "subscribe to this search" sections to only show the sub categories. On mobile view only when I click on a main category I would like it to automatically show the filter first so they can select a  sub category to go to. Desktop view I want to leave normal.

Can I add something like <div class="wrap  isDesktop Ismobile">  to main.php home-cats section.

I think this is the code for the filter toggle, I am not sure how to implement it. I added a pic of my search sidebar.

<div class="actions">
        <a href="#" class="resp-toogle show-filters-btn btn btn-secondary"><?php _e('Show filter','sigma'); ?></a>

        <!--   START sort by     -->
        <span class="see_by btn btn-secondary">
          <span><?php _e('Sort by', 'sigma'); ?>:</span>
          <?php
          $orders = osc_list_orders();
          $current = '';
          foreach($orders as $label => $params) {
            $orderType = ($params['iOrderType'] == 'asc') ? '0' : '1';
            if(osc_search_order() == $params['sOrder'] && osc_search_order_type() == $orderType) {
              $current = $label;
            }
          }
          ?>
          <label><?php echo $current; ?> <i class="fa fa-angle-down"></i></label>
          <?php $i = 0; ?>
          <ul>
            <?php
            foreach($orders as $label => $params) {
              $orderType = ($params['iOrderType'] == 'asc') ? '0' : '1'; ?>
              <?php if(osc_search_order() == $params['sOrder'] && osc_search_order_type() == $orderType) { ?>
                <li><a class="current" href="<?php echo osc_esc_html(osc_update_search_url($params)); ?>"><?php echo $label; ?></a></li>
              <?php } else { ?>
                <li><a href="<?php echo osc_esc_html(osc_update_search_url($params)); ?>"><?php echo $label; ?></a></li>
              <?php } ?>
              <?php $i++; ?>
            <?php } ?>
          </ul>
        </span>

*

MB Themes

Re: Trying to customize search drop down menu
« Reply #5 on: December 09, 2021, 11:54:42 AM »
@mheston
Ideal way to hide something or hide something just on mobile is via CSS and media queries.
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mheston

  • ***
  • 48 posts
Re: Trying to customize search drop down menu
« Reply #6 on: December 09, 2021, 12:21:24 PM »
I dont want to hide the filter I just want it to show first right after clicking on a main category on mobile view
« Last Edit: December 09, 2021, 12:38:21 PM by mheston »

*

MB Themes

Re: Trying to customize search drop down menu
« Reply #7 on: December 09, 2021, 12:58:07 PM »
@mheston
There are just limited options to realign elements between desktop & mobile.
Easiest way is to change float:left; to float:right; on all elements in same level.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mheston

  • ***
  • 48 posts
Re: Trying to customize search drop down menu
« Reply #8 on: December 09, 2021, 01:18:06 PM »
code im trying to mod -


<div id="home-cats">
  <h2><?php _e('Main Categories', 'sigma'); ?></h2>

  <div class="wrap "example" isDesktop isMobile">
    <?php while(osc_has_categories()) { ?>
      <a href="<?php echo osc_search_category_url(); ?>">
        <div class="icon" <?php if(osc_category_color() <> '') { ?>style="color:<?php echo osc_category_color(); ?>;"<?php } ?>>
          <i class="<?php echo (osc_category_icon() <> '' ? osc_category_icon() : 'far fa-share-square'); ?>"></i>
        </div>

        <strong><?php echo osc_category_name(); ?></strong>   " example" if ismobile show filter or show div class="refine"> after clicking on category name




       
« Last Edit: December 09, 2021, 01:23:34 PM by mheston »

*

MB Themes

Re: Trying to customize search drop down menu
« Reply #9 on: December 09, 2021, 01:21:30 PM »
@mheston
Unfortunately it is not possible to debug issues just from parts of codes when talking about HTML and design  :'(
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots