Latest Posts V2

I am back with this question :frowning: The plugin creation was just abit to much for me so cant use that option… I have seen in the learn section a blog version which after changing a few variables is working for me :smiley:

Now I am attempting to use this on another part of the site but the url structure is more complex so am struggling a bit.

Basically I have this working for :-

Wallpapers
    -Wallpaper 1
    -Wallpaper 2
    -ETC

So everything from 2nd level works…

Discography
    -A
        -Ary
              Album 1
              Album 2
        -Aman
              Album 1
              Album 2
    -B 
        -B21
              Album 1
              Album 2
        -Babbu
              Album 1
              Album 2

URL: /discography/a/ary/album-1/

So what I am looking to do is get back the last modified Albums (Only)… Twig is as below:-

					<div class="def-block widget">
						<h4> Latest Discography Albums </h4><span class="liner"></span>
						<div class="widget-content row-fluid">
							<div class="videos clearfix flexslider">
								<ul class="slides">
								    {% for p in page.find('/discography').children.order('date', 'desc').slice(0, 8) %}
									<li class="featured-video">
										<a href="{{ p.url }}">
											{{ pages.find('/images/discography-artists/250x250').media.images[p.header.image~'.jpg'] }}
											<h3>{{ p.header.title }}</h3>
											<span>{{ p.header.album }}</span>
										</a>
                                    </li><!-- slide -->
									{% endfor %}
								</ul>
							</div>
						</div><!-- widget content -->
					</div><!-- def block widget videos -->

I cant seem to figure out the .children bit as unsure how to force it to look down 2 levels of folders for changes… Currently it goes down to the A/B/C folders and just outputs the last modified dates of these but I need it to go down to artist name and then album-name and list the last modified albums.

You will need to do multiple for loops, possibly with recursion. To go over all the current children, then if a child has children of it’s own, go over those.

You can see an example of this using a twig macro in the Antimatter theme’s templates/partials/navigation.html.twig file.

Hmmm, also seems over complicated for me :frowning:

Guess I will need to keep manually updating the homepage with areas that have multiple folders.

It’s really not that complicated, like I said, the navigation in Antimatter is kind of doing something similar, so it makes sense to just read the code.

If you want to do something custom, you have to expect to have to write something custom to make it happen. Grav is about keeping things simple, that sometimes means, making it easy to create some custom functionality, but you still need to create it.