This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Drupal 8 CORS set up for services

I am setting up a view with views, with display being rest json, how can I set up the Cross-Origin Resource Sharing (CORS) for it. I suppose the solution is to modify the defaut.servercies.yml, which is indicated by https://www.drupal.org/node/2715637 and I did already. But I still can not request the json resource from a different host. Does somebody know how to solve this?

SOLVED: Get File Uri of Node (Content Type)

Explanation

Within my block's configuration code (which implements the admin panel for configuring my custom block), I am attempting to get a file Uri of some custom content I've created.

The content type I created (jssor_content_type), contains a list of files. So each content type has 1 to n files associated with it.

Class not found when I try to use psr-4 in a drupal 7 project

Hello, I'm trying to develop a private module in d7, and I'm trying to use the psr-4 to load the class

Mi class is in /sites/all/modules/mymodule/src/Controller/MyclassPage404.php
And I have a static method call: render

My namespace is: Drupal\mymodule\src\Controller;

I'm trying this in the hook_menu

'page callback' => '\Drupal\mymodule\Controller\MyclassPage404::render'

But I only get

Add class to field in Drupal 8

I'm putting this here for my own future reference, because I know it's something I'll google in a year and be happy to find!

First, implement hook_preprocess_field().

However, it's best to target the specific field that you want to add the class to, so that the function is run for every field on every page. You can do this by enabling theme debugging, and looking at the theme suggestions in the code. Find the field, choose the template suggestion, drop the .html.twig, and convert hyphens to underscores.

getting entity field values in twig template

How to get user registration field(entity field value) values separetly in module twig template.

Like in registartion form if first name and last name field(entities) is there then how to access in twig files.

Display Custom Content Type within a Block

Is it possible to display a custom content type within a custom block, i.e. I've created the content type, and the block. The block is implemented via a module.

Ideally, within the block configuration area, I want the user to be able to select a single piece of content (it must be the specified content type). The selected piece of content will then be displayed within the block.

I've looked into this for a couple of hours, but I'm still stuck. Is the custom content type technically an entity? If so can I get at it from within my block's configuration code?

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions