Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
I working on a blog site and need some help with some Couch logic. Normally I would have a separate blog list page and not sure what to do since I am using the home page as the "blog list page" and pulling in the posts from the blog via <cms:pages masterpage='blog.php' limit='4' paginate='1'> tag:

I am using blog.php as the page post page and struggling to figure out how to accomplish listing blogs in folders using the <cms:if k_is_folder /> tag. Should I be wrapping the index page with that tag?

When I wrapped blog.php in the <cms:if k_is_page>.....<else /><cms:embed 'index.php'></cms:if> it broke all of the pages.

What is the best way to structure these two pages?
Hi,

Tell me, if someone clicks a link to a blog-folder, where would you want her to land? On blog.php or index.php?

If the answer is blog.php, then the answer is straightforward - use the regular logic given below in blog.php template -
Code: Select all
<cms:if k_is_folder>
    .. show list of pages in the folder here ..
</cms:if>

<cms:if k_is_page>
    .. your existing logic to show a single page here .
</cms:if>

If however you want to use the index.php to show pages filtered by the folders, things will get messy as now you'll have to pass the foldername/id manually to index.php's URL and then use it in the existing cms:pages loop there.

Can you please confirm which of the two options you are aiming at?
Thanks.
Hi KK,

Technically it would be the layout of index.php but I can create a separate page to embed if that will make it easier to accomplish.
Ok then you just place the <cms:if k_is_folder > check in blog.php and embed within it the same layout as you used in index.php. Make sure to set the 'folder' parameter of cms:pages loop -
<cms:pages folder=k_folder_name >

Hope it helps.
Hi KK,

Running into a bit of an issue. In blog.php I have this if tag right under the /template:

<cms:if k_is_page>
Page code, etc.

and then at the bottom of the page I have this:
<else />
<cms:if k_is_folder >
<cms:embed 'folder_list.php' />
</cms:if>

I created a page in my snippets folder for this page to be outputted and it is completely blank when I visit the folder link. I am assuming it is an issue with couch tags in a nested page?

Also not sure what to do with this tag: <cms:pages folder=k_folder_name >
Nesting of tags shouldn't be a problem but you can choose not to nest the statements if you wish -
Code: Select all
<cms:if k_is_page>
    .. your existing logic to show a single page here .
</cms:if>

<cms:if k_is_folder>
    <cms:embed 'folder_list.php' />
</cms:if>

Try the way given above as it should be easier for you (the k_is_folder block is totally independent of the k_is_page block).

In case of any difficulty, try to troubleshoot by outputting text at various locations e.g.
Code: Select all
<cms:if k_is_folder>
    <h1>Hello! This is folder-view</h1>
    <cms:embed 'folder_list.php' />
</cms:if>

If the text above shows up ok, move it into the 'folder_list.php' snippet etc. Standard debugging stuff.

Also not sure what to do with this tag: <cms:pages folder=k_folder_name >

The 'folder_list.php' snippet you are using will certainly have a cms:pages loop to list the pages. To constrain the listing to only the folder being visited, you need to add the folder=k_folder_name parameter to it.

Hope this helps.
Worked! Thanks for your help KK!
7 posts Page 1 of 1