-
AuthorPosts
-
November 17, 2019 at 2:59 pm #1157640
Hi there
I put a tab-element and a catalogue into the site and noticed, that the names of the tab are kinda anchor (f. e. kosmetikandnails.ch#nails). It does not work to set a link to the tabs – or at least I do it wrong somehow :-)On another section I mentioned the services I offered and wanted to link to the different tabs that shows the catalogue. How do I set that link?
I tried it with #nails, because I see that link when I hover over the picture. Unfortunately it does not jump there, unlike when I set the anchor to the tabs itself (#preistliste)
So… how do I get a link inserted (without using the whole url)?
Thanks for the help :)
- This topic was modified 5 years, 1 month ago by KosmetikAndNails.
November 17, 2019 at 4:06 pm #1157652Hey
You have to define the anchor ID (e.g. #nails or #preisliste) in the text block itself as well.
Otherwise WordPress does not know where to jump if you click at the link.However, it would be a lot easier to see the website in action so I could help you more specific.
Cheers
MichaelNovember 17, 2019 at 6:49 pm #1157667I honestly have no idea where I could put that in – it is just a tab withouth text
- This reply was modified 5 years, 1 month ago by KosmetikAndNails.
November 17, 2019 at 6:54 pm #1157670November 17, 2019 at 11:49 pm #1157696Gemäss Doku also nur die Lösung, die ich nicht wollte (und weshalb ich die Topic eröffnet hab) – kein Anker, sondern eine fixe URL, um einen Tab anzuspringen 8-/
Es funktioniert aber leider nicht mit der URL als Link mit Tab-Ankername.
Auf https://kosmetikandnails.ch/#angebot sind 4 Einträge, die ich zum Tab mit dem Katalog verlinkt habe. Bei “Nails” habe ich zu https://kosmetikandnails.ch/#nails verlinkt (weil mir bei diesem Tab diese URL angezeigt wurde), aber es springt weder zu diesem Tab noch öffnet es ihn.Bei “Kosmetik” habe ich zur Tab-Sektion verlinkt und es springt zu den Tabs (und zeigt mir den Tab, den ich als letztes geöffnet hatte)
Kann man irgendwo Vorschläge für Verbesserungen anbringen? Wär doch toll, wenn man bei diesem Tab-Element auch pro Tab eine “Developer”-Möglichkeit hätte, um einen Ankernamen zu vergeben. Wäre auch super, wenn es überhaupt funktionieren würde ;-)
November 18, 2019 at 6:49 am #1157756Hallo Christa
Das müsste schon so klappen, wie du dir das vorstellst.
Versuche bitte mal folgendes:
a) Unter https://kosmetikandnails.ch/#angebot verlinkst du “Waxing” mit https://kosmetikandnails.ch/#waxing.
b) Das sollte dazu führen, dass sich der Tab entsprechend öffnet und die Ansicht entsprechend scrollt.Funktioniert das so?
Übrigens: Ein sogenannter Onepager, wie du ihn hier erstellt hast (also mit Ankern auf der gleichen Seite), ist für Google leider alles andere alles optimal.
Viel besser wäre es, wenn du einzelne Seiten erstellst, also /angebot, /waxing, etc.Viele Grüsse
MichaelNovember 23, 2019 at 8:32 pm #1159505Hi,
Sorry for the late reply, please see this post.
So in your case, Try adding this code to the end of your functions.php file in Appearance > Editor:add_action('wp_footer', 'ava_custom_script'); function ava_custom_script() { ?> <script> (function($){ function getQueryParams(qs) { qs = qs.split("+").join(" "); var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g; while (tokens = re.exec(qs)) { params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); } return params; } var $_GET = getQueryParams(document.location.search); $(window).load(function() { switch($_GET['tabsort']) { case '1': $('a[data-av-tab-section-title="1"]').trigger('click'); break; case '2': $('a[data-av-tab-section-title="2"]').trigger('click'); break; case '3': $('a[data-av-tab-section-title="3"]').trigger('click'); break; case '4': $('a[data-av-tab-section-title="4"]').trigger('click'); break; case '5': $('a[data-av-tab-section-title="5"]').trigger('click'); break; } }); })(jQuery); </script> <?php }
and your link would look like
/?tabsort=5
or/?tabsort=#waxing
If this doesn’t help, please include an admin login in the private content area so we can be of more assistance.Best regards,
MikeMarch 12, 2020 at 3:20 pm #1192657Hey Mike
Sorry for the late reply. The code works to open the correct tab – but it reloads the page and you land at the top of the page 8-/
How can I keep the page from reloading?Christa
March 14, 2020 at 3:18 pm #1193100Hi,
I see that when linking directly from another page or site tohttps://kosmetikandnails.ch/#nails
the tab opens but the page doesn’t scroll down to the tab. to correct try adding this code to the end of your functions.php file in Appearance > Editor:function custom_id_script(){ ?> <script> (function($){ $(document).ready(function(){ $("a.av-section-tab-title").each(function() { var $this = $(this); var _href = $this.attr("href"); var itemId = _href.substring(1, _href.length); $this.attr("id", itemId); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_id_script');
it adds an “id” to the tab link so the page will scroll to the tab.
If the link to the tab is clicked on the same page the offset doesn’t always work so add this code to the end of your functions.php file in Appearance > Editor to apply an offset to the tabs:function custom_offset_script(){ ?> <script> (function($){ var width = $(window).width() if ((width >= 768)) { $('a.av-section-tab-title[href*="#"]:not([href="#"])').click(function() { var offset = -130; // <-- change the value here if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html, body').animate({ scrollTop: target.offset().top + offset }, 1000); return false; } } }); } else {} })(jQuery); </script> <?php } add_action('wp_footer', 'custom_offset_script');
Best regards,
MikeMarch 14, 2020 at 8:39 pm #1193125well i think it is because your av-layout-tab has only the data-tab-section-id – and maybe this i due to your Enfold Version 4.6.2
on 4.7.3 these av-layout-tab get the ID ( on your case nails)
You can do : update to newest version or put this to your child-theme functions.php:function tab_section_add_id(){ ?> <script> (function($){ $(window).load(function() { $('.av-layout-tab').each(function(){ var dataID = $(this).data('tab-section-id'); $(this).attr("id", dataID); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'tab_section_add_id');
it will do the job that 4.7.3 did allready.
i would advice you to update : see here some hints: https://kriesi.at/support/topic/some-hints-and-advice-to-update-enfold/#post-1056107March 15, 2020 at 12:01 pm #1193200Hi,
@Guenni007 thank you, that is a good point. @KosmetikAndNails please let us know if updating and using @Guenni007 code above helps.Best regards,
MikeMarch 15, 2020 at 2:58 pm #1193221with an update the code is then no longer necessary – because enfold 4.7.3 already has these ID’s on the av-layout-tab
March 16, 2020 at 3:25 pm #1193502This reply has been marked as private.March 16, 2020 at 3:54 pm #1193516This reply has been marked as private.March 16, 2020 at 4:22 pm #1193522found the problem… seems that there’s only an id available for “Tab Element” but not “Tab Section”-Element. The available options on “Tab Section” are much better, but there’s no ID for the tabs.
- This reply was modified 4 years, 9 months ago by KosmetikAndNails.
March 16, 2020 at 4:48 pm #1193526I added all three codes – it works when I link with /?tabsort=name, but it does not add an id-field for the tabs in the development settings of the” Tab Section” -element.
Maybe there was a missunderstanding with tab-element and tab-section? I use tab-sections where I can use pictures in the tabs, place other elements in a tab and so on. In the “tab-section”-element is no no id-field for the tabs (not even with added code).
The downside of using all 3 codes: yes, it reloads the side after clicking on a link with /?tabsort=name and scrolls down to the content of the tab. But now it scrolls down immediately when you open the page (I cleared the cache, swapped browsers, opened private tabs).
Right now I only have this code in the functions.php:
function tab_section_add_id(){ ?> <script> (function($){ $(window).load(function() { $('.av-layout-tab').each(function(){ var dataID = $(this).data('tab-section-id'); $(this).attr("id", dataID); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'tab_section_add_id');
- This reply was modified 4 years, 9 months ago by KosmetikAndNails. Reason: updated the info
March 16, 2020 at 5:06 pm #1193536This reply has been marked as private.March 17, 2020 at 12:19 am #1193691Hi,
Sorry we couldn’t assist more with a solution, but glad you have a working solution.Best regards,
MikeMarch 17, 2020 at 3:01 pm #1193812The working solution is to link to #preisliste, not directly to a tab which is why I opened the topic in the first place (so no solution).
But glad I found out there was an update – why don’t I get an update within WordPress or per mail? I haven’t even seen within the download-area of envato-market that I got an update.March 18, 2020 at 12:15 pm #1194081Hi,
I see you have the latest version but in your update options in your theme panel your “Envato private token” field is empty, this is necessary for updates in the theme panel to work, but envato-market should also send you emails, you will have to ask envato-market why you are not getting these.Best regards,
MikeMarch 18, 2020 at 8:20 pm #1194233Oh… thank you so much! Generated, filled in and all set for the updates to come :) Updated my envato-market account as well and should get emails from now on.
March 18, 2020 at 10:59 pm #1194247Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan ShannonMarch 19, 2020 at 12:40 am #1194271But please read carefully: if you have updated the theme to 4.7.3 ( and i see you have done that) then the code : here is obsolete. The Theme Version 4.7.3 has this allready implemented.
And you link now as described here : https://kriesi.at/support/topic/how-to-link-to-tabs/#post-1157756 -
AuthorPosts
- You must be logged in to reply to this topic.