0

The {% nav %} does not work for me as expected. After the last call of {% children %} but still inside the {% ifchildren %} the id of the last child element is used. Only after {% endifchildren %} the variable is as expected.

Am I missing something or is this a bug?

And in my case I need to access the page variables while inside the {% ifchildren %}, any suggestions on how to fix this, are welcome...

And sorry for the long html, the important part is at the very bottom.

<ul>
    {% nav page in pages %}
        <li>
            Start {{ page.id }}
            {% ifchildren %}
                <br>Start {{ page.id }} children
                <ul>
                    {% children %}
                </ul>
                End {{ page.id }} children
            {% endifchildren %}
            <br>End {{ page.id }}
        </li>
    {% endnav %}
</ul>
<ul>
  <li>
    Start 5
    <br>End 5
  </li>
  <li>
    Start 212
    <br>Start 212 children
    <ul>
      <li>
        Start 215
        <br>End 215
      </li>
      <li>
        Start 218
        <br>End 218
      </li>
      <li>
        Start 221
        <br>End 221
      </li>
      <li>
        Start 224
        <br>End 224
      </li>
      <li>
        Start 227
        <br>End 227
      </li>
      <li>
        Start 230
        <br>End 230
      </li>
      <li>
        Start 233
        <br>End 233
      </li>
    </ul>
    End 212 children
    <br>End 212
  </li>
  <li>
    Start 236
    <br>Start 236 children
    <ul>
      <li>
        Start 249
        <br>End 249
      </li>
      <li>
        Start 252
        <br>End 252
      </li>
      <li>
        Start 255
        <br>End 255
      </li>
    </ul>
    End 236 children
    <br>End 236
  </li>
  <li>
    Start 239
    <br>Start 239 children
    <ul>
      <li>
        Start 258
        <br>Start 258 children
        <ul>
          <li>
            Start 279
            <br>End 279
          </li>
          <li>
            Start 282
            <br>End 282
          </li>
          <li>
            Start 285
            <br>End 285
          </li>
          <li>
            Start 288
            <br>End 288
          </li>
          <li>
            Start 291
            <br>End 291
          </li>
          <li>
            Start 294
            <br>End 294
          </li>
          <li>
            Start 297
            <br>Start 297 children
            <ul>
              <li>
                Start 300
                <br>End 300
              </li>
              <li>
                Start 303
                <br>End 303
              </li>
            </ul>
            End 297 children
            <br>End 297
          </li>
        </ul>
        End 258 children
        <br>End 258
      </li>
      <li>
        Start 261
        <br>Start 261 children
        <ul>
          <li>
            Start 322
            <br>End 322
          </li>
          <li>
            Start 325
            <br>End 325
          </li>
          <li>
            Start 328
            <br>End 328
          </li>
          <li>
            Start 331
            <br>End 331
          </li>
          <li>
            Start 334
            <br>End 334
          </li>
          <li>
            Start 337
            <br>End 337
          </li>
        </ul>
        End 261 children
        <br>End 261
      </li>
      <li>
        Start 264
        <br>Start 264 children
        <ul>
          <li>
            Start 340
            <br>End 340
          </li>
          <li>
            Start 343
            <br>End 343
          </li>
          <li>
            Start 346
            <br>End 346
          </li>
          <li>
            Start 349
            <br>End 349
          </li>
          <li>
            Start 352
            <br>End 352
          </li>
        </ul>
        End 264 children
        <br>End 264
      </li>
      <li>
        Start 267
        <br>Start 267 children
        <ul>
          <li>
            Start 355
            <br>End 355
          </li>
          <li>
            Start 358
            <br>End 358
          </li>
          <li>
            Start 361
            <br>End 361
          </li>
          <li>
            Start 364
            <br>End 364
          </li>
          <li>
            Start 367
            <br>End 367
          </li>
        </ul>
        End 267 children
        <br>End 267
      </li>
      <li>
        Start 270
        <br>Start 270 children
        <ul>
          <li>
            Start 370
            <br>End 370
          </li>
          <li>
            Start 373
            <br>End 373
          </li>
          <li>
            Start 376
            <br>End 376
          </li>
          <li>
            Start 379
            <br>End 379
          </li>
          <li>
            Start 382
            <br>End 382
          </li>
        </ul>
        End 270 children
        <br>End 270
      </li>
      <li>
        Start 273
        <br>Start 273 children
        <ul>
          <li>
            Start 385
            <br>End 385
          </li>
          <li>
            Start 388
            <br>End 388
          </li>
          <li>
            Start 391
            <br>End 391
          </li>
          <li>
            Start 394
            <br>End 394
          </li>
          <li>
            Start 397
            <br>End 397
          </li>
        </ul>
        End 273 children
        <br>End 273
      </li>
      <li>
        Start 276
        <br>Start 276 children
        <ul>
          <li>
            Start 400
            <br>End 400
          </li>
          <li>
            Start 403
            <br>End 403
          </li>
        </ul>
        End 276 children
        <br>End 276
      </li>
    </ul>
    End 239 children
    <br>End 239
  </li>
  <li>
    Start 242
    <br>Start 242 children
    <ul>
      <li>
        Start 406
        <br>End 406
      </li>
      <li>
        Start 409
        <br>End 409
      </li>
      <li>
        Start 412
        <br>End 412
      </li>
      <li>
        Start 415
        <br>End 415
      </li>
      <li>
        Start 418
        <br>End 418
      </li>
      <li>
        Start 421
        <br>End 421
      </li>
      <li>
        Start 424
        <br>End 424
      </li>
    </ul>
    End 242 children
    <br>End 242
  </li>
  <li>
    Start 245
    <br>Start 245 children
    <ul>
      <li>
        Start 428
        <br>End 428
      </li>
      <li>
        Start 431
        <br>End 431
      </li>
      <li>
        Start 434
        <br>Start 434 children
        <ul>
          <li>
            Start 443
            <br>End 443
          </li>
          <li>
            Start 446
            <br>End 446
          </li>
        </ul>
        End 434 children
        <br>End 434
      </li>
      <li>
        Start 437
        <br>Start 437 children
        <ul>
          <li>
            Start 449
            <br>End 449
          </li>
          <li>
            Start 452
            <br>End 452
          </li>
          <li>
            Start 455
            <br>End 455
          </li>
          <li>
            Start 458
            <br>End 458
          </li>
          <li>
            Start 461
            <br>End 461
          </li>
          <li>
            Start 464
            <br>End 464
          </li>
          <li>
            Start 467
            <br>End 467
          </li>
        </ul>
        End 437 children
        <br>End 437
      </li>
      <li>
        Start 440
        <br>Start 440 children
        <ul>
          <li>
            Start 470
            <br>End 470
          </li>
        </ul>
        End 470 children
        <br>End 440
      </li>
    </ul>
    End 440 children
    <br>End 245
  </li>
</ul>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.