javascript - Adapting Blogger's Featured Post Gadget to show recent posts of specific labels -


essentially title says all. know how adapt blogger's featured post gadget instead of showing recent posts entire site, show recent posts label? want widget can show recent post (just 1 post) 1 of labels.
link site. gadget i'm talking called random post on site:http://newsotuniverse.blogspot.ca/
i'll provide code site non-blogger users see if can tackle problem:

          <b:widget id='featuredpost1' locked='false' title='random post' type='featuredpost'>             <b:widget-settings>               <b:widget-setting name='showsnippet'>true</b:widget-setting>               <b:widget-setting name='showposttitle'>true</b:widget-setting>               <b:widget-setting name='showfirstimage'>true</b:widget-setting>               <b:widget-setting name='usemostrecentpost'>true</b:widget-setting>             </b:widget-settings>             <b:includable id='main'>   <!-- display title if it's non-empty -->   <b:if cond='data:title != &quot;&quot;'>     <h2 class='title'><data:title/></h2>   </b:if>   <b:include name='content'/>    <b:include name='quickedit'/> </b:includable>             <b:includable id='content'>   <div class='post-summary'>     <b:if cond='data:showposttitle , data:posttitle != &quot;&quot;'>       <h3><a expr:href='data:posturl'><data:posttitle/></a></h3>     </b:if>     <b:if cond='data:showsnippet , data:postsummary != &quot;&quot;'>       <p>         <data:postsummary/>       </p>     </b:if>     <b:if cond='data:showfirstimage , data:postfirstimage != &quot;&quot;'>       <img class='image' expr:src='data:postfirstimage'/>     </b:if>   </div>    <style type='text/css'>     .image {       width: 100%;     }   </style> </b:includable>           </b:widget> 

would appreciate if help. in advance!

update: updated code filters posts label label1.

i don't think possible, since can't access labels property featured post data element, but replace featuredpost widget blog widget, code this:

<b:widget id='blog2' locked='true' title='featuredblog' type='blog' >   <b:includable id='main'>     <div class='post-summary'>       <b:with var="filtereddata" value="data:posts filter (p =&gt; p.labels ( l =&gt; l.name == &quot;label0&quot; ))">              <b:loop values='data:filtereddata' var='post' index='index'>           <b:if cond='data:index == "0"' >              <h3><a expr:href='data:post.url'><data:post.title/></a></h3>             ...           </b:if>           </b:loop>       </b:with>    </div>   <b:include name='quickedit'/>   </b:includable> </b:widget> 
  • it not sexy, , have copy html-structure featured post widget
  • you have change id='blog2' according needs.

mini explanation filtering:
data:posts filter (p =&gt; p.labels ( l =&gt; l.name == &quot;label0&quot; ))
data:posts: posts
filter: lambda function, called posts( filter items ) , returns "fitting" items
(p => ... ): outer function "construct" p.labels: p current post, labels labels of current post any: other lambda function, returns true if 1 items "fits"
(l => l.name == "label0") ... inner function checking if post has label name label0

here link inofficial reference website: http://template-data.blogspot.co.at


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -