texts: Proxying a subdirectory to a remote site

texts:
The goal

Make all requests to a previously static page at https://www.example.com/sub/folder on server 1 (Proxy) ACTUALLY go to a Drupal site at https://other.example.com on server 2 (Origin)

This is also getting setup as a multisite, because there are sub/folder2, sub/folder3, etc. that will need to be converted to Drupal sites. I don't think this has anything to do with the problem, but for the sake of completeness, I'm adding the sites.php changes too below.

What I've done so far

Changes on Server 1 (Proxy): Apache config

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/sub/folder
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
SSLProxyEngine On
<Location /sub/folder>
  ProxyPass https://other.example.com/
  ProxyPassReverse https://other.example.com/
  ProxyPassReverseCookiePath / /sub/folder
</Location>

Changes on Server 2 (Origin): settings.php and sites.php

sites.php (because of multisite; and sites/sitename/settings.php is the file I'll be referencing below)

$sites['other.example.com'] = 'sitename';
$sites['www.example.com.sub.folder'] = 'sitename'; // I don't think this one is necessary, but just in case?

Aside from the standard DB setup in settings.php, the following has been added:

// $base_url allows for links/URIs to be generated properly
// Changing the REQUEST_URI seems to have fixed form issues, like the search block/form
// Not sure if the cookie_domain is doing anything/working properly
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) && $_SERVER['HTTP_X_FORWARDED_HOST'] == 'www.example.com') {
  $base_url = 'https://www.example.com/sub/folder'; // NO trailing slash!
  $_SERVER['REQUEST_URI'] = '/sub/folder' . $_SERVER['REQUEST_URI'];
  // (Edit) note don't put 'http' in front of this
  $cookie_domain = '.other.example.com';
}
...
$conf['reverse_proxy'] = TRUE;
...
$conf['reverse_proxy_addresses'] = array('ip.of.origin.server');

The problems

Trying to login through www.example.com/sub/folder/user validates (according to Drupal log)... but then it treats the page re-load as an anonymous user and fails access. Presumably, the cookie gets broke/lost/invalidated somehow in between. So, authenticated access to the server has to be done through other.example.com Not a huge problem (since the average Joe won't be logging in), but...
There's just a lot of annoying things occuring having to deal with fixing user/content created links and URIs. Currently, links that are first viewed after a cache clear are cached as whatever domain they're being viewed from. (This happened from using Pathologic module to force absolute URLs.) I realize this might not have been the BEST solution--using Pathologic--but if I fix problem 1., this should become a moot point.

So, I think I've got some kind of SSL/Proxy cookie issue at this point... any suggestions?


texts:
I am not able to insert rows into a table even though I have granted permissions to the corresponding database user.

I am able to insert rows into the same table with the same user from an individual php application. But if I try to insert a row from drupal, I get the error message as follows.

user warning: INSERT command denied to user 'username'@'localhost' for table 'table_name'

I even tried changing the password of the database user and changed the settings.php of drupal to reflect the new password, but still I get the same error message. I am able to run the SELECT queries successfully but not INSERT queries. What might be the problem here? Any help is appreciated. Thanks.


texts: Drupal Navigation Title "Reset" to Use Page Title

texts:
Does anyone know if there is a way to "reset" a navigation title so that it falls back in-sync with a page's title?

Please find below scenario.  Created a page with a title of "Page About Stuff." In the Main Navigation, we edited the navigation title of the page so that it was shorter (e.g., "Stuff Page"). Then we said, that's silly, let's go back to using the original page title as the navigation title.  However, now if we change the page title from the "Edit Page/Current" window (along with some other content on the page), the title of the page changes appropriately but the title within the navigation doesn't, it stay to what we manually set. My question is, is there a way to "reset" this title link so everything is back in-sync.

Share your thoughts on this?


texts:
On Drupal 9, I want to install the Taxonomy menu module using Composer, but I get the following error.

Using version ^3.4 for drupal/taxonomy_menu
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals

Installing drupal/taxonomy_menu (dev-3.x e89d1e8):
Authentication required (git.drupalcode.org): Username:

The command is waiting for a Git username/password, but two days ago the installation ran smoothly.
How can I ask for a stable version of the module?
On the project's page they write that, as of 21 May 2019, Taxonomy menu 8.x-3.x-dev is already fully compatible with Drupal 9.
This must be why composer require initially proposed 3.4 version and ultimately tried to install the dev-3.x version.


texts: How to get success message in popup using custom form?

texts:
How to get success message in popup form  here is my code :

   <?php
 /**
 * Implements security_settings_form().
*/
function security_settings_block_info() {
$blocks['testing'] = array(
'info' => t('testing1'),
'cache' => DRUPAL_NO_CACHE, //there are a number of caching options for this
 );

 return $blocks;
 }

function security_settings_block_view($delta = ''){
  switch($delta){
    case 'testing':
  if(user_access('access content')){ //good idea to check user perms here
     $block['subject'] = t('testing');
     $block['content'] = drupal_get_form('security_settings_form');
     //$block['content'] = security_settings_form();
     return $block;
  }
  break;
  }
  }
function security_settings_form($form, &$form_state) {
$form["wrapper"] = array("#markup" => "

");

   $result = db_select('taxonomy_term_data', 'ttd');
  $result->fields('ttd');
  $result->condition('ttd.vid', 2, '=');
  $results = $result->execute()->fetchAll();
   $termName = '';
   foreach($results as $record){

   $v[]=$record->name;

}
$form['cities'] = array(
'#type' => 'select',
'#title' => t('Click on your city'),
//'#multiple' => true,
'#options' => $v,

 '#attributes' => array('class' => array('my-class-1')),
  );
   $form['email'] = array(
   '#type' => 'textfield',
   '#title' => t('Enter email'),

   '#validate' => array('security_settings_form_validate'),
 );
    $form['save'] = array(
    '#type' => 'button',

    '#value' =>  'Save',

     "#ajax" => array(
  "callback" => "dr_search_test_form_callback",

  "wrapper" => "test-ajax",
  "effect" => "fade")

    );

return $form;
 }

function security_settings_form_validate($form, &$form_state) {
$email = $form_state['values']['email'];

 // Verify that the email address is valid.
   if (!valid_email_address($email)) {
  form_set_error('email',('You must provide a valid email address.'));
  }

}

  function dr_search_test_form_callback($form, $form_state) {

   global $user;
   $v=db_insert('security_settings')
   ->fields(array(
  'uid' => $user->uid,
  'email' => $form_state['values']['email'],
  'cities' => $form_state['values']['cities'],
    ))->execute();

   $email = $form_state['values']['email'];
   if (valid_email_address($email)) {
   $message = array('A new entry has been submitted');
   $to = 'abc@gmail.com';
   $params = array(
    'body' => $body,
    'subject' => 'Website Information Request',
     );
       if (drupal_mail('security_settings', 'some_mail_key',   $to,          language_default(), $params)) {
    drupal_set_message('Thanks, email sent.');  //success message
   } else {
    drupal_set_message('Email not sent.');
  }
  }

return "
".$v."
";
  }
 function security_settings_mail($key, &$message, $params) {
   $message['subject'] = $params['subject'];
   $message['body'] = $params['body'];
  }


texts: Can I include nodes in a view's results only at URLs specified in the nodes?

texts:
Is it possible to conditionally include nodes in a view based on the paths specified in a field on that node? The idea is to essentially mimic the default property of blocks, making their display allowed or disallowed at specified paths. My view (technically a view block) is being used to show sponsor images as a slideshow, and I'd like to be able to define which pages each specific sponsors' graphics should display.

I'd imagine it would include the use of a contextual filter on the field containing the paths, but I can't figure out how it would work. Possibly via some implementation of Views Argument Substitutions, although that seems to base its results off of specified path arguments and not the whole path.
In the meantime, I'm implementing Nodeblock as a partial substitute, but I'd prefer to leverage views if possible.

EDIT: Thanks to mchar's answer below, I was able to get a working snippet for this functionality. It could probably be optimized, but that's for another thread.

function MYMODULE_views_pre_render(&$view) {
    if($view->name=='sponsors') {
        $current_path = drupal_lookup_path('alias',current_path());
        foreach($view->result as $row_num => $row) {
            foreach($row->field_field_urls_to_show_up_on as $urlNum => $url) {
                $this_path = $url['rendered']['#markup'];

                // If the path contains an asterisk
                // Asterisks should only appear at the end of a path at the time of writing
                if (strpos($haystack = $this_path, $needle = '*') !== false) {
                    $this_path = str_replace('/*', '', $this_path);
                    if (strpos($haystack = $current_path, $needle = $this_path) === false) {
                        unset($view->result[$row_num]);
                    }
                }

                // if current_path is not the same as the provided path (no *)
                elseif ($current_path != $this_path) {
                    unset($view->result[$row_num]);
                }
            }
        }
    }
}


texts: How to change the label of the "To:" field in the Date Module

texts:
This doesn't seem to be the kind of thing you can change using hook_form_alter() unless I'm missing something.

The label of the "From" field can be any value you want, but the "to" field, if you have one, defaults to "to", see modules/date/date_elements.inc, line 369:

    $element[$to_field]['#title'] = t('to:');

so what's the correct way to change that to a value of my choosing, i.e. "Expires"? Via the Theme?


texts: How to modify contents of drupal select form element based on what was selected in a preceeding select element

texts:
First off, I am not a Javascript guru so this may be easy to acccomplish but I just don't know how.

Here is my situation: I have created a form in Drupal 7 and I have two dropdown select box in that form. I would like to change the possible selections in the second dropdown based upon what the user has selected in the first drop down.

Is there a way to add a change listener in Drupal so as to trigger an ajax update of the form?

Thanks.


texts: How can classes be removed from panel panes?

texts: Is there a way to remove the default 'panel-pane' classes, without creating hundreds of templates for different entities, and while still keeping the option of adding custom classes to panes?


texts:
I'm using media-7.x-2.0 and I would like to programmatically import media.

The workflow is this:

uploader uploads an audio file via ftps
a file watcher watches for changes in the upload directory and once upload has completed the file gets moved to the import dir and renamed.
a mail is sent to the publishers with the file's length.
whichever publisher is on duty that day imports the file via UI
creates a post
publishes post to social networks

So. I'd like to step in, after file gets moved to import dir and renamed the file should be imported to Drupal and the media library.

I have full root access and can do whatever it takes.

I'm guessing I have to somehow bootstrap Drupal and use the site's credentials. How do I do that and, step 2, how would I then use the media module's own functions to run the import?

Update:

Ok bootstrapping

<?php define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

getcwd() because even if you give it the correct root dir bootstrapping fails with theme errors and whatnot.

So this is step 1. Step 2? How would I now import a file, let's call it import/file.mp3?


texts: I have a backup of a Drupal 7 website with its database. Is there any solution to get the login path? I have tried many options: /?q=user/login, /login, /user, and /user/login.


texts: Adding metadata to a node through a module

texts:
I am developing a module that sync selected nodes with an outside site (another API on the web).  I need to add some meta-data to each node:

Last sync time (timestamp) - Not editable through UI
Outside API ID for this item - Not editable through UI
Sync enabled for this node (yes/no) - Editable through UI

Should I have my module create a new table through the Drupal Database API to store this data, or should I use the Field API?


texts: How to create charts in Views using Google Analytics data?

texts:
I'm trying to generate charts in Views using Google Analytics data.

I have the Google Analytics Reports module installed, but this module doesn't allow aggregation of data which make charts very difficult to develop.

Does anybody have a working solution to get charts in Drupal 7 using Google Analytics data?


texts: Can PHP pages be ported into Drupal "easily"?

texts:
If I have a php page, just a regular webpage that php retrieves database information from, dumps it out in tables, css, divs, all that.  Is it extremely difficult to port to Drupal?

I ask because if I don't use drupal, then I have one page with all my content and presentation and model all mixed up.  If I don't, then I've either got another framework I'm using, or I'm rolling my own.

Problem is that I need to build some pages now, but Drupal is not ready.  I can't delay, so later I want to integrate them.

I was hoping for advice on at least the best way to write a page that I know will later be in Drupal.

edit:  How do I write a php page in such a way that it is best prepared for later integration?


texts:
I think module views have problem with menu tabs.
I was created a simple views with settings menu tabs like this.
Custom view for user

Custom path

Settings menu Tabs

Contextual filter and settings

After i go to url: examples.com/user/1/display  and get error

RuntimeException: Callable
"Drupal\contact\Access\ContactPageAccess::access" requires a value for
the "$user" argument. in
Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument()
(line 142 of core/lib/Drupal/Component/Utility/ArgumentsResolver.php).

and url examples.com/user/1 with error:

Symfony\Component\Routing\Exception\MissingMandatoryParametersException:
Some mandatory parameters are missing ("arg_0") to generate a URL for
route "view.user.page_1". in
Drupal\Core\Routing\UrlGenerator->doGenerate() (line 171 of
core/lib/Drupal/Core/Routing/UrlGenerator.php).

I was doing something wrong? Can you help me?


texts: How to filter content (admin view) based on taxonomy term

texts:
I'm looking for a way (I'm happy to write a module if shown the way) to filter content in the admin view based on taxonomy term. I've been using the Administration View modules, but it doesn't provide what I'm looking for. And to be honest, I'd be happy to write a simple module that would do such thing. Can anyone point me in the right direction?

Thanks


texts:
I'm wondering that Drupal t() strings are not available for the translation.

Let me explain what I did. I'm going to make my site as multilingual (English & Dutch). English is my source language.

For this, I have added locale module and enabled English and Dutch language.

Then I installed Entity Translation && i18n module on my site.

And then I wanted to show some multilingual text in the user profile edit form. Hence I put form alter and given some string inside t('My topics').

Then I went to /admin/config/regional/translate/translate this page to add a translation for my custom string "My topics". But it not available there.

Where did I'm going wrong?

I'm using
 - Drupal 7.54
 - Enabled Drupal's core locale module
 - Entity Translation(7.x-1.0-beta6)
 - Internalization (7.x-1.17)


texts: how to do validation for duplicate primary key in database

texts:
I want to alert user for duplicate primary key insertion in database. here is the code:

<?php

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

  $items['form/formModule'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Form', //page title
    'description' => 'A form with a text field and Submit button.',
    'page callback' => 'formModule_intro', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form

    'access callback' => TRUE,
    'expanded' => TRUE,
  );

  $items['form/formModule/form1'] = array(
    'title' => 'Form One',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('formModule_form'),
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
    'weight' => 1,
  );

  return $items;
}

function formModule_form($form, &$form_state) {

 $result = db_query("SELECT n.nid, n.title FROM {node} n
                         WHERE n.type = 'product'");

    $options = array();
   foreach($result as $row) {
      $options[$row->nid] = $row->title;
    }
    //dsm($options);

    $form['productid'] = array(
    '#type' => 'select',
    '#title' => t('Select a product'),
    '#required' => TRUE,
    '#options' => $options,
    '#description' => t('Choose an option.'),
  );

  $form['stock'] = array(
    '#type' => 'textfield', //you can find a list of available types in the form api
    '#title' => 'Enter the stock',
    '#size' => 10,
    '#maxlength' => 10,
    '#description' => t('stock should be integer value'),
    '#required' => TRUE, //make this field required
  );

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

  return $form;
}

function formModule_form_validate($form, &$form_state) {

if (!($form_state['values']['stock'] > 0)){
   form_set_error('stock', t('Stock must be a integer value only.'));
  }

}

function formModule_form_submit($form, &$form_state) {

global $user;

  // Here u can insert Your custom form values into your custom table.
  db_insert('formModule_stock')
    ->fields(array(
      'productid' => $form_state['values']['productid'],
      'stock' => $form_state['values']['stock'],
      'created' => REQUEST_TIME,

    ))->execute();
    drupal_set_message("successfully saved formModule_stock");

}


texts: Problems with accessing private files uploaded via file field in a webform

texts:
I have a webform with a file field configured to private files. When I'm logged in as a superuser (uid=1) and trying to download the file, I get access denied.

I was trying to debug this, and this is what I noticed.

All private files served by the file_download() function that is called in the system.module. This function validates if the file exists and request the file headers using file_download_headers() function that triggers hook_file_download().

In the webform_file_download() function the module determines whether the file was a webform upload and grant or deny file access based on access to the submission. It validates access permission by calling webform_submission_access(). When I run dpm($account) in this function, I get an anonymous user when I'm trying to access the private file. When I browse recent log messages I have the entry below:

access denied   06/02/2015 - 11:23  system/files/webform/cv-uploads/cv.pdf  Anonymous

When I change the URL to file that doesn't exist, I get this:

page not found  06/02/2015 - 11:26  system/files/webform/cv-uploads/cv.FDP  admin

As you can see for some reasons when the module is trying to get access to the file that does exist, I get access denied and the user is anonymous. When the file doesn't exist, I get page not found and the user is a logged in user.

Any ideas why this happens?

UPDATE

I've added the following code to my index.php but I still get anonymous user when I'm trying to access the file.

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

+ global $user;
+ watchdog('user', '<pre>'. print_r($user, TRUE) . '</pre>');

menu_execute_active_handler();

I've copied over the whole site including database and files to my local machine, and I'm not experiencing this issue. There's should be some settings that does this on the live site.

UPDATE 2

I've noticed that on the live site we have a list of disabled functions that I'm not aware of. Maybe it will help somehow.

disable_functions = apache_child_terminate, apache_setenv, define_syslog_variables, escapeshellarg, escapeshellcmd, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, mysql_pconnect, passthru, php_uname, phpAds_remoteInfo, phpAds_XmlRpc, phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, system, xmlrpc_entity_decode, parse_ini_file,show_source,shell_exec


texts: How to sort view by the weight of referenced nodes?

texts:
I'd like to display the list of studies and their authors in a view. Authors are stored in a node reference field. It's very important to keep the original order of referenced authors in the view which is repredented by their weight.

I looked through View UI for a solution for this problem but didn't find any useful option.


texts: How to insert field value programmatically after node is created?

texts:
Let's say user creates a node of article type.There is a field called my_field which can be added multiple times to that node.If user creates or edits the node leaving my_field blank, a default value something like NA should be created in database and should be visible inside the my_field when user edits  node next time.

Tried so far:

Inside page.tpl.php

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'article')
      ->propertyCondition('status', 1);

$result = $query->execute();

if (!empty($result['node'])) {
  $nids = array_keys($result['node']);

  foreach ($nids as $nid) {

    $node = node_load($nid);

   if(empty($node->field_my_field))
   {
     $field_language = field_language('node', $node, 'field_my_field');
     $node->field_my_field['LANGUAGE_NONE'][0]['value'] = 'NA';

      field_attach_insert('node', $node);
   }
  }
 }

Note: I don't want to create default value inside field settings as my_field can be added multiple times which can go upto more than 20.

I am using drupal 7.41.


texts: altering a block that is embedded in a view

texts:
I have a view and in the header of the view, I am rendering a custom block. The block is showing up just fine, however, I need to alter it and I cannot seem to figure this out. I have tried hook_preprocess_block, hook_block_view_alter and a couple others. I know the ID of my block but it isn't helping.

If I am embedding the block in the view and I want to alter the block, do I need to first alter the view and tell it to rerender the block? I am using drupal 8. Any help would be appreciated.


texts: Content Moderation: Remove transition from select list programmatically

texts:
How do I alter this select list programmatically in my module?

Permissions won't work here since all the roles can use the 'Request publish' transition, but the roles that can also use the 'Published' transition don't need to see 'Request publish'. I think the easiest way to make this change is to remove 'Request publish' from the dropdown list.

I'm working with hook_field_widget_form_alter()

The code that I'm trying to override is from formElement() in ModerationStateWidget.php.

Thanks.


texts: How does one 'override' string used in a core file?

texts:
I'm trying to change the text "Already a member?" located in commons_core.blocks.inc to a different value. I would preferrably like to override this value and not directly edit a file in /profiles/drupal_commons/.

Can anyone recommend a good solution?


texts:
I want to inject a checkbox within a preprocess function and I think it should be a renderable array.

What is the structure of a renderable array for a checkbox?

Update:

I use profile2 module and have created profile checkbox fields. While viewing profile currently the field are show as just text. I want to show it as disabled checkbox with state. So it is not within a form.


texts: Checkboxes: how do I set the default values or show the user defined values using Form API?

texts:
I am using an checkboxes element within a form in module that I started developing for Drupal 7. This is my first attempt at module development and using the Form API. I am creating a list of checkboxes that list down all the content types of a specific site. An array of all the content types can be obtained by using the following: $nodeTypesRaw=node_type_get_names();. An array with the machine names of the content types as the keys and the human readable names as the values are obtained.

By default, I would like all the checkboxes to be selected and when the form is submitted. How do I achieve that? The Form API pages on the drupal site aren't very helpful with regards to setting the default values for checkboxes.

$nodeTypesRaw=node_type_get_names();
$nodeMachineNames=array_keys($nodeTypesRaw);
$form['process_comments']['custommod_published_comments_select_node_types']['custommod_published_comments_node_types_checkboxes']=array(
          '#deafult_value'=>$nodeMachineNames,
          '#options'=>$nodeTypesRaw,
          '#type'=>'checkboxes',
);

I initially started out with the above code, but it won't work. It does display the list of checkboxes, but they are not checked by default. The variable does get on form submission though (checked via drush and var_dump).


texts: Covert link field as link field text format?

texts:
I have used the link field for the button. Here, I have to change one word as Italic. I am not able to change the word as Italic in the link field.

I want to change the link field as link's title lik formatted.

How could I achieve this without using any module.

Please suggest me!


texts: How to programmatically duplicate a node reference field during rendering?

texts: I am working on a node type which contains node references to other types. I want to programmatically duplicate a few node reference fields based on a set of conditions during rendering of the node. I have not been able to figure that out.


texts: installed drupal site locally but not working (XAMPP)

texts:
I want to install the site from the server locally so I can test changes before performing them.

So:

I exported the database and installed it locally
I downloaded all the files that were inside the site root folder and put them in a root folder locally (but with another name)
I changed the parameter $db_url and $base_url

The problem is that the front page is shown correctly but when I click to go to another page from the menu it says:

[an error occurred while processing this directive] The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. [an error occurred while processing this directive]

Anyone have any idea?

NOTE: I just noticed that the url is something like this: http://localhost/root//articles/article-one

Thank you


texts: How do I display data in a dynamically created page

texts:
I have a form on the page that has multiple fields, one of which is a path (www.sample.com/PATH). With form data that I have, I need to forward to that dynamic page, and display form data (5 nodes for example).

This is the code I am using.

function MODULE_menu() {
  $items = array();
  $items['admin/URL_TO_SEE_FORM'] = array(
    'title' => 'Some title',
    'description' => 'Desc',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MODULE_form'),
    'access arguments' => array('administer users'),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

function MODULE_form($form, &$form_state) {

  $form['form_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Path'),
    '#size' => 60,
    '#maxlength' => 128,
    'autocomplete_path' => FALSE,
    '#required' => TRUE,
  );

  // other code that get's different data with ajax etc.

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

  return $form;
}

function MODULE_form_validate($form, &$form_state) {
  // some validation
}

function MODULE_form_submit($form, &$form_state) {

  $form_path = trim($form_state['values']['form_path']);

  $nodes = $form_state['values']['nodes'];
  // I need to get content from nodes ids whic should be easy

  // Need to set content to page under www.sample.com/$form_path

  $form_state['redirect'] = $form_path;
}

How can I do it?


texts:
I've created a custom twig template in which I'm placing a text field inside a  tag like so:

{{ content.field_sample_text }}

It renders the content of that field just fine but when I inspect it, it seems to create a new div below the  tag and places its contents in that div like so:

  Content of the field

There's an extra p tag at the end as well which is also confusing. How can I ensure that my text field renders inside the original p tag as intended so that I can style it properly?


texts:
Are there methods to exclude revision data in a database dump?
The purpose would be to reduce the file size for developers that want a db dump for local development.
I know that drush sql-dump has an option to exclude data from some tables with --structure-tables-key or --structure-tables-list. But is it safe to simply omit data from revision tables?


texts: If Statment in Custom node template based in feild content existance

texts:
I have a content type called specials

In that content type I have a field called discount code which has a machine name of field_discount_code

I have a custom node template called node--specials.tpl.php that I am using to fomate the display of this content type

If the discount code if filled in by the user I want drupal to show some text if it is left empty I want it show some other generic text

here is the code I am trying but not having any luck with

<?php if (!empty($content['field_discount_code'])): ?>

Call 1-800-661-2555 to contact our Guest Service specialists to reserve this package or book online by using discount code "<?php print render($content['field_discount_code']);?>".

<?php else: ?>

Call 1-800-661-2555 to contact our Guest Service specialists to reserve this package.

<?php endif; ?>

If I leave the discount code empty drupal is still showing the first text chunk but with nothing in the render($content['field_discount_code']); area.

so like this

Call 1-800-661-2555 to contact our Guest Service specialists to reserve this package or book online by using discount code "".

I have also tried

<?php if ($content['field_discount_code'] == "NONE"): ?>

text to display here

<?php else: ?>

text to display here

<?php endif; ?>

but no joy I am relatively new to drupal dev so perhaps I am doing this the wrong way any insight would be greatly appreciated!


texts:
I would like to link 2 images to their own external url using link image field.
I've tried adding the following codes under "rewrite results" but it doesn't work.

[field_social_links]

I suspect [field_social_links-url] still includes the internal URL. What can i do? Please advise.


texts: If a node is changed by another user, the change time is shown on /admin/content but not by which user the node was changed. I couldn't find any field in the respective view to add. Did I miss sth?


texts: Receiving notifications when user edits a node?

texts:
Newbie here!
I'm running a site on Drupal 7 (iloveqatar.net) and users have the ability to submit their own content (News, Events, etc...).

I'm facing a couple of issues.

1) When users submit new content that's in moderation to be approved, I don't get any notification. What's the best module to a) send emails to moderators / admins so they're aware there is content that needs to be approved and b) Display the notification on the site (like an unread message counter).

Right now I click on "Needs Review" on the admin bar on the top of the site every few hours just in case theres new content.

2) This one is the more problematic issue. When a user submits an event for example, and it's then approved, the user still has the ability to edit his/her post, which then creates a draft that needs to moderated and approved. However since it's creating a draft of an existing note, I'm not seeing it under the 'needs review' table. I actually have to go to that specific event and then edit it to approve the changes. Of course that's no good for me, because I can't go around checking every single post just in case there's an edit.

Does anyone know of a solution for this so that I can get notified and/or it shows up in 'needs review' ?

Please do let me know if I need to include any additional information to get help.

Thank you so much in advance!


texts: Changing the logic for an exposed taxonomy select in a view

texts:
So, I have a view of a content type, and this content type has three unique taxonomy terms it are: Alpha, Beta, and Both.

Currently, my view lists all nodes of this type, and I've added an exposed filter that lets the user select one and only one of the three terms above, like so:

Both -> Show only content tagged Both

Alpha -> Show only content tagged Alpha

Beta -> Show only content tagged Beta

What I would now like to do is extend the behaviour of the filter so that the following happens:

Both -> Show only content tagged Both

Alpha -> Show only content tagged Alpha and Both

Beta -> Show only content tagged Beta and Both

So as you can probably see, if something is Both, then it is also Alpha and Beta. Obviously the taxonomy terms themselves don't contain this semantic information.

I cannot use "All" to represent Both because then selecting Both -> Alpha, Beta, Both.

So I'm thinking that somehow I could make Alpha and Beta a child term of Both, and Better Exposed Filters might allow this logic to work? Or will I need to use a hook - if so, which hook and any ideas about how I might approach it?


texts: Views 3.8 hook_views_default_views() stopped working

texts:
I have a default view made using the views hook hook_views_default_views().

It was working right and when I updated to Views 7.x-3.8 it stopped working.

It is not shown in structure -> views, the routes don't work too (site_url/calendar)

Seems the hook is not launching, or if it is, it does not load the view.

Updated drupal to 7.31 version, and CTools to 7.x-1.4.

Erased all the caches, drupal, views, memcached.

And it is not working.

The code looks like this:

// code included in my_module.views_default.inc
function my_module_views_default_views()
{
  export = array();
  $view = new view();
  $view->name = 'planning_calendar';
  $view->description = 'Calendar with planning dates';
  $view->tag = 'Calendar';
  $view->base_table = 'node_revision';
  $view->human_name = 'Planning Calendar';
  $view->core = 7;
  $view->api_version = '3.8';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

  // view code ......

  $export[$view->name] = $view;
  return $export;
}

There is also this hook on the module:

// code included in my_module.module
function my_module_views_api() {
  return array("api" => "3.8");
}


texts:
I'm adding different way of node editing so I have this code in my module:

$items['node/%node/edit-full'] = array(
'title' => 'Full edit',
'page callback' => 'node_page_edit',
'page arguments' => array(1),
'access callback' => 'node_access',
'access arguments' => array('update', 1),
'weight' => 0,
'type' => MENU_LOCAL_TASK,
'file' => 'node.pages.inc',
'file path' => drupal_get_path('module', 'node'));

What is disturbing.. it changes theme from admin to regular. Instead of Seven Theme I see regular website theme. Am I missing some variable in my definition?


texts: altering access callback in hook_menu_alter

texts:
So, I want to set a new function as access callbacks for URLs specified by registration module.

Specifically I want only users that have the update rights on the node to be able to manage registrations for the node.

I implemented hook_menu_alter in this manner:

function enge_events_menu_alter($items){
  $items['node/%entity_object/registrations']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/list']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/list']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/settings']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/settings']['access arguments'] = array(1);
  $items['node/%entity_object/registrations/broadcast']['access callback'] = 'user_can_manage_registrations';
  $items['node/%entity_object/registrations/broadcast']['access arguments'] = array(1);
}

but for some reason the function never fires.

If I instead redeclare the module's hook_menu and change the access callback functions there, it works and it get's written in the database after a cache clear.

Is it possible to alter access callbacks in hook_menu_alter?


texts: How can i display unread articles to a user

texts:
I want to display unread articles to the users.

I thought about using views, since the history module is active in core with my Drupal 8.

But i didn't find a way to only display those unread articles.


texts: How to log actual SMTP Authentication module communication with server?

texts:
We are using SMTP Authentication  module. Our SMTP provider claims we are whitelisted. Configuration works. When Drupal is supposed to send email, proper entry appears in Watchdog, claiming succesful sending.

Sadly, these days only 2 kinds of email ever arrive to our users: "Account disabled" and "Account deleted" notifications, and SMTP Authentication module test email. Password restore mails, email confirmation ones, user awaiting moderator's approval etc does not.

How can we log actual communication with SMTP server and have it stored for future reference? Now we don't know if we have to look for a bug in Drupal, or is it SMTP server's fault. With real data, we could tell for sure, and fix / have fixed the part that really needs it.

Enabling "debug" in SMTP Authentication is not practical - it debugs to screen, so it breaks AJAX calls and most of these emails are password recovery or new user ones, so they are triggered by anonymous - who obviously will not see debug data.


texts: Display a block only if another specified block isn't visible?

texts: The issue is that I have a Menu Block with parent items that don't yet have child menu items, but eventually might.  I want to display another block in place of the menu block if the menu block is not on a particular page.  I have tried rules, rules bonus blocks, context, even conditions in my page templates but I am a PHP novice and so far it doesn't seem possible to create a condition based on a block's visibility.  I hope that makes sense!  Any help much appreciated!  I am using D7.


texts: Filtered HTML Text format without an editor

texts:
How can I set up the following:

Administrator should be able to use Full HTML with an editor window in Nodes.
Users should be able to use Filtered HTML in Nodes without an editor - just the markup.
Everybody should be able to use Filtered HTML in comments via markup - no editor.


texts: How to change Drupal's default "Unable to send e-mail." message?

texts:
I wanted to override/change the text message that appears while sending Drupal mail.

This is the text "Unable to send e-mail. Please contact the site administrator if the problem persists."

What are the ways to change this message into my own custom message ?


texts:
I am not able to get drush to work properly:

1) I can download modules & themes through drush but I cannot enable them (more details below).
2) Also I cannot use the omega commands even though they are listed (more details below).

= I installed Composer & Drush as per docs.drush.org/en/master/install/
= Drush is properly installed on my computer, when I type drush version I get: Drush Version : 7.0-dev

My system setup: Linux mint 17 KDE with Xampp 1.8.3-4

I guess my problems are (partly?) caused because Drush was not able to start (bootstrap) the Drupal database. So I run mysql from command line:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

In my system mysqld.sock is in a different location, namely /opt/lampp/var/mysql/mysql.sock. So I created a symbolic link in /var/run/mysqld/ but this has no effect. Still have the same problems. Maybe caused by permissions?

I have spend a few days of and on (had to stop out of frustration) and I cannot get drush to work.

Details of my problems:
1) I can download modules & themes through drush but I cannot enable them:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush en disqus
Command pm-enable needs a higher bootstrap level to run - you will need to invoke [error]
drush from a more functional Drupal environment to run this command.
The drush command 'en disqus' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:

bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See drush topic docs-aliases for details.
connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See drupal.org/node/1428638 for details.
Drush was attempting to connect to:
Drupal version : 7.34
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database port :
Database username : root
Database name : drush
PHP executable : /usr/bin/php
PHP configuration : /etc/php5/cli/php.ini
PHP OS : Linux
Drush version : 7.0-dev
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /opt/lampp/htdocs/drush
Site path : sites/default

When I add

'host' => php_sapi_name() == 'cli' ? '127.0.0.1' : 'localhost',

or:

'host' => '127.0.0.1',

to settings.php as per this post I get following error:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush en disqus
PHP Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /opt/lampp/htdocs/drush/includes/database/mysql/database.inc on line 46
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in
/opt/lampp/htdocs/drush/includes/database/mysql/database.inc, line 46

2) Also I cannot use the omega commands even though they are listed:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush help --filter=omega
All commands in omega: (omega)
omega-export (oexp) Exports the theme settings of a given theme from the database to the
.info file.
omega-guard (ogrd) Runs guard for the given theme including Compass and LiveReload by
default.
omega-revert (orev) Reverts the theme settings of a given theme by deleting them from the
database.
omega-subtheme Creates a Omega subtheme.
(osub)
omega-wizard (owiz) Guides you through a wizard for generating a subtheme


texts: How to prevent adding of duplicate item to Drupal Queue?

texts:
I am using Drupal Queue (Class DrupalQueue) to store items (a simple objects).

How can I check if there is already the same object in the queue before adding a new one ?


texts: How to only show the first paragraph item?

texts:
I have a content type and attached is paragraph type with the setting of unlimited paragraph items.

On creating a page view of nodes and adding a relationship with the known paragraphs.

The views page shows all paragraph items attached to the node. How do I only show the first paragraph image item? I have a group of nodes that need to show the node title and the paragraph items first image in the page view

I have tried to filter it using image_first as suggest and I still be all the images on the paragraph type showing. See image


texts: Unable to go to administration pages (access denied)

texts:
It seems I have some problems to access some functions. When I try to run my website
I have these errors:

  warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'nodereference_autocomplete_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in D:\SVN\lancaster\Dev\drupal\includes\menu.inc on line 452.
You are not authorized to access this page.

I tried to check if all my modules were enabled, but I can't log in as administrator in my site too. When I do it, I get the following error:

  Forbidden
  You don't have permission to access / on this server.


texts: Drupal 6 Webforms sends duplicate emails

texts:
A user fills out a webform that I created and it gets emailed me. Sometimes I get duplicate emails when they fill it out. I'm thinking that this is because they are hitting the submit button multiple times.

Is there a way to avoid these duplicate emails from happening? I use the smtp authentication support module and gmail to send the request out. Perhaps it's taking too long connect with gmail and the user is getting impatient, thus feeling the need to press the button continuously.


texts: How to update a views row class in real time clicking a Flag (ajax) link

texts:
Flag allows flag toggle link to use ajax, but that does not update the row class in real time. Only the field class is changed.
Question is how to make the row to have a class when the flag link is clicked.
In my case, its a simple common case scenario of task list and the flag toggle is used to make a task 'completed', which should make the whole row another color in real time, not after page refresh.

I got as far as this script, which doesnt yet seem to work. It adds the class .highlight_row to the row in which a flag link is clicked. The flag link has a class .unflagged before clicking.

$(document).ready(function(){
    $('.flag').click(function() {
       if ($(this).is("unflagged")) { //If unflagged
        $(this).closest('tr').addClass("highlight_row");
    } else {
        $(this).closest('tr').removeClass("highlight_row");
    }
    });
});

EDIT
The following code worked eventually:

(function($) {
   $(document).ready(function(){
        $(".rules-link-set_completed").children("a").click(function() {
            $(this).closest('tr').addClass("completed");
        });
   });
})(jQuery);


texts:
I have created a custom block (that resides with path visibility of users/*).

I have written some PHP code to allow users to message each other (D7 Privatemsg module):

<?php
// Get user object.
if ($account = menu_get_object('user')) {
  if ($url = privatemsg_get_link(array($account))) {
    return l(t('write a mail to this user'), $url, array(
      'query' => drupal_get_destination(),
    ));
  }
}
?>

In that same block, I would like to add another snippet to show a Flag Friend link. This would give me one block with two links: one for mail, one for adding/removing friendship.

Does anyone know the PHP code for flagging a friend?


texts: How to make commands invoked by drush_invoke not to fail after adding extra option?

texts:
I've added new option into drush command as suggested here:
function hook_drush_help_alter(&$command) {
  if ($command['command'] == 'features-revert-all') {
    $command['options']['cleanup'] = 'Remove non-existing components.';
  }
}

where features-revert-all is overridden by another created custom command as demonstrated here (so basically another custom-features-revert-all command is called).
However when my custom command invoking another commands via drush_invoke - they fail, because they cannot find that option. I really don't care about the option whether they can recognise it or not, but they shouldn't fail.
So basically when I run:
drush fra --cleanup --yes

I've these errors:

Unknown option: --cleanup.  See drush help features-cleanup-feature for available options. To suppress this error, add the option --strict=0.
Unknown option: --cleanup.  See drush help rules-revert-all for available options. To suppress this error, add the option --strict=0.

Here is how my function look (simplified for clarity):
function drush_FOO_custom_features_revert_all() {
  module_load_include('inc', 'features', 'features.export');
  $force = drush_get_option('force');
  $cleanup = drush_get_option('cleanup'); // At this point, the option is working.

  $features_to_revert = features_get_features(NULL, TRUE);
  if ($cleanup) {
    drush_invoke("features-cleanup-feature", $features_to_revert);
  }
  else {
    drush_invoke("features-revert", $features_to_revert);
  }
  drush_invoke('rules-revert-all');
}

So basically the option works fine within the main function, but sub-commands are complaining that this option that it's unknown to them.
Question is, what's the correct approach of fixing it (so they won't fail)?
Do I need to add option to every other command which uses drush_invoke into drush_help_alter? Maybe there is some way of passing original drush options along. Or maybe I am forced to use --strict=0? Or there is some better way of fixing this issue?


texts:
I have this array in PHP

$link = array(
    '#type'    => 'link',
    '#title'   => 'link1',
    '#href'    => 'http://www.link1.example',
    '#suffix'  => '
',
  );

when i call the render() functions i get the correct html

link1

How i can change the above render array in order to include an image as a link?

In other words i want this as output from the render() function

I have tried to use the theme('image',$array) function but when the result of theme() is passed to the render() i don't see the image to my page but the actual html code.


texts: WSOD on deploy: failed to open stream: No such file or directory

texts:
I am trying to deploy a site to a live server, but running into a "white screen of death". Enabling logs revealed that the zurb foundation starter theme was the source of my issues, so I disabled that and was able to use the site. I then switched it back on and went straight into white screen of death again.

Then I used drush to get a login url and accesed /admin where I could so the following list of errors:

https://gist.github.com/webconsult/a82eebc3d25480f674ed

I checked, and it seems these files and functions are all present. I'm not sure if the ownership settings are correct, though, but I am assuming the apache user is able to read and execute the fieles correctly since everything works if I switch away from the Zurb Foundation theme (i.e. Garland theme). Here is a sample of ownership and permission of the files in /includes:

-rw-r--r-- 1 admin admin  13816 Mar 19 18:30 actions.inc
-rw-r--r-- 1 admin admin  48742 Mar 19 18:30 ajax.inc
-rw-r--r-- 1 admin admin   1701 Mar 19 18:30 archiver.inc
-rw-r--r-- 1 admin admin  13664 Mar 19 18:30 authorize.inc
-rw-r--r-- 1 admin admin  17497 Mar 19 18:30 batch.inc
-rw-r--r-- 1 admin admin   2310 Mar 19 18:30 batch.queue.inc
-rw-r--r-- 1 admin admin 119919 Mar 19 18:30 bootstrap.inc

How can I fix this issue?


texts: How to define a timestamp field using drupal6 schema

texts:
In this way I can create a table with a timestamp field in MySQL:

CREATE TABLE foo (
  id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  created_at TIMESTAMP,
  name varchar(255)
);

Which would automatically insert a timestamp value each time a new row is inserted.

For example:

INSERT INTO foo (name) VALUES ('bar');
SELECT * FROM foo;

Output:

+----+---------------------+------+
| id | created_at          | name |
+----+---------------------+------+
|  1 | 2012-03-12 10:47:02 | bar  |
+----+---------------------+------+

How can I create a timestamp field like this using the drupal6 schema API?


texts: Resources for creating complex entities?

texts:
I have been working with Symfony 2-3 from the developer perspective, where you are able to create complex entities with various relation types (many-to-one, many-to-many, one-to-one) easily. Also these entities have multiple relations and can be added/edited/deleted/read via short and handy class methods.

Example for a complex entities:

"product entity" has a one-to-many relation to "color entity"
"color entity" has a many-to-many relation to "color structure" entity

See entity associations in Doctrine: http://symfony.com/doc/current/doctrine/associations.html

Another benefit in Doctrine is, that the entities are structured with primary-foreign-key pairs. They allow you, to easily inspect the relations via your database schema by a database tool like MySQL Workbench.

I do not want to use Doctrine inside of Drupal 8. I want to use Drupal entities. However it seems more complicated than in Doctrine and I am searching for some guidance.

In Drupal 8 I see just resources for simple entities. Like the content entity example in the "Examples for Developers" module: https://www.drupal.org/project/examples. There's just 1 relation from 1 contact entity to the user entity.

If I inspect the Drupal 8 database schema, there are no primary-foreign-key pairs. By digging in the code of the Drupal 8 core entities, I see just the "entity_reference" field type. There's no one-to-one, many-to-many or one-to-many relationship. It seems that Drupal entities are just so far behind the entities in Doctrine. Right now it seems like a mess, to inspect any data via a database tool like MySQL Workbench.

So I am asking myself, how am I able to practically work with "complex entities" in Drupal? How do I get an overview of my complex entities structure and how do I create them at all? How can I limit the association types (one-to-many, many-to-many etc.)?

Should I be using a REST api into Symfony to build complex entities?

I have been checking the ERD project at https://www.drupal.org/project/erd, but it seems that this project is dead and it has not been working in my tests.

Any sources which would enable to efficiently work with Drupal 8 entities would be appreciated. Please be so kind and share a bit of your resources in working with Drupal 8 entities.


texts: I have comments that are being auto approved in Drupal and I'd like to disable that.  I want to approve comments before they are published.


texts: How do I programmatically change the query "limit"?

texts: I've created listing with views module in which page has 9 items and only in first page the sixth item should be advertisement instead of result item. It means all items after sixth element should be shifted for one item. How can I do this? Would be hook_views_query_alter() the correct hook?


texts:
I created block in the custom module. This block works, but I see Notice in the Recent log messages.

  Notice: Undefined index: elements in block_theme_suggestions_block() (line 179 of /var/www/html/drupal-8.3.x-dev/core/modules/block/block.module)

I see block_theme_suggestions_block().

function block_theme_suggestions_block(array $variables) {
  $suggestions = array();
  $suggestions[] = 'block__' . $variables['elements']['#configuration']['provider'];

And for my block $variables['elements']['#id'] is NULL.

I can't understand why my block can't pass the ID as other blocks.

The code I am using is the following.

/**
 * @Block(
 *   id = "hello_messages",
 *   admin_label = @Translation("Hello messages"),
 * )
 */
class HelloMessagesBlock extends BlockBase {

  // ....

  /**
   * {@inheritdoc}
   */
  public function build() {
    $config = $this->getConfiguration();
    $hello_messages = hello_messages_block_get_messages($config['amount_messages']);

    return array(
      '#theme' => 'block--hello_messages_block',
      '#type' => 'markup',
      '#content' => $hello_messages,
      '#attached' => array(
        'library' => array(
          // Custom .css styles for block.
          'hello_messages_block/hello_messages_block',
        ),
      ),
    );
  }
}

/**
 * Implements hook_theme().
 */
function hello_messages_block_theme($existing, $type, $theme, $path) {
  return array(
    'block--hello_messages_block' => array(
      'variables' => array('content' => NULL),
      'base hook' => 'block',
    ),
  );
}

This is the content of block--hello-messages-block.html.twig.

{% extends "block.html.twig" %}
{% set attributes = attributes.addClass('block-hello-messages') %}
{% block content %}
{% for key, value in content %}

{{ value.user }}

{{ value.time }}

{{ value.text }}

{% endfor %}
{% endblock %}

Why doesn't my block pass $variables['elements']['#id'] to the theme suggestion hook?

UPDATE:

Thank you, Berdir.
This solution helps me.

function hello_messages_block_theme($existing, $type, $theme, $path) {
  return array(
    'block--hello-messages-block' => array(
      'variables' => array('content' => NULL),
      'template' => 'block--hello-messages-block',
    ),
  );
}


texts: Commerce: is there something in the basket?

texts: Is there a global variable of sorts that can be used as a bool to determine if something is in the basket?


texts: Where can I alter the labels used on the login form?

texts: This must be configurable somewhere, surely, but I just can't find where. I'm sure I'm doing something silly. Apologies for such a simple question.


texts: Error: setLibraries() must be of the type array

texts:
I am trying to integrate a React module into Drupal, my first time trying to do such a thing. I have developed this module locally and it runs fine. When I upload it to my server, I get the following error. What could be the difference that is causing this error and how can I fix it? I know there is probably a lot different between my local env and the server env, so any help with what it could be is appreciated.
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\Core\Asset\AttachedAssets::setLibraries() must be of the type array,
string given, called in /var/www/html/web/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php
on line 141 in
Drupal\Core\Asset\AttachedAssets->setLibraries() (line 52 of core/lib/Drupal/Core/Asset/AttachedAssets.php).

/modules/custom/react-crud/react_crud.libraries.yml
react-basic:
  js:
    dist/index.js: { preprocess: false }

/modules/custom/react_crud/src/Controller/ReactCRUDBlock.php
<?php

namespace Drupal\react_crud\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\react_crud\Controller\ReactCRUDController;

/**
 * Provides a 'ReactCRUDBlock' block.
 *
 * @Block(
 *  id = "react_crud_block",
 *  admin_label = @Translation("React CRUD block"),
 * )
 */
class ReactCRUDBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];
    $build['#attached']['library'][] = 'react_crud/react-basic';
    $build['react_crud_block'] = [
      '#markup' => '

'
    ];
    return $build;
  }
}

/modules/custom/react_crud/src/Controller/ReactCRUDController.php
<?php

namespace Drupal\react_crud\Controller;

//use Drupal\examples\Utility\DescriptionTemplateTrait;

/**
 * Controller routines for block example routes.
 */
class ReactCRUDController {
/**
   * {@inheritdoc}
   */
  public function example() {
    $build = [];
    $build['#attached']['library'][] = 'react_crud/react-basic';
    $build['react_crud_block'] = [
      '#markup' => '

'
    ];
    return [];
  }
}


texts: How to enable a payment method as soon as an order is saved in Drupal commerce programmatically?

texts:
I am trying to create a membership site using Drupal commerce. I have created a custom form that collects all the billing details of the user and the membership type and then on submit creates and saves a Drupal commerce order (products have already been created).

Now I want to activate the payment system for the order as soon the order is saved but I have not been able to do so. All of this should be happening in the backend and I do not want to redirect the user to a payment page. How do we do that?


texts: Commerce programatically Create Order with Customer Profile

texts:
I am using this method to create order successfully, how do I add a customer profile with all the country/address etc to this order?

There does not seem to be any reference to customer profiles in commerce_order_save. I had a peek into the commerce_order database table and it also must be hidden in data.

function create_order_with_products($product_ids, $uid) {
    $order = commerce_order_new($uid, 'pending');

    // Save the order so its ID is assigned.
    commerce_order_save($order);

    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);

    //add products to order by ids array
    foreach ( $product_ids as $product_id ){
        $product = commerce_product_load($product_id);

        // Create a line item with quantity 1 and this product.
        $line_item = commerce_product_line_item_new($product, 1, $order->order_id);

        // Save the line item to get its ID.
        commerce_line_item_save($line_item);

        // Add the line item to the order using the wrapper.
        $order_wrapper->commerce_line_items[] = $line_item;
    }

  // Save the order.
  commerce_order_save($order);

//somehow attach the profile to the order????
$profile = commerce_customer_profile_load(exampleID);

//How do I use this wrapper maybe?
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$wrapper->{????????} = $profile;

      return $order;
    }

  // Ensure the attached line items are associated with the order if they do not
  // have an order_id set yet.
  foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) {
    if ($line_item_wrapper->order_id->value() == 0) {
      $line_item_wrapper->order_id = $order->order_id;
      $line_item_wrapper->save();
    }
  }


texts: How can i find out when the next cron will run?

texts:
How can i find out programmatically when the next cron will run in order to present it to the author scheduling stuff?

i am using ultimate cron and an external cron process.


texts: I have a page where i post English articles by default. but sometimes I have a Persian article that should be posted inside this page. After posting, it shows left to right and is very bad looking. specially if there is bullet points included in the articles. I want to know if there is a module for this or a way to edit my theme files.


texts: GA Virtual pageview on Webform reload: is there an easier way?

texts:
I can't believe it was so difficult.

I have Webform and Google Analytics installed. I want to track submissions of my webform, but since it's set to reload current page on submission, I must make use of either Virtual Pageviews or Events. I went with the former.

At first I thought it'll be as easy as using hook_webform_submission_insert()1 and invoking GA code via drupal_add_js() from there, but somehow it didn't work: the hook itself was executed, but JS was never added to the page.

Now I reached the bottom of Google and haven't found any help on this specific case (everybody seems to be using separate "thank you" pages). Fast forward a couple hours, dozen approaches and hundreds of pages, I finally arrived at this working code:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  //add custom submit callback
  if ($form_id == 'webform_client_form_[node id here]') {
    $form['#submit'][] = 'mymodule_submit_ga';
  }

  //add GA tracking upon successful submission
  if (isset($_SESSION['mymodule_submission_successful']) &&
      $_SESSION['mymodule_submission_successful'] == TRUE) {
    //reset temporary variable
    unset($_SESSION['mymodule_submission_successful']);
    //build JS
    $script = '(function() {';
    $script .= '_gaq.push(["_trackPageview","[virtual page path here]"]);';
    $script .= '})();';
    //add JS somewhere in the end
    drupal_add_js($script, array("type"=>"inline","group"=>JS_THEME,"weight"=>20));
  }
}

function mymodule_submit_ga($form,&$form_state) {
  //set temporary variable for the code above
  $_SESSION['mymodule_submission_successful'] = TRUE;
}

I'm sharing this in case it helps anybody, but as I'm not a PHP expert, I can't help the feeling that I missed something really simple.

Is there an easier way of doing this?


texts: count nodes of two different content type in rules

texts: I need to use rule module and count nodes of a content type A, then count nodes of content type B and after that if count of nodes A is higher of count of nodes B do an action, otherwise do another action. What i need to do for achieve that?


texts: clear boost cached pages as the content is changed

texts:
I am using boost with Maximum Cache Lifetime = 1 Day and Maximum Cache Lifetime = 0 Sec

If i do update some content / banners, i have to clear caches at

  /admin/config/development/performance

Is this the only way? There is no way that changed nodes/frontPage cache will be automatically cleared instantly ? and all users will see new content instead of asking them to use Ctrl + f5.

any clues
thanks


texts: Better Exposed Filters slider max/min - database request

texts:
I am trying to use this hook function in order to get the min/max values from the database. As I am no coder I am facing some trouble with this. Here's my approach:

At first I recognized that I don't have an own template.php in my subtheme folder. I copy pasted the original one in my subtheme folder and adjusted the name "bartik" everywhere into "new" (which is the name of my subtheme). Then I put the code in my template.php and changed "hook" into "new". Then I changed 'field_price_value' into 'field_size' (which is one of my fields). Just for checking I set the min and max values different from the BEF settings. I cleared all caches and refreshed my website but the min/max values didn't change. The original values from the BEF settings are still shown?

Does somebody see a mistake in this approach or what could cause this problem?

Thanks for any help in advance.

This is my code:

function new_better_exposed_filters_settings_alter(&$settings) {
  $settings['field_price']['slider_options']['bef_slider_min'] = 200;
  $settings['field_price']['slider_options']['bef_slider_max'] = 250000;
}


texts:
I tried "Inline Form Errors" module but it add errors message content after form element.
How to add inline form errors with bootstrap tooltip or popovers directly to inputs and selects? Does somebody do something like this?


texts:
I have installed drupal 7 using MAMP and following this tutorial to configure drupal with oAuth,

While adding consumer I tried call back URL with domain name like http://mastmobilemedia.com/oauth/request_token which gave http status 404 error in browser , when i tried with IP Address http://192.168.1.4/drupal/services/xmlrpc ( as i found in one of the sample code) i got page not found error in browser

so please can anyone help me in knowing what is the proper call back URL to be specified ? how to get client side URL ?


texts:
I'm trying to display a block on a left side bar with few links. I've created a block and it shows up with the links but NO CSS applied:

            Home

            Site Info

            Career

            About Us

When I check the elements in UI, it doesn't show the vertical-tabs class being applied.

I'm not looking for any custom form. I need to know how the CSS should be applied in this case.

Thanks.


texts: Menu system - accepts extra args on path

texts:
Awhile back, working in Drupal 6, I found an issue in which a valid path, say:

  example.com/real/page

would be served if the following did not exist:

  example.com/real/page/fake-arg

I thought it was occurring only with pages defined through Panels and Views, and managed to implement a rather complex check (run during hook_init()) for whether a panel should really be handling that path, and if not, call drupal_not_found().

However...

I just today realized that this same thing occurs with paths defined in Drupal core, e.g.

  user/7

gets served for

  user/7/blah

(This answer is what tipped me off: https://drupal.stackexchange.com/a/5080/834)

So evidently, this is happening by design (and through no fault of the CTools-related modules that instate pages through hook_menu()).

I haven't fully been able to dig into menu_get_item() to figure out how it's accepting the extra args, but my question is: does anyone know a way to get around this behavior and make these non-existent paths result in 404s?


texts: Best way to search and replace text from blocks

texts:
Is there a module or some other method to find and replace text from all existing blocks?  I've come accross Search and Replace Scanner Module but it looks like it only does search and replace on nodes.

Much Thanks.


texts: CKEditor Link a content with rule as a hypelink with title and url to a custom field

texts:
I would like to add a hyperlink entry in a blog which points to a internal content URL with different content type which needs to be display for authenticated users.

1.) The hyperlink should show the title of the content

2.) The hyperlink URL should be mapped to a custom field

3.) The hyperlink should not be visible to a chosen user and should be customizable

Is this possible in drupal ckeditor? or should we write PHP for it using PHP filter?


texts:
I want to display some content, returned from an AJAX call in an overlay or popup.

Do you have any idea on how I can do it?


texts:
I want to print out a script from facebook on a specific node page in my html.tpl.php file. What is the best way of doing this? looking for nid? I need some kind of a if statement...

thanks


texts: Fill link text with target nodes title field

texts:
In a content type im using a link field to link to internal pages.
When such a content type is created i want that the (internal) URL is added to the link field and it pulls the links text automatically from the target nodes title field. I do not want the link text being entered as separate field.
E.g when "PageA" has a link field and the links points to "PageB" (with URL "http://www.sitename.org/node/731"), and PageB has a title "This is page B" the link on "PageA" should read "This is page B" and not "http://www.sitename.org/node/731".
I tried the different formatters for the link field, but none is pulling the target pages title. Also Tokens do not offer the option to pull the nodes title.

Has anyone done this already?


texts: Views Data Export Module hide button when unfiltered

texts: I'm using the Views Data Export module to export an Excel spreadsheet of search results from a View. The problem is that the button is still visible when the View is unfiltered, and the full export of several thousand records (on the fly) chokes the server. Is there a way -- through the Drupal admin interface, since I don't have server access -- to simply hide the "XLS" button when the full dataset is being displayed? Hiding the button when the search results are above a certain threshold count would be even better.


texts: How to override text field widget form in Drupal 8

texts:
In my project I am using maxlength module to display the message like
'Content limited to 100 characters, remaining: 20'. The module using the hook 'hook_field_widget_third_party_settings_form' and provide textboxes to add length size and count down message.

I want to alter this count down message for all the fields by using my own custom module. Please help on this ?


texts: Need to send "High" and "Critical" priority only in email subject line itself

texts:
I'm using Support Ticket System module and I need to send ticket "High" and "Critical" priority along with subject line of an email. Can i do the same through coding part as i have tried from mail settings tab of support ticket system, help if anyone have an idea.

Thanks.


texts: How can I track all Flagging/Unflagging history for statistics?

texts: Is there any way to track the flag/unflagging of a node/user without the Heartbeat module? Or a way to track all user/node interaction to use it after for statistics?


texts: What is the best way to show custom field information in node.tpl.php in Drupal 7

texts:
Hi I want to show in node.tpl.php this information about a custom filefield :
File name , File type , file weight and link to download


texts: Using Zurb Foundation without installing the required dependencies: npm, gulp, bower, etc

texts:
I just created a sub theme for zurb foundation 6 on drupal 8, and reading the docs it tells me to do a npm install and a npm bower

When doing a npm install I get the following errors:

I fixed that by figuring out how to update npm and node and that solved that issue. Now I have to install bower and do a bower install.

My question is: Do I have to install all these things in order to setup foundation to work? I prefer not to use SASS as I work in a team of devs and sometimes the backend dev goes in to edit the css files without knowing that they have to first turn on a sass compiler before doing that.


texts: RuntimeException when patch submission. Module Webform Rest

texts:
When i send a PATCH request to my site to /webform_rest/{webform_id}/submission/{sid}?_format=json with the body
{
    "data":{
        "sincronizado":1
    }
}

or
{
  "sincronizado":1
}

from postman, I receive a 500 error.
The site log displays the next error:

RuntimeException: Callable
"Drupal\webform_rest\Plugin\rest\resource\WebformSubmissionResource::patch"
requires a value for the "$webform_data" argument. en
Drupal\Component\Utility\ArgumentsResolver->handleUnresolvedArgument()
(line 142 of
/usr/home/example.com/web/core/lib/Drupal/Component/Utility/ArgumentsResolver.php).

Am I making a bad request? What is the $webform_data argument? My webform has a field "sincronizado", of type value.
I'm using Drupal 9.
REST UI 8.x-1.18.
RESTful Web Services 9.0.2
Webform 6.0.0-alpha12
Webform Rest 4.0.0-beta1

Same problem sending sid parameter with Webform rest version 8.x-2.0-beta3.
My request from postman, in curl code is

curl --location --request PATCH 'http://example.com/webform_rest/webform-id-example/submission/36?_format=json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic (admin user and password in base 64)' \
--data-raw '{
"sincronizado":"1"
}'


texts: How to add classes to every menu block placed within in a specific region?

texts: How do I add classes to menus but only when they appear within a certain region? Is there a way to do this in a theme?


texts: How to get block id on block add & edit form?

texts:
Blocks are plugin in Drupal-8, I need to add a form element in the block add form & all the block edit forms.
I am able to add the new form element in the form by form alter. But i need to get the block id on submit(custom submit handler). For block add forms block id has to be new block created & for block edit form, the existing block id.

How can i get the block id?


texts: How to make users with administrator role member of all organic groups?

texts:
Is there a way to make all administrator users a member of all the Organic Groups?

For the moment, if an administrator creates an organic group, the only one who will be member of the newly created group will be this particular Admin user.

Maybe I should just find a way to do it throught a Rule ?

UPDATE
I FOUND HOW:


texts: Custom field doesn't show up in 'field type' dropdown

texts:
I've been trying to create a custom field for my module.  I have used the field_example module as a guide but my field doesn't show up in the 'field type' dropdown on the 'manage fields' page.

Here is my code:

mantis.module

function mantis_field_info() {
    return array(
        'mantisform' => array(
            'label' => 'Mantis ' . t('Form'),
            'description' => 'Mantis Support Request Form',
            'default_widget' => 'mantis_mantisform_widget',
            'default_formatter' => 'mantisform_default'
         )
    );
}

function mantis_field_is_empty($item, $field) {
    if($field['type'] == 'mantisform') {
        if(empty($field['mantis_form_id'])) {
            return true;
        }
    }
    return false;
}

function mantis_field_widget_info() {

    return array(
    'mantis_mantisform_widget' => array(
        'label' => 'Mantis ' . t('Form'),
        'field_types' => array('mantisform'),
        'behaviors' => array(
            'multiple_values' => FIELD_BEHAVIOR_DEFAULT,
            'default_value' => FIELD_BEHAVIOR_NONE
            )
        )
    );
}

function mantis_field_widget_form($form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

    $base = $element;

    if($instance['widget']['type'] == 'mantis_mantisform_widget') {
        $widget = $instance['settings'];
        $settings = $widget['settings'];

        $element['mantis_form_id'] = array(
            '#type' => 'select',
            '#title' => t('Support Request Form'),
            '#default_value' => isset($items[$delta]['mantis_form_id']) ? $items[$delta]['mantis_form_id'] : NULL
        );
    }
    return $element;
}

function mantis_field_formatter_info() {
    return array(
        'mantisform_default' => array(
            'label' => t('Default'),
            'description' => t('Allows a ') . 'mantis' . t('support form to be selected'),
            'field types' => array('mantisform'),
        )
    );
}

function mantis_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

    $element = array();

    switch($display['type']) {
        case 'mantisform_default': {

        }
    }
    return $element;
}

mantis.install

function mantis_field_schema($field) {
    if($field['type'] == 'mantisform') {
        $schema['columns']['mantis_form_id'] = array(
                'type' => 'int',
                'not null' => false,
        );
        return $schema;
    }
}

I haven't completely fleshed out mantis_field_formatter_view but figured that I should still be able to see the new field as an option in the dropdown.

Can anyone see where I'm going wrong?


texts: How to print Blocks in commerce-product.html.twig

texts:
I am looking at building a Drupal 8 Commerce 2 product display through twig but I am having issues with how to print custom blocks in this template file. (And also testing these in normal page.html.twig as well)

Looking at the Custom Block Library (/admin/structure/block/block-content) I can see that the ID is '4', as the ID from the Edit URL is 4. (http://www.example.com/block/4)

I have installed the module Twig Tweak and tried all the combinations below in the commerce-product.html.twig, and each time I get a WSOD

  The website encountered an unexpected error. Please try again later.

{{ drupal_entity('block_content', 4) }}

{{ drupal_entity('block_content', '4') }}

{{ drupal_block('block_content:4') }}

{{ drupal_entity('block', 4) }}

{{ drupal_entity('block', '4') }}

I have also tried in my example.theme file:

function theme_preprocess_page(&$variables) {
  $block = \Drupal\block\Entity\Block::load('4');
  $block_content = \Drupal::entityTypeManager()
    ->getViewBuilder('block')
    ->view($block);
 $variables['productinfo'] = $block_content;
}

Then in *.html.twig with lots of cache flushing before and after:

{{ productinfo }}

I also seam to be not even able to use any of the examples from the Twig Tweak Cheat Sheet, as each one of these I add to my any *.html.twig I get the WSOD.

{{ drupal_view('who_s_new', 'block_1') }}

or

{{ drupal_region('sidebar_first') }}

Question:
How do I print custom blocks into a commerce-product.html.twig template?


texts:
There are a spammer(s) out there constantly creating accounts on my site. The accounts are 'blocked' by default so they do not pose a problem, nor does the spammer gain anything from them.

Still, I would like to delete them all but without having to click on the /admin/people page 150 times: canceling accounts 50 at a time.

Is there a way to cancel all 'blocked' accounts in one step?

Drush only appears to let me cancel one at a time...


texts: Theming and overriding taxonomy term/vocabulary page

texts:
I have a taxonomy vocabulary (Authors) which is used only for the Books content type. What I would like to achieve is to create a file (taxonomy-term--authors.tpl.php) in which I can customize the HTML markup.

Currently when I create the file I can only more static markup instead of modifying the output of the books which contain the specified term.
I also tried to use the mytheme_preprocess_page() and give a template suggestion but when I add content to the file it's not rendering how I would expect. It does not include header/footer styles and other stuff.

I also tried using Views module but the behavior is similar to first point 1.


texts: How to set automatically meta tag from node content?

texts:
I use the Nodewords module and in the Readme file it talks about ability to automatically create metatag from node content but I don't find how to do.

  Each content type should be configured to control whether certain meta tags
  should be automatically generated, e.g. the "description" tag can be
  automatically taken from the node teaser.

Do someone know? Do I need additional module?


texts: Why drupal_get_form will reset variables?

texts:
I would like to implement a simple searching form.

When the form is posted, the searching result will be shown before the form.

The page callback is as following.

$output have content at the first line, but no content at the second line.

Why drupal_get_form have this side effect?

Or do I have a bad idea about this implementation.

function _camp_search_page() {
    $output = '';
    if(isset($_POST['name'])){
        $sql = "SELECT * FROM {node} n JOIN {field_data_field_camp_order} o ON n.nid = o.entity_id WHERE n.type = 'camp_reg' AND n.title = :name";
        $result = db_query($sql, array(":name" => $_POST['name']))->fetchAll();
        if($result){
            $output .= "
";
            foreach($result as $order){
                $output .= "
field_camp_order_value/$order->nid'>Click
";
            }

            $output .= "
";
        }
    }
    dpm($output); // There is $output here
    $search_form = drupal_get_form('camp_search_form');
    dpm($output); // $output become empty here.
    $search_form['#prefix'] = $output;
    return $search_form;
}

update

Drupal will redirect the browser to a new page when the submitted form is processed. Although I don't where and how this is happening, the two lines of dpm seem to executed in different request.


texts: Change '/user(/*)' URLs to 'profile(/*)'

texts:
I want change all /user, /user/* urls by /profile, /profile/* urls.
From a custom module, I copied all user routes (found in /core/module/user/user.routing.yml) to my custom .routing.yml file. I replaced all "user*" paths by "profile*".

Now, I have the following.

mycustommodule.register:
  path: '/profile/register'
  defaults:
    _entity_form: 'user.register'
    _title: 'Create new account'
  requirements:
    _access_user_register: 'TRUE'

mycustommodule.pass:
  path: '/profile/password'
  defaults:
    _form: '\Drupal\user\Form\UserPasswordForm'
    _title: 'Reset your password'
  requirements:
    _access: 'TRUE'
  options:
    _maintenance_access: TRUE

mycustommodule.page:
  path: '/profile'
  defaults:
    _controller: '\Drupal\user\Controller\UserController::userPage'
    _title: 'My account'
  requirements:
    _user_is_logged_in: 'TRUE'

mycustommodule.login:
  path: '/profile/login'
  defaults:
    _form: '\Drupal\user\Form\UserLoginForm'
    _title: 'Log in'
  requirements:
    _user_is_logged_in: 'FALSE'
  options:
    _maintenance_access: TRUE

mycustommodule.login.http:
  path: '/profile/login'
  defaults:
    _controller: \Drupal\user\Controller\UserAuthenticationController::login
  methods: [POST]
  requirements:
    _user_is_logged_in: 'FALSE'
    _format: 'json'

mycustommodule.login_status.http:
  path: '/profile/login_status'
  defaults:
    _controller: \Drupal\user\Controller\UserAuthenticationController::loginStatus
  methods: [GET]
  requirements:
    _access: 'TRUE'
    _format: 'json'

mycustommodule.logout.http:
  path: '/profile/logout'
  defaults:
    _controller: \Drupal\user\Controller\UserAuthenticationController::logout
  methods: [POST]
  requirements:
    _user_is_logged_in: 'TRUE'
    _format: 'json'
    _csrf_token: 'TRUE'

mycustommodule.cancel_confirm:
  path: '/profile/{user}/cancel/confirm/{timestamp}/{hashed_pass}'
  defaults:
    _title: 'Confirm account cancellation'
    _controller: '\Drupal\user\Controller\UserController::confirmCancel'
    timestamp: 0
    hashed_pass: ''
  requirements:
    _entity_access: 'user.delete'
    user: \d+

mycustommodule.reset.login:
  path: '/profile/reset/{uid}/{timestamp}/{hash}/login'
  defaults:
    _controller: '\Drupal\user\Controller\UserController::resetPassLogin'
    _title: 'Reset password'
  requirements:
    _user_is_logged_in: 'FALSE'
  options:
    _maintenance_access: TRUE
    no_cache: TRUE

mycustommodule.reset:
  path: '/profile/reset/{uid}/{timestamp}/{hash}'
  defaults:
    _controller: '\Drupal\user\Controller\UserController::resetPass'
    _title: 'Reset password'
  requirements:
    _access: 'TRUE'
  options:
    _maintenance_access: TRUE
    no_cache: TRUE

mycustommodule.reset.form:
  path: '/profile/reset/{uid}'
  defaults:
    _controller: '\Drupal\user\Controller\UserController::getResetPassForm'
    _title: 'Reset password'
  requirements:
    _user_is_logged_in: 'FALSE'
  options:
    _maintenance_access: TRUE
    no_cache: TRUE

From my website, when I go to the http://mysite/profile, I'm redirected to the correct page (the user view), but the URL change automatically to http://mysite/user. I want keep the URL as http://mysite/profile. How can I do that? Is it possible?


texts:
I have the following problem and I am currently looking for the best approach to solve it:

I have a site with various entities. These entities all have their own permissions to view, edit, delete and so on.
Now I don't want to restrict the access to an entity per entity type but per entity element, with every user probably having access to different entity elements.

This means that I will need a very granular way to change permissions.

Thats why I would suggest to add a few basic roles to which you can assign your users.
On top of these roles you are able to overwrite the permissions per user per entity element. This would probably happen in a seperate tab in the profile of a user.

If you have any idea on how to do so or you have another approach on my problem I would welcome your response.

Thanks in advance.


texts: Commerce checkout, check if checkbox is checked

texts:
I added a field to my commerce checkout form:

mymodule_form_alter(..) {
 ...
 if($form_id ="commerce_checkout_form") {
 $form['thisfield'] = array(
  '#type' => 'fieldset',
  '#title' => t('Contact settings'),
  '#weight' => 5,
  '#collapsible' => TRUE,
  '#collapsed' => FALSE,
 );

 $form['thisfield']['checkbox']= array (
   '#type' => 'checkboxes',
   '#options' => drupal_map_assoc(array(t('SAT'), t('ACT'))),
   '#title' => t('What standardized tests did you take?'),
   '#required' => TRUE,
 ),
 ....
 }
}

Now the form may not go to the next step if the checkbox is not checked. If i press the sumbit button now, i go to the next step with the error displayed that the field is requierd. So  the error message appears, but the form still continues to the next step.

Now i don't really know how to keep the commerce form on the same step if the checkbox is not checked.


texts: How to redirect particular page after login via social networking site?

texts:
In my Drupal site I have placed a link in checkout page which takes to user/login. On successful login it redirects back to checkout page. For this I have used ?destination=checkout in the url. I have achieved using form alter

function module_form_commerce_checkout_form_checkout_alter(&$form, &$form_state, $form_id) {
  $form['checkout_message']['#markup'] = t('Click to login');
}

This redirects to login page and then redirects back to checkout page, till now it works fine. I have social site login in my login page (for eg., facebook, twitter, google).

How can I redirect the user to checkout if he/she login via social sites? FYI: Above is not working for social network login.

These are the modules used for performing a social login:

Facebook: Facebook OAuth.
Twitter, Google+: HybridAuth Social Login.


texts: How to "use Search by Page as its own entity"?

texts: Can someone clarify what sort of menu item is needed for my D6 site to be able to "use Search by Page as its own entity"?  I have SBP working -- in the sense that /search/search_by_page/keyword does a search and returns results, but I'm having trouble getting rid of the "Content" and "Users" tabs.  I've tried a couple of different entries in some_random_module_menu(), but haven't found the right one.  Any advice out there?  Thanks!


texts: How to customize drupal_mail() error messages

texts: How can I customize drupal_mail() error messages? I 've switched off the display of error messages, but this config does not seem to affect to the management of email messages, which insists on displaying the status of the delivery in the navigator screen.


texts:
I have a "user list" view, which displays an "unformatted list" of user accounts.

While the row display is controlled via views-view-unformatted.tpl.php and customizing it works, the row plugin "user" in views/modules/user/views_plugin_row_user_view.inc directly outputs the user profile into the row.

Now as I already have a customized user-profile.tpl.php I cannot customize it for both view row and user profile page...

How do I implement custom display of user profiles in the user list, then?


texts: Why the routing system has been changed in Drupal 8?

texts:
In Drupal 7, some part of hook_menu was used for routing and registering paths (That is what  I have read).

I read an article about Drupal 8 and it said that one of the biggest changes in Drupal 8 is its routing system being ported to something called as Symfony HTTP kernel.

Why is this being done?


texts: How to limit access for some special user to a single (Views) page?

texts:
I'm using Drupal 7.43 and I have to create a special user, with access to a single page (a Views page) and nothing else.

What would be the best approach for this situation?

Note: The view is already made (I show a custom content type made in a custom module). The website is private (the only thing an anonymous user can see is the login page).


texts: Ajax fired when Filefield "Add Another Item" button is clicked conflicts with my jquery

texts: I have a node type with a multivalue filefield. I am using some jquery called by my custom module to modify some of the UI in the form, but when I click the "Add Another Item" button it completely breaks and wipes out my custom external jquery. How can I fix this?


texts:
I  have the following tree structure, I want to get all child terms. I implemented taxonomy_get_children('tid') drupal api function.

1.Gloves
 1.1 Seamless
   1.1.1 Kevlar
    1.1.1.1 Shell
    1.1.1.2 Dots
    1.1.1.3 Coated
 1.2 mechanics
 1.3 cut and sewn
2.Apparels
 2.1 Coveralls
 2.2 Aprons
 2.3 Trousers

When I clicked on Apparels I successsfully get all child terms using but when I clicked on Gloves, it provides me only top level child terms ('seamless', 'mechanics','cut and sewn'), not the deep levels.


texts: Having trouble understanding private files in Drupal 7

texts:
I'm trying to set up private files on Drupal 7 using Organic Groups. So far, I have

(1) one group type that although I appear to have set it up as such

(2) have private files set up in as below. (The webroot is /var/www/html.)

(3) Ensured the link on the OG's page is /system/files/test.example.doc,

(4) I inspected the database entry and this appears to be good.

MariaDB [s7data]> select * from file_managed \G

*************************** XXX. row ***************************
      fid: 357
      uid: 103
 filename: test.pwww_.doc
      uri: private://test.pwww_.doc
 filemime: application/msword
 filesize: 9
   status: 1
timestamp: 1460390385
     uuid: 3a9877fc-77b2-47bc-8d4f-e8bc349f4c74

I am still able, using this link path do download that doc in a new browser without being logged in. In effect, this file is not private and does not require an authenticated session to download.

Question: Did I miss something? How does one set up private files correctly on Drupal 7?


texts: Where can you change the #type of a checkbox?

texts:
I have content type with a taxonomy attached to it (since it is Drupal 8, it ends up being an Entity Reference field).  The form is configured to render out this field input as checkboxes.

I have run into a situation where I need to change some of the checkboxes into plain text when the form is rendered (node create, note edit etc).  I tried to push a #process function onto the field,

function MYMODULE_form_node_job_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['field_foo']['widget']['#process'][] = 'MYMODULE_foo';
}

function MYMODULE_foo(&$element, FormStateInterface $form_state, &$complete_form) {
  // do stuff
}

but when I inspect the $element with XDebug, the #options haven't been processed yet.

So, where in the form / render pipeline can this be changed?


texts: Trying to Conditionally Add JS File to page if in a paragraph block reference on that page

texts:
I am not sure how to accomplish this...

I want to have a custom block that I have created and referenced via paragraphs to implement code in that block and push it into the header of the page. The idea is that we want to have single pages that run specific JS files and this is the way for the content author to place these files on the pages that they want. If there is a better way to do it, I am open to suggestions.

Here is where I am now:

I have a custom block that I am referencing via paragraphs in pages that will house the JS files. I believe I need a preprocessor script for this, but I am having a lot of issues with figuring out what kind of preprocessor I need.

Here is what I have but I think it is totally wrong and definitely incomplete:

if ( isset($vars['content']['#block_content']) ) { // check for custom content
    if ($vars['content']['#block_content']->type[0]->getValue()['target_id'] == 'js_file_block') { // only run on js_file_block types

      $vars['foobar'] = $js_files_page; // export var to twig
    }
  }

I need to be able to make more than one file load if added to the block, and I need it to attach to the header of the page that the block is referenced from. Can anyone point me in the right direction?

I am sure I need to add a $routematch and other things but I am not sure.


texts: How to re-create a notifications 'inbox' similar to the one here at stackexchange?

texts:
I'm looking for a simple way to let users know when new content (comments mainly) has been submitted to nodes they published or commented on and groups they are members of.
Is it possible to groupe that new content within a view ?
The ideal scenario would be to have something that works like stackexchange's inbox in the upper left side of the nav bar with the badge showing the number of new notifications.

I'm using drupal 7 with basic content types and organic groups 7.x-2.9

Any suggestions are welcome.


texts: I have installed the module jsonlog on drupal 7, but there are no information on how can I push the logs to elasticsearch or kibana or logstash. How do I do that?