texts: Include node creation form error processForm

texts:
I am using the following code include a node creation form.

namespace Drupal\fritr_register_friterie\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Class RegisterFriterieForm.
 *
 * @package Drupal\fritr_register_friterie\Form
 */
class RegisterFriterieForm extends FormBase {

    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'register_friterie_form';
    }

    /**
     * {@inheritDoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state) {
        $entity = \Drupal::entityManager()->getStorage('node')->create(array(
            'type' => node_type_load('friterie')->id(),
        ));
        // OPTIONAL - Set default values for node fields
        // $entity->set('field_machine_name', "value");
        $node_create_form = \Drupal::service('entity.form_builder')->getForm($entity);

        // I can display it with this method, but I don't know how to delete
        // some fields.
//        $form['friterie'] = [
//            '#type' => 'container',
//            'form' => $node_create_form
//        ];
        $form['friterie'] = array(
            '#type' => 'markup',
            '#markup' => render($node_create_form),
            '#prefix' => '
',
            '#suffix' => '
'
        );
        return $form;
    }

    /**
     * {@inheritDoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {}

}

I get the following error.

  Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Drupal\fritr_register_friterie\Form\RegisterFriterieForm' does not have a method 'processForm' in Drupal\Core\Form\FormBuilder->doBuildForm() (line 979 of core/lib/Drupal/Core/Form/FormBuilder.php).

I can fix it by changing $form['friterie'] to a markup type; with the markup I then use render($node_create_form). When I want to alter my form with hook_form_alter() it's a string and I cannot modify the form.


texts: User Specific content on a page - Beginner question

texts:
So there are a few threads that might be my answer, but it doesn't seem like the modules are for Drupal 8.

So what I'm trying to do is to create a page that filters its content to display only content that references the user without building a new page per person.

The webpage itself would read as something along the lines of the following.
http://www.website.com/UserSpecific/
However, if the user didn't have any content referencing them the page would be empty. However, if they had content referencing them they would be able to view that content, and no other user would be able to.

Is that how the system works to begin with in Drupal 8 so long as it's referencing a particular user? Or is there another step in getting this done?

The threads I'm referring to are the following.
Tag users in a content field to create user-specific content listings

How to display content for specific user


texts: In sent message, the user name is not displaying

texts:
I am using the Privatemsg module, version 6.x-1.x.

If my username is "TEST" and I am sending the email to myself, the sent messages doesn't show "TEST." The "From" field is empty.

If I send the email to other users their names is displaying fine.

What is the reason of this, and what should I do to display my name there?


texts: Redirect anonymous users to the register page

texts:
Is it possible to redirect anonymous user to user/register page?
How can I do that?


texts: Why is ddebug_backtrace coming up blank?

texts:
I've been using the Devel module for a couple of years now but every time I try to get a backtrace I run into issues.  I remember getting it working once, but I don't remember how.

It seems like using dpm(ddebug_backtrace()); should do the trick.  I have tried it with no argument, TRUE, and FALSE, and I have also tried removing the dpm function it's wrapped in.

I have dpm calls directly above and below this code that print variables appropriately, but the most I get out of dpm(ddebug_backtrace()); is a blank line in the Krumo output.

Suggestions mightily appreciated.


texts: How can I sort taxonomy term using attachment in drupal view

texts: I would like to sort taxonomy term using attachment in view like this (A B C ...). When I created sort for Taxonomy term using contextual filter, the Alphabetical(radio button) was disabled under "When the filter value is NOT available" section for taxonomy term. This radio button already enabled for content: title but it was disabled for taxonomy term.


texts:
Is there a contrib module out there that provides the text equivalent of image marker? E.g. I have views output and i want to place a post it on top of it.

The closest thing i've seen is the annotation field for Drupal 5 which is a bit outdated and i don't really know how it works.


texts: How to remove "authenticated-user" from this [user:roles:join-path]/[user:name]

texts:
I have these roles:

anonymous user,
authenticated user,
administrator,
members,
partners.

In URL Aliases I changed at USER PATHS with this: [user:roles:join-path]/[user:name]

I created 2 views for user: first for members role and second for partners role (the views contain userpicture and username). The link for these users in both roles are :

www.example.com/authenticated-user/members/username
www.example.com/authenticated-user/partner/username

I know that authenticated user role is default for authenticated users, but it is possible to remove from USER PATH: from „www.example.com/authenticated-user/members/username” to „www.example.com/members/username”?

Thank you.


texts:
This is what I've done so far:

Installed & enabled the Plupload integration module in my drupal website (version 7.x-1.7)
Added Plupload library to my libraries directory (version 1.5.8)

In my status report I see that he can find the plupload library:

Now when I want to add an Image I only get the widget type Image and not the Pupload option. What could be the problem of this?


texts: how can i add a subterm of taxonomy in code

texts:
$vocabulary = (object) array(
'name' => st('A'),
'description' => st('A'),
'machine_name' => 'user_a',
'help' => 'test for subterm',
);
taxonomy_vocabulary_save($vocabulary);

$user_a=array(st('A'),st('B'));

$user_a_vid=db_select('taxonomy_vocabulary', 'tv')
  ->fields('tv', array('vid'))
  ->condition('machine_name', 'user_a')
  ->execute()
  ->fetchField();

foreach ($user_a as $name) {
    $term = new stdClass;
    $term->name = $name;
    $term->vid = $user_a_vid;
    taxonomy_term_save($term);
 }

i have two vocabulary A and B

and i want to add sub-term of A and B

A have sub-term 1,2
B have sub-term 3,4

how can i do that in code?

Thanks for reading my question~thx~


texts:
Trying to make a custom page to add taxonomy terms. The page contains one drop-down menu that lists all enabled vocabularies. Full taxonomy add form loaded after I select some from that menu.

This is menu callback:

    function add_term_form_callback($form, $form_state) {

      module_load_include('inc', 'taxonomy', 'taxonomy.admin');
      $vid = $form_state['values']['vocabulary'];
      $vocabulary = taxonomy_vocabulary_load($vid);

      $form_state['values'] = array();
      $form_state['build_info']['args'] = array(array(), $vocabulary);

      $form_state['rebuild'] = TRUE;
      $form_state['no_cache'] = TRUE;
      $form = drupal_build_form('taxonomy_form_term', $form_state);

      return $form;

    }

...and form

    function add_term_form($form, &$form_state) {

      $options = array();
      $options[0] = t('- Select -');
      $vocabularies = taxonomy_get_vocabularies();
      foreach ($vocabularies as $vocabulary) {
        $options[$vocabulary->vid] = $vocabulary->name;
      }

     $form['vocabulary'] = array(
       '#type' => 'select',
       '#title' => t('Select vocabulary'),
       '#options' => $options,
       '#default_value' => $selected,
       '#ajax' => array(
         'callback' => 'add_term_form_callback',
         'wrapper' => 'container',
         'event' => 'change',
       ),
     );

      $form['container'] = array(
       '#type' => 'container',
       '#prefix' => '
',
       '#suffix' => '
',
      );

      return $form;
    }

So the problem is that the form remains in the same state after first load. How to refresh the form properly?


texts:
So I'm trying to open a modal via a button in Drupal 8 beta 11. I've patterned my code after some I found in BlockListBuilder.php in core, but I can't seem to get it to work. My routes are correct because I've successfully made a modal link. Here's my code:

$row['button'] = array(
      '#type' => 'button',
      '#value' => $this->t('Modal'),
      '#button_type' => 'primary',
      '#url' => Url::fromRoute('settings_profile'),
      '#attributes' => array(
        'class' => array('use-ajax'),
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode(array(
          'width' => 500,
          'height' => 500,
        )),
      ),
    );


texts: how to use an entity query to make a sortable table

texts:
I need to use an entity query such as this:

$query = \Drupal::entityQuery('node')
->condition('type', 'blog_post')
->sort('field');

$nids = $query->execute();

to make a table that is sortable in a custom module .  I found instructions on how to do this with a normal query , (below) how can I make this work for this entity query

  $header = array(
  // We make it sortable by name.
  array('data' => $this->t('Name'), 'field' => 'name', 'sort' => 'asc'),
  array('data' => $this->t('Content')),
);

$db = \Drupal::database();
$query = $db->select('config','c');
$query->fields('c', array('name'));
// The actual action of sorting the rows is here.
$table_sort = $query->extend('Drupal\Core\Database\Query\TableSortExtender')
                    ->orderByHeader($header);
// Limit the rows to 20 for each page.
$pager = $table_sort->extend('Drupal\Core\Database\Query\PagerSelectExtender')
                    ->limit(20);
$result = $pager->execute();

// Populate the rows.
$rows = array();
foreach($result as $row) {
  $rows[] = array('data' => array(
    'name' => $row->name,
    'content' => '[BLOB]', // This hardcoded [BLOB] is just for display purpose only.
  ));
}

// The table description.
$build = array(
  '#markup' => t('List of All Configurations')
);

// Generate the table.
$build['config_table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
);

// Finally add the pager.
$build['pager'] = array(
  '#type' => 'pager'
);

return $build;

}
}


texts: yes/no rating with node reference target

texts:
I have a review content type that (node) references a product content type. I'm using fivestar ratings for overall rating and specific ratings. With fivestar I can make the product the "vote target".

One of the ratings is a "yes/no" type rating where I want to show the aggregate on the product node (x% of users rated yes).

I tried to use fivestar with a "1 point" rating where 1=yes, 0=no but the problem is that 0 votes are not saved at all, therefore always resulting in a 100% result.

I could probably use a "2 point" rating and then have a custom display formatter to do the math and translate it to the correct %.

Are there any other solutions? I can't use the rate module because I already use it for "thumbs up/down" ratings.


texts: Paid membership plans on registration page

texts:
I am creating a registration based website that has five membership plans.

Based on the selected membership plan, users have to pay the membership fee using Stripe payments.

How can I create membership plans and this kind of payment functionality?


texts:
I have temp table field : $field.'_temp'
I need to rename it as $field. {no other structure changes}

  db_drop_field($table, $field);
  db_change_field($table, $field . '_temp', $field, array('type' => 'int'));

This works fine!

I read in the documentation that is necessary

  IMPORTANT NOTE: To maintain database portability,
      you have to explicitly recreate all indices and primary keys
      that are using the changed field.

https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_change_field/7

As my table has many indeces like here below:

That means in order to maintain portability we need to drop indeces and recreate them using

db_drop_primary(), db_drop_index(), db_add_index() and db_add_primary_key()

it is not very clear how this should be done in the specific context (core table) and how would be the impact on other components.


texts: How to invalidate cache when a config entity is added/deleted?

texts:
In a MenuLinkContent entity I've a list_string field populated with a $key => $value array of a custom config entity. When I add or delete a config entity the values in my field are not updated until I rebuild the cache.

I think I should set a cache tag, but I can not figure out where I should add the tag and which tag should I use.

Edit: The array is created in a static method on my entity class.

public static function getConfigList() {

  $entities = SvgIcon::loadMultiple();
  $config_list = array();

  /** @var SvgIconInterface $entity */
  foreach ($entities as $entity) {
    $config_list[$entity->get('id')] = $entity->get('label');
  }

  return $config_list;
}

The field is defined via hook_entity_base_field_info().

function svg_icon_menu_link_entity_base_field_info(EntityTypeInterface $entity_type) {

  $fields = array();

  if ( $entity_type->get('id') !== 'menu_link_content' ) {
    return $fields;
  }

  $fields['svg'] = BaseFieldDefinition::create('list_string')
    ->setLabel('SVG sprite')
    ->setDescription('Select the SVG sprite file.')
    ->setSettings(array(
      'allowed_values' => SvgIcon::getConfigList()
    ))
    ->setDisplayOptions('form', array(
      'type' => 'select',
      'weight' => 0,
      'settings' => array(
        'display_label' => TRUE
      )
    ));

  return $fields;
}


texts: What hook can I use to modify Views Datasource JSON output?

texts:
I'm using Views and Views Datasource to generate a JSON feed for my site. I've got a Video field which has both a video and a thumbnail image.

I want to include the url of the thumbnail image in my json feed. I add the Video field to my list of fields in the View and I choose the "Video thumbnail" format instead of the "Video Player" format so that it will show the thumbnail instead of the video. When I do this in a normal View it works perfectly. However, when I do it with a JSON document view, it doesn't work properly. It renders the url to the video instead of rendering the url to the thumbnail image.

I'm going to create another question which talks about how to get this to work properly, but THIS question is my backup solution.

I can rewrite the field so that it includes the fid of the thumbnail image, so my current idea is implementing a hook that will allow me to post process the rendered json or manipulate the data structure before it gets converted to json so that I can just lookup the image by its fid and then replace that piece of data in the array with the proper image url.

I have tried MANY hooks so far, but none of them provide data which represents the json data.

hook_views_pre_view
hook_views_pre_render
hook_views_post_render
hook_views_post_execute

My guess is that Views Datasource is processing the data after I've seen it in my hook implementations.

What hook can I use so manipulate the data structure before it gets converted to json or alternatively, what hook can I use to manipulate the json string after it has been converted to json?


texts: How merge two different views on single page?

texts:
How can I merge two different views on single page by displaying value with common filter condition for both views.

Ex: I have view1 and View2 and now I want to display both views on single page and filter condition if I select Id card number from View1 along with view1 fields the respected linked users in view2 should display.


texts:
I'm fairly new to Drupal and made my first module. It works. Yay!

What I have: Calling
/form-test/186 (nid)
Nid gets loaded, renders content.

What I want: The same but with an simple submit button at the end, that calls a

function exportIt() {
  // put $output from formtest_page() in email
}

when clicked, not before.

    <?php

/**
 * Implements hook_menu().
 */
function formtest_menu() {
  $items['form-test/%'] = array(
  'title' => 'Export von:',
  'page callback' => 'formtest_page',
  //'page callback' => 'drupal_get_form',
  'page arguments' => array(1),
  //'page arguments' => array(formtest_simple_form),
    'access arguments' => array('access administration pages'),
    'type' => MENU_CALLBACK, );
  return $items;
}

function formtest_page($nid = NULL) {

  $node = node_load($nid);
  if ($node) {
    $title = $node -> title;
    dpm($node); //Why is this not get displayed?
    drupal_set_title('Klicket Export von: ' . $title);
    $output = '';
    $items = array("<b>titel: </b>" . $title,
    "Where is my beef?" );

    $output .= theme('item_list', array('items' => $items));
    //drupal_get_form('formtest_simple_form');
    return $output;

  }
  return;
}

function exportIt() {
  // put $output from formtest_page() in email
}

//simple submit form
function formtest_simple_form($form, &$form_submit) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Export an Klicket'));
return $form;
}

I'm having basic conceptional issues I guess. I either can render the submit Button or the Output, but not both.


texts:
I am new to Drupal and can't get the download PDF feature working in Drupal 8 webform submission, getting the following message:

Error generating document: Missing dependencies. Please install with: composer require "dompdf/dompdf 0.8.0"

I have downloaded dompdf/dompdf 0.8.0 zip.file from here https://github.com/dompdf/dompdf/releases/tag/v0.8.0 and coverted it to tar.gz (since zip upload is not working) and when trying to upload I am getting the following error:

dompdf_0-8-0.tar does not contain any .info.yml files.

Where can I get dompdf_0-8-0 that include .info.yml files?


texts: Redirect form out of modal window after submit

texts:
I have a form within a Colorbox Modal window which successfully submits using the _submit handler. I then successfully redirect the form to another page (which pre-loads a few fields on another form) using drupal_goto(). The problem I am having is that redirect stays in the Colorbox Modal window. I need to somehow close the modal window and transfer the url of the new form to the parent window. I can get this to work with a jquery function of

$(#my_form_id).submit(function (){
   parent.window.location="/user/register";
});

The problem with this issue is that the function calls when my form is submitted while disregarding anything that happens in the submission handler. So what ends up happening is I get the new page/form without the pre-loaded values until I refresh the page.

Do you have any thought or idea?


texts: Undefined variable errors that disappear, should I worry about them?

texts:
I get these when I first login to my admin account:

Notice: Undefined variable: total in include() (line 19 of C:\WAMP\apache2\htdocs\apricity\sites\all\themes\apricity\templates\page.tpl.php).
Notice: Undefined variable: base_url in eval() (line 17 of C:\WAMP\apache2\htdocs\apricity\modules\php\php.module(80) : eval()'d code).

$total is a variable I'm using in page.tpl for the commerce module:

  <?php
  global $user;
  $quantity = 0;
  $order = commerce_cart_order_load($user->uid);
  if ($order) {
      $wrapper = entity_metadata_wrapper('commerce_order', $order);
      $line_items = $wrapper->commerce_line_items;
      $quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
      $total = commerce_line_items_total($line_items);
      $currency = commerce_currency_load($total['currency_code']);
  }
  ?>

and it works great. $base_url I have in settings.php like usual. What's strange is if I refresh the page the errors disappear. Should I worry about them?


texts: Trying to integrate Rate-Widget (Rate-Module) into Status-Block (Statuses/Facebook Style Status)

texts:
With Drupal 7, I am trying to combine the Rate-module and the statuses-module (formerly Facebook Style Status), for my voting widget to show up in status boxes.

At https://drupal.org/node/811742 it explains to implement the hook hook_facebook_status_render_components.

<?php
/**
 * Implementation of hook_facebook_status_render_components().
 */
function MYMODULE_facebook_status_render_components($status) {
  //Only show on individual status pages.
  if (arg(0) == 'statuses' && is_numeric(arg(1))) {
    //Here, the theme function MYMODULE_voting_widget is assumed to take a "type" and "id" parameter, but it may vary.
    return array(
      'MYMODULE' => array(
        'value' => theme('MYMODULE_voting_widget', 'facebook_status', $status->sid),
      ),
    );
  }
}
?>

The README from the rate-module however describes to use the following code:

<?php
if (arg(0) == 'node' && is_numeric(arg(1)) && ($node = node_load(arg(1)))) {
  print rate_embed($node, 'NAME');
}
?>

So I used this latter code and implemented the hook in the rate-module:

<?php
function rate_facebook_status_render_components($status) {
  //Only show on individual status pages.
  if (arg(0) == 'statuses' && is_numeric(arg(1)) && ($node = node_load(arg(1))) ) {
    //Here, the theme function MYMODULE_voting_widget is assumed to take a "type" and "id" parameter, but it may vary.
    print rate_embed($node, 'ratingwidget');
  }
}
?>

I deactivated the module and re-activated it, but nothing shows up.
What did I do wrong? Do I need to include any files from the Statuses-module in my rate.info-file, in order to implement hooks from one module in the other? Did I do something totally wrong and just don't understand the concepts?

Thanks very much in advance.


texts: Make search block appear for anonymous user

texts:
I have defined a region in my theme in which I've placed the search box. But, it only appears when a user is logged in. I checked to see the visibility and made sure the block is also visible to anonymous users; but it doesn't show up.
I searched online for the issue but I wasn't able to find a good (working) solution. Is there a way to do so?

My search block visibility settings:


texts: Disable Taxonomy Generated Teaser List Pages

texts: I have a site that uses the Taxonomy module to categorize content. The vocabularies and terms are used as arguments and filters in various Views. I do not want the Taxonomy module to generate its own pages at URLs like "/taxonomy/term/1,2" . Is there an easy way to disable this functionality?


texts:
I'm having trouble with refreshing content in a block created with a custom module, placed within a panels page. My end goal is to display either regular or seasonal hours based on a set date range. My hook_theme() implementation looks like the following:

function daily_hours_theme() {
  if (daily_hours_is_summer()) {
    $table_template = daily_hours_get_summer_vars();
  } else {
    $table_template = daily_hours_get_regular_vars();
  }
  $items =  array(
    'todays_hours_table' => $table_template,
    'daily_hours_text_content' => array(
      'render element' => 'element',
    )
  );
  return $items;
}

I'm using hook_block_info() to test cache settings; the following doesn't seem to have an effect on caching:

function daily_hours_block_info() {
  $blocks['hours_table'] = array(
    'info' => t('Daily Hours Table'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

And hook_block_view() to call the theme function:

function daily_hours_block_view($delta = '') {
  switch ($delta) {
    case 'hours_table':
      $block['content'] = theme('todays_hours_table');
      break;
  }
  return $block;
}

Ideally, I'd clear the module's block data at midnight every day, but I'd settle for just knowing how to implement any caching rules in this context.


texts: Call internal pages with drupal_http_request

texts:
I'm writing a little module, and I need to call several pages of my site using drupal_http_request(), which accepts only absolute URLs.
I don't want to add a variable to store the domain of the site, also because on my company we have proxy etc.

Which is the best way to add the domain of the site?


texts:
I want to show the block only on this page /category and not show on every next like /category?page=1

As I see it's a big problem for Drupal 8?


texts:
I need a view for taxonomy terms that shows both any child terms as links and a table of product nodes tagged with the term, but I can only work out how to apply one or the other.

Any help appreciated!

edit for clarity: For the path taxonomy/term/%, I need to show the child terms of parent terms, or for a child term a table of all products (nodes) that are associated with that term. I have assumed it would be easiest to combine these two into one view somehow.


texts: Custom entity field is missing in Add content form

texts:
Created a content type 'News' having fields 'title', 'body' and a custom entity field 'Department'-which will be populated from department vocabulary terms. I can add contents by loging as admin. I can see all the fields for Add 'News' when I login as admin. Now I created a role, 'Content Writer' and given permission to Add 'News' Content and Edit Own Content.

1) From the Navigation menu I can see the add 'News' form also. But the form is missing the custom entity filed 'Department'. What I did wrong/missed?

2) How can I hide the bottom portion(Revision information, publishing options etc.,) of the form for such users


texts: Views filtering by taxonomy term = url(the view is placed)

texts:
So, im having a Products site right now, with submenu items of every category the Product belongs. I started with making a view for the first submenu category, and its filtering the results by taxonomy term.

I got 6 more submenu items and i want to reuse my view and not make 6 more with diferent taxonomy terms. I would like to make one universal view that filters by the url alias where the views block is placed.

So if im right, the view block placed on the site with the  "abc" url alias should show all products with the "abc" taxonomy value.

How do i set the view filtering for my needs?

I hope i express my idea clear.

Thanks in advance for help.

P.S. All the Submenu items are multilingual if that does matters. The url is not translated.


texts:
I have a staff member that needs to be able to update a View in the drupal admin area...specifically they need to be able to change the node id displaying in a block.

Is there a way to allow this person to edit just this view?

And if that's not possible what permission do I need to give them?

Thanks!


texts: Entity Translation - permission for translating only own nodes of specific content type

texts:
I use the Entity Translation module to translate my content type "profile". With the content type "profile" an authentificated user can create a profile and then translate some of the nodes' fields. My problem is that I can't figure out how to give the authenticated role the permission to translate only their own profile.

I can only select the permissions "Translate any Entity" or "Translate entities of type node". When I activate the "workflow permission" in Entity Translation's settings, I can additionally select "Edit shared values" and "Edit original values".

However, the user should be able to translate only his own content type "profile".

Does somebody know how to achieve this?


texts:
I am new to drupal 7. I read the online documentation but, due to less programming skills, I could not figure out the exact solution.

I want to disable pager link. How can I do that?


texts: How do I display articles in sticky footer?

texts:
Not sure if i am going about this the right way but my intended goal is this:

Create a sticky footer that displays:

In Section 1(Left section) a Link to Latest magazine issue.
In Section 2 (Right Section)
A. Either show the latest Archived Articles.
B. Allow a user to input or select their own desired archived article.

Can I use a view to display this, or should I use a block? If I can accomplish this with a view, what should my approach be?


texts:
I would like to place the search bar in the main menu on the right. I have seen several people on the net asking for this but never encountered some information I could actually use.
I use Drupal 7 and the "Responsive Blog" by Devsaran.

As far as I understand the way to go is inserting some php into the main menu code in the main-menu part in page.tpl. This is what it looks like but I am struggeling with the exact to dos now...

<nav id="navigation" role="navigation">
  <div id="main-menu">
    <?php
      if (module_exists('i18n_menu')) {
        $main_menu_tree = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu'));
      } else {
        $main_menu_tree = menu_tree(variable_get('menu_main_links_source', 'main-menu'));
      }
      print drupal_render($main_menu_tree);
    ?>
  </div>
</nav>


texts: Automated task to see deprecated functions used in a site

texts:
There have already been many Drupal 8 functions that have been deprecated.

Is there an automated way (perhaps through the reporting pages in Drupal or a code linter) that reports when these deprecated functions/methods are used from code used from the site?

The goal, of course, is to stay as current as possible on our APIs so that we're ready when Drupal 9 drops.


texts: Link by internal path in *.links.menu.yml not visible in admin menu

texts:
Based on the official documentation to create menu links I've tried to use an internal link on the administration menu. But the internal link is only visible for users with administrator rights.

In my my_module.links.menu.yml I use the following links for testing:

my_module.test_link:
  title: 'TEST LINK internal'
  url: internal:/node/add
  description: 'TEST internal'
  parent: system.admin_content
  weight: 99

my_module.test_link_2:
  title: 'TEST LINK external'
  url: https://www.stackoverflow.com
  description: 'TEST external'
  parent: system.admin_content
  weight: 100

Both links are visible for administrators, but an user with editor role does only see the external link.

I activate every permission for the editor role, the link remains invisible.


texts: How to override node add template for custom content type?

texts:
I have a custom content type named called "circular". For Admin user the "circular" node add form is opening using administration theme (i.e. Seven). But for Authenticated user the node add form is opening using my custom theme. I want to override template of the node add/edit form the custom theme.

I created page--node--add.html.twig in the template folder of the custom theme and used {{ form }} to render the form. But blank page is coming.

How do I fix this?


texts: How to show selected options only if item is selected in select?

texts:
I have created a select option for Province which has values of #1, #2, #3

and I have created a second select for Municipality with values #4,#5,#6,#7,#8,#9,#10,#11,#12

If I select #1 in Province I want to show #4,#5,#6 in Municipality select only.

Can this be achieved? If so how?


texts: Add html5 placeholders to node_add inputs

texts:
I'd like to add placeholders to node_add field inputs. I'm trying to use dpm($form) but am not sure where to put it. I couldn't get node-add.tpl to work with this

 function MYTHEME_theme() {

  $items = array();

  $items['node_add'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'MYTHEME') . '/templates',
    'template' => 'node-add',
    'preprocess functions' => array(
      'MYTHEME_bootstrap_preprocess_node_add'
    ),
  );

  return $items;

}

The only template I got to work was page--node--add.tpl but $form shows a blank krumo.


texts:
SITUATION:

A View page displays all "items" that have a certain "code".

The code is passed via a contextual filter, e.g. /items/17, where 17 is the code.

A user might try to guess a code by typing it in, e.g. /items/345.

When the View is empty (i.e. the code is bogus), a not-found exception is raised as follows:
function mymodule_views_pre_render(\Drupal\views\ViewExecutable $view) {
  if ($view->current_display == 'page_machine_name' && empty($view->result)) {
    throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
  }
}

There is a menu included as a block that's displayed at the top of the View page.

The menu block configuration restricts the block to pages with paths /items/*.

PROBLEM:
The menu also appears on the 404 page, since that page retains the bogus path /items/345. How can I exclude the menu block from the 404 page?
NOTES:

I want to display the default 404 page rather than the view with a "not found" message as its body.
I don't want to display the view as a block instead of as a page unless it's the only way. I already know how to solve the problem if I have to do that.
If there were a way to say, "Include this block only on View pages" (like you can for content types), that would be ideal.
There are actually three blocks that need to be excluded from the 404 page; I mention only one to make it simpler. The other blocks are a text block and a banner block.
I see that a solution to this problem has been proposed for Drupal 9, but not available yet.


texts: stream wrapper public /private not found Error

texts:
Configuration : WAMP on windows drupal 7

I have tried using

$image = file_get_contents('E:\Team_Install\wamp\www\rootfolder\sites\all\modules\my_module\errorwinmobilesdk.jpg');
$file = file_save_data($image, 'public://',FILE_EXISTS_REPLACE);

I can see the result after first line file_get_contents but on file_save_data I get that destination folder invalid error

Another method I had tried was  $file = file_copy($source, $dest);

here also it says $dest does not exists
Wrapper folder permission and path are check thorughly they are working when I add an image using media_gallery module as it saves to public gallery or creates a new article with image, when I try to add from code it breaks and start showing message

  The data could not be saved because the destination public is
  invalid. This may be caused by improper use of file_save_data() or a
  missing stream wrapper.

Please help I am new to drupal and stuck at this.

Thanks in advance


texts: I’m trying to create a link to a user user/%user/stores on a commerce marketplace and open social

texts:
I’m using commerce marketplace and open social, I need to create a link to the user products and my store.
But somehow I’m not able to get it running. I keep getting access denied when using  "user/%user/stores"
I first tried something like this:
  if (empty($context['user']) || !($context['user'] instanceof AccountInterface)) {
    return [];
  }

  return [
    'My_store_page' => [
      '#type' => 'link',
      '#url' => \Drupal\Core\Url::fromUri('internal:/use/%user/store'),
      '#title' => t(‘My Store),
      '#weight' => 100,
    ],
  ];
}

Then I tried this:
use Drupal\Core\Url;
function wtff_store_social_user_account_header_account_links(array $context) {
  return [
    'my_products' => [
      '#type' => 'link',
      '#url' => Url::fromRoute('entity.user.store', [  'user' => \Drupal::currentUser()->id() ]),
      '#title' => new Drupal\Core\StringTranslation\TranslatableMarkup('My products00'),
      '#weight' => 100,
    ],
  ];
}


texts:
I am on Drupal 7.56 on a multilingual site.

I have created a view that contains tab menu links. Almost all the site it available now in two languages. But I still can't translate those view tab menu links.

I use those tabs to let users access some information via their account area

Example : in a view that contents articles (that I want to user to see only those they created) I add a menu link this way :

link       : "user/%/myarticles".
Menu name  : My Articles
Menu type  : menu tab
Menu "Menu : User menu

I have translated the view but I can not find any way to translate the "Menu name", not even in "admin/config/regional/translate/translate".

Users will see "My Articles" in both languages when I want them to see it written in the correct language in each case.

How do I present the user with only the correctly translated tab?


texts: How to create a token to render nodes in content?

texts:
The goal is to place one ore more polls and/or slideshows anywhere within my blog post.

Step 1 is easy:  With the Token Filter module, I can place tokens anywhere in my content.

Step 2 requires a module that creates a token which takes a nid as an argument and renders the node within my content, e.g. [render-node:1].  The rendered node would have a content type of poll and/or slideshow.

Is this a good way to go, or is there a better way?  If this is the way to go, how would I go about creating a module to do this?


texts: Rules- how can I redirect a user to view their profile only when they update their profile?

texts:
I want to redirect users to their profile (/user) after they save changes to their profile settings (/user/[uid]/edit).

If their accounts are updated in another manner (by rules, etc.), I do not want them to be redirected.

I made a rule like this:

Event-> After updating an existing account
Actions-> Page redirect to user/[account:uid]

This redirects properly; however, on my site sometimes user accounts get updated when a user adds content.  Adding content then also causes this rule to get called, which I don't want.  I only want the user to be redirected if they updated their account details at user/[account:uid]/edit.

I tried adding:

Condition: Path has URL alias: user/[account:uid]/edit

However, then the redirect ceases to function.


texts: Is it safe to truncate the key_value_expire table?

texts:
I am seeing over 8 GB in the database for the key_value_expire table.
Is it safe to manually truncate that table?
This appears to be caused by a bug in the Honeypot Module, which I am unable to uninstall without throwing an error.


texts: How to make Toolbar unsticky at the top?

texts:
Drupal 7

The toolbar is sticky at the top even you scroll down the page.

How can I make it unsticky at the top?

Thanks.


texts: How to display a view without using a page template - drupal 7

texts: So on a drupal site I am working on the client has a page where they have a view without a page template applied to it, and now the client wants to change the url of that page. As soon as I change the url of the view it applies the page template to the view. Obviously this was hard-coded in by url by the person who originally built the site, however, I have no idea how they did it. So i'm hoping someone on here has had a similar experience or knows how to make a view without a page template being applied to it.


texts: Change directory where MySQL saves its data

texts:
Is there a way to get Acquia Dev Desktop to save the MySQL data to a different location other than the one it chooses by default?

Imagine to reinstall Acquia and thus needing to save the MySQL data from a Drupal instance into an alternate drive.

Acquia Dev Desktop places the database in C:\Program Files (x86)\DevDesktop\mysql\data.

Looking into the preferences, the config files contain the following.

[client]
port=33067
user=drupaluser

[mysql]
max_allowed_packet = 128M

[mysqldump]
max_allowed_packet = 128M

[mysqladmin]
user=root
port=33067

[mysqld]
pid-file="C:/Program Files (x86)/DevDesktop/mysql/data/mysql.pid"
log-error="C:/Program Files (x86)/DevDesktop/mysql/data/mysql.err"

# The TCP/IP Port the MySQL Server will listen on
port=33067

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files (x86)/DevDesktop/mysql"

#Path to the database root
datadir="C:/Program Files (x86)/DevDesktop/mysql/data"

#set innodb as default
default-storage-engine=InnoDB

innodb_log_buffer_size=32M
innodb_buffer_pool_size=512M
innodb_log_file_size=32M

innodb_file_per_table=1

#Max open files
open_files_limit=10000

#Max packets
max_allowed_packet = 128M

#The log buffer is written out to the file at each commit. Flushing on the log file takes place once per second
innodb_flush_log_at_trx_commit=2

#Enable slow query log
long_query_time=1
slow_query_log=1
slow_query_log_file=slow.log

If the data directory is changed, then I get the following error.


texts:
I'd like to associate an user to a taxonomy term. I create users in a process import managed by rules.

I didn't found a solution with an existing module so I try to develop mine. I've also installed Entity reference module but I feel confused.

I've added a field_user in my taxonomy term fields management.I've added a field_conventions in my user field management.

I do not understand how to associate one or many terms to an user with rules.

I found User Terms module but unfortunately only for a Drupal 6.x


texts: How do I use the Bootstrap 4 mobile menu in a Drupal 8 theme?

texts:
I am trying to make a Drupal 8 theme from an existing HTML page. The page uses the Bootstrap 4 menu.

I was able to get the normal version (desktop) of the menu working by copying menu--main.html.twig from the Drupal 8 Bootstrap Barrio theme. I added the following code to the file:

<button aria-controls="navbarSupportedContent1" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler" data-target="#navbarSupportedContent1" data-toggle="collapse" type="button"></button>

...

And when resizing the page the menu is disapearing as intentended.

I am having trouble to get the mobile menu working. The problem is that the button (hamburger - three lines) to open the mobile menu is not showing up.

The theme is loading the following .js files:

As far as I understand there are no errors in browser console concerning this issue.

What might I still be missing?


texts:
I am getting this error message in the logs after installing RNG module for Drupal 8 and trying to submit a completed a event form. The error log contains this error.

  Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "Value is not a valid entity." at /home/vhosts/***********/public_html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php line 757, referer: http://**********/node/add/event_1

Any idea on how I can resolve this please?


texts: Export node display with Features not taking in account format of fields

texts:
I'm trying to export a node display with features and I already created the feature with the display and imported it to another site.

The problem is that the display has some differences, mainly in the format of the fields (see the graph in yellow). It seems that the format of fields are not exported. I checked the generated code and found nothing about these formats.

Moreover, I'm changing the formats of the fields and features do not change at all, it status is not "Overriden", and I generated it anyway and there is no change at all, despite the different formats.

I don't know if it is a common issue with Display Suite or if I should active another module to do a better export.

How to fix this problem? Do you have exported node displays with features? What else can I do.


texts:
I can not figure this out for the life of me, I am trying to have doubt digit values for  the day and month in my module using form api, I have tried this with the date api and still no luck,

my function looks like this

function set_dob_year_range($form_element) {
$form_element['year']['#options'] = drupal_map_assoc(range(1900, 2012));
return $form_element;
}

    $form['dob'] = array(
        '#type'  => 'date',
        '#title' => t('Date Of Birth'),
        '#default_value' => array(
            'month' => format_date(time(), 'custom', 'm'),
            'day' => format_date(time(), 'custom', 'd'),
            'year' => format_date(time(), 'custom', 'Y'),
        ),
        '#after_build' => array('set_dob_year_range'),
        '#required' => TRUE
    );

using in on the month should count the months values as 01 02 03 but instead its using 1 2 3, thing for the days it should be 01 02 03 instead its using 1 2 3.

Any help is greatly appreciated.

EDIT: The date formats are not passing through to the values for anyone that is confused.


texts: How to install a drupal distribution using Drush quickstart command?

texts: What is the command for drush qc to install a drupal distribution? I'm trying to install this one: https://drupal.org/project/onepagecv


texts:
I'm creating a node--page.html.twig and I'm using twig_tweak to help render a block for my sidebar to display the sub-menus. Is there a way to hide it if the page doesn't have any submenus?
Here's my code:

    {{ drupal_entity('block', 'mainmenu', check_access=false) }}

Is there some sort of if statement I could use to hide the block if the page has no submenu?
Thank you!


texts:
I am using the SMS Framework module and after updating my site from Drupal core 8.8.8 to Drupal Core 8.9.3 and the SMS Framework module from 8.x-1.3 to 8.x-2.0.0-alpha1, I start seeing the below error in "Status Report" Section (/admin/reports/status).

and because drush entup is now deprecated, I had to install the Devel Entity Updates module so drush entup can work again.
However, After running drush entup, I faced another error as shown below:

How can I solve this error In SqlContentEntityStorageSchema.php line 1887: The SQL storage cannot change the schema for an existing field (id in sms_phone_number_verification entity) with data. without having to delete all related data from fields as the site has more than 50 000 registered phone numbers ?

Is it safe to ignore the Mismatched entity and/or field definitions error from the Status Report page ?

Thank you,


texts: Date is wrong in storage but correct on display?

texts:
I am trying to programmatically load a node and get its date time value. The default format is HTML5 date, long date. I load it and I get the field value with the following code.

dpm($record['nid_value']);
$entity = \Drupal\node\Entity\Node::load($record['nid_value']);
dpm($entity->get('field_date_range')->value);

The output is the following one.

740
2018-02-23T02:00:00
734
2018-02-23T00:00:00

Why is it stored as 2018-02-23T02:00:00 when the real date is Thursday - February 22, 2018 - 4:00pm to 5:00pm?

The field type is date range; the display type is smart range. When you view the node, it looks perfect. The display is correct. If I create a view, it also outputs the incorrect date, no matter what format I chose on the field output. Time zone has been forced.

Can anyone point me in the right direction here?

UPDATE - Here was the solution to my problem

$nid = 411;
$entity = \Drupal\node\Entity\Node::load($nid);
$dval = $entity->get('field_date_range')->value();
$dt = new DateTime($dval, new DateTimeZone('UTC'));
$dt->setTimezone(new DateTimeZone('America/Los_Angeles'));
$date_to_print = $dt->format('g:ia \o\n l jS F Y');
//$date_to_print = $dt->format('m-d-Y h:m:i');
echo $date_to_print;
//output: 12:00pm on Saturday 24th February 2018


texts: Is it possible to use the batch API with transactions?

texts:
I'm using the batch api for reading large csv files and storing some information in my database. If something fails during the batch run I want all the processed information to be gone, I would like to use drupals transactions for this, but I don't know if this is supported.

If this is not supported is there any known workaround for this?


texts: Create a view/list of pages made with Panels

texts:
I know how to view/list particular content types in a View:

I just need to add a "filter criteria" to the View that will display all node belonging to that type.

cool. but, I can't figure out how to view/list particular pages made with Panels.

Pages made with Panels are not selectable from the "filter criteria" box in the View.


texts:
i created a module. I created a form and implemented it on the page:

function tudakozo_menu() {

  $items['tudakozo'] = array(
    'title' => t('Tudakozo'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('tudakozo_nevszerint_form'),
    'access callback' => TRUE,
  );

  return $items;
}

I would like to have an another form on this


texts: Views support for custom entity with base table in seperate database

texts:
I have a custom content entity that has been setup with several properties declared. This was really nothing special, just a standard entity representation of data from a custom table in the Drupal database. Everything worked as expected (CRUD operations, views integration, etc.).

This was initially just a test however. The table behind this entity needs to live in a separate MySQL database. This database will be on the same sever as the Drupal database, but must be managed independently with write operations initiated from separate platforms. To attempt this I simply modified the relevant part of the entity annotation from:

base_table = "mytable",

To:

base_table = "mydb.mytable",
persistent_cache = FALSE,

The first line declares the base table inside the separate DB (also discussed here) and the second line bypasses local entity caching so fresh data is always displayed in Drupal (also discussed here). For the most part this also works great and seems fully compatible with Drupal's entity API (CRUD operations still work as expected). The issue is that views integration now fails. I can still create a new view based my content entity, but no properties are available (not even the base ID). If I attempt to alter a view created before changing the annotations all properties result in broken handlers and query errors, in the same manner as describe in this question (which is similar, though related to the prefixing of the base table, not fetching it from a separate database).

There are certainly projects in the contrb space that attempt to integrate views with external/remote data, and I always have the option to use search_api as an intermediary between my custom content entity and views, but I'd like to see if there is a native Drupal 8 core solution for this. Given that the main entity APIs appear to support entity data from another database just fine I was hopeful views support would be implied. Are there alterations required to my entity delcaration (perhaps something in the extended \Drupal\views\EntityViewsData object for my custom entity) to get this working?


texts: Combining two node forms: is that possible?

texts: I am using Drupal 6 and I got a node form for a content type. I want to alter the other content type node form inside the first one; is that possible?


texts: Data returned from the controller is not showing in the template file

texts:
I am sending data from a custom module controller to a template file using the following code.

module.info.yml

name: Module
description: Module description
package: Custom
type: module
version: 1.0
core: 8.x

module.module

function module_theme($existing, $type, $theme, $path) {
  return [
    'module_template' => [
      'variables' => [
        'var' => [],
        'title' => ''
      ]
    ]
  ];
}

module.routing.yml

module.event:
  path: '/path/{dynamic}'
  defaults:
    _controller: '\Drupal\module\controller::RunQuery'
    _title: 'Module'
  requirements:
    _permission: 'access content'

module-template.html.twig

 test {{ title }}

{% for user in var %}

 {{ user.title }}

{% endfor %}

test 2

controller.php

namespace Drupal\module;

class controller {

  public function RunQuery($dynamic) {

    // Some query here which work fine and return what I want
    $ok = 'Some value';

    return [
      '#theme' => 'module_template',
      '#var'   => $ok,
      '#title' => 'Title',
    ];
  }

}

This will return only test and test 2 in the template file, so the template file is called by the module controller, but it does not show {{ title }} and {{ user.title }}.


texts:
I have below code coming from External Link module in Drupal 7:

/**
* Implements hook_page_build().
*/
function extlink_page_build() {
   $path = drupal_get_path('module', 'extlink');
   drupal_add_js($path .'/extlink.js', array('every_page' => TRUE));
   drupal_add_js(array('extlink' => array(
     'extTarget'     => variable_get('extlink_target', 0),
     'extClass'      => variable_get('extlink_class', 'ext'),
     'extLabel'      => check_plain(variable_get('extlink_label', t('(link is external)'))),
     'extImgClass'   => variable_get('extlink_img_class', 0),
     'extSubdomains' => variable_get('extlink_subdomains', 1),
     'extExclude'    => variable_get('extlink_exclude', ''),
     'extInclude'    => variable_get('extlink_include', ''),
     'extCssExclude' => variable_get('extlink_css_exclude', ''),
     'extCssExplicit' => variable_get('extlink_css_explicit', ''),
     'extAlert'      => variable_get('extlink_alert', 0),
     'extAlertText'  => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'),
     'mailtoClass'   => variable_get('extlink_mailto_class', 'mailto'),
     'mailtoLabel'   =>   check_plain(variable_get('extlink_mailto_label', t('(link sends e-mail)'))),
   )), 'setting');
}

I want to add below code from above function only if my some condition is true (which will be based on some user filed) , without overriding files of module it self:

drupal_add_js(array('extlink' => array(
    'extTarget'     => variable_get('extlink_target', 0),)), 'setting');

I am not getting any solution how to override this function thorough my custom module, Please suggest !

To make more clear I just want to add condition in above function so that js will only get added if condition according to user field is true.

UPDATE: I have tried like below code but its not working, please suggest what I am doing wrong My custom module name: custom_overrides

function custom_overrides_page_alter(&$page) {
   global $user;
   $userid = $user->uid;

    if($userid){
        $path = drupal_get_path('module', 'extlink');
        drupal_add_js($path .'/extlink.js', array('every_page' => TRUE));
        drupal_add_js(array('extlink' => array('extTarget' => variable_get('extlink_target', 0),)), 'setting');
  }
}

Thanks!


texts: Error using Drush on Windows 7 using Cgwin & Composer for Installation - The system cannot find the path specified

texts:
I am using Windows 7 64, with WAMPServer64, with Cygwin and composer installed.

C:\cygwin64
C:\wamp
C:\Users\dev\AppData\Roaming\Composer

I have followed all the steps required to complete a successful install of Drush. Everything seems to work correctly as far as I can tell. Here's the output of a drupal status command.

Drupal version                  :  7.32
 Site URI                        :  http://default
 Database driver                 :  mysql
 Database hostname               :  localhost
 Database port                   :
 Database username               :  db
 Database name                   :  db
 Drupal bootstrap                :  Successful
 Drupal user                     :
 Default theme                   :  theme548
 Administration theme            :  garland
 PHP executable                  :  /cygdrive/c/wamp/bin/php/php5.5.12/php
 PHP configuration               :  C:\wamp\bin\php\php5.5.12\php.ini
 PHP OS                          :  WINNT
 Drush script                    :  C:\Users\dev\AppData\Roaming\Composer\vendor\drush\drush\d
                                    rush.php
 Drush version                   :  7.1.0
 Drush temp directory            :  C:\cygwin64\tmp
 Drush configuration             :
 Drush alias files               :
 Install profile                 :  standard
 Drupal root                     :  C:\wamp\www\projects\dev\Mirror
 Site path                       :  sites/default
 File directory path             :  sites/default/files
 Private file directory path     :  sites/default/files/private
 Temporary file directory path   :  /tmp

However, when I execute the following command, I receive an error.

Initialized Drupal 7.32 root directory at                   [notice]
C:\wamp\www\projects\dev\Mirror
Initialized Drupal site default at sites/default            [notice]
Executing: mysql --defaults-extra-file="C:\\cygwin64\\tmp\\dru2DAB.tmp" --database=db --host=localhost --silent  < "C:\\cygwin64\\tmp\\dru2DAA.tmp"
Executing: mysql --defaults-extra-file="C:\\cygwin64\\tmp\\dru2E29.tmp" --database=db --host=localhost --silent  < "C:\\cygwin64\\tmp\\dru2E28.tmp"
Loading release_info engine.                                [notice]
Loading version_control engine.                             [notice]
Loading package_handler engine.                             [notice]
Executing: wget --version
Loading update_status engine.                               [notice]
/cygdrive/c/wamp/bin/php/php5.5.12/php                      [notice]
"C:\\Users\\dev\\AppData\\Roaming\\Composer\\vendor\\drush\\drush\\drush.php"
--php=/cygdrive/c/wamp/bin/php/php5.5.12/php  --backend=2
--verbose
--root="C:\\wamp\\www\\projects\\dev\\Mirror"
--uri=http://default  pm-updatestatus drupal 2>&1
Illegal string offset 'site' backend.inc:1030            [warning]
The command could not be executed successfully (returned:[error]
The system cannot find the path specified.
, code: 1)
pm-updatestatus failed.                                  [error]
Command dispatch complete                                   [notice]
Command dispatch complete                                   [notice]

The specific error being returned:

Illegal string offset 'site' backend.inc:1030            [warning]
The command could not be executed successfully (returned:[error]
The system cannot find the path specified.
, code: 1)

I cannot seem to track down this issue and I do not know enough about Drush to fix this error.

Can anyone offer any assistance?


texts: Trying to create a link in a custom module

texts:
I have the following code
  `  class PopularContentParselyBlock extends BlockBase {

 /**
  * {@inheritdoc}
  */

 public function build() {
 $client = new \GuzzleHttp\Client();
 $res = $client->request('GET', 'http://www.APIURL.com');
 $decoded = json_decode($res->getBody(),TRUE);
 foreach($decoded['data'] as $article) {
    $url = Url::fromUri( $article['url']);
    $endpoint = Link::fromTextAndUrl($article['title'], $url);

    }
  return $endpoint->toRenderable();
  }
}

`

When it prints out though all I get us Object. What am I doing wrong?


texts: How to allow for files of any extension to be uploaded?

texts:
I'm surprised this hasn't been asked before like this.

I want to allow users to upload files of all file extensions, without enabling each extension by hand. How do I do it?


texts:
I have a view with grouping (by one field) and sorting by nodequeue weight.
I want to sort the groups as well so I've used hook_views_pre_render and sorted the results array programmatically, but as far as I can see the results aren't rendered as the results array on $view->result order.

What am I missing? Workaround will also be great!
Thanks!


texts: render call in hook_node_presave uses admin theme

texts:
I am using hook_node_presave() to render my node and then save the output to a field field_node_cache.  However, when I do this, the renderer uses the admin theme, whereas I would like to use the site's main theme.

Is there a way to force it to use the site's main theme without disabling the admin theme?

function MYMODULE_node_presave(NodeInterface $entity) {
  switch ($entity->getType()) {
    case 'MY_CONTENT_TYPE':
      $render_controller = \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
      $render_output = $render_controller->view($entity, 'MY_VIEW_MODE', 'ja');
      $html = \Drupal::service('renderer')->renderPlain($render_output);

      $entity->set('field_text_main_display', $html);
      $entity->field_node_cache->format = 'MY_FORMAT';
    break;
  }
}


texts:
Drupal installation creates innoDB tables even though myIAM is set as default in my.ini

whenever i install a new Drupal 7.26 on my XAMPP (ApacheFriends XAMPP Version 1.8.2) running under Windows 7 I get innoDB tables in my database.

I put the following line in my my.ini file under [mysqld]

default-storage-engine=MyISAM

But still - after installing Drupal the tables are all innoDB?

What is is that i do wrong?


texts: How do I specify the custom template for a theme?

texts:
Instead of page.tpl.php, How can I use a custom template in theme? I am using the Zen theme.

In Drupal 6, we will specify it in the theme_preprocess_page(), using the $vars['template_files'][] array. I don't know what to use in Drupal 7.


texts: move paid paypal orders from shopping cart to Orders

texts:
I have an issue where people paying by paypal aren't completing the shopping workflow by returning back to site and therefore some orders are stuck in shopping cart with status of Shopping cart:Confirm Order.
When I goto Store -> Orders these are in the Shopping cart Tab.

I could edit order and complete transaction manually but is there a rule based or code I could run to occasionally update orders in this status.
or a View I could create which I could set status for these orders?


texts: How should I create a main page with a mix of dynamic and static content?

texts:
I apologize for the terribly basic question but I'm not even a particularly adept web dev.  I've read that Drupal is great if you know exactly what you want to do (then the API is handy) but I don't even know what I need yet. That is what I am hoping to gain from this discussion.

I want a main content page which has a fancy content slider (using jQuery or something) which will be a selector for showing some basic information on these 2 or 3 subjects.  I'm stuck on where I should be writing this mix of markup. In the template? Create "content" through a content type?  Since there's a fair share of CSS and markup required to do this, I don't know if I can do that through the "basic page" content type that was there.

I'm looking for pointers that can teach me how I would become aware of what Drupal can and can not do.


texts: Import your own interface translations automatically during profile or module installation

texts:
I have been trying to import my custom interface translation during profile installation using a .po file that is put inside the translations folder in my custom module. After running:

  drush locale-update && drush cr

All I get is community translations which are not accurate sometimes (no translation is imported from my .po file).

How can I import translations only from my local .po file?

Thank you.


texts: Alter exposed form with multiple exposed filters

texts:
I would like to change the default value of my exposed form. But the issue is, I work with multiple selects. So the values of the second select changes depending on the value of the first select...

I've tried with hook_pre_views, hook_pre_build,... but nothing seems to do the thing I meant to do...

Anyone with some suggestions or advice?


texts:
In Drupal 7, I'm trying to create a page that shows all terms in a specific taxonomy, along with node content that uses the taxonomoy.

What I'm hoping to do is create what's essentially a grid of views, where each term in the taxonomy displays: an image associated with the taxonomy term (the image field was added to this particular taxonomy), and then below it a list of nodes tagged with that term, ideally with each list having its own mini pager (although a complete listing or a partial listing with a "more" link would also work if a pager is not achievable).

I'd also like to do this without Panels, since I'm not using it anywhere else on the site.

Can someone point me in the right direction as to how I should approach this?


texts: Correct way to create Departments/Categories cck selectors in Drupal 7?

texts:
1. My Scenario:

I'm building a shopping cart and using Ubercart+Drupal 7 for it.

Manufacturers will be able to log in and create their own products with

Product attributes {Name, SKU, price etc}
Department + Category - can be multiple
a brand

A product can exist in multiple Department/Categories too.

Sample screenshot:
http://picpaste.com/pics/menu.1375842751.png
(wanted to post here but low reputation, can an admin post it here pls?)

2. Elaboration of the situation

I'm having trouble figuring out the most correct, stable and fastest way to set up Department/Categories with the following goals and criteria:

2i. Product - CCK fields for adding Department, Categories to product:

Select a department, and it's associated category (Dep+Cat)
There are going to be about 12 Deps, 15 Cats each = 180 categories. I do not want to list this as an entire taxonomy dropdown - confusing and ugly. My thought right now is to have two multi-select boxes side by side - "Department" with 12 items & "Category". To illustrate, here's a simple wireframe: http://picpaste.com/Add_dept_cat.png
As per the wireframe, manufacturers can list the product in multiple related departments and categories.

2ii. Add / Create + Add brand to product
 - Add an existing brand to the product
 - If brand doesn't exist, add a new brand and add it to the product
 - Brands are attached to the manufacturers who created them

2iii. I'm searching and finding modules such as taxonomy_menu, taxonomy_hierarchy and content_taxonomy. However a lot of them look like they are not stable or supported for Drupal 7. Even if they are ok, I'm not sure if I'm heading in the right direction by using these modules.

2iv. Shoppers (Authenticated users) should be able to see the main menu on top which actually lists the departments available. On hovering, a particular department's categories & brands within are shown. They can click a department from the menu or drill down to category or brand. On selecting one of these three, the product listing comes up -- if department, shows department items, allowing filtering by brand/category -- if category selected, e.g "moisturisers", shows all items and allows filtering by brand --- if brand selected, shows all items for that brand in this department / category, allows you to move up and see all items for the brand in this department, and in other departments..

3. Question

Having said all that, my question is more to do with the CCK input fields of department, categories & brands and the underlying taxonomy / menu structures and modules. For 2iii, any tips are welcome, but I'm not at that stage yet anyways so I'm not looking at that yet.

I'm having trouble with

how I should structure my data in taxonomies or other structures (menus?)
how to create the cck fields for the manufacturer to add multiple department / categories to his product
how he can add a brand to his product or create and add a new brand to his product

Ideally I want to achieve the above with modules in the most Drupal-correct, stable and fastest way possible, without having to write any code.

Thanks

Edit: one more question. If user adds multiple "Department-category" to a product, how to allow one of it to be the "main"?


texts: Antibot Failing when Webform Embeded in Gutenberg

texts:
When enabling Antibot on a Webform rendered through Guntenberg, I can not submit the form.

Create a "Custom Webform" block type with a single entity reference field for Webforms.
Create a block (of type "Custom Webform") that references a "Booking" webform
Go to the setting of my "Basic Page" content type and  allows users to include the webform block

However, when I enable Antibot on the webform and try saving the form, I get the error:

You have reached this page because you submitted a form that required
JavaScript to be enabled on your browser. This protection is in place
to attempt to prevent automated submissions made on forms. Please
return to the page that you came from and enable JavaScript on your
browser before attempting to submit the form again.

I've tried enabling Ajax with no success. I suspect this is a caching issue: when I edit the label of a input field, I have to flush all caches to see the changes reflected.
Currently, exploring lazy loading the block.


texts: How to define the right dependencies in .info, so drush can understand it?

texts:
Currently in my booking_timeslots.info I've the following dependencies:

dependencies[] = date
dependencies[] = date_views
dependencies[] = hierarchical_select
dependencies[] = hs_taxonomy
dependencies[] = hs_taxonomy_views

which fails with the following errors:

  No release history was found for the requested project
  (hs_taxonomy_views).

  No release history was found for the requested project (hs_taxonomy).

  No release history was found for the requested project (date_views).

when I'm trying to either enable the module, or installing it with quick-drupal command like:

drush qd --yes --core=drupal-7 testsite booking_timeslots

How do I specify to which main project they belong to, so the installation process won't fail?

Personally I know to which modules they belong, but I would like to automate this process, ideally by adding appropriate syntax into .info file so other services can understand its dependencies (such as drush). It seems running module in Simplytest sandbox can recognise these dependencies fine.

I can't find anything relevant in .info syntax docs apart of specifying (major.minor).


texts: How do I programmatically delete a node by internal url alias?

texts:
How do I programmatically delete a node with a specific internal url alias?

Background:
We are trying to delete this node so that it can be replaced during an update hook.


texts:
I'd like to remove the breadcrumb from the frontpage and haven't been able to find a solution in the configuration settings of the theme or custom breadcrumbs. So I am thinking of modifying the page.tpl.php

Do you see a problem with this?

Replace:

<?php print $breadcrumb; ?>

With:

<?php if ($_GET["q"] == variable_get("site_frontpage",
"node")){}
else if ($breadcrumb) {print $breadcrumb;} ?>


texts: Field values of nodes available as tokens

texts:
we would like to habe a node type only for side wide available values. We think we have a title and a 'value' field. When we need one of these values in text areas/fields we would like to type [title_of_the_node] and in the output we get the value of the value field displayed.

Does anyone know a solution for this?


texts:
Hi I am developing a custom module for menus and I want to add active class to menu items based on the current path. For this I have tried theme_menu_link() but this function only provides the mlid(menu link ID) of the original links and not all the menu items. But I need the mlid of all individual menu links.

Is there any alternate hook for this functionality, or any other way to do this?


texts: What happened to array-shift.com (Drupal Stackoverflow Clone)

texts:
It's interesting that there is no (recent) Drupal implementation of SO-like features.  I (and others) have a need to have an SO clone that has areas for private data (corporate owned), so we cannot use SO or the StackExchange engine.  I had high hopes for http://drupal.org/project/arrayshift, but it's fallen into disuse (and the demo site has been down for months).

Any suggested alternatives?  We've looked at OSQA and Question2Answer, and both seem like an annoying integration mess for user profile information.


texts: cache : "drush cr" versus admin toolbar "flush all caches"

texts:
What the drush cr would do that the flush all caches would not?
Particularely regarding block caching?

I got mad trying to set a custom block twig template for eventually figuring out that nothing was wrong with my code but flush all caches was not enough and drush cr would do the job.

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

EDIT: could there be a bias of my local dev settings ?

$settings['cache']['bins']['render'] = 'cache.backend.null';

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';


texts: Limit Entity Reference to Only Display Content Created By User

texts: This might be an easy solution, but I can't seem to figure it out. I have a content type referencing another content type. I have the entity reference field in the cotent type, and wish to limit the display to only show cotent from the other content type that the user has created. Right now, it is displaying all the content created from the other content type.


texts: Placing result count below Views exposed filters?

texts:
I have a View, and I want to display result summary below the exposed filters. Currently I am modifying views-view--view_name.tpl.php.

How I can render result summary header just below the exposed filters?


texts: How to prevent site showing wsod if guzzle try block fails

texts:
I am using guzzle to call web service .If there is any error i get white screen with error.
'GuzzleHttp\Exception\ClientException: Client error'

My code is as follow:

    try {
      $response = $this->httpClient->post($endPoint, [
        'verify' => FALSE,
        'body' => Json::encode($data),
        'headers' => [
          'Auth-Token' => $token,
          'Content-Type' => 'application/json',
        ],
      ])
    }
   catch (RequestException $e) {
      watchdog_exception('message', $e->getMessage());
    }

if i add 'http_errors' => false as option in post request i don't get white screen. Is there any other way of implementation that i don't get white screen with error if try block fails. The desired  feature is if there is a error in calling web service the default page should reload.


texts:
I am trying to find a module or a standalone solution that I can turn into a module that will allow me to have an instant messaging system like Facebook does on a Drupal site that I am working on. I have never setup a chat system before.

My particular requirements are rather stringent. It needs to be a solution where we host the chatting server (if one is needed separate from the website itself). It must use the site's login state (can't use an external system at all, that means no GTalk, Yahoo IM, or AIM). It also must be able to handle up to 1,000 users at any given time.

I have looked through the Drupal community and I tried the DXMPP module, but it requires Jquery UI 1.8 and that doesn't work with all of the other things that my site uses (such as Homebox). We do have a Jabber server already setup and ready to go.

Does anyone have any thoughts or options here? Thanks!


texts:
I am relatively new to Drupal and am about to develop a tribute site.  It will have a few informational pages but it's main focus is photographs.

There are about 150 photographs which have been sorted into about 10 categories.  I have these in raw form, and also in a powerpoint deck.  My preference would be to display the photos individually, but I'll use the powerpoint if it proves too difficult.

Ideally users would be able to navigate to a category of photos, then flick through them one at a time, or 'play' a slideshow.  Also, if it was not too difficult, I'd like to annotate some or all of the photos.

Where should I start with this?  I have installed Drupal 7 but see there is a wide range of modules and approaches for displaying photos.  I have experience with CSS, jQuery and PHP...

Any pointers much appreciated!


texts: URL Redirects and Configuration Management

texts: I have installed Drupal's Redirect module to redirect from old URL's to new ones. I have added the required redirects in my local environment, ran drush cex but can not see the redirects in the export directory. Are URL redirects are content and not config? Therefore can not be exported via configuration management and have to be added manually per environment?


texts:
I have a CSV file from which I am importing some data. Should I need to apply XSS filter? How do I achieve this?

   while (!feof($handle)) {
    $data = fgetcsv($handle);
    $path[] = $data[0];
    $title[] = $data[1];
    $description[] = $data[2];
    $abstract[] = $data[3];
    $keywords[] = $data[4];
}


texts: Is the Drupal Multisite something automated once its setup?

texts:
I am looking to create a multisite system that creates websites for users. But I need the users to be able to create their own website.
something like below steps :
Register>add domain>select theme>give donation(optional)>Done

Does the multi site feature allow this? If not, what is the best way to achieve this functionality?

Or what do you recommend we to achieve this?

Thanks


texts: Editable Fields, Custom Submit function is not being called?

texts:
I'm using editable fields, so I can edit the fields on node display page (e.g. at node/123). I want to add a submit function, so that I can add other process every time the user edit the field. My problem is my custom submit function is not being called.

Below is the code I'm using:

function apws_extras_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'editablefields_form_node_field_apws_batch_completed_field':
      if ($form['type']['#value'] == 'apws_batch') {
        $form['#validate'][] = 'apws_extras_batch_completed_form_validate';
        $form['#submit'][] = 'apws_extras_batch_completed_form_submit';
      }
      break;
  }
}

function apws_extras_batch_completed_form_validate(&$form, &$form_state){
  // Check if this field is set.
  // Code for validation here.
}

function apws_extras_batch_completed_form_submit(&$form, &$form_state) {
  drupal_set_message('Submit is working');
}


texts: We are creating a single page website responsive one. Planning to add a blog link. Can anyone specify how to create a blog page?


texts: how to add cck field to a content type Programatically in drupal 7?

texts:
Possible Duplicate:
  Programmatically create Fields in Drupal 7

I want to to add a cck field to a content type Programatically in drupal 7.

Any one who have some idea about this?


texts: format field option taking too long to loading

texts:
When I choose Plain Text or other format, the loading animation (blue throbber) is never stop, and I can't change the value to another.

If I force to click save button, It won't save the configuration change.
How to fix this problem?


texts:
Is there any slideshow module in D7 similar to this one - http://www.cnngo.com/shanghai/life/facekini-woman-chinas-latest-beach-sensation-680659

In D6 the Views Slideshow can do this but not sure in D7. Any ideas?


texts: How to pass pagination value to drupal view programatically?

texts:
I have a view with contextual filter and I render the view through program as below
$args=[$id];
$view = Views::getView('schedule');
$render_array = $view->buildRenderable('rest_export_1',$args);
$rendered = \Drupal::service('renderer')->renderRoot($render_array);

The view is paged with 5 results in each page. How do I pass the value to get results from the second page of the view?


texts:
How do you upload images to content other than articles? I tried adding  into the body of a block where I want a photo but it doesn't work. I've forgotten a lot of my html.

I'm doing something wrong. LEt's say, I want some sidebar blocks or even trtyptich blocks with an image in it. Do I start w/creating a view, a block, or an image that links to an article with the image and a caption showing in that block? That would help me immensely.


texts: How can I get a user_reference type field working that allows me to enter names that don't exist on the site as well as ones that do?

texts: So essentially I want a text field to operate in a similar fashion to the facebook tagging text field. By default I would be looking up other users on the site. So user reference field is obvious. However if the user isn't found I'd still like to keep the text they entered as they are just entering someone's name.  Obviously I could just go and code this I'm just wondering whether anyone has done or seen this done before?


texts: How to use PHP Mail function or sendmail to send and/or receive emails from my live site

texts:
I am hosting my site on OVH and they have told me that sending emails using external SMTP servers is not allowed. I need to use the PHP Mail function or sendmail. I have a Drupal 7 installation and I am completely lost.

Which of these is the best option?
What steps do I need to follow in order to use one of these options?

My site is currently live and I am not able to receive emails through my contact form.

Thanks in advance.


texts: How to put up a notification about scheduled maintenance?

texts:
I'm using Drupal 7.5 and I want to put up a notification about the website going into maintenance mode on x scheduled date and time. What is the best way to do this? Are there any built-in options for posting server maintenance notifications or must I create a custom block for it?

Forgive me for this super basic question, but I did a search and the other questions on this were more advanced.

Note: this site is run on a Commons Profile and developed by someone else.


texts: How to find elements inside a commerce order form with dpm()?

texts:
I want to identify a specific field inside a commerce order form. The machine name of the field inside the order form is: commerce_customer_profile.

Using Devel Themer I've got:

$form['element']['#field_name'] = 'commerce_customer_profile';

But I don't know if that's correct, or how programatically get that information?

I know that I could add dpm($node, 'Debugging node ' . $node->title); to my node.module file, but how may I do the same with commerce module without actually hacking it?


texts: Setting a header for checkmark in tableselect

texts:
I am interesting in adding text next to the checkmark in the table #header.

As you can see from the photo there isn't any text there.

My code for the table:

$header = array(
    'campground' => t('Campground'),
    'name' => t('Name'),
    'phone' => t('Phone Number'),
    'message' => t('Message'),
  );

$form['table'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
    '#default_value' => $values,
    '#empty' => t('No campground to claim'),
  );

Is it possible to add a title next to the checkmark?


texts: Fields missing on "Create a new entity" for Entityform submission

texts:
I'm using Rules to create node from Entityform submission. When I add an action with "Create a new entity", there is only one field ("title" value) available. How can I get the other fields from node type(content type)?

PS: Same issue with webform + webform rules.

- - update: add screenshots with Conditional Rules Setting - -

As you can see the "Create a new entity" only have Title and Author" fields available event I have other field tokens available.


texts: Using loadbalacer drupal admin not logged in

texts:
We have developed drupal site. Now our production enviornment is like this
Two load balancer IP's x.x.x.34 and x.x.x.35 and production server having IP y.y.y.56

Our production site name is www.examples.com is working fine but when we try to access the admin using www.examples.com/admin, it shows login page. After entering credentials it will display page not found/search page.

Please help help us how to resolve this problem?


texts: Get book bid to display at search results page

texts:
I'm trying to tweak my search results template to include the book root title at the bottom of every search results snippet. I have several books with very similar titles and content and i'd like to be able to print title of the book below each search result snippet so users know what they're going to get when they click search result.

I tried simply print $node->book['bid'] but it didn't print any result. I think it's because i have to somehow get the bid of a snippet and i'm getting bid of search results page which has no bid.

Am i right? And how i do that? I'm using Custom Search module to display my search results.


texts: common header and footer for all pages in drupal7

texts: i use different layouts for different pages for a large website, which share common header and footer. how can i create common header and footer templates and link the templates to these pages.


texts:
I have just been trying to get twitter going on my drupal 7.21 website.  i followed the tutorial at http://drupal.org/node/1346824
Everything was fine until the last step of authorising a twitter account, when i got a blank page back from the twitter app and a message saying "unauthorised oauth request".  I've tried re-installing, messing with callback URL's etc but cannot get anything to work. Has anyone else solved this problem?
Thanks
Andy


texts:
How to setup entity access correctly?

i have entity:

/**
 * @ContentEntityType(
 *   id = "test_entity",
 *   bla... let me know if you need detail of this
 *     "route_provider" = { "admin" = "Drupal\test_entity\Entity\TestEntityRouteProvider" },
 *   bla... let me know if you need detail of this
 */

and class TestEntityRouteProvider extends AdminHtmlRouteProvider implements EntityRouteProviderInterface with getRoutes as follow:

$parameters = ['target_type' => 'test_entity_type', 'target_id' => ['type' => 'entity:{test_entity}']];

$route = (new Route('/admin/testing/my-entity/{test_entity}'))
         ->addDefaults([
           '_controller' => '\Drupal\test_entity\Controller\TestEntityViewController::view',
           '_title_callback' => '\Drupal\test_entity\Controller\TestEntityViewController::title',
         ])
         ->setOption('parameters', $parameters)
         ->setRequirement('_entity_access', 'test_entity.view');

$route_collection->add('entity.test_entity.canonical', $route);

i read comments in: EntityAccessCheck:Access, it said:

  /**
   * ... dynamic entity type:
   * example.route:
   *   path: foo/{entity_type}/{example}
   *   requirements:
   *     _entity_access: example.delete
   *   options:
   *     parameters:
   *       example:
   *         type: entity:{entity_type}

question: is my $parameter in class TestEntityRouteProvider correct? i'm not sure if i follow the instruction in comment correctly.

and with my code above, $entity value in EntityAccessCheck:Access is "test_entity-15" as string

*for reference: "test_entity-15" is referring to my test entity ID the same as in my url: /admin/testing/my-entity/test_entity-15

if ($parameters->has($entity_type)) {
  $entity = $parameters->get($entity_type); // <-- value: "test_entity-15"
  if ($entity instanceof EntityInterface) { // will false in here
    return $entity->access($operation, $account, TRUE); // and didn't reach here
  }
}

and will giving me response:

  403: You are not authorized to access this page.

what am I missing here? let me know if you need my particular part of my code.

Thank You,


texts: How do I render a custom form on a view page?

texts:
In my module's routing.yml file I set the form path to a path which also shows a view page. But on that path the form does not get displayed, only the view.

When I change the path in the routing.yml it works, so I guess views somehow overrides/ ignores my form.

How can I do that?


texts: Why does Drupal need list (integer, float AND text) and what is the difference?

texts:
Could somebody explain why Drupal needs list (integer), list (float) AND list (text). What is the difference?

Values are set in key | value pairs. So:

list integer - saves key in database in integer format
list float - saves key in database in float format
list text - save key in database in varchar format

Why do we need list (float) and list (text), if we have list(integer)?

An explanation with examples would be great.


texts:
I have a form:

public function buildForm(array $form, FormStateInterface $form_state)
  {
    // Disable caching on this form.
    $form_state->setCached(FALSE);

    $scheme_data;
    // code to get select options removed for legibility

    $form['scheme'] = [
      '#type' => 'select',
      '#title' => $this->t('Select an organisation'),
      '#options' => $scheme_data,
      '#empty_option' => $this->t('Select an organisation'),
      '#ajax' => [
        'callback' => [$this, 'choseSchemeOption'],
        'event' => 'change',
        'wrapper' => 'scheme-option',
      ],
    ];

    $form['scheme-option']['option-query'] = [
      '#type' => 'container',
      '#attributes' => ['id' => 'option-query'],
    ];

    $formTrigger = $form_state->getTriggeringElement();
    if (is_array($formTrigger)) {
      switch ($formTrigger['#name']) {

        case 'scheme':
            $option_data = $this->buildQueryselect($form_state, true);
            $form['scheme-option']['option-query'] = [
                '#type' => 'select',
                '#title' => $this->t('Tell us more about your query'),
                '#empty_option' => $this->t('Select an option'),
                '#options' => $option_data,
                '#ajax' => [
                  'callback' => [$this, 'choseQuery'],
                  'event' => 'change',
                  'wrapper' => 'option-query',
                ],
              ];
          }

          break;

        case 'option-query':
          $option_data = $this->buildQueryselect($form_state);
          $form['scheme-option']['option-query'] = [
            '#type' => 'select',
            '#title' => $this->t('Tell us more about your query'),
            '#empty_option' => $this->t('Select an option'),
            '#options' => $option_data,
            '#ajax' => [
              'callback' => [$this, 'choseQuery'],
              'event' => 'change',
              'wrapper' => 'option-query',
            ],
          ];
          break;
      }
    }

    return $form;
  }

  public function choseSchemeOption(array &$form, FormStateInterface $form_state)
  {
    return $form['scheme-option'];
  }

  public function choseQuery(array &$form, FormStateInterface $form_state)
  {
    return $form['scheme-option']['option-query'];
  }
  private function buildQueryselect($form_state, $reset = false)
  {
  // ..returns select options
  }

When the scheme select changes, the option-query updates to the correct options.
When I change the option-query selected option, I want its options to change based on the value selected.

If I debug and watch the variables, $option_data is updated to what I am expecting, but the front end select options do not.

I have also tried commenting out the switch "case 'option-query':" in buildForm() and updated the ajax callback:

  public function choseQuery(array &$form, FormStateInterface $form_state)
  {
    $option_data = $this->buildQueryselect($form_state);
    $form['scheme-option']['option-query']['#options'] = $option_data;
    return $form['scheme-option']['option-query'];
  }

But that also failed to achieve the desired result. It also started generating "Illegal choice xx in Tell us more about your query element." errors when selecting an option after the first attempt.

What do i need to do to replace the options in the select that is calling the ajax callback? I don't want to replace the options in a different form element which the examples I have seen to far have demonstrated.

Thank you for your help.


texts: Limit the search for the current language only

texts:
I am using the default search block provided in druapl 8.2 and have languages 'english' & 'french' enabled on my site. However when i am doing a search on the site, the results return are for both the EN & FR version of the content. How can i limit the search for the current language only?

FYI: I am not using any views or modules for performing my search but simply using the default core search module.


texts:
In Drupal 8, Admin-Report > Status report > Twig C extension:   Not available
Enabling the Twig C extension can greatly increase rendering performance. See the installation instructions for more detail.

I installed Twig C Extension, but it's reported to not be enabled.

How do I install and enable the Twig extension for PHP, in Drupal 8?


texts: Remove the Preview button on the Contact Form

texts:
In in Drupal 8.5 (Theme Bartik), although I disabled in the UI the Preview button,  as shown in the picture below, it still shows up in the contact form page.

Am I doing something wrong? How can I remove the button? (I would like to avoid using CSS to do it)


texts:
I was playing around with my website, which was built by a developer long time ago, and I remove the permission for the "administrator" role, and now as a "superadmin" I can't access the Drupal panel of my own site.

Can someone help me figure out how can I access the control panel?

Thank you!


texts: Drupal 7: How to create dynamic link based upon url

texts:
I simply want a menu item which scans the url, grabs the second argument, and plugs it into the second wildcard location of the new menu item it's creating.

So if the URL is: http://drupal.org/contenttype1/johndoe (johndoe = 2nd argument)

the menu item displayed will be: http://drupal.org/contenttype2/johndoe (johndoe = wildcard location)

So far, based upon a few forum, I've sketched out the following code, which is clearly incomplete, and it is doing nothing right now.

Basically, I just want this menu item to link to an existing page mysite.com/[coach name]/page. I'm using clean URLs by the way.

        <?php
    function coachmenu_menu() {
      $items = array();

      $items['%/page'] = array(
        'title' => 'Coach Page',
        'page callback' => 'coachpagelink',
        'page arguments' => array('0'),
        'access arguments' => array('access content'),
        'type' => MENU_NORMAL_ITEM,
        'menu_name'=>"menu-coach-menu",
      );
        return $items;
    }

    function coachpagelink($wildcard) {
        return $wildcard;
    }

Any ideas on what I can do?


texts:
I would like to create a sign up form for visitors to my site to receive an e newsletter. One of the stakeholders in the project has specified some additional functionality in that he wants an email to fire to the user after they have completed to form that asks them to validate their details and confirm they wish to receive the email prior to said details being stored on Drupal.

Is there an off the shelf solution anywhere in the community, or will I have to create something from scratch?

I have done a (very) quick search, which yielded no results - if someone has seen something/ heard of something that will give this functionality I would appreciate hearing about it.

Many thanks.


texts: Custom module with config exposed in json api

texts:
I have a module with two pieces of config set using an admin form and Drupal the drupal config service.
Like this
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);

    $this->config('mars_spot_collection.defaultcollections')
      ->set('default_collection_title', $form_state->getValue('default_collection_title'))
      ->set('default_collection_description', $form_state->getValue('default_collection_description'))
      ->save();
  }

How do I make this conig available in the JSONAPI?
Cheers


texts: How can I send an e-mail to the admin when use of a view results in an error?

texts:
I have a large number of complicated views on a site, some of which, when searched with certain options or by certain users, give the following error:

  An illegal choice has been detected. Please contact the site
  administrator.

Is it possible to somehow catch this error and email the admin?  Ideally, I would be able to include the URL of the view causing the problem and the UID of the user accessing the view for troubleshooting purposes.


texts: Pathauto, user profile alias from content profile fields

texts:
I created the alias bartender/profili/[content-profile-profile-profile_name-raw]-[content-profile-profile-profile_surname-raw] for users.
I want to have '-' between name and surname but it always turns into a white space in my URLs.

Could anybody give me any clue about this?


texts: How can I make a node title input form in a block?

texts:
Im on d7. I want to have a block on the landing page of my site that has a "enter your title here" input field. When a user enters something in it and clicks continue, they are directed to the node submission form and the title field should be populated with what they had just entered. How would I put something like his together?
Thanks?


texts:
I followed this tutorial:
https://rapiddg.com/blog/creating-ajax-callback-user-reference-fields

to create a button to fill some field in a form with the values of the current user.

Here the cose I added to my hoo_form_alter:

if ($form_id == 'datore_node_form')
{
global $user;
  $form['title']['#type'] = 'hidden';
  $form['title']['#value'] = 'test';

$form['user_replace'] = array(
    '#title' => t("User Information"),
    '#prefix' => '
',
    //name of the node form (already existing, if you're modifying an existing node form)
    '#suffix' =>'
',

    $form['user_replace']['user_copy'] = array(
      '#type' => 'button',
      '#value' => 'Sono io il datore!',
      '#ajax' => array(
        'event'=>'click',
        'callback' =>'user_replace_ajax_callback',
        'wrapper' => 'datore_node_form_group_cs',
      ),
    ),
  );

 $form['user_replace']['field_cognome'] = $form['field_cognome'];
  unset($form['field_cognome']);

  $user = user_load($user->uid);
  dpm($user);
  dpm($user->field_cognome['und'][0]['value']);
  dpm($form);
  dpm($form_state);

  if (!empty($form_state['values']['field_cognome']))
  {
    unset($form_state['input']['field_cognome']['und'][0]['value']);
    $form_state['input']['field_cognome']['und'][0]['value'] = $user->field_cognome['und'][0]['value'];
    return $form;
  }

  function user_replace_ajax_callback($form, &$form_state)
  {
    ajax_command_alert("hello"); // doesn't work
    return $form['user_replace'];
  }

but if I click the button nothing happen.
Any advise?


texts: What is the performance impact of modules that use Field API instead of a custom way of accessing the database?

texts:
This answer states that it is better to share fields among content types when possible because each field added slightly negatively impacts performance.  Assuming this answer and my interpretation of it is correct, for nodes that already have lots of fields for unavoidable reasons, would avoiding the use of modules that make use of the Field API when alternatives are available enhance site performance?

For example:

Meta Tags instead of Meta Tags Quick