Select a single 'featured' post in Tumblr? - 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!

Related

View all comments in GitHub

When searching for some text in a GitHub issue with lots of comments, I first need to have all the comments loaded.
Currently I search for the text items not shown, and then click the View more link.
I sometimes need to do this multiple times.
Is there a way to load all comments in one go?
This also annoyed me, I wrote the following userscript to solve it (as of Dec 2021).
// ==UserScript==
// #name Show all comments on github issue
// #namespace https://www.taylrr.co.uk
// #version 0.1
// #description Automatically clicks the "xxx hidden items" button on Github issue pages to successively load in all the comments in the page on load.
// #author taylor8294
// #match https://github.com/*/issues/*
// #icon https://icons.duckduckgo.com/ip2/github.com.ico
// #grant none
// #license GPLv3
// ==/UserScript==
(function() {
'use strict';
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
function clickButton(){
let button = document.querySelector('.ajax-pagination-form button');
if(button){
if(!button.disabled) button.click();
setTimeout(clickButton,50);
} else console.log('All comments are now showing.')
}
ready(()=>{setTimeout(clickButton,2000)});
})();
Install it in your userscript manager of choice (eg Greasemonkey, Tampermonkey, Violentmonkey, Userscripts Safari etc) and once the page is loaded it will just keep clicking the button for you until all the comments are showing. I've also published the script on Greasyfork (#437823) if you prefer to install from there.

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.

Display contents from a single predefined album

I've been playing around with the FB SDK and some examples that exist for displaying FB photo albums, but the examples are much more complex than what I want to do. All I want to do is set the album id for a single album and pull in the contents. That's it, I can style everything after that, I just need to be able to view the contents of one album and pull in the caption for each photo.
I'm trying to create a WordPress album that does this; I can easily create the base of the widget, but I'm lost when it comes to API's.
Are there any examples out there that I've overlooked?
Does anyone know how to accomplish this?
hopefully this gives you a hint ;)
<?
if (empty($_GET['album'])) {
//get all albums of page
$graph_url = "https://graph.facebook.com/PressPlayPrague/albums? fields=id,link,name,cover_photo&limit=500";
$albums = json_decode(file_get_contents($graph_url));
$counted = sizeof ($albums->data); // get the number of albums for later use
//output all albums of given page
for($c=0; $c<$counted; $c++){
echo ("<div class='wrapper' <a href='?album=".$albums->data[$c]->id."'><div class='stack'><div style='width:180px; height:120px; display:inline-block; background-image:url(https://graph.facebook.com/".$albums->data[$c]->id."/picture?width=300&height=200); background-repeat:no-repeat;'> </div></div><div class='caption'>".$albums->data[$c]->name."</div></a></div>");
};
}else{
//get the album pictures replace the $_GET[album] with specific ID and remove the if clause to get only one album
$pic_url = "https://graph.facebook.com/".$_GET[album]."/photos?fields=picture&limit=500";
$pictures = json_decode(file_get_contents($pic_url));
$countpic= sizeof ($pictures->data); // get the number of pics for later use
for($p=0; $p<$countpic; $p++){
echo ("<img style='width:250px; max-height:167px;' src='https://graph.facebook.com/".$pictures->data[$p]->id."/picture' alt='".$pictures->data[$p]->id."'>");
};
}
?>

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

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

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.