• Greetings – We’re attempting to build a dynamic table using this plugin with ACF. Essentially this is a front-end for entering products onto a website and then displaying them in a table. It’s been a challenge and we’re looking for some help.

    The code is below and the first table row works fine — it loads the column headers the user selected from an ACF form from a list of 12 or so.

    The next section of code needs to pull in the field data from the above column headers for whichever products the user chose to be included in the table.

    So, they choose the table’s column headings (which have values of things like size, color, etc.), and then they choose the products to show in the same table via an ACF Post Object field.

    We can’t figure out how to replace [field part_number] in the code below with a dynamic loop that will show the appropriate data based on the columns the user selected in the first repeater (e.g., size, color, etc.).

    Hope that makes sense!

    ———————————————

    [repeater product_table]

    <h2>[field product_table_title]</h2>

    <table style=”width:100%”>

    <tr>
    [-repeater product_table_columns]
    <th>[field product_table_column]</th>
    [/-repeater]
    </tr>

    [-repeater product_table_products]
    [related product_table_product]
    <tr>
    <td>[field part_number]</td>
    </tr>
    [/related]
    [/-repeater]

    </table>

    [/repeater]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Not sure what you want to do.

    You have a content type with an repeater field called prouct_table.
    You have repeater fields within that repeater called product_table_columns and product_table_products.
    You have a relation field within the product_table_products repeater called product_table_product.
    You have a field called part_number within the posts related from product_table_product
    You want to read the content of the the field from the related posts.

    Did I get it right?

    • This reply was modified 3 years, 7 months ago by polarracing.
    • This reply was modified 3 years, 7 months ago by polarracing.
    Thread Starter mpturner

    (@mpturner)

    Hi, yes it’s quite confusing for sure but thanks very much for responding. You have that right except the last line (I’ll explain below – sorry so long!). The screenshot of parts of the ACF form might help – https://www.dropbox.com/s/cyyvxwvp42dqwu4/product-table.png?dl=0

    So, we have thousands of products. Each product has about 5 attributes that need to be displayed in a table (or more than one table, hence the nested repeaters) on a web page but there is a list of about 12 attributes that a website admin gets to choose from (all attributes don’t apply to all products).

    On our form in the screenshot, the admin first selects the table’s five or six column headers from a list of those 12 attributes. Then, they select which products to display in the table via the Post Object field. The table will then auto-populate each row based on that Post Object and the attributes selected as column headers.

    The code as it is now works if we manually add which attributes to display (in my original post, that would be “field part_number” we plugged in as a test). But we need to replace that “field part_number” code with some kind of loop that looks to the columns the user selected in the first nested repeater.

    We think this is something with a variable, PASS, etc. but we just can’t figure it out.

    Thanks for any help!

    • This reply was modified 3 years, 7 months ago by mpturner.
    • This reply was modified 3 years, 7 months ago by mpturner.

    If you need to replace a part of a field name with a dynamic value you can use [pass]

    [set myvar]en[/set]
    [pass vars]
    [field myfield-{MYVAR}]
    [/pass]

    gives back the content of

    [field myfield-en]

    • This reply was modified 3 years, 7 months ago by polarracing.
    Thread Starter mpturner

    (@mpturner)

    Thanks for the response. I think we’re struggling with where to put the PASS code within our code below.

    Trying to explain better with the bold comments below (and removing the table HTML)…

    [repeater product_table]

    [-repeater product_table_columns]
    [field product_table_column] <<< this returns a comma list, which is fine for the table column headers we’re creating here.
    [/-repeater]

    [-repeater product_table_products]
    [related product_table_product]
    [field part_number] <<< Instead of part_number, this needs to return the above comma list but one at a time so we can make each one a table row.
    [/related]
    [/-repeater]

    [/repeater]

    • This reply was modified 3 years, 7 months ago by mpturner.
    • This reply was modified 3 years, 7 months ago by mpturner.
    • This reply was modified 3 years, 7 months ago by mpturner.

    Ok, but why the related in the second repeater

    But you should try this.

    You have to nest the repeater if you would like to have him to do things step by step. Otherways you would need to split your commalist and inject each value into the repeater2.

    [-repeater product_table_columns]
    [field product_table_column] <<< this returns a comma list, which is fine for the table column headers we’re creating here.
    [set myvar]YOURVAR[/set]
    [/-repeater]
    [-repeater product_table_columns]
    [--repeater product_table_products]
    [related product_table_product]
    [pass vars]
    [field {MYVAR}] <<< Instead of part_number, this needs to return the above comma list but one at a time so we can make each one a table row.
    [/pass]
    [/related]
    [/--repeater]
    [/-repeater]
    • This reply was modified 3 years, 7 months ago by polarracing.
    • This reply was modified 3 years, 7 months ago by polarracing.
    • This reply was modified 3 years, 7 months ago by polarracing.
    • This reply was modified 3 years, 7 months ago by polarracing.
    • This reply was modified 3 years, 7 months ago by polarracing.
    Thread Starter mpturner

    (@mpturner)

    Ok, thanks – we’re gonna have to play with your code a bit to see if we can work through it.

    The second repeater is because the end-user has to choose which columns they want as headers in the table, and then tell us which products. If it was all in the same repeater, we’d have column headers that repeat (I think…) We’re very confused at this point =/

    Thread Starter mpturner

    (@mpturner)

    Oops – You asked about the “Related.” That’s there because we don’t know how else to display a Post Object, based on this plugin’s documentation.

    I realize this is all going down a rabbit hole but here is a screenshot from our Elementor edit page of where we’re at with some notes on the issues we’re having:

    https://www.dropbox.com/s/ozc974xt34gcezm/h0OQWxdXEl.png?dl=0

    And this is the end-user interface for the tables:

    https://www.dropbox.com/s/cyyvxwvp42dqwu4/product-table.png?dl=0

    Thanks again for helping us work through this!

    • This reply was modified 3 years, 7 months ago by mpturner.

    Depending what you need from the post object and what information you have – there are several ways to display the information.

    But I still do not get a 100% what you are trying to do. If you like, contact me via info@polar-racing.com and we can discuss.

    Thread Starter mpturner

    (@mpturner)

    Thanks, that’s very kind. We’ll keep plugging away to see if we can figure it out and perhaps hit you up if we can’t. Thanks again for everything thus far!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Output ACF Field Based on Another ACF Field’s Value’ is closed to new replies.