Problems, need help? Have a tip or advice? Post it here.
16 posts Page 1 of 2
Hi there!

I'm building an Audi fan site where i want the front page (http://webtest.stikzdesigns.com/index.php) to show the most recent post. As you can see at the middle of the website, i've assigned 2 editable boxes. One is the box where the news comes in, and the box next to it is the archive box.

Now i've got the Archive function to work properly, but because i've used the index.php as a clonable page, webtest.stikzdesigns.com will show up without having any content at all.

I understand that its clean because it is a clonable page, but i want to know if there is a possibility to show the newest post (i.e. as shown in the archive: This is my forth post) on visiting the first page of my website.

Thanks in advance!

(excuse my bad english, im dutch :P )

SOLUTION:
After some messages back and forth, these kind guys helped me out on finding a solution.

step 1:

Code: Select all
<cms:template title='Index' clonable='1'>
    ...editable regions defined here...
</cms:template>


So, add the regions where you've used the <cms:editable ... /> tag between the template tag, like this:

Code: Select all
<cms:template clonable='1' title='index' > 
   <cms:editable name='box_top_left' />
   <cms:editable name='bottom_box' />
   </cms:template>


step 2:

Make a new document named: page_detail.html inside the couch/snippit folder, which can look like this:
/subdomains/webtest/httpdocs/couch/snippets/

step 3:

Add the following lines of code to the page_detail.html file.

Code: Select all
<div id='box-top-left'>
               <cms:show box_top_left />
         </div>
          <div id='bottom-box'>
                  <cms:show bottom_box />
          </div>


In my case, i've had two editable regions inside the divs "bottom-box" and "box_top_left".

step 4:

Next, replace these div's on your (for instance) index.php file and replace it by the following lines of code:

Code: Select all
<cms:if k_is_page >
<cms:embed 'page_detail.html' />
<cms:else />
<cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
<cms:embed 'page_detail.html' />
</cms:pages>
</cms:if>


This page will now show the most recent post of your clonable template sorted by date.

I hope this explains alot for you, atleast it made me alot of things clear!
Thanks alot KK and Simon!

Let me know if i made any mistakes or misunderstood the whole idea.
Hi and welcome to our forums.

Couch allows you to fetch in and show any page (or pages) just about anywhere you desire.
We can the use the 'pages' tag to do so by specifying the template (masterpage attribute) and specifying either the name of the page or its id or any other attribute that you desire to use to segregate the pages (please see http://www.couchcms.com/docs/tags-reference/pages.html).

In the particular case you mentioned, to show only the latest page we can set the 'masterpage' to 'index.php', order the pages in the descending order of their publish_date (i.e. from latest to oldest) and finally pick up only the first page of this list -
Code: Select all
<cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
   ...We'll have all the variables belonging to the latest page here..
</cms:pages>

Incidentally, the default values of the 'orderby' and 'order' parameters happen to be what we are specifying in the code above. So if we so wish, the two parameters can be omitted altogether The following code snippet should work exactly the same as the previous one -
Code: Select all
<cms:pages masterpage='index.php' limit='1'>
   ...We'll have all the variables belonging to the latest page here..
</cms:pages>

Hope this answers the question. Please feel free to contact us if you require further help.
Looks like KK beat me to the answer.

Taken a look at the website, good design.

Seams you have some errors in pages though.
ERROR! TAG_NAME: Invalid char " " in tagname (line: 52 char: 1462)

And you thought about also doing it in English? or States laungauge? many owners over the countrys, so maybe an good idea.

Designs fresh :)

Any support needed, please do post up the code and im sure couch team, or myself can help.


Regards,
Simon.
wow what a fast and great responses! :)

Thanks for the compliments! i wanted to keep it as fresh as possible ;).
The reason why the error shows up is because im working on it as we speak.

I will try to edit it with the snippet i received above.

Thanks for the help and interest guys, i realy appreciate that! :D
Oke guys i think i haven't explained it properly, so here's another try.

The thing is, i want the user to see the latest article (http://webtest.stikzdesigns.com/index.php?p=11) when he fills in (http:www.webtest.stikzdesigns.com). What happens now is that it will show up the editable fields without any content.

So the latest page i've added (the right box is an archive of all the cloned pages from index.php) should be popping up.

The solution given above (if i used it correctly) will only make the archive show up 1 article.

Thanks again! (what an amazing CMS by the way :D, i realy love it).
jaaplelie wrote: Oke guys i think i haven't explained it properly, so here's another try.

The thing is, i want the user to see the latest article (http://webtest.stikzdesigns.com/index.php?p=11) when he fills in (http:www.webtest.stikzdesigns.com). What happens now is that it will show up the editable fields without any content.

So the latest page i've added (the right box is an archive of all the cloned pages from index.php) should be popping up.

The solution given above (if i used it correctly) will only make the archive show up 1 article.

Thanks again! (what an amazing CMS by the way :D, i realy love it).


Ok so far i think i'm with you so here goes.
You want to show some articles, like news or something on them lines, you want to show them by post order, so when it was posted and then list them. You can show as much as you want, so if you want one post, no problem, if you want 16 posts then no problem.


KK outlined above that you need this code.


<cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
...We'll have all the variables belonging to the latest page here..
</cms:pages>


That shows them by publish_date


Now its only showing a number of 1. Ive highlighted it in red for you, limit that to whatever you want, so 1 is one, 16 is 16 posts.

Just so you know, couch does show them by posted order, by the time and date you have made the topic, and clicked save, however you can make them a draft with the new update or use the normal none-publish.


Hope that helps.
In regards to the lastest article showing you need to add your content, all your doing is showing the content, rather than having it editable.

You want the same code, So go onto the article_list.php page or whatever you called it to list all your articles, that is used to show all the articles, and use the same code, if you want to change the look then no problem, just use the normal code like.

<cms:show k_page_link />
<cms:show k_page_title /> and so on, and add that to where you want to show it,

When adding the code bellow, which is the outer field of the div codes, where you want it to show, make sure you use that code bellow and limit to '1'

otherwise if you want more, then limit to whatever you would like shown..

<cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
...We'll have all the variables belonging to the latest page here..
</cms:pages>
Thanks for the reply again!

It still isnt exactly what i mean, but we're getting there :P
(Forget the Archive list on the right side)

Simply said i mean this:
When visiting webtest.stikzdesigns.com i want people to see this contenthttp://webtest.stikzdesigns.com/index.php?p=11
but when you go to http://webtest.stikzdesigns.com
you will see that the editable fields are blank.

If you look at my code you will understand what i mean:
<div id="box-top-left">

<p>Leusden, donderdag 21 april 2011 - Op de autotentoonstelling van Sjanghai debuteert de Audi A3 e-tron concept. Dit studiemodel is een doorontwikkeling van de Audi A3 concept die in Gen&egrave;ve werd onthuld. De Audi A3 e-tron beschikt echter over plug-in hybridetechnologie. Hiermee is het bijvoorbeeld mogelijk om over een afstand van 54 km volledig elektrisch aangedreven en dus lokaal emissievrij te rijden.</p>

</div>

Everything inside this box is editable, and the index.php page is clonable, thats why the webtest.stikzdesigns.com/index.php is not giving any content at all.

I hope i've made myself more understandable now!

Many thanks,

Jaap
I think i understand, but i'm confused on the way you are implmenting the cms.

If you want to clone pages, you need to have a list area, i wouldnt have the area
http://webtest.stikzdesigns.com/index.php because its going to just jam the website up.

I would start with making an articles area, or news area. So lets say

http://webtest.stikzdesigns.com/articles/index.php

Make an index php page that can be cloned, how the layout sits of the atricle, then you need to make a article_list.php page, which will list all your articles, and then use the code above to show the one recent you want on the index page you first visit when putting in your website URL.

You cant really use the index page to be cloned. as you need to be using a articles_list.php page that will list all the posts you have made within the articles area, then needs tobe uploaded into the snippets part of couch folder.

Have a look here - http://www.couchcms.com/docs/tutorials/ ... /blog.html

The index page, when you visit http://webtest.stikzdesigns.com will be the index page of the website, and used to show the lastest posts.
Hi,

You had explained yourself perfectly well :)

The snippet I posted above is NOT for the archive.
You can use it to show the latest cloned page on any page - in our case on the index page when it is accessed in home-view i.e. http:www.webtest.stikzdesigns.com.

I'll try and illustrate it a little more -
Suppose this is your template -
Code: Select all
<cms:template title='Index' clonable='1'>
    ...editable regions defined here...
</cms:template>

<div id='content'>
  <div id='navbar'>..</div>
  <div id='text-box>..</div>
  <div id='box-top-left'>
    <cms:show editable_region_one />
  </div>
  <div id='bottom-box'>
    <cms:show editable_region_two />
  </div> 
</div>

In the snippet above, <cms:show editable_region_one /> and <cms:show editable_region_two /> will show up only in page_view.
When accessing index.php alone (in home_view etc.) there will be no page associated and hence <cms:show editable_region_one /> and <cms:show editable_region_two /> will output nothing. This is what you have already noticed.

What we can do is that if the view is not a page_view, we'll explicitly fetch in a page (the latest in your case).
Code: Select all
<div id='content'>
  <div id='navbar'>..</div>
  <div id='text-box>..</div>
  <cms:if k_is_page >
    <div id='box-top-left'>
      <cms:show editable_region_one />
    </div>
    <div id='bottom-box'>
      <cms:show editable_region_two />
    </div> 
  <cms:else />
    <cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
      <div id='box-top-left'>
        <cms:show editable_region_one />
      </div>
      <div id='bottom-box'>
        <cms:show editable_region_two />
      </div> 
    </cms:pages>
  </cms:if>
</div>

Notice how we have duplicated the same HTML code for the non page_view but this time we wrap it around the 'pages' tag that fetches in the latest page. The variables of this page will now become available and will be shown.

If the HTML code for displaying the page variables is substantial, we can cut and paste the into a snippet (saved within couch/snippets folder) and then use the embedded snippet -
Code: Select all
<div id='content'>
  <div id='navbar'>..</div>
  <div id='text-box>..</div>
  <cms:if k_is_page >
    <cms:embed 'page_detail.html' />
  <cms:else />
    <cms:pages masterpage='index.php' orderby='publish_date' order='desc' limit='1'>
      <cms:embed 'page_detail.html' />
    </cms:pages>
  </cms:if>
</div>

where the snippet 'page_detail.html' can contain
Code: Select all
      <div id='box-top-left'>
        <cms:show editable_region_one />
      </div>
      <div id='bottom-box'>
        <cms:show editable_region_two />
      </div> 

or anything much more substantial. The idea is to avoid duplicating the code twice - one for the page_view and another for the home_view.

Hope I was able to explain myself. If you have any doubts please feel free to contact us.
16 posts Page 1 of 2