texts: Get users by custom field and field type

texts:
I'm using Drupal 7.
I'm trying to get all users with custom field field_id:

$users = user_load_multiple(array(), array('field_id' => '123456789'));
var_dump($users);

and I got the following error:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base.field_id' in 'where clause': SELECT base.uid AS uid, base.name AS name, base.pass AS pass, base.mail AS mail, base.theme AS theme, base.signature AS signature, base.signature_format AS signature_format, base.created AS created, base.access AS access, base.login AS login, base.status AS status, base.timezone AS timezone, base.language AS language, base.picture AS picture, base.init AS init, base.data AS data FROM {users} base WHERE (base.field_id = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 123456789 ) in DrupalDefaultEntityController->load() (line 191 of C:\wamp\www\my_proj\includes\entity.inc).

My questions:
1. How can get users by custom field ?
2. How to query the field type ? (is it text, int, float, etc..).


texts: How to sort autocomplete results by post date?

texts:
I have a content type named "News" which contains a node reference field named "Related News" in autocomplete mode.
Does anyone knows how to sort the results when i write something? I need to get the most recent nodes.

Thank you!


texts: Is there a module or functionality to export/import roles and permissions?

texts: I have been searching for a module or functionality to export/import roles and permission from one installation to another, but could not find it. Is there such a functionality or module for Drupal 7?


texts: Is there a Drupal API function for retrieving text filter settings?

texts:
I've created a custom text filter, building on the filter_example.module.  The filter lets the admin enter a setting for the filter (just like the "foo" filter in the example lets the admin set the string to substitute for "foo" everywhere in the text).

However, I want to use one of the filter setting in a hook somewhere else in my code base - something like:

/**
 * Implements hook_something().
 */
function mymodule_something(&$vars) {
  $vars['foo'] = _filter_variable_get('myfiltermodule', 'foo');
}

AFAIK, the function _filter_variable_get() does not exist. I am able to create it myself.  The following works as one would expect.

function _filter_variable_get($module, $filtername) {
  $setting = db_query('SELECT settings FROM {filter}
    WHERE module = :module', array(':module' => $module))->fetchField();
  $settings = unserialize($setting);
  if (isset($settings[$filtername])) {
    return $settings[$filtername];
  }
  return NULL;
}

However, getting text filter sttings seems such a common thing to want.  Am I supposed to roll my own, or is there a Drupal API call for this?


texts: Migrating password with custom hash algorithm

texts:
I am trying to migrate data from a custom database which uses a different method to HASH the password.

password = md5(email + password + salt)

During the process of migration I face two issues.

I )    To differentiate the new register Drupal passwords from Old site passwords. I tried adding "OLD$" code to the old password using

  public function prepareRow(Row $row) {

    if ($value = $row->getSourceProperty('password')) {
      $row->setSourceProperty('password', 'OLD$' . $value);
    }

    return parent::prepareRow($row);
  }

But this doesn't seem to work.

II ) To check the passwords with old hash, I read in a blog post that new service needs to be created by extending PhpassHashedPassword

public function check ($password, $hash) {

    if (substr($hash, 0, 2) == 'U$') {

      $stored_hash = substr($hash, 1);
      //
      // Here you use the same algorithm the old site has to hash passwords
      // and store it on $password.

      if (substr($stored_hash, 0, 3) == '$P$') {
        // A phpass password generated using md5. This is a password migrated with
        // md5_passwords = TRUE
        $computed_hash = $this->crypt('md5', $password, $stored_hash);
        return $computed_hash && Crypt::hashEquals($stored_hash, $computed_hash);
      }
    }

In my algorithm,  password = md5(email + password + salt) the salt and email ID are needed. How can I get the values in check function


texts: How to obtain raw field value from db table in a view?

texts:
In Views 2 I am rewriting a field to generate a link that has arguments appended.

One of those fields is referenced as [field_name_value] but outputs 'public' (and translated) value of the field.  In the database the value is stored as 0 or 1 but it outputs No or Yes respectively.  The No/Yes must be coming from the content type template which provides a pair of radio buttons, where 'No' is 0 and 'Yes' is 1.

Is there any way to obtain the raw database (0 or 1) value? Thanks.


texts:
I need a draggable view that includes draggable sections, where both sections and rows are draggable (see image for reference). The sections are not entities on their own. Ideally, the sections would map to a field attached to the entities being output in the view so that they would be available in views, theming, etc. See attached image for reference.

Is there anything in the drupal world that does this today? Looking for ideas or examples on how best to approach this requirement.

Edit Jan 7, 2013 - this is what I have so far, using entity reference, field collection , and field collection table modules, per user user5950's answer below. It's not exactly what I want, and it becomes slow as you add a lot of items (a lot slower to edit a node with 50+ items), but it is functional.


texts: Prevent User from changing html in CKEditor

texts:
I wonder, if there is a way to prevent users from harming any html within my default html in a CKeditor textfield.

Yes I know this is not the Drupal way. Normally I would create a paragraph with its own fields. This is also not really a Drupal specific question as CKeditor is an independent project.

It's a totally different approach to allow users to just change text within predefined areas (tags) without giving them a way to remove or change any html as it just acts as some kind of frame.

I have not find this feature on the CKeditor site. I wonder if anybody thought about this away of content editoring.


texts: How to get width and height of user pictures?

texts:
It seems that Drupal doesn't store the width and height of uploaded user profile pictures (standard profile, not profile2).

I would like to be able to link the profile thumbnail to a larger version if the uploaded image is larger than 480 pixels.

Is that possible without jumping through too many hoops?

I can require new users to upload pictures with a minimum size but I have imported lots of profile pictures and many are smaller than 480 pixels wide or high.


texts: How can I get rid of the paddings and margins that come with the webform?

texts: What I did was use position: absolute to have them the way I want, but that is probably not a good idea. I tried to put padding and margin 0 everywhere, but Drupal seems to override my CSS or something.


texts:
I am using fancybox JS library for creating a slideshow from a custom bloc with a multivalue image field.

it works but the images on the slideshow are small because a style have been applied to the images.

I then get the original size image using a substring JS function but it is not entirely satisfying

(function ($, Drupal) {

  $('.bloc-image-gallery img').each(function (){
    var currentImage = $(this);
    var path=currentImage.attr("src");
    var StyleCutPath = path.substring(
      path.lastIndexOf("/") -7,
      path.lastIndexOf("?")
    );
    currentImage.wrap(''); });

  Drupal.behaviors.fancyBoxInit = {
    attach: function (context, settings) {
      $('[data-fancybox="gallery"]', context).once('fancyBoxInit').fancybox({
        buttons: [
          'close'
        ]
      });
    }
  }
})(jQuery, Drupal);

I wonder how i could get the href with an new style applied to it ( bigger image but not original size )

The src takes this form

  /sites/my_site/files/styles/directory_user_photo/public/2018-09/seminary.png?itok=5597asHF

i made it to

  /sites/my_site/files/2018-09/seminary.png

but i would rather have smthg as

  /sites/my_site/files/styles/my_new_style_adapted_to_full_screen_visio/public/2018-09/seminary.png?itok=5597asHF


texts: I'm trying to stop the editing of Group Titles (Content Types that are set as Groups) by users. With Drupal (v7.21) I've added Organic Groups (7.x-2.1) and set it so that the Group manager does not have full permissions. Instead I've created a Role for them called 'owner' and give them the ability to edit the group but not administer the group. I want them to be able to change the Group Body but not the Title. I have the Organic groups field access module installed and that lets me stop them editing fields like the Body but it doesn't allow me to stop them editing the Title. Does anyone know if there is a way to do this?


texts: "Drupal root not found. Pass --root or a @siteAlias in order to see Drupal-specific commands"

texts:
I have multiple sites inside the same htdocs directory. In one, I removed all the folders except vendor under Web. Now drush will not work (it worked before I moved the folders). But now, it cannot find the database, which is correctly defined in web/sites/default/settings.php
/srv/www/htdocs/jar/drupal # ./drush status
 PHP binary    : /usr/bin/php
 PHP config    : /srv/www/php.ini
 PHP OS        : Linux
 Drush script  : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush
 Drush version : 10.3.6
 Drush temp    : /tmp
 Drush configs : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 Drupal root   : /srv/www/htdocs/jar/drupal

I am running Drupal 9.0.8 and drush 10.3.6 (in /srv/www/htdocs/jar/drupal). I have removed drush using composer (2.0.3) and reinstalled it (recreating vendor in the process).
/srv/www/htdocs/jar/drupal # ./drush -vvv cr
 [preflight] Config paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /srv/www/htdocs/jar/drupal/drush/sites,/srv/www/htdocs/jar/drush/sites
 [preflight] Commandfile search paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/src
 [debug] Starting bootstrap to site [0.04 sec, 8.17 MB]

In BootstrapHook.php line 32:
  [Exception]
  Bootstrap failed. Run your command with -vvv for more information.
Exception trace:
  at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 Drush\Boot\BootstrapHook->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:296
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Command/Command.php:221
 Symfony\Component\Console\Command\Command->run() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:1018
 Symfony\Component\Console\Application->doRunCommand() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:271
 Symfony\Component\Console\Application->doRun() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:147
 Symfony\Component\Console\Application->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:49
 Drush\Runtime\Runtime->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.php:72
 require() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush:4

I looked at all the above suggestions, but am stuck. Drush works perfectly on my other 5 sites...


texts:
I'm running a Drupal commerce site and using Views to display up to 30  product node teasers per page.  The product display content type has a several fields (image, desc, manufacturer) and I am also using the flag module so that users can mark favorite products. As a result, the query ends up being fairly large with several joins.

Views statistics reveal that despite the complex query, the slow page loads are due to the rendering time it takes...

Query build time    21.13 ms
Query execute time  1.67 ms
View render time    4237.2 ms

How do I improve my Drupal template/rendering performance to get my pages to load faster?


texts: Drupal 7: Database select query FROM cache_bootstrap brings server down

texts:
The below query occasionally takes up to 24 sec and consumes the complete server resources.

SELECT cid, data, created, expire, serialized
FROM cache_bootstrap
WHERE cid IN ('variables');

I was informed today by my web hoster (I am on a shared server) that above select query brings down the whole node.

I have caching enable (with block caching disabled). JS- and CSS files are aggregated and cached pages are compressed. The site is running ok with no issues.

Any ideas how to track down the problem?


texts: How to grab $form_state value from text-format from drupal form

texts:
I created a form for my module. I have a formatted text box

$form['message'] = array(
'#type' => 'text_format',
'#title' => 'Body',
'#format' => 'basic_html',
'#default_value' => '
The quick brown fox jumped over the lazy dog.
',
);

When I try to save the form message comes back as an array and I don't know how to pull the value out of it.

public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    \Drupal::logger('td')
      ->notice('text: @message', array('@message' => $form_state->getValue('message'),));
  }


texts: How to use the Rules module to publish all nodes authored by a user when the user's role changes?

texts:
I'm using the SMSFramework module for my user validation, I have a rule which changes user role to "Confirmed" when the user approves his cellphone number.

That means then, every node that the user have must become Published. I have no idea how to implement this with just using rules!

Since my event is: After updating an exisiting account it means I have no access to the users's nodes! that I can get some actions fired on them!

I'd really appreciate your help.


texts: How do I enable anonymous users to vote?

texts:
I created a poll, and I am displaying it in a block on my site. The radio buttons are available, when I am logged in; when I log out, they aren't showing, and the vote results are instead displayed.

How do I enable the anonymous users to vote?


texts: Different twig template for user profiles of different role

texts:
I would like to theme user profile pages differently based on the role but I can't figure it out how to do so.

I will need when someone is viewing an administrator profile this twig file to be loaded:
user--administrator.html.twig

and when is viewing an editor profile this:
user--editor.html.twig

Any idea how can I achieve this?


texts: Hide tab for user page for specific roles

texts:
I am trying to hide tab for user page. This is good script but work only for node type. How can I make it work for user pages?
Thanks to all!

function bartik_preprocess_page(&$variables, $hook) {
    if (!empty($variables['node']) && $variables['node']->type == 'article' && in_array('editor', $variables['user']->  roles)) {
        $to_be_removed = array('node/%/edit', 'node/%/view');
        foreach ($variables['tabs'] as $group_key =>$tab_group) {
            if (is_array($tab_group)) {
                foreach ($tab_group as $key =>$tab) {
                    if (isset($tab['#link']['path']) && in_array($tab['#link']['path'], $to_be_removed)) {
                        unset($variables['tabs'][$group_key][$key]);
                    }
                }
            }
        }
    }
}

/--------
Update
--------/

Now I tryed this:

function my_theme_preprocess_page(&$variables, $hook) {
    /* Hide Tabs in users page */
    global $user;
    $arg = arg();
    if (($arg == 'user') && in_array('gestore', $variables['user']->roles)) {
        foreach ($variables['tabs'] as $group_key =>$tab_group) {
            if (is_array($tab_group)) {
                foreach ($tab_group as $key =>$tab) {
                    if (isset($tab['#link']['path'])) {
                        unset($variables['tabs'][$group_key][$key]);
                    }
                }
            }
        }
    }
}

But not work.

/----- Last Update -------/

This works. Thx @Yogesh.

global $user;
if ((arg(0) == 'user') && in_array('editor', $variables['user']->roles)) {
    foreach ($variables['tabs'] as $group_key =>$tab_group) {
        if (is_array($tab_group)) {
            foreach ($tab_group as $key =>$tab) {
                if (isset($tab['#link']['path'])) {
                    unset($variables['tabs'][$group_key][$key]);
                }
            }
        }
    }
}


texts:
I want to display node add form of a particular content type in a pop-up for anonymous users too. There are posts related to displaying a node content in pop-up but not about node add form.

I have a .tpl for a calendar display view. Now when anyone click on a particular div of the table I need to open a pop-up of node add form. So I need to add the <a> anchor tag in the tpl file.

How to achieve this? Is there a way to call the node add form as a pop-up in jquery?


texts: How to download a module hosted on GitHub via composer.json?

texts:
I've got the following composer.json file:

{
    "name": "my-project",
    "type": "project",
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        },
        {
            "type": "package",
            "package": {
                "name": "contrib/term-csv-tree-import",
                "version": "dev-master",
                "type":"drupal-module",
                "source": {
                    "url": "https://github.com/grahl/term_csv_tree_import.git",
                    "type": "git",
                    "reference": "master"
                }
            }
        }
    ],
}

However after composer update, the module is downloaded to the vendor folder as:

./vendor/contrib/term-csv-tree-import/term_csv_tree_import.info.yml
./vendor/contrib/term-csv-tree-import/term_csv_tree_import.module
./vendor/contrib/term-csv-tree-import/term_csv_tree_import.routing.yml

How can I correct above configuration to download the project as a Drupal module under docroot/modules/contrib folder? My Drupal root is under docroot folder.


texts: How to set a page level variable that views has access to

texts:
I'm trying to build a custom responsive theme using Zurb Foundation. I'm also using Views to render a grid of nodes, let's call them Events, that are each wrapped in Foundation classes to lay them out in a responsive grid.

The Problem:

The Foundation classes I need to use need to change based on the visible regions on the page.

For example, if the sidebar_first region is showing, each item in the events list needs to have the classes: columns large-4 medium-6 small-6.

If the sidebar is not rendered, each item needs the classes: columns large-3 medium-4 small-6.

I cannot find a way to evaluate which regions will be rendered at the time the View is being built. I'm currently using template_preprocess_views_view_unformatted() to add the Foundation classes to the Views template, however this hook is being fired well before template_preprocess_page() for example, where I might be able to evaluate the visible regions and set a variable with information about the sidebar.

See the below pseudo code for the ideal structure when the sidebar is rendered:

...

...

...

      ...

...

See the below pseudo code for the ideal structure when the sidebar is not rendered:

...

...

...

...

      ...

Ideally, without the sidebar rendered the events will be 4 across spanning all 12 columns. With the sidebar rendered they will be 3 across spanning only 9 columns, as the above classes in the pseudo code imply.


texts: Control content access whilst creating content

texts:
Is there  a way to control access during the content creation process?

With the Content Access module I can setup access controls for individual nodes of the same type, but only after I have created that content.

Could this process be integrated into the content creation process for the sake of intuitiveness.


texts: How do I get the Subscriber UID in Simplenews to Create Personalized Newsletters?

texts:
I am using the insert view module to create a personalized newsletter, now I need to pass the subscriber uid as a parameter to the view but I am not finding a way to do that. Any ideas ?

Thanks !


texts: Using Profile2 and Views - How to display the separate profile data on a single row

texts:
I have several different pieces of info in separate profile2 forms.  When I run the view to display the data I want, it looks like this:

Profile      UID PID IID  Name         Email                     Membership
Main Profile 124 15  1237 Bernardo Lee BernardoLLee@teleworm.us
Membership   124 76                                              Basic Member

The Membership and Main Profile show up on different rows for the same users. I was hoping that by not displaying Profile and PID, the data would show up on one line like:

UID IID  Name         Email                     Membership
124 1237 Bernardo Lee BernardoLLee@teleworm.us  Basic Member

But it still shows on two lines.

Also, I can't figure out where the "profile2" table is. The query in Views is

        SELECT profile.type AS profile_type, profile.uid AS profile_uid, profile.pid AS
     pid, 'profile2' AS field_data_field_ibo_number_profile2_entity_type, 'profile2' AS
     field_data_field_first_name_profile2_entity_type, 'profile2' AS
     field_data_field_last_name_profile2_entity_type, 'profile2' AS
     field_data_field_primary_email_profile2_entity_type, 'profile2' AS
     field_data_field_cell_phone_profile2_entity_type, 'profile2' AS
     field_data_field_globalnet_membership_plan__profile2_entity_, 'profile2' AS
    field_data_field_monthly_educational_book_profile2_entity_ty
        FROM
        {profile} profile
        INNER JOIN {users} users_profile ON profile.uid = users_profile.uid
        WHERE (( (profile.type IN  ('main', 'knowing_you_better', 'website_info',
 'credit_card_info', 'membership', 'line_of_sponsorship')) ))
        ORDER BY profile_uid ASC

but when I drop it into mysql, it's an invalid query

I don't understand the {profile} and {users} nor the 'profile2'
I was hoping to rewrite the query if I can't get views to directly display what I am looking for.


texts: Message "Restricted HTML" on node/add page

texts:
On node/add page for any content type(Article, Basic page. Custom)  message appearing "Restricted HTML" , not able to add content.

What shall a do to resolve this problem?


texts: How to restrict user role to see only their members profile?

texts:
I am using Group module and I created a new role: moderator

Here's my group:

Company A - Moderator role
Company A1 - Member role
Company A2 - Member role

How can I restrict the companies profile view of the members?

Company A with moderator role should be allowed to see only the members profile of its group. Company A1 with member role can only see its own profile.

And that goes for company B, B1, B2 etc of another group.

For example: Company A, can't see Company B1 user profile because it doesn't belong to its group.

How can I achieve this? I tried in the Moderator permissions but i can still see other companies profile if I just change it in the url.


texts: Get the submitted values from $form_state

texts: Is there a function (in Drupal 8) to build an array containing the submitted values in $form state? If I use $form_state->getValues(), I get more values than the ones I need.


texts:
I was looking to use a text editor with statuses. Statuses is neither a Node nor an Entity. I searched a lot and found a simple solution. I just has to replace '#type' => 'textarea', with '#type' => 'text_format', in statuses/includes/utitlity/statuses.form.inc file. It converted it to a text format enabled textarea, but there are few problems.

Ckeditor is not respecting the character limit set by the module, so I found maxlength module and added '#maxlength_js' => TRUE, but it does not make the default work. Instead it adds a separate character counter. The markitup library is respecting this, but I want to use ckeditor as I think it is the best editor. How to overcome it?
The form is now scrollable after enabling ckeditor. I want to disable scrolling. The resizeable was already set to FALSE in the module, but ckeditor is not respecting it. How to solve it?
How to hide paragraph counter and word counter? I have not enabled it from settings. I was there by default.

Here is the SnapShot of the statuses form.

Code was added like this: Only 2 modifications were made to the code, the rest is the original code of the module.

$form['fbss-status'] = array(
    '#type' => 'text_format',
    '#rows' => variable_get('statuses_box_rows', 2),
    '#maxlength_js' => TRUE,
    '#maxlength' => 140,
    // 508 compliance: add a label, but visually hide it
    '#title' => t('Status'),
    '#title_display' => 'invisible',
    '#default_value' => $default,
    '#attributes' => array('class' => array('statuses-text', 'statuses-text-main')),
    '#resizable' => FALSE,
    '#prefix' => '
',
    '#suffix' => '
',
    '#weight' => -40,
  );


texts: How to include jQuery UI on a page without PHP?

texts:
I want to include jQuery widgets on my Drupal 7 page. So, I started the way is described here:

drupal_add_library('system', 'ui.dialog');
drupal_add_js('jQuery(document).ready(function(){jQuery("#dialog").dialog({ modal: true });});', 'inline');

However, there are two problems with this approach. First, I would prefer to keep the pages themselves HTML (with JavaScript, of course - but without PHP). And these two lines are the only PHP lines on a large HTML/Javascript page.

Second, JavaScript itself is in quotes which prevents some visual assistance from the editor (since everything is in the string) and forces me to use only double quotes or escaped single quotes inside.

So, I was wondering if there is a way to specify drupal_add_library outside the page, and get Drupal to read <script> tags and JavaScript inside those tags.

In general, I didn't find relevant documentation on Drupal side (relevant being not for theme or module developers but for those who want to use JavaScript / JQuery / JQuery UI as part of site building). If I missed it, I apologize!


texts:
Possible Duplicate:
  Is Drupal Commerce ready for the real world?

I am considering using Kickstart 2 for a project.

Is Kickstart 2 stable ?

Does it allow for modifications or is it locked ?

Anyone experience with this. There doesn't seem to be many sites done using this.


texts: What properties does a custom cck_phone form field need to work?

texts:
I am struggling to get a working custom implementation of a cck_phone field from the cck_phone module. I have included my partially working code at the bottom.

What seems to be not working is that the function cck_phone_phone_number_process expects to be able to retrieve information about the widget with

$instance = field_widget_instance($element, $form_state);
$settings = $instance['settings'];

However in my implementation, field_widget_instance($element, $form_state) returns NULL, resulting in both $instance and $settings being NULL and problems further on in the cck_phone_phone_number_process function.

What does work is that the code below does render a properly populated country code dropdown and phone number entry textfield.

My code to create the custom cck_phone field:

$form_section['phone']['field_phone_home'] = array(
    '#type' => 'phone_number',
    '#field_parents' => array(
        'profile_personal_information'
    ),
    '#field_name' => 'field_phone_home',
    '#language' => 'und',
    '#delta' => 0,
);


texts: Related Nodes with exposed Filter that share all / multiple terms

texts:
Here is my problem: I have several nodes tagged with multiple terms. I want to display related nodes based on these terms in a block. I followed the main instructions that one can find as this: http://scito.ch/content/show-related-nodes-block-based-taxonomy-terms-views-3-and-drupal-7

Everything works okay but even if I choose "Filter to items that share all terms" only a matching on "any terms" seems to be made by Drupal. Here is my setting:

Node 1

category: sunglasses
color: yellow
gender: male

Node 2

category: sunglasses
color: red
gender: male

Node 3

category: jeans
color: blue
gender: female

Node 4

category: jeans
color: red
gender: male

Node 5

category: shoes
color: yellow
gender: male

As result I want for "node 1" only "node 2" to be displayed as a related node based on category and gender. Because category and gender hit my filter so it's an AND combination.

In my current problem I see all nodes that would hit on an OR combination. Here is my views setting:

All common problems that one can find on this topic seem not to be my problem. Anyone that can help?

Thanks a lot!!


texts: Does drush need to be installed as root?

texts:
Per http://docs.drush.org/en/master/install/

# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
php -r "readfile('http://files.drush.org/drush.phar');" > drush
# Or use our upcoming release: php -r "readfile('http://files.drush.org/drush-unstable.phar');" > drush

# Test your install.
php drush core-status

# Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.
chmod +x drush
sudo mv drush /usr/local/bin

# Optional. Enrich the bash startup file with completion and aliases.
drush init

So I try it but get the following error:

[Michael@devserver ~]$ php -r "readfile('http://files.drush.org/drush.phar');" > drush
[Michael@devserver ~]$ php drush core-status
PHP Warning:  pcntl_exec(): Error has occurred: (errno 13) Permission denied in phar:///home/Michael/drush/includes/startup.inc on line 359

Warning: pcntl_exec(): Error has occurred: (errno 13) Permission denied in phar:///home/Michael/drush/includes/startup.inc on line 359
Error has occurred executing the Drush script found at /home/Michael/drush
(errno 13) Permission denied
[Michael@devserver ~]

So then I try running it as root.

[Michael@devserver ~]$ su -
Password:
[root@devserver ~]# php /home/Michael/drush core-status
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /home/Michael/drush
 Drush version          :  8.1.2
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :

[root@devserver ~]#

So, all is good, and I just need to install it as root?  Any way I can install it as a normal user?  Thanks


texts: Site running from accidental upload of core in subdirectory

texts:
Several months ago I accidentally uploaded the folder containing Drupal 6.25 core files to sites/all/modules.

The site now sees that folder as the base install and ignores the installation in the site root.  How can I safely get Drupal to look at the files in the site root as the base install and delete these files?   I tried simply deleting them when I did it and it takes down the site with a configuration error.

Configuration error:  500 - Internal server error - neither front end or back end will load


texts: condition inside template.php (if logged_in/logged_out and else)

texts:
Is it possible to perform condition inside template.php (if logged_in, do these...else do that/ do nothing)?

I am a front-end developer, and as a front-end developer, i like my code clean. So i'm cleaning up my drupal html source code output.

I found some modules out there, that help a lot, and one of then is HTML5 Tools and Metatag (thank you for the team developers). But even with those great tools, i still having the "Drupal.settings" in my html output.

Ocasionally, i found that i can remove the "Drupal.settings" from the html with the hook_js_alter :

  function MYTHEME_js_alter (&$js) {   unset($js['settings']); }

But the problem is: my logged in users still needing this "Drupal.settings" because some modules use it. So that's why i'm asking if there is a way to perform condition inside template.php to logged_in/logged_out users.

THank you in advance


texts: Can I delete old hook_update_N functions?

texts:
Suppose you have a custom module, and you have hook_update_N() implementations in your .install file.

If you have old update functions, and all updates have run in all sites that the module is installed, is it safe to delete those functions?
Please note this is about custom modules that you have access to all sites and updates have been run.

Thank you in advance and I wish everyone a merry Christmas!


texts: What is the difference between index all on a node and indexing that takes place after node save for a rendered html node on a solr index?

texts: If a page containing panels is indexed as a rendered item, when indexing all the content of the panels is not included in the index. However if you save the node then the content of the panels is added to the index.  What is the difference between the process of index all on a node vs indexing that occurs after node save?


texts:
I have a taxonomy list (sector), linked with differtent content, for example:

Company 1 has taxonomy Security & Computers.
Company 2 has taxonomy Security
Company 3 has taxonomy Computers

I created a view, but, in my view I get the following result:

Security
Company 2

SecurityComputers
Company 1

Computers
Company 3

Is it possible to get:

Security
Company 1
Company 2

Computers
Company 1
Company 3

So, that he show 2 times the company who is linked with different taxonomy?...


texts:
I am creating nodes programmatically. I Have written following code,

$e = entity_create('node', array('type' => 'some_node'));
// Specify the author.
$e->uid = 1;
// Create a Entity Wrapper of that new Entity.
$entity = entity_metadata_wrapper('node', $e);

// Specify the title.
$entity->title = 'Some Title';
$entity->body = 'abc';
$entity->save();

On giving value to body i am getting following error. Commenting body it works fine

  EntityMetadataWrapperException: Invalid data value given. Be sure it
  matches the required data type and format. in
  EntityMetadataWrapper->set()

What is causing this error and how can I fix it?


texts: Alter entity reference autocomplete field

texts:
I have made a module to alter the way entity reference works with autcomplete fields. I have override the entity_reference_autcomplete function where i have changed the following line:

        $key = "$label ($entity_id)";

with

        $key = "$label";

It seems to work when completing fields in form , but after the form has been submitted the autcomomplete field gets blank and the result is not saved . How can i solve this issue ?


texts: Question about adding a field value to a view programmatically

texts:
I am having a problem getting a field to print and know it is something I am missing. I am trying to print a product field in a view that is created programmatically. Everything else is working fine, but I cannot pull the item size in to the view. here is the code:

 $form['assigned'] = array(
'#type' => 'fieldset',
'#title' => t('Assigned orders'),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$orders = views_get_view('get_drivers_orders');
$orders->set_display('default');
$orders->set_arguments(array('0' => $account->uid));
// change the amount of items to show
$orders->pre_execute();
$orders->execute();
$orders->render();
if ($orders->result) {
foreach ($orders->result as $key => $value) {
  $order = uc_order_load($value->field_driver_id_users_order_id);
  $form['assigned'][$key] = array(
    '#type' => 'fieldset',
    '#title' => t('Order #' . $value->field_driver_id_users_order_id),
    '#tree' => TRUE,
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['assigned'][$key]['view'] = array(
    '#markup' => l('View order', 'user/' . $account->uid . '/delivery/' . $order->order_id),
  );
  foreach ($order->products as $product_id => $product) {
    $form['assigned'][$key][$product_id]['attribute'] = array(
      '#type' => 'item',
      '#title' => t($product->title),
      '#markup' => isset($product->data['attributes']['What would you like']) ? $product->data['attributes']['What would you like'][0] : '',
    );
    $form['assigned'][$key][$product_id]['size'] = array(
      '#type' => 'item',
      '#title' => t('Size:'),
      '#markup' => isset($product->data['size']) ? $product->data['size'][und][0]['value'] : '',
    );
  }
  $address = uc_custom_process_get_order_address($order);
  $form['assigned'][$key]['map'] = array(
    '#markup' => l('View map','http://www.google.com/maps?q='.$address.'(tooltip/infowindow title)',array('attributes' => array('target'=>'_blank'))),
  );
  $form['assigned'][$key]['total'] = array(
    '#type' => 'item',
    '#title' => t('Total:'),
    '#markup' => '$' . $order->order_total,
  );
}

Here is an image of the krumo of the the view with the products, I do hope someone can help!
    }

I have looked over the proposed solution and it does not fit my use case. I have a view that shows an individual order, that order has products, and those products have all of there values stored in $product->data. I have tried everything to get information from the 'size' field to display in that view and it is not happening. I am not trying to change a value, just display it! I hope this helps everyone help me! :D


texts: How can I translate those translatable texts defined in t() in contribute/custom modules?

texts:
I wrote some custom modules, follow the Drupal standards, put all interface texts in t() function, make them translatable. Module enabled.

I enabled Locale module, added new Language under admin/config/regional/language:

However, under admin/config/regional/translate/translate
I cannot see those text I defined t('xxx') in my custom modules. (cache cleared)

How can I make Drupal aware of them? Thanks.


texts: how can I update user global fields in drupal services?

texts:
I have a user account, in this account I added a global fields. I am using services module for consuming users data.

I am performing CRUD operations on users account. In this account, normal fields are updated successfully and one more global field also updated by using PUT method.

But some user's global fields are not updated.

Example:

In this, first name and user email fields are updated when I perform PUT call, but check boxes fields are not updated.

And in my request content body I wrote this code:

URL: http://drupal.com/services/user/100

{
"uid":"100",
"mail":"example@gmail.com",
"current_pass":"xyz",
"field_first_name": {
            "und": [
                {
                    "value": "xyz",
                    "format": null,
                    "safe_value": "xyz"
                }
            ]
        },
"field_status": {
            "und": [
                {
                    "value": "1"
                }
            ]
        }
}

field status given 1, but field is not checked in user account.

Any suggestion?


texts: How to create a "Link posting" system in Drupal 7

texts:
I'm new to drupal. What I want is to share "links" of different sites - users can publish links. Links can be a certain type of "content" -  I've some knowledge of working with custom content types & "Views". I'm assuming Links should be a custom content type, users can add new links from Add Content >> Links

This "Link" content type should have only two fields:

Text to display for the link
URL

In front page, I want a block that will display most recent links: the first field (text to display for the link) -  when clicked, viewer will be navigated to the 2nd field (URL)

Thanks in advance for helping!


texts: Migration bringing in duplicate taxonomy terms

texts:
I have a very simple taxonomy term migration (migrate module, that lets in duplicate terms for no reason I can figure out.  I have tried explicitly setting allow_duplicates to False, even though that should be the default behavior, but nothing changes.  The base migration that this migration inherits from just sets up a db connection object, sets up team description variables, and sets some configuration variables.  It also sets up a few helper methods that are not used in this migration.

Here is the migration class:

class EnviroscopeKeywordMigration extends BaseEnviroscopeMigration
{
    public function __construct($arguments)
    {
        parent::__construct($arguments);

        $this->description = t('import Keyword data');
        $query = $this->getConnection()
            ->select('doc_keyword', 'k')
            ->fields('k', array('ID', 'NAME'));

        $this->dependencies = array("GeoArea");

        $this->source = new MigrateSourceSQL($query, array(), NULL, array('map_joinable' => FALSE));

        $this->destination = new MigrateDestinationTerm('keywords');
        $this->map = new MigrateSQLMap($this->machineName,
            array(
                'ID' => array(
                    'type' => 'int',
                    'length' => 11,
                    'not null' => TRUE,
                    'description' => 'Keyword ID',
                ),
            ),
            MigrateDestinationTerm::getKeySchema()
        );

        $this->addFieldMapping('name', 'NAME');

        $this->addUnmigratedDestinations(array(
            'description',
            'parent',
            'parent_name',
            'format',
            'weight',
            'path',
            'pathauto',
        ));
    }

}

Can somebody, PLEASE help me debug why this might be bringing in duplicate terms like this:


texts:
I've built a form within a module using form api.
Simply liek this:

function input_menu() {
  $items['request'] = array(
    'title' => 'Request',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('input_request'),
    'access callback' => TRUE,
  );
}
function input_request($form, &$form_state) {

    $form['make'] = array(
    '#title' => t('Car make'),
    '#type' => 'textfield',
    '#required' => TRUE,
    );
}

I have some specific fields that didn't allow me to use webform module.
Now how can I send the results of this form to my mailbox?

Thank you!


texts: Saving existing node doesn't update automatic alias

texts:
I have a node with pattern /route/[node:title]. Whenever I save a new node with automatic alias checked it saves perfectly.

Whenever I edit an existing node with Generate automatic alias checked it doesn't update the URL to the new title but instead keeps the old one. When I go back to editing I see that Generate automatic alias is unchecked all of a sudden and an alias is in place(The old title).

I'm using Pathauto and Pathauto persist but can't seem to find the problem, even when disabling and uninstalling Pathauto persist.


texts: Apache Solr Search, add taxonomy field in search results

texts:
I'm really bumping my head on this.

I simply need to add tids from a term reference field on nodes returned by a solr search result.

It's a unique term reference.

I looked for the field in solr console and it's 'im_field_arbo'.

I followed this and that and came to this :

1.

    function MYMODULE_apachesolr_index_document_build(ApacheSolrDocument $document, $entity, $entity_type, $env_id) {
      if(isset($entity->field_arbo)) {
        $document->addField('im_field_arbo', $entity->field_arbo['und'][0]['tid']);
      }
    }

This doesn't throw back any errors.

2.

Then, to retrieve it, I tried either hook_apachesolr_query_alter, hook_apachesolr_query_prepare with :

    $query->addParam('im', 'im_field_arbo');

and hook_apachesolr_modify_query with :

    $params['im'] .= ',im_field_arbo';

Still, no trace of my field in my search results.

Any help ? Thx very much.

Update

I think my field is well indexed : _apachesolr_index_document_build_node works like a charm.

Now the question is : "How do I get them back in search results ?"


texts: How do I find out which Contrib module is compatible with PHP 7?

texts: Drupal.org misses a PHP version field. As far as I can see, I have to go through the issue queue or .info file for every third-party module to find out which PHP version is supported. Is that correct?


texts: Keep track of which user fully downloaded a file

texts:
I'm looking for a solution to check which users fully downloaded a specific download/file.
I found several solutions to detect whether a download/file is completed.
F.e. https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download
But this use case is quiet different. I need to retrieve a list of people who downloaded the file afterwards.

Thanks in advance.


texts: add function on date selected through date popup field

texts:
I am using Date popup module for selecting a date in a registration form.
Is it possible to fire an event on date select?


texts: Rules Workflow: Data selector is invalid

texts:
A website that has a workflow system based on Rules, as detailed here

Some of the rules use the condition 'User has role(s)', and all these rules now show the following error:

  Error: Data selector site:current-user for parameter account is invalid.

The condition must have been valid when it was created, or the rule would not have been saved.

The site uses Entity API 7.x-1.0-rc3 and Rules 7.x-2.2.

Any suggestions? Even deleting and recreating the rule does not work, as I cannot seem to find site-current-user in the Data Selector dropdown.


texts: How can I create a web form automatically when an organic group is created?

texts:
I would like to automatically create a webform when a new organic group node is created.

The webform should have predefined fields and trigger an email to the group administrator or a user in the group with a predetermined role.  Alternatively it could email an address filled out in a cck field on the group content type.

I tried using og_webform but couldn't figure out how to get it to create webforms for each group.


texts: Aren't the Article content type and the Blog module the same?

texts: Here's a small question, if Drupal already has an Article Content Type, what then is the use of the blog module? Aren't they supposed to be the same?


texts:
I've been embedding an image with my page using item type form control in Drupal 7 Forms API.Below are my codes:

function myid_user_page_form(){
    $form = array();
    $form['id'] = array(
        '#type' => 'fieldset',
        '#title' => t('ID Information'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
    );

    $form['id']['myid'] = array(
        '#type' => 'item',
        '#markup' =>
            '

'
    );
    return $form;
}

My image doesnt show up and is broken eventhough the path is correct and file permissions are set properly.

What Shall I Do? Below is the error:

Resource interpreted as Image but transferred with MIME type text/html: "http://localhost/drupal-7.34/user/7/images/id-background.jpg".

Below is a screen capture of my page.


texts: How to move node contents from local to server environments?

texts:
What is the best way to move node contents from a local environment to a server environment?

I don't want to go with the Features modules.

Any examples that we can go with dbscripts?


texts: Is there a way to store/save the user verification email link in the database after a new user creates an account?


texts: Accessing field values in node--mycustomtype.tpl.php

texts:
I have a content type that contains a field called headshot. This is a file field. In my custom node template file, I need to access the value of the headshot's filename property. dpr($content) produces this for the field:

[field_headshot] => Array
                        (
                            [und] => Array
                                (
                                    [0] => Array
                                        (
                                            [fid] => 53
                                            [display] => 1
                                            [description] =>
                                            [uid] => 10
                                            [filename] => kanderson.jpg
                                            [uri] => public://headshot/kanderson.jpg
                                            [filemime] => image/jpeg
                                            [filesize] => 21669
                                            [status] => 1
                                            [timestamp] => 1337356962
                                            [type] => image
                                            [rdf_mapping] => Array
                                                (
                                                )

                                            [image_dimensions] => Array
                                                (
                                                    [width] => 180
                                                    [height] => 252
                                                )

                                        )

                                )

                        )

I've tried

<img class="speaker_headshot" src="sites/default/files/styles/large/public/headshot/<?php print render($content['field_headshot'][0]['filename']); ?>" alt="<?php print $title; ?>" />

and

<img class="speaker_headshot" src="sites/default/files/styles/large/public/headshot/<?php print render($content['field_headshot']['filename']); ?>" alt="<?php print $title; ?>" />

with no success. How do I access this property?


texts: How in the request db_update to recalculate all fields under the formula?

texts:
I need to count every day about 10,000 records of one of the fields of the node. Now I use the following scheme:
1. getting list of nodes db_select
2. I load and save all nodes with new values (node_load and node_save) in foreach.

This process has become a heavy load on the server and I want to use to change the db_update fields.

function mymodule_select_nids() {
  db_select...
  retutn $nids
}

$nids[0][nid] = 250; $nids[0][rating] = 108; $nids[0][daycount] = 375
$nids[1][nid] = 251; $nids[1][rating] = 525; $nids[1][daycount] = 138

function mymodule_update_fields($nids) {
  foreach ($nids as $node) {
  $fiels_new_rating = (rating + daycoun)/2
  db_update record ...
  }
}

My question is: can one query to the database (db_update)  the records of the entire table or do I need to update each record in the table in foreach?

UPD
If you update 10,000 records, what works faster than db_update against node_load and node_save?


texts: Profile fields under Author by field in drupal 7

texts:
I am using Drupal7 and I have created a profile like: Employee id, first name, last name etc ... it is working fine in registration form.
Now when I try to create a node by admin and when I want  give it author by, I need to search from username. But I want admin to be able to use employee id instead of username.
How to do this?

Thanks


texts:
I am trying to accomplish a certain requirement that is really seeming very confusing to me.

I have two content types for example, ListBank and List (both have pretty much the same fields i.e: title, notes, etc, etc..).

The ListBank content type holds some already created nodes.

Now what i am having trouble with is.. How can i show users the nodes existing in the ListBank content type (this part isn't that difficult as i think i can use a custom view to show a table for this).

But the real tough part i can't get around is when they select a node from the ListBank table and click a button called "add to my list" then it is suppose to create a new content type of List with the values of the selected ListBank node.

Any help would greatly be appreciated regarding this matter.


texts:
I have created a new role 'news contributor'.
I have created a new content type 'news'.

The 'news contributor' role has permissions enabled to view, revert, delete revisions.
However, this setting also gives them access to view, revert, delete revisions on ALL nodes.

How can i restrict node revisions on specific content types based on user role and content type?

The 'news contributor' should only be able to tinker with revisions for the 'news' content type and nothing else.

At the moment they have access to revision any node which is undesirable.

Has anyone had this issue before and, how did you resolve it?

Thanks.


texts: How can hook_theme_registry_alter() associate, for example, theme_mymodule_image_output() with the 'image' theme ID?


texts: Getting a taxonomy-term-name as plain-text in computed field

texts:
In an entity-type with term-reference i want to add a computed field, which grabs the term and sanitizes it for further use with the drupal_clean_css_identifier for example. My code doesn't work, because field_get_items gives back a full link to the term instead the term name as plaintext:

$entity_field[0]['value'] = drupal_clean_css_identifier(array_pop(field_get_items($entity_type, $entity, 'field_myterms'))));

Can someone help me out?


texts:
Drupal uses email for user registration purpose. Instead of the out-of-box Drupal user registration that requires user to specify a username and email address, I want a full-fledged user registration form ( with captcha, user profile etc, like yahoo or gmail registration) for my website.

Is there a module that does that?


texts: buildForm runs before ajax button's submit handler on first click

texts:
First of all, here is some working example code for the classic "Add more" AJAX button (complete module available as a gist):

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

  if (!$form_state->get('number_of_fields')) {
    $form_state->set('number_of_fields', 1);
  }

  $form['#tree'] = TRUE;
  $form['container'] = [
    '#type' => 'container',
    '#id' => 'replace-me',
  ];

  for ($i = 0; $i < $form_state->get('number_of_fields'); $i++) {
    $form['container'][$i] = [
      'my_text' => [
        '#type' => 'textfield',
        '#title' => $this->t('Any text'),
      ],
    ];
  }

  $form['add'] = [
    '#type' => 'submit',
    '#value' => t('Add another'),
    '#submit' => [[$this, 'addTextFieldCallback']],
    '#ajax' => [
      'callback' => [$this, 'ajaxReplaceMeCallback'],
      'wrapper' => 'replace-me',
    ],
  ];

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

  return $form;
}

public function addTextFieldCallback(array &$form, FormStateInterface $form_state) {
  $form_state->set('number_of_fields', $form_state->get('number_of_fields') + 1);
  $form_state->setRebuild();
}

public function ajaxReplaceMeCallback(array &$form, FormStateInterface $form_state) {
  return $form['container'];
}

Now I want to save more things in the form storage. For example, I would want to generate a unique id for the container, so I can include my form more than once per page:

if (!$form_state->get('unique_id')) {
  $form_state->set('unique_id', Html::getUniqueId('replace-me'));
}

// ...

$form['container'] = [
  '#type' => 'container',
  '#id' => $form_state->get('unique_id'),
];

// ...

$form['add'] = [
  '#type' => 'submit',
  '#value' => t('Add another'),
  '#submit' => [[$this, 'addTextFieldCallback']],
  '#ajax' => [
    'callback' => [$this, 'ajaxReplaceMeCallback'],
    'wrapper' => $form_state->get('unique_id'),
  ],
];

However, this does not work. Using xdebug and phpstorm, I found out why:

When I load the page containing the form, buildForm runs. It generates a unique ID. First time round, the ID is replace-me. All good.

The first time I click on "Add another", the following functions run, in this order:

buildForm
validateForm
addTextFieldCallback
buildForm
ajaxReplaceMeCallback

The first time buildForm runs, $form_state->getStorage() is empty, which is unexpected! Consequently, a new ID is generated, e.g. replace-me--62or3gVN0K0. This means that the AJAX won't find the right node to replace next time, since the button still points to the old ID, replace-me.

The second time I click on "Add another", the following functions run, in this order:

validateForm
addTextFieldCallback
buildForm
ajaxReplaceMeCallback

This time, it works as expected, and the ID stays the same, but functionality is broken because the ID shouldn't have changed in the first place.

Questions:

Is this normal behaviour, or have I discovered a D8 bug?
What am I doing wrong?
Why would buildForm run twice on the first click?


texts: How to display a js popup saying "Loading..." after user saves a node?

texts: Been looking for solutions that would show a javascript popup or the like after a user submits or saves a node. How could I achieve this? Any modules out there?


texts:
On a Drupal 7 site with pathauto installed I'm using a view to show all taxonomy terms of a given node. The terms are linked to the term's page. The problem is, that the path of those terms does not use the url alias' that are set for the terms. Is there a way (without programmatically rewrite the view) to use alias in a view?

I know about the globalredirect module, but a redirect is not a clean solution here, in my opinion. And I do not understand why the pathes aren't replaced by there aliases in a view, can someone explain please?


texts: Too many redirects error with https and domain access module

texts:
I'm redirecting traffic for my various domains to HTTPS. Things seem to work fine on my local, but when I deploy to my production site I get the "www.mysite.cn redirected you too many times." error. I'm on Acquia Cloud, so I have limited access to debug apache stuff on the server.

I suspect that this may have something to do with the Domain Access module b/c we have another site with a couple domains running a multisite install (no domain access) and redirects / ssl work fine.

Details:

Drupal (7.56) site running domain access (7.x-3.13) for about 10 domains for various languages (site.com, site.de, site.cn)
Running on Acquia Cloud Professional (use of "HTTP:X-Forwarded-Proto" should handle load balancer issues)
UCC (SAN) SSL certificate with 20 domains on it
the .com domain (default for domain access) switches to https with no problems when deployed, all other domains give me the "too many redirects" error
on my test environment test.mysite.com resolves to https despite the "RewriteCond %{HTTP_HOST} !^.test..$ [NC]" condition

Relevant code:

.htaccess

#Send sites to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^.*devcloud.acquia-sites\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Send PROD sites to https
RewriteCond %{HTTP_HOST} !^.*dev\..*$ [NC]
RewriteCond %{HTTP_HOST} !^.*test\..*$ [NC]
RewriteCond %{HTTP_HOST} !^.*local\..*$ [NC]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

settings.php (standard domain access bootstrap include at the bottom)

// domain access
include DRUPAL_ROOT . '/sites/all/modules/contrib/domain/settings.inc';


texts: tableselect showing empty message instead of options

texts:
I'm trying to populate a tableselect on a form of a custom module. The tableselect is actually visible, but it's displaying the #empty message. I've simplified it to this code:

$form['my_module_overview'] = array(
    '#type' => 'tableselect',
    '#header' => array('parent' => t('Parent'), 'child' => t('Child')),
    '#options' => array(
        1 => array('parent' => 'test1', 'child' => 'test2'),
        2 => array('parent' => 'test3', 'child' => 'test4')),
    '#empty' => t('There are no relationships defined yet.'),
    '#multiple' => TRUE,
);

So I'm seeing the table with the correct headers, but with the message "There are no ...".

I think I'm donig it correct, as the options array contains key-value-pairs with the values being arrays again. And those arrays have the header keys as keys ('parent' and 'child').

So how can I get the data to become visible in my tableselect?


texts: Is there a way to share content between users?

texts: Drupal 7... I just want to be able to send some information via content type from one user to the next such as an event. One user will create this content and only wants it seen by a select few of other users. Is there a way to make this happen. What would be cool is a field on my content type that collects usernames or emails for a private message or invite to view the content...


texts: Downloading custom module with drush make

texts:
I am trying to download a custom module from a private repo using drush make.
This is the make file:

core = 7.x
api = 2
projects[cs_all][type] = "module"
projects[cs_all][subdir] = "contrib"
projects[cs_all][download][url] = "git@bitbucket.org:myrepo/cs_all.git"
projects[cs_all][download][branch] = "master"

I run the following command:

drush -d make --no-cache --no-core my.make build

The output is as follows:

Starting Drush preflight. [0.46 sec, 2 MB] [preflight]
Cache HIT cid: 7.0.0-commandfiles-0-4ea41d3d78dd4cb8ebf6ca2ee09bd808 [0.61 sec, 2.05 MB] [debug]
Bootstrap to phase 0. [3.31 sec, 8.02 MB] [bootstrap]
Bootstrap to phase -1. [3.35 sec, 8.03 MB][bootstrap]
Found command: make (commandfile=make) [3.36 sec, 8.03 MB] [bootstrap]
Bootstrap to phase -1. [3.36 sec, 8.03 MB][bootstrap]
Loading release_info engine. [3.38 sec, 8.03 MB][notice]
Calling hook drush_make_validate [3.42 sec, 8.23 MB][debug]
Returned from hook drush_make_validate [3.42 sec, 8.23 MB][debug]
Calling hook drush_make_pre_make [3.42 sec, 8.24 MB][debug]
Returned from hook drush_make_pre_make [3.43 sec, 8.24 MB][debug]
Calling hook drush_make [3.43 sec, 8.25 MB][debug]
Beginning to build my.make. [3.44 sec, 8.27 MB] [ok]
Downloading release history from https://updates.drupal.org/release-history/cs_all/7.x [3.45 sec, 8.35 MB] [notice]
c:/Users/myname/.drush/cache/download/https---updates.drupal.org-release-history-cs_all-7.x retrieved from[notice]
cache. [3.45 sec, 8.35 MB]
No release history was found for the requested project (cs_all). [3.46 sec, 8.36 MB][error]
Returned from hook drush_make [3.46 sec, 8.35 MB][debug]
Command dispatch complete [3.46 sec, 8.32 MB]

Basically drush looks for the module release history file on drupal.org.

I have not found any specific documentation regarding downloading from private repos. However various snippets taken from presentations show the same make parameters that I have used.

I am using drush 7.0.0., php 5.5.26 and Windows 7.

How to fix the issue?


texts: Question about views (related to page specific blocks)?

texts:
Lets say I have a website called "website123" along with several pages called "pageA", "pageB", "pageC" and "news". Each of these pages has custom blocks that will only display on these pages. (Think bannerA/bannerB/bannerC and sidemenuA/sidemenuB/sidemenuC)

On the news page you have a view that will grab all published content that are articles. On "pageA" it will grab all content tagged with "a", "pageB" and "pageC" will have a view just like "pageA" except it will go for content tagged with "b" and "c".

I'll create an article called and tag it with "a,c" so this will go to "news", "pageA" and "pageC".

If you go to "pageA" the layout will be banner at the top and sidemenu on the left with the view in the middle with a list of articles tagged with "a" in a teaser viewmode

Is it possible to make it so that when you click "read more" it will open the article in the current region / page so that the same custom banner/sidemenu applied on "pageA" will be applied to all articles in "viewA"?

Then since the article was tagged with "c" as well if you went to "pageC" and in "viewC" if you clicked the same article there it would open with the banner and sidemenu that only "pageC" has.

Sorry if this question is really confusing, but any advise would be appreciated.


texts: Which hook is used to alter a field's description?

texts:
Which hook should I use to alter description of a field?

I want to add some descriptions to fields in several content types. because number of fields and content types are too many, I prefer to add descriptions programmatically.


texts: Is it possible to create a "Meta-Forum" view when using organic groups?

texts:
We are using Drupal 6.x with organic groups. The groups have very different users and permission sets, and each group has a forum.

I was wondering if it is possible to have a kind of "Meta-Forum" view, i.e. one view in which all of the different Forums the user has access rights to are displayed, organized by group.

I have had a look at configuring a View for this, and while I am able to get things like a list of the most recent forum entries in all the subscribed groups, I was not able to get a "forum type" view where I have the groups on the highest level, then the individual forums and posts below this.

Is something like this possible?


texts: How to display photo properties (ISO, Aperture, Exposure, Shutter Speed) in Drupal 7

texts: everyone! I know that every image contains specific information about itself( ISO, Aperture, Exposure, Shutter Speed). The problem is how to display them in the article of Drupal 7? Thanks!


texts: What is the proper way to uninstall a module that adds a content type

texts:
I heard that when uninstalling a module that is a content type, you should not use node_type_delete('my_module') in hook_uninstall(). Instead, you should let it be handled by Drupal that just disables the content type in the database. Is this right?
Apparently Drupal handles it in hook_node_info().

Wouldn't it be better to delete this node type in the database, or does Drupal handle uninstallation process in an other way?

I am using Drupal 7.


texts: Field type Entity Reference as select list but based on value

texts:
I want field with entity reference showed as select but based on value from the another field in the same form [radio button field]
for example the entity reference field will list these values

-entity 1
-entity 2
-entity 3
-entity 4

and the field radio button will hold countries like so:

-England
-Germany

notice that the entities reference (Content Type) has field called country, so when i check the
value "England" i want the field entity to be filtered based on England for ex:
-entity 1 & -entity 4
and same if i clicked Germany.

is that applicable in Drupal 7 even by Views module, or i have to do it custom !?


texts: Get all registered Users into a Field Type List

texts:
I would like to create a content/form where an authenticated user is able to choose another registered user from a list/dropdown. I've been searching for ways to get this done but am not able to find any working solution. Token can only display current-user, not all users. I can list all users using Views but not able to import them into the field of type list.

ie:
Nomination Form
Favorite Sport : [options](list from taxonomy)[/options]
Favorite Users : [options](list of all registered users)[/options]
etc

Appreciate if someone can point out what I am missing. Thank you


texts: How to can create a user profile with approve changes by admin

texts: I want if user changes his/her profile information they not applied till administrator approve them,I am using drupal 7 ,How can I do this ? is there any module exist for this job?


texts: Client wants to have their D6 and D7 site run under the same domain. They're not ready to upgrade. Each has a similar theme so linking to the D6 site will 'look' seamless. How can this be done?


texts:
I have a form with a <button> element

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['address'] = array(
      '#type' => 'textfield',
      '#autocomplete_route_name' => 'geocoder_autocomplete.autocomplete',
      '#title' => '' . t('Find an adoration place') . '',
    );

    $form['submit'] = [
      '#type' => 'inline_template',
      '#template' => '<button type="submit" class="glyphicon glyphicon-search"></button>',
    ];

    return $form;
  }

When I click the button the page is refreshed but the submitForm() method is not called. If I add an <input type='button'> element in the form and I click the <button> or the <input type='button'> the submitForm() is called.

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['address'] = array(
      '#type' => 'textfield',
      '#autocomplete_route_name' => 'geocoder_autocomplete.autocomplete',
      '#title' => '' . t('Find an adoration place') . '',
    );

    $form['submit'] = [
      '#type' => 'inline_template',
      '#template' => '<button type="submit" class="glyphicon glyphicon-search"></button>',
    ];

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

    return $form;
  }

I'm missing something here? Why my button element don't trigger the submitForm method?


texts: Clean URL notworking properly (With Virtualmin)

texts:
Some times, for some links/pages of my Drupal 8 site /index.php/en appears instead of /en. Currently I'm using Virtualmin, I haven't this behavior before use this virtualmin admin panel.

Thank you for your help.


texts: drupal_find_theme_functions() and Omega performance

texts:
A related question explains this issue.  drupal_find_theme_functions called on every page - is our theme registry being rebuilt?

With omega, there are 3 themes total (Alpha, Omega, and Subtheme) so this adds to the number of times drupal_find_theme_functions is called.

Shouldn't base hooks be stored in the cache?  I see that it has logic to check to see if they are already set, but it seems like every time the page loads drupal_find_theme_functions calls preg_grep about 2,014 times. It takes 4,969,243 microseconds.  I have a lot of modules installed, and this doesn't seem very efficient for every page load.  Can someone please advise?

Edit

Looks like the issue is APC related, or at least I think so.

I installed APC and memcached previously to increase performance.  I'm noticing some cached items are going missing even when they're set to not expire.  I have features installed and tested features_get_info()'s cache which should never expire.  It remains set for 5-10 minutes then goes away.  Looking at apc.php shows 192M of 192M free about 500K usage, so something's definitely wrong.  I'm not sure if the default APC/Memcache settings attempt to store the theme registry or not, but I'm going to play around with ttl values and see what works.  If anyone can help, I'll mark this as answered.


texts:
In Drupal we can open a modal is two ways, either with HTML:
Open Modal

Or with JS:
let ajaxSettings = {
  url: 'node/1',
  dialogType: 'modal',
  dialog: { width: 800 },
};
let ajaxObject = Drupal.ajax(ajaxSettings);
ajaxObject.execute();

Once the modal is open I would like to attach an event to the close button so I can drop a cookie on the close event to show the visitor has seen the modal and not show it to them again.
The close button has the class ui-dialog-titlebar-close but this is added after the initial page load so to attach an event we would need a dynamic click handler such as:
$('body').on('click', '.ui-dialog-titlebar-close', function() {
    alert('close button was clicked 2');
});

However this event never fires. This ctools issue mentions the same thing and has a solution involving binding to the CToolsCloseModalBehaviors event, however that was 6 years ago and I'm using D9 with no ctools so need to find a new solution.
When I inspect the attached events on the close button I can see jquery.ui/ui/widget-min.js r() and an anonymous function in jquery.min.js. Using non minified vs would help but not sure how to do that?


texts: Any clues or examples how to programmatically create node types with cck fields in Drupal 6? I would like to create a content type with has a cck file field in it. The Example module has an example of creating a node type but it does not utilize existing cck fields.


texts: How do you programmatically set a custom title via a Views display using PHP?

texts:
I'm trying to set a custom title for my Views display by programmatically doing a drupal_set_title() within the Global PHP footer. But it seems that its not firing as I think its firing before the page is rendered.

How can I programmatically set the title of the page using Global PHP within the footer? I want to tap into the results data to create a custom title using drupal_set_title().


texts:
I followed the steps on skvare to index Civicrm contacts via Search API, then to have Views list the contacts with the search box as an exposed filter. This seems to work overall, but custom Civicrm fields don't seem to be showing up via Views. For example, I've got records showing up with display name, bio, and contact ID. But they're also supposed to have custom fields called "designation" and "role". I've checked that the corresponding contact created in Civi has values (strings "test" and "pencil sharpener" respectively) for these fields. I've made sure that these fields are indexed in the search API and I've rebuilt the search index, to no avail. I'm able to select the fields in the Views UI but when I look at my View, I don't see them and when I do a dump of the fields variable in the View template, those fields are there but they just have an empty value.

Why are my custom Civi field values empty when I try to display them on contacts indexed with the search API via Views? This is all in Drupal 7.


texts: Specification of an Image field attached to forum topic node type?

texts:
I have somehow a strange issue with Fields : I've created an Image field for each of my content types. This image field allow the insertion of images into the node body with Insert and Colorbox. Everything work as wonder for all the content types... except for forum topics.

Indeed, when creating a new forum topic, my users can't see the Image field in the form. Also :

Admin can see it, but not other users
Users can perfectly see Image field when creating a new content of other type.

I've also checked : it's not a question of CSS or other modules hooking the field.

Do you have any idea of what has to be done ?!  :/


texts:
I have 14 blocks added through Drupal interface, for all of them I was override tpl.php file because I need some changes there (like block--block--1.tpl.php).

What I want to do is to create just one tpl.php file and apply it for all these blocks. So, if I need to change something someday, I change it just in one file instead 14 files.

How I can accomplish that in Drupal 7?


texts: Getting image URL and rewrite results for Views Module

texts:
I have a Content Type of only an Image field and I am using Views module to create a view for it as in follows

Using Image URL Formatter module I was able to get the image absolute URL, but using the following "rewrite rule" in Views

It outputs the URL wrapped in a

or

tags, how can I possibly get the pure text URL for this image?


texts: Views block template print individual field from content

texts:
I created a view of paragraphs and I passed the parent ID as the contextual filter using a relationship to the content that use the field that reference the paragraph.

I can see the data been display and now I want to theme the output that I want to display on a block. I created a custom template file for the view block:

  block--views-block--MY-VIEW-NAME-block-1.html.twig

and it is working. I can see the content of the view by adding:

{% block content %}
{{ content }}
{% endblock %}

But I would like to access the fields value individually. I have try the followings without luck:

content.field_name
content.field_name[0]
content.field_name[0].value

What am I missing?


texts: looking for a slider module to use in the header

texts: what's a good slider for a header in drupal 7 (I would like to have a slider for different content in other blocks/pages of the website, so if the same module could work for both, better)


texts: How to create a select list of which the selected item is used as parameter in VBO rules component?

texts:
It's a common scenario, but I couldn't find a solution yet:

I have a view (a list of tasks) with checkboxes (views bulk operations)

I want:
1) a dropdown select list of taxonomy terms 'Priority' above the view.
2) a rules component that uses the selected taxonomy term, as parameter for applying the priority to the selected tasks.


texts: How to override views results after ajax enabled exposed filter is submitted?

texts:
Is there a hook in the views api that allows for accessing the $view object of each result row after submitting exposed filter values in an ajax-enabled view block? I need to override the field output of an ajax-filtered view.

I need something similar to hook_views_pre_render which works great to override fields in a view that doesn't use ajax/exposed filters, but it doesn't work for ajax-reloaded view blocks generated by exposed filter input.


texts:
How can i make certain nodes of group Private in a Public Group irrespective of content types.
So lets say I have a Public group X which has Page as a content type. So i have 10 as contents of groups which is public.So I have to make 2 contents of the group Private such that it is only available to the group members.

Tks in adv,
-Vil


texts: Language switcher shows me same node on switch

texts:
I am using Locale and Content Translation modules. First I created node and translated it. On content listing both have proper alias urls, everything seems to be ok.

As a guest user I see content in first language when I want to switch to translated version of current node, language switcher block gives me node in the same language (previuosly selected) and url of this node is just raw node url (node/ID). So everything is f up.

Could somebody give me any advice?

More info:

current lang is en:

language switcher links: pl (node/154) and en (en/sample)

en/sample is alias of node/154 :/

But I am sure that I have translated to "pl" node of id 154.

Lanuage codes (admin/config/regional/language):
en, pl

Detections (admin/config/regional/language/configure)
- URL


texts:
I want to hide the flag on a node if a boolean field is unchecked.

My Code in node.html.twig

{% if node.field_registration_status.value == 0 %}

    {{ content|without('content.flag_class_registration') }}

{% endif %}

{% if node.field_registration_status.value == 1 %}

     {{ content }}

{% endif %}

My CSS classes print as expected when the field is checked or unchecked. However, the Flag is not being removed from the output.


texts:
I am running a Drupal 8.9.2 site as a content repository accessed via an Angular 8 app.
So there is one administrator who uses the Drupal interface to write content / upload files eccc.... and anonymous users view that content via the Angular app.
I have set up some views with REST Export display and have been able to pull the content in my Angular app running both backend and frontend on localhost, but when I deployed to the server problems have arisen...

all my calls fail or get canceled, this was the configuration on localhost:
the Drupal website was in a folder in XAMPP/htdocs/example
the views rest endpoints were like: http://localhost/example/web/api/content
the Angular app was in a folder on the desktop and was served at http://localhost:4200/home

now I put all the files for both backend and frontend on the root folder on the server, I also have commented this line ErrorDocument 404 /index.php in the htaccess file found in the web folder so that non existent urls are managed by the Angular app

how to make sure that Drupal articles and pages are not accessible to anonymous users and they are not indexed by Google?

how to make sure that only the anonymous users of my Angular app can access the REST views endpoints and they can only make GET requests?

how to make so that the Angular app allows me to go to the Drupal admin pages? In the app there is no route like example/web/admin/user so I get redirected to the App login page

Any suggestion and help is appreciated
Thanks
Elena


texts: Views image fields render slow causing overlaping results

texts:
I have a view displaying some content fields including images being used as the background. I also have 2 attachments with the same fields.

When i visit the page for the first time, or when i do a hard refresh of my browser (hold shift and refresh) the main content and the two top attachments squish together. if i then refresh all looks ok.

Im using bootstrap theme as my base theme. If I disable my CSS file, the error still occurs.

I was thinking it had something to do with the image resizing and loading later than the text content.

Please let me know if you need more information.

http://dev-tangrm-test.pantheonsite.io/


texts: I need to get Drupal to list all its files and their management status for debugging purposes. It seems like there must be a simple way to print the list of managed files, right? How is this done?


texts: How does CSS and JS aggregration work in Drupal?

texts:
When Drupal is set to optimize JS and CSS, it creates the 'js' and 'css' folders in your public file system root. Aggregated JS and CSS get stored in these directories. I've tried to figure out how Drupal keeps track of these files, and how Drupal matches consequent page request against applicable aggregated files in these directories. Is the filename a hash based on, say, the request URL?

Right now, I'm working on a site which has 4 web servers. All web servers have the same storage mounted as their public and private file systems. When one server generates CSS and JS files for a page, how does any of the other servers utilise these generated files for an indentical request?


texts: form_alter to change value of default in dropdown list

texts:
I need to change the first value (the default one) in one of my taxonomy based dropdown menus. It is currently set to '- CHose a value -', and I need it to be changed to: '- Chose city -'.

I thought I might use form_alter for this, But I cant get further then to the correct form_id.

What to I do next?


texts: Can I define the minimum php version for my module in my .info.yml file?

texts:
I need to define the minimum PHP version in my module.info.yml file but I don't know if this is posible using:

php: 5.6

If you search about this in the drupal.org documentation you will only see the reference about this in the theme.info.yml file: Defining a theme with an .info.yml file

  php (optional)

  The minimum version of PHP required. Defaults to value
  of DRUPAL_MINIMUM_PHP constant.

  php: 5.5.9

But in the documentation about the module.info.yml file there is nothing about the php version: Let Drupal 8 know about your module with an .info.yml file.

So, really I can't define the minimum php version in my module.info.yml file?


texts: Views: filter on taxonomy term OR nodequeue relation cause duplicates

texts:
I need to extract 30 nodes which (among others criteria):

has a particular taxonomy term (as a filter)
OR
belongs to a particular nodequeue (as a not-required relationship)

Nodeque gives editors the opportunity to identify first N nodes in the desired order.  When these N nodes are less than 30 (total number of nodes the views retrieve) other nodes follow in published date order.

That's OK, it works, but not when a node is present in another taxonomy subqueue. In this case the node is duplicated (becouse the position is (usually) different in the two subqueues).
I even try using contextual filter "Nodequeue: Subqueue ID" and " Nodequeue: Subqueue reference" but it doesn't work because I get only the N nodes in the nodequeue.

The limit is you can't use a specific subqueue as a views relationship. Only parent queue is available.

This is the actual query:

SELECT DISTINCT node.nid AS nid
, node.title AS node_title
, users_node.uid AS users_node_uid
, node.uid AS node_uid
, node.created AS node_created
, **nodequeue_nodes_node.position AS nodequeue_nodes_node_position**
, 'node' AS field_data_taxonomy_vocabulary_3_node_entity_type
, 'node' AS field_data_field_occhiello_node_entity_type
, 'user' AS field_data_field_nome_e_cognome_autore_user_entity_type
, 'node' AS field_data_field_immagini_node_entity_type
, 'node' AS field_data_taxonomy_vocabulary_13_node_entity_type
, 'node' AS field_data_field_sezione_di_appartenenza_node_entity_type
, 'node' AS field_data_body_node_entity_type
FROM
 node
LEFT JOIN users as users_node ON node.uid = users_node.uid
LEFT JOIN nodequeue_nodes as nodequeue_nodes_node ON node.nid = nodequeue_nodes_node.nid AND nodequeue_nodes_node.qid = '15'
LEFT JOIN field_data_field_sezione_di_appartenenza as field_data_field_sezione_di_appartenenza_value_0 ON node.nid = field_data_field_sezione_di_appartenenza_value_0.entity_id AND field_data_field_sezione_di_appartenenza_value_0.field_sezione_di_appartenenza_tid = '25685'
WHERE (( node.nid=5925 AND (node.status = '1') AND (node.type IN  ('dossier_post', 'materiale_post', 'rubrica_post')) )AND(( (field_data_field_sezione_di_appartenenza_value_0.field_sezione_di_appartenenza_tid = '25685') )OR (nodequeue_nodes_node.nid != '0') ))
ORDER BY nodequeue_nodes_node_position DESC, node_created DESC

Do you have any solution to suggest?


texts: How do I load specific page template for /store-locator

texts:
I want to control the region the store locator and panel being placed into. I was hoping I could just use a content-type page .tpl to move things around within the rest of the layout, but that doesn't seem to be working.

After trying it and it not working I'm guessing all that would do is change the display of the actual "/name-of-store" path and not the sitename/store-locator path.

Store Locator seems to be an odd duck. I can't find anything in the code that would point to a tpl file. It certainly isn't a view in a block since it's basically being rendered in the primary content area of my standard tpl file.

My first wish is to have a separate page.tpl so I can get all the parts of pieces of the page where I want them. Being that it looks like all the code is generated in JS, I can't even think of a way load that into a view and then but the view in a panel layout that's full width.

Any thought on what the page tpl needs to be and what the right theme hook would need to be in preprocess? This is what I have working for my other hinting for page tpl's.

  if (isset($variables['node'])) {
  // If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
   $variables['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $variables['node']->type);
  }


texts: Add block programmatically in the right region

texts:
I have followed the instruction to create a new block here which is basically the same as here on SE. My block is indeed created but the region is wrongly set to "none" instead of "Content Post".

In my module events.module file:

function events_block_info () {
    return [
        'events_list' => [
            'info'       => "Events list",
            'region'     => 'content_post',
            'visibility' => BLOCK_VISIBILITY_NOTLISTED
        ]
    ];
}

function events_block_view ($delta = '') {
    $result = false;
    if ($delta == 'events_list') {
        /* ... do my stuff .... */
    }

    return $result;
}

This creates a block but the region is set to "none". The drawback is I have to go on each environment and change the region manually back to "Content Post". It is inefficient.

I also find it extremely weird that the creation of a block is done this way. I would expect instead that the creation takes place in the module.install file in the hook_install() function. Maybe there is way?


texts: Scald: themable atom reference – where to find image path etc.?

texts:
I can't find a way how to get an atom reference's values (image path etc.) into my theme template. When printing the node array I do get the SID for the referenced image, but I just don't know how to load the actual details.

Or is it possible by simply using node_load or entity_load or the like? Any pointers gladly appreciated.


texts: How do I show a translated the value of a content type in my template

texts:
I have a bootstrap banner (jumbotron) on my site, which roughly looks like this:

{% if page.banner %}

 Welcome to foo.com

 we provide

{% endif %}

Now, instead of hard-coding the texts for h1 and h2 ... I went to  Administration > structure > content type and created content type called short texts and then to Administration > Structure > Content types
and added a content called site slogan and site description they both contain the values of h1 and h2.

Now, my question is how do I replace the text inside the H tags with a (translatable) text I created as a content?

This is my first week in Drupal, so I am a bit lost


texts: force image style generation on save node

texts:
I've got still my problem described here Image style, reuse image in field collection item but i gave up to get a solution.

A workaround which came up in my mind is to force the generation of imagestyles on nodesave. are there any possibilites to do so?


texts: get commerce order variables dpm without loading order again

texts:
I try to get order variables using devel module from inside custom order template page--admin--commerce--orders__%.tpl.php.

I use code $order = commerce_order_load(123);

Question: is it possible not to load full order again and get the variables ? (assuming that I am on order page, the variables should be loaded anyways correct?)
Thank you for explanation.


texts: I need to export some order data to a CSV file. One field is the date (d-m-Y) when the order has been paid. I have search in hook_commerce_*, in the database, but I have not find anything that can help me. Is this data saved in the database, or I need to create a rule that saves this information when the order is payed in full the first time?


texts: How to read a Drupal 7 node as a css file?

texts:
I know that this isn't how Drupal is meant to be used, but I have this special case where I created a node that ends in a .css extension and need to have that file be used as the css file for the whole website.

So what I've got are:

a node named styles.css residing at the url "http://www.mysite.com/styles.css"
all of my regular nodes linking to that file. the "" is hardcoded into page.tpl.php

Drupal appears not to read styles.css as a css file; any ideas?


texts:
A few weeks ago a site admin canceled a user account on one of my Drupal 7 sites and clicked on "Delete the account and its content." That user had created about half the content on the site in different content types and uploaded files.

So we lost about half our content.

I have backup (a mysql dump) of the site from before account was removed and all the uploaded files, and I'm sure the user wasn't active in the time between the backup and the removal.

Is there an easy way to recover the content from that one user? I cannot just restore the database from the dump, since that will wash away any changes since then.


texts: Commerce Product Display or just Views Display of line items?

texts:
I will be presenting the products in one view and don't need the display nodes as they wont be seen.

Do I have to create display nodes for each product or can I just use views to display the line items in a table for example?

Is there any catch with doing this?


texts: Having each child record inherit (display) data elements from a parent record

texts:
I'm new to Drupal and have been watching lots of videos on entity relationships but am a bit lost still....trying to wrap my head around the differences between nodes, entities, etc. and how to define relationships.

What I would like to do is have 2 pieces of content - Company and Program.

The company information will be filled in by an administrator of the site (company name, address, phone, website, etc)  -- these values are only editable by the administrator but can be read by any authenticated user.

Then any authenticated user can create a Program which will have its own set of fields (program name, date, program director, etc.)

Each Program is considered a child of Company and so the Program would also have read only fields that present the company info.

Can someone please point me in the right direction of how to link the Company directly to the Program.  I have seen ways of adding a select list field that would allow the user to select a Company from a list of companies...but I want this to default to the same company each time.

Thank you for any ideas/help.

E


texts: How to send monthly newsletter if the site is complex and has a lot of content types?

texts:
I want to send monthly newsletter to subscribers via Drupal. The website has lots of content types (news, events, books, courses, blog posts etc.). If the site has only one content type it would be easy to prepare this newsletter with Simplenews module or Mailchimp etc.

Because the site is so complex and needed to create some specific views for each content type I wonder if is it better to prepare custom newsletter manually (without Drupal interface) or is there any solution to send newsletter via Drupal interface, "easily" and automatically?


texts: Place the footer AND the copyright blocks at the bottom of the page responsive

texts:
I installed Industrial Theme from Zymphonies and I am struggling to place the footer and the copyright (2 block layouts) at the bottom of the page.

So, on my website it looks like that.

I tried a lot of methods but I do not know how to deal with 2 containers simultaneously.


texts:
In Datetime.php from Core\Datetime\Element, I read:

#date_date_callbacks: Array of optional callbacks for the date element.
    Can be used to add a jQuery datepicker.

What does it mean? How am I supposed to add a jQuery datepicker from a PHP function? Right now I am doing from a JS file included as a library, but I'd like to keep my custom widget more self contained (I am developing a custom widget to select weeks using jQuery datepicker).


texts:
I have a multi step custom made form in Drupal 8.2.x.

Some of the user input from the form needs to be shown on a separate block.

The following code worked fine for users that are logged in:

$tempstore = \Drupal::service('user.private_tempstore')->get('mymodule_name');
$tempstore->set('my_variable_name', $some_data);

But it doesn't work for anonymous users on my site.

Is there a tempstore for anonymous users that works site wide that I just haven't discovered yet?


texts: How to override node comment form template?

texts:
I usually override a form template this way.

/**
 * Implementation of hook_theme().
 */
function MODULE_theme() {
  return array(
    'user_login' => array(
      'render element' => 'form',
      'template' => 'user_login',
      'path' => drupal_get_path('module', 'MODULE').'/templates',
    ),
  );
}

I create templates/user_login.tpl.php in my module folder; then, I can override the form.

I tried overriding a node comment form this way, but it didn't work: The node comment form didn't use my custom template file.

I have googled a lot, but I got nothing about overriding a node comment form template.

How can I force Drupal to use a template file for the node comment form?


texts:
I need to show the list of the content created by the currently logged-in user.
How do I do this with the Views module?


texts:
In the user.services.yml, it defines a theme negotiator service as such:

  theme.negotiator.admin_theme:
    class: Drupal\user\Theme\AdminNegotiator
    arguments: ['@current_user', '@config.factory', '@entity.manager', '@router.admin_context']
    tags:
      - { name: theme_negotiator, priority: -40 }

This class determines whether or not the current user sees the admin theme when on the user path.

How does this work? What looks at this and knows when and where to call and instantiate that class? How is it correlated (beyond implementing the interface) to the service below:

  theme.negotiator:
    class: Drupal\Core\Theme\ThemeNegotiator
    arguments: ['@access_check.theme']
    tags:
      - { name: service_collector, tag: theme_negotiator, call: addNegotiator }

Is service_collector something that finds defined services and makes them available by tag name?

What other basic examples of this exist around Drupal 8 core?


texts: Select which assets and scripts should load on certain pages

texts:
This is to avoid loading other assets and scripts that are not needed for certain content types, pages, etc.

I have seen this in wordpress, there are performance plugins that allow you to selectively choose which scripts and assets to load.

I can't find any module on Drupal that allows this, just wondering if any of you know about some, or what approach could we use to achieve this.


texts: Detect translatable strings in custom module code

texts:
I have a D6 site with several custom modules. The site now needs to support multiple languages.

All my strings are wrapped in t() and I'm pretty familiar with locale.module and the i18n modules. I know that all translatable strings get written to the 'locales_source' table, and that from there I can export a .pot file to send to translators.

What I can't figure out, however, is how I can get all of the translatable strings in my custom modules into the 'locales_source' table. I know that the t() function calls locale(), which in turn will write a newly found string to this table, but how can I make all translatable strings get into the table at once?  I think I need a function that will parse the PHP source for t(), watchdog, hook_menu, etc to find everything that's translatable and write it to 'locale_source'...?