BuddyDev

Search

Open a link in a new window or tab with BP Custom Group Tabs plugin ?

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25265

    Hello, how is it possible to do that please ? (for internal links or external links)
    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #25281

    Hi Eric,
    Opening a link in new tab needs the target attribute to be added on the link. The tab links(main tab) are managed by BuddyPress and we can not add the target attribute.

    The only way to do it will be to use js to modify the links.

    For sub navs in group, we create the links, so we can provide a way to do it.

    Please let me know if you want to go with js and I will assist. It will need modification in your theme’s js.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25284

    Hello, thanks a lot, yes I would like to… However, it’s not for sub nav but for primary nav…

    I’ve tried also a plugin supposed to open any external link in a new tab, but it does not work…

    Thanks!

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25285

    P.S. I want to open this page, which is not external, in a new window : https://autistance.org/groups/org-aut_allianceautiste-org_orgintl_onu-cdph/allianceautiste-org_orgintl_onu-cdph_audio-video/

    This is only an example and there will be more in the future.

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25289

    P.S.2 I installed the version 2 of that plugin (WP New Window) and added the CSS classes of the button (BBB) but no way, it never wants to open in a new tab. And could not find how to open a specific link (not the button) in a new tab in this plugin.

    Anyway it would be nice if there was a checkbox “open in a new window” in your plugin, like it is in the regular WP menus and even in menu plugins (like MegaMax).

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #25292

    Hi Eric,
    In order to let browser open links in new tab automatically, we need to set the ‘target’ attribute. The problem is we do not have control over that. We register our items and BuddyPress generates the links.

    That’s why we can not add the open in new tab.

    The work around is using javascript. Which is not good enough to be part of the core plugin.

    I or @ravisharma will share some code to open tabs in new window in next 2 days.

    Thank you
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25298

    Hello, thank you so much 🙂
    I hope you will also give me a link to a page explaining where and how to put that code (I’ve never done that, I always rely on plugins). Thanks !

  • Participant
    Level: Enlightened
    Posts: 48
    Eric LUCAS on #25385

    Hello Brajesh and @ravisharma, I hope you will find a minute to tell me how to do.
    Now I discovered a plugin called “Code Snippet” allowing to put some code easily, hence if you want you can give me the code and I will try to manage that.
    Thanks a lot!

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #25397

    Hi Eric,
    Please put this javascript in your js file(or cusotm code [plugin if that allows it)

    
    (function ($) {
    	var tabSelectors = ['#activity-groups-li', '#home-groups-li' ];
    
    	$(document).ready(function(){
    		if( ! tabSelectors.length){
    			return;
    		}
    		
    		var allItemsSelector = tabSelectors.join(',');
    
    		$(allItemsSelector).each(function () {
    			$(this).addClass('no-ajax').find('a').attr('target','_blank').addClass('no-ajax');
    		});
    	});
    
    })(jQuery);
    

    Change the ids of the tab in this line with your own

    
    var tabSelectors = ['#activity-groups-li', '#home-groups-li' ];
    

    Or you can point me to the site and tell me which tabs and I will provide the updated list of tabSelectors.

    Regards
    Brajesh

The topic ‘Open a link in a new window or tab with BP Custom Group Tabs plugin ?’ is closed to new replies.

This topic is: not resolved