Image, link and title for Facebook like button at the product list. - facebook

How can I display the right image, title and link for a Facebook Like button in a list of products?
I do implement sucessfully the like button but it is when you navigate to the product details, you see only one product.
I ask how can i do it in the list of products, for now the image displayed on my facebook page is a generic image from the site and not the specific image of the product, the link is right.
Must the tag <meta property="og:image" content="some value"/> only be inside the head tag? I cannot use it inside the body tag?

The meta tags for the news story don't need to be on the page that is displaying the Like button. The news story will be generated from the meta tags on the page listed in the URL parameter of the Like button.
Here is an example. -
This Repeater will dynamically generate a list of products from a database with customized Like buttons:
<asp:Repeater ID="_RPT_Product" runat="server">
<HeaderTemplate><h3>Products</h3><ul class="bulleted-list"></HeaderTemplate>
<ItemTemplate><li><%# Utilities.ScrubText(((Product)Container.DataItem).ProductName) %>
</li>
<div style="padding-top:10px;">
<iframe
src="https://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.yourdomainname.com/Product.aspx%3FID%3D<%#((Product)Container.DataItem).ProductID %>%26x%3D1&send=false&layout=button_count&width=88&show_faces=false&action=like&colorscheme=light&font&height=23"
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:88px; height:23px;"
allowTransparency="true">
</iframe></div><br />
</ItemTemplate>
<FooterTemplate></ul></FooterTemplate>
</asp:Repeater>
This would be the code-behind on a separate Product page that dynamically renders meta tags from a product database:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Get the product meta content from the ID URL parameter.
string productName = "";
string productImageURL = "";
string productDescription = "";
int productID = 0;
if (Request.QueryString["ID"] != null)
{
productID = Convert.ToInt32(Request.QueryString["ID"]);
}
if (Request.QueryString["ID"] != null)
{
using (ProductDatabaseDataContext db = new ProductDatabaseDataContext(Config.ConnectionStrings.ProductDatabase))
{
Product select = new Product();
select = db.Products.FirstOrDefault(p =>
p.ProductID == Convert.ToInt32(Request.QueryString["ID"]));
productName = select.ProductName;
productImageURL = select.ProductImageURL;
productDescription = select.ProductDescription;
}
}
// Dynamically generate Open Graph Meta Tags for each Product:
HtmlMeta _metaTitle = new HtmlMeta();
_metaTitle.Name = "og:title";
_metaTitle.Content = "Product: " + productName;
this.Header.Controls.Add(_metaTitle);
HtmlMeta _metaURL = new HtmlMeta();
_metaURL.Name = "og:url";
_metaURL.Content = "http://www.yourdomainname.com/Product.aspx?ID=" + Convert.ToString(productID);
this.Header.Controls.Add(_metaURL);
HtmlMeta _metaImage = new HtmlMeta();
_metaImage.Name = "og:image";
_metaImage.Content = Convert.ToString(productImageURL);
this.Header.Controls.Add(_metaImage);
HtmlMeta _metaDescription = new HtmlMeta();
_metaDescription.Name = "og:description";
_metaDescription.Content = Convert.ToString(productDescription);
this.Header.Controls.Add(_metaDescription);
}
}
Note that every Like button must have a unique URL parameter, because only one set of meta content attributes can be tied to a single URL. This can be accomplished by having a unique ID parameter on your separate Product.aspx page. The "og:url" meta tag for each of your products can be the same if you just want all of the product news stories to link back to one master list page.

The Like button likes a specific URL and if it's a product the user is liking, that link really should bring users back to a description of that product and not to a completely different set of content.
What you display on that propduct page itself isn't really important (it could be the full product list if you really wanted) provided that that URL returns the same meta tags to the Facebook crawler each time
What you're trying to do could be achieved by setting up a script which serves the meta tags for each product based on URL parameters (making sure to keep the og:url tags pointing to the correct URL to generate the same tags again.
Serve those tags to the Facebook crawler and redirect other browsers wherever you want.

Related

Branch.io inetegration with cordova / ionic 1 app. Shared link generated by branch for snapchat does not show image preview and the link not clickable

We have used Branch.io for implementing deep links in our mobile hybrid app which is developed using ionic 1 framework. We have used branch-cordova-sdk plugin and configured the deep links for sharing with social media apps. We are passing title, description and contentImageUrl for branch.io to create the link. It works great on almost all SM platforms except Snapchat.
When the content is shared on snapchat, the link is showing up along with content but it is not clickable from snapchat. There is no preview of the image is shown. I could not find any solution for this yet. Also please see the code down below in reply. thanks.
Here is the code i'm using:
var branchUniversalObj = null;
var props = {};
props.canonicalIdentifier = 100;
props.title = "my title";
props.contentDescription = "my description";
props.contentImageUrl = "http://lorempixel.com/400/400/";
//create branch object
Branch.createBranchUniversalObject(props).then(function (res) {
branchUniversalObj = res
console.log('Response: ' + JSON.stringify(res))
}).catch(function (err) {
console.log('Error: ' + JSON.stringify(err))
});
Somewhere in the code:
var analytics = {
campaign: "sharing cards"
}
var properties = {
cardId : 100,
cardType: "promo",
refUser: "John"
}
// share sheet
branchUniversalObj.showShareSheet(analytics, properties, "Hello awesome stuff");
When you share a Branch link on various Social Media platforms, it is scraped to display the OG related information (i.e. OG Title, OG Image and OG Description).
When scraped, Branch will return: 1st: any OG parameters that have been defined for the link; 2nd: any OG parameters that have not been defined for the link but that have been defined at the app level (in Social Media Display Customization on the Link Settings page); and finally: any meta tags present on the web site specified in the Default URL ($fallback_url) page.
In order, to ensure that the OG image is displayed correctly, you need to ensure that you have the OG parameters defined at atleast one of the three levels mentioned above.
Here are the various ways to set OG tags
To add the og_image for a particular Quick link on the dashboard:
Visit the Quick links page on your dashboard.
Click on 'Create new Link'
On the 'Configure Options' tab and 'Social Media' section either add the og_image or the og_image_url.
While creating links from the iconic SDK add image URL to the Branch Universal Object using contentImageURL tag as shown below:
Code snippet
var properties = {
canonicalIdentifier: 'content/123',
canonicalUrl: 'https://example.com/content/123',
title: 'Content 123 Title',
contentDescription: 'Content 123 Description ' + Date.now(),
contentImageUrl: 'http://lorempixel.com/400/400/',
price: 12.12,
currency: 'GBD',
contentIndexingMode: 'private',
contentMetadata: {
custom: 'data',
testing: 123,
this_is: true
}
}
// create a branchUniversalObj variable to reference with other Branch methods
var branchUniversalObj = null
Branch.createBranchUniversalObject(properties).then(function (res) {
branchUniversalObj = res
alert('Response: ' + JSON.stringify(res))
}).catch(function (err) {
alert('Error: ' + JSON.stringify(err))
})
To set these OG tags by default for your branch links:
Go to the Link Settings Page on your dashboard:
Scroll down to the "Social Media Display Customization" section
Set the Link Title, Description and an image. Here is a screen shot for your reference.
PS: As a final caution, make sure the image you specify as the OG Image adheres to the Snapchat accepted image dimesions, which I belive is 1080 x 1920 pixels.

How can I set a Facebook iframe like button to add current page URL to href on meteor app?

Hy
I want to add facebook iframe like button to my meteor app, but with a dynamic one not static; means, I ll share any page I want not only one page ( one url)
thank's à lot
You can use the query string you are expected to pass to the src of the iframe like this :
<template name="facebookButton">
<iframe allowtransparency="true" frameborder="0" scrolling="no" class="facebook-button"
src="https://www.facebook.com/plugins/like.php?{{queryString}}">
</iframe>
</template>
We use a simple helper to build the query string, it will be reactive and we can feed it with the current url (location.href).
Template.facebookButton.helpers({
queryString:function(){
var parameters={
href:encodeURIComponent(location.href),
send:"false",
layout:"box_count",
show_faces:"false",
action:"like",
font:"arial",
colorscheme:"light"
};
var pairs=_.pairs(parameters);
var pairsJoined=_.map(pairs,function(pair){
return pair.join("=");
});
return pairsJoined.join("&");
}
});
EDIT : forgot to URI encode the href param.

Show thumbnail of News Author in Sitefinty

I have crated 1 news item in Sitefinty news content section .How can i get Image of News Author in Sitefinty . I have uploaded my pic in my sitefinty profile and crated 1 news Item but no idea i have for display my image on the news detail page .I am using Sitefinty 6.3.
This will have to be a user control referenced from the news widget details template that looks up the profile that created the news post.
I've got a custom control in my solution at ~/CustomControls/AuthorPicture.ascx, in the ascx file its just a .net image control:
<asp:Image runat="server" ID="imgAuthor" />
In the code behind for the control, use this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Modules.Libraries;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Security;
using Telerik.Sitefinity.Security.Model;
namespace SitefinityWebApp.CustomControls
{
public partial class AuthorPicture : System.Web.UI.UserControl
{
public Guid NewsId { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (NewsId == Guid.Empty) return;
var newsManager = NewsManager.GetManager();
var newsItem = newsManager.GetNewsItems().FirstOrDefault(n => n.Id == NewsId);
if (newsItem == null) return;
var userManager = UserManager.GetManager();
var upManager = UserProfileManager.GetManager();
var owner = userManager.GetUser(newsItem.Owner);
var profile = upManager.GetUserProfile<SitefinityProfile>(owner);
var lmanager = LibrariesManager.GetManager();
var image = lmanager.GetImage(profile.Avatar.ChildItemId);
imgAuthor.ImageUrl = image.ThumbnailUrl;
}
}
}
You can see that we'll be passing in the news item id through the NewsId Guid property on the control.
To just show how this works, create a page in Sitefinity and add a News widget on to the page. Click "Edit" select "One particular news item" and select your news item. Under the "Single Item Settings" tab select your details template, the default name is "Full News Item". Click "Edit Selected Template" and register your control in the template:
<%# Register TagPrefix="custom" TagName="AuthorImage" Src="~/CustomControls/AuthorPicture.ascx" %>
Then somewhere in the RadListView itemTemplate, use the control and pass in the news Id to the property:
<custom:AuthorImage runat="server" ID="cstmAuthorImage" NewsId='<%# Eval("Id") %>' />
Save the changes and publish your page, your new control should be run, and it should pull the profile image of whoever created the post.
I found something similar in Sitefinity forums here: http://www.sitefinity.com/developer-network/forums/developing-with-sitefinity-/retrieving-post-author-details-avatar-nickname-etc-in-blog-post-templates
I would probably create a new template for the News detail. Inside here you can attach to the ItemDataBound event where you can set an image for the news item.
The Author field has no relation to a Sitefinity User, so you need to get the ID of the user that created the Newsitem. (the owner)
This code shows you how to do this:
protected void Repeater_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e) {
var data = ((RadListViewDataItem)e.Item).DataItem as NewsItem;
// Get the owner
var owner = userManager.GetUser(data .Owner);
}
The logic for retrieving a user and an image you can find in the code from Ben.
Another way would be to create a custom field which shows you a UserPicker field, which would then allow you to be completely flexible on choosing which Sitefinity User you will relate to a news item.

Setting the page title in TYPO3

I have the below code and which makes the page title more seo friendly. However I am running into the below problems.
config.noPageTitle = 1
page.headerData {
100 = TEXT
100 {
field = description
noTrimWrap = noTrimWrap = |<title>| - Example Site</title>|
}
}
If I have the field = title it displays tha page title field, however on the news single page it doesn't work as it displays the name of the page rather than the title of the aritle.
If I have the field = description the news single defaults to the article title however if I haven't put a description on one of my pages then it displays
<title> - Example Site</title>
Is there away to do if description = '' show title (if it is not a news article)?
Or is there another way I should be approaching this?
There are many samples and snippets for using tt_news title as page title.
Check for an instance this one: http://blog.chandanweb.com/typo3/display-news-title-as-page-title-in-tt_news-detail-view

Select a single 'featured' post in Tumblr?

I would like my Tumblr homepage to show a single Question/Answer post that is selected by a 'featured' tag, or rather by being the most recent Question/Answer post tagged 'featured'. I don't see any built in Tumblr tags that will do this.
I am using jQuery to get the featured post (n number of them) from a category 'featured' by default. I have implemented this solution to my theme - Purely
Here is a screen-shot (displaying three featured posts)
Add this line 's meta section
<meta name='text:Featured Tag' content='featured' />
Add jQuery library in
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
Add these lines in where you want to display the featured post
{block:IndexPage}
{block:IfFeaturedTag}
<h1 class="featured-subhead">
Featured Posts +
</h1>
{/block:IfFeaturedTag}
{/block:IndexPage}
Add these lines just before the closing tag
{block:IndexPage}{block:IfFeaturedTag}
<script>
var rssurl = '/tagged/{text:Featured Tag}/rss';
$.get(rssurl, function(data) {
$('.featured-subhead').append('<div class="featured-posts">');
var $xml = $(data);
var vari = 0;
$xml.find("item").each(function() {
var $this = $(this),
item = {
title: $this.find("title").text(),
link: $this.find("link").text(),
description: $this.find("description").text(),
pubDate: $this.find("pubDate").text(),
author: $this.find("author").text()
}
vari = vari +1;
if(vari <4){
$('.featured-subhead').append('<div class="featured-post" style="overflow:hidden;"><h2 class="featured-title">' + item.title + '</h2><div class="featured-post-description' + vari + '">' + item.description + '</div><div class="featured-post-link">Read More</div></div>');
//Do something with item here...
}
});
$('.featured-subhead').append('</div>');
});
{/block:IndexPage}{/block:IfFeaturedTag}
You can change if(vari <4){ line according to the numbers of posts you want to display as featured. For example, to display a single post, it would be if(vari <2){ .
I have also added few CSS classes to design the output. This can be declared in segment in
h1.featured-subhead
{
/* Heading of featured post */
}
.featured-posts
{
/* Outer box of all featured posts */
}
.featured-post
{
/* Inner box of each featured post */
}
h2.featured-title
{
/* Heading of each featured post */
}
.featured-post-description
{
/* Description or body of each featured post */
}
.featured-post-link
{
/* Link to Permalink page of each featured post */
}
Here only featured-subhead class is necessary. This must be added to the heading of featured post. jQuery will add the featured posts after that.
How does it work?
No surprises here. Tumblr generates a tag RSS page for each page. By using javascript, I am fetching that specific tag page and displaying 'n' number of elements from the XML elements. Sometimes, Tumblr takes a little more time (I don't know why) to generate the RSS page of newly added tags. Be patient and try to browse your-blog.tumblr.com/tagged/featured/rss page to check it is generated or not.
What you're asking is not a native setting to tumblr, in other words there's no preference setting you can simply check.
In order to do what you describes above, you will either need to edit your current theme code, or code a new theme from scratch.
In order to only show 1 question post, at the top, with a tag of featured, you will need to work with the jQuery/Javascript and the Tumblr API.
It's pretty complex coding, but if you're up for it, head on over to the Tumblr API Codex.
This is a little late, but in case it's of any help: Our free Single A theme has the sticky post feature built in. It's the first (and only) tumblr theme to have it. You can get it here: http://www.tumblr.com/theme/28638 or learn more about it here: http://singleatheme.tumblr.com/. Hope this helps!