texts: Form posting before ajax can update content

texts:
My form is submitting faster than ajax can update my textarea. How can I delay the form from submitting so the ajax can update my textarea?

$form['submit']['#ajax'] = array(
'callback' => 'getCampaignString',
'event' => 'submit',
'wrapper' => 'Comments_replace',
'method' => 'replace',
);
$form['submitted']['Comments']['#prefix'] = '
';
$form['submitted']['Comments']['#suffix'] = '
';

 function getCampaignString(&$form, &$form_state){
    $campaingString = $form_state['values']['submitted']['campaignstring'];
    $comments = $form_state['values']['submitted']['Comments'];
    $comments = $comments."[".$campaingString."]";
    $form['submitted']['Comments'] = $comments;

    $form['submitted']['Comments'] = array(
        '#type' => 'textarea',
        '#title' => t('New Comments'),
        '#name' => 'submitted[Comments]',
        '#value' => $form['submitted']['Comments'],
    );

    return $form['submitted']['Comments'];

}

So basically I have this webform for getting leads. There is a textarea for comments on the form. What I need to do is append a string to the end of the comments text on POST. For example: Say they made a comment like "I want more information" and when they hit submit. I need to add a string to the end of the comments so in the post it will look like this: I want more information - campaignName. The only way I have found to add my campaingname to the post of the comments is to replace the textarea with the new information in it but I cannot seem to replace it fast enought when submitted.


texts:
When you call menu_get_object(), the first argument defaults to 'node' if no arguments are passed to the function. The code uses the $type variable to check if the current object is of that type, using $router_item['load_functions'][$position] == $type . '_load'.

Sometimes, I just want to get the current menu object, regardless of it's type. In other words, when I'm looking at user/123, I want the user object, and when I'm viewing node/456, I want the node object.

Why does menu_get_object force a single entity type?

What is the best way to retrieve the current menu object, regardless of it's type?


texts: Entity browser not showing image after selecting an entity (Drupal 8)

texts:
I'm using drupal 8 entity browser to select entities/images. I cannot figure out how I can show a thumbnail or rendered image after selecting an entity. Below is an image that only shows the label of the entity after selecting

I have already checked the View and Entity Browser but couldn't not find an option to display the image after selecting


texts:
So I've got a custom module that builds a page (/simple-ajax-form) and has a form on it with the ID "payment_form" and other fields with IDs like "number_1". My module name is "Drupalup Simple Custom Form" for reference.

The problem I can't figure out (as I'm new to hook_form_alter) is that on the form ID instead of it being "payment_form" the ID gets rendered as "payment-form" and then on the input fields instead of it being "number_1" the ID get rendered as "edit-number-1".

What code do I need to make the form render as "payment_form" and inputs without "edit" and to also have underscores? And where does this code go - in my custom module?


texts: This is a pretty basic problem I think but i can't seem to find the solution. I've install the adminimal menu and I would like to remove the second menu on the bottom of this image. I've disable toolbar.


texts: When I run drush sql-sanitize, is there a way to exclude user #1 (or specific other users, for that matter) so his email address and password are not changed?


texts: How to list and store the value of hidden exposed filter of several views for anonymous user?

texts: I need to list vocabulary terms as text links, and then store the choice for anonymous user. Then the exposed filter of several views should get stored value. What is the easiest way to achieve that?


texts:
I am trying to create my first module in drupal 6.
I just need to add some new fields to the already existing comment form(comment module).
Eg: City,Email and state fields.

I have created 2 files:
1. mmcomment.module
2. mmcomment.info

Used a function hook_form_alter() like this:

 function mmcomment_form_alter(&$form, $form_state, $form_id) { // form override
 if ($form_id == 'comment_form') {
    // unset the other field elements

    $form['subject'] = array(
      '#access' => FALSE
    );
    $form['comment_filter']['comment'] = array(
      '#access' => FALSE
    );
    // add field to all comments

    $form['Email'] = array(
      '#type' => 'textfield',
      '#title' => t('Email Address'),
      '#maxlength' => 255,
      '#size' => 30,
      '#required' => 1,
      '#weight' => 1,
      '#default_value' => $email
    );
     $form['displayName'] = array(
      '#type' => 'textfield',
      '#title' => t('Display Name'),
      '#maxlength' => 255,
      '#size' => 30,
      '#weight' => 2,
      '#default_value' => $displayName
    );

    $form['_author'] = array(
      '#access' => FALSE
    );
    $form['author'] = array(
      '#access' => FALSE
    );

I need to get the form values and insert into DB.
What Function can I use for the same.
I have tried:
hook_nodeapi(mmcomment_nodeapi).
But can't get the form values.
Any suggestions..
Thanks


texts: drupal zen theme using sass - sub folder dont get regenerated

texts: i have followed these instructions to install ruby and compass and sass, everything is ok and works. However, do i need to do a 'compass watch' at a lower level for the component and layout folders in my zen theme folders as well? for example, if i change .../sass/layouts/fixed.scss it doesnt automatically regenerate the equivalent ...css/layouts/fixed.css


texts: Drupal 6 - theme the standard nodequeue admin view

texts:
I have a site where a client needs a 'visual' way of re-ordering their content. Is there a way to basically add more cck content to the nodequeue admin interface? so that it is not just showing a list of titles but instead maybe some cck content that the user can drag around?

I am thinking that I need to hack the module, which is fine, but wanted to know if there was some sort of recommended approach to this.

Thanks!


texts: Rate module: rate icon disappears and no vote is recorded

texts: I am having a problem with the rate module. I have implemented it on node 'project' and it appears. When I click on 'thumbs up', the icon disappears. It looks like the AJAX is not working.


texts: Store custom messages displayed by \Drupal::messenger()->addMessage() in the database

texts:
In a custom module, I have the following code:

\Drupal::messenger()->addMessage(t("Email changed to %email.", ['%email' => $new_email]));

I issue more than a dozen different messages in this way.

I want a way to store these messages in the database with a way to list them and edit them, assign an ID or keyword to each message, and then do the equivalent of

\Drupal::messenger()->addMessage(message_id, parameters);

I'm sure I can accomplish this by creating a "message" content type with keyword and message fields, adding a message node for each message, and then writing a function in my custom module that loads a node by keyword, inserts any variables, and then calls \Drupal::messenger()->addMessage() to display it. I could also create a View to list all messages for editing purposes. But it seems like there should be a better way that doesn't involve adding messages to the content of the site.

Is there a module or a built-in Drupal facility that does this?

My reading hasn't uncovered anything that looks like it will do these things. I realize Interface translation will support some of what I'm looking for, but don't know that it can be used with \Drupal::messenger()->addMessage().


texts: How to use Rules to prevent the creation of nodes if certain conditions are true?

texts:
I need this in Rules:

  When a node is being created (before the node is saved), and certain conditions are true, the user can't create the node, and an error message appears instead.

I have a rule that is working, and the error message is displaying. But the node is still created.

Is there a way to prevent node creation in rules?

Note:
I'm using Drupal 7. I selected the Action "Show error message" directly on rules.


texts: How to exclude some keywords from a search with Search API?

texts:
I can't find how to do boolean search, and ignore some keywords from a search.

I would like to do a search like "house+garden" - parking, which return all the nodes containing house, and garder as keywords, but not parking.

How is it possible?


texts:
In my Drupal site I got this error in google chrome console:

GET http://domain.com/file?mq8c07 404 (Not Found)

But I can't find where this file is included, how can I find it?


texts: Add / Remove column in admin/content/node

texts: How can I add / remove columns in admin/content/node ?


texts: How to use standard Drupal 7 farbtastic component? jQuery error

texts:
So, this is my code:

  drupal_add_library('system', 'farbtastic');

I've added it to a page callback function (also tried putting in an implementation of hook_page_alter()). It doesn't seem to initialize properly, it fails on the first line of the system library farbtastic,

  Uncaught TypeError: Cannot read property 'farbtastic' of undefined

Has anyone had this issue before? Any ideas? I get the sense I'm doing something wrong because farbtastic is part of Drupal core now...


texts: How can I get a date popup on the exposed filters of a view on D8 ?  I do not see the option, is it on D8 yet?


texts: Override page.tpl.php for a custom theme hook

texts:
I have a module that's creating a custom menu callback for a page that will be designed to be a PDF download, so I want to remove the usual menus and blocks. I want to create a tpl file that is only for this page that will be used for creation of a PDF.

I created the callback here:

function engine_activities_menu(){
  $items = array();
  $items['activities-pdf/%/%'] = array(
    'title' => 'Activities Calendar PDF',
    'page callback' => 'activities_calendar_pdf',
    'page arguments' => array(1, 2),
    'access callback' => 'activities_calendar_true',
    'type' => MENU_CALLBACK
  );

  return $items;
}

In that function, activities_calendar_pdf I have return theme('pdf_page', array('date_array' => $date_array));, which I got from this function:

function engine_activities_theme(){
  return array(
    'pdf_page' =>  array(
      'template' => 'page--pdf',
      'render element' => 'page',
      'variables' => array('date_array' => array()),
      'path' => drupal_get_path('module', 'engine_activities')
    ),
  );
}

This is backed up by a preprocess function in that same module:

function engine_activities_preprocess_page(&$variables, $hook){
  if(arg(0) == "activities-pdf"){
    $variables['theme_hook_suggestions'][] = "page__pdf";
  }
}

(Possibly not the most stable condition check, I know)

Finally I have a page--pdf.tpl.php file which is being rendered appropriately, but it's in the content section of the standard page.tpl.php file. I want page--pdf.tpl.php to be rendered instead of page.tpl.php.  How do I go about doing this?


texts: How to move every node to its own subdomain with Drupal?

texts:
I have a content site that was affected by Google Panda, and recently it was suggested that it is advised by Google that moving content to subdomains might work.

Does anyone have a working solution to move aliased nodes to their subdomains so
mysite.com/subfolder/my-great-content
moved to
my-great-content.mysite.com ?

I found this but seems to be abandoned:
http://drupal.org/project/subdomain

Also this which is very advanced:
http://www.easymodrewrite.com/example-subdomains

Or is multisite the way to go? I notice drupalgardens.com has subdomains for user pages.

Also found another method that uses the PURL module for Open Atrium, described here: https://community.openatrium.com/documentation-en/node/708
I guess this could be combined somehow with a wildcard subdomain setup? I notice it even has a subordomain module
http://drupal.org/project/subordomain

Here is a general solution
https://stackoverflow.com/questions/1943356/creating-subdomains-programmatically


texts: how to exclude current node from a view inside a node commerce kickstart

texts:
I know variations of this have been asked left and right but I can't get this to work.

I have a Commerce Kickstart Product Display (shopping cart form, basically a node).

Inside this content type is a display field which uses ViewField to insert a View inside the form. This View is a list of related products (nodes in the same category). I pass the category of the current node as a token %1 to the View and it works great.

However, I'd like to further exclude the current node (ie. the product being displayed) from this Related Products view.

I tried adding a second Contextual Filter:

Indexed Content: Node ID
Provide Default Argument: Content ID From URL

and then checking the 'Exclude' box in the More section.

And this does nothing. The current node still displays in the Related Products View.

NOTES:
1. FWIW: This View is of Type: 'Product Display' (from Commerce) as opposed to 'Content' or 'Message')

There is no default argument for 'Node ID'. Only 'Indexed Content: Node ID'. Probably because of the type of View (I cloned an existing view in Commerce Kickstart as a template.)

Any ideas?


texts: webform + form builder: how to clone an existing form

texts:
I am using webform + form builder to manage some forms on my site.

I can't find a way to clone the form (with all its elements) to a new form?
I know that I can clone elements inside the same form, but I can't export them to another form (and I can't export the form itself).

There is a way to do it?

Thanks


texts: Contextual filter based on translated term

texts:
I'm looking two days for the right answer but can't find it anywhere.

Here is my issue:

I'm using Drupal 7.21 with Entity Translation to build a multilangual site (English and Dutch). English is the default language. I have a vocabulary 'Sections' with the terms (lets say) Section 1, Section 2, Section 3, Section 4 and Section 5. Each term is translated to Dutch with the Entity Translation module.

I have also a content type 'Case', with a term reference field 'Section'. When I add a Case 'Case example' with section 'Section 1' the generated URL-alias will be 'section-1/cases/case-example'.
When I translate 'Case example' to Dutch, the generated URL-alias will be 'section-1-du/cases/case-voorbeeld-1'.

The site contains five sections and each section contains its own cases.

I use Views (1 View, 1 Display) to display a case-overview per section. To achieve this, I've done these steps:

Add a contextual filter 'Content: Has taxonomy term ID'.
When the filter value is not available:

Provide default value
Type: Raw value from URL
Path component: 1
Check 'Use path alias'

When the filter value is available or a default is provided:

Check 'Specify validation criteria'
Validator: 'Taxonomy Term'
Check vocabulary 'Sections'
Filter value type: 'Term name converted to Term ID'
Check 'Transform dashes in URL to spaces in term name filter values'
Action to take if filter value does not validate: 'Hide view'

So here is my problem. If I look at the page 'section-1/cases' everything works fine. But when I look at the Dutch page 'section-1-du/cases', the view doesn't show anything.

My question: How is it possible to use a entity-translated term as contextual filter?

Any help will be appreciated!


texts: How to use 'session' to check path history of user

texts: I want to keep a track of the pages user visited, I got to know i can do this with the help of session and hook_node_view. Being a beginner, i couldn't find any particular help on using session API, can anyone help?


texts: how to get view_mode from within hook_field_formatter_view

texts:
I've created a custom field formatter which works correctly. My problem is that I want to differentiate its output depending on whether it's being used in a default or teaser view mode.

The hook_field_formatter_view doesn't seem to provide this.

One way I can solve this is by providing a setting on that formatter (hook_field_formatter_settings_form) with possible values default and teaser. I'd then have to go to the teaser view mode of all content types and configure this setting on all uses of that formatter. I'd then be able to get the setting using $display['settings']. This would work but it's a bad solution since it would be replicating data that is already there and it also requires administrative work.

Is there a cleaner solution to this?


texts: How to change new theme for a content type

texts:
Requirements: Create content type based theme.

I have a requirement to create content based theme, I mean if the content type is article then node view call theme-1 and if type is basic page then node view call theme-2


texts: How to alter node body content through Views pre render hook?

texts:
I have build the view to display node title and node body also I have applied combined fields filter which searches the keyword in title and body and returns the results.

While rendering the contents I have to render the title and body with the highlighted keywords that  are been searched.

Currently I am using hook_views_pre_render to alter the same.But unable to replace the body text with my generated results.

How can I alter the body contents?


texts: How to add a local image file to an image field programatically

texts:
I have serveral image files in the folder /sites/subsite.example.com/files/blog.dir/1/gallery1, and I need to add these files to a node programatically. I think this is the right code:

 use Drupal\node\Entity\Node;
 use Drupal\file\Entity\File;

  $node = Node::load(1);
  $uri = 'public://image.jpg'; <--- this is my problem

  // check first if the file exists for the uri
  $files = \Drupal::entityTypeManager()
    ->getStorage('file')
    ->loadByProperties(['uri' => $uri]);
  $file = reset($files);

  // if not create a file
  if (!$file) {
    $file = File::create([
      'uri' => $uri,
    ]);
    $file->save();
  }

  $node->field_image[] = [
    'target_id' => $file->id(),
    'alt' => 'Alt text',
    'title' => 'Title',
  ];

  $node->save();

What I don't know is how must be the $uri I need to put when my files are in a subdomain directory in a mulitsite drupal installation.


texts: How to link from a group of fields in a View?

texts:
I am using the Search API module in Drupal 8.6.3 and I have a page of search results displayed using Views. Each search result row consists of a number of fields.

I would like to link each whole Views row (i.e. group of fields) to the entity that the search result is referring to. How can that be done?

I have been able to link each individual field within a result back to the same found entity. However the user experience is poor because the mouseover (hover) behavior operates independently on each field in the result, implying in many cases that the link would lead to something other than the desired entity. For example in the image below my mouse was over "Category: Living Things" (hence the grey a:hover color). I have made it link to my "Fiji Barberi Clownfish" page but the user would probably expect it to lead to my "Living Things" page.

Ideally the whole Views row div including the white space would link to the found entity. If that's not possible then if all the text together could link to it, that would be better than the current behavior.

I have tried the Views fieldsets module, but it only appears to provide the ability to style a group of fields, not link from it.

I suspect Views > Format > Settings > Field Grouping might allow this, but I am unclear how it functions and have been unable to find documentation about it.


texts: onClick attribute striped out in rendered html

texts:
I have below code in my Form. But after rendering i could not see the onClick attribute in the link.

$form['step2_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
    '#prefix' => '
'.t('Back').'

',
    '#suffix' => '
',
    '#name' => 'step2',
    '#attributes' => array('class' => array('enabled-for-ajax')),
    '#ajax' => array(
                'callback' => '::myajaxmethod',
              )
);

But i got the below output, without onClick attribute and javascript: in the output.

Back

Is this restricted? If so, how to achieve this in drupal 8?


texts: Commerce Default Product change not working fully

texts:
function default_select_commerce_product_reference_default_delta_alter(&$delta, $products) {
    dsm($products);

  foreach ($products as $key => $product)  {
    if (!isset($currentlowest)) {
    $delta = $key;
    } elseif ((int)$product->commerce_price[und][0][amount] < $currentlowest) {
         $delta = $key;
      }
  }
}

This is not picking the item with the lowest price, it is working but not picking the lowest price, it seems to be ignoring 2 of the attributes of the products.


texts: Contextual filter with hierarchical taxonomy terms

texts:
Using contextual filters, I have created a view which shows a page of users at us/california, based on a taxonomy I have made of locations.

This taxonomy is hierarchical, though, so when the user selects San Francisco, they no longer appear on the page.

I would like them to appear on both us/california and us/california/sanfrancisco.

How can I achieve this?


texts: How can I programatically log another user out in D7?

texts:
On our site we have client accounts, each with a super administrator and sub users belonging to that account.

We want the super admin to be able to force sub users to log out. What's the best way to destroy a user's session in Drupal that works regardless of whether the session information is stored in Redis, Memcache or the database?

Before someone feels tempted to suggest user_logout(), that destroys the current user's session. I want the current user to be able to destroy a different user's session!


texts:
I've custom content-type with several fields, e.g. rozdzielczosc1, rozdzielczosc2 and rozdzielczosc3. There are references to the term.

I'm creating the search. Now, I've several filters

My question is about third group of filters. I created exposed filter for field_rozdzielczosc1 and filters for field_rozdzielczosc2 and field_rozdzielczosc3 inherit values from filter for field_rozdzielczosc_1. When user set the filter value for field_rozdzielczosc1, filters values for another filter (field_rozdzielczosc2 and field_rozdzielczosc3) is the same. It works.

My search

In my description I ignore the two first group of filters. They work.

When user set "Rodzielczosc" in the search I'd like to choose contents whose field_rozdzielczosc1 or field_rozdzielczosc2 or field_rozdzielczosc3 is equal choosen value.

When user set "Rodzielczosc" and fill in the "title", I'd like to choose what above but only if title of content includes given "title".

When user doesn't set anything I'd like to choose all contents.

As you've seen, I tried something, yet it doesn't work.


texts: setup Drupal with Docker: clone repositories via deploy token

texts:
I am quite new working with docker. I tried to set up drupal via docker and docker-compose.
So far i got a running instance and installed drupal via the installation script.

No i want to clone repositoires via the Dockerfile, which is a drupal module. So after cloning and rebuilding the module should appear in the admin/modzles page)

So i edited my Dockerfile so it looks like this (the last few lines).

FROM drupal:7-apache

RUN apt-get update && apt-get install -y \
        curl \
        git \
        mysql-client \
        vim \
        wget

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
        php composer-setup.php && \
        mv composer.phar /usr/local/bin/composer && \
        php -r "unlink('composer-setup.php');"

RUN wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.4.2/drush.phar && \
        chmod +x drush.phar && \
        mv drush.phar /usr/local/bin/drush

RUN rm -rf /var/www/html/*

COPY apache-drupal.conf /etc/apache2/sites-enabled/000-default.conf

WORKDIR /app/web/sites/all/modules
RUN git clone -b <branch> --single-branch \
      https://<deploytoken>:<pw>@<gitlab-address>/<path-to-git-rep>.git \

WORKDIR /app

This is my docker-compose.yml

version: '3'
services:
  db:
    image: mariadb:10.2
    environment:
      MYSQL_DATABASE: drupal
      MYSQL_ROOT_PASSWORD: <pswd>
    volumes:
      - db_data:/var/lib/mysql
    restart: always
  drupal:
    depends_on:
      - db
    build: .
    ports:
      - "80:80"
    volumes:
      - ./app:/app
    restart: always
volumes:
  db_data:

Then i used docker-compose build and docker-compose up. It looks like the repository gets cloned and the latest images is used (no errors) but the repository is not in the folder. What did i do wrong?


texts:
I have many, MANY redirects (thousands).  Most just redirect the system (node/12345) url to the friendly one - but we also have a lot of others.

I have Drupal set to never delete old redirects after they haven't been accessed for X amount of time, but the mere presence of the option to do so makes me think there's a legitimate reason I may want to.

Is there a lot of overhead?  Or is it simply to keep the list manageable?  Do people typically delete them, and if so, what's the time frame?  Six months?  A year?


texts: How to show the status of a referenced webform in view of nodes?

texts:
My use case is a list of events and I want to show a label on the views item, if the event is already booked out. Therefore I would render the status of the referenced event registration webform.

The registration webform ist connected to each event node via the Webform Node module (submodule of Webform). The view consists of nodes of the type event which contains an entity reference field to the resgistration webform.

I have installed the Webform Views Module. Now I want the view to render this entity reference field as the status of the webform, meaning open or closed.

The problem is, that the views UI for the field rendering only lets me select from

URL of the Webform
the whole webform
a link to the webform

The Link option provides a text input field for YAML code. Maybe I could use this? But I don't know how ...

Any ideas, how I can get the view to render the status of the referenced Webform?


texts:
In 1 node. I'm using multiple paragraph type & within that I have fields.

Paragraph 1 -> field_title, field_time
Paragraph 2 -> field_test

How to access Node's Paragraph 2 -> field_test value?


texts: How to programmatically create an image style?

texts: I need to create image style programmatically in Drupal 7. I found this issue: https://www.drupal.org/project/drupal/issues/2735969 and much more other issues, but all are for Drupal 8. I can't find anything to Drupal 7. Is that impossible in Drupal 7?


texts: Why can I not see a field which depends on two other fields related by the OR operator?

texts:
I'm using the Conditional Fields module and I have a field that I can set while editing my custom content type.

That field is dependent to two other fields which are related by the operator OR.

The edition works well, but the field is not visible when I view the node.

Can you help?


texts: Hide user pictures from guests and web crawlers

texts:
I'm using Drupal 7 with Blog and Comments and user pictures enabled. The theme is Bartik.

The user pictures are also used in the Flash game that is embedded in my website, so I can't just turn them off.

I'm looking for a way to hide user avatars from guests and web crawlers.

The background is that I've gotten a bill for EUR 1000,- from Getty Images, because one of the users has supposedly used their picture as avatar. I'm not looking for any lawyer or pseudo-lawyer advices here, just for the way to hide user pictures from web crawlers.

I've tried searching in the theme file for picture and bartik_preprocess, but haven't find any hints yet:

# grep -r bartik_preprocess .
./themes/bartik/template.php:function bartik_preprocess_html(&$variables) {
./themes/bartik/template.php:function bartik_preprocess_maintenance_page(&$variables) {
./themes/bartik/template.php:function bartik_preprocess_node(&$variables) {
./themes/bartik/template.php:function bartik_preprocess_block(&$variables) {

and print_r($variables); in the above functions does not contain a "picture".

Also I've tried setting $account->picture = NULL; in the hook_user_view($account, $view_mode, $langcode) hook, but then the picture is hidden for everyone including registered users and also this is for user profiles only, not for blog comments.


texts: How to create a node from an other node template?

texts:
I would like to have a form for the creation of a node (let's name it news) when you are on the page of an other type of node (let's name it movie). So on /node/31 (of type movie) I would like to have the node content and a form to create a news

I thought about using a Webform but after all it felt like trying to hack the Webform with a trick. Moreover since the form already exists (at path node/add/node_name), I might be able to reuse it but I don't know if it is really possible.

What should be the right way to do it ? With a webform ? By exposing the form for the specific node ? By creating a custom form ? Maybe an other solution I didn't think about ?


texts: Does disabling a module erase its settings?

texts: This is kind of a basic question that I can't find the answer to in the Googles. In the process of debugging, I know disabling modules is a good start but I'd like to be able to go back and turn them on without losing any pre-configured settings.


texts: How to add a assign a value to File Field Desciption through tokens

texts:
Have been struggling with this, I have a field collection that contains a selection list and will like to assign this value to a file field description in the same field collection, so the selected value becomes the file display name.

Many thanks, Peace!


texts: Is there any security risk to use getenv() inside settings.php to populate databases variable from a .env file?

texts:
I am using the Drupal composer project, which doesn't use getenv() by default.  I wanted to use the following code inside the settings.php file in a production site.

  $databases['default']['default'] = array (
   'database' => getenv('MYSQL_DATABASE'),
   'username' => getenv('MYSQL_USER'),
   'password' => getenv('MYSQL_PASSWORD'),
   'prefix' => '',
   'host' => getenv('MYSQL_HOSTNAME'),
   'port' => getenv('MYSQL_PORT'),
   'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
   'driver' => 'mysql',
);

I read somewhere we shouldn't use getenv() in production sites. What are the downsides of it? Is there any security issue?


texts: Instantiate DateTime with localized time

texts:
I'm trying to migrate some data from MySQL DateTime format. Here's one:

$old_date = "2019-05-06 08:00:00"
My content type has a custom field using DateTime.

Using the info from SO links below, I can do this:

$date_object = DateTime::createFromFormat("Y-m-d H:i:s", $old_date);

which gives me a lovely object in my current timezone.

date: 2019-05-06 09:00:00.0 US/Central (-05:00)

MySQL is looking for a string in the UTC format. When I attempt to format this new object, it dutifully returns

$date_object->format(DATETIME_DATETIME_STORAGE_FORMAT);
"2019-05-06T08:00:00"

But this is not helpful. Using the Drupal 8.7 admin interface, when I enter the date and time values, I see in MySQL table when I save the node, that I get:

2019-06-06T03:00:00

So, apparently Drupal Entity has a handler to automatically instantiate a localized DateTime value in MySQL that is UTC friendly. I ask because I haven't found what this method might be and I have not found it in DrupalDateTime or related classes. Happy to be shown what I've overlooked. Or how to discern how Entity handles all of these functions that I can use in my custom modules.

Or should I do the math for each of these strings and hope I get the correct timezone differential depending on the time of the year?

How to get formatted date string from a DateTimeItem object

Inserting the value from Datetime field form


texts: Im fairly new to aegir and I have some hard time finding out the proper way to set a legacy database in aegir context. As far as I can see settings.php inside a platform is automatically generated so if I edit this file and run verify all changes will be lost. Other option is to insert it into drushrc file but Im still not sure what the syntax should be there. I see that database is inside the options array. Anyone with similar experience and few advice how to tackle this properly?


texts: Related nodes based on a shared taxonomy?

texts:
Using views, how can I find related nodes (across different content types) based on a shared taxonomy?

Let's say I have two content types:

Cars
Motorcycles

Both share a taxonomy: Colors.

If I have a car node titled "Accord", tagged with the color "Red", and a motorcycle node titled "Sportster", also tagged with the color "Red"... using a views block configured to find similarly tagged nodes, how would I list the Sportster node on the Accord node page?

FYI: I'm working on a somewhat locked down Drupal installation. So if this can be accomplished purely with views, and not by relying on additional modules, that would be awesome!


texts:
I have set of coordinates in EPSG 4326 / WGS84(ie. longitude and latitude in degrees) and I would like to store it as spatial information in DB so that I can perform spatial computations and use spatial indexes.

Currently I have a FieldType item that has longitude and latitude decimals but I would like to extend it and add this type of information. Since FieldType items do provide schema I can define the type via mysql_type/pgsql_type but I am not sure how to tell Drupal to use expression when inserting the value into database since there is no data manipulation available in the FieldType object and I do not see anything as well in DataType(in case I would create a new one instead of using string).

Looking ad DB drivers, I do not see anything particular that would need me to create my own version so I think this should be handled by the FieldType somehow but am not sure how.


texts: Drupal Commerce add multiple products to cart at once with different attribute values

texts:
I'm developing a shop based on Drupal Commerce which sells customizable objects.
I'd like to be able to order t-shirts of a certain type in different colors an sizes (like 5 orange ones size XS, 10 blue ones size L...).

This would normally be done by going to the product page, selecting "orange" as the color, "XS" as the size, adding it to the cart, then going back to the product page...but this is too complicated.

So I'm wondering what is the cleanest approach to achieve this.

Here is an example of the result I would like to obtain (choose a color, then a size, then a quantity, do it as many times as you need, then only click add to cart) :
http://www.objetrama.fr/tee-shirt-personnalise-femme-melrose-150-gr-m.html

I think this could be done by finding a way to send multiple add to cart requests from the same page using ajax (tried this approach with not much success).
Another solution would be to create a custom add to cart function which accepts multiple products with different attribute values.


texts: Where are all the controller classes instantiated?

texts:
In Drupal 8, if I want to create a form, I have to define a class inside the module folder like this.

class MyForm extends FormBase{

   public function getFormId()
   {
     return 'my_form';
   }
   public function buildForm(array $form, FormStateInterface $form_state)
   {

   }
   /* AND ALL OTHER OVERRIDDEN METHODS  */
}

Then I need to register a path for it in module.routing.yml.

module_name.myform:
  path: '/admin/structure/myform'
  defaults:
    _form: '\Drupal\my_formr\Form\MyForm'
    _title: 'My form'
  requirements:
    _permission: 'administer banner configuration'

Where is the MyForm class instantiated? What calls all the methods we are overriding?

We just define the class and register a path for it; neither we create an object of that class, nor we invoke any of the methods.

So, how does Drupal 8 manage these classes?


texts: Managing custom aliases on translated content

texts:
We have a Drupal 8 site with translated content, and using the Pathauto module. The issue we are running into is that when we un-check the "Generate automatic URL alias" on, say, the Chinese node, because the content editors want to customize that URL, that applies to all the other languages of that node, and path aliases are no longer automatically generated.

Ideally, we would like to separately control how to generate path aliases for each language a node is using, whether automatic or custom. The Pathauto_i18n module looks like it might be helpful, but it's woefully unfinished for Drupal 8 and I don't think we have the resources to finish it on our own right now.

Is there something else I am missing?


texts: Where do I put a custom function for multiple themes

texts:
I have two 2 themes so two template.php. I have a function that I use in both themes. I don't want to write it twice.
Where do I put it ?


texts: Notify Module doesn't force production domain

texts:
I've just installed the Notify Module and it works awesome, except for one thing that I can't seem to change or configure.

My site is being hosted across multiple names and there is a specific one I would like the Notify Module to use. When I receive notifications via email, I get a link to the content which was added/modified. It uses the same domain name that the user used when adding/modifying content, and I'd rather it use my production domain.

If a user uses our test domain, this is what I get:

1. A Message of Security for the 2014 Holidays. Blog entry by John Doe
[Published]
    [ http://direct.example.com/Security-Message-Holidays-2014 ]

I would much rather it use:

` [ http://www.example.com/Security-Message-Holidays-2014 ]`

What happened was that the user used direct.example.com instead of our production domain www.example.com. I would like it to report the changes as being made to the production domain, not the one that the changes actually occurred through.

Unfortunately, I have been unable to find any way of changing this.

Is there any way that I can force the Notify module to use the production domain instead?


texts: hook_menu() with a query string parameter?

texts:
I have a module that loads at path module/1/view and then when user clicks a button they are redirected to another site and then redirected back to the same URL they left from with a querystring that looks like module/1/view?code=123

How do I implement a hook_menu to catch this slight difference in url/querystring param? I essentially want the hook_menu for module/1/view and module/1/view?code=123 to be different.


texts: How can I suppress the "connection to @remote closed" message?

texts:
I'm running Drush 10 and have set up site aliases for my local and the remote Drupal site. When I run the following command for my local alias:
drush @local dd

This returns:

var/www/html/abc

But when I run the same command for my remote alias:
drush @remote dd

This returns:

var/www/html/abc
Connection to "remote" closed

Why is the output different? Is there any chance to avoid the "connection closed" message?


texts: Views: two filters on one term reference (=wrong join)

texts:
Strange effect in my view:

I have a list of nodes. On of the fields is a term reference.

I want the list to only show nodes related to 3 specific terms. that's one filter.
I want the user to optionally select one of these 3 terms. that's another (exposed) filter.

It almost seems to work. But if the user selects that term from filter 2, in the sql, the first filter is rewritten to explicitly deny that term. zero results. In an almost duplicate display of that view, the same happens, but with one other term (of the same three).

So without selecting anything in filter 2, the sql is:

SELECT DISTINCT bla
FROM
{node} node
...
INNER JOIN {field_data_field_publication_cat} field_data_field_publication_cat ON node.nid = field_data_field_publication_cat.entity_id AND (field_data_field_publication_cat.entity_type = 'node' AND field_data_field_publication_cat.deleted = '0')
...
WHERE (( (node.status = '1') AND (node.type IN  ('publication')) AND (field_data_field_publication_cat.field_publication_cat_tid IN  ('48', '50', '49')) ))
ORDER BY ... LIMIT .. OFFSET ..

and as soon as I select one of the terms in filter two, it reads

SELECT DISTINCT bla
FROM
{node} node
...
INNER JOIN {field_data_field_publication_cat} field_data_field_publication_cat ON node.nid = field_data_field_publication_cat.entity_id AND (field_data_field_publication_cat.entity_type = 'node' AND field_data_field_publication_cat.deleted = '0')
LEFT JOIN {field_data_field_publication_cat} field_data_field_publication_cat2 ON node.nid = field_data_field_publication_cat2.entity_id AND field_data_field_publication_cat2.field_publication_cat_tid != '48'
...
WHERE (( (node.status = '1') AND (node.type IN  ('publication')) AND (field_data_field_publication_cat.field_publication_cat_tid = '48') AND (field_data_field_publication_cat2.field_publication_cat_tid IN  ('48', '50', '49')) ))
ORDER BY ... LIMIT .. OFFSET ..

The number 48 in the second query, second join seems fairly random. If I remove and reattach the filter it seems to change.

cat2 is only a left join, but in the where clause, the number 48 is required again. Thats why I get zero results.

What's going on ?


texts: How to put the widget to rate nodes in a view next to title?

texts:
I have a view with the list of nodes, how can I put the widget to rate the nodes next to title?

Note: I'm already using the Rate module. But it returns me only the results.


texts:
I used the following steps for a D8 site:
 git clone
 composer update (get the packages)
 make a database
 make files folder and settings.php writable
navigate to d8.localhost.install.php (host made and site enabled)

Somehow this did not work do I miss something?


texts:
What I'm trying to do is function working like this:

function my_function($id){
   while($id){
      if($id = not free){
          $id=$id+'1';
      } else {
          return $id;
      }
   }
}

I'm new to php and drupal generally and can't figure out how to handle this cycle.
For instance, 'if statement' should test if the id is already in database. If it is then +1 to id if not return this free id.

I'm using this to check whether the id is free or not:

$check_unique_station_id = 'SELECT field_station_id_value FROM {field_data_field_station_id} WHERE field_station_id_value = :input_id LIMIT 1';
if (db_query($check_unique_station_id, array(':input_id'=>$input_id))->fetchField()){

}

Any help would be appreciated.

//EDIT

I guess I didn't explain it well. I have custom module and few custom fields. One of them is 'station_id' which is field for storing number (type) of station. Let's say it is a name of the station expressed in number.
Here is an example of values I have in database in field_station_id:

22
45
89

Now what I want to do: when user input=22 then check if 22 already exists and if so check if exist 22+1. When input=45 then return 46 etc.
Now I see that I explained it really bad. Hope that now you know what I mean.

// EDIT 2
// MY SOLUTION

I came up with this piece of code. However I was just wondering if there is some query function to do it (propably faster). As mentioned by Felix downthere (pick as the right answer) it seems that the only query function founds the maximum number in db and return it. Which is not what I want.

Here is my code:

function free_value($occupied_value){

// loads all used values from db
$query_all_occupied_values = 'SELECT field_station_value FROM {field_data_field_station_value} WHERE field_station_value >= :occupied_value ORDER BY field_station_value';
$all_occupied_values = db_query($query_all_occupied_values, array(':occupied_value'=>$occupied_value))->fetchAll();

// count number of rows of used station_values
$number_of_values = count($all_occupied_values)-1;

// finds first closest value which is not occupied in db
for($i=0; $i<=$number_of_values; $i++) {
    if($occupied_value == $all_occupied_values[$i]->field_station_value) {
        $occupied_value = $occupied_value+1;
    } else {
        break;
    }
}

$free_value = $occupied_value;

return $free_value;

}


texts: Approach to removing extra space at beginning of RSS file?

texts:
I ran the RSS xml file through W3C's RSS validator. The results say:

line 2, column 0: XML parsing error: <unknown>:2:0: XML or text declaration not at start of entity

I'm not sure how to approach this one. I searched on drupal.org and found these:

RSS Problem
XML Parsing Error: XML or text declaration not at the start of entity .... solution.

Based on the 2nd link, I tried placing an echo in the current template.php being used and the output appeared after the space right before the XML tag. That means the extra line in the RSS XML was placed there before the theming was invoked, right? Where should I look?


texts: Link to nodes in WYSIWYG Editor and Domain Access

texts:
I  have a Drupal installation using Domain Access.
Is there a solution for inserting links on nodes using WYSIWYG-Editor considering if the node is published to the particular domain.
For Example:

Node A, published to domain Y and Z, has a link to node B, published only to domain Z.
Viewing node A on domain Z the link is rendered as a link. Viewing node A on domain Y the link is rendered as plain text (without

Thanks in advance


texts: I have 2 Drupal sites running on Drupal 7. How can I add the full HTML format, and attach CKEditor to it?


texts: In which file is the list of the installed modules saved?

texts:
I am trying to synchronize some config data, and I'm getting the following error:

X depends on modules (examples here) that will not be installed after import.

Now I'm fine with adding the setting that they'll be enabled after synchronization, but I cannot for the life of me find any documentation or where in the config files this lives.

Does anyone have any information?


texts: Drupal Content Access and if anomynous show login block

texts:
I have this website where every pages are viewed by anonymous users.

I want to create a new page (and add it to the menu) where only the authenticated users can have access to it.

I installed Content Access module but somehow it does not work...

What I want is this: If it is an authenticated user - show page.
If not, show login block, and then redirect to the page.

I installed Rules module as well but I don't know how can that help me at all...

Thank you in advance, hope you guys can help!


texts: How to trim a field that's been excluded from display?

texts:
In Views, in order to group certain fields inside a common div, i excluded them from display and inserted them in a global text field by using their 'replacement pattern references'.

Here's what the div looks like :

[title]

[name] - [created]

More details &raquo;

The thing is i wanted to trim the node title to 50 characters max.
Trimming works fine when displaying the field 'as is' but not when it's been used as a replacement pattern in a different field.

Any help on how to achieve this ?

Thanks


texts: How to add custom entities to group types?

texts: I'd like to add my custom content entity to my group types, just like the module's "group node" plugin does already with nodes bundles. Has anyone done this? There does not seem to be much progress other than the documentation request about Document making custom entity types available as content for group types.


texts:
I have my Drupal site hosted at a society that gave me a 400M database quota.  After 4 weeks of production, it has reached 100M.  I predict that after a year, it will reach the limit.

Is any way to reduce the database size, so I don't have problems with my quota?


texts: Add product - price and sku field missing

texts:
When I want to add a product, the field price and SKU are missing.

Running on Drupal 8.7.1 on MAMP on macOS and PHP 7.1.23

Any idea?


texts:
I am using contact_form_blocks-7.x-1.x-dev module. Using this module I have embedd contact us form in my website. For themeing I have created file named block--contact.tpl.php. Cleared cache, but it doesnt result anything.
How should I theme this contact us form?


texts: Drush installed but all commands could not be found

texts:
I have drush installed on a remote server and was able to successfully run commands this morning, however I tried executing Drush Self-Update and got a permission error probably because I don't have sudo rights etc and now any drush commands I try run return the error The drush command 'drush_command_here' could not be found.
when I run which drush it returns /usr/bin/drush so I know its installed + other users on the server can run drush commands without issue.
I tried adding the drush alias in my .bashrc file like this alias = '/usr/bin/drush' and also tried using the alias pointing to usr/share/drush but no luck.


texts: Is there a way to edit/write templates from the user interface?

texts:
One of the UI/UX issues with Drupal is that theme templates are not editable from within the interface. Even for devs who know what they are doing this is awkward time consuming distraction needing FTP and other software outside of Drupal to create/remaster themes or put in a little logic . While knowing that the ability to edit tpl.php templates from the UI can potentially create security issues, still it seems to me that showing the template code and ability to re-write templates within the interface is lacking in Drupal 7.

Css can be writen to files (from themes and modules ie administratiom theme and css editor) so why not templates?

Can it be done?


texts: Show create content menu item to ananymous users but call URL for login/register popup on click

texts:
I thought it would be simple to do, but after lots of searching I couldn't find exact solution for it.

So the issue is, I have 2-3 main menu items which I have to show to anonymous users but have to call a URL(for login/register popup) & prompt for login or register if they click on them.

Best solution I found for create content link "node/add/node-type" was something like --

function THEME_preprocess_page(&$vars, $hook) {
    global $user;
    # if url starts with "add" and current user is anonymous
    if (arg(1) === 'add' && $user->uid === 0) {
          # redirect to login page
          drupal_goto('user/login');
          exit;
    }
}

It didn't work & it says - "$base_path has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer."

This is a very important functionality thing & I don't know how people resolve it. Can I get any suggestion for it ?


texts:
Problem:
My contenttype has a geolocation field and I added more than 600 contents of that contenttype with geolocation lat-lon. Now I added a new geofield field in that same contenttype and I want to transfer all geolocation field (only points) values into this newly created geofield.

Tried solutions with no success:
1. ran following insert and update queries:

INSERT INTO `field_revision_field_geofield_field` (
    `entity_type`,
    `bundle`,
    `deleted`,
    `entity_id`,
    `revision_id`,
    `language`,
    `delta`,
    `field_geofield_field_lat`,
    `field_geofield_field_lon`,
    `field_geofield_field_left`,
    `field_geofield_field_top`,
    `field_geofield_field_right`,
    `field_geofield_field_bottom`,
    `field_geofield_field_geohash`
)
SELECT
    `entity_type`,
    `bundle`,
    `deleted`,
    `entity_id`,
    `revision_id`,
    `language`,
    `delta`,
    `field_geolocation_field_lat`,
    `field_geolocation_field_lng`,
    `field_geolocation_field_lng`,
    `field_geolocation_field_lat`,
    `field_geolocation_field_lng`,
    `field_geolocation_field_lat`,
    null
FROM `field_revision_field_geolocation_field`

UPDATE `field_revision_field_geofield_field`
SET `field_geofield_field_geo_type`="point"

But still geofield values are not appearing in my content display.

How to go about this issue?

Note: I inserted and updated field_data_field_geofield_field also as it is the one which is needed to reflect in the page. However the fields are not getting displayed. Work around I found is to edit the content (the geofield lat/lon are filled) and clicking save puts values into 'geom' and 'geohash' fields after which geofield values are displayed in my display and views.

However doing the above operation for each content is so laborious. Looking for bulk trigger save option (VBO is very close, still it does not trigger save of geofield for an unknown reason). I hope it is a separate issue.


texts: Get current taxonomy in template_preprocess_html()

texts: I have a custom field on my taxonomy that I would like to access in template_preprocess_html(). How do I get the current taxonomy id, in Drupal 8, on a taxonomy listing page?


texts: How to make billing cycles available as product attributes?

texts:
On our current billing system (from which we are trying to switch to Drupal Commerce) customers can select a product and then easily select between monthly, quarterly and yearly payment periods. In other words, billing cycles can be selected as product attributes.

And I can't figure out how to make billing cycles available as product attributes on a DC setup. According to the instructions on Commerce License Billing products are bound to billing cycle types. Does that mean I have to create three different products (for each monthly, quarterly and yearly billing cycles) for every single good or service product we offer on our website to customers? Doesn't make much sense for websites selling tens different types of services. I would appreciate if someone could point me to the right direction of configuring this.


texts: View presents fewer items per page after using Unset

texts:
I'm deleting items by means of an unset in hook_views_post_execute, as far as the view I have it configured by 10 items per page.

The problem is that it shows me sometimes 6 or 8, I have searched for options but to reduce the size as when inserting programmed nodes and not when they are missing

/**
 * Implements hooks_views_post_execute().
 */
function module_views_post_execute(ViewExecutable $view) {

    // Remove by region user origin the rows.
    if ($view->id() == 'taxonomy_term' && $view->current_display == 'page_1') {
        $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
        foreach ($view->result as $key => $row) {
            $node = Node::load($row->_entity->id());
            $region_user = $node->getOwner()->field_region->value;

            if ($language != $region_user) {
                unset ($view->result[$key]); // delete a row
            }
        }
    }
}

Code according to references to update the page:

/**
 * Implements hooks_views_pre_render().
 */
function module_views_pre_render(ViewExecutable $view) {

  if ($view->id() == 'taxonomy_term' && $view->current_display == 'page_1') {

    // Rebuild number of items per page.
    $view->pager->total_items = $view->total_rows;
    $view->pager->updatePageInfo();
  }
}

Reference pages consulted:
Change views pager programmatically

https://www.drupal.org/forum/support/module-development-and-code-questions/2017-10-10/update-views-result-and-pager-in-hook

https://www.drupal.org/project/views/issues/953072

Debug of $view->result after $view->pager->updatePageInfo();, can see that only 6 items and not 10


texts: pdf.js unable to locate libraries in Drupal 7

texts:
I followed the installation instructions that was located in both the module that you download from the modules section in Drupal as well as also downloaded the precompiled pdf.js and pdfworker.js files from the PDF.JS information page hosted by drupal.

However despite my efforts I am unable to get the modules page of Drupal to see the librarie for pdf.js

I have tried to alter the pdf.module by change the build/pdf.js lines of code to libraries/pdf.js/build/pdf.js as suggested in IRC chat but this didn't do the trick as well.

I was last looking at the simlink solution offered but noticed that there was a additional folder of external?  And not sure since that post was 2 years old and wondered if it was still a valid solution.  See reference -> https://drupal.stackexchange.com/questions/65768/pdf-js-installation-in-drupal-7

Running a windows environment with drupal 7

Not sure what else to do suggestions would be grand.


texts: How can I attach a node to a user profile with profile 2 (or some other way)? It says here that it is possible but it does not say how.


texts: How to limit entity reference field values in a node programmatically?

texts:
I know there's a way to limit the number of allowed references for an entity reference field in the field settings on field creation.
Now, to be more flexible, I want to set this to unlimited but then limit it on form submission with a custom module.
For example:
I have a node which includes an entity reference field for referencing another node. This field in general should allow unlimited values.
When the node is created or updated, the custom module should check, if there are max. 5 values referenced.
If there are more than 5 references, then the form should throw an error message and the form should not further processed.
Do I need here node_form_alter? Or how can I do that?
Thanks for any help .


texts: Form Redirect not working if 'destination' is in URL

texts:
In one of my forms, I'm trying to set a $form_state['redirect'] so the form will go to that destination after the user clicks one of the action buttons.

If I inspect $form_state['redirect'] both before and after I add the redirect, it is NULL before, and after contains the proper array. Here's how I'm setting up the redirect:

$form_state['redirect'] = array(
  'my/custom/path/' . $nid,
  array('query' => drupal_get_destination()),
);

I want to preserve the destination from the form that the user's viewing to the next path (that's why I'm calling drupal_get_destination(), which returns an array with 'destination' => 'some/path/here' inside.

It seems that, because there's already a destination in the path of the current form, the form redirects to that destination no matter what I put in my own form submit handler (see above code). I even tried using drupal_goto() and that didn't redirect the user either.


texts: What is the correct thing to do when reusing code from an old, abandoned project?

texts:
I've recently reused the source code from an old project - Anonymous Publishing that seems to have been abandoned around 2008 as a Drupal 5 development version.  There has never been an official release of Anonymous Publishing

I'm interested in the functionality Anonymous Publishing offers for my some of my own Drupal 7 sites, and have started work to convert it to Drupal 7.  The conversion project is currently in my sandbox.  However, the entire idea for this module and about 80 % of the code in the sandbox is from the original author (Ronny López).

I plan to develop this to the point when it is fully debugged and tested, and ready to be placed under drupal.org/projects as an "official" contributed module.

I wonder: What is the "right" thing to (do according to protocol on Drupal.org)? I believe my options are:

To request to become the official maintainer of the abandoned module, and to release my Drupal 7 port as a "continuation" of the abandoned module.
To release my project as a "new" module, with just an acknowledgement pointing back to the previous project.

My question is: What is generally considered the correct thing to do in a case like this?


texts: How to examine existing field values and modify other field in hook_form_alter?

texts:
I have a content type with a bunch of fields attached.  When displaying the node edit form I want to hide or display one field ( using $form['some_field']['#access'] = FALSE; ) if another field has a specific value.

I am using hook_form_alter() and would expect to find existing field values within $form_state['values'] but this key isn't present even though the form fields do contain existing previously saved field values.

What am I missing ?

Thanks


texts: Use a custom view for the front page without alias

texts:
I am a Drupal Newbie, I have not learn't all the features yet.

I want to do the following.

I have created custom twig template for the front page.

By default I have default Frontpage view. I deleted it.

I've created a new view. And I want to use it as my default view for the front page, but I can't figure out how to do this.

I know about setting front page url in global settings. But it requires alias. Or it uses default frontpage.

So basically my questions are

How to create a view without alias, not exactly without, but with / or nothing for the front page.
How to associate a pathless view with a front page ?

I would be grateful for any help.


texts: Creating a duplicate button for multiple entry field collection field

texts:
I'm building a form for inputting people's travel plans, and as part of that, I need to capture who will be in what country on what days (see diagram for relevant section of the form)

Next to the Add Another Item button to allow me to add another top-level itinerary, I would like to add a 'duplicate last itinerary button' that would add another item to the itinerary list, but copy the contents of the last itinerary item into it.  Ideally, the button would only copy the data in the section surrounded by a dotted line on the diagram (the itinerary leg content) and leave the traveler(s) field blank.

If there is a ready module to do this, that would be fantastic, but I'd be perfectly happy for a code-based solution or failing that, pointers to good info.

I've found How to pre-populate multiple "field collection" fields in node form which in spite of being closed seems like it may contain good information on populating the entries.  I think I need to know how to do basically 3 things and what hooks make sense to accomplish them:

add a button alongside the other multi-entry field buttons
read the contents of the last itinerary leg field collection field in the list of itineraries.
add a new item, and populate the itinerary leg field collection fields with the values from step 2.


texts: How to add first and last classes to local task items?

texts:
I'd like to add some classes to local task items, now there is only "active" class available which is pretty not flexible, I'd like to have "first" on first item and "last" on last item.

Tried theme_menu_local_tasks() and theme_menu_local_task(), neither of them work. And the post about "Add first and last classes to secondary local tasks" is probably for Drupal 6 so it's not working either.


texts: Is it possible to run code when the REMOVE button is clicked from a managed file?

texts:
I have a managed_file field on a custom form when I need to run some code if the REMOVE button is clicked after uploading a file.
PURPOSE:
When a user uploads a file to the managed_file field on the custom field a second managed file is created for processing purposes. If the user cancels by clicking the REMOVE file button I need to run code to also remove the secondary file that I created programmatically.


texts: Longer text doesn't translate in custom module

texts:
I have built a simple module that contains several modules.
Each shows a page with some descriptive text, a form and a result table. The result table is populated using the input and some calculations in javascript. The form works as expected.

The descriptive text is in English but my site is multilingual so I have added Dutch translations as well. The translations of single words or short sentences works fine, but longer text (e.g. three lines of text in a ) doesn't translate at all even if the English text and the translation is in a nl.po file, alongside of the shorter text.

It worked once, but now I don't seem to get it to work again.
I did notice that the correct number of whitespace is vital, but I cannot find what to do to get it to work.

For clarification purposes, this works:

msgid "Calculate"
msgstr "Berekenen"

msgid "Have fun!"
msgstr "Veel plezier!"

So on the Dutch version I see 'Berekenen' and 'Veel plezier!'

This doesn't work:

msgid ""
"The units of the sizes are equal to the number you enter, i.e. if you "
"enter the size in inches, the\n"
"        calculated sizes are also in "
"inches."
msgstr ""
"De eenheden zijn gelijk aan de eenheid die u invoert, m.a.w. als u centimeters invoert, zijn de\n"
"  berekende maten ook in centimeters."

This is displayed as English on the Dutch page.

What do I need to do to make this work again?

And is there a more finegrained way than simply exporting everything to work with multilingual content in custom modules?


texts: Returning alternate HTTP codes for unpublished content

texts:
Sometimes when nodes are unpublished, they are not meant to be taken live again.

Under those circumstances, I would like to return a 410 Gone status, instead of the default 403 Forbidden.

Implementing the 410 itself is a 1 line patch to Page manager, but I soon realize that there is no easy way to get the response to the client, as the router system itself checks the node status, and denies access.

How can I force the menu router to process my request for an unpublished node as usual?


texts:
I'm having issues with drupal on nginx. CSS is not displaying but the website is working and I have no clue why this is happening. I have installed nginx + php70-fpm on Mac OS El Capitan and I am using the configuration from drupal website with a slight mod:

The server name is also set in my /etc/hosts file as I am developing locally.

server {
    server_name drupal.mac;
    root /Users/fabriziomazzoni1/nginx/drupal/;
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Allow "Well-Known URIs" as per RFC 5785
    location ~* ^/.well-known/ {
        allow all;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
        return 403;
    }

    location / {
        # try_files $uri @rewrite; # For Drupal <= 6
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    # controllers other than update.php in a future release.
    location ~ '\.php$|^/update.php' {
       root /Users/fabriziomazzoni1/nginx/drupal/;
       fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
       #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
       include fastcgi.conf;
       $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       fastcgi_intercept_errors on;
       fastcgi_index index.php;
       fastcgi_pass 127.0.0.1:9000;
   }

    # Fighting with Styles? This little gem is amazing.
    # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
    location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
        try_files $uri @rewrite;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
}

Attached is a screenshot of the web browser to better understand what is happening:


texts: Trigger login / send login credentials from different subdomain

texts:
I have my Drupal 9 living on a subdomain like e. g. drupal.xyz.com. Then I have some marketing-related landingpage stuff at subdomain.xyz.com, which is not Drupal, but another system.
Now I would like to have a quick-login form on subdomain.xyz.com pointing to that Drupal I run on drupal.xyz.com.
Is it possible to somehow create a usual HTML form and point the action to drupal.xyz.com/user/login?
<form action="https://drupal.xyz.com/user/login" method="POST">

or is there some security logic which would prevent this (because it doesn't seem to work)? If yes, is there another "easy" approach for this?


texts: How to add some configuration option to vertical tab on content type edit page

texts:
Is it possible without touching Dupal core's code, add some configuration option to content type edit page? preferably to vertical tabs of bottom? such as a checkbox.

I mean this page: /admin/structure/types/manage/article


texts: Add custom link when using field_get_field

texts:
I have an image field on a taxonomy term. I am retrieving it via field_view_field and render it afterwards to display it. But I would like to give it a custom link. How to do this?
Do I need to make a new image formatter, with a link as configuration property? Or is there another solution to add the link before the render?

Thanks!


texts: When editing a node, some markup disappears

texts:
I'm using Drupal 7 and my page loads and looks fine when I add a new node and insert HTML markup. When I edit the page, some of the markup either disappears or it's replaced.
For example, if I add
, the node saves and it's displayed fine. When I edit the node,
 is replaced by
. If I add ,  is replaced by
.
Do you know why this would happen? How can I fix it?


texts: Request a new password mail without any content inside of the mail.

texts:
I got a problem. When I want to request a new password due to password forgotten, the system definitely send a mail to my email address. But, this mail is without any content inside.
I check the Configuration->People->Accounting Settings. I already setup all the content. But, I can't get any content.
Hope someone can help me. Thanks.


texts:
I have a field age in profile of my Drupal Instant which computes age from the D.O.B of the user. How do I make sure the age is updated along with cron job. Is there any way to trigger.

Right now I believe it will only update when the profile is saved.


texts: How to create on mouse over dropdown menu in drupal 7?

texts: Am working on drupal 7.x and using pixture reloaded sub theme 2.x. Under the Main Menu, am creating a menu with the menu name "Development". On mover over the menu "Development", in drop drop, list of sub-menus should list out. I installed a nice-menu module, but i don't know how to use. Please give a step by step tutorial to create a sub menu on mover over. Thanks


texts: What is the difference between "Language: Not specified" & "Language: Not applicable"?

texts:
What is the difference between Language: Not specified and Language: Not applicable in Drupal 8 In the context of multilinguality ?

There was no such distinction in Drupal 7 (and 6, IIRC) and it seems to me a bit redundant in comparison to the Drupal 7 method of Language: Natural vs Language: name. I also didn't find any documentation about this in a quick Google search about the difference and thought it would be nice if we would have an explanation here.


texts: Location to Call the function theme_uc_price($variables)

texts:
This function is located at /public_html/location/sites/all/modules/ubercart/uc_store

function theme_uc_price($variables) {
  $output = '' . uc_currency_format($variables['price']) . '';
  if (!empty($variables['suffixes'])) {
    $output .= '' . implode(' ', $variables['suffixes']) . '';
  }
  return $output;
}

So my problem is, where can I find the ubercart file that calls this function? So I could get the computation where they add up the products so I could tweak it.

Any help would be appreciated. :)


texts: Is it possible to remove the subject field on comment forms?  I find it to be kind of useless and redundant, since the subject of the comment is usually the title of the article being read, at least for me anyway.


texts: configuring drupal to use unicode characters

texts:
I'm working on a site for mathematics so every so often I have to deal with Unicode characters like "".  Right off the bat, this causes trouble for my Drupal 7.15.  For example: I create a Basic Page with Full HTML format, and paste that character in, and I get this error:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect string value:
'\xF0\x9D\x94\x85' for column 'body_value' at row 1: INSERT INTO {field_data_body}
(entity_type, entity_id, revision_id, bundle, delta, language, body_value,
body_summary, body_format) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6,
:db_insert_placeholder_7, :db_insert_placeholder_8); Array (
[:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 86234
[:db_insert_placeholder_2] => 29768 [:db_insert_placeholder_3] => page
[:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => en
[:db_insert_placeholder_6] =>  [:db_insert_placeholder_7] =>
[:db_insert_placeholder_8] => full_html ) in field_sql_storage_field_storage_write()
(line 448 of /home/joe/staging/drupal_planetary/modules/field/modules/field_sql_storage/field_sql_storage.module).

Now, I recognized that this was probably something to do with the way the database was set up, so I followed some guides around the internet, like this one: http://cameronyule.com/2008/07/configuring-mysql-to-use-utf-8/ and things are looking good, after a fresh install:

mysql> show variables like 'collation%';
+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)

mysql> show variables like 'character_set%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.01 sec)

I even adjusted the way the database is invoked inside settings.php:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'MYDB',
      'username' => 'MYUSER',
      'password' => 'MYPASS',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
      'pdo' => array(
                     PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
                     )
    ),
  ),
);

But, no luck, I still get the error when pasting my .  Are there further database tweaks I should try?

One further note: I've tried running utf8_encode(...) on the content that I expect to have unicode symbols in it, and this works as a temporary work around.  In other words, I can save content, the pages display without problem.  But then I wait a while (24 hours?) and come back and the pages are full of garbled unicode expressions!

Can you help me figure out how to either make this workaround unnecessary, or how to make it work and stay working?


texts: Custom Block Form Not redirecting to New Page

texts:
I have created a form to take a node ID and then you select either edit or delete and then I would like it to go to 'node/[nid]/edit' or 'node/[nid]/delete' depending on the selection of the radio button.
Here is my code:

function edit_node_block_info(){
    $blocks['edit_node'] = array(
        'info' => t('Custom Block to allow edit/delete/copy'),
        'status' => 1,
        'region' => 'Primary',
        'weight' => 0,
        'visibility' => BLOCK_VISIBILITY_LISTED,
    );

    return $blocks;
}
/*
 * Implements hook_block_view: sets how the block is displayed
 */
function edit_node_block_view($delta = ''){
    switch ($delta) {
        case 'edit_node' :
            $block['subject'] = t('Edit Nodes');
            $block['content'] = drupal_get_form('edit_node_form');
            break;
    }
    return $block;
}
/*
 * implements custom form/creating custom form for drupal_get_form named above.
 */

function edit_node_form($form, &$form_state) {
    $form['node-id'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter the Node ID'),
        '#max-length' => 8,
        '#required' => 1,
    );
    $form['edit-node'] = array(
        '#type' => 'radios',
        '#title' => t('Select Action'),
        '#options' => array(t('edit'), t('delete')),
        '#required' => 1,
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
    );
    return $form;
}

function edit_node_form_validate($form, &$form_state){
    $query = db_query('SELECT nid FROM {node}');
    foreach ($query as $result) {
        if (!($form_state['values']['node-id'] != $result)) {
            form_set_error('node-id', 'Node-id must match a current nid.');
        }
    }
}

function edit_node_submit($form, &$form_state){
    if (form_state['values']['edit-node'] == 'edit'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/edit';
    }
    if (form_state['values']['edit-node'] == 'delete'){
        $form_state['redirect'] = 'node/' . (form_state['values']['node-id']) . '/delete';
    }
}

In the $form array do I need some sort of redirect handler to make it work? Or a print_r or render?

I also tried $link = (form_state['values']['node-id']);


texts: Include a PHP file located in the home directory in a module

texts: How can I include a PHP file located in my Drupal's home directory from a module?


texts:
Does anyone know if there's an inherent problem with an extremely large permissions table? I'm dealing with a Drupal install with about 50 roles (permissions were set up using taxonomy terms), and there look to be about 800 permissions. So, quick estimates suggests approximately 40000 checkboxes on the permission table. Now, out of all of these, probably only about .1% are actually checked; I know that the role_permissions table only stores the enabled permissions. I don't know how Drupal is checking the permissions though as it goes; obviously, if it were making DB calls for each checkbox to check its status, that would be horrible.

Obviously, this can't be a good thing, but can someone tell me if it's necessarily a bad thing? The connection seems to be timing out before table gets loaded (or at least I think it's timing out; this is my first time using IIS with Drupal, and it's error message is vague, to say the least.) Does anyone have any suggestions beyond "remove unnecessary roles"? (Not that it's a bad suggestion, and I'll probably end up having to recommend it anyway, I'm just looking for additional options.)


texts: Views table doesn't set fields next to each other

texts:
I got a content type with 7 fields. Each field can contain unlimited inputs. Like:

Field Type/DN got fields 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
Field L got fields 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11

When I make this in a view table I get this:

Type/DN       L
1             1
1             2
1             3
1             4
1             5
1             6
1             7
1             8
1             9
1             10
1             11
2             1
2             2
2             3
2             4
2             5
2             6
ETC.

What I want is

Type/DN       L
1             1
2             2
3             3

The fields are imported from a CSV file by feeds importer.

Here some images to show my settings:


texts:
I want show the number of  views count in node.tpl.php with Drupal 7, but I cant find  the Drupal 7 Equivalent of statistics_counter.

where can I find it?


texts: Don't let user register without role/profile2 profile?

texts:
I created a site for a client that lets users register an account of either one out of two roles, which then is linked to one of two profile2 types.

Therefore my client wanta no other being able to register without one of these roles/profiles so i did a 301 direct from $site/user/register to  in .htacces. It works, as I see it, but somehow users/bots seem to be able to get passed this and register accounts without a role anyway.

Any ideas how to secure this in a better way than currently?

Daniel


texts: Rankings and Dates in Views (data architecture)

texts:
I'm working on building a small name ranking database, but I'm having some issues coming up with how to architect the data. Here's the scenario:

You have a list of 100 names with rankings by year.

|  Name  | 2012 rank | 2011 rank | 2010 rank
--------------------------------------------
|  Carl  |    1      |     4     |    15
| Frank  |   40      |    18     |    34
|  Lou   |    8      |     6     |     4

et cetera and so forth. If each name was a node, how would that content type be set up so you can filter rankings by year?

Would you have a new field for each year that has the ranking in it? ie: Field name: 2012 Rank, value: 8.

Just curious how someone might approach this.


texts: Put exposed form as block back into original view

texts:
I've created a view which essentially is a tag-filter. I have exposed some checkboxes in a form to the user and set that form to be exposed as a block.

However, I can't really see any option to put that exposed form back in to the view itself (as setting it as block removes it). I have the View Field View module, but I am only able to select the "Page" display of the search view, thus recursion.


texts: How can I set up an a SQLite memory database to improve PHPUnit test speeds?

texts:
I'm trying to speed up a functional Drupal test.
Given a test...
...
  public function the_front_page_loads_for_anonymous_users() {
    $this->config('system.site')
      ->set('page.front', '/node')
      ->save(TRUE);

    $this->drupalGet('<front>');

    $assert = $this->assertSession();
    $assert->pageTextContains('Welcome to Drupal');
    $assert->pageTextContains('No front page content has been created yet.');
  }

This test runs really slow against my database ... 2+ mins.
If I use a test sqlite database, it drops to around 1.6 mins
<env name="SIMPLETEST_DB" value="sqlite://localhost/logs/test.sqlite"/>
If I use a in-memory database, <env name="SIMPLETEST_DB" value="sqlite://localhost/:memory:"/>, Drupal detects no database and runs install.php
How can I set up an sqlite memory database to improve test speeds?


texts: append values to drupal7 cck link field entry

texts:
I've got a question about the CCK link field.

I'm using the link field as a way to get a youtube video embedded onto a page and displayed through colorbox, but in order to make it work I have to include all the embed video information like size and iframe acceptance.

i.e. ?width=560&height=315&iframe=true

Ideally I'd love my users to just have to put the video link in and not worry about including the size specs.

is there any way i can append this kind of information to this field?

I'm using:
D 7.23
CCK link mod 7.x-1.1

Thanks!


texts: drupal 7, db_select(), strange behavior : malformed query

texts:
I have a table: mantenimiento_extras.

I want a query like this: select * from mantenimiento_extras where id in (7, 9).
(this case assumes passing array(7, 9), but it could be variable, even including the case for "in ()".

I execute this query:

db_select("mantenimiento_extras")->fields("mantenimiento_extras")->condition("id", $values, 'IN')->execute();//$values is guaranteed to be an array.

I get this query, and an error:

SELECT mantenimiento_extras.* FROM {mantenimiento_extras} mantenimiento_extras WHERE (id IN ()); Array( )

I modify the dynamic query:

db_select("mantenimiento_extras")->condition("id", $values, 'IN')->execute();

I get this query, and an error:

SELECT FROM {mantenimiento_extras} mantenimiento_extras WHERE (id IN ()) ; Array ( )

Now I bang my head against the nearest object in my desk.

Why is it generating malformed queries?


texts: How can I use Typekit fonts with Drupal 6? Preferably without an extra module

texts:
I need to use some fonts from Typekit on the site I'm working on. Without the help of an extra module would be the best solution.

I have two lines to go in the  of page.tpl.php that call scripts.(< script >< /script >)

Should I put them in /themes/mytheme/template.php ? If so how, can you give me an example of what the code should look like?

Can I just put the call for the scripts right in the page.tpl.php file? with drupal_add_js ?

Anything else I should know?

Helpful links would be cool too. I got a bunch from #drupal on IRC today but none pinpointed it enough for me.

Thanks

Drupal 6


texts: How do I make the exposed filter values available as tokens for text areas

texts:
How do I display (or render in twig) the search term, entered in the search field. When you enter a search term and click on the search button, you will go to the search results page (view).

In the header of that view I want to display something like:

  Your search of [mysearcherm] has x number of results.

I build the search field with a views exposed form and Search API.

Update:
In the textarea of the views header I want to insert the search term as replacement token, but it's not available?


texts: Using an include file from a different module

texts:
I've got a module that I've created just for the sole purpose of sharing .inc files between multiple modules. The modules .module file is empty, as it doesn't do anything. But in the modules .info file I have included:

files[] = includes\Permissions.inc
files[] = includes\Roles.inc
files[] = includes\PermissionsInterface.inc
files[] = includes\RolesInterface.inc

And then in a module that is using these files (a different module), I have included:

use Portal\Permissions;
use Portal\Roles;

$permissions = new Permissions\Permissions();
$roles = new Roles\Roles();

I don't have any include or require statements, because I thought that was covered by the files[] declaration in the shared modules .info file.

However, I'm getting a PHP error that it can't find the class Permissions(). Just wondering what I'm doing wrong?


texts:
I want to clone a node type and add a few fields in it. I think the simplest will be to duplicate it and start working on it.

It seems there is no official way to clone a content type in Drupal 7. Features may allow it but there is no written procedure as to how it could be done.

I've even tried Bundle Copy module.

What'll be best way to clone any content type in Drupal 7?


texts: How to remove a Required Field based on other field value

texts:
i have a form with two fields, FieldA (Select List) and FieldB (Select List, required field).

How to set the FieldB to optional when FieldA has certain value in order to pass the form validation?


texts:
What are the differences between 'Text' and 'Long text' in Drupal 7?

If it is simply database character length, is it better to be cautious and default to using Long text in situations where the domain of possible entered values is not precisely known?


texts: Tokens keep 'disappearing', drush rr fixes the website for a time, sometimes hours sometimes seconds

texts:
As title suggests my problem is missing tokens, at random intervals tokens will just cease to work on the site in question which makes any webform entries that are emailed out to a client appear empty. It also gets rid of all metatags from pages.

Metatag shows this while broken:

Then if I catch it in a good mood after running drush rr:

I am unable to see any errors in the database logs, no warnings/notices around the time of this happening either. Haven't got Entity Tokens enabled. The behaviour seems entirely random. I have read en earlier question with similar problems being caused by Node Export, I do not have this installed either.

Latest Drupal Core, latest Metatag, latest Webform versions. Infact everything is latest version as I ran a bunch of updates hoping that would fix the ongoing issue.

The URL Alias Patterns page is also empty, regardless of whether I have run drush rr and appeased the bug.

SimpleTest run on Token results in 0 fails 0 exceptions and a few debug messages that don't seem relevant.

Webform seems to be the culprit here, as it happens more often when I'm submitting webforms, though I'm not sure if it is. Version 4.1 of Webform.

Any help/ideas greatly appreciated


texts: I'm trying to make a module that searches LDAP for users

texts: I want to be able to search LDAP users by first name, last name, or email, and in the results show the user's picture, first/last names, role, and email.  I've looked into it a little and found the LDAP module for drupal, but all I see is syncing with users.  Is this something I can do using this module? Am I going to have to sync the LDAP db with a table in my MySQL db and then reference that table?


texts:
I am using the below code to get the value of email. It works fine if the field type is "Text". But the field type used is "Email"

<?php
  $node=node_load(14);
  print $node->field_contact_email[$node->language][0]['value'];
?>

Please help.


texts: altering them for node edit page not working

texts:
I got the following to work by adding it to the admin template.php file. But I am not having any luck changing the one edit form to use boostrap_subtheme vs the default admin theme. Any advice with that? To add a little more to this, I am using the following code to set the add node for data set to the default theme, how would you do this for a node edit page?  The url for the node edit page contains the node id.

function mymodule_menu_alter(&$items){
    $items['node/add/data-set']['theme callback'] = 'mm_get_default_theme';

}

function mm_get_default_theme(){
    return variable_get('theme_default', '0');
}

I am using the hook_theme() function to override the theme for a given node's edit form. This works when you create a new node but does not override the theme with the use clicks "edit". Any ideas? Path of the edit form is for instance node/39/edit.

$items['custom_node_form'] = array(
  'arguments' => array('form' => NULL),
  'render element' => 'form',
  'path' => drupal_get_path('theme', 'bootstrap_subtheme') . '/templates',
  'template' => 'custom-node-form',
);


texts: Prevent drupal from adding a favicon from default directory in custom theme

texts:
I want Drupal to look for a favicon in a specific directory dynamically. This is mainly because I'm using the domain access module and I'd like the favicon based off the subdomain that is being used. For example if the url is

example.url.com

I want drupal to look for the favicon in

sites/all/themes/mytheme/example/favicon.ico

If the subdomain is example2 I want it to look for the favicon here

sites/all/themes/mytheme/examples2/favicon.ico

I think I have a handle of how to grab the url and base the location on that but right after I have added the favicon, drupal adds it's own. For example I see this in the header

<link rel="shortcut icon" href="sites/all/themes/mytheme/examples2/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="http://example.url.com/misc/favicon.ico" type="image/vnd.microsoft.icon">

I've accomplished adding my own favicon but it doesn't matter since it is added before anything else. I'm currently using preprocess_html to do this

function mytheme_preprocess_html(&$variables) {
    $favicon = 'sites/all/themes/mytheme/example/favicon.ico';
    $type = 'image/x-icon';
    drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
}

(It does not yet have the logic to grab the url) I'm assuming that it is at the top based on the term preprocess. Is there a way to give it weight? Or is there another function I should be using?


texts: Drupal site crashes when clearing the cache after Entity API installation

texts:
I'm trying to install the module Entity API. But if I clear the cache after the installation, my Drupal site crashes (i.e. something is causing a signal segmentation fault). I can't figure out why, because I have used the Entity API module before without any problems.

I'm using Drupal 7.13. I have tried both available versions, but it doesn't work. I have manually installed the module.

Can anyone please help me to understand what's going on?


texts: How do I have a dropdown select list for an entity reference?

texts: For Drupal 8, the entity reference field displayed in form is a textfield with auto-complete feature for you to select the entity, is it possible to have it be dropdown select list instead? I have tried using views as the reference method to check the possible solution, but without luck, someone can help me with this?


texts: Is it a bad idea for a view to specify nodes by node id?

texts:
I'm inheriting a project which contains a view that specifies what to include by node id.  This initially strikes me as a terrible idea, but it could be that in Drupal it's not as brittle as it would be if done in other frameworks that I'm more familiar with.

Is this considered an acceptable practice within the Drupal community?  If so, why is this not as dangerous as it sounds to me?


texts:
I have a view which is displaying nodes in the teaser view mode.
I would like to to have all those teasers inserted into a details HTML element.
This is the code I am using.
function mymodule_preprocess_node(&$variables) {
  $variables['content'] = [
    '#type' => 'details',
    '#title' => $variables['label'][0]['#context']['value'],
    'content'=>$variables['content'],
  ];
}

I tried to use the following code without success.
function mymodule_preprocess_node(&$variables) {
  $variables['content'] = [
    '#type' => 'details',
    '#title' => $variables['label'][0]['#context']['value'],
    'content' => [
      '#theme' => 'node',
      '#node'=> $variables['node'],
      '#view_mode'=> 'teaser',
    ],
  ];
}

The idea was to reuse the teaser template. When doing this, the site is taking too much time to display the page. (In fact, it doesn't display it.)
The same happens when I use 'content' =>\Drupal::entityTypeManager()->getViewBuilder('node')->view($node,'teaser').
As only the first snippet works, I added a template suggestion for the details element in order to re-create the layout of the teaser template.
Is it the best approach?


texts: How to implement invitations limits per user when using the Invite Module?

texts:
So, basically, I'm trying to create a private invitation-only forum. I'm using the invite module.

Is possible to set invitation-restrictions? For example, each user can only invite a total of 3 users, or a user can only send one invite per month?

Also, do unclaimed sent invites expire?


texts:
I have made my own module, that has a form where the user can upload a file.
Once the file has been collected, Drupal should open an FTP connection to a server and upload the file into it.
I have found "Storage API" and "Media Move" modules that seems to have this kind of functionality, but I have no clue on how use those modules with my custom code.
How do I make an FTP connection from Drupal to an external server and upload the file?


texts: in ckeditor plugin, why isn't my getConfig returned array affecting editor?

texts:
I'm including the wordcount plugin to CKEditor in D8. I'm including some configuration (maxWordCount) through the configurable interface. The issue I'm having is that no matter what I return from getConfig there's no affect on the editor.

class WordCount extends CKEditorPluginBase implements CKEditorPluginContextualInterface {

  public function isEnabled(Editor $editor) {
    return TRUE;
  }

  public function isInternal() {
    return FALSE;
  }

  public function getFile() {
  return drupal_get_path('module', 'ckeditor_maxlength') . '/wordcount/plugin.js';
  }

  public function getConfig(Editor $editor) {
  // just return a hardcoded maxWordCount.
    return [
      'maxWordCount' => 10,
    ];
  }

  public function getButtons() {
  // No buttons needed.
  }
}

To be clear the counter works as expected, but I don't seem to be able to override the default configuration.

Inside the core ckeditor module the getConfig function has this notation:

* @return array
*   A keyed array, whose keys will end up as keys under CKEDITOR.config.

When I inspect CKEditor.config in the console I don't see the configurations, and infact, the wordcount plugin is buried in CKEditor.plugins.externals.


texts: In a taxonomy view, enabling aggregation causes HTML tags in description to be output

texts:
I created a view of taxonomy terms and turned on aggregation for the view.
My view shows fields, including the description.
However, when I turn on aggregation, HTML tags are output like this:
**Term name: Addition**

Learn about addition.

When I turn off aggregation, the HTML tags disappear.
Is this a bug in Views?


texts:
I like the Quiz module but its affiliated modules are not ported to D7.

Is there any alternative to the Quiz module?


texts: How to set specific Meta Tag values while creating Article Content.?

texts:
I am using Meta tags(Module: Metatag) on my Article content type page. I want to set specific  Meta Tag values depending on Article type I select for example by default check some check box for robots.

Does this possible in Drupal 7. If yes please give sample code for doing the same.


texts:
I am trying to print taxonomy terms using this code:

<?php foreach ((array)$taxonomy as $item) { ?>
<a href="<?php print base_path() . "taxonomy/term/" . $item->tid; ?> "class='tags'><?php print $item->name ?>,
<?php } ?>

It works fine if I put in contemplate, however it doesn't in the full node (node.tpl.php), the tags are empty in the full node. Can any one tell me what is the reason for this and how to fix this?