Skip Navigation

[Resolved] Add url parameter on views submit

This support ticket is created 4 years, 3 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.

Our next available supporter will start replying to tickets in about 1.73 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by culturaI 4 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1667027

Hello i have a view (you can look at here: hidden link)
My view is not using ajax (because i would like to use amp in a while)

I would like redirect to a row when visitors click on submit button, so i basically want to add "&#myrow" to parameter url when they click on.

Not sure about what function to use.

Thanks!

#1667417

Hello, unfortunately we don't have anything exactly like this built-in to the software. I think you could use custom JavaScript to detect whether or not the wpv_view_count URL parameter exists, and if so, append your hash to the URL. You could trigger any other code you want at that time as well, like animation to scroll to some specific row of results by ID.

Here's a handy utility function to get URL parameter(s) from a URL. You don't need to make any changes in this code:

var getParams = function (url) {
	var params = {};
	var parser = document.createElement('a');
	parser.href = url;
	var query = parser.search.substring(1);
	var vars = query.split('&');
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split('=');
		params[pair[0]] = decodeURIComponent(pair[1]);
	}
	return params;
};

Reference: https://gomakethings.com/getting-all-query-string-values-from-a-url-with-vanilla-js/

Here's an example showing how to use the utility function to test whether or not the current page URL contains the parameter "wpv_view_count". You should be able to use this in the page load hook to determine if the search form has been submitted:

var params = getParams(window.location.href);
if( params['wpv_view_count'] && params['wpv_view_count'] == 5750 ) {
  // You have confirmed the search form was submitted.
  // Place custom code here to update the URL hash, scrollto the right location, etc.
}

Here's documentation for using location.hash to add something like #myrow in the URL:
https://www.w3schools.com/jsref/prop_loc_hash.asp
See "Set the anchor part" for an example.

#1672009

My issue is resolved now. Thank you!

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