1. Freebies
  2. Advanced Web Design Tutorials
  3. Categorize K2 Articles
Categorize K2 Articles

Categorize K2 Articles


One good way to increase your seo and ease navigation is to get more info into your page title...

If you're using K2 and Joomla here is an easy way to include your category and the name of your website into your page title. If you'd like to see the process, just take a quick look below...

Navigate to: com_k2 -> views --> item

Open your view.html.php file

Then search for this code:
//Set page title
$menus = &JSite::getMenu();
$menu = $menus->getActive();
if (is_object($menu) && isset($menu->query['view']) && $menu->query['view'] == 'item' && isset($menu->query['id']) && $menu->query['id'] == $item->id) {
   $menu_params = new JParameter($menu->params);
   if (!$menu_params->get('page_title')) {
      $params->set('page_title', $item->cleanTitle);
   }
} else {
   $params->set('page_title', $item->cleanTitle);
}
$document->setTitle($params->get('page_title'));

Where you see "cleanTitle", you'll want to add a "|" Then the category name another "|" Then your domain name. You do that with the following code:

..cleanTitle . ' | ' . $item->category->name . ' | ' . 'YOURSITENAME.com');
For example, my final code ends up looking like this...
//Set page title
$menus = &JSite::getMenu();
$menu = $menus->getActive();
if (is_object($menu) && isset($menu->query['view']) && $menu->query['view'] == 'item' && isset($menu->query['id']) && $menu->query['id'] == $item->id) {
   $menu_params = new JParameter($menu->params);
      if (!$menu_params->get('page_title')) {
         $params->set('page_title', $item->cleanTitle . ' | ' . $item->category->name . ' | ' . 'HaeckDesign.com');
   }
} else {
   $params->set('page_title', $item->cleanTitle . ' | ' . $item->category->name . ' | ' . 'HaeckDesign.com');
}
$document->setTitle($params->get('page_title'));

and looks like this...

mytitle

Of course you can do some more tweaking, but I like to keep things as "White-Hat" as possible. If this was useful, toss me some social love!


Related Articles
  • Beautiful CSS3 Button Set
    A concisely coded CSS3 button set increases usability across the board, gives you a ton of options, and keeps all the code involved to an absolute minimum.
    Beautiful CSS3 Button Set
  • Creating a Post Joomla Author Bio / Joomla Author Box
    A brief author bio helps blog posts on several fronts & in this tutorial we'll show you how to create a Joomla author box from scratch. That means more blog content, added credibility, and no extra work for your clients!
    Creating a Post Joomla Author Bio / Joomla Author Box
  • Joomla 101: Create an Article & SEO Settings
    This Joomla 101 tutorial infographic shows you how to create a Joomla post and optimize your basic Joomla SEO settings to get the best out of them.
    Joomla 101: Create an Article & SEO Settings
  • Organic SEO - Improving Natural SEO Results
    With the rise of paid ads and social traffic, Organic SEO has taken a back seat to many digital marketing companies. Although trends may be pushing against organic search, growing companies should see this opportunity for what it is...
    Organic SEO - Improving Natural SEO Results
  • The Source Code Resources for Web Pros
    We've compiled the source code resources for web development's top web professionals. All house fantastic snippets of various languages that make it easy to view, sort, and download website source code.
    The Source Code Resources for Web Pros
Written By:
Matthew Haeck

Greetings, I'm the lead designer and resident full stack web developer at Haeck Design. A majority of my time is spent creating beautiful logos, websites, print design, & staying up to date on all the tricks of the web development trade. (Matthew Haeck Bio Page)

Haeck Design - Stamp Logo