Ive got $5 for anyone who can solve this one issue for me

A place to make for-pay "CMS made simple" job offerings
Locked
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Ive got $5 for anyone who can solve this one issue for me

Post by wmdvanzyl »

As title states - i can buy you a cup of coffee (via PayPal)... if you can tell me why the hell prettyPhoto is giving me the middle finger.

I am trying to use prettyPhoto to display images which are shown using the Gallery module which is in the content area of a blog post. Everything seems like it should work, but prettyPhoto doesn't pick anything up.

This is just a test page, but it is on a live site. Just have a look at the source and tell me why you think prettyPhoto doesn't display the images on this page: https://modh.co.za/2016/07/House-Galloway
Instead, clicking on an image just shows it in the default browser view. The paths all seem fine.

Good hunting! :D
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: Ive got $5 for anyone who can solve this one issue for m

Post by velden »

Because your site is in maintenance mode I guess!?

Where can I post my paypal address? ;)
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

Re: Ive got $5 for anyone who can solve this one issue for m

Post by Jos »

wmdvanzyl wrote:clicking on an image just shows it in the default browser view.
Usually this is caused by two or more calls to the jquery library. jquery only allows one call. This can be solved by deleting the first line from the Gallery template javascript field.
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Re: Ive got $5 for anyone who can solve this one issue for m

Post by wmdvanzyl »

velden wrote:Because your site is in maintenance mode I guess!?

Where can I post my paypal address? ;)
LOL Velden. Sorry, forgot about that. All bets are off on that one.

@Jos - that's a nice try, but i already did that. I thought the same thing, but i moved all the JS into the template to make sure.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Ive got $5 for anyone who can solve this one issue for m

Post by Dr.CSS »

Add / to the beginning of you JS call...


<__script__ type="text/javascript" src="/modules/Gallery/templates/prettyphoto/jquery.prettyPhoto.js" defer></__script>
caciavar
Forum Members
Forum Members
Posts: 64
Joined: Wed Feb 11, 2009 6:30 pm
Location: Toronto, Canada

Re: Ive got $5 for anyone who can solve this one issue for m

Post by caciavar »

This likely has something to do with it:

In my browser console I see the following error:

Code: Select all

Uncaught ReferenceError: $ is not defined
Which means that the jQuery library is not loaded yet...

When you are loading the library you have specified a "defer" attribute in the tag:

Code: Select all

<__script__ src="https://modh.co.za/uploads/js/epilogue.jquery.min.js" defer></__script>
The "defer" above specifies that the jquery library will not run until after the page has finished loading. But it should run before the page finishes loading.

Try removing "defer" from that script tag and see what happens. I bet that will fix the problem.


EDIT: Just did a quick test and ran this code in my browser console after the page finished loading:

Code: Select all

    $(document).ready(function(){
    	$("a[rel^='prettyPhoto']").prettyPhoto({
    			animation_speed: 'fast',
    			slideshow: 5000,
    			autoplay_slideshow: false,
    			show_title: true,
    			allow_resize: true,
    			counter_separator_label: '/',
    			theme: 'dark_rounded', /* light_rounded / pp_default / light_square / dark_square / facebook */
    			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto*/
    			overlay_gallery: true,
    			keyboard_shortcuts: true
    	});
    });
...as soon as I did that, pretty photo started working. So the issue is exactly what I stated above: The jQuery library is not loaded at the appropriate time... removing "defer" will fix it.
wmdvanzyl
Forum Members
Forum Members
Posts: 214
Joined: Fri May 06, 2011 12:48 pm

Re: Ive got $5 for anyone who can solve this one issue for m

Post by wmdvanzyl »

@DrCSS - thanks for picking that up, but i think i was saved by the base tag that had a trailing "/"

I think this prize goes to @caciavar ;) He nailed that one. It seems i went a little crazy with the "defers" when i was trying to improve the loading experience and later when i added prettyPhoto I forgot that jquery object was not loaded until the very end. And since the prettyPhoto code is inline, kazaam... problem.

Thanks to all for playing along - it was fun! I think there a few other peeps around here i also owe a coffee... Might be time to start paying my debt :P I'm looking at you @velden and @rolf (to name but 2)
Locked

Return to “Help Wanted (commercial)”