Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
When I tried to make the relation between my News section and Games section. I put:
Code: Select all
<cms:editable type='relation' name='game_news' masterpage='news.php' />


In the template and it gave me an error:
Code: Select all
ERROR: Tag "editable" has unknown type "relation"
\

Any idea why?

Thanks,
Steve C
It seems you are using Couch v1.2.5.
Please upgrade to v1.3 downloadable from this location:
viewtopic.php?f=5&t=7014
Thanks that worked.
Got a ?? Is it possible to create an if so that if posts related posts exist then do X and if not then do y?

If so how?

Thanks,
Steve C
Could you please post in the exact scenario where you'd like to use this?
What im trying to do is make a game database that will hold all of our games that we add to the site. If you are on a specific game for example Dead Space 2 http://www.judgegame.com/games.php?p=19

If you see the tabs, what im doing is using a relation to my news posts to show all related news posts.

What I want is an if that works if I have no news posts related, then it will show some text that says something like "No News Posts for Dead Space 2" or something like that.

Thanks,
Steve C

if you need more details let me know.
We can use a technique very often employed with cms:pages tag ('related_pages' tag is very closely related to it).

Suppose we have the following snippet
Code: Select all
<cms:pages masterpage='something.php' >
   <cms:show k_page_title />
</cms:pages>

If there are suppose 5 pages, as expected the loop above will repeat 5 times and show the 5 entries. However if suppose there are no pages to fetch, the loop above will not execute even once.
We can use this behaviour to help us figure out if there are no pages to show.

What we do is, we set a global variable, say named 'pages_found' before we enter the pages loop
Code: Select all
<cms:set pages_found = '0'  'global'/>

<cms:pages masterpage='something.php' >
   <cms:show k_page_title />
</cms:pages>

Then within the pages loop, we set this variable to '1'
Code: Select all
<cms:set pages_found = '0'  'global'/>

<cms:pages masterpage='something.php' >
   <cms:show k_page_title />
   <cms:set pages_found = '1'  'global'/>
</cms:pages>

Obviously, if there are no pages to fetch, the 'pages' tag will not execute and the 'pages_found' variable will never be set to '1' i.e. will remain on its initial value of '0'.
We check this after the pages tag and if the 'pages_found' variable is still '0', we display the 'No pages found' message
Code: Select all
<cms:set pages_found = '0'  'global'/>

<cms:pages masterpage='something.php' >
   <cms:show k_page_title />
   <cms:set pages_found = '1'  'global'/>
</cms:pages>

<cms:if pages_found = '0' >
   No pages found
</cms:if>

The technique outlines above can be easily ported to 'related_pages'. An example could be -
Code: Select all
<cms:set pages_found = '0'  'global'/>

<cms:related_pages 'artist_albums' >
   <!-- All variables of 'albums.php' are available here -->
   <cms:show k_page_title /><br/>
   <cms:set pages_found = '1'  'global'/>
</cms:related_pages>

<cms:if pages_found = '0' >
   No News Posts for <cms:show k_page_title />
</cms:if>

Hope this helps.
Sweet that worked perfectly, thank you.

If you want to see it in action you can see here.

Game with related content http://www.judgegame.com/games.php?p=19

Game without related content http://www.judgegame.com/games.php?p=38

Thanks again,
Steve C
8 posts Page 1 of 1