Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

How to disable wrapper section for specific shortcode?

Open maiakhoa opened this issue 11 years ago • 13 comments

Hi team,

Do we have any way to disable wrapper section for specific shortcode ? Currently, We have 2 type of shortcode : column and section, can we have another type to process in the Corrector ?

Thanks

maiakhoa avatar Jan 12 '15 12:01 maiakhoa

I found a config to disable for whole Page Builder extension : "disalbe_correction". It's good if we have the same for each short-code :)

maiakhoa avatar Jan 12 '15 13:01 maiakhoa

Hi @maiakhoa,

I understand what are you saying, but can you tell me more about your use case, what kind of shortcode do you want to create, how should it look in the page builder (in the backend): is it something custom like the section or column shortcodes, or is it ordinary like the rest all the shortcodes from the Content elements tab. Please also provide some code for me to understand what kind of html do you want the shortcode to generate in the frontend.

rockalife avatar Jan 12 '15 13:01 rockalife

Hi @rockalife , Currently, I'm using bootstrap for the theme, so I have a slider shortcode and I don't want it's wrapped by Section and Row. It will have a padding of "Container" class. I can handle it in the Section shortcode if I can have the name of that short-code.

<section>
  <div class="container"> //Gen by Section shortcode
    <div class"row> //Gen by Row shortcode
       <div class="column"> //Gen by Column shortcode
           Slider Code
       </div>
    </div>
  </div>
</section>

The thing I want as below :

<section>
       Slider Code
</section>

maiakhoa avatar Jan 12 '15 13:01 maiakhoa

I understood, currently this is not possible, could you rewrite the css for your slider div and give it some negative margin so it would stretch outside of the column and the column's padding would not affect it ?

rockalife avatar Jan 12 '15 15:01 rockalife

ok thank @rockalife

maiakhoa avatar Jan 12 '15 16:01 maiakhoa

Hi ThemeFuse,

I think I have the same kind of problematic.

If I'm not wrong when I add a shortcode, it's always wrapped inside a section. Why doing this? At least could this behavior be optional.

If we want the section wrapped, we just have to put our shortcode inside a section block…

My idea to solve this is to override the section shortcode with an option to wrap it or not:

With wrap attr:

<section>//Gen by Section shortcode
  <div class="container"> //Gen by Section shortcode
    <div class="row> //Gen by Row shortcode
       <div class="column"> //Gen by Column shortcode
           My shortcode code (can be a text block for instance)
       </div>
    </div>
  </div>
</section>

Without wrap attr:

    <div class="row> //Gen by Row shortcode
       <div class="column"> //Gen by Column shortcode
           My shortcode code (can be a text block for instance)
       </div>
    </div>

The stupid think is that the user will have to nest his shortcode in a section to remove this section.

Am I wrong? Is it possible to do it an other way? Would it be possible to not render this section code if the the shortcode is not inside a section?

I think that the same happen with row and column.

Thanks.

flody avatar Mar 27 '15 15:03 flody

@flody :+1: if anything is outside the section or row , it should render without the wrappers.

danyj avatar Mar 27 '15 18:03 danyj

All current themes that run on Unyson use this behavior and will break the design/html if we will change it. So there should be a settings parameter to enable/disable it (by default enabled).

P.S. I have no idea how it works and if it will be possible to change/fix this issue, I just wanted to say about the settings parameter.

ghost avatar Mar 27 '15 19:03 ghost

yes , param would be fine , default enabled to take care of legacy

danyj avatar Mar 27 '15 19:03 danyj

:+1: . It should be supported param to disable

dylan-ngo11 avatar Mar 28 '15 03:03 dylan-ngo11

Currently there is a filter, and you can try to debug and check two arrays and decide what to return (this seems a little complicated, but it's a solution until that config parameter will be added)

function _filter_theme_fw_ext_page_builder_item_correction_complete(
    $corrected_items,
    $corrector_instance,
    $initial_items
) {
    // debug
    {
        ob_start();
        fw_print($initial_items, $corrected_items);
        FW_Flash_Messages::add(fw_rand_md5(), ob_get_clean());
    }

    return $corrected_items;
}
add_filter(
    'fw_ext_page-builder_items_correction_complete',
    '_filter_theme_fw_ext_page_builder_item_correction_complete',
    10,
    3
);

ghost avatar Jun 20 '15 21:06 ghost

https://github.com/ThemeFuse/Unyson/issues/799

ghost avatar Oct 01 '15 09:10 ghost

### If you want to completely remove fw wrapper from your custom specific shortcode. add this on your shortcode config.php file

your-theme/framework-customizations/extensions/shortcodes/shortcodes/{my-shortcode-name}/config.php

**`'disable_correction' => true,`**

It will remove the fw default fw-container div and fw-row div.

$cfg['page_builder'] = array(
	'disable_correction' => true,
	'title'       => __( 'My shortcode', 'fw' ),
	'description' => __( 'desc', 'fw' ),
	'tab'         =>  __( 'My Element', 'fw' ),
);

Next step : past below code on the same file (config.php) and it will remove fw default main wrapper div class="fw-page-builder-content"

add_filter ( 'fw_ext_page_builder_output_content_wrapper', function(){
	return false;
} );

mhsohag11 avatar Sep 21 '20 05:09 mhsohag11