Keyword

Remove non-selectable categories from the Category

  • Jonathan Abbott-Hull
  • Jonathan Abbott-Hull's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago #61573 by Jonathan Abbott-Hull
Remove non-selectable categories from the Category was created by Jonathan Abbott-Hull
I want to be able to remove categories from the drop down list that the users profile does not have access to edit.

I have tried several 'fixes' I have stumbled across but they either seem to be written for an older release of K2 or do not still give access to a drop down menu. The site I'm building relies on users submitting content but I do not want to confuse them by displaying a full category tree most of which they do not have access too.

Thanks in advance

J

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

More
12 years 8 months ago #61574 by william white
Replied by william white on topic Re: Remove non-selectable categories from the Category
Have you tried
Override the core K2 item form layout by copying the file 'components/com_k2/views/item/tmpl/form.php' to 'templates/YOURJOOMLATEMPLATE/html/com_k2/item/form.php'
- Edit this new file and add this js code to it (in 2.4.1, i've added this in line 208, just before the end of the K2 js part) :

window.addEvent('domready',function () {
$$('#catid option').each(function(item, index){
if (item.getProperty('disabled'))
item.remove();
});
});

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

  • Jonathan Abbott-Hull
  • Jonathan Abbott-Hull's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago - 12 years 8 months ago #61575 by Jonathan Abbott-Hull
Replied by Jonathan Abbott-Hull on topic Re: Remove non-selectable categories from the Category
Hi,

Firstly thanks for the post, Im running K2 v2.5.4 and it seems to me that the file structure has changed.
I believe I have found the file that relates to front end editing, (please see attached)

itemform.php
Line 90

This file for me is found here:
/components/com_k2/templates/default/

Thanks in advance

Jonathan
Attachments:

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

More
12 years 8 months ago #61576 by william white
Replied by william white on topic Re: Remove non-selectable categories from the Category
This is the same file, but i was in an override so as not to overrite the core

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

  • Jonathan Abbott-Hull
  • Jonathan Abbott-Hull's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago - 12 years 8 months ago #61577 by Jonathan Abbott-Hull
Replied by Jonathan Abbott-Hull on topic Re: Remove non-selectable categories from the Category
Have you got an amended file you could send me?

Im having problems understanding where I should place this code.

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

More
12 years 2 months ago #61578 by Karabo
Hi

I edited @William's code a bit but i works on the most recent K2, well at least on mine it does -

<script type="text/javascript">
window.addEvent('domready',function () {

$K2('#catid option[disabled="disabled"]').remove();

});
</script>

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

More
12 years 2 months ago #61579 by william white
Replied by william white on topic Re: Remove non-selectable categories from the Category
@karabo - Thanks for sharing the code

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

More
12 years 2 months ago #61580 by Karabo
my pleasure...

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

More
11 years 10 months ago #61581 by Wayne Tooley
Hello;
I just came across this and it was a big help. Further to this, after this script removes the categories how would I auto select the proper category? There is only one.

Regards,

Wayne

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


Powered by Kunena Forum