Your Time:
Our Time:
← Back to discussions

✓ Adding css class to section shortcode element

Need help with a different issue? Search the forums or open a new ticket.
Open a support ticket
Resolved
Posted in: Hostme V2

This topic has 3 replies, 2 voices, and was last updated 10 years ago by Fem.

  • 2016-10-21 at 2:41 pm
    Support Expired
    #17249
    juroo
    Participant
    • Topics: 3
    • Replies: 3
    • Total posts: 6
    • Post count: 6

    Hi, is there any parameter for adding a css class to section shortcode element? I see there is such an option for ex. button element.
    Or is there a fix solution, ex. adding a div with align style option inside the section?
    Thanks.

    2016-10-21 at 5:45 pm
    #17266
    Fem
    Keymaster
    • Topics: 2
    • Replies: 8473
    • Total posts: 8475
    • Post count: 6003

    Replace the below code with “custom_css” parameter in hostmev2/framework/shortcode/general in place of section shortcode.

    // Section
    //--------------------------------------------------------]
    if( !function_exists('sys_section')){
    	function sys_section($atts, $content = null, $code) {
    		extract(shortcode_atts(array(
    			'bgcolor'	=> '',
    			'image'	        => '',
    			'textcolor'	=> '',
    			'padding'	=> '',
    			'custom_class'  => '',
    		), $atts));
    			
    		$textcolor = $textcolor ? 'color:'.$textcolor.';':'';
    		$padding = $padding ? 'padding:'.$padding.';' : '' ;
    	
    		if( !empty($textcolor) || !empty($padding)){
    			$section_extras = ' style="'.$padding.$textcolor.'"';
    		}else{
    			$section_extras = '';
    		}
    		$custom_cssclass = $custom_class;
    	
    		$bgcolor = $bgcolor ? 'background-color:'.$bgcolor.';':'';
    		$image = $image ? 'background-image:url('.$image.');':'';
    		if( !empty($bgcolor) || !empty($image)){
    			$inner_extras = ' style="'.$bgcolor.$image.'"';
    		}else{
    			$inner_extras = '';
    		}
    		$out = '<div class="section_row clearfix ' . $custom_cssclass . '" '.$section_extras.'>';
    		if ( $inner_extras != '' ) {
    			$out .= '<div class="section_bg" '.$inner_extras.'></div>';
    		}
    		if ( $image ) {
    			$out .= '<div class="section_overlay"></div>';
    		}
    		$out .= '<div class="section_inner">'.do_shortcode($content).'</div></div>';
    	
    		return $out;
    	}
    	add_shortcode('section', 'sys_section');
    }
    2016-10-21 at 6:34 pm
    Support Expired
    #17267
    juroo
    Participant
    • Topics: 3
    • Replies: 3
    • Total posts: 6
    • Post count: 6

    Great, works perfect! Thank you 🙂
    Now I know how to add some more parameters if I would need.

    In case of future theme updates, will this be included in your code?

    • This reply was modified 10 years ago by juroo.
    2016-10-24 at 10:26 am
    #17292
    Fem
    Keymaster
    • Topics: 2
    • Replies: 8473
    • Total posts: 8475
    • Post count: 6003

    Yes, it will be included.

    We are setting this topic to be resolved. If you wish to update this topic please reply here instead of creating another topic.

You must be logged in to reply to this topic.