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

Altering a node link title in Viewbuilder; #pre_render

My custom block gets multiple nodes and uses ViewBuilder to render these nodes. The node titles in this block are linked to the canonical route. That works for a default but my customer wants to link to an external link if that attribute has that value. So I'm incorporating TrustedCallbackInterface in my custom block to build a pre_render callback. But I'm getting an unexpected error:

Parameter 1 to Drupal\mymodule\Plugin\Block\MyBlock::changeUrl() expected to be a reference

Here's an excerpt of my custom block

access to field name in fields loop

first of all i tried to print field content as {{ kint(field) }} but it causes blank page, also {{ kint(field.content) }} renders markup output, i need to check the field name as below

{% for field in fields -%}

{% if field.name == 'field_image' %}

... do something

{% endif %}

{%- endfor %}

Login to drupal 8 from a php script

Hallo, scuse for my English. I need to’ login to mysite using a php script. I have trouble with the password. 
I need crypt the clear password in the encrypted to query the table users_field_data and i read that si possible through password-hash.sh but i can not understand how it’s done. Please help me ... thanks 
 

How can I have node pages with comment fields cached properly?

I was struggling with high page load time for my node pages when I realized that the problem was due to content pages not being cached (I am talking about the cache for the full page). The page is rebuilt after every single request. With some hit and trial, I realized that fields that have form elements, in my case, Fivestar widget and also the comment form at the bottom of the page (either of them) prevent page from getting cached. This adds 1-1.5 seconds in page load time for Mobile.

When I remove both those two fields, page starts to get cached.

You are not authorized to access this page. for Administrator?

Hi,

I have created custom display view & have role based access, I have assigned it to multiple roles. It's working fine on my staging ENV, recently I have moved my site to production ENV, there it's says You are not authorized to access this page. even if I am logged in with admin user.

However, if I assign role named Authenticated User, it starts working

Please see attached screenshots for further understanding:

https://prnt.sc/z6axpl

Error "Form has become outdated..."

Hi to all!

Version: Drupal 7

My problem is that for some users (not for all) when they submit a form the get the error:

'The form has become outdated. Press the back button, copy any unsaved work in the form, and then reload the page'

And the are not allowed to send the form.

The user is logged before he is sent to the form by this way:
    $user = user_load(4478);
    $form_state = array();
    $form_state['uid'] = $user->uid;
    user_login_submit(array(), $form_state);

Pages

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