Expand my Community achievements bar.

SOLVED

Unable to programatically create blog entries

Avatar

Level 2

We have customized the OOTB blog, but retained the code in the various JSPs(for the time being) associated with the blog component. I have programatically created blog articles/posts under the blog - these have the same node structure and properties as that of the articles/posts created through the 'Add Entry' option present in the blog. However, the following piece of code, present inside the content.jsp of the blog's 'page' component(similar to that of /libs/social/blog/components/page/content.jsp)

blog.isEntry()

always returns false when I run the blog articles/posts that I created programatically, whereas it returns true in the articles/posts created through the 'Add Entry' option present in the blog page. I have compared the properties and node structures of both and they seem to be exact. Am I missing something when I programatically create blog entries? I cannot quite understand what exactly happens when the blog.isEntry() method is called after looking at the API documentation of com.adobe.cq.social.blog.Blog

I have printed out the BlogEntry of the blog under which I created the articles/posts programatically, by iterating the blog.getEntries() and printing them out. On doing this, I could observe that the programatically created articles/posts appeared as blog entries. So, I cannot understand why the blog.isEntry() returns false for these posts/articles.

This is a real showstopper. Please help me.

 

Thanks in advance
Shriram

1 Accepted Solution

Avatar

Correct answer by
Level 2

This was a really silly mistake that I made. When I compared the existing blog post nodes with the programatically created nodes, I was checking if any property present in the former was missing in the latter. I was completely oblivious to the fact that the presence of an extra incorrect property could affect the blog.isEntry(). In my case, the mistake was that the year node and the month node(parents of the blog post node) should have a property called blogarchive. However, this property should not be present in the blog post node. In my case, as I was creating all the year node, the month node and the blog post node using a single piece of code, I was setting the blogarchive property for all these nodes. I removed this property from my blog post node and BINGO! It worked.

 

The actual fix : Remove unnecessary properties from the blog post node - In my case, it was the blogarchive property.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 2

This was a really silly mistake that I made. When I compared the existing blog post nodes with the programatically created nodes, I was checking if any property present in the former was missing in the latter. I was completely oblivious to the fact that the presence of an extra incorrect property could affect the blog.isEntry(). In my case, the mistake was that the year node and the month node(parents of the blog post node) should have a property called blogarchive. However, this property should not be present in the blog post node. In my case, as I was creating all the year node, the month node and the blog post node using a single piece of code, I was setting the blogarchive property for all these nodes. I removed this property from my blog post node and BINGO! It worked.

 

The actual fix : Remove unnecessary properties from the blog post node - In my case, it was the blogarchive property.

Avatar

Level 10

Good pickup -- nice work on solving the issue and letting the community know about it. 

Avatar

Level 2

Hi Scott,

How to create Customized  Blogs template can you please .

 

Thanks,

Surendar

Avatar

Level 9

In general, any time you customize, you copy from the /libs directory to the /apps directory and make your customizations there.

 

Please provide information as to which version of AEM, whether or not you applied a Communities feature pack, and your deployment.

The Blog feature found in AEM 6.1 (publish-side blogging) is different from the Blog feature found in AEM 6.0 and earlier (author-side blogging).

 

AEM 6.1 : http://docs.adobe.com/docs/en/aem/6-1/develop/communities/essentials/blog.html

    You should install the latest Communities version.

 

AEM 6.0 : http://docs.adobe.com/docs/en/aem/6-0/develop/social-communities/essentials/blog.html

     You should install the latest Communities version.

 

- JK