We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Reference a field of another page?

How Do I?

DV007's avatar
DV007
1 posts
9 months ago
DV007's avatar DV007

My pages have a file field. I’d like to reference the field of another page (let’s say page1) on all other pages (page2, page3, page4, etc.) if those pages do not have any value given for their file field. If I have the {entry_id} of page1 how could I do that?

       
Tom Jaeger's avatar
Tom Jaeger
426 posts
9 months ago
Tom Jaeger's avatar Tom Jaeger

Hi DV0007, Thanks for getting in touch about this. There are several ways you could do this. The easiest is probably to do something along the following lines

{exp:channel:entries channel="pages"}
 {!-- Please note the channel name above will have to be the one you are using --}
 {if '{file_field}' != ''}
  {!-- This means we have the file field for this entry  --}
  {file_field}
 {if:else}
  {!-- open channel entries loop along the following lines .. 
  I'd generally put this in an embed to keep things clean
  If you went that route you would use something like 

  {emebd="_embeds/page_1_image" entry_id_of_page_1="{passed in entry ID}"}
   --}
  }
  {exp:channel:entries channel="pages" dynamic="no" entry_id="{entry_id_of_page_1}"}
   {!-- Please note, the {entry_id_of_page_1} is a placeholder --}
   {file_field}
  {/exp:channel:entries}  
 {/if}
{/exp:channel:entries}

Please note, you could also use the url_title or a few other methods to achieve this.

Thanks,

-Tom Jaeger

       
jamescarrion's avatar
jamescarrion
4 posts
7 months ago
jamescarrion's avatar jamescarrion

Hello, To achieve this functionality where you reference the file field of one page (let’s say page1) on all other pages (page2, page3, page4, etc.) if those pages do not have any value for their file field, you can use a scripting language like PHP along with a database to store and retrieve the file field information.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.