Forum for discussing general topics related to Couch.
8 posts Page 1 of 1
First off I want to thank the CouchCMS team for making this amazing product. I've been playing with CouchCMS for about a year now and it has by far been my go to CMS for creating websites. I've been able to get most of my issues resolved by simply reading through the documentation, forums and looking at examples but I've come up to a wall that I need some assistance with.

To give some context, what I'm trying to do is build a very simple message board or forum system. After reading through the Advanced Tutorial and the Extended Entities posts I think I've come up with a way to do it utilizing some of the more advanced features of CouchCMS. One of those is combining the <cms:route /> tag with <cms:smart_embed />. However, since Routes requires us to ignore the View context (with K_IGNORE_CONTEXT), the Smart Embed tag doesn't seem to be picking up what it should be displaying. This is what I'm currently working with (this is my forums.php template):

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>

   <cms:template title='Forums' clonable='1' routable='1' dynamic_folders='1'>

      <cms:route name='list_view' path='' />

      <cms:route name='folder_view' path='{:id}/category' />

      <cms:route name='page_view' path='post' />

   </cms:template>

   <cms:match_route debug='0' />

   <cms:smart_embed 'header' />
   <cms:smart_embed 'sidebar' />
   <cms:smart_embed 'content' />
   <cms:smart_embed 'footer' />

<?php COUCH::invoke( K_IGNORE_CONTEXT ); ?>


In my content folder I have a forums-list.inc and forums-folder.inc. Appending /category to my domain doesn't seem to pick up the new view though. It just acts as it's still in list view. Any help would be appreciated!
Hi :)

As you have correctly figured out, routes turn off the canonical views (e.g. list-view, page-view etc.) that cms:smart_embed depends upon. This makes them mutually incompatible.

I am sorry but you'll have to fall back on using explicit conditionals (e.g. <cms:if k_is_page> etc.) to make things work instead of using cms:smart_embed.
That's kind of what I figured, just wanted to make sure I wasn't missing something.

So going that route then, my plan is to layout the hierarchy of the posts in this manner:

Main Page (Displays Forums which will be a list of folders)
Forum Page (Displays Topics which will be a list of sub-folders)
Post Page (Displays Posts which will be a list of pages belonging to a sub-folder)

Utilizing a Data Bound Form, users with sufficient privileges will be allowed to create a post (or page) in the currently viewed Topic (or sub-folder). With that said, how would one utilize the <cms:if k_is_folder> on the Forum template to list out the sub-folders of the currently viewed parent folder. I'd imagine it would go something like below, but I don't know that we have a way to check if View is a Sub-folder View or if we'd have to write conditional statements within the snippet controlling the Folder View to distinguish between the two. If that's the case, I need a little help understanding how that'd work.

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>

   <cms:template title='Forums' clonable='1' routable='1' dynamic_folders='1'>

      <cms:route name='list_view' path='' />

      <cms:route name='folder_view' path='{:id}/category' />

      <cms:route name='page_view' path='{:id}/post' />

   </cms:template>

   <cms:match_route debug='0' />

   <cms:embed 'header/default.inc' />
   <cms:embed 'sidebar/forums-default.inc' />
   <cms:if k_is_page>
      <cms:embed 'content/forums-post.inc' />
   </cms:if>
   <cms:if k_is_folder>
      <cms:if k_is_subfolder> <!-- Does this tag or function exist? -->
         <cms:embed 'content/forums-list.inc' />
      <cms:else />
         <cms:embed 'content/forums-default.inc' />
      </cms:if>
   </cms:if>
   <cms:embed 'footer/default.inc' />

<?php COUCH::invoke( K_IGNORE_CONTEXT ); ?>
If the above doesn't work, the other option I worked out would look like the code below. However, I'm still unsure on what would go in place of <cms:if sub_folder>.

Code: Select all
<cms:if k_folder_name><cms:set current_folder=k_folder_name /></cms:if>

<div class="col-md-9">
   <div class="panel panel-default">
      <div class="panel-heading">
         <cms:if sub_folder>
            <h2 class="panel-title">Forums &gt; <cms:show current_folder></a></h2>
         <cms:else />
            <h2 class="panel-title">Forums</a></h2>
         </cms:if>
      </div>
      <table class="table table-striped">      
         <thead>
            <cms:if sub_folder>
               <tr>
                  <th>Topics</th>
                  <th>Replies</th>
                  <th>Views</th>
                  <th>Last Post</th>
               </tr>
            <cms:else />
               <tr>
                  <th>Forum</th>
                  <th>Topics</th>
                  <th>Posts</th>
                  <th>Last Post</th>
               </tr>
            </cms:if>
         </thead>
         <tbody>
            <cms:if sub_folder>
               <cms:folders masterpage='forums.php' parent=current_folder>
                  <tr>
                     <td><cms:show k_folder_title /></td>
                     <td>99</td>
                     <td>99</td>
                     <td>Last post by Username<br />12/12/9999 at 10:10am</td>
                  </tr>
               </cms:folders>
            <cms:else />
               <cms:folders masterpage='forums.php'>
                  <tr>
                     <td>
                        <a href="<cms:show k_folder_link />">
                           <span class="forum-cat-title"><cms:show k_folder_title /></span><br />
                           <span class="forum-cat-desc"><cms:show k_folder_desc /></span>
                        </a>
                     </td>
                     <td><cms:pages folder=k_folder_name><cms:show k_count /></cms:pages></td>
                     <td>99</td>
                     <td>Last post by Username<br />12/12/9999 at 10:10am</td>
                  </tr>
               </cms:folders>
            </cms:if>
         </tbody>
      </table>         
   </div>
</div>
I think it would require a separate route to distinguish between folder and subfolder views. I barely took a snap view on your post, so take my suggestion lightly.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I believe you're right. After going back over the Advanced Tutorial and Routes documentation I believe I found a solution that works. I'm going to split this project off from the current site I'm working on into a stand alone site so I can develop all the forum features without any outside code influences then I'll go from there. Once I get done I'll post up a preview.
Sn3aKyGuY wrote: I believe you're right. After going back over the Advanced Tutorial and Routes documentation I believe I found a solution that works. I'm going to split this project off from the current site I'm working on into a stand alone site so I can develop all the forum features without any outside code influences then I'll go from there. Once I get done I'll post up a preview.


I don't know what your actual routes look like in real life, but probably it is possible to detect any subs in folder route, since any subs would look like "main-folder/sub-folder". So if you can write a simple regex to split the route value into "word-slash-whatever else", then whatever-else( if exists ) would statute your sub-folder. This is a way to avoid creating a new route.

Is this forum thing going to be small or big, feature-wise? Interesting :) I could offer my advice on the matter in skype whenever you need one( free ). Btw, did you consider using relations instead of folders and if yes, what were the reasons to choose 'folder-approach'?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
This project is for a group of players that play World of Warcraft. They just need the ability to have simple topic based conversations, so I don't have plans (at this time) for a lot of features. Once I get the core of the system worked out I may take it further at a later date.

As far as using folders, the initial plan was to go that route for ease of using smart_embed with folder_view. However, since that doesn't really apply at this point, I'm going to take the direction that the Notejam project did and make cloneable pages for Topics, Sub-Topics and Posts. Of course that will require a lot more work on the authentication and visibility side, but I think it will make adding additional features (like private messaging) easier down the road. And maybe any work I do here can inspire the CouchCMS team to build something more custom tailored to the back end.
8 posts Page 1 of 1