The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

HTML Question - Generate URL in Link

PeterAndCompanyPeterAndCompany Registered User regular
edited June 2010 in Help / Advice Forum
I know, this is basic HTML stuff and I'm a bit ashamed for asking, but looking around online hasn't yielded any results and I'm just frustrated at my inability to make this work.

I'm trying to link to a collection of social networking sites in a "Share This Page" type of arrangement. Problem is, the page itself is a generated news article from a central SQL database, so I can't manually type in the URL into the HREF tag. I'm trying to find whatever code it is that I can put into the tag that will include/generate the URL of the news article/page in the reference link.

Like I said, I know it's something simple, and usually I can figure this stuff out. I just have a dozen things on my checklist this morning and this isn't something I can waste time trying to fix.

PeterAndCompany on

Posts

  • ChanusChanus Harbinger of the Spicy Rooster Apocalypse The Flames of a Thousand Collapsed StarsRegistered User, Moderator mod
    edited June 2010
    I don't know much about it either, but is this more of a PHP thing than HTML?

    Chanus on
    Allegedly a voice of reason.
  • PeterAndCompanyPeterAndCompany Registered User regular
    edited June 2010
    It could be. It's a code I need to include in the HREF tag, but I'm not sure if I need to call a function in order for the browser to recognize the URL of the currently-loaded page. If that's the case, then this will likely take a little more work, but I just need to be pointed in the right direction. Searching on Google to find the answer to this problem has been pretty fruitless.

    I would THINK that it would be a standard HTML code for the browser to simply insert the current page into the tag, but that may just be me hoping for a simple answer.

    PeterAndCompany on
  • amateurhouramateurhour One day I'll be professionalhour The woods somewhere in TennesseeRegistered User regular
    edited June 2010
    It could be. It's a code I need to include in the HREF tag, but I'm not sure if I need to call a function in order for the browser to recognize the URL of the currently-loaded page. If that's the case, then this will likely take a little more work, but I just need to be pointed in the right direction. Searching on Google to find the answer to this problem has been pretty fruitless.

    I would THINK that it would be a standard HTML code for the browser to simply insert the current page into the tag, but that may just be me hoping for a simple answer.

    Are you using wordpress? If so, there's a plugin called social bookmarking reloaded that will do this for you, and it works really well.

    If you're not using wordpress, you can just write a simple set of ahref tags with images and links to the general site, copy them to notepad, and add them after every post. This is basic, and time consuming.

    If you're using CMS, then you'll want a php script that will actually tag the post with the social links that actually link the current blog entry when users click the links. Again, I say download the social bookmarking reloaded plugin, or any wordpress plugin that does this, and then examine the php script and see where the calls are made.

    amateurhour on
    are YOU on the beer list?
  • PeterAndCompanyPeterAndCompany Registered User regular
    edited June 2010
    Nope, I'm not using Wordpress. It's a site built from the ground-up. It uses mostly ASP and CSS to make the site function. Very basic and nothing too flashy about it (which was intentional, based on the client's requests).

    I went through the code for Social Bookmarking Reloaded (thanks so much for the suggestion!) and found the code for when it calls the page URL. I think I can use something similar, but it's looking more and more like I'll have to type up some custom code just to make such a simple function. ARGH.

    Unless I can find a free-to-use script that essentially generates a dynamic URL for incorporation into an HREF tag... hmm.

    PeterAndCompany on
  • TejsTejs Registered User regular
    edited June 2010
    If I understand your question right, you have a page that you are making, and it lives on some Url, http://example.com/SomeFolder/MyDynamicPage, and you want your links to share to point to http://example.com/SomeFolder/MyDynamicPage correct?

    You can easily accomplish this with some javascript like so:
    <script type="text/javascript" language="javascript">
               document.getElementById('myLink').href = window.location.href;
          </script>
    

    Tejs on
  • PeterAndCompanyPeterAndCompany Registered User regular
    edited June 2010
    Ahh, that does sound much easier. Thanks! How do I utilize that with the link now?

    Just for one example, here's the Facebook "Share" code, sans the dynamic URL that would be generated from that Javascript code:
    <a href="http://www.facebook.com/sharer.php?u=[insert url here]">
    

    PeterAndCompany on
  • TejsTejs Registered User regular
    edited June 2010
    You'd just do something like this:
        document.getElementById('myLink').href = 'http://www.facebook.com/sharer.php?u=' + escape(window.location.href);
    

    The escape is used to encode your website url in case you use query string arguments. Might want to test it a bit though.

    Tejs on
Sign In or Register to comment.