Skip to content

Instantly share code, notes, and snippets.

View rakeshjames's full-sized avatar
💤

Rakesh James rakeshjames

💤
View GitHub Profile
@rakeshjames
rakeshjames / ExampleController.php
Created September 30, 2014 12:04
Drupal 8 Custom module example
<?php
/**
* @file
* @author Rakesh James
* Contains \Drupal\example\Controller\ExampleController.
* Please place this file under your example(module_root_folder)/src/Controller/
*/
namespace Drupal\example\Controller;
/**
* Provides route responses for the Example module.
@rakeshjames
rakeshjames / example.module
Created October 1, 2014 11:46
Drupal 7 Ajax call back on form submit example
<?php
/**
* @File
* The following code from the "example.module" will help you to find the example using AJAX form with one textfield called “Name”. When the submit button is pressed, it shows the output “Hello <Name>”.
*/
/**
* Implementing hook_menu().
*/
function example_menu() {
@rakeshjames
rakeshjames / example.module
Created October 1, 2014 11:49
Drupal 7 - Add a cancel button on node forms (How to add a cancel button on node form?)
<?php
/**
* Implements hook_form_alter().
*/
function example_form_alter(&$form, &$form_state, $form_id) {
// You might want to filter by content type.
if ($form_id == 'YOUR_content_type_node_form') {
// Add a cancel button.
$form['actions']['cancel'] = array(
@rakeshjames
rakeshjames / auto_load_block.php
Created October 14, 2014 09:37
Auto click or auto loading popup with colorbox drupal 7?
<?php
global $base_url;
print "<div class = 'auto-click'><a href='" . $base_url . "/video/1?width=500&height=500' class = 'colorbox-load'></a></div>";
if (!empty($_GET['banner'])) {
$thankyou = $_GET['banner'];
if ($thankyou == 'yes') {
echo "<script langauge='javascript'>
jQuery(window).load(function(){
jQuery('.auto-click a').click();
});
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
}
@rakeshjames
rakeshjames / example.module
Last active August 29, 2015 14:10
Drupal 7 How to add a button act like "Clear all caches" in the custom form in custom module? example
<?php
/**
* @File
* Example for button act like "Clear all caches" in the custom form in custom module
* @author Rakesh James
*
*/
/**
* Implementing hook_menu().
<?php
/**
* Implementing hook_form_alter()
* @param $form
* @param $form_state
* @param $form_id
*/
function YOUR_MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'views_exposed_form') {
$term_reference_tree_path = drupal_get_path('module', 'term_reference_tree');
server {
listen 80 default_server;
root /srv/www/drupal8;
index index.php index.html index.htm;
server_name YOUR_SERVER_NAME.com;
location / {
try_files $uri @rewrite;
}
name: Example Profile
type: profile
description: Example for profile creation in Drupal8.
core: 8.x
distribution:
name: Example Distribution.
dependencies:
- automated_cron
<?php
/**
* @file
* Enables modules and site configuration for the Example Profile profile.
*/
// Add any custom code here like hook implementations.