Home Forums ACF PRO Using ACF PRO to build a comparison chart Reply To: Using ACF PRO to build a comparison chart

  • Given what you have said, I would likely build an application.

    First I would create an options page. This options page would allow the client to create features. This being all of the things on the left side of the page. I would give them a few options, for example I see

    • features that have or do not have a check
    • I see features that have a yes or no
    • Features that might a choice of possible values
    • features that would require entering text

    These I would set up as a repeater on the options page and each row would allow the client to create features with the needed options. Depending on the conditions I would likely make it so that the client could add features, but never delete a feature. You’d also need to add some custom validation to ensure that they do not create duplicate features.

    Then I would do what Mark said and create a CPT for the “Products”, all of the things at the top of the page.

    The next step would be to build a field group using what the client adds to the features options page. I would create this field group in PHP, not in the ACF editor. I would read through the list of features and create an ACF field for each feature.

    The next step for me would then be to add another CPT for the “comparisons”. This CPT would contain it’s own field group. The first field would be a relationship field that allowed the client to select the “products” they want to compare on the page. The second would be a repeater that would allow them to select and order the features that they want to compare. I’d use a select field and the choices of this select field would also be dynamically generated from the features entered into the options page.

    Finally I’d build a template for showing the comparisons that pulls it all together. Get the list of fields to display and the order to display them, get the posts to display and then loop though the posts and show the values for each feature.

    A little complicated and would take more time, but then I’d never have to touch it again.