Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi all, I'm currently making a memorial page and at the moment each person's memorial is listed on the homepage in one big list like:

Person 1 (with details like their name, age, bio etc.)
--
Person 2
--
Person 3
--
Person 4

etc.. (about 100+)

I'm using clonable page templates for each person like:
Code: Select all
<cms:template title="Memorials" clonable="1">
[a bunch of editables for their name, age, bio etc.]
</cms:template>


And then using a snippet like:
Code: Select all
<cms:pages orderby="weight" order="asc" masterpage="memorials.php">
[a bunch of html which grabs each person's name and bio from the editables above]
</cms:pages>


Which is then listed on the home page like:
Code: Select all
<cms:embed "memorial-list.html" />


This works fine and all but I wish to group certain people in to categories (e.g for families) and visually make that clear on the front end like:

Person 1
--
Family 1:
Person 2 (plus their field data like name, age, bio, not just the title)
Person 3
Person 4
---
Person 5

Essentially list-view each clonable page but while doing so check to see if a page belongs to a certain family, and if it does, to loop that family within one group (so there are no separators between them)

I have tried using both folders (dynamic) and nested pages but for the life of me can't seem to grasp how to solve this issue. If using folders, I don't just want to display the folder title but the contents of the folders pages too while at the same time listing all the other pages that aren't in folders.

Could anyone please help me out? :) big fan of couchcms here
Hi,

Wouldn't it be easier to list out folders (i.e. families) and sub-list below each family its members?
Hi KK, thanks for replying, so I've done that now like this:

Code: Select all
<cms:folders masterpage='memorials.php' orderby="weight" >
      <cms:set count='0' 'global' />
      
      <cms:pages orderby="weight" folder=k_folder_name order="asc" masterpage="memorials.php">
            <cms:if count == '0'>
               <cms:show k_folder_title /> <br>
            </cms:if>

            <cms:set count="<cms:add count '1'/>" scope='global'/>
            <cms:show k_page_title/>
            <cms:show age/><br>
      </cms:pages>
</cms:folders>

Where it lists the family's surname (aka the folder title) and underneath lists the actual family members and their details. The 'count' statement is just to make sure the surname only appears once. On the front-end it visually looks like:

Code: Select all
Smith:
Bob Smith, 38
Larry Smith, 29
---
Johnson:
Richard Johnson, 24
Lisa Johnson, 29

This works fine and families are grouped properly however, I also want to list pages (singular people) that aren't in any folders as well, for family's where there is only 1 entry we don't want to assign a folder to them, so something like:

Code: Select all
Smiths:
Bob Smith, 38
Larry Smith, 29
---
Johnsons:
Richard Johnson, 24
Lisa Johnson, 29
---
Richard Price
---
Michelle Daniels
---
Marcia Moran

I can achieve this using a standard pages loop alongside the above folders loop like

Code: Select all
<cms:folders masterpage='memorials.php' orderby="weight" >
[the "folders" code loop I mentioned at the start]
</cms:folders>


<cms:pages orderby="weight" order="asc" masterpage="memorials.php" >
[list of all pages and their details]
</cms:pages>

This works but repeats any listings that were already listed from the <folders> loop so I get stuck with:

Code: Select all
Smiths:
Bob Smith, 38
Larry Smith, 29
---
Johnsons:
Richard Johnson, 24
Lisa Johnson, 29
---
Richard Price
---
Michelle Daniels
---
Bob Smith, 38 (repeating again)
---
Larry Smith, 29 (repeating again)

Am I using the right approach with two seperate loops?
Should I just make every page have a folder and any entries with no other family members could be in a 'single' folder?
Is there a way to only list pages that ARE NOT in any folder? like
Code: Select all
folder="NOT *"

Thank you!! I hope I've explained the problem clearly
Try this parameter for cms:pages -
include_subfolders='0'
Thank you trendoman! That was the last fix I needed to get this running.

Thank you very much KK and trendoman for your great support!
I would just use relation editable and create 'families' by relating people. I did not see in reality how comfortable it is (or isn't) to work with folders though. I am posting this to remind that a template can have a 'relation' set to itself. Showing families and single people will rely on cms:pages and cms:related_pages tags in this case. If in future your current solution doesn't live up to expectations, you have a backup plan with relation.
6 posts Page 1 of 1