Managing Articles Using the K2 Content Construction Kit

Exclusive offer: get 50% off this eBook here
Joomla! 1.5 Cookbook

Joomla! 1.5 Cookbook — Save 50%

Over 60 quick and direct recipes to help you overcome common Joomla! queries.

€20.99    €10.50
by Tom Canavan | October 2010 | Cookbooks Joomla! Content Management Open Source Web Development

Like Joomla!, K2 also offers categories, except that it removes the concept of Sections. What that opens up is Categories, within Categories, within Categories. This is known as Nested Categories. This article by Tom Canavan, author of Joomla! 1.5 Cookbook, will show you how to set up and configure your categories for maximum use.

Tag Clouds are a popular means to display descriptions about your content and help with your Search Engine Efforts. You'll learn how to use this powerful tag cloud system. The final two sections cover configuration and moderation of comments in K2 as well as some tips and tricks to enhance your K2 experience.

In this article, we will cover:

  • Setup and configuration of categories and sub-categories
  • Using the K2 Tag Cloud
  • Configuration and moderation of commenting system
  • Overall tips and tricks to make your K2 site work

 

Joomla! 1.5 Cookbook

Joomla! 1.5 Cookbook Over 60 quick and direct recipes to help you overcome common Joomla! queries.
  • Find quick solutions to common Joomla! problems
  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible
  • Look at recipes that cover the portions of Joomla! 1.6 that are brand new
  • Over 60 practical recipes covering a range of site management and core Joomla! activities
        Read more about this book      

(For more resources on Joomla!, see here.)

The reader would benefit from the previous article on Installation and Introduction of K2

Working with items AKA articles

The power of K2 is in the idea of categorizing your data, thus making it easier to manage. This will be especially helpful as your site grows in content. Many sites are fully article-based and it is not uncommon to see a site with thousands of articles on it.

In this section, we'll tackle some more category-specific recipes.

You may have noticed by now that data does not show up as typical articles do in Joomla!. In other words, if you added an item, set it published and featured, it may not be displayed on your site because you have not set up a menu item to your K2 content.

K2 will need to be added to your menu structure to display the items (articles) in K2.

The first recipe will take into account a site that has been in operation for a while and has K2 added to it.

Getting ready

This section assumes you have installed K2 and have content on your site.

How to do it...

  1. Make sure you have a full backup of the database and the files.
  2. Log in as the administrator.
  3. Open the K2 Dashboard.
  4. If you DID NOT import your content in, (see the first recipe), do so now.

    If you have ALREADY imported your content using the Import Joomla! Content button - DO NOT import again. You run the risk of duplicating all your content. Should this happen, you can go in and delete the duplicate items. This can be a time-consuming process.

  5. Open Article Manager | Content | Article Manager.
  6. Select all your articles from the Article Manager and unpublish.
  7. Open Menu Manager and find your Home menu.

    Now that we have unpublished content, we'll need to replace the traditional Joomla! content items with K2 content. Opening the Menu Manager and selecting the Home menu item will show this:

    K2 Content Construction Kit

    As you can see under K2 there are several choices to display content on your site. I will choose Item | Item as my display mode. This will show my visitors content in article form.

    You can pick what works best for you. Now returning to the instructions:

  8. After choosing Menu Item Type - click Save.
  9. Open K2 Dashboard.
  10. Select Items.

    Here is a partial screenshot of the items in our sample site.

K2 Content Construction Kit

As you can see, it now starts to take on a bit more traditional Joomla! look. I can choose featured articles, publish them, or note. Set the order they show up in, the category they belong to and more.

When you import content, from Joomla!, the articles retain their identity from Section and Category configuration. For example, the Joomla! Community Portal listed in the preceding screenshot as belonging to the category Latest has a parent category of News.

When you imported the content, sections became the new K2 top-level categories. All existing categories become subcategories of the new top level categories. As we added K2 to a working site with sections and category data already in place, I want to make sure they inherit from our master category.

In our sample site, we see the following screen when we open the K2 categories from the K2 Dashboard:

K2 Content Construction Kit

We instruct the new top-level categories to follow the master category as the model for the rest. The following instructions will show you how.

  1. Open K2 Dashboard.
  2. Click Categories.
  3. Open your imported top-level categories - for this site it's About Joomla! and News. Each of these has sub-categories.
  4. Click About Joomla! (or your equivalent).
  5. Change the Inherit parameter options from category to MASTER CATEGORY USE AS INHERIT ONLY.
  6. Make sure the Parent category stays set to –None--.
  7. Click Save.

    When done, it will look like this:

    K2 Content Construction Kit

Extra fields
Did you notice the Associated "Extra Fields Group" is set to - None - ? You can change this parent category group to use an extra fields group and still keep the master category parameters.

Each of the subcategories will inherit from the master category.

By doing this, you can still control all the categories parameters simply by changing the master category.

How it works...

The category system as described here for K2 is a giant access-control system allowing you the flexibility to structure your site and data as you need. It also offers a means to control the 'look and feel' of the articles from a central place.

When you import a Joomla! site into K2 you bring all the sections, content, articles, and other associated parts into it.

Sections become new parent categories and the old categories become subcategories. This can be a bit confusing at first. One suggestion is to write out on paper what you want the site to look like, and then lay out your categories. You might find that the structure you had can be more user-friendly using K2 and you will want to change.

This category system offers you nearly unlimited means to nest articles. In essence, a category can have unlimited categories under it. There is a limit to this in terms of management, but you get the idea.

There's more...

Using tags in K2 will give you the ability to improve your Search Engine Optimization or SEO on your site. Additionally, the use of tags will allow you to give your users the ability to follow the tags to other articles. In this section we'll review how to use Tags in K2.

Tags are keywords or terms that are assigned to your content. This enables your visitors to quickly locate what they need by one word descriptions.

Using Tags in K2

Tags can be created before an article is written or on the fly. I prefer on the fly as it will match the article. You can think of a tag almost as a dynamic index. Every time a tag is added to an article, it will show up in the K2 Tag Cloud module if you are using it. The more a single tag, such as Joomla!, is used in the content, the larger it appears in the K2 Cloud module.

K2 Tag Clouds can benefit your search engine optimization and a navigational element.

Here is an example of our K2 Tag Cloud:

K2 Content Construction Kit

This is an image of our K2 Tag Cloud module. The more often a tag is added to an article, the larger it appears.

Setting up your site for Tag Clouds

K2 installs the K2 Tools module by default. The module has many functions, but for our purposes here, we'll use the Tag module.

  1. Log in to the Administrator Console of Joomla!.
  2. Click Extensions | Module Manager.
  3. Click New to create a new module.
  4. Find this for your new item:

    K2 Content Construction Kit

  5. Once in there, give it a name and select its module location.
  6. On the right under Parameters, pull down the Select module functionality drop-down list as follows:

    K2 Content Construction Kit

  7. Select Tag Cloud as shown in the preceding screenshot.
  8. Leave all the root categories set for none - this will enable K2 to pull in all the categories.
  9. Click Save.

This particular module, has many functions and you can set up a new module to use any of the great tools built into it.

Next you will want to add some tags to articles. As I said at the beginning of this article, you have two different ways to do this. You may add them to the article or you may add them to the Tag Manager. Let's quickly review the latter method.

  1. Open K2 Dashboard.
  2. Click Tags.
  3. You may see a list of tags there. If you wish to delete them, simply check the ones you want to remove and click Delete in the upper right-hand corner. Otherwise just leave them.
  4. Click New which will open the Details box. Fill in the tag; make sure it's published and click Save. This is an example of a filled out tag box (before save).

    K2 Content Construction Kit

Adding Tags on the fly

This model allows you to tag the content as soon as you create it. If there are tags available, already such as those from the previous step, then you can add them.

  1. Open K2 Dashboard.
  2. Click Items.
  3. Select an item or click New to create an item.
  4. The field Tags will be blank, you can start to type in a field, such as K2 Content Creation Kit (as shown in the preceding screenshot). If it exists, then it will be available to be able to click and add.
  5. If there are no tags available, then simply type one in and click Return or add a comma.
  6. Here is an example item with tags.

    K2 Content Construction Kit

    Here we have four tags, Security x, PHP x, Joomla x, K2 Content Creation Kit x. Any item (article) that has these tags will be easily found by both users and search bots. Let's see how our Tag Cloud looks now:

    K2 Content Construction Kit

    You probably notice the changes, especially the addition of the new tag K2 Content Creation Kit. Clicking on that tag will yield two articles, and clicking on the Security tag yields three. Search engines can follow these links to better categorize your site. Users can get a sense of what is more important in terms of content from your site and it helps them navigate.

    Closing on this, I strongly suggest you spend time picking tags that are important on your site and is relevant to the purpose of it.

Joomla! 1.5 Cookbook Over 60 quick and direct recipes to help you overcome common Joomla! queries.
Published: October 2010
eBook Price: €20.99
Book Price: €34.99
See more
Select your format and quantity:
        Read more about this book      

(For more resources on Joomla!, see here.)

Working with comments

Your site may be one such as a blog that allows visitors to comment on the articles. It may be a product site, which seeks customer feedback. Or you may just want people to leave a comment.

K2 has you covered in all these scenarios and more. The built-in comment system is easy to use and requires little configuration.

How to do it...

Enabling comments in a category.

You first need to decide if commenting will be allowed GLOBALLY or by certain categories or items. Let's examine all three methods.

Globally:

If you used the master category method then you can make this change quickly and easily.

  1. Open K2 Dashboard.
  2. Open Categories.
  3. Open your master category category.
  4. Scroll down on your right (Parameters) and select Item view options.
  5. Scroll down to the option shown as follows:

    K2 Content Construction Kit

  6. To allow Comments to be given globally check Show.
  7. To disallow Comments to be given globally check Hide.

    Each of these can be overridden at the sub-category and Item level.

Top level and sub-categories

  1. Open K2 Dashboard.
  2. Open Categories.
  3. Open your chosen top level category or sub-category.
  4. Scroll down on your right (Parameters) and select Item view options.
  5. Click Hide or Show to display it on items in this top Level or sub-category

Enabling comments by Item

There might be specific Items (articles) you wish to turn commenting on for, but leave it off for the entirety of the site. Follow these steps to enable it by ITEM:

  1. Open the K2 Dashboard.
  2. Click Items.
  3. Find the item you wish to enable commenting for.
  4. In the Parameters on the right, open Item view options.
  5. Scroll down till you see this:

    K2 Content Construction Kit

  6. To allow Comments to be left on this item, select Show.

How it works...

K2 has a great commenting system that is fully integrated with the rest of the CCK. This gives you all the tools you need to enable commenting in articles, products, news articles, products, or wherever your imagination takes you.

The K2 system is built to be very granular and allows global, top-level, or sub-category and item-level support. The great thing about this is, the commenting can be over ridden at any level.

Moving to the next section, it's one thing to let people leave a comment but managing them is the next task.

Configuring comments

Invariably if you allow comments on a public site, you'll get the occasional ad for 'watches' or 'prescription med'. You're likely to get someone leaving inappropriate comments. Using a human verification tool such as a Captcha extension can mitigate most of this.

Moderating comments

First, you will want to set up your particular parameters within the commenting system. K2 allows comments to be published automatically by default. I would recommend you to disable that.

  1. Open K2 Dashboard.
  2. Select Comments.
  3. Select Parameters in upper right-hand side.
  4. Scroll down in Parameters to the section called Comments. It will look like this:

    K2 Content Construction Kit

    There are many settings in parameters, but for our purpose let's focus on these few for now.

    • Global setting for comments: Your choices are:
      • Disabled
      • Enabled for everyone
      • Enabled for Registered Users Only
    • Enable comment auto-publishing: Again, this is the default, but if you leave it on, any posted comment will show up immediately. That could be dangerous.
    • Enable Gravatar.com avatar lookup for non-registered commenters: This will pull avatars from Gravatar.com - Your choice. The same rules apply if the avatar is inappropriate for your site, then you may wish to disable this.
    • Enable reCaptcha: This is an anti-spam feature. You'll need to sign up for reCaptcha to use this.
    • Further down (not shown in the preceding screenshot) you will find a section in Parameters called: Content Cleanup Settings. In that section, there are two important settings for stripping out HTML tags. I suggest as a matter of course that you enable this to prevent malicious code from being added to comments.

      There are many more Parameter settings available that control Twitter feeds, and one to integrate Google search on your site.

      Take a few minutes to review all the Parameter settings and adjust them to your needs.

Moderating content

Now you have comments enabled by category or item and you have configured your comments parameters. Once your site is live and you start receiving comments, you'll need to moderate them.

  1. Open K2 Dashboard.
  2. Click Comments.
  3. There you will see the comments left on your site. Here is a partial example:

    K2 Content Construction Kit

There are several fields that span across this comment. My options for this article are:

  • Edit
  • Publish
  • Unpublish
  • Delete

Or I could even delete all the unpublished comments.

Editing a comment

You may wish to edit a comment for many reasons such as misspellings or trademark violations. Doing so is simple. Click Edit under the comment. This will open the comment as follows:

K2 Content Construction Kit

Once I am satisfied, I can publish, and I am done.

This works the same for all comments on your site.

K2 does not provide any mechanism to alert you when you receive comments. You may wish to look into third-party extensions that will provide notification of pending comments for your K2 articles. One such extension that will give you this functionality is http://www.jiliko.net/en/Resources/Extensions/K2/K2-Multi-Notify.

Summary

In this article we scratched the surface of K2 by learning how to set up categories. We also explored how to set up a master category enabling you to take advantage of the inheritance features.

K2 offers some great features such as extra fields and tags to improve both the usability of your site and the search engine optimization.

Using the built-in commenting system in K2, you can enable users to leave comments on content.

Overall, K2 is a good Content Construction Kit to have in your design tool bag.


Further resources on this subject:


Joomla! 1.5 Cookbook Over 60 quick and direct recipes to help you overcome common Joomla! queries.
Published: October 2010
eBook Price: €20.99
Book Price: €34.99
See more
Select your format and quantity:

About the Author :


Tom Canavan

Tom Canavan has been in the Computer and IT industry for 20+ years where he spent several years as a Systems Consultant to many Fortune 100 clients and other global companies.

Canavan is considered a top security and disaster recovery expert in the Joomla world. He is the author of the Packt Published book Joomla! Web Security.

He is a former CIO and is currently the co-founder of SalvusAlerting.com. Canavan contributes articles on security and disaster recovery to several websites.

Books From Packt


Joomla! Social Networking with JomSocial
Joomla! Social Networking with JomSocial

Joomla! 1.5 Top Extensions Cookbook
Joomla! 1.5 Top Extensions Cookbook

Building job sites with Joomla!
Building job sites with Joomla!

ChronoForms 3.1 for Joomla! site Cookbook
ChronoForms 3.1 for Joomla! site Cookbook

Joomla! 1.5 Multimedia
Joomla! 1.5 Multimedia

Joomla! 1.5 SEO
Joomla! 1.5 SEO

Joomla! 1.5 Templates Cookbook
Joomla! 1.5 Templates Cookbook

Joomla! 1.5 Content Administration
Joomla! 1.5 Content Administration


Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software