Keyword

Useful little hack so you can have category id preset

  • Lukas Niklasson
  • Lukas Niklasson's Avatar Topic Author
  • Offline
  • New Member
More
14 years 6 months ago #83883 by Lukas Niklasson
Hello guys,This is my first post here, so first let me say a big thank you for K2, it really is a fantastic component.I thought maybe some of you would be interested in a little hack i did for the "add article" link. The hack allows you to preset a category, so you can have a link called "Add article to category 1" for example. Then when you click on this article the normal K2 popup window comes up and category 1 is preset.Here is what i did to make this happen:Open up "view.html.php" file  located at: components/com_k2/views/item/view.html.phpThe hack codes are within the lines 371 to 373. I just added 2 lines of codes to set the category id passed from the url. Below are my hack codes// Hack by www.indell.se | dev$catid = JRequest::getInt('category_id', 0);$item->catid = $catid;Then open up "userblock.php", which is located at: modules/mod_k2_login/tmpl/userblock.phpThe hack codes are within the lines 40 - 42. On this file, I changed the "Add New Item" url so that it now also consists of extra parameter category_id. Below are my hack codes.// added by www.indell.se | dev$user->profile->addLink .= strpos($user->profile->addLink, '?') === false ? '?' : '&';$user->profile->addLink .= 'category_id=2';Then you basically just change the category id to whatever id you want to be preset. :-)

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


Powered by Kunena Forum