I have overwritten K2 Frontend item submit
I made a copy of
components/com_k2/templates/default/itemform.php
to
templates/YOUR TEMPLATE/html/com_k2/SUBTEMPLATE NAME/itemform.php
Based on the instructions here https://stackoverflow.com/questions/8623310/joomla-k2-frontend-page-modification
but now, i need to override the category list displayed on this item form.
<tr>
<td class="adminK2LeftCol">
<label><?php echo JText::_('K2_CATEGORY'); ?></label>
</td>
<td class="adminK2RightCol">
<?php echo $this->lists['categories']; ?>
</td>
</tr>
The itemmenu is configured to allow users to create itens only in few categories. The form don't permit in the others. But i wish that the category list display only allowed categories instead of all categories of the site.
The html result is that, the unauthorized categorys have a disabled="disabled"
<td class="adminK2LeftCol">
<label>Categoria</label>
</td>
<td class="adminK2RightCol">
<select id="catid" name="catid">
<option value="0">- Selecionar categoria -</option>
<option style="color: rgb(128, 128, 128);" value="1" disabled="disabled">Notícias</option>
<option style="color: rgb(128, 128, 128);" value="2" disabled="disabled">- - - Estado</option>
<option style="color: rgb(128, 128, 128);" value="3" disabled="disabled">- - - Política</option>
<option style="color: rgb(128, 128, 128);" value="4" disabled="disabled">- - - Esporte</option>
<option style="color: rgb(128, 128, 128);" value="27" disabled="disabled">- - - Policia</option>
<option style="color: rgb(128, 128, 128);" value="28" disabled="disabled">- - - Municípios</option>
<option style="color: rgb(128, 128, 128);" value="29" disabled="disabled">- - - Cultura</option>
<option style="color: rgb(128, 128, 128);" value="41" disabled="disabled">- - - Nacional</option>
<option style="color: rgb(128, 128, 128);" value="5" disabled="disabled">Colunas</option>
<option style="color: rgb(128, 128, 128);" value="6" disabled="disabled">- - - Trocando em miúdos</option>
<option style="color: rgb(128, 128, 128);" value="15" disabled="disabled">- - - Espaço da Cidadania</option>
<option style="color: rgb(128, 128, 128);" value="37" disabled="disabled">- - - Karine Rosa</option>
<option style="color: rgb(128, 128, 128);" value="7" disabled="disabled">- - - Colunistas</option>
<option style="color: rgb(128, 128, 128);" value="8" disabled="disabled">- - - - - Planeta vivo</option>
<option style="color: rgb(128, 128, 128);" value="13" disabled="disabled">- - - - - Economia</option>
<option style="color: rgb(128, 128, 128);" value="14" disabled="disabled">- - - - - Gastronomia</option>
<option style="color: rgb(128, 128, 128);" value="17" disabled="disabled">- - - - - Atualize</option>
<option style="color: rgb(128, 128, 128);" value="18" disabled="disabled">- - - - - Cultura Dinâmica</option>
<option style="color: rgb(128, 128, 128);" value="19" disabled="disabled">- - - - - Espaço Acadêmico</option>
<option style="color: rgb(128, 128, 128);" value="22" disabled="disabled">- - - - - Nosso direito</option>
<option style="color: rgb(128, 128, 128);" value="23" disabled="disabled">- - - - - Quebra galho</option>
<option style="color: rgb(128, 128, 128);" value="24" disabled="disabled">- - - - - Tecnologia</option>
<option style="color: rgb(128, 128, 128);" value="25" disabled="disabled">- - - - - Moda [**Categoria não publicada**]</option>
<option value="10" selected="selected">Classificados</option>
<option value="30">- - - Imóveis</option>
<option value="11">- - - - - Venda</option>
<option value="12">- - - - - Compra</option>
<option value="31">- - - Automóveis</option>
<option value="32">- - - - - Compra</option>
<option value="33">- - - - - Venda</option>
<option style="color: rgb(128, 128, 128);" value="16" disabled="disabled">Jurídica</option>
<option style="color: rgb(128, 128, 128);" value="26" disabled="disabled">Atividade parlamentar</option>
<option style="color: rgb(128, 128, 128);" value="42" disabled="disabled">- - - noticias parlamentares</option>
<option style="color: rgb(128, 128, 128);" value="20" disabled="disabled">Informativo</option>
<option style="color: rgb(128, 128, 128);" value="21" disabled="disabled">- - - Colunas</option>
<option style="color: rgb(128, 128, 128);" value="36" disabled="disabled">- - - Sobre a Gazeta</option>
<option style="color: rgb(128, 128, 128);" value="34" disabled="disabled">Minuto a minuto</option>
<option style="color: rgb(128, 128, 128);" value="38" disabled="disabled">- - - ACOMPANHE A COBERTURA DO IMPEACHMENT</option>
<option style="color: rgb(128, 128, 128);" value="39" disabled="disabled">ESPECIAL</option>
<option style="color: rgb(128, 128, 128);" value="40" disabled="disabled">- - - ACOMPANHE A COBERTURA DO IMPEACHMENT</option>
UPDATE:
i try to hide these categories with CSS
.adminK2RightCol > select option:disabled {
visibility: hidden;
}
This hide the name of category in the dropdown list, but keeps a blank option line
disabled
and you wish to hide these from the dropdown?hidden
attribute to the option using JS but this will only work in IE11+ I think. Otherwise try setting usingheight: 0px
in your CSS. Else see this: stackoverflow.com/questions/9234830/…