Support

Support is part of Event Gallery Extended.

Please get a subscription if you need support. Feel free to use the ticket system or the contact form for reporting defects or pre-sale questions. Make sure you're logged in in order to be able to create a new ticket.

For general information you can also jump to the manual.

Subscribe now!

#1636 Script Declarations

Posted in ‘Event Gallery Extended’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by pAnd0rA on Thursday, 16 July 2015 21:14 UTC

pAnd0rA
Hi Sven,

You use a few <script... Declarations in your Templates. Since nowadays it's common practice, to load the Javascript at the bottom of the page and there are a lot of Plugins, e.g. "ScriptsDown", that accomplish that on Joomla, you should consider rewriting those to JFactory::getDocument()->addScriptDeclaration("..."); since otherwise your code breaks (Scripts are loaded before jquery).

For the time being, I created Template Overrides and it works great (also with ScriptsDown active).

E.g.
components/com_eventgallery/views/snippets/tmpl/cart.php line 27 ff.
change from
    <?php IF ($use_cart_inside_component): ?>
        <script type="text/javascript">
            /* <![CDAT[ */
            (function(jQuery){
            	jQuery( document ).ready(function() {

	                var options = {
	                    buttonShowType: 'inline',
	                    emptyCartSelector: '.eventgallery-cart-empty',
	                    cartSelector: '.eventgallery-ajaxcart-internal',
	                    cartItemContainerSelector: '.eventgallery-ajaxcart-internal .cart-items-container',
	                    cartItemsSelector: '.eventgallery-ajaxcart-internal .cart-items',
	                    cartItemSelector: '.eventgallery-ajaxcart-internal .cart-items .cart-item',
	                    cartCountSelector: '.eventgallery-ajaxcart-internal .itemscount',
	                    buttonDownSelector: '.eventgallery-ajaxcart-internal .toggle-down',
	                    buttonUpSelector: '.eventgallery-ajaxcart-internal .toggle-up',
	                    'removeUrl': "&lt;?php echo JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=removefromcart&amp;format=raw", true); ?&gt;".replace(/&amp;/g, '&amp;'),
	                    'add2cartUrl': "&lt;?php echo JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=add2cart&amp;format=raw", true); ?&gt;".replace(/&amp;/g, '&amp;'),
	                    'removeLinkTitle': "&lt;?php echo JText::_('COM_EVENTGALLERY_CART_ITEM_REMOVE')?&gt;",
	                    'getCartUrl': "&lt;?php echo JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=getCart&amp;format=raw", true); ?&gt;".replace(/&amp;/g, '&amp;')
	                };

	                var eventgalleryCart = new Eventgallery.Cart(options);

            	});
            })(eventgallery.jQuery);
            /* ]]> */
        </script>


to

    <?php IF ($use_cart_inside_component): 
        JFactory::getDocument()->addScriptDeclaration("
            /* <![CDAT[ */
            (function(jQuery){
            	jQuery( document ).ready(function() {

	                var options = {
	                    buttonShowType: 'inline',
	                    emptyCartSelector: '.eventgallery-cart-empty',
	                    cartSelector: '.eventgallery-ajaxcart-internal',
	                    cartItemContainerSelector: '.eventgallery-ajaxcart-internal .cart-items-container',
	                    cartItemsSelector: '.eventgallery-ajaxcart-internal .cart-items',
	                    cartItemSelector: '.eventgallery-ajaxcart-internal .cart-items .cart-item',
	                    cartCountSelector: '.eventgallery-ajaxcart-internal .itemscount',
	                    buttonDownSelector: '.eventgallery-ajaxcart-internal .toggle-down',
	                    buttonUpSelector: '.eventgallery-ajaxcart-internal .toggle-up',
	                    'removeUrl': \"". JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=removefromcart&amp;format=raw", true) ."\".replace(/&amp;/g, '&amp;'),
	                    'add2cartUrl': \"". JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=add2cart&amp;format=raw", true) ."\".replace(/&amp;/g, '&amp;'),
	                    'removeLinkTitle': \"". JText::_('COM_EVENTGALLERY_CART_ITEM_REMOVE')."\",
	                    'getCartUrl': \"". JRoute::_("index.php?option=com_eventgallery&amp;view=rest&amp;task=getCart&amp;format=raw", true) ."\".replace(/&amp;/g, '&amp;')
	                };

	                var eventgalleryCart = new Eventgallery.Cart(options);

            	});
            })(eventgallery.jQuery);
            /* ]]> */
        "); ?>

(you'll have to escape " with \" and change the occurences of <?php echo in your original code)

While you're at it, you might also consider changing <style> declarations to JFactory::getDocument()->addStyleDeclaration("..."); so that they are in the <head> :)

Occurences of script declarations, I found:
components/com_eventgallery/views/cart/tmpl/default.php (106)
components/com_eventgallery/views/checkout/tmpl/change_address.php (90)
components/com_eventgallery/views/singleimage/tmpl/default.php (17)
components/com_eventgallery/views/singleimage/tmpl/minipage.php (45)
components/com_eventgallery/views/singleimage/tmpl/share_facebook_feeddialog.php (16)
components/com_eventgallery/views/singleimage/tmpl/share_facebook_photoshare.php (23)
components/com_eventgallery/views/singleimage/tmpl/share_facebook_sharedialog.php (16)
components/com_eventgallery/views/snippets/tmpl/cart.php (28)
components/com_eventgallery/views/snippets/tmpl/event/ajaxpaging_script.php (11)
components/com_eventgallery/views/snippets/tmpl/imageset/imagesetselection.php (36)

Would be great, if you could consider that for your next version...

Cheers,
Chris

sbluege
Not a bad idea! I added that to my list.

pAnd0rA
Glad, you like it...

I attached my Template-Overrides - feel free to use those and save some work :) I changed all necessary <script and <style appearances and it works - however, I did not test comments and cart functionality, since I don't use them. They should be ok though :)

-Chris

Attachments

com_eventgallery.zip