Choosing a site path with conditionals


#1

howdy folks,

quick question regarding accessing site.whatever for posts that can be switched back & forth. so pretty much a previous & next button.
I have something working pretty damn well & uses the same type of layout I have made, but I use collections. so have a collection for games, sound etc. & like the way I can switch between these projects for the genre its in.

but with this reconstruction of the layout im using I cant use the site.whatever option anymore, only if I set the site.whatever to soemthing such as site.game I can use, but since the layouts used for sound, design etc, I am unable to use it for those

this is the current for loop I am using at the bottom of my layout. im happy with the layout because it can be used for everything. but just wondering if I can affect the site.whatever for each page with something like page directory: game

{% assign sorted = site.whatever | sort:'order' %}
{% for post in sorted %}
  {% if post.url == page.url %}
    {% assign post_index0 = forloop.index0 %}
    {% assign post_index1 = forloop.index %}
  {% endif %}
{% endfor %}

{% for post in sorted %}
  {% if post_index0 == forloop.index %}
    {% assign next_post = post %}
  {% endif %}
  {% if post_index1 == forloop.index0 %}
    {% assign prev_post = post %}
  {% endif %}
{% endfor %}

can I affect the site.whatever to something like site.{{ page.directory }}, so I can choose how it cycl/es thru tho posts so I can use next/previous for the collections

thanks. I hope this made sense


#2

not quite sure I follow, sounds like you want to get all items in collections without specifying which collection?

have you tried site.pages? it should return all pages, though not sure if that contains posts or not. It would contain other pages not part of a collection but maybe you could filter them out.


#3

hmmm. ok. I guess thats near to what I need. if it works, it works. thats the main thing

thanks