• Resolved scShaw

    (@istudiodesign)


    Is it possible when inserting the shortcode to specify only certain of the fieldnames be displayed?

    For example, if I have fieldname1 through fieldname7 for [CP_CALCULATED_FIELDS id=”6″], can I cause only fieldname1 and fieldname6 to be displayed on the website?

    This doesn’t work
    [CP_CALCULATED_FIELDS id=”6″] “fieldname1” “fieldname7”

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @istudiodesign,

    If you want to display only the fields: fieldname1 and fieldname7, there are different alternatives depending on the structure of your form and the controls.

    1. Using hidden fields.
    2. If some of these fields are calculated fields, you simply should tick the checkbox: “Hide Field From Public Page” in the fields’ settings.
    3. The last alternative would be assign the predefined class: hide to the fields, simply entering the word: hide into the attributes: “Add CSS Layout Keywords” of the fields to hide.

    Best regards.

    Thread Starter scShaw

    (@istudiodesign)

    I’m trying to create a branching method on the website whereby the user makes a choice on a page which then takes them to a page that contains a limited set of fieldnames from the CFF…a different choice on the branching page takes them to a different page that displays a different limited set of fieldnames from the same CFF. So, hard coding hiding some field names is not an option I want…I want to be able to use the CFF for any of the branching choices.

    Plugin Author codepeople

    (@codepeople)

    Hello @istudiodesign,

    The alternative in this case would be define dependencies using a calculated field as auxiliary.

    For example, insert a calculated field in the form with the equation: filter*1
    (I’ve used filter as the variable name you can use the name you want)

    Now, in the settings of the calculated field, define the dependencies you need with the fields in the form. For example, in case the result of the equation is 1 show the fields: fieldname1, fieldname2, fieldname3, if the result of the equation is 2 show the fields: fieldname10,fieldname9, etc….. You should create a dependency rule for showing the fields you need in each case.

    Note, as the calculated field is used as auxiliary it is not relevant in the form’s interface, so, should be ticked the checkbox: “Hide Field From Public Page” in its settings.

    Finally, you should know that every additional parameter you pass to the form’s shortcode would be converted in a javascript variable with global scope. so, assuming the id of the form is 123, you can use now the shortcodes:

    [CP_CALCULATED_FIELDS id="123" filter="1"] or [CP_CALCULATED_FIELDS id="123" filter="2"] etc…

    If you want pass the filter variables as a parameter of the URL, then you can use the combination of shortcodes:

    
    [CP_CALCULATED_FIELDS_VAR name="filter" default_value="1"]
    [CP_CALCULATED_FIELDS id="123"]
    

    In this case if the web page is visited with a parameter called filter, the “filter” javascript variable is created with the value of this parameter, and if the “filter” parameter is not passed in the URL would be used the default_value 1

    Best regards.

    Thread Starter scShaw

    (@istudiodesign)

    So, in the calculated field I set a function like this (based on having fieldname1 through fieldname6):

    (function(){
    var filter1 = fieldname1+fieldname6;
    jQuery(‘.filter1-here’).html(filter1);
    return filter1;
    })()
    (function(){
    var filter2 = fieldname1+fieldname3+fieldname5;
    jQuery(‘.filter2-here’).html(filter2);
    return filter2;
    })()

    Thread Starter scShaw

    (@istudiodesign)

    Do I need the variable name to have the asterisk?

    filter*1
    filter*2

    Plugin Author codepeople

    (@codepeople)

    Hello @istudiodesign,

    The variable name would be only: filter (or the name you want), the equation associated to the calculated field would be the multiplication operation: filter*1 to force javascript to interpret the filter variable as a number and not as a text.

    Best regards.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    I’m sorry, but I guess you don’t have understood the process.

    If you want show/hide fields in the form based on an URL parameter, you should implement the form as usual, but thinking that exists different cases of use.

    In my previous example I’ve described how you can create dependencies from a calculated field, using for filtering a parameter received through the URL.

    You don’t need show/hide the elements in the form using jQuery because this action is responsibility of the dependencies.

    Best regards.

    Thread Starter scShaw

    (@istudiodesign)

    Understand…I misinterpreted what you said. This recent answer makes it clear what I need to do.

    Thank you for clearing that up for me.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Display only certain fieldnames on web page when inserting shortcode’ is closed to new replies.