Forums

submit article - category selection in frontend

jagang 30 Jun, 2011
hey,

first of all thanks for this great joomla extension, I really like it!

Now to my problem, I use the submit article action to create articles with chronoform. I created a selectbox with fieldname "catid" like the column name in jos_content is called so the user can set the category in the frontend. But it doesn´t work, everytime it uses the setting options from the submit article action instead the value of the fieldname "catid". Is there any way how to fix this and give the selectbox a higher priority then the category settings from the submit article action?

greetings alex
GreyHead 30 Jun, 2011
Hi Alex,

This needs a code hack :-(

In administrator/components/com_chronoforms/form_actions/submit_article/submit_article.php look for this line around line 26
$form->data['catid'] = $params->get('catid', '');
and replace it with
if ( !$form->data['catid'] ) {
  $form->data['catid'] = $params->get('catid', '');
}

Bob
Navarre 03 Oct, 2011
I believe my question is somewhat related to this one so I decided to post here.
I'm using Chronoforms V4 in Joomla 1.7

I created a form with a select field:
<div class="ccms_form_element cfdiv_select" id="category_container_div">
  <label for="4">Category</label>
  <select size="1" label_over="0" hide_label="0" id="4" class=" validate['required']" title="" type="select" name="category">
    <option value="25">Plant Database</option>
    <option value="26">Trees</option>
    <option value="28">-Deciduous Trees</option>
    <option value="27">-Evergreen Trees</option>
    <option value="29">Shrubs</option>
    <option value="31">-Deciduous Shrubs</option>
    <option value="30">-Evergreen Shrubs</option>
    <option value="36">Ground Cover</option>
    <option value="37">Vines</option>
    <option value="38">Bamboo</option>
    <option value="35">Grasses</option>
    <option value="39">Corms</option>
    <option value="40">Ferns</option>
    <option value="33">Annuals</option>
    <option value="34">Perennials</option>
    <option value="41">Rhizomes</option>
    <option value="42">Bulbs</option>
    <option value="43">Palms</option>
    <option value="44">Tubers</option>
    <option value="45">Gingers</option>          
  </select>
  <div class="clear"></div>
  <div id="error-message-category"></div>
</div>


The numbers are actual content categories on the site and I am trying to have chronoforms post the content of the form to an article in the selected category by using the following action:
{"title":"common_name","fulltext":"common_name","introtext":"botanical_name", "created_by_alias":"user_id","state":"0","catid":"category"}

.......no luck though.

Keep up the good work guys, Chronoforms is awesome!
GreyHead 03 Oct, 2011
Hi navarre,

I'm no sure what this is:
{"title":"common_name","fulltext":"common_name","introtext":"botanical_name", "created_by_alias":"user_id","state":"0","catid":"category"}
It looks like it may be a JSON encoded array.

Where are you using it and what do you expect it to do?

Are you using the Submit Article action?

Bob
Navarre 03 Oct, 2011
Yes that is correct, I'm using the submit article action.

This code was generated by chronoforms and stored in the jos_chronoforms_actions MySQL table under the submit_article record for this form in the "params" field.

I was hoping to achieve having this article posted in a dynamically generated category based on the selection made in the field on my form that is shown in the first piece of code, rather than having it posted in a statically set category chosen in the Settings tab under category in the "submit article" action in the wizard.

The original code looked like this (notice the "25" for "catid")

{"title":"common_name","fulltext":"common_name","introtext":"botanical_name", "created_by_alias":"user_id","state":"0","catid":"25"}


I changed the catid value to "category" which is the field name on my form.

My suspicion is that in the joomla content table catid is an integer value and the form output for the select field is text, if this is indeed what my problem is then I do not know how to remedy it.

I hope this helps.
GreyHead 04 Oct, 2011
Hi navarre,

OK the code you posted is presumably the serialised data stored in the database table.

You need to make the code hack posted earlier in this thread.

Your select box needs to have the name 'catid' (not 'category'). I think it should then work OK.

Bob
Navarre 04 Oct, 2011
Hmmm, that didn't work, I wish it did so I could just have bought you that beer and be done with it. For now I am going to assume that I overlooked something or made an ID10T error somewhere and will analyze all settings again before I yell for more help.

You are right about the serialised data stored in the database table.

To be concluded.
Navarre 04 Oct, 2011
Great, my bad.......I fixed it. Your answer worked and you got your beer.
Cheers!
GreyHead 05 Oct, 2011
Hi navarre,

Well done :-) Glad to hear that it worked in the end.

Bob
swd 19 Nov, 2011
I am running into a kind of similar problem. I have a form, where registered users can submit articles. Now, instead of having them select a category, every user should post in a pre-defined category. I've been trying multiple approaches to modifying the code discussed in this topic. But somehow, I am drawing a blank.

Any hints as to how I can assign a category prior during the submission process, based on the user id that submits the form? I am using a field to load the user id into the form and have created a blank field for the category id.
<div id="userid" class="ccms_form_element cfdiv_text">
	<label>User-ID</label>
	<input type="text" name="userid" value="<?php echo $user->id; ?>" title="" class="" size="30" maxlength="150" style="border:none;">
	<div class="clear"></div>
	<div id="error-message-userid"></div>
</div>
<div id="catid" class="ccms_form_element cfdiv_text">
	<label>Kategorie</label>
	<input type="text" name="catid" value=" " title="" class="" size="30" maxlength="150" style="border:none;">
	<div class="clear"></div>
	<div id="error-message-catid"></div>
</div>

Any hints/ideas as to how I get a conditional category id loaded into that field on submitting the form (e.g. if user 66 submits, it's category 901, 67 is 902, etc.)
GreyHead 24 Nov, 2011
Hi SWD,

Drag a Custom Code action into the On Submit event and move it up before the Submit Article action then add:
<?php
$user =& JFactory::getUser();
$form->data['cat_id'] = $user->id + 835;
?>

Bob
swd 27 Nov, 2011
Hi Bob,

Thanks for the input. Tried your suggestion but couldn't get the form to accept the code. However, I have achieved the same result by taking your suggestion and putting it directely into the form code:

<input type="text" name="catid" value="<?php echo $user->id + 836; ?> " title="" class="" size="30" maxlength="150" style="border:none;">


If have just one issue remaining: The current solution is based upon the assumption that the difference between the user id and the corresponding category will always stay at 836. If now, I register a second admin account (for example), this ratio will be broken. Any ideas on how to get from the current code to something where I can assign one specific category to every user account?

Doesn't matter if I have to change some form code by hand each time I add a new user..

cheers
Michael
GreyHead 28 Nov, 2011
Hi Michael,

I guess that the easiest way would be to have some code to create the new category and get its id. Not sure how you'd do that but it should be possible.

Bob
kevinlam 21 Dec, 2011
many thanks folk

I got the answer to fix my website

Kevin Lam
vbarlakoski 28 Feb, 2012
Hello all!

So as we all expect, i have a similar problem🙂

I`m using Chronoform 4.0 RC3.11, for joomla 2.5.

My site is with, for an example, this type of categories:

- Cups
-yellow
-red
-blue
- Plates
-yellow
-red
-blue
- Pans
-yellow
-red
-blue

I have different categories for level1, but always the same sub-categories on level2.
So in my form i have fields to choose between Cups, Plates and Pans, and other field to choose the color if it`s yellow, blue or red.

How the user can choose in which YELLOW sub-category will add that article, if as we know on Joomla 2.5 are just categories?

Hope you understand.

Thanks!
GreyHead 29 Feb, 2012
Hi vbarlakoski ,

I'm not sure I guess that you'll either need to build a two part drop down so that the second one show the options after the first is chose, or build a more complex set of options with for example:
Cups-yellow
Cups-red
Cups-blue
Plates-yellow
Plates-red
Plates-blue

Bob
vbarlakoski 29 Feb, 2012
I have wondered how can i do two select boxes, so the second one shows options after first one is selected?

And with that type of solution, how should it work sumbit article?
GreyHead 29 Feb, 2012
Hi vbarlakoski ,

In CFv4 RC3 and later there is a Dynamic Drop-down action to do this. I'm not sure if it will work with sub-categories but it should be possible to write the WHERE clause correctly.

Bob
This topic is locked and no more replies can be posted.