Forum for discussing general topics related to Couch.
10 posts Page 1 of 1
I may have missed/misunderstood this when going through the tutorial, but is there a way to directly link a cloned page to another cloned page?

I'm trying to link multiple artworks to an artist page, these artworks will be updating on a constant basis. I haven't been able to find a straightforward answer on this but I'm assuming there has to be a way!

Thanks in advance!
Hi,

'Artists' and 'Artworks' - it is not clear from your question if these are two different templates?
Anyway, please take a look at the 'relations' feature -
https://docs.couchcms.com/concepts/relationships.html

I think that should help you in doing what you want.

Hope this helps.
KK wrote: Hi,

'Artists' and 'Artworks' - it is not clear from your question if these are two different templates?
Anyway, please take a look at the 'relations' feature -
https://docs.couchcms.com/concepts/relationships.html

I think that should help you in doing what you want.

Hope this helps.


Two different templates with clones, that's correct!
Right. Then you should have no difficulty in following what is explained in the linked docs page (https://docs.couchcms.com/concepts/relationships.html).
KK wrote: Right. Then you should have no difficulty in following what is explained in the linked docs page (https://docs.couchcms.com/concepts/relationships.html).


So I've been following this page and working on it. I've created a relationship between the to pages:

(This code is within the artists template)
<cms:editable type='relation' name='artists_artwork_database' masterpage='final-dbfa-artwork-template.php' reverse_has='one'/>

The artists template and the artworks template are linked together, when I go to the admin, it shows the dropdown list. Great!

I've now tried to move this line into a repeatable so that I can link each artwork listing to its respective artwork clone. However, the list disappears when I try to place it within the repeatable code:

<cms:repeatable name='artwork_images' >
<cms:editable type='relation' name='artists_artwork_database' masterpage='final-dbfa-artwork-template.php' reverse_has='one'/>
<cms:editable type='image' name='artwork_image' label='Artwork' />
<cms:editable type='richtext' name='artwork_text' label='Artwork Text' />
</cms:repeatable>


Any suggestions? Thanks so much for your help!
Relation works by associating two 'pages' with each other - when you place it within a repeatable-region, you are attempting to associate a 'row' of that repeatable-region and not a page; therefore it won't work.

That said, there is another way of associating rows of RR with pages -
please see my reply here viewtopic.php?f=4&t=11767

You can, as shown there, populate the dropdown with pages from the opposing template.

Hope it helps.
KK wrote: Relation works by associating two 'pages' with each other - when you place it within a repeatable-region, you are attempting to associate a 'row' of that repeatable-region and not a page; therefore it won't work.

That said, there is another way of associating rows of RR with pages -
please see my reply here viewtopic.php?f=4&t=11767

You can, as shown there, populate the dropdown with pages from the opposing template.

Hope it helps.


I feel like I'm so close but I just cant get it to work quite right! When I click on the artwork, it 404's as it directs to the "name" of the page instead of the actual page (https://www.blank.com/the-artwork). I'm guessing it's due to using the wrong cms:show in the a href but I can't figure it out (I've highlighted it in red below)...

Now showing on the artwork page:
https://imgur.com/4kFC0DV

Top of that page:

<cms:editable type='relation' name='artists_database' masterpage='final-dbfa-artist-template.php' reverse_has='one'/>




Now showing on the artist page:
https://imgur.com/JJBNBhp

Top of Page:

<cms:repeatable name='artwork_images' >
<cms:editable
name="items"
label="Linked Artwork Page"
opt_values='my_artworks.htm'
dynamic='opt_values'
type='dropdown'
/>
<cms:editable type='image' name='artwork_image' label='Artwork' />
<cms:editable type='richtext' name='artwork_text' label='Artwork Text' />
</cms:repeatable>




Page content within the page:
<cms:show_repeatable 'artwork_images' >
<div class="isotope-item portfolio-item">
<div class="portfolio-media">


<a href="<cms:show items />" class="thumb-overlay">
<img src="<cms:show artwork_image />" /> <br/>
</a>
<cms:show artwork_text />



</div>
</div>
</cms:show_repeatable>



And my HTM snippet:

Please Select=-
<cms:pages masterpage='final-dbfa-artwork-template.php'>
| <cms:show k_page_name />
</cms:pages>
Yes, you are indeed close.
The missing piece is converting the page_name into its proper link.

Please try this -
Code: Select all
<a href="<cms:link masterpage='final-dbfa-artwork-template.php' page=items />" class="thumb-overlay">
    <img src="<cms:show artwork_image />" /> <br/>
</a>

As you'd notice above, we are using <cms:link> tag to get the link of a page given its name and masterpage.

Hope this helps.
KK wrote: Yes, you are indeed close.
The missing piece is converting the page_name into its proper link.

Please try this -
Code: Select all
<a href="<cms:link masterpage='final-dbfa-artwork-template.php' page=items />" class="thumb-overlay">
    <img src="<cms:show artwork_image />" /> <br/>
</a>

As you'd notice above, we are using <cms:link> tag to get the link of a page given its name and masterpage.

Hope this helps.


Honestly I just about cried haha. I'd figured out the cms:link portion but just needed that last push. That fixed it for me. Thank you so, so much! I can't thank you enough for the help.
You are welcome :) Glad I could help.
10 posts Page 1 of 1