Notice

This old forum is now only available for consultation/read. User accounts on this old website are blocked.
Please create a new account on seblod.com and use the new forum http://www.seblod.com/community/forums.
Apologies for this perturbation and thank you for your understanding!
Welcome, Guest
Username Password: Remember me

Save form data in joomla database instead of article
(1 viewing) (1) Guest

TOPIC: Save form data in joomla database instead of article

Save form data in joomla database instead of article 3 years, 9 months ago #1

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
Hello Folks,

is it possible to save the data from my own content_type directly into the joomla database?

Best regards
Peter

Re: Save form data in joomla database instead of article 3 years, 9 months ago #2

Hi Peter,

I assume you are referring to creating a custom content type where users can submit certain content (specified by you( straight into the database?

Can you elaborate a little more on what you want achieved?

Regards,
Simon
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #3

  • extension
  • ( Banned )
  • OFFLINE
  • Banned
  • Posts: 280
Hi,

- I have the same problem with saving to DB from a custom content type see this thread:

www.jseblod-cck.com/forum/feature-reques...component.html#13789

Best regards
Boris

Re: Save form data in joomla database instead of article 3 years, 9 months ago #4

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
Hi Simon,

yes, you are asssuming right
I want to create a custom content type(what I already did) where users can submit certain content straight into an new table (which I will create and specify before) in the database.

Is that possible?

best regards
peter

Re: Save form data in joomla database instead of article 3 years, 9 months ago #5

Hi Peter,

It most certainly is possible, and easy too! Assuming you're using the latest release of jSeblod CCK (no reason not to be) then simply instantiate the database object and voila! Lets "assume" you made a table called pancakes that has three columns (name, weight, and taste) and now you want to insert certain values into it:

 
$name = "My Pancake";
$weight = "250g"; //That's HEAVY!
$taste = "Excellent"; //A tasty pancake
$query = "INSERT INTO pancakes (name, weight, taste) VALUES ('$name', '$weight', '$taste')";
$doinsert = CCK::DB_loadResultArray( $query ); //perform a query
 


How you actually want to get the values from the user is totally up to you!

It is as easy as that. Play around with the $doinsert variable and maybe do a print_r($doinsert); to see what return values it holds, because I guess in there will be a way to determine if it was successful or not.

Does this help?

Regards,
Simon
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.
Last Edit: 3 years, 9 months ago by SimonDowdles.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #6

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
Hi Simon,

wow, that definitely helps me!
Thank you

One more question:
Where do I need to instantiate the DBObect?
From within a custom code field inside my new content type?

Thanks a lot and best regards
peter

Re: Save form data in joomla database instead of article 3 years, 9 months ago #7

Sorry Peter,

Perhaps that was the wrong terminology, by simply typing CCK::DB_loadResultArray( $query ); you are indeed instantiating it, no need for anything else!

Kind regards,
Simon
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #8

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
No, its okay

but im sorry, I need to ask once more.
Where do I put the code?

sorry, its not my day today

Re: Save form data in joomla database instead of article 3 years, 9 months ago #9

No problem,

You would put that code in your custom template, wherever you want to put it in there is up to you.

For example, you could create a form within your template and when users submit the form, capture the submitted values and insert them into the database.

Regards,
Simon
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #10

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
ah okay.

I thank thats enough information to start
Thanks a lot again.

If I should need further information, may I contact you again?

best regards
peter

Re: Save form data in joomla database instead of article 3 years, 9 months ago #11

Sure! Just remember, I do have a day job so I will always reply ASAP. If it is not instant, I apologize, but I will always respond to the best of my ability.

Happy coding!
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #12

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
great. I've just started testing
Thats what I alread did:

1. Created a test table in the joomla database called jos_test
2. modified the code you gave me
3. created a new custom_field with the type "free code
and here's the issue: I can't select the option "onAfterContentSave"
How do I achieve that?

You can see on the screenshot what I mean.
jseblod_new_field.JPG

Re: Save form data in joomla database instead of article 3 years, 9 months ago #13

Hmmm, that is rather strange. What I usually do (to have more control) is I assign my fields to my form, make a custom form template, and build the form myself. As long as your input fields are called the same thing, you are fine. For example if you have a field assigned called my_content_title then your input would look like this:

<input type="text" name="my_content_title" id="my_content_title" maxlength="25" />

Get my drift? HOWEVER, if this form saves content to Joomla in the form of user submitted articles, then this approach will not work.

Let me take a look and see if I can select that option...
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #14

flashpiet,

That option is still being implemented into the jSeblod CCK component. You can still manually add the code to your form template though, or your content template.

Can you describe what exactly it is you want to save?

Regards,
Simon
My SEBLOD Extensions on the JED

SD Field Concat

Was I helpful and did I save you hours of work or research? Consider donating something small as I volunteer my time to the community.

Re: Save form data in joomla database instead of article 3 years, 9 months ago #15

  • flashpiet
  • ( User )
  • OFFLINE
  • Junior Boarder
  • Posts: 36
Hey Simon,

thanks for you answer.

If Im getting you right, I have to put my code into the index.php of the form template?

I want to create a ToDo Calendar. With date fields, file upload, descriptions, responsibilities..
I've already created my own content type with all fields I need for the calendar.
Now I want so save all the fields into a table in the database.

Another task is to you use the saved data to display in calendar view (but thats not important now)

best regards
peter
Last Edit: 3 years, 9 months ago by flashpiet.
Time to create page: 0.31 seconds