- Posts: 5
COMMUNITY FORUM
Remove non-selectable categories from the Category
- Jonathan Abbott-Hull
-
Topic Author
- Offline
- New Member
Less
More
13 years 4 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
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.
- william white
-
- Offline
- Platinum Member
Less
More
- Posts: 3722
13 years 4 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();
});
});
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
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 5
13 years 4 months ago - 13 years 4 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
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
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
Less
More
- Posts: 3722
13 years 4 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
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 5
13 years 4 months ago - 13 years 4 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.
Im having problems understanding where I should place this code.
Please Log in or Create an account to join the conversation.
- Karabo
-
- Offline
- New Member
Less
More
- Posts: 12
12 years 9 months ago #61578
by Karabo
Replied by Karabo on topic Re: Remove non-selectable categories from the Category
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>
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.
- william white
-
- Offline
- Platinum Member
Less
More
- Posts: 3722
12 years 9 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.
- Karabo
-
- Offline
- New Member
Less
More
- Posts: 12
12 years 9 months ago #61580
by Karabo
Replied by Karabo on topic Re: Remove non-selectable categories from the Category
my pleasure...
Please Log in or Create an account to join the conversation.
- Wayne Tooley
-
- Offline
- New Member
Less
More
- Posts: 1
12 years 5 months ago #61581
by Wayne Tooley
Replied by Wayne Tooley on topic Re: Remove non-selectable categories from the Category
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
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.