Step 5: Getting Profile Content into the Event Page
Now that I have an Event content type, and additional information in our user profile, I have to figure out how to stitch all of this together so that the user’s contact information, etc. is actually showing up on our sample Event. There are a few options for how we can do this:
- The User Reference module
This module allows you to create a “User Reference” field into a content type, and populate it with content. While we already have this in the Event content type, the only option for displaying this field is the user’s username as a link to their profile. This isn’t what we’re looking for.
- A Related User view
This option, using Views, is more complex, but gives you the most control over how content is output and displayed. For example, we have some extra information on the profile, such as Interests and Event Types; we really don’t need those to show up on our Event page.
- Creating a custom .tpl file
This option, arguably the most complex, also isn’t very sustainable. You’d start by copying
node.tpl.phpin your theme file and calling itnode--event.tpl.php.Note: This assumes that your content type’s machine name is
event; you can create a custom .tpl for any content type by adding--CONTENTTYPEto the name of the file. From there, you’d use custom code to manually insert the individual fields into the .tpl file.
Although the last option can give you a lot of control over the code you output, there are several reasons this approach can ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access