In Drupal 6, we can configure the 404 Page not found and 403 Access denied urls @ admin/settings/error-reporting. Everything seems works fine except the 403 Access denied page will use the Administration theme. If you want to apply the site theme on it, the following patch could help.
theme403fix-759836.patch
Continue reading Drupal 6 – Wrong theme on 403 page
Tag Archives: Drupal Development
Drupal 7 – Add PHP field to view
Starting from Drupal 7, the Views Custom Field module is replaced by Views PHP.
Continue reading Drupal 7 – Add PHP field to view
Drupal – Limit the number of values of a content type field by role @ 2
Previous: Drupal – Limit the number of values of a content type field by role @ 1
Another way to limit the number of values of content type field is adding an extra validation on the node create/edit form. Assume we have a content type called center and a media field called field_center_video.
1. Create a custom module and add an extra validation. Continue reading Drupal – Limit the number of values of a content type field by role @ 2
Drupal – Limit the number of values of a content type field by role @ 1
Sometimes will be want to restrict the number of values of content type field by roles. In that case, we could create a custom module and alter the node create/edit form. The following example will unset any field values which are outside the limit.
Continue reading Drupal – Limit the number of values of a content type field by role @ 1
Drupal – Clear Cache programmatically
Use the following function to clear the Drupal cache programmatically.
drupal_flush_all_caches();
Done =)
Reference: Drupal API – drupal_flush_all_caches
Drupal 7 – Redirect anonymous user to login page on 403 access denied
If you try to access a Drupal page without proper permission, you will be redirected to default 403 access denied page. But if you have enabled the Redirect 403 to User Login module, you will be redirected to the user login page with destination set to the path which you wanna access.
Continue reading Drupal 7 – Redirect anonymous user to login page on 403 access denied
Drupal 7 – Render the Privatemsg send message form programmatically
Privatemsg allows Drupal users sending message to each other. It is a must-have feature of community oriented websites. The module includes all necessary features including inbox, outbox, user block list etc. In my case, i want to render the send message form on the user profile page. So i created a block which generate the send message form by PHP code and attached it to the user profile page. Here you are.
Continue reading Drupal 7 – Render the Privatemsg send message form programmatically
Drupal 7 – Show page not found if view argument exists
Assume we have a Views page which does not have a contextual filter setting and the view path is /eureka. If you provide an argument in the url such as /eureka/abc, the argument is ignored and the Views page will return all view rows. But sometimes we may want to show the user a page not found instead of return all rows. This can be done by adding a Global: Null argument in the contextual filter.
Continue reading Drupal 7 – Show page not found if view argument exists
Drupal 7 – Render user profile picture programmatically @ 2
Yesterday we have talked about 2 normal ways to render the user profile picture in Drupal 7.
Drupal 7 – Render user profile picture programmatically @ 1
Unfortunately you can only get the user profile picture with default size if you have enabled the Gravatar integration moddule. i.e Continue reading Drupal 7 – Render user profile picture programmatically @ 2
Drupal 7 – Render user profile picture programmatically @ 1
Normally, there are 2 ways render the user profile picture programmatically in Drupal 7. But before i show you the code, i would like to introduce the profile picture setting @ admin/config/people/accounts/settings. Continue reading Drupal 7 – Render user profile picture programmatically @ 1