<a href="https://myurl.com?toth=[show_param param="total_things"]">My Total Things Link</a>..but that doesn't work. The resulting link just has the shortcode and not the value, as displayed in the View. How can I get the value displayed by the [show_param ..] shortcode to use as a URL parameter?
I think you want:
<a href="https://myurl.com?toth=[get param="total_things"]">My Total Things Link</a>
Thanks for the suggestion, Rob! Since I'm using frm-set-get inside a view, to save a complex value (the result of a frm-math calculation, get-param won't retrieve the parameters set by the frm-get-set, so I'm using the show_param shortcode, as noted in the docs here:
The value shows up in the View just fine.
Can you use the simple shortcode to get the value and put it within an element with a CSS class or ID that will be hidden and then capture the value from the class/ID with JS and then hook that to create your link?
<p>Hey Bobby. As always I appreciate the creativity and depth of knowledge in the insights you share. Your potential workaround/solution may work. Unfortunately, once we get into the realm of using JS to grab a value based on a CSS class or ID, I'm at a loss. Even moreso when thinking about how to use that value in as a parameter in a link.</p><p> </p><p>Let me see if I can take a stab at it. First set my variable, in this case, "toth", and use the CSS ID to get it:</p><p> </p><p><span id="toth">[show_param param="total_things"]</span></p><p> </p><p>var nm = document.getElementById("toth").innerText;<br />console.log(nm);</p><p> </p><p>But after that, I'm at a loss. I can run the above code in JS Fiddle, replacing the shortcode with a value and log that value to the console, it works but I can't get it to work in my view. Help me make magic? :)</p>
The view doesn't grab the value with the code that works in JS fiddle or you can't figure out how to create the link with the new set variable?
I can't figure out how to set the variable in js in my view or use it as a parameter in my link.
Do I create a in my view and set the var in there? Once it's wherever it needs to be, can I just reference it in building the link, just like a short code (without brackets)?
Not too proficient here, but I'm totally grateful to learn!
It seems like a pretty straightforward thing, to parse a value from text inside a CSS ID, and the then use that value as a URL parameter, but after hours on stackexchange, I'm no closer than getting the console in js fiddle to log the value correctly. :/
Add the script into your view within script tags. I usually put this type of code in the after content. You'll then need something like this to grab the CSS ID of the place where your link will go, something like this:
This looks great. I'll give this a go. And report back.
Bobby, you provided a great script and it got me *way* closer. Since I've got to use FF shortcodes referencing other fields as additional URL parameters, this won't work. Even if I got it to work, not sure how sustainable it'd be. Really appreciate your help on this. If anybody needs to grab a value from a show_param shortcode to use as a single URL parameter, modifying this snippet should work for you:
let nm = document.getElementById("tm").innerText; //surround the shortcode in a span with an id and call that id here
let text = "Click For The Things"; //the text of the link or button
result = "" + text + ""; //build the link with the shortcode value and the link/button text value
document.getElementById("applink").innerHTML = result; //output the resulting link to an element with an id of your choosing
Please login or Register to submit your answer