Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
Hi! I have a question for which I wasn't able to find an answer for neither in the Documentation or in the Forum. I apologise in advance if the answer to this question is already available, but I've missed it.

I use a template with the following data asked for each entry:
- Title (default),
- Name (default),
- Description,
- URL.

The acquired data is then presented as a list of links with titles and descriptions for each list item. When a link is clicked, it should be opened in a new page where the header stays the same, but the content should be fetched from the URL and served in an iframe.

Is this doable and how could one make it work?
Thanks!
Hi Davor,

If I understood the scenario right, the following could be a way of doing what you desire -

In the list-view of the template, we use cms:pages tag the regular way to list all the cloned pages (where each cloned page represents one entry).
Code: Select all
<cms:if k_is_list>
    <cms:pages>
        <h3><cms:show k_page_title /></h3>
        <cms:show my_desc />
        <a href="<cms:show k_page_link />">View ..</a>
    </cms:pages>
</cms:if>

In the list above, each entry has a link (View..) leading to its page-view. In the page-view, we can easily use the data contained in the url field (I am assuming it is named 'my_url' here), to set the src of the IFrame. The code above now becomes -
Code: Select all
<cms:if k_is_list>
    <cms:pages>
        <h3><cms:show k_page_title /></h3>
        <cms:show my_desc />
        <a href="<cms:show k_page_link />">View ..</a>
    </cms:pages>
<cms:else />
   
    <h1><cms:show k_page_title /></h1>
    <iframe src="<cms:show my_url />"></iframe>

</cms:if>

Does this do what you wanted? Please let us know.
Thanks.
It works wonderfully for fetching the iframe content from the given link - awesome! That was the harder part.

The problem still remains with showing the list of items. On the homepage there is a list of entries/pages with their iframes - screenshot:

Image

I am probably missing something on a really basic level, hence why the solution is so elusive to me.

This is the code of the page:

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<cms:template title='Index' />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Welcome to the test page!</title>
    <meta name="description" content="Testing Couch CMS" />
    <link type="text/css" rel="stylesheet" href="css/style.css">
    <link rel="shortcut icon" href="img/favicon.png" type="image/x-icon">
</head>

<body>
   <header>
      <div class="wrap">
         <a href="/" class="logo"><img src="img/logo.png" alt="Page title"></a>
         <div class="searchform">
            <cms:search_form msg='Enter keywords' processor="<cms:show k_site_link/>search.php"/><cms:search limit='10'>
                <cms:if k_paginated_top >
                    <div>
                        <cms:if k_paginator_required >
                            Page <cms:show k_current_page /> of <cms:show k_total_pages /><br>
                        </cms:if>
                        <cms:show k_total_records /> Pages Found -
                        displaying: <cms:show k_record_from />-<cms:show k_record_to />
                    </div>
                </cms:if>

                <h3><a href="<cms:show k_page_link/>"><cms:show k_search_title /></a></h3>
                <cms:show k_search_excerpt />
                <hr>

                <cms:paginator />
            </cms:search>
         </div>
      </div>
   </header>
   <nav>
      
   </nav>
   <div class="wrap">
      <div class="content">
         <cms:pages masterpage="demos.php">
                  <cms:if k_is_list>
                      <cms:pages>
                          <h3><cms:show k_page_title /></h3>
                          <cms:show description />
                          <a href="<cms:show k_page_link />">View...</a>
                      </cms:pages>
                  <cms:else />
                     
                      <h1><cms:show k_page_title /></h1>
                      <iframe src="<cms:show url />"></iframe>

                  </cms:if>
               </cms:pages>
      </div>
   </div>
   <footer>
      <div class="wrap">
         
      </div>
   </footer>
</body>
<?php COUCH::invoke(); ?>


What am I missing? :)
Hey Davor,

I can see two issues -
1. You are using the cms:pages loop twice!
This is your original code
Code: Select all
<div class="content">
<cms:pages masterpage="demos.php">
          <cms:if k_is_list>
              <cms:pages>
                  <h3><cms:show k_page_title /></h3>
                  <cms:show description />
                  <a href="<cms:show k_page_link />">View...</a>
              </cms:pages>
          <cms:else />
             
              <h1><cms:show k_page_title /></h1>
              <iframe src="<cms:show url />"></iframe>

          </cms:if>
       </cms:pages>
</div>

Notice how you are using cms:pages once inside the k_is_list block and also once outside it.
We can change the code to just this -
Code: Select all
<div class="content">
  <cms:pages masterpage="demos.php">
      <h3><cms:show k_page_title /></h3>
      <cms:show description />
      <a href="<cms:show k_page_link />">View...</a>
  </cms:pages>
</div>

2. The template on which this code is placed is 'index.php' (I think). In the code, the
<a href="<cms:show k_page_link />">View...</a>
statement will invoke 'demos.php' in page-view and not index.php (because that is the template we are making cms:pages use by setting its 'masterpage' parameter).
Therefore the part of the original code handling the page-view
Code: Select all
<cms:else />

  <h1><cms:show k_page_title /></h1>
  <iframe src="<cms:show url />"></iframe>

</cms:if>

should now be moved into 'demos.php'. The following can be placed in 'demos.php' -
Code: Select all
<cms:is k_is_page>

  <h1><cms:show k_page_title /></h1>
  <iframe src="<cms:show url />"></iframe>

</cms:if>

Hope this helps.
Works like a charm!
Thank you Kamran. Your desire and ability to help your users is unparalleled. I'm so happy to be a "on the Couch"! :D
5 posts Page 1 of 1