drupal-8

passing a parameter from a content type to a module

被刻印的时光 ゝ 提交于 2019-12-13 21:59:01
问题 I assumed this would be easy but I am stumped. I have a custom content type that includes an id field. I render these with a basic page template. I have written a small module that creates a block which is populated with data from an external API. Everything works except I cannot seem to figure out how to pass the value of the id from the content of a given page to my module so it can make the API call. It would be a couple of lines of code in straight php, it can't be that complicated in

programmatically get all nodes from drupal 8

戏子无情 提交于 2019-12-13 18:26:49
问题 I am trying to get all nodes of a certian type from drupal. I have tried many ways to achieve that, but maybe due to my lack of Drupal custom module programming experience I couldn't achieve my desire. the closest way that I found on the web, is this: $nids = \Drupal::entityQuery('node')->condition('type','news')->execute(); $nodes = \Drupal\node\Entity\Node::loadMultiple($nids); the first line returns an object of id's the second line returns the nodes of those id's this looks easy and

Acces raw data in Drupal 8 view template

旧街凉风 提交于 2019-12-13 16:21:19
问题 In a overridden template of the View module (views-view-field.html.twig), i'm trying to access to the raw data of a field. In the doc file, we can read this: * Available variables: ... * - fields: A list of fields, each one contains: ... * - raw: The raw data for the field, if it exists. This is NOT output safe. ... but it's alway's empty. {{ dump(fields.field_myfieldname) }} print object(stdClass)[1899] ... {{ dump(fields.field_myfieldname.raw) }} print null I want the raw to build a file

Why is my Drupal 8 CORS setup not working?

醉酒当歌 提交于 2019-12-13 14:15:34
问题 Since Drupal 8.2 the cors setup is in core. In my services.yml (and default.services.yml ) I have the following setup: cors.config: enabled: true # Specify allowed headers, like 'x-allowed-header'. allowedHeaders: ['x-csrf-token','authorization','content-type','accept','origin','x-requested-with'] # Specify allowed request methods, specify ['*'] to allow all possible ones. allowedMethods: ['*'] # Configure requests allowed from specific origins. allowedOrigins: ['*'] # Sets the Access-Control

Columns must be immediate children of rows?

微笑、不失礼 提交于 2019-12-13 07:59:00
问题 Columns must be immediate children of rows or I can have other divs inside a row without being a column? I'm working with drupal and it produces a lot of divs inside a container or row I've created. For example I'm restricted to follow this structure always: <div class="container"> <div class="row"> <div class="col"> One of three columns </div> <div class="col"> One of three columns </div> <div class="col"> One of three columns </div> </div> </div> Or I can do something like this: <div class=

Drupal 8 YAML Form Module: Populate Select Element

柔情痞子 提交于 2019-12-13 07:38:16
问题 I'm a newbie in Drupal and I'm trying to create custom forms in Drupal 8 using 'YAML Form' module: https://www.drupal.org/project/yamlform I have added some 'select' elements with some custom options from the Form elements page provided by the module, but I don't find the way to populate these elements from database. How can I do it? Step by step if possible, please. Thanks in advance! 回答1: I don't know if it's the best way to do it but it works for me: I've created a custom module and in the

Solarium gets “Permission Denied” when trying to connect apache solr at local ip

跟風遠走 提交于 2019-12-13 05:25:17
问题 I have a drupal 8 site on the same physical server as apache solr (5.2.1). Drupal 8 uses the search_api_solr contrib module, which uses Solarium (installed by composer) to talk to the solr server using the http api. I have successfully installed solr and created a core. I can query the core using cUrl on the linux command line, using various linux users. I can access the solr admin screen in a browser (over vpn with 192.168 ip or domain resolving to such) and view the core I created on the

Saving data with varying keys and values

岁酱吖の 提交于 2019-12-13 04:36:34
问题 What I want to do I want to have templates tied to a page that can have varying amounts and kinds of data within it. So template a can have a list or just body content or a special layout. I want part of this content to be editable from the frontend using create.js. So the page title, the body content, ect would all be editable and need to be saved somewhere (mysql) and somehow. I do not want the content edited in one big WYSIWYG editor. Similar Functionality but not quite Wordpress allows

Solr Error: Unable to create core [mycore] Caused by solr.ICUCollationField

白昼怎懂夜的黑 提交于 2019-12-13 03:46:39
问题 I am trying to create a solr core, I am using drupalvm with vagrant and virtual box. When setting up solr with this command: sudo su - solr -c "/opt/solr/bin/solr create -c m4m -d /tmp/search_api_solr/solr-conf/7.x/" I am getting this error: INFO - 2018-11-05 19:21:45.804; org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop ERROR: Error CREATEing SolrCore 'mycore': Unable to create core [mycore] Caused by: solr

Is there a way to input the data of multiple content types all on the same page in Drupal 8?

こ雲淡風輕ζ 提交于 2019-12-13 03:13:57
问题 I have three content types: student , course , and student_takes_course ( student_takes_course have two reference fields that points to the student and course content types). To input a new student_takes_course record, I would first have to go to the student content type and input a new student record, and then go to the course content type and input a new course record, and only then I can go to the student_takes_course content type and input a new record that have references to the newly