- Posts: 4
COMMUNITY FORUM
Frontend Editing - Hide Categories which are disabled
- Don De Longe
- Topic Author
- Offline
- New Member
Less
More
14 years 6 months ago #80662
by Don De Longe
Frontend Editing - Hide Categories which are disabled was created by Don De Longe
Hi!Is there a way or a trick in the frontend editing (add new item) to show only the categories the user is allowed for in the select category listbox?It would be great if you could hide the disabled options or change the default categoriefrom "select category" to the one the user is allowed for. Thanks!
Please Log in or Create an account to join the conversation.
- scyllar
- Offline
- Senior Member
Less
More
- Posts: 60
14 years 4 months ago #80663
by scyllar
Replied by scyllar on topic Frontend Editing - Hide Categories which are disabled
I also want to have the enabled category (or one of the enabled categories) selected by default for a certain user when he is adding a new item from the frontend, instead of having the long greyed list of categories and subcategories in the selection box. If k2 can support this it would be very handy for the frondend publishers.
Please Log in or Create an account to join the conversation.
- Markus Thiel
- Offline
- Premium Member
Less
More
- Posts: 149
14 years 2 months ago #80664
by Markus Thiel
Replied by Markus Thiel on topic Frontend Editing - Hide Categories which are disabled
I´m also looking to hide categories that users cant submit to!
Please Log in or Create an account to join the conversation.
- Markus Thiel
- Offline
- Premium Member
Less
More
- Posts: 149
14 years 2 months ago #80665
by Markus Thiel
Replied by Markus Thiel on topic Frontend Editing - Hide Categories which are disabled
One problem that I came across is that I still need to show the parent category :P because the subcategories all have the same name :P
But like to hide the parent of the parentcategory hehe :D
But like to hide the parent of the parentcategory hehe :D
Please Log in or Create an account to join the conversation.
- Marios Katsis
- Offline
- New Member
Less
More
- Posts: 9
14 years 1 week ago #80666
by Marios Katsis
Replied by Marios Katsis on topic Frontend Editing - Hide Categories which are disabled
I find a solution to your problem, but for now you can see it only at Firefox.
You must go at http://yoursite/components/com_k2/views/item/tmpl/form.php and add this
var disabledOptions=$$('#catid option[disabled]');
$each(disabledOptions, function(option){
option.setStyle('visibility', 'hidden');
option.setStyle('font-size', '0px');
});
before (or after, it does not matter) the code
if(window.ie){
var disabledOptions=$$('#catid option[disabled]');
$each(disabledOptions, function(option){
option.setStyle('height', '0px');
});
}
I am looking to give a solution for IE, Opera, Chrome
You must go at http://yoursite/components/com_k2/views/item/tmpl/form.php and add this
var disabledOptions=$$('#catid option[disabled]');
$each(disabledOptions, function(option){
option.setStyle('visibility', 'hidden');
option.setStyle('font-size', '0px');
});
before (or after, it does not matter) the code
if(window.ie){
var disabledOptions=$$('#catid option[disabled]');
$each(disabledOptions, function(option){
option.setStyle('height', '0px');
});
}
I am looking to give a solution for IE, Opera, Chrome
Please Log in or Create an account to join the conversation.
- Marios Katsis
- Offline
- New Member
Less
More
- Posts: 9
14 years 2 days ago #80667
by Marios Katsis
Replied by Marios Katsis on topic Frontend Editing - Hide Categories which are disabled
The solution is to add the following code to the page http://yoursite/components/com_k2/views/item/tmpl/form.php
var disabledOptions=$$('#catid option[disabled]');
option.remove(option.selectedIndex);
});
This works for all browsers
var disabledOptions=$$('#catid option[disabled]');
option.remove(option.selectedIndex);
});
This works for all browsers
Please Log in or Create an account to join the conversation.
- Jakub Jedynak
- Offline
- Senior Member
Less
More
- Posts: 56
13 years 11 months ago #80668
by Jakub Jedynak
Replied by Jakub Jedynak on topic Frontend Editing - Hide Categories which are disabled
Code for all browsers dosn't work for me at all.
Code for Firefox only works (in Firefox only).
How can I change forms.php to show only cuurent category (for both Add and Edit links).
I've changeed the code in forms.php (using changed k2 function getCategoryPath) which works in Edit mode, but in Add mode there is no category assigned so I get an error:
FROM
echo $this->lists;
TO
function getCategoryName($catid) {
static $array = array();
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id={$catid}";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->name);
}
return array_reverse($array);
}
$categories = getCategoryName($this->row->catid);
foreach($categories as $catName) {
echo $catName;
}
Marios Katsis said:The solution is to add the following code to the page http://yoursite/components/com_k2/views/item/tmpl/form.php
var disabledOptions=$$('#catid option[disabled]');
option.remove(option.selectedIndex);
});
This works for all browsers
Code for Firefox only works (in Firefox only).
How can I change forms.php to show only cuurent category (for both Add and Edit links).
I've changeed the code in forms.php (using changed k2 function getCategoryPath) which works in Edit mode, but in Add mode there is no category assigned so I get an error:
FROM
echo $this->lists;
TO
function getCategoryName($catid) {
static $array = array();
$db = &JFactory::getDBO();
$query = "SELECT * FROM #__k2_categories WHERE id={$catid}";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
array_push($array, $row->name);
}
return array_reverse($array);
}
$categories = getCategoryName($this->row->catid);
foreach($categories as $catName) {
echo $catName;
}
Marios Katsis said:The solution is to add the following code to the page http://yoursite/components/com_k2/views/item/tmpl/form.php
var disabledOptions=$$('#catid option[disabled]');
option.remove(option.selectedIndex);
});
This works for all browsers
Please Log in or Create an account to join the conversation.
- Jiliko.net
- Offline
- Platinum Member
Less
More
- Posts: 567
13 years 11 months ago #80669
by Jiliko.net
Replied by Jiliko.net on topic Frontend Editing - Hide Categories which are disabled
Hi,
You can also try that solution :
community.getk2.org/forum/topics/remove-not-assigned-categories-1?commentId=3536014:Comment:85244
Olivier
You can also try that solution :
community.getk2.org/forum/topics/remove-not-assigned-categories-1?commentId=3536014:Comment:85244
Olivier
Please Log in or Create an account to join the conversation.
- Jakub Jedynak
- Offline
- Senior Member
Less
More
- Posts: 56
13 years 11 months ago #80670
by Jakub Jedynak
Replied by Jakub Jedynak on topic Frontend Editing - Hide Categories which are disabled
Thanks. This one works (for now).
But IMO Add/Edit in front end windows should work in a different way.
When you are in category and click New Article button, category should be already assigned (without dropdown at all).
In the same way it should work in Edit Mode.
Anyone have an idea how can I do that? No droppdown - just assigned current category?
Olivier Nolbert said:Hi,
You can also try that solution :
community.getk2.org/forum/topics/remove-not-assigned-categor...
Olivier
But IMO Add/Edit in front end windows should work in a different way.
When you are in category and click New Article button, category should be already assigned (without dropdown at all).
In the same way it should work in Edit Mode.
Anyone have an idea how can I do that? No droppdown - just assigned current category?
Olivier Nolbert said:Hi,
You can also try that solution :
community.getk2.org/forum/topics/remove-not-assigned-categor...
Olivier
Please Log in or Create an account to join the conversation.
- Chris Dewook
- Offline
- New Member
Less
More
- Posts: 5
13 years 2 months ago #80671
by Chris Dewook
Replied by Chris Dewook on topic Frontend Editing - Hide Categories which are disabled
Cheers Olivier, works a treat.
Please Log in or Create an account to join the conversation.