Sử dụng panels page để làm trang Access Denied - 403

Sử dụng panels page để làm trang Access Denied - 403

What happens when a user bookmarks an access-protected page? If their session expires before they next visit the bookmark, they'll see an "Access Denied" message with no login form. How confusing for the end user! Let's change that.

>> Những Modules tốt nhất Drupal 7: Winter 2014 Edition

>> 14 Modules cần thiết cho website Drupal 7 của bạn

One good option is to use the Redirect 403 to User Login module. However, you can also accomplish similar functionality with a simple Panels page (and avoid the overhead of another module). There are two steps. First create the new Panels page to replace the standard "Access Denied" page (steps and export code below). And second, set Drupal's "Default 403 (access denied) page" setting to use the newly created Panels page.

STEP 1/2: CREATE THE PANELS PAGE

Before following the steps below, you can try starting with the export code in this gist. Visit the import page and paste in the code.

Create a new custom page.

Give it a title and a path.

Create a new variant for the un-authenticated (anonymous) 403 page. Give it a selection rule on "User: role" and select "Anonymous" as the role.

Add the "User login" widget to the variant's content section.

Create a second variant, for authenticated traffic.

This time, no selection rules are needed. Simply add a "New custom content" pane to the content section.

Give the custom content pane some text. E.g., "You are not authorized to access this page."

 

STEP 2/2: SET DRUPAL'S DEFAULT 403 (ACCESS DENIED) PAGE

Visit the Configuration » System » Site Information page.

And set the "Default 403 (access denied) page" to the URL you used above for you Panels page.

Voila! Try visiting an access-restricted page in an anonymous browser, and you'll see the login block. After logging in, you'll either see the requested page (if that user has access) or the "access denied" message (if the user doesn't have access).

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Bình luận (0)

 

Add Comment

Filtered HTML

  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Các thẻ HTML được chấp nhận: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Tự động ngắt dòng và đoạn văn.

Plain text

  • No HTML tags allowed.
  • Các địa chỉ web và email sẽ tự động được chuyển sang dạng liên kết.
  • Tự động ngắt dòng và đoạn văn.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Hướng dẫn nâng cấp Drupal 6 lên Drupal 7 hay Drupal 8

Hướng dẫn nâng cấp Drupal 6 lên Drupal 7 hay Drupal 8

Drupal 8 is not backward compatible, I think that's a good thing: you don't want to drag legacy stuff behind you. That's a big bucket on your boat.

30 iPhone khổng lồ vinh danh 'nhà phát minh' Steve Jobs

30 iPhone khổng lồ vinh danh 'nhà phát minh' Steve Jobs

Cơ quan Bản quyền và Thương hiệu Mỹ (U.S. Patent and Trademark Office - USPTO) thực hiện một triển lãm độc đáo dành cho cựu CEO Apple

Thực hiện Targeted Drupal Cache Clears bằng Drush

Thực hiện Targeted Drupal Cache Clears bằng Drush

But clearing all of Drupal's caches at once can be overkill. You usually don't need to clear everything, and doing so can put heavy load on your servers (especially if your site is large or gets a lot of traffic).

Công ty diệt chuột T&C

 

Diet con trung