We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26074
    • 121 Posts
    Hi,

    how I can set option target="_blank" in a new weblink?
    Is it possible?

    For example I want create a new voice in my menu that is a link to my forum. When I click on forum link from menu, I want open forum in a new window.

    Thanks
      ___________________________________________________________________
      ..:: Samuele ::..
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      As far as I know, weblinks don’t allow for any parameters.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 32963
        • 1,732 Posts
        Quote from: samuele at Jun 18, 2006, 08:07 AM

        Hi,

        how I can set option target="_blank" in a new weblink?
        Is it possible?

        For example I want create a new voice in my menu that is a link to my forum. When I click on forum link from menu, I want open forum in a new window.

        Thanks

        Hi,

        This feature has been on requested many times. I think we will be addressing it the near future
          xWisdom
          www.xwisdomhtml.com
          The fear of the Lord is the beginning of wisdom:
          MODx Co-Founder - Create and do more with less.
          • 4018
          • 1,131 Posts
          I’ve been thinking about this myself. I think a worthwhile solution would be to write a plugin that changes all target attributes that have a value of "_blank" into a line of javascript that forces the URL to open in a new window. I’ve played with the idea a little bit...but didn’t get very far.
            Jeff Whitfield

            "I like my coffee hot and strong, like I like my women, hot and strong... with a spoon in them."
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: Bravado at Jun 18, 2006, 10:21 AM

            I’ve been thinking about this myself. I think a worthwhile solution would be to write a plugin that changes all target attributes that have a value of "_blank" into a line of javascript that forces the URL to open in a new window. I’ve played with the idea a little bit...but didn’t get very far.

            See this solution I posted in the NewsParserX thread at http://modxcms.com/forums/index.php/topic,2366.msg18361.html#msg18361-- it’s based on a technique used by A List Apart; now we just need to be able to set custom attributes on a WebLink and then have the core generate the rel attribute when
            $modx->makeUrl()
            is called in a snippet/plugin or the link tags are used in content ( e.g.
            [~[*id*]~]
            ).
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              A while ago when I hacked the parser to allow for the use of the MODx [~...~] tags in a weblink I thought about going the whole bit and adding all the code to that section but I got lazy... Sorry about that. It shouldn’t be too difficult to add the rest of the code for a full parsing of the content of the weblink as a full URL complete with query strings.

              Actually, that’s all it does... it checks if it’s a weblink (reference) and uses its content as an argument to sendRedirect:

                    // check whether it's a reference
                    if($this->documentObject['type']=="reference") {
                        // if it's an internal docid tag, process it
                        if(strpos($this->documentObject['content'],'[~') !== false) {
                            // generate a url
                            $this->documentObject['content'] = $this->rewriteUrls($this->documentObject['content']);
                        }
                        $this->sendRedirect($this->documentObject['content']);
                    }
              

              So that middle bit could be expanded to deal with the query string.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 33238
                • 388 Posts
                http://modxcms.com/extras/package/&package=650

                Better Late than never!!! that one wors for me!!! grin grin grin
                  --
                  ysanmiguel.com
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Actually, that’s what the "Attributes" field is for. If you’re on Evo, you may need to check the ManagerManager rules chunk, as I believe it hides that field in some cases.

                  Wayfinder uses the [+wf.attributes+] placeholder for it.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 33238
                    • 388 Posts
                    Simple solution, i use this with Ditto but i think it may works for Wayfinder, inside the tpl (&tpl=`name`) code just add the template variable [+link_attributes+]:

                    <a href="[~[+id+]~]" [+link_attributes+]>[+menutitle+]</a>


                    This code will activate the field Link Attributes in the Edit Resource area of the Weblink or normal page.
                    You just need to fill the field with the code target="_blank" if you want to open the link in a blank page, if you don't put anything it will open in the seem window, Ex:



                    That was a headache for ages, i feel so stupid because the solution was so basic! tongue
                    hope you use it, and don't spend more time looking for a solution!

                    Cheers! laugh
                      --
                      ysanmiguel.com
                      • 19872
                      • 1,078 Posts
                      Ysanmiguel!
                      You save the day again. I have spent the last hour trying to figure this out, and it was so simple.

                      Thank you.

                      Marc

                      Quote from: Ysanmiguel at May 30, 2013, 04:41 PM
                      Simple solution, i use this with Ditto but i think it may works for Wayfinder, inside the tpl (&tpl=`name`) code just add the template variable [+link_attributes+]:


                      This code will activate the field Link Attributes in the Edit Resource area of the Weblink or normal page.
                      You just need to fill the field with the code target="_blank" if you want to open the link in a blank page, if you don't put anything it will open in the seem window, Ex:


                      That was a headache for ages, i feel so stupid because the solution was so basic! tongue
                      hope you use it, and don't spend more time looking for a solution!

                      Cheers! laugh