Skip to content

Instantly share code, notes, and snippets.

View purushotamrai's full-sized avatar
👨‍💻
git bisect good

Purushotam Rai purushotamrai

👨‍💻
git bisect good
View GitHub Profile
$type = node_type_load('marketing_tool');
$type->type = 'download_library_item';
$type->old_type = $type->orig_type; // This will be 'example'.
node_type_save($type);
node_type_update_nodes('marketing_tool', 'download_library_item');
node_types_rebuild();
node_access_rebuild();
if (variable_get('site_default_country') == 'US') {
// change weight views for specific country.
}
/**
* Implements hook_replicate_entity_ENTITY_TYPE().
*/
function replicate_replicate_entity_node(&$entity) {
$entity->nid = NULL;
$entity->tnid = NULL;
$entity->vid = NULL;
$entity->created = NULL;
$entity->changed = NULL;
$entity->path = NULL;
@purushotamrai
purushotamrai / DestinationItem.js
Created February 14, 2019 17:00
Getting Started with ReactJS and Drupal - Step 3 - DestinationItem.js
import React from 'react';
export default class DestinationItem extends React.Component {
render() {
return (
<div>
<h2>Travel Destination Title</h2>
<div>Travel Destination Description goes here</div>
@purushotamrai
purushotamrai / DestinationList.js
Created February 14, 2019 17:02
Getting Started with ReactJS and Drupal - Step 3 - DestinationList.js
import React from 'react';
import DestinationItem from "./DestinationItem";
export default class DestinationList extends React.Component {
render() {
return (
<div>
<h1>Here are your best Travel Destinations</h1>
<DestinationItem/>
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:03
Getting Started with ReactJS and Drupal - Step 3 - App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import DestinationList from "./Components/Destination/DestinationList";
class App extends Component {
render() {
return (
<div className="App">
<DestinationList/>
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:04
Getting Started with ReactJS and Drupal - Step 4.1 - App.js
constructor() {
super();
this.state = { data: null };
this.loadDestinations = this.loadDestinations.bind(this);
this.updateData = this.updateData.bind(this);
}
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:05
Getting Started with ReactJS and Drupal - Step 4.1 - App.js
const LIST_URL = 'http://td-drupal.local:80/jsonapi/node/destination';
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:06
Getting Started with ReactJS and Drupal - Step 4.1 - App.js - loadDestinations
loadDestinations() {
// Fetch Destinations.
fetch(LIST_URL, {mode:'cors'})
.then(function (response) {
return response.json();
})
.then((data) => this.updateData(data))
.catch(err => console.log('Fetching Destinations Failed', err));
}
@purushotamrai
purushotamrai / App.js
Created February 14, 2019 17:07
Getting Started with ReactJS and Drupal - Step 4.1 - App.js updateData
updateData(responseData) {
  this.setState({data: responseData.data});
 }