Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
I have a site that is a one page site. So on the index page I am using code like this to embed the couch content
Code: Select all
<!-- About Page -->
    <div id="about-us" class="page">
      <cms:pages masterpage='about-content.php'>                           
         <cms:show about_content />            
      </cms:pages>      
    </div>



the problem I have is that I want to do the same with the blog, but using the blog as per the tutorial this causes a problem.

I am calling the blog masterpage from the index like so
Code: Select all
<!-- Blog Page -->
   <div id="blog" class="page">
        <div class="container-fluid innerPage">
         <div class="col-sm-10 col-sm-offset-1">
            <!-- Page Heading -->
            <div class="row">
               <div class="col-lg-12">
                  <h6 class="page-header">Our Blog</h6>                  
               </div>
            </div><!-- /.row -->
   
            <!-- Blog Content -->
            <div class="row">
               <cms:pages masterpage='blog.php'>                           

               </cms:pages>   

               
            </div><!-- /.row -->
            <hr>
         </div>
      </div>
    </div>   


and then the blog page is calling the snippet blog-list like so
Code: Select all
<?php require_once( 'cms/cms.php' ); ?>
<cms:template title='Blog' clonable='1' commentable='1' order='1'>
   <cms:editable
       name='blog_title'
       label='Blog Title'
        desc='Enter blog title here'
       type='text' />
   <cms:editable
       name='blog_image'
       label='Blog Image'
        desc='Upload your blog image here(330px x 250px)'       
       width='330'
       height='250'       
       type='image'
     />       
   <cms:editable
       name='blog_text'
       label='Blog Text'
        desc='Enter blog text here'
       type='richtext' />    
</cms:template>

<!-- blog Section -->
<cms:if k_is_page>      
         <!-- Blog Content -->
         <div class="row">
            <section class="content-section">
               <div class="container-fluid" id="bgWhite">
                  <div class="container">
                     <div class="row blogListitem">
                        <div class="col-sm-8 col-sm-offset-2 text-center">                  
                           <div class="col-sm-6 col-sm-offset-3"><img src="<cms:show blog_image />" class="img-responsive center-block" title="<cms:show blog_title />" alt="<cms:show blog_title />"/></div>
                           <div class="col-sm-12">
                           <br/>
                              <h1><cms:show blog_title /></h1>
                              <cms:show blog_text />
                              <br/><br/>
                              <a href="#blog" class='btn btn-lg btn-success'>&laquo; return to blog feed</a>
                           </div><!-- /col-->                  
                        </div><!-- /col-->                 
                     </div><!-- /row-->
                     <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">      
                           <h3>Comments</h3>
                           <hr/>                     
                           <cms:if k_comments_count >
                              <ol class="commentlist">
                                 <cms:comments page_id=k_page_id order='asc' limit='5' paginate='1' limit='10'>
                                    <li class="comment">
                                       <div class="gravatar">
                                          <cms:gravatar email="<cms:show k_comment_author_email />" size="60" />
                                          <a name="<cms:show k_comment_anchor />">
                                       </div>
                                       <div class="comment_content">
                                          <div class="clearfix">
                                             <cite class="author_name"><a href=""><cms:show k_comment_author /></a></cite>       
                                             <div class="comment-meta commentmetadata"><cms:date k_comment_date format='F j, Y'/> at <cms:date k_comment_date format='h:ia'/></a></div>
                                          </div>
                                          <div class="comment_text">
                                             <p><cms:show k_comment /></p>
                                          </div>
                                       </div>
                                       <hr/>
                                    </li>
                                 <cms:paginator />
                                 </cms:comments>
                              </ol>
                           <cms:else />
                              No comments.<br/>
                              <hr/>
                           </cms:if>                              
                        </div><!-- /col-->
                     </div><!-- /row-->
                     <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">   
                           <cms:embed 'comments_form.html'/>
                        </div><!-- /col-->
                     </div><!-- /row-->
                  </div><!-- /container-->
               </div><!-- /container-->
               <div class="drop-shadow-white curved curved-hz-2"></div><!---drop shadow-->
            </section>               
         
<cms:else/>   
   <cms:embed 'blog-list.php' />
</cms:if>   


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


nothing is showing up is there an easy way of embedding the blog masterpage within the index page?

thanks for any help
Your code is perfectly fine, Barry. It seems you are just confused with the usage of blog_list.html snippet.

On the index.php you don't need to call blog_list.html. Try this -
Add the highlighted line below to your existing code in index.php
..
<!-- Blog Content -->
<div class="row">
<cms:pages masterpage='blog.php'>
<h4><a href="<cms:show k_page_link />"><cms:show k_page_title /></a></h4>
</cms:pages>


</div><!-- /.row -->
..

You'll see that you can list all blog posts right there without the need to use blog_list.html.

Point is, the spot where we placed the line (i.e. between the tag pair of cms:pages) you can access all the data of your blog pages. Put there any HTML you want to display the posts as you like.

Hope this helps.
So I am to use the code that i have in the blog list inside the the masterpage call on the index page?

sorry a little confused

I want the blog list and then the blog article to appear within the index page and not to gom off to a separate page
So I am to use the code that i have in the blog list inside the the masterpage call on the index page?
You are free to use whatever HTML code you want. If the one in blog_list suits you, by all means use it.

I want the blog list and then the blog article to appear within the index page and not to gom off to a separate page
The code I posted above was meant as an example.
Don't use <a href="<cms:show k_page_link />">..</a> and there would be no link to any external page.

Output all the data right there e.g.
Code: Select all
<cms:pages masterpage='blog.php'> 
        <!-- Post Title -->
        <h3><cms:show k_page_title /></h3>
       
        <!-- Post Data -->
        <!-- Post Image -->
        <img src="<cms:show blog_image />" />
       
        <!-- Post Content -->
        <cms:show blog_content />

        <hr />
</cms:pages>

Format as you wish.

Does this make things any clearer?
sorry, yes I understand what you are saying, I just worded my response incorrectly.

I have the content from the list in the call for the masterpage on the index page now, but when i click on a read more link with the link as <cms:show k_page_link /> the k_page_link links to the actual blog page and so the link goes away from the index page and loads the blog page. What I am trying to achieve is for the full blog that has been called from the list via the link to load within the index page also.

Is this possible with couch?

thanks for your input
What I am trying to achieve is for the full blog that has been called from the list via the link to load within the index page also.
If you could please try out using the following code I posted earlier, you'll see that it shows the *entire* blog post on the index page. It has *no* link that leads anywhere -
Code: Select all
<cms:pages masterpage='blog.php'> 
        <!-- Post Title -->
        <h3><cms:show k_page_title /></h3>
       
        <!-- Post Data -->
        <!-- Post Image -->
        <img src="<cms:show blog_image />" />
       
        <!-- Post Content -->
        <cms:show blog_content />

        <hr />
</cms:pages>
Code: Select all
<cms:pages masterpage='blog.php'>
        <!-- Post Title -->
        <h3><cms:show k_page_title /></h3>
       
        <!-- Post Data -->
        <!-- Post Image -->
        <img src="<cms:show blog_image />" />
       
        <!-- Post Content -->
        <cms:show blog_content />

        <hr />
</cms:pages>

this will mean that all content of each blog entry would be listed from the off on the index page. I was looking for a solution where a snippet of each blog item could be listed and then a 'read more' link that would load up the full content of the selected blog on click, whilst staying within the index page

I suppose I could create this via jQuery, hiding the full content of each blog and then showing it on the 'read more' click, but that would mean loading every blog item on the initial page load of index.php and as time passes the page load times would become greater and greater.
I suppose I could create this via jQuery, hiding the full content of each blog and then showing it on the 'read more' click, but that would mean loading every blog item on the initial page load of index.php and as time passes the page load times would become greater and greater
One way could be to load the posts via AJAX.
You might find the following related thread useful - "Load more posts with AJAX" (viewtopic.php?f=8&t=8440).
this is what I have created to solve this(didnt think it warranted ajax as each post is only an image a title and some text and it only the text that I am showing as a snippet)

Code: Select all
<cms:pages masterpage='blog.php'>   
                                 
    <img src="<cms:show blog_image />" class="img-responsive center-block" title="<cms:show blog_title />" alt="<cms:show blog_title />"/>

    <h1><cms:show blog_title /></h1>
                                 
   <span class="text-justify blogSnippet" id="blogSnippet<cms:show k_page_id/>"><cms:excerptHTML count='125' ignore='image'><cms:show blog_text /></cms:excerptHTML></span>

   <span class="text-justify blogFull" id="blogFull<cms:show k_page_id/>"><cms:show blog_text /></span>

    <button class='btn btn-lg btn-success blogButton' id="blogButton<cms:show k_page_id/>" onclick="openBlog(<cms:show k_page_id/>);">Read More</button>   

</cms:pages>   


and then in Jquery
Code: Select all
$(document).ready(function () {
$(".blogFull").hide();
function openBlog(blogid){
         $(".blogSnippet").show();
         $(".blogFull").hide();
         $(".blogButton").show();
         $('#blogSnippet'+blogid).hide();
         $('#blogFull'+blogid).show();
         $('#blogButton'+blogid).hide();
      }
});
That seems to be a perfectly fine solution :)
10 posts Page 1 of 1
cron