Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Adjusting the Settings for Each Panel Pane

0 (0 Likes / 0 Dislikes)
Hello, and welcome back to Drupal and Panels. We just talked about how to create a custom two-column layout for our homepage, and what we're going to talk about now is how to make the content on this page different based on who's looking at it. So, right now we have an advertisement on the left-hand side, we have an article on the right; If we wanted that advertisement only to appear who are not logged in to our website, we can do that. We can use Panels to make different content appear on the left-hand column when people are logged in. There's actually two different ways to solve this problem, and the first way we're going to talk about solving this problem is by using the 'Visibility' settings for each content pane itself. So we're going to start by editing our panel. We'll click the 'Contextual Administration' link at the top right-hand side of this panel; it says 'Edit Panel'. That'll take us to the 'Content' section of the Page Manager interface. This is where we see our wireframe layout of what our page should look like. You'll notice that each content pane itself has a little cogwheel at the top right-hand side, and that's how we get to the settings for each content pane. So we're going to start with our advertisement, and what we want to do here is take a look at the settings that are provided by Panels. We've already visited two, we've already checked out this settings option here. We did this through the Panels In-Place Editor. We notice that settings takes you back to the form that you were given when you were adding this piece of content to the page in the first place. So, we were offered to allow an over-write of the title, so what we're going to do here is change that again, and also in this settings dropdown we have an access to the styles. This is also something we changed through the Panels In-Place Editor interface. We could change it again here, if we wanted to change the system style. The third thing we're going to talk about are the 'Visibility' settings for this particular content pane. And the 'Visibility rules' are very similar for panels, as they were for blocks. So, for those of you who are familiar with blocks, we can go to the blocks interface, and check on the configuration of, for example, the search form. And here you can see that we have the ability to over-write the title, just like we do with Panels, and we also have 'Visibility settings' here at the bottom. This is how you decide which pages your blocks should appear on. The options that are available to us here are just 'Pages', which is where we enter in a path, basically a URL stream. And we also have 'Content types', where you can determine a specific type of content that it's supposed to appear next to. And user roles, so we could say: if the user is logged out, show this block; if the user is logged in, show this block, etcetera, etcetera. We're going to do the same sort of thing with our content pane. So, back to our Panels interface. Only here, you'll notice that there are a lot more options for Panels under the 'Visibility rules' section. So if we wanted to add a new rule, you can see that there are options here for context which we'll talk about a little bit later. The 'Current theme', the 'Front page', 'PHP Code' (which I would not recommend using but sometimes it's your last resort), and the 'URL path', just like we saw with the block module. The 'User Bundle' which is sort of like a user type; we haven't gotten to that yet but we'll talk about it a little later. 'User role', which we saw in Panels, and also 'User permission', which is a slightly more specific way of accessing User. So, what we're going to do here is use 'User role' because we want to make this advertisement invisible to people who are logged in. So we'll click 'Next'. The top option here can sometimes be confusing because what Drupal's trying to ask you is: which user should we check the role on? And in this case, we want to check the role of the user who's looking at the page, and that's not always the user who's logged in. In fact, what we want to do is check and see if that user is logged out. So if the user is logged out, which is an 'anonymous user' is Drupal-speak then we want this block to be visible. If the user is logged in then we don't want it to be visible. So when you're reading this page you need to think of the dropdown option under the very first question here for 'User', as if it were saying user who's looking at the page. And then you can read this form as, if the user who is looking at the page is logged out then you want to show the advertisement block. Then the advertisement block will be visible. So we're going to go ahead and click 'Save'. And just to make sure we've got that correct, we're going to 'Update and save' our panel. Then we should notice that the advertisement block disappears for us since we're currently logged in. And it has, which is great. So now what we're going to do is go back and add two more pieces of content in to the left-hand sidebar. The first one will be a search form, and we'll choose an Advanced search, and the second one will be a list of users who are online. So, in order to add the search form we're going to use the 'Contextual' cogwheel at the top-left. We're going to click 'Add' and the search form is located in the 'Widgets' category on the left. So we'll add the 'Advanced search' form here, we'll leave everything as they are, which is fine. Click 'Finish'. And then we're going to also add a list of currently online users, which is found under the 'Activity' category; it's called 'Who's online'. Drop that in, also. And we'll slide the search form to the top page. So we'll click 'Update and save' and now you'll notice that we'll see both 'Advanced search' form and also a 'Who's online' block. So, now that we've got the content showing up, the rest of that's great. But we need to make sure that this content doesn't also appear for people who are logged out. So we're going to go back and edit this panel again; we're going to use the 'Contextual Administration' link; click 'Edit Panel', and we're going to adjust the settings on these two new content panes we've added. So we're going to start with 'Who's online', and we're going to add here a 'Visibility rule' to make sure that this block only appears for a specific 'User role'. And we're going to check that the user looking at the page is logged in, which is authenticated. We're going to click 'Save', and now that pane should only appear when the user is logged in. We're going to do something a little extra-sneaky with the 'Content search form', where the first thing we're going to do is add that same 'Visibility' check just to make sure that the 'User role' is a user who is looking at the page must be logged in, which is good, but now we're also going to make sure that the user who is logged in has permission to do an Advanced search. So we're going to add a second 'Visibility' rule here, for a specific permission and make sure that they have permission too, and here's a list of all the permissions Drupal provides. We're going to go down to the 'Search' module and say 'Use advanced search'. So, that way we don't get a search block showing up for people who don't have permission to run that search. Then we'll click 'Save'. There's also something else that you should know about the 'Visibility rules', and that's that you can control how they combine. So, in our 'Content search form' under the 'Visibility rules' setting you can see now we have one for the user looking at the page is logged in or the user looking at the page has the ability to run an advanced search. There's also an option here for 'Settings' at the bottom. If you click 'Settings', you can decide whether all of those criteria you specified must be true, or if only one of them must be true. So what this is basically asking is, if you want those two criterias 'and'-ed together or if you want them 'or'-ed. And with Panels you can either choose all of them must 'and' or all of them must 'or'. You can't mix and match. We can talk about other ways to solve those problems. This, most of the time, will get you through them. In this case, we want both of those criteria to be true; we want them to be 'and'-ed together so we'll leave it as 'All', but if you needed it to be one or the other you do have the option here, to save that. So now we're going to go ahead and 'Update and save' this panel again, and when we look at our front page, we can see both options here. And if we were to log out we should see just the advertisement. And there it is. So that's how to make the same page, which is a panel, display different content based on who's looking at it. Thanks a lot.

Video Details

Duration: 8 minutes and 21 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 31
Posted by: drupalizeme on Oct 25, 2012

Each piece of content placed into a panel has it’s own configuration settings, covering everything from display style to access control. In this lesson we will take a tour through the settings for each pane.

Caption and Translate

    Sign In/Register for Dotsub to translate this video.