Not updated for CUSTOM MODULES yet
Hi guys, thanks for stopping by. I haven’t updated this post yet to accommodate front-end accessibility. I’m working on it and hope ti have it updated soon.
Sincerely,
Rebekah
Divi and the Blurb
Again with the Blurb? I know, I know. I am a little obsessed. This time we’re making it flip. Right now card style layouts are all the rage. This is tutorial will incorporate another wonderful tutorial from Tymapnus. There are many styles to chose from but, I am using #7 with some modifications. I want mine to turn to the right instead of turn down. Example below:
A Flipping Blurb
A Flipping Blurb
A Flipping Blurb
Necessary Notes!
The Code
Of course, you can find the files on github. The first thing we are going to do is create a new file for our custom modules folder. The file is going to be creatively called, card_blurb.php. In this file we are going to add our custom module data. The real changes happen around line 401 with the changing of the output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
< ?php class FDL_Builder_Module_Card_Blurb extends ET_Builder_Module { function init() { $this->name = esc_html__( 'Card Blurb', 'et_builder' ); $this->slug = 'et_pb_blurb4'; $this->fb_support = true; $this->main_css_element = '%%order_class%%.et_pb_blurb'; $this->whitelisted_fields = array( 'title', 'url', 'url_new_window', 'use_icon', 'font_icon', 'icon_color', 'use_circle', 'circle_color', 'use_circle_border', 'circle_border_color', 'image', 'alt', 'icon_placement', 'animation', 'background_layout', 'text_orientation', 'content_new', 'admin_label', 'module_id', 'module_class', 'max_width', 'use_icon_font_size', 'icon_font_size', 'max_width_tablet', 'max_width_phone', 'icon_font_size_tablet', 'icon_font_size_phone', ); $et_accent_color = et_builder_accent_color(); $this->fields_defaults = array( 'url_new_window' => array( 'off' ), 'use_icon' => array( 'off' ), 'icon_color' => array( $et_accent_color, 'add_default_setting' ), 'use_circle' => array( 'off' ), 'circle_color' => array( $et_accent_color, 'only_default_setting' ), 'use_circle_border' => array( 'off' ), 'circle_border_color' => array( $et_accent_color, 'only_default_setting' ), 'icon_placement' => array( 'top' ), 'animation' => array( 'top' ), 'background_layout' => array( 'light' ), 'text_orientation' => array( 'center' ), 'use_icon_font_size' => array( 'off' ), ); $this->advanced_options = array( 'fonts' => array( 'header' => array( 'label' => esc_html__( 'Header', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} h4, {$this->main_css_element} h4 a", ), ), 'body' => array( 'label' => esc_html__( 'Body', 'et_builder' ), 'css' => array( 'line_height' => "{$this->main_css_element} p", ), ), ), 'background' => array( 'settings' => array( 'color' => 'alpha', ), ), 'border' => array(), 'custom_margin_padding' => array( 'css' => array( 'important' => 'all', ), ), ); $this->custom_css_options = array( 'blurb_image' => array( 'label' => esc_html__( 'Blurb Image', 'et_builder' ), 'selector' => '.et_pb_main_blurb_image', ), 'blurb_title' => array( 'label' => esc_html__( 'Blurb Title', 'et_builder' ), 'selector' => 'h4', ), 'blurb_content' => array( 'label' => esc_html__( 'Blurb Content', 'et_builder' ), 'selector' => '.et_pb_blurb_content', ), ); } function get_fields() { $et_accent_color = et_builder_accent_color(); $image_icon_placement = array( 'top' => __( 'Top', 'et_builder' ), ); if ( ! is_rtl() ) { $image_icon_placement['left'] = esc_html__( 'Left', 'et_builder' ); } else { $image_icon_placement['right'] = esc_html__( 'Right', 'et_builder' ); } $fields = array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'The title of your blurb will appear in bold below your blurb image.', 'et_builder' ), ), 'url' => array( 'label' => esc_html__( 'Url', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'If you would like to make your blurb a link, input your destination URL here.', 'et_builder' ), ), 'url_new_window' => array( 'label' => esc_html__( 'Url Opens', 'et_builder' ), 'type' => 'select', 'option_category' => 'configuration', 'options' => array( 'off' => esc_html__( 'In The Same Window', 'et_builder' ), 'on' => esc_html__( 'In The New Tab', 'et_builder' ), ), 'description' => esc_html__( 'Here you can choose whether or not your link opens in a new window', 'et_builder' ), ), 'use_icon' => array( 'label' => esc_html__( 'Use Icon', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'basic_option', 'options' => array( 'off' => esc_html__( 'No', 'et_builder' ), 'on' => esc_html__( 'Yes', 'et_builder' ), ), 'affects' => array( 'font_icon', 'use_circle', 'icon_color', 'image', 'alt', ), 'description' => esc_html__( 'Here you can choose whether icon set below should be used.', 'et_builder' ), ), 'font_icon' => array( 'label' => esc_html__( 'Icon', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'class' => array( 'et-pb-font-icon' ), 'renderer' => 'et_pb_get_font_icon_list', 'renderer_with_field' => true, 'description' => esc_html__( 'Choose an icon to display with your blurb.', 'et_builder' ), 'depends_default' => true, ), 'icon_color' => array( 'label' => esc_html__( 'Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'description' => esc_html__( 'Here you can define a custom color for your icon.', 'et_builder' ), 'depends_default' => true, ), 'use_circle' => array( 'label' => esc_html__( 'Circle Icon', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'configuration', 'options' => array( 'off' => esc_html__( 'No', 'et_builder' ), 'on' => esc_html__( 'Yes', 'et_builder' ), ), 'affects' => array( 'use_circle_border', 'circle_color', ), 'description' => esc_html__( 'Here you can choose whether icon set above should display within a circle.', 'et_builder' ), 'depends_default' => true, ), 'circle_color' => array( 'label' => esc_html__( 'Circle Color', 'et_builder' ), 'type' => 'color', 'description' => esc_html__( 'Here you can define a custom color for the icon circle.', 'et_builder' ), 'depends_default' => true, ), 'use_circle_border' => array( 'label' => esc_html__( 'Show Circle Border', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'layout', 'options' => array( 'off' => esc_html__( 'No', 'et_builder' ), 'on' => esc_html__( 'Yes', 'et_builder' ), ), 'affects' => array( 'circle_border_color', ), 'description' => esc_html__( 'Here you can choose whether if the icon circle border should display.', 'et_builder' ), 'depends_default' => true, ), 'circle_border_color' => array( 'label' => esc_html__( 'Circle Border Color', 'et_builder' ), 'type' => 'color', 'description' => esc_html__( 'Here you can define a custom color for the icon circle border.', 'et_builder' ), 'depends_default' => true, ), 'image' => array( 'label' => esc_html__( 'Image', 'et_builder' ), 'type' => 'upload', 'option_category' => 'basic_option', 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ), 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ), 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ), 'depends_show_if' => 'off', 'description' => esc_html__( 'Upload an image to display at the top of your blurb.', 'et_builder' ), ), 'alt' => array( 'label' => esc_html__( 'Image Alt Text', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Define the HTML ALT text for your image here.', 'et_builder' ), 'depends_show_if' => 'off', ), 'icon_placement' => array( 'label' => esc_html__( 'Image/Icon Placement', 'et_builder' ), 'type' => 'select', 'option_category' => 'layout', 'options' => $image_icon_placement, 'description' => esc_html__( 'Here you can choose where to place the icon.', 'et_builder' ), ), 'animation' => array( 'label' => esc_html__( 'Image/Icon Animation', 'et_builder' ), 'type' => 'select', 'option_category' => 'configuration', 'options' => array( 'top' => esc_html__( 'Top To Bottom', 'et_builder' ), 'left' => esc_html__( 'Left To Right', 'et_builder' ), 'right' => esc_html__( 'Right To Left', 'et_builder' ), 'bottom' => esc_html__( 'Bottom To Top', 'et_builder' ), 'off' => esc_html__( 'No Animation', 'et_builder' ), ), 'description' => esc_html__( 'This controls the direction of the lazy-loading animation.', 'et_builder' ), ), 'background_layout' => array( 'label' => esc_html__( 'Text Color', 'et_builder' ), 'type' => 'select', 'option_category' => 'color_option', 'options' => array( 'light' => esc_html__( 'Dark', 'et_builder' ), 'dark' => esc_html__( 'Light', 'et_builder' ), ), 'description' => esc_html__( 'Here you can choose whether your text should be light or dark. If you are working with a dark background, then your text should be light. If your background is light, then your text should be set to dark.', 'et_builder' ), ), 'text_orientation' => array( 'label' => esc_html__( 'Text Orientation', 'et_builder' ), 'type' => 'select', 'option_category' => 'layout', 'options' => et_builder_get_text_orientation_options(), 'description' => esc_html__( 'This will control how your blurb text is aligned.', 'et_builder' ), ), 'content_new' => array( 'label' => esc_html__( 'Content', 'et_builder' ), 'type' => 'tiny_mce', 'option_category' => 'basic_option', 'description' => esc_html__( 'Input the main text content for your module here.', 'et_builder' ), ), 'max_width' => array( 'label' => esc_html__( 'Image Max Width', 'et_builder' ), 'type' => 'text', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'mobile_options' => true, 'validate_unit' => true, ), 'use_icon_font_size' => array( 'label' => esc_html__( 'Use Icon Font Size', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'font_option', 'options' => array( 'off' => esc_html__( 'No', 'et_builder' ), 'on' => esc_html__( 'Yes', 'et_builder' ), ), 'affects' => array( 'icon_font_size', ), 'tab_slug' => 'advanced', ), 'icon_font_size' => array( 'label' => esc_html__( 'Icon Font Size', 'et_builder' ), 'type' => 'range', 'option_category' => 'font_option', 'tab_slug' => 'advanced', 'default' => '96px', 'range_settings' => array( 'min' => '1', 'max' => '120', 'step' => '1', ), 'mobile_options' => true, 'depends_default' => true, ), 'max_width_tablet' => array ( 'type' => 'skip', 'tab_slug' => 'advanced', ), 'max_width_phone' => array ( 'type' => 'skip', 'tab_slug' => 'advanced', ), 'icon_font_size_tablet' => array( 'type' => 'skip', 'tab_slug' => 'advanced', ), 'icon_font_size_phone' => array( 'type' => 'skip', 'tab_slug' => 'advanced', ), 'disabled_on' => array( 'label' => esc_html__( 'Disable on', 'et_builder' ), 'type' => 'multiple_checkboxes', 'options' => array( 'phone' => esc_html__( 'Phone', 'et_builder' ), 'tablet' => esc_html__( 'Tablet', 'et_builder' ), 'desktop' => esc_html__( 'Desktop', 'et_builder' ), ), 'additional_att' => 'disable_on', 'option_category' => 'configuration', 'description' => esc_html__( 'This will disable the module on selected devices', 'et_builder' ), ), 'admin_label' => array( 'label' => esc_html__( 'Admin Label', 'et_builder' ), 'type' => 'text', 'description' => esc_html__( 'This will change the label of the module in the builder for easy identification.', 'et_builder' ), ), 'module_id' => array( 'label' => esc_html__( 'CSS ID', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'option_class' => 'et_pb_custom_css_regular', ), 'module_class' => array( 'label' => esc_html__( 'CSS Class', 'et_builder' ), 'type' => 'text', 'option_category' => 'configuration', 'tab_slug' => 'custom_css', 'option_class' => 'et_pb_custom_css_regular', ), ); return $fields; } function shortcode_callback( $atts, $content = null, $function_name ) { $module_id = $this->shortcode_atts['module_id']; $module_class = $this->shortcode_atts['module_class']; $title = $this->shortcode_atts['title']; $url = $this->shortcode_atts['url']; $image = $this->shortcode_atts['image']; $url_new_window = $this->shortcode_atts['url_new_window']; $alt = $this->shortcode_atts['alt']; $background_layout = $this->shortcode_atts['background_layout']; $text_orientation = $this->shortcode_atts['text_orientation']; $animation = $this->shortcode_atts['animation']; $icon_placement = $this->shortcode_atts['icon_placement']; $font_icon = $this->shortcode_atts['font_icon']; $use_icon = $this->shortcode_atts['use_icon']; $use_circle = $this->shortcode_atts['use_circle']; $use_circle_border = $this->shortcode_atts['use_circle_border']; $icon_color = $this->shortcode_atts['icon_color']; $circle_color = $this->shortcode_atts['circle_color']; $circle_border_color = $this->shortcode_atts['circle_border_color']; $max_width = $this->shortcode_atts['max_width']; $max_width_tablet = $this->shortcode_atts['max_width_tablet']; $max_width_phone = $this->shortcode_atts['max_width_phone']; $use_icon_font_size = $this->shortcode_atts['use_icon_font_size']; $icon_font_size = $this->shortcode_atts['icon_font_size']; $icon_font_size_tablet = $this->shortcode_atts['icon_font_size_tablet']; $icon_font_size_phone = $this->shortcode_atts['icon_font_size_phone']; $module_class = ET_Builder_Element::add_module_order_class( $module_class, $function_name ); if ( 'off' !== $use_icon_font_size ) { $font_size_values = array( 'desktop' => $icon_font_size, 'tablet' => $icon_font_size_tablet, 'phone' => $icon_font_size_phone, ); et_pb_generate_responsive_css( $font_size_values, '%%order_class%% .et-pb-icon', 'font-size', $function_name ); } if ( '' !== $max_width_tablet || '' !== $max_width_phone || '' !== $max_width ) { $max_width_values = array( 'desktop' => $max_width, 'tablet' => $max_width_tablet, 'phone' => $max_width_phone, ); et_pb_generate_responsive_css( $max_width_values, '%%order_class%% .et_pb_main_blurb_image img', 'max-width', $function_name ); } if ( is_rtl() && 'left' === $text_orientation ) { $text_orientation = 'right'; } if ( is_rtl() && 'left' === $icon_placement ) { $icon_placement = 'right'; } if ( '' !== $title && '' !== $url ) { $title = sprintf( '<a href="%1$s"%3$s>%2$s</a>', esc_url( $url ), esc_html( $title ), ( 'on' === $url_new_window ? ' target="_blank"' : '' ) ); } if ( '' !== $title ) { $title = "<h4>{$title}</h4>"; } if ( '' !== trim( $image ) || '' !== $font_icon ) { if ( 'off' === $use_icon ) { $image = sprintf( '<img src="%1$s" alt="%2$s" class="et-waypoint%3$s" />', esc_url( $image ), esc_attr( $alt ), esc_attr( " et_pb_animation_{$animation}" ) ); } else { $icon_style = sprintf( 'color: %1$s;', esc_attr( $icon_color ) ); if ( 'on' === $use_circle ) { $icon_style .= sprintf( ' background-color: %1$s;', esc_attr( $circle_color ) ); if ( 'on' === $use_circle_border ) { $icon_style .= sprintf( ' border-color: %1$s;', esc_attr( $circle_border_color ) ); } } $image = sprintf( '<span class="et-pb-icon et-waypoint%2$s%3$s%4$s" style="%5$s">%1$s</span>', esc_attr( et_pb_process_font_icon( $font_icon ) ), esc_attr( " et_pb_animation_{$animation}" ), ( 'on' === $use_circle ? ' et-pb-icon-circle' : '' ), ( 'on' === $use_circle && 'on' === $use_circle_border ? ' et-pb-icon-circle-border' : '' ), $icon_style ); } $image = sprintf( '<div class="et_pb_main_blurb_image">%1$s</div>', ( '' !== $url ? sprintf( '<a href="%1$s"%3$s>%2$s</a>', esc_url( $url ), $image, ( 'on' === $url_new_window ? ' target="_blank"' : '' ) ) : $image ) ); } $class = " et_pb_module et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}"; $output = sprintf( '<div %5$s class="et_pb_blurb%4$s%6$s%7$s ch-grid2"> <div class="et_pb_blurb_content ch-item2"> <div class="ch-info2"> <div class="ch-info-front2"> %2$s %3$s </div> <div class="et_pb_blurb_container ch-info-back2"> %1$s </div> </div> </div> <!-- .et_pb_blurb_content --> </div> <!-- .et_pb_blurb -->', $this->shortcode_content, $image, $title, esc_attr( $class ), ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ), ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ), sprintf( ' et_pb_blurb_position_%1$s', esc_attr( $icon_placement ) ), esc_url( $url ), ( 'on' === $url_new_window ? ' target="_blank"' : '' ) ); return $output; } } new FDL_Builder_Module_Card_Blurb(); |
1 2 3 4 5 6 7 8 9 10 11 |
<?php function divi_child_theme_setup() { if ( class_exists('ET_Builder_Module')) { get_template_part( 'custom-modules/card_blurb' ); $cbm3 = new FDL_Builder_Module_Card_Blurb(); add_shortcode( 'et_pb_blurb4', array($cbm3, '_shortcode_callback') ); } } add_action('et_builder_ready', 'divi_child_theme_setup'); |
Now, the Card Blurb will be a new module.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
.ch-info-front2 .et_pb_main_blurb_image {margin-bottom: 0;} .ch-item2 {width: 100%; height: 100%;position: relative;cursor: default;-webkit-perspective: 900px; -moz-perspective: 900px; -o-perspective: 900px; -ms-perspective: 900px; perspective: 900px;} .ch-info2{position: absolute;width: 100%;height: 100%;-webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -o-transform-style: preserve-3d; -ms-transform-style: preserve-3d; transform-style: preserve-3d;} /* ------------ Turn to the right 90deg --------------- */ .ch-item2:hover .ch-info-front2 { -webkit-transform: translate3d(280px,0,0) rotate3d(0,1,0,90deg); -moz-transform: translate3d(280px,0,0) rotate3d(0,1,0,90deg); -o-transform: translate3d(280px,0,0) rotate3d(0,1,0,90deg); -ms-transform: translate3d(280px,0,0) rotate3d(0,1,0,90deg); transform: translate3d(280px,0,0) rotate3d(0,1,0,90deg); opacity: 0; } .ch-item2:hover .ch-info-back2 { -webkit-transform: rotate3d(0,1,0,0deg); -moz-transform: rotate3d(0,1,0,0deg); -o-transform: rotate3d(0,1,0,0deg); -ms-transform: rotate3d(0,1,0,0deg); transform: rotate3d(0,1,0,0deg); opacity: 1; } .ch-info2 .ch-info-back2 { -webkit-transform: translate3d(0,0,-280px) rotate3d(0,1,0,-90deg); -moz-transform: translate3d(0,0,-280px) rotate3d(0,1,0,-90deg); -o-transform: translate3d(0,0,-280px) rotate3d(0,1,0,-90deg); -ms-transform: translate3d(0,0,-280px) rotate3d(0,1,0,-90deg); transform: translate3d(0,0,-280px) rotate3d(0,1,0,-90deg); opacity: 0; } .ch-info2>div {display: block;position: absolute;width: 100%; height: 100%;background-position: center center;-webkit-transition: all 0.4s linear; -moz-transition: all 0.4s linear; -o-transition: all 0.4s linear; -ms-transition: all 0.4s linear; transition: all 0.4s linear; -webkit-transform-origin: 0% 50%; -moz-transform-origin: 0% 50%; -o-transform-origin: 0% 50%; -ms-transform-origin: 0% 50%; transform-origin: 0% 50%;} .ch-info2 p {color: #00a69a;padding: 10px 5px; font-style: italic;margin:30px;font-size: 18px;border-top: 1px solid rgba(255,255,255,0.5);line-height:1.2em;} .ch-info2 p a { display: block; color:#00a69a;font-style: normal;font-weight: 700;text-transform: uppercase;font-size: 18px; letter-spacing: 1px;padding-top: 4px;} .ch-info2 p a:hover {color:#f38020;} .ch-grid2 {margin: 20px 0 0 0;padding: 0;list-style: none;display: block;text-align: center;width: 100%;} .ch-grid2:after,.ch-item2:before {content: ''; display: table;} .ch-grid2:after {clear: both;} .ch-grid2 {width: 300px;height:300px;} /* setting the blurbs height and width */ |
That’s it, you should be ready to rock. This effect can be rather tricky. Because of the absolute positioning of several elements, a fixed height is required. In this example, it’s 300 X 300. This may or may not work for you. You can change the size in the last line of the css. You can play with the transform values and change the direction that the blurb rotates. It can be both fun and frustrating to figure out. You could also incorporate a different Tymapanus example that have the same structure.