Add a custom font with the "PDF using mPDF" module

6 days 16 hours ago

I made a custom module to create a PDF from a views page. This module depends on PDF using mPDF. I'm now trying to add a custom Google font. This should be the default font when generating a pdf. But I can't find out what I should do to have a custom font used in the PDF.

The mPDF documentation gives me an example of what I should do to load the custom font. I tried adding this in a custom function called right before generating the pdf but it doesn't work.

I both tried adding the font as default font to the setting (as shown in the example) or/and via css just using font-family: aller, none of it worked till now.

So my question is, am I using the code snippet in the right way? Or what can I do to get this to work?

namespace Drupal\views_pdf\Controller; use Drupal\Core\Controller\ControllerBase; use Drupal\pdf_using_mpdf\Conversion\ConvertToPdf; use Symfony\Component\DependencyInjection\ContainerInterface; class GenerateViewsPdf extends ControllerBase { /** * @var ConvertToPdf */ protected $convertToPdf; /** * Inject ConvertToPdf service * * GeneratePdf constructor. * @param ConvertToPdf $convert */ public function __construct(ConvertToPdf $convert) { $this->convertToPdf = $convert; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('pdf_using_mpdf.conversion') ); } public function generateviews($arg = NULL, $views_name = NULL, $display_id = NULL) { addFont(); $settings = $this->convertToPdf->getConfig(); $settings["pdf_font_size"] = '10mm'; $settings["default_font"] = 'aller'; $settings["orientation"] = 'landscape'; $settings["pdf_css_file"] = __DIR__ . "/../../css/style.css"; $rendered_view = \Drupal::service('renderer')->render(views_embed_view($views_name, $display_id, $arg)); $this->convertToPdf->convert($rendered_view, $settings); return true; } } function addFont(){ $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; $defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults(); $fontData = $defaultFontConfig['fontdata']; $mpdf = new \Mpdf\Mpdf( [ 'tempDir' => __DIR__ . '/../../upload', 'fontDir' => array_merge($fontDirs, [ __DIR__ . '/../../fonts' ]), 'fontdata' => $fontData + [ 'aller' => [ 'R' => 'aller_rg-webfont.ttf', 'I' => 'aller_it-webfont.ttf', ], ], 'default_font' => 'aller' ] ); }

I tried adding the font data directly to the mpdf code in the vendor folder and this works perfectly, so the font files work fine. The idea of adding the font data is fine. I don't know where to inject the code to make it work.

Joost

Passing variables from hook_mail to cutom twig template

6 days 17 hours ago

Custom twig template into hook_mail()

$body_content = array( '#theme' => 'mail_body_content', '#node' => $node, );

I would like to access to node Entity and display value into the twig

myfield_name: {{ node.get('field_myfield_name').value }}

Render code

$renderedContent = \Drupal::service('renderer')->renderPlain($body_content);

Only myfield_name: is display. How to get / pass the variable to twig ?

linyifan

JavaScript ES6 modules import from CDN library

6 days 18 hours ago

I have a custom JavaScript file in my theme which handles some logic for external iframe (not exactly iframe tag but a custom element) loading. Normally, I would declare the CDN or JS file in theme.libraries.yml or mymodule.libraries.yml, e.g.:

tableau-embedding-api: version: 1.0 js: https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.min.js: { type: external, attributes: { type: module } } # Adding type module since it is export module dependencies: - core/drupal - core/jquery - core/drupalSettings - core/once

But I am unable to find a way to access the exported modules in my custom js file where I use the above library as dependency:

tableau-embedding-api: version: 1.0 js: js/custom.js: {} dependencies: - core/drupal - core/jquery - core/drupalSettings - core/once - mytheme/tableau-embedding-api

And custom.js is:

(function ($, Drupal, drupalSettings) { Drupal.behaviors.my_custom = { attach: function (context, settings) { once('program_insights_page', '.main-section-program-insights').forEach(function(element) { // I want to access exported modules by the CDN here. // For instance, the above link exports TableauEventType module. }); } }; })(jQuery, Drupal, drupalSettings);

The only way I found is to include import {TableauEventType} from 'https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.min.js at the top of custom.js and then I can access TableauEventType in attach function which seems not so Drupal way and clean because I need might need to change the embed code and version in different environments.

Any help would be appreciated.

Thank you

Imran Aslam

Solr multi-select facets occurs bad request error

6 days 18 hours ago

I faced with a weird problem using apache solr faceting search. While selecting two facet constraints, solr respond with 400 error:

"400" Status: null: null HTTP ERROR 400

Problem accessing /solr/project/select. Reason:

null

Basically I have one index configured and number of fields indexed inside. I'm using facet for "content type" field. There is no problem at all when only one facet constraint is selected.

http://localhost:8983/solr/project/select?fl=item_id,score&fq={!tag=facet:type}ss_type:"system"&start=0&rows=10&sort=ds_created desc&facet=true&facet.sort=count&facet.limit=10&facet.mincount=1&facet.missing=false&facet.field={!ex=facet:type}ss_type&f.ss_type.facet.limit=50&wt=json&json.nl=map&q.alt=(ss_search_api_language:"sv") (index_id:"project_nodes_index") (hash:gf1tmd)

Problem starts where two constraints are selected:

http://localhost:8983/solr/project/select?fl=item_id,score&start=0&rows=10&sort=ds_created desc&facet=true&facet.sort=count&facet.limit=10&facet.mincount=1&facet.missing=false&facet.field={!ex=facet:type}ss_type&f.ss_type.facet.limit=50&wt=json&json.nl=map&q.alt=(ss_search_api_language:"sv") ((({!tag=facet:type}ss_type:"system") OR ({!tag=facet:type}ss_type:"product"))) (index_id:"project_nodes_index") (hash:gf1tmd)

Standart modules are used: * search_api_solr * search_api * facetapi

Solr version 3.6.2

Elijah

Remote login via REST fails [closed]

6 days 18 hours ago

I have a pair of sites where Site B authenticates users via REST to a Drupal 7 installation on Site A. It's been working well but suddenly I have one user who cannot authenticate. She can login just fine on the Drupal site itself, but not the remote site. I figured I would be able to solve it by debugging, stepping through the code on my macbook using the development copy of Site B, using a fresh copy of the database from the live Site B, but on my Macbook it actually works! Makes debugging really hard! LOL

In watchdog I see various entries, with the last one from REST being

a:1:{s:10:"@arguments";s:59:"Array ( [0] => AnnaWxxxxx [1] => Tempzzzzzzz ) ";}

which is correct, followed by

%type: !message in %function (line %line of %file).

a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:25:"Undefined variable: aName";s:9:"%function";s:34:"CRM_Contact_BAO_Query->restWhere()";s:5:"%file";s:106:"/home/domain/domains/money.domain.org/public_html/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php";s:5:"%line";i:2219;s:14:"severity_level";i:5;}

So, "Undefined variable: aName" I think is still related to the REST login query. But I have no idea what the actual problem is.

Drupal is using the Services extension, version 7.x-3.28 to handle the REST requests from Site B. The code for handling the login is this:

// try Drupal login $request_url = 'https://money.domain.org/rest/user/login'; // User data $user_data = array( 'username' => $username, 'password' => $unhashedPassword, ); $user_data = http_build_query($user_data); // cURL $curl = curl_init($request_url); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/json')); // Accept JSON response curl_setopt($curl, CURLOPT_POST, 1); // Do a regular HTTP POST curl_setopt($curl, CURLOPT_POSTFIELDS, $user_data); // Set POST data curl_setopt($curl, CURLOPT_HEADER, FALSE); // Ask to not return Header curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_FAILONERROR, TRUE); $response = curl_exec($curl); $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); // Check if login was successful if ($http_code == 200) { // Convert json response as array $logged_user = json_decode($response); // set return value return $logged_user; }

The request response is, simply, "false". Suggestions?

Rob Brandt

Custom module Pager does not work with Ajax filter

6 days 23 hours ago

My custom module uses an Ajax enabled drop down to allow users to filter images. There is also a pager attached to the query. The pager works fine when all the data is displayed i.e. no filter applied but after applying a filter, clicking a pager button just gives a white screen.

Here is my code.

function view_colouring_sheets($form, $form_state){ $query = db_select('field_data_field_image','fi')->extend('PagerDefault'); $query->join('node','n','n.nid = fi.entity_id'); $query->fields('fi'); $query->fields('n',array('title')); $query->limit(20); if($form_state['input']['tid']){ $query->condition('entity_id', colouring_sheets_filtered_tid($form_state['input']['tid']),'in'); } $images = $query->execute()->fetchAll(); $output = array( '#theme'=>'image_matrix', '#type'=>'markup', '#images'=>$images, '#title'=>'Colouring Sheets', '#pager'=>theme('pager'), '#filter_form'=> drupal_render(drupal_get_form('image_filter_form')), ); return $output; } function colouring_sheets_filtered_tid($tid){ $query = db_select('field_data_field_image_category','ic'); $query->condition('field_image_category_tid',$tid); $query->fields('ic'); $result = $query->execute()->fetchAll(); $term_array = array(); foreach($result as $row){ $term_array[] = $row->entity_id; } return $term_array; } function image_filter_form($form, $form_state){ $terms = taxonomy_get_tree(18); $terms_array = array(); foreach($terms as $term){ $terms_array[$term->tid] = $term->name; } $form['tid'] = array( '#type'=>'select', '#options'=>$terms_array, '#required'=>TRUE, '#title'=>'Fitler Images', '#ajax'=>array( 'method'=>'replace', 'wrapper'=>'image_matrix', 'callback'=>'view_colouring_sheets', 'progress' => array('type' => 'throbber', 'message' => 'Images Loading'), 'effect'=>'fade', ), ); return $form; }
PrestonDocks

PHP constructor property promotion: how to call the parent constructor?

6 days 23 hours ago

So I have a Controller that I am trying to rewrite to use PHP constructor property promotion:

class MyUserController extends UserController { /** * Constructs MyUserController. * * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * Parent dependency. * @param \Drupal\user\UserStorageInterface $user_storage * Parent dependency. * @param \Drupal\user\UserDataInterface $user_data * Parent dependency. * @param \Psr\Log\LoggerInterface $logger * Parent dependency. * @param \Drupal\Core\Flood\FloodInterface $flood * Parent dependency. * @param \Drupal\Component\Datetime\TimeInterface $time * The time service. */ public function __construct(DateFormatterInterface $date_formatter, UserStorageInterface $user_storage, UserDataInterface $user_data, LoggerInterface $logger, FloodInterface $flood, TimeInterface $time) { parent::__construct($date_formatter, $user_storage, $user_data, $logger, $flood); $this->time = $time; }

So I did this:

public function __construct( protected TimeInterface $time, ) {}

Wow, so much shorter!

I eliminated the parent variables like protected UserStorageInterface $userStorage because PHPStorm gives a warning:

Type must not be defined (as in base class '\Drupal\user\Controller\UserController')

But without the parent class variables, how do I call the parent constructor?

Patrick Kenny

Webform mail formatting broken after moving to symfony-mailer-lite from swiftmailer

1 week ago

In march 2024 we left swiftmailer and switched to symfony-mailer-lite.

Everything looked well until we found that the font for mails which had no template specified in our theme had a default font like times new roman instead of arial.

We then took the mail template from the old swiftmailer and put it in our theme thought this will fix it.

It did fix it for the font but not for the formatting. Before any Element title was bold and styled in the mails now only plain text.

So now I wonder if there is something else we missed.

Here are two mails, the first is from february and contains all the style info. The second is from now.

<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css"> table tr td { font-family: Arial; font-size: 12px; } </style> </head> <body> <div> <table width="800px" cellpadding="0" cellspacing="0"> <tr> <td> <div style="padding: 0px 0px 0px 0px;"> <p>Gesendet am: Fr., 26.04.2024 - 19:35</p> <p>Gesendet von: admin</p> <p>Gesendete Eingaben:</p> <b>Anrede</b><br>Familie<br><br><b>Vorname</b><br>Dixisset<br><br><b>Nachname</b><br>Loremipsum<br><br><b>Straße</b><br>Dixisset<br><br><b>Hausnummer</b><br>Oratione<br><br><b>PLZ</b><br>Loremipsum<br><br><b>Ort</b><br>Loremipsum<br><br><b>E-Mail</b><br><a href="mailto:test@test.com">test@test.com</a><br><br><b>Telefonnummer</b><br>Oratione<br><br><b>Betreff</b><br>Loremipsum<br><br><b>Ihr Anliegen</b><br>Quae cum dixisset, finem ille. Quamquam non negatis nos intellegere quid sit voluptas, sed quid ille dicat. Progredientibus autem aetatibus sensim tardeve potius quasi nosmet ipsos cognoscimus. Gloriosa ostentatio in constituendo summo bono. Qui-vere falsone, quaerere mittimus-dicitur oculis se privasse; Duarum enim vitarum nobis erunt instituta capienda. Comprehensum, quod cognitum non habet? Qui enim existimabit posse se miserum esse beatus non erit. Causa autem fuit huc veniendi ut quosdam hinc libros promerem. Nunc omni virtuti vitium contrario nomine opponitur.<br><br><b>Weitergabe von personenbezogenen Daten</b><br>Ich bin nicht damit einverstanden, dass meine in diesem Formular erhobenen personenbezogenen Daten zum Zweck der Beantwortung meiner Anfrage an andere Behörden der Landesverwaltung, Bundes- oder kommunale Behörden weitergeleitet werden. Wir weisen vorsorglich darauf hin, dass Ihre Anfrage u. U. nicht beantwortet werden kann, wenn Sie hiermit nicht einverstanden sind.<br><br> </div> </td> </tr> </table> </div> </body> </html>

The current one:

<!-- THEME DEBUG --><!-- THEME HOOK: 'symfony_mailer_lite_email' --><!-- FILE NAME SUGGESTIONS: * symfony-mailer-lite-email--webform--kontakt-e-mail.html.twig * symfony-mailer-lite-email--webform.html.twig x symfony-mailer-lite-email.html.twig --><!-- BEGIN OUTPUT from 'themes/custom/hw_radix_standard/templates/mail/symfony-mailer-lite-email.html.twig' --><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css"> table tr td { font-family: Arial; font-size: 12px; } </style> </head> <body> <div flags="63"> <table width="800px" cellpadding="0" cellspacing="0"> <tr> <td> <div style="padding: 0px 0px 0px 0px;"> <b>symfony-mailer-lite-email</b> <!-- THEME DEBUG --> <!-- THEME HOOK: 'webform_email_message_html' --> <!-- FILE NAME SUGGESTIONS: * webform-email-message-html--kontakt--email--e-mail.html.twig * webform-email-message-html--kontakt--email.html.twig * webform-email-message-html--kontakt.html.twig x webform-email-message-html.html.twig --> <!-- BEGIN OUTPUT from 'modules/contrib/webform/templates/webform-email-message-html.html.twig' --> <b>webform-email-message-html</b> <p>Gesendet am: Fr., 26.04.2024 - 13:44</p> <p>Gesendet von: admin</p> <p>Gesendete Eingaben:</p> <p> Anrede<br>Frau</p> <p> Vorname<br>Dixisset</p> <p> Nachname<br>Dixisset</p> <p> Straße<br>Oratione</p> <p> Hausnummer<br>Oratione</p> <p> PLZ<br>Oratione</p> <p> Ort<br>Loremipsum</p> <p> E-Mail<br><a href="mailto:test@test.com">test@test.com</a></p> <p> Telefonnummer<br>Oratione</p> <p> Betreff<br>Loremipsum</p> <p> Ihr Anliegen<br>Quae cum dixisset, finem ille. Quamquam non negatis nos intellegere quid sit voluptas, sed quid ille dicat. Progredientibus autem aetatibus sensim tardeve potius quasi nosmet ipsos cognoscimus. Gloriosa ostentatio in constituendo summo bono. Qui-vere falsone, quaerere mittimus-dicitur oculis se privasse; Duarum enim vitarum nobis erunt instituta capienda. Comprehensum, quod cognitum non habet? Qui enim existimabit posse se miserum esse beatus non erit. Causa autem fuit huc veniendi ut quosdam hinc libros promerem. Nunc omni virtuti vitium contrario nomine opponitur.</p> <p> Weitergabe von personenbezogenen Daten<br>Ich bin damit einverstanden, dass meine in diesem Formular erhobenen personenbezogenen Daten zum Zweck der Beantwortung meiner Anfrage an andere Behörden der Landesverwaltung, Bundes- oder kommunale Behörden weitergeleitet werden. </p> <!-- END OUTPUT from 'modules/contrib/webform/templates/webform-email-message-html.html.twig' --> </div> </td> </tr> </table> </div> </body> </html> <!-- END OUTPUT from 'themes/custom/hw_radix_standard/templates/mail/symfony-mailer-lite-email.html.twig' -->

We did not have any special template with all the styles for the mail body.
So I wonder where this information did come from before. Any changes in webform module, core or is symfony-mailer just dropping it?

Found this issue in symfony-mailer-lite https://git.drupalcode.org/project/symfony_mailer_lite/-/commit/623c53acc21bd1d82fad41bec7cfd8eacd1e7546 and changed the config to not use the default content in the message settings of symfony-mailer-lite - but no change to the behaviour. Somehow the HTML of message.body from webform gehts stripped.

macbert

Using Twig template to generate a PDF

1 week ago

I am trying to generate a Twig template for the Attachment PDF item in a webform. I am able to automatically generate a label and field data using : {{ webform_token('[webform:element:to]', webform) }} : {{ data.to }}

I am trying to figure out how I can get access to the rest of the webform settings such as the labels of the different fields: {{ webform_token('[webform_submission:created]', webform_submission) }}

What if I want to display the title of the form only using label:value? I know I can use : {{ webform_token('[webform_submission:label]', webform_submission) }} but this gives The form name with Submission No attached to the end. I need the form name only.

Is there a command or a setting I can use to get a list of all available settings and fields in the webform?

Sorry if this is not clear enough. Thanks

Stephane

Populating select list from a taxonomy term field

1 week ago

I'm trying to populate a select list dynamically by pulling its values from a taxonomy term field linked to the current-user account. Just to clarify, below function is a hook defined by a module that came with a custom installation profile. It is basically used to create fields on a specific form. So, my custom module has-

function some_function_attributes() { global $user; $user_fields = user_load($user->uid); $termid = $user_fields->field_user_organization['und']['0']['tid']; $taxonomy_term = taxonomy_term_load($termid); //dsm($taxonomy_term); $options = field_get_items('taxonomy_term', $taxonomy_term, 'field_org_environment','select'); dsm($options); return array( 'environment' => array( 'type' => 'select', 'options' => $options, 'name' => t('Environment'), ) ); }

Allowed values in the field (for this user)-

E1|Env1

E2|Env2

Here's the devel screenshot for dsm($options);

So, its populating the right field but not in the way it should.

Actual form element looks like this-

Currently, its just returning the array and I can't figure out what I missed. Been banging my head to the wall for this- How would I populate Env1 and Env2 in this select-list ?

dharma

How to setup access dependency on a block content created programatically

1 week ago

In Drupal 8, I am creating block instances (BlockContent) for node layouts programatically and setting them all as non-reusable. That causes a following access error: "Non-reusable blocks must set an access dependency".

How do I set access dependency on an existing block instance (or during it's creation)? Was never in a position to have to manipulate access from such angle and I can't find a good example for this.

belinea

Views contextual filters taxonomy name 2 fields using same vocabulary

1 week ago

I have a content where two fields using the same vocabulary. I want to show nodes related content filtered by the these fields.

I try with relation

Relationships

  • content:field_1

  • (term from field_field_1) Taxonomy term: Content using field1 (Relationship term from field_field_1 ; Require this relationship )

Contextual filters

(field_field_1) Content: field_2 Provide default value : Taxonomy term id from url Load default filter from node page Limit terms by vocabulary ( country) Specify validation criteria ( taxonomy term ) Vocabularies : Country Filter value type : Term name converted to Term ID Transform dashes in URL to spaces in term name filter values

This query returns nothing.

I don't want to use Views PHP code fields because of security concerns.

MariusM

Conditional Fields with multiple conditions

1 week ago

I am using Conditional Fields module. I need some guidance when setting dependencies for multiple fields (accepting unlimited values). Here is the situation:

In my entity form I have two fields:

  1. Assignment Status --> This is Select List type with two values DRAFT and FINAL

  2. Upload File --> This field is required field for accepting documents from student ONLY when Assignment status is FINAL else it is optional field.

Now my question is when I am using this case and creating Dependent and Dependee relation only for one assignment this work fine but when I give an option for accepting unlimited values the Conditional Fields doesn't work.

Because one student is required to submit more than one assignment I used Paragraph Module and also tested this case also with MultipleFields Module. I am not able to find any answer to my query. Please help me to find this answer.

user2129638

Execute Drupal Feeds Import Programatically - Where to put code

1 week ago

I found this code for executing feeds importers programatically:

<?php // Define the id (machine name) of the importer you want to use. $importer_id = 'my_feeds_importer'; // Load the Feeds Source object. $source = feeds_source($importer_id); // Override configurations... (more on that in a moment) // Execute the import. $source->startImport(); ?>

I'm just not sure where this code is supposed to go (I'm still pretty green when it comes to Drupal!).

CodeMonkey13

CKEditor adds inline nonsense

1 week ago

I'm hoping someone else has run into this and has a solution:

I have the CKEditor module (v. 7.x-1.13) installed using ckeditor.js version 4.01 (due to compatibility with Media module). The problem I run into is after I've added content into a field and publish it. After I return to edit the content, CKEditor has added all kinds of "stuff", a ton of inline CSS inside of a paragraph and span, and the letters "BESs" See sample below. Hoping someone can make some sense of this and offer a solution.

<p><span style="position:absolute;top:-999px;left:-999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;font-family:adelle,Georgia,'Century Schoolbook L',serif;font-style:normal;font-weight:900;">BESs</span><span style="position:absolute;top:-999px;left:-999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;font-family:ff-tisa-web-pro,arial,'URW Gothic L',sans-serif;font-style:italic;font-weight:700;">BESs</span><span style="position:absolute;top:-999px;left:-999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;font-family:proxima-nova,Georgia,'Century Schoolbook L',serif;font-style:italic;font-weight:800;">BESs</span></p>

Thanks in advance.

Brian P

How can I filter a result set based on a URL filter that affects an API call?

1 week ago

I have a View with a Rest Export display returning entities. I have a custom Normalizer class for it that crafts the object the way I want it in the response.

The node entity in the response has some custom data attached to it coming from an API (think operating hours). I am being asked that if someone clicks on 'Open Now' in the filtering form (not yet created), then anything not open should not be shown in the list.

Is there some way I can add a custom filter or hook into Views and look for this URL parameter and exclude a result from the list if it is not open? hook_views_pre_render and hook_views_post_render don't seem to fire, I assume this is because I am using Serializer format.

Kevin

Route Parameter Validation Problem

1 week ago

I have limited experience with D8 and custom routes.

Current mobile video system for client takes a scheme-less url for the video like so

https://example.com/mobile-video/some-video-desktop.azureedge.net

The routing has worked fine until we had a vendor change for video hosting and the new URLs include slashes and query strings which may or may not be the issue.

mobilevideo.routing.yml looks like

mobilevideo.content: path: '/mobile-video/{vguid}' defaults: _controller: 'Drupal\mobilevideo\Controller\MobileVideoController::content' _title: 'Mobile Video' requirements: _permission: 'access content' vguid: '^[-a-zA-Z0-9.\/?=]+'

Prior to today the validation was just '^[-a-zA-Z0-9.]+'

So testing the new URLs I am getting 404s. But if the parameter passed to the mobilevideo.routing.yml fails validation a 404 is the correct response so I assume the issue is validation. https://www.drupal.org/docs/8/api/routing-system/parameters-values-validation-in-routes

So I changed the validation from vguid: '^[-a-zA-Z0-9.]+' to vguid: '^[-a-zA-Z0-9.\/?=]+' that had no effect and I also tried '.+' and also the original without ? and = with no change.

I should note that the original URLs with no slashes worked continously through all of this and that each change was followed by clearing all caches.

Also tried removing validation entirely and that also failed so I am wondering if my path cannot include slashes in the parameter for reasons beyond validation?

What should my next step be in debugging this?

A full example URL will look like

https://example.com/mobile-video/someidhere.cloudfront.net/sessions/forty-characters-or-more-of-vguid-here.mp4?invocationId=thirty-more-chars-here

UPDATE Based on info re optional parameters and the comments on this post I added four more parameters and default values of '' for each updating mobilevideo.routing.yml to

mobilevideo.content: path: '/mobile-video/{vguid}/{vguidtwo}/{vguidhtree}/{vguidfour}/{vguidfive}' defaults: _controller: 'Drupal\mobilevideo\Controller\MobileVideoController::content' _title: 'Mobile Video' vguid: '' vguidtwo: '' vguidthree: '' vguidfour: '' vguidfive: '' requirements: _permission: 'access content' vguid: '^[-a-zA-Z0-9.]+' vguidtwo: '^[-a-zA-Z0-9.]+' vguidthree: '^[-a-zA-Z0-9.]+' vguidfour: '^[-a-zA-Z0-9.]+' vguidfive: '^[-a-zA-Z0-9.]+'

Then updated the controller to use public function content($vguid, $vguidtwo, $vguidthree, $vguidfour, $vguidfive) { and assemble the URL based on that array.

Attempting to flush the cache gets The website encountered an unexpected error. Please try again later.. What did I miss?

jerrygarciuh

Automated login with LDAP always returns error

1 week ago

I have successfully setup LDAP module to authenticate users (and create new users). This is done through manual login form. Now I'm trying to enable automated single sign-on, but with no luck.

I have enabled LDAP SSO, and selected Turn on automated single sign-on.

On IIS, I've enabled Windows Authentication (Anonymous is still enabled).

I do not get automatically logged in, it returns error msg "You were not authenticated by the server. You may log in with your credentials below".

What else needs to be configured in a Windows environment to enable SSO?

Does anyone have any insight on what the reference info is talking about, when the say "This requires that you have operational NTLM or Kerberos authentication turned on for at least the path /user/login/sso, or for the whole domain" ? Other than looking at Windows Authentication on IIS, enabled providers = NTLM, what else needs configuring?

Dubya

Unable to save content language configuration

1 week ago

My Drupal 8 website is multilingual and has many entity type bundles for nodes, taxonomy terms, paragraphs, media et cetera. This leads to a content language settings form (admin/config/regional/content-language) with more than thousand translatable-checkboxes.

Currently I'm not able to save this form. In the first place the form seemed to be successful submitted but changes have not been saved. This was caused by insufficient php setting value for max_input_vars, which could be solved by setting it to 6000. Now I'm struggling with a timeout. After submitting the form the request fails after some minutes.

Here are the php settings of my Drupal VM:

php_version: "5.6" php_memory_limit: "1024M" php_realpath_cache_size: "1024K" php_opcache_enabled_in_ini: true php_opcache_memory_consumption: "192" php_opcache_max_accelerated_files: 4096 php_max_input_vars: "6000" php_max_execution_time: "720" php_post_max_size: '64M'

How can I get around this issue? Which resource bottleneck could cause this?

Philipp Michael
Checked
19 hours 15 minutes ago
most recent 30 from drupal.stackexchange.com
Subscribe to Drupal StackExchange feed