php working preferrably composer working too
mkdir drupal && cd drupal && curl -sSL https://www.drupal.org/download-latest/tar.gz | tar -xz --strip-components=1
/** | |
1. Make sure the exported file does not exist (archive.csv) | |
2. Replace the following with the correct information: | |
- THE_FOLDER_ON_THE_DAM | |
- MYCLOUDNAME_HERE | |
- MY_API_KEY_HERE | |
- MY_API_SECRET_HERE | |
3. npm install csv-writer and npm install cloudinary | |
4. Run with 'node cloudinary_metadata_export.js' | |
<?php | |
if(empty($_GET['submithandler']) && empty($_POST['submithandler'])) { | |
http_response_code(400); | |
die('Invalid data'); | |
} | |
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']); | |
require_once DRUPAL_ROOT. '/includes/bootstrap.inc'; | |
require_once DRUPAL_ROOT. '/includes/common.inc'; |
<?php | |
$header = array(); | |
foreach ($programs->list as $program) { | |
$rows[] = array( | |
'img' => array( | |
'data' => array( | |
'#theme' => 'image', | |
'#attributes' => array( | |
'src' => $program->images[0]->url, //Images come from an external resources, otherwise use #uri on the level of #attributes | |
) |
<?php | |
$tree = \Drupal::service('entity_type.manager') | |
->getStorage("taxonomy_term") | |
->loadTree($vid, $parent = 0, $max_depth = NULL, $load_entities = FALSE)); |
//render all content without a specific field | |
{{ content.without('field_name') }} | |
//render only one specific field | |
{{ content.field_audio_file }} | |
//render only one specific field's value | |
{{ content.field_audio_file.value }} |
<?php | |
// Drupal 7 | |
global $is_https; | |
if ($is_https) { | |
// Do something | |
} | |
// Drupal 8 | |
if (Drupal::request()->isSecure()) { |
<?php | |
// Fetching The data via the container (old variable_get) | |
$data = \Drupal::config('my_module.settings')->get('my_setting_name'); | |
// Fetching the data via the Settings class | |
use Drupal\Core\Site\Settings; | |
$settings = Settings::get('http_client_config'); | |
$data = $settings['my_setting_name']; |
<?php | |
$client = \Drupal::httpClient(); | |
$url = 'http://something.com/data.json'; | |
try { | |
$request = $client->get($url); | |
$status = $request->getStatusCode(); | |
//Do something here. | |
//For example: | |
return json_decode($request->getBody()->getContents()); | |
} |
<?php | |
use Drupal\image\Entity\ImageStyle; | |
use \Drupal\file\Entity\File; | |
//Load the file | |
$file_id = 2; | |
$file = file_load($file_id); | |
//Render the IMage style "large" | |
$image_large_url = ImageStyle::load('large')->buildUrl($file->getFileUri()); |