Skip Navigation

[Resolved] Pull out data from Toolset

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 27 replies, has 3 voices.

Last updated by Ljuba 6 years, 4 months ago.

Assisted by: Beda.

Author
Posts
#1079473

Page is gone
hidden link

#1079474

Yes it was gone as I restored server and I thought that it is better to test on original page of demo hotel (hidden link). I mean, how you will check your fix if it is not on the hotel page (rooms belongs to hotel - right?)???

However, now is back also test page.

P.S. - On original dem photel page you can see anouther debug report vs Classifieds.

#1079475

To not forget, there is no more Bootstrap 4, only 3, provided by Toolset (however, something else was issue). Also, hotel template is not 'clean' Toolset Content Template in Bootstrap (just rooms are nested and missing post code 'cleaning'). So, no Elementor more.

#1079480

OK, I tried to fix it, activated mistakenly both snippets, sorry about that.
Of course now the site is a fatal, as the function is redeclared.

I see that my code triggers errors In Toolset Forms, I have no idea why, as its not even used on this code.

I need a copy of this site, please, not of this site instead of that form, if possible.

We are spending to much time like this

I can fix this in no time in my environment or report a BUG, but on a lively developed site we cannot.

The code is fine, it returns what it must, I var_dumped it.

This is the Toolset API that will return an array of post objects of related posts of the alojamiento-habitacion, where given is the alojamiento and we find habitaciones related to it.

    $parent_post == "198";//Parent
    $relationship == "alojamiento-habitacion";
    $posts = toolset_get_related_posts(
    $parent_post, // get posts related to this one
    $relationship, // relationship between the posts
    'parent', // get posts where $parent_post is the parent in given relationship
    999, 0, // pagination
    array(), // How was his surname, again…?
    'post_object',
    'child'
);

But it seems, this conflicts with something else on that page.

Can I get a copy - is this possible?
Online it makes no sense to debug this, the site is not accessible by me properly

It can't be that difficult, I had the posts there yesterday but the Bootstrap issue did not show the Select.
So, that works, I know it.

Something changed, need to see what.

#1079494

P.S. You can keep on online as I can fix all quickly.

#1080192

Please be kind to take it from Nigel ticket at https://toolset.com/forums/topic/bootstrap-genesis-optimization/. You saw title and it should be easy to understand why I ask it from you.

#1080228
Bildschirmfoto 2018-08-11 um 15.30.37.png

1. The PHP errors are from Toolset Classifieds Plugin - that issue seems not replicable locally on a clean install, we will handle this in a new ticket:
https://toolset.com/forums/topic/toolset-classifieds-plugin-throws-notice-on-install-until-now-not-replicable-on-fresh-install/

2. Reactivated the Code and it works, screenshot added

Code for reference:

add_filter('frm_setup_new_fields_vars', 'frm_populate_posts', 20, 2);
function frm_populate_posts($values, $field){
  if($field->id == 67){ //replace 125 with the ID of the field to populate  
	  $parent_post = "198";//Parent
	  $relationship = "alojamiento-habitacion";
		$posts = toolset_get_related_posts(
		$parent_post, // get posts related to this one
		$relationship, // relationship between the posts
		'parent', // get posts where $parent_post is the parent in given relationship
		999, 0, // pagination
		array(), // How was his surname, again…?
		'post_object',
		'child'
		);
	//get_posts( array('post_type' => 'post', 'post_status' => array('publish', 'private'), 'numberposts' => 999, 'orderby' => 'title', 'order' => 'ASC'));
    unset($values['options']);
    $values['options'] = array(''); //remove this line if you are using a checkbox or radio button field
    foreach($posts as $p){
      $values['options'][$p->ID] = $p->post_title;
    }
    $values['use_key'] = true; //this will set the field to save the post ID instead of post title
  }
  return $values;
}

3. Related to this:
https://toolset.com/forums/topic/pull-out-data-from-toolset/page/2/#post-1080192

I cannot, next week I am away until Thursday.
But a few Inputs:
- We are working on Bootstrap 4 to be added
- Have you seen the other themes in the same repo as I shared the other day (minimax, on GitHub) there is as well a theme that uses Bootstrap 4 (alpha, because I never worked on it again) that worked well with Toolset
The thing is, some Toolset things specially Layouts rely on col-sm-1 only and alone by default, so that won't be using 4.0's new grids unless you add the HTML classes.

However, I do understand you want to exclude Toolset's files - is that correct?
We cannot in any case suggest any method to do so, as these are plugins as delivered, not customizable in that sense

I can add such a feature request however.

In Toolset > Settings there you can disable or enable Toolset (or other's) Bootstrap - hence you can theoretically load whatever version you want, in a Theme, and set that so in those Settings.
It'll mostly work fine out of the box, because you will write the HTML to display content manually anyway, when using Toolset.

Only when you use Layouts some HTML is pre-made, and our Grid Wizard in Loops has a feature that relies on Bootstrap 3.0x

Here, we can close, the issue is resolved and I learned a great new way to use other forms with Toolset 🙂 while I could show you the Toolset Relationship API working

#1080720

==> "Here, we can close, the issue is resolved and I learned a great new way to use other forms with Toolset ? while I could show you the Toolset Relationship API working "

Unfortunately, not.

Your code contain hard-coded value ($parent_post = "198";//Parent) what mean that it could be applied only for specific single/unique post, what is not a solution. I tried to replace it with different values (ie - "$p->ID"), but no result.

P.S. About Bootstrap, I will reply in topic.

#1086520

Ljuba, how to set a dynamic variable in PHP is not something Toolset Support covers, this is something that either PHP supporters or forums cover, or maybe WordPress forums.

It is not related to Toolset in this case, we need a post ID, any, it does not matter, as long it's the parent (in this case) for our API to work.

For example, in WordPress, if you are in a Loop, you will see that usually a "global $post" is declared, and then $post->ID is extracted for example.
Global $post is provided by WordPress, it will provide you with the current post object.
https://codex.wordpress.org/Function_Reference/$post

Or, if you for some reason cannot access the current post you are viewing or working on, then we would use other methods to get the ID (or any other data) of the post.
One such method is get_post(), which again expects an ID:
https://developer.wordpress.org/reference/functions/get_post/

So, since there you are working on a current post, I think with global $post, $post->ID you will get the ID of the current (parent) post.
Otherwise you need to tell our API with other methods the ID of the post to get related posts from.

This is the same when you code with any other API.
The data it requires, cannot be provided by itself - it needs to be passed to the function.

In the example I created I used the hardcoded ID of the current post, hence, even get_the_id() should work:
https://developer.wordpress.org/reference/functions/get_the_id/

Logically, $p->ID does not work, we have no data in $p until we get some posts from toolset_get_related_posts(), right?

You need to get the current post BEFORE you get other, related posts.

This is however not failing under our Support Umbrella, however, as it is generic WordPress and PHP knowledge, not related to Toolset, in this case.

Thanks!

#1086553

Thanks. One more (last) question. For question > how to make exactly same form with Toolset, I should to open new topic, right?

P.S. I mean, functionally same, as that was goal of entire topic and effort > to show what is 'normal' to be done for one booking form vs, 'repeating', 'multipage' and 'no data recording' (in DB). I guess that you agree how I proved that with Formidable it can be done fast, easy, nice and well working. With Toolset I don't have any idea not even how to start vs 'repeating', .... to not go further.

#1087106

To not understand me wrong, I can confirm that "get_the_ID();" works and ticket itself can be closed.

However, we opened (started) ticket as idea was to get such form with Toolset Form and for me was difficult to explain (finally, you also said that Formidable is for you new kind of experience) features what I needed (and I think that should be essential features for Toolset, too):

1) Form what not create the entries (posts) > Formidable have in settings simple checkbox for that (so simple and easy).
2) Form with repeatable field groups in initial part of form (Toolset hardly can do it as there is no parent post for that).

So, to conclude, now I have 101% fully functional Formidable Form what working as I want. However, I would like to not use external tools and to have it with Toolset Forms.

Is it possible to make it (and how)? (new ticket?)

#1088209

1. how to make exactly same form with Toolset, I should to open new topic, right?

Given the length of the ticket here it'd be the best yes.

I understand the Form Field you have now is just adding a Post Meta (Post field) with the ID or Name of the Post chosen, to the current edited/created post, is it?

This should be doable in Forms, by using for example post reference field, or just a field that you update programmatically when submitting the form.

If you need detailed help with this we can start a new ticket.
It works however the same way as with your current setup.

You make a form, add a generic Field (for example) and populate that field with a ShortCode which returns all the posts you want.
Later you save that generic fields value to a post meta using the cred_save_data hook for it.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/

If you wait a little, there will not even be custom code needed for this, instead you'll be able to populate those generic fields with Views.
This is estimated to be released within the coming releases, so it can be expected soon.

While your form is fast and easy, it does not setup a post relationship at all, which is what you steadily outlined as your goal in other tickets.
Updating a Custom field of a post with whatever other data that you get programmatically (just as with that form) is easy as well in Toolset Forms.

2. 1) Form what not create the entries (posts) > Formidable have in settings simple checkbox for that (so simple and easy).

I do not know what you mean. Forms that create no posts? Can you explain?

2. 2) Form with repeatable field groups in initial part of form (Toolset hardly can do it as there is no parent post for that).

Those are repeating fields of a post, it's not the same as a repeatable field group, I think.
If you study the difference of a repeating field and a repeatable field group in Toolset you will notice that repeating fields as well can be added within the same form as you use to create the post.
Repeatable Field Groups are technically Posts. Those need new forms.

3. So, to conclude, now I have 101% fully functional Formidable Form what working as I want. However, I would like to not use external tools and to have it with Toolset Forms.

I think so, all you do there is populate a Select Field with some data you get by php and that is definitely possible in Toolset Forms.
New ticket only because this one is too long, not because its out of topic.

Thanks!

#1088235
03.png
02.png
01.png

Thanks for great support. I will close the ticket with remarks relevant for this part of the issue and open a new ticket (please pick up it), regards Toolset Forms.

To answer to you, I must to change order of replies.

1) "I do not know what you mean. Forms that create no posts? Can you explain?"

See attached image 01. There is substantial (diametrical opposite) difference in forms creators and Toolset Forms. Toolset Forms are forms creator for already created database structure (post and fields) or tool for such visual presentation. Forms creators contrary, creates database from visualized message (set of data) presentation - so, goal is on communication/interaction. From those data, they can to create posts (image 02), but not necessarily, most of them are limited on presentation of the 'entries' (sort of post lists - analogue to Toolset) and vary rare, also with Views (for front-end editing of database content - image 03).

In other words, Toolset Forms are focused on content creation and communication with clients is secondary, while forms creator are focused on communication with client with (not necessarily) some of (possibly) collected data presentation (as entries, views or even posts). On image 01, you saw how this my form WILL NOT COLLECT ANY SINGLE DATA. Form is created and set for EXCLUSIVELY COMMUNICATION PURPOSE, but I'm still able to decide to store some of the data (names, phones,...) in form of the entries (XML list), Views (same but more comfortable) or even to create custom post types (and posts itself).

2) Now maybe you will understand why I doubt that you can create the same with Toolset, as just to start from 'repeaters' you need to create posts (Formidable, Caldera, ...) - not.

Actually, even if you will be capable to work only with generic fields (I can't see how), you cannot do it without creating the posts (or I'm wrong?).

So, I'll open another ticket. Hopefully, I successfully explained 'forms creators'.