Unyson
Unyson copied to clipboard
How to Modify Page Builder Column Shortcode?
Hello, i'm trying to modify Column shortcode, but i have a problem when i wanna get the Section parent properties to Column view (or column Class)
this is current column view code
<?php if (!defined('FW')) die('Forbidden');
$class = fw_ext_builder_get_item_width('page-builder', $atts['width'] . '/frontend_class');
?>
<div class="<?php echo esc_attr($class); ?>">
<div class="builder-column-wrapper">
<?php echo do_shortcode($content); ?>
</div>
</div>
I want to ask, how to:
- Get section properties (i'm adding "Gap" option on section)
- Get total of columns on same row
- Get column current position (additional)
I really need this for adding some inline css styles to my column tag with this rules:
new_gap = GAP * ({TOTAL_COLUMN} - 1)
column_width = 100/{TOTAL_COLUMN}
width: calc(column_width% - (new_gap * (1/{TOTAL_COLUMN})) )
margin-right: {GAP}
So, if i have 3 column in 1 row with 30px gap, each column will generating css like this:
style="calc(33.33% - (60px * 0.33)); margin-right:30px"
And i need column current position to add a "last-col" or "first-col" class.
Thank you.
I would you recommend to find another solution for this. It's really a bad practice to create bidirectional dependencies.