Jump to content
  • [Beta2] Template hook for staffInfo in front/staffdirectory/layout_blocks (and other layouts) does not work


    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


    User Feedback

    Recommended Comments

    Dreadknux

    Posted

    I believe this is fixed in the next Beta.

     

    Esther E.

    Posted

    1 hour ago, Dreadknux said:

    I believe this is fixed in the next Beta.

     

    No, that's a different issue. John is actually asking for a template change.

    BN_IT_Support

    Posted

    1 hour ago, Esther E. said:

    No, that's a different issue. John is actually asking for a template change.

    Esther,

    Exactly - thanks!

    The reason being that the hook point is currently pointless (under Beta2) - Of course, I'm presuming that the only variables from the template that are available to the hook code are the variables that were initially passed to the template - not variables created within the template. If I got that wrong, then ignore me 😉 except there must be some other explanation that the hook code cannot currently access the $user variable.

    Thanks.

    John


×
×
  • Create New...