Display a specific slider on a page
Hello there, I have created a switch button to activate and select which slider the client wants to display on is current page. But I cannot figurate how to display it on front end. I have already tried this without result.
<?php fw()->extensions->get('slider')->render_slider(20, array(
'width' => 300,
'height' => 200
)); ?>
Moreover, I would like the slider to be displayed based of the selection,so a dynamic ID. In fact, I cannot change the code each time I create a new slider.
Thank you for you work and your support.

@Alex-Ascet you must echo the slider, because the render_slider method return a view.
Thank you for the quick answer. You rock. I definitely need more help to understand and learn how to use correctly this framework.
Here is my options in theme/options/slider.php this is linked with theme/options/posts/page.php
$options = array(
'demo' => array(
'title' => __( 'Slider', 'unyson' ),
'type' => 'tab',
'options' => array(
'demo_multi_picker_switch' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'gadget' => array(
'label' => __( 'Slider', 'unyson' ),
'type' => 'switch',
'right-choice' => array(
'value' => 'slider',
'label' => __( 'On', 'unyson' )
),
'left-choice' => array(
'value' => 'noslider',
'label' => __( 'Off', 'unyson' )
),
'value' => 'yes',
'desc' => __( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'unyson' ),
'help' => sprintf( "%s \n\n'\"<br/><br/>\n\n <b>%s</b>",
__( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'unyson' ),
__( 'Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium',
'unyson' )
),
),
),
'choices' => array(
'slider' => array(
'slideron' => array(
'type' => 'select',
'label' => __( 'Select the slider', 'unyson' ),
'choices' => fw()->extensions->get('slider')->get_populated_sliders_choices('$slider->ID'),
),
),
),
'show_borders' => false,
),
),
),
);
and her my output
<?php $sliderid = ( function_exists( 'fw_get_db_settings_option' ) ) ? fw_get_db_settings_option('slideron') : '';
if( !empty( $sliderid ) ) :
?>
<?php echo fw()->extensions->get('slider')->render_slider(echo $sliderid, array(
'width' => 300,
'height' => 200
)); ?>
<?php endif ?>
I cannot figurate how to catch the slider id based on the select button and then call it in the front-end. I have already spent hours without results. Very frustrated. Thank you in advance.
@Alex-Ascet you must use fw_get_db_post_option method instead of fw_get_db_settings_option method , please take a look at our documentation about database helpers.
@Alex-Ascet please answer if the response helped you and close the issue.
@llemurya Thank you very much for your time, must appreciate. I am close to find a solution but I have got still difficulty to display this particular option:
$options = array(
'demo' => array(
'title' => __( 'Slider', 'unyson' ),
'type' => 'tab',
'options' => array(
'demo_multi_picker_switch' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'gadget' => array(
'label' => __( 'Slider', 'unyson' ),
'type' => 'switch',
'right-choice' => array(
'value' => 'slider',
'label' => __( 'On', 'unyson' )
),
'left-choice' => array(
'value' => 'noslider',
'label' => __( 'Off', 'unyson' )
),
'value' => 'yes',
'desc' => __( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'unyson' ),
'help' => sprintf( "%s \n\n'\"<br/><br/>\n\n <b>%s</b>",
__( 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'unyson' ),
__( 'Sed ut perspiciatis, unde omnis iste natus error sit voluptatem accusantium doloremque laudantium',
'unyson' )
),
),
),
'choices' => array(
'slider' => array(
'slideron' => array(
'type' => 'select',
'label' => __( 'Select the slider', 'unyson' ),
'choices' => array(
'slider' => array(
'slideron' => array(
'type' => 'select',
'label' => __( 'Select the slider', 'unyson' ),
/// I think that the issue is this line, how to call it...
'choices' => fw()->extensions->get('slider')->get_populated_sliders_choices('$slider->ID'),
),
),
),
),
),
),
'show_borders' => false,
),
),
),
);
/// Output
<div id="main-content" class="main-content">
<?php $slider = ( function_exists( 'fw_get_db_post_option' ) ) ? fw_get_db_post_option(get_the_ID(),'demo') : '';
if( !empty( $slider ) ) : ?>
// Issue is maybe here, I cannot find the way to call the "choices" selector and the post_ID from the slider posts
<?php echo $slider['slideron'] ?>
<?php endif; ?>
I hope that you can help me @llemurya. Thank you very much in advance.
@llemurya Thank you for your time. There is a way to make a donation for this framework and your time? Thank you
@Alex-Ascet
print this in a view and you will see the options
fw_print ( $atts ) ;
than use it like
echo fw_akg('demo_multi_picker_switch/gadget',$atts );
Thank you @danyj. I have read a lot of your topics. Thank you for your involvement on this framework by the way. Sorry to be a pain. Could you give me more info regarding this process or a topics to look at? Do I need to create a view.php for this? I am not lazy just confused, I have read so many feeds. Thank you for your time.
@Alex-Ascet soon I will respond you more concrete please wait some time before I answer.Thanks!
@Alex-Ascet use this options array and modify as you want.
<?php if ( ! defined( 'FW' ) ) {
die( 'Forbidden' );
}
$options = array(
'demo' => array(
'title' => __( 'Slider', 'unyson' ),
'type' => 'tab',
'options' => array(
'demo_multi_picker_switch' => array(
'type' => 'multi-picker',
'label' => false,
'desc' => false,
'picker' => array(
'gadget' => array(
'label' => __( 'Slider', 'unyson' ),
'type' => 'switch',
'right-choice' => array(
'value' => 'slideron',
'label' => __( 'On', 'unyson' )
),
'left-choice' => array(
'value' => 'slideroff',
'label' => __( 'Off', 'unyson' )
),
'value' => 'slideron',
),
),
'choices' => array(
'slideron' => array(
'slider' => array(
'type' => 'select',
'label' => __( 'Select the slider', 'unyson' ),
'choices' => fw()->extensions->get( 'slider' )->get_populated_sliders_choices()
)
),
'slideroff' => array(
'slider-off-select' =>
array(
'type' => 'html',
'label' => __( 'Select the slider', 'unyson' ),
'html' => 'HTML DEMO'
)
),
),
'show_borders' => false,
),
),
),
);