Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am working with some responsive layout in nodes, say I want 2 col responsive layout with an image on the left and the rest on the right, but I want a full width content when no image is present.
hiding the sidebar and making the other region full-grid would be the way to good, is there any recommend way of doing this? I think it might be a good addition if not.
Comments
Comment #1
shadcn CreditAttribution: shadcn commentedYes we can definitely do this.
We'll use radix-burr-flipped.tpl.php as example.
Radix Burr has two regions: contentmain and sidebar. We want the contentmain to be full width when sidebar is empty.
Step 1: Copy the layout template file, radix-burr-flipped.tpl.php, to your theme templates directory.
Step 2: Wrap the code for sidebar in an
empty()
check.Step 3: We'll use a preprocess function to figure out what should the width of contentmain be.
Step 4: Print the
$contentmain_class
variable in your template as follows:Your final template file will look like this:
Step 5: Clear the cache.
Note: If you have Panels IPE enabled, you will still see the sidebar. Test as anonymous.
Comment #2
hanoiiThanks, this has to be one of the best answers I got so far in an issue queue, so double thanks.
I had already done something similar.
I wonder if something like this couldn't be add, with an option, to the module, or you think it's not worth it?
Comment #3
shadcn CreditAttribution: shadcn commentedI think this might be overkill to add to Radix Layouts (for now), but definitely something that can go in a custom module.
I'm going to mark this issue as fixed. Feel free to reopen if you have any question. Thanks.
Comment #5
aegirone CreditAttribution: aegirone commentedI have tried this way , but it can't work in the node page ! the $contentmain_class can't output .. help
Comment #6
bburgI still get these regions outputting, which seems that is because even though the region is empty, the region's content still contains the IPE tools.