Twig Objects and Array Keys

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:04
    with Leanna Pelham
  • 0:09
    Until now, we've been working with simple values,
  • 0:11
    like page title or products, which is an array that contains
  • 0:14
    simple values where we loop over and print each out.
  • 0:17
    Now, let's make things a bit more interesting.
  • 0:21
    I'm going to pass in a new variable called "pageData."
  • 0:30
    If you haven't seen the PHP code I just used to create this variable,
  • 0:34
    you could use the handy dump function to see that it's
  • 0:36
    an array with a title, summary, and hasSale keys.
  • 0:41
    So how can we get the data on the keys of the array?
Loading ...

Twig Objects and Array Keys

Loading...

Until now, we’ve been working with simple values like pageTitle or products, which is an array that contains simple values where we loop over and print each out. In this tutorial, you will work with more complicated arrays, using keys, and figure out how to get at object data as well.

Downloads: 
Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.