We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40851
    • 6 Posts
    Hi guys, i've been searching the forum and other sites for a couple of days now and have tried a bunch of things to no avail.

    It seems simple enough and have the rest of my code working but i cant get the right outcome.

    Im making my own social media share buttons and this question is specifically for a custom LinkedIn share button.

    Heres the code:

    <a href="http://www.linkedin.com/shareArticle?mini=true&url=I-NEED-THE-CALL-HERE&title=[*pagetitle*]&summary=[*introtext*]&source={articleSource}">


    i have tried as many variants of:

    [[*id]]`]]


    but i have had no luck.

    The rest of the code works, pulling the *pagetitle* and *introtext* as i'd like, but i need LinkedIn to display the URL, otherwise i just get text that leads to nowhere.

    Im sure this is a very easy solution, im just going around in circles with the lack of knowledge i have for Modx.

    If somone could post the code i need to add next to the '&url=' to automatically generate the page url, id be most appreciative.

    Thanks for your time.


      • 4172
      • 5,888 Posts
      If you are on Revo you would do:

      [[~[[*id]]]]


      but seems you are on EVO.

      Then try:
      [~[*id*]~]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40851
        • 6 Posts
        Thank you for your response but thats one i've already tried, and have copied and pasted it from here again just to be sure, but im not getting the link to show once redirected to LinkedIn.

        Attached is an image of the redirected view. You can see that the 'pagetitle' and 'introtext' is being displayed but no web url.

        Heres the code im using:

        <a href="http://www.linkedin.com/shareArticle?mini=true&url=[~[*id*]~]
        &title=[*pagetitle*]&summary=[*introtext*]&source={articleSource}">
        <img src="assets/templates/wheel/images/lin.png" alt="linkedin share button" title="linkedin share button" />
        </a>
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Can you determine exactly what is being generated here? [~[*id*]~] should definitely be generating the URL for the page. However, it may be generating relative URLs when you need full URLs. Do you have
          <base href="[(site_url)]" />

          in your template's head?

            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
            • 40851
            • 6 Posts
            Hi Susan, thanks for assisting,

            Yes i have, <base href="[(site_url)]"></base>, within the page template head, and in checking the browser source shows:

            <base href="http://www.mysite.com.au/"></base>

              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Hm Would still like to be able to see exactly what's getting output by that code.

              Try putting it in a testing resource and see what it displays. Of course, the {...} bit won't parse, but we'll see what MODx is sending them, anyway.

              Ah, sorry, I meant without the <a tags... just the inner part, to see what the MODx tag output is.
                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
                • 40851
                • 6 Posts
                Susan i'd kiss you if i could,

                Just by giving me that little way of testing by seeing what Modx spits out i was able to ascertain that it was only spitting out the page ie. index.php?id=41

                By adding [(site_url)] before [~[*id*]~] i was able to have LinkedIn post the correct link.

                I also removed the &source={articleSource}, but i dont know if that would have changed anything.

                So in all, for a custom LinkedIn link i used:

                <a href="http://www.linkedin.com/shareArticle?mini=true&url=[(site_url)][~[*id*]~]
                &title=[*pagetitle*]&summary=[*introtext*]">
                <img src="YOUR-IMG-URL" alt="LinkedIn share button" title="LinkedIn share button" />
                </a>

                Thanks very much for that testing tip, i thinks its going to save me a lot of headaches in the future, and thank you for the prompt support
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  That &source={articleSource} is most likely for internal LinkedIn use. It is responsible for parsing your query string and generating whatever it needs from that. Actually, it looks like a Smarty template tag.
                    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