Quantcast
Channel: User Amy - Drupal Answers
Browsing latest articles
Browse All 42 View Live

Comment by Amy on Change max length of title in a custom block added via a...

If you are embedding a view you should be able to limit the character count within that.

View Article



Comment by Amy on Move images from a image field to another field

Why would it be necessary to use paragraphs? Is there an issue stopping you from just adding another field for videos? There are many ways you can migrate data from one field to another but what's best...

View Article

Comment by Amy on Batch delete users and the content they created

@mbomb007 I don't think that answers the question because they also want to delete the content created by the blocked users.

View Article

Comment by Amy on How to reset admin password if account is blocked

@NoSssweat phpmyadmin was just the tool they were using to access the Drupal database. Arcticlisa just wanted to know how to unblock and reset a drupal admin password, which is unique to drupal.

View Article

Comment by Amy on Get Entity from Path or Url Object Retrieved from Menu...

@Keven I believe something '/this-is-the-alias' works. Let me know if that doesn't.

View Article


Comment by Amy on Drupal 7 Commons 3 Vs Drupal Core + Commons modules

@Umair I know this was years ago but I just ran into the same issue. It's because that function is defined in the commons.profile file in the profiles folder. Which isn't going to be used if that...

View Article

Comment by Amy on How can I get the path alias from a node ID or node object?

One of the issues with this is if there's a core update that changes how these aliases are stored this code will break.

View Article

Comment by Amy on Programmatically change view mode of media field

@sonfd I have but that hook doesn't get triggered by my media field.

View Article


Comment by Amy on Use a different twig media template if it is being rendered...

Which preprocess hook could I use this in?

View Article


Comment by Amy on How to add new fields to the 'edit media' dialog box on...

Thanks that worked great! Helpful as always Clive

View Article

Comment by Amy on Set nested value in storable config

That worked thanks!

View Article

Comment by Amy on Add tab for custom entity type on content page

Thanks this worked! It's enough info to land on the answer but If you like, you could mention that the base route would be system.admin_content since the question specifically asked about how to make...

View Article

Comment by Amy on How to programmatically invalidate the cache of every node

@Jaypan The reason why every node needs to be invalidated is because I've built a custom config that allows the admin to globally add a button that appears on every page. Because this appears on every...

View Article


Sort entityQuery by date published

I'm attempting to perform a query to retrieve only the three most recent nodes of a certain content type.$query = \Drupal::entityQuery('node') ->condition('type', 'blog_post')...

View Article

Answer by Amy for How do I programmatically update a UUID?

This is the route to go if you must add the uuid in this manner.$uuid = 'd12da227-890b-4eb7-86b1-93937e7d6d91';$p->set('uuid',$uuid);$p->save();

View Article


How to programmatically edit field settings of a content type

My ultimate goal is to use a drush command to change the allowed paragraphs in a paragraph entity reference field for various content types.I'm able to load the field entity and see the settings I need...

View Article

Answer by Amy for How to programmatically edit field settings of a content type

I was able to perform the edit like so$field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'custom_content_type');...

View Article


Answer by Amy for Get proper ID from media entity for file loading purposes

The issue was I wasn't thinking about using the actual field from the media object that contained the file. The IDs on the media object lining up with the files I needed might have been coincidences.In...

View Article

Get proper ID from media entity for file loading purposes

I'm attempting to load the file attached to a media entity used in a field attached to a paragraph in order to create a url to the file. $vid =...

View Article

How to check in a custom constraint validator whether a field allows for...

In my custom validator plugin I want to be able to tell whether the field value given was part of a field that allowed for more than 1 value.For example public function validate($items, Constraint...

View Article

Prevent validation constraint from triggering when 'add more' button is clicked

I have a custom validation constraint plugin that prevents submission if an entity reference field has an odd number of values. The validation triggers upon submission just fine public function...

View Article


Answer by Amy for Prevent validation constraint from triggering when 'add...

I was able to resolve this by setting the #limit_validation_errors property on the button to an empty arrayLike so:public static function alterFormElement(array &$element, FormStateInterface...

View Article


Answer by Amy for How to convert paragraph library item (ContentEntityBase)...

I was able to accomplish this by using the ViewBuilder like so$paragraphsRender = \Drupal::entityTypeManager() ->getViewBuilder('paragraphs_library_item') ->viewMultiple($paragraph_ids);

View Article

How to convert paragraph library item (ContentEntityBase) to render array for...

I'm attempting to render an array of LibraryItems in a twig template but I'm having trouble figuring out how to retrieve the render array.Currently my twig template looks like this{% set paragraphs =...

View Article

Display only the value of a field in a content-type template

I'm attempting to display a plain text field so that I can use it to embed youtube videosIn my template I have<iframe width="420" height="315" src="https://www.youtube.com/embed/{{...

View Article


How to create a view listing vocabularies (not terms)

I'm attempting to create a view that filters and displays a list of vocabularies however I can't seem to find an option to allows me to do so.In the View settings, I see options for taxonomy terms, but...

View Article

Answer by Amy for How to render a twig template in the meta data of a...

Looks like I needed to use renderPlain instead of render

View Article

How to render a twig template in the meta data of a cacheablejson response?

In a json response I'm returning some prerendered data. However I got tired of constructing the html by concatenating strings in php and decided to make a twig template for it.$render_facets_arr =...

View Article

Specifying parameters for block_load [closed]

I'm attempting to load a Book Navigation block programmatically inside another block. After doing some research it seems that I need to take advantage of the bload_load function. I'm using$block =...

View Article



Is there a way to specify order in a search_api query manually given a set of...

Using search_api I have an query with the following condition$query->condition('nid', [1,5,3,7,10], 'IN')I know I can sort by things like created date or title, but what if I knew the exact order I...

View Article

Answer by Amy for How do I create a paragraph using a bundle class defined in...

4uk4 was correct. Defining the class was unnecessary. I was able to generate the paragraph with the proper bundle class applied automatically by just defining 'type' in the create method of the...

View Article

How do I create a paragraph using a bundle class defined in another module?

I have a controller in one module that generates paragraphs that are using unique bundle classes that I want to be able to use in other modules.In my controller I have this$bundle_class =...

View Article

How to retrieve GET parameter in Twig template

I'm attempting to retrieve a GET request variable for use in a twig template.For instance if you go to the page myurl.com/node/64?name=Dave I want the page to render<h1>Dave</h1>However I'm...

View Article


Answer by Amy for Sort nodes by weight of taxonomy term attached to field

I was able to sort by the taxonomy weight with this->sort('field_my_custom_field.entity.weight','DESC');

View Article

Sort nodes by weight of taxonomy term attached to field

In a query for nodes I'm trying to sort the nodes by the weight of a taxonomy term attached to one of the node fields.Here is how my query is built $node_storage = \Drupal::entityTypeManager()...

View Article

Add text to user login page

I'm attempting to add text to user login page, with general info about accounts rather than only displaying the login form.I have a page.html.twig template like so{{ page.header }}<h2>This is my...

View Article


Remove certain content types from search

There are certain content types such as book pages that I don't want to appear on the search results page. I found example code implementing this on drupal 7 here/** * Implements hook_query_alter(). *...

View Article


Programmatically append values to entity reference field of node with a...

I understand that I can append values to an entity reference field to a node normally with this method$node->field_tags[] = ['target_id' => $my_id, ];However I have a function like sofunction...

View Article

Query webform submissions

I'm attempting to perform a query on webform submissions so I can display all submissions submitted by a specific user. However I'm not sure how to make this query. I made a guess that webform...

View Article

Add file field with Form API

I'm writing a block plugin that uses the form API to allow users to edit its settings, and then output them into a template.I'm currently using<?php/** * @file * Contains...

View Article

Image may be NSFW.
Clik here to view.

View is removing iframe from custom text

I'm using a global custom text field within a view that is meant to display an embedded youtube video. However in the actual render of the view it's completely removed from the dom.My first assumption...

View Article


Children of children not appearing in book navigation menu

UPDATE: I should mention that this is concerning the Book Navigation BlockI'm using the book module to display children of a book in a side menu. It displays the title of the book and it's children...

View Article
Browsing latest articles
Browse All 42 View Live


Latest Images