As a developer we always been into position where we need to write a custom script which bootstrap's Drupal Core from code and do some operations. This is pretty straight forward when working single site. But when working with Multisite or sub-site, how we can do this.
When building sites, many client wants users to get redirected to particular page (like Site Home Page) or page based on User Roles. Today we'll see how we can redirect user after login to particular page.
NOTE: I've defined my own custom page using [MODULENAME].routing.yml named as "custom.redirect_callback", which we'll be using for redirecting user.
Suppose we've file name (with extension) as part of string and while displaying to users we want to replace file extension from string.
Here's how we can do this:
Note: Make sure you're enabling this only on development server.
It's very common for any developers to make a mistake while developing, which will result in White Screen of Death (WSOD). WSOD is normally because PHP error reporting is turned Off.
Here's how you can enable error reporting using PHP.ini file:
When showing list of content (i.e. Posts, Custom Post Type) on Category Page, the main $WP_Query renders posts of default Posts type. To show content from different post type we've to alter the main $WP_Query.
There are few different ways using which we can alter the $WP_Query. But here is one of the way to alter $WP_Query without removing existing conditions in Query.
Today we're going to see how we can retrieve the payment method settings when ever we required. The payment methods are used to accept the payments from user during Checkout process. More details on payment in Drupal Commerce can be found here.
Views one of the great module available in Drupal. Views can be used to show various types of dynamic data and can also be used to allow users to filter results based on his criteria. To allow users to filter results based on his criteria we normally use views "exposed filter" option in every filter we add in view (screenshot 1.0).
The last project I was working on was having a requirement hiding the file URL in browser, for security reason. The file was actually PDF file and was containing user's order data. So to restrict the access to PDF file I've created a page callback, where I've written small piece of code to show the PDF output directly in page. Here is the sample code:
Here is how you can find the difference between two different timezones