How to access FeaturedPost widget data from outside the widget?

55 views
Skip to first unread message

RahetBaal

unread,
Apr 17, 2019, 5:07:57 PM4/17/19
to Forum Blogger Ambassade Francophone

Hi, I need to check if FeaturedPost widget is enabled, AND then check if FeaturedPost id is equal to current retrieved post on homepage loop then the loop will ignores it.

Something like this:

<b:with value='data:widgets.FeaturedPost' var='fp'>
​<b:loop index='item' values='data:posts' var='post'>
<b:if cond='data:item.id != data:fp.id'>
</b:with>
<b:eval expr='data:item.id'/>
</b:if>
</b:loop>

OR:

​<b:loop index='item' values='data:posts' var='post'>
<b:if cond='data:item.id != data:widgets.FeaturedPost.id'>
<b:eval expr='data:item.id'/>
</b:if>
</b:loop>

Soraya Lambrechts [fr-BE]

unread,
Apr 18, 2019, 10:09:54 AM4/18/19
to Forum Blogger Ambassade Francophone
Hi,

Use this data : data:widgets.featuredPost.first.postId


<b:loop values='data:view.isHomepage ? data:posts where (p => data:widgets.featuredPost.first.postId == p.id) : data:posts' var='post'>

</b:loop>


Best :)

RahetBaal

unread,
Apr 18, 2019, 8:50:44 PM4/18/19
to Forum Blogger Ambassade Francophone
Hi Soraya,

First of all i want to thank you very much for your efforts and time :) 
and i really respect you and like your tutorials on your blog bloggercode-blogconnexion .

Second. I want to tell you that i tried your suggested code but it not works for me :(
i wonder that 
<data:widgets.FeaturedPost.title/>
works like a charm and returns the string of widget title

but 
<data:widgets.FeaturedPost.posts/>
not works and returns error
 <!--Can't find substitution for tag [widgets.FeaturedPost.posts]-->

I also tried to use .first 
<data:widgets.FeaturedPost.first.posts/>
but it returns the same error.

i wonder where is the problem ?! :)

Soraya Lambrechts [fr-BE]

unread,
Apr 19, 2019, 10:10:28 AM4/19/19
to Forum Blogger Ambassade Francophone
Thanks.

posts is only available for Blog and PopularPosts.


To find and compare 2 posts, you must use the ID : data:widgets.FeaturedPost.first.postId == another ID

Reply all
Reply to author
Forward
0 new messages