Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
I have a standard clonable page + listing views page set up and it's working fabulously.

But for another section of the site, I need to display all pages that come in 3 separate forms. One will be a template that allows user to embed a single video, one template that has standard editable HTML information, and one that is a direct link to a .pdf (although, if it's easier, I can have listing page -> pdf.html page -> download .pdf file.)

I would like all three of these categories/templates to be displayed in a random order (or date modified or name or whatever). ie: a video, a catalog, a informational html page, a video, another video, etc. For reference, you can check out a demo page here: http://supergeniustay.com/americhip/videos.html

Is this possible? I know I could use the list masterpage video.php , masterpage catalog.php, etc and but they would be broken up by section.

Any advice on how to achieve this?

BTW - I am absolutely in love with this CMS. I have never encountered code and documentation that just MAKES SENSE. LOVE LOVE LOVE LOVE LOVE.
Hello and welcome to our forums, Tay :)
Thank you very much for the kind words. I am glad you liked Couch.

Coming to the question that you have, the cms:pages tag can only list pages from a single template.
To fetch pages from multiple templates, we'll have to resort to using raw SQL.
Couch has a cms:query tag that can make this process fairly easy.

Following is the code that you can adapt to your purpose -
Code: Select all
<cms:query
    sql="SELECT p.id pid, t.name tname
        FROM <cms:php>echo K_TBL_PAGES;</cms:php> p
        inner join <cms:php>echo K_TBL_TEMPLATES;</cms:php> t
        on p.template_id = t.id
        WHERE (t.name='video.php' or t.name='catalog.php' or t.name='info.php')
        AND publish_date < '<cms:date format='Y-m-d H:i:s' />'
        AND NOT publish_date = '0000-00-00 00:00:00'
        ORDER BY publish_date desc;"
    limit='10'
    paginate='1'>

    <cms:show pid />-<cms:show tname /><br/>

    <cms:pages masterpage=tname id=pid>
       <a href="<cms:show k_page_link />"><cms:show k_page_title /></a><br />
    </cms:pages>

    <br />
    <cms:paginator />
</cms:query>

Please modify the WHERE (t.name='video.php' or t.name='catalog.php' or t.name='info.php') line to put in your actual template names.

The cms:query tag above fetches in all the page ids and template names. The cms:pages tag within then uses the two values to fetch in the entire pages.

You can use conditional statements within the cms:pages block to display the contents of the various templates differently e.g.
Code: Select all
<cms:if k_template_name='video.php'>
   .. shoe regions of video template ..
</cms:if>

Hope this helps.
2 posts Page 1 of 1
cron