Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
Hello, I am having a very tough time implementing this:
My index page has a link to the list of dynamic folders which is in the same root folder as the index page. My dynamics folders list pages links to each single folder view where I show the image and description of the current folder being viewed and This I have placed inside the snippets folder. How do I link each folder view to the list of pages that fall under each folder. I have being trying this for 3 days now with no success . Thanks in advance
Not sure if I could understand the problem correctly - listing pages belonging to a folder is staple stuff in 'folder-view' (http://docs.couchcms.com/concepts/listing-pages.html) e.g.
Code: Select all
<cms:if k_is_folder >
    <cms:pages folder=k_folder_name include_subfolders='1' >
        <!-- All the variables of each page in this folder are available here -->
    </cms:pages>
</cms:if>

As seen in the code above, we first test if we are in folder-view and them use <cms:pages> setting its 'folder' param to the name of the current folder being visited. This shows only the pages under that folder.

Is that what you were looking for?
If not, please elaborate and share the code you have been trying to use.
Sorry about the question confusing you: What I specifically want to achieve is this:
My folder view has a different design altogether and in this design I have only the description of the current folder using :
Code: Select all
<cms:show k_folder_desc/>
to output information about the folder and
Code: Select all
<cms:show k_folder_image />
to output the current folder's image and then finally a link which is supposed to take me to the list of pages but sorted for the current folder I am on.
So in my first question, mapping the path of the links will be like this: Index page----> List of folders page ------> Single folder page(Which has a different design so I embedded it using
Code: Select all
<cms:if k_is_folder><cms:embed 'single-folder-view' /></cms:if>
on the page view ) -----> List of pages but sorted for the folder the list of pages was visited from. I hope this makes it clearer
This topic is very similar to another recent question viewtopic.php?f=4&t=11418

The problem in question, if I understood correctly, is an extra step between (1) a specific front-end design to display information about a single folder - its image and description etc. and (2) specific front-end design for the list of pages that belong to the folder in question.

Do I understand it correctly at all? I guess you want to be able to select a folder (like a category), view info about it in design #1, then be able to click to reveal folder's pages on a page with a different design #2.
Yes trendoman exactly what I want but in this case design #2 is the list view of all pages but should be sorted for single view I am coming from
adimpressions wrote: but in this case design #2 is the list view of all pages but should be sorted for single view I am coming from

Sure, the list of all pages that belong to the previously-viewed folder. In case you meant 'filtered' by 'sorted' my suggestion is valid. Otherwise, please explain what do you want them to look like.

Finally, let's check the URLs. Visitor will view a "folder-description" page on regular URL of folder, for example site.com/my-folder/. What do you plan to be for the URL for the "list-view of pages of that folder" page?
I have the file for the single folder view in the snippet folder and I used this as the link in the single folder view page to access and sort the page list- view:
Code: Select all
<a href=‘<cms:add_querystring “<cms:link ‘list-view-page.php’ />” “f=<cms:show k_folder_name />” />’ >link to sorted pages list view</a>

but it kept sending me to the same single folder page I am on.
adimpressions wrote: but it kept sending me to the same single folder page I am on.

It happens because of 2 things: (1) 'list-view-page.php' is a template with dynamic folders and (2) "f" is couch-reserved parameter which tells the cms to go to folder-view. I think if you change that parameter to something else (not "p, f, d"), things should work fine.

Your template's structure might then look like this:
Code: Select all
<!-- Check if list of pages requested -->
<cms:set my_folder = "<cms:gpc 'pagesof' method='get' />" />

   
<cms:if my_folder  >
   
    <!-- Showing list of pages of some folder -->
   
   
    <cms:pages folder=my_folder >
        <!-- html -->
    </cms:pages>
   
<cms:else_if k_is_home />
    <!-- Show list of folders -->
<cms:else_if k_is_folder />   
    <!-- Show folder description -->
<cms:else_if k_is_page />
    <!-- Show one page -->
</cms:if>   


In the sample above, I used some arbitrary querystring parameter pagesof, which has no conflicts with CMS.
At first, code checks for presense of this parameter in URL, then allows all regular views to work, if parameter not present.

So, your links then look like this.
Code: Select all
<a href=‘<cms:add_querystring “<cms:link ‘list-view-page.php’ />” “pagesof=<cms:show k_folder_name />” />’ >link to sorted pages list view</a>


-----

Alternatively, you may have another URL. For example, have the usual URL for default folder-view mysite.com/my-folder/ (showing folder description) and URL for list of pages mysite.com/my-folder/?show_pages=yes. Then template's structure is changed to this.
Code: Select all
 
<cms:if k_is_home />
    <!-- Show list of folders -->
<cms:else_if k_is_folder />   

    <!-- Check if list of pages requested -->
    <cms:set show_pages = "<cms:gpc 'show_pages' method='get' />" />
    <cms:if show_pages eq 'yes' >
       
        <!-- Showing list of pages of this folder -->
       
       
        <cms:pages folder=k_folder_name >
            <!-- html -->
        </cms:pages>     
       
    <cms:else />
        <!-- Showing folder description -->
    </cms:if>

<cms:else_if k_is_page />
    <!-- Show one page -->
</cms:if>   


I personally prefer this structure, as it deals with folder-view only and doesn't require to pass folder name in parameters.
Therefore a sample link-building code:
Code: Select all
<h2>Links to each folder</h2>
<cms:folders masterpage='my-template-with-folders.php'>
    <a href=‘<cms:link ‘my-template-with-folders.php’ folder=k_folder_name />’ >link to description of folder: <cms:show k_folder_title /></a>
    <a href=‘<cms:add_querystring “<cms:link ‘my-template-with-folders.php’ folder=k_folder_name />” “show_pages=yes” />’ >link to sorted pages of folder: <cms:show k_folder_title /></a>
</cms:folders>


Btw, "cms:link" recognizes parameter folder, which really helps with getting pretty links right away.
Great solution trendoman. I used the second solution and It worked like magic however I encountered another problem: when I try to access the list of all the pages by visiting the clonable template in my browser it sends me to the list of folders instead of the list of all the pages unsorted. What could be the problem
12 posts Page 1 of 2
cron