简体   繁体   中英

How do i add item ordering options to k2 category admin in Joomla?

I made a modification to some of the k2 core files to add another ordering option for items in a category (order by category id). Ive made modifications to the following files to achieve this:

com_k2/models/itemlist.php on line 279 added

     case 'catid':
         $orderby = 'i.catid ASC';
         break;

com_k2/views/itemslist/tmpl/category.xml on line 81 added

<option value="catid">Category</option>

com_k2/views/itemslist/tmpl/generic.xml on line 22 added

<option value="catid">Category</option>

The hacks i've made seem to work fine, but only if i change the params field in the jos_k2_categories table by hand in the database. Whenever i make changes to the category via the admin, the "item ordering" field reverts to "default". It seems to me that adding the option to xml files should make this option available, but i have limited knowledge of extension developement in Joomla. Is there some where else that add this new option to? How do i get the new ordering option i added to show up in the Joomla admin?

You didn't specify what kind of hacks you did, but I believe you need to make changes in the components/com_k2/views/itemlist/tmpl/category.xml
Here you can set the options about item ordering that you'll find in your admin panel. You can go for something like:

<param name="itemOrdering" type="list" default="" label="Item ordering" description="Select the order of items">
   <option value="date">Oldest first</option>
   <option value="rdate">Most recent first</option>
   <option value="alpha">Title Alphabetical</option> 
   <option value="order">Ordering</option>
   <option value="rand">Random ordering</option>
</param>

Many values are loaded into components/com_k2/views/itemlist/view.html.php , you call the $item_ordering = $params->get('itemOrdering') and pass it to your model. Look into that file for inspiration, I haven't been mangling with Joomla for a while.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM