文档
Liferay提供丰富知识资源,协助我们的社区与我们的技术更好地结合、应用。
Blogs
The word Blog is an apostrophe-less contraction of the two words web log. Blogs were first popularized by web sites such as Slashdot (http://slashdot.org) which have the format of a running list of entries to which users could attach comments. Over time, more and more sites such as Digg, del.icio.us, and Newsvine adopted the format, empowering users to share their opinions and generating lively discussions.
Over the course of time, blogging sites and applications began to appear, such as blogger.com, blogspot.com. TypePad, WordPress, and Web Roller. These applications allow individuals to run their own web sites in the same format: a running list of short articles to which readers who are registered with the site can attach threaded comments. People who run a blog are called bloggers, and sometimes they build a whole community of readers who are interested in their blog posts. Additionally, there are several famous people who run their own blogs. It gives people an outlet for self-expression which they would not otherwise have, and the ubiquity and wide reach of the Internet ensures that if you have something important and interesting to say, somebody will read it.
Illustration 73: Slashdot, one of the first blogs on the Internet Liferay Portal has a portlet called the Blogs portlet which allows you to provide a blogging service to users of your web site. In fact, Liferay extensively uses the Blogs portlet on http://www.liferay.com to provide employees with blogs of their own. In addition to the Blogs portlet, there is also a Blogs Aggregator portlet which can take entries from multiple users' blogs and put them all in one larger list. We will go over how to use both of these portlets to create a blogging site for your users.
The Blogs Portlet
Illustration 74: Initial view of the Blogs portlet The Blogs portlet is available from the Collaboration section of the Add → More menu. You will notice that it is an Instanceable portlet, meaning that it can only be added once to any community or organization. This allows you to use the Blogs portlet to create a shared blog to build a site like Slashdot or to create multiple personal blogs to build a site like http://blogger.com. What's the difference? Adding the Blogs portlet to a Community or Organization page creates a shared blog for members of the Community or Organization. Adding the Blogs portlet to a user's personal space creates a blog for just that user. Either way, the Blogs portlet works the same. And of course, you can change the Blog portlet's scope to have different blogs on different pages in the same community.
By default, the Blogs portlet will display the latest entry in its entirety. Since we have just added the portlet to a page, we have no entries, so the portlet will be empty. Before we start adding entries, we'll configure the portlet so that it displays entries according to our specifications.
Configuring the Blogs Portlet
The Blogs portlet is easy to configure. Click on the Menu icon in the portlet's title bar and select Configuration. Beneath the Setup tab, you will see another row of options.
Email From: Selecting the Email From tab allows you to define the From: field in the email messages that users receive from the Blogs portlet.
Entry Added Email: This option allows you to enter a subject and body of the emails sent out when a new Blog entry has been added.
Entry Updated Email: This option allows you to enter a subject and body of the emails sent out when a new Blog entry has been updated.
Display Settings: Here, you can configure the various display options for the Blogs portlet.
Illustration 75: Blogs ConfigurationThe Display Settings tab lets you configure the formatting of the Blogs portlet. You can choose the most optimal ways to display your entries as well as configure how you want your users to interact with you as you post those entries.
Maximum Items to Display: This allows you to choose the total number of blog entries to display on the initial page. You can choose up to 100 to be displayed.
Display Style: Choose between Full Content, the Abstract, or just the Title. Setting this to Abstract causes Liferay to display only the first 30 words of your blog entries, with a Read More link at the bottom of each to allow users to read the whole entry if they wish.
Enable Flags: Allow users to flag content as inappropriate and send an email to the administrators.
Enable Ratings: Allows you to enable your users to rate your blog entries from one to five stars.
Enable Comments: Allows readers to comment on your blog entries.
Enable Comment Ratings: Allows readers to rate the comments which are posted to your blog entries.
Click on the RSS tab to configure the way in which blogs will display to RSS readers. Here, you can choose how you want your blog entries to be published to feed readers and outside web sites.
Maximum Items to Display: Allows you to determine how many blog entries will be displayed at once. The default is set to twenty.
Display Style: You can select to display the full content, abstracts, or title of your blogs.
Format: You can choose which format you want to deliver your blogs: RSS 1.0, RSS 2.0, or Atom 1.0.
Permissions
Depending on whether this is a personal blog or a shared blog, you may want to modify the permissions on the blog. By default, the permissions are set up for a personal blog, so only the owner of the community to which the portlet has been added will be able to add entries. If you want to share a blog with multiple users, it is easy to do.
First, create a role for your bloggers and add them to the role. Next, click the Permissions button on the Blogs portlet. You will now see a list of both portal and Community / Organization roles, and currently only the owner is checked. Check off any other role or team that should have the ability to add blog entries, and then click Save.
Adding Blog Entries
Now you're ready to begin adding blog entries. Click the Add Blog Entry button. You will see the following data entry screen:
Illustration 76: Adding a Blog entryThere isn't much difference between this screen and any other data entry screen within Liferay Portal. You get a title, a way of scheduling when the entry is to appear, and a rich editor that allows you to format your entry the way you want, complete with embedded images, videos, and the like.
Note also that as you type, the entry is automatically saved as a draft at periodic intervals. This gives you peace of mind in using the portlet from within your browser, since you won't lose your entry in the event of a browser crash or network interruption. You can also tag your entries using the same tagging mechanism found everywhere else in the portal.
The Blogs portlet also supports trackbacks and pingbacks. Trackbacks are special links that let you or another site know if you or if someone else linked to a blog entry. For example, if you wanted to write an entry in your blog and reference someone else's entry, you might put the URL to the other entry in the Trackbacks to Send field. Similarly, if you want others who link to your blog to let you know about the link via trackbacks, leave the Allow Trackbacks box checked. This will generate a URL that is displayed with your blog entry. Others who want to link to your entry can use this URL for the link, and every time the link is clicked on, your Liferay-powered site will know about it and will be able to keep track of the clicks.
Note that trackbacks only work when the protocol is supported by both the linker and the linkee. For this reason, the Blogs portlet also supports pingbacks. Pingbacks are XML-RPC requests that are similar to trackbacks except they are automatically sent when you link to another site. So if you link to another site in your blog entry, Liferay will send a pingback to that site to notify that site that you linked to it. Similarly, if someone links to your blog entry, Liferay can receive a pingback from that person's site and record the link.
Once you have finished your blog entry, click Publish. You'll go back to the list of entries, and now your entry is displayed. Here is what it looks like when the display style is set to Abstract and the number of entries is set to 10:
Illustration 77: First blog entry added You can see that in the summary view, you don't see the trackback / pingback link, and you only see the number of comments which have been added. If you were to click the Read More link, you would see the entirety of the article, all of the comments in a threaded view, and the trackback / pingback link which others can use to link back to your blog entry.
Additionally, the full view of a blog contains convenient links to add blog entries to popular aggregating sites such as Digg, del.icio.us, and others. This gives your readers an easy way to submit your blog entries to these aggregators, potentially driving further traffic to your site.
As you can see, the Blogs portlet is a full-featured blogging application which gives you and your users the ability to enter the blogosphere with an application that supports anything a blogger needs.
Aggregating Blog Entries
You can set up a whole web site devoted just to blogging if you wish. The Blogs Aggregator portlet allows you to publish entries from multiple bloggers on one page, giving further visibility to blog entries. This portlet is also very easy and straightforward to set up. You can add it to a page from the Collaboration category in the Add → More menu in the dock.
If you click Configuration from the menu button in the title bar of the portlet, you will see the Blogs Aggregator's configuration page. From here, you can set several configuration options.
Illustration 78: Blogs Aggregator ConfigurationSelection Method: You can select Users or Scope here. If you select Users, the Blogs Aggregator will aggregate the entries of every blogger on your system. If you want to refine the aggregation, you can select an Organization by which to filter the users. If you select Scope, the Blogs Aggregator will contain only entries of users who are in the current scope. This will, in essence, limit the entries to members of the Community or Organization upon which the Blogs Aggregator portlet resides.
Organization: Allows you to determine which organization's blogs you want to aggregate.
Display Style: Just like the Blogs portlet, you can select from several different styles for displaying blog entries.
Maximum Items to Display: Select maximum number of entries the portlet will display.
Enable RSS Subscription: The aggregated entries can themselves be an RSS feed. Leave this box selected if you want people to be able to subscribe to your aggregated blog entries.
Show Tags: This option will display all the tags associated with the blogs.
When you have finished setting the options in the portlet, click Save. Then click Return to Full Page.
As you will see, the Blogs Aggregator looks very much like the Blogs portlet, except that the entries come from more than one author.