0

I'm making and slide in function to that product page. So when you are close to the bottom a static block will come visible.

That static block should have a link to an article the link is different from product to product and is set in by a custom product attribute.

The problem is to get that custom attribute into my .js can you help?

What I've done so far

  1. Call in an custom.js in page.xml
  2. Make static block, and call it in at the bottom on view.phtml

custom_att name is article link The js have only the "do somthing when you are close to bottom" function right now

jQuery(window).scroll(function() {
   if(jQuery(window).scrollTop() + jQuery(window).height() > jQuery(document).height() - 100) {
       alert("near bottom!");
   }
})
2
  • custom attribute name and add js code too – Qaisar Satti May 3 '16 at 6:39
  • Ive added more data – Patrick Knudsen May 3 '16 at 6:45
1

You can place this JS code anywhere to product page :

<script type="text/javascript">
    var article_link = "<?php echo $product->getArticleLink() ?>";
</script>

Now you can use javascript variable article_link anywhere on .js file, in your case it's custom.js

9
  • Every time i try I destoy all the other js on the site :O – Patrick Knudsen May 3 '16 at 7:30
  • Can you send VIEW-SOURCE of this line var article_link = '<?php echo $product->getArticleLink() ?>'; – Anil Suthar May 3 '16 at 7:34
  • What do you need? :D – Patrick Knudsen May 3 '16 at 7:45
  • Do VIEW-SOURCE of the page (ctrl+U), and send me the above line. O/W send me product page link – Anil Suthar May 3 '16 at 8:00
  • <script type="text/javascript"> var article_link = <br /> <b>Fatal error</b>: Call to a member function getartikelkode() on null in <b>/var/www/ifp.dk/public_html/app/design/frontend/ultimo/default/template/catalog/product/view.phtml</b> on line <b>534</b><br /> And a random product page is ifp.dev.magepartner.net/… – Patrick Knudsen May 3 '16 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.