texts: How to perform action from form opened in modal?

texts:
I have a form where I have a link that opens a modal window with another form(something like adding a block to a region).

I would like to perform the action on the opened/second/modal form during submission as usual but I also want to tell the current window to close the modal and to hit a specific button(which is ajaxified and it will rebuild the form so the changes made via the second form would be visible in the main form - they are based on the same data source).

Is there a way to achieve this with ajax command from the second form?

A good example is View form. When a new window is opened(adding a field, or configuring some part of the View), actions in that window are reflected in the form itself after the window is closed.


texts: How to add some buttons to add to cart form

texts:
I would like to add some buttons to my add to cart form to alter the quantity input. I want two buttons for +1 and -1, and two other buttons for +12 and -12. This is the code I use in my .module to add the first button, but without success.

/**
 * Implements hook_form_alter()
 */
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'commerce_order_item_dc_ajax_add_cart_form_') === 0) {
    $form['quantity']['widget']['0']['#prefix'] = '
';
    $form['quantity']['widget']['0']['#suffix'] = '
';

    $form['actions']['add_qty'] = [
    '#type' => 'button',
    '#value' => t('+1'),
    '#ajax' => [
      'callback' => '_add_one_callback',
      'wrapper' => 'quantity-wrapper',
     ],
    ];
  }
}
/**
* Increments +1 and rebuild.
 */
function _add_one_callback(array &$form, FormStateInterface $form_state) {
  $quantity = $form_state->get('quantity');
  $quantity= $quantity + 1;
  $form_state->set('quantity', $quantity);
  $form_state->setRebuild();
}


texts: How do I set the node title as breadcrumb?

texts:
How can I set the breadcrumbs for a node? I have a node which is in the menu and also the head menu with the id 2 which contains the imprint.

If I open my page http://my.page.tld/imprint (I'm using the SEO stuff) I can see my text with the correct title but with no useful breadcrumbs. It's Home instead of Home » Imprint.

How can I fix that?


texts:
In the process of developing a distribution, I'm stuck with the task to customize the install.php page. Can't find a way to change the tpl/layout of the installation process or which preprocess function to use.

I'd like to do the same as Commerce Kickstart did, in a certain way.

Any ideas how?


texts: Showing term description on terms page that are displayed using views

texts: I am currently using a view to override Drupal's core taxonomy pages. Unlike the core handling of taxonomy pages, views does not display the current term's description. Is there a good way to display a term's description through views or would I need to make a template file for the view?


texts: How to add PHP to a node without php filter?

texts:
I have a one-off page on my site (webcam), where i need to run some php to eg. calculate today's sunrise time, add a daylight image at night, etc.

I understand PHP Filter is a security risk, and not recommended if it can be avoided.

My page is actually a panesl page, so not neccessarly a node.

I thought maybe i could do the coding and (some) content in a node template, or what other options do i have? A module? Sounds heavy... In my theme's php?
What are pro's and con's?


texts: Views filter referenced content when end date is over

texts: This view is the result of a given postcode. how could I hide/filter referenced content when its end date is over? The referenced content should disappear but the non referenced content should still be displayed.


texts: Views Exposed Filters - position each filter independently

texts:
I am working on a drupal 7 project and have a view (v3) over 6,000 product items with 4 exposed filters.  This all works fine - I can put the "filter form" in a block - that is fine.

But I can't figure out how to separate out the individual filter drop downs for nicer positioning.  Say I want two dropdowns on the top of the result area and 2 with the apply button stacked on the left...

Is my only option to play with absolute positioning in the css?


texts: Importing Webform Submissions to create content

texts:
Is it possible to use data a user submits via a webform via a simple import into a site.  It would not be the same site.  The webform is being used to collect specific data.

e.g.  webform data = user name, address, photo file, csv file submitted via webform in site A

webform submission data imported in to site B


texts: How to modify the header  in superfish menu?

texts:
I am trying to convert a html theme into drupal theme using superfish module. I can't figure out what to edit so that my menu has a different ID. So, instead of

I'd like to have
.
 Which files do I have to edit? Here is the code

Home

Who we are

Project


texts: how to map fields in feeds module with csv that has no headers?

texts:
Can feeds module still know how to map the fields correctly even if there are no headers in a .csv file. I am trying to migrate sample data from database which i exported to a .csv file through phpmyadmin. i am testing the feeds module if it can handle large file migrate.

if the answer is no, can i manually input the headers in the excel files? or it has to be exported again with headers?


texts: Installing extra/additional plugins for standalone CKEditor module library

texts:
I have the CKeditor plugin installed by itself (i.e. not using WYSIWYG module.) Then, it uses a CKEditor library located in sites/all/libraries/ckeditor. This works fine. I'd like to add more plugins to it; namely, the footnotes plugin. (For the moment, please refrain from "just download a new library from ckeditor.com and replace it"; there were other issues/considerations involved.)

Now, I see this everywhere when I try to look for a solution

config.extraPlugins = 'footnotes';

I tried adding that to admin/config/content/ckeditor/edit// -> Advanced Options -> Custom JavaScript configuration, but it white screens the editor.

I tried adding it to the config.js in sites/all/libraries/ckeditor like below, but it had no effect.

CKEDITOR.editorConfig = function( config ) {
  config.extraPlugins = 'footnotes';
};

I can't really add it to a ckeditor.config.js file, dump that file in my theme, and choose "Yes" for "Load ckeditor.config.js from the theme path", since (for content creation/editing) it uses the admin theme which is different from the theme we're developing.

So, I'm at a loss. The only other thing I can think of is to use a hook in the module we have for the site, but I'm not sure if that's write/what hook would be called.

Is it just me, or does it seem like clear documentation on how to manage CKEditor in Drupal is severely lacking? Any help would be appreciated.

UPDATE: After some testing, it looks like the "Custom JavaScript configuration" is supposed to work, but it is possibly broken for CKEditor 4.4+ I read something (can't seem to find it now) that suggested the plugin/widget import was broken on 4.4+, so I changed to 4.3 and the extraPlugins worked. Now, I wasn't able to get footnotes working (which is what kicked this whole thing off), but some other plugins that previously failed during the same steps now work on 4.3. So, there's that. I'm wondering now if it's something with footnotes itself.


texts:
I'd like my webform to change a hidden randomly on every load. Here are the relevant parts of the webform I set up, with a textfield instead of a hidden for now so I can see what's going on, but I always get redirected to test_variant=test2_variant.
elements: |
  test:
    '#type': textfield
    '#title': test
    '#prepopulate': true
  test_variant:
    '#type': webform_variant
    '#title': 'test variant'
    '#variant': override
    '#display_on': form
    '#randomize': true
variants:
  test_variant:
    id: override
    label: 'test variant'
    notes: ''
    variant_id: test_variant
    element_key: test_variant
    status: true
    weight: 0
    settings:
      settings: {  }
      elements: |
        test:
          '#type': textfield
          '#title': test
          '#default_value': 'variant'
          '#prepopulate': true
      handlers: {  }
      debug: ''
  test2_variant:
    id: override
    label: 'test2 variant'
    notes: ''
    variant_id: test2_variant
    element_key: test_variant
    status: true
    weight: 0
    settings:
      settings: {  }
      elements: |
        test:
          '#type': textfield
          '#title': test
          '#prepopulate': true
          '#default_value': 'test2'
      handlers: {  }
      debug: ''

What am I doing wrong?


texts: Taxonomy dropdown to match the related content (in a views with exposed filters)

texts:
Goal

Each time I select a term from the select all the related articles in the page will be listed. The correct link is terms/term-name (taxonomy term alias)

e.g terms/sports will display all sports articles

How do I alter the form submit link?

Achieved so far

I created master display with 'exposed form in block: Yes'
The block is shown up with all the terms I need in the select widget.
Now when I select a term from the dropdown the url turns to terms?tid=54 displaying a page with the link to the terms/term-name. but I want to access directly.

All I need is to display at once from the select all the related content


texts: How do I add to $page_top in html.tpl.php?

texts:
I wanted to add a piece of HTML at the top of all pages, right after <body>. In the #drupal IRC channel I got the recommendation to override html.tpl.php in the theme. That works fine. But isn't there some useful hook that I could use, so I don't have to copy html.tpl.php and just add a few lines?

I tried to modify $variables['page']['page_top'] in THEME_preprocess_page() and THEME_preprocess_html() but upon debugging $page_top in html.tpl.php, the changes had been discarded.

How do I do it by hook? And which way is to prefer?


texts:
In the past, I developed a Drupal site in my localhost. After that, I uploaded to production site. Everything was OK.

Recently, my HDD was died. So, I lost my Drupal site source code. I downloaded my production site on localhost.

I cannot log in. I think the problem is cookies.

How can I force Drupal to get my login by adding some code lines?


texts: how to do addition of two field values in drupal 7during node_presave?

texts:
I had made two content types
content type 1 - 'product' with field name 'product_stock' and
content type 2 - 'Add stock' with field name 'stock_value'. It also contains a node reference to product content type.
I want to add the value of product stock and stock value during node_presave.

For Example: product stock = 10 and stock value = 14, then both should be added to give 24.


texts: Youtube Video still playing in background after attempt to close it by clicking on the overlay area (Colorbox module used)

texts:
I created a Youtube video gallery using video embedded field module (to put my Youtube url) and colorbox module to create a nice overlay pop up.

I have created the gallery grid with the Views module. Everything works perfectly on all browsers, except Internet Explorer >= 8.

When I try to close the video by clicking on the overlay area or the close button, the video closes, but its sound keeps playing on the background.

Do you have any idea about why it does this on Internet Explorer?


texts:
I am using Drupal 7 . and in a content type i created a field with user_reference,  which is working fine.

And while creating a content it shows all users.

Now i want to show  only User with particular role..

Does anybody tell me how to do this. Is there is any module avialable for this


texts: commerce kickstart 2 easy way to disable products from view

texts:
hi I'm having a hard time managing my stock using the kickstart 2 module. I have product display with multiple product variants. I do not use stock level, as I sell online and other places so I update manually when a product isn't available anymore. I will however want to use the variant and product again in the future.

So I thought nice and easy I'll just use the Disable button, located via admin/commerce/products then press the Quick Edit button select Disable and Save.

This kind of works as the product now shows Product Not Available on the purchase screen. however what I'd ideally like is the product not to show up at all, or to say not available on the broader search list.

Additionally I unpublished the content, which is a lot more convoluted to achieve. And this had the annoyance of being extremely hard to find again. I had to create a new view just to look for unpublished Product Display types.


texts: Correct Database settings for pushing a Drupal site live

texts:
I have a Drupal 7 site.

I have it working fine on localhost and my own test domain, with individual settings folders setup such as:

sites/localhost
sites/test.mydomain.co.uk

I am now putting it up onto a site where there is no domain set, but I can access it by visiting:
sitename.org/folder1/folder2

i have duplicate settings files in;
sites/folder1.folder2
sites/www.upcomingfinaldomainname.com

Have I got these right?

I keep getting the message:

PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in db_table_exists()

I'm using the user and pass I have been provided, and the correct db names. I have also set host as localhost and removed the port number.

Any suggestions?


texts: Display delete confirmations in a modal window

texts:
How do I display delete confirmation form in a modal window? I have a view which displays submissions of an entity form. Each one has a 'delete' link for the admin to remove a particular submission, but clicking it goes to a new delete confirmation page (entityform/[nid]/delete). How can I display this confirmation page in a modal overlay, like the edit forms?

I tried the overlay_path module but it tried to display a styled page in the overlay and it looked terrible with my current theme


texts: How to link taxonomy term with its content?

texts:
This is the code below that i am used

$ch=db_query("SELECT th.tid FROM taxonomy_term_hierarchy th
  INNER JOIN taxonomy_term_data td ON th.tid=td.tid
  INNER JOIN field_data_field_books book ON book.field_books_tid = th.tid
  WHERE td.vid = '6' AND th.parent = $tid AND book.entity_id = $nid")->FetchField();

"
Pages
";

$chap = taxonomy_get_children($ch);
foreach($chap as $ca){
  print "
Chapter===>".$ca->name;
}

how I link taxonomy terms using the above code?


texts: 8 - How do a get a view then save it with a new value

texts:
In an update_hook() I need to search all views' displays for a value, then resave them with a new/extra one.  How do I go about this?  What command can I use?

$views = Views::getEnabledViews();
foreach ($views as $view) {
  $source_value = '';
  $config = \Drupal::config('views.view.' . $view->id());
  $rawData = $config->getRawData();

  $master = FALSE;
  // Get the display with the draggableviews field.
  // It is a little tricky because the 'default' display is the master.
  foreach ($rawData['display'] as $display_key => $display) {
    $field = isset($display['display_options']['fields']) ? $display['display_options']['fields'] : [];
    if ($display_key == 'default' && array_key_exists('draggableviews', $field)) {
      $master = TRUE;
    }
    if ($display_key != 'default' && array_key_exists('draggableviews', $field)) {
      $source_value = $view->id() . '|' . $display_key;
    }
    if ($master && empty($display['display_options']['fields'])) {
      $source_value = $view->id() . '|' . $display_key;
    }
  }
  if ($source_value) {
    // Save the view with the source value in the sort handler.
    foreach ($rawData['display'] as $display_key => $display) {
      $sorts = isset($display['display_options']['sorts']) ? $display['display_options']['sorts'] : [];
      if (array_key_exists('weight', $sorts)) {
        // **************
        // SAVE VIEW HERE
        // **************
      }
    }
  }
}


texts: How to fix active-class problem in minicalendar with calendar / exposed filters

texts:
I have a calendar view for events. The events are categorized by taxonomy terms. I use the minicalendar for the selection of days and filter the result list with an exposed list of the categories.
This is all working fine.
But user interface lacks a bit of coherence. There's no indication of which day is picked on the minicalendar (which only has a class for "today").
This snippet helped me getting an "active" class for the datebox, so users can see, which date they have chosen:
<?php
function YOURTHEME_preprocess_calendar_datebox(&$vars) {
  $url = $vars['url']; // The (absolute) URL of the item.
  $current = url(request_path(), array('absolute' => TRUE)); // The absolute URL of the page being viewed.
  if ($url == $current) {
    $classes = explode(' ', $vars['class']); // Extract the current classes as a list.
    $classes[] = 'active'; // Add 'active' to the class list.
    $vars['class'] = implode(' ', $classes); // Concatenate and attach the updated class list.
  }
}
?>

But here's the problem: when i select a taxonomy term, the url changes from:
/myview/2014-11-27

to
/myview?field_category_tid_selective=8 (e.g)

and my active class is gone.
How can i achieve that the class stays, even when a filter is active on the results?
Any help appreciated!
Thx


texts: What hook is run on every page before hook_preprocess_page()?


texts: Whenever I edit/update a node all the page caches for anonymous user are lost

texts:
I have the following cache settings on the performance page

I have visited a few pages as anonymous user and made sure that they are being cached. Now I log in as admin in a different browser and edit a node. The moment I do this I see that Anonymous Page Cache for all the pages are cleared.

This seems counter intuitive and render caching useless for sites with high content editions.


texts: RESTful Web Services : How to simply post a paragraph entity

texts:
I have simply activated the default paragraph ressource with core (8.8.3) module :

I would like to post a paragraph but even just with the "type" field, I got 403 error in response ! I have nearly the same request that works fine for node...

        var newReleve = {

          type: [{
            target_id: 'releve_de_chantier'
          }],
          parent_id: [{
            value: this.nid,
          }],
          parent_type: [{
            value: 'projet',
          }],
          // field_type_de_releve_de_chantier: [
          //   {
          //     value: this.typeReleve
          //   }
          // ],

        };

        if(this.pid) {
          newReleve.id = [{
            value: this.pid
          }]
        }

        fetch('/entity/paragraph'+(this.pid ? '/'+this.pid : '')+'?_format=json', {
          method: this.pid ? 'PATCH' : 'POST',
          headers: {
            'Content-Type': 'application/json',
            'X-CSRF-Token': csrfToken
          },
          body: JSON.stringify(newReleve)})
          .then(response => {
            if(response.ok){
              return response.json();
            } else {
              console.log(response);
              throw('Error posting datas ! Details below \n ' + response.status + ' : ' + response.statusText);
            }
          })
          .then(para => {
            // console.log(para);
            this.pid = para.id[0].value;
            console.log(this.pid);

          })
          .catch( error => {
            alert('Enregistrement du relevé non effectué : erreur interne du programme ! Détail de l\'erreur : \n ' + (error.message ? error.message : error) );
            console.error(error);
          });

Any idea ?

thanks


texts:
I can get the field using entity_metadata_wrapper like this

$node = node_load($nid);
$node_wrapper = entity_metadata_wrapper('node', $node, array(
    'langcode' => $GLOBALS['language'],
    'bundle' => 'unit'
     )
);

$field_value = $node_wrapper->field_photo->value();

And that returns an array which I don't know how to render. I tried drupal_render() but it seems that it doesn't do the job.

So how can I render this field ?


texts: Organic groups: permissions groupadmin not respected

texts:
I am having troubles getting organic groups permissions working.

In my grouptype I want to give the groupadmin the permission to edit the group.

  On an OG level:

  admin/config/group/permissions/node/mygrouptype

I have set the permissions to 'Edit group' for administratormember

  On a Global level:

  admin/people/permissions

I have set the permission to Edit 'Mygrouptype'

However still my groupadmins are not able to edit their group. Setting this permission on a groupmember level does give the groupadmin the permission.

What am I missing?


texts: How can I show the field setting options like "Style Settings", "Rewrite Results" in Views

texts:
I created a view and added some fields, I saw others can configure field options like "Style settings" and "Rewrite Results", but in my "Configure Field:" window, I don't have these options, only several blank rectangles. See below image,

Is there any settings I missed or any new modules I didn't installed?


texts: Control Visibility of Paragraph Without Fields

texts:
I'm preprocessing a paragraph to add a custom form but I'm having trouble with the visibility. I don't need any fields on this paragraph.

If I just add the form to the paragraph the whole paragraph is hidden for anonymous users.

function my_module_preprocess_paragraph__my_paragraph(&$variables) {
  $paragraph = $variables['paragraph'];
  $form = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\MyCustomForm');
  $variables['content']['form'] = $form;
}

However, if I add a title field to that paragraph everything shows up fine. Is there a way I can get the form to show without having to add fields?


texts: How to print the products (fields) on a node using a custom display

texts:
I am new to Drupal and I've been trying to create a site to function as a lending inventory. I have so far created a new content type with my fields (describing product details) which the user fills with data every time he adds content(adds a product). I want to be able to print the saved result of the add content page to a document but not in the display that it has as a row of the table view. To be more specific I would like to print every product and its details in a customized way so that the details are displayed in two columns and above them a text of lending agreement can be put.

I am sorry in advance for the complexity of the description
Does anyone have an idea?

Thank you


texts: title_callback not working for certain user in hook_menu

texts:
I am developing a module to manage Human Ressources.
I implement hook_menu with a title_callback like this:

$items['intranet/hr/%user'] = array(
  'title callback' => 'user_page_title',
  'title arguments' => array(2),
  'page callback' => '_hr_redirect_to_personal_data',
  'page arguments' => array(2),
  'access callback' => 'hr_check_menu_access',
  'access arguments' => array(2),
  'type' => MENU_NORMAL_ITEM,
  'menu_name' => 'navigation',
);

Users with certain role and the user to whom the HR data belongs can access to this menu, and should see the name of the concerned user.
It works perfectly if the logged user has a role, but the title of the menu is "Home" for the user to whom the HR data belongs.
I don't understand what's happening as I am implementing hook_menu() the same way the user module does for the user profile page.
If I inspect the menu with the devel menu, the title is correct for every user.
Any idea on what I am doing wrong ?
Thanks!


texts: Wrapp every form item select with div, excluding label

texts:
im trying  to wrap form item  with

I had success with hook_from_alter and #prefix #suffix that is wrapping whole element with div like this:

I used this hook:

function em_form_alter(&$form, &$form_state, $form_id){
if ($form_id == 'user_register_form') {
    $form['field_gender'][LANGUAGE_NONE]['#prefix'] = '
';
    $form['field_gender'][LANGUAGE_NONE]['#sufix'] = '
';
}
}

And i got this.

    Gender
    <select id="edit-field-gender-und" name="field_gender[und]" class="form-select required">
        <option value="_none">- Select a value -</option>
        <option value="1">Male</option>
        <option value="2">Female</option>
    </select>

But what i need to accomplish is this:

Gender

    <select id="edit-field-gender-und" name="field_gender[und]" class="form-select required">
        <option value="_none">- Select a value -</option>
        <option value="1">Male</option>
        <option value="2">Female</option>
    </select>

And i would like to have this on every select on whole website, so maybe hook_form_alter isn`t so good idea?


texts: How to add custom email to account user emails?

texts:
There are a few email templates in account user emails page: "/admin/config/people/accounts".

How can i add custom emails from my own module? I would like to have&edit all email templates in the same place.


texts: How to change a field value to 500 products (commerce module) at the same time?

texts:
I have about 500 product in my site powered by the commerce module. I need stock capabilities so installed the commerce_stock module. So far so good.

This module add a stock field and a checkbox to check Disable stock for this product in the product itself.

Thing is that stock field is set to 0,00 by default, then all the product are shown as Out of stock.

The solution is as simple as to mark the checkbox to check Disable stock for this product for all products. But I have 500 products, then this will be a waste of time...

Is there any way to do this programmatically? Any other idea to get this done?

I thing of doing this directly in the database with a sql query, but not sure if this is a good idea?


texts: Prepare name and address for use with drupal_mail()

texts:
I'm having problems with certain characters when using the drupal_mail() function.

Here is the apache error.log entry for the issue:

  Ignoring invalid 'To:' recipient address '=?UTF-8?B?IsWgxZLFvcWhxZPFvsW4wqXCtcOAw4HDgsODw4TDhcOGw4fDiMOJw4rDi8OMw40=?=  =?UTF-8?B?w47Dj8OQw5HDksOTw5TDlcOWw5jDmcOaw5vDnMOdw5/DoMOhw6LDo8Okw6XDpg==?=  =?UTF-8?B?w6fDqMOpw6rDq8Osw63DrsOvw7DDscOyw7PDtMO1w7bDuMO5w7rDu8O8w73DvyI=?=  =?UTF-8?B?IDxjaXRyaWNndXlAZ21haWwuY29tPg==?='
  Transaction aborted: no recipients specified

For sake of example, what would be the simplest way to successfully send an email (In the RFC2822 format of "User <user@example.com>") to:

ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÍÎÏÐÑÒÓÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñóôõöøùúûýÿ <example@example.com>

Currently drupal_mail() fails with:

  "Unable to send e-mail. Contact the site administrator if the problem
  persists."

Preferably, I would like to be able to keep these special characters intact.

Otherwise, could I use a project like Transliteration or Pathauto to convert or prepare the string? If so, which project and function should I use to prepare the "To" name?

Drupal Log Message:


texts: Is there a module which allows users to edit text together?

texts:
I am building a site which allows users to upload handwritten images and transcribe them. Ideally, I would like if there were a text box type of module which updated the default value of the box each time it was written to.

Example:

Text box is created: "Default text"
Alice updates text box: "Alice was here!"
Text box now reads "Alice was here!" to all users.
Bob updates text box to "Alice was here! And bob!"

Is it possible to do something like this using modules? If so - which?

The page layout will look something like this:

[ Slide show ]
[ Transcription box ]
[ Comments ]

Ideally it would have the following functionality:

The image must appear on the page alongside the text editor (I had a WYSIWYG in mind but haven't been able to crack it yet)
Version control for text
Load 'default text'
Saving would overwrite the 'default text'

Is it possible to embed the transcription box in to the page? It is important that the user is able to view the image while editing the text box.

Thanks


texts: After rearranging field order in a view, how do I export this modification in features?

texts:
I am using drupal 7, I rearranged the order of the fields in a view, using the contextual menu link 'raerrange' (see image). But now I am not able to export this modification into the feature related to this view. The feature is still in 'default' status. Which is the feature component that is storing this modification? Which component should I add to the feature?

Any help will be really appreciate.


texts: How can i publish my content with Schedule

texts:
I want to publish some content in a day, not all of unpublish content at once.

for example
I have 20 unpublish content and i want to publish 2 random content in a day at 13:00.

How can I resolve this?


texts:
At some point we will be enabling translations on all entities in Drupal 8. However, we are not ready yet so in the meantime we would like to set all of the entities (content types, taxonomy terms, paragraphs, menus, blocks) to be defaulted to English language. We want to do this because we do not want any entity to have a language code of undefined (or und).

I am unable to find the setting that will allow us to default all entities to just English.

How can we set the default for all entities as English?


texts: Drupal site shows frontpage instead of added content

texts:
I'm restoring a client's site after they lost all information. After some trouble, we could restore their database, which now shows all tables. The problem is that, after uploading all files and connecting to the database, the page displays Drupal's default frontpage and says 'no content has been created yet'. The database contains all tables, and I'm assuming the connection is right; otherwise I'd get an error message.

Why aren't I seeing all info stored there?


texts: PHP drupal added css file does not appear in page source

texts:
I have enabled LessCSS on my site and I have a node instance where I want to add a specific CSS.

I used the following piece of code:

<?php
    drupal_add_css( '/sites/MyStuff/introduction.css');
?>
<div id="myid" class="box">
    ....some text
</div>

Yet, there is no import or link statement in my page source code for introduction.css. I am not using compression. FireBug does not mention loading an introduction.css file. I have doubled-checked and the file is properly located in the folder.

What could cause this issue? And how to solve it?

P.S.:

The css file contains the following:

.box {
    color: green;
    background-color: red;
}

The styling is not applied on the page.


texts: Load Javascript when a particular form is loaded

texts:
I have the code below in my own drupal module(myid):

myid.module file:

function myid_init() {
    drupal_add_js(drupal_get_path("module", "myid") . "/js/myid.js");
}

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

    $items['admin/settings/myid'] = array(
        'title' => 'myid Settings',
        'description' => 'Configuration options for the myid module',
        'page callback' => 'myid_admin_settings',
        'access callback ' => 'user_access',
        'access arguments' => array('administer site configuration'),
    );
    return $items;
}

function myid_admin_settings()
{
    return drupal_get_form('myid_settings_form');
}

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

    $form['settings'] = array(
        '#type' => 'item',
        '#title' => t("Registrar's Signature"),
        '#description' => t(''),
        '#markup' => "<canvas id='myid_registrar_signature' width='500' height='100'></canvas>",
        '#required' => TRUE,
    );
    return $form;
}

myid.js file:

1. $( document ).ready(function() {
2.     myid_retrieve_save_information();
3. });
4. function myid_retrieve_save_information(){
5.     var cnv_rsignature = document.getElementById("myid_registrar_signature");
6.     var ctx_rsignature= cnv_rsignature.getContext('2d');
7. }

Why does every time I load the page, it gets the following error pointing to Line 6 in myid.js:

Uncaught TypeError: Cannot read property 'getContext' of null

Is it because #myid_registrar_signature was not yet loaded when Line 6 was executed? Where did I went wrong?


texts: I have created a custom menu with hook menu booking/%/reschedule and where % is nid of bookings ( content type ), I want to override tpl file for this page in my theme. I tried with page--booking--%--reschedule.tpl.php but its not working.


texts:
I know similar questions have been asked before.  I did my search, and indeed found similar topics here and here, among others.  But I can't find a solution.

Let me explain.

I have a view which presents information from a content type called 'courses'. Information is presented in a table, using views-view-table.html.twig.  I have tweaked that code to 'group' my results based on semester.  All that works ok.  All I want to do now is output an asterisk next to a course title and a respective text at the end of that semester.  So I want a simple comparison (based on course title say) so I add an asterisk next to the title, and then another comparison so that I add some text at the end of the respective table for that semester.

Finally I did solve this problem, but I think my code is very ugly - there must be a better and more elegant way, that is why I turn here to get some help.

Say that when the course title is 'Programming Methodologies' I want to add a simple asterisk.

No matter how hard I try, I could not find a good way of doing that.  Here is relevant kint output:

Based on this and other examples, I 've tried various stuff, but whenever I try to drill 'below' content, I always get NULL - whatever syntax I try.

I just cannot get the string 'Programming Methodologies' .. And generally I guess can't understand how to write correct syntax there. Even testing simple things like content[0] gives NULL.

Finally, thanks to this thread, and some experimentation, I managed to achieve what I want. The following code works, but seems really ugly .. I am sure there must be a better way, but I can't find.  Any help is appreciated...

I post the code because I assume it will help you understand what I 'm looking for:

{% set item = content|first|first %}
              {% if item|striptags|trim|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""}) == 'Programming Methodologies'%}
                (*)
              {% endif %}

In a few words, I am looking for a better way to get the string value instead of using all those twig filters: content|first|first| ... |striptags|trim|replace etc.

In another piece of code, I tried to do something similar, again relying on multiple twig filters to drill the value I wanted ...

In views-view-table.html.twig comments its specified that a 'caption' variable is available. kint output of caption is:

Again I tried a lot but could not get the 'Semester: 01' value as a simple string, so I finally used the following piece of code which does work but seems really ugly to me. I would appreciate if someone could help with something better and cleaner, both for elegance but also for the understanding it will provide.

{% if caption|first|trim|striptags|replace({"\n": "", "\r\n": "", "\t": "", "\n\r": ""}) == 'Semester: 02' %}
  <div style="font-size: 90%; margin-top:8px;">some text here
    </div>
{% endif %}


texts: How can I use my table for Views 3 sort criteria?

texts:
I am trying to create a special sort criterium.
I have a table with 2 cols: nid, and count.

How can I use this table to sort the view by count?


texts:
Simple rule:

after update node: create new entity with type: "comment"

but after update node, nothing happens...

why that?

UPD, added screenshots of my rule:

UPD2: i can create node by creating entity, but not a comment o_O

UPD3: ok understand what is the problem: i called the content type(machine name) 'task' =)

UPD4: errors while updating node and creating comment:

full error message: "Unable to get variable entity_created, it is not defined."


texts: I was trying to work out why cron wouldn't run on my site and came across this post: http://codekarate.com/blog/drupal-6-fixing-stuck-cron-run which said that enabling and disabling search would fix it. It did, but does anyone know why search breaks cron?


texts: Views 3 remove exposed filter programmatically

texts:
I've got several node types each of them referenced to different taxonomy term vocabulary.
For category showing i use taxonomy_display module.

For example, we've got two categories: cues and billiard balls.

Cues has price from, price to and wood type filters.
But balls has no wood type filter.

So i need to remove wood type filter if taxonomy_term tid referenced to billiard balls vocabulary.

Thus, I need to remove one of many exposed filters programmatically.

function modulename_views_pre_view(&$view, &$display_id, &$args) {
  // Some custom logic wich field_info_instances checking ...
  $filter_field = 'filter_id';
  // Removes from everywhere where i can find filter or filters properties
  unset($view->display[$view->current_display]->display_options['filters'][$filter_field]);
  unset($view->display[$view->current_display]->handler->options['filters'][$filter_field]);
  unset($view->display_handler->display->display_options['filters'][$filter_field]);
  unset($view->display_handler->options['filters'][$filter_field]);
}

Filter field removes successfully, but I've got php notice:

  Notice: Undefined index: field_wood_reference_tid in function views_handler_filter_term_node_tid->exposed_validate()

Also i try to remove field in hook_pre_execute(), but with the same result:

function modulename_views_pre_execute(&$view) {
  $filter_field = 'filter_id';
  unset($view->display_handler->handlers['filter'][$filter_field]);
  unset($view->filter[$filter_field]);
}

Also try with override_option() method like here - http://groups.drupal.org/node/82219, but no result at all.

Any suggestions?
Pls help =)

Thanks to everybody for reply but I still has no answer.
Maybe something is not clear? =(


texts: Register a new user programmaticaly having id proof

texts:
I want to create a user programatically. But I have a field id proof where user can upload files.

But I don't know how to save that file while creating user.

Here is my code

$form_state = array();
$form_state['values']['name'] = 'robo-user';
$form_state['values']['mail'] = 'robouser@example.com';
$form_state['values']['pass']['pass1'] = 'password';
$form_state['values']['pass']['pass2'] = 'password';
$form_state['values']['op'] = t('Create new account');
//need to know about files

drupal_execute('user_register', $form_state);

Can anybody tell me how to do this

Thanks


texts: How can an existing user login to check on previous orders?

texts:
I see where an existing customer can login during the checkout process for a new order.  But where can they login to check on existing orders?  Or is that even possible?

I tested and it appears that the Drupal site logon is not the same as the Commerce customer login.


texts: how to create a user registration form in drupal using webform module?

texts: I want to create user registration form using web-form module.Because I want to track users and need to download option for users.


texts: I'm building a multi-lingual site with drupal 7.  I see that you can "translate" a page.  How do I translate a view?  The url http://mysite.com/view is a view, but I don't see the "translate" button.


texts: Would a cached page be considered, solely by definition, RESTful?

texts:
I'm thinking about how to explain the definition of a RESTful interface and am wondering if a cached page in Drupal would, purely by definition be considered RESTful: http://en.wikipedia.org/wiki/Representational_state_transfer#Constraints

Obviously if I wanted to setup a truly RESTful interface I would use Services or Fago's RestWS modules.

But by definition if the page is cached in D7 (thus there is no state information) is there a difference in definition between returning an xml or json endpoint and cached html page? Would the fact that there is javascript on the page create a state that would make it by definition not RESTful?

Again this is purely intellectual so thanks for any of your thoughts.


texts:
I added two fields to my vocabulary terms field management. How do I get these values? There is no fields like color or Image in my Taxonomy Term vocabulary dump.

How does Drupal 8 store these additional fields?

$terms = $this->taxonomyStorage->loadTree($vocabularyName);

//CAN ACCESS
$terms[0]->name

//CAN'T ACCESS
$terms[0]->color


texts: How to alter Casetracker's comment form?

texts:
I'm trying to alter the comment form of the casetracker module to allow changing the "due date" field via comments. Casetracker already does this for other but not for the "due date" field.

I found the hook_form_comment_form_alter() function, which calls casetracker_case_form_common, which does the actual form assembly. When I add my custom field inside that function, it shows up in the form. But I don't really want to alter casetrackers code, so I made a custom module which also implements hook_form_comment_form_alter() and adds the "due date" field (field_due_date) to the form. Unfortunatly this doesn't seem to influence the form at all. Although I can see the field in the $form array when I do a var_dump, it doesn't show up in the form.

I'm probably missing something, since I'm not very experienced in Drupal development. Yet.

I'm running OpenAtrium with all the latest updates.

Can someone help me out? Or at least point me in the right direction?

Thx

edit: my hook_form_comment_form_alter()

function duedate_form_comment_form_alter(&$form, &$form_state) {
  $node = isset($form['nid']['#value']) ? node_load($form['nid']['#value']) : NULL;
  if (casetracker_is_case($node->type)) {
    $form['#node'] = $node;

    $default_due_date = format_date(time(),'custom','d.m.Y');
    $form['casetracker']['field_due_date'] = array(
        '#title' => t('Due date'),
        '#type'=> 'date_popup',
        '#date_format' => 'd.m.Y',
        '#value' => $default_due_date,
    );
  }
  drupal_set_message(var_dump($form['casetracker']), $type = 'status');
}


texts: What all is required to completely uninstall Webform?

texts:
After disabling and uninstalling Webform, I noticed that it appears to still be active. Existing Webform content are all still there and accessible. Apparently this is intended behavior.

I can delete the content and content type, but I'm worried there might be other items or residue that is not as apparent. What all do I need to do in order to completely remove all Webform stuff from the site?


texts: Flagging content via email notification using Rules, Flags and Drupal 7

texts:
I'm using the Flag module to allow authors to approve (or flag) certain types of content that anonymous users upload.

Everything is working well, but I would like to extend the approval feature so it can be done using a notification email as well.  I can trigger an email without issue using the Rules module, but I would like to embed the non-ajax version of the flag link to simplify the approval process.

Is it possible to retrieve and send a 'flag' link via email using only the Flag and Rules module?  Otherwise, what would be the best way to go about allowing users to flag content via automated notification emails?


texts: Why does The special menu items module break the bootstrap dropdown?

texts:
Hi Guys this is my issue on my parent menu item i am using the<nolink>shortcode to leave the link blank however in my tree i have 3 items underneath it.
If i add <nolink> the menu item becomes wrapped in a span tag with no link and the dropdown does not work. if i give the parent a link the dropdown works but only if i select the parent first.
Is this css or a js issue?


texts: How to play a video via drupal video ftp?

texts:
I've installed the Video module (Drupal 6.2), and everything works fine. I also enabled the uploading of the video via FTP. I edited the video content type with the FTP CCK field.  The FTP field uploaded file is listed in the drop-down, and as I select it provides a file link to it. I need it to be displayed in a video player.

In other words, the video file is linked as an HTTP link, and it is not being played using the video player.

Do you have any suggestions?


texts: “Some files and directories in your install are writable by the server.”

texts:
I’m running a Drupal 8.5.3 site and the module: Security Review. One od the “red” results was:  Some files and directories in your install are writable by the server.

Details:
“It is dangerous to allow the web server to write to files inside the document root of your server. Doing so could allow Drupal to write files that could then be executed. An attacker might use such a vulnerability to take control of your site. An exception is the Drupal files, private files, and temporary directories which Drupal needs permission to write to in order to provide features like file attachments.
In addition to inspecting existing directories, this test attempts to create and write to your file system. Look in your security_review module directory on the server for files named file_write_test.YYYYMMDDHHMMSS and for a file called IGNOREME.txt which gets a timestamp appended to it if it is writeable.
Read more about file system permissions in the handbooks.
The following files and directories appear to be writeable by your web server. In most cases you can fix this by simply altering the file permissions or ownership. If you have command-line access to your host try running "chmod 644 [file path]" where [file path] is one of the following paths (relative to your webroot). For more information consult the Drupal.org handbooks on file permissions.”
(long list of files, including those of /core, /modules, /themes, etc)

Nevertheless if I set the permissions of the core directory to 644 the site does not work.
How can I solve this reported warning?


texts: How to show a views count for nodes that ar not available to anonymous users

texts: I made a view which displays a count for nodes in a nodetype. But anonymous users don't have access to nodes in that type. Those users should be able to view the count. Is there a way to achieve this?


texts: REST Export Serializer adds quotation marks to my field

texts:
I'm using the REST export to expose a list of my nodes including some fields.
One of the fields is paragraphs field with subfields.

I have written a formatter for this paragraphs field that puts together some of the fields within the paragraph and renders them as a json object.

The only problem I have is that the serialiser automatically adds quotation marks, which turns my json object into a string and thus renders the formatter futile.

Can I somehow tell the serializer to not do that to my field and just print the json string without doing anything to it? I couldn't find any setting in the view that would help me. Using a "raw output" only prints the paragraph ID.

EDIT: A couple of hours later I stumbled upon this article (https://blog.karmacomputing.co.uk/drupal-8-rest-endpoint-with-entity-reference-field-set-to-unlimited-using-views/) and the REST Views module (https://www.drupal.org/project/rest_views) which basically does what I want to achieve, but unfortunately only renders the entire paragraph content as an array and doesn't allow to change the labels. A boolean field is also printed as a string.
It's close to what I need, but not quite it.


texts: Split an array of ids and save it as individual rows in table

texts: I managed to get all ids from a table using query in drupal. I got the array of ids. I'm struggling to insert all the ids in another table as individual rows. As Im new to the drupal concepts,its very difficult for me to figure it out. Any help is appreciable.:)


texts:
For my drupal I want an article always to have an image when it's published, however the authors do no have the rights to upload images (due to copyrighting issues, I only let this be done by a few people who have access to our photo partner, just to be sure that people don't download images from google)

So I want the image field to be required when publishing, but if I put it on required, then the authors have to fill it in during the draft as well, and they don't have the access for it.

I found the following module:

https://www.drupal.org/project/required_for_pub

But it requires a module "content" which I can't seem to find anywhere.
Does anyone have a suggestion for me?

Thank you very much


texts: Getting rid of the form validation error bubble in Panopoly

texts:
In Panopoly, errors that display with form_set_error() do not display in a block at the top of the page the way they normally do in Drupal. Instead they display in a floating popup that looks like a speech bubble.

How do I get rid of this bubble? It sounds silly but I can't figure out how to get rid of it and make it use the normal Drupal styling for validation errors.


texts: Drupal 7 theme similar to Wordpress Twenty Fourteen theme?

texts:
I'm looking for a Drupal 7 theme similar to the wordpress theme Twenty Fourteen. The main factors that I would like to find in a drupal theme are

the image grid for posts similar to the grid pictured on the theme page
the menu locked into the side
responsive

I was hoping to find something with as little modification needed as possible, but I'm not opposed to creating a subtheme and doing some customization. I tried searching some drupal theme repositories like the offerings available on themeforest and template monster but I haven't found anything that caught my eye.


texts:
I've developed a module which generates and displays dynamic content.
The title of the page is also generated dynamically in the controller as show below:

if ($route = $request->attributes->get(\Symfony\Cmf\Component\Routing\RouteObjectInterface::ROUTE_OBJECT)) {
  $route->setDefault('_title', strval($title))
}

This provoques each title is marked as untranslated text and fills the locales_source table.

I tried to use this line to stop this

$route->setDefault('_disable_route_normalizer', TRUE)

but it doesn't work.

And I tried to use

['#title' => $title]

and it doesn't work.

How to avoid this?


texts: How do I add a class on a "checkboxes" element's option?

texts:
I have an exposed field with a "checkboxes" field, that I need to theme by adding (and removing) Drupal's default classes. I found close to nothing about how to do that, excepted this answer.
So, I did the following thing:
function MY_THEME_preprocess_form_element(array $variables) {
  $elements = $variables['element'];
  if ($elements['#type'] == 'checkbox' && strpos($elements['#attributes']['id'], 'field-news-tag')) {
    $variables['element']['#attributes']['class'][] = 'c-tag-filters__item__input';
  }
}

I had to use strpos() because the checkboxes are related to a taxonomy term, so the id is different, with the taxonomy term id added at the end. My code, as is, doesn't return any error but no class is added to the checkbox.
Am I on the right track? Or is this doable only from the hook_form_alter() ?
Thank you in advance.


texts: Customize the output style of a view field

texts:
I have a view block, where fields are added in the table.
I followed below steps to customize the output fields:

Navigate to the edit screen for a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
In the Fields section, click a field. The Configure Field dialog box displays.
Click Style Settings.
Enabled the following options:
        Customize Field HTML
Specified the HTML element <div> to wrap around the item. and clicked on Create a CSS Class and specified a class name.
disabled the Add Default Classes option.
Clicked on Apply.

The problem is, the specified class name in step no. 5. got added to the corresponding <td> of the view table and not to the selected html element <div>

How to add class name for the specified HTML element <div> ?


texts: How do I access the parameters fields of hook_mail_alter(&$message)?

texts:
I am using hook_mail_alter in drupal 8 to alter the email messages sent  through contact form .
How can I access $message['params'] fields in hook_mail_alter()?

I am getting the following values with print_r(array_keys($message['params']));.

Array (
  [0] => contact_message
  [1] => sender
  [2] => contact_form
)

Can anyone suggest how I access the contact form fields?

When I access the values with print_r($message['params']['contact_form']);die; I don't get anything displayed.


texts: Use custom content entity theme suggestions in own module?

texts:
I have a custom content entity called 'offer'.
I've added template_preprocess_offer() and offer_theme() to the  offer.module file.
function offer_theme($existing, $type, $theme, $path) {
  return [
    'offer' => [
      'render element' => 'elements',
    ],
  ];
}

function template_preprocess_offer(array &$variables) {
  foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
  }
}

In modules/custom/offer/templates/offer.twig.html, I successfully render the entity.
Next, I've added theme suggestions because I've added a view mode 'full' via the UI.
/**
 * Adds template possibility for view modes
 * Implements hook_provider_theme_suggestions_hook_alter
 */
function offer_theme_suggestions_offer_alter( array &$suggestions, array $vars, $hook ) {
  if ( $offer = $vars['elements']['#offer'] ) {
    if (isset($vars['elements']['#view_mode'])) {
      $suggestions[] = 'offer__' . $vars['elements']['#view_mode'];
    }
  }
}

After clearing caches:
<!-- THEME DEBUG --> <!-- THEME HOOK: 'offer' --> <!-- FILE NAME SUGGESTIONS: * offer--full.html.twig x offer.html.twig --> <!-- BEGIN OUTPUT from 'modules/custom/offer/templates/offer.html.twig' -->

This only works if I place a offer--full.html.twig inside the theme's templates folder. It doesn't work in the custom module template folder. Inside modules/custom/offer/templates, the template file with the view mode won't get used. While the template suggestions suggests offer--full.html.twig, offer.html.twig is used instead.
Why does it happen? How can I solve it?
Edit: I'm on drupal 9. My custom entity has no bundles. I've made sure the id inside @ContentEntityType is "offer".


texts: how to Remove "Add new Content" from the Main page

texts:
I have a front page in which blocks and some contents (ie story) were displayed.
These stories were marked as "Promoted to front page"; later, I unchecked them.
These stories are now gone, yet the blocks were present.

Now I have the following content on my front page:

"No front page content has been created yet.

Add new content"

How do I remove this content or text?


texts:
Since good 10 years I work with Views in Drupal. Seems I am just to stupid to get it :)
I tried really every combination but I am not able to put out a working block view with articles, which are referenced to the current node.

We have two node types:

- Articles
  -  field (relationship to product node)
- Products

Some articles have a relationship (node reference field) to products. When on the node page the view blog should output every 'article', that has a relationship to the current node (product).

I tried to add a contextual filter (node id from url) and a relationship (field_node_reference).
The contextual filter uses then this relationship. However, I know this is not enough.

Results are 0
Which steps are involved? What have I forgotten?

Thanks


texts: Editing field twig template for taxonomy term

texts:
I would like to edit field.html.twig for taxonomy-term.html.twig. I've tried field--taxonomy-term.html.twig and a bunch of other options, none of them seem to work. What is the correct naming convention?

Clarification: I mean the template for fields used on the taxonomy term page, not the fields used in content type to reference a taxonomy.


texts: How do I disable/enable the Advanced Content Filtering (ACF) in CKEditor 4.8.0?

texts:
Please tolerate me for asking such a question.  All the answers I found are for Drupal 7.  There is barely any talk on this issue for Drupal 8.  I am a beginner in Drupal and I am not a programming oriented person.  However, I am determined to find the solution to make this work.

It seems the most straight forward solution is to add the following line of setting:

CKEDITOR.config.allowedContent = true;

However, where should I add it in Drupal 8?  There's no (ckeditor).config.js, as far as I can find within my Drupal's installation directories.  How or where should I proceed?  Does this matter need coding in order to achieve my goal in Drupal 8?

Many of the CSS classes and scripts embedded within the content are stripped off by the CKEditor either after saving or works in the initial save but are then stripped after editing the content the second time.

If you have the patient for someone like me, please help.  Much appreciated!  If I am tackling the problem in a completely wrong direction, please advise as well.  Thank you!


texts: Access view exposed filter arguments in field view

texts:
My problem is that I can't access $view->filter['my_filter_field'] from my views-view-fields.tpl.php file.

In views-view.tpl.php I get my correct View object with the arguments sent via AJAX as exposed filter parameters, but how can I get this information without using the field's template file?


texts: I have a webform which is built in English. I need to add two more languages. Is that possible to display many languages in webform?


texts: How to stop redirecting to newest URL after updating a node

texts:
I have setup 2 aliases for each node of a content type called "property". The first alias is like example.com/texas/village-apartments and the second is example.com/texas/corp/village-apartments.

When you go to the second URL (the one with "corp") you see different pieces of information on the page, different buttons, menus and other items that do not really belong on a non-corp page.

Pathauto handles creating the first alias (without "corp"), then I manually created the corp aliases by going to admin/config/search/path/add and added each one.

This all works fine except for when I go to edit the node and add text or a picture or whatever. When I click save, I am redirected to the URL with corp and of course see different menus, blocks, etc.

Is there any way to configure things so that I am redirected back to the same URL path I was on when I clicked 'edit'?

Tim


texts: How can I make someone else group manager of a group I've created?

texts:
I created a few groups and populated them with users. I also selected an admin per group. I don't want to appear on the OG members view of the group anymore, therefore I want to remove myself from the group. I find this impossible.
Probably, because I'm the group manager. How can I change the group manager to that admin?


texts: Which files do I need to edit to alter webform #states with hook_form_alter?

texts:
I need to create #states conditions between either the fields in any one element in a webform or across other elements in the same form. I'd hoped I could do it via the WF yaml editor but it seems I couldn't [1].  As per @jrockowitz 's comment on the attached link #1, I

  might be able to use a form alter hook to add the needed #states

I am not a developer but it seems with drupal 8+ I do need to learn to start to be one and that's on my list for sure. I'd love to be able to contribute something to Drupal and especially webform but I find the learning process intimidating especially with the lack of "beginner-type" tutorials at least when it comes to creating custom modules with more than "hello world!".

For now, I need to know the steps I need to follow @jrockowitz 's advice and use hook_form_alter to serve my goal. My understanding is that could be done either on a theme level or custom module level (please correct me if wrong) and since I'm more comfortable with the theme way and I feel it's simpler for someone like me, I like to know (at least):

which files ( other than MYTHEME.theme) I need to edit or/and create to start with and
what info do I need to look for and study so I can do the job and begin my learning journey.
I learn best by example and so any extra clear a-b-c type tips to get me started is greatly valued if any.

If the custom module way is more advisable or the only way:

What is the minimal skeleton of a custom module that I need to have for the purpose.
What do I need to study to learn how to create such a module.

(I'm not sure if the last question should be a separate question so please forgive my newbie status here but I promise I've done my best)

Thanks so much everyone

A sample of what I want to achieve:

some_question:
  '#type': tableselect
  '#title': 'some question'
  '#options':
    q1: 'q1 (hide if q2 is checked)'
    q2: 'q2 (hide if q1 is checked)'
    q3: q3
    q4: q4
    q5: q5
    q6: q6
    q7: q7

Related links:

[1] Why isn't my custom Form API #states applied in my webform yaml editor working?

[2] https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_alter/8.7.x

[3] https://www.jrockowitz.com/blog/add-ons


texts: Export user's passwords from one sites to another

texts:
I queried users table from an old site and saved those users in a new site, excluding passwords (every user has default 'password' password). Now I'd like to get hashed passwords from the old site and copy them to the new site's users table. Both sites are Drupal 7 and have the same hash salt string in settings.php.

I noticed all users with the same password 'password' have different hashed passwords. Therefore I am wondering, will be users able to log in to the new site with their original passwords after replacing current hashed 'password' password with the original hashed passwords from the old site?


texts: moving *.tpl into "templates" folder, but Drupal does not recognize them. How?

texts:
I am building a custom theme. Currently, I put all the overridden *.tpl files under the theme root folder; it would be more clean and meaningful to put those files under "mytheme/templates", but Drupal does not recognize them after I move them. (I did clear the cache.)

Did I miss any steps?


texts: How to use URL as a filter in view module?

texts:
I asked a question here and now I am going to create a view that the view take the URL and use it as a filter.

and I want to have a the view by a dynamic filter use the URL path and show the result by different type something like sport, economy, etc.

Pathauto: news/[node:news_type]/[node:title]

I want to use [node:news_type] in my filter


texts:
I`m trying to find a way to import the userprofile information of drupal to a external soap server, everytime a user is created, updated or deleted.

I figured out that the rules module should be at the basis for what i want to do.

I also found the webservice client module which seems to be able to handle soap requests(don't get it yet how this module exactly works).

But i can't wrap my fingers around on how to use these two things to send the userprofile information in xml to external soap server.

Any idea's, tips, suggestions would be welcome! :)


texts: Override a method implemented by a third-party module

texts:
I want to change something in a method implemented in a third-party module without hacking the module itself, but overriding the method in my module.

The third-party module is views_data_export. I want to change the attachtTo() method in the Drupal\views_data_export\Plugin\views\style\DataExport class.

public function attachTo(array &$build, $display_id, Url $url, $title) {
  // @todo This mostly hard-codes CSV handling. Figure out how to abstract.

  $url_options = [];
  $input = $this->view->getExposedInput();
  if ($input) {
    $url_options['query'] = $input;
  }
  $url_options['absolute'] = TRUE;

  if (!empty($this->options['formats'])) {
    $url_options['query']['_format'] = reset($this->options['formats']);
  }

  $url = $url->setOptions($url_options)->toString();

  // Add the CSV icon to the view.
  $type = $this->displayHandler->getContentType();
  $this->view->feedIcons[] = [
    '#theme' => 'feed_icon',
    '#url' => $url,
    '#title' => $title,
    '#theme_wrappers' => [
      'container' => [
        '#attributes' => [
          'class' => [
            Html::cleanCssIdentifier($type) . '-feed',
            'views-data-export-feed',
          ],
        ],
      ],
    ],
    '#attached' => [
      'library' => [
        'views_data_export/views_data_export',
      ],
    ],
  ];

  // Attach a link to the CSV feed, which is an alternate representation.
  $build['#attached']['html_head_link'][][] = [
    'rel' => 'alternate',
    'type' => $this->displayHandler->getMimeType(),
    'title' => $title,
    'href' => $url,
  ];
}

I want to append other parameters in $url_options, and apply some logic using the module views_data_export, without writing it directly.

How can I achieve this?


texts: How to configure D7 so files get uploaded to a different server

texts: In Drupal 7, the default path for uploading is set in the File system options in the Public file system path.  Is it possible to specify a different server in this path?  I have a Drupal 7 web site we are developing that is going to have about 20k files and I'd like to put them on a different server than the web server.  If not possible to specify a different server than are there any user contributed modules that can handle this?


texts: hook_node_load doesn't work when node is loaded by REST api

texts:
On the web, everything works fine (and I even checked the node values with krumo), when I tried fetching the json equivalent of the node using REST api, it's as if the hook_node_load() didn't run.

If in case you are curious what does my hook_node_load() function do, it manipulates a custom field value(that was initially saved) and change it into equivalent value from my custom database table
tl;dr - I changed the value of a field

I would like some help/tips/guide in anyway how can I execute my hook function so I can manipulate the data outputs given from REST api.

ps: I just started with drupal a month ago, if by chance I am approaching this the wrong way and should be using other hook function instead, please  tell me.

Thank you


texts:
I am using the 'Advanced Forum' module with Drupal 7, in conjunction with the 'pathauto' module. I would like to include the parent forum, if  not the container of the  parent forum as well, in the URL of the forum topic, so it is like: forums/catergory/forum/topic-title. However, I can not seem to find compatible tokens/replacement patterns in order to do so, so I was hoping somebody here could provide a solution for me, please!?

So far all I have is: forums/topic-title!


texts: How to get and display menu items except the parent item?

texts:
Let's say my menu tree is like below:

Parent

Sub-Parent

Child

I want to get the Sub-Parent title and all child's title and url.

How can I do it in Drupal 8?

I have looked at this answer but it just for getting the parent, it is not the one I'm looking for.


texts:
I really tried many Solutions to get my site work on Amazon AWS. There is only one last thing i can not solve. Some of my links are still "http://"-links and i dont know how to get them right.

My Setup:

Drupal 8.6.10 running on an EC2-Instance managed via Beanstalk
the Load-Balancer is managing the access and has two open ports (http/80 and https/443) directing to the ec2-instance via http (port 80)
the ssl-certificate is configured
my domain has the correct dns-config directing to xxx.eu-central-1.elasticbeanstalk.com
settings.php includes the following lines

     $settings['reverse_proxy'] = TRUE;
     $settings['reverse_proxy_addresses'] = array($_SERVER['PROXY_ADDRESS']);
     $settings['reverse_proxy_proto_header'] = 'https';
     conf['https'] = TRUE;
     $_SERVER['HTTPS']='on';

$_SERVER['PROXY_ADDRESS'] is assgned to 'xxx.eu-central-1.elasticbeanstalk.com' by beanstalk
.htaccess includes the following lines:

     RewriteCond %{HTTPS} off
     RewriteCond %{HTTP:X-Forwarded-Proto} !https
     RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The affected places are:

in a twig: url('')
in a php-file: fileentities->url();

All other links are nicely rendered as 'https'-links. I would be really thankfull for any advice you could give me.

Best Regards,

FirstSanny


texts:
What would be the easiest way to make the Views PAGER text on a view aka first previous next etc, align center in the view?

Thank  you!


texts: Converting a left join query with empty right side to Views

texts:
On a multilingual site, I'm trying to create a view on nodes where the content should be either in the current language, or in English if no translation exists in the current language. After trying to solve this with the Views web interface for a while, I figure that what is provided for filtering is simply not sufficient.

So I'm thinking of adding module code, to extend Views to support this particular use case.

Starting from then end result, this is what the constructed query should look like:

select node.* from {node} node  -- provided by Views
-- join:
left join {node} tnode on node.tnid = tnode.tnid and tnode.tnid > 0 and tnode.language = ***CURRENT_LANGUAGE***
-- condition:
where (node.language = ***CURRENT_LANGUAGE*** or node.language='en' and tnode.nid is null)

I'm assuming that ***CURRENT_LANGUAGE*** is a macro that will be replaced by the actual value of the current language; 'en' might be an argument, chosen in the admin interface, but that is not really important.

But now I'm stuck on how to actually code this up for Views.

Any help, including alternative approaches, welcome.


texts: email address not appearing in user profile

texts: I am using drupal 7 default user_register module, when a user registers with all the required fields, it successfully registers but when I click that user in people> tab his/her profile is displayed in which email is not appearing as you can see in the screen shot. Whereas when I clicked on edit link on the right side of that user email address exists.


texts: Redirect unauthorized user to login page

texts: I need to show only home page and some inner pages (which i will create using a common content type) to the anonymous user. I need to redirect all other access to home page where i added a login box. Is there a way to do it.


texts: Can I use --remote-host without a site-alias?

texts:
I am trying to use Drush to execute some commands as part of my CI/CD workflow. The problem is that due to it's flexibility I want to avoid using site aliases which would basically mean writing temporary files during the build process (I really want to avoid that).

However, I've been trying to use --remote-host, --remote-user and --root in-line (e.g. 'drush --remote-host=example.com --remote-user=exampleuser --root=/var/www/example.com') without success. I did some debugging with XDebug and it seems that even though Drush initially picks up the provided command-line options it later purges them again/overrides them at some point. Is that a Drush Bug or am I doing something wrong / missing something?

Will do some further debugging now but maybe someone knows the answer ;).


texts: Using #states to disable a field collection field

texts:
I am trying to disable a date field's second value, inside a field collection, but it isn't working.

My hook_form_alter has this:

  $form['field_certification']['und'][0]['field_validity']['und'][0]['#states'] = array(
        'disabled' => array(
          'input[name="field_certification[und][0][field_auto_calculate_validity][und]"]' => array('checked' => TRUE),
        ),
      );

The HTML for the date field is here:

<input class="date-clear form-text hasDatepicker date-popup-init" type="text" id="edit-field-certification-und-0-field-validity-und-0-value2-datepicker-popup-0" name="field_certification[und][0][field_validity][und][0][value2][date]" value="07/23/2014" size="20" maxlength="30">

The checkbox is here:

<input type="checkbox" id="edit-field-certification-und-0-field-auto-calculate-validity-und" name="field_certification[und][0][field_auto_calculate_validity][und]" value="1" class="form-checkbox">

Could it be because I'm not specifically selecting the (second) value of the date field?


texts: Should you use multi-site or multiple Drupal instances to host different content for subpath sites?

texts:
I want to host a Drupal 7 site that effectively has four different silos of information. The architecture will look like this:

example.com - Blog site with content about the parent company
example.com/foo - Informational site about sub-company "foo"
example.com/bar - Informational site about sub-company "bar"
example.com/fubar - Informational site about sub-company "fubar"

The top site will pretty much be a blog with navigational elements directing people to the sub-sites. The three sub-sites will essentially be the same structure, but have slightly different CSS (different color schemes) and have different information. Logins can be separate, because we actually want to be able to peel away one of the subsites to sell as an asset, if need be.

I'm wondering what the best way to do this would be. Multi-site should keep it easy to update, because the modules and core should be upgraded in lockstep. However, I can't seem to get multi-site to work for these subpaths.

Is multi-site the best way to go here? Or should I just host four different instances of Drupal, one for each site?

(Note, I saw a question about subsites just after I posted this, but it seems that subsites is only available for Drupal 6. Please correct me if that is wrong!)


texts:
I want to create a button on each node to a donation page. The button needs to send the title of the node to that page, I have managed to do this.

I have a product type donation. I modify the form price with line item and setup a form where you can select different donations values.

The problem is that I need to find a way to include that title in the donation form so It can be passed to cart.

I have tried commerce add to cart function to alter that, but it doesn't work.


texts: How to change value a field of preproces

texts:
I am new to PHP and Drupal. I have content type with a type list text field "Infraestructura". The values and labels are these:

agua | Agua de pozo
incendios | sistema contra incendios
electricidad |Electricidad

The quantity options is unlimited, is to say, the user can select unlimited options (Checkbox)
How I do to change the output for this field as image?
I need  that output for this field  show an image , example:

for: agua | agua =>
for: incendios | sistema contra incendios  =>
for: electricidad |Electricidad  =>

I'm thinking to do this using preprocess, but I not have idea. Could anyone help me please?
Here is another way to explain what I want to do:


texts: How to redirect exposed view filter form submission?

texts:
I have a view which is displayed from a theme method using views_get_view() and view::preview (see below). This view has an exposed filter. Unfortunately the exposed filter form does not work. When I submit the form it calls the wrong URL.

The wrong URL looks like this

http://domain?date_start=12

For comparison, the link of the sortable columns (which work as expected) does look like this:

http://domain/myselfcare/communications?order=destination&sort=asc&date_start=12

How can I fix this?

function theme_win_care_communications_page( $customer, $form, $form_state) {
  global $user;
  $output = '';
  watchdog('win_care', 'communications_page user=' . $user->uid . ', cust=' . $customer->id);
  $communications_view = views_get_view('drp_communications');
  $output .= $communications_view->preview('default', array($user->uid));

  // add an explanatory text
  if ($customer->reseller_id==33) { // mbudget only
    $output .= t('Note M-Budget: tariff is a function of the call time (in lots of 10 cents).');
  }
  else {
    $output .= t('Note: setup fee of 0.50 per call, minute rate according to current tariffs');
  }

  return $output;
}


texts: How to (reliably) add jQuery plugin to Drupal

texts:
This question has been asked, but not really answered. It is NOT as simple as has been suggested in

This response

If it were, there would be no reason to have a module like
jquery_plugin

Simply putting a line in the theme info file like

scripts[] = js/jquery.scrollme.js

Does not work. In the case above, the script does actually show up on the rendered page, but the function(s) within it result in "undefined".

In the case of scrollme.js, are there dependencies that need to be included?

I fought this thing with hoverintent for a day or two, and finally just punted and added the module "hoverintent".  And incidentally, the fact that the hoverintent module exists suggests strongly that one can not simply throw the hoverintent.js code into a directory and load it with a script from the theme info file.

Any experienced direction would be really appreciated!


texts:
I'm trying to create a node via services 3 in Drupal 7. The node os created, but when I try to pass the location parameters in, it does not work. If I pass an lid that already exists, it seems to reference that location; if I try to pass a new lid, the information is not registered.

Is there such thing as a location resource for the services module? THis is the JSON string I am using.

{
"title":"test",
"type":"test_type",
"locations":[
      {
         "lid":"4",
         "name":"",
         "street":"",
         "additional":"",
         "city":"",
         "province":"",
         "postal_code":"",
         "country":"us",
         "latitude":"40.663062",
         "longitude":"-73.969760",
         "source":"1",
         "is_primary":"0",
          "locpick":{
            "user_latitude":"40.663061",
            "user_longitude":"-73.969760"
         },
         "province_name":"",
         "country_name":"United States"
      }
   ],
}


texts: Programmatically geting teaser of a field other than body

texts:
I need to get teaser of a custom field. I used the below code that I used for body.

$fieldContent = field_get_items('node', $nodeObj, 'my_field_name');
$teaser = field_view_value('node', $nodeObj, 'my_field_name', $fieldContent[0],'teaser');
//Below line prints an empty array
print_r($teaser);
$teaser   = drupal_render($teaser);

When I try the above code for the field body it works. What the code expects from the field to display teaser? How to fix this?


texts: When creating content with new term, show all term fields for input also

texts:
Taxonomy terms are clubs and there are many in vocabulry, with fields to enter address, long/lat etc.

User adds content Concert and can pick a club (terms) from Simple Hierarchical select.
If club is not in vocabulary user can add new term. While doing this he should also be able to input fields for new term (address, long/lat) while creating content.

How can i achieve this ?


texts:
I have created a view of page and called events (content types) which are showing correctly in Admin/Front then I add contextual filter year which is working correctly if I enter year eg: 2017.

I have hack template created my own template file (page--events.html.twig) and included view {{ drupal_view('events','page_1') }}

All events are showing instead 2017 if I hit url drupal.local/events/2017 so here is problem contextual filter not worked on page.


texts:
In Drupal I've scheduled, on the future, some e-mail, using rules schedule module. Now I want to force the delivery, before the scheduled time, to check the text of e-mail.
Is this is possible?


texts:
Can anyone help me with the following?

I want to let users of my site book a visit to my office by clicking on the time or on a button somewhere on the calendar day view.

This is the scenario:

a. The user can navigate to an empty calendar showing times from 9 am to 6pm (9.00 - 10.00, 10.00 - 11.00 etc). The user can see available times and book the hour he wants.

b. For every blank hour the calendar says "Available Time" and when an hour is booked says "Unavailable".

c. The user clicks on the desired hour and books it.

Though I said a lot, the question is simple.

This functionality is exactly the opposite from registering to an event, because the event is created by the user that books the hour. I mean that there are not events that the user registers for.

So how can the user do this and the show the hour as booked?


texts: What is the difference between "Autocomplete" and "Autocomplete (Tags style)" field widget type?

texts: What is the difference between an "autocomplete" and an "autocomplete (Tags style)" widget. These options are present when I add an entity reference field for example.


texts:
I have a site where menus are created using Site building -> Menus -> List menus -> Primary links -> Add item option. Some of them have sub-menus under them. I want to retrieve these menus from a REST client. How do I expose these menus from my service endpoint?

I admit I am an absolute beginner in drupal.


texts: Override specific routing from a core module

texts:
I want to stop anonymous users being able to access a specific set of routes offered by the core/forum module.

specifically:

forum.index:
  path: '/forum'
defaults:
  _controller: '\Drupal\forum\Controller\ForumController::forumIndex'
  _title: 'Forums'
requirements:
  _permission: 'access content'

and

forum.page:
  path: '/forum/{taxonomy_term}'
defaults:
  _controller: '\Drupal\forum\Controller\ForumController::forumPage'
  _title_callback: '\Drupal\taxonomy\Controller\TaxonomyController::termTitle'
requirements:
  _permission: 'access content'

I just need to add: _user_is_logged_in: 'TRUE' to the routes' requirements.

How does one do this without 'hacking' core?

I have alternative routes for the above in my own module - with different names and controllers and in an ideal word I would also wish to redirect both those routes through my own. However, for a start I will take being able to stop anonymous users seeing my forums.


texts: How to hide a field in a views row if the row is about content type article?

texts:
I have a view that is showing all my content types. What I want is to hide a certain field in its row if the content type on this particular views row has a content type of Article.

How can I do that?


texts: Create entities when user account created

texts: I am looking for a hook to fire off an Entity creation method (for an unrelated item that pertains to the user) when a user registers for the site. I'm divided between hook_form_user_register_form_alter and hook_user_insert. What's the best approach here, and i'm wondering which one is the best to use here.


texts: Can I use Simpletest to test site upgrades?

texts: Going through upgrades it's often a bit tedious to test site functionality such as creating and editing nodes. Can Simpletest perform this kind of functionality? Or do I need a solution like Selenium?


texts: Attach a simple custom handler to a Webform

texts:
I'm trying to create a custom webform handler. I'd like to be able to attach my handler to any webform and have it display the message 'xyz' when the (multi step wizard) form is finally submitted. I have this file in my custom module at:  my_module/src/Plugin/WebformHandler/PostWebformHandler.php.

<?php

namespace Drupal\test_b\Plugin\WebformHandler;

use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Webform test b handler.
 *
 * @WebformHandler(
 *   id = "test_b",
 *   label = @Translation("Test B"),
 *   category = @Translation("Test B"),
 *   description = @Translation("Test B webform submission handler."),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL,
 * )
 */
class TestBWebformHandler extends WebformHandlerBase {

  /**
   * {@inheritdoc}
   */
  public function preSave(WebformSubmissionInterface $webform_submission) {
    \Drupal::messenger()->addMessage(t('xyz'));
  }

}

On navigating to my Webform settings, I see:

but when I click Add handler for Test B it does not attach to my form handlers?


texts:
I am very new to Drupal. I have an html form and I want to create a module that take the html of the form and create a table in the database and saves the form values in database.

what i have done i have created a form with form api (with buildForm method) my form is being rendered and i have converted it into Twig template (it is being shown in twig template), but first my CSS is not getting loaded.

My library file: mymodulename.libraries.yml

bootstrap:
  version: 1.x
  css:
    css/bootstrap.min.css: {}
  js:
    js/bootstrap.min.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once

global-components:
  Version: 1.x
  css:
    css/baselayout.css: {}
    css/form.css: {}
    css/wisdom.css: {}

  js:
    js/jquery.smartmenus.min.js: {}
    js/custom.js: {}
  dependencies:
    - core/jquery
    - core/drupal.ajax
    - core/drupal
    - core/drupalSettings
    - core/jquery.once


texts: "Redirect Loop" when creating a multisite

texts:
I know there are a few questions related to this one, yet I haven't been able to answer mine.

I want to develop 2 websites pointing to the same Drupal core files,

so :

drupal1.example.com should point /www/dev/sites/drupal1.example.com drupal2.example.com should point to /www/dev/sites/drupal2.example.com

I've created both subdomains to point to /www/dev/ folder.
I've put settings.php in drupal1.example.com and default.settings.php in drupal2.example.com
When I load drupal2.example.com, I get a "Redirect Loop" error.

Do you know what I'm doing wrong ?

Thanks!

ANSWER :

When there was no settings.php file in my sites/drupal2.example.com folder, it showed the drupal1.example.com website.

When there was a settings.php file in my sites/drupal2.example.com folder, it got me an infinite loop.

So I modified the settings.php in sites/drupal2.example.com folder to connect to a different empty databse, but then I got an error "Base table or view not found: 1146" then another error upon refresh "error: Class 'SelectQueryExtender' not found".

It seemed as though the installer had a hard time loading the 2nd instance of Drupal since there were no tables in the DB.

So I imported DB #1 into DB #2 and it worked.  I could change the theme in drupal2.example.com and I still had the old theme in drupal1.example.com.

The only downside is that I have to delete the content types, nodes, menus, etc ... in my drupal2 but I least it's working!


texts: To add a value entered in a field to select list

texts:
I have a field and select list. When a value is entered in the field ,if that value is  not present in the select list then i want to append that value in the select list.
how can i acheive this?


texts: Is there a recognized practice for keeping security details in files excluded from version control?

texts:
As settings.php also contains the database connection details and the site key among others, it is excluded from version control in .gitignore.

But there some modules, APC for instance that require some of their configuration to be added to settings.php.

This means that some settings necessary for the site to run correctly may not be present in a site created from a git clone.

Is there a standard practice for dealing with this, ie enabling settings.php for source control and include-ing the security and other settings from different files, or vice versa?


texts:
I am trying to do something a priori simple.

I wish in a template to add a link to the login page.

I found this documentation, so I know how to link to a node etc. but to a url type "/ login", I did not find.

Do you know how to do it ?


texts: Prevent User from checking out without email on order

texts:
I am using drupal commerce and sometimes a truly anonymous order without email comes through (phone is required so we always call when it happens, its super super rare). Is there a way to not allow the payment process button to proceed if an email hasn't been attached to anonymous cart? I use commerce login step (https://www.drupal.org/project/commerce_login_step) to show a simple login page before proceeding. (BTW Email is required on account panel so I'm not sure how they get through)

With that said I made a module to try and figure this out if they get past the commerce login step :

$uid = 0; // anon
$product_count = 0;
$product_quantity_count = 0;

$cart = commerce_cart_order_load($user->uid);
if($cart->uid == 0 && empty($cart->mail)){
   dsm("Hey there is no email here!");
}

However is there a way to add to the checkout validation hook to see if "There is no email on the order, do not allow them to checkout and process payment?"


texts: How can I add classes to rows depending on the loop index?

texts:
I have received a design where they want to have the latest three articles links put on the top of the front page (over their respective images) so that the first is taking left half of the page and second and third to split (vertically) the right half top.
I thought that view-view--latest-articles.html.twig would solve the problem elegantly like this:

{% for row in rows %}
    {% if loop.index == 1 %}

          {{ row }}

    {% elseif loop.index==2 %}
    ...   // dull and inelegant code dismissed
    {% endif %}
{% endfor %}

But if I put debugging code for loop.index into the code it only shows the index once and splurts out all the rows after it, never minding my if. It still shows the index once, so I know it IS using the template.
Am I missing something or trying just to it in a wrong way?


texts:
I would like to revise the default new user registration form in Drupal 7.
Rather than to requst "username", I want to request "full name" with helper instructions to enter the text "username is your full name as you would normally use it."

There may be some other minor formatting changes I would like to make as well.

I cannot find an admin menu item to access anything relating to this question. And I am unable to locate a file within any director that has any text that would indicate it is the source for the new user registration form.

I realize this is a bit unconventional, however it is useful for our needs. I am aware of a module that allows the input of First Name / Last Name, but in processing it changes the input to first initial/lastname, ie Tom Thumb = username of "tthumb". The module "Realname Registration" would be just what I am looking for if it would only translate the username the same as the input.

That wouldn't necessarily solve the other formatting edits, but I would be very happy just to be able to manually edit the registration form help text under the username field, instructing the new user to register using thier real name.

Thanks for any help that you can provide.

J.M.


texts:
I would like to have a reference to a comment in my node detail.

For example when I create a node of content type = Proposal and someone comments with a good argument I would like to add the argument in my node body and add a reference to the comment that suggested the argument.

I have no clue on how to start with this, google didn't help me much either. Could this be possible to do?


texts: Change Drush memory_limit on shared host

texts:
I've got problem using drush on shared host.

drush status shows:

   Drush version          :  8.0-dev

and when I run:

   drush php-eval "phpinfo()" | grep memory

It reporsts:

   memory_limit => 1024M => 1024M

Which is quite big

But whenever I run drush cc all (this is D7 site) it  with:

   Fatal error: Out of memory (allocated 61341696) (tried to allocate 79 bytes) in .../public_html/includes/registry.inc on line 41

I created drush.ini file in .drush directory and whatever I put there is reported by drush and drush status shows fail as loaded but memory limit does not go away.

Is it possible this error to come from drush version or what else could I ask hosting provider to change or check?

Edit:
When I add drush.ini file  in .drush directory with following in it:

memory_limit = 256M

and drush status

PHP executable         :  /usr/local/php56/bin/php-cli
 PHP configuration      :  /usr/local/php56/lib/php.ini
                           /home/tennist/.drush/drush.ini
 PHP OS                 :  Linux
 Drush script           :  /chroot/drush/drush.php
 Drush version          :  8.0-dev
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

In /usr/local/php56/lib/php.ini  memory_limit = 1024M

In /home/tesnnist/.drush/drush.ini memory_limit = 256M

the command drush php-eval "phpinfo()" | grep memory reports:

[2] => --php-options=-d memory_limit="256M"

And after this drush cc all also fails when reaching 62M limit.


texts: Programmatically update an entity reference field

texts:
I know I can update (or set a value for) an entity reference field in Drupal 7 with code similar to the following.

 $node['field_code_used_by'][LANGUAGE_NONE][0]['target_id'] = $id;

I want to programmatically set a value for my user entity reference field in Drupal 8.

I tried with $node->field_code_used_by->setValue(1); and $node->field_code_used_by->entity->value = 1; but neither of them worked.

How can I set the value for an entity reference field?


texts:
I am creating a Student portal in my project.

I am adding student by using content type.

That i gave title as "ADD STUDENT" as a Content name, but it shows "Create ADD STUDENT".

Help me to show the tile as "ADD STUDENT"

Here the [Key Personnel] Comes as [Create Key Personnel], i just want it as [Key Personnel]


texts:
I have created a dropdown menu using smartmenus module, now I've got a design request asking me to add an image to each parent item. Here's the idea:

My first approach was to try with Menu Items Extra and Simple menu icons but the images are not rendered. So I thought that this could be related to the menu module I've been working with so I tried with Superfish and Megamenu. But again it didn't work.
I must say that Megamenu was the closest one but since it requires Font Awesome Icons I cannot use my designer's icons with this module.
My last try was to add a class to each parent menu link with Menu Link Attributes so I could add the images via CSS. The huge problem with this approach is that if I replace the parent menu item name with an image it will also appear on mobile making the menu to look massive.
Any ideas on how to add the images?


texts: How to set a field value before importing nodes using feeds module

texts:
I am importing nodes using Feeds module. I have an Entity reference field in my content type which is being generated by Views.

I need the users to select the entity reference field value before starting the import.

My content type is "Student" and the entity reference field is "Course". User Role "Teacher" should import students and select the "course" before importing. (Adding the course ID or Name in the excel sheet is not accepted by my client ).

please suggest.
thanks


texts: How to attach media item created during migration to media field in node

texts:
I am migrating content from Drupal 7 to Drupal 8.
There is an audio field that I am currently moving to media via a custom process during migration.

When I get the id of the new media created I can't seem to get it to attach to my new media reference field in the also newly created node.

Can anyone tell me what is wrong with the import below?

field_audio_fileinfo:
-
  plugin: sub_process
  source: field_audio_fileinfo
  process:
    target_id:
      -
        plugin: migration_lookup
        method: process
        source: fid
        migration: upgrade_d7_file
      -
        plugin: my_custom_process
        destination: field_media_audio

In my custom process I can save the media and get it's ID via:

$media_id = $audio_media->id();
$arr[] = array(
  'target_id' => $media_id,
  'display' => NULL,
  'description' => NULL
);
return $arr;

But it doesn't seem to populate the destination field.

This is also the case if I just return the ID directly from the process.


texts:
I'm trying to create a query like this:

SELECT DISTINCT ON (field1, field2) field1, field2, field3 FROM table1

But can't figure out how to get DISTINCT ON narrowed down to a few fields in Drupal like that. Calling $query->distinct() just seems to structure the query like this:

SELECT DISTINCT field1, field2, field3 FROM table1

I did figure out a hacky way to add what I want by adding an expression before I add any fields like this:

$query->addExpression('DISTINCT ON (field1, field2) field1', 'field1');

Which creates:

SELECT DISTINCT ON (field1, field2) field1 as field1, field2, field3 FROM table1

I'm looking for a better way to this ?


texts: Entityfrom spam protection module without captcha

texts: Is there a module which I can use with entity forms without needing captcha field?


texts: Installing Drupal module requires ftp access - macOS localhost

texts:
I have Drupal 8 running on localhost on macOS Catalina. When I try to install a module, I get prompted to enter ftp credentials (which I don't know). See the following screenshot.

I've seen solutions that suggest this ftp prompt is caused by a permission issue in sites/default folder and can be fixed with chown www-data sites/default or chown apache sites/default for linux but those commands on a mac throw 'chown: www-data: illegal user name' or 'chown: apache: illegal user name' error. What do I need to do to enable installing modules/themes without being prompted for ftp?
EDIT
I'm specifically asking about installing modules by the url method from the admin interface.


texts:
Searching is not working when the search string contains special characters.

For example, when we search &$#%^@, we are redirected to http://example.com/search/node/&$#%^@. There, if I search with some other text (e.g. test) we are still at http://example.com/search/node/&$#%^@.

I tried in different websites which are using the core Search module. It is failing in all websites.