Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1496200

    Hi,

    I have recently moved away from using styled portfolio items to using a formidable form view in a tabbed section. While the tabs and content display right, if I go to a detailed view for an entry, I cannot change tabs in a meaningful way. The problem is that the URL just appends the #tab-name on the URL rather than refreshing the original URL.

    This happens most clearly on our About Us page (https://cprn.org/about-us) in which we have a tab section to display multiple groups of leaders. The views all display correctly when a tab is clicked on, e.g., https://cprn.org/about-us/#leadership. But if I click on a detailed view for someone in the tab, the URL will change to https://cprn.org/about-us/entry/200578/ because it is a detailed page in the view. But now clicking on another tab, say “Board” just appends #board to the end of https://cprn.org/about-us/entry/200578/ rather than refreshing to https://cprn.org/about-us/#board.

    How can I fix this?

    Paul

    #1496201

    Hey paulgross,

    Thank you for the inquiry.

    This is expected behavior. The tab element in Enfold uses anchor-based navigation (hash URLs), so clicking a tab only toggles the content on the current page. When you navigate to a detail entry URL like https://cprn.org/about-us/entry/200578/, the tab section from the parent page is no longer present, so clicking a tab just appends the hash to the current URL without redirecting back.

    To get the behavior you’re looking for, the tab links on the detail page would need to redirect back to the parent page with the appropriate hash (e.g., https://cprn.org/about-us/#board). This would require custom js or modifications to the view template.

    One approach is to override the tab click behavior using a small js snippet in your child theme:

    
    add_action( 'wp_footer', function() {
        ?>
        <script>
        jQuery(document).ready(function($) {
            $('.tabcontainer .tab_titles .tab').on('click', function() {
                if (window.location.href.indexOf('/entry/') !== -1) {
                    var hash = $(this).data('fake-id');
                    window.location.href = 'https://cprn.org/about-us/' + hash;
                }
            });
        });
        </script>
        <?php
    } );
    

    This checks whether the user is on a detail entry URL and redirects them back to the parent page with the correct tab hash instead of just appending it. Another thing that might help is to create a custom layout that you can apply to multiple pages.

    https://kriesi.at/documentation/enfold/custom-layout-and-dynamic-content/
    https://kriesi.at/documentation/enfold/custom-element-templates/

    Let us know how it goes

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.