texts: Create an Action on 'node_insert' or 'node_presave'

texts:
I created a new action on a new node being created, it shows up in my triggers and the action gets triggered. Works so far. Problem is trying to add additional functionality using some submitted field values. As of now, all its doing is logging in Watchdog. My goal is to be able to set a flag on the node based on certain values.

------------------------------------------------------------------

/**
 *  Implementation of hook_action_info().
 */

function my_custom_action_info() {
  return array(
    'my_custom_action' => array(
  'type' => 'node',
  'bundles' => array('article'),
  'label' => t('Check article for stuff'),
  'configurable' => FALSE,
  'triggers' => array('node_insert'),
    ),
  );
}

function my_custom_action($node) {
    $myvar = $node->nid;
    my_custom($myvar);
}

function my_custom($myvar) {
    watchdog('Test', 'My Custom Variable: ' . $myvar);
}

--------------------------------------------------------------------------

If I set the variable to an integer or text, it works.
But how to get any value from the submitted node?
Eventually I'd like to get a value from a specific field, but for now just testing with the Node ID and can't seem to get it.

The error I'm getting is :
"Notice: Trying to get property of non-object in my_custom_action() ... "

This part: $myvar = $node->nid;


texts: drupal 7, paths and urls are not working properly

texts:
I'm developing a website on my localhost. I have a problem with urls.

for a url like this

http://localhost:81/my_website/library

I should output image src this way :

<img src="<?php print $directory; ?>/image/header/headerR.png"/>

but when the above url is changed to this

http://localhost:81/my_website/library/

I should output image src this way :

<img src="../<?php print $directory; ?>/image/header/headerR.png"/>

I mean it should refer to the parent. my website has also contextual filter which must be inserted after library/ .is there any general solution for handling such thing?


texts: How to use the Rules module to lock English nodes from editing?

texts:
I need to lock all English nodes from editing because translators sometimes change English nodes by mistake instead of creating translations for them.

Can it be done with Rules?

I guess it might work with the Rules Condition that uses a data comparison node:language equals English.

What Rules Action can be used here?


texts:
I'm using entity registration module on a drupal 7 for events. I managed to enable the registration but I can't find out how to style the registration form.

I tried to modify the form via css but I would prefer have a better control over it, in a template page for example.
I'm quite new to drupal so any help would be much appreciated.


texts: Can't send managed file as mail attachment

texts:
I'm working on a form submit in a Drupal 7 project, the form has and upload file field, in my form submit handler I can get the file id, what I want to do is to send and mail which has as attachment the uploaded file.

my form submit function:

function my_form_submit($form, &$form_state) {
  $fid = $form_state['values']['document'];
  $file = file_load($fid);
  $params = array(
    'attachment' => $file,
  );
  global $language;
    drupal_mail('my_module', 'key_1', 'my_own_mail@gmail.com', $language, $params);

}

hook_mail implementation:

function my_module_mail($key, &$message, $params){
  switch ($key) {
    case 'key_1':
      $message['subject'] = t('my mail subject');
      $message['body'][] = t('Hello this is a test content');
      $message['params']['attachments'][] = $params['attachment'];
  }
}

When submitting the form the mail has not been sent and this error is shown:

Error : Cannot use object of type stdClass as array in my_module_mail()

Anybody has an idea why it doesn't accept object and or how to deal with this in this case.
Thanks.


texts:
I am using Ubercart 7.x-3.2 on Drupal 7.

I am trying to sell files on my new website using this ecommerce system.

How can my users download files from an external website when they have paid for it?

I am trying to re-direct them to the website that actually provides the files

Thanks


texts:
I have a view displaying webform fields (results).

In some questions, the user answered for example 15€, but I added the sufix "€" to the webform so the user won't have to write it. So the answer is just "15".

I want to add the same sufix "€" to the view field so it appears "15€". How can I do this?


texts: Field rendered invisible when code block enabled

texts:
I have this weird issue when altering a webform. Below are two versions of my code:

function tubitekuz_form_webform_client_form_97_alter(&$form, &$form_state, $form_id) {
  $form['submitted']['kullanici_adi'] = array(
    '#type' => 'textfield',
    '#ajax' => array(
      'event' => 'blur',
      'callback' => '_tubitekuz_do_stuff',
    ),
  );
}

The above code renders my field invisible, while

function tubitekuz_form_webform_client_form_97_alter(&$form, &$form_state, $form_id) {
 $form['submitted']['kullanici_adi']['#ajax'] = array(
    'event' => 'blur',
    'callback' => '_tubitekuz_do_stuff',
  );
}

gives me .

What might I be doing wrong?


texts: "[warning] Invalid argument supplied for foreach() Migration.php:641"

texts:
Why does this error appear when I use the drush ms command?

[warning] Invalid argument supplied for foreach() Migration.php:641


texts: How to print an image field on all the basic pages only?

texts:
In my custom type "Page" I've added an image field (field_page_cover_image) and applied image style to it.

<?php
  $field = field_get_items('node', $node, 'field_page_cover_image');
  if($field){
     $theme_img = file_create_url($node->field_page_cover_image[$node->language][0]['uri']); //origional image path
     if(isset($theme_img)) {
        // print styled image
        print theme('image_style', array('path' => $node->field_page_cover_image[$node->language][0]['uri'], 'style_name' => 'page_theme'));
    }
  }
?>

I have a requirement show this image (if uploaded) in all basic pages only (in a separate div container). For this I added the above code in `page.tpl.php

This code is working fine in all the pages but when I load search or other pages, I am getting error, as they don't have this field ($field).


texts: What is the name of the module that gives a detailed report of modules and themes installed?

texts:
There is a module that gives a very detailed view of all the modules and themes installed on a site and the core modules as well. I can't remember the name, but I know it exists because I installed it for testing purposes some time ago.

Can anyone remember the name, or tell me about some other modules which do the same thing so I can check if it is the one?


texts:
I want convert font size in existing theme from px to percentage. The theme and the CSS. Should I change font-size in body and headers only, or better to change font size in all places in CSS? What is the correct way to specify font-size in percent in this particular CSS?

body {
  font-family: 'Open Sans', sans-serif;
  line-height: 160%;
  color: #666;
  font-size:13px;
  background: #fff;
}

h1 {font-size: 18px;}
h2 {font-size: 16px;}
h3 {font-size: 14px;}
h4 {font-size: 13px;}
h5 {font-size: 13px;}
h6 {font-size: 13px;}


texts: Where do I add HTML content into a block?

texts:
I have created a custom block, but there is no option to add content or any body part.

How do I add content to a block?


texts:
I have created content type with field as List(text).
If I select any of above option and try to save it, it through "fieldName: illegal value" error.But if I modified option in below format and then try to save it. It get saved successfully.

-option1

-option2

-option3

-option4

Does list doesnot support first format? Is there any other way to resolve this without changing its format ?


texts: Filter to only nodes with an image in an imagefield in Views 3

texts: In my view, I want to include/exclude nodes that do not have an image in a specific field with exposed filter. The field allows an unlimited number of images. I don't care about the exact quantity, just that there are more than 0. How do I create this filter?


texts: How to render a template declared in hook_theme directly in a twig template without preprocess?

texts:
Lets say I have a hook_theme like this :

/**
 * Implements hook_theme().
 */
function mytheme_theme($existing, $type, $theme, $path) {
  return [
    'partial' => [
      'variables' => ['current_url' => NULL],
      'template' => 'partial'
    ]
  ];
}

Then in a node.html.twig, I want to call the template.

Currently I'm doing this :

{% include '@mytheme/partials/partial.html.twig' {'current_url': url('<current>')} %}

But the problem with this is that I never go into my

function mytheme_preprocess_partial(&$variables) {}

Also I can't benefit from the TWIG DEBUG mode.

Is there any way to do something like this :

{{ theme('partial', {'current_url': url('<current>')}) }}

Thanks for helping.


texts:
I have constructed a content type, 3 fields are timestamps.

I wish to reuse this content type (form input etc) to a client facing application, with the caveat being the form is modified. For example my module should be able to tweak the form (ie: Hiding the timestamps fields and updating them accordingly).

I don't want to rebuild the whole form and muck with the CCK API to get data to persist, so I am wondering if it is possible to simply re-call that form and it's functionality and tweak it ever so slightly???

I found this googleing:

//Showing a node edit page with drupal_get_form() and hook_menu()

And implemented some of it:

function _tasks_create() {
  module_load_include('inc', 'node', 'node.task');

  $nid = '1';
  $node = node_load($nid);

  return drupal_get_form('task_node_form', $node);
}

function tasks_menu() {
  $items = array();

  $items['tasks/create'] = array (
    'type' => MENU_CALLBACK,
    'title' => t('Create New Task'),

    'page callback' => '_tasks_create',
    // Where is $node coming from???
    'page arguments' => array('task_node_form', $node),

    'access arguments' => array('create tasks')
  );

  return $items;
}

But I see two immediate issues:

$node in hook_menu is undefined -- where do I get it from??
I have no idea what the $nid (Node ID) will ever be for my content type

I need to essentially re-display the form that I use in the admin, hiding everything but maybe three fields (that means no URI, menu options, etc).

I will probably need to hook into the submission of the form in this context only and update the timestamps accordingly.

What am I missing or doing wrong? Any ideas?

Alex


texts: How to notify site admin when user registers with a specific field checked

texts:
My case site has student and teacher accounts (teacher/student radio buttons). When user registers as a teacher, admin has to be notified so that admin performs further checks to accept the account.

How can I do this programmatically


texts:
I am trying to get into module building with Drupal 7.

Why is  $tryk = "test" not being taken for the title, but literal strings such as "testmenu" are working?

$tryk = "test";
function menufun_menu() {
    global $tryk;
    $items['menufun'] = array(
        'title' => $tryk,
        'page callback' => 'menufun_greeting',
        'file' => 'menufun_greeting.inc',
        'page arguments' => array('Jane', 'Doe'),
        'access callback' => TRUE,
        'type' => MENU_NORMAL_ITEM,
);
return $items;
}


texts: How to bypass required fields in form validation function of a module?

texts:
I have a form with two radios and two forms related to each of them. These forms have some required fields. user can just check one radio and then fill in one form. but then clicks on submit button drupal gives error for those unselected and empty field ( which are required but now they are not required because their radio isn't selected) .

How can I bypass those required inputs in my module ? I am developing my module's form with Form API.


texts:
Referring to https://www.drupal.org/project/health_check

I am confused as to what 'If Drupal fails to bootstrap' means.

What is term 'bootstrap' referring to? Does it make a database call? From what I have read bootstrap can mean from the Drupal core.

So if the healthcheck module fails is it because it cannot see the database, will the module render a 200 or some other response code?


texts: How can I hide search results until the user submits the exposed form?

texts:
I have a fairly straightforward view, which exposes a simple keyword filter to the user.

Currently, when I first land on the page containing this view, all records are displayed (i.e., the search results are unfiltered).

How can I alter this behavior, so that no search results are displayed until the user has entered a keyword and submitted the form?

(I'm converting an old Drupal 7 site to Drupal 8. On the D7 site, the view does not show search results when I first land on the page. Is this a difference in behavior between the Views implementation in D7 and D8? I can't find anything in the D7 site to suggest that this difference in behavior is caused by a module.)


texts:
I'm working on a site that has (and must have) three image fields for out three breakpoints. We could call them field_img_mobile, field_img_tablet and field_img_desktop

Is there a way (a module?) that could load the image field corresponding to the breakpoint?


texts:
I have setup a website for three choirs in different age groups:

Adults (18y and up)
Adolescents (12-18y)
Children (8-12y)

Some members are related (parent-child-sibling), others are not.

I've created three user roles, one for each choir. And by using User Role Fields, and Field Permission modules I've managed to add fields to the user profile, depending on the roles the user belongs to, to put member related data for that specific user role (birthday, voice, etc...). But there are two problems with this approach:

What if a parent has two children beloning to the same age group? For now, I can only add 1 childs details.
If a child has his/her own account, can I share the user role fields, and make them visible/editable by both child and parent?
And while I'm at it:

Can I make some fields editable by both parent and child, and some only by the parent? e.g: the field "has to be picked up after rehearsal" would be only editable by parents, not by children themselves...

I know it's complicated, I've allready spent a lot of time searching modules. But maybe my experience with Drupal is just too limited to see the possibilities/strengths/weaknesses of these modules, since it's my first Drupal site...

Writing this up, I came up with a different approach: can I create a profile for each user : parent/children. And then setup some relationship to make the childs profile editable by the parent? But, what about the fields that would be only editable by the parent?


texts: Organic groups + Views: members of certain group can see all group content

texts: I have to view to show each user a group content for groups the user is member of. I would like to set that members of one group can see all content (even if not directly specified for them). Is that possible?


texts:
Some how it seems like the core image module is missing from the module list.

Here is the screenshot of the module list:

Also I tried fetching the list using drush.

$ drush pml | grep image
 Image                                Image Attach (image_attach)                                                          Module  Not installed  7.x-1.x-dev
 Image                                Image Gallery (image_gallery)                                                        Module  Not installed  7.x-1.x-dev
 Image                                Image Import (image_import)                                                          Module  Not installed  7.x-1.x-dev
 Image                                Image legacy (image_legacy)                                                          Module  Not installed  7.x-1.x-dev
 Image                                ImageMagick Advanced Options (image_im_advanced)                                     Module  Not installed  7.x-1.x-dev
 ImageAPI                             ImageAPI (imageapi)                                                                  Module  Enabled        7.x-1.x-dev
 ImageAPI                             ImageAPI GD2 (imageapi_gd)                                                           Module  Enabled        7.x-1.x-dev
 ImageAPI                             ImageAPI ImageMagick (imageapi_imagemagick)                                          Module  Enabled        7.x-1.x-dev
 Other                                Image crop (imagefield_crop)                                                         Module  Not installed  7.x-1.1
 Spam control                         Image CAPTCHA (image_captcha)                                                        Module  Enabled        7.x-1.0-beta2

But the list shows up on the database system table. All the images on my site are not showing up because of this.

I fixed this issue by manual enabling the module from the database and also had to set bootstrap = 1 for it work properly, without it won't work.

so for image row I have to make this changes on system table.

status = 1 and bootstrap = 1

This is bit weird but some how the image module gets disable after some time ( days ). Not sure what is causing it. Every time I have this issue, I have to go to database and make the same changes as above. Can some one guide me what might be causing this issue or how do I debug this.

Note: this is multi site installation.

  Update: Rregistry rebuild using drush rr also fixes the issue, but
  doesn't seem to be permanent.


texts:
I am using the media-gallery module to create dynamic galleries for a site.
I have a problem when I edit a node; I get the following error:

  Notice: Undefined index: media_gallery_format in locale_field_node_form_submit() (linea 405)

I have read Undefined indexes in locale_field_node_form_submit(), but I didn't resolve the problem. The issue report suggests that the error depends from a local language, and that I should change one line in media-gallery.module, but I don't understand where that line is, and how to change the code.

Can anybody help me?


texts: How can I view a list of pages to link to in the Navigation module?

texts:
I am learning Drupal, and currently creating my first navigation menu. When I click 'Add Link' I can see this view:

This allows me to type a value into the path field to link to, however what I am looking for is a list of current Pages or Content nodes within the site to link to. Surely you cannot be expected to remember the list of current paths that exist within the entire site everytime you want to add something to your navigation menu.

As an example of what I mean, if you create a link in the Wordpress backend, you are shown a dialog which shows a list of current site content to link to as below:

How can I view a list of pages/content to link to in the Navigation module?


texts:
What I want, is that the CKEditor will use the website css, as you can see here:

it is not the same as:

I am using less css. I have tried to define the main less css file which imports all the other less css files together. This didn't work. Also the automatically generated css file by drupal doesn't has a solid path to put into the CKEditor CSS settings underneath the CSS file path settings.

Is there a way to make my editor use the same style as I use for the website?


texts:
I have managed to create a product type and import my product data, so I now have a list of products.

How do now go about getting the products to display? Do I have to build a content type from scratch and add the fields manually, or is there a way to generate the content type?


texts: How to theme a custom object from an external datasource?

texts:
I am building a Drupal 7 website that has several Content Types (CTs) like Page, Event, Blog etc. For each CT, the full node view mode has been heavily customized using Display Suite.

I am requested to display data (let's say articles) from an external datasource (remote json API) within my website. Each remote article should be displayed in a single page within my website (like full node view modes), should look like (similar if not the same HMTL markup) as in my normal Drupal nodes and should not be persisted.

In a custom module, I have implemented hook_menu and defined a custom page callback, and within my callback, I perform the remote API request for a remote article (let's assume that remote article identifiers are available to me) and parse the json into a php object.

function my_custom_module_menu() {
  $items = array();
  $items['foo/bar/article/%'] = array(
    'title' => 'Remote article page',
    'page callback' => '_remote_article_display',
    'page arguments' => array(3),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

function _remote_article_display($article_id) {
  // unrelated remote request and json parsing code
  $article = get_remote_article_by_id($article_id);
  $output = ''; // how to theme $article object?
  return $output;
}

How should I print the proper HTML markup for my $article object without hardcoding it? The fact that my normal nodes are using Display Suite is an additional overhead as at this point I am not even sure how to print the default Drupal html for fields.


texts: How do I assign a new role to all the existing accounts on the site?

texts:
I have more than 300 users in my site. I want to assigned them a new role I just created.

How do I achieve this?


texts: How to limit entity_load with entity translation module to return active language from url

texts: Drupal 7 entity_load somehow returns all available translations when used with entity translation module. If we have 5 fields and 10 languages, there will be a total of 50 translations in result set. Is it supposed to work that way or is it too much overhead for the system?


texts: Workflow, Workflows, Workspace, and State Machine-- what is the difference?

texts:
Drupal 8 core has an experimental module called Workflows.

There is also a contrib moduled called Workflow.

There's also the Workspace module, which is associated with the Deploy module.

Commerce 2 uses State Machine, another module that provides workflow management in Drupal 8.

What are the differences between these four modules?

Is one more future-proof than the others?  Normally, I would assume the module in core has the brightest future, but in this case Commerce picked a different module (perhaps because the core module wasn't ready?).  And in D7, Workflow has a large following.


texts: Fast method to locate occurrences of SQL queries via code?

texts:
I'm reviewing some SQL queries made throughout a few modules, but to do that, I've been reading every line of code manually, which is time consuming.

Is there a term or phrase I could CTRL+F for to find out where the queries are occurring directly? Any packages I should be on the look for?


texts: How can I disable theme update notifications?

texts:
How can I disable Drupal update notifications for certain themes?

I am using the Drupal Bootstrap 7.x-3.0 Theme which is not the latest version. That is why Drupal sends out a email Update notifications and shows a update warning. I don’t want to miss any module updates, thus I would  like to keep update notification enabled. However I don’t want receive theme update message all time.I didn’t know that this is such difficult approach.

I was looking for a easy solution e.g. theme .info settings or on/off option in Drupals settings.php.


texts: Commerce Kickstart: facets are disabled when using back button

texts:
Commerce Kickstart facets get temporarily disabled (showing reduced opacity) after selecting one of them until the new search downloads. This is a cool feature. However, if the user clicks the browser's back button after that, then the previous page is displayed without reloading and the facets are still disabled, therefore making a new search impossible unless the user manually reloads the page.

In order to reproduce this problem, just visit KickStart Demo (http://demo.commerceguys.com/products), select a facet term, wait until the search is loaded and then go back.

What's the easiest way to solve this? I've been thinking of forcing a page reload in search pages or to use jQuery to make sure that all facets are enabled. Neither of them sound very natural.

Thanks for you answers!
David


texts:
I am using the field_group module and want to programmatically create groups of fields in the hook_install of my module.install file.

It seems that field_group doesn't have much of an api that can be used by other modules. Does anyone know of a way that I can create a field group and assign field types to it programmatically?


texts: Multilingual settings form using i18n variable

texts:
I'm using a settings form for my module and I'm trying to make some of the fields multilingual.

I've declared the multilingual variables with hook_variable_variable_info (and with hook_variable_group_info for my custom group):

function MYMODULE_variable_info() {
  $variable['my_variable_name'] = array(
    'type' => 'string',
    'title' => t('My title'),
    'default' => MY_DEFAULT_VALUE,
    'description' => t('My description.'),
    'localize' => TRUE,
    'group' => 'my_group'
  );

  return $variable;
}

I've added my settings form (one field for example)

function MYMODULE_settings_form() {
  $form = array();

  $form['my_variable_name'] = array(
    '#type' => 'textfield',
    '#title' => t('My title'),
    '#title_display' => 'before',
    '#default_value' => variable_get_value('my_variable_name'),
  );

  return system_settings_form($form);
}

And as you can see I've used system_settings_form($form) to save my form fields as variables.
I've checked my new variable at 'admin/config/regional/i18n/variable' and the form shows that it's a multilingual form and multilingual field, but when I'm switching to another language the value isn't saved. (Only the English version saves and changes the value for all languages)

Thanks.


texts:
Have a look at this screenshot:

After creating a crowdfunding reward, it appears on the event page as for example "Pledge $10 for Test Run".

When I checked the source code, I found that this line should be linked with a link <a href="/drupal/crowdfunding/pledge/2/5"> which redirects to the pledge so that the user can make the payment.

But this link is not clickable from the page. I need to go to "inspect element" in google chrome and then click on the link.

My question is, why can't I click on the link? Why doesn't it appear on the page?


texts: Custom search box to be included in a view

texts:
I am using the search box provided from the Custom Search module. It works great. I want to know if there is any way by which i can include the search box in a view which i have created. Regards

PS: I tried this but no effect:

<?php
  $block = module_invoke('custom_search', 'block_view', 'custom_search');
  print render($block);
?>

It displays nothing

Based on below comments i tried doing this:

<?php
$block = module_invoke('custom_search', 'block', 'view', 0);
print $block['content'];
  ?>


texts: With current D8 status, what's the decision tree for creating a new content entity type versus creating a Content Type for the "Node" content entity?

texts:
We have seen four years and Drupal 8's first release since the accepted answer was written for the question "When is it appropriate to create an Entity versus just adding a new content type?"  And, entities are more central to Drupal 8 than they were in Drupal 7.(RefB, RefC, RefD)

In this new Drupal 8 world, what is the decision tree for creating a new content entity type versus a new Content Type for the content entity of type "Node"?

As you consider a response, please consider the following:

Is a new Content Type for the content entity type of "Node" still appropriate in 99% situations versus a new content entity type?
Does the decision tree now include more, better, or clearer reasons to veer away from using the "Node" content entity type and instead create a new content entity type?  And if yes, what are they?  Do they include:

Performance?
Security/permissions?
The number of modules that work with Node-entity-type Content-Types and do not work with other content entity types?

Perhaps -- based on the previous accepted answer that is referenced above -- the only general reason to do a custom content entity type is if you want to group Node data, e.g. with taxonomy terms, or otherwise annotate Node, e.g. with comments?

Module compatibility seems like a particularly interesting consideration for a decision tree.  At present, few of the most-installed modules have a release for 8.x that is not merely alpha, beta, or rc (a release candidate).  And it seems difficult to identify how many of them will work out-of-the-box with a new custom entity type versus a new Node-entity content type.  There does not appear to be a project attribute to distinguish between those that are "written for entities" versus "written for node entity content types".

Take a look at pathauto, which is currently the fourth-most installed module of those that have any kind of 8.x release.  Folks are working hard on a 8.x version that generally supports entities and not just Node-entity-type Content Types.  But what about all the other modules?  And will modules that support entities going to generally require custom content entity types to have module-specific "hooks" before the module will work with them?  (Versus how the modules may just work straight out of the box with new Content Types?)  That appears to be the kind of challenge the pathauto team is working with, and perhaps it is a reason to veer away from a custom content entity type?

It might also be worth mentioning that Drupal 8 core contains a UI for creating new Content Types for the content entity of type "Node", but it does not currently contain a UI for creating new content entity types. (RefX, RefY, RefZ)


texts: How to display 1 full article and the a summary of others

texts:
Hi I'm new to Drupal and I'm trying to find a way to display on my home page the full version of the latest article and a list of other articles as teasers.
The teasers could be either listed under the full article or in a block in the sidebar. Is this possible? Currently I can only list articles as teasers.


texts: Drush update for the first time hosed my website

texts:
Running latest versions of Drupal, etc.
Localhost - dev site
Maintenance mode

While trying to install Commerce_kickstart and running Drush for first time to update modules,  Drupal got completely hosed.

Can not find problem in database
Repaired all databases but get Drupal white screen, no error messages
Phpmyadmin won't work

Can anyone offer a series of steps to attempt recovery or at least find out what went wrong?

Thanks in advance.  I need ASAP.


texts: Attach view of content by author only to the user page

texts:
I am using the EVA: Entity Views Attachment module to create a view of content by author, to attach it to each author's user page.  So, for example, when viewing /user/1, I will see a list of all the content created by user #1.
I've been able to do this successfully, but too successfully: Not only does this list show up on the author's user page, but it also shows up on every single piece of content that user has written.
Obviously, I don't want it to show up there.
How can I fix this, so that it only shows up on the user page?
These are my settings.

Entiti content settings

Entity type: User
Bundles: User
Arguments: id

Contextual filters
Content: Author UID

When the filter value is not available

Provide a default value: Type: User ID from route context

I'm working with Drupal 9, if that makes any difference.


texts: Modelling one-to-many relationships with content types

texts:
So I'm trying to build a web app, and I've got it set up so far to have two content types, "Client" and "Client Contact".

Now the schema I've put together makes a one-to-many relationship between client and client contact, i.e clients can have one or more client contacts, and each client contact can be associated with only one client.

I'm trying to model this relationship through Drupal 7's content types, but I can't seem to find a way to do it. I thought it could be done through the 'existing fields' section of the 'manage fields' tab on the 'content types' page, but it doesn't seem to work.

Is there any way this can be done or do I need to download a separate module to get it to work?


texts:
I used drupal 6.25 and views and translation modules .

I do not know why not I am not getting my translation path but another page translated.

I noticed I created 2 views but I cannot get the translated path view in page

http://demo.dolphin-sch.ir/nagara/fa/world
Home » World » علمی
translated path view in page
http://demo.dolphin-sch.ir/nagara/fa/entertainment
خانه » پژوهشی » پژوهشی


texts: Block visibility based on the content type

texts:
I have created a block for showing author details for every individual author; the article's authors can be identified by the 'Author' field.
Now I want to match the author block with the particular author's content.

For example, I have an author called 'vividvilla', and I have created a block for 'vividvilla'. How do I show this block for articles where 'vividvilla' is the author?

I know it can be done with PHP code in blocks, but I am not sure about the code.


texts: How can I translate the label of a vocabulary?

texts:
I load the vocabulary with taxonomy_vocabulary_load($vocabulary_id).

How can I can translate its label in the language currently used?


texts:
do you think, it is possible to display in views the languages the node was translated to?
I mean something like this:

First article
english|german

Second article
english|german|dutch


texts: How to make custom fieldset collapsed by default in Drupal 8

texts:
In Drupal 7 there was option to have fieldset collapsible or not, and to restrict default state of this form element (collapsed, or uncollapsed). Example:

$form['contact_data'] = array(
        '#title' => t("Contact data"),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
);

Now, in Drupal 8 I cannot find attributtes #collapsible and #collapsed in Drupal\Core\Render\Element\Fieldset. In official documentation of Fieldset element is not mentioned any new element, which should substitute the Fieldset element.

Also there is not Form API elements overview for Drupal 8, such as for Drupal 7. You have to manually search for all Render Elements definition in code, which is more time consuming (especially when you would like to see elements overview and compare them).


texts: Unlimited Custom Form Fields - Without Ajax

texts:
I have a simple form where users can set the number of fields they need. Users may need 100+ fields so I am not using ajax "add more" options.

With the below code, everything works (Even though you have to save the form twice, once to add the fields, twice to save the data), but I get an Undefined offset notice Notice: Undefined offset: n anytime I increase the field count and save the form.

As I'm not sure a better way to ask this question...

1) I know the code below is not perfect UX (having to save a form twice), does Drupal offer any API advantages to my approach I am not aware of?

2) Is there a way to handle/suppress these notices?

public function buildForm(array $form, FormStateInterface $form_state) {

  $config = $this->config('MYMODULE.settings');

  $form['#tree'] = TRUE;

  $form['fieldset'] = [
    '#type' => 'fieldset',
  ];

  $form['fieldset']['field_number'] = [
    '#type' => 'textfield',
    '#default_value' => $config->get('field_number') ?: 1,
  ];

  for ($i = 0; $i < $config->get('field_number'); $i++) {

    $form['fieldset']['field'][$i] = [
      '#type' => 'textfield',
      '#default_value' => $config->get('field')[$i] ?: '',
    ];

  }

  return parent::buildForm($form, $form_state);
}

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state->getValues();

  $this->configFactory->getEditable('MYMODULE.settings')
    ->set('field_number', $values['fieldset']['field_number'])
    ->set('field', $values['fieldset']['field'])
    ->save();

  parent::submitForm($form, $form_state);

}


texts: Displaying custom module content in a popup from other page

texts:
I have a custom module which displays listings and info about realties. How can I display realty's images in a popup from other page?
In example I have info about realty on realty/566 and it's images can be viewed realtyimages/566


texts: Views: Page by view-group where multiple results are loaded under each group from a relationship

texts:
I have a view displaying data as follows:

Course name 1

Course instance a
Course instance b

Course name 2

Course instance a
Course instance b
Course instance c
Course instance d

Course name 3

Course instance a
Course instance b
Course instance c
Course instance d

The view is grouped by Course name, and there's a relationship with the course instance table to bring in the course's course instance.

The pager is set to 10, but the list displays 10 course instances. How can I get it to display 10 Course names, with all of their instances underneath.


texts: How to make changes in HTML code and make them show up on site

texts:
I am working on a Drupal 7 site that is being manged via Github.

I am trying to change the HTML code on one page. The HTML that I am changing is in the [appname]/sites/all/themes/[app] folder. The HTML in this file is identical to what is on the page if I were to go to the [siteurl]/user/login then navigate to the page and press edit. However when I change the HTML on my local branch and push it up to github and then deploy it using heroku it doesn't actually change the page.

My question is how can I change to way this page is displayed in code instead of changing the page on the drupal website itself.


texts: How can I add a field to a view description

texts:
I'm running into a quite simple problem : I would add fields to a view description, in order to list my views by this field.

Example : add a taxonomy field to the views, let's say "View color". Then, I would create a view of views, only for the views having a color, ordered by their colors and letting me see a XML containing the color and a link to the view's page :

<...>
    <view>
        <color>red</color>
        <link>http://example.com/path-to-red-view</link>
        <color>blue</color>
        <link>http://example.com/path-to-blue-view</link>
    <....>
</...>

I don't want to generate the links by rewriting (I know how to do that), but really add a field to the views.

The question is a bit wobbly, but I don't figure out how to write it. I found nothing on the web describing what I want to do, maybe due to that.

Thereby, all help is welcome !

Thanks


texts: Create an "About the Author" box for multilingual sites

texts:
I'm having a hard time figuring out how to display a simple box containing some info about the author of a node. I have tried drupal's built-in user profile manager and profile2 module but none of these work on multilingual sites as they should...

Profile2 come with a "Profile2 translation" but it seems that it can be used only for fields labels and not for fields content.

Anyone knows a workaround on how to do it?

P.S.: I use the i18n module.

Thank you!


texts: hook_form_search_block_form_alter is not working with bootstrap theme?

texts:
I am facing an issue where hook_form_FORM_ID_alter() code is working in bartik theme while same is not working in Bootstrap theme. Any idea what could be the reason or am I missing something? Very Thanks.

In THEMENAME.theme of bootstrap theme

<?php
/**
 * @file
 * Bootstrap sub-theme.
 *
 * Place your custom PHP code in this file.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Template\Attribute;

function subtheme_form_search_block_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['keys']['#attributes']['placeholder'] = t('Sentence for placeholder!!!.');
}

OtherWay,

function subtheme_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if($form_id == 'search_block_form'){
      $form['keys']['#attributes']['placeholder'] = t('Sentence for placeholder!!!.');
    }
}

In bartik.theme

<?php

/**
 * @file
 * Functions to support theming in the Bartik theme.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Template\Attribute;

function bartik_form_search_block_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['keys']['#attributes']['placeholder'] = t('Sentence for placeholder!!!.');
}


texts: Views Custom Join change the 'on' condition

texts:
We are using Drupal commerce and have a report in views using commerce_line_item as the base. We need to be able to split the quantities up into multiple rows. So if a line item has a qty of 5 there should be 5 rows. I am trying to implement this:

https://stackoverflow.com/questions/22291814/mysql-return-result-by-quantity-per-row

I am adding a join in hook_views_query_alter but there does not appear to be a way of changing the join condition from = to <=.

LEFT JOIN {line_items_tally} line_items_tally ON commerce_line_item.quantity = line_items_tally.n

needs to be

LEFT JOIN {line_items_tally} line_items_tally ON commerce_line_item.quantity <= line_items_tally.n

Is there any way of doing that?


texts: Change workflow default state with hook_form_alter()

texts:
How can I programmatically access and alter the Workflow module settings with hook_form_alter() on a node edit form?

I can see the Workflow] module settings in its own field-set on the node edit form, but I cannot find any mention of it when I look at the output of dd($form), dd($form_state), or dpm($form).

I would have expected to find it somewhere similar to the following.

$form['edit_workflow']['value'];


texts: How to suppress print in only in front page via twig

texts:
{{ node.field_test1.entity.label }} prints the label of a taxonomy field in a node.html.twig.
Is there a possiblity to suppress that outside the frontpage via node.html.twig? Or enable that only for front_page?
That means: in a view, that is searching for this term exactly, I have the same information double on screen in the view result.

"is_front"condition is not defined in node.html.twig.
'EDIT:
What I meant is that:

{% if not page %}

        {{ node.field_kategorie.entity.label }}: {{ label }}

    {% endif %}

This'll be printed all over.
How to do: print this (in the URL above) only for front page, for example not not in a view (that just searched for this entity)?


texts: Edit node link in view redirects to false URL

texts:
I have a view with a list of nodes and their associated edit links. The nodes can be categorised/filtered so I use an argument* in the view that I set manually on the content template of the pages to display the view (different pages should show different sets) -- there is no correlation between this argument and the path to the pages containing the view. This works fine except that every edit link in the view redirects to a path that is a combination of the page's internal path and some string identifier that depends on the page being shown but isn't the page's title. On node/6 the link looks like edit?destination=nodeIdentifierF6. I've confirmed the number at the end corresponds to the node's ID and it is always preceeded by a capital F. My guess is that Identifier is really meant to be % and that Views substitutes some argument I'm not sure where comes from.

Is there a way to fix this, or a different approach altogether (e.g. using filters in a way that allows me to control the node sets dynamically), short of creating a whole template for this minor annoyance?

*Actually there are two arguments plus the three from the Views Or module, but I'm assuming it doesn't consume arguments, and the other argument has a default value and shouldn't be used. Using filters would be more appropriate, as users shouldn't have control over what set of nodes to display anyway, but I couldn't find a way to adjust filters dynamically, and the alternative seems to be to create n idental views but for this filter. I am mentioning this in case it's important.

22/9 Update:
This appears to be related to drupal_get_destination(), which returns an encoded path (/ => %2F). For the view in question the %2 part must then be interpreted as an argument placeholder and substituted. I am no closer to a solution to the problem, unfortunately.


texts: How to show/hide the prefix/suffix for fields?

texts: Sometimes in theming I want to programmatically hide the prefix or suffix of numeric fields. How can I do so?


texts: How can I change the Apache Solr search URL?

texts: How can I change the default Apache Solr URL path from "search/apachesolr_search/term" to something else?


texts: Use Twig to render HTML email body for SwiftMailer

texts:
I have a custom module with a controller where I'm building a PDF file with a node's data that will be mailed to a certain user.

I have installed the SwiftMailer module and I have been able to produce my desired outcome, but it isn't very clean.

I was wondering if I could use a twig template to build the body of my HTML email. Is there anyway I can make use of Drupal's Twig Extension for this purpose?

I already created a email.html.twig file with the layout I need and I already have a $parameters array with all the variables I need to use in the template, but as SwiftMailer uses an HTML string in the setBody() method, I'm trying to use Twig to produce the HTML I need to use there. Any thoughts?

Please note that I don't want to use the twig template in my module ( to show a Drupal page or something), but rather have Twig render an HTML string I can use with SwiftMailer.
Also, the instructions for the SwiftMailer module regarding theming are rather confusing for me and they are for Drupal 7, so I don't see how I can make use of them in my case.

Any help would be very welcome!


texts:
My human.tpl.php file is located in /tpl folder. Im trying to use hook_theme from the module:

    function human_theme($existing, $type, $theme, $path){
    return array(
        $item['human'] = array(
            'template' => 'human',
            'path' => drupal_get_path('module', 'human').'/tpl',
            'type' => 'theme',
            'variables' => array(),
        ),
    );
    return $item;
}

Why is this not working? I have some basic html code in my template file for testing purposes so it should show me something, but I get nothing back. If more information is needed, please let me know and I will add. Full code of a .module file can be found here.


texts:
on my front page the user registers by typing in his username, email, password..once he clicks submit he log ins and is redirected to his profile edit page (not account settings)..i am able to do that using rules..i am using Profile2 and adding new fields..however i also want the old fields such as username, password,and email id to appear there ...
it would be the same password or username and email id that the user entered while registering but i just want to create/display these fields on this edit profile page for completeness.they may have the earlier entered values copied and the user may enter/edit it here again and be able to save (ofcourse he should get an error if he enters a new email id on that page)

what i want is something like this: http://imgur.com/fa31Xt1


texts: How do I create a custom Drupal 7 login?

texts:
On my site there are 3 types of users:

Public users who do not need to log in
Public users who need to log in in order to access documents (pdfs, excel, etc)
Users who maintain the web site (add, edit, delete content, etc)

I need to have a login form on my web site for the public users to log in to access what are otherwise "hidden" documents. These users will be public users so they will not have the ability to access anything related to the Drupal administration, such as adding content. I don't see how I can use Drupal's built-in Users system by adding a new role and modifying its permissions, especially since permissions are inherited from the authenticated user role.

What's the best way to go about this?


texts:
I passed the $uid as a hook_menu()-wildcard to a form and loaded the user of that uid with $account = user_load($uid). Admin then is able to fill some textfields and save. I want some other non editable fields from $account simply to be displayed as markup or anything like that in the form. Tried to pass these fields to #markup like so:
'#markup' => $account->field.

But this doesn't work. Should this normally work? What am I doing wrong?

Or would it be better to display an aditional block which fetches the $uid from the URL and prints me my fields?


texts: Submenu item linked to anchor in parent's content

texts:
I would like to have a multi-level menu where some of the menus are links not to a content node, but just for inline anchors specified in the parent node's content source.

Is there an already existing solution for this feature? If not, what method should I choose for not to spend too much time on this issue?


texts: Drupal 7: How can I display nodes of specific author in a taxonomy term?

texts:
I've a question about taxonomy terms.
In my organization I've actors that work for me and, for each actor I created a taxonomy term containing some information, such as bio, an image etc.
Each actor can create content of type "post". I want display all contents of a specific actor in his own term.
So, if in actors vocabulary there are "alan", "jack" and "Lucy", whan an user reaches alan term, he can see all posts created by Alan, and so on.
For security I don't want the actors select terms when create posts.
I hope you can understand my question.


texts: Drupal 7: Protect entire site in a maintaince mode-esque fashion

texts:
Looking for a way to lock down the site like maintenance mode, but without having to use maintenance mode.

I don't want to use maintenance mode because I want to have that feature available for it's proper use.

However, I would like to able to have the site viewable as normal for logged in users, and anonymous users just get a screen telling them to login or register. Probably with a login/register box as well.  So hopefully something with a template.

Any modules out there or maybe a simple custom module?


texts: With Commerce Product taxonomy term view, is there a way to have page title set to the translated term title?

texts:
The only way to have the taxonomy term name in the title of a taxonomy term Commerce Products view page I've found so far is the example view in the estore theme (I still don't get how tid which should stand for Term ID becomes the title field value):

The problem is that the title shown is not translated on multilingual sites when the term definitely has a proper translation. Is there any way to show that title translated?
For some reason there are no Product: Has taxonomy term ID as there is Content: Has taxonomy term ID in the default taxonomy term view that is displaying the title translated.
AFAIU {{ arguments.tid|t }} is not the way because it will go through a different subsystem.


texts:
I have a Drupal View that displays the 2 most recent articles from our db. How do i allow a user to select which article they would like to display. And, if the user does not choose the 2 articles then the 2 most recent will be shown.

I tried to use filters and the "Expose this filter to visitors, to allow them to change it" option. But I cant seem to figure out how this would be done.

Thanks.


texts: Comment replies to be another comment type

texts:
I need the comment replies to be another comment type. So, the normal comments should be of type "Standard". The answers to these standard comments should be of the type "Special", with more fields.

How do I achieve this?


texts: How to hide webform block after submission for anonymous users?

texts:
I can not hide webform block by Per user submission limit.

I choose Per user submission limit = 1- > ever, but block is shown.

How can I hide the block, if it was submitted?


texts:
I've got a basic field constraint figured out (per question here: Validation constraints on form fields ignored )

Next, I want to constrain the main image field to limit the file name. For example, if someone uploads a file named "1234-shutterstock.jpg" I want to detect that the file name contains "shutterstock" and add that violation.

But I have no clue how to tackle the syntax for this. Maybe someone can point me in the right direction?

I've started with something like this. I know this is wrong.

            <?php
            namespace Drupal\custom_validation\Plugin\Validation\Constraint;

            use Symfony\Component\Validator\Constraint;
            use Symfony\Component\Validator\ConstraintValidator;

            /**
             * Validates the Image constraint.
             */
            class MainImageConstraintValidator extends ConstraintValidator {

              /**
               * {@inheritdoc}
               */
              public function validate($items, Constraint $constraint) {
                foreach ($items as $item) {
                  if (strpos($item->value, 'shutterstock') !== false) {
                    $this->context->addViolation($constraint->wrongImageName, ['%value' => $item->value]);
                  }

                }
              }

            }


texts: Drupal: on node save, redirect user to homepage?

texts: How can I redirect the user to the home page (or another drupal page) on node save instead of them seeing the saved content?


texts: What are the different ways I can export permissions from a preconfigured Drupal site

texts: I have a site that I need to export permissions from and import into version-controlled code. We aren't using feature, strongarm etc, so although I know a  lot of people will say these are the go to  solutions, I need to look at alternatives. Are permissions stored as variables in the site or otherwise? I would I export and import variables into an install profile or in a module?


texts: How do I translate the Webform module form?

texts:
I really see no way of translating the Webform module. Is anyone else facing this issue?

I know it is possible with locale (for the same node), or creating another node, but I really want to use the first option.


texts: Sending an email blast only goes to certain users

texts:
A little background on the problem:  I have been tasked with figuring out a problem in a Drupal site that I have no experience with.  I have done Web Development using PHP, etc. but never used Drupal.  I have a parent site with 3 sites underneath, and roles for each user (can be members of all sites or just one).  I have a rule that sends an email out to these users after certain content is submitted.  However, not all of the users receive the emails (about 150-180 users per email blast).

Does anyone have suggestions as to how I can go about debugging and figuring out this problem?  I have to fix this by tomorrow.  Here is what I have done so far:

-Made sure users were assigned to the role in the email rule.
-Unchecked the box "send only to active users"

Any help is appreciated!


texts: Using Simple jQuery click() events in Drupal 7

texts:
I've been able to get jQuery to load and work for some basic things such as:

(function ($) {
  console.log('jquery called');

  $(document).click(function() {
    var h1 = $('h1').text();
    console.log(h1);
  });
}(jQuery));

However, when I try to do the following, nothing happens.

(function ($) {
  $("h1").click(function() {
    alert('clicked!');
  });
}(jQuery));

I'm wondering if this has something to do with when the .js file gets called. I suspect that the document element already exists, so having a click event on it is no problem. However, I think that the h1 elements don't exist by the time the click event is loaded. I've tried the .bind() and .on() functions as well, with no luck.

Any ideas?

I call my .js file from my theme's info file, not sure if that matters.


texts: To suppress this error, add the option --strict=0 Drush

texts:
My custom Drush commands use options(--ver,--env,etc). Whenever the option is used, I get message:

Unknown option: --ver.  See `drush help build-asset` for available options. To suppress this error, add the option --strict=0.

By adding --strict=0, it will suppress the message, however. how to make the custom Drush commands run with --strict=0 automatically or what needs to be done to avoid this all together. Thank you for helping


texts:
I'm trying to write a simple twig extension to render a menu inside twig template files.

I created a custom module for this purpose. It's folder structure looks like this:

-modules
--MenuRender
---src
----MenuRenderExtension.php
--menurender.info.yml
--menurender.services.yml

The *.info file is a standard file, the *.services files looks like this:

services:
  menurender.twig_extension:
    class: Drupal\MenuRender\MenuRenderExtension
    tags:
      - { name: twig.extension }

And the MenuRenderExtension class is as follows:

namespace Drupal\MenuRender;

class MenuRenderExtension extends \Twig_Extension {

  public function getName() {
    return 'MODULE.twig_extension';
  }

  /**
   * @return array
   */
  public function getFunctions() {
    return [
      new \Twig_SimpleFunction('renderMenu', [$this, 'renderMenu'])
    ];
  }

  /**
   * Provides function to programmatically rendering a menu
   *
   * @param String $menu_name
   *   The machine configuration id of the menu to render
   */
  public function renderMenu($menu_name) {
    // 50+ lines so i cut this part as it's mostly clean PHP
  }

}

I am constantly getting this error msg in apache's error log

Service 'menurender.twig_extension' for consumer 'twig' does not implement Twig_ExtensionInterface

Any one have a clue ?
p.s. new to drupal8


texts: Is there an OOP alternative to hook_entity_operations_alter() in Drupal 8

texts:
In my custom module, I want to add a new action to the operations menu for each row of the user list that is displayed when going to /admin/people. I would like to stay in OOP-land and therefore I'm wondering if there is an alternative to implementing hook_entity_operations_alter() in my module? E.g. something that would allow me to create a PHP class for adding my action, or alternatively some way to add the action through the admin interface.

currently I have this code in somemodule.module:

/**
 * Implements hook_entity_operation_alter()
 */
function somemodule_entity_operation_alter(array &$operations, EntityInterface $entity) {
  if($entity instanceof UserInterface){
    $operations['translate']['title'] = t('Hello @entity_type', array(
      '@entity_type' => $entity->getEntityTypeId(),
    ));
    $operations['translate']['weight'] = 99;
  }
}

This works, but as said I would like an alternative that would skip the .module file completely.


texts: excluding non english field values from search_api index (or facet)

texts:
I have a CT product and a CT factory. Products have an entity reference field pointing to factories. I use node translation on factories (en, fr, de) but products are not translated (en only).

Creating facet on the product's factory (entity reference field) and indexing works well but the problem is that the facet displays all translated versions of factories. e.g:

china factory in english (14)
china factory in french (14)
china factory in german (14)
taiwan factory in english (6)
taiwan factory in french (6)
taiwan factory in german (6)
EU factory in english (2)
EU factory in french (2)
EU factory in german (2)

Since the search page regards products which are only in english, I'd like to be able to remove the fr and de values from that facet, or even better, not allow them to be indexed at all.

I've tried the facetapi_bonus module but its options for values exlusions doesn't suit me because I don't know the titles of the factories or their node ids beforehand.


texts: How to add javascript library that does not need a module, but is required by modules?

texts:
I have a JavaScript library written for my project. It is just that - helper library without configuration. I don't like the idea of empty .module file loading each time. On the other hand, I need it to be versioned and I need to be able to require it in other modules, with version specification. Libraries API looks like a bit of overkill as my script is from the ground written for Drupal and is no way "external" - and using empty .module file would be easier and faster anyway.

So, what's the best practice to include JS-only code?

How to include a JavaScript library, with CSS, in Drupal 7 without using a module? is about JavaScript needed by theme, so it looks similar but is unrelated to my question.


texts:
I want to use ajax to load some html from a php file. I don't want to write a module. So, here's the thing I did:

In sites/all/themes/mytheme/js/myjs.js:

$('#color_main_id a').click(function() {
  $.ajax({
    url: "get_node_details.php",
    type: 'GET',
    cache: false,
    // data: nid <--- Question#1
    data:  "color=" + this.rel,
    success: function(data, status, jqXhr) {
      $('.product-summary').html(data);
    }
  });
});

In sites/all/themes/mytheme/js/get_node_details.php I wrote some code to get a node detail with entity_load and field_view_field.

Here's the questions:

How can I pass the current node id from my js function in js file to php function in php file? (See the comment above)
In get_node_details.php I've got Call to undefined function entity_load(). How can I solved this?

Thanks


texts:
I'm trying to generate a custom token to a prepopulated URL.  My code looks like this:

        $replacements[$original] = url('user/login', array(
          'query' => array('edit[name]', $account->mail),
          'absolute' => TRUE,
        );

The resulting URL looks like this:

http://example.com/en/user/login&edit[name]=myemail@example.com

But the & should be a ? because it's the start of a query string.  What am I doing wrong?


texts: How to get all node ids from same content type

texts: I am using Drupal 8 and I want to create related content, but the problem is that I can't figure it out, how I can get all node IDs(except current one) for a specific content type.


texts: How to replace drush_download_file in Drush 9

texts:
drush_download_file() existed in includes/drush.inc for Drush 8 and below, but this has been removed in Drush 9 as far as I can tell.

Is there a standard way that file downloads should be executed in custom commands written for Drush 9?


texts:
I would like to change the layout of articles on my homepage.
But I cannot find the template hereof.
I've got my page.html.twig, which but that only includes a placeholder "{{ page.content }}" in which all the articles are loaded.
And then I've got node--article--full.html.twig, but the layout there only seems to affect the article pages.
So where can I find the template to adapt the articles and their layout as shown on the homepage?
Do I have to create something like page--node--article.html.twig to overwrite the design of something?


texts:
I have set up access to some custom data by creating ContentEntity classes in my module, so I can query and display that data through Drupal entities. However, that data is also updated by a non-Drupal service, that changes some columns in the database directly. After the data is changed by that service I have to use "Clear all caches"  in order to see any changes in Drupal.

How can I stop Drupal 8 from caching an entity type at all - so it always queries the fields fresh from the database?

I have tried annotating my Entity class with

render_cache = FALSE,
field_cache = FALSE

as these are the cache related options listed in the documentation (Structure of an Entity annotation) and suggested in How to avoid caching of fields in Entity View?
However, this didn't have any noticeable effect in my scenario.


texts: Programatically altering a field formatter in Views

texts: I'd like to create a new (date) field formatter in Views, but also keep the existing formatters intact. As of now, I've managed to use hook_field_views_data_alter() to entirely replace the exiting handler with mine. However I would prefer to have my custom formatter available in the dropdown below. Is it possible to append an option to this dropdown for my custom formatter?


texts: Need Module for Images/Video in Node, works with Views

texts:
I'm using d7.2. I have been searching and working on this all day- can't figure it out. So I'm posting here for some help...

I have a Node that I want the users to be able to upload images and/or video to. They can upload either or BOTH if needs be. They can upload a single image, multiple images, single or multiple videos (3rd party hosted- you tube, vimeo, etc), or a combination of images and video.

I'd like for it to be displayed in a nice looking format- kind of like gallery formatter does (can't seem to get that to work for me)  with a larger image on top/middle, and thumbnails of the others on the side or bottom.  When the user clicks on the larger image, it'll open in lightbox.

I need it to work with views, as I'll be attaching a voting module to it, as well as others that will implement with Views.

I am really stuck and frustrated on this one. There doesn't seem to be any solid modules that can handle this- unless I'm just not seeing it.

I sincerely appreciate any/all help!


texts: French language not showing url alias path

texts:
I have installed multilingual module and added french country for this.

Added one content with English & french.

English & French text showing fine for this content (using block region

But after mouse hove to english & french, in english url alias path showing, but in french url alias not showing.

How to rid this in D7?


texts: How to relate nodes by field, not title?

texts:
I'm using Feeds to import content from XML. The content is films and their showtimes, like this:

<film id=av1>
  <title>Avatar</title>
  <showtimes total="2">
    <showtime show_id="1" id="av1" date="1/1/2012" price="10" />
    <showtime show_id="2" id="av1" date="2/1/2012" price="15" />
  <showtimes>
<film>

Right now, I've created two content types (Film and Showtime) and using Node Reference (References module) to relate Showtime to Film. Then I have various views that use the relationship to show listings, date listings etc.

This works ok, but Node Reference can only link on node title, so if someone updates the film title in the source feed we get problems. It would be better to link using the ID field, which never changes.

The problem is that I'm using Feeds to import to two content types, so running two Feeds importers, and they have to use title from the source to sync. So say the Film title is changed in Drupal, then more Showtimes get added to the XML. On import, the new Showtime nodes are created but can't find their Film node. Using the ID field from the source would keep things joined up. Maybe using Field Collection instead of referenced content types is better?

Possible solutions:

Use a taxonomy vocabulary and create a new term 'id' for each film. Then tag showtimes with the same term. I'm not sure this is a good use of taxonomy, creating single-connections in this way?
See if Relation module provides linking by field. Probably won't work with Feeds yet.
Create a single content type for films, and use Field Collection to store the showtimes. Then everything is connected in a single node. Not sure how feasible this is.

Any guidance or suggestions welcomed!


texts:
I am trying to programmatically update a node with a value from another entity. When I call node_save, the function just "stops". There is nothing in watchdog or in my php_logs that would indicate that any issue was encountered.

$node = node_load($base_node->nid, FALSE, TRUE);

$node->field_product[LANGUAGE_NONE][] = array('product_id' => $entity->product_id->value());

dpm('This text prints.');

node_save($node);

dpm('This text does not print.'); //This line is never executed.

I have tried a variety of methods for saving the node including using entitymetadatawrappers on $node. So far, nothing I have tried has gotten me anywhere.

Thanks!

Edit:

A few more details on what I have tried/am trying to do.

This field is a product reference field that I am adding a reference to.

There is nothing at all in the php logs or the watchdog logs.

I am trying to do this as a part of custom rules action. I was originally using the add item to list action, but only one item was being added to the list (usually there will be 4-5). As a test, I tried to update and save the node manually (thus the code above).

I should have specified that part, but got a bit wrapped up in my own solution. Either way, it seems pretty odd to me.

Edit Part 2:

I have confirmed that the structure for field_product is correct. I am also doing checks to make sure that I am not referencing a non-existent field, etc.

I wasn't originally using dpms for debugging, it just seemed like the simplest way to communicate my issue. Originally I was doing some further processing on my data that was not being done. Since that further logic isn't pertinent to the problem, I added a dpm as an example. There were no errors in the following logic and it wasn't dependent on the node save.


texts: Ajust the position of autocomplete fields

texts:
I working with the theme base bootstrap and my problem is that in autocomplete fields it's a bit offside of position, see the screenshot.

How fix this ? I need this more to the left and below the textfield.

Greetings.


texts:
I get this error when I drush up panels:

Code updates will be made to the following projects: Panels [panels-7.x-3.4]

Note: A backup of your project will be stored to backups directory if it is not managed by a supported version control s
ystem.
Note: If you have made any modifications to any file that belongs to one of these projects, you will have to migrate tho
se modifications after updating.
Do you really want to continue with the update process? (y/n): y
Project panels was updated successfully. Installed version is now 7.x-3.4.
Backups were saved into the directory /home/bzisad0/drush-backups/newco/20141017210224/modules/panels.       [ok]
WD php: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'newco.cache_panels' doesn't [error]
exist: TRUNCATE {cache_panels} ; Array
(
)
 in cache_clear_all() (line 165 of
/var/www/vhosts/www.newco.com/releases/20131007153705/includes/cache.inc).
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table &#039;newco.cache_panels&#039; doesn&#039;t exis
t: TRUNCATE {cache_panels} ; Array
(
)
 in cache_clear_all() (line 165 of /var/www/vhosts/www.newco.com/releases/20131007153705/includes/cache.inc).
Drush command terminated abnormally due to an unrecoverable error.                                           [error]
Backups were restored successfully.                                                                          [ok]


texts: Adding a jQuery interaction with Views Accordion

texts:
I have a Views Accordion displaying some books under their categories.
I want to add some jQuery interaction, so when the user clicks the triangle of each category, the content will be loaded via jQuery AJAX.
How can I include this functionality? Something like this, though I cannot see any ID identifier associated with the href which opens / closes each of the accordion bellows.

 function mymodule_views_pre_render(&$view) {
     if($view->name == "categorias"){
         drupal_add_js('jQuery(function() {
             jQuery("#categorias-page-0").click(function(e) {
              // ... AJAX stuff
              });
         });', 'inline');
     } // if
 } // function

Show image below, what I have, and when clicking on each category I would like to perform whatever jQuery actions I'd like.


texts:
I want to hide a node from our site for users with a specific role. I.e I have a section of my site that should only be accessed by logged in users, and I want to hide the node and the link to it in the main menu for anonymous users.

This seems like a very easy task but I'm having a hard time finding an easy way of doing this. I'm using Drupal 7.

-I've tried to do it with Rules but have not succeeded, (main problem has to do with not getting any relevant selections to choose from in the data selection.)

-I'v tried to create a new context in Context and everything looks good, but it has not the desired effect.

Is there a module for this?
Something like the equivalent of node access since it is not developed anymore.


texts: how to retrieve the index size of a field array

texts:
What I am working with it this. I have a custom content type with an image field (field_img) that accepts multiple images so they are stored in an array. what I need to figure out how to do is one of two things and I need to do them from the node--custom.tpl.php if possible.

1: get the size of the $node->field_img array so I can then loop through and assign appropriate HTML id's for each image in the content type.

OR

2: directly loop through the field_img array using maybe foreach() to set the id of each image in the content type to an appropriately unique value.

what I am able to do here works for one value because I can put in the actual index of the instance I am working with but the arrays are not all the same length some have 10 images some have only 6 so I need something that will loop through the array.

Here is the static code that works for one element

<?php $i = 0 ?>

<img class="album-image<?php print $i ?>" src="<?php print render (file_create_url($node->field_img['und'][$i]['uri'])); ?>">

this is inside node--gallery.tpl.php and it works fine but it only displays 1 image and I need 14 or how ever many there are for the instance of the content type.


texts: Drupal 6 site running slow on my localhost

texts: Hi I am working with a drupal 6 site and have a setup for this on my localhost the site is very huge and consists of almost 290 tables but the site is working super slow on my localhost specially the admin pages. It took almost 1hr to create a simple content type and 20-25 min to load module page, 30 min to enable/disable a module if not using drush about 10 mins using drush. This is becoming really time consuming for me to work like this. I have also configured the site performance but still no change. Rest of drupal 6/7 sites on my localhost are running fine.


texts:
I need some expert help. I need to export data into JSON. Here are the steps I followed:

1> Created a draggable view to allow admin to provide appropriate sort order.
ref (https://3cwebservices.com/drupal/creating-drag-drop-sorting-interface-drupal-view)

2> Adding a page on the same view, with format as 'JSON data document'

I can see the output in JSON format but the SORT order provided by admin is missing.

Any help is appreciated.


texts:
When is it necessary to use check_url()? For instance, if I create a login link by putting the code below in the body of a block, which of the 3 check_url() calls are necesssary and which ones are not?

<?php print 'Login';
?>


texts:
The default form layout has each form element wrapped in individual div tags, with a label, and input inside. I would like to lay things out neatly, and create a column for the field labels, and another column for the input areas.

I can see this being accomplished in one of two ways:
- I could create a table, using table elements or divs, and separate the labels from the inputs. Would I use Twig for this?
- Alternatively, maybe there's a creative way to use CSS with the default structure to make everything look good. If there is, I can't figure it out.

How should I implement one of these, or another way to accomplish the same thing?


texts:
Here is my code

function addToCart($product_id, $quantite){
    global $user;
    $product = commerce_product_load($product_id);
  $line_item = commerce_product_line_item_new($product, $quantite);
  $line_item->data['context']['product_ids'] = array($product_id);
  $line_item->commerce_unit_price->amount  = '900';
  commerce_cart_product_add($user->uid, $line_item);
}

The above code add the product to the cart with the correct quantity but the price isn't changed ...
Any idea ?

Update (resolved thanks to scott's answer)

//Panier
function addToCartCallback()
{
    addToCart($_POST['product_id'], $_POST['quantite']);
}

function addToCart($product_id, $quantite){
  global $user;
  $product = commerce_product_load($product_id);
  $line_item = commerce_product_line_item_new($product, $quantite);
  $line_item->data['context']['product_ids'] = array($product_id);
  commerce_cart_product_add($user->uid, $line_item);
  $order = commerce_cart_order_load($user->uid);
  commerce_cart_order_refresh($order);
}

function groupes_views_commerce_cart_line_item_refresh($line_item, $order_wrapper) {
  global $user;
  $idProduit = $line_item->commerce_product['und'][0]['product_id'];
  $prix = getPrixClient(getIdClient($user->uid), $idProduit) * 100;
  $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount'] = $prix;
  $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']['price']['amount'] = $prix;
}


texts:
I created a custom field but I don't know how to set a value.
I can read values with

$entity->get('field_myfield')->getValue()[0]['data']

The field consists of several elements: value, data, api_key

I'm loading the entity and would like to set the values of the field programatically, I tried:

$entity->set('field_myfield', ['data' => 'some data'], 'value' => 'some value');

This doesn't work.


texts: Path (URL) to call custom module function

texts:
I am developing a custom module and I need an URL that would trigger an action when called.

The purpose is for an external server to call this address passing some variables through $_REQUEST['message'], and then return a STRING with the success/error string. So the URL in question is only supposed to be called by a machine.

I now have a PHP file in the root that does the job, but I'd like to integrate it to the Drupal way through this custom module.... Is there a way to do this?

Thank you


texts: Hiding submenu items of a page in Drupal 6

texts:
Is there a way, in Drupal 6, to automatically hide all submenu pages? For example, suppose I have the following menu structure:

Sport

football
cricket

Is there a way I can enforce "football" and "cricket" to never be seen?


texts:
Have the following code

    $links = array_merge($links, array(
      l(t('Administration pages'), 'admin'),
      l(t('Front page'), '<front>'),
     ));
    }

    $output = theme('item_list', array('items' => $links, 'title' => t('Next steps')));

It does <ul> html list. My goal is to override, for example, "admin" path on given page from my custom module. Since it's themed output, I can use hook_theme_registry_alter() to override the theme function. But seems I can't do that dynamically (because of cache).

Is it wise solution to copy whole theme_item_list function, rename it to my_theme_item_list and write there my own path logic?

Another solution?


texts: Drupal 8, how fix the error 'class not found' for custom class ?

texts:
Its a php issue but maybe I missing a 'Drupal 8' thing ?

I have this custom module :

> mymodule (directory)
    > mymodule.module
    > src (directory)
        > myclass.php
        > myclassinterface.php

In myclass.php, I have :

namespace Drupal\mymodule\src;

Class myclass implements myclassinterface{
    ...
}

In my mymodule.module, I have :

use Drupal\mymodule\src\myclass;
...
function mymodule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
    $test = new myclass();
    // or $test = new Drupal\mymodule\src\myclass(); // same error, class not found
}

And when I load a page via my browser, I get a blank page and apache log tell me the class 'Drupal\mymodule\src\myclass' not found.

I don't understand..where is my mistake ?


texts: Is it possible to add permissions to a Ctools content type plugin?

texts: Is it possible to add permissions to a Ctools content type plugin, similar to a node entity?  I want to be able to check if a user has permission to add a certain content pane to a panels page through the IPE.


texts:
I want to add the below code to a node in full html text format in drupal7 website. The idea is to select one of the link in select list after selection relevant link is opened.

<form name="jump1">
<select name="myjumpbox"`
OnChange="location.href=jump1.myjumpbox.options[selectedIndex].value">
<option selected>select a link...
<option value="http://rediff.com">link1
<option value="http://google.com">link2
<option value="http://yahoo.com">link3
</select>
</form>

but once an option is selected it is not doing anything. It is not implementing 3rd line of this code.


texts:
Export Users with custom fields?
I found this Q&A,a resolved Q.but I want to import the users in another sites ?


texts:
When I refresh the node add/edit form page which has some elements having CKEditor enabled, there is a delay in applying the style of CKEditor on the text edit form element. I mean it shows the transition from the basic view into the CKEditor styled view.

How can I solve it?


texts:
I know the way that I'm currently implementing ajax page loads is not the best way to do it. It goes like this:

I have a module (that I created) that has a path to send all ajax request though. based on the urls parameters, it's able to figure what actual page (node) needs to be loaded. It just returns a json_encoded string for processing (rendering is done client side).

The trouble with Drupal is that it wants to decorate EVERYTHING with all the templates. So I get json intermingled with html. I obviously don't want that. I don't want any rendering done at all in fact. So far, the only thing I've come up with on my own is to implement hook_page_alter and just unset as much data as possible until it renders with only the json. That was working for a while.

Then I added the devel_themer module (or whatever it's called). That automatically appends some javascript to the end of every response. That is breaking the json I'm sending via these ajax requests.

This has brought up the issue of my method of processing the ajax.

What is considered best practice for this type of thing? Ultimately, there may be minimal server side rendering, but I want the data to be sent in chunks that I can inject in various parts of the page. I don't want to have to put in all in one spot. To the ajax_response.title would go in the div with id="title" and the ajax_response.body would go in the div with id="body". There may be info between those two that I don't want to replace/re-render between requests.

Mostly my question is this: How can I tell drupal to send exactly the text that I want as a response instead of insisting on decorating the response with templates and allowing modules to add information?


texts: How do I add a link to a table row in a custom module?

texts:
I am making a sortable table in a custom module. If I put the whole link as part of the row information, the URL does not come out right.

I tried the following code.

  array(
    'data'=>array(
      '#title' => $entry['name'],
      '#type' => 'link',
      '#url' => $entry['link_url'],
    )
  )

I also tried what suggested on https://www.drupal.org/node/745272,  which describes how to do it for Drupal 7.

I also tried this code.

 $rows[] = array(
   array(
     'data' => array(
       'name' => new FormattableMarkup('@name', [':link' => $entry['link_url'], '@name' => $entry['name']])
     )
   )
 );

Neither displays anything.

How do I achieve this for Drupal 8?


texts: How do I define a separate form template for a multistep form?

texts:
I have a multistep webform in Drupal 8. I want to define spearate page template for each page in the webform.

I'm trying to define it using hook_theme_suggestions_hook() like below. But how can I identify the current webform page currently viewing from $variables.

function custom_module_theme_suggestions_webform(array $variables) {
  $suggestions = array();

  $suggestions[] = 'webform__'.$current_page;

  return $suggestions;
}


texts: How do I use jQuery code through a module/theme?

texts:
How do I use jQuery through a Drupal 8 module?
I'm trying to get some jquery code running on a drupal 8 website. It's a div animation that randomly moves the div within a wrapper.
I've added the JS and CSS files and they're both showing in the source. I've then added the Div ID of 'container' to html.html.twig(yes I copied it into my theme folder first) -

{%
  set body_classes = [
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    db_offline ? 'db-offline',
    theme.settings.navbar_position ? 'navbar-is-' ~ theme.settings.navbar_position,
    theme.has_glyphicons ? 'has-glyphicons',
    'container',
  ]
%}

Also added a div to use for this. Again in html.html.twig

<js-bottom-placeholder token="{{ placeholder_token|raw }}"> //**Not part of my code just adding it for comparison.

TEST DIV, IF I MOVE I'M WORKING!

So the files show up in the source and the source also shows that the div ID of container has been added.

Here's the jQuery code, keep in mind that I've adjusted it to work with Drupal 8 so there's probably a syntax error or two.

$.extend(Drupal.theme, {
  animateDiv: (function() {
    ($('.fly')); }),

* Almost certain the problem is here ^^^

  makeNewPosition: function ($container) {
    // Get viewport dimensions (remove the dimension of the div)
    var h = $container.height() - 10;
    var w = $container.width() - 10;

    var nh = Math.floor(Math.random() * h);
    var nw = Math.floor(Math.random() * w);

    return [nh, nw];
},

animateDiv: function ($target) {
    var newq = makeNewPosition($target.parent());
    var oldq = $target.offset();
    var speed = calcSpeed([oldq.top, oldq.left], newq);

    $target.animate({
        top: newq[0],
        left: newq[1]
    }, speed, function() {
        animateDiv($target);
    });

},

calcSpeed: function (prev, next) {

    var x = Math.abs(prev[1] - next[1]);
    var y = Math.abs(prev[0] - next[0]);

    var greatest = x > y ? x : y;

    var speedModifier = 0.23;

    var speed = Math.ceil(greatest / speedModifier);

    return speed;

}

});

Here's the CSS code

.fly {
width: 50px;
height:50px;
background-color: red;
position:fixed;

}

That's what I've tried and yet there's still no jQuery activity, I've also tried using different types for class names(.div instead of #div etc) which I think is where the problem is. The flying div shows but isn't being styled and there's no jQuery. What am I doing wrong?

Update: After playing with the code for awhile I've managed to at least get the style to show on the div. jQuery still a no show though..

This isn't the same jquery code but it's similar and it's what I would like, the div floats around the entire page, I've tried using this code as well but I still get the same problem as above. http://jsfiddle.net/Xw29r/15/


texts: Does memcache allow anonymous users to be served content when the database server is down?

texts:
I'm exploring options around keeping my Drupal 7 sites working for anonymous visitors while a database server is being upgraded.  The site is already fronted by Cloudflare - but their always on tech is a little hit and miss.

I'd like to understand more about when the database is queried when using the memcache module.  My other choice is to use the AutoSlave module and setup a master - slave replication - but if I can get a performance boost from memcache and a little resilience added in - I'd maybe prefer that route.

I'm hoping that the page cache will remain relevant enough to perform the database upgrade.  What are the rules around the memcache content going stale?


texts: List all the taxonomy terms in a particular vocabulary in Drupal 6.

texts:
My task is to display all the terms in a particular vocabulary. It should also display all the sub-terms along with their parent terms.

For example the taxonomy page for a particular vocabulary is like

Term 1

Term 2

Term 3

Sub-term 1 of Term 3

Sub-term 2 of Term 3

Sub-term 3 of Term 3

Term 4

Term 5

Term 6

Sub term 1 of Term 6

Sub term 2 of Term 6

I need an exact display of taxonomy terms as above (without edit, just to list all the terms in a tree order). Is it possible with views or whether I have to do coding? I tried this thing with views by giving term- weight filter, taxonomy parent term relationships etc, received duplicate values and found it very complex.


texts: What is the access record "content_access: all"? This is overriding my taxonomy access module

texts:
I have had problems with my permissions ever since I last rebuilt my permissions.  (I did this after working on user reference permissions.  This field has no user reference on it)

The taxonomy permissions have the same priority of 0.  In fact all access modules have the priority of zero.  When I go to the page that can be seen even though it should not be seen, it shows the following as granting access to view the page:

I think that I have to give people access to see pages by default and then take it away if taxonomy is assigned.  I had this working before and I don't understand why it stopped working.

What can I do to figure this out? I'm a few hours into the issue and am a bit stumped.

I have the following modules installed regarding permissions:

Content Access
Node access user reference
Taxonomy Access Control

I'm not sure if it is relevant or not but I also get a message when I hover over delete that says:

  DNA and Core seem to disagree on this
  item. This is a bug in either one of
  them and should be fixed! Try to look
  at this node as this user and check
  whether there is still disagreement.


texts: Adding DIV ID= Tags to a views table output

texts:
I know that I can do a template override to style the views output, as described here.

I've also used a template preprocess function to add a "row_classes" to a views output. This will add DIV classes, but is it possible to add IDs as well?

Could I also use the views UI for that, maybe with a rewrite?


texts: Display number of times content is referenced in content

texts:
How would I go about implementing the following content types + fields

Parent

Name
Description
Other fields (e.g. location, date)
Number of children

Child

Name
Description
Other fields (e.g. location, date)
Parents (entity reference)

Children can have multiple parents.

Basically what I want to do is to create a new Child and "tag" a Parent in it. A View with a list of Parents would then display something like "[Parent Name] has x Children" for each Parent.

I'm very new to Drupal so if I'm going about this completely the wrong way, please let me know!


texts:
I have the following custom URL aliases that point to specific Views paths:

/california/los-angeles maps to /locations/los-angeles
/username/listing/post maps to /item/post

Views still uses the older, pre-defined aliases. Is there any way to get Views to respect the custom aliases I've set? I'd need to do this at a global level, as there are too many paths to be changed in Views.


texts: Importing pre-built content into the site

texts:
There are frequent installs of Drupal 7 that I do. All of them are almost the same, except, some need to have additional content types and modules on top of the default setup.
I'd like to ask if there is a way to modularize the deployment to save time on manually creating content types and installing modules.

Example:

(Required) I download and install Drupal 7 (possibly Drupal 8 in the future) with minimal profile
(Optional) I import a "magic package" (prebuilt) that would import all the custom content types I made, menu items, views and extra modules into the site created in step 1.
(Optional) I import a second "magic package" (also prebuilt) that would give site more capabilities with additional modules, menu items, views and content types.

some of the imported stuff is linked to Drupal users via Entity Reference fields.

What is the best way to accomplish something like this?
Is there a module that can help me build these "Magic Packages"?

Thank you.


texts: How can I access untranslated field values in a translated view row?

texts:
If you add the title field to a view you can use the token title__raw as a pattern. I just created a custom field for use in view named dossier_status and I need to create something a like dossier_status__raw token. The reason is that the status can be translated to different languages but I need the status always in english to use it as a css class. How can I accomplish this?

For the moment I have another field named dossier_status_machine_name (with the status always in english) But I think that this is not the best approach.


texts: How to convert the Title field on Image type to multi-line text box

texts:
I have a Basic Page content type with a Gallery field that lets the user upload images to that page.

when I active the Title field for the user to input a title, it shows as a single text box.

But is there a way to convert this to a multi-line text box?


texts:
I am updating a site from Drupal 8.7 to Drupal 8.8, and after running a drush updb, I encountered this error:
[error]  TypeError: Argument 2 passed to Drupal\pathauto\AliasStorageHelper::__construct() must be an instance of Drupal\path_alias\AliasRepositoryInterface, instance of Drupal\Core\Path\AliasRepository given, called in drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 289 in Drupal\pathauto\AliasStorageHelper->__construct() (line 79 of drupal/modules/contrib/pathauto/src/AliasStorageHelper.php) #0 drupal/core/lib/Drupal/Component/DependencyInjection/Container.php(289): Drupal\pathauto\AliasStorageHelper->__construct(Object(Drupal\Core\Config\ConfigFactory), Object(Drupal\Core\Path\AliasRepository), Object(Drupal\Core\Database\Driver\mysql\Connection), Object(Drupal\pathauto\VerboseMessenger), Object(Drupal\Core\StringTranslation\TranslationManager), Object(Drupal\Core\Entity\EntityTypeManager))

I found a similar issue in this link here and there seems to be a solution(patch) for it.
EDIT:
I ran a composer command attempting to fix the path alias error:
composer require 'drupal/pathauto:1.x-dev@dev'
Ran composer update, and drush updb.
The following is the error displayed by the console:
>  [error]  Argument 2 passed to Drupal\pathauto\AliasStorageHelper::__construct() must be an instance of Drupal\path_alias\AliasRepositoryInterface, instance of Drupal\Core\Path\AliasRepository given
>  [error]  Update failed: block_field_update_8001
> PHP Fatal error:  Uncaught ReflectionException: Class Drupal\path_alias\AliasRepository does not exist in /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php:1174
> Stack trace:
> #0 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1174): ReflectionClass->__construct('Drupal\\path_ali...')
> #1 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(634): Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition), Array, true, 'path_alias.repo...')
> #2 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1281): Symfony\Component\DependencyInjection\ContainerBuilder->doGet('path_alias.repo...', 1, Array, true)
> #3 /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(1238): Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices(Object(Symfony\Component\DependencyInjection\Reference), Array, true)
> #4 /var/www/html/docroot/ in /var/www/html/docroot/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1174
 [error]  Update aborted by: system_update_8803, block_field_update_8001
 [error]  Finished performing updates.

Is there anything else I can do with the pathauto module?


texts: How to sort content of nodes by dynamic fields?

texts:
I have a content type named "Article". "Article" has fields: Body, Image, Tags, etc. I want to create a sort handler that will sort node content by content type fields. I know, every field has its own table in database. So, If I choose "body" field, it's database table will be field_body and has column body_value. How to sort content on basis of field's column, specially when we don't know which field our user is going to choose next.

I mean fields are dynamic and so the sorting should also be dynamic. For some static non-fields like "title", "node id", "node_created", etc, I used below approach to reach the scenario.

$query = new EntityFieldQuery(); //get all nodes of content type selected by each block
$query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', $content_type)
      ->propertyCondition('status', 1);
foreach ($sort_fields_array[0] as $sfaa_key => $sfaa_value) {
    if(!empty($sfaa_key) && $sfaa_value == 'Assc'){
    $query->propertyOrderBy($sfaa_key, 'ASC');
    }
     elseif(!empty($sfaa_key) && $sfaa_value == 'Desc'){
    $query->propertyOrderBy($sfaa_key, 'DESC');
    }
}
$results = $query->execute();

$sfaa has all dynamic fields and non-fields. This code is working for non-fields like title, nid, etc. but not for dynamic fields like body, image etc.

if $sfaa == title, then sorting will be done by title else if it is = nid then sorting will proceed by node id.

And if $sfaa == body, it gives me fatal error node.body doesn't exist.

How to overcome this error or sort content by dynamic fields?

Edit 1:

I got some half way clue that's why editing here.
If I use ->fieldOrderBy('field_photo', 'fid', 'DESC') , no doubt it will sort content by fields. But can we make it's column (fid) here dynamic?

Edit 2:
I am using db_field_exists($table, $field) to check if field exists or not. But, Isn't there any other way to get columns of the field dynamically for sorting. I don't think, it is impossible, as Views module is using some kind of similar approach in Views Sort Criteria

Modified code is shown below:

 if(db_field_exists('node',$sfaa_key) && $sfaa_value == 'Assc'){
      //  print "if condition executed";
    $query->propertyOrderBy($sfaa_key, 'ASC');
    }
     elseif(!(db_field_exists('node',$sfaa_key)) && $sfaa_value == 'Desc'){
       //  print "else condition executed";
    //$query->propertyOrderBy($sfaa_key, 'DESC');
      $query->fieldOrderBy($sfaa_key, 'value', 'ASC');