How do I add a new article in Liferay 6.1 programmatically? - liferay

In liferay 6.0 you can use
JournalArticleServiceUtil.addArticle
But now there are some new arguments in this method:
long classNameId, long classPK
What does its mean?

For adding journal articles, it looks like you can pass 0 for both values.
It appears it was added for your convince as a 3rd party developer to find articles created for your application quicker. See, http://issues.liferay.com/browse/LPS-16960.

Related

How do I display most commented articles in Liferay 7

I would love to work with the number of comments within one article in the asset publisher. For example, I would love:
to display the most commented articles
add tags to the articles with most comments
or something similar that enables me to select the most commented articles. What is the easiest way to start working with articles based on number of comments?
Any examples, code, API, and similar is highly welcome!
For the second point the solution is easy: Model Listener
Just implement a model listener of comment (MBMessage should be the real name) and in the method onAfterCreate retrieve the article on which the comment has been posted and the total number of comment for it, then for example if(totalArticleCommentNumber > 99) add your tags.
Then in the configuration of the Asset Publisher you can select just the articles with your specific tag.
But, if you need some different logic (sort the articles by comment number for example) the case is more complex and you'll have to customize the Asset Publisher to add your new logic.
EDIT:
Some guide that may help you for customize the portal:
Overriding App JSP
Liferay 7 Portlet to Empower Your Custom Development: In this article there is a lot of usefull things but I want point you to the paragraph 4.3, to summarize very shortly: If a class is a OSGI Component (so has the OSGI annotation #Component) you can extend that class and through the service.ranking:Integer property of the annotation you can tell to Liferay that your class overrides the original service.

Customize Search Portlet in Liferay DXP 7

I would like your support in order to get some help in customizing the search component in Liferay DXP 7.0 Enterprise.
I have reviewed all the available documentation but although I have found many articles about the issue, the step by step is not so clear for me.
I need to customize the native search component:
Change the input component to give suggestions while the user is typing the search terms
Change the search result page look and feel.
Anyone ever implemented anything like this?
I know this is an old thread, but StackOverflow keeps showing it as the first open question when I am navigation this particular tag...So here are some pointers, as this is a pretty broad topic...
The search is really confusing for adding customization. Mainly you have to provide some of them as contributors, using the asset framework. following the regular steps to build an asset for the asset publisher you will hit the best place to find documentation about the search contributors.
About the search page, best is to create a new page, besides the default one for extra freedom. As long you use the friendly URL /search it will a basic replacement. In this page you can add everything you need, except for translations for the friendly URL - not great. Another option is to keep the default page (which will not be visible in the build area 7.1.x, but you can edit after you search something and fall inside it).

xpages display the document history

In some 'old' lotus notes applications, we created a history of each document: who created the doc, every person which edited it + the respective dates. The code contained several libraries in lotusScript.
For xpages, is there any snippet / sample working example which I could use? I found this but I couldn't download any example ...
ValueChangeListeners allow you to capture changes to specific components. I've used them to create audit trails in customer applications before.
Tony McGuckin has an XSnippet for it:
http://openntf.org/XSnippets.nsf/snippet.xsp?id=server-side-value-change-events-listeners
Declan Lynch covered it in a blog post:
http://www.qtzar.com/using-a-valuechangelistener-to-build-an-audit-trail/
Don McNally has also done a blog post:
http://dmcnally.blogspot.co.uk/2013/02/xpages-detecting-and-logging-field.html
I don't know of any pre-done snippet yet. But this becomes a lot easier in XPages especially if expand into Java. When I create an application these days I basically convert the document to a Java object. I don't do this yet but it would be easy to store in the object a Map of all the fields and their current values and then on save, look for differences and then write them out to a log document.
this could be done without java of course. Create an map object in scope. Populate it on loading of the document and on save do the compare and write.
Something went wrong with that project on OpenNTF (don't ever use an ampersand in the name). I'm the original author of that custom control. AFter some digging I found a direct url to the project here.

Adding new section in control panel of Liferay

I want to add a new section in control panel of liferay and within that section I want to have my custom-portlet. I did it using ext. However I want to do it with hook . Is it possible ?
I don't think it would be that easy with a hook, because of the following reasons:
You can't modify in a Hook - the class com.liferay.portal.util.PortletCategoryKeys which contains the keys for displaying the different sections. The different sections are hard-coded in this class in a String array ALL.
You can't modify the logic of PortalImpl#isControlPanelPortlet() which uses the PortletCategoryKeys#ALL to determine if the request in question is for a control panel portlet.
Then you also have another method which you can't modify with a Hook and is used extensively PortalImpl#getControlPanelCategory()
Doing it with a hook:
I have not tried this but I think if you need to do it with a hook you would have to change all those JSPs which make use of PortletCategoryKeys#ALL and the methods of PortalImpl as stated above, and provide your custom implementation for all these methods in the JSP.
I would really like to know how you implemented it with an EXT may be just the steps or the methods you have overridden. So that I can try to convert those in terms of a hook.
This is as far as my understanding goes. Hope this helps.
With the advent of Marketplace, ControlPanel has a new category named "Marketplace" and that section is introduced in a plugin. However, I never checked if 6.1 GA2 introduced a new section that this plugin just fills. Check the marketplace plugin if you can find a trace of this section implemented there.
On the other hand, nobody has yet named any section that definitely required a new section (though some have asked me how to solve the same problem). For this reason, you might want to re-think the requirement and choose one of the existing sections. If you don't, at least I'd be interested in the name and purpose of the new section - I might find a first one actually justifying this kind of implementation...

WSS 2.0 - Customizing document library toolbar

I am using Windows Sharepoint Services 2.0 and was looking out for a way to add a new item to the Document Library toolbar along side 'New Document' menu item. I would like to add the menu item for the existing libraries as well as any new libraries created in future. Is this possible? I found that the toolbar items are defined in SCHEMA.xml file. But changing this would affect only the new libraries created right? Also editing this file seems complicated.
Appreciate any help.
Regards,
Jagannath
Have a look at WSS 2.0 reference on MSDN : Customizing the Toolbar for a ListT
Editing schema.xml with WSS 2.0 isn't easy. But it's the "better" way to update lists behavior.
When you udpate schema.xml for a list (custom or not, but you better create a custom one, explanation here), some things a updated immediately, others after a iisreset, and some other only after creating a new list based on this schema file. Unfortunately, I don't remember all the cases.
Otherwise, you can try FrontPage 2003, but it depends on how many lists you have to update, and it breaks "page ghosting".

Resources