Forum for discussing general topics related to Couch.
7 posts Page 1 of 1
Hi. I'm new to Couch and am having a small problem
I have added an image to a page in the normal way - cms:editable, type=image, etc
I then uploaded the image and showed it on the page using <cms:show image1>
This works fine and the image displays on the page as expected.

Now I want to display the same image on another page, but when I add the tag
<cms:show image1> on the new page, I just get an empty space

Is it possible to show images uploaded on one page on another page?

Thanks in advance
Hi!
I'll assume, that you have 2 registered couch templates. One with editable image - profile.php and another without it, contacts.php

The thing is that image is registered only for profile.php You can show it as you've done - <cms:show image />. On contacts.php if you put the same statement - template doesn't know which image to show.

What if you have 2 different templates and each have image as editable?

To easily show anything anywhere there is a tag: http://docs.couchcms.com/tags-reference ... field.html
Put this in contacts.php and you'll show your profile's image:
Code: Select all
<cms:get_custom_field 'image' masterpage='profile.php' />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
When you get into more variables to show, you'd like to use cms:pages tag.
Let's say on profile.php there are 5 variables:
Name, Email, Image, Website, Status

Of course 'get_custom_field' works here too, but it is easier to fetch all of variables at one strike:

Code: Select all
<cms:pages masterpage='profile.php' >
   <cms:show name /><br>
   <cms:show email /><br>
   <cms:show image /><br>
   <cms:show website /><br>
   <cms:show status /><br>
</cms:pages>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I see that @trendoman has posted while I was in the process of preparing my reply :)
But I'll go ahead and post mine as it contains some more info about 'clonable' templates.

===============================

Hello Joel :)

Is it possible to show images uploaded on one page on another page?
Certainly. We can show data from any editable region (including image) defined in one page on any other page.

However, while trying to do so we'll need to give more information as to exactly which page it has to fetch that data from.

I'll give you some concrete examples -
In Couch parlance we define regions in 'templates' (i.e. the physical PHP files) so I'll use that term.

Templates can be either 'non-clonable' (i.e. will only represent one single page e.g. 'contact-us' section) or can be 'clonable' (i.e. have multiple virtual pages from the same physical template e.g. 'blog' or 'news').

I'll give the examples for both types of templates.

Suppose the template you have defined the image in is non-clonable and is named 'contact.php'. Assuming the name of the region is 'my_image', you can use either of the following two versions of code in *any* template of the site to fetch that image -
Code: Select all
<cms:get_custom_field 'my_image' masterpage='contact.php' />

or
Code: Select all
<cms:pages masterpage='contact.php'>
    <cms:show my_image />
</cms:pages>

Please notice how in both the versions we are also letting Couch know about the template (contact.php) where the image region (my_image) is to be fetched.

For clonable templates, templates can have more than one pages. You can see now that each of those pages can have a different image uploaded for it.
So with clonable templates, we'll need to specify an additional parameter - the 'name' of the page as well.

So suppose now the template we have defined the 'my_image' region is clonable and is named 'blog.php'.

To fetch the image uploaded for a cloned page named 'my-first-blog-entry', we can now use either of the two versions of the code below -
Code: Select all
<cms:get_custom_field 'my_image' masterpage='blog.php' page='my-first-blog-entry' />

or
Code: Select all
<cms:pages masterpage='blog.php' page_name='my-first-blog-entry' >
    <cms:show my_image />
</cms:pages>

Please change the parameters to match your setup and you should be able to fetch data from anywhere in the site.

Hope it helps.
@KK, I am glad you covered clonable templates. Thank you. I hope @Joel talks about the setup a bit more openly and we know what sorts of templates are in work without guessing.

To add more about cms:pages:

Suppose, blog.php is indeed a clonable template and has several 'blog posts' as clonable pages.
Each page of course has an editable image 'my_image'.

What happens if you don't specify the exact page of blog.php?
cms:pages would show all images of all the pages one by one, fetching one page at a time and showing its image:
Code: Select all
<cms:pages masterpage='blog.php' >
   <cms:show my_image />
</cms:pages>

To see what's going on inside any pair of tags, use <cms:dump /> or <cms:dump_all /> like this:
Code: Select all
<cms:pages masterpage='blog.php' >
   <cms:dump />
</cms:pages>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi Guys

Thanks for your help. With your input I have managed to create the cloneable templates
The temporary site is here so you can see how I've set it up

www.pensionsmart.org.uk

The page - Properties to Rent - is the one with the isotope filter. This shows an html page in my snippets folder. When results are selected from the filter, it shows the cloneable page which is a php page in the root folder. I'm using prettyurls which show the folder name
This URL explains it all :)
http://www.pensionsmart.org.uk/property ... treet.html

The page - Properties to Rent - is the one with the isotope filter. This shows an html page in my snippets folder. When results are selected from the filter, it shows the cloneable page which is a php page in the root folder. I'm using prettyurls which show the folder name

I hope you don't mind if I rephrase the whole story in couch terms, so others may also follow.

The website's page 'Properties to Rent' is a clonable template propertytemplate.php in website's root. In home-view, it shows your snippet. In page-view it shows one of template's clonable pages. Clonable pages are organized in folders. When pretty-urls are enabled, URL also shows folder name.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
7 posts Page 1 of 1