Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #582938

    Hi,

    we want to change the Portfolio/Masonry Options to Filter Style.

    I want to add checkboxes and show/hide items every time a user clicks on checkboxes. The basically needs is the posibility of show more than one category at the same time.

    I made a child theme for actual changes (we made a lot :) ) and I’m search the way to change this. Please, anyone that tell us what action/filter/function we need to look to do necessary changes?

    Thanks,
    Victor

    #583032

    Hi Victor!

    Everything is possible, but that would need a lot of work to be done.

    You can contact one of our Customization Contractors, who will help you out with the process.

    Let us know if we could do anything else, regarding our theme

    Best regards,
    Basilis

    #584101

    Hey Guys, very disappointed, I’m not paying support for get this templated answer. I think that is not complex question and answer. I have been forced in do a deep investigation in your code, this is my answer to my question:

    First of all you need to know that i’m using a child theme because I want to update enfold in a future. I think (but not tested) that this code works in normal enfold functions.php but i wrote this code in child theme functions.php :

    
    add_action( 'init', function () {
    	
    	//we need new portfolio class extending actual portfolio class
    	class ebavs_portfolio extends avia_sc_portfolio {
    
    		//this method is called when shortcode needs to render, we need override and then copy and paste original content 
    		public function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
    		{
    			$atts['class'] = !empty($meta['custom_class']) ? $meta['custom_class'] : "";
    			
    			if(current_theme_supports('avia_template_builder_custom_post_type_grid'))
    			{
    			    if(isset($atts['link']))
    			    {
    			        $atts['link'] = explode(',', $atts['link'], 2 );
    			        $atts['taxonomy'] = $atts['link'][0];
    			
    			        if(isset($atts['link'][1]))
    			        {
    			            $atts['categories'] = $atts['link'][1];
    			        }
    			    }
    			
    				if(empty($atts['post_type']) || !current_theme_supports('add_avia_builder_post_type_option'))
    				{
    					$atts['post_type'] = get_post_types();
    				}
    
    				if(is_string($atts['post_type'])) $atts['post_type'] = explode(',', $atts['post_type']);
    			}
    			
    			$atts['fullscreen'] = ShortcodeHelper::is_top_level();
    
    			// HERE WE CHANGE $grid TO NEW OBJECT
    			$grid = new ebavs_post_grid($atts);
    			$grid->query_entries();
    			$portfolio_html = $grid->html();
    		
    			if(!ShortcodeHelper::is_top_level()) 
    			return $portfolio_html . '<!-- ebavs -->';
    			
    			
    			$params['class'] = "main_color avia-no-border-styling avia-fullwidth-portfolio ".$meta['el_class'];
    			$params['open_structure'] = false;
    			$params['id'] = !empty($atts['id']) ? AviaHelper::save_string($atts['id'],'-') : "";
    			$params['custom_markup'] = $meta['custom_markup'];
    			
    			//we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before
    			if(isset($meta['index']) && $meta['index'] == 0) $params['close'] = false;
    			if(!empty($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section )) $params['close'] = false;
    				
    			$output  =  avia_new_section($params);
    			$output .= $portfolio_html;
    			$output .= avia_section_after_element_content( $meta , 'after_portfolio' );
    			
    			return $output . '<!-- ebavs -->';
    		}
    
    	}
    
    	// Create new Grid class and extends the original
    	class ebavs_post_grid extends avia_post_grid { 
    
    		// override sort buttons, this methods render html for sort bar
    		protected function sort_buttons($entries, $params)
    		{
    			//get all categories that are actually listed on the page
    			$categories = get_categories(array(
    				'taxonomy'	=> $params['taxonomy'],
    				'hide_empty'=> 0
    			));
    
    			$current_page_cats 	= array();
    			$cat_count 			= array();
    			$display_cats 		= is_array($params['categories']) ? $params['categories'] : array_filter(explode(',',$params['categories']));
    
    			foreach ($entries as $entry)
    			{
    				if($current_item_cats = get_the_terms( $entry->ID, $params['taxonomy'] ))
    				{
    					if(!empty($current_item_cats))
    					{
    						foreach($current_item_cats as $current_item_cat)
    						{
    							if(empty($display_cats) || in_array($current_item_cat->term_id, $display_cats))
    							{
    								$current_page_cats[$current_item_cat->term_id] = $current_item_cat->term_id;
    
    								if(!isset($cat_count[$current_item_cat->term_id] ))
    								{
    									$cat_count[$current_item_cat->term_id] = 0;
    								}
    
    								$cat_count[$current_item_cat->term_id] ++;
    							}
    						}
    					}
    				}
    			}
    
    			// DRAW HERE YOUR HTML
    			$output = 'new sort buttons';
    			return $output;
    			
    		}
    
    	}
    
    	// Look for builder Avia Object
    	global $builder;
    
    	// Magic here, change portfolio class by our new class
    	$builder->shortcode_class['avia_sc_portfolio'] = new ebavs_portfolio( $builder ); 
    	
    	// init new object
    	$builder->shortcode_class['avia_sc_portfolio']->init();
    
    	// and replace the named class for shortcode
    	$builder->shortcode[$builder->shortcode_class['avia_sc_portfolio']->config['shortcode']] = 'ebavs_portfolio';
    
    	// this shortcode have a heavy css and js components, you can add your new js and css in this point
    },'100');
    

    As you can see only few lines of code explaining how you can override portfolio sort buttons, masonry is similar.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Change Portfolio/Masonry Sort Options to checkboxes’ is closed to new replies.