0

I'm trying to figure out how to display a particular entry ONLY to the logged in author of the parent entry AND to any authors of related field included in the parent entry.

This gets me 1/2 way there: {if logged_in_member_id == author_id}

What do I need to add to this conditional to pickup any authors of a related fields?

1 Answer 1

0

Not entirely clear from your question what you are trying to do: what are "authors of related field" ... ?

  • You might mean "authors of entries that have the same category"
  • You might mean "authors of entries that also link to the same value in a shared 'topic' field (e.g. a select drop-down)"
  • You might mean "authors of entries that have a relationship field that establishes a link to a particular other entry in the site database"
  • You might mean "authors of entries that have the same value chosen from a 'Pro Variable' field of some kind"

It also is not clear whether these target entries come from any channel, a sub-set of channels, or the same channel that the entry you are getting the author details from.

In general, the solution to the question is probably the same regardless of how these questions might be answered, but the specifics of how you go about implementing it will vary significantly depending on any specifics that might come from thinking about such answers.

So in general, you probably cannot come up with a conditional that can be applied to just one channel entry listing to solve this. What you need to do is approach this via multiple steps. Broadly something like:

  • Work out what channels might contain the information you are looking for and list the contents of these - saving the author field_id and either the entry_id or the url_title of the records they contain, along with whatever the "related field" value is that you want eventually to pair up with the entry concerned to a set of layout variable arrays (i.e. one layout variable array for each factor). If you need to run multiple channel entries calls to get this information you can simply run multiple channel entry loops in series and append the results - to end up with a set of arrays that collectively contain all the records that might be relevant to your query.

  • Next you need to identify the "related field" value is for entry whose visibility you want to control. To do this, run a layout variable replay loop using the arrays you built in the first step. Run through your layout variable array (this, due to the limitations of layout variables will need to be happening on the "next" template in your template layout stack) and use a conditional to save from this list the author_id's for each value in your array set that has the appropriate "related field" value. This intermediate layout variable array will contain the author_id's of all the people who can be allowed to 'see' the entry concerned.

  • Next you need to turn your intermediate layout variable array into a pipe separated list of values. You can do this by (on yet another template in your stack) replaying the intermediate layout array and building up your pipe separated list in a regular layout variable (if you are good at this sort of thing, you possibly could create this pipe separated list as the output from the previous step and miss this step out).

  • Finally you need to use this pipe separated list in your conditional determining whether or not the visitor can 'see' the entry or not. You can do this using the "contains" conditional operator to compare your visitors logged_in_member_id with the values in your pipe separated list - if the value is found, show them the content, if it is not, don't.

The above is not hugely efficient: if you have the skills doing the above in an add-on would be better - but it should do the job.

HTH

🐾

3
  • Thanks for your mindful response. I think you've covered the possibilities so well that I may be able to execute my objective with your notes.
    – Ron Flack
    Commented Jul 24 at 12:40
  • I'm building a collaboration utility for my recording clients. We have a pool of session players who all are Members. PLAYERS channel. They author their own profiles. Then we have recording clients who are also Members and author projects. CLIENT Channel. Clients can add session players to their projects via relationship fields. I'm trying to create a means for clients to grant access to session players by simply relating them to their projects.
    – Ron Flack
    Commented Jul 24 at 12:48
  • Can you explain a bit more about how players need to view a client project. Do you mean that, when "related", a player can view a clients project? Commented Jul 26 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.