• Register or
  • Sign In
    • Forgot your password?
    • Forgot your username?
    Or sign in with your account on:
    Facebook
    Twitter
    Google
    LinkedIn

K2 | The powerful content extension for Joomla! developed by JoomlaWorks

  • home
  • about
  • blog
  • documentation
  • extend K2
  • showcase
  • community
  • demo
adding the missing features in Joomla!
  • Index
  • Recent Topics
  • Search
Welcome, Guest

To post messages, you need to login first.
K2 Community Forum
K2 Community Forum
New to K2? Ask here first!

Frontend Editing - Hide Disabled Categories
(1 viewing) (1) Guest
Reply Topic
New Topic
  • Page:
  • 1

TOPIC: Frontend Editing - Hide Disabled Categories

Frontend Editing - Hide Disabled Categories 1 year, 3 months ago #8616

  • Rodrigo Moragas
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hello,

I found a topic for this, but only for the 2.4.1 editing the form.php.

I'm using joomla 1.7 and K2 2.5.4 and the file form.php don't axist anymore. The file that I have found was itenform.php, but I coundn't found the code they talk about.

This is the post I found: community.getk2.org/forum/topics/fronten...14%3AComment%3A57384

I have search this for many days and try lots of combinations with those codes, but I just starting at php.

Thanks in advance.

Rodrigo Moragas
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 3 months ago #8777

  • Rodrigo Moragas
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Can anyone help, please?

Thanks..
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 2 months ago #9039

  • Rodrigo Moragas
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
Hello,

I search the web trying to find an answer, but without luck.

I talk to some friends to see if they know how to solve this but no could help.

If anyone have this same issue and solve it, please help.

I'm only dependinng on this to finish this project.

Thanks again,

Rodrigo Moragas
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 1 month ago #10249

  • Mircea Rusu
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
Same problem here, After upgrade k2 to 2.5.5, the file specified in
community.getk2.org/forum/topics/remove-...536014:Comment:85244
is not working
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 1 month ago #10284

  • William White
  • ( Moderator )
  • OFFLINE
  • Moderator
  • Posts: 3551
There may be chages but this code from the old forum for 2.4.1 by Olivier worked for me
You can do it like this :

- 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();
});
});

I've just tested on a local website with Joomla! 1.5.20, K2 v2.4.1 and mootools 1.1/1.2
For better answers, please include urls to your live site.
williamwhitejr.com/index.php/k2-support/...it-a-support-request
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 1 month ago #10396

  • Mircea Rusu
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
Is exactly what i did have on k2.4.1 and was working perfect. Then. Now, after i upgraded k2 to 2.5.5, the override is not overriding anymore.
Is Joomla 1.5.26 with k2 2.5.5 ( just upgraded from 2.4.1)
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 1 year, 1 month ago #10404

  • Mircea Rusu
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
Done:

I have edited ..\media\k2\assets\js\k2.js at the line 239 from
$K2('#catid option[disabled]').css('color', '#808080');
to
$K2('#catid option[disabled]').css('font-size', '0px');

not nice but is working on Firefox. Not working on IE9, Chrome, etc.

Still need a solution for this
Reply Quote

Should be standard K2: Hide Disabled Categories 11 months, 2 weeks ago #13390

  • Bor
  • ( User )
  • OFFLINE
  • Senior Boarder
  • Posts: 73
 
Done:

I have edited ..\media\k2\assets\js\k2.js at the line 239 from
$K2('#catid option[disabled]').css('color', '#808080');
to
$K2('#catid option[disabled]').css('font-size', '0px');


is not a good solutution.

Anyone knows how to hide the disabled categories when adding an article? (disabled = depending on usergroup)

Thanks for your help

Rob
Reply Quote

Re: Should be standard K2: Hide Disabled Categories 11 months, 2 weeks ago #13573

  • Bor
  • ( User )
  • OFFLINE
  • Senior Boarder
  • Posts: 73
Here is my solution.
It now works with IE9, Firefox and Chrome.

Go to \media\k2\assets\js\k2.js

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



before this

                  $K2('#catid').change(function(){
if($K2(this).find('option:selected').attr('disabled')){
alert(K2Language[4]);
$K2(this).val('0');
return;
}
Last Edit: 11 months, 1 week ago by Bor.
Reply Quote

Re: Should be standard K2: Hide Disabled Categories 11 months, 1 week ago #13793

  • Bor
  • ( User )
  • OFFLINE
  • Senior Boarder
  • Posts: 73
Only works on Joomla 1.5.x (so not on 1.6 and 2.5 )
Reply Quote

Re: Should be standard K2: Hide Disabled Categories 11 months ago #13910

  • Thomas
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
Any solution?
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 9 months, 2 weeks ago #160039

  • Megan Valentine
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Here is what I did on my Joomla 2.5.6 with K2 2.5.7. Tested in Firefox and IE9.

First, copy /components/com_k2/templates/default/itemform.php to /templates/(yourtemplate)/html/com_k2/default/itemform.php.

Then in your new file, near the top is a $document->addScriptDeclaration:

$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton){
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
if (\$K2.trim(\$K2('#title').val()) == '') {
alert( '"
.JText::_('K2_ITEM_MUST_HAVE_A_TITLE', true)."' );
}
else if (\$K2.trim(\$K2('#catid').val()) == '0') {
alert( '"
.JText::_('K2_PLEASE_SELECT_A_CATEGORY', true)."' );
}
else {
syncExtraFieldsEditor();
\$K2('#selectedTags option').attr('selected', 'selected');
submitform( pressbutton );
}
}
"
);


Replace that block with this, which adds a new windows.addEvent near the bottom of it:

$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton){
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
if (\$K2.trim(\$K2('#title').val()) == '') {
alert( '"
.JText::_('K2_ITEM_MUST_HAVE_A_TITLE', true)."' );
}
else if (\$K2.trim(\$K2('#catid').val()) == '0') {
alert( '"
.JText::_('K2_PLEASE_SELECT_A_CATEGORY', true)."' );
}
else {
syncExtraFieldsEditor();
\$K2('#selectedTags option').attr('selected', 'selected');
submitform( pressbutton );
}
}
window.addEvent('domready',function () {
$$('#catid').each(function(item, index){
for(i=item.options.length-1;i>=0;i--) {
if (item.options[i].getProperty('disabled'))
item.options[i]=null;
}
});
});
"
);
Reply Quote

Re: Frontend Editing - Hide Disabled Categories 7 months, 1 week ago #163622

  • N
  • ( User )
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
Megan Valentine wrote:
Here is what I did on my Joomla 2.5.6 with K2 2.5.7. Tested in Firefox and IE9.

First, copy /components/com_k2/templates/default/itemform.php to /templates/(yourtemplate)/html/com_k2/default/itemform.php.

Then in your new file, near the top is a $document->addScriptDeclaration:

$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton){
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
if (\$K2.trim(\$K2('#title').val()) == '') {
alert( '"
.JText::_('K2_ITEM_MUST_HAVE_A_TITLE', true)."' );
}
else if (\$K2.trim(\$K2('#catid').val()) == '0') {
alert( '"
.JText::_('K2_PLEASE_SELECT_A_CATEGORY', true)."' );
}
else {
syncExtraFieldsEditor();
\$K2('#selectedTags option').attr('selected', 'selected');
submitform( pressbutton );
}
}
"
);


Replace that block with this, which adds a new windows.addEvent near the bottom of it:

$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton){
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
if (\$K2.trim(\$K2('#title').val()) == '') {
alert( '"
.JText::_('K2_ITEM_MUST_HAVE_A_TITLE', true)."' );
}
else if (\$K2.trim(\$K2('#catid').val()) == '0') {
alert( '"
.JText::_('K2_PLEASE_SELECT_A_CATEGORY', true)."' );
}
else {
syncExtraFieldsEditor();
\$K2('#selectedTags option').attr('selected', 'selected');
submitform( pressbutton );
}
}
window.addEvent('domready',function () {
$$('#catid').each(function(item, index){
for(i=item.options.length-1;i>=0;i--) {
if (item.options[i].getProperty('disabled'))
item.options[i]=null;
}
});
});
"
);



This didn't work for me.
Reply Quote
Reply Topic
New Topic
  • Page:
  • 1
K2 Community Forum
K2 Community Forum
New to K2? Ask here first!
Find this topic helpful? Why not share it with others?
Tweet
Powered by Kunena
Time to create page: 0.77 seconds
Advertisement
  • Contact us
  • Join the K2 Expert Companies list
  • Privacy Policy
back to top
Copyright © 2006 - 2013 JoomlaWorks Ltd.. All rights reserved. K2 is a joint project by JoomlaWorks Ltd. & Nuevvo Webware Ltd., released under the GNU/GPL v2 license.
Joomla! is a registered trademark of Open Source Matters, Inc. JoomlaWorks/Nuevvo are not affiliated with or endorsed by Open Source Matters or the Joomla! Project.
designed by Nuevvo