Support

Account

Home Forums Add-ons Repeater Field Repeater in a repeater in a repeater

Solved

Repeater in a repeater in a repeater

  • Hi,I’m in trouble with Repeater field…

    I made repeater in a repeater in a repeater.
    Then I can’t get result.

    Here is my code.
    Please give me your help…

    <?php while(has_sub_field('parent_field')): ?>
    <ul>
    <?php if(get_field('child_field')): ?>
    <li>
      <h4><img src="img.png" /></h4>
      <ul>
        <?php while(the_repeater_field('child_field')): ?>
        <li>
          <?php echo get_sub_field('child_child_field1'); ?>
          <?php echo get_sub_field('child_child_field2'); ?>
        </li>
        <?php endwhile; ?>
      </ul>
    </li>
    <?php endif; ?>
  • Hi @k2b8692

    Your code contains a few issues. These are:
    1. No if statement around initial while loop
    2. incorrect use of get_field for ‘child_field’. This should be get_sub_field
    3. incorrect use of the_repeater_field. This should be has_sub_field

    Your code only goes 2 levels deep. You need to add a 3rd payer as per your topic title.

    Thanks
    E

  • Hi Elliot

    i’m having the same issue

    can you please provide a code sample for the above question to help me along with my issue.

    thanks

    Michael

  • Hi @k2b8692

    This is a support forum, not a free dev service.

    Sorry mate. You will need to read the docs and write you own code.

    Feel free to ask any specific questions.

    Thanks
    E

  • Hi Elliot

    I do not consider this a free developer service, and yes of course i did read your docs first and got stuck.

    But, since your not so helpful answer, pissed me enough off to go back an have another go, i managed to find a working solution:

    <?php // check for rows (parent repeater)
    if( get_field(‘repeaters’) ): ?>

    <?php // loop through rows (parent repeater)
    while( has_sub_field(‘repeaters’) ): ?>

    <?php // check for rows (sub parent repeater)
    if( get_sub_field(‘repeater_1’) ): ?>

    <?php // loop through rows (sub parent repeater)
    while( has_sub_field(‘repeater_1’) ): ?>

    <?php // check for rows (sub parent repeater)
    if( get_sub_field(‘repeater_2’) ): ?>

    <?php // loop through rows (sub parent repeater)
    while( has_sub_field(‘repeater_2’) ): ?>

    <div style=”margin-bottom: 20px”>
    <?php the_sub_field(‘repeater_2_text’); ?>
    </div>

    <?php endwhile; ?>

    <?php endif; ?>

    <?php endwhile; ?>

    <?php endif; ?>

    <?php endwhile; ?>

    <?php endif; ?>

    which resolves in this output:

    (from sub repeater_1)
    1-test 1
    1-test 2

    (from sub repeater_2)
    2-test 1
    2-test 2
    2-test 3

    (from sub repeater_3)
    3-test 1

    I really like this plug-in and can only rate with the best score, so i do feel a bit sad, with your response to my question.

    Cheers

    Michael

  • Hi @mandfolk

    It’s a shame that you have responded in this way on a free public support forum.
    Perhaps you could help improve the docs by explaining why you found it hard to render a nested repeater field in the first place?

  • Hi again Elliot

    i did find it difficult to make a nested repeater in the first place, simple because i got confused with the hole sub repeater thing.

    Because it goes like this with the first repeater:
    parent repeater > sub repeater

    i thought that the next repeater has to be a sub sub repeater of the parent repeater.

    parent repeater > sub repeater > sub sub repeater

    which of course didn’t work.

    So all i was looking for was a simple example like the one i provided showing the structure with

    parent repeater > sub repeater > sub repeater

    I’m sorry, if you believe that my post was to direct in it’s tone-of -voice, but i personally don’t feel it is a shame to speak ones mind.

    And since i’m quite sure that you would have been able to write a short code example in the same amount of time, as you did spend on your first feedback, all this could have been avoided if you had gone about this differently.

    You do sell at piece of really great software (for a low price), but given the fact that is not a free software, i expected a more helpful answer, than the one you gave me.

    For me a support forum, is a place where i go for help and not free labour, so when you write this:

    “This is a support forum, not a free dev service.

    Sorry mate. You will need to read the docs and write you own code.”

    I just don’t really see the support function at all in the above statement.

    But as i said before. your software is great and please keep up the good work, and in the spirit of wordpress, provide help, when help is needed.

    Feel free to edit or remove my previous post in any way you feel, i simply added it to provide help to others in my situation. not to start up a dispute with you.

    thanks

    Michael

  • Hi @mandfolk

    Perhaps you could go back and have a look at your original comment.

    You did not take the time to state any details, data or show that you had attempted to find a solution via the documentation. This is why you did not receive the helpful response you were hoping for.

    You simply said “I have the same problem, can you write the code for me”.

    Just to clarify, you don’t have the same problem. The original topic asked why their code did not work. To this, I clearly described what needed to be fixed.

    Perhaps next time, you can take the time to provide such details and I can help you out.

    Thanks
    E

  • Hi Elliot

    Agreed my orignal post could have been informative, but i still don’t see how you can read “code example” as “please write the code for me”

    If you did find my original question to be insufficient, a simple feedback stating that you needed more information in order to help, would have been better, and something that i would have the full understandig for.

    Again, i did not intent to start a dispute with you.

    But, please tell me why you decided to make a “Private” reply public?

    i made it private so, we could solve this between us, and not the whole world.

    So. let us end this in the most positive way possible, and i do suggest that we remove this entire dialog, and i will repost my first post with only the solution, and a more friendly intro.

    I can only regret that we came to this point, which was never my intension

    Best

    Michael

  • Hi @mandfolk

    Just to wrap this up. There is absolutely no need for this kind of attitude on a free support forum for a WordPress plugin which has lots of documentation resources and thousands of forum threads to search through. Just no need at all.

    Next time you do post a question. Perhaps spare a thought for the developer who is going to answer your question. provide useful details and don’t get angry with them, they are just trying to help.

  • This reply has been marked as private.
  • Hi @mandfolk

    What I did not appreciate about your original comment was the way you asked for a ‘code example’ with the least amount of words possible.

    I have already written a code example of nested repeater fields which you can find on the docs. So my first thought is that you have not looked at the docs due to these reasons:

    1. You fail to ask an actual question
    2. You fail to show any signs of research / problem solving
    3. You fail to mention any details about your issue
    4. Your statement im having the same issue is probably the most frustrating things you could say to a web developer. That and ‘it isnt working’. It gives no information, but forces me to ask you hundreds of questions.

    This is why I told you this is not a free dev service and that I am happy to answer any specific questions. Perhaps you can read over my reply to see that I did ask you to provide a specific question.

    You were the one to then fire up and use abusive language, not me.
    There is my reasoning. I hope this clears up your query.

    I am genuinely curious, why did you say that you have the same issue? Have you read the original post fully? His issues is far different from yours.

  • This reply has been marked as private.
Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Repeater in a repeater in a repeater’ is closed to new replies.