Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Apologies for the noob questions..

I'm using the code below to display footer links for subfolders of the current 'root' folder - which is a folder created in the "industries.php" template.
eg.
Folder Root
-Folder Root link
-Folder Two link
-Folder Three link
Code: Select all
<cms:if k_template_name == 'industries.php'>
              <cms:set current_folder_name=k_folder_name />
                <cms:folders masterpage='industries.php' hierarchical='1' limit='1'>
                  <cms:if k_level == '0' >
                    <p class="footer-label text-md-left text-xs-center"><cms:show k_folder_title /></p>
                    <p class="text-md-left text-xs-center" <cms:if k_folder_name = current_folder_name > style="color: rgba(255,255,255,.7);" </cms:if>><cms:if k_folder_name=current_folder_name>&rarr; Resources<cms:else /><a href="<cms:show k_folder_link />" >Resources</a></cms:if></p>
                    <cms:else />
                    <p class="text-md-left text-xs-center" <cms:if k_folder_name = current_folder_name> style="color: rgba(255,255,255,.7);"</cms:if>><cms:if k_folder_name=current_folder_name>&rarr; <cms:show k_folder_title /><cms:else /><a href="<cms:show k_folder_link />" ><cms:show k_folder_title /></a></cms:if></p>
                  </cms:if>
                </cms:folders>
            </cms:if>


It works fine and give me what I want, except it shows all folders from industries.php like this

Folder Root A
-Folder Root link
-Folder Two link
-Folder Three link

Folder Root B
-Folder Root B link
-Folder Two link
-Folder Three link

Folder Root C
-Folder Root C link
-Folder Two link
-Folder Three link

When I'd like to restrict it to just the "current" root folder.

I've tried childof, ancestors, and various other conditional blocks, but can't crack it.

How do I stop cms:folders showing all the folders like this?
Please post your desired look. Do you want to show the link of current folder on top and then below it the links to current folder's children sub-folders? What are folder-two and folder-three?
Also post your sample folder structure, because it is not clear if you have sub-sub-folders and what is required to output in case a child-child folder is selected, or a folder whithout children.

I advise you to use <cms:dump /> extensively to check for available information regarding output and tailor it accordingly.
To quickly test parameters I suggest 'listfolders' tag, could be used as this:
Code: Select all
    <h3>All folders</h3>
    <cms:listfolders hierarchical='1' />

    <h3>Current folder</h3>
    <cms:if k_is_folder>"<cms:show k_folder_title />"<cms:else />none</cms:if>

    <h3>Folders with current folder as root</h3>
    <cms:listfolders hierarchical='1' root=k_folder_name />

    <h3>Folders with current folder as root, depth='2'</h3>
    <cms:listfolders hierarchical='1' root=k_folder_name depth='2'/>


My existing folder structure which I tested is:
Code: Select all
<cms:template hidden='0' clonable='1' title='Industries Folders' >

    <cms:folder name='test-folder' title='First folder' >
        <cms:folder name='test-inner-folder1' title='Child folder one' />
        <cms:folder name='test-inner-folder2' title='Child folder two' />
        <cms:folder name='test-inner-folder3' title='Child folder three' />
        <cms:folder name='test-inner-folder4' title='Child folder four' />
        <cms:folder name='test-inner-folder5' title='Child folder five'>
            <cms:folder name='test-inner-folder51' title='Sub Child folder one' />
            <cms:folder name='test-inner-folder52' title='Sub Child folder two' />
            <cms:folder name='test-inner-folder53' title='Sub Child folder three' />
            <cms:folder name='test-inner-folder54' title='Sub Child folder four' />
        </cms:folder>
        <cms:folder name='test-inner-folder6' title='Child folder six' />
    </cms:folder>
    <cms:folder name='another-test-folder' title='Another folder without children' />
    <cms:folder name='test-folder2' title='Second folder with children' >
        <cms:folder name='test2-inner-folder1' title='Child folder one' />
        <cms:folder name='test2-inner-folder2' title='Child folder two' />
        <cms:folder name='test2-inner-folder3' title='Child folder three' />
        <cms:folder name='test2-inner-folder4' title='Child folder four' />
        <cms:folder name='test2-inner-folder5' title='Child folder five'>
            <cms:folder name='test2-inner-folder51' title='Sub Child folder one' />
            <cms:folder name='test2-inner-folder52' title='Sub Child folder two' />
            <cms:folder name='test2-inner-folder53' title='Sub Child folder three' />
            <cms:folder name='test2-inner-folder54' title='Sub Child folder four' />
        </cms:folder>
    </cms:folder>

</cms:template>



Following code worked fine, showing curent folder as top-folder with its children (if available). Parameter depth='2' made available two k_level variants: 0 (for current root) and 1 (for children). It could help tailor html for the footer.
Code: Select all
    <cms:folders masterpage=k_template_name root=k_folder_name hierarchical='1' depth='2'>

        <cms:dump />

    </cms:folders>


You may want to change root=k_folder_name from my test sample to root=current_folder_name to match your variable set before 'folders' tag.
Sorry, wasn't very clear description of what I'm trying to acheive.

I have industries.php template with pages organised in the following folder structure:

Industries
- Local Government
-- Tutorials
-- Testimonials
-Drones
-- Tutorials
-- Testimonials
-Mining
-- Tutorials
-- Testimonials

When on the Local Government folder, I'd like to list only descendants of Local Gov:

Local Government
- Resources (link to /local-government )
- Tutorials (link to /local-government/tutorials )
- Testimonials (link to /local-government/testimonials )

When on the Business folder, I'd like to list only descendants of Business:

Business
- Resources (link to /business )
- Tutorials (link to /business/tutorials )
- Testimonials (link to /business/testimonials )

and so on.

I have managed to achieve kind of achieve this, however, my current code (below) displays all folders that are descendants of industries.php, not folders that are descendants of the first child. so it's showing:

- Local Government
-- Tutorials
-- Testimonials
-Drones
-- Tutorials
-- Testimonials
-Mining
-- Tutorials
-- Testimonials

Image

on all folder views.

Code: Select all
<cms:if k_page_foldername>
  <cms:set current_folder_name=k_page_foldername /></cms:if>
<cms:if "<cms:is_ancestor parent=k_folder_name child=current_folder_name />">
  <cms:folders masterpage='industries.php' hierarchical='1' limit='1'>
    <cms:if k_level=='0'>
      <p class="footer-label text-md-left text-xs-center">
        <cms:show k_folder_title />
      </p>
      <p class="text-md-left text-xs-center" <cms:if k_folder_name=current_folder_name> style="color: rgba(255,255,255,.7);" </cms:if>>
    <cms:if k_folder_name=current_folder_name>&rarr; Resources
      <cms:else /><a href="<cms:show k_folder_link />">Resources</a></cms:if>
    </p>
    <cms:else />
    <p class="text-md-left text-xs-center" <cms:if k_folder_name=current_folder_name> style="color: rgba(255,255,255,.7);"</cms:if>>
<cms:if k_folder_name=current_folder_name>&rarr;
  <cms:show k_folder_title />
  <cms:else />
  <a href="<cms:show k_folder_link />">
    <cms:show k_folder_title />
  </a>
</cms:if>
</p>
</cms:if>
</cms:folders>
</cms:if>
</cms:if>


In my code, I'm using "Resources" as the link to the "root" folder, and the folder name for the title, purely for aesthetic reasons.

I tested your code, and it gives me only current and child folders, so when I'm in --Tutorials, it doesn't show ancestors.

Thanks for the tip on dump - I've been using it for debugging, but hadn't thought to place it within the folders loop
when I'm in --Tutorials, it doesn't show ancestors.

Before I dig into the coding, let's clarify the last bit - If you are in Tutorials or Testimonials - what should menu show?
trendoman wrote:
when I'm in --Tutorials, it doesn't show ancestors.

Before I dig into the coding, let's clarify the last bit - If you are in Tutorials or Testimonials - what should menu show?



If I'm in /local-government/ it should show:

Local Government
-> Resources
Tutorials
Testimonials

If I'm in /local-government/tutorials/ it should show:

Local Government
Resources
-> Tutorials
Testimonials

If I'm in /local-government/testimonials/ it should show:

Local Government
Resources
Tutorials
-> Testimonials


If I'm in /drones/ it should show:

Drones
-> Resources
Tutorials
Testimonials

Tutorials and Testimonials folders are created as children of each industry vertical: Local gov, Drones, Mining, etc

Like I said, I have it "working" by showing the folders I want, but it also shows the other vertical folders on top of industries.php

I guess I could code a bunch of if/else blocks that specify exact folders to show where, but I'm looking for a solution that is future proof -- so I don't have to manually update the footer code each time we create a new industry vertical.

Perhaps I'm attacking this from the wrong angle, but I can't get any other angle to work.

Appreciate the help!
erin wrote: ..so I don't have to manually update the footer code each time we create a new industry vertical.

Of course, it will be automated. One last question
"-> " before the folder name - means it should be highlighted somehow?
trendoman wrote:
erin wrote: ..so I don't have to manually update the footer code each time we create a new industry vertical.

Of course, it will be automated. One last question
"-> " before the folder name - means it should be highlighted somehow?


Yes, I'm using the following to indicate current folder

Code: Select all
<cms:if k_folder_name=current_folder_name>&rarr; <cms:show k_folder_title />
  <cms:else />
  <a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a>
</cms:if>


Image
Ok, here is a working tested code that shows what you want (how I understood it).
Top 'cms:pages' tag-pair enclosing the whole code can be removed, it was used for my tests. I think you need that code on page-view (in contrast to folder-view). If you need a folder-view also - let me know.

You need to change masterpage=k_template_name to masterpage='industries.php' everywhere in that code if you use this code outside of 'industries.php'.
Code: Select all


<!-- This is a page-view: -->
<cms:pages masterpage=k_template_name >

    <cms:if k_page_folderparentid eq '-1' >
    <!-- We are on page which is in a parent folder. Show folders from this root -->
        <h2><cms:show k_page_title /></h2>

        <cms:folders masterpage=k_template_name hierarchical='1' root=k_page_foldername >
            <cms:if k_level eq '0' >
                <p class="footer-label text-md-left text-xs-center">
                    <cms:show k_folder_title />
                </p>
                <p class="root_folder active" ><a href="<cms:show k_folder_link />" >Resources</a> - we are here</p>
            <cms:else />
                <p class="child_folder" ><a href="<cms:show k_folder_link />" ><cms:show k_folder_title /></a></p>
            </cms:if>
        </cms:folders>

    <cms:else />
    <!-- We are on page which is NOT in a parent folder and is in a child folder. Show folders starting from the ancestor  -->
        <h2><cms:show k_page_title /></h2>

        <!-- Find the ancestor of current folder -->
        <cms:set my_ancestor_folder = '' scope='global' />
        <cms:parentfolders folder=k_page_foldername >
            <cms:if k_folder_parentid eq '-1'>
                <cms:set my_ancestor_folder = k_folder_name scope='global' />
            </cms:if>
        </cms:parentfolders>

        <cms:folders masterpage=k_template_name hierarchical='1' root=my_ancestor_folder >
            <cms:if k_level eq '0' >
                <p class="footer-label text-md-left text-xs-center">
                    <cms:show k_folder_title />
                </p>
                <p class="root_folder" ><a href="<cms:show k_folder_link />" >Resources</a></p>
            <cms:else />
                <p class="child_folder <cms:if k_page_folderid eq k_folder_id >active</cms:if>" ><a href="<cms:show k_folder_link />" ><cms:show k_folder_title /></a><cms:if k_page_folderid eq k_folder_id > - we are here</cms:if></p>
            </cms:if>
        </cms:folders>


    </cms:if>

</cms:pages>


erin wrote: Yes, I'm using the following to indicate current folder

Oh, sorry - I saw this reply after I published the code. I assumed that extra text 'we are here' and 'active' class would help you locate the current folder of the page and mark it any way you like.
trendoman wrote: If you need a folder-view also - let me know.


Sorry, also to clarify, I'm showing these links of the footer of the folder view, specifically.

On a page, I'm getting the following using your code:

Image

and the same on the folder view, but with page titles of all pages in all folders
12 posts Page 1 of 2

Who is online

In total there are 4 users online :: 0 registered, 0 hidden and 4 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 4 guests

cron