Skip Navigation

[Resolved] Real Estate site Search form State dropdown default value

This support ticket is created 8 years 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 2 voices.

Last updated by cemcildir 8 years ago.

Assisted by: Luo Yang.

Author
Posts
#388704

I am trying to:Set a default value for for States

I visited this URL:-

I expected to see:-

Instead, I got:-

#389238

Dear cemcildir,

The select dropdown field "State" is using Views shortcode [wpv-control-set], for example:
[wpv-control-item type="select" ancestor_type="state" default_label="-- State --"]
If the are going to change the text of default option "-- State --", you will edit the attribute "default_label" as what you want.

If you are going to setup the default value of field "State", according to our document:
https://toolset.com/documentation/views-shortcodes/#wpv-control-item
There isn't such an option to setup the default value.

But you can pass it with URL parameter, for example:
hidden link
user/pass: xgren/111111
It will setup the the "State" dropdown as default value "428", which is "Arizona"

#389260

Dear Luo,
I was hoping for the second solution to have an option for a default value,because the third solution forces my homepage url to look cluttered.
Bad-->hidden link
Good-->hidden link
Is there a way to have the functionality above with the url of below?(I guess a .htaccess query string redirect?)
Thanks
Cem

#389321

In your case, it needs some custom codes, for example this thread:
https://toolset.com/forums/topic/display-default-value-in-a-parametric-search-filter/#post-375967

Hope it help

#389337

Can you be more specific?

#389818

For example, we can setup the "Arizona" as default value, you can try this:
1) Add below codes into your theme/functions.php:

add_shortcode('default-state', 'default_state_func');
function default_state_func($atts, $content){
    $atts = shortcode_atts( array(
        'state' => 428,
        'url_param' => 'wpv-pr-child-of-state',
    ), $atts);
    if(!isset($_GET[$atts['url_param']][0]) || $_GET[$atts['url_param']][0] == ''){
        $_GET[$atts['url_param']][0] = $atts['state'];
    }
    return;
}

2) Edit the archive page:
hidden link
put the shortcode [default-state] just before the Views shortcode
[wpv-view name="search-house"]

#389906
snap.png

Hi Luo,
I can't access your demo site(see image)
hidden link
using user/pass: xgren/111111
I am using the layout version of Real Estate so I thought the shortcode should go to the
"Search - House" View but there isn't [wpv-view name="search-house"] shortcode?

#389922

Sorry, I just setup the user "xgren" as admin user of above test site, please test it again.

#389925

Dear Luo,
I think I am on the "Layout" version of Real Estate and your test site isn't.
So I do not know where to put [default-state] since there is no
[wpv-view name="search-house"] shortcode 🙁

#390059

You can simply create a content template cell to replace the Views cell, and put above custom shortcode and the View's shortcode into it

#391107

Dear Luo,
I guess it would work that way but I have decided that I don't need that function any more so you could say that my problem's solved.
Thanks

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.