texts: How to fetch fields in a view in the overrided twig file?

texts:
I have created a view like so:

I have written a twig file for it named
views-view--employee_details--block_1.html.twig, which is placed in folder /project_name/themes/theme_name/templates/views.

I want to fetch fields from the view into
views-view--employee_details--block_1.html.twig file.

How can I do so?


texts:
I want to learn to alter node fields after a migration. I have a custom module and inside is a .inc file I use as a script that I will run once using drush eval module_load_include. I want to learn a simple task like replacing text inside all nodes body field. First I load all nodes, then search the body fields for all nodes for the word "red" than I want to replace that word with "blue" How would I write this? This is my starting point

<?php

use Drupal\Component\Utility\Html;
use \Drupal\node\Entity\Node;

function _update_node() {

// load nodes
foreach($nids as $nid) {
    $node = Node::load($nid);

// do the work  here

  $node->save();

}

Then I want to run this script once. My module name is create_content. So I can run the command.

drush eval "module_load_include('inc', 'create_content', 'create_content'); _update_node();" > debug.txt


texts: How to set Class for a particular image style?

texts:
I'm trying to add a CSS class to a particular image style, in Drupal 8. For this purpose, I'm trying to set up a template, but am open to all solutions since I know I lack knowledge (I've been teaching myself this stuff over the past couple of months).

Specifically, I want all images with the style machine name 'feature_main_960_x_640_' and field machine name of 'field_image' to include the following class during 'Full content' view mode. I would like this class to be added to the img tag.

The purpose: to have my articles' feature images to be centered when the full content is being viewed.

Specifications:
Drupal 8, theme is Bootstrap 3, using Display Suite module.

I've used Display Suite to add the Bootstrap 3's 'center-block' class. The class is added before the img tag, in a div. This doesn't center the image. I could only get the image to center when I manually added 'center-block' within img. I also used the Field Formatter Class module for this purpose and it also added the class to a div rather than img: so the problem persists.

So far, I've taken a sledgehammer to the problem and used the following template to apply the class to all images but would like to be precise in application, as mentioned above. This is the template I used:

image.html.twig

{% set classes = [
  theme.settings.image_shape ? theme.settings.image_shape,
  theme.settings.image_responsive ? 'img-responsive',
  'center-block',
] %}
<img{{ attributes.addClass(classes) }} />

Any solution?


texts: Form ID value changes, breaking the action link

texts:
I have a custom module creating a form. As the form is a bit down the page, I have added an anchor to the submit so the user sees the results without the need to scroll down
  public function getFormId() {
    return 'form_name_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state, $entity_id = NULL) {
    $form['#action'] = '#form_name_form';
    //.. rest of form removed for clarity
  }

This works and then it does not... I can see why:
<form class="form_name_form" data-drupal-selector="form_name_form" action="#form_name_form" method="post" id="form_name_form" accept-charset="UTF-8">

Becomes
<form class="form_name_form" data-drupal-selector="form_name_form-2" action="#form_name_form" method="post" id="form_name_form--2" accept-charset="UTF-8">

But I am not sure how to stop the addition of '--2' to the ID?
Or set $form['#action'] = '#form_name_form'; to the actual generated form id?


texts: How to add "open in new tab" option in CkEditor

texts:
Now, we can only add link. But our client is looking for an option in Ckeditor for adding an option to addition of "Open in NEW tab" option with Link.

Do we have any module or any trick for solution of this issue ?

OR

Do we have to alter CkEditor module ?


texts: Media library duplicating results view in ckeditor

texts:
After numerous problems on a certain website I tried a bare bones fresh install of drupal 7.5 on a subdomain with nothing but the medial library and its dependencies as well as all modules required to put the media library in the CKeditor and what I got was a brand new media library failure not yet seen...

Anyone know why the modal popup repeats the results view multiple times? 3 to be exact but you can only see 2 in this image. I followed the instructions on all components to get this far but the never ending failure of drupal continues to plague me.

update

I hadn't noticed before because of the baffling behavior, but it turns out I can't even select media from any of these repeating views. If I click one and hit submit it just returns me to the node, not updated. Right inside the modal box.

Another note, the views for media library include 3 different views - "media browser" "my files" and "media library" and if I disable any of them they do indeed disappear from the popup, which I could live with if any of the remaining views actually did anything. I applaud the champions who wrote this.

Final Update

With Kevin's help we figured it out. Basically we had to run with wysiwyg module, and use the manual install of ckeditor v 3.5.3 - between those 2 and all the configurations standard to drupal the wysiwyg media library finally works. I guess this makes sense since drupal 8 came out some people may have just not cared to keep the 7x modules stable. Or maybe I'm an idiot and following the step by step instructions on the latest media library module for 7x was just too complicated... but for all of us stuck in the nightmare of drupal, here's one option.


texts: Is there a flag hook (flag module) which is called when a flagged node is saved?

texts:
I am using the flag module to flag content.

Say user A flags a node. When user B updates the node, I want to send a mail to the user A (who flagged the node - I know I can use the Notifications and Messaging module but I want to send a notification in another way).

Is there an hook called when a flagged node is saved? So I can tap in on that hook and then retrieve a list of all users who flagged the node?

Thanks!

Paul


texts: Within a field template, how can I print the value of another field from the same node?

texts: I have an email field that I would like to present on the node as a name that links to the email address. As such, I am trying to edit the email field template to embed the name from a text field. However, I'm having difficulty figuring out how to access the content of this text field. I've gotten as far as figuring out that twig(_context['element']['#object']) will give me some info about the node object, but I cannot figure out how to access the field values. Am I even in the right ballpark for accessing this data?


texts: How to change image resolution on selection of field type

texts: I am creating a Content type and added field (like: category, image etc). I want to use different resolution default image for each category. As well as I want to restrict the user to upload specific resolution image while creating content of different categories of the same content type.


texts:
Similarly to changing the theme based on the requesting browser or logged in user, I want to change the theme based on where the request is coming from.

If a request comes from a specific address, domain or computer, how can I force a specific theme? I can't seem to find a module that accomplishes this.


texts:
I am using the CAPTCHA module on my user registration form. I need to alter the error message from What code is in the image? field is required. to My custom text.

Is there any hook to alter the error message, or some other way to change it?


texts:
I am new to Drupal. I'm trying to implement advanced search on my Drupal8 website. It's working perfectly with the logical operator 'OR' and 'AND' but not with 'NOT', '+', '-'.

Here is my request :

$index = \Drupal\search_api\Entity\Index::load('videos_full');
    $query = $index->query();
    $parse_mode = \Drupal::service('plugin.manager.search_api.parse_mode')
                  ->createInstance('direct');
    $query->setParseMode($parse_mode);
    $query->addCondition('search_api_language', \Drupal::languageManager()->getCurrentLanguage()->getId());
    $query->addCondition("status",5);

    $query->setFulltextFields(['field_title', 'title', 'resourcetype', 'tag', 'choreographer', 'director', 'producer', 'structure', 'contributor', 'secondaryauthor']);
    $query->keys($search);

    $query->sort('created','DESC');
    $results = $query->execute();

Thank you for your help !


texts: When are '$form_state['values'] copied to '$form' on rebuild?

texts:
as far as I understand it whenever you submit and rebuild a form (e.g. 'Add another item' on fields with infinite cardinality) something like this happens:

User submits a form with filled values
User input is copied to $form_state
Element validation happens
Form validation happens
drupal_get_form is called (form is being rebuild)
??? old user input from $form_state is copied to every $element[#value]
Individual elements of the form are created in $element[#process] callbacks
Rebuild form is shown to a user

My question is, when and how is user input from the old form transferred into the new one?

From what I've been able to understand by reading the documentation it must happen somewhere in drupal_build_form before the element #process callback is called. But when exactly that I haven't been able to find.

//I know about this FAPI flowchart if anyone could point me in the right direction on it I'd appreciate it.


texts: How do you embed an external URL (to a software application) in Drupal with 508 compliance?

texts: We need to embed a software application (by URL) into a Drupal 7 site. The resulting page needs to be Section 508 compliant. I have been told that iFrames are not Section 508 compliant. That is what we used in the past. Is there an alternative that is accessible?


texts: Can't find location of files after running drush make

texts:
I am creating a drush .make file for a site.  I have generated the drush.make file using drush make-generate and then updated the file as necessary.  I am now trying to use the .make file to create a new site.

To do this I first change to the directory where I wish to install the new site.  I then run the command drush make qmlc.make.  Drush asks me if I want to "Make new site in the current directory? (y/n)".  I reply "y" and then drush begins building the site.

The problem is that after the build has finished, the current directory is empty, except for the qmlc.make file.

Why are the files not appearing in the directory? If they are not here, then where are they?


texts: How to get group ids by ids of elements of group content?

texts:
I use the Group module and I have created several groups and assigned several nodes as content of these groups.

For example, I know id of some node. How can I figure out which groups contain this node ?  That is, how to get group ids by nid, if this node is a content of these groups ? And I don't want to use SQL for it. Are there methods of classes for it ?


texts: How to create a Hook_Schema for Fieldset Form?

texts: i have a form i would like to have the values submitted into a table in mysql database using hook_schema in a .install file. problem is i have no idea how to properly write it out being new to php  and all. i basically have a custom form with over 50 total field divided up into 3 different fieldsets displayed to user depending on checkbosed clicked. what is the best way to write a hook_schema to upload the submission values from my form into my database?


texts: How do I attach JS and CSS on Slick Views

texts: I would like to attach a CSS file and a JS library on Slick Views module from a custom module. Is there a hook function for Slick Views or any solution?


texts:
Is there any Field to display Message and Images instead of taking values ??

In Drupal Commerce I have created few fields to take Custom Measurements on Order Settings page.

Now I need to display a Picture and a text message on the page where I am taking measurements.


texts:
My Drupal version is 8.6.10

I am trying to upload a file through the file_save_upload function and the function is looking for the file in

Symfony\Component\HttpFoundation\FileBag Object

$all_files = \Drupal::request()->files;
debug($all_files);

Symfony\Component\HttpFoundation\FileBag Object
(
    [parameters:protected] => Array
        (
        )

)

But my file is in

Symfony\Component\HttpFoundation\ParameterBag Object.

$all_files = \Drupal::request()->request;
debug($all_files);

Symfony\Component\HttpFoundation\ParameterBag Object
(
    [parameters:protected] => Array
        (
            [name] =>
            [type] => 4
            [files] => Array
                (
                    [image_section] => logo_capnord.png
                )

            [op] => Ajouter
            [form_build_id] => form-wMTrCGaN5mPlOOv8bqS7UsJ0lRiSN6QQp9UviA0cTIA
            [form_token] => 1hTMXJRfoQvFV9Lqq3TuJ29eYC6L-zt3U7Bow1P8yJ0
            [form_id] => capnord_section_form_list
        )

)

The field is generated through the reloading of the form in ajax.

  $form["base"]["fields"] += [
    "image_section" => [
      "#type" => "file",
      "#title" => "Image",
    ]
  ];


texts: How to decrease the width of the sidebar for a specific page?

texts:
Is it possible to decrease the width of my right sidebar for any specific page only? If so, please shed some light on that.

I have created a basic page whose node id is 56. In that page I want my right sidebar region to occupy less width than it normally does. This can be done through CSS but I want to know if there is a way to do that through Drupal, either with coding or without it.


texts:
I am using Field Group.

With 2 Vertical Tab, 'Step 1' and 'Step 2'.

I want to put a link "NEXT" on 'Step 1' that should open 'Step 2', same a back link on 'Step 2' that should go back to 'Step 1'.

I tried different combinations with Multipage but did not work here. How can I do this? I can put text but I don't know how to get the link of the other tabs directly.


texts: How to use strongarm module without features module

texts: I am using Drupal 6 and now I am planning to add the Strongarm module to my site. Can anyone tell me how to use that, without the dependency of the Features module("since feature module is needed to import variables from db" - as per my understanding ). Please guide me on this.


texts:
I'm trying to display an ad every six rows of a view. I'm thinking of using another view that contains all the ads and displaying a random result of that every 6 rows of the main view.

Drupal 7 & Views 3.14

I have tried to do this but gotten stuck on the displaying something every 6 rows. Here is my code:

...code irrelevant, unedited coded copied from the template file in views module folder...

    <?php foreach ($rows as $row_count => $row): ?>
      <tr <?php if ($row_classes[$row_count]) { print 'class="' . implode(' ', $row_classes[$row_count]) .'"';  } ?>>
        <?php foreach ($row as $field => $content): ?>
          <td <?php if ($field_classes[$field][$row_count]) { print 'class="'. $field_classes[$field][$row_count] . '" '; } ?><?php print drupal_attributes($field_attributes[$field][$row_count]); ?>>
            <?php print $content; ?>

        <?php endforeach; ?>

      <?php if ((($row_count % 6) == 0 && $row_count !== 0): ?>
This is the row after every 6th multiple
<?php endif; ?>
    <?php endforeach; ?>

UPDATE: I figured out a way to print a random result. Just add randomize as the only sort in the view. However, I still can't get the printed view result to be in the appropriate location.


texts: What Plugin goes "type" of a FieldStorageConfig type?

texts:
I have a module creating a field type. It works.  I can create and add the field through the admin UI.  However, I am trying to update a content type with hook_update_N and change a field from entity reference to my field type. I am creating the FieldConfig and FieldStorageConfig like this

$field_storage = FieldStorageConfig::create([
       'field_name' => 'content_category',
       'entity_type' => 'node',
       'type' => 'my_field_type',
    ]);

$field = FieldConfig::create([
      'field_storage' => $field_storage,
      'field_name' => 'content_category',
      'bundle' => 'story',
      'label' => $label,
      'settings' => array('display_summary' => TRUE),
      'entity_type' => 'node',
    ]);
    $field->save();

This results in an error that says

The "my_field_type" plugin does not exist

but i can  create a field of type "my_field_type" and when I export configurations for my field created through the UI  the type says "my_field_type"

So What plugin is it looking for in the "type" field of a fieldConfigStorage?  In my Plugin folder of my module the Formatter.php  Field.php and Widget.php  which of these is the correct one?


texts: Drupal 7: how to display the content of the field without the label in node--type.tpl.php?

texts:
I created a content type called Community (machine name: community).

So I created file node--community.tpl.php to rearrange the fields.

I can do it like this...

<?php
  print render($content['field_phone']);
?>

it prints (with Phone in bold)...

Phone:
(888) 555-555

But I just want it to display the raw value with no label and no surrounding HTML. I just want  to print (888) 555-555.

How can I do this?


texts:
I have a node in Dutch and I want to get the field in this language.
When I do:

$node->field_name[$node->language][0]['value'];

I get the error:

Undefined index: nl

So I try:

$node->field_name[$node->language]['nl']['value'];

But that doesn't work. What am I doing wrong?

Edit:

I already figured it out:

  $language = field_language('node', $node, 'field_yourfield');

This gave me the language of the field and it was 'und' and not 'nl' as I thought it would be. The language of the node can be different then of the field. Learnt a lot about i18 & Drupal :)


texts: How to limit adding content of a specific content type to paid memberships only?

texts:
I have created a user role "seller"

when user enters to their account a "Add blog post"-tab is shown to  user when user click on it he/she can add "Add blog posts"

"Add blog posts" is a node form which contains field "title","image upload","body"

I want to add restriction to "seller" type user
Only those users can add post who paid (paid membership) for it to add "Add blog posts" (I have created a special role for paid membership).

Notes:

I have created a special role for paid membership.
When a user clicks on "Add blog post"-tab, the user must be redirected to checkout page if the user didn't paid in past. Users who already have the paid membership role should be able to create, edit and delete blog posts.


texts: Add a "Save" action in local task to a node

texts:
I would like to add a new action to local task on node.
This new action has to save the current node.

I have drupal 8.8.0

I know how to add a new action.

But my question is about how to save the current edit node from it if it's possible.

My goal is to replace the "save" button at the bottom of the node on edit mode


texts: How do I disable the default user system or view pages without login?

texts:
I apologize in advance if I haven't used the proper terminology, but I am very new to working with any CMS, let alone Drupal.

Now... On to the question...

On the  page, I have a block that explains the purpose of the site, and everything looks fine when I'm signed in, however, once I sign out, I get "Access Denied" on all of my pages & subpages.

For the website I'm building, I have absolutely no need for a user/authentication system at this time.

How can I disable the user framework, or how can I make all pages visible without having people log in?

Again, sorry for the likely improper terminology... Thanks in advance for your time & help.


texts: How can I disable Webform submit button after being clicked

texts:
I've been trying to resolve an issue with no luck. For some reason there are no submission indicators out of the box with D7 Webforms and from what i've found it doesn't look like they have any plans to implement this as they have already added this 'feature' in D8.
I wrote a handler in javascript that will just replace the input with another, but it doesn't appear that the script is firing because the actual submit is taking priority
var form = document.getElementsByClassName("webform-client-form")[0];
var isValidForm = form.checkValidity();
var submitBtn = document.getElementsByClassName('webform-submit')[0];
function preventExtraSubmits() {
    if (isValidForm) {
        var fakeBtn = document.createElement("input");
        fakeBtn.value = "Submitting...";
        fakeBtn.classList.add('webform-submit button-primary form-submit')
        insertAfter(submitBtn, fakeBtn);
        submitBtn.style.display = 'none';
    }
}
function insertAfter(referenceNode, newNode) {
    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
submitBtn.onsubmit = function(){preventExtraSubmits()}

From what i've seen is that this might need to be handled server side, but I can't seem figure out how to override webforms submit function.
Fairly new to Drupal and this has been a very frustrating battle to get this working
Drupal v 7.77
Webform v 7.x-4.23


texts: Unable to perform update when adding new menu field

texts:
I'm attempting to add a custom image field to my menu from a custom module like so

function my_module_entity_base_field_info(EntityTypeInterface $entity_type) {
  $fields = array();
      if ($entity_type->id() === 'menu_link_content') {
          $fields['menu_link_secondary_image'] = BaseFieldDefinition::create('image')
              ->setLabel(t('Menu link secondary image'))
              ->setDescription(t('Upload a secondary image related to this menu item'))
              ->setDisplayOptions('form',array('type' => 'image','weight' => 1))
              ->setDisplayConfigurable('form',TRUE)
          ->setSettings([
              'file_directory' => 'public://',
              'alt_field_required' => 'FALSE',
              'file_extensions' => 'png jpg jpeg',
          ]);

      return $fields;
    }
}

Then in my update function I have

function my_module_update_8001(){
    $entity_manager = \Drupal::entityManager();
    $definitions = $entity_manager->getLastInstallFieldStorageDefinitions('menu_link_content');
    if(!isset($definitions['menu_link_secondary_image']) || empty($definitions['menu_link_secondary_image'])){
        $definition = $entity_manager->getFieldStorageDefinitions('menu_link_content')['menu_link_secondary_image'];
        $entity_manager->onFieldStorageDefinitionCreate($definition);
    }
}

But when I attempt to run update.php it hangs and I get errors like

  Notice: Undefined index: menu_link_secondary_image__alt in
  Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromSharedTables()

Strangely enough I added a menu link afterwards and my field was actually there. I couldn't tell if my update actually worked and just didn't act as if it did, or if it already worked before hand and the update was unnecessary. Did I do something wrong?

UPDATE: I see that although my field appeared I'm unable to save it due to this error

  Column not found: 1054 Unknown column
  'menu_link_secondary_image__target_id' i


texts:
There is a problem with Drupal 6 site. It seems seesion cookie is preventing some pages to load.

Site has approximately 5 to 10 pages (out of 30 000) of difference content types which can't be loaded. No errors returned — browser's wheel turning endlessly. After disabling cookies pages load just normally. After some testing I can say, that the problem in session cookie.

The problem doesn't exist in the development environment. I have made some testing on production (stopped Nginx and restarted Apache as single web-server) to make it similar to to development environment, but nothing changed. Now I have no idea how to debug the problem.

Thanks for any pointers.

[Solution]

The problem was in big sessions table (2GB). After truncating the table error has gone.


texts: Search engines tries to access node editing links

texts:
In my dblog occassionally I am seeing query coming probably from search engines for links as

http://mydomain.com/node/13130/delete?destination=node

I wonder how possibly search engine got idea to query that kind of links (of course those links are not exposed to anonymous users)

I have xml sitemap installed but no such links exists in the index

When I query google for that link, I see that link is present in index (of course clicking on that link leads to access denied page), and also shows

A description for this result is not available because of this site's robots.txt


texts:
How do I render $tabs used in page.tpl.php, not horizontally, but as a vertical tree so the secondary tabs will be placed under/in the parent?

This is what I got:

Primary tabs

Item 1

Item 2

Secondary tabs

Child item 1

Child item 2

This is how I want it to be:

Primary tabs

Item 1

        Item 2

Secondary tabs

Child item 1

Child item 2

How do I achieve this without using javascript? I'm currently using render($tabs); to get something similar to the output above.


texts: How to render in commerce-product.html.twig calculated price?

texts:
I can render calculated price via {{ product.variation_price }}
Is it any chance to this price from product_entity variable in twig? I have used custom resolver class to update price.
updated at 16/06/2020
I`m using resolver class to made some calculations with price. And all changes goes to product.variation_price variable. In product_entity price left initial without calculations. The main problem that i want to divide output for product.variation_price separately price and currency. I have price in USD but should output price in EUR. and get currency without price is not so obvious


texts:
When I create a new content type with an image field, the image alternative text shows this error message.

  This value should be of the correct primitive type.

The image isn't shown in the view.

How can I solve the problem?


texts:
I want to give a role the possibility to create new articles and save them as unpublished. Only the administrators can save articles as unpublished, and I want to give this possibility to another role. How can I do that?

I only have Save and publish for the other roles.


texts:
I am trying to add some attributes to a render array. In Drupal 7, we can do this by adding a property in an array like the following.
$items[] = array('data' => $item_data, 'id' => 'someId'); // attribute = 'id'
$variables['subpanels'] = theme('item_list', array('items' => $items, 'title' => NULL, 'type' => 'ul'));

In Drupal 8, there's no #attributes property documented in Render Arrays in Drupal 8. How can I add this id as an attribute in a render array, with Drupal 8?
This is the code I am using so far.
mymoduleController.php
public static function _mymodule_f1($users_online) {
  $user = \Drupal::currentUser();

  $render_array_1 = array();
  $render_array_1['name'] = 'test-name';
  $render_array_1['header'] = t('test-header');
  $render_array_1['contents'] = array('#value' => '
' . ''. '
');

  $items = array();
  foreach ($users_online as $key => $value) {
    if ($key != 'total') {
      $items[] = array('#value' => '' .   $value['name'] . '', 'class' => array('status-' . $value['status']));
    }
  }
  //print_r($items);
  if ($items) {
    $item_list = array(
      '#theme' => 'item_list',
      '#items' => $items,
    );
    $render_array_1['footer'] = $item_list;
  }
  $render_array_1['text'] = array('#value' => t('T1') . ' (' . count($items) . ')');
  $image = [
   '#theme' => 'image',
   '#uri' => drupal_get_path('module', 'mymodule') . '/css/themes/images/loading.gif',
   '#width' => NULL,
   '#height' => NULL,
   '#class' => 'icon'
  ];

  $render_array_1['icon'] = $image;
  $mymodule_subpanel = array(
    '#theme' => 'mymodule_subpanel',
    '#subpanel' => $render_array_1
  );
  return $mymodule_subpanel;
}

mymodule.module
function mymodule_theme() {
  return array(
    'mymodule' => array(
      'variables' => array('mymodule' => NULL),
      'template' => 'mymodule',
    ),
   'mymodule_subpanel' => array(
     'variables' => array('subpanel' => NULL),
     'template' => 'mymodule-subpanel',
   ),
 );
}

function mymodule_preprocess_mymodule(&$variables) {
  $items = array();
  $users_online = mymoduleController::f2();
  $render_items = mymoduleController::_mymodule_f1($users_online);
  $render_items['#attributes'] = array('id' => 'some_id'); //not working; unable to add id='some_id' in the
 tag.
  //print_r($render_items);

  $items[] = $render_items;
  //print_r($items);

  $item_list = array(
    '#theme' => 'item_list',
    '#items' => $items, // array of render arrays.
    '#title' => NULL,
    '#list_type' => 'ul',
    '#attributes' => array('id' => 'mainpanel')
  );
  $variables['subpanels'] = $item_list;
}


texts: Hiding group_group field programmatically

texts:
I am trying to hide the group_group (request membership) field for organic groups based on a radio button. Here is what I have done that doesn't work:

/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  $menu = menu_get_item();
  $path = drupal_get_path_alias();

  $node = node_load($menu['page_arguments'][0]->nid);

  // field_show_group_group is radio button
  if($item['field_show_group_group'][LANGUAGE_NONE]['value'] === 0) {
    dsm("Just show the subscribe button - NOTHING to do.");
  }
  else {

    dsm("hide button");
    $instance = field_info_instance('node', 'group_group', 'community');
    $instance['widget']['settings']['og_hide'] = FALSE;
    $instance['settings']['behaviors']['og_widget']['access_override'] = FALSE;
    unset($instance['widget']['settings']['og_hide']);
    unset($instance['settings']['behaviors']['og_widget']['access_override']);
    $form['group_group']['#access'] = FALSE;
    $form['group_group'][LANGUAGE_NONE][0]['value']['#access'] = FALSE;
    unset($form['group_group']);
    unset($form['group_group']);
    $menu['page_arguments'][0]->group_group['und'][0]['value'] = 0;
    unset($menu['page_arguments'][0]);
    $item['group_group'][LANGUAGE_NONE][0]['value']['#access'] = FALSE;
    unset($item['group_group'][LANGUAGE_NONE][0]['value']['#access']);
    $node->group_group[LANGUAGE_NONE][0]['value']['#access'] = FALSE;

}

These are all possibilities I couldn't think of, which of course for some reason don't work. I searched the whole internet for this including drupal.org, drupal.stackexchange, google and stackoverflow. Can you help?


texts: Using CONTEXTUAL FILTER [Content: Has taxonomy term ID] while excluding one field

texts:
I have several taxonomy reference fields and would like to use [Content: Has taxonomy term ID] to filter content based on all these fields but one (keywords).

I tried adding [Content: Has taxonomy term ID] then adding [Content: keywords] in order to exclude (keywords). But, there is no option to exclude taxonomy terms as in NodeID.

Any idea?


texts: How to create a generic page for each user without a custom module?

texts:
I'm looking for a way to create one basic page for all user's website (instead of creating one basic page by user). This basic page must manage an url with a variable component. When I will create this basic page, theses url will must be available :

http://mywebsite.com/thebasicpage/1
http://mywebsite.com/thebasicpage/2
http://mywebsite.com/thebasicpage/3
...
http://mywebsite.com/thebasicpage/n

The reason is : I created a block view with a contextual parameter. And the default value of this parameter is in the path component. By exemple, if a user go to the http://mywebsite.com/thebasicpage/4 , so the block view displays all contents authored by the user number 4 (uid)
(I don't want create a page view because there will be several bloc view in the "thebasicpage/*")

I know it is possible via a custom module, but is it possible with only the drupal administration panel?


texts: Custom module translations without interface translation

texts:
I'm trying to figure out if I can provide translations to my custom module that are considered part of the "content translation" rather than the "interface translation."

I have a form in my module and some extra text. I've followed all the tutorials and have it working using...

interface translation project: contact
interface translation server pattern: 'modules/custom/contact/translations/%language.po'

However, the translations are only picked up if I allow for "interface translations." What I want is for my form to be translated, but for it to be considered content.

I don't want all the admin toolbar links and everything drupal admin to change languages too. I want my admin to be able to see the custom module's page in spanish, without setting the drupal admin to spanish too.

Is this possible?


texts: field_collection_item not updating / old data preserved

texts:
I am using SalesForce suite to pull data from SalesForce to Drupal.

In the SalesForce object I have multiple date fields.  These fields needs to map to a field-collection in the node.  The field-collection can have multiple (unlimited) values.

So for example in the SalesForce object I have

sales_force_object -> start_date
sales_force_object -> event_date
sales_force_object -> end_date

which needs to map to

node -> the_dates [0] = sales_force_object -> start_date
node -> the_dates [1] = sales_force_object -> event_date
node -> the_dates [2] = sales_force_object -> end_date

The solution was to add 'temporary' fields on the node, let's call them:

node -> sync_start_date
node -> sync_event_date
node -> sync_end_date

When I get data from SalesForce (using pull; and yes the data comes through OK) - I map the values from the SalesForce object to the sync fields.  Then just before the node is saved (updated), I use hook_node_presave to take values from the sync fields and create the field-collection items.  This is the code:

  $fc = field_collection_item_load($key_dates_entity_id);
  $fc_wrapper = entity_metadata_wrapper('field_collection_item', $fc);
  $fc_wrapper->field_date->set((int) $date);
  $fc_wrapper->save();
  field_attach_update('node', $node);
  field_attach_presave('node', $node);
  entity_get_controller('node')->resetCache([$node->nid]);

You can safely assume that $key_dates_entity_id is the correct field-collection entity ID.

Inspecting the code I can see the entity is correctly updated (nothing wrong with the data), and when I check the MySQL general-log, I can see the data being saved to the database, however, when the set of instructions end, the old (cached) data is also saved.  In other words the DB is updated twice - once with the new value, and once with the old values: net result is field collection items are not updated.

I have tried all sorts of combinations - nothing works.  Any help please.


texts: Best way of including a View without extra modules as Panels, CTools, Context, etc

texts:
I have a View which shows a list of nodes of a certain type.
If I don't want to use additional modules as Panels, CTools, Context, etc... which is the faster and better way of including it in a landing page? I have made a new kind of content for the landing page, with its own URL in PathAuto, and in the template.tpl I embed the Views with views_embed_view. Is it a good idea? Is it the simplest way of doing it? I have managed to get all working but the method seems very cumbersome and strange.


texts:
We can search all the default views on our relatively new Drupal 8 site, to see what view resides at a particular path, with a query like:

$view_trim_path = 'blog';
$query = $this->entityQuery->get('view')
  ->condition('display.page_1.display_options.path', $view_trim_path)

Unfortunately, this relies upon a hardcoded display name of page_1, which will not hold true in general.  In my dreams I would use a wildcard query like

  ->condition('display.page*.display_options.path', ...)

Is there a way to do either of the following?

create a set of entityQuery conditions to find views that have display.*.display_options.path equal to a certain value, no matter what the value of * ... preferably when * begins with the page_ prefix
use another Drupal / View function to look up a view ID from its path (I can't find one)

I can see how to find this by loading the config entities for all views and traversing all those arrays, but my guess is that Drupal has provided a simpler means for this.  Also it seems the database abstraction layer would be of use, and if that's the best practice then it would really help me to have an example of how to use it for the above query.


texts: Do we need hash in Config Sync Directory if outside root

texts: If we set the config directory to be outside root and plan on committing the configuration to git, do we need (or is it recommended) to use hash in the config folder name?


texts: Term translations not working as View's path contextual filter

texts:
Let's say you have a taxonomy called Animals and you have terms like Dog, Cat, Horse, etc. Every term has its translation, so for example for dogs you have Hund and Chien. Now you want to make a View which generates a page that lists content tagged with the Animals term reference, contextually filtering the tag based on the URL part.

And this is the part I'm having difficulties with.
The contextual filter I made works perfectly with source language values and converts properly to term ID. So I'm getting correct listing (both in preview pane and generated page) for /animals/dog but incorrect for /tiere/hund.

The contextual filter is set to Content: Animal Genre (Translated) and validation to Localised term or synonym converted to term ID (actually I tried perhaps every possible combination of i18n and non-i18n options here, no joy).

I trie out another solution - with Content: Has taxonomy term ID + relationship (as described here).

Is it something I'm not setting up correctly or is there a bug around i18n, Views, i18nviews...? I'd be grateful for any guidance


texts:
During install, it is possible to choose the language to be used on the admin screens. However, in this new Drupal 7.40 instance it was not chosen at install time. I need now to change the language from the default English (this is NOT a multilanguage issue).

Every tutorial I read tells me to click the "Add Language" button on Administration > Configuration > Regional and language > Languages. But there is no such button, there isn't even a "Languages" option under "Regional and language":


texts: Running unit test only for my custom module

texts: Is there any way I can run unit testing only for my modules? I know there is a way to run a specific unit test but I want to run unit test for all tests under certain directory (/modules/custom in my case). Is it even possible? I want to do it so that CI/CD automatically runs unit tests only for my code.


texts: Different slide intervals for Views Slideshow

texts:
I've created a slideshow using Views Slideshow and the Cycle plugin. In the Slideshow settings, there are advanced transition options that allow you to set the timer delay between slides. The project I'm working on requires that the delay between slides be different for each slide, so I need a way to do something like this:

Slide 1: 3000 ms
Slide 2: 5000 ms
Slide 3: 10000 ms

I have searched and cannot find a way to accomplish this easily. Is there something I'm missing, or would this require a custom module?


texts:
I have 1 view /admin/people, and its 2 display, both are of type page.

I want display = page will be shown to admin role while display = LMA is for xyz role.

After setting roles for 2 different pages with same access url /admin/people, I logged as admin role and xyz role. Display for admin role is working fine, but for xyz role, it says access denied.

Whats the correct way to have views display for different roles.


texts: Proper way to get the base path when including an image from a module?

texts:
When using just drupal_get_path() to include an image from a module directory, this produces non-existent urls when using language prefixes.

I've seen a couple of modules prepend base_path() to deal with this, but on the api page for base_path() someone comments that you should use the DRUPAL_ROOT constant. What is the recommended way?


texts: Custom tpl not being applied in user register form which is included by inline registration

texts:
I've created a custom template for user register form and added theme hooks for it.
It works great when I browse to registration page.

However, when the form is used as inline form with Inline Registration module it won't use my custom template.

Why it won't follow theme rules? As far as I known in Drupal theme is the last one called while rendering pages so the rendered output should be according to theme.


texts:
i'm trying to get a extra element in our XML that show the site langues where te customer is working in. However i can not get is to work....

Here is the code:

if ($submission->nid == 315) {
$destination['path'] = 'private://export/account/';
$destination['filename'] = 'request_password_' . $submission->sid . '.xml';
$wrapper = 'request_password';

// when content is supplied, generate XML file
if (isset($destination['path'], $destination['filename'], $wrapper)) {
$source = array();
$source['data'] = $submission->data;
$source['node'] = $node->webform['components'];

$xml = new XmlWebformGenerate();
$xml->setXmlHeader('1.0', 'utf-8');
$xml->setXmlWrapper($wrapper);
$xml->source = (new XmlSource($source))->getSource();

What this does is; create a XML from a webform.
When the user submit the webform then it will create a XML file with te field of the webform. However what i would like to add is a  tag that displays the language the user is viewing. however i cannot find a way to insert it to the XML, because it's already receiving the source from the node.

Could some one help me out with this? Many thanks! :)


texts:
For each user, I created a new field called field_cover, this field is an image.

I want to get the field_cover path, to use it into a background-image property.

I try this but it does not work.

<?php print render (file_create_url($user_profile['field_cover'])); ?>

Thanks for your help !


texts: How to use Rules to transform upvotes and downvotes towards User Points?

texts:
I know that there is the Userpoints Karma module, and this is only updated to Drupal 6 version.

Are there any techniques for transforming votes towards User Points? Or can you point me in the direction of reference for creating a custom module for this purpose?

Note: The votingpoints module is not available for Drupal 7, so I was looking into using Rules to grant points to the creator of a node, when a user votes on it.


texts: Why won't my images appear inside buttons?

texts:
In the page displayed, there is a row of buttons that each say "Submit Query."

The HTML for one of these buttons is:

<INPUT TYPE="image" SRC="../images/OneLine30px.png" CLASS="select-button" ID="OneLine">`

I've also tried slightly modifying the paths to these images. This HTML is in a .tpl.php file which is inside the templates directory. The images directory is a sibling of the templates directory.

Why is Drupal displaying "Submit Query" instead of the image?
How can I get Drupal to display the images?


texts:
I'm using the scald module for image management.
It's working 99% as I'd want it to - but when used with WYSIWYG (ckeditor) I'm having an annoying issue.

The images in this context need captions so I've hooked into the scald templating and changed the output to use  and  tags.

All fine - except when saved the WYSIWYG / scald seem to add lots of empty  tags between the figure and the figcaption.

Attempting to use the empty paragraph tag module or create my own input filter have failed as they run before scald replaces the atom reference with the actual image output.

Any suggestions on where to hook into scald to be able to influence this markup?


texts: 500 internal server error while installing

texts:
What is the reason for the error "500 internal server error" while trying to install drupal,

i have created database successfully
After that i have downloaded and extracted the drupal 7.22 in my desired        directory.

But when i trying to install the tables in my database its showing  the error and approximately more than 30 tables are storing and the installation process stops automatically with showing the above error . Can anybody tell me why the error is coming.


texts: Create a rule at the event of "Cron maintenance tasks are performed"?

texts:
I created a rule to be fired when "Cron maintenance tasks are performed".

Now I need an action to check delete all nodes of the content type: "Question" that have the field "Delete" set to "yes"

How can I do this?


texts: Send node file attachment on form submit

texts:
I have a form built into a block on one of my content types, the content type has a file connected to the node.

I currently have a form the will send an email to the address you put in with a default message (ie if you put into the form, me@myemail.com, this email will receive a message saying "thank you for your interest.. ..please find your document attached" etc) However I'm struggling when it comes to attaching the file attachment of that node to the form, I have downloaded the mimemail module but there isn't a lot of documentation on how to do it.

Any help would be great,

Kind regards


texts: The special price attributes provided by Commerce Exra Price Formatters are not translatable. Especially RRP. I cannot change the translations of these fields. I can write the label in the display dialog but it is not changeable depending on the site's language. How can I solve this problem?


texts: How to save uploaded image in an content type to picasa?

texts:
I am uploading an image in a content type and I want that image to saved in picasa web albums.

While showing that node, I want the image to be displayed from picasa. Is there any module available for that or how do I achieve this?


texts: Is there way to list all users? I haven't found such method on UserInterface. The few hints I found on internet are for version 7 or using entityManager which is deprecated. Loading custom fields is a bonus.


texts: A view that displays content with taxonomy term of current user?

texts:
The Setup:

A Taxonomy Vocabulary called "School" - During registration, users can choose multiple "Schools" from the taxonomy list to associate themselves with.

A content type called "Lesson" - Each lesson can choose a school from the taxonomy list to associate itself with.

The Challenge:

I would like to construct a view where the logged in user sees a list of lessons from schools they have associated themselves with.

I'm struggling to understand the relationships and (presumably) the contextual filters that I'll need to have in place to make this happen. Help!


texts: How to dynamically create a view, and then export to PDF

texts:
I'd like to dynamically create a view for each of my content types/items, and then export that View's data to PDF format.

My (Drupal 7) website tracks mileage, gas usage, engine usage, and other items for a fleet of cars. Let's say I want to run a report on Car A. I'd like to have a single view that could pull in only the information for Car A when I click a link on Car A's content page. Then, if I click a link on Car B's page, it would pull in only the information for Car B. The same would be true for Engine A, Engine B, etc. The purpose would be to see a snapshot of the usage of that car, engine, etc.

I use the Entity Reference module to link individual usage content items to each of the "master" content items (cars, engines, etc). The Usage content items have the following fields: the VIN/serial number of the car/engine (which links the usage content item back to the car/engine), miles driven since last visit, gas remaining since last visit, etc. These usage items are the most important thing for this usage report. There will be other fields from the Car, Engine, etc (such as the color of the car, starting mileage, etc) that will appear on the report, but those are really just information; the usage items are key.

Is all of this possible with Views out of the box? Or would I need an additional module to accomplish this?

Thanks!


texts:
I'm trying to wrap my head around contextual filters again! I used it a while back but I just got totally stumped again. Here's what I'm trying to do:

Generate a cloned content node page with taxonomy terms inserted into this cloned page.

ex.:  EXAMPLE.com/white-shoes/blue
When a user reaches the /white-shoes page it will show the original node page geared toward the white color. Now if the user lands on /white-shoes/blue it will show the same node page, but this time all of the body content will be rewritten replacing the white color with blue color.
In Views I would have to create a Page display with the path of: %/%
Now I would create a contextual filter to retrieve the nid. I add Content: nid as a contextual filter. I pick PROVIDE A DEFAULT VALUE and I put in this PHP code:

$x = drupal_lookup_path('source', arg(0));
$y = explode('/', $x);
return $y1;

That PHP code basically converts the /white-shoes part of the URL into a NID. But it doesnt work. I tested the code via drush ev via the terminal and I indeed get a returned result, so i know it works.
I do the same for the taxonomy term name and add a contextual filter for that aswell. This time I pick PROVIDE A DEFAULT VALUE and select RAW VALUE FROM URL and select the 2nd argument.

As you can see when I input a PREVIEW VALUE for the contextual filter: AAA/BBB/CCC . My default value gets ignored. It's supposed to be grabbing the 2nd argument, but it's getting the 1st only. Look at the SQL statement WHERE and you'll see it's getting AAA when it should be BBB.

So the question is what am I doing wrong or is there a better solution to what I want to accomplish?


texts: Reduce latency in loading a page in Drupal 6

texts:
I have activated cache in Drupal, and the Devel module.
The total time in all queries is less than one second, but the latency is 4.34 seconds.

Can anyone explain the latency? What happens during the latency time?

I am using IIS, Php 5.25, Wincache, and MyIsam.


texts: Remove password field from user registration form

texts: I don't want the password field to be a required user registration field. How can I remove the password field? Is this done by changes in user.module file?


texts:
I'm developing a module, and there is a table that needs views integration. The table is not so special, but can't find a solution yet.

This is how my table looks:
nid_a|nid_b|data

I would like to join this table to the node base table, with nid_a as joining key, and nid_b should come from a contextual filter (aka argument).

How can I achieve this?

System: Drupal 7.x and Views 3.x


texts: Howto override a function in privatemsg.module?

texts:
There is a function in the module private message that I want to override. What is the right way to do this?

This is the function:

/**
* Format an array of user objects.
*
* @param $part_array
*   Array with user objects, for example the one returned by
*   _privatemsg_generate_user_array.
*
* @param $limit
*   Limit the number of user objects which should be displayed.
* @param $no_text
*   When TRUE, don't display the Participants/From text.
* @return
*   String with formatted user objects, like user1, user2.
*/
function _privatemsg_format_participants($part_array, $limit = NULL,$no_text = FALSE) {
 global $user;
 if (count($part_array) > 0) {
$to = array();
$limited = FALSE;
foreach ($part_array as $account) {

  // Directly address the current user.
  if (isset($account->type) && in_array($account->type, array('hidden', 'user')) && $account->recipient == $user->uid) {
    array_unshift($to, $no_text ? t('You') : t('you'));
    array_shift($to, $no_text ? t('You') : t('you'));
    continue;
  }

  // Don't display recipients with type hidden.
  if (isset($account->type) && $account->type == 'hidden') {
    continue;
  }
  if (is_int($limit) && count($to) >= $limit) {
    $limited = TRUE;
    break;
  }
  $to[] = privatemsg_recipient_format($account);
}

$limit_string = '';
if ($limited) {
  $limit_string = t(' and others');
}

if ($no_text) {
  return implode(', ', $to) . $limit_string;
}

$last = array_pop($to);
if (count($to) == 0) { // Only one participant
  return t("From !last", array('!last' => $last));
}
else { // Multiple participants..
  $participants = implode(', ', $to);
  return t('Between !participants and !last', array('!participants' => $participants, '!last' => $last));
}
  }
  return '';
}

I like to remove this part from the code:

// Directly address the current user.
  if (isset($account->type) && in_array($account->type, array('hidden', 'user')) && $account->recipient == $user->uid) {
    array_unshift($to, $no_text ? t('You') : t('you'));
    array_shift($to, $no_text ? t('You') : t('you'));
    continue;
  }


texts: How to hide certain fields to a user if they aren't referenced in a field on the node?

texts:
I have a content type which has a full content and teaser display. It has a number of fields, and one of the fields on it is an Entity Reference field which references users (called field_registered_users with unlimited values allowed).

If a user views the node and they aren't referenced within the field then I want to hide certain fields on the node.

How do I do this? Should I do it in the template file or through a custom module? I also want to display a block on the page instead of the fields if this is the case.


texts:
I need to know the package of a given module to performs some actions inside the implementation of a custom a drush command. So usually you will find that we will found this information in the module_handler service. But there is not method to get the module package.

So, how can I know the module package?


texts: Add variations to coupons commerce module of drupal

texts: On my commerce site, I want to add a coupon which can be use for a particular brand or catagory (taxonomy : product attributes).I am using commerce module with drupal 7. Any one help me on rule making...


texts: What entity type should I choose for a comment type?

texts:
When I add a comment type (for example, Blog comments), I can select an entity type as target for the comment.
What should I choose and why?
Is it Custom block or Comment? My intuition says to pick Comment, but I don't know on what basis I should decide what to pick.
The other option seems in any case less likely for my case. I just need a global article comment type.


texts: How to create a view of nodes of which a user is a member?

texts: How do I create a view of Nodes that a logged in user is a member of? Is this enforced in Relationships or Contextual Filters? That is, can you explain how group membership is enforced via relationships and contextual filters?


texts: Returns 404 status code even though I am given the correct data

texts:
I'm using Drupal Services to get JSON for an Angular app. Everything works fine on my local (Mac OX 10.10, Apache/2.4.9), but I've just deployed to a DigitalOcean instance (Ubuntu 14.04, Apache/2.4.7) and that's where I'm getting the 404 statuses (even though the request Response is fine). I'm not seeing any errors in my /var/log/apache2/error.log

I'm guessing there's maybe a configuration difference between my local and the DigitalOcean instance? But I don't know what it would be.

Here's my XHR traffic:


texts: How To Assign Breadcrumb To Commerce Kickstart Omega Collection Or Category?

texts:
How does one assign 'Collection' or other Taxonomy vocabularies to the Crumbs that Kickstart Omega uses. They give examples for Content Types but not for taxonomies.

So any pages based on taxonomies just show 'Home' as the breadcrumb.

I've looked in admin/structure/crumbs and the text pane seems to be correct for some tests I ran with the Debug tab. (ie. the item appears to be in the key menu.link_title.menu-specialties) but I don't know what to -do- with that information.

Maybe there is a -straightforward- tutorial on how to configure this text file?

Below is a screen cap of the crumbs screen I'm seeing.


texts: Search Api Solr - Pointing term links inside a view to its facet

texts:
Using Search Api. Solr as a backened. Search pages built with Views. When adding a term field to a view, that term links to the core taxonomy term pages. That term should instead link to it's facet(not adding to the other facets if the user had previously click on other facets).

I have searched high and wide for any documentation or discussion involving this, and only found a few issues that didn't go anywhere. There is hardly any discussion, which I find odd because I would imagine this would be a pretty common request.

Does anyone have any knowledge on this issue?


texts: D7 Custom Module: Turning tabs into contextual links

texts:
Created a module (D7) that turns every nodes edit tabs into contextual links instead. Works great... But on the first initial load to the page I get a warning. Disappears after I refresh once. Then it comes back around surfing to another page and back again.

Warning: Invalid argument supplied for foreach()
in mytheme_contextual_contextual_links_view_alter()
line 19....

Driving me bonkers. Code below. It's having an issue with my foreach($tabs as $tab)...

  function mytheme_contextual_block_view_system_main_alter(&$data, $block) {
      if (user_access('access contextual links')) {
        $tabs = menu_primary_local_tasks();
        $data['content']['#contextual_links']['block'] = array(
          'admin/structure/block/manage',
          array('system', 'main'),
        );
      }
  }

  function mytheme_contextual_contextual_links_view_alter(&$element, &$items) {
      if (arg(2) != 'edit' && arg(3) != 'edit' && arg(0) != 'admin' && arg(1) != 'add') {
        if (isset($element['#element']['#block']) && $element['#element']['#block']->delta == "main") {
          $tabs = menu_primary_local_tasks();
          foreach( $tabs as $tab ){
              $element['#links'][$tab['#link']['path']] = array(
                'title' => $tab['#link']['title'],
                'href' => url($tab['#link']['href'], array('absolute' => TRUE)),
              );
          }
        }
      }
  }

  function mytheme_contextual_preprocess_page(&$variables) {
      if (arg(2) != 'edit' && arg(3) != 'edit' && arg(0) != 'admin' && arg(1) != 'add') {
        $variables['tabs']['#primary'] = array();
      }
  }


texts: Child & Grand Child terms of Parent Term from URL

texts:
I am looking for a way to display both the Child and Grand Children of a taxonomy term (found on the URL) on the same page.

Example Taxonomy called Food. Top root term called GRAPE has children and grandchildren like this.

-Grape

--Red

---Small

---Medium

---Large

-- White

How can we create a view (block in our case) that will always show the children and grandchildren of the parent term from URL?

I am guessing one or two contextual filter where the filter takes the taxonomy term ID Raw from the URL.

Example: doamin.com/fruit/grape/,

therefore, parent will be second in path. The parent term in this case is Grape.

So in the block we will show children and grandchildren of Grape:

--Red

---Small

---Medium

---Large

-- White

Ideally grouped by RED, WHITE.

Apply the contextual filter to a second filter? Not sure, I am just guessing.


texts: My Superfish menu is being repeated 4 times. Why?

texts: My superfish menu is being displayed 4 times. In the header. I originally selected 4 from the dropdown menu, but have since changed it to 1. Even after clearing the cache, the menu is being repeated 4 times. How do I fix this?


texts: edit the order of link appearances in links__system_main_menu

texts:
I have setup links through the Drupal 7 web interface, however I am trying to change the order of the link appearances through code. For example, currently I have:

ABOUT US          CONTACT US          HOME          THE PRODUCT

The order is clearly incorrect, but I cannot find a way to edit the PHP code to edit the order of the appearances of these links. I am aware of overriding MYTHEME_menu_link to get this done, however I do not know what code would be required to go in there to actually perform the change.

I am new to PHP so any help would be appreciated.

Also, the following is my code. It works (looks the way I want it), but I  do not think this is the correct way to do it in Drupal, if someone could please correct me I would appreciate it

          <?php print theme('links__system_main_menu', array(
          'links' => $main_menu,
          'attributes' => array(
            'id' => 'main-menu',
            'class' => array('links', 'inline', 'clearfix'),
          ),
          'heading' => array(
            'text' => t('Main menu'),
            'level' => 'h2',
            'class' => array('element-invisible'),
          ),
    )); ?>

Thank you.

EDIT: I know you can edit the order of links through the web interface, but as a developer I do not feel quite comfortable just using the web interface for everything, I would like to learn how to do the actual coding.


texts:
Is there a way to show / hide filters via a dropdown select. What I want to achieve is, that there is a dropdown with all my filters, and only the one I select in dropdown will show up.

I've found the Composite Views Filter  module. But this works only with one group. If I have two Dropdowns to select filters, it won't work.


texts:
I would like to have, on my Drupal 8 site, a forum that can be visited only by the members of the group XY; all the other users should not see the forum.

In the permissions I can't find one for viewing the content of the forum.
How can I do that?


texts: which version is this cache_set function belong to?

texts:
The function I have commented out is in Drupal 5.x and I've seen a lot. I　want to know which Drupal version the function I haven't commented out belongs. This is the function that I have seen on the site that I am working on. I am about to replace the site by Pressflow. But I met some problem with cache_set function. Serialized seems a new column and this function is so different. So I really don't know which version of Pressflow in 5.x that I can use for my site...

/*
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
  $created = time();
  db_query("UPDATE {". $table. "} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, $created, $expire, $headers, $cid);
  if (!db_affected_rows()) {
   print_r($data);
    db_query("INSERT INTO {". $table. "} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, $created, $expire, $headers);
  }
   //mysql_query("INSERT INTO tbj_cache_views (cid, data,created, expire,headers) VALUES ('aaa', 'adsfadfasdfdffa', ".$created.", ".$expire.", NULL)");
}
*/
function cache_set($cid, $table = 'cache', $data, $expire = CACHE_PERMANENT, $headers = NULL) {
  $serialized = 0;
  if (is_object($data) || is_array($data)) {
    $data = serialize($data);
    $serialized = 1;
  }
  db_lock_table($table);
  db_query("UPDATE {". $table ."} SET data = %b, created = %d, expire = %d, headers = '%s', serialized = %d WHERE cid = '%s'", $data, time(), $expire, $headers, $serialized, $cid);
  if (!db_affected_rows()) {
    @db_query("INSERT INTO {". $table ."} (cid, data, created, expire, headers, serialized) VALUES ('%s', %b, %d, %d, '%s', %d)", $cid, $data, time(), $expire, $headers, $serialized);
  }
  db_unlock_tables();
}


texts: How to load the node to print the node title, etc?

texts: I have a content type 'news' and created a seperate template for this which is node--news.html.twig. I want to load the node like Drupal 7 so I can print the node title, body and other fields as well. In Drupal 7 we load the node by node_load($nid) but is there any way to load the node in Drupal 8?


texts: Can't change default settings in foundation theme

texts:
I am thinking about changing my Drupal site theme to a Foundation based one. I use Windows 7, with the Foundation module installed and activated, along with Ruby, Compass and Sass.

To experiment I have changed this in the scss files:

_variables.scss:

 $row-width: em-calc(1280);
 $column-gutter: em-calc(30);
 $total-columns: 12;

_init.scss:

$topbar-height: rem-calc(90);

I get no error messages when I navigate to my sub theme's folder and run compass compile from the command line. Instead I get this:

 write css/custom.css
directory css/foundation
 write css/foundation/foundation.css
 write css/foundation/normalize.css

... which looks promising enough. After this I added this to my sub theme's info file:

stylesheets[all][] = css/foundation/foundation.css
stylesheets[all][] = css/foundation/normalize.css

I also commented out the app.css line in the info file:

; For CSS users, load the app.css file:
; stylesheets[all][] = css/app.css
; Comment the app.css file (above) if you're using sass to preprocess css:
 stylesheets[all][] = css/custom.css

I have looked in the page source and can confirm that those files are actually loaded.

The width is still is the default 1000px value and the top bar still have the same height (45). And yes, I have cleared all cache.

What have I forgotten?


texts: How to sort the language detection methods

texts:
In a two languages Drupal 7 site, I am using the following order of language detection methods:

URL
Session
User
Browser
Default

With this order, every time I visit the site as an anonymous user it comes in the default language.

Instead I would like to:

display the default language in the first visit.
if a language selection is made, display that language in the next visit

Is there a way to achieve this?


texts:
I'm using Random class to generate a password for a new user in my custom module.

I added the namespace in my module controller: use \Drupal\Component\Utility\Random;
And I am using it like this:

$user = User::create();
$user->setPassword(Random::string());

Problem is this function seems to be deprecated, however I found it in the Drupal API documentation.
Here is the error I get:

  Deprecated function: Non-static method Drupal\Component\Utility\Random::string()

Did I use it wrong or do you know a better way to generate a random string ?

Drupal version: 8.4


texts: 7 - Dynamically changing links based on environment

texts:
I am working with a Drupal site that is a central hub for several other pieces of software. The Drupal site and the other Software all have their own dev, testing and production environments. Each of these environments have their own url.

What I am looking to do is to change these urls based on the current envrionment by setting a variable/token of some kind. For example:

If the site is in dev, it links to all other dev versions of the software. For example dev-drupal.website.com links to dev-software1.website.com and dev-software2.website.com
If the codebase moves to testing, there is a file (for example the template.php) file that either doesn't need to be changed, or needs to be changed once to change all of the links.

There are over a dozens of these externally linking software pieces, and they are often linked in the content, but there are also menu items, blocks and a few views. Currently we have to do a find and replace to manually change these links one at a time. I'm trying to figure out if there is a better way, perhaps through a template variable or a token. Any ideas? This solution would ideally not be stored in the db, but I'm flexible.

I'm looking for suggestions on the best approach.


texts: What's the best way to configure some products so that they are not on sale .. i.e not show the price or add to cart button without creating a new product type?


texts:
I'm completely new in using drupal 6. I was wondering if there is a way to print the name of an uploaded file in a node. Thanks for the help

Cheers


texts: How to change field attributes of Content Entity?

texts:
In a custom module, I have a content entity in which I have defined this field:

$fields['formheader'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Header'))
  ->setSettings([
    'max_length' => 255,
    'text_processing' => 0,
  ])
  ->setDefaultValue('')
  ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'string',
    'weight' => $weight,
  ])
  ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    'weight' => $weight,
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

I'd like to change its type from string to string_long and max_length from 255 to 1024.
How can I do that without uninstalling my module, changing my source code and installing my module again (there is already content in this entity)?


texts: How to override views title using values from several contextual filters?

texts:
I have a view where the user can filter by using contextual filters in the URL, like this:

timeline/%year/%month/%day

I then use these contextual filters:

Content: node.field_daterange (year)

Content: node.field_daterange (month)

Content: node.field_daterange (day)

Users can use this path to get all events in a year, e.g:

timeline/1945

Or to get all events on a specific month in a year they can use

timeline/1945/05

Now I want to dynamically build the title of the view. If only the year parameter is used it should the title "Timeline YEAR" and if both year and month is set I want it to have title "Timeline MONTH YEAR".

In the contextual filter, there is an alternative named "Override title" (under the box "When the filter value IS in the URL or a default is provided")

It is written "Override the view and other argument titles. You may use Twig syntax in this field." But how can I now catch back the %year, %month or %day argument to use it in the title?


texts:
I want to add a new page node using drupal services and REST server.

$postdata = http_build_query(array(
      'type' => 'page',
      'title' => 'aaa',
      'field_test[en][0][value]' => '
test
\n',
      'field_test[en][0][format]' => 'filtered_html'
      )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-Type: application/json'."\r\n".
                     'Cookie: ' . $sessid."\r\n",
        'content' => $postdata
    )
);

    $context = stream_context_create($opts);
    $contents = file_get_contents($main_url."node", false, $context);

    echo json_encode($contents);

When I run above code I get an error:

Warning: file_get_contents(http://192.168.1.129:80/test/node)
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0
401 Unauthorized:
Missing required argument node in D:\xampp\htdocs\serv\server.php on line 61


texts: Is there any module to create different menus per user?

texts:
I would like to have different menus per user.

How can I achieve this?
I searched on drupal.org, but I found a module that creates a menu per role, not per user.


texts:
I'm working on a two-factor login form that sends a text message to the user. With a "did not recieve message" button. I would like to limit the number of times a user can request for a new text message.
I know that I can register flood for a certain event like: \Drupal::flood()->register('eventName', 1800, $user->getUuid()). The FloodInterface has a isAllowed($name, $threshold, $window = 3600, $identifier = NULL); method that, I imagine, tests when a user tries to do a certain $name event, it tests if that event has been done more often than the $threshold within the $window. If so then the method returns false and otherwise true.
In my example I can register the event somewhere in the chain of events/functions that send the message and also check there if the event isAllowed?
Something like so:?
public function someFunction() {
  \Drupal::flood()->register('send message', 900, $user->getUuid());
  $token = 12345;
  $this->sendMessage($token);
}

private function sendMessage($token) {
  $is_allowed = \Drupal::flood()->isAllowed('send message', 3, 900, $user->getUuid());
  if ($is_allowed) {
    // Send the message
  }
}

What I don't get is why I also have to indicate the $window in the isAllowed method when I already assign that in the register method?


texts: How to do a newsletter / mailing list with Drupal 7

texts:
I would like to make a mailing to a Drupal (7.4) community, sending an email to every user or every user with a specific role.

I would like to send this mails from my admin interface and I want to send mails with HTML.

What is the best way to do it ?


texts:
I'm wondering whether it is possible to simply click on a Drupal calendar tile (month view) and be automatically taken to the page for creating an event. The only thing I've found that comes close to this is the event calendar module, specifically the In-place Add/Edit/View of events in pop-up functionality. However I need more control over this and want it to use my own content type for creation.

My colleague, who creates many calendar events, wanted this functionality to save time.


texts: How to link to a page view from a template file?

texts:
If I were linking to a node via a template file I would write something like this...

<a href="<?php echo url('node/22'); ?>">Back to blog

I get that node ID by hovering over the node under 'Admin > Content' and looking at the node number that pops up when I hover over the 'edit' link in the bottom left (in Chrome). In the screenshot attached I've hovered over the 'edit' link alongside the node 'Head of Development' which shows node/5 in the bottom left.

The issue I've got is that I want to link back to a page view which doesn't show alongside all the other content. Thanks in advance.


texts: What does a 'reset' refer to with Drupal?

texts:
In the docs for the State API, the term 'reset' is used, without any reference as to what a reset is:

  use State API to store transient information, that is okay to lose
  after a reset.

I've spent a significant amount of time digging through the back-end implementation of the State API, looking at the database tables, and testing writing values, and as far as I can tell, the state data is never removed. So I'm thinking that by a 'reset', they mean wiping the entire DB, re-installing Drupal, then importing all the config.

I'm just looking for other confirmation before I update the doc page with a clearer explanation. Can anyone confirm that my theory on what a 'reset' is, is correct? And if it's not, can anyone explain what a 'reset' is?


texts: Send mail to users including receiver's username

texts:
I have searched settings of Contact (in Drupal core), Simple news and Mass contact modules but haven't found a way to include receiver's username in the mail body.

Any suggestions how to do this?


texts:
I know this may be very basic but I can't seem to figure out a way to hide a product that I've got set up in Drupal Commerce. I'm new to Drupal so thanks for your patience.

I am using the Expressa theme. In the product's edit screen, I go to 'Status' and choose 'Disabled' which prevents them from being added to carts (instead of Add To Cart, it displays 'Product Not Available' in the store) but it doesn't actually remove it from Product Display in the store. I've set the stock status to 0 on these products and made sure that they are not being displayed as 'Featured' yet they still show up.

Is there a simple setting where I can keep the product in the backend, in case I want to activate it later, but hide it from the store?

I've also navigated to the content list, found the list of content, checked all the relevant products and unpublished them.

Thanks for your help!


texts: How to find the count of items in a block?

texts: I have a block named views-view-fields--our-services--block.tpl.php i need to find the no of nodes under this block.How do find the total no of nodes displaying inside a block?


texts:
I am using the feeds module to import an rss feed from twitter. The feed title and body starts with ": then my tweet". I wish to remover ":" from the creation of my nodes. I can remove it in the body by using a custom input format that removes it. However I can't remove it from the title.

I suppose I have two options:

While saving the nodes of my custom content type, remove the text
create a custom plugin for feeds

What do you think is the best way to do this? Should I try another way?

Update

I added hook_node_presave to deal with this. As it is called on both the insert and update.

/**
 * Implementation of hook hook_node_presave
 */
function my_module_node_presave($node) {
    if($node->type=='mytype'){
        $node->title =  _my_module_my_function($node->title);
        $node->body[$node->language][0]['value'] =  _my_module_my_function($node->body[$node->language][0]['value']);
    }
}

It works great but is this the correct place to be doing the check and removal?


texts: Form fields still treated as required even after setting #required to false

texts:
I'm using hook_form_alter to remove the "required" setting for a couple of fields, specifically the First name and Last Name fields on the Address form.

Here's my code, where I provide a callback function for #after_build to remove the required setting:

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id === 'listing_edit_form') {
    $form['address']['widget'][0]['address']['#after_build'][] = '_mymodule_customize_address';
  }
}

function _mymodule_customize_address($element, $form_state) {
  $element['given_name']['#required'] = false;
  $element['family_name']['#required'] = false;
  return $element;
}

The problem is that after I submit the form, the fields are still treated as required, which means that if I don't enter any data for them the submit fails with an error message telling me that those fields are required.

Note that even if I hide the fields by setting #access to false, the form submit will still complain that they are required. So it seems to be a backend issue with the Address module.

I have:

Drupal                  8.7.1
drupal/address          1.6.0
commerceguys/addressing 1.0.3
commerceguys/enum       1.0
commerceguys/intl       1.0.4

I'd appreciate any help with this. Thanks!


texts: How to embed and choose entityform in custom content type?

texts:
I have a D7 Website, and I am using entityforms module.
I want to include those entityforms which I created in my custom content type so that users can submit their details. For example: a node with multi-field comments box.
To achieve this, I added a field in custom content type of type "Entity reference" -> List.
As an admin, I get to choose all available entity forms but not as a custom user role for which it shows "access restricted" while choosing entity form type.

Please guide.


texts:
I have content type called "sample", where i have field called 'user detail' which is a multifield. I'm using multifield module to get this.
  I'm creating a view for display sample content type contents, but i'm not able to fetch multifield fields in view table.Can anybody help me in fetching multifield values?


texts: How to add "Agree to terms" checkbox in Drupal 8 form

texts:
I've tried several solutions starting from the Boolean checkbox field in the Drupal 8 contact form to this answer, this answer and even this module but none of them work for me.

Basically I just want to display a checkbox which displays the text, "I agree to the terms and conditions of this site", and the words "terms and conditions" needs to be linked to its respective page on the site - to open in a new tab.

Any ideas on how this could be achieved in Drupal 8, via code or even a module is greatly appreciated

This is the code which I tried using in the .theme file

function <theme_name>_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'field_config_edit_form':
      $form['default_value']['widget'][1] = array(
        '#type' => 'checkbox',
        '#title' => t('Your checkbox'),
        '#size' => 10,
        '#maxlength' => 255,
        '#default_value' => 1,
        '#required' => TRUE,
        '#description' => '<p>' . t('Your checkbox altered.') . '</p>',
    );
    break;
  }
}

And I need this done on all contact forms of the site


texts: theme_radios working but theme_radio is not

texts:
Hello I am trying to figure it out what's causing theme_radio not to work. It is Drupal 7 and this is my code:

// Hook Theme in my module
function MY_MODULE_theme(){
    return array(
        'MY_MODULE_radios' => array(
          'render element' => 'element',
          'variables' => NULL,
        ),
        'MY_MODULE_radio' => array(
          'render element' => 'element',
          'variables' => NULL,
        ),
    );
}

My implementations of the themes are Drupal standard still since I am trying to get them to work  first, the XDebug does stop at the breakpoint in theme_MY_MODULE_radios but not in theme_MY_MODULE_radio:

function theme_MY_MODULE_radios($variables) {
  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  $attributes['class'] = 'form-radios';
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
  }
  if (isset($element['#attributes']['title'])) {
    $attributes['title'] = $element['#attributes']['title'];
  }
  return '
' . (!empty($element['#children']) ? $element['#children'] : '') . '
';
}

function theme_MY_MODULE_radio($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-radio'));

  return '
Hello -
<input' . drupal_attributes($element['#attributes']) . ' />';
}

And this is how my form element looks like:

**************** Rest of Form *************
  $form['comment_preview'] = array(
    '#type' => 'radios',
    '#title' => t('Preview comment'),
    '#options' => array(
      1 => t('Yes'),
      0 => t('No'),
    ),
    '#theme' => 'MY_MODULE_radios',
    '#theme_wrapper' => array(),
  );
**************** Rest of Form *************

Why is theme_MY_MODULE_radio() never called?


texts: Drupal Commerce - ability to close shop (restaurant/takeaway)

texts:
Looking for the best solution for this. Ideally I would like it to be similar to how we put a Drupal website in and out of maintenance mode.

It would need to disable the add to cart button and change the text to Restaurant closed or something similar.

I would then as well like to have a message on the site in the header somewhere that says Open or closed for business.

I have some minimal module development experience so looking to advance my skills with this one and get stuck into some further development.

What I really need is someone with a better understanding of drupal to point me in a good direction so that I can figure this one out.

Appreciate any words of wisdom here.


texts:
I have a task to do a Drupal migration and was given a database backup and a backup of all the web files. It was a Drupal 7 site but I have no further information as to what modules and themes were used. I need to get it up and running on Windows IIS6 enviroment with FastCGI and ISAPI Rewrite running with a MySQL 5 backend. This is a staging environment.

I have
1. rebuilt the database in MYSQL from the sql dump
2. unpackaged the web files into the webroot
3. configured settings.php to point to the DB

and all I got was WSOD so I added

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

to the beginning of index.php to get a better handle on errors

I got "Fatal error: Call to undefined function: user_access() in menu.inc"
so I checked the system table but

system.module
node.module
user.module
filter.module
block.module

All check out- with status="1" and correct filepaths in data- e.g. module/system/system.module etc.

I have then tried truncating the cache (went directly in to the DB) and tried

TRUNCATE TABLE cache;
TRUNCATE TABLE cache_block;
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_field;
TRUNCATE TABLE cache_filter;
TRUNCATE TABLE cache_form;
TRUNCATE TABLE cache_image;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_page;
TRUNCATE TABLE cache_path;
TRUNCATE TABLE cache_token;
TRUNCATE TABLE cache_update;

this caused a slew of PHP Warnings that eventually righted itself as cache started rebuilding.

Am now in state where the page only shows multiple instances of one warning.

Warning: array_merge(): Argument #2 is not an array in theme_get_setting()
(line 1461 of C:\Sites\public_html\includes\theme.inc).

But now having finding any info on how to proceed from here. Apologies as this my first time doing a Drupal migration.Do have a copy of all the original backps so I can start agin from scratch as necessary.


texts: Unable to import due to "Field 'sourceid2' doesn't have a default value"

texts:
I am using the awesome module Migrate, but I have problem, which I am unable to solve. I try to migrate articles from custom PHP site with MySQL DB to D7 with MySQL. The generated SQL query from my migration is ok when I run it in my MySQL DB using MySQL CLI. But when I try to migrate it using the Migrate UI, I get an error:

  An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging
  information follows. Path: /batch?id=113&op=do StatusText: Service
  unavailable (with message) ResponseText: PDOException:
  SQLSTATE[HY000]: General error: 1364 Field 'sourceid2' doesn't have a
  default value: INSERT INTO {migrate_map_geografbgarticlenode}
  (sourceid1, needs_update, rollback_action, hash) VALUES
  (:db_insert_placeholder_0, :db_insert_placeholder_1,
  :db_insert_placeholder_2, :db_insert_placeholder_3); Array (
  [:db_insert_placeholder_0] => 2 [:db_insert_placeholder_1] => 3
  [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => ) in
  MigrateSQLMap->saveIDMapping() (line 434 of
  ~/drupal/dev/sites/all/modules/migrate/plugins/sources/sqlmap.inc).

It seems the problem is with my MigrateSQLMap function, looks like N.id is NULL when the query is run by Drupal. But I triple checked it before posting, it's not nullable field in DB and in the generate query result. Any idea how can I fix it?

$query = Database::getConnection('default', 'legacy')
      ->select('news', 'N')
      ->fields('N', array('id', 'category_id', 'createdon', 'updatedon', 'createdby', 'updatedby'))
      ->fields('L', array('code'))
      ->fields('NT', array('name', 'short_description', 'description'))
      ->fields('G', array('id', 'description'));
    $query->leftJoin('news_translations', 'NT', 'NT.target_id = N.id');
    $query->leftJoin('languages', 'L', 'NT.language_id = L.id');
    $query->leftJoin('tags', 'T', 'T.news_id = N.id');
    $query->leftJoin('gallery', 'G', 'G.target_id = N.id');
    $query->addExpression('GROUP_CONCAT(LOWER(T.tag))', 'tags');
    $query->groupBy('N.id');
    $query->orderBy('N.id', 'ASC');

    $this->source = new MigrateSourceSQL($query);
    $this->destination = new MigrateDestinationNode('article');

    $this->map = new MigrateSQLMap($this->machineName,
        array(
          'id' => array(
            'type' => 'int',
            'unsigned' => TRUE,
            'not null' => TRUE,
            'description' => t('Article Source ID'),
            'alias' => 'N',
          ),
        ),
        MigrateDestinationNode::getKeySchema()
      );

    //... not relevant


texts: I have added a few custom nodes to my website via the admin CMS. I wanted to know if I would have to explicitly add them to cache or if the nose_save or one of the internal drupal methods would add it to cache? I am using memcache for my caching purposes.


texts:
I am overriding the fields template

views-view-fields--machine_name.html.twig

I want to render some Fields in a different div than the other fields.  I do not want the fields to render twice.

<div class="foo">
  {{ fields.field_events_date_start.content }}
  {{ fields.field_events_date_start_1.content }}
</div>

{% for field in fields -%}
  {{ field.separator }}
  {%- if field.wrapper_element -%}
    <{{ field.wrapper_element }}{{ field.wrapper_attributes }}>
  {%- endif %}
  {%- if field.label -%}
    {%- if field.label_element -%}
      <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }}</{{ field.label_element }}>
    {%- else -%}
      {{ field.label }}{{ field.label_suffix }}
    {%- endif %}
  {%- endif %}
  {%- if field.element_type -%}
    <{{ field.element_type }}{{ field.element_attributes }}>{{ field.content }}</{{ field.element_type }}>
  {%- else -%}
    {{ field.content }}
  {%- endif %}
  {%- if field.wrapper_element -%}
    </{{ field.wrapper_element }}>
  {%- endif %}
{%- endfor %}

If I exclude those Fields from the display in Views it hides them both when they render before and in the normal content area.

{{ content|without('field_events_date_start,field_events_date_start_1') }}

...Does not work because I am rendering Fields, not content.

How do I get the fields to render before, but be excluded later?


texts:
When using the drush site-upgrade (drush sup) to do a D6 to D7 upgrade, does the target database need to be pre-filled with D6 tables? Or can it be completely empty?

Thanks


texts: Migrate WordPress featured image into to Drupal content type

texts:
I have a Drupal 8 site and I've installed the WordPress Migrate module and its dependencies for migrating a WordPress site to Drupal 8.

All things are done and imported successfully with help of this post. But I can't Import the featured images and map it to the image field in the Drupal site content type.

anyone have a solution for this?

Thanks


texts:
How do I remove the itok token from the image URLs?

I found an article discussing it, but it only works for Drupal 7 (https://www.drupal.org/node/1934498).

Some articles explains why Drupal adds tokens to the image URLs.

http://www.unimitysolutions.com/blog/image-style-token-itok-drupal
Why is Drupal adding token on image url


texts: Create link to node in specific language

texts:
So I need to create links to specific translations of a node but am having issues.
This is my code:
foreach($entities as $entity) {
$urls[] = Url::fromRoute('entity.node.canonical', [
        'node' => $entity->id(),
        'language' => $entity->language()->getId(),
      ]);
}

$entity in this context is EntityInterface.
But this gives me /node/1185?language=es instead of /es/node/1185.


texts: On hook_entity_presave how do I now if it is a new node?

texts:
I'm using the hook

function nvgh_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
}

but I only need to do something when the node is new (not when it is edited). How to do this? I'm inspecting the entity with kint but cannot find a good indicator for this... also kint is disappearing as the node view is redirected into view modes.

How to do this?


texts: Making contextual filter conditions "OR" vs. "AND" in Drupal7

texts: I have a view that needs to allow for the "OR" of a set of contextual filters (filtering on node references) rather than what appears to be the default of "AND". In the answer to a previous question here, someone suggested that there was a way to do this by changing the first filter group from OR to AND. My problem is that I am unable to find the menu to make this change.


texts: Is it possible to alter $form_state before it is passed to user_profile_form_submit?

texts:
I have a form posting updates to the user account.
The problem is I need to add some more data to the post object before user_profile_form_submit gets a hold of it.

Is this possible in Drupal 7?


texts: Javascript libraries not loading from block class

texts:
I am working on porting module to drupal 8.

My block code is as follow

public function build() {
  $delta= $this->getDerivativeId();
  $num           = str_replace('dexp_layerslider_block_', '', $delta);
  $sid = $this->configuration['dexp_layerslider_block_slide_'.$num];
  $block_id = $this->getDerivativeId();
  $slideshow = dexp_layerslider_load($sid);
  if (!$slideshow){
     return 'No slider selected';
  }
  $content =   array(
      'id' => $sid,
      'slides' => $slideshow->slides,
      'settings' => $slideshow->settings
     );
   return array(
     '#theme' => 'dexp_layerslider_slides',
     '#items' => $content,
     '#attached' => array(
        'library' => array('dexp_layerslider/dexp.block'),
        ),
      );
}

my yaml file:

dexp.slides:
  version: 1.x
  css:
    theme:
      plugins/font-awesome/css/font-awesome.min.css: {}
      css/admin.style.css: {}
      plugins/rs-plugin/css/settings.css: {}
  js:
    js/dexp.layerslider.js: {}
    js/layeroption.js: {}
    js/admin.layerslider.js: {}
    plugins/rs-plugin/js/jquery.themepunch.revolution.min.js:  {}
    plugins/rs-plugin/js/jquery.themepunch.tools.min.js:  {}
 dexp.block:
  version: 1.x
  css:
    theme:
      plugins/rs-plugin/css/settings.css: {}
      css/layerslider.css: {}
  js:
    plugins/rs-plugin/js/jquery.themepunch.revolution.min.js:  {}
    plugins/rs-plugin/js/jquery.themepunch.tools.min.js:  {}
  dependencies:
    - core/drupal
    - core/jquery

my theme function :

  $themes['dexp_layerslider_slides'] = array(
    'template' => 'slides',
    'path' => $path . '/theme',
    'pattern' => 'layerslider__',
    'preprocess functions' => array(
      'template_preprocess',
      'dexp_layerslider_preprocess_slides'
    ),
    'variables' => array('items'=>null),
  );

None of  javascript and css files are load , when i try to access items in twig template {{ items }} nothing gets printed , though if write random string in the my slide.html.twig file it get printed. where i could be going wrong?


texts:
I'm new in Drupal7, I created a webform using webform module and I created a template for my customised html e-mail with HTMLMail module that will be sent on webform submission.
I want to put every value from the webform on a table but I don't know how to get the values entered in the webform on submission?
For example I want a result e-mail like this

Hello, Thank you for your registration

Name:          "webform_name_field"

Last Name :    "webform_lastname_field"

Adress :       "webform_adress_field"

How can I get every value of my webform ??


texts: What is the replacement of drupal_match_path()?

texts:
What is the replacement of drupal_match_path() in Drupal 8?
The following function is removed from Drupal 8. How can I achieve same functionality in Drupal 8?

function drupal_match_path($path, $patterns) {
  $regexps = &drupal_static(__FUNCTION__);

  if (!isset($regexps[$patterns])) {
    // Convert path settings to a regular expression.
    // Therefore replace newlines with a logical or, /* with asterisks and the <front> with the frontpage.
    $to_replace = array(
      '/(\r\n?|\n)/', // newlines
      '/\\\\\*/', // asterisks
      '/(^|\|)\\\\<front\\\\>($|\|)/', // <front>
    );
    $replacements = array(
      '|',
      '.*',
      '\1' . preg_quote(config('system.site')->get('page.front'), '/') . '\2',
    );
    $patterns_quoted = preg_quote($patterns, '/');
    $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
  }
  return (bool) preg_match($regexps[$patterns], $path);
}


texts:
I'm trying to save a node (with the normal node form) via an ajax callback. The first save works. But after that I want to return the same node form again so that the user can update the values and save the node again. But this second save attempt fails. I always get a message like "this form has already been submitted". Are any solutions for this problem? Or shall I write a custom JS menu hook which saves the node programmatically?

Here are the relevant parts of my module

function MYMODULE_form_finding_node_form_alter (&$form, &$form_state){
  $form['#prefix'] = '
';
  $form['#suffix'] = '
';
  $form['actions']['submit']['#ajax'] = array(
    'callback' => 'MYMODULE_finding_node_form_submit_ajax',
    'wrapper' => 'finding-form-wrapper'
  );
}

function MYMODULE_finding_node_form_submit_ajax($form, &$form_state){
  $form_id = '#' . str_replace('_','-',$form['#form_id']);
  $commands = array();
  $commands[] = ajax_command_remove('.l-messages');
  if(form_get_errors()){
    $commands[] = ajax_command_replace($form_id, '

');
    $commands[] = ajax_command_replace('#finding-form-wrapper', drupal_render($form));
  }
  else{
    $node = $form_state['node'];
    $form_state = array();
    $form_state['rebuild'] = TRUE;
    $form_state['build_info']['args'] = array($node);
    $form = drupal_build_form('finding_node_form', $form_state);
    $form['#id'] = str_replace("_", "-", $form_id);

    $commands[] = ajax_command_replace($form['#id'], drupal_render($form));
  }
  $commands[] = ajax_command_prepend('.page', '

' . theme('status_messages') . '

');
  return array('#type' => 'ajax', '#commands' => $commands);
}


texts: Changing the default imagefield formatter for a node field

texts:
I am trying to change the default formatter for an imagefield node form field so that it will default to the thumbnail image and not the icon. I have already tried a form alter and that isn't doing a damn bit of good. I have already flushed all the cache. So I was wondering if anyone else knew how to do this.

I am running Drupal 6 by the way. The field in question is using imagecache presets.


texts: How can I display a search form with a different style from search bock, inside a node?

texts: I have a search block enabled at top side of my site. But I also need to display the same search form, but with different css class applied inside a node. How this can be done?