Support » Plugin: Custom Content Shortcode » Need Help Finalizing This Code

  • Resolved mpturner

    (@mpturner)


    Greetings – Without attempting to explain here exactly what we’re looking to achieve here because it is quite unique and complicated given our company’s website situation, we need help getting over two final roadblocks.

    1. Thanks to @polarracing and a few others, the code below works great for us EXCEPT the SECOND nested -repeater is not repeating. All of the data is loading correctly once, then it moves to generate the next HTML table and stops.

    2. Due to the way our variables are set up here, we need the first repeater’s ACF SELECT to output as values vs. labels. So, that’s how we have it set in the ACF fields UI. As column headers in the table, we need to display these as labels but out=label does not work (the column headers disappear when we try it) We can change the ACF output to Label but then our variables stop working. In ACF, this is a SELECT with manually added choices (e.g., value : label combos).

    If anyone could look at this code for any obvious/glaring issues in the loop or whatever, that would be great.

    Thanks!

    
    [repeater product_table]
    
    [set colheads][/set]
    [set colheadscount]0[/set]
    [set loopcount]0[/set]
    [set fieldtofetch][/set]
    
    <h2>[field product_table_title]</h2>
    
    <table style="width:100%">
    
    <tr>
    
    [-repeater product_table_columns]
    
    <th>[field product_table_column]</th>
    
    [if var=colheadscount value=0]
    [set colheads][field product_table_column][/set]
    [else]
    [set colheads][get colheads], [field product_table_column][/set]
    [/if]
    
    [set colheadscount][calc][get colheadscount]+1[/calc][/set]
    
    [/-repeater]
    
    </tr>
    
    [-repeater product_table_products]
    [related product_table_product]
    
    <tr>
    
    [loop]
    
    [set loopcount][calc][get loopcount]+1[/calc][/set]
    
    [pass vars]
    [set fieldtofetch][format split="," part={LOOPCOUNT}][get colheads][/format]
    [/set]
    [/pass]
    
    [pass vars]
    <td>[field {FIELDTOFETCH}]</td>
    [/pass]
    
    [/loop]
    
    </tr>
    
    [/related]
    [/-repeater]
    
    </table>
    
    [/repeater]
    
    
    • This topic was modified 1 year, 9 months ago by mpturner.
    • This topic was modified 1 year, 9 months ago by mpturner.
    • This topic was modified 1 year, 9 months ago by mpturner.
Viewing 1 replies (of 1 total)
  • Thread Starter mpturner

    (@mpturner)

    Once again, I dunno how to delete a post but we solved this issue that probably no other person will ever encounter by resetting our loopcounter variable again just after the loop itself.

    Carry on 🙂

    [repeater product_table]
    
    [set colheads][/set]
    [set colheadscount]0[/set]
    [set loopcount]0[/set]
    [set fieldtofetch][/set]
    
    <h2>[field product_table_title]</h2>
    
    <table style="width:100%">
    
    <tr>
    
    [-repeater product_table_columns]
    
    <th>[field product_table_column]</th>
    
    [if var=colheadscount value=0]
    [set colheads][field product_table_column][/set]
    [else]
    [set colheads][get colheads], [field product_table_column][/set]
    [/if]
    
    [set colheadscount][calc][get colheadscount]+1[/calc][/set]
    
    [/-repeater]
    
    </tr>
    
    [-repeater product_table_products]
    [related product_table_product]
    
    <tr>
    
    [loop]
    
    [set loopcount][calc][get loopcount]+1[/calc][/set]
    
    [pass vars]
    [set fieldtofetch][format split="," part={LOOPCOUNT}][get colheads][/format]
    [/set]
    [/pass]
    [pass vars]
    <td>[field {FIELDTOFETCH}]</td>
    [/pass]
    
    [/loop]
    
    [set loopcount]0[/set]
    
    </tr>
    
    [/related]
    [/-repeater]
    
    </table>
    
    [/repeater]
Viewing 1 replies (of 1 total)
  • The topic ‘Need Help Finalizing This Code’ is closed to new replies.