Problems, need help? Have a tip or advice? Post it here.
17 posts Page 1 of 2
First of all, a big compliment for creating a great system with a fantastic documentation. As a front-end developer, I found CouchCMS a couple of days ago and I am impressed with the intuitive way you can dynamicallly implement any design. Reminds me a bit of ProcessWire (https://processwire.com/)...

I followed the official tutorial and encountered a problem when trying to dynamically set the links for the different category folders of the blog, in which the post entries are placed. For example in blog.php, which displays a single post entry I use the following:

Code: Select all
<div class="post">

            <!-- Post Title -->
            <h3 class="title"><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></h3>

            <!-- Post Title -->
            <cms:if k_page_foldertitle >
               <cms:set my_category=k_page_foldertitle />
            <cms:else />
               <cms:set my_category='Uncategorized' />
            </cms:if>

            <p class="sub">
               <a href="<cms:link masterpage='blog.php' folder=k_folder_link />"><cms:show my_category /></a> &bull; <cms:date k_page_date format='jS M, y' />
            </p>
            <div class="hr dotted clearfix">&nbsp;</div>

            <!-- Post Title -->
            <img class="thumb" src="<cms:show blog_image />" alt=""/>

            <!-- Post Content -->
            <cms:show blog_content />

            <!-- Post Links -->
            <p class="clearfix">
               <a href="<cms:link masterpage='blog.php' />" class="button float" >&lt;&lt; Back to Blog</a>
            </p>

         </div>
         <div class="hr clearfix">&nbsp;</div>


This will correctly set the category folder (<cms:show my_category />), but it won't show the correct link (<cms:link masterpage='blog.php' folder=k_folder_link />). The link will always redirect to blog.php, instead of using the correct category prefix (e.g., blog.php?f=5).
I have the same problem in the view-list, in this case blog_list.html.

Would appreciate your advise how to set the links correctly.
Hello and welcome JD,
I'm glad you liked Couch :)

Apropos the problem you mentioned -
I think the following should work
Code: Select all
<cms:link masterpage='blog.php' folder=k_page_foldername />

TIP: A handy way of knowing which variables are available for use at any particular place is placing a <cms:dump /> or <cms:dump_all /> tag at that place. You'd have easily identified the variable to use.

Hope this helps.
That solved it. Thanks.

I am just a bit confused because to display the categories in the sidebar (which is a snippet that gets pulled in),
I could directly use k_page_link:

Code: Select all
<cms:if k_is_page >
   <h4>Latest News</h4>
      <ul class="sidebar">
         <cms:pages masterpage='blog.php' limit='3'>
         <li><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></li>
         </cms:pages>
      </ul>
</cms:if>


I assume you always have to differentiate carefully between the different variable categories for the current view?!

http://www.couchcms.com/docs/concepts/v ... views.html
I am just a bit confused because to display the categories in the sidebar (which is a snippet that gets pulled in),
I could directly use k_page_link:
I'll try to explain -
Different variables get available in different contexts e.g. in the example you quoted, the <cms:pages> block makes available the variable 'k_page_link' containing the full URL of each page that it lists.

Similarly, if somewhere you happen to use <cms:folders> loop, within it you'll find 'k_folder_link' for each folder that is listed.

In a page-view (i.e. when you are visiting a single page) the k_page_link gets available automatically for the single page being visited and similarly k_folder_link gets available for the single folder being visited in a folder-view.

Now the important point that seemed to be confusing you -
if the link variable you are looking for is not available in a particular context, you can explicitly craft one by using the <cms:link /> tag. For example, in the code we used -
Code: Select all
<cms:link masterpage='blog.php' folder=k_page_foldername />
- we supplied the the folder 'name' (and its template) and got back a full link.

That is why I suggested the use of <cms:dump /> or <cms:dump_all /> to take a look first-hand as to which variables are available.

Incidentally, in our particular case, we needn't have used cms:link to explicitly craft the folder link at all - the cms:pages tag, as it loops through the pages, makes available info about each page's containing folder also e.g. you have already used 'k_page_foldertitle' and 'k_page_foldername'. It also sets a variable named 'k_page_folderlink' that contains the full link to the containing folder.

So we could have simply used
Code: Select all
<cms:show k_page_folderlink />

and that would have been the equivalent of
Code: Select all
<cms:link masterpage='blog.php' folder=k_page_foldername />

Hope I was able to clear up the confusion a little.

Thanks :)
Great explanation. Thanks a lot ! :)
I was having the same problem as the OP, still have it in fact :)

I've tried both:
Code: Select all
<a href="<cms:show k_page_folderlink />"><cms:show my_category /> </a>

<a href="<cms:link masterpage='blog.php' folder=k_page_foldername />"><cms:show my_category /> </a>
   


They both prepend the f=1 to the post links. I only have one category(Adventure) and the other posts are uncategorized.

When clicking on the link that has f=1, it just opens all posts, regardless of category.

Any tips?

Here is the full code for that part.

Code: Select all
       <cms:pages masterpage="blog.php" folder="k_folder_name" paginate="1" limit="3">
              <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
              <div class="blog-post-wrap">
                  <span class="blog-date"><cms:date k_page_date format="jS M, Y" /></span>
                 <div class="blog-list-image-wrap">
                  <a href="<cms:show k_page_link />"><span>View <span>Article</span></span></a>
                  <img class="blog-list-image" src="<cms:show blog_list_image />">
                  </div>
                  <div class="blog-post-body">
                  <div class="blog-post-title-wrap">
                      <a class="blog-post-title-link" href="<cms:show k_page_link />"><h1 class="blog-post-title"><cms:show k_page_title /></h1></a>
                      </div>
                      <p class="blog-post-category"><span>Posted in</span>
                            <cms:if k_page_foldertitle >
                     <cms:set my_category = k_page_foldertitle />
                        <cms:else />
                        <cms:set my_category = "Uncategorised" />
                    </cms:if>
                <a href="<cms:link masterpage='blog.php' folder=k_page_foldername />" style="cursor:pointer;"><cms:show my_category /> </a>
                      </p>
                      <div class="blog-post-content">
                      <cms:excerptHTML count="75" ignore="img"><cms:show blog_content /></cms:excerptHTML>
                      </div>
                      <a class="read-more" href="<cms:show k_page_link />">Read Article</a>
                  <div class="pagination-wrap">
                 <cms:if k_paginated_bottom >
             <div class="col-xs-6">
                 <cms:if k_paginate_link_next >
          <a class="paginate-posts prev" href="<cms:show k_paginate_link_next />"><span>&larr;</span> Older posts</a>
                     </cms:if>
         </div>
         <div class="col-xs-6">
             <cms:if k_paginate_link_prev>
         <a class="paginate-posts next" href="<cms:show k_paginate_link_prev />">Newer posts <span>&rarr;</span></a>
                 </cms:if>
         </div>
         </cms:if>
                      </div>
                  </div>
                  </div>
              </div>
              </cms:pages>
@madebym
The problem lies in how you are setting the highlighted parameter below -
<cms:pages masterpage="blog.php" folder="k_folder_name" paginate="1" limit="3">

You are making Couch search for a folder literally named 'k_folder_name'.
The correct code would be -
Code: Select all
<cms:pages masterpage="blog.php" folder="<cms:show k_folder_name />" paginate="1" limit="3">

or simply
Code: Select all
<cms:pages masterpage="blog.php" folder=k_folder_name paginate="1" limit="3">

Hope it helps.
Hi KK,

The first line you provided did the trick :)

Although I am a bit confused with the part after "or simply", it is the same as my piece of code !! :)


Thanks
the part after "or simply", it is the same as my piece of code !!
Take a look again, @madebym :)
<cms:pages masterpage="blog.php" folder="k_folder_name" paginate="1" limit="3">
<cms:pages masterpage="blog.php" folder=k_folder_name paginate="1" limit="3">

Spot the difference?
Yes, I spot the difference now !! Thanks KK :)
17 posts Page 1 of 2