Welcome to Ancestral Health Today, Evolutionary Insights into Modern Health. Welcome to Ancestral Health Today, a podcast providing evolutionary insights into modern health. I'm Todd Becker. We're talking today with Dr. Anna Lemke. Dr. Lemke is the medical director of Stanford's Addiction Medicine Center, in addition to being a practicing psychiatrist and helping patients with their addictions. And her book, Dopamine Nation, Finding Balance in the Age of Indulgence, takes a deep look at the epidemic of addiction, not only to opioids and other hard drugs, but to a surprisingly broad range of rewarding activities, including food, gambling, sex, shopping, the internet, and, yes, smartphones. In her book, Anna lays out the behaviors and the brain processes that underlie addictions, including the central role played by dopamine. And her book also describes a number of practical and successful strategies that people have used to overcome their addictive behaviors, restore balance to their lives, and keep dopamine in check. So thanks for joining us on Ancestral Health Today, Anna. Thank you for inviting me. I'm happy to be here. Great. Before we get into the meat of your book, can you just tell us a little bit about your psychiatry practice and how you came to lead up the addiction medicine program at Stanford? Sure. So I first went into psychiatry wanting to treat mood disorders, and I was willing to see anybody with any kind of mood disorder as long as they weren't also addicted. But what I realized shortly thereafter was that there were so many patients with mood disorders who were also struggling with addiction that if I didn't figure out how to also treat their co-occurring addictive disorders, I wasn't going to make much headway treating their mood disorders. And so over a gradual process, I began asking patients about addictive behaviors to substances, to behaviors themselves, gambling, shopping, et cetera. And over the last two decades, I started seeing more and more people addicted to the traditional drugs like alcohol and cannabis and stimulants, cocaine, nicotine, but also seeing a lot of patients addicted to prescription opioids, prescription benzodiazepines like Xanax, prescription stimulants like Adderall. And then especially in the last 10 to 15 years, people addicted to behaviors, especially behaviors involving some kind of digital medium.  So kind of I'm an unwilling, initially unwilling practitioner in this space, but have come to really love the work that I do to have a tremendous regard for the patients themselves. Who are very courageous in their recovery journeys. And the great thing about treating addiction is that when people get into recovery from their addictions, they not only improve their lives, but they vastly improve the lives of the people who love them, the people who work with them, the people they live with. And so it can have a really tremendous positive impact. So it's really fun and rewarding work. So Anna, that's very interesting that you include a lot of activities as being addictive, not just the hard drugs, so even digital media. So it's really wide ranging and encompassing. So then in that case, how do you actually define addiction? Addiction is the continued compulsive use of a substance or a behavior, despite harm to self and or others. We think of addiction as a complex biopsychosocial disease. That means there are biological risk factors like inherited risk factors based on genetics. There are psychological risk factors like what we learn as coping strategies as young children are attachment to caregivers. And then there are sociological risk or environmental risk factors, like do we live in a world in which highly addictive substances and behaviors are readily available? And the answer is we do. So therefore we've all become potentially much more vulnerable to the problem of addictive use. So, yeah, so that's how I think about it. So it's really about whether it's harming your life and the lives of others. But then can it can there be good or healthy addictions like exercise or work? Yeah, great, great question. And so when I when I use the word addiction, I'm really equating it to psychopathology. So in my use of it, I'm using it in a very non-trivial way.  But really I'm using it in a clinical way to speak of something that maybe was originally healthy and adaptive or maybe just originally a hobby or a passion or an interest, but has become over time with repeated use, something that is not healthy, something that is maladaptive, something that has me caught caught in it, right? So that I have lost some of my personal agency with regard to that substance or behavior where I'm unable to cut back or limit my use or even stop when I want to. And even even when I can see the harms. So, but your point is a very good one. Like how, you know, how do we distinguish between a passion or a hobby or an interest and an addiction? And again, I would say that the main difference is that addictive behaviors are behaviors that we compulsively do to access to the point where we're causing harm to ourselves and or others. There is no brain scan or blood test to diagnose addiction, although there are actual brain changes that occur with the disease of addiction. We're not yet at the place where we can, for example, use functional imaging to determine who's addicted and who's not addicted. We're not there yet. So we base it on phenomenology, that is to say patterns of behavior. And we diagnose it based on diagnostic criteria that map to those patterns of behavior.  Tolerance is needing more of that drug and in more potent forms over time to get the same effect or finding that our at our current dose, the drug no longer did what it used to do for us. Withdrawal is the manifestation of not having that substance after our brain has become adapted to it and that can manifest as physical withdrawal. But the universal symptoms of withdrawal from any addictive substance are anxiety, irritability, insomnia, depression and craving. And craving is intrusive thoughts of wanting to use. So you're really looking at the effect on the individual and their behavioral characteristics and maybe some physiological characteristics. But what's interesting is, classically, you would think that certain drugs are just inherently addictive and, you know, opioids and maybe others like, I don't know, marijuana or cannabis or not. But can anything become addictive or are there certain inherent properties of things. People talk about, for example, supernormal stimuli things or they're just so inherently compelling. Or is that really a misleading way to look at it and it's more about the behavioral pattern? It's really both. So it's the inherent addictiveness of that substance or that behavior for a given individual. So this is really, really important because we're all wired slightly differently. And so when we speak about an addictive drug, what we really have to do is consider the substrate on which that drug is acting. What's interesting about intoxicants that we've known about for millions and millions of years is that they tend to mimic a chemical that our own brain makes. So we make our own endogenous opioids. We make our own endogenous cannabinoids. We make our own endogenous GABA, which is a calming neurotransmitter. Alcohol works on the GABA system and the opioid system. We make our own serotonin and oxytocin, which mediates falling in love. So, you know, we have all these chemicals and the standard intoxicants found in nature basically bind to the receptors that we have for our own endogenous, you know, feel good hormones and neurotransmitters. So those are these kind of inherently addictive types of substances that we're, we have a natural propensity to get addicted to. And most people exposed to those substances will develop at least some form of dependence, if not full on addiction dependence being defined as the brain changes that characterize tolerance and withdrawal. But having said that, we are now living in a day and age when almost all substances and behaviors have become drug-ified in some way, even substances and behaviors that we think of as healthy. For example, let's take our food supply with the addition of fat, sugar, salt, flavorants and caffeine to almost all of the things that we eat. Food has become a modern day drug, which explains the epidemic of worldwide obesity, not to mention the development in very modern times of full-on food addiction. People using food exactly phenomenologically as you see people using cocaine or alcohol or methamphetamine in an addictive way. We have digital media. Absolutely digital media is a form of a digital drug, especially for people, again, who are vulnerable to that particular medium. Now I would say most of us are somewhat addicted to our smartphones. So clearly these are naturally reinforcing and intoxicating devices and the content is naturally reinforcing intoxicating. But again, some people are going to be able to use digital media and digital drugs and realize, oh, wow, this is heading in a bad place. I'm going to self-correct and they will be able to self-correct. And then other people, probably about 5 to 10% of the population will not be able to self-correct and will become seriously addicted to digital drugs. And then those people, we're seeing that, right? It's non-trivial. They're anxious. They're depressed. They can't stop even though they want to. They're harming their loved ones, their selves, their jobs are compromised. They're thinking about ending their own lives because they can't stop using pornography or doing online shopping or online gambling or gaming or what have you. So we're in a really different world today where even something as seemingly healthy as exercise, which is healthy for the most part. And we'll get into this more later. I know actually has become a drug because we now have these machines that allow us to move through space faster and higher than we ever did before. We can count ourselves in myriad ways that make it a more potent drug. We can do exercise in a kind of social context, augmenting it with social media that makes it more inherently reinforcing. So now you have a very small subset for whom exercise is their potential drug of choice. Exercising to the point where they're harming themselves and others. Again, the key sort of diagnostic factor there. So Anna. By the way, let me just say cannabis is addictive. I just have to jump in because if you said something like cannabis, cannabis is so addictive. Oh my goodness, especially the cannabis of today where we've got like 90% THC content. We've got people primarily dabbing on a daily basis that is using the highly potent resin instead of smoking the plant. We were seeing more and more people who are daily heavy cannabis users. A kind of a week and bake phenomenon far different from 30 years ago where people were mostly weekend recreational users with friends. And people have full on cannabis addiction where it's absolutely destroying their lives. They have difficulty stopping. And when they do, they have a full blown withdrawal phenomenon. Hyperemesis. So terrible vomiting. In some instances, you know, a body aches certainly through the roof restlessness, anxiety, dysphoria, insomnia and craving, which are all, you know, also deeply biological. Yeah, so the subtitle of your book. And this refers to finding balance in the age of indulgence, age of indulgence. And this is really interesting to me because as you know, our, our society ancestral health society is really focused on this idea of evolutionary mismatch that somehow are we adapt. We were adapted in a very different environment than the one we we lived today. We evolved with all the same neurochemicals that we have. But there's something about the modern environment that has caused a mismatch. So what is it about modern times that makes people more prone to addiction or were humans always addicts? Yeah.  And when I think about that from like an evolutionary perspective, like why would mother nature conserve for this propensity for compulsive overconsumption? Well, in a world of scarcity and ever present danger, which is the world that humans have lived in for most of our existence, this would be a very, very favorable trait, right? People who are willing to work harder, walk further, trade more, sacrifice more in order to get the things we need to survive food, clothing, shelter, finding a mate. But now fast forward to the modern day. Not only do we have most of our basic survival needs met, at least in rich countries, but also in most of our emerging economies, that's increasingly true. But we've also, as I said, drugified almost everything in modern human life, turning almost everything into a potential drug, making us all much more vulnerable to this problem of addiction. And how have we done that? Four factors. Number one, we've made things more rewarding or reinforcing, which from a brain science perspective means that it releases more dopamine in our brain's reward pathway, dopamine being our pleasure and reward neurotransmitter. We have more of these drugs than ever before, right? So we don't like run out of stuff, especially when you think of modern drugs like social media, like TikTok is virtually infinite pun intended, right? You never run out of TikTok. We have more novelty. And one of the ways to overcome tolerance is to combine drugs together and make them similar to what you had before, but to change one little aspect of it. And the internet can do that in a heartbeat, right? Just combine two videos together, combine a gamify, a video game, or pornography, a social network. I mean, you name it, we just mix and match. And then finally, you have access. I mean, at the touch of our fingers, we have immediate access to these highly reinforcing images and human connections and games and what have you. Go right to our visual cortex and right to our reward circuitry and are highly potent and highly reinforcing. You guys mentioned that we can also have drugs delivered right to our doorstep as easy as ordering a pizza, as easily as ordering a pizza. So yeah, you know, so we, this phenomenon of, you know, our vulnerability to addiction is deeply rooted in our reflexive tendency to approach pleasure and avoid pain, which is the sort of most primitive functioning of our reward circuitry, which is what we have needed to survive these many millions of years. But now we did such a good job, you know, at kind of meeting our needs and then some that we are now, I think we've reached a kind of tipping point where now what was evolutionarily adaptive has now become a liability. That was a great answer. And you've identified these four factors that really are present in the modern environment that we didn't have in our in the course of our long evolution, the intensity, the abundance, novelty and access to all of these sources of pleasure and reinforcement. It's the same chemistry in our brains, the same reward pathways, but the world has changed, right? Right. And then you use another word gamify and that almost suggests that somebody's doing this to us, right? Maybe it's that clever marketers realize this and so they play on it and and they and they deliberately tap into this. So it's a play between just the sheer abundance and affluence, but also maybe some intent to get us addicted. Oh, without a doubt.  But the ways in which it's a terrible system is that the, you know, the ultimately successful, a final solution of any capitalist system is to turn us all into addicts, right, to have us consuming all day long. Every single product to be products ourselves, which we're seeing today, right, where people are now branded, they're branding themselves or they're using themselves to sell products on social media. Everything is gamified and gamblified. You know, you can walk, you can't walk into a public school classroom today and not see the gamification and gamification of our attempts even to learn. So, I mean, we, you know, our attention span has been altered by this. Nobody has the patience anymore to wait for anything.  I'm not, I'm not trying, I'm fighting against it, but let me tell you, I'm swept up as much as the next person. So, yeah, this is completely engineered. You know, when you think about especially something like social media, the algorithms learn where we've been, where we've spent time before, what we've liked. And then they essentially push to us similar content that ultimately studies show push people to more extreme versions of that content. And again, that accelerates the whole addiction narrative because as you're ingesting more extreme versions of that content, you're essentially having more and more responses, which is then leading to more tolerance and neuroadaptation, which ultimately then leads to you needing even more extreme versions of that content and on and on it goes such that we're caught up in this metaverse, even when we don't want to be there. I mean, that's, that's been absolutely engineered. Absolutely engineered. So hopefully, as we get into this discussion a little bit more, you're going to give us some defense strategies. Yes. So we're aware of this going on and then we can protect ourselves to some extent. Yes. So, but now let's turn to the central player in it's in the title. It's the first word in your book, dopamine. Can you explain what is dopamine and how does it function as this kind of universal currency in rewarding certain behaviors? Dopamine is a neurotransmitter. Neurotransmitters are the molecules that bridge the gap between neurons, neurons that belong spindly cells in our brain that work by sending an electrical impulse from one neuron to the other.  There's a little gap between them called the synapse, which allows for finer tuning of those electrical circuits. And that gap is bridged by molecules that are called neurotransmitters. They're released from the presynaptic neuron. They bind to a receptor on the postsynaptic neuron and they either then inhibit the conduction of another electrical impulse in the downstream neuron or allow that impulse to be carried out further. And this is happening at, you know, through billions and billions and billions of neurons all throughout our brains. Dopamine has many different functions as a neurotransmitter, but one of its most important functions is to mediate the experience of pleasure, reward and motivation. Now, when I say pleasure, what I mean is that an experience that gets the organism to feel in a way that makes them want to do that thing again. The reason I qualified is because there's enormous inter-individual variability in what might release dopamine in one person's brain, might not release dopamine in another person's brain. This is I think also part of Mother Nature hedging her bets, but some people are even stimulated by novelty or even aversive or painful stimuli, more than they're stimulated by typical intoxicants. And again, I just think this is Mother Nature making sure that within that tribe, we've got enough variety there that people are pursuing different objects of desire to make sure that as a tribe, everybody gets what they need to survive. Dopamine has been used by scientists over the last 75 years as a kind of universal currency to measure the addiction process in the brain to measure and describe what happens as people and as organisms become addicted. Dopamine is really the final common pathway for all reinforcing substances and behaviors. As I mentioned earlier, all substances and behaviors have their own unique chemical cascade, but they all ultimately will release dopamine in a dedicated part of their brain called the nucleus of cumbens in the ventral tegmental area, which is kind of like the accelerator part of our reward system. So is dopamine about pleasure or is it more the anticipation of pleasure? People say that dopamine rises before you get to this expected pleasurable event or does it rise during the event or is it both? All of the above and it really depends on where in the phase the organism is in terms of their exposure. So in the initial encounter with a stimulus, whether it's a behavior or a substance that is ingested, it will release dopamine or not, right? And the more dopamine that it releases with that initial exposure, the more likely that is to be reinforcing or pleasurable for the organism and the more likely the organism is going to say, hey, you know what, that felt really good. I want to do that again. And this maps very clearly onto the phenomenology of people with addiction who will say, I knew from my first sip of alcohol or I knew from the first time I smoked pot or I knew from the first time I saw a pornographic image that that was for me or maybe they'll frame it as that I was in trouble. However you want to think about that, there's this sense of, you know, a key fitting into a lock. But what happens is that with repeated exposure to the same or similar reinforcing stimulus, the brain adapts, which is to say it starts to down-regulate dopamine transmission in part, for example, by involuting postsynaptic dopamine receptors so that ultimately the transition of dopamine goes down so that you get to a point where you're in kind of a state of craving akin to a dopamine deficit state. And now your use of that substance might not even get you in the positive register. It might be just enough to get you out of dopamine deficit and feeling normal.  Yes, once they've already been exposed to that reward. Right? So you have to know what it feels like first and your body has to have said, ding, ding, ding, ding, that's for me.  And yes, we get a little mini dopamine hit, which is again a wonderful system that Mother Nature has invented that we kind of lay down this very long lasting memory for what gives us pleasure and what gives us pain. You can imagine that in a world of scarcity, I would need to remember where I found that berry bush. Right? That would be super important for me to find it again. So, but number one, the berry bush has to be pleasurable. And then number two, when I see a bush that's similar looking to my original berry bush, I have to also get some pleasure from that. Not as much, but enough to say, oh, remember that thing that felt good before? Here it is again. You know, go for it. So it's very adaptive then because you form this association. As you said, the berry bush or the deer is up that mountain. You've been there before and that little bit of association builds the anticipation, the initial surge of dopamine. And then you're not there yet. So you get this little bit of a craving and that keeps driving you to find the deer or the berry very adaptive. Oh, super adaptive, super adaptive. So this is a good thing. So then how does it become maladaptive? How does the addiction develop to a point where it's no longer in check? Right. Well, let me just say that there are these amazing studies they've done in mice where they put a probe in the nucleus accumbens, which is part of the reward circuitry to measure dopamine levels in a rat in response to certain stimuli, but also in response to reminders like the rat learns that if it presses a lever, it will get cocaine. So once rats learn that, they will press that lever till exhaustion or death because rats love cocaine. Now, if the rat then is trained to associate getting cocaine from pressing a lever only after it's seen a light, right? So it's not going to get cocaine every time from the lever. It's only going to get cocaine if it sees a light and then goes to the lever. What we see, and this is just to further describe what we've already talked about, but I think it's worth spending a little more time on, is that if you measure dopamine firing above baseline, obviously when the rat gets cocaine, dopamine firing goes way above baseline, at least in the early stages of exposure. But the dopamine levels go a little bit high when the rat just sees the light. Even with that, before getting the drug, there's a little bit of a dopamine hit followed importantly by dopamine levels, not going just to baseline, but actually below baseline. So I want to point this out because the state of craving is a profoundly biological state. The reason that we are motivated to do the work after we're reminded of our drug of choice or we have a sense that if we go to this place, we'll get more of it is because we are literally in a physiologic dopamine deficit state. And one of the major drives in all living organisms is to restore homeostasis or baseline levels. So we then crave because, not necessarily because we want that thing, but because we want to bring our dopamine levels back up to baseline. So what happens when people get addicted is essentially they've exposed their brains so often to such potent dopamine releases that the brain is reeling to try to compensate for much more dopamine than we were evolved for. And so in order to do that with repeated exposure, the brain down regulates dopamine transmission, down regulates dopamine receptors, not again to baseline, but actually below baseline, ultimately changing our hedonic set point or our reward set point, such that now our baseline level of dopamine firing is well below our normal healthy level. So now we're seeking out our drug all the time, not because we like want to solve a problem or feel good, but because we feel really, really crappy, right? Because we're in this sub-threshold dopamine firing state and we want to bring it back up to threshold. So it is this kind of chronic dopamine deficit state characterized by the universal symptoms of withdrawal, anxiety, irritability, depression, insomnia, craving that then drives the obsessive maladaptive reuse. It's again, people lose agency not because they're selfish and want to feel high, but because they're in a state of withdrawal that's very painful that they're trying to get out of. Yeah, so this gets to a very interesting model that you talk about in your book. It was developed by Solomon and Corbett. It's called the opponent process theory, right? I think that Solomon was first actually studying not addicts but skydivers. I didn't know he started with skydivers. He was interested in homeostasis, which you write about, and the brain doesn't want too much pleasure or too much pain, right? So the skydivers were exposed to this frightful situation, which you could call pain, but when they landed, they felt some degree of euphoria. And the more they did it, the initial shock and fright went down and the euphoria got more and more and more extended. And he said the same, the reverse is true with addicts where they're pursuing a pleasure, which at first is great, but then there's a little bit of a let down. The brain is homeostatically trying to blunt any extremes, so it has these counter regulatory processes or opponent processes.  And to the point where you're getting very little pleasure and a lot of extended pain. So he sort of had this model that, yes, we start with homeostasis, but if you do it too long, I think George Kub and Volko called it allostasis where your set point changes and you're no longer can get back to normal. So is this a correct model of what's going on in the brain, this kind of change due to these opponent processes that Solomon describes? Yeah, except that I think I would put some brackets around the skydiving as leading to more and more euphoria with repetition. Because what in fact what does happen is that those individuals eventually develop tolerance to that phenomenon and then become anhedonic. So there are a few studies. I was going to include these in my book, but ultimately, you know, they ended up on the cutting room floor. Couldn't include everything. But there are studies showing that individuals who are repeated skydivers versus individuals who are high level rowers, you know, rowing a boat, that they rate higher on the scales of anhedonia or inability to take joy in anything than people who are rowers. And so my theory about that is that and also I think that the studies on skydiving show that after the initial skydive, there's not much euphoria.  It's with the second and third and fourth where there's this thing. It's the repetition. It's the repetition that leads then to this, this, you know, basically post shock euphoria. But then with even more repetition, what happens is they become enured to that. And then it very much functions like an intoxicant and stops being something that that's that leads to more euphoria and instead does the opposite. So it's kind of kind of complicated, but it's nonetheless a good example of this this opponent process mechanism, which I talk about in the book, I use a metaphor of this balance or this teeter totter. Happy to go into that if you want me to. I really like that image of the balance or the teeter totter where you've got pleasure and pain. Can you explain how that works in normal life and then how can that teeter totter go wrong? Yeah, so for me, one of the really interesting findings in neuroscience in the last 75 years is that pain and pleasure are actually co located in the brain, such that broadly speaking, what we find through a lot of different types of studies, you know, EEG neuro brain imaging animal studies, the same parts of the brain that process pleasure also process pain. So I use this metaphor of the balance to represent homeostasis and how they do that. Imagine that in your brain, there's a seesaw or a teeter totter like in a kid's playground when it's at rest that central beam on the fulcrum is level with the ground. And that represents homeostasis or baseline levels of dopamine firing and neurotransmitter transmission. When we do something pleasurable, that balance tips to the side of pleasure. When we do something painful, it's tips to the side of pain. There are certain rules governing this balance. The first and most important rule is that the balance wants to remain level. And with any deviation from neutrality, our brains are going to work very hard to try to restore a level balance. How do our brains do that? First by tilting an equal and opposite amount to whatever the initial stimulus was. So if we do something like use an intoxicant that releases a lot of dopamine all at once, our brain will slam down hard to the side of pleasure. Very quickly, our brains will adapt to that by down regulating post synaptic dopamine receptors. For example, that's called neuro adaptation. I like to think of that as these neuro adaptation gremlins hopping on the pain side of the balance to bring it level again. But the gremlins like it on the balance, so they don't get off as soon as it's level. They stay on until it's tilted an equal and opposite amount to the side of pain. That's the come down, the after effect, the hangover, the blue Monday, whatever you want to call it. Now, if we wait long enough without using our drug of choice again, the gremlins get the memo, they hop off, and a level balance or homeostasis is restored. But the second rule of the balance, and this is the most important one for understanding addiction, is that with repeated exposure to that same or similar reinforcing stimulus, that initial deviation to pleasure gets weaker and shorter in duration, but that after response gets stronger and longer. In other words, the gremlins multiply. And pretty soon, you end up with enough gremlins on the pain side of the balance to fill this whole room. They're camped out there, not going anywhere. And now we're in addicted brain. We've changed our hedonic set point. Allostasis is what has occurred as opposed to homeostasis. And our brain does this in order to accommodate the changing environment, right? To adapt to the changing environment, which is how humans survive. We adapt to changing environments. It's what we do so well. But the problem is that when we're adapting to intoxicants or highly reinforcing drugs and behaviors, we end up in this vicious cycle where we don't see true cause and effect. And what feels like using to have fun or solve a problem is really just using to fight the gremlins and restore homeostasis. And that's that's what leads to this kind of compulsive over consumption, despite harm to self and or others. So you talked about in that last answer, receptors. And so this raises another question for me.  She sees not just lower dopamine, but lower levels of dopamine receptors, right? Less sensitivity or actually fewer receptors. So is somebody who's addicted, is it that they have lower dopamine or is it that they have a dopamine receptor regulation issue? Yeah, I think to understand this work, we just have to fundamentally understand homeostasis and the way the brain is trying to compensate for the fire hose of dopamine that it's getting from these highly reinforcing substances and behaviors for which it was not evolved, right? We were evolved to sort of have a pleasure pain balance that's slightly tipping to the side of pain every day because we're hungry and we're tired and we're cold and we're lonely. And then we have to do a lot of work to find a modest amount of food, including shelter, people that is enough dopamine to bring us level again and maybe the occasional extra berry bush to give us a little bit of a high. But what we have today is our pleasure pain balance slamming to the side of pleasure, not what we were meant for. And then in its effort to compensate slamming to the side of pain and what's happening neurobiologically is that the brain is basically down-regulating dopamine transmission in any way it can. So this would involve an involuting postsynaptic dopamine receptors, right? So there's less dopamine to bind to. It probably also involves decreased production or release of dopamine in the pre-synaptic neuron. All kinds of modulatory ways. But the bottom line is that with addiction and chronic use of intoxicants, we end up in a chronic dopamine deficit state. So our dopamine transmission overall is lower than normal. And this is the wonderful work of Nora Volkov, where she compares the brains of healthy control subjects, measures dopamine transmission in the nucleus accumbens, finds nice robust dopamine sloshing around, compares that to the brains of people who have been using heroin, methamphetamine, opioids, what have you, and finds that they don't have a lot of dopamine transmitting and sloshing around in the nucleus accumbens compared to the healthy controls. So these are not absolute levels. These are functional imaging comparisons. So it's relatively speaking. That's essentially that work. Is it kind of analogous with insulin resistance, where people have very high levels of insulin due to too much sugar in the blood and so they become insulin resistance because there's a down regulation of insulin receptors and then there's a vicious cycle. Is this kind of like dopamine resistance, where the transmission becomes less effective because there's so much overexposure to it that the D2 or D3 dopamine receptors kind of take a back seat? Yeah, exactly. Yes, that's a great analogy. And in fact, we often analogize addiction to drugs and alcohol to type 2 diabetes, because both of them are chronic remitting disorders with both a biological component and a strong behavioral component. And when you look at treatment, the treatment response is quite similar when we try to treat addiction and when we try to treat type 2 diabetes because again, it's a biological phenomenon. It's a mismatch with the modern ecosystem phenomenon and it's a behavioral phenomenon. So, yeah, that's a really good analogy. We talk a lot about dopamine, but I read another book by Judith Grisel, Never Enough, another former addiction patient who became an expert in addiction herself. And her contention is that it's not all about dopamine, that for example, dopamine is involved in addiction to stimulants, right, like cocaine, but then if you have, for example, opioids, that you're involving more opioid receptors or depressants like alcohol might work through GABA and glutamate. So, does that complicate the picture or is it basically the same story with those other neurotransmitters and you're just focusing on dopamine as the main actor? How do these other neurotransmitters factor in? Yeah, so I think the latter thing that you said, and these are complex chemical cascades, but what I'm trying to do is use dopamine and this pleasure pain balance as a metaphor for how to understand neuroadaptation and the homeostatic process. It's obviously not as simple as it's just about dopamine, but dopamine, again, there's probably the most research on dopamine with relation to addiction. We have great animal models. We have human functional imaging studies. So dopamine, again, has been kind of a currency and it's the final common pathway. Yes, it's true that stimulants will increase and augment dopamine directly into the synapse, whereas alcohol is mediated primarily by GABA and the opioid system. LSD is mediated primarily by the serotonergic system. Social media, love and sex addiction is probably a combination of serotonin and opioids primarily. So they all work through these different chemical cascades, but dopamine becomes a way... Right, but your seesaw would just apply the same across. So dopamine is a good example, it applies to these other mechanisms as well. Exactly, yep. Okay, great. So I want to leave some time to talk about the good news that people can overcome addictions or at least turn them into more adaptive kinds of behaviors. So you write about a number of strategies that have been successful for overcoming addiction and they're all about getting back to balance, right? Right. So one of the first ones you talk about is essentially abstention, right? Doing without the pleasure for a certain period of time. How does that work? How long does that take? So going back to this metaphor of the gremlins and the balance, essentially the way to restore homeostasis and get back to baseline healthy levels of dopamine firing is to abstain for long enough for the gremlins on the pain and the balance to get the memo that they need to hop off so that the brain says, oh, okay, we're not getting that, you know, that exogenous stimulation anymore. Time to start to re-upregulate dopamine transmission by recreating our dopamine receptors in the postsynaptic neuron, increasing dopamine production and other feel-good neurotransmitters. So it does start with that period of abstinence. On average, it takes about four weeks for people to begin to feel that they're out of that, you know, the clutches of painful withdrawal, the first 10 to 14 days of abstinence tend to be extremely difficult. But once people can get through that initial hump, whether your addiction has video games or pornography or sugar or cannabis or what have you, and by the way, with any kind of pornography or sex addiction, we ask for abstention from orgasms with self or others, because they're really the, ultimately, the drug or the culmination of the drug is the orgasm. And if people are able to abstain, then by weeks three and four, it's not that, you know, their addiction is cured or that they feel 100% better, although some people really feel a lot better in that timeframe, but it's that they begin to get out of this, the clutches of constant craving that feels so insurmountable. Once that happens, then people have a kind of a clarity and our ability to sort of look back and see true cause and effect and how their behaviors were really impacting their lives. They're able to make a more reasonable plan for how they want to maintain recovery, what recovery looks like for them. For some people, it's continued abstinence. For other people, it might be going back to using their drug, but using it differently, using it more moderation. When we're dealing with things like food addiction, obviously people have to eat. You know, we're not saying don't eat for a month. What we're saying is avoid food additives and highly processed food, avoid sugar, which is clearly a drug. Avoid, you know, caffeine, salt, all of that. So, you know, if that's their particular drug of choice within the food category, people have to identify what is it for me.  So, but it does start with the hard road of abstinence. That's for sure. And I think it's important that you, how you've laid it out that there's a basis, a biological basis for your brain to recover. And that if you can get, it's going to be miserable, right? Especially the first two weeks. But by seeing this light at the end of the tunnel, do you find that that helps some of your patients stick it out because they know that something good is coming? Oh, yeah. I mean, and that's a lot of the psychoeducation, right? Explaining the neuroscience, explaining that what feels like is self-medicating their anxiety or depression is actually just medicating withdrawal from the last dose.  You know, saying it's going to validate, it's really hard, but if you can get through that initial hump, you really will feel better. A lot of patients come to us wanting help, not with compulsive overuse, but actually for depression, anxiety, insomnia, and people coming in with inattention problems and using cannabis, right? And are saying, well, you know, here's the first step to improving your anxiety and inattention is abstaining from that cannabis because by doing that alone, without doing any other intervention, you are likely to feel a lot more attentive and a lot less depressed and anxious. I do want to footnote all of this by saying that we would not recommend this intervention for anybody who is at risk for life-threatening withdrawal from alcohol, benzos, or opioids. For people who are at risk for life-threatening withdrawal, which can happen with those substances, they need medical monitoring and a higher level of care. So I want to just raise another alternative, and this might be controversial, that some have felt that abstinence, it can work for a while, but it leaves you vulnerable to relapse because ultimately, let's say you avoid the cues even. You avoid even looking at alcohol or having certain foods in your house or pornography or whatever, but you're going to encounter that in the future. And then you've relit the fuse and the association is there and it's off to the races. So there's another strategy called Cue Exposure Therapy and there's a study by Conklin and Tiffany that training alcoholics or other drug addicts to deliberately expose themselves to the cue, handle a bottle of gin or paraphernalia and resist the temptation, but do it in a realistic environment rather than off in a rehab farm where you're isolated from that might inoculate you more toward those cues. What do you think about that as an alternate strategy or do you think that that doesn't really work? I don't think those are dichotomized strategies. So to me, you need both abstinence-oriented strategy initially in early recovery. And then if you wanted to do something like a cue-induced learning paradigm later when you have more health and you've reset reward pathways, then that would be totally appropriate. Let me just go back though a second and say that it's universally true for almost everybody who is trying to get out of an addiction loop that abstinence is a state of vulnerability in which relapse is always possible, especially living in an ecosystem where we're surrounded by drugs and triggers for drugs. And so that becomes the major challenge of anybody in recovery from addiction or even if you don't self-identify as having addiction, anybody who's trying to manage compulsive over consumption at any level we're constantly being triggered and tempted which is where I talk about these self-binding strategies where we create both literal and metaphorical metacognitive barriers between ourselves and our drug of choice to help us manage consumption in an environment that's constantly titillating us to consume. And I think the cue-induced exposure therapy first you have to start with abstinence to reset reward pathways. And then you have to have a goal. Is your goal continued abstinence? Is your goal moderation? And then to me an added layer of that is, okay, let's enure ourselves or let's develop some mental calluses to these cues. But you have to do that from a position of strength. You can't be in like a cute withdrawal and be like, here, surround yourself with beer bottles or something. Most people aren't going to be able to do that. Now some people will. So for example, it just comes to mind, a patient of mine who actually was drinking kept one beer in his refrigerator and kind of thought of that as the totemic beer. So for him that was symbolic of like all of the beers that he was not going to drink. And for him it was an emblem of his ability to control his impulses. So, but that took on a very kind of sacred almost symbolic meaning for him rather than that he was constantly surrounded by a bunch of beer and people drinking beer in early recovery. But everybody's different. For some people, the cues are really triggering for other people, not that much. Let me say that a little known literature which goes even further than this cue exposure is to actually expose people to a cue of their drug of choice and then actually give them an aversive shock, which is interesting, right? So give them a painful aversive shock when they're seeing a cue so that their brains then come to associate the pain of the shock with the cue and then you hope there's some rewiring there. That's also by the way how hypnosis probably works.     Every time I smell a cigarette, it makes me feel nauseated. I wouldn't want to put a cigarette in my body. So it is really fascinating. Yeah, I've heard of that. The aversive conditioning reminds me a little bit of Clockwork Orange. The movie, right? No, all of these things. But I like your answer how it's not an either or that there's maybe stages of recovery and the abstinence comes first. That's a great answer. The strategy you mentioned is near and dear to my heart. I write a blog about this and that's Hormesis.  What you call pushing on the side of pain, making us more tolerant to discomfort or pain, can actually help restore that balance by then eliciting a counter process of pleasure. So for example, and this is something I do when you write about somebody in your book who does this, cold showers or cold plunges, right? Very uncomfortable. But there's an adaptive process that goes on there where actually that becomes much more tolerable and you get a feeling of well-being afterward. But can you actually use that as a deliberate way to counteract addictions? Absolutely. And we prescribe Hormesis. So Hormesis is Greek. It means to set in motion. And basically it's a whole branch of science that shows that if you expose an organism to mild to moderate doses of toxic or aversive painful stimuli, you actually stimulate the bodies or you set in motion the body's own healing mechanisms. You get the body to upregulate feel-good neurotransmitters like endogenous opioids, endogenous cannabinoids, endogenous serotonin, and also endogenous dopamine production. So and there are experiments showing that one of the most effective forms of Hormesis is exercise, right? When people exercise, we can measure their dopamine levels and what we find is over the latter half of the exercise, dopamine levels gradually start to rise and then remain elevated for hours afterwards before going back down to baseline levels. So we never go into that dopamine deficit state. That is the state of craving that triggers the addiction loop. And we do that by paying for our dopamine upfront, which is really how we evolved, right? To have to pay for it upfront, not to get it so easily. Yeah, no, this is my personal experience with cold showers. You get this extended feeling for hours. Exercise the same thing. And another form of Hormesis I would throw in there is intermittent fasting. You actually can get a great feeling of well-being once you're able to do it, right? But there's many other examples of Hormesis, yes. Right, but what I always want to emphasize here, because I think it's so important, is that it needs to be right-sized pain. It needs to be not too little and not too much for a given individual. And I especially want to emphasize that if it is too much, basically what happens is we get a flooding of our neurotransmitters as the body registers, not merely, oh, there's been an injury. I need to up-regulate my healing mechanisms. The body registers, I'm going to die. And there's this flooding, which is what happens with skydiving, which is why ultimately those types of activities I don't put in the category of Hormesis, because they're not maintainable. And they very easily become like drugs and lead to addictive maladaptive behaviors. Self-cutting is another one, where we get a flooding of endogenous opioids in response to cutting. But then we kind of break that pleasure-pain balance. We don't make it more resilient. We kind of just, you know, explode the whole process. So it's really important that it's the right size pain. I also want to emphasize that just like we've drug-ified and made more potent, available, abundant, and novel intoxicants of all sorts, including drugs that didn't exist before, we've also made it much easier to get addicted to hermetic or painful things like work, like exercise, like, you know, cold showers, like intermittent fasting. I mean, we've done that, you know, through kind of this general drugification where we now have machines that augment all of this. We have social media that augments all of this. So it's really important to see that in the world today, even what we traditionally think of as healthy and adaptive behaviors that would be very difficult to get addicted to and probably are more difficult to get addicted to because they're just hard to do, you know. And most people are just not going to get addicted to them. We're seeing more and more people addicted to these kinds of activities, again, because of the way that technology primarily has turned even these behaviors into intoxicants. Really, really good point. And it comes back to your central theme of balance, right? It's in the title of your book is, in any of these approaches, you've got to find that balance. Right. And as you said, the hormesis can go to such an extreme that it pushes us out of balance. I want to get to, I think, two other points I found really interesting in your book that you say have been very helpful in people in their recovery paths. One of them is focusing on small tasks, focusing on things outside of yourself volunteering. And another one is what you call radical honesty. And I think both of these, you're not using any substances, any drugs or whatever, these are just mindsets. Can you talk a little bit about doing the small things in volunteering and radical honesty? And how does that work? Yeah, so these are sort of bigger topics, hard to do in the time that we have left, but I'll do my best. I think my main point, you know, I see so many young people in particular today who kind of like want to go out and save the world. And I think social media is a big driver of all this, feeling like you can't just, you know, do the thing that your neighbor needs help with.  And I think this leads to not just lack of efficacy and truly making a difference, but just kind of this feeling of like never measuring up unless it's this grand thing. But I wish that, you know, people would realize that just by kind of, instead of going inward and kind of imagining how can I save the world, it's much better to just look around you, go outward. And what are the little things that you practically speaking in your position right now could do to make a small difference today? And the cumulative effect of those small differences over time are really what changed the world, right? Every individual in small ways, in small moments throughout the life they've been given is really, I think, the great change agent of the world, although we don't usually think about it that way. And radical honesty is, again, something that I learned from my patients in recovery who have told me and taught me that in order to maintain their recovery, they can't lie. And it's not just they can't lie about their use. They can't lie about anything. They can't lie about what they ate for breakfast, why they were five minutes late to a meeting, where they're going to be spending Saturday night. They have to tell the truth. And if they don't, they're very quickly in danger of relapse, which is really a fascinating phenomenon. Like, what is the link there? And I speculate on a bunch of different layers of that and look at some science to potentially support the theory. But I think really radical honesty is a form of hormesis. It's hard to do. We're all natural liars. The average adult tells one to two lies per day. These are usually small lies to protect ourselves in some small way. We figure there's no harm done, but really there probably is harm done, especially to ourselves and probably other people too by the commutative property. But essentially what radical honesty does is it's an effortful thing that we have to commit to as a project and sort of watch ourselves do. And I think it bolsters true intimacy. It bolsters insight in our ability to really see how our actions affect the world and ourselves. And it also bolsters community. And so there are all these layers. And I infer from some studies that radical honesty, because it's an effortful thing, actually stimulates the prefrontal cortex. We know the prefrontal cortex is what acts as the break in terms of a repetitive control. And when our repetitive control is healthy, we have a healthy functioning robust prefrontal cortex. When we're in our addiction, our prefrontal cortex essentially goes offline. So I suspect that committing to the active engagement of truth telling is something that we can practically do in order to stimulate prefrontal cortex, which then enhances a repetitive control. Great. Well, I think those two pieces fit together nicely because they're practices you can think about doing daily, right? And you're building back to this balance that we need that is a defense against these unwitting forces that want to hack our dopamine systems and our pleasure systems. If we're aware of this, right, and we focus on what's right in front of us and being honest, maybe we can stave off, you know, some of those forces. I think it's a very helpful picture. Yeah. Not just for people recovering, but even preventative prevention. We can all use this. Yeah. Well, thanks so much for this discussion. I guess the last place I would leave it open to you would be to say, you know, is there anything you thought of including in your book that you left out that could be a kernel of a next book or something you're thinking about? Yeah. Gosh, I mean, I think probably the big one is the role of spirituality in recovery, you know, and kind of what, why it is that so many people with severe addictions have noted that a spiritual pathway is helpful for them. I find that really fascinating. So I would say that's the thing. I touch on it, but I don't delve into it in the book. And yeah, it's a hard one to add. It is. It's a whole human itself. Yeah, it's a whole separate thing. Exactly. Yeah, great. Well, that's a great place to end. And thank you so much, Anna, for this discussion. My pleasure. It was fun. Yeah, good. All right, take care. Bye-bye. Take care. Bye-bye. Again, we've been talking today with Dr. Anna Lemke, author of Dopamine Nation, Finding Balance in the Age of Indulgence. You can go find out more information also at her website, analemke.com. Thanks for joining us on this episode of Ancestral Health Today. We hope you enjoyed our discussion on how evolutionary insights can inform modern health practices. Be sure to subscribe to our podcast to catch future episodes.


All right, so I think we can go ahead and get started. All right, so you should be in the presentation view section if you're in the wrong room. Feel free to exit. So what do we do when we need to store some data and provide a fancy display for our end users? Say we have a company with information about employees, and that company wants a directory display on their website. Well, maybe it's not for a company at all, but instead a supervillain named FiloniusGrew. So it seems like a fitting client as most of mine act like supervillains from time to time. So if you're familiar with Grew, you'll know the infamous minions that helped him carry out his evil bidding. And Grew has assigned his minions tasks. And through these tasks, they inherit job titles. And as a web developer, it's our job to create a presentation of this data. So today, we'll demo a solution for this, and I'll share a modular views concept I call Viewception. So good morning. My name is Brandon Ratzloff. You can communicate with me at Brandon Ratzloff on Twitter. I am a lone Drupal developer for conference management and event planning company. I have nearly seven years of Drupal site building experience. I started working on a content management system called Joomla. Might be familiar. At one point, I was looking for a solution to sell video subscriptions. A friend of mine pointed me to Drupal 6. I found an Uberkart node access module. And from the vague module description, seemed like the adequate solution. So I found Drupal had a much higher learning curve. But thanks to the amazing Drupal community, I got to where I am today. For example, I can give myself a fancy title like Site Solutions Architect. So as a Drupalist, I've come to the conclusion that I'm supposed to know it all. And honestly, when dealing with clients, I do have to know it all. So win site building, try to know it all, and know it all the Drupal way. So the goals for this session are going to be think more deeply about your content structure. Content is stored in the database. So think like a database administrator. And I'll help you expand your views toolbox. We'll review a few modules, give us more flexibility and functionality. And we'll help take control of the duplicate results in views. So why views returns duplicate results and propose a solution. And I'll share a modular views concept. And we'll explain how to break our views into pieces and then recombine them. So again this morning, I will review a little about relational databases and data modeling, why relationships are necessary and how they complicate data removal. We'll look at a different approach to displaying content through modularity in views. I'll perform a live demo on combining multiple views to gain ultimate control. So we're gonna stay 100% in the user interface today, so plan accordingly. So let's put a few things into perspective and talk a little bit about this data modeling. So in a database, tables are used to organize different types of content. The complexity of the content sometimes requires us to organize the data into parts. And these parts become separate tables in the database. If different types of data relate to one another, you can connect them. And these are called relationships. A table's given relationship to another is referred to as its cardinality. These relationships might be a one-to-one, a one-to-many, or even a many-to-many. And a one-to-run relationship might be employee to their name or a minion to their photo. And a one-to-many relationship could be a department to their various employees or a minion to their assigned tasks. So has anyone ever seen the Drupal's entity relationship diagram? Hands? Yeah? Some? This is a picture of Drupal 7's database tables. So every box here is referred to as an entity table, and the lines represent the relationships of cardinality. I might note this is without any additional content types or fields added. It's vanilla Drupal. So as you can see, a data model can get very complicated. So why review these modeling basics? Because creating content types and adding content is a form of data modeling. And views looks directly into your database to create its displays. So when creating content types, the Drupal user interface reacts with the database and does all the grunt work. Drupal works very well as a data modeling tool. The bottom line is to know every time you create a new content type or a field, you're actually building tables in your database with these relationships. So here's just an example of a data model, maybe with Drupal terminology. And then we can see how that data model might be translated into human readable terms. So how do we get the data out of this database we've been designing? So we use a language called SQL, structured query language. It allows us to interact with the database and we use CRUD operations, which are create, read, update, delete, right on our database. So we can write select statements to select and retrieve our data. If we have multiple tables relating to one other, we can use join statements to bring them together. It can take extremely complicated queries to get the data we need. So I found this image lurking on the internet. I was not aware until this time you can write a six page query, apparently. So yeah, if this is your idea fun, we probably won't have a lot in common. But enough of this SQL data modeling junk, let's get down to business. So what is views? Views is a query building and inspection tool. So it allows you to create a page or block or attachments displays right out of the box. It uses render plugins to output various different types of markup. So a large majority of your database is available through views as long as it uses the entity's system. From the module page, it does say you need views if and it lists some common reasons. I propose we say anything worth doing requires views. Views however powerful still requires you to know what you're building. And so a quick overview of what views does do for us. When adding a new view, we're starting our select statement in the query. So through the add new view screen, we start by choosing our base table. It will allow us to set up some filters like the type of content. These are actually where clauses in our query. And this page will also give us a sort order, which is order by clause. And then finally, the number of results, perhaps, which is the limit clause. So with these options selected, we've actually built a full query and views can use it to render our content. Some of you may not be aware, but you can actually inspect your query directly in the preview section. I don't think this is set up by default. For this, you can change your views settings and that's available at admin slash structure slash views slash settings. And I do advise you take a look at this page. There are many tools that can help your mastery of views. So one way to help you understand the views interface is to split it into parts. So one for formatting a display and the other for how to select and filter your query. As shown in yellow, we can see our selected fields, relationships and contextual filters. And then blue shows us the type of page block or attachment, so the type of display. And also the markup formatter and other page settings. So now we're pretty much ready to build our view. We know all these things. So looking back in our slides, here's a refresher on the data model we've designed and a quick diagram showing the relationship between our minions, their jobs and tasks. Sorry, there's a little typo there. You may expect this model to complicate your views results. And so a common problem when querying data models like this are duplicate results. So if we try to select every minion and his tasks, we've actually joined our one to one fields, the photo and name with our one to many, like the tasks and job titles, together. So when we print our results row by row, we'll get a multiplying factor on our fields, generally one set of minion fields for every term. So some solutions might be aggregation. It tries to combine all the common fields and it's kind of applied to all parts of the view. I think it seems a little clunky and it doesn't give the control I'm after. Also there's a setting in the query settings called distinct. And by definition it's meant to display only different or distinct values from a table. It'll only work in specific use cases. So a module I'm not gonna demo today but deserves honorable mention is views distinct. And views distinct is intended to assist in the removal of duplicates on individual fields. It provides aggregation or filtering options per field in your view. So it's worth taking a look at. So if not for these more common approaches than what? Viewception obviously, right? So viewception is a modular views building concept that provides full control over each level of your view. It leverages the help of views field view module to embed views as actual fields. So our goal with this concept is to build each view out to provide just the necessary results and then recombine them. So in a demo I'm about to do, I will go ahead and build three different views. It's gonna be one for the minions themselves and one for the job titles and one for our tasks. So then we'll combine them into one display like it's illustrated here. So that's all I have for the slides and I'm gonna try to see if I can't change my display here and get the correct thing showing on the screen for you guys. All right, so we all should see the minion directory website here. Is that what we're seeing? Got a look for myself. Okay, so I've pre-made a few things in this website for us to move us along. So the first thing I wanted to talk about is whenever you're creating anything, of course, you wanna prepare your content. So you wanna gather your content types and if you have taxonomies, you wanna get those in order. Be a forward thinker, I guess, when designing these type of things. So the first part of this I've actually set up is a taxonomy with jobs and this uses a hierarchical structure. So this is something you may or may not normally run into but I wanted to show this because it's kind of an advanced way, I guess, to deal with these type of hierarchies. So in this case, I've actually done something where you've got your job titles on top and then perhaps the tasks underneath so it's a parent-child relationship in that way over here. So then I've gone ahead and created the content type minion. I've just changed the title field here, the label to name so no big changes there. Added a photo field and perhaps what a minion loves just to add a little bit of flair to our minions themselves and then I've gone ahead and used a term reference field which is pretty common to actually build that relationship between my minions and that vocabulary of the different jobs. And so just to kind of preview what I'm gonna put together for you today, we should end up with a display with something like this. So there's actually three views, different views working here and they're all embedded together. So I know demos are sometimes looked down upon but I'm going to go through this and I think we're gonna be successful so no worries. And just in case I've got them all pre-made so we can just look at them if we want. All right, so the first view I wanna make is going to be for my minions themselves. Make sure that's what I actually wanna do. Look at my little demo outline here. Okay, so I'll just give this a quick name and for this we're actually jumping right into the content tables and we're gonna go ahead and use a filter for minion and I don't care about how it's sorted and I'm not actually creating a page because this particular view is gonna be embedded so I'm just gonna create a block. So I continue and edit that. First thing I wanna make sure of is that all of my items do display. I don't need any limiters on this. I don't like that that's actually a default in views but I do understand. So I'll change the format settings. I like to use a module that enables semantic views that just gives you a better markup results. And then we're actually gonna choose to use show actual fields here so we're not using a view modes or anything like that. So in the fields I really, I just want the title. I'm gonna want the photo and then what a minion loves so we'll just add those really quick. Manipulate a few of the settings. We don't need any of the labels, the formatter for the loves is just fine. It's just a plain text field. Remove the label for the image. Got some pre-designed image style here. I think that's actually default. I'm gonna copy in some classes that I have to make everything look a little bit better. All right so once we do have those standard fields, those are like I said the one to one type of fields. I'm gonna rearrange these real quick. I actually want the photo on top. I'm gonna add that relationship to its jobs or to each minion's tasks here. So I can just go through the content, add the actual, the content jobs field there so I'll get that term reference connection. And what I want to build here is I only want the results from an individual task. So I'm going all the way down the tree and I'm gonna decide that if he is a dishwasher then I only want to receive those minions as results. So I'm gonna add a contextual filter here based on that relationship that I just built opens up the taxonomy terms for me and simply use the term ID because I'm not gonna need to know this. Later on it's gonna be automatically embedded so I will add that and hide the view if nothing is provided. And then we get no query down here. I do know, I believe it's eight. Eight should give us a set of the minions that actually are the dishwasher so we have three results there. There's no titling of the terms or anything like that. That's exactly what I want. So I can go ahead and save this particular view and I'm going to add now my tasks. And for this we're gonna start directly in the taxonomy table and go ahead and filter out based on our jobs. And again this is just going to be a block because it will as well be embedded. So we continue and edit that. Gonna remove or go ahead and display all those as well. And here I'll just use the semantic views formatter again and the key is of course we want to get the fields printed in here. So at this point we are looking at receiving all of our sub, we want to try to get all of our sub tasks and we can see that we've really just queried all of the tasks on an equal level. So Mad Scientist no longer has its hierarchy. So here's kind of an interesting trick and maybe you can add this to your views arsenal. So how we want to go ahead and parse out the tasks instead of getting the parents, we can add a relationship and this is kind of an introduction of a module. I believe it's called views arg parent term. So write that down views arg parent term. And so that gives you a new taxonomy term, parent term relationship that I can add to this particular view. Use the identifier parent. And so nothing has changed at this point. We're just identifying the parent and what I want to do with that relationship is go ahead and add a filter and I can use the ID again and I'm going to use that parent relationship and here I'm going to make sure that it is not empty. So therefore we know that there is a term above it and this actually identifies that it is a sub term so it's a child in this case. So now we know we're only getting our tasks in our hierarchy that we've created. So I scroll down here, we see that I've now removed the top job titles as I've referred to them. So this view is done for the moment. Well at our final view and this actually going to be a page view so this is going to be the jobs themselves and this again is in the taxonomy terms table because it is for the job titles we're looking for. Sorting doesn't matter but we're actually going to create a page this time. Like I said, we'll just use the path demo. Minion jobs helps to practice this before so it's auto filled in. Here we'll use that semantic views and fields once again. I want all everything to display there so I don't need pager. Continue and edit that. I apologize, I want to go back here real quick. I did want to actually test this so if I put in mad scientist for example on the tasks view that I just created and update that preview, I should get, oh, okay so this is why demos get a little hairy. The one last thing I did want to add to my tasks view after the highlight of only identifying the sub tasks is I wanted to add a contextual filter and then only get the chosen tasks that I actually wanted here so I was meaning to add another contextual filter on this view and I'm gonna use that parent relationship once again there so then if I do select five for example being a mad scientist I do only get gadget tester and toxic waste on dumper because those are the tasks of the job title so I apologize for having to go back there. Okay so back on the job titles we're just trying to get a full list of our job titles here so just like on the previous view we're gonna wanna add that parent term relationship once again with the parent identifier get a filter in here to remove all of the child terms and so in this case we'll use that parent relationship but we're actually gonna make sure that it's empty because we don't want anything above it so when we apply that to the display we will end up with just our three job titles as we've defined them and so that's actually where I'm looking kind of phase one so I've built all three of the views now I actually wanna take each individual one and kind of plug them into the other and like I mentioned the views field view will allow us to do that so I will start back on my task view and remember just doing some checks all right so I'm actually looking to add underneath gadget tester and toxic waste dumper the view of the minions parsed out using their taxonomy or contextual filter to give me just the results I want so what I'm gonna use here is I'm actually gonna add a view and after enabling the views field view module I get this global view and I can add this in as a field and it gives me a couple extra options here and the key items you wanna look at is actually what view we are inserting into this field and so in this particular case we're on the tasks view so I want only the minions brought in here so I'm gonna choose my demo minion directory and I can choose the block or master whatever display you've created and the key here is we can actually send architectural filters or send a token or send any identifier we want to the other view through this so when I apply the display I actually don't have any changes just yet because I didn't have a field to add to push over to my minions view for that contextual filter and remember on the minions view our contextual field was filter was actually the term ID so in our tasks view I need to add that specific term ID to our field set here so I'm gonna go ahead and add that I don't need this displayed at all it's just to use in the views field and of course when creating your views in this way we need to make sure if we're going to get the tokens and such available in the replacement patterns we need to have our fields above the other field so I'll put my term ID above my global view that'll actually give me a replacement pattern for that term ID which I can plug in to that view field and once I've done that I've actually passed the taxonomy term for each individual row of a task to the minions view and so when those are combined together in this way I should receive gadget testers or Dave and Jerry and the toxic waste dumper would be Tim and George so at this point it's just up to you to work on how you'd actually like to display that but you have control over each individual level that way so I'm gonna save that one and the final thing I wanna do is go ahead and basically do the same to my job titles view so knowing that I have to add the term ID here I'm gonna go ahead and do that and then add my global view field view and one more time and on this one I'm looking to select the tasks view that I've created and I'm gonna use the term ID once again in the contextual filter because that's what I'm actually passing down to that other tasks view that I created so here we should be able to see exclude that display so we should be able to see now the gardener and his tasks and then the actual minions then are attached to the tasks which are then that group is then attached to the job titles so I think it's a pretty cool concept let's go back and take a look at what I actually you can actually turn this into so the mad scientist again was the job title in this case and then a sub item the terms would be gadget tester and then I've attached the different minions directly to gadget tester and attached gadget tester to the mad scientist so I'll take a quick look here at the view I just created and all right so it doesn't look like the other view that I created and again as I mentioned it's all up to you in styling so this is just a lesson in design I suppose I do have these individual items kind of blocked out and what you're able to do once you have this configuration is go ahead and define exactly how each individual view that you've created does look so if you need a view within a view to look different than maybe the top view or something like that you have that full control so that's a really great way to do your views that to gain that extra control anybody want to actually see just what I applied to actually get that visual styling is that important to anyone? Maybe, no? Okay real quick then so I've also used in the jobs there's another module you can use responsive grid views responsive grid I believe and I'm using a particular grid system here so I'm able to go ahead and change how many columns I want and so on and so forth and I think it's a bootstrap theme so I'm able to apply different classes just directly to each one of the individual views so I get the results that I'm looking for and I'll go to my pre-made view here just so we can see that so when I choose the responsive grid and go to my settings I'm using two columns for the different tasks and some different column classes to help outline that in the row and so on and so forth so it just kind of gives you a quick example of how much control you might gain over this actual display so that's the demo I think it worked out kind of, yeah? So really I'm ready to take any questions if you guys have any yeah so the question is about performance and I haven't spent a lot of time analyzing that specifically I'm running in kind of a varnished, cached environment and so with that I've had no real issues I will say there absolutely is and you need to analyze that this was pulling out five pieces of content with various fields so we're looking at a very small example if you have thousands and thousands of nodes it's definitely going to be a bigger hit than trying to do everything in an individual query and I'll say caching results are a little bit mixed because it's a query within a query it does if it tries to cache one you usually won't get the actual results you're looking for so usually you can't use full caching on in your individual views because of that yeah so views field view is the actual name of the module I'm using to it gives you that global global view field that you can plug in and you can actually use that I believe directly in the header and footer as well so it's another way right so I'll give you a quick example I have somewhere in the range of four or five hundred different abstracts on this particular website and I've actually built so all abstracts belong to multiple categories so for this example I want to be able to filter out only one category and not see the other groupings of the category so I've actually done a view in bed here so if I was to select one category I only see one title even though a different category might belong to category three or sorry a different abstract might belong to category three for example and so that yeah that's how I use that and so to directly answer the question I've used four or five hundred nodes in a query and this loads pretty quickly especially I'm logged in so it's just up to you to do kind of the testing there right so it's kind of a lesson in naming conventions I guess yeah and I struggle with that same thing so for this demo I started each view with the name demo you can actually use over two of you here so in our demo jobs if you wanted to you can create multiple displays and then once your view is saved then those become accessible to the to the view field so that's one way to organize it I think it just makes it more confusing in a demo case but usually that's something like I'll do and then I'll also combine it with view modes itself which is actually what I did with the abstracts instead of making a set of fields as a view I just use a view mode and then just call on those and then embed that set of view I guess view mode nodes into another view does that answer your question? yeah okay anything else? okay I don't I don't know of any documentation I used a lot of contextual filters I guess when they were arguments right in Drupal 6 so I really just try to look at them as they're another way to filter a dynamic filter right so right yeah you could give a whole session on that yeah I don't think I have either myself and you know because then you can get into you know dynamically writing your dynamic filters so you could do uh write a custom PHP in there and that type of thing which you know so you have to convert your handler and this and that so it gets kind of it gets really tricky but sorry I don't have any documentation for that right right so so I guess it's a good thing I gave this particular example if I used group by and did this in a single singular view uh I'm querying in abstracts like I said with their um categories as a field let's say and if I used group by it's going to try to either it's gonna if one abstract belongs to two categories it it has both of those available to you so the only way to get only one category to show here would be that either um well to do it this way or you could filter or aggregate that group by result and so that's really where the group by I guess for me I run into a lot of problems uh I don't I don't know if I explain that well at all I guess did that make sense I think so so yeah I mean group by is like what it's aggregating uh on one field and then taking out it out of the display and and uh so if you have if your different nodes have multiple uses of that field and it's name different it's gonna have to try to combine those or display both of them so if it's if one of my abstracts here belong to category 11 and 10 and I do a group by display I'm gonna get category 11 and 10 grouped on this display but that's not what I want I only want the results of of 11 here so anything else yeah it kind of comes down to how you I guess how you want to design that I wanted to show that example so you could see that hierarchy is manageable here but I think there's a vast number of other modules like sorry I'm not really familiar with them but for managing hierarchy in in taxonomy itself like hierarchical views or I think is one or something like that I definitely think you could use this method I wouldn't go I wouldn't go too far with it but again I use it for its strengths of being able to have control over each one of those those levels so even if I only have two levels of hierarchy I have to make three views that way four would be it could definitely get out of control so I'd explore and see if it's manageable otherwise try to take a different approach so it I'm not a hundred percent here but it could be when you actually run when you're doing a sort on a different field that's pulling it into the query so it might give you be giving you those duplicate results just because of like this same this same problem so it's I guess the view seeing that field and and yeah it does kind of blow up on that level and I guess this doesn't worry about your duplicates it's okay because you're filtering amount anyway through contextual filters so it gives you the exact I guess set of results you're looking for and so when using sorting it's not it's not a concern of like that additional I don't feel being there so I think that it would it would help so I don't know if this correctly answers your question or not but in sorting there is a views natural sort module that that might assist you in that I know I know one of the problems you're gonna have is is like is just perhaps your sorting sorting will be incorrect because of of that particular item but I I can't think of the top of my head exactly you're looking to to sort the taxonomy and then the items within right or yeah well maybe maybe come chat with me after and we can think things up and up yeah sure right okay right yeah I can't I can't elaborate a lot but I know said there's like a there's like a query hook with views so you can just override your actual query and then send it back to your views so it kind of overwrites it like the same way maybe a template file or something like that would so maybe look in into just writing that hook to call on your view I guess write your own query and then maybe you can get the data back that I'm not 100% sure how that works but it's off top of my head an idea anything else that last part would that be adding a query and a module you would write yeah yeah yeah okay right right yeah then you what you'd have to start writing your own handlers and such all right well thank you so much guys enjoy the rest of the conference