Adds option to display 'Items related to this' section
This commit is contained in:
parent
d86c882a0a
commit
9a41192595
|
@ -29,4 +29,11 @@ $options = [
|
||||||
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-list.php', [
|
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-list.php', [
|
||||||
'prefix' => $post_type->name . '_single',
|
'prefix' => $post_type->name . '_single',
|
||||||
], false)
|
], false)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ( function_exists('tainacan_the_related_items_carousel') ) {
|
||||||
|
$options[] = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/items-related-to-this.php', [
|
||||||
|
'prefix' => $post_type->name . '_single',
|
||||||
|
'enabled' => 'no'
|
||||||
|
], false);
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ $options = [
|
||||||
'units' => blocksy_units_config([
|
'units' => blocksy_units_config([
|
||||||
[
|
[
|
||||||
'unit' => 'px',
|
'unit' => 'px',
|
||||||
'min' => 80,
|
'min' => 42,
|
||||||
'max' => 200,
|
'max' => 200,
|
||||||
]
|
]
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (! isset($prefix)) {
|
||||||
|
$prefix = '';
|
||||||
|
} else {
|
||||||
|
$prefix = $prefix . '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isset($enabled)) {
|
||||||
|
$enabled = 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = [
|
||||||
|
$prefix . 'display_items_related_to_this' => [
|
||||||
|
'label' => __( 'Display "Items related to this"', 'tainacan-blocksy' ),
|
||||||
|
'type' => 'ct-panel',
|
||||||
|
'switch' => true,
|
||||||
|
'value' => $enabled,
|
||||||
|
'sync' => blocksy_sync_whole_page([
|
||||||
|
'prefix' => $prefix,
|
||||||
|
]),
|
||||||
|
'inner-options' => [
|
||||||
|
$prefix . 'items_related_to_this_max_items_per_screen' => [
|
||||||
|
'label' => __( 'Max amount of items per slide', 'blocksy' ),
|
||||||
|
'type' => 'ct-number',
|
||||||
|
'design' => 'inline',
|
||||||
|
'value' => 6,
|
||||||
|
'min' => 1,
|
||||||
|
'max' => 10,
|
||||||
|
'sync' => ''
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
|
@ -115,7 +115,25 @@ $options = [
|
||||||
'sync' => blocksy_sync_single_post_container([
|
'sync' => blocksy_sync_single_post_container([
|
||||||
'prefix' => $prefix
|
'prefix' => $prefix
|
||||||
])
|
])
|
||||||
]
|
],
|
||||||
|
blocksy_rand_md5() => [
|
||||||
|
'type' => 'ct-condition',
|
||||||
|
'condition' => [
|
||||||
|
$prefix . 'display_items_related_to_this' => 'yes',
|
||||||
|
],
|
||||||
|
'options' => [
|
||||||
|
$prefix . 'section_items_related_to_this_label' => [
|
||||||
|
'label' => __( 'Label for the "Items related to this" section', 'tainacan-blocksy' ),
|
||||||
|
'desc' => __( 'Leave it blank for not displaying any label.', 'tainacan-blocksy' ),
|
||||||
|
'type' => 'text',
|
||||||
|
'design' => 'block',
|
||||||
|
'value' => __( 'Items related to this', 'tainacan-blocksy' ),
|
||||||
|
'sync' => blocksy_sync_single_post_container([
|
||||||
|
'prefix' => $prefix
|
||||||
|
])
|
||||||
|
],
|
||||||
|
]
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
|
@ -11,6 +11,7 @@ $prefix = blocksy_manager()->screen->get_prefix();
|
||||||
|
|
||||||
$page_structure_type = get_theme_mod( $prefix . '_page_structure_type', 'type-dam');
|
$page_structure_type = get_theme_mod( $prefix . '_page_structure_type', 'type-dam');
|
||||||
$template_columns_style = '';
|
$template_columns_style = '';
|
||||||
|
$display_items_related_to_this = get_theme_mod( $prefix . '_display_items_related_to_this', 'no' ) === 'yes';
|
||||||
|
|
||||||
if ($page_structure_type == 'type-gm' || $page_structure_type == 'type-mg') {
|
if ($page_structure_type == 'type-gm' || $page_structure_type == 'type-mg') {
|
||||||
$column_documents_attachments_width = 60;
|
$column_documents_attachments_width = 60;
|
||||||
|
@ -85,6 +86,11 @@ add_action( 'blocksy:single:top', function() use ( $page_structure_type, $prefix
|
||||||
|
|
||||||
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-metadata' );
|
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-metadata' );
|
||||||
do_action( 'tainacan-blocksy-single-item-after-metadata' );
|
do_action( 'tainacan-blocksy-single-item-after-metadata' );
|
||||||
|
|
||||||
|
if ($display_items_related_to_this) {
|
||||||
|
tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-items-related-to-this' );
|
||||||
|
do_action( 'tainacan-blocksy-single-item-after-items-related-to-this' );
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
$prefix = blocksy_manager()->screen->get_prefix();
|
||||||
|
|
||||||
|
$section_label = get_theme_mod($prefix . '_section_items_related_to_this_label', __( 'Items related to this', 'tainacan-blocksy' ));
|
||||||
|
$max_items_per_screen = get_theme_mod($prefix . '_items_related_to_this_max_items_per_screen', 6);
|
||||||
|
|
||||||
|
if ( function_exists('tainacan_the_related_items_carousel') && (get_theme_mod( $prefix . '_display_items_related_to_this', 'no' ) === 'yes') && tainacan_has_related_items() ) : ?>
|
||||||
|
|
||||||
|
<section class="tainacan-item-section tainacan-item-section--items-related-to-this">
|
||||||
|
|
||||||
|
<?php if ( get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes' && $section_label != '') : ?>
|
||||||
|
<h2 class="tainacan-single-item-section" id="tainacan-item-items-related-to-this-label">
|
||||||
|
<?php echo esc_html( $section_label ); ?>
|
||||||
|
</h2>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="tainacan-item-section__items-related-to-this">
|
||||||
|
<?php
|
||||||
|
tainacan_the_related_items_carousel([
|
||||||
|
// 'class_name' => 'mt-2 tainacan-single-post',
|
||||||
|
// 'collection_heading_class_name' => 'title-content-items',
|
||||||
|
'collection_heading_tag' => 'h3',
|
||||||
|
'carousel_args' => [
|
||||||
|
'max_items_per_screen' => $max_items_per_screen
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
?>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
<?php endif; ?>
|
Loading…
Reference in New Issue