cancel
Showing results for 
Search instead for 
Did you mean: 

Viewing Blog posts

igneus
Champ in-the-making
Champ in-the-making
Hello,

i have a small problem, that is probably easily resolved, but i cant find the solution myself so im asking for some direction.

We are using Alfresco Community 3.4.d running on a virtual Linux machine.

I'm having several blog posts that are shown in Site Blog part of the Share and they always need to be shown, without updating them.
The "problem" i'm having is that every time a user goes to Blog section on the site, the posts are not shown until he filters them with "ALL" , since the default filter is "Latest" .

Simple, is there any way to change the default behavior of Blog component, so that someone clicks on Blog link on the site, he is shown with "ALL" Blogs as a default?

Thank you in advance.
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
The way to figure this out is to first find the client-side JavaScript file that is setting the initial filter. Using something like Firebug, you'll find that it is in a client-side JavaScript file called "/components/blog/postlist.js". On line 109 of that file, you'll see that there is an option called initialFilter. Later in the code, around 560, you'll see where the value set in the initialFilter gets merged with a default value. If you watch this line in the debugger, you'll see that the initialFilter option is getting set before we arrive at this code, which means we do not want to change the client-side JavaScript. Instead, we need to figure out where that option is set and override it there.

Next, we go look at the web scripts used to make up the blog functionality. These reside in "/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/blog/". If we grep for initialFilter, we get a hit on postlist.get.html.ftl. If you take a look at that file, you'll see:

new Alfresco.BlogPostList("${args.htmlid}").setOptions(
   {
      siteId: "${page.url.templateArgs.site!''}",
      containerId: "${template.properties.container!'blog'}",
      initialFilter:
      {
         filterId: "${(page.url.args.filterId!'new')?js_string}",
         filterOwner: "${(page.url.args.filterOwner!'Alfresco.BlogPostListFilter')?js_string}",
         filterData: <#if page.url.args.filterData??>"${page.url.args.filterData?js_string}"<#else>null</#if>
      }
   }).setMessages(
      ${messages}
   );

So what we want to do is change that filterId from 'new' to 'all'. It is tempting to change this file, but the right thing to do is to use Share's extension mechanism. To do that, copy the file to "/WEB-INF/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/blog/postlist.get.html.ftl". Then, edit the file to change the filterId string.

Now, when you restart the Share webapp, Alfresco will override its postlist.get.html.ftl view with your copy, and when you navigate to the blog page, the default filter will be All instead of Latest.

Jeff

igneus
Champ in-the-making
Champ in-the-making
I just tried it and it works like a charm!

That was one of the best and most detailed solution Jeff. Thank you very much for that!
Beer is on me next time you visit Croatia  Smiley Tongue

This one is solved.

I guess i can do the same with Discussions right?

Thank you again for the help.

igneus
Champ in-the-making
Champ in-the-making
Just to add, I managed to change the filter on Discussions also, in topiclist.get.html.ftl