• Resolved WiSch

    (@wisch)


    Hi Fabio.

    First my thanks for your plugin!

    But I got a little question…
    I want to integrate a different slider on each of my subsites.
    So I choose to use the site-slug as the title of the slider to automatically get the right slide on the given page.

    In php it looks like this:
    global $post;
    $alias = $post->post_name;
    if ($alias && function_exists(‘crellySlider’)) {
    crellySlider($alias);
    }

    But additionally I want a fall back to a default slide if there’s no slide for the actual post/page.
    For that I have to test in a way like this
    if (!exists_crellySlider($alias)) {
    $alias=”default_crellySlider_name”
    }

    Is that possible? Maybe you can help me out?

    Thanks for your support,
    J?rg

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Fabio Rinaldi

    (@fabiorino)

    Hi!
    Yes, that’s possible.

    if(CrellySliderCommon::sliderExists($id)) {
        // Do something if slider exists
    }

    This function was not meant to be used as an API, that’s why it is not documented. But there’s no problem to use it ??

    Thread Starter WiSch

    (@wisch)

    Hi Fabio.

    Thanks for the reply, but I didn’t get it working.

    My code now looks like this:

    global $post;
    $alias = get_post_field( 'post_name', get_post() );
    if ($alias && function_exists('crellySlider')) {
    	if(CrellySliderCommon::sliderExists($alias)) {
    		crellySlider('standardslider');
    	} else {
    		crellySlider($alias);
    	}
    }

    If exists, the slide for the post_slug comes correct.
    If it not exists, nothing happend, even not integrating the slider “standardslider”.

    In the page-source I can find the comment “The Slider wasn’t found” (in german)?
    But in my dashboard there’s this slider. The shortcode your PlugIn shows: [crellyslider alias=”standardslider”]

    Can you see, where’s the problem?

    Regards,
    J?rg

    • This reply was modified 7 years, 3 months ago by WiSch.
    • This reply was modified 7 years, 3 months ago by WiSch.
    Plugin Author Fabio Rinaldi

    (@fabiorino)

    Are you sure you haven’t swapped the 2 functions?

    if(CrellySliderCommon::sliderExists($alias)) {
        crellySlider($alias);
    } else {
        crellySlider('standardslider');
    }
    Plugin Author Fabio Rinaldi

    (@fabiorino)

    Removed

    • This reply was modified 7 years, 3 months ago by Fabio Rinaldi.
    Thread Starter WiSch

    (@wisch)

    Hi Fabio.

    Thanks for the support, but…

    If I use your snippet, on every page the ‘standardslide’ comes up.
    If I swap the if & else content the right slider comes up, if exists, but not my default if there’s no slider named like the slug.

    Any other ideas?

    Update:
    Maybe your code checks the ID and I come with the slug in my $alias…

    if(CrellySliderCommon::sliderExists($id)) {
        // Do something if slider exists
    }

    So I have to find out the ID before? But how?

    • This reply was modified 7 years, 3 months ago by WiSch.
    Plugin Author Fabio Rinaldi

    (@fabiorino)

    You’re completely right, I was distracted…

    global $wpdb;
    $slider = $wpdb->get_row($wpdb->prepare('SELECT id FROM ' . $wpdb->prefix . 'crellyslider_sliders WHERE alias = %s', esc_sql($alias)));
    if($slider === null) {
    	// Slider not found
    }
    else {
    	// Slider found!
    }

    this is the only way to do it with the alias. It’s a direct query to the database, but it should work

    Thread Starter WiSch

    (@wisch)

    Hello Fabio.

    Sorry for the delay… checked it today and your last solution works now!

    Thanks for your support.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Default Slide as fallback’ is closed to new replies.