Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I am working on the section of the website what will work in the following way:
- On the main page (index.php), I will show multiple clickable regions with a title and a video
- When clicking on the title or the video the user will go to a specific page that will show the same title, description, hero image and image/video gallery

I understand that I need to use the clonable functionality of the template. Here is how my current template looks like:

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<cms:template title='Section' clonable='1' />

    <cms:editable type='text' name='video_url' label='Video URL' />
    <cms:editable type='nicedit' name='desc' label='Description' />
    <cms:editable type='image' name='hero_image' label='Hero image' show_preview='1' preview_width='150' />

    <cms:repeatable name='single_gallery_item' label='Single gallery item' stacked_layout='1'>
        <cms:editable type='image' name='gallery_image' label='Gallery image' show_preview='1' preview_width='150' />
        <cms:editable type='text' name='gallery_video_url' label='Video URL' />
    </cms:repeatable>

<?php COUCH::invoke(); ?>


Now on the main page (index.php) I call the template like so:
Code: Select all
<cms:pages masterpage='services.php'>
<iframe src="<cms:show video_url />"></iframe>
<h4><cms:show k_page_title /></h4>
<a href="<cms:show k_page_name />"></a>
</cms:pages>


The main page (index.php) will only display one latest entry (page) instead of all the existing entries (pages).

How can I display all the available entries (pages) on the index.php?
How can I display all the available entries (pages) on the index.php?

using <cms:pages> with 'masterpage' pointing to the relevant template is the correct way of doing this.

Your code seems to be doing just that so, assuming that the template we are interested in is named 'services.php' and that it has more than one cloned pages, it should list all its pages.

Please try using a simplified version for troubleshooting -
Code: Select all
<cms:pages masterpage='services.php'>
    <cms:dump />
</cms:pages>

If you still don't see all the pages data, please check the missing pages and confirm that they are 'published' and that their publish date does not lie in the future (by default <cms:pages> will list only published pages with non-future dates).

Hope this helps.
1. The template is indeed called "services.php". I have provided the contents of it in my original question.
2. All the cloned pages are published on the 4th of December today is 5th. Nothing is scheduled for future publication.
3. <cms:dump/> returns the k_page_title and k_page_name of the lastest published page instead of all the published pages.

I have got this to work by doing the following:
Code: Select all
<cms:pages masterpage='services.php'>
   <cms:if k_is_page>
      <iframe src="<cms:show video_url/>" ></iframe>
      <h4><cms:show k_page_title /></h4>
      <a href="<cms:show k_page_name />" ></a>
   <cms:else />
      <iframe src="<cms:show video_url/>" ></iframe>
      <h4><cms:show k_page_title /></h4>
      <a href="<cms:show k_page_name />" ></a>
   </cms:if>
</cms:pages>


The code above will display a certain section of the all the published pages. This leads me to another question.

How can I set the template for a separate published page? Is it a part of <cms:embed />?
I have got this to work by doing the following:

Code:

<cms:pages masterpage='services.php'>
<cms:if k_is_page>
<iframe src="<cms:show video_url/>" ></iframe>
<h4><cms:show k_page_title /></h4>
<a href="<cms:show k_page_name />" ></a>
<cms:else />
<iframe src="<cms:show video_url/>" ></iframe>
<h4><cms:show k_page_title /></h4>
<a href="<cms:show k_page_name />" ></a>
</cms:if>
</cms:pages>

This is intriguing as 'k_is_page' is always true within <cms:pages> and therefore the portion of your code in the <cms:else /> block should never execute.

I'd like to take a look at this issue - would it be possible for you to grant me FTP+Couch access to your site please?
I
I was able to resolve the issue myself. Here is how I have done it:

First, in index.php I wrote this:
Code: Select all
<cms:pages masterpage='services.php'>
      <iframe src="<cms:show video_url/>" ></iframe>
      <h4><cms:show k_page_title /></h4>
      <a href="<cms:show k_page_link />" ></a>
</cms:pages>


Second, in services.php I wrote this:

Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<cms:template title='Section' clonable='1' >

    <cms:editable type='text' name='video_url' label='Video URL' />
    <cms:editable type='nicedit' name='desc' label='Description' />
    <cms:editable type='image' name='hero_image' label='Hero image' show_preview='1' preview_width='150' />

    <cms:repeatable name='single_gallery_item' label='Single gallery item' stacked_layout='1'>
        <cms:editable type='image' name='gallery_image' label='Gallery image' show_preview='1' preview_width='150' />
        <cms:editable type='text' name='gallery_video_url' label='Video URL' />
    </cms:repeatable>
</cms:template>
<cms:if k_is_page>
<!DOCTYPE HTML>
<html>
<section style="background-image: url('<cms:show hero_image />');">
<h2><cms:show k_page_title /></h2>
</section>
<section>
<p><cms:show service_desc /></p>
</section>
</html>
</cms:if>
<?php COUCH::invoke(); ?>


Now I can display some fields in index.php and other or the same fields on any new page I create.

The only problem with this approach is that domain.com/services.php will show an empty page. I know that this is an expected behavior. Is there a way to get the user to redirect from domain.com/services.php and domain.com/services to domain.com, but keep the current links with separate pages valid domain.com/services/page-title.html?
5 posts Page 1 of 1
cron