Skip Navigation

[Resolved] are fields available directly in the js editor?

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to know if possible to use custom fields in the js editor.
Solution:

Unfortunately no this is not possible to do.

This support ticket is created 6 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by edr-2 6 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1140469
san-luis.jpg

Tell us what you are trying to do? trying to use fields as a string in the js editor

Is there any documentation that you are following? n/a

Is there a similar example that we can see? on the site i am trying to remove hyphens in county names ( hidden link

What is the link to your site? hidden link

#1140616

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ed,

Thank you for contacting our support forum.

Is it that you want to remove the hypens from the url ?

Please let me know.

Thanks,
Shane

#1140664

well i was able to resolve some of the problems, and was able to remove the hyphens and capitalize the first char of the county. But for example now i am getting "San luis opispo", but i am thinking instead of writing all the js for the string manipulation, if i could just use the County name that was in the breadcrumb, ( which i think i was doing using "pathway"
array), if i could use the county as it appears in the loop it would be easier.
so for example i am using [types field="cdf-county" output="raw"] in the loop,
are any of these kinds of fields usable in the js panels?

#1140672

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ed,

Well, you can't add the shortcode itself to the JS editor, so what you will need to do is to get the output text from the frontend directly using the JS.

From there you can manipulate that text however you want to.

Thanks,
Shane

#1140684

Hi Shane!

ok, can't use the shortcode.
but from "get the output text from the frontend directly" i am not sure what that means.
if i have a url like
hidden link
i have i think the san-luis-obispo part, but am lazy to see how i can convert that to San Luis Obispo.
( i have gotten so far as to have San luis opispo).
is the url what you mean from the frontend? or is there something else?
thanks

#1140685

oh i am now thinking you might be saying i could use css for that term.
in using the css i could wrap the county in something like
<span class="countyname">
and text-transform the thing.
in using the css part, do i need to use the <style> tags?

#1140706

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ed,

I think there is some confusion here.

Lets try to clear it up. Now that you've removed the hypen from the page.

Is it that you want to remove it from the URL as well ?

Please let me know.

Thanks,
Shane

#1140712

Hi ,
its text that i want to place on the page and the code is in the wordpress archive panels.
so on the page hidden link
i am adding the text there that says
Probate Attorneys in San luis obispo
i got the county name from the url and am using it in the text area.
i have the following code

var pathname = jQuery(location).attr('pathname');
var pathArray = window.location.pathname.split( '/' );

//alert ('pathArray is ' + pathArray);
//alert ('pathArray length is ' + pathArray.length);
//alert ('pathArray[3] is ' + pathArray[3]);
//alert ('pathArray[4] is ' + pathArray[4]);
var state = pathArray[2];
var county = pathArray[3];

//state = state.toLowerCase().replace(/b[a-z]/g, function(letter) {
// return letter.toUpperCase();
//});
state = state.toLowerCase();
county = county.toLowerCase()

// replace possible hyphens and numbers from state and county text
// but county sometimes has state name in it as a slug problem
state = state.replace(/-[0-9]/g, '');
//county = county.replace(/-[0-9]/g, '');
// make sure all is lowercase and then capitalize
var len = county.length;
var first = county.charAt(0);
first = first.toUpperCase();
var part = county.substr(1,len);
county = first + part ;
var str = county;
var n = str.replace(/[-]/g, " ");
county = n;
//jQuery('#myTable').append('<tr><td>' + state + pathArray[4] + '</td></tr>');
var rowCount = jQuery('#myTable tr').length;
//alert ( 'rowcount is ' + rowCount );
if (rowCount == 0 ) jQuery('#myTable').append('<tr><th colspan="2"><h1>Probate Attorneys in ' + county + '</span></h1>' + '</th></tr>' +
'<tr><td colspan="2"><img style="text-align:center" id="searchingattorneys" src="hidden link"></td></tr>' +
'<tr><td colspan="2">' +'We’re sorry, we don’t yet have any member attorneys for this search yet. However, we would still like to help you find a qualified probate professional in your area. Click the "Contact Us" button below and email us a request for an attorney in your particular area!</td></tr>' + '<tr><td colspan="2" valign="top" align="right"><img id="myButton" style="float:left;margin-left:220px;margin-top:0;" src="hidden link">' + '</td></tr>' + '<tr><td colspan="2" style="text-align: center;font-weight:700;font-size:16px;">' + 'Are you a Probate Attorney in this Area? Sign up for a Free Listing!' + '</td></tr>' + '<tr><td> If you are an active Probate attorney and would like a free listing our site, click the button below and fill out our easy listings request form.' + '</td></tr>' + '<tr><td colspan="2" style="text-align: center;">' + 'hidden link"><img src="hidden link">' + '</td></tr>');

if (rowCount == 0 )
jQuery("#myButton").click(function ()
{
history.back();
});

and would like to improve it, by having the different parts of the county name in caps, when it has more than one space and two parts to its county name. i am thinking i can use css to do a text-transform now. so in the css panel below the js panel would i use something like
text-transform:capitalize;
if so, i don't know whether toolset css panel would have the <style> tags or not, or just the rules.
e

#1141352

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ed,

Yes I think the use of CSS would be a far simpler solution by using the text transform as it will capitalize the first letters.

Also there is a JS solution that I found here
https://stackoverflow.com/questions/32589197/capitalize-first-letter-of-each-word-in-a-string-javascript/32589256

You can also try this but the css solution is much simpler.

Thanks,
Shane

#1144234

My issue is resolved now. Thank you!