We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41970
    • 79 Posts
    Quote from: nuan88 at Aug 04, 2014, 04:58 PM
    Wow! Great job!

    For url redirecting, you might try redirect_uri

    target="_blank" redirect_uri="www.sitename.com" title="Share on Facebook">

    Also I notice a couple extra spaces before target, those are ok?

    But important thing it is grabbing the metas, I wonder what did the trick. But still, very cool!

    I figured out that I had the metas in the headers of the article twice, once within a chunk that I linked to, and a second time just written into the header. Once I removed the chunk link, it worked! I also had to use the FB linter debugger for each article to remove it out of the cache, so that is also a good advice.

    As for the target, thanks for noticing that, it seems I am already "blind", looking at the code forever! The url redirecting is not what I meant though, this would only load another page or site after submitting to FB, right? What I need is the link that is being posted to Facebook to be different, since the content is on a one-single page, meaning, the link on FB needs to link to the correct "anchor" on that page. I am looking into this more this evening, with the help of a friend who knows more about javascript.
      • 46886
      • 1,154 Posts
      Yeah I can see you have a bunch of chunks. Looks like you have been working on that site for some time!

      Ah I did misunderstand about what you are trying to do now, and I might still not have it right.

      So you are saying the link to your site that appears in FB is wrong? What link are you getting and what link do you want?

      If I got you right, here is where you give the link to FB: u=[[++site_url]][[*id]]"

      I am using slightly different code because I am working with Discuss, the forum module, and each post isn't a resource and doesn't have long title or any of that.

      [[++site_url]] should be www.mycoolsite.com and [[*id]] should be (I think) www.mycoolsite.com/phpid?=22, where 22 is the number of that resource and "phpid" is not the right code, I can't remember exactly what it looks like.

      Here is what Menno has, and notice that its [[*uri]] and not url, see if this works:

      <a target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=[[!++site_url]][[*uri]]">Facebook</a>
        • 46886
        • 1,154 Posts
        Yeah I almost missed Dan's important point, thanks Dan!
          • 41970
          • 79 Posts
          I am sorry if I explained it not very well wink
          The situation I have is that since my website is a single-page site, with all "pages" on one page, instead of them being separately. The link I share with FB is correct, and it needs to be just like I have it in order to load the correct og:image, title etc. But when a FB user clicks on that same link, it only takes him to the top of the website, but not "down" to where the news articles are. So what we'll have to come up with (my developer friend and I) is to take the FB user "down" to the correct position of the article linked in FB.

          We are almost there though, and I am confident that I'll come up with the solution soon.
            • 41970
            • 79 Posts
            Quote from: nuan88 at Aug 04, 2014, 05:30 PM

            I am using slightly different code because I am working with Discuss, the forum module, and each post isn't a resource and doesn't have long title or any of that.

            [[++site_url]] should be www.mycoolsite.com and [[*id]] should be (I think) www.mycoolsite.com/phpid?=22, where 22 is the number of that resource and "phpid" is not the right code, I can't remember exactly what it looks like.

            Do you have a link to your site, maybe I can check and see something you don't?

              • 46886
              • 1,154 Posts
              Ah! Your explanation is clear now!

              Its an interesting problem. You I think were trying to use the div name to direct it.

              I don't know exactly how this works, but it sounds like a faq where you can click and go right to that part of the page. That should be fairly simple, I think that's just html, something like this:

              <section class="about">

              or

              <div class="about">

              But how to get that url might be trickier. I wonder if you could just hard code it, if there are just a few sections:

              u=[[++site_url]]/about"

              Anyway, let us know how it all shakes out!
                • 46886
                • 1,154 Posts
                This morning I figured out that it won't be www.mycoolsite.com/about but rather www.mycoolsite.com#about.

                Sure I am always happy for some feedback. My site is at www.rayxilawforums.com.

                Basically my front page is a bit plain, I need to jazz it up a bit but don't know where to start. So any advice is welcome!

                So how is it going? Fix that last problem yet? If you want to add twitter as well that's the one I did get working before I stopped.
                  • 41970
                  • 79 Posts
                  Sorry for not posting the solution here earlier, but that very same website has been giving me major headaches....

                  For everybody who is looking for a solution to include proper FB sharing into one-page websites, here is the solution I came up with for my project:

                  First of all, this solution is really NOT a perfect solution because it uses iframes. So if you are not comfortable with this, don't use it. For my project, it really was the only way without having to restructure everything. So I am just "warning" you that this might not be a very clean solution, but it works.

                  The structure in my project is that I have one main page where all content is loaded into, and I do this with renderResources. First I am loading the "events container" into the main page with this code:

                  [[!renderResources? &resources=`67`]]


                  Resource ID 67 is my container for the event articles. This container uses a template, containing this code:

                  <div class="content">
                     [[!renderResources? &parents=`67` &tpl=`specialevents_tpl`]]
                  </div>


                  What this code is doing, it loads the event articles into the container, using the template chunk "specialevents_tpl", which includes the following code:

                  <script language="javascript" type="text/javascript">
                    function resizeIframe(obj) {
                      obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
                    }
                  </script>
                  
                  <iframe id="article[[*id]]" class="iframe1" width="100%" frameborder="0" scrolling="no" 
                    marginheight="0" marginwidth="0" src="[[*id]]" onload="javascript:resizeIframe(this);">
                  </iframe>
                  


                  Here you see the iframe solution, and the javascript was necessary because otherwise the articles wouldn't fully show but were cut off.

                  The template for the event articles lookks like this:

                  <html>
                  <head>
                  <title>[[++site_name]] - [[*articleHeadline]]</title>
                  <meta property="og:type" content="website" /> 
                  <meta property="og:image" content="[[++site_url]][[*roundImage]]" /> 
                  <meta property="og:title" content="[[*articleHeadline]]" /> 
                  <meta property="og:description" content="[[*articleText:strip_tags]]" /> 
                  <meta property="og:url" content="[[++site_url]][[*id]]" />
                  
                  [[$specialEventsCSS]]
                  [[$specialEventsJS]]
                  [[$googleAnalyticsJS]]
                  [[$colorboxJS]]
                  [[$slideToggleJS]]
                  
                  <script>
                  if (self == top)
                  {
                   document.location.href='http://www.pricklybaymarina.com/index.php#article[[*id]]'
                  }
                  </script>
                  <script>
                    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
                    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
                  
                    ga('create', 'UA-53612514-1', 'auto');
                    ga('send', 'pageview');
                  
                  </script>
                  
                  </head>
                  <body>
                  
                  <div class="contentLeft iframe">
                  <div class="roundimage">
                  <img class="round" src="[[*roundImage:phpthumbof=`w=200&h=200&zc=1&q=95`]]" alt="[[*articleHeadline]]" />
                  </div>
                  
                  <a class="fbsharebutton" id="shareFB" target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=[[++site_url]][[*id]]" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;" title="Share on Facebook"></a>
                  
                  
                          <h4 id="article[[*id]]" class="blue" style="margin-bottom:10px; margin-top:0;">[[*articleHeadline]]</h4>
                          <p class="datetext">[[*datetimeText]]</p>
                          [[*articleText]]
                     <div class="divider"></div>
                  </div>
                  </body>
                  </html>
                  


                  To see this all in "action", go to www.pricklybaymarina.com and choose "Entertainment" and "Special Events". Voila.

                  Again, this is not a great solution at all, but it works, so I hope it is of help for some of you who have been looking for something similar.

                  Any questions, feel free to ask.
                    • 46886
                    • 1,154 Posts
                    Wow thanks for coming back and providing your solution to the community! Your site is absolutely gorgeous!

                    It is true your system is not perfectly clean, but I think no site ever is, even for the really skillful coders. If there is a real drawback then you may want to re-organize later, but if not, hey if it works don't mess with it!