Keyword

Few suggestions to improve K2 (probably in 2.5)

  • Ivo Apostolov
  • Ivo Apostolov's Avatar Topic Author
  • Offline
  • Senior Member
More
13 years 11 months ago #88845 by Ivo Apostolov
This suggestions relate on "on page" site optimization and are proposed after certain tests from one of the local SEO experts here in Bulgaria.
1. Change the behavior of tags in URL.
Currently the tags in URL "as is" meaning that these include spaces, if such exist in the tag. The following proposal concern changing the tag spaces in dashes in the URL, as such addresses generate more content visits (because are more readable) in Google Search results.
So a tag "my nice tag" will have an URL: "my%20nice%20tag" instead of "my-nice-tag"

In order to make it working, we need to hack components/com_k2/helpers/route.php after line 105 and add the following:
// change all spaces to dashes in URL$tag=str_replace(' ','-',$tag);// end hack

2. Add description to tags.
This hack will allow the administrator to add description to the tags (and to tag pages in frontend). This is important because tag pages include content from articles, which basically is considered duplicated content. By adding a description to each tag, this will create unique content.
Now the hack:
First let's add the field to the database. Go to phpMyAdmin and execute:
ALTER TABLE `jos_k2_tags` ADD `description` text

In models/itemlist.php in the function GetData() after line 39 add:

// add description to tagsif ($task == 'tag'){$query .=' ,tags.description as description ';}// end hack

At row 140 of the same file under 

case 'tag':

$tag = JRequest::getString('tag');
we are adding:
// myhack$tag=str_replace(':',' ',$tag);  $tag=str_replace('-',' ',$tag);  // end my hacк
In /views/itemlist/view.html.php after:
//Get items$items = $model->getData($ordering);
We are adding:
// my hackswitch ($task) {case 'tag':if ($items){echo $items[0]->description;}break;}// end my hack
In the same file after $document->setTitle($params->get('page_title')); on row 299 we are adding:
// my hackswitch ($task) {case 'tag':if ($items){$document = &JFactory::getDocument();$document->setDescription(strip_tags($items[0]->description));}break;}// end my hack

After that we go to touch the admin panel and hack administrator/components/com_k2/tables/k2tag.php after $name = null; we add:
// my hackvar $description = null;// end my hack

Then we go to views/tag/tmpl/default.php
After: 
<tr><td><?php echo JText::_('Name'); ?></td><td><input type="text" name="name" id="name" value="" size="50" maxlength="250" /></td></tr>
We add:
<tr><td></td><td><textarea name="description" id="description" rows="10" cols="70" maxlength="8192" /><?phpecho $editor->display( 'description', $this->row->description, '550', '300', '60', '20', 'true') ;?></textarea></td></tr>

We also add after the defined('_JEXEC') or die('Restricted access'); to add:
$editor =& JFactory::getEditor();

Then we go in  views/tags/tmpl/default.php
we search for <th> <?php echo JHTML::_('grid.sort', JText::_('Name'), 'name', @$this->lists, @$this->lists ); ?> </th>
After it we add:
<th> <?php echo JHTML::_('grid.sort', JText::_('Description'), 'description', @$this->lists, @$this->lists ); ?> </th>
After: <td><a href='<?php echo $link; ?>'><?php echo $row->name;?></a></td>
We add:
<td><a href='<?php echo $link; ?>'><?php echo $row->description;?></a></td>

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum