Web development includes non-design aspects of building web sites: writing markup and coding.
6 Jul, 2023
The PHP code snippet demonstrates how to extract last names as keys and first names as values from a multidimensional array using the array_column function. The array, named $records, contains...
27 Jun, 2023
In Drupal 7, you can use the hook_views_data hook to define custom tables and relationships for Views. When implementing relationships, you need to define the relationship key in your hook_views_data...
25 Jun, 2023
27 Mar, 2023
In PHP, you can combine two or more arrays using the + operator or the array_merge() function. While both approaches combine arrays, there are some differences to consider.
13 Nov, 2022
Redirect all subdomains to main domain using .htaccess. Using some sort of a mass-hosting provider, you never know what they might change in your DNS automatically. This is a backup solution to make...
23 Oct, 2022
Using .htaccess to force redirect traffic from http to https is the most simple way in Apache. If you have more access to your server, you can do it in VirtualHosts configuration. With redirecting...
23 Jul, 2020
Removing array element from vue property caused a tricky anomaly for me. I was trying different methods delete didn't work, splice worked but always removed the last item from array. Finally I...
25 Mar, 2020
Simple blank "Hello, World!" setup combining Gin (golang) + React + Webpack. Create files with these codes, download dependencies and run.
23 Nov, 2019
An example of a simple dropzone using Semantic UI. Is achieved by using "react-dropzone", which does not provide theming.
19 Nov, 2019
Use this snippet when you have created a menu using BrowserRouter from 'react-router-dom' and you need to reset the state when you click on the current menu item (same url path as you are currently...
8 Oct, 2019
You can use FormData to send form data using AJAX, including files. This is for you if you have to manually add files, you don't take them from a form, for some reason. This snippet is a react...
8 Jul, 2019
When you get this error from your webpack project "ERROR in Entry module not found: Error: Can't resolve './src' in '/var/www/your-project'", you have probably used application directory different...
11 May, 2019
Another way to setup Laravel expecting that you have git and composer installed on your machine. Presented in configuration file examples for fastest reading/setup.
24 Jul, 2018
Exclude content from these tables, to get clean db backup(backup_migrate module usage). You can even use git to store your database, when you don't export cache tables.
26 Mar, 2018
Delete all taxonomy terms from all vocabularies in Drupal 7. This is ran by Drush, but you can run it from wherever Drupal is initialised.
12 Mar, 2018
Handles any HTTP request correctly. This is a flexible and powerful HTTP client implementation of GET, POST, PUT or any other HTTP requests. The reason I built this was due to use of url arguments...
12 Mar, 2018
Example for how to create product variation types programmatically.
React: Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`
25 Jul, 2017
Testing React components with Jest I got an error: "Warning: Failed context type: The context `router` is marked as required in `Link`, but its value is `undefined`.". I am using Link from react-...
29 May, 2017
The snippet shows how to move item to the end of array. In a case where we have an array of objects and we want to move the array item by property value. In this example I am using lodash/underscore...
19 May, 2017
Snippet shows you how to fix url query parameters starting with "&" instead of "?". This can be useful when you have to use "parse_url" function. It cannot detect query parameters when they start...
22 Mar, 2017
No data is actually a module that needs to be loaded separately from the highcharts library. For some reason highcharts no data message is displayed below the grid. There is an easy fix of enabling...
21 Mar, 2017
You can create a vertical line on highlighted value in Highcharts. This might give a better visual when you have multiple lines. You could also use "shared: true" option in your tooltip to display...
5 Dec, 2016
This snippet shows you how to download a file from url without loading it to memory. When you use file_get_contents() and file_set_contents() you load the content to memory and then to file. The...
21 Jun, 2016
Using selectionStart, selectionEnd, setSelectionRange in jQuery example. You can't use DOM commands on jQuery objects directly, you have to get the first value of the object.
17 Jun, 2016
To hide drawer menu on large screens in MLD you have to add a class "mdl-layout--no-desktop-drawer-button" to the layout since the drawer icon is automatically rendered.
8 Feb, 2016
SimplePie is set to 10 seconds timeout in default. So if the feed has problem with speed then you can increase the time. The exact error that I got was "cURL error 28: Operation timed out after 10001...
1 Feb, 2016
Add column collation to column creation in SQLAlchemy. Optional, a column-level collation for use in DDL and CAST expressions. Renders using the COLLATE keyword supported by SQLite, MySQL, and...
29 Jan, 2016
Using SQLAlchemy to create table columns. To use numeric data types you have to use mysql dialects.
29 Nov, 2015
Changing line item price is not as easy as you could think. It can seem that the price has changed, but there are multiple places where you have to actually change it. Especially when you compute the...
19 Nov, 2015
Just a snippet that shows how to check if current user has edit permissions for some node in Drupal 7. Using node_access function like in the example you are also able to check permissions for...
7 Nov, 2015
Check if a python module is installed or not on the system. The simplest way to do it is in terminal.
18 Feb, 2015
Edit field output after the field module has performed the operation. This gives you possibility to alter the field output before rendered in your module. This works with display suite and other...
3 Feb, 2015
Entity API provides wrapper classes that make dealing with the values of an entity's properties and fields easier. This post is to make the information easy to learn by examples.
29 Jan, 2015
I had an error in "jquery.ui.mouse.min.js" when using jQuery 1.9 (or newer) with jQuery UI 1.8 (or older). This jquery plugin is used to restore deprecated functionalities in jQuery and removed as of...
25 Aug, 2014
There are many functions for menus, but since Drupal is not hierarchical but is modular, that's why menu doesn't have node requirement and the opposite way around. So this snippet shows how to get...
23 Jun, 2014
This tutorial shows how to set up Apache, PHP and MariaDB (drop-in replacement for MySQL). You can use pacman instead of yaourt on installing the server, since yaourt doesn't come with Arch in...
24 Mar, 2014
This shows code examples of what I had to do to create custom pane programmatically for Panels in Drupal 7. In this example I create new pane where you can pick your node and display it.
26 Feb, 2014
I had a problem with path breadcrumbs where I couldn't get taxonomy therms through commerce product reference. So I had to disable the path breadcrumb for the node and do it manually. I didn't want...
21 Feb, 2014
Add content to view header, footer, before or after using hook_views_pre_render() in Drupal 7. Using hook_views_pre_render gives you the opportunity to use values from executed views query.
2 Jan, 2014
Use hook_page_build() instead of hook_init() to add CSS or JS to every page. The reason is that hook_init() runs on every request that goes to Drupal (AJAX requests, private file requests, boost /...
20 Nov, 2013
This tutorial shows how to prepare a Debian Wheezy web server. This is just a simple setup of basic web server. I myself did it to set up a development environment for myself.
15 Nov, 2013
This snippet shows you how to change date format for better exposed filters in Drupal 7. I was not able to use strtotime with the default setting.
6 Aug, 2013
This snippet shows you how to convert file size in bytes to nice (human-readable) format in PHP. If the size is less than 1 MB, show the size in KB, if it's between 1 MB - 1 GB show it in MB, etc.
30 Jul, 2013
This example shows how to alter filter in views exposed filters using form_alter in Drupal 7.
25 Jul, 2013
Snippet about getting img tag image url from html using regex in PHP. Example below.
7 Jun, 2013
This snippets shows you how to create lists the right way using theme_item_list.
28 May, 2013
This simple snippet shows you how to add body class programmatically from your module in Drupal 7.
5 Apr, 2013
Sometimes you have to make button that skips form field validations. For an example Cancel button. This snippets shows how to skip form validation for button. Works in Drupal 7.
8 Feb, 2013
How to display message before closing the page or moving to another page. Don't use this to annoy people. Sometimes this functionality is still useful, for an example if you have some sort of unsaved...
23 Aug, 2012
Creating your own template files that you can use in your modules in Drupal 7. Template files are for separating HTML from PHP. This tutorial shows you how to create and use tpl.php files. Template...
22 Aug, 2012
Programmatically create menu link language relation in Drupal 7. This example takes a certain taxonomy vocabulary by id and creates language relations to menu links by terms relations. You might need...
14 May, 2012
This snippet shows you how to get date on mouseover from cell in jQuery UI datepicker.
3 Mar, 2012
How I set up my multi-site in localhost so that my different sites would be in different sub-folders. I did it on my windows machine.
16 Jan, 2012
How to remove views view filter programmatically in Drupal.
29 Nov, 2011
How to display eck form anywhere you wish, just few lines of PHP can make you a big head ache.
22 Sep, 2011
Selecting from multiple tables using ActiveRecord in CodeIgniter. Basics are the same as in query. You select multiple tables, relate tables and select the output fields.
20 Aug, 2011
How to get taxonomy vocabulary id(vid) by machine name in Drupal.
8 Aug, 2011
This menus page shows child menus under that menu item.
1 Jun, 2011
Adding your css stylesheet to TinyMCE editor in WordPress admin panel.
21 Apr, 2011
You can enable or disable comments programmatically. Get node using node_load, set comment value and save node.
17 Apr, 2011
First find this line: $form['path']['pathauto_perform_alias'] = array( Then add: '#value' => 1,
17 Mar, 2011
I needed to get some xml data and generate nodes out of them. This shows how I created nodes programmatically from my module in Drupal 7. I also suggest looking into creating a node using entity...
3 Aug, 2010
This tutorial shows how to make Log In, Log Out and Register links for Google App Engine in Python.