markup. * * @param mixed $icon Icon value: array { unicode, type, weight } or "unicode||type||weight". * @param string $css_class Wrapper class. * * @return string */ public static function render_icon($icon, $css_class) { if (empty($icon)) { return ''; } if (is_array($icon)) { $uni = $icon['unicode'] ?? ''; $type = $icon['type'] ?? 'divi'; $wt = $icon['weight'] ?? '400'; } else { $parts = explode('||', (string) $icon); $uni = $parts[0] ?? ''; $type = $parts[1] ?? 'divi'; $wt = $parts[2] ?? '400'; } if ('' === $uni) { return ''; } $font = 'fa' === $type ? 'FontAwesome' : 'ETmodules'; if (function_exists('dtq_inject_fa_icons')) { dtq_inject_fa_icons($uni . '||' . $type . '||' . $wt); } $glyph = function_exists('dtq_resolve_icon_unicode') ? dtq_resolve_icon_unicode($uni) : $uni; return sprintf( '%4$s', esc_attr($css_class), esc_attr($font), esc_attr($wt), esc_html($glyph) ); } /** * Server-side render for the Image Carousel slide. * * @param array $attrs Block attributes. * @param string $content Block content (unused). * @param object $block Parsed block. * @param object $elements Module elements helper. * * @return string */ public static function render_callback($attrs, $content, $block, $elements) { $advanced = $attrs['module']['advanced'] ?? []; $card_preset = $advanced['cardPreset']['desktop']['value'] ?? 'custom'; $content_type = $advanced['contentType']['desktop']['value'] ?? 'normal'; $content_position = $advanced['contentPosition']['desktop']['value'] ?? 'bottom'; $content_alignment = $advanced['contentAlignment']['desktop']['value'] ?? 'left'; $image_hover_anim = $advanced['imageHoverAnimation']['desktop']['value'] ?? 'none'; $overlay_on_hover = $advanced['overlayOnHover']['desktop']['value'] ?? 'off'; $use_button = $advanced['useButton']['desktop']['value'] ?? 'off'; // Photo. The D5 upload field stores the image as an object // (`{ src, ... }`); accept both that and a plain URL string. $photo_val = $attrs['photo']['innerContent']['desktop']['value'] ?? ''; $photo_src = is_array($photo_val) ? ($photo_val['src'] ?? '') : $photo_val; $photo_alt = $attrs['photo']['advanced']['alt']['desktop']['value'] ?? ''; $img = ''; // Pinch to Zoom and Parallax Captions are set on the carousel. $slide_opts = CarouselEngine::slide_options(CarouselEngine::parent_advanced($block)); if (!empty($photo_src)) { $img = sprintf( '%2$s', esc_url($photo_src), esc_attr($photo_alt) ); if ($slide_opts['zoom']) { $img = '
' . $img . '
'; } } // Overlay. $overlay = ''; if ('on' === $overlay_on_hover) { $overlay_icon = $advanced['overlayIcon']['desktop']['value'] ?? ''; $overlay_glyph = self::render_icon($overlay_icon, 'dtq-overlay-icon dtq-et-icon'); $overlay = sprintf('
%1$s
', $overlay_glyph); } $figure = sprintf('
%1$s%2$s
', $overlay, $img); // Texts. $title = $elements->render(['attrName' => 'title']); $sub_title = $elements->render(['attrName' => 'subTitle']); $title_text = $attrs['title']['innerContent']['desktop']['value'] ?? ''; $sub_text = $attrs['subTitle']['innerContent']['desktop']['value'] ?? ''; // Button. $button = ''; if ('on' === $use_button) { $button_text = DynamicValue::resolve($advanced['buttonText']['desktop']['value'] ?? 'Click Here'); $button_link = DynamicValue::resolve($advanced['buttonLink']['desktop']['value'] ?? ''); $button_target = ($advanced['buttonTarget']['desktop']['value'] ?? 'off') === 'on' ? ' target="_blank"' : ''; $button_icon = $advanced['buttonIcon']['desktop']['value'] ?? ''; $button_glyph = self::render_icon($button_icon, 'dtq-btn-icon'); $button = sprintf( '
%3$s%4$s
', esc_url($button_link ?: '#'), $button_target, $button_glyph, esc_html($button_text) ); } // Content block — only when a title or subtitle exists (mirrors D4). $content_block = ''; if ('' !== $title_text || '' !== $sub_text) { $content_block = sprintf( '
%3$s%4$s%5$s
', esc_attr($content_alignment), esc_attr($content_type), $title, $sub_title, $button, null === $slide_opts['parallax'] ? '' : sprintf(' data-swiper-parallax="-%d"', $slide_opts['parallax']) ); } // Order: content above figure when normal + top, else below. $is_bottom = !('normal' === $content_type && 'top' === $content_position); $item_html = sprintf( '', esc_attr($image_hover_anim), $is_bottom ? '' : $content_block, $figure, $is_bottom ? $content_block : '', esc_attr($card_preset) ); return Module::render( [ 'orderIndex' => $block->parsed_block['orderIndex'] ?? 0, 'storeInstance' => $block->parsed_block['storeInstance'] ?? null, 'id' => $block->parsed_block['id'], 'name' => $block->block_type->name, 'moduleCategory' => $block->block_type->category, 'attrs' => $attrs, 'elements' => $elements, 'classnamesFunction' => [self::class, 'module_classnames'], 'stylesComponent' => [self::class, 'module_styles'], 'scriptDataComponent' => [self::class, 'module_script_data'], 'children' => [ $elements->style_components(['attrName' => 'module']), $item_html, ], ] ); } }