VM3 addthis buttons disappears when go to a neighbour prev next link[SOLVED]

Started by smarmellow, December 09, 2016, 18:57:26 PM

Previous topic - Next topic

smarmellow

Hello, i searched this all the day, and nothing. :'(
I have addthis buttons on detail product page, when i go to a neighbour product by links "prev" "next" the social buttons disappears.
I have read this https://forum.virtuemart.net/index.php?topic=61918.0 but is for vm1.

Someone has the same issue? how have you solved?

Thanks!!!

vm3, joomla 3.6.4. , flatize template

GJC Web Design

would assume the JS isn't being loaded when you ajax refresh the details page..

see at the bottom of the productdetails default.php how JS should be handled
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

smarmellow

hello, thanks for the answer!

i'm in contact with addthis team, they sent me that:
"It sounds like your pages are loading dynamically with JavaScript when you are clicking Next/Prev, rather than being fully loaded from the server each time. In order to correct this, you'll need to call addthis.layers.refresh() upon content changes.

https://www.addthis.com/academy/using-dashboard-configuration-tools-dynamically/ "

i don't know js and i don't know whats going on here. :o

Can you help me to adapt this script to my virtuemart files?


smarmellow

I managed to make it work, but, now i have a blank page when i go tu domain.xx/administrator.

i added this:
:function loadDynamicContent() {
    // Code that will load the dynamic content

    // Once that's all done, call addthis.toolbox()
    addthis.toolbox('.addthis_toolbox')
}


at the end of my jquery.min.js file

now the code is:
/*! jQuery v1.12.4 | (c) jQuery Foundation | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="1.12.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(.....

........................

.......:(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,n.extend({},h))),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,n.contains(b,e)?("undefined"!=typeof e.getBoundingClientRect&&(d=e.getBoundingClientRect()),c=mc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===n.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(c=a.offset()),c.top+=n.css(a[0],"borderTopWidth",!0),c.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-n.css(d,"marginTop",!0),left:b.left-c.left-n.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Qa})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);n.fn[a]=function(d){return Y(this,function(a,d,e){var f=mc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?n(f).scrollLeft():e,c?e:n(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=Ua(l.pixelPosition,function(a,c){return c?(c=Sa(a,b),Oa.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({
padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return Y(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.extend({bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var nc=a.jQuery,oc=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=oc),b&&a.jQuery===n&&(a.jQuery=nc),n},b||(a.jQuery=a.$=n),n});:function loadDynamicContent() {
    // Code that will load the dynamic content

    // Once that's all done, call addthis.toolbox()
    addthis.toolbox('.addthis_toolbox')
}


if i delete the new added code the administrator page displays correctly, but the addthis buttons issue turns again.

GJC Web Design

as I said->

would assume the JS isn't being loaded when you ajax refresh the details page..

see at the bottom of the productdetails default.php how JS should be handled
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

smarmellow

i gave a look at the bottom of the default.php and i found this script
<script>

// GALT

/*

* Notice for Template Developers!

* Templates must set a Virtuemart.container variable as it takes part in

* dynamic content update.

* This variable points to a topmost element that holds other content.

*/

// If this <script> block goes right after the element itself there is no

// need in ready() handler, which is much better.

//jQuery(document).ready(function() {

Virtuemart.container = jQuery('.productdetails-view');

Virtuemart.containerSelector = '.productdetails-view';

//Virtuemart.container = jQuery('.main');

//Virtuemart.containerSelector = '.main';

//});



// Open print and manufacturer link to Modal window

  <?php if(VmConfig::get('usefancy',1)) : 

  $manulink JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' $this->product->virtuemart_manufacturer_id[0] . '&tmpl=component'FALSE);

  ?>


  jQuery('a.printModal').click(function(e){

  jQuery.fancybox({

href: '<?php echo $link.'&print=1'?>',

                type: 'iframe',

                height: '500'

  });

                  e.preventDefault();

  });



  jQuery('a.manuModal').click(function(e){

   jQuery.fancybox({

href: '<?php echo $manulink ?>',

                type: 'iframe'

  });

              e.preventDefault();

  });

 

  <?php else : 

  $manulink JRoute::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' $this->product->virtuemart_manufacturer_id[0] . '&tmpl=component'FALSE);

  ?>




  jQuery('a.printModal').click(function(e){

  jQuery.facebox({

iframe: '<?php echo $link.'&print=1'?>',

rev: 'iframe|550|550'

  });

          e.preventDefault();

  });



  jQuery('a.manuModal').click(function(e){

jQuery.facebox({

iframe: '<?php echo $manulink?>',

rev: 'iframe|550|550'

});

        e.preventDefault();

      });

     

  <?php endif; ?>

 

   

</script>


i have no knowledge of js and php, what i have to do here?

GJC Web Design

you have to load your addto js there like u tried to do by hacking the main jquery file
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

smarmellow

YESSS! Now it works! Thanks very much for your support!

For all of you interested in how to solve this:


at the bottom of your template file just above </body> paste

<script type="text/javascript">
var addthisScript = document.createElement('script');
addthisScript.setAttribute('src', 'http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-XXXXXXXXXXX')
document.body.appendChild(addthisScript)
</script>


in yourtemplate/html/com_virtuemart/productdetails/default.php paste your buttons div in the position you want they appeare. In my case just below the product image before all other informations

    <?php

$count_images count ($this->product->images);

if ($count_images 1) {

echo $this->loadTemplate('images_additional');

}




?>



<!-- SOCIAL links -->

   <div class="my-social-links">

     <!-- Go to www.addthis.com/dashboard to customize your tools --> <div class="addthis_inline_share_toolbox"></div>

   </div>   

<!-- SOCIAL links end-->

   

    </div>
   

<div class="col-sm-7">



<?php

            
// Product Navigation

            
if (VmConfig::get('product_navigation'1)) {

            
?>


Last thing to do is paste the function

function loadDynamicContent() {
    // Code that will load the dynamic content

    // Once that's all done, call addthis.toolbox()
    addthis.toolbox('.addthis_toolbox')
}


at the bottom of default.php file like this:

<script>

// GALT

/*

* Notice for Template Developers!

* Templates must set a Virtuemart.container variable as it takes part in

* dynamic content update.

* This variable points to a topmost element that holds other content.

*/

// If this <script> block goes right after the element itself there is no

// need in ready() handler, which is much better.

//jQuery(document).ready(function() {

Virtuemart.container = jQuery('.productdetails-view',):function loadDynamicContent() {
    // Code that will load the dynamic content

    // Once that's all done, call addthis.toolbox()
    addthis.toolbox('.addthis_toolbox')
};

Virtuemart.containerSelector = '.productdetails-view';

//Virtuemart.container = jQuery('.main');

//Virtuemart.containerSelector = '.main';

//});
...