TomodomoCo / total-slider

A WordPress plugin for creating, editing and removing ‘slides’ with text and images (for a homepage, for example).
GNU General Public License v2.0
7 stars 2 forks source link

Sliding not working with custom template #6

Closed paoloquaglino closed 12 years ago

paoloquaglino commented 12 years ago

Hi, I followed istructions and created "total-slider-templates" subfolder in my theme directory. Also I copied the "total-slider-template.css" and "total-slider-template.php" files there. Since then only the first slide is viewed, and no sliding happens. If I make modifications to the custom css and php they work. Everything works ok if I rename or remove the custom directory template.

Anything I could check? Thank you

chrisvanpatten commented 12 years ago

It's hard to say for sure without seeing your site (do you have a link?) but I have a feeling it's looking for the total-slider-template.js file in your-theme/total-slider-templates, but it sounds like you didn't copy it over. Try copying the JS file as well and seeing if it works.

@PeterUpfold: We should do a smarter check so if any of the individual files are missing from the template folder, it falls back to the defaults in the plugin folder.

chrisvanpatten commented 12 years ago

And assuming this is the issue (and I'm prettty sure it is) I'll make this clearer in documentation. And for future versions, this should be fixable so it falls back to the plugin folder if you don't copy every file over.

paoloquaglino commented 12 years ago

Hi, I'm afraid it didn't solve.. below there is the link (the site is not finished yet) I have already fixed the box size issues, now i replaced the original files just to be sure I didn't messed up things customizing it..

I'm using WP 3.3.2, with a twenty-ten child theme. I just discovered that 'custom' sliding works if I activate the original twenty-ten theme, and stops when I switch back to my theme... any ideas? thanks a lot!

http://www.redwest.eu/wp/

chrisvanpatten commented 12 years ago

Hmmm... you're right: I was wrong!

For some reason, jQuery Cycle isn't being enqueued properly. @PeterUpfold: any thoughts?

This probably also means we have the proper fallbacks in place, and my original wild guess was totally off :)

PeterUpfold commented 12 years ago

If a total-slider-template.js file exists in your themes/yourtheme/total-slider-templates folder, then it will be enqueued, but we will not also enqueue our default jQuery Cycle.

It assumes that if you've customised your own JS, you're 'doing your own thing' and have separately enqueued anything else your JavaScript needs in your theme. This behaviour certainly needs to be made much more clear, so we will update the documentation.

This doesn't answer, however, why the slider wasn't sliding before. If you have just a CSS and/or PHP file in your custom total-slider-templates directory, then Total Slider is intelligent enough to use the default JavaScript, and the default jQuery Cycle is enqueued too. I don't know why this is not working for you... yet. :)

If you delete the custom total-slider-template.js from your total-slider-templates directory and reload the page, can you find any reference to jQuery Cycle in the generated page source?

If that works, are there any errors in the JavaScript console in your browser's Developer Tools that might indicate why the JavaScript is failing?

Let us know how you get on.

chrisvanpatten commented 12 years ago

I thought I'd add in a quick snippet here for enqueing jQuery Cycle. I've also added this to the developer docs. Remember, you only need this if you're using a custom theme, as Peter described above.

Add this to your functions.php file in your theme, and you should be good to go!

function custom_total_slider_cycle() {
    wp_enqueue_script(
        'jquery-cycle',
        'https://cdnjs.cloudflare.com/ajax/libs/jquery.cycle/2.99/jquery.cycle.all.min.js',
        array('jquery')
    );
}
add_action('wp_enqueue_scripts', 'custom_total_slider_cycle');

Peter: perhaps in future versions, rather than enqueuing jQuery Cycle as a separate file, we can just copy it right in the total-slider-template.js file. This would reduce HTTP requests, and we can include some inline commenting that explains what we're doing. And ultimately, it would prevent this type of breakage.

paoloquaglino commented 12 years ago

Hi, sorry but no luck.. I removed the js from [theme]\total-slider-templates and added lines you said to 'functions.php', nothing changes. Still works with parent theme. Looks like the script is found (the tag is at bottom of the page) and don't see any errors, as you may check.

PeterUpfold commented 12 years ago

Hi again,

Now, jQuery Cycle is being enqueued. The functions.php snippet now means it is being enqueued twice, so it's best now to remove that.

I have confirmed that not enqueuing the template script is a bug with Total Slider. In this one scenario, it registers the script to start the slider, but fails to enqueue it!

Really sorry for the problems you've been having. I will have a software update out to fix this bug very shortly.

You can fix this right now by opening total-slider.php. At the end of line 599, press Return a couple of times and add this line before the }:

wp_enqueue_script('total-slider-frontend');

PeterUpfold commented 12 years ago

Total Slider 1.0.1 should show up in your plugin updates shortly which should resolve this issue for you.

We'd be really grateful if you could take a moment to rate Total Slider on the Plugin Directory, and vote to say it 'Works' under Compatibility if this update has fixed your problem!

paoloquaglino commented 12 years ago

WELL DONE, problem solved! Glad to have been helpful, I'm going to vote right now!