Keyword

Set certain category 2 post items in,via front-end

  • ghandil
  • ghandil's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #121715 by ghandil
How to set a k2 add item link in front-end in a way that just post to a certain category, In other word the category is automatically selected in the submission form, or even the category selection field could be hidden and items would post to a certain k2 category by default.

Thank you

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 10 months ago #121716 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Set certain category 2 post items in,via front-end
The item edit form menu type of k2 already has this feature,
Look at the Basic Options in the right pane, Pre-selected category

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • ghandil
  • ghandil's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #121717 by ghandil

Mohamed Abdelaziz wrote: The item edit form menu type of k2 already has this feature,
Look at the Basic Options in the right pane, Pre-selected category


Thanks a lot Mohamed :)
How to hide the category filed? You know it shows all other categories (however disabled) in a drop down field in submission form.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 10 months ago #121718 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Set certain category 2 post items in,via front-end
You need to override templates at first

Then edit the itemform.php file at line ~88, to add style="display:none;" to the row categories list, it should be like this:
<tr style="display: none;">
									<td class="adminK2LeftCol">
										<label><?php echo JText::_('K2_CATEGORY'); ?></label>
									</td>
									<td class="adminK2RightCol">
										<?php echo $this->lists['categories']; ?>
									</td>
								</tr>

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • ghandil
  • ghandil's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago - 10 years 9 months ago #121719 by ghandil
Thanks,
But this way and similar ways (such HTML commenting <!-- -->) users are still able to show and see hidden categories by set display to normal via browsers' developer tools.
Would you recommend to hide field theme with an always false PHP conditional blocks, like this:
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #121720 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Set certain category 2 post items in,via front-end
That won't work a value has to be selected.

You can use a simple JS script to remove all the other options from that select box.

stackoverflow.com/questions/18866745/remove-all-options-from-select-jquery-but-only-one

Something like this will help you or you can remove all the option that are not preselected

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • ghandil
  • ghandil's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago - 10 years 9 months ago #121721 by ghandil

Krikor Boghossian wrote: That won't work a value has to be selected.

You can use a simple JS script to remove all the other options from that select box.

stackoverflow.com/questions/18866745/remove-all-options-from-select-jquery-but-only-one

Something like this will help you or you can remove all the option that are not preselected


Thanks.
Therefore is there any way to define a value in template overriding files and hide its related field completely? (It's better to be by variable but constant would work too). I would need it to Auto title assignment for item submitted by users

Also to hide some other fields than category field, (such as main content tab and others) it would be helpful, since they need values too methinks? I'm going to hide almost all fields (including Toggle sidebar fields) except ExtraFields

P.s: Sorry for delaying. I had trouble to post reply in this topic for 2 weeks
Regards

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #121722 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Set certain category 2 post items in,via front-end
You can disable almost all the elements through K2's parameters.
This way you don't have to remove any code from the itemform file.

Also I suggest you hide the select box using CSS since you have already defined a category and removed all the other options.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • ghandil
  • ghandil's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 9 months ago #121723 by ghandil

Krikor Boghossian wrote: You can disable almost all the elements through K2's parameters.
This way you don't have to remove any code from the itemform file.

Also I suggest you hide the select box using CSS since you have already defined a category and removed all the other options.

Hi Krikor, Merry Christmas :)
Thanks for your reply. I really appreciate your help

About disabling elements from K2 parameters, I already disabled all elements except EXtraFields, But content tab and top inputs (Featured, Published,tags, ...) still remain. (I showed them in the attached image)

And as you see in the image, even when the default category is selected in the menu link parameters, users are still forced to select it from drop down input,; even though other categories aren't selectable.

Regards
Attachments:

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 9 months ago #121724 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Set certain category 2 post items in,via front-end
Merry Christmas to you too and all the best for 2014.

Actually you pretty much don't need any element from K2.
You can predefine a title by editing the
<input class="text_area k2TitleBox" type="text" name="title" id="title" maxlength="250" value="<?php echo $this->row->title; ?>" />

as for all other values I think you should populate the data with a jQuery script and then apply a display: none value.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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