Forum for discussing general topics related to Couch.
14 posts Page 1 of 2
I've been struggling with this for a few days now...

I'm creating a website for a real estate company, using couch (as descibed here before).
I have (dynamic) folders to keep certain projects in a Region together and a cloneable template with further data and custom fields for the project itself.

eg.:
- Region1:
--Region1Project1
--Region1Project2
-Region2:
--Region2Project1
-Region3:
--Region3Project1
--Region3Project2
--Region3Project3
--Region3Project4
--Region3Project5
...


I want to create a list-view which handles the name and image of the Region and the underlying Projects.

Meaning: Region1 - Region1Project1 - Region1Project2 - Region2 - Region2Project1 - Region2Project2 ...

In best case the output would be something like:
<div class="row">
<div class="region">Region1</div>
<div class="project">Region1Project1</div>
<div class="project">Region1Project2</div>
<div class="region">Region2</div>
</div>
<div class="row">
<div class="project">Region2Project1</div>
<div class="project">Region2Project2</div>
<div class="region">Region3</div>
<div class="project">Region3Project1</div>
</div>
...


The Regions (eg. Region1, Region2,...) should have different content between the <div> tags...
I've tried several things but without good result. One of the problems is, the <div class="row"> that need to be closed after 4 times an underlying <div> that can be coming out of a "folder" or a "page" (meaning:dynamic). Further if a row doesn't contain 4 times a <div> , it will need to be closed with something like <div class="">&nbsp;</div> (to keep the grid working correctly).


Any advice for attempts are really appreciated.
I'm struggling with my code combining <cms:folders><cms:pages></cms:pages></cms:folders>
Thanks in advance...

info tags: pages
info tags: folders
I have doubts this is what you are actually looking for, but it will make sure each row div has 4 child divs:
Code: Select all
<cms:set count='0' scope='global'/>

<cms:folders>
    <cms:if "<cms:not count/>">
        <div class="row">
    </cms:if>

    <div class="region"><cms:show k_folder_title/></div>

    <cms:set count="<cms:add count '1'/>" scope='global'/>

    <cms:pages folder=k_folder_name>
        <cms:if "<cms:not count/>">
            <div class="row">
        </cms:if>

        <div class="project"><cms:show k_page_title/></div>

        <cms:set count="<cms:add count '1'/>" scope='global'/>

        <cms:if count == '4'>
            <cms:set count='0' scope='global'/>

            </div>
        </cms:if>
    </cms:pages>

    <cms:if count == '4'>
        <cms:set count='0' scope='global'/>

        </div>
    </cms:if>
</cms:folders>

<cms:if count>
    <cms:repeat count="<cms:sub '4' count/>">
        <div class="spacer">&nbsp;</div>
    </cms:repeat>

    </div>
</cms:if>
If this is not what you want, then please provide more information and examples of how the HTML markup should look like.
Hi cheesyproof and thanks for the prompt feedback (I'll test your code).

The thing I want to recreate is the following (referring to the image beneath):
Images with the orange backgrounds are folders, after that the pages for that folder and then again the next folder with its pages and so forth...

Obviously you don't know in advance the amount of pages of that folder nor the folders.
Clicking on the description of the project will trigger the page view.
As you can see, the content in the <div> tag of a "folder" will be different from the content of a "page".

Hope it clarifies my problem a bit more...

Image
@divian, I think cheesypoof's code does exactly that.
Ok, I've tried several things but I still have some trouble in getting it to work correctly.
It seems like the part where there should be 4x <div> in a row is ignored, as well as the part where a new row should be created.

On the visual, bold lines are folder-data, nonBold ones are page-data.
Any help is appreciated...

OUTPUT:
Image
VISUAL:
Image
CODE:
Code: Select all
<!-- START IF -->   
                  <cms:set count='0' scope='global'/>

                  <cms:folders childof='aan-de-kust'>
                      <cms:if "<cms:not count/>">
                          <div class="row residenties linkResidentie">
                      </cms:if>
                  
                      <div class="col-md-3"><b><cms:show k_folder_title/></b></div>
                  
                      <cms:set count="<cms:add count '1'/>" scope='global'/>
                  
                      <cms:pages folder=k_folder_name>
                          <cms:if "<cms:not count/>">
                              <div class="row residenties linkResidentie">
                          </cms:if>
                  
                          <div class="col-md-3"><cms:show k_page_title/></div>
                  
                          <cms:set count="<cms:add count '1'/>" scope='global'/>
                  
                          <cms:if count == '4'>
                              <cms:set count='0' scope='global'/>
                  
                              </div>
                          </cms:if>
                         
                      </cms:pages>
                  
                      <cms:if count == '4'>
                          <cms:set count='0' scope='global'/>
                  
                          </div>
                      </cms:if>
                  </cms:folders>
                  
                  <cms:if count>
                      <cms:repeat count="<cms:sub '4' count/>">
                          <div class="spacer">&nbsp;</div>
                      </cms:repeat>
                  
                      </div>
                  </cms:if>
                  <!-- FINAL IF -->
If I use it without childof='aan-de-kust' on the folders tag, it seems to work at some point and then breaks once again...

OUTPUT:
Image
VISUAL:
Image
CODE:
Code: Select all
<!-- START IF -->   
                  <cms:set count='0' scope='global'/>

                  <cms:folders >
                      <cms:if "<cms:not count/>">
                          <div class="row residenties linkResidentie">
                      </cms:if>
                  
                      <div class="col-md-3"><b><cms:show k_folder_title/></b></div>
                  
                      <cms:set count="<cms:add count '1'/>" scope='global'/>
                  
                      <cms:pages folder=k_folder_name>
                          <cms:if "<cms:not count/>">
                              <div class="row residenties linkResidentie">
                          </cms:if>
                  
                          <div class="col-md-3"><cms:show k_page_title/></div>
                  
                          <cms:set count="<cms:add count '1'/>" scope='global'/>
                  
                          <cms:if count == '4'>
                              <cms:set count='0' scope='global'/>
                  
                              </div>
                          </cms:if>
                         
                      </cms:pages>
                  
                      <cms:if count == '4'>
                          <cms:set count='0' scope='global'/>
                  
                          </div>
                      </cms:if>
                  </cms:folders>
                  
                  <cms:if count>
                      <cms:repeat count="<cms:sub '4' count/>">
                          <div class="spacer">&nbsp;</div>
                      </cms:repeat>
                  
                      </div>
                  </cms:if>
                  <!-- FINAL IF -->
Ok, the code had a logical error.
Please try this modified version -
Code: Select all
<cms:set count='0' scope='global'/>

<cms:folders>
    <cms:if "<cms:not count/>">
        <div class="row residenties linkResidentie">
    </cms:if>

    <div class="col-md-3"><b><cms:show k_folder_title/></b></div>

    <cms:set count="<cms:add count '1'/>" scope='global'/>
    <cms:if count == '4'>
        <cms:set count='0' scope='global'/>

        </div>
    </cms:if>
   
    <cms:pages folder=k_folder_name>
        <cms:if "<cms:not count/>">
            <div class="row residenties linkResidentie">
        </cms:if>

        <div class="col-md-3"><cms:show k_page_title/></div>

        <cms:set count="<cms:add count '1'/>" scope='global'/>
        <cms:if count == '4'>
            <cms:set count='0' scope='global'/>

            </div>
        </cms:if>
    </cms:pages>

   
</cms:folders>

<cms:if count>
    <cms:repeat count="<cms:sub '4' count/>">
        <div class="spacer">&nbsp;</div>
    </cms:repeat>

    </div>
</cms:if>

Does this help?
Seems to cover the example perfectly!
Thank you very much KK, will work further on this!
Is there a possibility to have 2 different list-views for certain folder-lists, based upon what was selected from the menu in the same template?

I have something like this in the menu:

PROJECTS (menu containing deeper links)
-Aan de kust (dynamic folder)
-- all projects (static in menu, lists all projects in "aan de kust")
-- De panne (dynamic folder, containing several pages)
-- Koksijde (dynamic folder, containing several pages)
-- Nieuwpoort (dynamic folder, containing several pages)
-- Oostende (dynamic folder, containing several pages)
-Binnenland
-- all projects (static in menu, lists all projects in "binnenland")
-- Antwerpen (dynamic folder, containing several pages)
-- Brugge (dynamic folder, containing several pages)

If I want to list the seperate folders; eg. Koksijde, Antwerpen,... all goes exactly how it should be, even with pages. (using <cms:if k_is_folder>...<cms:else />...</cms:if> to check list-view or page-view)

My problem contains in addressing the static parts which differs all projects from "aan de kust" and all projects from "binnenland".

Basically I need this: <cms:folders childof="aan-de-kust"> or this <cms:folders childof="binnenland">
based upon what has been clicked on, but don't seem to find how to...

Code: Select all
                                 <li><a tabindex="-1" href="projecten.php">Alle projecten</a></li>
                                 <cms:folders masterpage='nl/projecten.php' childof='aan-de-kust'>
                                    <li><a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a></li>                           


Am I obliged to use "all projects" as an extra folder and address it from there on?
eg.

aan de kust
- all projects
-- De Panne
-- Koksijde...

binnenland
- all projects
-- Antwerpen
-- Brugge

and then perhaps use "childof"- and "root" parameter combined in the above folder-tag-loop mentioned previously?
Thanks in advance...
OK so now we are dealing with nested folders, right?
Code: Select all
-Aan de kust (folder)
---De panne  (sub-folder)
---Koksijde    (sub-folder)
-Binnenland (folder)
---Antwerpen (sub-folder)
---Brugge      (sub-folder)

Once again, can you please post some mock images as to what should display when someone visits
1. Root (i.e. project's home page which is the parent of 'Aan de kust' and 'Binnenland')
2. 'Aan de kust' or 'Binnenland' (top-level folders)
3. 'De panne' (sub-folders)

Also, can you please post in your current code?

Thanks.
14 posts Page 1 of 2
cron