1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Link Forum > links open in new window

Discussion in 'XenForo Questions and Support' started by Echelon, Dec 4, 2013.

  1. Echelon

    Echelon Active Member

    Whatever I do......target_blank, target_new, <href......
    can't get it done to have the link open in a new window

    check visual.

    what is the code to have the link open in a new window


    Attached Files:

  2. Mike

    Mike XenForo Developer Staff Member

    You would need to modify the templates that link to these forums (node_link_level_*).
    Echelon likes this.
  3. Echelon

    Echelon Active Member

    yes....but how......?
  4. Jeremy

    Jeremy Well-Known Member

    Add a target attribute to the links, specifically, _blank.
    Echelon likes this.
  5. Echelon

    Echelon Active Member

    yes. thanks.....still...im not a coder....where to put the "target=_blank". I put it everywhere on "luck" but this did not work out for me ;-)

  6. Jeremy

    Jeremy Well-Known Member

  7. Echelon

    Echelon Active Member

    Wuebit likes this.
  8. Jeremy

    Jeremy Well-Known Member

    You don't need to be a coder to learn a basic understanding of HTML. The link I provided explains the anchor tag, its attributes (including target) and even has an example that utilizes it. You posted a screenshot surrounding the correct code, so I'm treating this as a perfect opportunity for you to learn and I have provided all of the resources you need to experiment and get the link working the way you want.
  9. Echelon

    Echelon Active Member

    Ok. I will figure it out. thanks for your help
  10. Morgain

    Morgain Well-Known Member

    I do know how to add target="_blank" in ordinary html.
    But how to add this to a Link Forum?

    The field for the URL is then subjected to a script, which surrounds it with the html a href etc, including the quote marks around the actual URL.
    So just adding target="_blank" on the end of the URL line does not work (I tried just in case).
    Other attempts like inserting the quote marks around the URL to make it more complete, unsurprisingly throw an error.

    Above on this thread Jeremy clearly knows this can be done. How please?
  11. Jeremy

    Jeremy Well-Known Member

    Mike explained it in the second post:
  12. Morgain

    Morgain Well-Known Member

    Thanks Jeremy. I got there.
    For anyone else not confident on this here's the code:

    Go to template node_link_level_2
    Count 8 lines down, and insert the blue bit of code where it's shown below.

    <div class="nodeInfo linkNodeInfo">
            <span class="nodeIcon"></span>
            <div class="nodeText">
                <h3 class="nodeTitle"><a href="{xen:link link-forums, $link}" target="_blank" data-description-x="#nodeDescription-{$link.node_id}">{$link.title}</a></h3>
                <xen:if is="{$link.description}"><blockquote class="nodeDescription muted baseHtml" id="nodeDescription-{$link.node_id}">{xen:raw $link.description}</blockquote></xen:if>
    The only drawback is this means that ALL link forums will open the link in a new page.
    abdfahim, rwm1962 and MMAcomm like this.
  13. Jeremy

    Jeremy Well-Known Member

    Surround it in conditionals using node IDs if you don't want them all to link out. See @Brogan's guide.
  14. 51463

    51463 Well-Known Member

    Hello. This works if the link forum is in the node tree but not for the Navigation Bar.

    I disabled the link forum and kept it just in the Nav Bar.

    Where exactly do i modifiy it? I cant find the correct template for the nav bar links.
  15. Jeremy

    Jeremy Well-Known Member

    How did you add it to the navigation bar? If it was an add-on, you'll need to contact the author.
  16. 51463

    51463 Well-Known Member

    oh that's right. I forgot it was an add-on. Now i understand why.

    It was Nodes as Tabs. Thanks i'll ask them
  17. ArsalanS

    ArsalanS New Member

    Hi Guys,
    I followed the process and it works, HOWEVER when the link is clicked from the main page it still opens in the same page instead of opening in a new tab


Share This Page