drupal-8

Drupal 8: render view in twig template

此生再无相见时 提交于 2020-01-25 06:50:35
问题 I created view with name "centers" and render that view in twig template with {{ views_embed_view('centers', 'block_1') }}. It gives me nothing in result. So,please anyone help me 回答1: The above module was depreciated in favour of Twig Tweak Twig Tweak module provides a Twig extension with some useful functions and filters that can improve developer experience. Ex: <dd>{{ drupal_view('centers', 'block_1') }}</dd> hope this help you THANKS 来源: https://stackoverflow.com/questions/46971639

Twig: how to check the inner html content of a field

假装没事ソ 提交于 2020-01-23 12:25:32
问题 i have a single field and that field can have one or two lines of html: <p>One line</p> or: <p>first line</p> <p>Second line </p> Using twig how can i check if the field has one or two tags. Example of what i want to do: {% if item|length('<p>') = 1 %} <div class="one">{{ item }}</div> {% elseif item|length('<p>') = 2 %} <div class="two">{{ item }}</div> {% endif %} Any ideas of how to accomplish this? Update #1: What Honza said is true I want the parent div to have a class if there is only

Populate twig template from external api

孤者浪人 提交于 2020-01-17 03:05:30
问题 I am building a Drupal 8 site and am new to the twig templating engine. For one specific content type I would like to make a call to an external restful api and render some of the returned data as fields in the twig template. I have an internal id to call out to the API and I would like to embed in the template: The api call set a number of variables from the call render the result (with some logic if it does not exist) Is this something that is easy to do with twig and drupal 8? As a

Extract Url & Title from link field in Drupal 8?

爷,独闯天下 提交于 2020-01-11 15:28:33
问题 I'm trying to retrieve the URL and the Title values of a Link field in Drupal 8 . In my custom controller, I retrieve the nodes with: $storage = \Drupal::entityManager()->getStorage('node'); $nids = $storage->getQuery() ->condition('type', 'partners') ->condition('status', 1) ->execute(); $partners = $storage->loadMultiple($nids); When I loop throught all my nodes, to preprocess vars I'll give to my view, I would like to retrieve the URL and the Title . foreach ($partners as $key => $partner)

Increase behat performance with drush driver

為{幸葍}努か 提交于 2020-01-06 19:29:12
问题 I am running behat inside vagrant in a drupal installation. When I use the drush driver, in order to authenticate an admin for example, the test runs extremelly slow(2'). My behat.yml is: default: suites: default: contexts: - FeatureMinkContext - FeatureContext: - "/vagrant/images/behat" - 813 - 1855 - Drupal\DrupalExtension\Context\DrupalContext - Drupal\DrupalExtension\Context\MinkContext - Drupal\DrupalExtension\Context\MessageContext - Drupal\DrupalExtension\Context\DrushContext

Theme installation in drupal 8 Fails

南楼画角 提交于 2020-01-06 18:09:39
问题 i am a newbie in drupal. I installed drupal then tried to change the theme i tried three themes. Everytime i get the same error zircon_profile-8.x-1.0-beta11.zip does not contain any .info.yml files. name of the theme changes only. Am i missing any thing? Any help would be greatly appreciated. I tried getting themes from this site http://www.weebpal.com/free-drupal-themes. I followed steps from this site http://www.inmotionhosting.com/support/edu/drupal-8/themes/upload-new went to Apperance

Theme installation in drupal 8 Fails

。_饼干妹妹 提交于 2020-01-06 18:08:43
问题 i am a newbie in drupal. I installed drupal then tried to change the theme i tried three themes. Everytime i get the same error zircon_profile-8.x-1.0-beta11.zip does not contain any .info.yml files. name of the theme changes only. Am i missing any thing? Any help would be greatly appreciated. I tried getting themes from this site http://www.weebpal.com/free-drupal-themes. I followed steps from this site http://www.inmotionhosting.com/support/edu/drupal-8/themes/upload-new went to Apperance

Is it possible to use Twig addClass with condition?

此生再无相见时 提交于 2020-01-06 08:06:10
问题 In Twig, it's easy to add dynamic classes to elements. But instead of duplicate rules settings , I wonder if I could use condition on element type to use the same "set" array like this: {% set champ5_classes = [ 'label-' ~ node.field_liens_vdl.fieldDefinition.name | replace({"_" : "-"}), ***if it's a UL, add this class :*** 'liste-' ~ node.field_liens_vdl.fieldDefinition.name | replace({"_" : "-"}), ]%} and then apply it as usual: <ul {{ champ5_attribute.addClass(champ5_classes) }}></ul>

Drupal - upgrade from 8.6.7 to 8.8.1

六月ゝ 毕业季﹏ 提交于 2020-01-05 01:40:08
问题 I have upgraded using below command https://www.cloudways.com/blog/update-drupal-8-core/ https://alvinalexander.com/drupal/how-update-drupal-7-website-with-drush drush pm-update After update it gives below error Fatal error: Class 'Aws\S3\StreamWrapper' not found in //web/modules/contrib/s3fs/src/StreamWrapper/S3fsStream.php on line 23 I also added latest AWS SDK composer require aws/aws-sdk-php Any idea how to fix this? [UPDATE] Before Upgrade 8.6.16: composer.json composer.lock config ->

How to integrate a react application in drupal 8, using drupal custom module?

穿精又带淫゛_ 提交于 2020-01-04 07:04:38
问题 I am very new to react and drupal 8. I know to create custom modules in drupal and react SPAs, but I m not able to call my react app using a drupal8 controller . Can someone please make me clear of the flow and the correct way to integrate react app in drupal 8? 回答1: So there isn't really a good means of calling a React application from within the regular Drupal controller layer or in the twig templates of Drupal 8. There are two ways people usually connect a React Application to D8. Option 1