Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
Hello,

I currently have a cloned page which lists portfolio images, like so:

<TITLE>
<DESCRIPTION>
<REPEATABLE><IMG></REPEATABLE>

This means that the client can choose to have as many images as they wish within that one 'post', however my problem now is, the client wishes to show "Latest Work" on a totally different page (Homepage), and wants to display the latest posts, due to the limitations of space, I have decided to go about this by displaying it like so:

<TITLE>
<DESCRIPTION>
<REPEATABLE><IMG></REPEATABLE> <-Only the first image from the portfolio entry. (Is this possible)

And doing this for the last three posts the client has created.

What I'm wondering is how would I target the last three posts, such as ?p=10, ?p=11, ?p=12, and have each of those posts titles, descriptions and first image display within "latest work".

Thank you.
Listing pages of one template on any other template is trivial. You just need to set the masterpage parameter. So, for example, if your template name is 'portfolio.php' and you wish to display its cloned pages on 'home.php', this is what you can place in 'home.php' -
Code: Select all
<cms:pages masterpage='portfolio.php'>
    .. this will list pages from portfolio ..
</cms:pages>

To list only the latest 3 pages, use the 'limit' parameter
Code: Select all
<cms:pages masterpage='portfolio.php' limit='3'>
    .. this will list 3 latest pages ..
</cms:pages>

All the variables of each cloned page being listed can be displayed the usual way.
Listing only the first image of the repeatable region will require, however, some additional code -
Code: Select all
<cms:show_repeatable 'name_of_the region' startcount='1' >
    <cms:if k_count='1' >
        .. show the image here ..
    </cms:if>
</cms:show_repeatable>

Hope this helps.
At first, your post looked like great help (which it still is), but unfortunately it didn't work, most likely my wrong doing.

I even went to the case of copy and pasting exactly what I have from my portfolio-list.php into index.php to see what it would display, and it failed to display it, it didn't show content, title, and couldn't locate the image, is there any reason for this?

Thank you.
Please PM me both your templates (index + portfolio) in a zip file and I'll take a look at what is going wrong.
Don't worry, it must be some trivial mistake somewhere.

Thanks.
Thank for sending me the templates.

I had a look and the problem it seems is that, your 'index.php' is not a Couch managed template i.e. you have not added the required <?php require_once( 'couch/cms.php' ); ?> and <?php COUCH::invoke(); ?> statements to it so as to make it appear in the admin-panel (just as you have done with portfolio.php).

You see, for the Couch tags (e.g. <cms:pages> you have put in index.php) to take effect, the template has to managed by Couch else the tags will simply be echoed verbatim.

So please add index.php to the admin panel and the code should work.

P.S. Unrelated to the discussion above - I also noticed that your portfolio.php has the following code
Code: Select all
<?php COUCH::invoke(); ?>
<?php include 'footer.php'; ?>

Please make it
Code: Select all
<?php include 'footer.php'; ?>
<?php COUCH::invoke(); ?>

as the <?php COUCH::invoke(); ?> should be the very last PHP statement in a template.

Hope this helps. Please let me know.
Great! That worked.

Is it possible to hide index.php from the admin panel so the client cannot see it, and it is also possible to target the last image like I've targeted the first image with:

Code: Select all
<cms:show_repeatable 'name_of_the region' startcount='1' >
    <cms:if k_count='1' >
        .. show the image here ..
    </cms:if>


Such as something like startcount='last' ?

Thank you.
Add hidden='1' to your 'cms:template' tag.

Use the following if condition:
Code: Select all
<cms:if k_count == k_total_records>
    ...
</cms:if>
The startcount='1' you are using is redundant because the default startcount is 1; the docs are incorrect in this regard.
7 posts Page 1 of 1