Adding new variables with preprocess functions

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:02
    Adding New Variables with Preprocess Functions
  • 0:04
    with Michelle Lauer
  • 0:08
    In this chapter, we are
  • 0:09
    going to discuss adding new variables to our theme
  • 0:13
    that can be used in our page.tpl.
  • 0:16
    I have been tasked with replacing the static text in our template,
  • 0:22
    and creating a new variable that changes whether you're logged in
  • 0:27
    or not.
  • 0:27
    So if you're logged in, the footer area should say,
  • 0:31
    welcome-- whatever your username is-- Lullabot loves you.

Adding New Variables with Preprocess Functions


Continuing on our work with preprocess functions, we look at how to add a new variable for our template files to use. We also see how to change the output based on whether the user is logged in or not, and how to add a variable to the t() function.

Additional resources: