Web Development

Web development includes non-design aspects of building web sites: writing markup and coding.

written tutorial - useRef hook in React
27 Jul, 2022
The useRef Hook allows you to persist values between renders. First example would be to use the hook to update values without causing the component to re-render.
snippet - useEffect hook in React
26 Jul, 2022
React hook useEffect is used in functional components to implement life-cycle callbacks. The Effect Hook lets you perform side effects in function components, but some people argue that DOM events...
snippet - useState hook in React
25 Jul, 2022
useState is a hook what you use in a React function to create a state variable. This is not used if you use React class components. useState has tricks you must know about.
snippet - TypeScript: Error when loading image (png)
18 Jun, 2022
In react you can import image and use it in JSX, so that the compiler knows to load the asset. Apparently by default TypeScript doesn't support image files to be loaded. So you have to add new...
snippet - Show Logo image on AppBar in Material UI
18 Jun, 2022
Most sites or apps show a logo on the left corner of the screen. In Material ui there is AppBar component. The official examples don't have this snippet. Link to the official documentation: https://...
snippet - Install Preact
12 Jun, 2022
Installing Preact two ways shown. At first the official way did not work for me. I had to fix permissions for the global node modules, official solution. Then the alternative way worked, and after...
snippet - PHP - str_replace() all variations
14 May, 2022
Collection of all variants of str_replace function like functionality. Examples providing all kinds of solutions for your needs. From simple string replacement to regular expressions.
snippet - PHP: Zendesk api attach file to ticket
19 Apr, 2022
You can't directly add a file to a ticket, but y can upload a file and attach it to a ticket comment. The attachment appears in the ticket comment. You can only attach the uploaded file to a ticket...
snippet - PHP: OneSky api get translations
21 Dec, 2021
Example where we download via api and parse translations. In multiple language export there is only one format "I18NEXT_MULTILINGUAL_JSON". That format does cut phrase ids using "." as a separator....
snippet - PHP: Imagick rotate and merge
1 Dec, 2021
Rotate and merge image using data from css transform. In this code example the input data comes from javascript where visually image is rotated using css transform property. CSS transform and Imagick...
snippet - PHP: Imagick resize / scale image
1 Dec, 2021
Change the size of an image by resize or scale an image. The resizeImage method is an inbuilt function in PHP which is used to scale an image to the desired dimensions.
snippet - PHP: Imagick transparent background
30 Nov, 2021
In order to work with transparent images, you have to define image as transparent. Do that immediately after creating an instance, by setting the object's default background color with...
snippet - PHP: Imagick read image files from URL
24 Nov, 2021
The code example shows how to read an image from url to Imagick. Imagick doesn't take in url directly, but it has a method for reading file as binary content. So we just need to get the content form...
snippet - MQL5 for GeSHi
1 Oct, 2021
MQL5 language file for GeSHi (Generic Syntax Highlighter). I used C++ langague file to base this on, since MQL is based on C++. I don't think it's the best possible highlight and ideally would use...
snippet - Javascript: object keys and values to html table
14 Jun, 2021
Convert javascript object into html table, where keys are in the first column and values are in the second column. This uses plain javascript so you can use it anywhere.
snippet - PHP error: class 'DateTimeZone' not found
1 Mar, 2021
DateTimeZone class is built into php. If you get error that it's missing, then it's namespace problem.
snippet - go-pg: Output generated SQL
7 Sep, 2020
go-pg is PostgreSQL client and ORM for Golang. To show generated queries we have to implement some hooks. There are multiple posts about this in issues, this is an exact working example of it.
snippet - Removes last item from array in Vue
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...
snippet - Explode / split string in ES6
15 Jul, 2020
How to split string in ES6. I would suggest the method of using split function from lodash. In modern JavaScript frontend you use a lot of dependencies and lodash is used in almost every project....
snippet - Validate Date in JavaScript
15 Apr, 2020
How to find out if a Date is indeed a valid Date. Simply instance check will not do it, the date might be "Invalid Date".
written tutorial - Setup Gin (golang) + React + Webpack
25 Mar, 2020
Simple blank "Hello, World!" setup combining Gin (golang) + React + Webpack. Create files with these codes, download dependencies and run.
written tutorial - PHP connect to Azure DB
11 Feb, 2020
This snippet shows you how to connect to Azure database for you to run some scripts for an example. In this example we use ODBC class not through PDO. You need to download two packages from your...
snippet -
11 Jan, 2020
This character appears mostly when you have copied code from somewhere. Some syntax highlighters are poorly made and when you copy code you get bad utf-8 symbols along with it. It doesn't show on...
snippet - React Semantic UI: Simple drag and drop file field
23 Nov, 2019
An example of a simple dropzone using Semantic UI. Is achieved by using "react-dropzone", which does not provide theming.
snippet - React: Address Search using Google Places API
23 Nov, 2019
This snippet shows you how you can use google places api in react to create address autocomplete dropdown. There are other service providers than google, but google supports business names in...
snippet - React: reset state when you click current menu router
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...
snippet - React file upload using FormData and fetch.
13 Nov, 2019
You can create input fields or use libraries like react-dropzone in React very easily. You still need to get the files from the form and send them to backend for saving. This snippet is the upload...
snippet - Trim Array Whitespace in PHP
23 Oct, 2019
This snippet shows you how to trim whitespaces from each array value in PHP. Expects all array values to be strings.
snippet - Append a file to FormData from file input in React ES6
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...
snippet - Get filename from file type input in React ES6
2 Oct, 2019
Get file name from file input and save it into state. You might need to use this when you hide your html file input and use button or some other element to trigger the click on the file input.
snippet - Get FormData using ref in React ES6
1 Oct, 2019
Get form data using ref attribute on form tag. This could be useful in some cases. The error that I was tackling before I found this solution: "Uncaught TypeError: Failed to construct 'FormData':...
snippet - Simple file field with React Semantic UI
24 Sep, 2019
Snippet of a simple file field with original Semantic UI for React. Semantic UI is still missing a file field component. Other solution would be to use react-dropzone for creating a dropzone.
snippet - Encode, decode and output JSON in PHP
11 Sep, 2019
This snippet contains a small class that does most of the JSON operations that you might ever need. Static functions for encoding, decoding and outputting json from PHP. Ensure that you get the right...
snippet - React, Semantic UI and DataTables.net
27 Aug, 2019
Working example of Semantic UI variation of "DataTables.net" on ES6 variation of React.
snippet - PHP: Check string for a specific word
6 Aug, 2019
The fastest string parsing is using existing functions, in this case you can use the strpos() which is used to find the occurrence of one string inside another one. When you need a stripos() for a...
snippet - PHP Output Buffering
24 Jul, 2019
Output buffering catches all echo-s, print-s and other output to stdOut. Then you can call a function on script shutdown to output all of the content. You can buffer output and stop scripts from...
snippet - ERROR in Entry module not found: Error: Can't resolve './src' in '/var/www/your-project'
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...
written tutorial - CodeIgniter 3: Using mssql with PHP 7 on Linux
6 Jul, 2019
Connect to mssql server in CodeIgniter 3. This will probably apply on any php version, just I had v 7.3 at this point. The setup is really easy, I even used mssql on my linux machine locally.
snippet - Enable composer in CodeIgniter 3
29 Jun, 2019
How to use Composer in your CodeIgniter 3 project.
snippet - Json output in CodeIgniter 3
24 Jun, 2019
Right way of JSON output in CodeIgniter 3.
written tutorial - Set Up Laravel, PHP 7.3, Nginx, and MySQL with Docker
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.
snippet - Subtract time in Python
3 Apr, 2019
Examples of time subtraction in Python. Using the best date-time library called Pendulum. You can use add or subtract to alter time.
snippet - Show all errors for development in PHP
26 Mar, 2019

Usually in default errors are disabled for production. Sometimes you have error 500 for an example and you need to see the error message. For an example in Drupal 7 you can put this in settings.php...
snippet - Create and Post HTML Form using Javascript
20 Mar, 2019
This snippet creates html form and submits it, the same way as browser submits form "with redirect". If you need the redirect not an ajax solution, for example credit card payment.
snippet - HMAC SHA1 in Python 2
11 Mar, 2019
HMAC (a keyed-hash message authentication code) is used to verify API request. HMAC is constructed by concatenating form parameter key and value pairs into a string ordered by alphabetic order of the...
snippet - Enable HTTP/2 in Apache Web Server
28 Feb, 2019
HTTP/2 enables a more efficient use of network resources and a reduced perception of latency by introducing header field compression and allowing multiple concurrent exchanges on the same connection...
snippet - PHP: Send json with post request
26 Nov, 2018
Instead of curl I like to use http request function from a long and stable framework PHP: http request function, alternative to curl or file_get_contents. Because I find curl to be tedious. Using...
snippet - Convert to Integer in JavaScript
8 Nov, 2018
There are multiple ways to convert values to integer in javascript. Using Math.trunc gives the most accurate results.
snippet - Magento 2: Module is not listing
18 Oct, 2018
When you copy a custom module to app/code directory. Magento does not pick it up automatically. You need to run this.
written tutorial - React ES6: Styled Components
6 Oct, 2018
Styled components are the best way to give some visual aid to your components. The heavy lifting should be done by a library, it can be either material design, bootstrap, semantic, etc... To adjust...
snippet - Number to words in PHP
24 Jul, 2018
Helper function for converting numbers to words. There is same function available in PHPs NumberFormatter class, but using it is not always possible, since it's not enabled by default.
snippet - Tables content to exclude on DB export in Drupal 7
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.
snippet - Migrate Field Collection in Drupal 7
25 Jun, 2018
You can use migrate to import field collections. It has full support. You just need to define the host entity, where you have defined the field collection.
snippet - Load a file by uri in Drupal 7
16 May, 2018
This snippet shows you how to load a file by uri. Basically this option is available with file_load_mulitple only.
snippet - Field group alter to add html in Drupal 7
4 May, 2018
Field group lets you do some amazing forms. Still when you have empty element or the form just is too long and needs some custom modifications, you can then use prefix and suffix from form api to...
snippet - Delete all terms from all vocabularies in Drupal 7
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.
snippet - PHP: http request function, alternative to curl or file_get_contents
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...
snippet - Drupal 7 commerce add product variation types programmatically
12 Mar, 2018
Example for how to create product variation types programmatically.
snippet - jQuery form submit error detection
20 Dec, 2017
Snippet shows you how to catch errors like 404 when you submit form using jQuery.
snippet - PHP: First x characters of a string
2 Nov, 2017
Get first n amount of characters from a string. You could use substr for that, but you will get empty results when there are special characters. Thus multibyte string method is the right way to go.
snippet - PHP: Instagram to RSS feed
2 Aug, 2017
Instagram gives out json feed. You can use this little php snippet to create rss feed from the given json. The script leverages paging, which enables you to control the items count in the output feed.
snippet - 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-...
snippet - Webpack: Remove comments from compressed css
1 Jun, 2017
You can minify css with optimize-css-assets-webpack-plugin, but by default some comments are left untouched. If you want to remove all comments you have to use an option for the cssnano, that is used...
snippet - Javascript: move item to end of array (of objects), by property value
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...
snippet - PHP: Encode Url for Curl
23 May, 2017
This snippet encodes urls for curl. If you use special letters like äõöü in url, then you get a bit different url parsing from browsers than curl in PHP. You would think that you could use php's own...
snippet - 401 Unauthorized Error with https redirection
22 May, 2017
Got an unauthorized error from htaccess passwords after https redirection implementation. This was an unexpected result, but I guess what happens is that you are redirected to access denied page...
snippet - PHP: Fix url query parameters starting with
19 May, 2017
Snippet shows you how to fix url query parameters starting with "...
snippet - WordPress: force https using .htaccess
19 May, 2017
Since Google says https gives websites a small ranking benefit and Let's Encrypt gives free certs, more and more sites have been converted. This is a more thurral snippet of https redirection. It has...
snippet - JavaScript ES6: Clone Object
13 May, 2017
The Object.assign() method copies all properties from one or more source objects to a target object. It returns the target object. This can be used for cloning an object in ES6, just create an empty...
snippet - React: Wait for full render in snapshot testing
5 May, 2017
If you use full render not shallow in your tests, your tests might be rendered before the actual component and its subcomponents are fully loaded. In that case you need to delay the output, while...
snippet - Highcharts: full width lines
19 Apr, 2017
Highcharts has paddings and spacings that will make the area charts line appear inside of the chart element. To get full width line you need to disable some spacings and lines. You have to disable...
snippet - Highcharts: Hide highcharts.com link from footer
23 Mar, 2017
Highcharts comes with a credits link by default. This snippet shows how to hide the link using the configurations.
snippet - Highcharts: display no data message on top of the grid
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...
snippet - Highcharts: Create a vertical line on highlighted value
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...
snippet - webpack: Minify CSS in production
14 Mar, 2017
You can achieve this by adding a library that supports css minify to "webpack.config.js". In this snippet I use "optimize-css-assets-webpack-plugin" which uses cssnano for minimizing by default. The...
snippet - Python 2: Save directory to Amazon S3 using boto
27 Feb, 2017
You can save files to Amazon with Python using library called boto. Boto is a Python interface to Amazon Web Services and we need just a tiny part of it. If you have very large files you have to...
snippet - SQLAlchemy custom column names for queries
20 Feb, 2017
To get custom columns from a query you can use the with_entities() method to restrict which columns you'd like to return in the result. Use label() method to give AS value to your query. To use...
snippet - Python write to tmp directory
10 Feb, 2017
Snippet shows you how to write to temporary directory. You can either write a single file, or do stuff in a directory. In any case you should remove the files and folders after you have done your...
snippet - Python: Get timestamp in seconds
27 Jan, 2017
Get timestamp in seconds as integer in Python using the time library.
snippet - PHP: Check url for valid response code 200
9 Jan, 2017
Check the HTTP Status Code of the website header using PHP. Check that url is giving valid response code of 2xx. You can modify this for different purposes. For detecting 404 not found only or...
snippet - Soap request with NTLM authentication
6 Dec, 2016
Usually when you have errors with soap it is because private Soap requests require some kind of authentication. One of the most common ways is to use NTML authentication, because Microsoft. PHP soap...
snippet - PHP: Download large file from url without loading it to memory
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...
snippet - Filename from path in PHP
22 Nov, 2016
Snippet shows you how to get filename from a path in PHP. Filename and extension separately. Can be used for extending filenames with timestamp or anything.
snippet - Select a random file from directory in PHP
22 Nov, 2016
Select a random file from directory. This can be useful if you want to display a random image on your website. For an example a background image randomly from a directory in your files.
snippet - Delete object key and value in javascript
12 Oct, 2016
Deleting object value with key in javascript. For this you can use the delete operator. Permits you to remove a property from an object.
snippet - Get body tag using PHP Dom Document
22 Sep, 2016
How to use a DOM parser and get the contents of the body.
snippet - Validate AJAX requests in Zend 1
26 Aug, 2016
How to validate AJAX requests in Zend Framework. There is a function in request class, to use instead of comparing the $_SERVER['HTTP_X_REQUESTED_WITH'] directly. This can be beneficial for security...
snippet - Radio Buttons in MDL (Material Design Lite)
19 Jul, 2016
Material Design includes beautification of radio buttons as well. These need javascript, if you use ajax to load you content, you need to call for dom update.
snippet - Text Input in MDL (Material Design Lite)
8 Jul, 2016
There are multiple ways to display text input field. You can use lable or not, you can do some validation with regular expression. Also you can show pretty inline form errors. For more information go...
written tutorial - File Upload in MDL (Material Design Lite)
1 Jul, 2016
Since there is no File Upload form functionality in MDL, we need to create some css, html and js. I have tried to make it as simple as possible.
snippet - Checkbox in MDL (Material Design Lite)
29 Jun, 2016
This snippet shows how to convert checkbox type inputs to MDL (Material Design Lite). There are separate classes for checkboxes in Material Design.
snippet - jQuery: Using selectionStart, selectionEnd, setSelectionRange
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.
snippet - Hide drawer menu on large screens in MLD (Material Design Lite)
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.
snippet - Select tag in MDL (Material Design Lite)
17 Jun, 2016
This snippet shows how to convert select tag to MDL (Material Design Lite). To achieve this you have to use text fields classes.
snippet - Python: convert po to mo
19 May, 2016
This snippet shows you how to convert po files to mo files. Po is the raw plain-text translation file with key value storage format. Mo files are compiled po files, binary format allows you to read...
snippet - Directo class
17 May, 2016
Class for fetching and sending data between http://www.directo.ee/ API. This class includes pulling data from Directo and posting xml with php array to xml generation.
snippet - Python: Read and decode json file
11 May, 2016
Read and decode json file in Python. You can use the same method for regular json strings.
snippet - Python: Pretty Print Array
11 May, 2016
Pretty print array, meaning that you print array, dictionary, object or any non string format in human-friendly way. This is great for terminal / command line. When you are looking for something for...
snippet - PHP: Trim Array
5 May, 2016
This snippet shows you how to trim an array with single line of code. This can be achieved by using "array_map".
snippet - Python define an array
4 May, 2016
This short snippet shows how to define an array in Python.
snippet - jQuery: Input - focus and select all
18 Apr, 2016
How to focus and select all using javascript. This snippet shows it in an example of "jQuery: Toggle input text using checkbox". For an example you can extend this to any event or action where you...
snippet - jQuery: Toggle input text using checkbox
18 Apr, 2016
Snippet shows how to toggle input text using checkbox. Sometimes you need to show text field only when a checkbox is checked, that can be called conditional text field. So you need a checkbox and a...
snippet - jQuery: Run something after $.each has completed
12 Apr, 2016
JavaScript runs asynchronously, that means when you initialize $.each every bit of code that comes after that will not be executed when $.each has finished. Sometimes you need your code to be...
snippet - Minify JavaScript from command line
8 Mar, 2016
This snippet shows how to minify javascript files from command line. Minifying JavaScript is useful in many respects. Most important are security and performance. Security is increased due to the...
snippet - Get previous / next element using JavaScript
8 Mar, 2016
This snippet shows how to get element next to your element / selector. This a part of dom traversal. Using javascript for next element parsing can be used to create some powerful dynamic content. I...
snippet - Drupal 7: Wrapping group by content in Views
24 Feb, 2016
You can use "group by" in views to group data by a field. When you start writing css for it, or even use accordion. You need to wrap the rows into a container. This can be achieved by creating a...
snippet - SimplePie Error: timed out after 10001 milliseconds
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...
snippet - Python: Get Current Time with Timezone
3 Feb, 2016
Get current time with timezone in Python. This can be achieved using a library named arrow. It's a datetime library for correct and easy calculations using only one library.
snippet - Python generate HMAC-SHA-256 from string
2 Feb, 2016
Generating hmac involves using "private" key. So you you need to "double encode it". In python you can achieve it using two libraries hashlib and hmac.
snippet - SQLAlchemy: Add Column Collation to Column Creation
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...
written tutorial - Running Django on Apache and MySQL
30 Jan, 2016
If you plan to use Python for your web backend then you might want to consider Django as there are many good libraries that you need for web development.
snippet - SQLAlchemy: Create Table Column using Decimal and Tinyint
29 Jan, 2016
Using SQLAlchemy to create table columns. To use numeric data types you have to use mysql dialects.
snippet - PHP: Days since today or days between two dates
13 Jan, 2016
How to find out the amount of between two dates. For an example how many days have passed since a defined date.
snippet - Get every other member of array in PHP
11 Jan, 2016
Getting every other member of array in PHP. Examples of getting even or odd members of an array, using foreach loop and "modulo operation". The modulo operation (division by %) finds the remainder...
snippet - Enable Phar in PHP 7
10 Jan, 2016
Phar is included in PHP 7 amongst other updates. It's no longer external module. You have to turn off the "readonly" parameter. Since it disables Phar write support by default.
snippet - Cache json from curl request in PHP
5 Jan, 2016
When you create a simple request without any special REST client, you can do it just by using curl. When you need to do curl request, it's not a good practise to do it on every page load. So the...
snippet - Explode multiple delimiters PHP
4 Jan, 2016
To explode multiple delimiters PHP you have to use regular expression. Add your delimiters in the parentheses separated by pipe. You might have to escape your characters if they have meaning in PCRE...
snippet - PHP: Detect delimiter of CSV file
9 Dec, 2015
Using PHP to read csv file is a common thing to do. Sadly there is no solid standard on delimiters, depends on fully from where you get your csv file. Usually simple csv exports are a bit different...
snippet - Change line item price programmatically in Drupal 7
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...
snippet - AddThis: Popup instead of hover box
25 Nov, 2015
AddThis is an awesome social sharing tool. It is fully customizable. I suggest using addthis module for loading add this library, this has performance options for the javascript loading.
snippet - Check if current user has node edit permission in Drupal 7
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...
snippet - Add .tpl.php files to your module in Drupal 7
9 Nov, 2015
This nifty little snippet will scan your module for tpl.php files. Include template files from your module. Override default template in custom module. I usually have a single module where I keep my...
written tutorial - Running Python on Apache
8 Nov, 2015
Using Python in the web. Setup Apache the way that you can run Python backend on it.
snippet - Check if Python module is installed on your system
7 Nov, 2015
Check if a python module is installed or not on the system. The simplest way to do it is in terminal.
snippet - Select next as well in PhpStorm
6 Oct, 2015
Select next, is a functionality well needed in everyday programming. For an example, if you have a function that defines a variable and the variable is used multiple times. You would like to select...
snippet - PHP: Replace all whitespaces with a single space
8 Sep, 2015
You can replace all whitespaces (space, new lines, etc.) with a single space using regular expression find and replace.
written tutorial - Set PhpStorm to always show line numbers
4 Sep, 2015
PhpStorm by default does not display line numbers. Working with version control or when debugging stuff, you usually get line number of the code where the error appears. So it would make sense that...
snippet - Uninstall modules programmatically in Drupal 7
13 Jul, 2015
Snippet shows how to uninstall modules programmatically. This is not deleting the files, but doing a full uninstall.
snippet - Get cursor position in CKEditor
12 Jun, 2015
Get cursor position in CKEditor is simple if you know some facts. You have to have the instance initiated, so simple jQuery ready would not work. You can get selection and use that functionality to...
written tutorial - My perfect web server configuration on localhost
17 May, 2015
Apache default configuration can be a bit slow in case of today's standard web applications. Especially on local environment where you develop your application, class, framework or plain old PHP from...
snippet - Get GET parameters in Drupal 7
23 Mar, 2015
Getting URL query parameters array where unwanted elements are removed. For that you can use drupal_get_query_parameters function. In default q parameter will be removed. That parameter includes...
snippet - PHP: Get values by key in multidimensional array
5 Mar, 2015
How to get values by key name in multidimensional array. You have to iterate it recursively. This is the first time I can use Iterator classes of PHP and I already can think multiple problems this...
snippet - Post data to external url in Drupal 7
4 Mar, 2015
Sending data using POST to external url should be done by using drupal_http_request.
written tutorial - PHP: Memory management
22 Feb, 2015
If you are using larger files like bigger data files or images, memory might become an issue. Even if not, it's always good practice to use optimal amount of memory. Clearing memory is just a part of...
snippet - Edit field output before it is rendered in Drupal 7 using hook
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...
snippet - Create htpasswd file from command line in Linux
17 Feb, 2015
Create or generate .htpasswd file from command line in Linux. The file is used for password protected websites in Apache. The easiest way to create one is to generate it from terminal.
snippet - Drupal 7 - file_save entity wrapper file uri
10 Feb, 2015
Since this snippet includes a lot of information the title is simply a bunch of keywords. Basically we are using file uri to determine if it exists and is managed or needs to be saved as new managed...
snippet - Get values / Rendering of fields in Drupal 7
5 Feb, 2015
The idea would be that you don't take any values directly from node_load result. You can either use entity wrapper(is not a part of this tutorial) or field get and view functions.
written tutorial - Entity metadata wrapper (entity_metadata_wrapper) in Drupal 7
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.
snippet - Uncaught TypeError: Cannot read property 'msie' of undefined
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...
written tutorial - Apache: *.localhost vhosts wildcard subdomains
5 Dec, 2014
This "tutorial" is how I created wildcard subdomains in my localhost. So I get domains like "http://bt.localhost". This bit is from my http.conf or apache.conf depending on your system. There also...
written tutorial - Php pcre regex or operator tutorial
2 Nov, 2014
PCRE regular expression operator OR. In regular expressions "or" is known as "alternatives". Create a subgroup using parenthesis.
snippet - PHP - Replace using regex
29 Oct, 2014
Search and replace using regular expression in PHP using preg_replace function. It is very powerful way to search and replace. I suggest using some online regular expression tool to test out your...
written tutorial - Embed PDF in HTML
24 Oct, 2014
In general we are going to embed pdf in html. For this tutorial I am going to use PDF.js. It is a web platform for parsing and rendering PDF files. Canvas support is one of the main things that is...
snippet - Load menu item first child in Drupal 7
24 Oct, 2014
This is how you can load menu items children. Also the example / snippet is about how you can get the first child, but the menu has to be in a single language tough. It takes access and being hidden...
snippet - Get a single query result as string in Drupal 7
30 Sep, 2014
This snippet shows you how to get a single query result as string in Drupal 7, using select from database abstraction layer.
written tutorial - Install phpMyAdmin for Apache (on Arch Linux)
23 Sep, 2014
Install phpMyAdmin for Apache on Arch Linux so that it would open under "pma.localhost". This works on other distributions as well just use your specific package manager to download the packages and...
snippet - Get node menu item (mlid) by node id (nid) in Drupal 7
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...
snippet - Compress web using gzip / mod_deflate
5 Aug, 2014
Compress site using mod_deflate to reduce bandwidth and loading time, also Google Speed suggests it. List of compressible mime-types to compress. You should not compress mime types that compress...
written tutorial - Install web server (Apache, PHP, MariaDB) on Arch Linux
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...
snippet - PHP array of iso country list
28 May, 2014
PHP array of iso country list. This list includes Kosovo (KV) and Democratic People's Republic of Korea (KP). That I found hard to find from somewhere else.
snippet - Validate UTF-8 strings in PHP
7 May, 2014
This function checks whether a string is valid UTF-8. You can ensure that the string you operate is a valid UTF-8 string. preg_match fails on strings containing invalid UTF-8 byte sequences. It does...
snippet - Create contextual links in Drupal 7
1 May, 2014
This snippet shows you how to create contextual links in Drupal 7. If you don't know what contextual links are then those are the links in front end that come up from the ratchet.
snippet - Install Drupal using Drush
29 Apr, 2014
How to install any version of Drupal using Drush the Drupal Shell. You can replace the version name with the version you like. Also feel free to replace words in caps to get an installation that you...
written tutorial - Protect site with password using htaccess
28 Apr, 2014
Protect site with password using htaccess. The htpasswd file is just a text file that includes usernames and password hashes. You can generate those by using online tools for generating htaccess...
written tutorial - Rebuild menu in Drupal 7
24 Mar, 2014
Sometimes menu gets messed up and all the new links go on the admin menus first level. Or you have other reasons to rebuild menu. You also need devel module to do this.
written tutorial - Create custom pane programmatically for Panels in Drupal 7
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.
snippet - Use Drupal to run queries on other databases.
14 Mar, 2014
First you need to add the connection information of the other database. This way you can use drupal database abstraction layer for altering any database.
written tutorial - Group views by first letter in Drupal
10 Mar, 2014
This tutorial describes how you can group the results of a view by first letter of their title. This might not suit for you in two cases, first if you need to order them by ascii not utf-8, secondly...
snippet - Migrate image from URL in Drupal 7
7 Mar, 2014
There is a module called migrate that enables you to migrate content to Drupal. This snippet shows you how to migrate image from URL to Drupal 7. You have to get file name from the importing source...
snippet - Alter node breadcrumbs by hook form your module in Drupal 7
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...
snippet - Views header, footer, before and after using hook_views_pre_render() in Drupal 7
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.
snippet - Change field instance programmatically in Drupal7
20 Feb, 2014
Change or update field instance programmatically in Drupal 7. For more information check out Field CRUD API in drupal.org.
snippet - Check if variable is a jQuery object
2 Jan, 2014
Checking that variable is a jQuery object. We are going to use instanceof and it returns true if the statement is true.
snippet - Use hook_page_build() instead of hook_init() to add CSS or JS to every page.
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 /...
snippet - Convert text or HTML to plain-text in PHP
25 Nov, 2013
Encodes special characters in a plain-text string for display as HTML. Validates strings as UTF-8, if not UTF-8 it returns an empty string. It prevents CSS attacks on IE 6.
written tutorial - Install web server (Apache, PHP, MariaDB) on Linux Debian Wheezy
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.
snippet - Change date format for better exposed filters in Drupal 7
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.
snippet - Install module programmatically in Drupal 7
14 Nov, 2013
Installing module programmatically in Drupal 7 can be achieved with just one step, using module_enable function.
snippet - Check if text contains cyrillic characters in PHP
5 Nov, 2013
Check if text contains cyrillic characters in PHP. This example shows you how to do exactly that.
snippet - Converts URLs in text into links in Drupal 7
5 Nov, 2013
Converts URLs in text into links in Drupal 7 automatically. Three types of "links" get converted. URLs like http://example.com, e-mail addresses like name@example.com and urls without the "http://"...
snippet - jQuery Catch Form Submit
29 Oct, 2013
Form submitting is really simple with jQuery. You can use submit function to submit form or catch a form submission and do something else.
snippet - Get taxonomy vid by machine name Drupal 7
7 Oct, 2013
This snippet shows how to get taxonomy vocabulary id (vid) by machine name of taxonomy vocabulary Drupal 7.
snippet - Using image_scale_and_crop in Drupal 7
3 Oct, 2013
This snippet shows you an example of using image_scale_and_crop function to scale and crop image as in image styles.
snippet - Get words in string as array in PHP
16 Sep, 2013
How to split words in string to an array using regular expressions. You can use this for search indexing for an example.
snippet - Useful hooks and functions in Drupal 7
2 Sep, 2013
List of useful hooks and functions in Drupal 7. You can find here something new or just bookmark it for your reference.
written tutorial - Change or add file icons to Drupal 7
21 Aug, 2013
Change or add file icons to Drupal 7. First you have to define your mime type of a file, if it isn't done already. Then add icon URL to that mime type (16x16).
snippet - Alter URL GET parameters using JavaScript
14 Aug, 2013
This function alters url get parameters using javascript. The function takes to consideration all aspects of url (parameter existis, hash, parameter doesn't exist). For an example if you need to be...
snippet - How to create time field in Drupal 7
8 Aug, 2013
This example shows you how to create time field using date module and Field API in Drupal.
written tutorial - Read or parse feeds with PHP
7 Aug, 2013
This tutorial shows how to parse RSS feeds with PHP. From the libraries and methods that I have tested and used SimplePie is by far the best PHP RSS parser. It supports most common RSS modules out of...
snippet - Convert file size in bytes to nice (human-readable) format in PHP.
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.
snippet - Alter filter in views exposed filters using form_alter in Drupal 7
30 Jul, 2013
This example shows how to alter filter in views exposed filters using form_alter in Drupal 7.
snippet - Get img tag image url from html using regex in PHP
25 Jul, 2013
Snippet about getting img tag image url from html using regex in PHP. Example below.
snippet - Customize Views RSS Feed Title in Drupal
14 Jul, 2013
This snippet shows you how to customize views RSS feed title in Drupal. This example shows you how to create title for taxonomy feed, so that the title would be the term with it's parents.
snippet - Use colorbox programmatically in Drupal
12 Jul, 2013
How to use colorbox module programmatically. Colorbox module provides with loading inline content, explained here: https://drupal.org/node/1971564. Since that didn't work for me, I tok a different...
written tutorial - Exclude current node from view
12 Jul, 2013
This tutorial shows you how to exclude current node from view. For an example, if you need a block that shows related content by taxonomy then you want to exclude current node from the list.
snippet - Create lists using theme through render in Drupal 7
7 Jun, 2013
This snippets shows you how to create lists the right way using theme_item_list.
snippet - Add body class programmatically from your module in Drupal 7
28 May, 2013
This simple snippet shows you how to add body class programmatically from your module in Drupal 7.
snippet - Creating views programmatically in Drupal 7
20 May, 2013
Creating views view in your module is really simple.
snippet - Convert time to other time zone in PHP
7 May, 2013
Convert time and date from one time zone to another in PHP. Don't ever manage time adding or subtracting seconds, there is more to datetime than meets the eye.
snippet - Remove HTML elements using DOMDocument in PHP
19 Apr, 2013
This snippet shows how to remove HTML elements using DOMDocument in PHP. The problem is that you can't do it in the same loop.
written tutorial - Using DOMDocument to parse HTML in PHP
15 Apr, 2013
This snippet is about parsing HTML with PHP. It's hard to parse HTML, because people write incorrect HTML syntax very often. This code forces DOMDocument to read and later write HTML. So your changes...
snippet - Form API -  Skip form validation for button 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.
snippet - Translate taxonomy terms in Drupal 7
3 Apr, 2013
How to translate localized taxonomy terms in Drupal 7.
snippet - PHP - get extension from file name
21 Mar, 2013
Get extension from file name.
snippet - jQuery - Check if selector is disabled
7 Mar, 2013
You can use "is" to see if the form element is disabled.
snippet - Change page title programmatically in Drupal 7
19 Feb, 2013
How to override page title in your theme, after all modules have done their jobs.
snippet - Message before leaving the page - JavaScript / jQuery
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...
snippet - Remove form elements in Drupal
8 Feb, 2013
This snippet shows how to remove form elements in Drupal. I am using hook_form_alter and access parameter from form api.
snippet - jQuery - Animate .prepend
2 Feb, 2013
Rather than simply dumping the HTML into the page you might want it to be animated. You can .hide() the content before doing a .prependTo(), then call .slideDown() on the element.
snippet - Drupal - Change page titles in template.php
27 Jan, 2013
Changing page titles in your theme. There is also hook_page_title_alter hook. If for some reason you still want to do it your theme, then this is how.
snippet - Views query alter - use select in where clause
23 Jan, 2013
How to use select query as where clause in Drupal views module query alter. You can't use hook_views_query_alter, because it places single quotes around the value. So you can't use query instead of...
snippet - Localize taxonomy term in Drupal 7
1 Dec, 2012
This snippet shows you how to Localize taxonomy term in Drupal 7.
snippet - Remove width and height form img tag using PHP
29 Nov, 2012
Remove width and height attributes from img tag using PHP. Really plain and simple replace width and height attributes with nothing.
snippet - Change Drupal calendar events color.
28 Nov, 2012
You can only change event colors by content type or taxonomy terms in Calendar view. More advanced coloring requires some programming.
snippet - Convert plain text URLs into links in Drupal
23 Nov, 2012
How to turn plain text URLs into active links in Drupal.
snippet - Get URL variables with JavaScript
21 Nov, 2012
This function gets URL variables in JavaScript. Current page url parameters will be parsed into array, that will be returned.
snippet - Monochrome Google Maps
19 Nov, 2012
This example shows how to create monocrome Google Maps. Where the map will be using only shades of grey (with or without black and/or white). It might also be called grayscale or black-and-white.
snippet - Using jQuery Datepicker in Drupal
25 Oct, 2012
This snippet shows how to use jQuery datepicker in Drupal. Drupal already includes jQuery and jQuery UI in its core. So you just have to make sure it's loaded and then you can use it in your scripts.
snippet - PHP range where key and value is same
2 Oct, 2012
Creating range array where key and the value is the same number. I am using array_combine function for that. I give two parameters which are the same array created by range.
written tutorial - Draw Rectangle in HTML5 Canvas Tag
23 Sep, 2012
Drawing a rectangle in canvas tag with rectangle functions.
snippet - Field API email field in Drupal
30 Aug, 2012
Creating email field. The field is still textfield, you just have to make validation for the field.
written tutorial - Create your own template files ( tpl.php ) in Drupal 7
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...
snippet - Programmatically create menu link language relation in Drupal 7
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...
snippet - Get Years of nodes in Drupal 7
21 Aug, 2012
This query gets node created dates and selects all years of nodes that has been made. Also there are filters: node.status equals 1 is published filter, node.type is content type filter and node...
snippet - Make sure your cron runs daily in Drupal
14 Aug, 2012
How to make sure your cron task runs once per day in Drupal? You can set crontab once per day, but you still might want to run cron manually every now and then. Also you might have to change the cron...
snippet - PHP - strip defined tags, strip_tags reverse
9 Aug, 2012
Strip tags in PHP strips all tags, except allowed tags. This function strips tags that you define. Also you can define if you want to strip content as well.
snippet - Strip tag with class, id or anything else in PHP
23 Jul, 2012
This function strips tags by any identifier without regexp, and without heavy XML parsing. As long as the tag looks exactly the same in source-code it works.
snippet - Create table using theme table in Drupal
12 Jul, 2012
Create table using theme table in Drupal. This is the simplest example of creating table. In the code I added link to the documentation. You can do things like add classes, caption, colgroups etc.
snippet - PHP Date or Time Range
12 Jul, 2012
Iterate through date or time range using PHP.
snippet - Show Drupal 404 page programmatically.
25 Jun, 2012
Show Drupal 404 page programmatically. Just return this function from your page function.
snippet - Get MSSQL Field Data Type in PHP
29 May, 2012
Example how to get field types in MSSQL. You can use it on any query, even procedures.
snippet - Get date on mouseover from cell in jQuery UI datepicker
14 May, 2012
This snippet shows you how to get date on mouseover from cell in jQuery UI datepicker.
snippet - Add node to nodequeue in Drupal 5-7
2 May, 2012
How to add node to nodequeue using a little code. You can make it automatic using Rules and PHP filter module(in core that adds option to add PHP code to textarea).
snippet - Translate block title in Drupal 7
2 May, 2012
Translate block title in Drupal 7 using this theme hook.
snippet - Detect character encoding in PHP
26 Apr, 2012
Detect character encoding in PHP and convert string to UTF-8.
written tutorial - SQL query examples in Drupal 7
20 Apr, 2012
Drupal SQL query examples, includes regular query and select, insert, update and insert or update using abstraction layer. Explanations of different data return types like fetchAssoc, fetchAll and...
snippet - Page title for taxonomy term pages in Drupal
6 Apr, 2012
How to fix page titles for taxonomy term pages. It creates title from term hierarchy. You have to remove the views title override.
snippet - Get or load taxonomy term(s) in Drupal 7
6 Apr, 2012
Load taxonomy term object by name or tid. Also how to get term parents from top to bottom.
snippet - Get current URL using jQuery
5 Apr, 2012
This shows you how to get the path of the current URL and assign it to a variable. This is achieved by taking url from location object. The location object also has other properties, like host, hash...
snippet - Term name in right language in Drupal using i18n
13 Mar, 2012
How to get term name in right language in Drupal? Internationalization (i18n) module is used for localization.
written tutorial - Drupal 7 multi-site on localhost (XAMPP or Windows example)
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.
snippet - Get all MSSQL tables using PHP
17 Feb, 2012
How to get all tables names that are in a certain table.
snippet - Remove language links from node links in Drupal 7
9 Feb, 2012
How to remove language links from node links in Drupal 7
snippet - Change file name after saving in Drupal 7
26 Jan, 2012
How to change file name programmatically after file is saved in Drupal 7.
snippet - Filter feeds log by Importer in Drupal 7
23 Jan, 2012
First you need to create a filter to your views. Add "Feeds log: Importer id" filter to All entries display / tab. Then this code snippet alters the form so there won't be textfield, but selection.
snippet - Remove views view filter programmatically in Drupal
16 Jan, 2012
How to remove views view filter programmatically in Drupal.
snippet - Get languages in Drupal 7
11 Jan, 2012
How to get all active languages as array in Drupal 7.
snippet - Language select field in Drupal 7
19 Dec, 2011
This code snippet is about creating languages form field in Drupal 7 using field api.
snippet - Add field to entity programmatically in Drupal 7
13 Dec, 2011
How you can add field to an entity programmatically in Drupal 7.
snippet - Add body classes in Drupal 7
8 Dec, 2011
Adding body classes in Drupal 7. Just a little code snippet that can be useful in some cases.
snippet - Checkboxes as radio buttons using jQuery
4 Dec, 2011
Make a group of checkboxes behave like radiobuttons.
snippet - Display Entity Construction Kit (ECK) form programmatically
29 Nov, 2011
How to display eck form anywhere you wish, just few lines of PHP can make you a big head ache.
written tutorial - Redirect based on country in Drupal 7
15 Nov, 2011
Redirect users to their main language first visit. I needed it only on the front page, but you can simply remove the if statement if you need the functionality on every page. The language detection...
written tutorial - Create ajax forms in Drupal 7
23 Oct, 2011
How to create forms that are submitted via ajax. To understand this tutorial you have to have a basic knowledge of Drupal programming and its form api.
snippet - Check if URL is external or internal in PHP
11 Oct, 2011
Check if URL is external or internal in PHP. We are going to use parse_url PHP native function. Function parse_url parses a URL and returns an associative array containing any of the various...
snippet - How to redirect everything to index.php
8 Oct, 2011
How to redirect everything to certain page like index.php or root.
snippet - Round numbers in JavaScript
1 Oct, 2011
This snippet shows you how to round a number to a specified number of decimal places in JavaScript.
snippet - Selecting from multiple tables using ActiveRecord in CodeIgniter
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.
snippet - Print JavaScript object
21 Sep, 2011
This snippet shows how to print JavaScript object.
snippet - Change breadcrumb in Drupal
19 Sep, 2011
To change breadcrumb in module you can use two functions. You can change breadcrumbs separators or the whole logic using theme_breadcrumb in your templates template.php file.
snippet - Embed views view in Drupal 6 - 7
18 Sep, 2011
This function embeds views view in Drupal. This function doesn't display the title of the view.
snippet - Get taxonomy term depth in Drupal 7
8 Sep, 2011
How to get taxonomy term depth or level in Drupal 7.
snippet - Get vid by vocabulary name in Drupal 6
8 Sep, 2011
How to get vid - vocabulary id by vocabulary name in Drupal 6. You can get it by using this little function.
snippet - Get PHP script execution time
22 Aug, 2011
How to test execution time of any part of the code in PHP. Basically you have to start counting microseconds before you code execution and stop after. This snippet shows how to do the counting.
snippet - Get taxonomy vocabulary id by machine name in Drupal
20 Aug, 2011
How to get taxonomy vocabulary id(vid) by machine name in Drupal.
snippet - Set page title for view in Drupal
20 Aug, 2011
Sometimes it's hard to set the title you want for your views. So you have to do this programmatically in your module. This snippet shows you how.
snippet - Drupal 7 views prerender
17 Aug, 2011
How to edit views content before rendering the view. This is what you need in your Drupal 7 module.
snippet - Redirection in JavaScript
16 Aug, 2011
There are many ways of doing redirect in JavaScript this should be the standard implementation for changing the current window's location.
snippet - Hide or remove /node page in Drupal
9 Aug, 2011
How to hide default /node page from viewers. It's useful to do this if you don't use the page. People might access to some unwanted places.
snippet - WYSIWYG module, br instead of p tags in Drupal 7
8 Aug, 2011
How to make enter insert br tag instead of p tag. Works when using WYSIWYG module and ckeditor or tinymce.
snippet - Custom admin menu, page shows child menus in Drupal
8 Aug, 2011
This menus page shows child menus under that menu item.
snippet - Change search page title in Drupal
7 Aug, 2011
This snippet shows how to change page title on search page. For this example the title will be the content of search box(search string).
snippet - Drupal include module file
4 Aug, 2011
How to include module file to anywhere. For an example if you want to spread up your functions in different files for structure and readability then this is the right way of including module files.
snippet - Print level 2 sub-menu of main menu in Drupal 7
29 Jul, 2011
How to print sub-menus or any level menus in Drupal 7. You get only sub-menus of the current page you are on.
snippet - Remove css from theme in Drupal
27 Jul, 2011
I used theme hook called theme_css_alter. There is an array where are the css files. Foreach loop to go through them and unset ones that shouldn't be there. This one goes to your themes template.php...
snippet - Menu delimiters in Drupal
22 Jul, 2011
Menu delimiters or separators in Drupal. Tested on Drupal version 6.
snippet - Group search results by content type in Drupal 7
21 Jul, 2011
By placing this code to your themes template.php file, you get search results grouped by node/content type.
snippet - Add block to anywhere in Drupal 7
19 Jul, 2011
This snippet shows you how to load a blocks content programmatically. You can use this way to display a block anywhere you want.
snippet - Redirect form submit in Drupal 7
18 Jul, 2011
This snippet shows how to redirect form after submitting and saving in Drupal 7. You can also use Rules module for this.
written tutorial - JavaScript in Drupal 7
17 Jul, 2011
JavaScript libraries, basics and examples for Drupal 7. JavaScript is provided using the Library API.
snippet - Creating roles programmatically in Drupal 7
16 Jul, 2011
This little snippet shows you how to create roles programmatically in Drupal 7.
snippet - Adding custom content types in Drupal 7
16 Jul, 2011
Creating content types programmatically in Drupal 7. If you add this code to install hook then this way you can define your own content types in a module for an example.
snippet - Save file or image programmatically in Drupal 7
10 Jul, 2011
Save file or image programmatically. First get file from directory or URL. Then save the image and assign it to the field you wish.
snippet - Get files content type in PHP
8 Jul, 2011
This snippet gets content type of a file form external url. This snippet uses curl to download the file and get the content type.
snippet - Drupal language switcher theme
7 Jul, 2011
How to create custom language switcher. You can write your own tags and classes to get completely custom language switcher.
snippet - jQuery send form via AJAX using post method
29 Jun, 2011
This snippet sends form with id contactform using ajax via post method. When it's send and result is returned. It writes result into #feedback-form.
snippet - Always have latest jQuery version
29 Jun, 2011
To always have latest jQuery version, you can use this fast loading jQuery library from Google.
snippet - Get nodes by content type in Drupal
23 Jun, 2011
How to get node ids of certain content type in Drupal.
snippet - Add dependencies to Drupal modules
21 Jun, 2011
To add add dependencies to Drupal modules you have to open your modules .info file. Add new line "dependencies[] = module_machine_name" and you are done.
snippet - Order Views Programmatically in Drupal
19 Jun, 2011
How to order views programmatically. You might need to do this on special occasions. This hook initializes before query is built so it goes for all data, not just current page.
snippet - Create Drupal Page Programmatically
17 Jun, 2011
This snippet is a code from my module that just makes a simple menu item into my admin menu in Drupal 7. I am using menu_hook function to achieve this.
snippet - jQuery selector exists
16 Jun, 2011
This snippet shows how to check if jQuery selector exists.
snippet - Drupal - Alter Node Form
12 Jun, 2011
How to use hook_form_alter for altering node forms.
snippet - Add your css stylesheet to TinyMCE at admin panel in WordPress
1 Jun, 2011
Adding your css stylesheet to TinyMCE editor in WordPress admin panel.
snippet - Remove RSS feed from head tag in WordPress
30 May, 2011
How to remove RSS feed from head tag in your template.
written tutorial - Get and save jQuery window scroll position
24 May, 2011
Getting and save window scroll position with jQuery. You also need cookie plugin to store the position value in cookies, so it can be used after browser page changes.
written tutorial - How to create a widget in WordPress
23 May, 2011
How to make a widget that has one textbox and custom html output in WordPress.
snippet - Get node path alias in Drupal
15 May, 2011
How to get node path alias in Drupal. All you need to know is node id(nid).
snippet - Add taxonomy terms in Drupal 7
14 May, 2011
How to add taxonomy terms programmatically in Drupal 7.
snippet - get_posts multiple categories in WordPress
12 May, 2011
How to get posts from multiple categories using get_posts function.
snippet - Drupal get comment form
10 May, 2011
How to place Drupal node comment form to anywhere in your module or theme.
snippet - Get Years in PHP
3 May, 2011
How to get current, last and coming year in PHP. Simple examples of how you can get different years. Currently the years are calculated from the server time.
snippet - Get text area value or text with jQuery
29 Apr, 2011
This snippet shows how to get html element textareas value or text with jQuery.
snippet - Getting Base URL in WordPress
26 Apr, 2011
This example shows you how to get base URL of your wordpress powered website. It takes the value from your site information which can be modified and was set during the installation of WordPress.
snippet - ColorBox for Ajax loaded content in Drupal 7
22 Apr, 2011
ColorBox for images is loaded on first load, so all images loaded by ajax are colorBox free. To enable ColorBox for ajax loaded images you have to scan the html for images after load is complete....
snippet - Enable or disable comments using node_save in Drupal 7
21 Apr, 2011
You can enable or disable comments programmatically. Get node using node_load, set comment value and save node.
snippet - Center Floats with CSS
17 Apr, 2011
Center floating divs or menus or any kind of floats using css.
snippet - Drupal Snippet:
17 Apr, 2011
First find this line: $form['path']['pathauto_perform_alias'] = array( Then add: '#value' => 1,
written tutorial - Switching Images With Arrows in JavaScript
7 Apr, 2011
This tutorial shows how to make image switcher with javascript. You can switch images by using arrows.
written tutorial - Getting Taxonomy Terms Names in Drupal 7
6 Apr, 2011
This tutorial shows how to get taxonomy terms names in Drupal 7. First how to get all taxonomy terms, how to get categories by a parent and with a little effort, you can turn it into a treeview.
written tutorial - Create Nodes programmatically using node_save in Drupal 7
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...
written tutorial - Get Drupal 7 Profile Fields with profile2_load
14 Mar, 2011
How to get profile fields in Drupal 7. Profile fields are made with Profile2 module.
written tutorial - How to Create Drupal Module
12 Mar, 2011
This beginners tutorial shows how to create a durpal module. We will set up a module, create a menu item and a "Hello World" page.
written tutorial - Get Full/Absolute URL in Drupal
11 Mar, 2011
How to get full/absolute url of the page you are currently visiting.
written tutorial - Searchbox Background Text with jQuery
24 Feb, 2011
This tutorial shows how to create background text to your search box that will dissapear on click/focus.
written tutorial - Include External JavaScript Files to Drupal
22 Feb, 2011
This Drupal API tutorial shows you how you can include external javascript files.
written tutorial - PHP: Add Zeros Before Number
20 Feb, 2011
This tutorial shows how to add or append zeros before numbers. You might need this if you want to make folders named by numbers and you want them to be in right order when browsing the folder with...
written tutorial - jQuery - Send Single Form Field via Post on Blur
19 Feb, 2011
This tutorial shows how to send a single form field/input of a form. We are going to use jQuerys ajax features to do that.
written tutorial - Get Values of Checkboxes Group with jQuery
9 Feb, 2011
This tutorial shows you how to get values of checkbox array using jQuery. You can use this to send selected checkboxes values with ajax or add those to url variable(like in this example). If you...
written tutorial - jQuery Change Image src Attribute
4 Feb, 2011
You can use these examples to change img tags src attribute or any attribute of any tag.
written tutorial - IE Only CSS Files in Drupal
29 Dec, 2010
How to make Internet Explorer only CSS files for Drupal themes.
written tutorial - Installing App Engine Python SDK on Ubuntu
20 Dec, 2010
Installing Google App Engine SDK on Ubuntu or any linux distribution.
written tutorial - Installing Yii Framework
17 Dec, 2010
How to install and set up Yii framework application to your hosting.
written tutorial - Add Text to Image in PHP
15 Dec, 2010
This tutorial shows how you can add text to images with PHP. You can use it to make banners with dynamic content for an example.
written tutorial - How to echo or print arrays in PHP
6 Dec, 2010
Examples of parsing array values on screen. Some examples for beginners.
written tutorial - Custom Node Layout in Drupal
6 Dec, 2010
This tutorial shows you how to make a custom node layout. Which is a custom placement of node fields. Also we do it without any coding.
written tutorial - HTML Symbol Codes Table
30 Nov, 2010
HTML symbol codes are used to replace symbols so they would fit in ASCII codes. Also to remove certain symbols so content wouldn't interfere with HTML.
written tutorial - Drupal Tutorial: Multiple Nodes on One Page
30 Nov, 2010
This tutorial shows how to show multiple nodes on one page. Just like front page but not with a checkbox but different content type. Views are used for this.
written tutorial - Storing Images in MySQL With PHP
12 Nov, 2010
Easy to understand tutorial on how to upload, store and display images in mysql database.
written tutorial - HTML Upload Form
12 Nov, 2010
Upload form allows users to upload files through their browsers.
written tutorial - Writing Text in Canvas Tag
20 Oct, 2010
How to put, render, write or draw text in canvas tag using drawText function in JavaScript.
written tutorial - Draw Circle in HTML5 Canvas Tag
19 Oct, 2010
Drawing a circle in canvas tag with arc function is actually really simple, but you have to have a browser that supports HTML5.
written tutorial - What’s New in HTML5?
19 Oct, 2010
HTML5 introduces a number of new elements and attributes that reflect typical usage on modern websites. The new standard incorporates features like video playback and drag-and-drop that have been...
written tutorial - Create Treeview Using Recursion in PHP
9 Oct, 2010
An easy example of recursion. PHP treeview can be used to create hierarchical lists like menus including sub-menus, category trees, taxonomy trees or site maps. This tutorial shows you how to...
written tutorial - Parsing JSON With jQuery
25 Sep, 2010
Getting data from JSON with jQuery is really simple.
written tutorial - Converting CodeIgniter Query to JSON
24 Sep, 2010
This tutorial shows you how you can generate JSON from SQL data that comes from model. Converting query to JSON is really simple in PHP and even simpler in CodeIgniter.
written tutorial - CodeIgniter Login With Google Using OpenID
20 Sep, 2010
How to make login system for CodeIgniter using OpenID. This example uses Google Accounts for login.
written tutorial - CodeIgniter - Cache Any Code Into a File
19 Sep, 2010
This tutorial shows you how you can cache code in CodeIgniter, by saving string or plain text into a file.
written tutorial - Round Corners for HTML Divs in CSS
12 Sep, 2010
This tutorial shows you how to make round corners for divs. From scratch with and without jQuery UI library.
written tutorial - 100% layout with footer bottom of the page
3 Sep, 2010
This tutorial shows how you can make 100% height and width layouts with footer that stays always at the bottom of the page.
written tutorial - Add Form Fields With jQuery
26 Aug, 2010
This tutorial is about adding form fields, more precisely how to add textboxes dynamically with JavaScript. To make the code easier I use jQuery library.
written tutorial - Loading AJAX Page / Dynamic Content
25 Aug, 2010
Tutorial about loading page with AJAX between any HTML tags. We are using jQuery JavaScript library to do this.
written tutorial - Generate RSS 2.0 Feeds with CodeIgniter
22 Aug, 2010
In this tutorial we will make RSS 2.0 feeds from latest posts in your site.
written tutorial - Writing App Engine RSS Feeds
18 Aug, 2010
This tutorial shows how to make RSS feeds in Python for Google App Engine.
written tutorial - Delete Row From Datastore in AppEngine
16 Aug, 2010
Fourth part of AppEngine Forms. This time we delete added rows from database.
written tutorial - AppEngine Edit Form in Python
16 Aug, 2010
Third part of AppEngine Forms. This time we are making edit from.
written tutorial - AppEngine Forms in Python
16 Aug, 2010
Tutorial about making forms in AppEngine with Python. First part.
written tutorial - Submit AppEngine Forms Using POST in Python
16 Aug, 2010
Second part of AppEngine Forms. This time we will try to get our data through post and save the data to database.
written tutorial - HTML Lists Examples
8 Aug, 2010
This tutorial shows different kinds of HTML lists. There are lists with bullets, numbers, etc...
written tutorial - Login, Register and Logout in Python for AppEngine
3 Aug, 2010
This tutorial shows how to make Log In, Log Out and Register links for Google App Engine in Python.
written tutorial - Get Self/Base URL in Python
1 Aug, 2010
This tutorial shows you how to get your domain name(base url) from address bar in Google AppEngine, using self and urlparse
written tutorial - HTML Contact Form
25 Jul, 2010
How to make HTML contact form. First part of pop-up AJAX form submission that also works with no JavaScript.
written tutorial - Popup Contact Form With jQuery UI
25 Jul, 2010
Making beautiful pop-up contact form with jQuery and jQuery UI. If JavaScript is disabled the form is usual.
written tutorial - CakePHP Routing - URL With Parameters Only
25 Jul, 2010
This tutorial shows how to do URL routing in CakePHP, if you need your URL to be without controller and view.
written tutorial - Dynamic Layout With Dynamic Menu in CakePHP
24 Jul, 2010
This tutorial shows how you can attach dynamic menu or any content to layout that you still want to call from controllers.
written tutorial - Installing CakePHP
22 Jul, 2010
This tutorial shows how to install CakePHP. After this tutorial you can start making web application.
written tutorial - PHP Global Variables
15 Jul, 2010
Tutorial about global variables in PHP. How to use global, superglobal in PHP.
written tutorial - jQuery: Create a function
5 Jul, 2010
Tutorial about creating your own functions using jQuery JavaScript library.
written tutorial - Using CSS files in Python on Google App Engine
3 Jul, 2010
This tutorial shows how to use Cascading Style Sheets in Google AppEngine. It's all about url mapping. You have to have some basic setup of a project to follow this tutorial.
written tutorial - AJAX Form Submission in CodeIgniter With jQuery
26 Jun, 2010
Some knowledge of CI and OOP could be handy. This tutorial shows how to submit Ajax forms in CodeIgniter using jQuery. With optional jQuery UI feedback bubbles.
written tutorial - Handling Timestamps in PHP
25 Jun, 2010
This tutorial is about using and converting timestamps in PHP, witch are common formats of storing some timeperiod in database.
written tutorial - Integrating WYSIWYG TinyMCE into CodeIgniter
16 Jun, 2010
This tutorial shows you how to set up WYSIWYG TinyMCE in CodeIgniter. Both versions standalone and jQuery. It's really easy, most time takes the sample code tweaking.
written tutorial - Setting up Netbeans + Google App Engine + Python
13 Jun, 2010
This tutorials shows how to set up NetBeans IDE for writing Python for Google App Engine. Using NetBeans IDE is optional, you can complete the tutorial by skipping all the NetBeans related steps.
written tutorial - Displaying random value from array in PHP
13 Jun, 2010
This beginners tutorial shows and explains how to get random value from array in PHP.