texts: How to ignore opening quote in views sort

texts:
I use views to display a sorted list of book titles. Titles that begin with a quote are listed first. I want to ignore the quote for sorting purposes. So, instead of:

"Once Upon a Time": Fairy Tales in Reality
Grimm's Fairy Tales
The Best Book of Fairy Tales

I want:

Grimm's Fairy Tales
"Once Upon a Time": Fairy Tales in Reality
The Best Book of Fairy Tales

It appears the Views Natural Sort module will handle this, but it's still in Alpha for Drupal 8. Is there another, relatively straightforward (non-custom-code if possible) means of accomplishing this?

I've read a number of posts addressing more complex situations with fairly complex solutions, but it seems something this simple should have a simple solution.


texts: How do I delete a vote (e.g.rate module)?

texts: Is there a module with a functionality to delete votes using the voting api? If not, how do I implement a button that erases all votes? Or is it easier if I just empty the MYSQL table?


texts: How can I get term id or term name on user profile page

texts:
I have a vocabulary(lessons) with terms as math,art,chemistry etc..

These terms are on user page in my lesson field.
For example:
My Lessons: Math,Geography,Art

Scenario: I'm gonna use linked field with different destination. When I click math term on user page It will goes to view page with path ../teacher/math to list all related teachers.
Views page is ok no problem.
But I can't get term name or id on user page. No available tokens.
Terms new linked destionation as  teacher/[my_lessons:term:name]

I've tried

teacher/[my_lessons:term:name]
teacher/[my_lessons:term:tid]
teacher/[my_lessons:name]
teacher/[current-page:user:field-my-lessons:tid]
teacher/[current-page:user:field-my-lessons:name]

None of them work.

teacher/[current-page:user:field-my-lessons] gets all term name.

How can I get users lessons term name or id ?


texts:
I am using Drupal Commerce in that user can add a product to cart. If user add same product for five times, cart contains same product for five times. What I need is when user adds same product again and again it should reset to 1. I have include the following lines still I am getting the same.

function dt_admin_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state) {

   $form_state['line_item']->data['context']['add_to_cart_combine'] = TRUE;

   return $form;

}


texts: How do I translate empty text of a view?

texts:
I have created a view with empty text using PHP code. Now, when I try to translate it through the translation interface (admin/build/translate/search), while I find the string (it show up all the PHP code) and translate it (I did it by adding the PHP code again with the translated strings), when I change the language of my site I see nothing. When I come back to English, it showed up correctly.

Does anyone have any idea?


texts:
In my page.tpl.php I have 2 different sections nl. $page['section_orange'] and $page['section_contact'].

What I want is for my block.tpl.php to print my heading in h2 when a block is listed in the $page['section_orange'] section and in h4 in the $page['section_contact'] section.

How can I achieve this from within my block.tpl.php template.
Or do I need to create a hook within my template.php?


texts: Multiple aliases based on taxonomy terms

texts:
I have a content type which has a categories field that contains values from A-C. This is a multi-select list as below.

I have configured the URL pattern as below.

categories/[node:field-token-of-term-reference-field]/[node:title]

As long as I select a single value from the list, the URL looks alright. example.com/categories/a/planning

The issue is when I need to assign multiple categories for a given node. Then the URL becomes example.com/categories/a-b/planning instead of one alias for example.com/categories/a/planning and another for example.com/categories/b/planning

My search engine doesn't like all categories in one URL and the preferred method is to have a URL per category. Is this even possible from Drupal?


texts: How can I query a webform in all instances at once to export a file?

texts:
We recently had a security breach and those making the decision opted to remove the capability of end users to create the file upload component.
What I am hoping to do is two-fold:
1.) Use drush sql-query to iterate through all our databases and return all webforms using the file upload component. Optimally this output would need to be sent to a .txt file or something similar so that we know which webforms to address and which sites were using it.
I am hoping to use sql-query with a SELECT statement to look at the webform_component table to get this data so that we can take action.
I know how to drush simple things to a text file, on each database directly (drush @cms.name_of_database site-alias >all.txt), and I know how to use drush sql-query to UPDATE but I do not know how to iterate through each of our databases and then output the results of the query into a single .txt file.
2.) Use Drush to disable the file component (Configuration > Content Authoring > Webform Settings) to uncheck the file component.
We have about 300 sites so we are really hoping we can avoid having to manually configure this across all 300 databases/sites.
Note: I am not trying to export/import content types, I am trying to query our databases via drush and output the results into a .csv or other file type. My second issues is that I need to iterate that script across all 300 databases we have and output the results to either a single file or a file for each db


texts: Why methods valueValidate and valueSubmit don't execute?

texts:
I'm trying to create a views filter containing an exposed form.

The filter class is inherited from FilterPluginBase. In principle, the filter almost works, but I have run into a strange problem.

I want to modify some data upon submitting the exposed form and use for it a method valueSubmit.

Here is the code of my filter class.

/**
 * Class PalomGeoFilter
 * @package Drupal\field_elements\Plugin\views\filter
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("palom_views_geo_filter")
 */
class PalomGeoFilter extends FilterPluginBase {

  public function valueForm(&$form, FormStateInterface $form_state)
  {
    parent::valueForm($form, $form_state);

    if ($form_state->get('exposed')){

      $form['country_id'] = [
        '#empty_option' => t('Select a country'),
        '#type' => 'select',
        '#title' => t('Country'),
        '#options' => PalomGeo::getCountryList(),
        '#default_value' => 2,
      ];

      $form['region_id'] = [
        '#empty_option' => t('All the regions'),
        '#type' => 'select',
        '#title' => t('Region'),
        '#options' => PalomGeo::getRegionList(2),
      ];

      $form['value'] = [
        '#type' => 'hidden',
        '#default_value' => '2_0',
      ];
    }
  }

  protected function valueSubmit($form, FormStateInterface $form_state)
  {
//    parent::valueSubmit($form, $form_state); // TODO: Change the autogenerated stub

    $form_state->setValue(['value'], '49_0');
  }

  public function query()
  {
///
  }

}

But somehow this method doesn't want to be executed. I tried to make a breakpoint inside that method for XDebug or output a message using drupal_set_message, but it isn't executed.

What can be a reason for it?

Has anybody encountered it?


texts: How do I create a menu item when a node is submitted?

texts: I have created a new content type and want to add a menu item every time a user creates a new node for this content type.  I can catch the submission using hook_node_submit, but I don't know how to add it to a menu from there.


texts: How does data propagate from the formElement of a Widget to the properties of a FieldItem?

texts:
Here is my custom Widget:

<?php

namespace Drupal\scripture\Plugin\Field\FieldWidget;

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;

use Drupal\my_module\Plugin\Field\FieldType\MyFieldItem;

/**
 * Plugin implementation of my custom widget.
 *
 * @FieldWidget(
 *   id = "my_widget",
 *   label = @Translation("My Widget"),
 *   description = @Translation("A Widget belonging to me"),
 *   field_types = {
 *     "my_field_type"
 *   },
 *   multiple_values = FALSE,
 * )
 */
class MyWidget extends WidgetBase {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $element['#type'] = 'fieldset'; // just to show the title and put a nice frame around it

    $element['verse'] = array(
      '#type' => 'verse_picker', // This is a custom Element defined elsewhere.
    );

    /** @var MyFieldItem $item */
    $item = &$items[$delta];

    // If the item is not empty, populate the form element
    if (!$item->isEmpty()) {
      // ...
    }

    return $element;
  }

}

And here is my custom FieldType:

<?php

namespace Drupal\scripture\Plugin\Field\FieldType;

use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;

/**
 * Plugin implementation of my field type.
 *
 * @FieldType(
 *   id = "my_field_type",
 *   label = @Translation("My field Type"),
 *   description = @Translation("A FieldType belonging to me."),
 *   default_widget = "my_widget",
 *   default_formatter = "my_formatter"
 * )
 */
class MyFieldItem extends FieldItemBase {

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    // Prevent early t() calls by using the TranslatableMarkup.
    $properties['from'] = DataDefinition::create('integer')
      ->setRequired(TRUE);

    $properties['to'] = DataDefinition::create('integer')
      ->setRequired(TRUE);

    $properties['abbr'] = DataDefinition::create('string')
      ->addConstraint('Length', [
        'max' => 8,
      ])
      ->setRequired(FALSE);

    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    $schema = [
      // ...
    ];
    return $schema;
  }

  /**
   * {@inheritdoc}
   */
  public function isEmpty() {
    return empty($this->get('from')->getValue()) || empty($this->get('to')->getValue());
  }

}

Whenever I save a field, the properties stay NULL. Even when I use xdebug to inspect every call to isEmpty(), $this never has any populated properties. How does the user input get from the form element to the field item's properties? I could not find Drupal documentation on the matter.


texts:
Datepicker is not working. This code working with Drupal 6, but not with Drupal 7.

drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/jquery-1.4.1.js', 'module');
drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/jquery.min.js', 'module');
drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/jquery-ui.min.js', 'module');
drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/datepicker.js', 'module');
drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/ztfb_datepicker.js', 'module');
drupal_add_css(drupal_get_path('module', 'PROPERTY') .'/jquery/ui.all.css', 'module');

drupal_add_js(drupal_get_path('module', 'PROPERTY') .'/jquery/scrollJump.js', 'module');

$(document).ready(function() {
  $("#startdate").datepicker({
    dateFormat:'dd-mm-yy',
    autosize:false,
    changeYear:true,
    changeMonth:true
  });
});

I include the file in PROPERTY_Form.admin.inc file.

require_once("D://wamp/www/propertysite/cron/includes/jquerydatepicker.php");

function PROPERTY_Form() {
  global $user;
  $form = array();

  $form['PROPERTY_Form']['startSyncFrom'] = array(
    '#type' => 'textfield',
    '#prefix'=>'
',
    '#suffix'=>'
',
    '#id'=>'startdate',
    '#default_value'=>date('d-m-Y'),
    '#description' => '(You can select any past date to ensure even your old Data gets synced)',
    '#attributes'=>array('tabindex'=>9,'style'=>'width:70px;'),
  );

  return $form;
}


texts: Using rules to populate a field with the output of pdfprevew

texts:
I have a field (public_files) that accepts file uploads to which I have applied the pdfpreview module which provides a field formatter that will provide the generated image for pdf files.  I have another field for cover images.

This setup is working well, and I basically default to the cover image field, and fallback to the pdf preview version of the first file if the cover image hasn't been provided.  A problem arises for a section of the site where I only want to list items that have cover images.  There is a complicated bug in drupal that prevents me from doing the filtering in views to only items that have a cover image or for which the first file is a pdf file.

To alleviate this, what I'd like to do is use rules to automatically populate the cover image field with the generated cover whenever there is a generated cover image, and the cover image field is empty.

Sorry for the long preamble, here is the question:

Is there any way to get at the pdf preview image and populate an image field with it in rules?


texts: How to display list of nodes that share the same Parent taxonomy term as current node

texts:
I have a vocabulary set up called (for example) "Produce". And it has parent terms like "fruit" and "vegetable". Child terms are like "banana", "apple" and "cucumber", "squash".

Whenever I create a new node about fruit or vegetables, I use a content type that I created.
In this content type, I have a field set up called "field_produce_and_name". So when I create a new "Fruit" page, called "papaya", I also create "papaya" as a child taxonomy term to "fruit". And I set the field field_produce_and_name to "papaya".

When someone is viewing the "papaya" page/node, I would like a sidebar menu list to display the titles of other "fruit" nodes. That is, a list of nodes that share the Parent taxonomy term as "papaya".

I have tried using the contextual filter "Content: Has taxonomy term ID (with depth)" but it still isn't working :(

I also think that maybe I need to add a relationship, but am unsure how/which one.

Any ideas?


texts: Getting field label with entity_metadata_wrapper

texts:
Say I am iterating through a list of field names, and I have loaded a particular node using entity_metadata_wrapper().

$wrapper = entity_metadata_wrapper('node', $node);

Shouldn't I be able to just grab the label by using the following command?

Or is this not the correct command to do what I want?

        foreach($field_names as $item)
        {
           $label = $wrapper->$item->label();
        }

Here's the field as it is in the actual node:

'field_grade_comment' =>
    array (size=13)
      'default_value' => null
      'description' => string '' (length=0)
      'display' =>
        array (size=4)
          'default' =>
            array (size=5)
              ...
          'email' =>
            array (size=5)
              ...
          'teaser' =>
            array (size=4)
              ...
          'node_reference_embedded_view' =>
            array (size=4)
              ...
      'label' => string 'Grade Comment' (length=13)


texts: How can I change tag separator from "," to "+"?

texts:
I want to change tag separator in a Term reference field of my content type (using Autocomplete term widget (tagging)) from "," to "+" or maybe something else (in Drupal 7) because this field needs to be filled in Persian.
What shoud I do ?
thanks.


texts: How to allow a role to add user without adding user name, password, roles, etc

texts:
I created a role. I would like the users of the role be able to add some people without entering user name, password, roles, active, etc. These people that the role will add are actually customers. When we get new customers, specific role users will login to the system and add the customers to the system and these people/customers do not need to access the system.

I did search google and i found this site link but I could not follow it.

Do you know how I can do it?

I thought about it. Here is the problem. After I add the customers, I need to be able to link each customer to another module content(e.e. xxx.com/module/add). The module that I am using it has a field which allows to select a user only exists in the system. If I create a content type 'customer' like you said, module field does not see these customers when i go to xxx.com/module/add. Module field only sees these customers if they are users of the system. Not sure how to proceed?

Other module name is simple reservation which has a field 'This reservation is for'. This field is only takes users names from the system.

sr_week.tpl.php has the below code to get the users ( i guess)

<div id="srFor">
          <?php if (($reservation["for_uid"] > 0) && ($reservation["uid"] != $reservation["for_uid"])) {
              print(" (". t("for") ." ". l($for->name, 'user/'. $for->uid)) . ")";}
              else print("&nbsp;");?>
        </div>


texts: Create a menu block with images in Drupal 8 & keep menu order

texts:
On the 1st level pages from our main menu I would like to list all the 2nd level child page titles from that page and corresponding images from those children  pages' content fields. I would like them ordered the same as they are in the menu. I am using the path-auto pattern of [parent-url]/[page-title]. I'm open to any suggestions on how to do this.

I've looked into trying to create this with a view block or even a view REST feed but it appears I cannot get attributes from a menu in views in Drupal 8 to use to sort or filter the items. I tried to do this with a menu block but it appears I cannot add fields such as an image to show.


texts:
I am new to drupal, I read some introductory tutorial.

I notice there is some theme() function in template files.

Like this:

<?php print theme('uc_price',array('price'=>$price)); ?>

It will generate some html source code:

$59.85

Is it theme() function is only to generate the html source? If this is the case, why I need use theme() function? I Think just only write html source manually.

I use Zen base-theme, Does theme() is one of zen's native function?

Please tell me the real usage of "theme()".


texts: I got a notice every time I upload an image

texts:
Suddenly, I got this error every time I want to upload an image. It does not matter if it is an file field, or an IMCE import to CKeditor. I got the message, and the image does not upload. Do you have any idea?

  Notice:getimagesize() [function.getimagesize]: Read error! in image_gd_get_info() (line 349 of /www/mysite.com/modules/system/image.gd.inc

My "tmp" and "sites/files" directories have the permission 777, php5-gd is already installed.
I have also problems uploading attachments files, after upload them the size of the file is 0 bytes.

In this conversation, they suggest two solutions: one is changing the path of the "tmp" directory, but it doesn't work for me; the other is related to favicon set.
I remember that I uploaded a favicon in theme settings as I always do, and I think after that I began to have the issue. I am not really sure if it is related because this bug happened in older versions of Drupal.

Some images of my problems.


texts: How can I encapsulate Drush command with option to use arguments

texts:
I have a drush command for installing a Drupal website with configuration in it. I do not want to type this command with all the configuration all the time because it is long so I would like to encapsulate the command as alias but I still want to pass additional arguments to the original command.

Specifically I need to pass at least the db url since that will always be different.

I was thinking something like this: drush install-mysite --db-url="..."

So basically any argument that is provided to my alias would override the defined argument defined in my alias.

From what I have read this could be done with drush aliases but I am not sure about the syntax and the arguments themselves. Another way is to create a new drush function but I think alias is simpler and I don't need any additional functionality.

This is for Drupal 8 so Drush 7 but I think it is not that relevant.


texts: Theming Views, getting a list of object I have access of

texts:
I'm Currently trying to theme a view.
Unfortunately I'm having a hard time to find elements I should use to access my fields.

Is there any where on the web, where I could find those variables ? or the parent one, that will allow me to find out other by searching down.


texts: Is there a reliable way to see what other users see when logged in?

texts:
I've found the Impersonate and Masquerade modules, but the first is for Drupal 5 (I remember the hardest thing about Drupal 5 development was having to keep an eye out to avoid being lunch for a hungry T Rex) and the second is still a release candidate (for Drupal 7) and is "minimally maintained".

Is there another, better way?  Or can anyone vouch for the stability of Masquerade?


texts: calculate nested field collection with computed field

texts:
I have this complex collection field in content type

collection field "parent"

 - computed field "a" (sum all computed field "b" listed in collection field "a")
 - collection field "a" (unlimited value)
 *******************************************
               - - computed field "b" (sum of "Result" listed in collection field "b")
               - - collection field "b" (unlimited value)
               ********************************************
                                    - - - num1
                                    - - - num2
                                    - - - Result computed field (sum num1 + num2)

so how can i do this or what the computed code which must write in each computed field for each one


texts: Add allowed values list programmatically in drupal CCK field “list_text”

texts:
I was wondering if i can create programmatically a CCK field instance and insert the "allowed_values" in a single stage. So i tried this:

 field_create_instance(array(
  'field_name' => 'card number',
  'entity_type' => 'payment_method',
  'bundle' => 'debit_card',
  'label' => t('Debit/Credit card'),
  'description' => t('Add card\'s number '),
  'widget' => array(
      'type' => 'options_select',
      'weight' => 0,
      'settings' => array('size' => 50),
   ),
  'required' => TRUE,
 ));

I've tried some cases i.e to set in 'settings' => array( 'allowed_values' => array( 1, 2, 3 ) ) but nothing happened. Any suggestions?


texts: View block listing nodes with lower/higher Nodequeue position

texts:
I'm trying to build up two blocks for nodes with a Nodequeue position, one above the node listing nodes with lower Nodequeue position and one below the node listing nodes. It should look like a list of linked titles and a full node display in between:

Node A (Linked title only, Nodequeue position: 1)
Node B (Linked    title only, Nodequeue position: 2)
Node C (Current full node display, Nodequeue position: 3)
Node D (Linked title only, Nodequeue position: 4)
Node E (Linked title only, Nodequeue position: 5)

Clicking the title of "Node D" should result in this:

Node A (Linked title only, Nodequeue position: 1)
Node B (Linked title only, Nodequeue position: 2)
Node C (Linked title only, Nodequeue position: 3)
Node D (Current full node display, Nodequeue position: 4)
Node E (Linked title only, Nodequeue position: 5)

I've tried Contextual Filters in Views, but couldn't find a way to limit the list to nodes with lower/higher Nodequeue position.

Any Ideas?


texts: Our company is looking to use Drupal as a platform going forward. We plan on making some modules for in house use only i.e. A module to talk to our holiday system. We wanted to know the best way to host these internally so people can browse the modules. Is it possible to get Drupal to report when a custom module is out of date?


texts: OG how to contrain a group to a maximum number of users

texts: I would like to restrict groups to a certain amount of members. Is there any ways to do so?


texts:
Here is my code:

function THEME_preprocess_block(&$variables) {
    $variables['user_profile'] = menu_get_object('user');
}

I print the field "name" using print $user_profile->name, and I get the following error:

  Notice: Trying to get property of non-object in include() (line 71 of SITE\sites\all\themes\parce\block--block--2.tpl.php).

I assumed $user_profile was not an object and I tried print render($user_profile['name']), which returned me:

  Fatal error: Cannot use object of type stdClass

What is going on? I checked the Drupal API reference, and menu_get_object() should return me an object.


texts:
I've this breadcrumb I've created, where I would like to show it as

Home > Main menu > Sub menu

Where sub menu is connected to a node. So when a user click on node, it must show the breadcrumb of the above format.

I've done this, but it is only giving

Home > Sub menu

Menu is missing.

function basis_preprocess_breadcrumb(&$variables) {
  if (($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']) {
    $variables['breadcrumb'][] = array(
      'text' => $node->getTitle(),
      'url' => $node->URL()
    );

  }
}


texts: How do I use the Hierarchical Select module?

texts:
I'm a total newbie in Drupal.

I have successfully installed Drupal 7 in my WAMP installation, downloaded the Hierarchical Select module, put it in the sites/all/modules folder, and enabled it.

How can I now use it? I don't see any option.


texts:
Hello I'm building a multilingual (en/el) website using views panels taxonomy etc etc and other modules.All was fine with the world when suddenly I decided to customize the page-node by adding a panel layout which I created. The problem is that even when I saved the panel layout and the content on /node/%node nothing happened when I view an article. The article page ?q=node/3 for example remains unchanged.

I'm trying 2 says to find the solution but no luck at all.
Any info will be greatly appreciated, thnx in advance.


texts:
We can create reset password block by \Drupal::formBuilder()->getForm('Drupal\user\Form\UserPasswordForm') in d8, but change password block \Drupal::formBuilder()->getForm('Drupal\user\Form\UserPasswordResetForm') didn't work for me.
This is my code:

public function build(Request $request) {
  $session = $request -> getSession();
  $session->set('pass_reset_hash', $hash);
  $session->set('pass_reset_timeout', $timestamp);
  $user = \Drupal::currentUser();
  $expiration_date = $user->getLastLoginTime();

  $myblock = \Drupal::formBuilder()->getForm('Drupal\user\Form\UserPasswordResetForm::class', $user, $expiration_date, $timestamp, $hash);
  return array(
    '#type' => 'markup',
    '#markup' => drupal_render($myblock),
  );
}


texts:
I am adding a caption to images by using the following module: https://www.drupal.org/project/image_field_caption

For the front page I am using views. There, I also show the images but I do NOT want to show the captions. I guess the captions can be stripped away by using CSS...

How is that done? I do not know CSS and the "interaction" of Drupal and CSS very well.

My questions:
1. Where do I have to add the CSS code?
2. What do I have to write there?
3. How is this CSS snipped included in views to get the effect of stripping caption away?

Thanks!


texts: how to get current bloc config from hook_theme in drupal 8?

texts:
i have created a plugin block and call the hook theme on build()

$output[] = [ '#theme' => 'amu_news' ];

from this hook_theme

function amu_news_theme($existing, $type, $theme, $path) {

i would need to access to the block form config values .

what object and method can use?


texts:
In a form_alter, I simply want to add a class to an exposed form (this code works for a custom form) :

$form['#attributes']['class'][] = 'my_class';

But neither my class nor the default class (views-exposed-form, I can see it in $form['#attributes']) is printed in front in the form tag.

Any idea?


texts: "View any coupon of any type " permission for anonymous reduces the Score in acquia

texts: In my e-commerce website, anonymous user can't able to view the add coupon field until and unless I gave "View any coupon of any type" permission. Because its having notice like this: Warning: Give to trusted roles only; this permission has security implications. Acquia Reduced the score of our website.So any other way is there to solve this problem?


texts: How do I install the Spark distribution using only Drush?

texts: How do I fire up the Spark Distribution via a drush command?


texts: Is it possible to change the table class when using drupal's format table for view. It seems to allow me to only change the row class.


texts: How to make node hierarchy with siblings and child pages

texts:
I want to make a node hierarchy menu which will display the child pages and siblings if child pages don't exist. I want to have the following structure

parent
   child
   child
   child
or

parent
   sibling
   sibling


texts: How can I add my Bootstrap classes to a custom menu?

texts:
How can I add different Bootstrap menus to menu_tree_output()?

I know this is a very common question asked by a number of people earlier. I have found tons of answers, but none of them are working for me. However, I have tried a number snippets and here is the latest piece of code I am working on to get all menus and sub-menus.

<?php
  $menuTree = menu_tree_all_data('main-menu');
  $menu_tree_array = menu_tree_output($menuTree);
  print render($menu_tree_array);
?>

It works and prints all the submenus, however, It adds the same "menu" class to all parent ul. Rather I would like add sub-menu classes like the below output:

        Home

        Biography

        Services


texts: Drupal Custom Search Results Per Content Type

texts:
So I have a View that is a list of all content on my site. I have an exposed form in a block that is "Search Terms". I have a custom template for my view to customize the results page. I have a couple of content types including "Products" and "Locations".

I'd like the Products to be displayed in a grid format with their corresponding product images and the Locations to be displayed in a list with a corresponding map. What would be the best way for me to accomplish this?


texts:
Hello fellow druaplistas!

I have a situation where I need to output an image field using different image styles depending on some checkbox settings.

I'm doing this inside a node template. Basically this goes like this:

if ($layout == 1) {
  print $small_image;
}
if ($layout == 2 {
  print $medium_image;
}

To get the url to the correct sized image I can use image_style_url, but this way I have to build the links to the bigger version to open inside colorbox manually.
Is there some function available that I can pass two image styles and it uses them to generate an image tag wrapped with a link to the bigger sized image?

Update:
I took Clive's code (thanks again) and added a second parameter to be able to choose the preset that will be shown inside the colobox. Also Title and Alt is now included:
As your code was better than mine I took it and extended the stuff I needed, maybe it's of use for someone:

function _colorbox_link($image, $style_name, $style_name_link = 'colorbox_full') {
  $image_style = theme('image_style', array(
    'style_name' => $style_name,
    'path'       => $image['uri'],
    'alt'        => $image['alt'],
    'title'      => $image['title']
  ));

  $url = image_style_url($style_name_link, $image['uri']);

  $link = l($image_style, $url, array(
    'html' => TRUE,
    'attributes' => array(
      'rel' => array('colorbox-gallery'),
      'class' => array('colorbox')
    )
   ));
  return $link;
}


texts: Advertisement view sorted by Nodequeue relationship

texts:
I have a Advertisement type of View listing Ads by taxonomy but I need to order them by Nodequeue and I don't see it available in the Relationships area.
Is there a hack for this anywhere?

thanks


texts: Default image is not displayed while creating a node

texts:
I have created a content type and added a Preview Image field. Its type is file and its widget type is image. For Default Image, I have uploaded an image that should be displayed at the time of creating one new node.

My problem is that it is not displaying on the node creation form.


texts: Remove "Delete" in node/edit via hook_form_alter

texts:
I need to programmatically remove the Delete button in node edit forms under certain circumstances.

Normally, I'd do this in a hook_form_alter using $form['actions']['delete']['#access'] = FALSE;.

When I view in dpm(), "delete", however, does not have an "#access" key (though 'Submit' and 'Preview' do).  How do I disable 'Delete'

(…and, if you know why it wouldn't provide #access, I'm curious about that too).


texts:
I want to create a filter text module for drupal 8.

emtfilter/src/Plugin/Filter/emtfilter.php

/**
 * @file
 * Contains \Drupal\emtfilter\Plugin\Filter\emtfilter.
 */

namespace Drupal\emtfilter\Plugin\Filter;

use Drupal\Core\Form\FormStateInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;

/**
 * Text filter for highlighting PHP source code.
 *
 * @Filter(
 *   id = "emtfilter",
 *   module = "emtfilter",
 *   title = @Translation("Tipograf"),
 *   description = @Translation("Tipograf"),
 *   type = Drupal\filter\Plugin\FilterInterface::TYPE_HTML_RESTRICTOR,
 * )
 */
class emtfilter extends FilterBase {

  /**
   * {@inheritdoc}
   */
  public function tips($long = FALSE) {
    if ($long) {
      return t('text1r-');
    }
    else {
      return t('text2r-');
    }
  }

  /**
   * {@inheritdoc}
   */
  public function process($text, $langcode) {
        return new FilterProcessResult($text);
  }
}

After clearing cashe everything is ok. But when I visit some forms with textfields second time, Drupal generates this error:

  Notice: _filter_tips(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "Drupal\emtfilter\Plugin\Filter\emtfilter" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition in _filter_tips() (line 350 of core/modules/filter/filter.module).
  _filter_tips('full_html', ) (Line: 378)
  template_preprocess_filter_guidelines(Array, 'filter_guidelines', Array) (Line: 293)

And my tips disappear. What am I do wrong?


texts: Change the expiry time for welcome user notification message

texts: Is there any way to change the expiry time for the welcome message sent after an administrator user created a new account for a user? By default, the login link included in the email is valid for a day, and I would like it to last seven days.


texts: How to format JSON data response from a view defined by relationships to content types related by entity reference fields

texts:
I have a content type event with content name of the event, event image, a relatioship to organizer another relatioship to participant and another relationship to self event that i call programs. Now I want to make a view which return me a datasource json like

{
    date:"10/10/2017"
    event:[
        {
            img:"image",
            description:"description",
            date:"date complet",
            program:[
                {
                    title:"titre",
                    description:"description",
                    date:"",
                },
                {
                    title:"titre",
                    description:"description",
                    date:"",
                }
            ],
            organizer:[
                {
                    name:"chis",
                    description:"description"
                },
                {
                    name:"chis1",
                    description:"description"
                }
            ],
            participant:[
                {
                    name:"zina lacina",
                    titre:"consultant"
                }
            ]
        }
    ]
}

The result is grouping by the date.


texts:
I have an element $form['elements']['manufacturer']. On change, I want to change $form['elements']['form_factor'] and $form['elements']['model'].
Currently I have:
$form['elements']['manufacturer']['#ajax'] = [
    'callback' => 'formChanged',
    'wrapper' => 'form-factor',
    'event' => 'change',
];

which works and changes the form-factor. But, I want to change the model as well.
Iniside formChanged return form-factor in the callback function, so I can't return model element.
function formChanged(array &$form, FormStateInterface $formState){
  $form["elements"]["form_factor"]["#value"] = 0;
  return $form["elements"]["form_factor"];
}

Reading from past posts, one option was to return the whole form inside formChanged (return $form), but this doesn't seem like a good approach.
I can't do something like, having 2 callbacks:
$form['elements']['manufacturer']['#ajax'] = [
   [
    'callback' => 'formChanged',
    'wrapper' => 'form-factor',
    'event' => 'change',
   ],
   [
    'callback' => 'anothercallback',
    'wrapper' => 'another-one',
    'event' => 'change',
   ]
];


texts:
I want to change the size of the time textbox but I can't find a way to do it.

    $form['feld']['start'] = array(
        '#type' => 'date_popup',
        '#title' => 'Start',
        '#size' => 10,
        '#date_formant' => 'd.m.Y',
        '#date_year_range' => '0:+1',
        '#default_value' => date('Y-m-d H:i'),
        '#date_timezone' => 'Europe/Rome',
        '#date_increment' => 15,
        '#required' => TRUE,
);

'#size' => 10 only effects the date textbox.

This is an example.

How do I alter also the size of the textbox used for the time?


texts:
I just tried to create a simple mandatory file upload field in a custom form like this:

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

  $form['#attributes'] = array('enctype' => "multipart/form-data");

  $form['pdf_file'] = array(
    '#type' => 'file',
    '#title' => $this->t('PDF File'),
    '#description' => $this->t('PDF files only'),
    //'#multiple' => TRUE,
    '#required' => TRUE,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $this->t('Save'),
  );

  return $form;
}

And that did not work.

When submitting a file (no matter what kind of), i get this error all the time:

"PDF File field is required."

Does anybody have an idea what I am doing wrong?

I am using Drupal 8.2


texts:
I have a field (list integer) and I would like to render its keys and values. I found field.html.twig but within I only have access to item.content which is the value. I would also like to access the key.
I also had a look to theme_preprocess_field(&$variables) but I'm not able to get the correct keys.

I tried

  foreach ($variables['items'] as $key => $item) {
    $variables['items'][ $key ]['key'] = $key;
  }

Unfortunatelly this only gives me the array positions 0,1,2 ... But I would like to have the actual keys from my list, i.e.

100|red
200|green
300|blue
400|black
...


texts: Some variables not listed when creating feature

texts:
I'm building a feature that includes modules settings stored as variables. Strongarm module is great for that but for some reason, pathauto_entity's module variable called pathauto_entity_available_entity_types is not listed as available strongarm variable when I'm creating new feature.

The variable is listed on Strongarm's admin page when I go to admin/config/development/strongarm.

Any ideas why this is happening? Is it strongarm or maybe CTools issue?

The variable exists in database and I can read it with drush without problems.


texts: How to run the cron within specified timebound only?

texts:
I have a requirement which needs to be done via cron.
Some of the jobs should run only in time frame of 9AM-7PM everyday. So how I can schedule a cron for this type of requirements in the crontab.I surfed around it, but didn't get any solutions so please anybody help me in this regard.


texts:
I've searched what feels like hundreds of solutions and implemented them all. I've also searched this website in order to find the same question, but I was unable to locate it.

I have a development site and a production site. To migrate between the two I use github push and pulls. This hasn't been an issue in the past, however, I have run into this problem multiple times. After a file migration Drupal no longer allows me to login. I attempt my login credentials and immediately receive an Access Denied page.

My site cookies are reading and writing no problem. I've located the cookie ID and found it's entry in the database. So the cookies seem to be working fine and the database entries are working somewhat fine.

The problem that I can see is that the database session records are not saving any user ids. When I manually change the user id in the db record to 1, for my IP, and then refresh the website, I'm logged in. Any ideas?

https://stackoverflow.com/questions/2846935/cannot-login-to-drupal-in-chrome-or-firefox-but-safari-works suggests that I update $cookie_domain in the settings.php file. I've tried every configuration and it has not helped.
http://www.go2linux.org/cannot-login-into-drupal-table-corrupted also suggest that I repair the sessions table. I've done that, cleared the sessions from the db and cleared my cookies. It did not work.
http://www.madebymorgan.com/blog/2010/07/15/cant-login-after-drupal-617-upgrade suggests that I update the values in my settings.php file: $cookie_domain and $base_url. I've tried every combination and was unsuccessful.
I've read the install.txt which says to run the following commands for proper permission and ownership levels: chmod o+w sites/default/settings.php, chmod o+w sites/default, chmod o+w sites/default/files, chmod a-w sites/default/settings.php, chmod a-w sites/default.  It didn't work.
The patch in http://drupal.org/node/56357#comment-236726 adds some code to your sessions file. I've done this and it didn't work.
On http://drupal.org/node/56357#comment-391535, markus_petrux had a good suggestion by defining the PHPSESSID with a new name as well as setting the cookie domain and path manually. It didn't work.
http://old.nabble.com/Re%3A-Can%27t-login-p22258960.html suggests adding register_shutdown_function('session_write_close'); at the end of settings.php works, which also didn't work for me.
http://drupal.org/node/6696#comment-204863 tells us to add some ini settings into settings.php, clear the cache, clear cookies, clear privacy, restart Firefox, and add to settings.php the following lines:

ini_set('session.cookie_domain', 'exampleorg');
ini_set('session.cookie_domain','www.example.org');
ini_set('session.auto_start', 0);


texts: Conditionally enable/disable #autocomplete from client side js

texts:
I have a custom search field which searches for a type of content depending on the radio box selected. I have applied autocomplete functionality to the field using hook_form_alter but only want the autocomplete functionality to be available for one of the search types.

Is it possible to conditionally detach the Drupal.behaviors.autocomplete from the text field using my own js?

Update:
I have managed to disable the autocomplete functionality by unbinding the events, but I do not know how to add/bind it again:

// update search box text when search type is changed
$(SI_SEARCH.radio).change(function() {
  // get search type
  SI_SEARCH.search_type = $(this).val().trim();
  switch(SI_SEARCH.search_type) {
    case 'course' :

      break;
    case 'university' :
      // disable autocomplete
      $('#edit-search').unbind('keydown keyup blur');
      break;
  }
})


texts:
I have a custom filter added for a content type 'sample'. On selecting the custom filter for the node body, it checks for webform tokens like [webform:1234], by exploding it checks whether it is a webform or not. If it is a webform, it loads that node and render the same to the node body. Here is my code please have a check.

function landing_page_filter($text, $filter, $format, $langcode, $cache, $cache_id) {
  preg_match_all('/\\[([a-zA-z0-9_]+:[a-zA-z0-9_]+)+\\]/m', $text, $match);
  $matches = $match[0];
  foreach ($matches as $token) { dpm($token);
    $token_name = str_replace(array( '[', ']' ), '', $token);
    $type = explode(':', $token_name);
    if ($type[0] == 'webform') {
      $nid = $type[1];
      $node = node_load($nid);
     $form = drupal_render($node);
    }
  }
  return $form;
}


texts: Assign a submitted Node to a Single User of Role Editor

texts:
I am building a content publishing website. There are users with different roles editors, authors, content managers. There are many users with each role. Now what needs to be done is to assign a node to a specific user with a role as an editor or you can say to a specific editor.

I am using workflow module which puts the article to a review state once it is submitted. Now what it does is it allows all of the user with a role as an editors to edit and review the node. But I want that it should only be assigned to one editor and that should be done by the content manager.

I can not get my head around how should this be done. Are there any modules available or I would need to write something myself?


texts: How to get user permissions for the role Administrator?

texts:
I need to get permissions for all user roles, which are used. The code looks something like this:

$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();

The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:

$administrator = Role::load('administrator');

How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)

I have tried also:

$administratorPermissions = user_role_permissions(['administrator']);

It returns:

array(1) {
    ["administrator"] =>
        array(0) {
    }
}

If I try:

$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
    $role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);

Then I get:

Array
(
    [anonymous] => Anonymous user
    [authenticated] => Authenticated user
)


texts:
Does drush have an option in its sql-dump command to skip extended inserts?

I am looking for a particular value in the database, and having shorter lines would be a boon for my task.


texts: How to create a views listing of all groups including a join link in OG 7.2x

texts: The 7.2x version of OG leverages the Entity Reference module to create the relationship between the group node and entity. There about 8 possible OG Entity Relationships to choose from in views that upon review seem pretty ambiguous. I just need to figure out which one(s) are required to create a join link when listing all of the groups on the site.


texts:
I'm trying to add an entity form in Ctools popup. I'm using this module https://www.drupal.org/sandbox/andreymaximov/2058521 . My entity form path is like this eform/submit/quote

module docs say use this as link

modal_forms/%ctools_js/eform/submit/%entityform_empty

I'm really lost how to put my quote entity form here according to that link.


texts: How to make a content type a Ubercart product

texts:
Basically I want to add the "add to cart" button to a content type.
I've got Ubercart installed and enabled.
Normally whilst editing a content type there should be a section
"ubercart product settings" where I can check "products... are shippable"

But there's no such section to make it a ubercart product.


texts: View block need to display in custom field and need to pass nid as a argument for that view block. Help me on this.


texts: How to display only some terms of a specific vocabulary in Views

texts:
I have a taxonomy vocabulary (Drupal 7) called "Categories", with 6 terms: a, b, c, d, e, f

I can't see a way to create a view that will show just terms b, d, e (i.e. any sub-set of the full term list).

This seems like something that should be easy to do. Hopefully it is and I am just missing something, though an hour of searching has turned up nothing...

Any suggestions?


texts:
I can change the overall layout of a block editing the block.tpl.php file. I can modify the way subject looks, but what I want to take control over contents of the block which is accessible by single line of code:

<?php print $content ?>

Now, How can I theme contents of the block, i.e. list items etc?

If I've failed to clarify myself, please mention it in your comments. Thanks :)


texts:
I am trying to create marketplace like etsy, where each user can add as many products as they want.

What i want to do is to globaly set a fee of 5% on each product.

So for example:
User creates product A with price of 10$.
After he clicks save price shown is 11$.


texts: How to merge results from two different views?

texts:
I need to write an impossible view and I achieve to retrieve the correct list of nodes in two different views and now I need to merge the results in one single table.

How can I merge it?

If the views_1 give me nodes: [2, 52, 68, 41]
and the views_2 give me nodes: [2, 66, 88]
I want ONE table with the nodes: [2, 52, 68, 41, 66, 88]

I can't just merge filter's views because they are based on two relationships so I can't say to require one relationship OR the other one, but only to require one or both relationship.


texts: How to correctly modify Taxonomy Term selection Plugin

texts:
I want some slight modifications of Drupal\taxonomy\Plugin\EntityReferenceSelection\TermSelection::getReferenceableEntities(), for example to not use - to indicate term hierarchy. How can that be achieved?

I tried to extend that class in a custom module like that:

/**
 * Provides specific access control for the taxonomy_term entity type.
 *
 * @EntityReferenceSelection(
 *   id = "default:custom_taxonomy_term",
 *   label = @Translation("Custom Taxonomy Term selection"),
 *   entity_types = {"taxonomy_term"},
 *   group = "custom",
 *   weight = 2
 * )
 */
class CustomTermSelection extends TermSelection {

  /**
   * {@inheritdoc}
   */
  public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
    // Customization will be here...
  }
}

The plugin seems to be detected, it appears while debugging $selection_plugins in Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::fieldSettingsForm(), but it won't appear as reference method on editing the term reference field.

What else do I need to modify to get it work?


texts: Access to core comment preprocess variables in a custom comment layout twig template?

texts:
In Drupal 8 I have a custom comment type and when I use the default core comment.html.twig to render the comments then variables like 'new_indicator_timestamp' and 'parent' get rendered as expected. But if I switch to using a custom layout (via layout_plugin and display suite) and copy across the relevant twig template code for those core comment preprocess variables into my own custom layout then they don't work.

What do I need to do to ensure that the comment.module template_preprocess_comment() variables are available to my custom comment layout?


texts:
Is it possible to offer viewers different options on how to view an image?

Currently, it just defaults to a flexslider that I have put as default on my image style.

Looking for instructions on how to achieve this functionality by using views.

I know there is a similar post here but that is WHILST creating the content type - I want the user to choose how to see a set of images after the images have been added to the website!


texts: I cant seem to find a proper way to do this, I found ways for d5 but nothing on d7 so I am asking how can I edit a specific taxonomy page in d7?


texts:
I am having this very exact issue

https://www.drupal.org/node/2392289

On everypage that I load.
But where to apply this patch?


texts:
I'm trying to rewrite a form item's suffix on an AJAX callback and it keeps prepending the first choice and then doing nothing else. My code:
function my_dashboard_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if($form_id == 'node_job_listing_owner_job_form_form'){
    $tid = $form_state->getValue('field_job_description')[0]['target_id'];
    if(empty($tid)){
      $tid = $form['field_job_description']['widget']['#default_value'][0];
    }
    $link = null;
    if(!empty($tid)){
      $link_url = \Drupal\Core\Url::fromRoute('entity.taxonomy_term.canonical', [
        'taxonomy_term' => $tid
      ], [
        'attributes' => [
          'class' => ['use-ajax'],
          'data-dialog-type' => 'dialog',
          'data-dialog-options' => \Drupal\Component\Serialization\Json::encode(['width' => 420]),
          'data-dialog-renderer' => 'off_canvas',
        ],
      ]);
      $link = \Drupal::l('Preview Job Description...'.$tid, $link_url);
    }

    $form['field_job_description']['#suffix'] = $link;
    $form['field_job_description']['widget']['#ajax'] = [
      'callback' => 'updateJobDescriptionPreviewLink',
      'wrapper' => 'edit-field-job-description-wrapper',
      'event' => 'change',
    ];
  }
}

function updateJobDescriptionPreviewLink(&$form, \Drupal\Core\Form\FormStateInterface $form_state){
  return $form['field_job_description'];
}

Basically, I'm trying to put a link below the "Job Description" drop down to preview the description of that term. I have the term id appended to the link text temporarily so I can see what happens. When I edit an existing node, it renders the link correctly the first time (i.e. "Preview Job Description...102"). But then, if I select a different option, it prepends another link to the existing suffix (i.e. "Preview Job Description...99 Preview Job Description...102"). Both links work correctly, but obviously two links aren't what I want. And also after that, it won't change anymore no matter what I select.
I feel like there's something simple I'm overlooking, but I confess Drupal AJAX has always confused me somewhat. Any ideas? Thanks!


texts: Default entity ID for _entity_view in routing.yml

texts:
I've a custom content entity (created using Config pages module) which is used as a welcome screen / dashboard. Privileged super editors can edit those content entities, normal editors can only view it.

The config pages module itself does not provide routes to view modes (only to edit forms), so I used the core's generic _entity_view to create routes for the normal editors myself:

This is my_module.routing.yml

my_module.view_config_pages:
  path: '/admin/config_pages/{i_dont_want_no_parameter}'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        i_dont_want_no_parameter:
          type: 'entity:config_pages'

This works with URLs like /admin/config_pages/1, /admin/config_pages/2 etc... But I want to create nice, parameter-less, named routes to specific entity IDs. Something similar to my dummy-code below

my_module.view_welcome:
  path: '/admin/welcome'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        yeah_no_parameter:
          type: 'entity:config_pages'
          id: 1
my_module.view_stats:
  path: '/admin/stats'
  defaults:
    _entity_view: 'config_pages.full'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: true
    parameters:
        yeah_no_parameter:
          type: 'entity:config_pages'
          id: 2

Can this be done with _entity_view in YAML files without coding a custom controller?


texts: Show a field in table if current user is node author

texts:
I want to create a view block that shows all published nodes of a certain content type. I've included an image below.

However the trick here is to only show the link Print Report if the logged in user is the author of that node. So if you look at my image above, the user Dennis Bonilla should be able to see his Print Report link but not see one for the row below for Test McTest.

Is there a module that can help me do this or some administrative trickery in the views ui? Or maybe even programmatically?


texts: How can I link back to Term's page using Node Auto Term [NAT]?

texts:
I'm using NAT on a content type called Profile configured as follows in the picture below. I've been able to use this in great ways in some views.

I see that when I do a dpm($var['node']) from theme_preprocess_node($vars) that I see a NAT entry in the debug output.

My question is how do I properly grab this tid and automatically create a link to the taxonomy term's page (/taxnonmy/term/503)?

Cross reference: https://www.drupal.org/node/2291797


texts: Dynamic site title based on role and/or content type

texts:
I need to dynamically change the Drupal site title to match the role the current use has, or as an alternative option I need to be able to change it based on the content type that is being viewed (on my installation, each role has it's own content).
How can i do that? I'm using Drupal 6


texts: Is there an alternative to the Node reference, and the Feeds modules?

texts:
I am using Drupal 7, Reference Module (references-7.x-2.x-dev), and Feeds Module (feeds-7.x-2.x-dev).

I created 2 Content Types: Address Book, and City. The Address Book content type has a node reference to nodes of the City content type; the CSV file is imported to "City" content type with success using Feeds Module.

I am unable to import to a node reference using the Feeds module. With it, I created an importer, and mapped 2 fields for AddressBook content type:

Name:  Target is Title
City:  Target is NodeID

The CSV file looks like the following:

  Name,City
  COK,1230

Executing this import gives me unfavorable results, where the City field does not get populated.

Is there an alternative module that may be used or another method that may be recommended?

Please advise where further clarification is needed.


texts: Use multiple choices of CSS class in Insert

texts:
If using Insert module, in the field editing, we can put Additional CSS classes to the image being inserted.

I need the images float right. So I type floatrimg in the field editing, and .floatrimg {float:right;margin:0 0 10px 10px;} in CSS. It works fine.

But if I need to have 2 images in one post: one image float right, another one float left, I need 2 image fields.

I hope I can have one image field, where multiple choices of CSS class can be selected when submitting. So that with one image field, I can insert image float right and float left.


texts: Multiple Relationships in CiviCRM Views Integration

texts:
I have been trying to set up a Drupal View of a a 3-way relationship in CiviCRM.

The view I wanted was that showed a list of contacts that are provided services from the current user's employer, as below

(current user) contact a => (is employed by) => organisation => (is a provider of) => contact c

I created a view of CiviCRM Contacts, and could not see a way of getting this relationship to display what I wanted without building a custom module, which is explained below.


texts: How to use hook_form_alter to target a specific drupal commerce form?

texts:
I have a fairly basic question I think. I've written a module that uses hook_form_alter to alter the fields in a product form.

But now I'd like to change the fields in the form for a different product and I was thinking of using my custom module to do so.

However, when I use the Devel module to try and find the specific $form_id for each of my created product forms I see they ALL have the SAME name: commerce_checkout_form_checkout. Soooo, I'm not sure how to target a specific form.

Moreover, I've used dpm() to check the variables in the forms and they all have the exact same values for everything. Even across product types. The only value that is different is #build_id but this changes for every form load so it can't be targeted.

Anyone know how to do this?


texts:
I don't fully understand how preprocessing works

I have a twig template /themes/custom/client/templates/content/node--myfile.html.twig that I want to alter

I want to show/hide a part of that template depending on a field display with the machine name field_display stored in the matching content type called Project and with the machine name project_machine_name.

So I well understand I have to use hooks in order to do this, but I don't understand how I am supposed to name the hook functionnality neither how I'm supposed to access the data stored from the content type into the hook to alter the template view.

I know the hooks goes into the .module file. Actually I already have some of them, but I don't understand them properly. The only things I know for sure is that the function name must start by the module name

function my_module_SOMETHING_SOMETHINGELSE() {

}

So the issue is: how to name the hook function in order to alter the template ? I guess I understand the name is some kind of standard structure which will tell drupal if the function needs to be called before a specific action.

How to retrieve data stored from the display field of the content-types Project?

Thanks for your assistance.


texts: new content type with fields for username and password

texts:
I have a requirement for creating a new content type and creating a new user through that.

The content type have fields like 'name', 'address' etc. but the client wants to have username and password field in that, so that the user could be created along with it.

I am a bit lost with this, any suggestions please?


texts:
I'm using the Image Title module with Drupal 7. I can successfully upload an image to be used as a title, however the images keep getting deleted. It looks like the problem is similar to this question on SO.

Oddly, I've been using image_title for several years but never encountered this problem until now. And the module is basically abandoned, so there are no recent changes to it that would have changed the behavior - so has there been some change in Drupal itself that could explain this?

As a workaround I went into mysql and did update file_managed set status = 1 for the image file in question, is that likely to solve it?


texts: how to automatically select entity reference field value from url when adding a node

texts:
I have a content type "Students" which has an entity reference field "Course".

Course field shows a list of course nodes titles from a view.

When adding a new student node, I need the course field to be automatically selected as per the URL value.

I will pass the course ID in the URL like this.

/node/add/student/COURSEID

Any idea how to get this done ?
thanks


texts:
I have a probably trivial question, but I could not find an answer.
I have this query, which works fine:

$query = db_select('books, 't');
$query
  ->fields('t', ['publication_year'])
  ->groupBy('t.publication_year')
  ->orderBy('publication_year', 'ASC')
  ->addExpression('COUNT(t.publication_year)', 'n');
$data = $query->execute();
$result = $data->fetchAll();

I want to add a second expression:

(SELECT COUNT(*) FROM books WHERE open_access=1) AS n_oa

But I have two problems:
When adding a second expression I get the error Method 'addExpression' not found in null|string regardless of the content.

When only adding the single expression ->addExpression('SELECT COUNT(*) from books WHERE open_access=1', 'n_oa'); I get a syntax error.

Edit:

I tried this, and it generally works except, that the seond expression can't find the 'year' alias.

 $query
    ->addField('t', 'publication_year', 'year');
  $query
    ->condition('wg', 'ag_zzexternal', '=')
    ->groupBy('t.publication_year')
    ->orderBy('publication_year', 'ASC')
    ->addExpression('COUNT(t.publication_year)', 'n');
  $query
    ->addExpression('SUM(IF(open_access=1,1,0) AND IF(publication_year=year,1,0))', 'n_oa');
}


texts: Does Acquia Dev Desktop still work with Drupal 6 (upgrading sites from Drupal 6 to 7)?

texts:
I've been cheerfully using Acquia Dev Desktop for some time now, and very handy it is too, to run copies of production sites on my (iMac) workstation. I've used it for D6 and D7 sites, with the "import" option.

I've just installed the latest version of Dev Desktop and am all set to start upgrading from D6 to D7, but I keep running into problems.

For a start, importing a D6 site does not correctly edit the
settings.php file (database is wrong, also $base_url does not get
edited) - so you have to do this by hand.
Trying to run an upgrade
    of Views, it complains that require_once in ctools cannot find
    /usr/lib/php in /Applications/DevDesktop/pear:/common (and indeed
    when I look it is not there.

So I'm beginning to wonder whether it is still possible to use Acquia DD safely at all for running D6 sites, or upgrading from them.


texts:
So I recently transferred my site to a new server and disabled cleanURLs because of facing many errors. But due to this, I'm facing multiple issues:

Sometimes (not all the time)- when I save a form in the admin (editing user profiles/nodes/content etc.), the page redirects to a cleanurl (even though it's disabled) - for example www.example.com/admin/people instaed of www.example.com/?q=admin/people - I have no idea why this randomly keeps happening
When I upload user pictures for users and set Image style as thumbnail, the original image gets uploaded properly, but the thumbnail never gets generated adding to the fact that the image path generated for the user is absurdly as follows: www.example.com/?q=sites/default/files/styles/thumbnail/public/pictures/example.jpg - Is this because of cleanURLs again?
Moreover, I can't even re-enable cleanURLs since it gives me a negative test result.

I tried replacing the .htaccess file and it didn't solve the issue. Maybe it's my server configuration?

Even yet, I don't want cleanURLs enabled at all. So how do I fully disable it? Or is disabled anyway and this is some other issue?

Please help! Thanks.


texts: How to set an expiration date on an active rule so that it is disabled on a certain date?

texts:
Anyone knows how to set an expiration date on a Drupal 7 Rule (using the Rules module) so that the rule is disabled on a certain date?

Example Use Case:

We've created a product (using Drupal Commerce) with a name that's just a long string of random upper and lowercase characters and numbers. We then created a rule with one condition and two actions so that when Drupal is initialized (the event) it recognizes a specific URL a user came to the site with (ie. sitename/?SKU=productnamewithlotsofcharacters)[using the text comparison condition and then the provide URL argument value action] and when that's the case it re-directs the user to a specific product form (page redirect action to a drupal commerce express checkout form).

We only want this promo to last until a certain date, but we will be using it again in the future (so we just want the rules disabled). When the user uses this link to get to our site and the promo is 'expired' it takes them to a page that says 'Promo Expired'.

It's not the most fool-proof method of doing things of course but it works well enough for our needs.


texts: Print something in a tlp file if a field isnt empty

texts:
I need to print some html in a node tpl file if a certain field is not empty. The follwing is giving me a white screen:

<?php if (!empty($content['field_hotel_sat_nav'])) {
                        print '
The field is not empty
'
            }
?>


texts: Login not redirecting to SSO (external) server login page

texts:
I'm trying to replace Drupal authentication with the authentication from a SSO server, in a scenario discussed here. I'm trying to modify the login_block (on "Homepage" as well as "Access Denied" page), and login_block_form (at mysite.com/user/login). I did reset the default "Log in" button and replaced it with "SSO Log in" button, and on its #submit, using drupal_goto, I'm trying to redirect it to SSO server Login page. But, I'm still getting redirected to mysite.com/node?destination=node. I'm not able to figure out what the problem is. And inputs would be appreciated.

function MODULE_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login_block' || $form_id == 'user_login') {
    // Add a button to form, used to login to SSO
        $form['foo'] = array(
            '#type' => 'button',
            '#value' => t('SSO Log in'),
            '#submit' => array('MODULE_user_login_foo_submit'),
            '#limit_validation_errors' => array(),
        );
        // unset the current default login button of Drupal
        unset ($form['actions']['submit']);
  }
}

function MODULE_user_login_foo_submit($form, &$form_state) {
  drupal_goto('PATH/TO/SSO-SERVER-LOGIN-PAGE.ASPX', array('external' => TRUE));
}


texts: Compare Two Select Lists, and Require User to Select Different Values

texts:
Use case:  I'm presenting the User with two Select Lists populated with the same People names.

The first select list is Primary Person, the second select list is Backup Person.

The User must select a different value from each list. The same Person can't be a primary and backup. If the User attempts to save the page using the same value, Drupal will throw an error.

What's the best approach?


texts: How to change theme colors based on time of day for Adaptivetheme (or other theme that allows user-selectable colors)?

texts:
I'm using a custom subtheme of the Pixture Reloaded subtheme of Adaptivetheme.  I want to change the theme colors based on the hour of the day.  (I want a "day" theme and a "night" theme.)

I know that I can do this with the Themekey module, which allows you to specify rules for which theme to use.  You can make a rule based on the time of day and have two different themes, but then I will have to maintain two entirely separate themes.  Since all I want to change is the colors, taking this approach would be a maintenance nightmare.

Pixture Reloaded uses the Color module to allow users to select the colors, so I don't understand how to easily override it.

One thing I noticed is that there are a number of pre-defined color schemes.  For my purposes, it would be sufficient to have a way to automatically use one pre-defined scheme during the day, and another at night.

How can I do this without creating (and maintaining) a copy of my original theme?


texts: Predefined field collection items in node edit form

texts:
I have a Products taxonomy with all possible product names offered by the organization, Order content type to place an order and ordering form. Order content type includes field collection with term reference field referencing to Product taxonomy. The case is that I need to predefine field collection items with all possible selected Product terms on ordering form.
Items number = count(Products terms)

I tried to use field_multiple_value_form function to generate items, but in this case I can't predefine default value for field inside field collection item (or can?).

$products_taxonomy = taxonomy_vocabulary_machine_name_load('products');
$product_tree = taxonomy_get_tree($products_taxonomy->vid);

if (is_array($product_tree)) {
  $field_instance = field_info_instance('node', 'field_fc_o_position', 'order_request');
  $field_instance['cardinality'] = count($product_tree);
  $field_instance['type'] = 'field_collection_item';
  $field_instance['columns'] = array();

  $form_state['field']['field_fc_o_position'][LANGUAGE_NONE]['items_count'] = count($product_tree);
  $instance = $form_state['field']['field_fc_o_position'][LANGUAGE_NONE]['instance'];

  $form['field_fc_o_position'][LANGUAGE_NONE] = field_multiple_value_form(
    $field_instance,
    $instance,
    LANGUAGE_NONE,
    array(),
    $form,
    $form_state
  );
}

Question is how to generate empty field collection items on ordering form and default value for select field inside each new item?

Thank you!


texts: Protect site from flooding when user login is attacked by brute force

texts:
I've been experiencing issues with bots trying to force their way into the website I manage. It seems to be a daily occurrence the the flood system is being triggered (I'm on D7).

I'm happy the the flood system is doing it's job and stopping the attacks, but the problem is the bots are using private IPs, so when the flood is triggered it just locks everyone out.

I would like to find out if there is a way to limit the amount of bots that are getting through to the actual login verification. I tried throwing hidden captcha on to the login form, which does an ok job of it, but even when it suspects a bot, it doesn't't stop the login verification, so the flood system still gets triggered. Does anyone know of anything I can put in front of that process to limit the amount of bots getting though? The less intrusive, obviously the better.


texts: How to get teaser break to work with WYSIWYG + CKEDITOR?

texts:
I have Drupal 7.7 + WYSIWYG 7.x-2.1 + CKEDITOR 3.6.1 installed.

My goal is to be able to insert a teaser break into my blog posts (blog post content type - body field), in order to specify what goes into the teaser and what goes into the full node view.

When I click the "Separate the teaser and body of this content" button in the CK EDITOR menu bar, the text <!--break--> is automatically inserted into my body field. However, this break is not having any effect on the text that remains in the teaser view vs. on the full node view. It simply doesn't seem to be working. I tried using TinyMCE and I had the same problem

Can anybody please advise on how can I get this function working?

Thanks!

---More details about my current setup: ----------------

In the CK editor profile for "Filtered HTML" - in the "CLEANUP AND OUTPUT OPTIONS", the following options are enabled:
- Verify HTML
- Convert  tags to styles
- Remove linebreaks

These options are not enabled:
- Preformatted
- Apply source formatting
- Force cleanup on standard paste


texts: How to get the operation Links in my own EntityListBuilder

texts:
I use the Symfony framework the first time and goes through several tutorials to create an own entity type. https://www.daggerhart.com/drupal-8-custom-entities-bundles/ or https://www.daggerhart.com/drupal-8-custom-entities-bundles/

Now runs all very well, but I didn`t get the operation links(edit/delete) in every row for the saved content. There is only a devel link. If I moved directly to the content like www.exapmle/mytest/{id}/edit or www.exapmle/mytest/{id}/delete I can saw the content, edit the content, delete the content and the tabs are shown. So I think I have the permission for that.

Any ideas?

mytest.routing.yml:

entity.mytest.delete_test:
  path: '/tested/{mytest}/delete'
  defaults:
    _entity_form: mytest.delete
    _title: 'Delete Test'
  requirements:
    _entity_access: 'mytest.delete'

mytest.php in src/Entity

* @ContentEntityType(
*   id = "mytest",
*   links = {
*     "canonical" = "/tested/{mytest}",
*     "delete-shop" = "/tested/{mytest}/delete",
*     "collection" = "/tested"
*   },
* )


texts: How to redirect an exposed filter query to a views results page that lives in another panel page?

texts:
My setup: Drupal 7.2, Panels 7.x-3.0-alpha3, Views 7.x-3.0-beta3, Chaos tool suite 7.x-1.0-beta1

Say I want to create a fruits directory website. In views I have a content pane "fruits" with exposed filters based on taxonomies "color". The website is supposed to have two panel pages. The first panel page displays only the exposed filter box "search a fruit" with a dropdowns for "color" and a search button. Upon choosing from the dropdown and clicking the search button the user is supposed to get redirected to the second panel page that includes the view's content pane displaying a list of fruits that match the filter (color).

The problem is: the exposed filter box on first page won't redirect to the result page after clicking the apply button. How do I set up views and panels to achieve this?


texts: How can I view nodes on my site from Drupalgap?

texts:
I am getting started with Drupalgap and trying to access nodes on my Drupal site by node ID from within Drupalgap.  I have checked the Node and Node Services documentation.  I thought I could use the node_page_view(nid) function like this:

function mymodule_sample_page() {
  try {
    node_load(11, {
        success:function(node){
        alert("Loaded " + node.title);
      }
    });
    return node_page_view(11);
  }
  catch (error) { console.log('mymodule_sample_page - ' + error); }
}

However, when I attempt to test this in my module, I get the alert "Loaded your node" but the content is not actually displayed on the page by node_page_view().  What do I need to do to display the content?


texts: Cardinality Violation during Views contextual filter setup, how to fix this?

texts:
I'm currently getting this error in my views setup:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column

I'm not sure why its giving this error as it seems like it should work. I have a contextual filter that matches taxonomy term id's. I have it configured to pass in an array() of tid's, but it throws the error if its more than one. What could be wrong?

Below are screenshots of my setup and sql statement generated by views:

http://img14.imageshack.us/img14/8079/f4bw.jpg


texts: How do you use hook_form_FORM_ID_alter() to alter the USER EDIT form?

texts:
I'm trying to mark fields on the /user/_uid_/edit screen as disabled.
These are custom fields I've created in /admin/config/people/accounts/fields in D8.

I have this code for another node entity type...

function MODULENAME_form_node_survey_edit_form_alter(&$form, $form_state, $form_id) {
  $form['field_content_type']['widget']['#type'] = 'hidden';
}

This works as expected, and on the node/123/edit screen for a that content type, that field is hidden. (works as expected)

(it gets populated by a migration process, and needs to stay how its set, even if users change other fields...)

My problem is, that I'm trying to disable a field on the USER-EDIT screen, such as /user/123/edit.

I'm trying the EXACT same code structure.

function MODULENAME_form_user_edit_form_alter(&$form, $form_state, $form_id) {
    $form['field_organization_reference']['widget'][0]['target_id']['#attributes']['disabled'] = 'disabled';
}

But it doesn't work.

I've tried throwing in class changes, and other things to alter the input fields, but they don't work.

$form['field_organization_reference']['widget'][0]['target_id']['#attributes']['disabled'] = 'disabled';
$form['field_organization_name']['widget'][0]['value']['#attributes']['disabled'] = 'disabled';
$form['field_organization_reference']['#attributes']['class'][] = 'borkbork';
$form['field_organization_name']['#attributes']['class'][] = 'borkbork';
$form['field_organization_name']['widget']['#type'] = 'hidden';

All as attempts to try and change something on the user edit form.

But nothing is working.

Is user-edit the correct form id?   Is there something else I'm missing

Thoughts? Help? Thank you!


texts: How to add fields to 'content' format in Views

texts: I created a view from  node. In the FORMAT settings, I choose content (because I need to display the comment form). How do I add fields such as post date or Share this link (ShareThis module) to the view?


texts:
I've got a custom AJAX link on my site, which does it's current job fine, but what I'd like to do is make it change the href attribute of an element on the page as well. I'm not brilliant at jQuery, so I'm not sure how I'd use the Drupal AJAX commands to do something like this, if it can even be done.

Basic info of my existing setup

HTML

Add

Module

/**
 * Implements hook_menu().
 */
function mymodule_menu() {
    // Creates a page to listen for a new slide being added
    $items['ajax/mymodule/slide/%node'] = array(
        'page callback' => 'mymodule_append_slide_to_deck',
        'page arguments' => array(3),
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );

  return $items;
}

function mymodule_append_slide_to_deck($node) {
    if (!empty($node)) {
        if ($node->field_image) {
            // CODE TO GET HTML OF THUMBNAIL FROM THE NODE REFERENCED, ADDED TO VAR $thumbnail

            // Prepare an ajax command to insert the node html into our ajax wrapper.
            $commands = array();
            $commands[] = ajax_command_append('#deck .deck-creator', $thumbnail);

            // Render the commands into JSON and print them.
            print ajax_render($commands);
            exit;
        }
    }
}

All this part works fine, does it's job. However I have another button on the page, and I'd like to pass this Node ID of the node I've referenced (in this case 15) to the end of the href property. Can this be done? or is the simplest thing to replace the HTML entirely using ajax_command_replace();?


texts:
Well I know that I have to use drupal_add_css like described here.

But that doesn't work and I don't understand why.

I tried to use this hooks: function hook_init, hook_views_pre_render, hook_preprocess_html and hook_preprocess_page.

I tried in that hooks this code:

$css=drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');
$variables['styles'] = drupal_get_css($css);

or:

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css');
$variables['styles'] = drupal_get_css();

or also just the first line.

also:

drupal_add_css("/".drupal_get_path('module', 'mymodule') . '/style.css');

or that:

drupal_add_css(drupal_get_path('module', 'mymodule') . '/style.css',
               array('group' => CSS_DEFAULT, 'every_page' => TRUE));

Here is my style.css:

#logo {
    display:none;
}

That should hide the logo on success. What is wrong with my tries?


texts:
I try with this, but no success:

$params = [
  'body' => 'My body',
  'subject' => 'My subject',
];

// I check by debug this code and $file get the right file
$file = File::load($myfile_id);

$attachment = [
  'filepath' => $file->getFileUri(),
];

$params['attachment'] = $attachment;

// This send a empty mail, without subject and not body
$send = \Drupal::service('plugin.manager.mail')->mail('mymodule', 'mykey', 'myuser@gmail.com', 'es', $params);

Why doesn't \Drupal::service('plugin.manager.mail')->mail work?

Then I tried this and it worked fine, but without attachments.

$system = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'mymodule', 'key' => 'mykey'));

$file = File::load($myfile_id);

$params = [
  'headers' => [
    'MIME-Version' => '1.0',
    'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' => '8Bit',
    'X-Mailer' => 'Drupal',
  ],
  'to' => 'myuser@gmail.com',
  'body' => 'My body',
  'subject' 'My subject',
  // I try with:
  'attachment' => $file;
  // or
  'attachment' => ['filepath' => $file->getFileUri()];
  // with not success
];

// the mail was sent but without attachment
$send = $system->mail($params);

How do I send a mail with attachment on Drupal 8?


texts: Submitting a form causes 'secure connection failed' error that persists

texts:
I've got a SSL certified server running drupal 7.37.
Everything was working fine until I started adding form submission to a module I'm working on.
As soon as I submit the form, I get 'Secure Connection Failed' in all browsers.
I can get to other pages ok, but not the homepage which then also throws the same error.
This persists until I restart my internet connection.

I did the following test to try and find the problem:

I submit the form on my desktop pc - secure connection failed.

I try to go to the domain root - secure connection failed.

I check on my laptop which is connected to the same router - secure connection failed.

I check on my phone using 4g - works fine.

So I seem to be causing a local network wide issue somehow, but I don't know how to fix it.

This is the form, it just uploads an xml file to the temp directory:

$form['file'] = array(
    '#type' => 'file',
    '#title' => t('XML file'),
    );
$form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Import'),
    );
return $form;

This is the validate function:

$file = file_save_upload('file', array(
    'file_validate_extensions' => array('xml'),
));

if ($file = file_move($file, 'public://'))
{
    $form_state['storage']['file'] = $file;
}
else
{
    form_set_error('file', t("No file was uploaded. Check extension is .xml"));
}

This is the submit function:

$file = $form_state['storage']['file'];
unset($form_state['storage']['file']);
dsm($file);
$file->status = FILE_STATUS_PERMANENT;
file_save($file);

$filepath = file_create_url($file->uri);
dsm($filepath);

Any help would be appreciated, it's driving me mental.

UPDATE: This problem disappeared for a few hours, then returned for no apparent reason.
I'm thinking it might be a problem with my internet provider.


texts: adding adwords tracking to a Click instead of a page load using goog_report_conversion

texts: I am using the simple subscription module to subscribe users to a newsletter and wish to track clicks of subscribers.  Is there an easy way to call the goog_report_conversion() function when someone clicks on the subscribe button? I don't see any configuration for this with the simple subscription module.


texts: Found index.php in files folder and all its subfolders? Anyone know what type of exploit is this?

texts:
I'm cleaning up my drupal installations and i found in the files folder there was an index.php file and all its subfolders.
screenshot:

I still dont know what kind of exploit was done to get all these files in here. Anyone had something similar or know what this is?


texts: Saving additional node fields programmatically

texts:
I have the following content type called stars with the following fields:

Title
Body
Distance (this is an added text field)

Here's what I have to save the node, but how do I add the distance field?

$node = new stdClass();
$node->type = "stars";
$node->status = 0;
$node->uid = $user->uid;
$node->title = 'This is the title';
$node->sticky = 0;
$node->language = 'en';

// Let's add standard body field
$node->body['und'][0]['format'] = 'filtered_html';
$node->body['und'][0]['value'] = 'Body info';

$node->revision = 0;

node_save($node);


texts:
I have created a view that shows few entities. To be able to see only a particular entity, I created a contextual filter.

How can I expose the contextual filter I added?


texts: How to customize the input phase of a custom field

texts:
i'v created a custom field using this tutorial (http://www.slideshare.net/zugec/fields-in-core-how-to-create-a-custom-field). everything went ok and i successfully created a custom field which consists of three different text-inputs.

Now i'd like to customize the way the user inputs this field and can add another field: instead of the standard drupal visualization, i'd like to implement something like when you add your language proficency in the euroCV.eu, where each 'field' is a row and the custom inputs are cell, and when you add another field, you add another row.

i think i have to modify this hook

function instruction_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $base = $element;
  if ($instance['widget']['type'] == 'instruction_instruction_form') {
    $widget = $instance['widget'];
    $settings = $widget['settings'];

    $element['titolo_studio'] = array(
      '#type' => 'textfield',
      '#title' => t('Titolo di studio'),
      '#default_value' => isset($items[$delta]['titolo_studio']) ? $items[$delta]['titolo_studio'] : NULL,
    );
    $element['descrizione'] = array(
      '#type' => 'textfield',
      '#title' => t('Descrizione'),
      '#default_value' => isset($items[$delta]['descrizione']) ? $items[$delta]['descrizione'] : NULL,
    );
    $element['votazione'] = array(
      '#type' => 'textfield',
      '#title' => t('Votazione'),
      '#default_value' => isset($items[$delta]['votazione']) ? $items[$delta]['votazione'] : NULL,

    );

  }
  return $element;
}

but i'm not sure. Is there any tutorial on this?


texts: Ubercart get order id from custom field value

texts:
I have created a custom field for using Drupal Field module. I want to get order if from the value of that custom field id. group_number_oc is the name of the custom field which stores 2,4 etc numbers. I want to get order or orders which has group_number_oc value equal to 2 or 4 or any dynamic value.

Is there any way?

Similarly there is a custom field group_number_usr for users as well. and I want to get all the users that have custom field value equal to 1, 2 etc.

Custom field name for users and orders have different name (Note).


texts: How to add link in user menu which is available for loggedin users in drupal

texts: I want to add link for member area in user menu which is only available for logged in user.Please let me know how i can do this.I am using Drupal 7.


texts:
This code saves the taxonomy term, but it doesn't add it to the node.
What is the problem?

             $node = new stdClass(); // Create a new node object
            $node->type = "article"; // Or page, or whatever content type you like
            node_object_prepare($node); // Set some default values
            $node->language = en; // Or e.g. 'en' if locale is enabled
            $node->title = $title;
            $node->field_image['und'][0] = (array)$file;
            $node->uid = '1'; // UID of the author of the node; or use $node->name

            $tags = explode(",",$sended_tags);
            $vid = 1;

            $term = new stdClass();
            $term->name = $tags[0];
            $term->vid = $vid;
            taxonomy_term_save($term);

            $node->taxonomy[] = $term;

            node_save($node);


texts: How to add page content and webform as tab in a page?

texts:
I'm using drupal 7 and I have a content type "service".

And I have a enquiry page, built with webform with following fields:

Name
Email
Service
Message

In each service page, I would like to have a tab for page content, a tab "Enquiry", with the enquiry webform in the tab.

For service field, I would like it to show page title as default.

Is there any way I can do it?


texts: How to load page content by url programmatically in custom region

texts:
How to load page content /node/add/page  programmatically in custom region? Example of custom region (https://jsfiddle.net/makbuk/1vetkgL2/).

I have found this How to get a node by its url alias? but it dosn't work for me.

$alias = "some/path/to/a/page";
$path = drupal_lookup_path("source", $alias);
$node = menu_get_object("node", 1, $path);


texts: Override "International phone" field placeholder

texts:
I've installed phone_international contrib module for Drupal 8 project and want to override placeholder.
In widget setting there are no placeholder.
Also tried to change it with form_alter_hook and hook_field_widget_form_alter, but without result.
// In form_alter_hook
$form['account']['field_account_contact_phone']['widget'][0]['placeholder'] = 'Custom placeholder';

Where "field_account_contact_phone" is "International phone" field.
After that code I see the following error:
"placeholder" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php).


texts: What is the purpose and differences between drupal_goto(),drupal_redirect_form() and $form_state['redirect']?

texts:
May you explain me the differences between drupal_goto(), drupal_redirect_form() and $form_state['redirect'] with examples?

How can I pass the form values with these functions, and how can I retrieve the values using $_GET and $_POST in Drupal 7? Which is the better one to use?


texts: Events showing on a calendar is radically different formats

texts:
With event nodes imported using the Feeds Importer. How might I get the Jan 1 event to appear only on January 1st?

These events shown below on Jan 1 and 4 are all day events. Their individual date formats are listed below. The dates entered in both seem to be the same, but the difference in the rendering is baffling.

Additional information: Based on a helpful comment below. Here is what the Inspector shows in Firefox.

Jan 1 event, should not span two days

(full size image)

Jan 4 event with proper rendering

(full size image)


texts: Inline entity form shows a content type select list

texts:
I am using Inline entity form for a non-commerce project.
The settings are:Widget:multiple values,Node:Allow users to add existing content.
Mode:Views:Filter by Entity reference view.So I have created an Entity reference view to show only nodes that have been created by the user.
The issue is:When looking at the Inline entity form to create or add existing content,there is a dropdown with all the content types of the site.This only appeared when I change the mode to Views:Filter by Entity reference view
How can I remove that?
thanks
See image attached


texts: Global search/replace on special characters accidentally taken in on an import ( â€™ )

texts:
I have imported (through CSV using Feed Import) and large amount of information. I have a large amount character encoding issues such as

  Grimsbyâ€™s teaching focus is on...

Where â€™ is in place of the apostrophe. Is there any way to search/replace myself out of this? Could I use an input filter?


texts: How do you add captions to each image of Flexslider? (already tried Google!)

texts:
First of all, I tried to search the answer in Google, there weren't many results and those who were weren't very informative, clear, stepped, or guiding. I've also checked Youtube, and I found something that seem too general and too long for this purpose.

What I look for is the simplest way to add overlay captions to Flexslider images. The captions should be different per image and I need these captions to contain both a headline and a body texts (That's why I've guessed that the image title field won't be enough by itself and that the solution should come from another place).

Please give me some guidance, for example, where do I even start to get this, what is the logical place to put the text in per image? (I guess it wouldn't be CSS content), what are the ways to do it, etc... And I hope that your good and didactic guidance will endure for all users to come.


texts: How to remove "leave blank for all" message from Views exposed filter

texts:
After updating the Views module from 3.11 to 3.13, I get an annoying text that says:

  Leave blank for all. Otherwise, the first selected term will be the default instead of "Any".

Does anyone know how to remove it, besides using CSS?

This only happens in taxonomy term exposed filters.

Could it be a bug?


texts: Menu item URL not updating using MenuLinkManagerInterface::updateDefinition()

texts:
When trying to update an existing menu link URL/ URI with updateDefinition() -

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Menu%21MenuLinkManagerInterface.php/function/MenuLinkManagerInterface%3A%3AupdateDefinition/8.2.x

It's noticed the url is not getting updated. Other key such as 'title', 'menu_name', 'description', 'enabled' etc gets updated.

This is expected as these are the keys that are allowed to override.
I'm trying to override a url or route of an existing menu item.
Is there any other way I can achieve this?
Below is my current implementation -

$menu_name = 'custom';
$menu_tree = \Drupal::menuTree();
$parameters = $menu_tree->getCurrentRouteMenuTreeParameters($menu_name);

$tree = $menu_tree->load($menu_name, $parameters);
$manipulators = array(
  array('callable' => 'menu.default_tree_manipulators:checkAccess'),
  array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
);
$tree = $menu_tree->transform($tree, $manipulators);

foreach ($tree as $item) {
  //update existing menu item.
  $item->link->updateLink(
      [
        'enabled'=> 0,
        'title'=>'new name',
        'link' => ['uri' => 'internal:/node/1000'],  //Need to update to a new internal url.
        'menu_name' => 'custom',
      ],
      true
   );

}

I'm open for any suggestions/ ideas. Thanks!


texts: Views Sort Criteria: Contextual Filter Multiple Value Order

texts:
I have a view that pulls in a collection of nodes via node id.  I'm using the Node:Nid filter, and have it set to allow multiple inputs separated by the '+' sign. (443+112+2060...)  This part works beautifully.

I was wondering if I could sort the view by the order of the nids?  I thought it might do this by default if I remove all sort criteria, but no joy. I'm looking and I don't see a way to sort the view by this data.

Any advice you might be able to give me would be greatly appreciated.

Drupal 7. Views 7.x-3.x-dev.


texts:
Hy,

If someone can help me with an idea. I have a second button on my webform with an specific handler. Everything it's OK it execute my function but I want that this button to also save in the db of drupal like the first button. But only the first button do that. I don't understand why. I must to set something special in the definition of this button to do that?

Here is how I created my buttons:

array_unshift($form['#submit'], 'decla_form_submit');
unset($form['actions']['submit']);

if ($declaLineOrigin[0] -> CLOSED == 'N') {
    $form['actions']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Recalculer'),
        '#validate' => array('decla_validate'),
        '#prefix' => '
',
        '#weight' => 50,
    );

    $form['actions']['validation'] = array(
        '#type' => 'submit',
        '#value' => t('Valider'),
        '#submit' => array('decla_form_validation_submit'),
        '#executes_submit_callback' => TRUE,
        '#suffix' => '
',
        '#weight' => 70,
    );
}

Is the "Valider" button.
The div is for an ajax call ... I want to hide this button if an specify textfield change.

$form['submitted']['declaration_fieldset']['base_trimestre']['#ajax'] = array(
    'callback' => 'decla_fire_callback',
    'wrapper' => array('replace_decla_button_div'),
    'event' => 'click',
    // 'event' => 'input',
    'progress' => 'none',
);

Thank you everyone and have nice day !