by
KK » Sat Mar 19, 2016 6:01 pm
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.