COMMUNITY FORUM
Search Results (Searched for: k2 Tag)
- Lefteris
27 Feb 2014 16:01
Replied by Lefteris on topic How to show unpublished items to publisher/admin
How to show unpublished items to publisher/admin
Category: English K2 Community
Yes i think you can do this using the native permissions system. You need to set the permissions under K2 parameters. The permissions you see there apply to items. For the rest sections tags, extra fields etc. user must have the " Configure " permission in order to access them. Not quite sure though. You need to try first.
- Jackson
27 Feb 2014 03:50 - 27 Feb 2014 03:53
Replied by Jackson on topic [SOLVED] SQL syntax error
[SOLVED] SQL syntax error
Category: English K2 Community
I'm having this issue too.
It happens when the plugin renders the HTML for an item in the admin page. If one's being added, it will fetch the current K2 item categories to show. But it doesn't realise it's being added, and there is no K2 item ID yet.
I've made a fix where it checks for the item id, and if it's null, then it doesn't bother fetching the categories.
Hopefully it works for others!
I can't seem to attach the file... it goes in k2/k2additionalcategories/k2additionalcategories.php
<?php
/**
* @version 1.0.1
* @package Additional Categories for K2 (plugin)
* @author Thodoris Bgenopoulos <This email address is being protected from spambots. You need JavaScript enabled to view it.>
* @link www.netpin.gr
* @copyright Copyright (c) 2012 netpin.gr
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ('Restricted access');
// Load the K2 Plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'k2plugin.php');
// Initiate class to hold plugin events
class plgK2k2additonalcategories extends K2Plugin {
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function plgK2k2additonalcategories( & $subject, $params) {
parent::__construct($subject, $params);
}
/**
* Modify the k2 query(items) before being executed in order to count or return additional items.
*
*
* @param string The query.
* @return string
*/
function onK2BeforeSetQuery(&$query)
{
$mainframe = &JFactory::getApplication();
$query_parts=explode('WHERE',$query);
//admin backend area
if($mainframe->isAdmin())
{
//filter by category
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//filter by category count results
if (preg_match("/ catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=trim($matches[0][0]);
$add_catids_in=str_replace('catid IN','ca.`catid` IN',$catids_in);
$catids_in_add_pref=str_replace('catid IN','i.`catid` IN',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//frontend area
if($mainframe->isSite())
{
$task = JRequest::getCmd('task');
$view= JRequest::getCmd('view');
$layout= JRequest::getCmd('layout');
$category_id= JRequest::getInt('id');
//user blog layout
if($task=='user' && $view=='itemlist')
{
if (preg_match("/i.catid IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//k2 2.6.3 +
if (preg_match("/c.id IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//one category id
if($task=='category' && $view=='itemlist' && $category_id > 0)
{
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//catalog mode
if (preg_match("/c.id\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id','ca.`catid`',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//multiple category ids
if($layout=='category' && $view=='itemlist' && $category_id==0)
{
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//k2 2.6.3 +
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
}
}
/**
* Brings the GUI of plugin in the content tab of the k2 item.
*
* @param object The k2 item.
* @param string The view.
* @param string The tab for assign the plugin.
* @return object
*/
function onRenderAdminForm(&$item, $type, $tab='')
{
if($type=='item' && $tab=='content')
{
$plugin = new JObject;
$language = JFactory::getLanguage();
$language->load('com_k2additionalcategories');
$plugin->set('name', JText::_( 'COM_K2ADDITIONALCATEGORIES_LBL' ));
$db = &JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories AS m WHERE m.`trash` = 0 ORDER BY `parent`, `ordering`';
$db->setQuery( $query );
$mitems = $db->loadObjectList();
$children = array();
if ($mitems)
{
foreach ( $mitems as $v )
{
if(K2_JVERSION!='15')
{
$v->title = $v->name;
$v->parent_id = $v->parent;
}
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 );
$mitems = array();
foreach ( $list as $i )
{
$i->treename = JString::str_ireplace(' ', '- ', $i->treename);
$mitems[] = JHTML::_('select.option', $i->id, ' '.$i->treename );
}
// New item, item ID not set yet
if ($item->id === null) {
$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', '' );
$plugin->set('fields', $fields);
return $plugin;
}
$query = "SELECT `catid` FROM #__k2_additional_categories WHERE `itemID` = {intval($item->id)}";
$db->setQuery( $query );
if (version_compare(JVERSION, '1.6.0', '<'))
{
$sel_value = $db->loadResultArray();
}
else
{
$sel_value = $db->loadColumn();
}
$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', $sel_value );
$plugin->set('fields', $fields);
return $plugin;
}
}
/**
* Saves data in db after apply or save.
*
* @param object The updated or new k2 item.
* @param boolean Flag setting if the item is new or not.
* @return void
*/
function onAfterK2Save(&$row, $isNew)
{
$add_catids = JRequest::getVar('itm_add_catids','',array());
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
if(is_array($add_catids) && count($add_catids) > 0)
{
foreach($add_catids as $k=>$v)
{
$v=intval($v);
if($v > 0)
{
$query = "INSERT INTO #__k2_additional_categories (`id`, `catid`, `itemID`) VALUES(NULL, '$v', {intval($row->id)})";
$db->setQuery($query);
$db->query();
}
}
}
}
/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @deprecated
*/
function onK2BeforeCountCategoryItemsQuery(&$query)
{
$query_parts=explode('WHERE',$query);
if (preg_match("/catid\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('catid','ca.`catid`',$catids_in);
$catids_in_add_pref=str_replace('catid','i.`catid`',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query_parts[0]=str_replace('FROM #__k2_items','FROM #__k2_items AS i',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @since 1.0.1
*/
function onK2BeforeCountCategoryItemsAdmin(&$result,$catid,$trash)
{
$db = &JFactory::getDBO();
$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid`={intval($catid)} AND i.`trash`={intval($trash)} AND i.`id`=ca.`itemID`";
$db->setQuery($query);
$total_additional = $db->loadResult();
$result=$result+$total_additional;
}
/**
* Custom trigger (not k2 core). Delete the k2 item entry from #__k2_additional_categories when
* item removed from k2.
*
* @param object The k2 item.
* @return void
*/
function onK2AfterDeleteItem($row)
{
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
}
// Events to display (in the frontend)
/**
* Custom trigger (not k2 core). Generate link and title of additional catecories if exists.
*
* @param int The id of k2 item.
* @return array
*/
function onK2AfterLinkCategoryPublish($itemID) {
$itemID=intval($itemID);
$output='';
if($itemID > 0)
{
$db = &JFactory::getDBO();
$query = "SELECT c.`id`,c.`name`,c.`alias` FROM #__k2_additional_categories AS ca, #__k2_categories AS c WHERE ca.`itemID` ='$itemID' AND c.`id`=ca.`catid`";
$db->setQuery( $query );
$sel_value = $db->loadObjectList();
foreach($sel_value as $k=>$v)
{
$link= urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($v->id.':'.urlencode($v->alias))));
$output.=', <span class="add_cat_link"><a href="'.$link.'">'.$v->name.'</a></span>';
}
}
return $output;
}
/**
* Custom trigger (not k2 core). Add additional category items to the count of current category subcategories.
*
* @param int The count of items that subcategory have.
* @param int The subcategory id.
* @param object The subcategories data.
* @return int
*/
function onK2BeforeSetCountCategoryQuery(&$total, &$id, &$categories)
{
$mainframe = &JFactory::getApplication();
$user = &JFactory::getUser();
$aid = (int) $user->get('aid');
$id = (int) $id;
$db = &JFactory::getDBO();
$jnow = &JFactory::getDate();
$now = $jnow->toMySQL();
$nullDate = $db->getNullDate();
$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid` IN (".implode(',', $categories).") AND i.`published`=1 AND i.`trash`=0 AND i.`id`=ca.`itemID`";
if(K2_JVERSION!='15')
{
$query .= " AND i.access IN(".implode(',', $user->authorisedLevels()).") ";
if($mainframe->getLanguageFilter())
{
$query.= " AND i.`language` IN(".$db->Quote(JFactory::getLanguage()->getTag()).", ".$db->Quote('*').")";
}
}
else
{
$query .=" AND i.`access`<=".$aid;
}
$query .= " AND ( i.`publish_up` = ".$db->Quote($nullDate)." OR i.`publish_up` <= ".$db->Quote($now)." )";
$query .= " AND ( i.`publish_down` = ".$db->Quote($nullDate)." OR i.`publish_down` >= ".$db->Quote($now)." )";
$db->setQuery($query);
$total_additional = $db->loadResult();
$total=$total+$total_additional;
}
}
It happens when the plugin renders the HTML for an item in the admin page. If one's being added, it will fetch the current K2 item categories to show. But it doesn't realise it's being added, and there is no K2 item ID yet.
I've made a fix where it checks for the item id, and if it's null, then it doesn't bother fetching the categories.
Hopefully it works for others!
I can't seem to attach the file... it goes in k2/k2additionalcategories/k2additionalcategories.php
<?php
/**
* @version 1.0.1
* @package Additional Categories for K2 (plugin)
* @author Thodoris Bgenopoulos <This email address is being protected from spambots. You need JavaScript enabled to view it.>
* @link www.netpin.gr
* @copyright Copyright (c) 2012 netpin.gr
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ('Restricted access');
// Load the K2 Plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'k2plugin.php');
// Initiate class to hold plugin events
class plgK2k2additonalcategories extends K2Plugin {
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function plgK2k2additonalcategories( & $subject, $params) {
parent::__construct($subject, $params);
}
/**
* Modify the k2 query(items) before being executed in order to count or return additional items.
*
*
* @param string The query.
* @return string
*/
function onK2BeforeSetQuery(&$query)
{
$mainframe = &JFactory::getApplication();
$query_parts=explode('WHERE',$query);
//admin backend area
if($mainframe->isAdmin())
{
//filter by category
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//filter by category count results
if (preg_match("/ catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=trim($matches[0][0]);
$add_catids_in=str_replace('catid IN','ca.`catid` IN',$catids_in);
$catids_in_add_pref=str_replace('catid IN','i.`catid` IN',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//frontend area
if($mainframe->isSite())
{
$task = JRequest::getCmd('task');
$view= JRequest::getCmd('view');
$layout= JRequest::getCmd('layout');
$category_id= JRequest::getInt('id');
//user blog layout
if($task=='user' && $view=='itemlist')
{
if (preg_match("/i.catid IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//k2 2.6.3 +
if (preg_match("/c.id IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//one category id
if($task=='category' && $view=='itemlist' && $category_id > 0)
{
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//catalog mode
if (preg_match("/c.id\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id','ca.`catid`',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
//multiple category ids
if($layout=='category' && $view=='itemlist' && $category_id==0)
{
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
//k2 2.6.3 +
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);
//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
}
}
/**
* Brings the GUI of plugin in the content tab of the k2 item.
*
* @param object The k2 item.
* @param string The view.
* @param string The tab for assign the plugin.
* @return object
*/
function onRenderAdminForm(&$item, $type, $tab='')
{
if($type=='item' && $tab=='content')
{
$plugin = new JObject;
$language = JFactory::getLanguage();
$language->load('com_k2additionalcategories');
$plugin->set('name', JText::_( 'COM_K2ADDITIONALCATEGORIES_LBL' ));
$db = &JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories AS m WHERE m.`trash` = 0 ORDER BY `parent`, `ordering`';
$db->setQuery( $query );
$mitems = $db->loadObjectList();
$children = array();
if ($mitems)
{
foreach ( $mitems as $v )
{
if(K2_JVERSION!='15')
{
$v->title = $v->name;
$v->parent_id = $v->parent;
}
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 );
$mitems = array();
foreach ( $list as $i )
{
$i->treename = JString::str_ireplace(' ', '- ', $i->treename);
$mitems[] = JHTML::_('select.option', $i->id, ' '.$i->treename );
}
// New item, item ID not set yet
if ($item->id === null) {
$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', '' );
$plugin->set('fields', $fields);
return $plugin;
}
$query = "SELECT `catid` FROM #__k2_additional_categories WHERE `itemID` = {intval($item->id)}";
$db->setQuery( $query );
if (version_compare(JVERSION, '1.6.0', '<'))
{
$sel_value = $db->loadResultArray();
}
else
{
$sel_value = $db->loadColumn();
}
$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', $sel_value );
$plugin->set('fields', $fields);
return $plugin;
}
}
/**
* Saves data in db after apply or save.
*
* @param object The updated or new k2 item.
* @param boolean Flag setting if the item is new or not.
* @return void
*/
function onAfterK2Save(&$row, $isNew)
{
$add_catids = JRequest::getVar('itm_add_catids','',array());
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
if(is_array($add_catids) && count($add_catids) > 0)
{
foreach($add_catids as $k=>$v)
{
$v=intval($v);
if($v > 0)
{
$query = "INSERT INTO #__k2_additional_categories (`id`, `catid`, `itemID`) VALUES(NULL, '$v', {intval($row->id)})";
$db->setQuery($query);
$db->query();
}
}
}
}
/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @deprecated
*/
function onK2BeforeCountCategoryItemsQuery(&$query)
{
$query_parts=explode('WHERE',$query);
if (preg_match("/catid\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('catid','ca.`catid`',$catids_in);
$catids_in_add_pref=str_replace('catid','i.`catid`',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query_parts[0]=str_replace('FROM #__k2_items','FROM #__k2_items AS i',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}
}
/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @since 1.0.1
*/
function onK2BeforeCountCategoryItemsAdmin(&$result,$catid,$trash)
{
$db = &JFactory::getDBO();
$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid`={intval($catid)} AND i.`trash`={intval($trash)} AND i.`id`=ca.`itemID`";
$db->setQuery($query);
$total_additional = $db->loadResult();
$result=$result+$total_additional;
}
/**
* Custom trigger (not k2 core). Delete the k2 item entry from #__k2_additional_categories when
* item removed from k2.
*
* @param object The k2 item.
* @return void
*/
function onK2AfterDeleteItem($row)
{
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
}
// Events to display (in the frontend)
/**
* Custom trigger (not k2 core). Generate link and title of additional catecories if exists.
*
* @param int The id of k2 item.
* @return array
*/
function onK2AfterLinkCategoryPublish($itemID) {
$itemID=intval($itemID);
$output='';
if($itemID > 0)
{
$db = &JFactory::getDBO();
$query = "SELECT c.`id`,c.`name`,c.`alias` FROM #__k2_additional_categories AS ca, #__k2_categories AS c WHERE ca.`itemID` ='$itemID' AND c.`id`=ca.`catid`";
$db->setQuery( $query );
$sel_value = $db->loadObjectList();
foreach($sel_value as $k=>$v)
{
$link= urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($v->id.':'.urlencode($v->alias))));
$output.=', <span class="add_cat_link"><a href="'.$link.'">'.$v->name.'</a></span>';
}
}
return $output;
}
/**
* Custom trigger (not k2 core). Add additional category items to the count of current category subcategories.
*
* @param int The count of items that subcategory have.
* @param int The subcategory id.
* @param object The subcategories data.
* @return int
*/
function onK2BeforeSetCountCategoryQuery(&$total, &$id, &$categories)
{
$mainframe = &JFactory::getApplication();
$user = &JFactory::getUser();
$aid = (int) $user->get('aid');
$id = (int) $id;
$db = &JFactory::getDBO();
$jnow = &JFactory::getDate();
$now = $jnow->toMySQL();
$nullDate = $db->getNullDate();
$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid` IN (".implode(',', $categories).") AND i.`published`=1 AND i.`trash`=0 AND i.`id`=ca.`itemID`";
if(K2_JVERSION!='15')
{
$query .= " AND i.access IN(".implode(',', $user->authorisedLevels()).") ";
if($mainframe->getLanguageFilter())
{
$query.= " AND i.`language` IN(".$db->Quote(JFactory::getLanguage()->getTag()).", ".$db->Quote('*').")";
}
}
else
{
$query .=" AND i.`access`<=".$aid;
}
$query .= " AND ( i.`publish_up` = ".$db->Quote($nullDate)." OR i.`publish_up` <= ".$db->Quote($now)." )";
$query .= " AND ( i.`publish_down` = ".$db->Quote($nullDate)." OR i.`publish_down` >= ".$db->Quote($now)." )";
$db->setQuery($query);
$total_additional = $db->loadResult();
$total=$total+$total_additional;
}
}
- Justin Thomas
26 Feb 2014 02:47 - 07 Mar 2014 08:27
Search results weighting by category [SOLVED..ish] was created by Justin Thomas
Search results weighting by category [SOLVED..ish]
Category: English K2 Community
I am developing a site with K2 (as always B) ) and I am using the tag system as a reference for industry standards. These standards have their own category in K2. What I would really like is for the search results to favour the "standards" category so that the relevant standard comes first then all other related items by date.
Any thoughts?
Any thoughts?
- Tudor Drugan
25 Feb 2014 19:00
Replied by Tudor Drugan on topic css I compact all text
css I compact all text
Category: English K2 Community
it is not the css... your content has all HTML tags removed.
You are using the K2 content module witch has the option: Introtext word limit... hoover over this option and you will have a description of this option with a solution also.
You are using the K2 content module witch has the option: Introtext word limit... hoover over this option and you will have a description of this option with a solution also.
- María Esther Capellán
25 Feb 2014 13:57
Elegir categoría en elemento de menú joomla 3.2.2 was created by María Esther Capellán
Elegir categoría en elemento de menú joomla 3.2.2
Category: Comunidad hispana oficial de K2
No puedo elegir la categoría a la que quiero que enlace un elemento del menú, pues tras seleccionar "Tipo de elemento del menú" "K2/Catagorías" no aparece el campo para seleccionar la Categoría a elegir (sí aparece sin embargo esta opción para los enlaces a artículos simples).
¿Qué puedo estar haciendo mal? Gracias.
¿Qué puedo estar haciendo mal? Gracias.
- Lefteris
25 Feb 2014 12:10
Replied by Lefteris on topic Embed several YouTube videos into one K2 item
Embed several YouTube videos into one K2 item
Category: AllVideos
Hi. Putting the tags in introtext or fulltext should work. If it doesn't it means that content plugins are not being parsed. Are you using a menu link to K2 or a K2 module? Ensure that you have the latest version of K2.
- tdes
25 Feb 2014 05:59
Embed several YouTube videos into one K2 item was created by tdes
Embed several YouTube videos into one K2 item
Category: AllVideos
I'm trying to embed several YouTube videos into one K2 item.
Putting the main video into the media tab works fine ... but I want several videos in one item.
Putting the video in the content tab using the tags, like this:
{youtube}Bp2lLWEJ1qk{/youtube}
... doesn't work. I just see {youtube}Bp2lLWEJ1qk{/youtube} in the item, not the video.
What could I be doing wrong?
Putting the main video into the media tab works fine ... but I want several videos in one item.
Putting the video in the content tab using the tags, like this:
{youtube}Bp2lLWEJ1qk{/youtube}
... doesn't work. I just see {youtube}Bp2lLWEJ1qk{/youtube} in the item, not the video.
What could I be doing wrong?
- Krikor Boghossian
24 Feb 2014 16:30
Replied by Krikor Boghossian on topic Search module & tag click always same results
Search module & tag click always same results
Category: Commercial Joomla Templates
Sh404 rewrites all URLs and handles all redirects.
If sh404 results are not cached properly then you will most definitely face some issues. Same thing applies to the K2 system plugin.
You have to make sure that the caching system plugin is rendering after these plugins.
Finally you might find some usefull resources about SH404 and caching issues at their site.
My guess is the plugin order.
If sh404 results are not cached properly then you will most definitely face some issues. Same thing applies to the K2 system plugin.
You have to make sure that the caching system plugin is rendering after these plugins.
Finally you might find some usefull resources about SH404 and caching issues at their site.
My guess is the plugin order.
- Lefteris
24 Feb 2014 12:19
Replied by Lefteris on topic How to move Rate this item stars to top?
How to move Rate this item stars to top?
Category: English K2 Community
@sarah
The code that generates the rating system is the following:
You can move it wherever you want inside item.php.
The code that generates the rating system is the following:
<?php if($this->item->params->get('itemRating')): ?> <!-- Item Rating --> <div class="itemRatingBlock"> <span><?php echo JText::_('K2_RATE_THIS_ITEM'); ?></span> <div class="itemRatingForm"> <ul class="itemRatingList"> <li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li> <li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_1_STAR_OUT_OF_5'); ?>" class="one-star">1</a></li> <li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_2_STARS_OUT_OF_5'); ?>" class="two-stars">2</a></li> <li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_3_STARS_OUT_OF_5'); ?>" class="three-stars">3</a></li> <li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_4_STARS_OUT_OF_5'); ?>" class="four-stars">4</a></li> <li><a href="#" data-id="<?php echo $this->item->id; ?>" title="<?php echo JText::_('K2_5_STARS_OUT_OF_5'); ?>" class="five-stars">5</a></li> </ul> <div id="itemRatingLog<?php echo $this->item->id; ?>" class="itemRatingLog"><?php echo $this->item->numOfvotes; ?></div> <div class="clr"></div> </div> <div class="clr"></div> </div> <?php endif; ?>You can move it wherever you want inside item.php.
- Krikor Boghossian
24 Feb 2014 11:44
Replied by Krikor Boghossian on topic Search module & tag click always same results
Search module & tag click always same results
Category: Commercial Joomla Templates
Are you using an SEO/SEF extension or K2's advanced SEF?
- John Dunstan
23 Feb 2014 03:03 - 23 Feb 2014 03:06
Sorry K2 was created by John Dunstan
Sorry K2
Category: English K2 Community
Hello,
I write this post with a heavy heart...I have been using K2 for so so many years, and I have loved the component. I used it in every Joomla build I did for myself and my customers, and back in the Joomla 1.5 days, I even replaced the default Joomla articles with k2 items and used K2 for my info pages. K2 WAS the bomb back in the day!
When JoomlArt decided to drop K2 for EasyBlog, I personally protested and argued constantly, then I saw Gavick change to EasyBlog, and I protested again...I have been one of K2's biggest fan boys who has promoted K2 till I am blue in the face.
With that said, today I move to EasyBlog...I'll tell you why!
1) Joomla 3 does almost everything K2 does and it does it better and MUCH faster
2) If ALL a person wants is 1 blog (not team or multi blogging), then they don't need anything more than default Joomla articles and maybe disquss
3) The backend user interface is dated and doesnt look professional. K2 stayed with pretty much the same 'look' with its Joomla 3 implementation....This adds less professionalisim to our projects and it adds a different UI for customers to get accustomed to.
4) The front end user interface is horrible....if people want to use K2 for Team or Multi blogging, K2 simply is to much effort. Plus to get frontend editing actually working is to much of an effort...back when I started with K2, it took way to long to figure out how to get front end editing working...it should just be a check box, nothing more to enble front end editing...in fact, it should be enabled by default, especially with Joomla 3.
5) (this relates to 3 and 4)...K2 is only applicable for web designers or people who buy templates with K2 setup and styled. For anyone who is not a website developer, K2 is not an option. It is very ugly when you install it, and requires 'time' to style it. Therefore, K2 has cornered itself into the market of developers only...same goes for the front end and backend user interface. Compare this to EasyBlog, anyone can install this and not need to edit any code to make it look right.
6) K2 simply hasnt grown and adapted to give more than what default Joomla 3 articles can give. Look at the feature set difference between EasyBlog and K2? If K2 is to survive, it needs to adapt.
7) So K2 is a CCK, not just a blog! Yes, this is true...Lately, I have been trying to find any excuse to keep using K2, as I am so familar with it..I have tried to build business directories with it, a photography site with it, and much more....IK2 simply isnt flexible enough anymore for these things, there are better Joomla extensions out there that are designed for these exact things.
8) K2 is rather slow compared to default Joomla articles
9) K2 brings out maybe 2 updates per year...For a Joomla component that has won awards and has been used widely but many Joomla template clubs, the development of K2 has been very slow and very slow to bring out new features or just updates. updates are a sign of an active community.
10) For me lately, there have been to many show stopping bugs and things that don't work, which brings us back to no.9..with new versions of Joomla 3 coming out, we need updates. One example, is the Tags..selection based...When you choose a tag from the left list and then click ADD, NOTHING shows up in the right list...It is there, but it can't be seen. This has been a problem for almost 1 year now...this is ok for people like me that know its working, but for clients, It looked upon as a horrible mess up.
11) We are moving more and more into frontend editing, and as per no.4, K2 is quite awful. As a Joomla developer, I am personally ONLY interested in Joomla extensions that have decent looking and functioning front end editing capabilities. Clients are finally starting to use their sites more now and I am receiving less support phone calls asking how to edit this or edit that.
Guys, I know you provide a free component, but if you want K2 to endure, things must change, and they must change now. WIth Joomla template clubs like JoomlArt dropping support for you, it won;t be long before more drop support for you. etc etc....Template clubs are even dropping support for Virtuemart now, because Virtuemart won't provide a Joomla 3 version until it becomes LTS.
If you have to charge money, so be it....The JoomlaSphere has been changing to a subscription based model for extensions more and more lately, so why not do that?
Either way, I do write this with a heavy heart, and honestly I write this in hopes that you take what I write seriously and look to refresh K2 and bring the Joomla community back to K2...The trouble is, once you have lost people, its very hard to get them back....Its better to change when you have people, this way when you improve and provide great new features, customers love you even more and become even more loyal.
K2 has been great, but for me (and many others as it seems), we need to find something that caters to our needs better...
Sorry for this post, BUT I look forward to see where K2 goes from here!
Signed
X K2 Lover!
I write this post with a heavy heart...I have been using K2 for so so many years, and I have loved the component. I used it in every Joomla build I did for myself and my customers, and back in the Joomla 1.5 days, I even replaced the default Joomla articles with k2 items and used K2 for my info pages. K2 WAS the bomb back in the day!
When JoomlArt decided to drop K2 for EasyBlog, I personally protested and argued constantly, then I saw Gavick change to EasyBlog, and I protested again...I have been one of K2's biggest fan boys who has promoted K2 till I am blue in the face.
With that said, today I move to EasyBlog...I'll tell you why!
1) Joomla 3 does almost everything K2 does and it does it better and MUCH faster
2) If ALL a person wants is 1 blog (not team or multi blogging), then they don't need anything more than default Joomla articles and maybe disquss
3) The backend user interface is dated and doesnt look professional. K2 stayed with pretty much the same 'look' with its Joomla 3 implementation....This adds less professionalisim to our projects and it adds a different UI for customers to get accustomed to.
4) The front end user interface is horrible....if people want to use K2 for Team or Multi blogging, K2 simply is to much effort. Plus to get frontend editing actually working is to much of an effort...back when I started with K2, it took way to long to figure out how to get front end editing working...it should just be a check box, nothing more to enble front end editing...in fact, it should be enabled by default, especially with Joomla 3.
5) (this relates to 3 and 4)...K2 is only applicable for web designers or people who buy templates with K2 setup and styled. For anyone who is not a website developer, K2 is not an option. It is very ugly when you install it, and requires 'time' to style it. Therefore, K2 has cornered itself into the market of developers only...same goes for the front end and backend user interface. Compare this to EasyBlog, anyone can install this and not need to edit any code to make it look right.
6) K2 simply hasnt grown and adapted to give more than what default Joomla 3 articles can give. Look at the feature set difference between EasyBlog and K2? If K2 is to survive, it needs to adapt.
7) So K2 is a CCK, not just a blog! Yes, this is true...Lately, I have been trying to find any excuse to keep using K2, as I am so familar with it..I have tried to build business directories with it, a photography site with it, and much more....IK2 simply isnt flexible enough anymore for these things, there are better Joomla extensions out there that are designed for these exact things.
8) K2 is rather slow compared to default Joomla articles
9) K2 brings out maybe 2 updates per year...For a Joomla component that has won awards and has been used widely but many Joomla template clubs, the development of K2 has been very slow and very slow to bring out new features or just updates. updates are a sign of an active community.
10) For me lately, there have been to many show stopping bugs and things that don't work, which brings us back to no.9..with new versions of Joomla 3 coming out, we need updates. One example, is the Tags..selection based...When you choose a tag from the left list and then click ADD, NOTHING shows up in the right list...It is there, but it can't be seen. This has been a problem for almost 1 year now...this is ok for people like me that know its working, but for clients, It looked upon as a horrible mess up.
11) We are moving more and more into frontend editing, and as per no.4, K2 is quite awful. As a Joomla developer, I am personally ONLY interested in Joomla extensions that have decent looking and functioning front end editing capabilities. Clients are finally starting to use their sites more now and I am receiving less support phone calls asking how to edit this or edit that.
Guys, I know you provide a free component, but if you want K2 to endure, things must change, and they must change now. WIth Joomla template clubs like JoomlArt dropping support for you, it won;t be long before more drop support for you. etc etc....Template clubs are even dropping support for Virtuemart now, because Virtuemart won't provide a Joomla 3 version until it becomes LTS.
If you have to charge money, so be it....The JoomlaSphere has been changing to a subscription based model for extensions more and more lately, so why not do that?
Either way, I do write this with a heavy heart, and honestly I write this in hopes that you take what I write seriously and look to refresh K2 and bring the Joomla community back to K2...The trouble is, once you have lost people, its very hard to get them back....Its better to change when you have people, this way when you improve and provide great new features, customers love you even more and become even more loyal.
K2 has been great, but for me (and many others as it seems), we need to find something that caters to our needs better...
Sorry for this post, BUT I look forward to see where K2 goes from here!
Signed
X K2 Lover!
- Sara Samimian
23 Feb 2014 01:50 - 23 Feb 2014 01:52
Replied by Sara Samimian on topic How to move Rate this item stars to top?
How to move Rate this item stars to top?
Category: English K2 Community
Can any one do it for me please,
This is my item.php code: Displaying 2781 - 2800 out of 6582 results.
This is my item.php code:
- Sara Samimian

23 Feb 2014 00:17 - 23 Feb 2014 00:45 Replied by Sara Samimian on topic How to move Rate this item stars to top? How to move Rate this item stars to top?
Category: English K2 Community
- Jared
22 Feb 2014 14:34
Replied by Jared on topic Selection K2 Pre-defined Tags in Front- and Backend Editor
Selection K2 Pre-defined Tags in Front- and Backend Editor
Category: English K2 Community
Hi,
I am interested in this. Do you have a recent version?
Thanks!
Jared
I am interested in this. Do you have a recent version?
Thanks!
Jared
- Kannan Naidu Venugopal
22 Feb 2014 05:56
Replied by Kannan Naidu Venugopal on topic Override for tag.php not working
Override for tag.php not working
Category: English K2 Community
Hi Tracey,
You're welcome :)
You can override K2 tools, just make a folder in your template/html/ called mod_k2_tool and inside it just add the k2 tools specific files, like archive.php or breadcrumbs.php
You're welcome :)
You can override K2 tools, just make a folder in your template/html/ called mod_k2_tool and inside it just add the k2 tools specific files, like archive.php or breadcrumbs.php
- Lefteris
21 Feb 2014 13:04
Replied by Lefteris on topic Menu Item - K2 tag resets after changes are made
Menu Item - K2 tag resets after changes are made
Category: English K2 Community
Hi. Maybe you have modified the tags. Or you have untagged some items from the specific tag. Ensure that you are using the latest version of K2.
- Tracey
21 Feb 2014 06:45
Replied by Tracey on topic Override for tag.php not working
Override for tag.php not working
Category: English K2 Community
Hi Kannan,
Actually I had my home menu item set to k2 item with [module114] in the item description. Module 114 in my backend is the k2 content module set to show featured items only from all categories. At the point I am at with the site build it seemed to work as intended. LOL, well almost..
I am not really sure why I went that route^ (probably lack of k2 & Joomla knowledge) but after reading your last post I decided to try your approach. After setting things up I found I could not control intro text word limit in the way I wanted. I wanted around 29 words for the homepage featured item intros but around 100 words for all other category views. I just couldn't figure out a way to make it work.
I ended up using the k2 latest items for my home menu item type. This allowed me to have a custom template for just that home page view. Among other things I also was able to modify the latest_item.php to limit intro text to 29 words like i wanted.
I also wanted to mention I watched the video on templating you posted in another thread and for me that helped alot. I don't know why but that video didn't come up in search results for me when searching for k2 overrides and templating. Wish it had because it is very informative and would have saved me allot of head scratching!
Concerning the tag.php override I found yet another way to make a custom template for the results page. I found that I can modify the tag.php located in templates/mytemplate/html/com_k2/templates/default/.
I am guessing it has to be modified there because k2 Tools doesn't allow you to choose a custom template override?
Anyway I think I am squared away at the moment but thank you for your replies. You helped me look into things with a different perspective by trying a new approach and as a result I have learned much more about k2.
Actually I had my home menu item set to k2 item with [module114] in the item description. Module 114 in my backend is the k2 content module set to show featured items only from all categories. At the point I am at with the site build it seemed to work as intended. LOL, well almost..
I am not really sure why I went that route^ (probably lack of k2 & Joomla knowledge) but after reading your last post I decided to try your approach. After setting things up I found I could not control intro text word limit in the way I wanted. I wanted around 29 words for the homepage featured item intros but around 100 words for all other category views. I just couldn't figure out a way to make it work.
I ended up using the k2 latest items for my home menu item type. This allowed me to have a custom template for just that home page view. Among other things I also was able to modify the latest_item.php to limit intro text to 29 words like i wanted.
I also wanted to mention I watched the video on templating you posted in another thread and for me that helped alot. I don't know why but that video didn't come up in search results for me when searching for k2 overrides and templating. Wish it had because it is very informative and would have saved me allot of head scratching!
Concerning the tag.php override I found yet another way to make a custom template for the results page. I found that I can modify the tag.php located in templates/mytemplate/html/com_k2/templates/default/.
I am guessing it has to be modified there because k2 Tools doesn't allow you to choose a custom template override?
Anyway I think I am squared away at the moment but thank you for your replies. You helped me look into things with a different perspective by trying a new approach and as a result I have learned much more about k2.
- Albert primo
21 Feb 2014 05:35
Big issue problem with rendering images was created by Albert primo
Big issue problem with rendering images
Category: Simple Image Gallery PRO
After posting my second image gallery I keep encountering a rendering problem. After publishing the gallery inside an article and it keeps showing an error message at the top of the article. "There was a problem rendering your image gallery. Please make sure that the folder you are using in the Simple Image Gallery Pro plugin tags exists and contains valid image files. The plugin could not locate the folder: media/k2/galleries/862"
This is the link to my page:
teenkidsnews.com/index.php/component/k2/item/862-breathtaking-photos-of-the-coldest-city-in-the-world
Can anyone please help me to fix this issue. I have seen the same problem posted by many people and there is no specific solution what is causing the problem. I checked the folder' properties are they are set to 777.
My joomla version is the 3.2.2. Can anyone please help me?
This is the link to my page:
teenkidsnews.com/index.php/component/k2/item/862-breathtaking-photos-of-the-coldest-city-in-the-world
Can anyone please help me to fix this issue. I have seen the same problem posted by many people and there is no specific solution what is causing the problem. I checked the folder' properties are they are set to 777.
My joomla version is the 3.2.2. Can anyone please help me?
- Solomon Hodge
21 Feb 2014 04:12
Replied by Solomon Hodge on topic [SOLVED] Some pages randomly breaking
[SOLVED] Some pages randomly breaking
Category: English K2 Community
So I've figured out the issue is happening on any page where an email address appears (whether it's in the content, or the K2 User Module on pages such as a blog). As a note, I don't add the <a> tag on emails - I let K2 do it automatically.
I've never seen this happen before - any ideas as to how I could fix it?
I've never seen this happen before - any ideas as to how I could fix it?
- ryan
20 Feb 2014 18:54 - 20 Feb 2014 18:54
Menu Item - K2 tag resets after changes are made was created by ryan
Menu Item - K2 tag resets after changes are made
Category: English K2 Community
Hello, Not sure if this is the right category for support?
I have a menu that uses the k2 tag option to list the items by their tag. There are about 10 items in the menu.
I noticed that 2 have just started to go to an error page, so i checked the items configurations and the tag was set to "select tag" so I chose the corresponding tag, and it worked. A few minutes later i checked the links again and sure enough it went to the error page. All of my other items work no problem its just these two tags.
I tried changing menu alias & titles but nothing.
Any ideas on what is going on?
I have a menu that uses the k2 tag option to list the items by their tag. There are about 10 items in the menu.
I noticed that 2 have just started to go to an error page, so i checked the items configurations and the tag was set to "select tag" so I chose the corresponding tag, and it worked. A few minutes later i checked the links again and sure enough it went to the error page. All of my other items work no problem its just these two tags.
I tried changing menu alias & titles but nothing.
Any ideas on what is going on?