Hello,
(The same problem presumably applies to layout_full and layout_half as well as layout_blocks but layout_blocks was the only one that I want so the only one I tested!)
My objective is to add the Corporate Email address to the display of each member in the staff directory. Obviously, to get there we need a hook point that gets called for each staff member in turn so that we can add the Corporate Email address for that member. We are part way there - so thanks to the developer(s) who has at least done half the job 😉
What we do have is the staffInfo hook point so we can add some text (or similar) at the bottom of each entry in the staff directory.
What we do NOT have is any way of knowing which staff member is being displayed. So, for example, if there were 10 staff members then our code would be called 10 times and we could add a block of text to the bottom of each entry in turn. The problem is that because we don't know which entry we are processing at any moment in time we cannot vary the output according to the member - in particular, we don't know which Corporate EMail address to retrieve and display for the member currently being processed.
With the old V4 hook points this was easy as our hook had access to all variables at the point of the hook so we had access to $users, $user, $user->member() and so on.
After a little bit of investigation under V5 it appears that we do not have access to all variables - only those that were used to call the active template - in this case front/staffdirectory/layout_blocks. And that is not useful in this case as the template has been called with $users as the complete list of all users in the staff directory. Thus - we know who all the members are but we don't know which member we're processing at any moment in time.
If the above analysis is correct then I believe the solution is fairly simple... front/staffdirectory/layout_blocks contains a foreach loop {{foreach $users as $user}} so if the content of that foreach loop was moved to a subordinate template file then the only line required within the foreach loop would be a call to that new template passing $user as the parameter. If this was done then my code would be able to access the $user variable and would be able to add the appropriate Corporate Email address to each directory entry.
Thanks very much.
John
Recommended Comments