We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36635
    • 41 Posts
    Hi, I’m using a few template variables as foreign keys to other documents. For example, I have an "Art" branch and an "Artist" branch in the document tree. An Art document has a template variable "artist" that holds the id of the artist document.

    I’m trying to figure out the best way to provide foreign key document values to the document template. For example, in the Art template, I want to display the associated Artist name and country (page title and TV ’country’ in Artist document).

    * I can have a snippet that gets the ’artist’ tv, looks up doc, and returns an item from that doc. This could be fetched, stored and accessed for the entire template also.

    -OR-

    Can I fetch the values and append them to the current Art document and access them with [*artistname*], [*artistcountry*] for example? This makes it much easier on the designer and editor.

    If I add values to the current document, can they be accessed using [*fieldname*] syntax?

    Or how do you handle this issue?

    thanks,
    ---avibodha




      • 727
      • 502 Posts
      I would write a snippet to fetch the data and store in a PHP array. That array can then be used in subsequent snippets on the same page.

      Andy