Keyword

Show input for extra fields not chosing a category

More
11 years 8 months ago #108948 by Jerry
So I have figured out how to make it where you don't have to choose a category for frontend content submission, but now I have a whole new problem. With the default category already select, it is still saying that I have to select a category to show the inputs for the extra fields that I have. Is there a work around to where, since I already have the category selected, that the extra fields inputs will already be displayed? Thanks for the help in advance.

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #108949 by william white
Replied by william white on topic Re: Show input for extra fields not chosing a category
Tell us what youve done, so we can know exactly where you are in the code

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #108950 by Jerry
I just followed the part of the code from the below link that deals with the backend editing. Here is the part of the code that i changed:

www.byte-my-neck.com/j/index.php?option=com_k2&view=item&id=11:setting-a-default-category-for-k2&Itemid=4

In the file administrator/components/com_k2/views/item/view.html.php, I changed this:

$lists = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', $item->catid);

to this:

$lists = JHTML::_('select.genericlist', $categories_options, 'catid', '', 'value', 'text', 12);

Where 12 is the category id.

I see underneath that code is where the extra fields show up , but i don't know how to edit it to make it go ahead and display the extra fields. Here is the code I am speaking of:

JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
$category = JTable::getInstance('K2Category', 'Table');
$category->load($item->catid);

$extraFieldModel = K2Model::getInstance('ExtraField', 'K2Model');
if ($category->id)
{
$extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
}
else
{
$extraFields = NULL;
}

for ($i = 0; $i < sizeof($extraFields); $i++)
{
$extraFields[$i]->element = $extraFieldModel->renderExtraField($extraFields[$i], $item->id);
}

Do you know how to make this happen?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum