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

First off, great work on CouchCMS and great support as well! I've been following the forums discussions for a while and have learned a lot from just reading.

I'm currently working on my first website using CouchCMS and have a question I couldn't find an answer for.
One page represents a "news" page with different articles. I've used repeatable sections on other pages so I thought I'd use repeatable on this one as well.
Here's the tricky part: On the home page of the website, I'd like to incorporate a "latest news" section that displays snippets (or certain data from the news page). That would require me to fetch this information from the news template and/or the database.
What would be the best way to do this? If it's possible at all ...

Thanks in advance!

-Chris
Hello and welcome, Chris :)
I am glad you liked Couch.

I think @cheesypoof's answer in this thread should give you the solution -
viewtopic.php?f=2&t=7708

I must add, however, that the choice of repeatable regions to create a news section (that can potentially contain hundreds if not thousands of items) is questionable.

The ideal way would be to use simple cloned pages - a solution which, apart being scalable, also makes it simple to query and display selected pages anywhere on the site.

Thanks
Thanks for your quick reply!

I understood clonable pages as separate pages - the news site I'm planning though is a one-page template that has different blocks of news in it. Those won't last forever, so there's no need for multiple pages. They're rather 5-6 blocks of news which get deleted once they're out of date.

If I placed a repeatable news block into the global file - would I be able to extract certain editable regions out of it?

Let's say a news block consists of title, date and content. The news page displays let's say 5 blocks of those 3 editables. The home page only displays title and date of the first 3 news items. Would this be possible through the globals method you linked to?

Still learning, so sorry if I'm heading the wrong way.
If the number of news items is limited, there is no problem in using repeatable regions.

Replying to your query -
The 'globals.php' could be any other template - the technique was to demonstrate how to show repeatable regions defined on one template (e.g. news.php) on any other template (e.g. home.php).

In your case, if we put the following on any template it should show the top 3 rows of the repeatable region defined in news.php (I am assuming the name of the repeatable region is 'my_news' and the fields within it are named 'news_title', 'news_date', 'news_content'
Code: Select all
<cms:pages masterpage='news.php' limit='1' >
    <cms:show_repeatable 'my_news'>
        <cms:if k_count le '3'>
            <cms:show news_title /><br>
            <cms:show news_date /><br>
            <cms:show news_content />
        </cms:if>
    </cms:show_repeatable>
</cms:pages> 

Hope this helps.
Your snippet worked perfectly - that's what I was searching for.
Thank you and keep up the good work!
You are welcome, Chris :)
Great, this works here like a charm.

In my website I have two sections on one page where I want to output a repeatable region. Is this correct or is there a simpler solution:

index.html

1. output in the header section
Code: Select all
<cms:pages masterpage='mytable.php' limit='1' >
    <cms:show_repeatable 'my_table'>
     
            <cms:show data1 /><br>
            <cms:show data2 /><br>
            <cms:show data3 />

    </cms:show_repeatable>
</cms:pages>



2. output in the footer section
Code: Select all
<cms:pages masterpage='mytable.php' limit='1' >
    <cms:show_repeatable 'my_table'>
     
            <cms:show data1 /><br>
            <cms:show data2 /><br>
            <cms:show data3 />

    </cms:show_repeatable>
</cms:pages>


Question: is using masterpage='mytable.php' twice OK or can I output the same with calling masterpage='mytable.php' just once?
* * * * * * I LOVE COUCH CMS - flexible and straight forward * * * * * *
No problem in using the masterpage param multiple times, chichi.

While we can cook up something to run the code only once and show the output twice (hint - cms:set or cms:capture), I suggest you go with whatever is most straightforward for you.
8 posts Page 1 of 1