mikecheung Posted July 17, 2013 Share Posted July 17, 2013 (edited) I have tried searching Google and these forums and have not found a solution. So I am hoping that someone here can help. I am currently on version 1.5 of prestashop and am still using the default idTabs plugin that comes with the package. I have successfully added a custom tab via a module I am creating but cant seem to remotely link to it. To be more specific, I would like to have a anchor tag that I place below the products price and when clicked it will open/activate a specific tab. Does anyone know of a solution for this? Your help is greatly appreciated. Edited July 17, 2013 by mikecheung (see edit history) Link to comment Share on other sites More sharing options...
Krystian Podemski Posted July 17, 2013 Share Posted July 17, 2013 The function of this plugin is based on the identifiers of the individual tabs. So link: <a href="#idTab99">Some tab</a> Open: <div id="idTab99">content</div> Link to comment Share on other sites More sharing options...
mikecheung Posted July 17, 2013 Author Share Posted July 17, 2013 The function of this plugin is based on the identifiers of the individual tabs. So link: <a href="#idTab99">Some tab</a> Open: <div id="idTab99">content</div> Correct, but the problem is that the anchor tag needs to be within a class="idTabs" and it will not work if I define two different divs with that class (i've tried). If I take it out of the original tab group, it no longer works. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted July 17, 2013 Share Posted July 17, 2013 Maybe produtctcomments-extra.tpl example will help you? <script type="text/javascript"> $(function(){ $('a[href=#idTab5]').click(function(){ $('*[id^="idTab"]').addClass('block_hidden_only_for_screen'); $('div#idTab5').removeClass('block_hidden_only_for_screen'); $('ul#more_info_tabs a[href^="#idTab"]').removeClass('selected'); $('a[href="#idTab5"]').addClass('selected'); }); }); </script> Link to comment Share on other sites More sharing options...
mikecheung Posted July 17, 2013 Author Share Posted July 17, 2013 Maybe produtctcomments-extra.tpl example will help you? <script type="text/javascript"> $(function(){ $('a[href=#idTab5]').click(function(){ $('*[id^="idTab"]').addClass('block_hidden_only_for_screen'); $('div#idTab5').removeClass('block_hidden_only_for_screen'); $('ul#more_info_tabs a[href^="#idTab"]').removeClass('selected'); $('a[href="#idTab5"]').addClass('selected'); }); }); </script> Thanks Krystian, I was thinking about doing it manually as well, but figured i'd ask before I try it. You sharing the code really helps. I was using productComments as a guide as well, but missed this. Appreciate the help. If there is any cleaner way to do this, please do share. Link to comment Share on other sites More sharing options...
Krystian Podemski Posted July 17, 2013 Share Posted July 17, 2013 You can place this code in function, something like: function changeTab(tabID) { $('a[href=#idTab'+tabID+']').click(function(){ $('ul#more_info_tabs a[href^="#idTab"]').removeClass('selected'); $('a[href="#iidTab'+tabID+"]').addClass('selected'); }); } <a href="#" class="changeTab" data-tab="99" title="My Tab">My Tab</a> $('.changeTab').click(function() { changeTab($(this).data('tab')); }); Link to comment Share on other sites More sharing options...
mikecheung Posted July 17, 2013 Author Share Posted July 17, 2013 (edited) Maybe produtctcomments-extra.tpl example will help you? <script type="text/javascript"> $(function(){ $('a[href=#idTab5]').click(function(){ $('*[id^="idTab"]').addClass('block_hidden_only_for_screen'); $('div#idTab5').removeClass('block_hidden_only_for_screen'); $('ul#more_info_tabs a[href^="#idTab"]').removeClass('selected'); $('a[href="#idTab5"]').addClass('selected'); }); }); </script> Edited the above code a bit to be more versatile. Just add the class "linkTab" and target ID as the href to any anchor tag and the below code will detect which tab you are referring to. $('a[href^=#].linkTab').click(function(){ tabId = $(this).attr('href'); $('*[id^="idTab"]').addClass('block_hidden_only_for_screen'); $('div' + tabId).removeClass('block_hidden_only_for_screen'); $('ul#more_info_tabs a').removeClass('selected'); $('a[href="' + tabId + '"]').addClass('selected'); }); Edited July 17, 2013 by mikecheung (see edit history) 1 Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted September 20, 2013 Share Posted September 20, 2013 Can you explain it with an exaple? Thanks I want to remote link from product-list.tpl to more_info_tab from Product.tpl. Best regards Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted September 23, 2013 Share Posted September 23, 2013 Edited the above code a bit to be more versatile. Just add the class "linkTab" and target ID as the href to any anchor tag and the below code will detect which tab you are referring to. $('a[href^=#].linkTab').click(function(){ tabId = $(this).attr('href'); $('*[id^="idTab"]').addClass('block_hidden_only_for_screen'); $('div' + tabId).removeClass('block_hidden_only_for_screen'); $('ul#more_info_tabs a').removeClass('selected'); $('a[href="' + tabId + '"]').addClass('selected'); }); Can you show an example of tpl with this code? Thanks Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted September 25, 2013 Share Posted September 25, 2013 Up! Link to comment Share on other sites More sharing options...
ErikSebastia2 Posted September 26, 2013 Share Posted September 26, 2013 Any idea? Best regards Link to comment Share on other sites More sharing options...
Pirate Posted August 16, 2016 Share Posted August 16, 2016 Hello. Does anybody know, how to do this thing: when clicked a link it will open/activate a specific tab on a product page (from product page). But. I can use only id, not specific class. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now