Project

General

Profile

Facebook and twitter

Added by Marcel Tella about 14 years ago

Hi!

I came up with the idea of putting a twitter and facebook icons in the web application.

like that.

http://twitter.com/about/resources/tweetbutton

http://developers.facebook.com/docs/guides/web/

But I'm trying to do it by

_facebook= new WText(\"

<iframe src=\"http://www.facebook.com/plugins/like.php?href=YOUR_URL\\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; width:450px; height:80px;color:white;\">

\",XHTMLUnsafeText,this);

something like this, that I understand that is like inserting plain html.

And the applcation explodes, segmentation faults, some parts of the app just desappear...

Is there any other less hackish way to do it?

Thank you!


Replies (4)

RE: Facebook and twitter - Added by David Hubbard about 14 years ago

Marcel

I'm not able to look at the code myself at present, but you might want to have a look at the Blog example which includes an RSS Feed icon. From memory I think this uses WTemplate and WPanel for the formatting and positioning of the icon, I can't recall how the link details are managed, but pretty sure done via API call - possibly a WAnchor or WResource.

Dave

RE: Facebook and twitter - Added by David Hubbard about 14 years ago

Marcel

BTW I did notice that in your initial approach you don't have an end iframe just a second - so possibly not a strict XHTML block of text.

But as a follow up on the template technique I mentioned and having had a quick re-look at Blog example.

Within the template for this (blog.xml) there is referenced in the "blog-login" message - this is where (I believe) you'd put the twitter anchor text - with a parameter space as per ${feed-url}

<messages>
  <message id="blog-login">
    <div class="login-box">
      <div class="login-menu">
    ...
    <a href="${feed-url}">
      <img src="css/rss.png" alt="Rss Feed"
         style="margin-left: 6px; vertical-align: top;"/>
    </a>
      </div>
    ...
    </div>
  </message>

Then in your code this is linked via (just showing the key bits)

  app->messageResourceBundle().use(WApplication::appRoot() + "blog");    // links to template file "blog.xml"

  login_ = new WTemplate(this);                
  ... 
  login_->setTemplateText(tr(blog-login"));
  ...
  login_->bindString("feed-url", rssFeedUrl_);

Appreciate using Templates may be a shift from where you are and there may be other (better?) ways of doing this, but this is the approach I've been following for one of my projects

Hope that helps -

Regards

Dave

RE: Facebook and twitter - Added by Wim Dumon about 14 years ago

Marcel,

That example you gave should indeed work when you fix the typo (second should be ). Haven't tried it myself, though...

Wim.

RE: Facebook and twitter - Added by David Hubbard about 14 years ago

Yes, I noticed this "bug" was embedded in the example on the facebook link Marcel provided - however 50,000 people seem to "like" the page - they can't be wrong can they ;o)

    (1-4/4)