texts:
I want my drupal user to see the media edit form using the frontend-theme, not the admin-theme.
In my RouteSubscriber I use
if ($route = $collection->get('entity.media.edit_form')) { $route->setOption('_admin_route', FALSE); }
The function works for 'book' entities (for example) but not for media.
Did somebody already had this problem?


texts: What does the "Vary: Cookie" header actually do for serving pages from Varnish?

texts:
According to the documentation in default.settings.php, and I've seen similar descriptions elsewhere, "Without "Vary:Cookie", authenticated users would also be served the anonymous page from the cache."

However $conf['omit_vary_cookie'] = TRUE; is recommended with Varnish in Drupal 7 and doesn't seem to keep users from being able to switch from anon to authenticated sessions. Is this a header that Varnish doesn't actually care about?


texts: How do I configure subdomain url as one.mysite.com/subdomain1

texts:
I am a Drupal Developer currently working on Drupal 7.15 multi domain site. In my site, I have already installed Domain module and configured the domains as:

Main domain - mysite.com (say 1st level)
Sub Domains - one.mysite.com, two.mysite.com, ... (say 2nd level)

Now I need the 3rd level Domains as:

one.mysite.com/subdomain1,
one.mysite.com/subdomain2,
one.mysite.com/subdomain3.

But my control panel only has the option of setting this as one.subdomain1.mysite.com

Can any one help on this. Either how to configure the subdomain as of my requirement or else how to re-write the url?

Thanks


texts:
What does drupal_clone($node) do in Drupal? Will it clone a node?  I know the node will be saved only if node_save($clone) is rendered. So what will happen when drupal_clone($node) is rendered ?

/**
 * Generate a node preview.
 */
function node_preview($node) {
    if (node_access('create', $node) || node_access('update', $node)) {
        // Load the user's name when needed.
        if (isset($node->name)) {
            // The use of isset() is mandatory in the context of user IDs, because
            // user ID 0 denotes the anonymous user.
            if ($user = user_load(array('name' => $node->name))) {
                $node->uid = $user->uid;
                $node->picture = $user->picture;
            } else {
                $node->uid = 0; // anonymous user
            }
        } else if ($node->uid) {
            $user = user_load(array('uid' => $node->uid));
            $node->name = $user->name;
            $node->picture = $user->picture;
        }

        $node->changed = time();

        // Extract a teaser, if it hasn't been set (e.g. by a module-provided
        // 'teaser' form item).
        if (!isset($node->teaser)) {
            $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format);
            // Chop off the teaser from the body if needed.
            if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
                $node->body = substr($node->body, strlen($node->teaser));
            }
        }

        // Display a preview of the node.
        // Previewing alters $node so it needs to be cloned.
        if (!form_get_errors()) {
            $cloned_node = drupal_clone($node);
            $cloned_node->build_mode = NODE_BUILD_PREVIEW;
            $output = theme('node_preview', $cloned_node);
        }
        drupal_set_title(t('Preview'));

        return $output;
    }
}

Real Issue

I am getting the node cloned when clicking the preview button. Is it related to any code changes?


texts: Create path alias programatically when node is created

texts:
I have a custom content type that is created by a module.  Is there a hook I can use to set the path alias of my custom content type when a node is created?

One of my fields is an alpha-numeric code, and I want to use that in the path. eg.: 'event/myc0d3'

I noticed that this function (path_set_alias) existed in 6, but I can't find the equivalent for 7.  And do not know where I would call it.


texts: site-install error: /var/www/drupal7 does not contain a valid installation

texts:
I am running on Windows 7 Enterprise and have done to following to set up my site:

Downloaded and installed Virtual Box VirtualBox-4.3.18-96516-Win.exe
Downloaded and installed vagrant_1.6.5.msi
Downloaded vdd-8.x-1.0-alpha4.zip
Extracted the zip file and copied the vdd folder to /Test so I have /Test/vdd as my vdd directory
opened a command prompt and went to /Test/vdd
Ran vagrant up and it seemed to work.
Accessed the vm by using vagrant ssh
Changed permission on all directories to 777 (i.e. chmod -R 777 sites and I verified that all directories are 777)
The drupal7 directory did not have a setting.php file. I copied default.setting.php from default directory to the drupal7 directory and named it settings.php.
Also copied settings.php to default directory so default has both settings.php and default.settings.php

Now when I run drush @drupal7 site-install -y I get the following:

  Command site-install needs a higher bootstrap level to run - you will
  need to invoke drush from a more functional Drupal environment to run
  this command. The drush command 'site-install' could not be executed.
  The directory /var/www/drupal8 does not contain a valid Drupal
  installation

A couple of things worthy to note is that my drupal7 directory has no files other than settings.php.
I don't know if that is the way it is supposed to be.
mysql is up and running.  If I run mysql -u root -proot it connects to the db.
I am assuming apache and php are working because 192.168.44.44 returns the proper landing page.


texts: How to get the current active DB in Drupal 6?

texts:
You can easily print out the current db_name, by printing out $db_url. But there is no clear way in the API that allows you to print out the "key" for the active db. So I have two dbs, namely "testing" and "default". What php code can I run to find out whether I am currently using the "testing" db, or the "default" db?

I'm bascially looking for the inverse of "db_set_active". So If I do this:

db_set_active("default");

What can I call directly after it to find out which is the current active db (i.e. "default")?


texts: I am using https://github.com/drupal-composer/drupal-project . How to add more scripts after "create-project"?

texts:
I want to use https://github.com/drupal-composer/drupal-project to generate several customized projects.

If I want a contrib module to be available for all instances, what is the best way to get them when running "composer create-project"?

I thought to add this logic (to add contrib modules by default) in scripts/composer/ScriptHandler.php but this file doesn't seem to be suitable for customizations.

Is there an easy way to add other scripts to run on project creation?
Or which other way should I chose?


texts: Node form alter place default value for select list

texts:
I have node form for Images content type which have a taxonomy term reference field. It is a select field with the options in it. Now I am trying to place a default value for the field by checking the tid which is coming from the URL using $_GET and hook_form_FORM_ID_alter

My code is

$term = isset($_GET['term_id']) ? $_GET['term_id'] : '';
$form['field_term'][LANGUAGE_NONE]['#default_value'][] = trim($term_id);

When I print the form it gives me this:

[#default_value] => Array
 (
   [0] => 9913
 )

But it is not showing up on the form.

When I try to set the default value from the content type field settings UI it shows up and also the array structure is same. But even though via from alter the structure is same it doesn't show in the node form.

FYI have also tried out the following options:

$form['field_term'][LANGUAGE_NONE]['#default_value'] = trim($term_id);

$form['field_term'][LANGUAGE_NONE]['#default_value'] = $term_id;

$form['field_term'][LANGUAGE_NONE]['#default_value'] = $term_id;

$form['field_term'][LANGUAGE_NONE]['#value'] = $term_id;

$form['field_term'][LANGUAGE_NONE]['value'] = $term_id;


texts: How to prevent users with no relationship from viewing each others statuses stream

texts:
I have Statuses and user relationship module installed. I would like to prevent users who do not have a relationship from being able to view each others statuses stream.

It appears that by default, when a user visits any user profile, he/she is able to view the status update box and status stream of the other user irrespective of if they are "friends" or not.

I want to prevent this. I do not mind them viewing the status update box, but not the stream.

Thank you.


texts: Delete the content of a field from all the node under a specific content type

texts:
What would be  the best approach (preferably with GUI) to delete the content of certain fields from certain content types.

I am thinking of using rules but I cant configure to do it.

Ny ideas? Thanks


texts: Populate fields when a checkbox is clicked on a form

texts:
I have a regular drupal 7 form (based on a content type called guests) where I need a "Bring my partner" checkbox. When the checkbox is clicked, a field collection field (first name/last name/address) needs to be prefilled basing on the details for the currently logged-in user. (Partner details are in my user account details.)

Can this be done in hook_form_alter()? Is there any other way to achieve this?


texts:
It looks like silly question but I'm really confused about redirection after node save and update.

I tried to set $form['#redirect'] - without any success.
I tried to set some other vars for instance: $_REQUEST['destination'] or in $form['buttons']['submit']['#submit'] setting function name to call that sets $form_state['#redirect'] but none of this solution works.

Can you give me some source that explains node forms redirecting in D7?


texts: How to export comment fields (or other settings) with Features?

texts:
If I export a content type that has fields specified in the comment of the content type the fields of the comment are not exported.

How do I export those fields that I specified in the comment?

(In my case a have a Workflow status field specified in the comment)


texts:
first off I'm a beginner to Open Atrium, but am wondering if there is a simple way for all content on the site to require authenticated user permissions.

I'm building an open atrium 2 intranet and do not want anything but the login field accessible to anonymous users

I realize I can simply set the access permissions in every piece of content that is created, but this doesn't seem like a great solution.


texts: Optimize performance of custom pre-built option list to webform

texts:
I am looking to add a pre-built options list, based on a query. I crafted the function nicely with the below code

function mitacan_webform_select_options_info() {
    $items = [];
    if (function_exists('basliklariAl')) {
        $items['addresses'] = array(
            'title' => 'Stok Kodları',
            'options callback' => 'basliklariAl'
        );
    }
    return $items;
}

function basliklariAl($component, $flat, $arguments) {
    $nodes = [];
    $select = db_select('node','n')
        ->fields('n',[
            'nid',
            'title'
        ])
        ->condition('type','urun')
        ->execute()
        ->fetchAll();
    foreach($select as $n) {
        $nodes[$n->nid] = $n->title;
    }
    return $nodes;
}

This is very slow, mostly because there are about 10k records. What can I do to optimise the process?


texts: How to output plain URL to the node in Views?

texts:
I would like to output plain absolute URL of the node from Views as part of my XML feed (via Views Datasource).

So far I have found the following field handler:

  Content: Link - Provide a simple link to the content.

which is provided by Views it-self, but checking views_handler_field_node_link.inc file doesn't seems to support displaying plain text (and there are no any field formatters, as it's field specific), but instead I've got:

view

without possibility to change the format (apart of the text it-self).

Is there any other way to display just plain URL of the node using Views field handler (without having actual field)?


texts:
I am rebuilding a Drupal 7 site, making some changes to the data structure along the way. On the old site, I have a content type with an image, a description, and a couple other text fields. On the new site, I need this content to appear as images within a gallery (Media Gallery module). I also need to preserve the description field.

I'm not sure where to start. I used the Feeds module to migrate some other content types to their new versions, but that module cannot create this "Media" object, only nodes.

Thanks.


texts:
I'm working on a site which uses Apache Solr for the site search which is on the URL /search/site/.

What I want to do is add a form to every page on the site which allows the user to entered text in & submit it. The form will then take the user to the /search/site/ page displaying the results for their search term.

This sounds like it should be simple but I cannot see how to do it, I cannot find a way of creating a block for it & when I try to use the code below to programmatically display the form it is presented to the user but when submitted they are taken to the correct page (/search/site/) but the results of their search are not displayed.

$search_form = drupal_get_form('search_form');
$search_form_box = drupal_render($search_form);
print $search_form_box;
print render(drupal_get_form('search_form'));

I wasn't 100% sure that "search_form" was correct but when submitted it does take you to the correct search results page (/search/site/) but no terms or results are displayed.

I'm quite new to using Drupal & Solr so if there's any information you need that I missed out please ask.


texts: How to write options lists with drush vset?

texts:
When we want to pin a variable for an environment, we'll set the value in the admin, then go look it up in the database, and copy the name and value into a bash or phing script, to insure that that variable is always set to the appropriate value for the environment.

However, for complex variables, such as options lists, what should set string look like?   For example node_export_file_types looks like this in the database:

a:29:{s:4:"blog";s:4:"blog";s:10:"case_study";s:10:"case_study";s:7:"analyst";i:0;s:5:"asset";i:0;s:4:"book";i:0;s:6:"course";i:0;s:8:"download";i:0;s:8:"employee";i:0;s:19:"evaluation_download";i:0;s:4:"news";i:0;s:17:"front_page_header";i:0;s:11:"hero_banner";i:0;s:12:"landing_page";i:0;s:11:"layout_page";i:0;s:10:"news_event";i:0;s:10:"news_press";i:0;s:7:"product";i:0;s:16:"product_overview";i:0;s:17:"product_resources";i:0;s:15:"product_webinar";i:0;s:8:"workshop";i:0;s:12:"registration";i:0;s:8:"resource";i:0;s:7:"license";i:0;s:7:"support";i:0;s:16:"training_courses";i:0;s:16:"training_request";i:0;s:17:"training_webinars";i:0;s:7:"webform";i:0;}

if we wanted to set that using
drush vset node_export_file_types 'somestring'
what that 'somestring' look like?


texts:
I am using the 7.x-3.0 version of Bootstrap and have sub themed it. I want to change wrapped div, add 'input-group-sm' to the class bit I can't not figure out how to override it. if I add search-block-form.tpl.php to my sub theme I can access and alter that but the code I need is in bootstrap-search-form-wrapper-func.php I have copied that to my sub theme with no success. I have tried replicating the same file structure as Bootstrap 'mytheme/theme/bootstrap/bootstrap-search-form-wrapper.func.php', I have tried putting just in my templates dir.

My last attempt was trying to follow the instructions on theme registry alters: https://www.drupal.org/node/2224003 which I have as this:

function CFbootstrap_theme(&$existing, $type, $theme, $path) {
  $hooks['CFbootstrap_hook'] = array(
    'CFbootstrap_search_form_wrapper' => array(
      'render element' => 'element',
    ),
  );

  bootstrap_hook_theme_complete($existing, $theme, $path . '/theme');
  return $hooks;
}

Nothing works, what I am doing wrong? How do I override this *.func.php?


texts: Checking whether or not an unpublished comment exists on node for current user

texts:
I'd like to be able to let a user know that their comment has been submitted and is awaiting approval on every view of that particular node, not just a notification printed in the message region immediately after a submission.  I assume there's a way to cross-check the current node's unpublished comments and print something in the comment area if the user shows up as an author of an unpublished comment.  I have a feeling I can write a simple function, something like below, but I'm missing something and I'm not sure where to run it (ie, in the .tpl or in an .inc):

function find_unpublished_comments_of_current_user(&$comment, &$user) {
    if ($comment->status == 0 && $user->id == $comment->uid){
      //something here
      }
}

Thanks for any help.


texts: How to enable maintenance mode only when there are no active users?

texts:
When there are updates available for Drupal, I enable the maintenance mode, update, and disable the maintenance mode again.

As far as I understand it, users that were right in the middle of editing a node or checking out their shopping cart would lose their content/progress because of the maintenance break.

One solution could be to notify all online users that they should save their content, however, this would not work for users that are checking out right now (e.g., filling in the shipping data or being in the payment process).

Ideally, when trying to enable the maintenance mode, Drupal should warn me that users are currently active on the site.

Is this possible? Can Drupal detect that someone (be it a registered or an anonymous user) is "active", even if the user might have been afk/inactive for some time (e.g., searching for the credit card)? Possible indications could be: opened a node edit form but no submission or further request detected; started but not finished the checkout; added products to the cart without checking out; etc.

If yes, how could I achieve this? I’m not experienced enough to write this from scratch, so hopefully this doesn’t involve creating a totally new module. Does there exist a module for this purpose?


texts: simple math using field values inside views and global php

texts:
I am looking for a simple way to make an average or sum of values using views. The values are numeric cck fields. I tried views calc but I don't like the table output. I need just a single number output. If average function does not work inside views 2, I am ok with simple sum of values. I can then use the sum value/number of occurences to get the average. It would be probably best to use global php field or views template files.
I can use some help regarding the code. I would probably start with:

<?php
foreach ($fields as [myfieldname] => $fielddata) {
///put the mat function inside here?
print $fieldname ;
}

Any help with code would be appreciated. Thank you

EDIT: I would go with using global php field since it does not need to create custom template file. The view is very simple - just pulling the numeric cck field values from nodes. Filter set to nodetype called review.


texts: Postgres errors with Metatag module in combination with Drag and Drop File upload

texts:
After having migrated from a MySQL 5.5 to a Postgres 9.3 Database I encounter some issues in a Drupal OpenOutreach installation. I have a content type with a Drag & Drop Upload field to display images. Whenever I try to save the new content, I receive the following error caused by the Metatag module:

PDOException: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block: SELECT language, '' FROM {metatag} WHERE (entity_type = :type) AND (entity_id = :id) AND (revision_id = :revision); Array ( [:type] => file [:id] => 206 [:revision] => 0 ) in metatag_metatags_save() (line 518 of <drupal-instance>/var/www/arsleonis/profiles/openoutreach/modules/contrib/metatag/metatag.module)

It is the following function causing the error:

  // Handle scenarios where the metatags are completely empty.
if (empty($metatags)) {
$metatags = array();
// Add an empty array record for each language.
$languages = db_query("SELECT language, ''
    FROM {metatag}
    WHERE (entity_type = :type)
    AND (entity_id = :id)
    AND (revision_id = :revision)",
  array(
    ':type'     => $entity_type,
    ':id'       => $entity_id,
    ':revision' => $revision_id,
  ))->fetchAllKeyed();
foreach ($languages as $oldlang => $empty) {
  $metatags[$oldlang] = array();
 }
}

On MySQL everything worked out properly and so does it on a clean (new) install with a Postgres DB (chosen from the beginning).

I have already tried installing a different version of the modules, but this showed no results. Unfortunately I don't even know where to look for what's causing this error.


texts: How to prepare renderable array for images that are not stored in public or private filesystem, but are delivered statically with module?

texts:
I have a piece of code that prepares renderable array for my images:

if( !empty($row['image_file_id'])) {
  $row['thumbnail'] = array(
    '#theme' => 'image_style',
    '#path' => _mymodule_uri_by_id((integer)$row['image_file_id']),
    '#style_name' => 'product_thumbnail_small',
    '#attributes' => array(
      'alt' => $row['image_alt'],
      'title' => $row['image_title'],
    ),
  );
}

It works OK:

But I want to add else with image provided within a module. I still want this image to go thorough all image style processing etc. I want my theming colleagues to be able to simply not care if they'll ever decide to add some effects or change resolution. But of course this image is in module directory, not in public://. And it means this will not work:

else {
  $row['thumbnail'] = array(
    '#theme' => 'image_style',
    '#path' => drupal_get_path('module', 'mymodule') . '/frontend/noimage.png',
    '#style_name' => 'product_thumbnail_small',
    '#attributes' => array(
      'alt' => 'some universal stub',
      'title' => 'some universal stub',
    ),
  );
}

It gives:

And browser tries to read that image from http://example.com/sites/default/files/styles/product_thumbnail_small/public//sites/default/modules/mymodule/frontend/noimage.png?itok=-yYlM4ns

This gives nothing (status reports says "access denied"), unless I manually place image in public://sites/default/modules/mymodule/frontend - but I don't want it to be in public file system, I want it to stay in module space. How can I make it work?


texts: How to hide poll results to not-admin users after voting

texts:
I'm building a voting system for an election in a Drupal 8 website.
I'm using a combination of Poll, Advanced Poll, and Voting API; also, I created a view page which displays the list of open polls.
As settings, I decided to disable the Allow view results, but this indicates whether users may see the results before voting, since I would like to make the results hidden until the polls are over.
Is there a way to accomplish this? I've already looked into the Advanced Poll and Poll issues, but I couldn't find anything related to this matter.


texts: Form is not being rendered in template file

texts:
I have tried drupal_render,drupal_get_form etc for rendering the form,but the form is not being rendered. Is there any error in code or else what else should i add to the code so that it works.

function questionnaire_template_form($form, &$form_state, $question) {
 print_r("in template function");

 $form_build = unserialize($question->criteria_data);

 foreach ($form_build as $key => $value) {

  $options = ($form_build[$key]['1']);
   $list = explode("\n", $options);

   $list = array_map('trim', $list);

   $list = array_filter($list, 'strlen');

   foreach ($list as $key => $value) {

    $new = explode('|',$value);
    $new_key = reset($new);
    $new_value = end($new);
    $new_list = array($new_key => $new_value);
    dsm($new_list);
   }
dsm('next');

   $fb = explode("_",$key);
   $type =reset($fb);

  if($type == 'radio') {

    if($form_build[$key]['0']) {
      $form['radio_form'] = array(
        '#type' => 'radios',
        '#options' => $list,
      );
    }
  }
   elseif($type == 'checkbox') {
    if($form_build[$key]['0']) {
     $form['checkbox_form'] = array(
       '#type' => 'checkboxes',
       '#options' => $list,
      );
    }
   }
   elseif($type == 'selectlist') {
    if($form_build[$key]['0']) {
      $form['selectlist_form'] = array(
        '#type' => 'select',
        '#options' => $list,
        );
   }
  }

}
return $form;
}

Above code is my form.

<?php
//print_r($variables['entity']->qid);?>
<?php
print_r($variables['entity']->title);?>
<?php
print_r($variables['entity']->text);?>
<?php
?>
<?php
?>
<?php
if($variables['entity']->criteria) {
  ?>
<?php
  $form_template = drupal_get_form('questionnaire_template_form' , $variables['entity']);
  print(drupal_render($form_template));

}
?>
<?php

print_r(l( t("Yes"), 'questionnaire/' . $variables['entity']->yes_quid));?>
<?php
print_r(l( t("No"), 'questionnaire/' . $variables['entity']->no_quid));?>
<?php

?>

And this is the template where I am rendering the form.
I am getting the form if I dsm the form


texts: how to disable and delete correctly the boost module

texts:
in the last days Im having serious problems with the module boost, for some reason it is not loading the Javascript files, and CSS files. My site looks horrible for anonymous users its not loading the slider, but if I log in as admin then the site is displayed correctly, also after logout the site works correctly, but after clear browser's chache the sites looks horrible again

this is the errors that the console of Chrome shows me

Im almost sure that this problems are coused by the boost module, I need to reset it, or uninstall it, but need to know the correct steps for delete all the traces of this module that its causing me problems. Thank you


texts: I tried to follow the instructions for custom newsletter theme and it told me to copy and paste simplenews-newsletter-body.html.twig into my custom theme folder. But on sending test emails it doesnt render the changes that I have made in the file thats in my custom theme folder.


texts: Form API + Module: Nested default value variable_get doesnt behave the same as unnested variable_get

texts:
Heres the example code:

function mymodule_form($form, &$form_state){
    $form['nest'] = array(
        '#type' => 'fieldset',
        '#title' => t('Nested settings'),
        '#tree' => TRUE,
    );

    $form['nest']['nested_example_item'] = array(
        '#type' => 'textfield',
        '#title' => t('Nested Example Item'),
        '#default_value' => variable_get('nested_example_item', 'example value 1'),
        '#size' => 60,
        '#maxlength' => 128,
        '#description' => t('Nested Example Item'),
    );

    $form['unnested_example_item'] = array(
        '#type' => 'textfield',
        '#title' => t('Unnested Example Item'),
        '#default_value' => variable_get('unnested_example_item', 'example value 2'),
        '#size' => 60,
        '#maxlength' => 128,
        '#description' => t('Unnested Example Item'),
    );

    return system_settings_form($form);    }

Now what happens when i change both values and submit the form is the following:

The unnested field behaves like expected - it reflects the changes.
The nested field item, does not show this behaviour, does not reflect the changes

I am confused, should I treat the nested variable_get differently?


texts: Display Suite ignores hook_preprocess_node()

texts:
It seems like the Display Suite module completely ignores hook_preprocess_node() and hook_process_node(). Is this the case?

If it is so, what is the way to make minor changes to the final rendering with access to all the node variables?


texts: Get data and uploaded files from android (mobile) version of website

texts:
I built a website and it works well in browser. We need to create android version of this website, and in this version users must be able to log in to the site and upload images in their profile.

I really have no idea how Drupal does this and how can I let that android software to connect to my website, upload images and data. I would be appreciated for any help.

thanks.


texts: Dynamic value in Twig or preprocess based on config and getHost()

texts:
I need to dynamically change a value in Twig templates by selecting a configuration value (defined in a custom module) based on the current environment.
I did the following in a Form class, which works fine:
  /**
   * Generate parent site Base URL per environment.
   *
   * @return string
   *   The parent site Base URL used in all templates site-wide.
   */
  public function getBaseUrl() {
    $host = $this->requestStack->getCurrentRequest()->getHost();
    $config = $this->configFactory->get('clientname_cta_base.settings');
    switch ($host) {
      case 'resources.clientname.com':
        // Set $base_url to Production environment.
        $base_url = $config->get('prod_base_url') ?? [];
        break;
      case 'uatresources.clientname.com':
        // Set $base_url to UAT environment.
        $base_url = $config->get('uat_base_url') ?? [];
        break;
      case 'qaresources.agencyname.com':
      case 'qaresources.clientname.com':
        // Set $base_url to QA environment.
        $base_url = $config->get('qa_base_url') ?? [];
        break;
      default:
        // All other environments, including local, link to Dev.
        $base_url = $config->get('dev_base_url') ?? [];
        break;
    }
    return $base_url;
  }
  /**
   * Generate CTA destination URL per environment.
   *
   * @return string
   *   The CTA destination URL used in all templates site-wide.
   */
  public function getCtaUrl() {
    $config = $this->configFactory->get('clientname_cta_base.settings');
    $cta_url = $this->getBaseUrl() . $config->get('default_link_dest') ?? [];
    return $cta_url;
  }

This displays the desired URL paths in two disabled fields when the SettingsForm is loaded:
    // Active URL configuration (read-only).
    $form['clientname_cta_base_computed_base_url'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Computed base URL (Preview)'),
      '#default_value' => $this->getBaseUrl(),
      '#description' => $this->t('Read-only value based on config and environment. Save changes to update.'),
      '#attributes' => ['disabled' => 'disabled'],
    ];
    $form['clientname_cta_base_computed_cta_url'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Computed CTA URL (Preview)'),
      '#default_value' => $this->getCtaUrl(),
      '#description' => $this->t('Read-only value based on config and environment. Save changes to update.'),
      '#attributes' => ['disabled' => 'disabled'],
    ];

I could even store these updated values in configuration when the SettingsForm is submitted -- but that will not quite get me what I want.
These values need to be computed dynamically by selecting config based on the value of $host at runtime -- importing the Dev environment's computed config values to the QA environment won't do. So I am looking for a way to call the module's public methods (getBaseUrl() and getCtaUrl()) in either theme preprocess or Twig templates.
Is this approach possible? Should I have used theme settings instead?


texts: Help with JQuery Toggle Div, Start in Hidden State

texts:
Alright, this has been driving me insane for all too long. I'm trying to toggle a div, but start it in a hidden state. Suggestions on how to modify the following?

// Drupal 7 js code
(function ($) {
Drupal.behaviors.togg = {
attach: function (context, settings) {
$('a#togg-link:not(.togg-processed)', context).addClass('togg-
processed').each(function() {
$(this).click(function() {
$("div#togg").toggle(400);
return false;
});
});
}
};
})(jQuery);


texts: Drupal Search API Placeholder && Front Page?

texts:
I'm trying to get some placeholder text working for the Search API form, but have a different placeholder on the front page. Here's what I have so far which does work everywhere...

function THEME_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['search_api_views_fulltext'])) {
    $form['search_api_views_fulltext']['#attributes']['placeholder'] = t('Search Text here...');
  }
}

How can I get this working on only the front page, with a different placeholder text on all other pages? I've tried many things and totally stumped at the moment. Any help would be appreciated.


texts: Views pager shows an incorrect current page

texts:
I have a page view displaying a table of fields with a few exposed filters.  This page view also has a full pager (8 items per page). The view is not using AJAX, nor does it have any caching enabled (currently).

When on the view page, using the pager to navigate to specific pages, or next/last page works fine (since the pager adds the "?page=N" query argument).  However, the issue I am experiencing is that if I try to navigate from any other page back to page 1 (so the view does not pass "?page=" as an argument), the pager is "stuck" displaying the last page I was on as the current page. The results listed are correct (displays the results for page 1), it is just the pager is displaying the wrong page as selected.

On the first page of results, I click on the pager link to go to page 3; page reloads with results of page 3, and the pager shows page 3 as current page. I then click on the pager link to go to "<< first". The page reloads with the results of page 1; however, the pager still shows page 3 as the current page.

A few more details, I am using a custom theme with custom CSS to style the pager (but css should not interfere with the pager). I am not altering the pager at all in my template.php, nor do I have a custom pager.tpl.php.

Has anyone experienced this issue? I am not sure if it is specific to a views pager, or just the Drupal pager in general. I have no idea what could be causing the problem.

I am using Drupal 7.21 and Views 7.x-3.7.


texts: drush omega-guard and missing or unreadable gemfiles

texts:
My machine is running Archlinux and and I am new in drush and omega theme.
I have installed drush and then run bundle install to install the dependencies of my subtheme.
When I run drush omega-guard, I get some errors which says the file to import not found or unreadable, while I have installed those gems too.

[timmy@MyPC drupal-7.31]$ drush omega-guard
Which theme do you want to run Guard for?
 [0]  :  Cancel
 [1]  :  First (Subtheme of Omega) - My first theme.
 [2]  :  Ohm (Subtheme of Omega) - Omega based demonstration theme. Serves as a best-practice reference for the Omega documentation. Ohm
         will be constantly updated as best practice evolves so shouldnt be used in production.
 [3]  :  Omega - A powerful HTML5 base theme framework utilizing tools like Sass, Compass, Grunt, Bower, Ruby Version Manager, Bundler and
         more.
1
/home/timmy/.gem/ruby/2.1.0/gems/bundler-1.7.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/timmy in PATH, mode 040777
/home/timmy/.gem/ruby/2.1.0/gems/bundler-1.7.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/timmy in PATH, mode 040777
/home/timmy/.gem/ruby/2.1.0/gems/bundler-1.7.2/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /home/timmy in PATH, mode 040777
    error sass/first.no-query.scss (Line 3 of sass/first.styles.scss: File to import not found or unreadable: breakpoint.
Load paths:
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  Compass::SpriteImporter
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-core-1.0.1/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/susy-2.1.3/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-normalize-1.5/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/compass-rgbapng-0.2.1/lib/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/toolkit-2.6.0/stylesheets
  Sass::Globbing::Importer)
    error sass/first.normalize.scss (Line 8: File to import not found or unreadable: toolkit/border-box.
Load paths:
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  Compass::SpriteImporter
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-core-1.0.1/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/susy-2.1.3/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-normalize-1.5/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/compass-rgbapng-0.2.1/lib/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/toolkit-2.6.0/stylesheets
  Sass::Globbing::Importer)
    error sass/first.styles.scss (Line 3: File to import not found or unreadable: breakpoint.
Load paths:
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  Compass::SpriteImporter
  /srv/http/drupal-7.31/sites/all/themes/first/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-core-1.0.1/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/susy-2.1.3/sass
  /usr/lib/ruby/gems/2.1.0/gems/compass-normalize-1.5/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/compass-rgbapng-0.2.1/lib/stylesheets
  /usr/lib/ruby/gems/2.1.0/gems/toolkit-2.6.0/stylesheets
  Sass::Globbing::Importer)
Compilation failed in 3 files.

07:11:22 - INFO - Guard::Compass is waiting to compile your stylesheets.
07:11:22 - INFO - LiveReload is waiting for a browser to connect.
07:11:22 - INFO - Guard is now watching at '/srv/http/drupal-7.31/sites/all/themes/first'
[1] guard(main)> help


texts:
I have created fields deleted them. Tables for the fields are gone upon deletion, but they are still in field_config and field_config_instance

Is there anyway to clean them?

Thanks


texts: Specifying display of a new Paragraph type with images using HTML/twig?

texts:
I created "figure" Paragraphs type, which contains an image field and a caption field. How (from start to finish) do I specify in HTML/twig how to render this new Paragraphs type?

As an example, how would I specify that the output would generate following code?

caption


texts:
I want to run Drush on a OpenSuse Linux Version 12.1 box 32-bit machine.
I have a server admininistrator that takes care for the backend.

What do I need to ask him, in order to get Drush running on the server?


texts: As the title says, I'm looking for a way to show the node comments in teaser. Anybody knows how to do?


texts:
I use drush site aliases and drush sql-sync as part of my daily workflow between my local development environment and my company's production/staging servers (Acquia dev cloud). This works great for single site instances, but I haven't been able to get it to work with multisites.

Example site structure for my @remote alias:

@remote
  - default.com ``drush @remote`` <-- commands not targeted with `-l` execute here
  - sitename.com ``drush @remote -l sitename.com status``
  - foobar.com ``drush @remote -l foobar.com sql-connect``

For other drush commands, I can target the multisite that I want use the -l switch to specify a particular multisite, and I get the correct output for drush status and drush sql-connect (correct URI and Database name).

However, when I try to use -l with drush sql-sync, it just targets the root site, no matter what. I can get around this by manually dumping the database and doing drush sql-cli @remote -l multisite.com < db.sql, but it's not half as quick as just doing drush sql-sync @local -l sitename.com @drush.remote -l sitename.com

I can open up a drush issue queue if this is a bug, but I'm wanted to check and see if I was doing something wrong first. Thanks!


texts: Automatically block user that access /wp-login.php

texts:
Is it possible to block any users IP if they try to access a specific URL such as /wp-login.php page which does not exist on Drupal.

Basically to automatically blacklist the user, for days or even forever.

Trying to implement this as a security measure. For those who are looking for ways to hack the site.


texts: How to download directly to ~/.drush folder?

texts:
I've created a project that is basically a drush command with a starterkit folder. I noticed the make_local project will but I haven't figured out how it does that.

I've tried the approach recommended in the answers and added a .info file and tried to hide the .profile extension by renaming it to .profile.starterkit.  Drush still thinks I'm downloading a theme.


texts:
I have a form which provides select2 when the select1 is changed. However I would like select2 to be a multi-select. I can't seem to get this to work. It populates a single select input just fine, but not the multi-select. Any tips would be appreciated.

public function buildForm(array $form, FormStateInterface $form_state, $options = NULL) {
  $form['expeditions'] = [
    '#type' => 'select',
    '#title' => $this->t('Choose Project'),
    '#empty_option' => $this->t('Select a project'),
    '#default_value' => '',
    '#options' => $options,
    '#ajax' => [
      'callback' => '::getDeployments',
      'wrapper' => 'deployment-wrapper',
    ],
  ];

  // Disable caching on this form.
  $form_state->setCached(FALSE);

  $form['deployment_wrapper'] = [
    '#type' => 'container',
    '#attributes' => ['id' => 'deployment-wrapper'],
  ];

  return parent::buildForm($form, $form_state);
}

public function getDeployments(array &$form, FormStateInterface $form_state) {
  $expedition_id = $form_state->getValue('expeditions');
  if ($expedition_id != "") {
    $arms_config = \Drupal::config('arms.settings');
    $rest_root = $arms_config->get("arms_rest_uri");

    $client = \Drupal::service('http_client');
    try {
      $result = $client->get(
        $rest_root . 'arms/projects/' . $expedition_id,
        ['Accept' => 'application/json']
      );
      $expedition = json_decode($result->getBody());
    }
    catch (RequestException $e) {
      watchdog_exception('arms', $e);
      drupal_set_message('Error fetching project.', 'error');
    }
  }

  $options = [];

  foreach ($expedition->{'deployments'} as $deployment_id) {
    array_push($options, $deployment_id);
  }

  $form['deployment_wrapper']['deployments'] = [
    '#type' => 'select',
    '#title' => $this->t('Choose Deployment(s)'),
    '#options' => $options,
    '#multiple' => TRUE,
  ];

  return $form['deployment_wrapper'];
}


texts: #states not detecting a change to form via ajax_command_invoke

texts:
I have a form. On an elements I have an ajax call back.
In the callback I use the commands[] to update some elements on the screen.
One of the elements i have updated is used by another form element using the #states. When the ajax call is executed the first time the #states sees that the value has changed and updates.

When I call the ajax event for a second time the #states does not see the same.
One my ajax_commands is invoking the jQuery change().

I have an alert() being thrown when the element is changed and can see that it is being hit every time. However the #states is not updating.

Is there a way to get #states for the form to reevaluate from JavaScript?


texts: Fatal memory Error at the bottom of the page but not WSD. What this means?

texts:
I occasionally get the following error showing at the bottom of some pages when I'm logged in as Admin. I have seen this error before when the server didn't have enough php memory. But then always the page was WSD.

However I don't get WSD with the php memory error message I'm getting now.
It's just showing at the bottom of the page and the page itself works as usual.
What is the difference between this one and the one we get on WSD?
Can I just ignore it?

Fatal error: Out of memory (allocated 175112192) (tried to allocate 7015932 bytes) in  /public_html/includes/database.inc on line 225


texts:
I have issues autoloading classes found in subfolders of my module with xautoload.

my module is called myentity

Here is my hook_entity_info

function myentity_entity_info() {
    $return['myentity'] = array(
        'label' => t('My entity'),
// The entity class and controller class extend the classes provided by the
// Entity API
        'entity class' => 'Drupal/myentity/class/MyEntity',
        'controller class' => 'Drupal/myentity/controller/MyEntityController',
        'base table' => 'myentity',
        'fieldable' => TRUE,
        'entity keys' => array(
            'id' => 'me_id',
            ),
        'bundles' => array(
        'myentity' => array(
            'label' => 'myentity',
        // Information below is used by the Field UI - they "attach" themselves here and lets us
        // do the standard field management that all the core entities enjoy.
            'admin' => array(
                'path' => 'admin/structure/myentity/manage',
                'access arguments' => array('administer myentity'),
                ),
            ),
        ),
    'label callback' => 'entity_class_label',
    'uri callback' => 'entity_class_uri',
    'module' => 'myentity',
    'view modes' => array(
        'full' => array(
            'label' => t('Default'),
            'custom settings' => FALSE,
        ),
        'teaser' => array(
            'label' => t('Teaser'),
            'custom settings' => FALSE,
        ),
    ),
    'metatags' => TRUE,
);

return $return;
}

My class and controller are found in

sites\all\modules\myentity\lib\Drupal\class\MyEntity.php

with the following content

<?php

namespace Drupal\myentity\class\MyEntity;

/**
 * The class used for model entities
 */
class MyEntity extends Entity {

    public function __construct($values = array()) {
        parent::__construct($values, 'myentity');
    }

    protected function defaultLabel() {
        return $this->name;
    }

    protected function defaultUri() {
        return array('path' => 'myentity/' . $this->identifier());
    }

}

and

sites\all\modules\myentity\lib\Drupal\controller\MyEntityController.php


texts: How to get the super user in a functional test?

texts:
How can I get the information for the super user (uid 1) in a functional test?

I want to test the external auth logic I have written, and one of the steps is authenticating the Drupal superuser locally instead of in the remote system. I am not seeing a way to get the username/password of that user in order to simulate a login.

Test:

  /**
   * The superuser should not authenticate to Netforum.
   */
  public function testSuperUserUsesDrupalAuthentication() {
    $this->drupalGet('user/login');
    $edit = ['name' => $this->rootUser->getEmail(), 'pass' => $this->rootUser->pass_raw];
    $this->drupalPostForm(NULL, $edit, t('Log in'));

    $user = \Drupal::currentUser();
    $this->assertEquals(1, $user->id());
  }


texts: Getting an error on field module when saving a node

texts:
When I'm saving a node using node_save, I'm getting the following fatal error:

Fatal error: Maximum execution time of 30 seconds exceeded in /data/www/www.example.com/htdocs/modules/field/field.attach.inc on line 664

This is not happening every time node_save is called, only for a certain new node and I can't find anything strange about the fields I'm populating. Any clue?


texts: Access Denied even if permission is given

texts:
I have this module, as admin users I can access this module normally. But when I add permission to other roles (and it saved), other users who have the permimssion couldn't access it. Please help me.

This is the code.

include_once(drupal_get_path('module', 'tb') .'/tb.menu.inc');
include_once(drupal_get_path('module', 'tb') .'/tb.inc');

function tb_perm() {
  global $user;
  return array('trial_balance');
}

function tb_menu() {
  global $user;
  $items = array();

  $items['akuntansi/tb'] = array(
    'title' => 'Trial Balance',
  'type' => MENU_NORMAL_ITEM,
    'page callback' => 'tb_neracapage',
    'file' => 'tb.inc',
    'access arguments' => array('akuntansi'),
    'access callback' => TRUE,
    //'type' => MENU_CALLBACK,
  );

  $items['akuntansi/tb/pdf'] = array(
    'page callback' => 'tb_neracapage_pdf',
    'file' => 'tb.inc',
    'access arguments' => array('akuntansi'),
    'type' => MENU_CALLBACK,
  );
$items['akuntansi/tb/xls'] = array(
    'page callback' => 'tb_neracapage_xls',
    'file' => 'tb.inc',
    'access arguments' => array('akuntansi'),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

?>


texts:
hi i have a site in which i want to show items, now i want to be able to filter the items based on several paramaters (*note the parameters aren't related to one another which is why dependency filter module isnt the solution.)

what i want to do is the user can choose a value and filter the results by it, then the remaining filters and filter values would only be ones that have items remaining that fit the criteria.

an example if the items are computer screens and i have 3 attributes - color, width, company
then if a user chooses hp for company and they only have white screens then i will only see white as an option in the color filter.
if i choose dell and they have black and white then both colors will show on the filter.

is there a module that achives this affect, if not is there a way for me to do it myself (im pretty new to drupal i understand what hooks are but not to familiar with them and never developed a module).


texts: What are the major differences between Drush versions 3 & 4?

texts: What are some of the biggest differences between Drush versions 3.x & 4.x?


texts: Help me write a Rule condition and action to remove discount line item and to add payment

texts:
I am trying to write a rule for an existing order.
Order has a zero total due to (Commerce) discount, e.g.:
Widget $3.00
Discount -$3.00

For the condition, I'd like to check if a specific discount is applied.
For the action, I'd like to:

delete the discount line item (-$3.00)
add (specific) existing check payment method with the total before discount ($3.00)
Perform "cash" / cleared operation on the payment method.

So far I only managed to do step 1. by using the commerce_coupon_rules_order_has_specific_coupon.patch that looks for a specific coupon - which works but ideally condition that looks for a discount would be preferable. I wasn't able to do any of step 2 and 3 operations.

Here is the export of the rule I tried:

{ "commerce_checkout_update_the_order_payment_on_admin_orders" : {
    "LABEL" : "Update the order payment on Admin orders",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "commerce_coupon", "rules", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "commerce_coupon_discount_coupon_codes_exist_on_order" : {
          "commerce_order" : [ "commerce_order" ],
          "commerce_discount" : "discount_admin_only_prepaid_by_check"
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : "user@example.com",
          "subject" : "test",
          "message" : "test",
          "language" : [ "" ]
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "prepaid_by_check" : "prepaid_by_check" },
          "DO" : [
            { "component_rules_remove_prepaid_by_check_line_item" : {
                "prepaid_by_check" : "prepaid_by_check",
                "order" : [ "commerce-order" ]
              }
            }
          ]
        }
      }
    ]
  }
}


texts: Why is the Media module ignoring view_mode display settings?

texts:
I'm using the Media module 7.x-2.

I've added an image field to a content type, and I've enabled the Media CKEditor/Wysiwyg plug in and filter.
I've added fields to the image media/file type and set these up to display for the 'large' view mode setting.
When using the field, the image is displayed along with the other fields, as normal, but when I've inserted the image via Wysiwyg, only the image comes through; the fields are not displayed.

Why is this happening?


texts: When ever user comes to my website he should be greeted by a pop up or normal login page only. When he logs in whole website should open up to him. SO how do i do this ?


texts: In /admin/config/media/responsive-image-style. I created a responsive image style. The breakpoints group is bartik so now I have 3 breakpoints. Wide, Narrow and Mobile. I want to use a new image style I created called small, its 80x80 scaled pixels. I set all 3 breakpoints to use small. But in Mobile I want the image to stretch a little maybe have it go from 120 wide to 80 wide. Is this possible? Does that make sense? If I select multiple image style under small this field appears Enter the value for the sizes attribute, for example: (min-width:700px) 700px, 100vw. What does this mean and where can I find some format examples?


texts:
I've a view with a page display on url "progetti".

On my controller I'm trying to create a link to this url but I can't find the right way. I've added \Drupal\Core\Url namespace on top of the file.

I'm creating an items list:

$url = Url::fromRoute('progetti');
$variables['items'][]['value'] = array(
  '#type' => 'link',
  '#title' => array('#value' => 'sergio'),
  '#url' => $url,
);

It doesn't work, also if I use "/progetti" as argument.

Logs say:

PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "progetti" does not exist."


texts: Unable to use a hyphen in a Drupal 7 text field

texts:
I've got a simple field of type "text", widget = "text field" (Drupal 7).

I am able to use special characters like &(%, but when I try to type a hyphen, there is no result. I can use a rich text field, but I only want plain text.

I am able to use the ASCII code like S&#45;26 where I really just want S-26.

This was not an issue in Drupal 6.

Thanks very much!


texts: Translate website with prefix URL when everything is on domain

texts:
The website I'm working on has multiple languages and the detection is based on domain name.

I want to add another language, available only to developers, but do not have a domain name for it now. So I would like to know if it is possible for ONE language to be found via prefix, an example structure would be:

http://www.a.com (french)
http://www.b.com (english)
http://www.a.com/ru/ (russian)

Thanks.


texts: How to get a field value of custom block?

texts:
I have a custom block type, called "Features block". I added a field as alternative title (field_block_alt_title is that machine name).

I would like to display this alternative title on frontpage programmatically.

Now, I have this code so far that is displaying the title of blocks:

<?php

use Drupal\Component\Utility\Html;
use Drupal\Core\Render\Element;

function neft_preprocess_region(&$variables) {
  if ($variables['region'] == 'flick') {
    $titles = array();
    $ids = array();
    $block_ids = Element::children($variables['elements']);
    foreach ($block_ids as $block_id) {
      $block_title = Drupal\block\Entity\Block::load($block_id)->label();
      $titles[] =  Html::escape($block_title);
      $ids[] = 'block-' . Html::getUniqueId($block_id);
    }
    if (count($titles) && count($ids)) {
      $tabs = '
';
      foreach ($titles as $key => $title) {
        $tabs .= "
$title
";
      }
      $tabs .= '
';
      $variables['tabs'] = $tabs;
    }
  }
}


texts: How to add a custom display field to a content type in Drupal 6

texts:
Hi i am trying to add a custom field to a content type which would be un editable. And view able.

A php code to do some database access and prepare a xml file.

call a Swf animation will.

When user wants to post a content of the type he will give all the information in the form except this field, but once he submits it the info he entered will be hidden and this swf animation will show the data from xml.

Is there any way/ module which allows to add a extra display field? and module which executes a php code upon viewing the node.


texts: Create each forum with different custom fields

texts: I am using Advance forums module and I am trying to have each forum with different custom fields. I created a new content type and non-forum taxonomy terms. My question is how to display taxonomy terms in forums container since they are not treated as forum vocabulary terms.


texts: How to programmatically update node title?

texts:
I would like to programmatically update some fields including the title of a node, when this node is saved.
To do so I am using a hook

function MY_MODULE_node_update($node) {
    $node->title = "Something new an beautiful";
    $node->filed_what_ever = "Something";
    field_attach_update('node', $node);
}

The problem is, that the title is not updated, I assume, that's because of the fact it isn't a field an the Drupal sense.
But I can not use

node_save($node);

instead, because that brings me in an infinite loop: the function hook_node_update() is called by the function node_save()... So what would be a clean why to do this?


texts: Default File Display is Using Incorrect Image Style

texts:
I'm using Media-7.x-2.0-beta1. When adding an image with the default file display (default file display is identical to Original), it uses the "Medium" thumbnail display. I've checked to make sure the default is not configured to this display.

Where would these settings be saved that I could double check to make sure they were actually changed when I altered them? Is there any other reason for the Default display to be displaying the image in the wrong image style?


texts: Create a public profile page for specific roles only

texts:
Here is what I am trying to do.

I used profile2 to create an employee profile type that only users with the user role of employee could fill out.

What I want to do with views ( which I am not even sure if its possible) is have views create a profile page for each employee with a path of about-us/[user:full-name] (a field I created for the employee profile) and only create it for employee user.

Any help would be appreciated, thanks.


texts:
I want to update my theme settings. So that i can use it in one of my templates. ( page.html.twig )

Do i need to uninstall my theme every time when i need a new setting?

There must be a way to update my settings so that i can use it right away.

My question : How to import my theme settings immediately?

My settings/configuration are in the config/install directory

Here is an example :

header_title_enabled: true
header_slogan_enabled: true

I want to use this settings in an template like so :

{{ header_title_enabled }}
{{ dump(header_title_enabled) }}

{% include directory ~ '/partials/header.html.twig' %}

{{ page.content }}

{% include directory ~ '/partials/footer.html.twig' %}


texts: Media player for Drupal 7 that can play remote http-accessible files

texts:
I'm looking for a simple module for Drupal 7 to be able to have an embedded player that can play files that are stored on a different server and that is accessible via this URL:

http://[servername]/WebPlay/MCWS/v1/File/GetFile?File=[FileID]

(where [servername] is not a drupal site)

I think that file formats may vary, but should be the common ones (mkv, avi or flv containers).

Ideally the player should be able to play remote audio and locally (i.e. inside drupal) stored audio\video as well.

Note that the URL to be played (the one above) is stored in Drupal in a Token Field, but if needed by the player I can try and store it in a different field type.

Can anyone help me? None of the players I can find on drupal.org for D7 have documentation on how to do what I need and to me is not even clear if those players can do it (let alone how).

I tried the MediaElement + Link combo (putting the URL in the link field), but there's an issue with query parametesr in URLs being stripped, so it's not working.
The say the issue is fixed, but I tested it with MediaElement latest version (7.x-1.2) and it's still there.


texts: Scrape articles from one Drupal site to other?

texts:
Let's say I have already a Drupal website that has lots of articles and etc. And now I want to build another Drupal website under different domain, and when new article is added to the old site it would be somehow automatically scraped to the new website too?

Both sites are separate and not running under same database nor single installation.

I didn't find a module yet which would do what I need. It has to scrape articles into views lists and also somehow scrape views slideshows content and should be put in sidebars also somehow via views, I didn't find a solution yet, so that's why I asked here.


texts:
I tried a lot to get this warning solved, but end up with nothing. Can anyone look into this warning issue.

Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /var/www/html/std-build/httpdocs/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /var/www/html/std-build/httpdocs/includes/entity.inc).


texts: Create Content Type with a Default Title

texts:
How would for the Title of something to be default, static, unchanageable?

I've got a content type (plus others planned) that I plan on using as a data submittal for stuff similar to a "Quote of the Day" or "Create an Event for the Calendar" type content. I plan on keeping these "nodes" hidden for the most part and using views to view, edit, add, delete. The title will be mostly wasted space and unneeded.

How Can I do a Default, unchangeable Title for "Create" screen? Or... change a title for a content type to a different field type (Say... Date Field)?


texts: How to order a node's taxonomy terms hierarchically?

texts:
Are the terms in a node's taxonomy array ordered hierarchically by default?

If not, what is the most efficient way to do so?


texts:
I'm adding nodes to a view programmatically and i'm altering the pager 'x out of y' by setting the folowing in hook_views_pre_render:

$view->query->pager->total_items = $count;
$view->query->pager->current_page = isset($params['page']) ? $params['page'] : 0;
$view->query->pager->options['total_pages'] = ceil( $count / $lim );
$view->total_rows = (string) $count;
$view->items_per_page = (string) $view->query->pager->options['items_per_page'];
$view->current_page =isset($params['page']) ? $params['page'] : 0;

Let's say there are 10 pages but even with this code nothing seems to happen, nothing get's altered. When on the second page, it doesn't display the next button. How can this achieved with code? What object, array should i alter to have this result?
Any help would be appreciated.

Thanks


texts: How do I alter entity reference autocomplete results

texts:
I have an Album content type with some fields, including a contact field, which is an Entity reference field (taxonomy).

My contact taxonomy field has 3 text fields. I want to be able to add a contact to my Album content type with the autocomplete widget, but I want this autocomplete field to search from all of  my 3 contact fields, not only the title field (default behavior).

I have also tried to use the functionality Views: Filter by an entity reference view that comes with the Entity Reference module (Drupal 8 core) to search on more fields, as seen on https://drupal.stackexchange.com/a/125046/57071, but after creating my view, my autocomplete field return me a 500 fatal error (through AJAX) because of missing fields/relations.

I'm working with Drupal 8.0.2.


texts: db_query() doesn't seem to run in module

texts:
I have a custom user-management module in my Drupal 6 site. We are a corporate subscription service and needed a way for a subscribing company's primary user to delete other users from their company. When this happens, we need to not only delete the Drupal user record for that person, but also make some changes to a record in another mySQL database that's connected to one of our internal non-Drupal systems. There's a lot of jquery stuff involved, but the main thing is that a user clicks a delete link next to a name in a list of users. The link looks like this:

http://mysite.com/account/manage/disappear/1/182741

The final three params are what we use - disappear is the action (there are also promote and demote, which allow the primary user to change the type of account other users have), 1 is the Drupal ID of the primary user (in this case, I'm logged in as user 1), and the final param is the ID from our non-Drupal database. From that ID's record, we can find the Drupal account ID we need to delete (as well as other info we need for this function that are not specifically Drupal-related.)

Most of it works correctly - the user is deleted and the email is sent, but the query that's supposed to update our other database doesn't seem to be running. Can anyone help me out? Is there a way to debug queries? I know I'm dealing with the correct records; the error_log line right inside the disappear case returns the correct values.

Here's the function (I've stripped out the promote and drop actions since they work. Also, Viola is our intranet app where the non-Drupal database lives)

function user_manage_function($action, $uid, $viola, $email_prefix = '', $email_domain = '') {

    // action = delete, promote or drop?
    // uid = the UID of the primary user, as a security measure
    // viola = the Viola people ID of the person we want to promote, delete or drop
    // email fields = if the PU adds an email address, we need to verify it

    global $user;

    if ($user->uid == $uid) { # just a sanity check to make sure we know the current primary user

        // see what their UID is ... set $vuid = the drupal uid of the promoted/dropped/deleted user
        $people_row = db_fetch_object(db_query("SELECT institute_uid, email FROM {ismi.new_people} WHERE id = %d", $viola));
        $vuid = $people_row->institute_uid;
        $viola_email = $people_row->email;
        $data = 'pending';

        if ($vuid) {

            switch ($action) {

            case "disappear":
                error_log("inside main disappear - vuid=$vuid and viola=$viola");
                  $quer = db_query("UPDATE {ismi.new_people} SET active = 0, insitute_uid = 0 WHERE id = %d", $viola);
                    user_delete(array(), $vuid);
                    $message = array(
                        'to'                =>  'test@test.com',
                        'subject'       =>  t('User deleted by primary user'),
                        'body'          =>  t($user->name . ' (' .$user->mail.') just deleted the Institute website account for '. $viola_email),
                        'headers'       =>  array('From'=>'test@test.com'),
                    );
                    drupal_mail_send($message);
                    break;
            }

            $data = 'success';
    }
  }
}


texts: For external data, should I create custom table or new entity type?

texts:
I have a database that exists outside of Drupal. I wish to show the summarized data from that database on Drupal.

At a high level, you can see the structure of the data below.

| Seller's ID | Product Category | Date      | Total Sales |
| 1           | Widgets          | 5/1/2018  | 20000       |
| 2           | Widgets          | 5/1/2018  | 40000       |
| 3           | Widgets          | 5/1/2018  | 50000       |

In the past, I simply have made a custom table in Drupal and then performed SQL queries on that table using a custom module.

Within this table, I likely have hundreds of thousands of rows.  As far as I can tell, I have two viable options:

Entity Type - Create an entity type with fields that mirrors the columns that I expressed above.

Potential benefits:    I should be able to use the full power of views to create different reports.  I could also make new reports from data without having to touch the custom module.
Potential Disadvantages:  I have concerns about site performance. On a prior site, I had hundreds of thousands of nodes and it seemed like it substantially slowed down the site.

Custom Table:

Potential Benefits:  1) This would be easy to implement on the front end  2) I would not be adding lots of nodes that MIGHT negatively affect performance.
Weaknesses:  1) I won't be able to use the data without leveraging a custom module to query the SQL.   2) Only developers with knowledge of creating custom modules would be able to create new representations of data.

Overall, I would prefer to create an entity type to hold the data so I can deal with the data in the front end of Drupal.  With that said, I don't want to set myself up for disaster in terms of performance down the road.

Should I be worried about the database having hundreds of thousands of entities in the entity table?

Are there other options I am not aware of?


texts: product vs product type vs product display in drupal commerce

texts:
Is a product and instance of a product type? Like you'll have a media store where Books is a product type and 'The Definitive Guide to Drupal 7' would be a product?
Product display would then be literally a way of displaying your product?

I've been trying to get some clarity by reading tutorials and watching videos and somehow it's still not clicking with me.


texts:
I'm having an AJAX form, which on submit fires a callback function where I want to attach my library.
Here's the submit button:
$form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => 'Submit',
    '#button_type' => 'primary',
    '#name' => 'calculate',
    '#submit' => ['::submitForm'],
    '#ajax' => [
      'callback' => [$this, 'submitFormCallback'],
      'wrapper' => 'my-form-id',
    ],
];

When the submitFormCallback is called I attach my library using AjaxResponse and its addAttachments like this:
$ajax_response->addAttachments([
  'library' => ['my_module/library_name']
]);

The problem is when the AJAX is completed the whole page's layout is destroyed. When I do NOT attach the library to AJAX response everything seems to work fine. (I've already tried to empty my JS files in my_module/library_name so the javascript won't affect any DOM elements, but the result is the same.
Is there any problem with the way I attach the library to AjaxResponse that may cause the broken layout?


texts: How to define template suggestions for node add and edit form by content type?

texts:
I have a content type Project and it has a more than 100 fields in the node form. The form fields are grouped in different section and category. I tried to use a field_group module to group and categories in different sections, but when I add more than 20 groups field I got a problem in field arrangement and save the changes in form display. Also, i am facing difficulty to theme the form as per the design.

So, is it possible to define template suggestions for node add and edit form by content type and add an individual form element in the form template, where I can define my own HTML structure?

Eg:
from--project.html.twig some things like this, and able to add individual form elements in the form template.

<form{{ attributes }}>
 {{ form.title }}
 {{ form.field_project_description }}
</form>

Thanks for any help.


texts: With a WSOD upon deployment of a site, should I first clear the cache, check watchdog logs, or check the Apache logs?

texts:
With a WSOD upon deployment of a Drupal 8 site, should I first clear the cache, check watchdog logs, check the Apache logs, or something else?

I read the Drupal WSOD triage information here But it doesn't seem to share which solution should first be done in this situation.

This seems to indicate that it could be with the DB, so would I need to check that first?

I just noticed Fixing white screens step by step. It seems to suggest that I should look at the system (Apache) logs first. Am I interpreting this correctly?


texts: How to create a rule to automatically assign users to different profile 2 types?

texts:
I'm working on a project where different people can register.

1) Only certain domains can register. I've used the User restrictions module for this purpose.

2) Admins can create files/resources and assign them to different people. To accomplish this, I installed Profile2 module and created an entity reference field in my custom content type where admins can decide which profile types can view this resource.

My problem is now I'm trying to come up with a rule that when somebody registers, based on the domain name of their email address, I'd like to associate them to different profile types.

Is that possible?


texts: Openlayers Proximity Views Filter with Entity Relationship not Working

texts:
I'm using Drupal 7.15 to implement an music event site which allows users to search for events in their area and return a list of those events along with the associated venue and distance.

I have 2 content types, Venue and Event where the Event type uses an Entity Reference field to reference the Venue where the event is being held. The Venue type has an Addressfield which is geocoded by the Geofield module.

I have had no problem creating a View of just Venues which uses an exposed Openlayers Proximity filter to display a list of venues with their distances relative to the location criteria entered into the filter. I can enter in a starting location and get back a view of results that shows the distance relative to my starting point.

What I would like to do is to create a view of Event content types that pulls in associated Venues using an Entity Reference relationship to the Venue. I created the view and added a relationship of Entity Reference:Referenced Entity to the venue reference field. I then added fields to the view for venue address, geofield and proximity distance and selected the reference in the Relationship field for each of these.

By default, all event results are displayed when I first view the page and don't enter anything into the exposed proximity filter. I can see all of my data including the Venue fields being brought in by the relationship. The problem is that when I specify a location in the proximity filter I get no results back.

I had this same functionality working in a Drupal 6 site. There is an issue on Drupal.org http://drupal.org/node/979186 for Drupal 6 that included a simple patch to the openlayers_proximity_handler_filter_circle.inc file that I implemented some time back on my D6 site and there is mention in the issue that D7 still has a problem. I thought that I might try updating the same file on my D7 site but it did not work and ended up giving the error:

  SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'node_field_data_field_event_venue_ref__openlayers_proximity_filter_circle.distance'
  in 'where clause'

I reverted the code back to get rid of the error but I just can't seem to find what I need to do to get this working. Can anyone lend a hand and point me in the right direction? I'm assuming this is an issue with the Openlayers Proximity filter since all my data including the referenced data is displayed until I use the filter.

Thanks


texts: Access denied to custom REST API endpoint for anonymous user

texts:
I have developed a custom D8 REST API endpoint, and using the REST UI module, I have enabled it and set access to be allowed for the anonymous user using the permission created by REST UI. However, when I try to access the endpoint - either via Postman or with the D7 Feeds importer - I am unable to access the endpoint because I get a 403 - Forbidden return status code.

The settings for the endpoint in the REST UI settings provides the choices of basic or cookie authentication methods. Is the option of allowing anonymous access to a GET endpoint via the provided permission really doable, or is it required to actually send some type of authentication header?

Thanks.


texts: Drush scripting fails on call to drush_pm_enable()

texts:
I'm trying to script the automatic download and install of a set of modules for a Drupal 7 site.

At this point, I have Drupal and all desired modules downloading using a drush make profile, and installation of the site by calling drush_invoke_process on site-install.

I'm trying to get the downloaded modules activated after the installation of the site.  I have tried a number of things, the latest of which is:

(code here...)
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
drush_set_context('PM_ENABLE_MODULES',array('ctools', 'views', 'views_ui'));
drush_pm_enable();
(code here...)

Every attempt to enable the downloaded modules results in the following error:

  PHP Fatal error:  Call to undefined function drush_module_enable() in
  /Users/lhridley/sp/Drupal/tools/drush/commands/pm/pm.drush.inc on line
  904

Any ideas?


texts: Migrating specific nodes from Drupal 6 to Drupal 7

texts:
I have an existing Drupal 6 site, and an updated version of the same site running on Drupal 7. Setting up the Drupal 7 site did take a lot longer than I planned, and the old Drupal 6 site accumulated some more content in the meantime. I now want to migrate some new nodes from the old site to the new one, but not all of them as many already exist on the new site in updated versions.

I did find the Migrate module, but from what I can tell this seems to be a framework, and not an out of the box solution.

Is there an easy way to migrate specific nodes, either hand-picked or based on selection criteria like node type and creation date, between two Drupal installations of different major versions?


texts:
I would like to create a webform which accepts input from two parties. First party fills out part of a form and share a link with second party to proceed with the rest.

I have found 'save draft' feature useful for this service but only loads pre saved info for the same person. Is there anyway I can share a link (based on sid) so that whenever the URL has a SID parameter, it loads pre saved info?

Thanks


texts: Client-Side Equivalent of drupal_set_message with javascript

texts:
I've got javascript that notifies the user of actions and errors, and I'd like to use the existing Drupal messaging. Is this built in to Drupal?

Alternatively, (I'm fairly new to Drupal and am not very familiar with the modules available) if this is available as a module, I haven't been able to find it. Does anyone know of a module?

UPDATE: To clarify, I'm trying to set a Drupal message from the client-side (JavaScript), on a page that has already rendered. This is a very AJAXy page with tonnes of functionality that sometimes requires messages be shown to the user.

Is there is a provision in the Drupal client-side API for setting messages?


texts: Why cannot I choose MySQL as database type in the installation page?

texts:
I downloaded the Drupal archive and extracted it on the dedicated server. In cPanel, I created a MySQL database, but when I try to install Drupal, in the Database configuration page, I can only choose between PostgreSQL and SQLite as database type; I cannot choose MySQL.

Why did it happen? How do I fix it?


texts: Download a node (and its associated files as a zip archive)

texts: Looking to create a system whereby users can upload print quality images, have them resized for web, but allow admin users to download the contents of a particular node and download the highres images and field texts as a zip archive... what would be a good starting point for this?  A particular module?  Build a custom module?


texts:
I have made a copy of a Drupal 7 site with several sub-domains managed through domain access to a vagrant VM so I can experiment with it.

I have my vagrant set up so I reach it through localhost on the host machine. eg:

localhost:4567/default.basesite.com/

Where default.basesite.com is the name of the folder my site resides in and is configured as the base path for the drupal install in the virtualhost file on the VM. It is also the name of the original live site.

That gets me to the home page. However, the sub-domains are broken so when I try to visit them the link generated internally by domain access is of the form:

subsite.basesite.com/default.basesite.com/whatever...

Which is clearly not going to work. If I try to manually generate the link as I would expect it to look, eg:

localhost:4567/subsite.basesite.com/

I get a 404 not found error.

How do I configure Domain Access with Vagrant to take in to account the local host setup? Do I need to re-direct rule or is something else going on?


texts: How do I check the logged-in user username/password/role using a function to validate them?

texts:
I am allowing users to register an account on my site. They get a specific role using user_save().

When they log in for the first time, I have to verify the login credentials.

Is there a function to verify the login credentials?
Is there a function to get the user roles?


texts: Display a single view in different view format

texts:
I want to display a view in both grid and list style, and allow the users to explicitly select the format in which they want to view (Like the picture below)

The JQuery which I used is

(function ($) {
    Drupal.behaviors.mytheme = {
  attach: function (context, settings) {
    $('#content').once('course-view', function() {

  if ($(".view").hasClass("course-view")) {
    $(".view").addClass("grid-view"); // Sets .grid-view as default class on the view

    $(".list").click(function() {
      if ($(".view").hasClass("grid-view")) {
        $(".view").addClass("list-view"); // adds .list-view to the view class
        $(".view").removeClass("grid-view"); // removes .grid-view from the view class
      }
    });

    $(".table").click(function() {
      if ($(".view").hasClass("list-view")) {
        $(".view").addClass("grid-view"); // adds .grid-view to the view class
        $(".view").removeClass("list-view"); // removes .list-view from the view class
      }
    });
  }
});
  }
    };
    })(jQuery);


texts: How to get nid from URL alias in drupal 7?

texts:
I have a URL alias sitepath/john/video/nature-beauty where john = user, video = content type and nature-beauty = node. I am trying to get nid of node nature-beauty. Node title is "Nature beauty" actually. I have set node title in URL alias.

Can anyone tell me where am I wrong in below code?

   $last_page_visited = $_SERVER['HTTP_REFERER'];
   $alias =$last_page_visited;
   $path = drupal_lookup_path("source", $alias);
   $node = menu_get_object("node", 1, $path);
   $nid=$node->nid;
   print $nid;


texts: Allow Anonymous user to Subscribe while site under maintenance mode

texts:
The title says it all.
I have customized the Maintenance mode page, to Coming soon!!
how i want to enable the visitors of the website to Subscribe So they'll will be notified when the website is officially lunched.
how can i Achieve this, am developing the website in Drupal in 7.


texts: How do I print custom html in nodes of a certain type using template.php?

texts:
I want to print some custom html inside nodes of a certain type.
I could use node.tpl.php, but i'd prefer a template.php solution.

THX in advance.


texts:
I added some search block in my theme, and I placed each of them in a custom place.
I want to edit each of theme by using function hook_form_FORM_ID_alter for this purpose.

  Provide a form-specific alteration instead of the global
  hook_form_alter().

  Modules can implement hook_form_FORM_ID_alter() to modify a specific
  form, rather than implementing hook_form_alter() and checking the form
  ID, or using long switch statements to alter multiple forms.

How can I find each search block form ID? How can I edit them in ThemeName_form_search_block_form_alter() to add special classes to each of them?

I used the Devel module for this purpose, but It seems that for the Devel module, all those forms have the same ID (search_block_form).

This is the code I used.

function ThemeName_form_search_block_form_alter(&$form, &$form_state, $form_id) {
  drupal_set_message(kint($form));
  $form['keys']['#attributes']['placeholder'][] = t('Search');
  $form['actions']['submit']['#attributes']['class'][] = 'my-class';
}


texts: Automatically open linked pdf (bypassing download box)

texts:
I've created a Content type that allows me to upload files (specifically pdf's).

After uploading a pdf file and then linking to it in a static document, clicking the link gives me a download page.

I want the link to open the pdf directly. I tried the recommendation at http://www.drupalgardens.com/content/file-content-type
but get a similar page, without the link.

Assistance in fixing this would be greatly appreciated!

Try it for yourself

There are three bulleted links on the page:
 http://roguepublishing.ca/content/Communicating_Science

The regular 'Table of contents' leads to a page with one URL on it. That is the same URL as the hard-coded 'Table of contents'. As you can see, using these links opens the pdf's.

The 'Resource' Content type has
 * Enable Display field is checked
 * Files displayed by default is checked
 * The Manage Display is set to "URL to file"
If I change Manage Display to "Table of files", I get a table with a link to the file. Clicking that link launches the pdf.

Simply: how do I get Drupal to launch the pdf from the alias on the first page?


texts: Content: tags contextual filter seems to only match the first tag

texts: I have a contextual filter on the field content: tags set to "Match any value," but in practice, it appears that only nodes that match the first tag are displayed. For instance a node with the tags "blue, green" would show only other nodes tagged "blue."


texts: Blocks missing after clearing the cache or visiting the page that is not cached yet

texts:
I'm not sure whats wrong with my implementation. I need to print a region in node tpl so I created this code in

function theme_preprocess_node(&$variables) {
  if ($plugin = context_get_plugin('reaction', 'block')) {
    if (isset($plugin)) {
      $variables['rail_full'] = $plugin->block_get_blocks_by_region('rail_full');
    }
  }
}

And in my node tpl

<?php print render($rail_full); ?>

The problem is every clear cache I made all the blocks are missing (homepage and inner pages) in first page load or visiting a page that is not cached yet.

Any idea what I'm missing?

UPDATE:

Sorry my bad I should wrap the above code to a condition if "view_mode = teaser"

function theme_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full') {
    if ($plugin = context_get_plugin('reaction', 'block')) {
      if (isset($plugin)) {
        $variables['rail_full'] = $plugin->block_get_blocks_by_region('rail_full');
      }
    }
  } else {
   // Do anything here when teaser
  }
}


texts: What's the difference between creating a 'Content' or a new 'Pages>>Add Custom Page'?

texts:
I'm working on a pre-established site. I've noticed that I can add new 'Content' (Content>>Add Content) or I can add a new Page (Structure>>Pages>>Add custom page).

The site seems to use an indiscriminate amount of both, though Content seems to be used more with templates for blog and product pages.

What are the differences between the two and in what scenarios should I use them?


texts:
If u have seen drupal permission table, that is like

structure 1

pid rid    perm                   tid
1    1   view f1, edit f2          0
2    2   view f1                   0

what is good with  structure1?

why drupal doesn't use this structure?

table1

    fid      name
    1      view f1
    2      edit f2

table2

pid  rid  fid
1     1    1
2     1    2
3     2    1


texts: how to print a form in twig where a variable number of form elements have been printed already?

texts:
I am using a Twig template to render a form that has a variable number of elements.
Each element's key in the form is sequential integer.
So in my template, I can do this:
{% for item in form|children %}
  {{ item }}
{% endfor %}

However, then I have a broken form, because there's no <FORM> HTML element, or the form ID for submission.
I've looked at twig templates for forms in core, but they all work with fixed elements, so they're able to do something like this, seen in modules/content_moderation/templates/entity-moderation-form.html.twig:
{{ form|without('current', 'new_state', 'revision_log', 'submit') }}


texts:
We are using the Drupal Ad Module and require it to be responsive.

Used module: https://www.drupal.org/project/ad

One method I can think of would be to run Javascript to serve the same file name up but make the size of the screen control the dimensions of the file by selecting from the appropriate folder.

Anyone found a better way as this method relies on additional files being uploaded along side the one used in the ad module?

Is letting CSS resize it alone a viable option?


texts: advagg drupal module breaking my js file

texts:
I am using advagg module to improve my website performance and I also using date picker jquery UI function for date functionality.

I have datePicker  intialization $( "#datepicker" ).datepicker(); . It works perfectly, I can Even see the calender but when I am selecting the date, I don't see any alert.

for Some reason On datepicker function onSelect is not working when I have advagg enabled.

 jQuery('#datepicker').datepicker({
    onSelect: function(dateText, inst) {
        alert(dateText);
        glImgExpiry = dateText;
      }
});

If I disabled advagg, It works without any problem and I can see alert(dateText).
This is happening when I am configuraing advagg to my dev/test , In my local I am not able to configure correctly because I only see per file setting for jscompression and other settings in my dev/test.So sadly, I am not able to reproduce same issue in my local and it is breaking in my test/dev environment.

I know the information, I am giving is not sufficient to get the issue/ problem I am describing. I am just hoping some one might have faced same kind of issue and can help me resolve this problem.

EDIT

As suggested I have tried putting the datepicker onSelect function inside drupal.behavior

(function($) {
    //add drupal 7 code
    Drupal.behaviors.myfunction = {
        attach: function(context, settings) {
//end drupal calls

            jQuery(document).ready(function() {
                jQuery('#gl_img_datepicker').datepicker({
                    onSelect: function(dateText, inst) {
                        alert(dateText);
                     }
                });
//some jquery goodness here...
            });

        }};
})
        (jQuery);

But I still dont see the alert(dateText); in the page.

Thanks your help is really appreciated.


texts: What are the modules / pages / panels / or other features in Drupal which can be used to display an object which is made up of several content types?

texts:
I know views can be used, I have a functioning view which displays the relationship between the content types, using a limited number of fields.

Next I would like the hyperlink to resolve to a display of the contents of a "composite object" which includes a number of content types. What can I use?

Using: Views, Entity Reference, Panels, Page Manager

The first view is a LIST (alphabetical) of story titles, showing Relationships to other content types, as follows:
- Person (firstname, lastname, etc.)
- Story (field_story_title, orig copyright, description, etc.) Note: [content:title] is automatically generated and not used.
- Series (field_series_title, body)

and these content types which are join tables
- PersonStory (field_personstory_person_id, field_personstory_ story_id, relationship [e.g. author])
- StorySeries (field_storyseries_story_id, field_storyseries_series_id, field_storyseries_logical_order)

Person to Story is many to many, Story to Series is many to many.

I would like the hyperlink to resolve to a "page" which shows all of the fields from multiple content types which relate to that one story. This will be quite a lot of data: title, author, copyright, short blurb, synopsis (1K words) and a couple of images. So Views Megarow doesn't feel like an appropriate destination to me.

What are possible methods to show data from multiple content types?


texts: Double slash in path of downloaded module

texts:
I get a strange behaviour on 2 websites under Drupal 8.
When I download a module via Drush, the path contain two consecutive slashes like this.

  Project key_value (8.x-1.1) downloaded to /home/www/example/sited8//modules/contrib/key_value.

In admin/config/media/file-system, no extra slash is shown in the path settings.

  URL de base des fichiers publics       http://example.com/sites/default/files
  Chemin du système public de fichier sites/default/files

Perhaps it could be set in another part of the website.

Could it be a bug?


texts: How to validate temporary files with form API

texts:
Problem

I have a custom form with three file fields. The files are selected, then on submit they're attached to an email and sent off with a call to hook_mail.

I'm pretty sure the files aren't saved to the server and I don't want them saved as the files might be sensitive information.

But I want the fields to support certain file extensions. How can I validate them?

So Far

There is a function: file_validate_extensions which can validate but it only works for Drupal file objects and since these are never uploaded I'm not sure that works.

I tried using file_save_upload, as when a file is selected in a form (and not immediately uploaded) it's information appears in $_FILES so I tried to load the temporary path given there however it doesn't work.

(The path is of the form: C:\XAMPP\tmp\phpEDC6.tmp)

function mymodule_form_submit($form, $form_state) {
    $coverincluded = file_save_upload($_FILES['files']['tmp_name']['cover_letter_included'],
       array(
          'file_validate_is_image' => array(), // Validates file is really an image.
          'file_validate_extensions' => array('png gif jpg jpeg'), // Validate extensions.
       ));

     //unfortunately this dpm never shows, presumably because file_save_upload hasn't worked
      dpm($coverincluded);
 }


texts:
I'm updating a site in which I need to ensure that the alt (and possibly title) attribute are enabled for any field of time file (widget image).

There are tonnes of content types and I don't want to have to go through every field in every content type to check and enable it each.

I've had a search for modules but have been unsuccessful in my search. Is there a way I can enable them in as a bulk operation in the database?

I've looked but couldn't find exactly where the setting for each field was

For example, the table content_type_source_homepage has the following fields

field_shp_image_fid     int(11)                         Yes NULL
field_shp_image_list    tinyint(4)                      Yes NULL
field_shp_image_data    text        utf8_general_ci     Yes NULL

These obviously store a reference to the image but does not indicate whether or not the user is allowed to edit the alt attribute for that image, and what the default alt attribute might be.

Furthermore, fields which allow multiple images have a separate table such as content_field_title_image which again has similar fields without indication as to whether or not the alt attribute is editable.


texts:
I think it's an easy question but I just can't solve it.

I use responsive grid type in view to show a content type named "clinic information",and it is.

I want a row only have two clinics and the five-stars are beside the information(picture,phone number...), not below, how can I make it?

(picture, name, address, phone number, five-stars are clinic information in one content in a grid)


texts: Cannot enable node_view in ctools page_manager permanently

texts:
I have a strange problem. If I enable node_view in page_manager everything works as expected and the node layout is according to my settings. If I then do a menu cache clear node_view is not used anymore and my node layout is as without node_view. If I do a

page_manager_get_current_page();         (1)

shortly after activating node_view the array contains the normal values. Looking into the db the variable

variable_get('page_manager_node_view_disabled')         (2)

returns 0 as it should be. After the menu cache clear the function in (1) returns an empty array whereas the variable in (2) remains 0. Also the node_view page stays active inside the page_manager UI. If I deactivate and activate node_view everything works again until I refresh the menu cache again. So this seems to be an infinite loop for me: Everytime I do a menu cache flush I have to deactivate/activate node_view.

I don't know how long this problem exists, but I observed changes in my node layout also last year. I am using Drupal commons, so maybe the problem is related to this, since commons throws in a lot of modules and perhaps something overwrites node_view (panelizer is disabled on the specific nodes).

If I look into the code of the module, there should be a message

drupal_set_message(t('Page manager module is unable to enable node/%node because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');

if node_view is overridden, but there is simply nothing in dblog. I am really stuck here...

Does anyone have an idea what could be wrong or what I could do to find the reason for this behaviour?