Skip Navigation

[Resolved] Retrieve the fields of an related post in the post that i'm editing

This support ticket is created 5 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 15 replies, has 3 voices.

Last updated by Minesh 5 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1261757
Address fields.png

Hi there!

I'm developing a real estate website, that has listings, condominiums, etc.

I've created a custom post type, to the listings and using types, I created another for condominiums.

In this situation, I have a field for the listing address, that was hard-coded.

Since many listings can be on the same condominium, should be great for the brokers to don't fill the listing address everytime they need to add a listing inside a condominium.

My doubt if is possible to retrieve the listing address using jquery, API or something of the kind for the user just press on the button on the panel and the system retrieve the fields that are requested. In this example, the listing address.

Thanks in advance for your help!

#1262079

Hello,

There isn't such kind of built-in feature within Toolset Forms + Toolset Maps plugins
retrieve the listing address using jquery, API or something of the kind for the user just press on the button on the panel and the system retrieve the fields that are requested

The custom address field is based on Google map API, user can fill partial value into address input box, and Google map API will retrieve some related address, in your case, it needs to retrieve the existed address value from website database.

So it needs custom codes, for example, you can try these:
1) Create a post view:
- query listing posts,
- in view's loop, display the custom address field values as links

2) Setup custom JS codes, when user click address link, fill the specific address value into the address field of your post form.

More help:
hidden link

For your reference.

#1263577
button with jquery.png

Hi Luo!

Thanks for your help and sorry for the delay, I was trying to execute what you suggested.

My fields are inside the wordpress panel, so the listing fields and the condominium fields can be associated on the wordpress panel.

I could do the jQuery button inside the panel, as you concerned, to fill the input inside the panel, but since the wordpress panel, what is very good. The jquery code that I've done is below, and the result on the panel is on attach.
$("#wre-condo").click(function () {
$("#wre-geocomplete").val("[types field='cep' item='@associar-condominio.parent'][/types]");
});

I tried to pull the fields of condominium that is associated with that listing, but the wordpress panel, of course doesn't read shortcodes.

There's a way to use something like that shortcode inside the jQuery, in a way that the wordpress panel can read?

#1263629

Javascript codes won't support WordPress or Views shortcodes.

I suggest you try these:
1) Add a CSS class to the link I mentioned above in step 1)
https://toolset.com/forums/topic/retrieve-the-fields-of-an-related-post-in-the-post-that-im-editing/#post-1262079

For example:

<a href="#" class="my-class">My address A</a>
<a href="#" class="my-class">My address B</a>
<a href="#" class="my-class">My address C</a>
...

2) When user click one of above link, you can trigger your custom JS function like this:

jQuery(".my-class").click(function (event) {
	// here setup your custom codes
	var text = jQuery(this).text(); // get address text
	jQuery("#wre-geocomplete").val(text); // fill it into address field
});
#1264765

Hey, Luo!

I got your point, but this will just be doable inserting the info on the front-end of the listing.

I have a search in this website, based on the google maps API and the address should be pointed from the listing fields, at the wordpress panel.

Did I got your point wrong?

#1264775
Captura de Tela 2019-06-10 às 22.22.56.png

If there's not a way to get the address from API or front-end, I got an idea here:

In attach, I have the field to associate the condominium to the listing. This field just brings the condominium name. If like an relationship, it bring the address also, I could use the jQuery that you mentioned above to get the address on the same page.

Is possible to do that?

#1265463

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Luo is on vacation. This is Minesh here and I'll take care of this ticket. Hope this is OK.

Can you please share problem URL and access details and explain what exactly you want to achieve that will help me to understand your issue as well as to guide you in the right direction.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1267691

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Thank you for sharing access details but can you please share problem URL and share as much details as you can what exactly you want to achieve with what field? where I should look at?

I have set the next reply to private which means only you and I have access to it.

#1268753

Hey!

Sorry for don't providing those details, they are really important, hahaha

Well, since its a listing website, I have the listing (an existing one is in the link: hidden link ). Inside of the fields of this listing, I have the field 'associar condomínio', in English, Associate Condominium. This field its just a searchbox that makes a reference for the other custom post type, `condomínio' In English, condominium. One existing is hidden link and this particular one is related to the listing of the link above.

I just need that this field "Associar condomínio" bring the listing address fields ( slugs: 'cep' and 'endereco') for I use jQuery to fill the fields of the address of the listing, automatically, using the condominium data.

Please let me know if you need further info!

BR

#1269125

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I just need that this field "Associar condomínio" bring the listing address fields ( slugs: 'cep' and 'endereco') for I use jQuery to fill the fields of the address of the listing, automatically, using the condominium data.
==> Do you mean that you want to bring those listing address fields ( slugs: 'cep' and 'endereco') within the admin?

#1269151

Hi Minesh!

Yes, those fields should appear in the admin. When I make the reference for the condominium in the listing fields, currently it just brings the name of the condominium. If you could bring those two slugs, will be perfect.

Thanks!

#1269161

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - there is no such native feature available as well as this will need custom programming which is beyond the scope of our support policy.

What if you try to get those fields on save_post action when you save the post?

#1270159

Hi Minesh!

What if you try to get those fields on save_post action when you save the post?
-If the fields be filled automatically, when the user clicks on publish, that will be nice!

#1270345

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Types offer PHP API and you can use the save_post action to update the custom field value when you publish the post.

Please check the following Doc:
=> https://toolset.com/documentation/customizing-sites-using-php/updating-types-fields-using-php/

#1275291

Hi Minesh!

Thanks for your reply!

How do I can use the toolset PHP API to convert this shortcode ([types field='cep' item='@associar-condominio.parent'][/types]), that retrieves a field from a post reference?

Can you provide the script?

Thanks!