- Posts: 28
COMMUNITY FORUM
[SOLVED] Hide unused categories in front-end view
- Robert Peterson
- Topic Author
- Offline
- Junior Member
getk2.org/community/New-to-K2-Ask-here-first/139209-Frontend-Editing---Hide-Categories-which-are-disabled
... but it appears to be out of date. That solution seems to be for K2 v.2.4, while I'm using 2.6.7.
Can anyone offer any guidance for how to hide those unused categories? Thank you!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
- Posts: 15920
Just replace the [value="x"] with checking if the option is disabled.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Lefteris
- Offline
- Moderator
- Posts: 8743
You can try to add this,
div#k2Frontend select#catid > option[disabled="disabled"] {display:none;}
to your k2.css file.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
- Posts: 28
Yiota, I tried your CSS solution, cleared all my caches, and still no go. The categories are still appearing.
Krikor, thank you for the link! I'll give that a shot.
Can either of you tell me where that list of categories is generated? I've found the hook for the list in:
/com_k2/templates/Default/itemform.php
NOTE: I've added a template override for this file.
Here's the hook for the list of categories:
<td class="adminK2RightCol">
<?php echo $this->lists['categories']; ?>
</td>
But again -- that's only the hook. Where are the categories themselves generated? If I can adjust the markup for the categories themselves, I might be able to make this happen.
Thank you!!! :cheer:
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
- Posts: 28
Krikor Boghossian wrote: You need a simple JS script like: stackoverflow.com/questions/1518216/jquery-remove-options-from-select
Just replace the [value="x"] with checking if the option is disabled.
Krikor, I've been trying this solution with no effect. Here's where I'm placing the code:
[MYTEMPLATEFOLDER]/html/com_k2/templates/default/itemform.php
Is that where it should go?
Thank you!!!
b
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
- Posts: 15920
$K2('select[disabled="disabled"]').each(function() {
$K2(this).remove();
});
You need to place this inside a document ready or window load function in order to work.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
- Posts: 28
Krikor Boghossian wrote:
$K2('select[disabled="disabled"]').each(function() { $K2(this).remove(); });
You need to place this inside a document ready or window load function in order to work.
Krikor, I'm struggling to get the syntax right on this. Can I trouble you to show me how this would look inside a document ready? Here's what I have now:
<script>
$( document ).ready(function() {
$K2('select[disabled="disabled"]').each(function() {
$K2(this).remove();
});
</script>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
- Posts: 15920
$K2(document).ready(function() {
$K2('select[disabled="disabled"]').each(function() {
$K2(this).remove();
});
});
let me know if that did the trick
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
- Posts: 28
[MYTEMPLATEFOLDER]/html/com_k2/templates/default/itemform.php
Is that where it should go?
Thank you again! :)
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
- Posts: 15920
Actually the path is MYTEMPLATEFOLDER]/html/com_k2/default/itemform.php
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.