texts: Convenient way to copy & paste links to uploaded file attachments when editing Drupal 7 content?

texts:
In Drupal 6, when enabled, the upload module presents a handy list of all the files attached to a Page node.  The list includes the file URL in plain text for convenient copy & paste into the Page node body.  E.g.

Drupal 7 replaced the upload module functionality with file fields in core.  The listing provided by this functionality does not display the file URL.  E.g.

How can I conveniently copy and paste the file URL using this Drupal 7 method?

Note: Right-click + Copy file location is not convenient because you end up with extra overlay related information on your URL.  Furthermore, you also always get the full URL instead of just the parts you want (i.e. relative link).


texts: How to show a view page but hide all the content in the view for certain roles?

texts:
Working on a membership site built on Drupal and am aiming to hide the content of certain views pages on the site unless the user has a specific (membership) role.

However, setting view page access control hides the entire page — including title and its very existence (page disappears out of nav menus, etc.). My goal is to show the page is still there (almost as a teaser), allow anonymous users to click on it, but hide all of the body content (fields, etc.) if the user does not have the correct role. That body content should then be replaced by a message to subscribe to the membership.

Is that doable with views or another module ? If so, how? Any suggestions?

Note: I'm already using the Field Permissions module to hide some of the same fields on other pages using roles. As such, I can't apply that module for this use.

Edit: We're using views to generate 800+ pages automatically (tokenized paths, etc.). That adds a layer of complexity — any solution has to be able to scale easily.


texts: How do I add drupalSettings info from an AJAX callback

texts:
I have a custom Drupal 7 module that does a zipcode lookup to return town and county. I set Drupal.settings.zip_code_success to true within the callback. This is the code I am using.

drupal_add_js(array('zip_code_success' => TRUE), 'setting');
$commands = array();
$commands[] = ajax_command_html('#triage_city', $out);
return array(
  '#type' => 'ajax',
  '#commands' => $commands,
);

The zip_code_success value is then available in some processing code that runs on the js side.

In moving things to Drupal 8, the lookup and html replacement are working fine, but I can't figure out how to get the zip_code_success info into drupalSettings.  drupalSettings gets set up in the the initial page generation and shows within the DOM with the values that are passed initially through the hook_preprocess_html function.  I've tried a variety of things in the zipcode lookup function but haven't been able to update drupalSettings.  Here's the current D8 code snippet comparable to the D7 above:

$response->addCommand(new SettingsCommand(['zip_code_success'=>TRUE] ,TRUE));
$response->addCommand(new HtmlCommand('#triage_city', $out));
return $response;

I've also tried:

$response->setAttachments([
  'library' => ['core/drupalSettings'],
  'drupalSettings' => ['zip_code_success' => TRUE]
]);
$response->addCommand(new HtmlCommand('#triage_city', $out));
return $response;

Any wisdom as to how to handle this situation?


texts:
When using the drupal_add_js function, should I see the script I am loading appear in the list of scripts being loading in the header of the generated html page? I thought I should, but I don't - so perhaps my understanding of this function is wrong. Can someone clarify what is suppose to happen.

Just as note I have verified that the path to the script is correct so I know that isn't the issue.

Thanks.


texts: Using Drush site-install with multisite and a single database

texts:
I am trying to make a script that will create and configure a new multisite in a drupal 7 install using drush 5.8.

I have scripted creating the site folder and settings.php file manually and adding the database information (to get around a bug i was having with --db-url and sql server).

I am setting the dbprefix to be $newSite so that all the tables can live in the same database.
The first thing drush site-install tries to do is drop ALL the tables in the database. This includes all the tables created with a different prefix in a previous install.

Is there any way to stop this from happening?

Thanks for your help in advance!

Joe


texts: What settings are there for sending an email to the users who create accounts?

texts:
How can I send an email to users after registration, confirming they have been registered?

From user/register, when users enter the required data (name, username, email) as administrator I receive the account information, but the users don't get any message.


texts: How to restrict each user to making only 1 comment per node?

texts:
Does anybody know if there is any way I can restrict each site user to making only one comment per node on my Drupal 7 site? I haven't found anything yet.

I've just tried a complicated setup with flags and rules and triggers and actions and redirects. This didn't work too well.


texts: Why is theme.inc looking for view template in calendar module

texts:
So I am working on updating a drupal site that was very out of date, I have updated everything to the latest versions. When I updated the Calendar module things started going awry, now most of my views don't display anything. I'm assuming this error is the reason:

Warning: include(__custom_path__/sites/all/modules/calendar/views-view-fields.tpl.php): failed to open stream: No such file or directory in theme_render_template() (line 1525 of __custom_path__/includes/theme.inc).

I've searched and while there are numerous potential fixes none have worked. The last one I tried, adding a empty version of the views-view-fields.tpl.php and that only creates a different error where theme.inc can't find calendar.views.inc because it look for it at the path calendar/calendar.views.inc instead of calendar/includes/calendar.views.inc

Why is it looking for this in calendar instead of views? What can I do to fix this?


texts: drupal variables custom module and views

texts:
I'm trying to figure out how Drupal works. I created a simple module named "myModule".

In its myModule.module file I have:

<?php

function myModule_node_view($node, $view_mode, $langcode){
drupal_add_js(array('myModule' => array('nid' => $node->nid)), 'setting');
           }
?>

on myModule.js file I have:

    (function ($) {
  Drupal.behaviors.myModule = {
    attach: function (context, settings) {

      jQuery("#test").bind('click', function(e) {
        alert(Drupal.settings.myModule.nid);
      });
    }
  };
}(jQuery));

On my view which has nodes (articles), I created a custom field which has

<a id="test" href="#"Testing!!!

So basically what I want is when I click on the Testing!!! link to show an alert which shows the node id (nid) that belongs to the article in the view's row.

Right now it's showing the nid of the current node I am in, not the view's row.


texts: Issue trying to implement the Swagger UI module in Drupal: ReferenceError: SwaggerUIBundle is not defined

texts:
I am trying to integrate the Swagger UI module into Drupal 8 after adding custom REST routes/resources. I have installed the OpenAPI, OpenAPI_UI, and OpenAPI_Rest modules and I'm able to get a valid swagger json resource back when navigating to <mysite>/openapi/rest after installing all the modules.
The issue I am having now is trying to get the Swagger UI module to render in the OpenAPI module.  After navigating to Administration -> Configuration -> Web Services -> OpenAPI Resources I am able to select the Explore with Swagger button, which should utilize the Swagger UI Module which has been installed following the steps listed here: https://www.drupal.org/project/openapi_ui_swagger
Navigating to the page leads to an empty table, and digging into the console, I get this error:
js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:1544 Uncaught ReferenceError: SwaggerUIBundle is not defined
    at Object.attach (js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:1544)
    at js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:59
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:56)
    at js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:284
    at HTMLDocument.listener (js_gIQezLRH6hj-zYPQQ0n_5_ryM5tJpAP9kDSEP7r8TdE.js:276)

This is being thrown inside the swagger.js file inside the Swagger UI module:
 var config = {
        dom_id: dom_id,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl,
          SwaggerUIHideTopbarPlugin
        ],
        layout: "StandaloneLayout"
      }

It seems like the SwaggerUIBundle and other Swagger JS objects aren't being exported properly and JS is throwing the UncaughtReferenceError when accessing these members. Has anyone come across this error before? I am pretty new to Drupal and I'm trying to figure out what the issue is, because it seems like I've followed the steps properly to get everything working.
This also seems to be close to what I am experiencing, but unfortunately there was no posted resolution: https://www.drupal.org/project/openapi_ui_swagger/issues/3073250


texts:
I am trying to create a hook that creates a new entity('Notification') when an entity of another type is created (either of type 'Deadline' or 'Message'), but I can't seem to figure out how to add a new entity from a hook, am I completely missing something?
My hook in ost.module looks like this:
function ost_hook_ENTITY_TYPE_create(EntityInterface $entity){
  if ($entity->getEntityType() == ('Deadline' || 'Message')){
    createNotification($entity);
  }
}

The function which is called looks like this:
function createNotification(EntityInterface $notification){
  $newentity = EntityInterface::create([
    'title' => $notification->label() . "notification",
    'field_content' => $notification->toLink()
  ]);
  $newentity->save();
}


texts:
Trying to write entity queries with group by condition using Drupal::entityQueryAggregate. It works well for simple fields, for example:

$query = \Drupal::entityQueryAggregate('node')->condition('status', 1)->condition('type', 'node_type');

$result = $query
      ->groupBy('field_custom_field')
      ->aggregate('nid', 'COUNT')
      ->execute();

But now I have to select nodes aggregated by year from custom field and I can't figure out how to do it:

->groupBy('YEAR(field_custom_date)') - doesn't work

->addExpression('YEAR(field_custom_date)', 'fcd_year') - doesn't work

Any ideas how to implement this query?


texts: Session Timeout after certain period of inactivity

texts: How can I logout users after a certain period of inactivity (say 20 minutes)?


texts: How can i make a Slide Show for my Home Page with the following requirements

texts:
How can I make a Slide Show for my Home Page with the following requirements:

The image would link to any content
The caption would be different for all images of the slide show
The slide show would be responsive
The images can be added, deleted from the CMS itself by the client/admin
Navigation controllers
Place a link "Sign Up" on top of the slide show which takes the user to the  sign up page

I tried with Views Nivo slider but it has open issues regarding rewrite results. Are there any other modules? Views slideshow is one but I am not able to configure it as per my exact requirement.


texts:
Drupal's cache system is a complete nightmare causing all sorts of issues with my user sessions. To provide a couple examples

Our navigation header block contains a link that takes users to a different link based on their gender. If they are male they go to this site, if they are female they go to that site. If I login as a male and then logout, then login as a female, the link is still linking to the male link. Once I clear the cache, this works as expected.
We have an EventSubscriber on Requests using the EventSubscriberInterface that will redirect a user based on a custom field field_verified. If a user's field is marked as false, the event subscriber redirects them to a verification page. If I login with a verified user and then logout and create a new user (therefore not verified) the EventSubscriber never gets executed, so the user isn't redirected properly. Once I clear the cache, this works perfectly fine.

I have an endless list of situations like this where user data is persisted through different sessions and is only fixed by clearing the cache. I don't want to have to flush ALL the cache everytime a user logs in or creates an account as this is a performance issue.
How can I clear cache related to just the user objects and sessions?


texts:
How can I change form action in drupal 8?

In default, page not change and when my form path is /site/drupal/page, my form action is <form data-drupal-selector="test" action="/site/drupal/page" method="post" id="test" accept-charset="UTF-8">.

But I want change it to other page. How can I do this ?

** Redirect not worked, see this link: Redirect after submit form


texts: Query with multiple joins and conditions

texts:
I am trying to achieve this code, which works correctly as a SQL consult on Phpmyadmin, in a PHP field of a View (Drupal 7).

SELECT COUNT(*)
FROM `field_data_field_qrespuesta_preg1` `r`
LEFT JOIN `field_data_field_qrespuesta_franquicia` `f` ON f.entity_id = r.entity_id
LEFT JOIN `field_data_field_qrespuesta_cuestionario` `c` ON c.entity_id = r.entity_id
WHERE `field_qrespuesta_cuestionario_nid` = 3134
AND `field_qrespuesta_franquicia_nid` = 3139
AND `field_qrespuesta_preg1_value` = 0

Now that's what I'm trying with no success:

$query = db_select('field_data_field_qrespuesta_preg1', 'r');
$query->leftjoin('field_data_field_qrespuesta_franquicia', 'f', 'r.entity_id = f.entity_id');
$query->leftjoin('field_data_field_qrespuesta_cuestionario', 'c', 'f.entity_id = c.entity_id');
$query->condition('c.field_qrespuesta_cuestionario_nid', $nid '=')
    ->condition('f.field_qrespuesta_franquicia_nid', $franquicia, '=')
    ->condition('r.field_qrespuesta_preg1_value', $respuesta, '=')
    ->countQuery()
    ->execute()
    ->fetchField();

Any help will be really appreciated!

UPDATE: I did it with db_query, but I would still like to know how should it be done with db_select.

$query = db_query(
  'SELECT COUNT(*) FROM {field_data_field_qrespuesta_preg1} AS r ' .
  'LEFT JOIN {field_data_field_qrespuesta_franquicia} AS f ' .
  'ON r.entity_id = f.entity_id ' .
  'LEFT JOIN {field_data_field_qrespuesta_cuestionario} AS c ' .
  'ON f.entity_id = c.entity_id ' .
  'WHERE c.field_qrespuesta_cuestionario_nid = :nid ' .
  'AND f.field_qrespuesta_franquicia_nid = :franquicia ' .
  'AND r.field_qrespuesta_preg1_value = :respuesta',
  array
  (
    ':nid' => $nid,
    ':franquicia' => $franquicia,
    ':respuesta' => $respuesta,
  )
)->fetchField();


texts: How can I catch an EntityStorageException exception?

texts:
I have a custom Webform Handler that submits a webform to an external SOAP api. Once a user submits the form, the data is sent to the external api, my custom webform hidden field 'error' is updated to read 'Yes' or 'No' depending on the feedback from the api and the form details are saved to the Drupal database. The contents of the custom 'error' field is then used to send a conditional email to the website admin. All works fine except when the SOAP api is offline, then there is an EntityStorageException error and the details in the form are neither saved to the database or submitted to the SOAP api. I've tried to Catch the EntityStorageException, but it's not working.

My code is as follows:

namespace Drupal\mycustom_handler\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\webformSubmissionInterface;
use Drupal\Core\Entity\EntityStorageException;
/**
 * Form submission handler.
 *
 * @WebformHandler(
 *   id = "sentinelapplication",
 *   label = @Translation("Sentinel Application"),
 *   category = @Translation("Form Handler"),
 *   description = @Translation("Administers application via SOAP"),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
 */

class mycustom_handler extends WebformHandlerBase {
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [];
  }
  /**
   * {@inheritdoc}
   */
  public function preSave(WebformSubmissionInterface $webform_submission) {
    $values = $webform_submission->getData();
    $endpoint = 'www.soapapi.com';

    // Add the SOAP Call
    try {
      global $base_url;
      $wsdlurl = $base_url ."/modules/custom/mycustom_handler/src/Plugin/WebformHandler/mycustom.wsdl";
      $client = new \SoapClient($wsdlurl, array('location'=>$endpoint, 'exceptions'=>true, 'trace'=>true));
      // upload webform detail to SOAP
      $webform_submission->setElementData('error', 'No');
    }
    catch (SoapFault $ex) {
      $webform_submission->setElementData('error', 'Yes');
    }
    catch (Exception $ex) {
      $webform_submission->setElementData('error', 'Yes');
    }
    catch (EntityStorageException $ex) {
      $webform_submission->setElementData('error', 'Yes');
    }
  }
}

I have also tried but had no luck with:

catch (\EntityStorageException $ex)

catch (Drupal\Core\Entity\EntityStorageException $ex)

catch (\Drupal\Core\Entity\EntityStorageException $ex)

Not sure if it is an issue with the preSave function (and postSave function as I tried that too) because if I use the submitForm function, the error does not display and the data is saved to the Drupal database. However, while using the submitForm function solves my error problem, I can't seem to figure out how to update the custom 'error' field in the submitForm function.

So has anyone got any idea how to Catch the EntityStorageException error or alternatively, if that is not possible, how can I update the webform submission within the submitForm function?


texts: Access custom theme settings from within views

texts:
I have a few custom theme settings which so on my themes settings page.. this all works fine and as expected.

I now need to create a view that gets that custom theme setting. I can't find anything on how to do this.

I have installed the views php module and I know this theme_get_setting('setting_name') is what i used to get the theme settings in my template.php file.

Any help with this will be much appreciated.

Regards
C


texts: How to change the size of the avatar in Drupal 7?

texts:
When i visualize user avatar in Drupal 7 using this code:

$account = user_load(2);
print theme('user_picture', array('account' => $account));

The following image is generated:

How can i control such parameters as size of the image, title, alt?
And how can i get rid of the link (or change the path) which is generated automatically with the image?

...


texts:
I've just begun the transition process from D7 to D8.  I installed D8 and added a basic page w/ a menu link.  I then began to explore the new D8 routing system and expected to find a .yml file that contained information about where to find the added page but I don't see it. This is not a added module so it doesn't have a moduleName.routing.yml.

I'm looking for a conceptual description of why this does or doesn't follow the new .yml convention.


texts:
I use login toboggan and profile2. Now I'm logged in as "user1". The I logout and login with "user2". When I then go to the user profile page of user2 I see "user1" in page title.

Clearing the browser cache isn't a solution.

Clearing DRUPAL cache works (but at the moment DRUPAL cache is disabled). Then I see the right username in page title. Is it possible to exclude the user profile page data from DRUPAL cache?


texts: Images get deleted when uploaded to a theme settings field

texts:
I've got some custom text_format fields set up in my theme settings, but images don't seem to be working correctly with them. For some reason images uploaded to these fields don't get marked as "used" and thus get deleted by cron after 6 hours. Is there something I can do to correct this?

Shortened example of how I'm adding the fields:

/**
 * Add custom fields to theme settings
 */
function MY_THEME_form_system_theme_settings_alter(&$form, Drupal\Core\Form\FormStateInterface $form_state, $form_id = NULL) {
    $form["MY_THEME_settings"]["sidebar"] = [
        "#type"  => "details",
        "#title" => t("Sidebar"),
        "#open"  => TRUE,
    ];

    $sidebar_content = theme_get_setting("sidebar_content_1", "MY_THEME");

    $form["MY_THEME_settings"]["sidebar"]["sidebar_content_1"] = array(
        "#type"          => "text_format",
        "#title"         => t("Content"),
        "#format"        => "full_html",
        "#default_value" => is_array($sidebar_content) && isset($sidebar_content["value"]) ? $sidebar_content["value"] : "",
    );
}


texts: How to change the email recipient for contact form

texts: On a Drupal 8 site, I have a content type called TeamMember which has an email field.  From the view where I show all the TeamMembers, I'd like to link to a form where the user can email that person directly.  Is there a way to customize the recipient of the email from a contact form?


texts: How to make user picture editable without opening edit profile page?

texts:
I wanted to allow users to edit profile without going to edit profile page. I found few useful modules like Editable field and Editable fields as link. These modules provide field formatter which make the field editable without leaving the page except the user picture. I am not able to use this technique with user pictures because It is not a normal field as other fields.

How can I make user picture an editable field without going to edit profile page?

Note: I have created a custom profile page using panels. There is a module Picture Changer which allows users to change picture in a modal, but it does not work with panels.


texts: Unexpected error during import . . . plugin does not exist error on drush config import

texts:
This is an issue I've had occasionally when trying to delete a plugin in a custom module.  In this example, once a filter format filter plugin has been enabled it's impossible to remove.  If you disable it and remove the plugin class from the codebase, it still shows up in the "filter.format.full_html.yml" config.

If you try to edit this file to remove the dependency and then do drush cim, you get an error:

Unexpected error during import with operation update for filter.format.basic_html: The &quot;examplefilter&quot; plugin does not exist.

How do you get rid of this dependency if it shows up in the config when disabled and you can't remove it from the config and import the config without getting a fatal error that the plugin is missing?


texts:
I'd like to print a row number at the start of each table row in a field collection table.

Is this possible? Could you please explain?

thx in advance


texts: Render a drupal_get_form() don't execute ajax select callback

texts:
I want to re-use the commerce_customer_profile form in a particular context. To do this I use this :

function MY_MODULE_form($form, &$form_state, $profile_type) {
  $form = array();

  global $user;

  // Create new profile.
  $profile = commerce_customer_profile_new($profile_type, $user->uid);

  $form['customer_profile_' . $profile_type] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'field-type-new-' . $profile_type,
        'field-name-field-' . $profile_type,
        'field-widget-commerce-customer-profile')
    ),
    '#tree' => TRUE,
    '#parents' => array('customer_profile_' . $profile_type)
  );

 $form['customer_profile_' . $profile_type]['customer_profile'] = array(
    '#type' => 'value',
    '#value' => $profile
  );

  // Add the field widgets for the profile.
  field_attach_form('commerce_customer_profile', $profile, $form['customer_profile_' . $profile_type], $form_state);

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

  return $form;
}

function MY_THEME_preprocess_page(&$vars) {
  $args = arg();

  if ($args[0] == 'checkout' && !isset($args[2])) {
      $profiles = commerce_customer_profile_type_get_name();

      $vars['commerce_customer_profiles'] = "
";
      $vars['commerce_customer_profiles'] .= "
";

      foreach ($profiles as $profile_type => $profile_title) {
        $vars['commerce_customer_profiles'] .= '
';
        $form = drupal_get_form('MY_MODULE_commerce_address_form', $profile_type);

        if (isset($form['customer_profile_' . $profile_type])) {
          $form['customer_profile_' . $profile_type]['commerce_customer_address'][LANGUAGE_NONE][0]['country'] = ajax_pre_render_element($form['customer_profile_' . $profile_type]['commerce_customer_address'][LANGUAGE_NONE][0]['country']);
          $vars['commerce_customer_profiles'] .= drupal_render($form);
        }

        $vars['commerce_customer_profiles'] .= "
";
      }

      $vars['commerce_customer_profiles'] .= "
";
      $vars['commerce_customer_profiles'] .= "
";
  }
}

Everything works fine except one and only thing: AJAX to select the country. The drupal_render() does not execute the form elements with an AJAX callback, despite the ajax_pre_render_element() on form item.

Any idea ?


texts: Generate automatic URL alias removing words

texts: I'm trying to create a topic page for "internet of things", but each time I create the page I notice the URL slug removes the word "of" in it. By default Generate automatic URL alias is checked. The only solution I have found is to uncheck the Generate automatic URL alias option and giving custom url alias. This is a problem since we have alot pages and it's difficult to update it manually. (Some people who make these pages don't have permission to open drupal and push changes from our website). We also run into an issue with symbols # or + or character 'a'.This is restricting the SEO for pages like C#


texts: Create custom variables for a template file inside a menu callback function

texts:
here is a good one that has always stumped me.

I would love to see a solution in both D6 and D7.

I create custom modules and usually work with the menu api to create menu type -> MENU_CALLBACK.

Here is an example:

function example_menu() {
  $items['example/page1'] = array(
    'page callback'     => 'example_page1_callback',
    'access callback'   => TRUE,
    'type'              => MENU_CALLBACK,
  );
  return $items;
}

I would like to see the exact code solution to provide three different variables to be printed in a custom theme template based on the following code.  To add to that challenge, I would like the code to be written in the menu callback function only.  I know there are many possible ways to do it but could never figure out how to do it in a menu callback function which would be the most useful way.

//****************************************
// This code block goes in a custom module called example_menu_variables.module

// hook_menu example
function example_menu() {
  $items['example/page1'] = array(
    'page callback'     => 'example_page1_callback',
    'access callback'   => TRUE,
    'type'              => MENU_CALLBACK,
  );
  return $items;
}

// hook_meny callback function
function example_page1_callback() {
  // please provide code within this function to turn these next three
  // variables into separate output variables for the template.
  $variable_to_print1 = 'Foo';
  $variable_to_print2 = 'Bar';
  $variable_to_print3 = array('bing', 'bang', 'bong');
  return;
}
//****************************************

//****************************************
// This block of code represents the part of the custom theme template related to the menu location from the hook_menu call
// D6 template name would be page-example-page1.tpl.php
// D7 template name would be page--example--page1.tpl.php

<?php print  $variable_to_print1?>

<?php print  $variable_to_print2?>

<?php print  $variable_to_print3[0] . ' ' . $variable_to_print3[1] . ' ' . $variable_to_print3[2]?>

/*
output should look like:
Foo
Bar
bing bang bong
*/

//****************************************

Hope this is the kind of problem that someone wouldn't mind solving.  Thanks for your time.  :)

Ray James


texts: Change the confirm_form message of an entity made with eck

texts:
I have an entity created with eck module, and when I want to delete an entity the message is :

Are you sure that you want to delete %id ?

I want to change this message to show me the title of the entity and not the id.
I find where this is implemented, is in the code below in eck.entity.inc file located under the eck module folder:
function eck__entity__delete_form($form, &$form_state, $entity_type, $bundle, $id){
  $path = eck__entity_type__path();

  $entities = entity_load($entity_type->name, array($id));

  $form['entity'] =
      array(
        '#type' => 'value',
        '#value' => $entities[$id],
  );

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

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

  $form['submit_redirect'] =
  array(
    '#type' => 'value',
    '#value' => "{$path}/{$entity_type->name}/{$bundle->name}",
  );

  $message = t("Are you sure that you want to delete %id",
          array("%id" => $id));

  $caption = t("This action cannot be undone.");

  return confirm_form($form, $message, "{$path}/{$entity_type->name}", $caption, t('Delete'));

}

Is there a way to change this confirm message without changing the code of this module ?
thanks in advance


texts: How can authors choose a different display name?

texts: I am looking to add to the create user feature to allow or display a drop down and or a text field that would allow the user to create a custom display name to associate with the post he or she would be creating.


texts: How to animate background image on page load in drupal 7?

texts:
I have a site in Drupal 7 and I am using background image here.

I need to animate this image when page load, only one time. I used slider for this but for single image slider not giving any animation.


texts: How to remove 'Message log' tab from profile page?

texts:
I've got this tab on profile pages of all users and for whoever I've tested, pressing this tab just yields:

  No logged messages

So it seems a real glitch that comes with some module which I've no clue of. So just wondering how can I remove the tab?


texts: Pass view contextual filter arguments programmatically

texts:
I want to pass contextual filter arguments programmatically to a view. I know it can be done through views_get_view and views_embed_view, but I want to pass it to a view's page display. Also I want to pass multiple arguments to the view, so it won't be good to pass all the arguments in the url.
I tried to pass the arguments using $view->args = implode('+', $args); in hook_views_pre_render, but it didn't work.
Does anyone know how to pass contextual filter arguments using any of view hooks?


texts: Make top level terms un-selectable in hierarchical taxonomy?

texts:
I have a taxonomy like this:

Color
-blue
-green

Size
-large
-small

I need to use 1 vocabulary not 2. However I need 'Color' and 'Size' to not be selectable. If I create a hierarchal taxonomy is there a way to make certain (the top level) terms un-selectable by nodes?


texts:
I need your help :

When any user logs into my website (admins too), the maintenance page is displayed with the url "/node?destination=node", while maintenance mode is surely off.

Then, if the user calls the host base url, the website is working normally and user is properly logged-in.
The maintenance page never appears again while maintenance mode is off.

If you've got any idea please keep me in touch, I'm lost ^^

Thanks in advance.

--
Info(s) : Drupal 7.31 + Module Drupal Commerce


texts: Get all nodes where date field matches month and year

texts:
I have a content type with a date field (myFieldDate) whose values are timestamps. (I'm collecting only day, month, and year.)

I have a custom form where I have a select list to select month and year.
I need to use the EntityFieldQuery class to get all the nodes where the date field contains the month and the year I specified.

$query = new EntityFieldQuery();
$query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'horas')
  ->propertyCondition('status', NODE_PUBLISHED)
  ->fieldCondition('field_day', 'value', $myFieldDate, '=');

If the select list contains '2015-05', for example, the query should return all nodes where myFieldDate contains a date for that month and year.


texts:
We are using the default RSS feed view found at /admin/structure/views/view/frontpage. We want to change the Show to be Fields so we can setup up which field should be used for the title, link, description, creator, and publication date.

When we attempt to add the node url field we cannot find it. How to add the absolute URL of the node?

We have tried searching for, but cannot find it:

Content: Path
Node URL


texts: Need module for notifications like privatemsg

texts:
I am using Drupal7 and notification module. Now i want the notification like Private Message module. When any comment occurs or any post occurs at that time i want notification like "Private Message" module i.e. just like "3 new messages" i want same like this "3 new comments" etc..

Can you please inform me if there is any module exists or not


texts: What's a good way to prepopulate web form fields with data from an external database?

texts:
What might be a sane approach to prepopulating web form fields using data from an external database on the fly? This is my scenario: there is a form that we need clients to fill out, but we already have a lot of the client's information in our database. So to make it easier on the client, we want to fill out the form as much as possible before sending it to them to fill out the rest. I'm using the webform module on our Drupal 7 site, but all the data needs to come from our other database.
Ideally, there would be either a page or just a field where I can select the client ID. After choosing the client ID, other fields would use that ID to pull information like contact name, address, etc.
Is there a reasonable way to do this?


texts: Adding fmath editor plugin to ckeditor through wysiwyg module

texts:
How to add fmath editor plugin to ckeditor through wysiwyg module.
The link (http://www.fmath.info/plugins/drupal/doc.jsp) provides documentation for ckeditor module but it does not explains the steps for wysiwyg module.


texts: How to change the look and feel of exposed filters in a block

texts:
I have view which has exposed filters. I have configured those filters to block.
But now I want to change the look and feel of the exposed filters .

How to do this.


texts: Permissions deselected, but user can still edit content

texts:
Reproduce:

Create new content type with uid:1
In admin/people/permissions you can see that permissions are not given to Administrator role, they are deselected/unticked by default for the new content type.
E.g. create new user and give him Administrator permissions.
The new Administrator user (non-uid:1) can still edit/create/delete the new content type contents although the permissions are deselected?

How's that?


texts:
I am getting this error while cloning the site on aegir

  Unknown option: --profile.  See drush help provision-backup for available >options. To suppress this error, add the option --strict=0. [2.39 sec, 21.19 MB]

I am using aegir3 on ubuntu 14.04.4.
Can anyone please help me solve this.
I have searched on web but there is no solution regarding this issue.
This issue also occurs while migrating.


texts: How to set blog post under event section in Drupal commons

texts:
I use the Drupal Commons distribution. I already created blog-post depends under group section using OG_MEMBERSHIP. Likewise, blog-post depends under content type event. How to achieve this?

We also have some event section (with particular time/date and location), which is used for maintaining some blog-post (content type).

Can anyone provide some insight about how to do this? I.e some procedure or modules for creating such blog-post (content type) under event.


texts: How do I use the Print Module with a Custom Form Module?

texts:
I have searched and searched but have not found a definitive answer or direction. I've installed the Print module (Printer, email and PDF) and have it successfully working when associated with content types.

My problem however, is making it work with custom forms. I have tried placing print_insert_link() in the form and it doesn't show up. I think all I'm missing is an example of print_insert_link() pointing to a custom form module. The path for the custom module I'm working with now is glatfelter_forms/form_scorecard.  How do I properly use print_insert_link()?  I'm using Drupal 7.23. This is my first post so please let me know if I can provide any additional detail. Thanks!


texts: Custom menu link does not show up under "List links" but is in the database

texts:
I have three menus with six links each using the i18n module.

All of these links are to panel pages.  On one menu, however, there is an additional link to another custom panel that does not appear in the Menu UI (under List Links)  but is present in the database (I found it in the menu_links table).

When I go to the panel of the ghost link, the option for showing a menu link is disabled.

How can I put this link back in the UI?  Or should I simply delete it from the database and re-create it in the UI?

EDIT: I tried adding the link in the menu manually, but then it shows up twice.


texts: What to do if using Drupal 7 but host only supports Drupal 6? Downgrade not an option. Would like to keep Drupal 7.


texts: How do I set a variable in the install profile to enable users to sign up for the website

texts: I am trying to understand about how setting variables works in install profiles. As an example, how would I set the option to enable people to create a website for the account in the install profile? Here is the page on variable_set https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/variable_set but how do I retrieve the value.


texts: How to display a field in a content type template?

texts:
I edit my template field--field-email--customer.tpl.php and it works but I would like to display a field twice. I tried with this but it doesn't work :
    print render($content['field_nom']);


texts: How to use drush config:set for translations?

texts:
https://drushcommands.com/drush-9x/config/config:set/

For one language site the command is:

drush config:set system.site name "Drupal 8 English sitename"

But how to be, if the site is multilanguage, at example two languages?
Example:

English site name: "Drupal 8 English sitename"
Italian site name: "Drupal 8 Italian sitename"

At example for site settings in web interface I can translate it in tab "Translate system information" http://take.ms/i9jUN.
But how to set translated config value with drush? It is possible?


texts: Get views to format an image field for HiDPI / high pixel density / Retina displays

texts:
I have a view showing several nodes that have photos stored in an image field. It works great, but doesn't look so sharp on HiDPI displays (or when the page is zoomed-in on a traditional display) because the image file that views produces is exactly the size used in HTML. Views is giving me something like this:

But I think what I'd like views to do is produce something like:

This way I'm loading images bigger than necessary (downside = slower page load), but it would seem worth it to me because I could get the images to look nice and crisp when the client has a device pixel ratio > 1.

My images in these nodes are not always the same aspect ratio.

Any thoughts on how to get views to produce the image and markup above, or perhaps how to approach this problem a different way?


texts: slideshow_view: how to rewrite the output?

texts:
I have a content-type "gallery " which is composed of:

Field Image
Field Link (which is an EXTERNAL link like www.google.com or http://exemple.org)

so i've created a view with the link field hidden(the widget of the link field is: "Title, as Link (default)") and the image field

how should I rewrite the output of the image field to put the external link into the image?

i've tried with this:
    [field_image_1] but this is not working


texts: Add condition group in Views filter handler

texts:
I have a Views filter handler, which does

$this->query->add_where(
  $this->options['group'],
  $this->real_field,
  vms_get_current_mlid(),
  $this->operator = ($this->operator == '=') ? 'IN' : 'NOT IN'
);

Which initially looks fine, but fails with "NOT IN", when the field value is NULL, as NOT IN (100) does not return TRUE for a NULL value, which is what I would like.

When the operator is 'NOT IN', I need to add a "OR IS NULL" operator as well, but still keep it within the same group.

If the filters are

  Node is "page" AND NID_REFERENCE NOT IN (100, 101, 102)

I would like that to become

  Node is "page" AND (NID_REFERENCE NOT IN (100, 101, 102) OR NID_REFERENCE IS NOT NULL)

How do I do that?


texts: Altering the text after a checkbox using the Drupal Form Api

texts:
I got the following issue. A clients wants that the text after checkboxes are links to other pages and thus between ...

I have the following code:

$form['boxes_brands'] = array(
    '#type' => 'checkboxes',
    '#title' => '
Merken
',
    '#options' => $brandArr,
    '#default_value' => $_SESSION['filter_brands_cat'],
);

$brandArr is an array of brands.

I looked in the Form API of Drupal but I did not find an option to do this. I could alter the values in $brandArr but of course that changes the value of the value attribute of the input object too.

Using the prefix and suffix options won't work either because I don't want the checkboxes in the  tags too.

Is there a clean way to do this?


texts: theme style.css is not loading for custom theme

texts:
I am trying to learn Drupal 8 theme development. I am trying to create basic theme
My Folder structure

|-themes
  |  |-custom
  |  |  |-contra
  |  |  |  |-css
  |  |  |  |  |-style.css
  |  |  |  |-contra.info.yml
  |  |  |  |-contra.libraries.yml

My contra.info.yml is as follows:

name: contra
description: 'Drupal 8 starter theme'
type: theme
core: 8.x
libraries:
   -'contra/global-styling'

My contra.libraries.yml is as follows:

global-styling:
version: 1.0
css:
    theme:
        css/style.css: {}

I have cleared the cache in Admin->Configuration->Development and also refreshed my browser but I dont see the style.css loaded in view source.


texts:
I am migrating from a table in the database into a Drupal content type.
I have a field that is using a taxonomy reference that has a hierarchy.
The problem i am facing is when the taxonomy is in this format.

Phone->Mobile->Samsung
Tablet->Samsung.

I have the terms hierarchy saved with a comma separator.
Used explode to split and choose only last term and his parent.
The question is how i pick the parent name for that taxonomy term tried the following code since it's the only one i can find regarding this but i doesn't work.

$this->addFieldMapping('parent_name', 'category_parent')
  ->arguments(array('source_type' => 'field_product_category'));

Also i wan to create a different class that imports the terms with they're parents prior to the other migration, what is my best option to create a hierarchy like this

Top Term->Child1->Subchild1->Subsubchild1

Creating a structure like this : Term->Child is easy the problem is when i have multiple levels.


texts: How do I use add the image field Product entity in to my view?

texts:
I'm using Drupal 7.28, Views 7.x-3.8 and Commerce 7.x-1.9.

I've created lots of products in the Products section and I've also created some product displays. For example, I have created a round oak table, square oak table and a rectangle oak table. I have then created a product display called Old Oak Table and I've referenced the three oak tables.

Now I need to create a view that lists all tables. My view needs to show one image from each product display.

I was unable to add the image field to my view - so I added a Product reference and I'm now able to add the Image field which is on the Product entity not the content type.

Now that I've added the image field, my view shows every product image so for example the round table, the square table and the rectangle table - I just need it to show one image from each product display, so for example just one image from the Old Oak Table product display.

Thank you very much for reading.


texts: Set order / weight of user profile core fields against user profile custom fields

texts:
Is it possible to set the order of core fields against custom fields added on user profile page?
I want to bring the status field to the bottom of the list.
I'm trying the code below but without succes:

function MY_MODULE_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
  $form['status']['#weight'] = 100;
}

I want something in the following order for example:

Username (core)
Password (core)
Custom field 1
Custom field 2
Status
(core)

Thanks in advance


texts: LDAP SSO does not authenticate user on homepage

texts:
I have configured ldap sso and it is working so far for all Url paths except for the homepage.

I get authenticated on /user/login/sso and I get authenticated on /whatsoever but I don't get authenticated on /
The settings for Automated SSO is checked and my  settings for Apache look like this:

 <Location />
            AuthType Kerberos
            KrbAuthRealms xyz
            KrbServiceName HTTP/xyz
            Krb5Keytab /usr/local/apache2/conf/conf.d/drdc.keytab
            KrbMethodNegotiate on
            KrbMethodK5Passwd off
            KrbSaveCredentials on
            require valid-user
    </Location>

I did check the default excluded paths in the ldap sso module, but couldn't find the path / there.
I have tried to redirect every not authenticated user to /user/login/sso but somehow this results in "to many redirects"
(I want to keep /user/login/ free for loggin in as admin user without kerberos)

if ($event->getRequest()->getRequestUri() != '/user/login' && $this->currentUser->isAnonymous()) {
  if (preg_match('/\/comment\-([\d]+)/', $current_path)) {
    $destination = str_replace('/comment-', '#comment-', $current_path);
    user_cookie_save(['destination' => $destination]);
  }
  $url = '/user/login/sso';
  $response = new RedirectResponse($url);
  $event->setResponse($response);
  return;

Any idea?


texts: Linking to translated internal content in TinyMCE wysiwyg

texts:
What's the best way to allow editors to link to internal content using the TinyMCe wysiwyg editor in a way that provides the correct alias based on the end user language?  For example, I would like them to enter a link like /blog/some-great-news in the wysiwyg and have it return /de/some-great-news when the reader is viewing the German page.

It looks like CKEditor has something like what I need and I use Internationalization (i18n).


texts: How do I assign a template to the user edit form?

texts:
I am trying to create a twig template for user edit page.

I have tried

/**
 * Implements hook_theme_suggestions_alter().
 */
function my_module_user_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
  if($variables['element']['#type'] == 'form' && $variables['element']['#form_id'] == 'user_form') {
    $original_theme_hook = $variables['theme_hook_original'];
    $suggestions[] = $original_theme_hook . '__bs_' . str_replace('-', '_', $variables['element']['#id']);
  }
  return $suggestions;
}

I have added my template in my module under templates/form__bs_user_form.html.twig

I have also added in my form_alter:

$form['#theme'] = ['bs_user_form'];

and

function my_module_user_theme($existing, $type, $theme, $path) {
  return [
    'bs_user_form' => [
      'render element' => 'form',
      ],
  ];
}

It does retrieve this error:
Argument 1 passed to Drupal\Core\Render\Element::setAttributes() must be of the type array, null given

How can I assign a template to the user edit form?

Solved, I removed my_module_user_theme_suggestions_alter and I got it working.
If anyone has a better solution feel free to add it to the answers.


texts:
I tried to install a second site on a multi-site installation, following the instructions on Set up a multisite.
I am using WAMP Stack. The steps I have followed are the following.

I installed Drupal Core 8.9.x
I configured the directory alias on the Apache server
I renamed /sites/exmaple.sites.php to sites.php and added the   $sites['localhost.sa'] = 'localhost.sa'; line
I copied the example.setting.php file from /site/default to the directory for the second site

The installation of the second site has been successful. The front page loads, but any link redirects to the main site, not the second site.
The Apache virtual host configuration file contains the following lines.
<VirtualHost *:80>

  ServerName localhost

  ServerAlias localhost

  DocumentRoot "${INSTALL_DIR}/www"
  <Directory "${INSTALL_DIR}/www/">
    Options +Indexes +Includes +FollowSymLinks +MultiViews
    AllowOverride All
    Require local
  </Directory>
</VirtualHost>

The Apache directory alias is defined as follows.
Alias /sa "C:\wamp64\www\drupal8\portal/"

<Directory "C:\wamp64\www\drupal8\portal/">
    Options Indexes FollowSymLinks MultiViews
  AllowOverride all
  <ifDefine APACHE24>
        Require local
    </ifDefine>
    <ifDefine !APACHE24>
        Order Deny,Allow
    Deny from all
    Allow from localhost ::1 127.0.0.1
    </ifDefine>
</Directory>


texts: db_select query for given sql query with equi join

texts:
I'm trying to do a equi join but it isn't working.
I have 2 tables:
Table 1 - taxonomy_term_data with fields "tid,vid,name,description,format,weight etc"

Table -2 -taxonomy_term_hierarchy with fields "tid and parent"

I have sql query with me it is working fine. This is the query "select t1. *,t2.vid,t2.name from taxonomy_term_hierarchy t1, taxonomy_term_data t2 where t1.tid = t2.tid AND vid=2 limit 5;"

I just want to get tid,name,vid from taxonomy_term_data table and parent from taxonomy_hierarchy table in db_select query format


texts: How to track field changes in custom (ECK) entities

texts:
I'm using Feeds to import an online spreadsheet into Drupal (ECK) entities.
This goes okay but there doesn't seem to be a module (?) that allows to view the tracked changes in the entity fields.
There is one module that is promising but doesn't yet support custom entities: "Track Field Changes"https://www.drupal.org/project/track_field_changes

So the question is: is there an alternative module or way to view changes of entities, especially the field changes?

I tried the diff module but that doesn't give an overview of entities that have changed?


texts: how to hide the facet api block if it has only one item?

texts: I have to hide the Drupal facet API block if it has only one item. Is there any settings available or should I go with any hooks?


texts: Add class to a views row tr tag if a certain condition is met

texts:
Hello I have the feeling that i fight against drupal currently.

I created a view called "customview" and i want to have the output in a table. Now i want to evaluate some values in a row and if the condition is met add a class called "colorthisred" to the table row (tr). Is there a module which can do this. I tryied to do it programmatically but failed, because i only was able to change the individual fields...but i need the whole row...

I would greatly appreciate any help with that, since i'm totally stuck for hours!


texts: Organic Group activity with grouped results

texts:
I'm currently running a D7 system and want to build an admin-only view of Organic Group activity.

I want that view to have two exposed filters:

Group name
Date posted

In a nutshell  user should be able to select the 'group name' and 'date posted' and gets presented with a list of content which was posted within the group X form 'x date' to 'y date'.

Something like:
Following items has been posted in the group 'X'

news total 32
webforms total 12
galleries total 10

Any help would be much appreciated.


texts: What is the difference between Query build time Query execute time View render time in drupal veiws

texts:
I'm using drupal views and set Live preview settings enabled.
I'm curious about the difference between three factors: build time, execute time and render time. Sometime when I change a filter or sort criteria one of them increases and another one decreases.

So which one should be lowest? Which one affects on page load speed? What is the difference between them?


texts: What is the best (secure) way to run PHP code on a Drupal 8 system?

texts:
I am pretty new with Drupal. I have installed Drupal 8.17 on my webserver and now I am configuring it.

It runs on Ubuntu 16.04 with Apache 2.4 and PHP-7.0, the DBMS is PostgreSQL 9.5.

I would like to execute some PHP code is some pages. I have read that there was PHP Filter in Drupal 7, but it is now moved to modules and it warns user than:

  Warning
  Enabling this module can cause security and performance issues as it allows users to execute PHP code on your site.
  There are better alternatives out there that do not expose such vulnerabilities on your site.

But I cannot find any alternative over the web. Then I found Drupal SE, and I am asking for user advice: What is the best way (I mean secure way) to run PHP code on a Drupal 8 system?

I must connect another PostgreSQL DB, perform query on it and display results in Drupal. Essentially this will be done in pages that only administrator can read an modify.


texts: How do I code to take action when a VBO (bulk action) is finished?

texts:
I've recently coded a few Drupal\x\Plugin\Action classes that respond nicely to my VBO (now bulk actions?) in Drupal 8.  Now I'd like to implement a hook, or whatever is required, to take action when all the entities in a selected action have been processed...essentially a VBO post-process hook like we had with hook_views_bulk_operations_finish in Drupal 6.  Where and how can I implement that?

I see no obvious hook in D8 to do this, and unfortunately, I've been unable to get Rules to work in D8 (still really confused by Rules and Actions configuration) so I really don't want to go down that path if I don't have to, yet.


texts: Install routinely failing after database authentication

texts:
I am having the worst time installing drupal 7 on Ubuntu 14.04 on an amazon aws ec2 instance and I don't know why. I've never had this much trouble before. No matter how closely to a T I follow these instructions: https://www.digitalocean.com/community/tutorials/how-to-install-drupal-on-a-virtual-server-running-ubuntu-12-04 (i really can't imagine 12.04 being that different from 14.04, i'm not doing anything fancy) it always results in the following failure:

So I get the LAMP stack installed and set up and verify it's working correctly. And I create the database and the database user and verify that that's all working. And I download and move all the files to /var/www/html and start the install. Everything goes fine until I hit the database connection stage. I put in the credentials, it thinks, then the database connection page refreshes and the fields are empty. At this point I go and I check the database and there are 31 tables created by Drupal, so it is connecting and modifying the database.

So what else can I do but restart the install, and when I do it jumps to the site information page, so I add that information, save it and I get the following error:

Fatal error: Call to undefined function field_attach_load() in /var/www/html/includes/entity.inc on line 321 (which would otherwise be a WSOD, but at least I have development debug turned on)

If I just go to the site now, the default drupal page comes up but only with:
Page not found
The requested page "/" could not be found.

It's really throwing me here, I've Googled the error and the results are just so all over the place and I have no idea why I can't even get this thing installed before something goes wrong. This is not my first time installing a drupal site, have done it many times before on ubuntu servers from amazon aws and non-virtual servers.


texts:
I have a content-type with 4 fields each of which is a term reference. There are 100 nodes each assigned 4 term references. I have accidentally deleted one of these fields from the admin>structure>content-types>mycontent-type...resulting in all 100 nodes losing the term reference this lost field contained.

After installing the Database Admin module I could see that the database for my deleted field was still present, it had been renamed to something like "field_deleted_field_74"

Using mysql I have been able to rename this database back to "field_data_field_originalname" - i.e. using the original machine name for the deleted field
Furthermore I have been able to switch the value of the deleted column inside this database from '1' to '0'.

I have done the above with the other 'ghost' database that I found that was called something like "field_revision_field_74" ...

My problem now is that my renamed field is not appearing as a pre-existing field on my content-type manage fields display nor at admin>reports>fields list.
When I run 'drush field-info fields' it is also missing.

How to I bring it back? I am assuming that there is another database that refers to it that I need to edit.

Thanks!


texts: I wanna create a page in my module with file managed upload, such as  How make it? Show me source code please?


texts: Image Style in Views Module Is Not Working Properly?

texts:
Image style in views was working fine, but then I don't know what happened. Please see this video http://www.youtube.com/watch?v=PHTh356WgfM&feature=youtu.be.  I have several days tried to fix this problem but I can't figured out. Any help would be appreciated. Thanks.

This is what I want, I want views to resize an image to 300px by 300px using the image style I was able to accomplished. Here is my website: carlosgandara.com


texts: How to implement a horizontal set of translation links for every node?

texts:
I want to add a hardcoded translation block to my page.tpl.php, to link to a translated version of every node + a translated interface.

The Language Switcher Dropdown module did the trick, but I want a horizontal set of links and need something simpler.


texts: Display set of Views rows with different view modes

texts:
I have a Drupal 8 View with a set of rows, which are each rendered as a compact list teaser. Additionally I need to display those rows inside the same view in a another view mode (e.g. "grid teaser" with an extra image). As a result the visitor should be able to switch between the different view modes by toggling the display.

The template views-view.html.twig should contain this:

  {{ rows }}

  {{ rows_grid }}

I don't really know how to render those additional rows. I thought about using the hook template_preprocess_views_view:

function template_preprocess_views_view(&$variables) {

  // collect node ids
  $nids_rows = array();
  foreach ($variables['view']->result as $row){
    $nids_rows[] = $row->nid;
  }

  // load nodes
  $nodes_rows = Node::loadMultiple($nids_rows);

  if(!empty($nodes_rows)){
    // get views of nodes as grid
    $variables['rows_grid'][] = node_view_multiple($nodes_rows, 'grid');
  }
}

But the resulting render array is not in the same form like $variables['rows'] and I'm not able to loop through those rows_grid to wrap them with specific html (like in views-view-unformatted.html.twig).

Is there a function like view_load_rows($nids, $view_mode)? Or is there a way to alter the render array with some additional keys like '#theme' to get a real rows render array?

Maybe there is even an much simpler way to accomplish this. Any Ideas?


texts: What are the replacement patterns or tokens for Profile2 URL of a particular user?

texts: I just need to know how to key in token replacements for any given users different profiles. In my projects a user can have multiple profiles associated with the account. I am just having problems with tokens on how to locate or recreate those urls.


texts: How to add a Google Maps containing GeoRss Feeds on a page - don't know exactly what module to use

texts:
I have developed a Google maps following the example from https://developers.google.com/maps/documentation/javascript/examples/layer-georss but I am new to Drupal and I don't know how to include it on a page. Could someone please tell me what module should I use?

Some guidance would be very much appreciated!


texts: Does a third-party module need to implement hook_help()?

texts:
After having spent hours reading through (very old) coding standards and best practices threads on drupal.org, and even trying to revive the Contrib Development Best Practices group on groups.drupal.org which seems to having been abandoned for years, I'm still struggling to getting an answer to whether a third-party module needs to implement hook_help() to comply with the Module Documentation Guidelines or not.
Above guidelines state

All but the most trivial modules should implement hook_help().

Yet, should is not must, which sometimes leads to discussions within the Security Advisory Application Issues Queue.
I was not able to identify someone to ask, whether it is a requirement or a (strong?) suggestion.
As we're currently reworking the PAReview (pareview.sh) tool, it would be great to know for having a distinct severity for a missing hook_help(). That's why I'm hoping to getting a hint from the grey-bearded Drupalists here, on where to address this inquiry.
Don't get me wrong, I don't want to start a discussion here, nor subjective answers on whether there should be a hook_help or not. I just want to know which board is deciding such issues and where to ask when it comes to contrib module coding standards and best practices.


texts:
I have installed Drupal Commerce with latest version and also Commerce Paypal + Commerce Paypal Express Checkout.

EC is working so far, but I can´t find the Confirm-Pane on the checkout page/configuration.

Can somebody give me a tip what to do to make it visible on the checkout configuration.

It should be visible under "Confirm Order" and its called:
 "Express Checkout review and confirm (only to be used on the confirm order page)"


texts: How to add google maps js without breaking jquery?

texts:
So, I'm trying to implement a custom map using the Google Maps API in addition to a Google Map view. I'm working with an up-to-date D7 install. The reason for this is that I need to have multiple layers of content types, which isn't possible with the default views user interface. The view needs to show multiple entity types as individual layers, which I hope to implement as GeoJSON data layers from GeoJSON views through a custom map implementation.

The problem is my current approach is breaking my existing GMAP views and is interfering with jquery functionality.

I get a series of 'jquery is undefined' errors, as well as broken UI functionality, leading me to believe something is making variables collide.

I am approaching this by creating a block in a custom module and adding the markup and JS necessary through the module like so.

add js files $path = drupal_get_path('module', 'gmap_json');
drupal_add_js($path. '/gmap_json.js', 'file');

function gmap_json_block_info() {
    $blocks = array();
    $blocks['hello_world'] = array(
      'info' => t('Hello world'),
    );
    return $blocks;
  }

  function gmap_json_block_view($delta = '') {
    $block = array();
    if ($delta == 'hello_world') {
      $block['subject'] = t('Hello world');
      $block['content'] = t('This is the block content.');
      $block['content'] .= '

';
    }
    return $block;
  }

And my map js is here

function initMap() {
    map = new google.maps.Map(document.getElementById('json-map'), {
      zoom: 4,
      center: {lat: -28, lng: 137}
    });

    map.data.loadGeoJson(
        'https://storage.googleapis.com/mapsdevsite/json/google.json');
  }

The problem seem to be with how I'm adding my scripts, since leaving the drupal_add_js statement out of the module is what triggers the error.

So, how am I messing up in adding the js to the page? What's the right way to do this?


texts: How do you change the css of node editing forms?

texts:
This ought to be really simple -- all I want to do is increase the font size of the textfields in the standard node editing form (node/123/edit).  This should be a trivial tweak of a stylesheet, and I've just spent the last hour adding different bits of css to my standard theme style sheet, with no effect.  Nothing is affecting the style of the fields and I can't even see (via browser Inspect Element) what stylesheet is setting the font size.

Has this changed in Drupal 7?  I'm clearly missing something; can anyone offer advice?


texts: How to get the publishing and menu fields from the node edit form in the "Manage fields" tab?

texts:
I am wondering what is the cleanest way to customize the core node edit form fields like the publishing and menu options fields?

They do not appear in the Manage fields tab, otherwise I would be able to organize them using modules like Display Suite, Field Groups, and either Conditional Fields or Field Conditional States as I do with other fields.

Here are a few example of things I would like to do (I achieved such things in the past with Drupal 6 by altering the form array, but I want to avoid this now since this was more complex, less maintainable and with not enough separation between the presentation and application logic):

Adding supplementary fields to existing tabs: My site has news articles which can be promoted on the front-page (using the standard Drupal checkbox) and/or appear on some other pages (using multiple Entity Reference fields). All these control should be grouped together since they all are publishing options from the end-user perspective.
Core fields availability dynamically depends on custom fields: A user can choose to link the node title and the node's menu link title so changing one will alter the other automatically. In such case the field asking to enter the menu link title must be hidden. However, it must show-up if for some reason the user choose to unlink them and set different values for both titles.
Core fields availability dynamically depends on other core fields: Some content can be created either with no menu item, in which case it can only be referenced by other nodes, or with a menu item, in which case the end-user can choose to publish or unpublish it. The Published option should therefore be available only when the user chose to create a menu item since it is not relevant otherwise for this content-type.

I tried with Display Suite extra's Extra fields feature, but it only adds the fields on the Manage display tab, and not the Manage fields as I need.

My current solution is to add standard custom fields to the node, hide the default ones and code the logic in hook_node_presave() for instance, but I do not know if there any cleaner solution?


texts: How to add a "continue shopping" button after emptying cart in Ubercart?

texts:
This is really a weird issue. I get this on my ubercart page without any possibility for redirection:

One hint I'm eager to try is a drupal_goto function.

But how do I add this to which file to which line specifically?


texts: Block view for only the images uploaded to the image field of the current node

texts:
I am working in Drupal 8.

I have a content type defined with an image field. For each page of that content type, I upload one or more images for its image field.

I want to create a block view in Views that presents images in a grid. How do I filter the block view so that the only images displayed are the ones for the image field of the current node? The block will be placed in the block layout for this content type. It is easy to create a view that creates a grid with images from all pages of this content type. I am stumped on how to filter the view so only images for the current mode are displayed.


texts: Why field tables are not getting removed when I remove the field?

texts:
I have a content type with 20 different fields.

Now the project requirement changed and I dont need 15 fields of them. So I removed all those unwanted 15fields from content type.

But the database is still holding all the 15 tables and also the revision table, Why?
What happens if I remove it?

I feel like having these many unused tables in database might impact the performance. Will it really have impact on the performance?


texts: Commerce: Update weight value based on quantity on cart

texts:
Use Commerce Physical module to add weights to your products. E.g. product 1 is 1kg, so it means quantity of 2 would be total of 2kg, but adjusting the quantity on cart page, does not adjust the weight field value.

In this demo you can see how adjusting quantity and updating the cart updates the Total field, but not Weight.


texts: Are there any modules for questions and answers website in Drupal 6? I want it to have theme.


texts: How can i give alphabets only validation in webform?

texts:
I can give only required and maxlength validation in webform fields , How can i give

alphabets or numbers only validation in webform textfields  ??

UPDATE

I used hook like this :-

function mymodule_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'webform_client_form_48') {
        if (!preg_match('/^[A-Za-z]+$/', $form['submitted']['name']['#value'])) {
            // $form['submitted'][$key]['#attributes']['class'] = 'error';
            form_set_error('name', t('Please enter alphabets only for Name.'));
        }
    }
}

this is working . but the order of displaying message is not proper , the first three

message is coming from ajax form validation and fourth one is from the hook , but i need

the fourth message should come first .


texts: How do I create a field template or template override for a specific display mode?

texts: Because in the Drupal 7 Commerce module, the fields, 'sku,' 'title,' and 'status' aren't editable by Display Suite field wrappers, I'm unable to edit the field wrapper via the Drupal front end, I need to use a template to update "commerce-product-title.tpl.php" with an H2 wrapper, but I only need this for the 'product_full' view mode on all products. Is there a way to target this field in this display mode only with a template or theme function?


texts: Why is it sometimes $node->field_name[0], and sometimes $node->field_name['und'][0]?

texts:
Sorry for the code in the title, I couldn't think of a clearer way to ask it.

I have several nodes of the location content type, and a view outputting teasers of those nodes. I want to do some custom stuff in node--location.tpl.php to affect the teasers everywhere they're displayed. When I do a simple dpm($node) to get at the variables, some field values are not always in the same place.

For instance, I have field_phone that just has identically formatted phone numbers. For the first node in this view, that field is structured as $node->field_phone['und'][0]['safe_value']. But for the second node, it's simply $node->field_phone[0]['safe_value'].

I know that und has to do with translations, and perhaps means "undefined". I'm not doing anything with translations or localization or languages on the site, so it's not like this node is any different from other nodes that way.

What causes this, and is there a function or something that can help me test for and get at the value easily, or do I have to roll my own?

EDIT: Chris Rockwell below points out field_get_items(). This seemed to solve my problem on the site I was working on the other day. But now, on a different site, it's failing for exactly the reason I bring up here.

I have a view that outputs three nodes. For some reason, when I dpm($node) in the node--node-type.tpl.php file, I get six variable dumps. The first one has $node->field_link_image['und'][0], while all five others — INCLUDING the duplicate of this same node — just has $node->field_link_image[0]. And now, field_get_items() is silently failing and returning false on those last five nodes.

So I go back to my original question: What causes this difference between some node variables and others, and what can I do about it?


texts:
I'm looking for a way to convert a route to an Url with contextual filters added. I can do it manually and it works, but I still think there should be a better, "Drupalish" way to do it.

Url::fromRoute('view.view_name.display_name')) converts to the correct base route of the view. However, there doesn't seem to be a proper way to attach filter values to that Url.

Url::fromRoute('view.view_name.display_name', ['value' => $value]) would be nice but, in the case of views, this only adds query values. It would obviously work if the route was declared in routing.yml as a normal route with parameters (if the value passed in the array corresponds to a declared parameter, it will be replaced all right) but this isn't a manually declared route but one belonging to a view page.

As I said, string manipulation on the Url works, of course. But it just doesn't feel right.
Although the question is universal enough, if a use case is needed to see why this would be necessary, consider a view that shows the list of some entity and a corresponding archive block that summarizes the entities into links pointing to years or months. The block has to assemble links that point to the view the contextual filter added, eg:

/documents/listing/2020
/documents/listing/202006

where the view page itself resides at /documents/listing.


texts: How do I provide a "delete" link for comments?

texts:
For example, if I am posting a comment, how can I delete it?
How delete links should be given?


texts:
I am trying to build a page with Search API and Panels. I have created my search views with contexts, but I am unable to view any facets in my panel page.

My facets show up in regular blocks, but they don't show up in panels regions.

I have been able to find information regarding this issue from this Search API Issue. Apparently the order of the way the view is placed in panels is the problem, and if I re-order my facets and views in Panels, the facets show up properly.

In comment #28 of this issue, there is a way to set up a context to be able to display the facets anywhere on a panel page, but the wording is very confusing.

  EclipseGc actually gave me a quick walkthrough on how to do this the
  "proper" way. It takes a bit more time and effort but its a lot more
  flexible and effective (plus it works without having to try and figure
  out the order of blocks like above). The basics of it are:

  Create a context view for your display.
  Go to contexts in your panel and add a view context with your view.
  You will now have a new "view context" option when adding content
  to a region.
  Choose view row (this is where it gets a bit more complexed as you
  have to manually build grids etc using regions and rows and so forth).
  You can now add your facets using the miscellaneous content option
  in panels wherever you want in your panel!
  I had to use to the default view exposed forms as the context view
  exposed forms didnt want to inherit the path. These can also go
  wherever and work!

What is a "context view" and how do I add it? It is a ctools context? Or is it a new context in views, or is is a context having to do with the contexts module?

Thanks for your help!


texts:
I am trying to implement the Multistep tutorial (Step 9) from http://drupal.org/node/717750 in Drupal 7, however in the following function

function my_module_my_form_new_name($form, &$form_state) {
  $form_state['storage']['new_name'] = TRUE;
  $form_state['rebuild'] = TRUE; // Will cause the default submit function
                                 // to be skipped.
}

I just cant set the $form_state['storage']['new_name'] = TRUE;
therefore i can't catch it in :

 if (empty($form_state['storage']['new_name'])) {
    $form['new_name'] = array(
      '#type' => 'submit',
      '#value' => 'Add another name',
      '#validate' => array('my_module_my_form_new_name'),
    );
  }

I can however declare it in the beginning of the function, which can be executed fine. So how can I set it in Drupal 7?


texts: How to display different image on hover and content in pop-up?

texts:
I am displaying a list of images using Views. I would like a different image to display on hover, and then text/content to be displayed in the pop-up. I am trying to use Colorbox module, but can't figure out how to display a different image on hover, or how to display text/content in the pop-up.

Any help would be greatly appreciated.

This is the html that the Colorbox trigger field (set to Image) produces with "Enable Colorbox load" and "Enable Colorbox inline" options both UNTICKED:

What am I missing/doing wrong? The popup is still not working.


texts: Change value of user reference based on node reference

texts:
Is there any way to refine the user reference field values based on node references value.
Let me explain : I have one node reference field and user reference field in one content type and another node reference is added to user profile fields. Both node reference are of same content type with different name. Is there any way to refine the view of user reference field based on node reference field value.

 Image of User Profile

 Image of Content type


texts:
i'm looking for solution on how to create personality quiz. The Quiz module doesn't have an option to label answers - I need to find the most popular label checked and not the total amount of points.

It could be like this: 2 questions, 3 answers each. Each answer for each question has labels: "label one", "label two" and "label three" and they are randomized. I answer both questions and get "label two=2", which is the most popular label and therefore I am forwarded to node2 with some description.

Is it possible to do this with forms?


texts: Upgrade Backup and Migrate from 2.x to 3.x

texts:
Is it possible to upgrade without losing profile settings?
Or is it simply uninstall 2.x, install 3.x and recreate profile settings?


texts: Drupal7 provoking ajax error in Views (installed in sub folder)

texts:
I have installed drupal 7 in a subdirectory of my domain. The subdirectory is masked as explained on the following site: http://kahthong.com/2011/05/how-serve-drupal-sub-directory-web-root-0

Now, this works pretty well EXCEPT when an AJAX query is done by the drupal backend. This will always produce an error. One example is in the Views-UI module: when I try to edit some setting in a view, an error like the follow will pop up:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: ***mydomain****/en/admin/structure/views/ajax/display/store/page/row_options
StatusText: error
ResponseText:
ReadyState: 0

My guess is that the URL rewriting specified in the .htaccess is not being applied. Therefore my two questions:

Why does the URL rewrite not work for AJAX queries
How can I fix this?


texts: Add custom classes or theme a custom form

texts:
I have a custom form generated in a module.

I want to style the individual inputs by adding classes to them.

Can I add them through the buildform()?

public function buildForm(array $form, FormStateInterface $form_state) {
  //Return array of form API elements
  $form['location'] = array(
    '#type' => 'textfield',
    '#placeholder' => 'Enter your suburb or postcode...',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => $this->t('Go'),
  );
  return $form;
}

If yes, how would I do this? I can't seem to find a good reference for parameters that can be passed into the $form array.

Alternatively, is there a way to pass the elements to a theme template like can be done with custom blogs or controllers?


texts: How can I conditionally alter search API relevance score?

texts:
I must be missing some core concept of search API somehow, but I am stuck. The goal is to alter search API results depending on a flag, like Give flagged products in search API a higher search score? however this time without SOLR, but with database backend instead.

I can see all flagged fields properly indexed, so there is a line that associates the content entity id with the user who flagged, and now I want to increase the relevance score of the results, so that items flagged by the current user are always shown first.

I have hijacked the SearchApiDbService class and I did add the following line in postQuery (I also wonder why this hook does not exist, but that is not relevant for now):

drupal_alter('search_api_db_query_results', $results, $query);

This should allow me to alter the search results right before search_api_db hands them over to the search API right?

So now I use the alter hook as follows:

function mymodule_search_api_db_query_results_alter(&$results, SearchApiQueryInterface $query) {
  global $user;
  $uid = $user->uid;

  // Fetch a list of content entities that the user has flagged.
  $drupal_db_q = db_select('search_api_db_MY_FLAG_FIELD_TABLE', 'f')
    ->fields('f')
    ->condition('value', $uid);
  $items = $drupal_db_q->execute()->fetchCol();

  // Iterate over results and multiply score of flagged items.
  foreach ($results['results'] as $key => &$result) {
    if (in_array($key, $items)) {
      $result['score'] *= 10;
    }
  }

dpm($results);

}

In $results I can see that the scores have changed, but the order of the items on my views results page has not, even though I am sorting by relevance.

It has to be something simple, or I am completely misunderstanding how the score value works somehow?

p.s. Since this is conditionally I don't think altering the search api query directly makes sense because I found no way to boost any field scores there. Directions on how to achieve that are welcome too.


texts: Restricting "view content" to members of a group

texts:
I would like to make a site with content that anonymous users can read, and private content that only group members can read.

How do I achieve this? I have installed Group, but any group content I add can be viewed by anonymous users.


texts: How to import multiple terms from XML into a node?

texts:
I am trying to import all the Destinations as taxonomy terms using following XML. In my situation, the list is not a comma separated list. It is as follows:

<product>
    <category>Ship</category>
    <id>000032</id>
    <Description>The description comes here</Description>
    <list>
        <Destination>
            <DestinationName>Dest 1</DestinationName>
            <DestinationCountryISOAlpha3>US</DestinationCountryISOAlpha3>
        </Destination>
        <Destination>
            <DestinationName>Dest 2</DestinationName>
            <DestinationCountryISOAlpha3/>
        </Destination>
    <list>
</product>

I have a taxonomy called destinations and the list is already imported. Now how can I import Destinations list of a product as a term reference for the product node. I am using feed module, Feeds XPath Parser, and Feeds Tamper modules?


texts: How to show new added filed to comment table in comment form page

texts:
I am writing a module which is adding a new filed to comment table, and in the comment form I want a new filed to be displayed, saying: : " Which paragraph you want to put comment on?".

I have already added the new filed to comment table, I just do not know  what hook should I use, so this new filed will be also shown on comment form.


texts:
I have a book with some child pages and I'd like to show the last modified date of each corresponding node near them in their menu tree links, or a red badge near the nodes updated during eg. the last 3 days...
How to pass the changed_date of nodes to menu links?

Thank you


texts: Create a connection using FileTransferFTP

texts:
I want to create a FTP connection using the FileTransferFTP class.

How can I do it?


texts: module_load_include fails on WebTestCase post

texts:
I am writing test cases for my website using SimpleTest module. One of my test cases uses the following sequence

    $this->drupalGet( "myurl" array('query' => $params));
    $this->assertFieldByName('giftaid_granted','', "Giftaid checkbox exists");

    // now we will also attempt to submit a form and check that it goes out
    $this->drupalPost(NULL, array(), t('Submit'));

When I run this code, I get an exception in the test

Fatal error: Call to undefined function module_load_include() in ...sites/all/modules/mymodule/includes/entities.inc on line 3

1   0.0001  235336  {main}( )   ../index.php:0
2   0.0023  660936  drupal_bootstrap( ) ../index.php:20
3   0.0025  678144  _drupal_bootstrap_page_cache( ) ../bootstrap.inc:2236
4   0.0029  757040  drupal_bootstrap( ) ../bootstrap.inc:2378
5   0.0044  1174072 _drupal_bootstrap_variables( )  ../bootstrap.inc:2244
6   0.0046  1199928 variable_initialize( )  ../bootstrap.inc:2480
7   0.0102  1626520 array_map ( )   ../bootstrap.inc:935
8   0.0102  1631120 unserialize ( ) ../bootstrap.inc:935
9   0.0102  1652040 spl_autoload_call ( )   ../bootstrap.inc:0
10  0.0102  1652112 drupal_autoload_class( )    ../bootstrap.inc:0
11  0.0102  1652376 _registry_check_code( ) ../bootstrap.inc:3107
12  0.0143  2484552 require_once( '...sites/all/modules/mymodule/includes/entities.inc' )   ../bootstrap.inc:3186

The offending line is apparently the module_load_include('inc', 'mymodule', 'includes/shared'); on top of my entities.inc file.

As best I can guess from the trace, there is some sort of cached variable causing class autoloading in bootstrap, before module_load_include function is defined. But form submission on a normal page works just fine.

Am I using module_load_include incorrectly? Or is it some problem with the SimpleTest?


texts: Custom Fieldable panels pane template rendering the Field collection items

texts:
I am using Fieldable Panels Panes (FPP). I created a custom FPP and I am using  Field Collection items into my custom FPP.

I want to customize the rendering of Field collection item fields in my FPP template file.

For example: fieldable-panels-pane--my_custom.tpl.php is my tpl file, where I am unable to customize my_field_collection_items fields seperately by using some classes.

Is there a way to customize these fields and render the output in desired way?


texts: Comments: "You are not authorized to post comments."

texts:
I'm using Drupal 7.
I'm trying to add comments to a node but I get this error back:"You are not authorized to post comments".
I can't find in the code which variables are being checked to don't allow me to post a comment.
Can someone tell me where to look in the code?
Thank you very much


texts: Routing Parameter Directly Passed And Upcast

texts:
Has anyone come across a way to both pass a dynamic route parameter as well as upcasting it?

something like:
/module/custom/mymodule/src/Routing/MyRoutes.php

$routes["my.custom.route"] = new Route(
  "/my/custom/route/{name}",
  array(
    '_controller' => '\Drupal\mymodule\Controller\MyController::view',
    '_title_callback' => '\Drupal\mymodule\Controller\MyController::title',
    'slugs' => '{name}',
  ),
  array(
    '_permission'  => 'access content',
  ),
  array(
    'parameters' => array(
      'name' => array(
        'type' => 'entity:my_entity'
      ),
    )
  )
);

This way I could have both the object due to upcasting and the original slug part from the url for use in my controller.


texts: In header region: having 2 blocks on inlined

texts:
In drupal7, I need to have 2 blocks in the header region, a search form and a menu.

By default, the theme "Skeleton 7" would stack up these 2 blocks.
How can I edit region--header.tpl.ph to have these 2 blocks on the same line?


texts: Change page title on user-profile using a field value from Profile2

texts:
Normally the /user/uid page shows the username as page-title. I'm using the Profile2 module to leverage more fields to my users, including a 'full name' field which I'd also like to use as the page title.

How would I go about this?


texts: How to enable special characters in Drupal Menu?

texts: I am using Drupal5 and Nice Menu Module. I need to provide a URL in my Menu dropdown. There are special characters in it. When I add the complete path it works but on giving the relative path special characters doesn't show up(it gets replaced by the hex code).  How can I display the special characters in Drupal Menu Dropdown as it is?


texts:
I added some users to my site.

Is there a way to add roles to thousands of users  at the same time?

Thank you.


texts: EntityQuery not returning content based on language

texts:
I'm trying to get a list of all of a specific content type, but my entityQuery is only returning the original language of the site (English). Here's my code:

  public function fetchDocumentReferenceOptions() {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('node')
  ->condition('status', 1)
  ->condition('type', 'document')
  ->condition('langcode', $language)
  ->sort('title', 'ASC');

$nids = $query->execute();

$nodes = node_load_multiple($nids);

$options = [];

foreach($nodes as $node)
{
  // check if the document (content type) has an uploaded file
  if ($node->field_document->entity) {
      $options[$node->id()] = $node->getTitle();
  }
}

return $options;

}

This is how I call the function:

'#options' => $DocumentReferenceCore->fetchDocumentReferenceOptions(),

What I am expecting, based on condition for langcode would be that, if, for example, I am editing a Chinese language node (translated from the original English node), I should see Chinese nodes, and the content being returned, but instead I am still seeing the original English content.

What am I doing wrong here?


texts:
I am trying to get Secondary Tabs to work. I want to create a local tab with sub tabs.

View | Edit | Reg Report

Reg Report
       Reg Report | Pre-Registration | Post-Registartion (Secondary Tabs)

I tried this method (Menu secondary tabs) and have it showing the naviagation, however when I add the path for Photo to my second view the navigation goes away.

Here is the code:

/**
 * Implements hook_menu().
 */
function secondary_tabs_menu() {
  $items['node/%node/update'] = array(
   'title' => 'Update',
   'page callback' => 'price_callback_function',
   'access arguments' => array('access args'),
   'type' => MENU_LOCAL_TASK // This adds the 'Update' tab to the node path
 );

 $items['node/%node/update/price'] = array(
   'title' => 'Price',
   'type' => MENU_DEFAULT_LOCAL_TASK,
   'weight' => -10
 );

 $items['node/%node/update/photo'] = array(
   'title' => 'Photo',
   'page callback' => 'callback_function',
   'access arguments' => array('access args'),
   'access callback' => TRUE,
   'type' => MENU_LOCAL_TASK // This adds another tab under 'Update'
 );
  return $items;
}

/**
 * Implements hook_admin_paths().
 *
 * Show admin theme on the participants totals report.
 */
function secondary_tabs_admin_paths() {
  return array(
    'node/*/update' => TRUE,
  );
}

My goal is to create a sub-section where I can click through a few views within this secondary tab area.

Also, I was trying to add the Admin theme to the views as well.I have it in code but it doesn't seem to work.

Can someone guide me towards what I might be missing. Thanks!


texts: How to access Drupal variables in a PHP included file?

texts:
I have a snippet of HTML that I've saved in my theme as mysnippet.inc. I'm using this code in template files (eg. node.tpl.php) to include it:

<?php include($directory."/includes/mysnippet.inc"); ?>

This is working fine, but the snippet also needs to access Drupal variable $node_url. So I tried to global it into my snippet:

<?php global $node_url ; ?>
<?php print $node_url; ?>

This doesn't work.

What would be the best way to achieve this? Should I be using template.php to create a variable containing my code snippet instead?


texts: Creating comments and nodes with Services 3.x and JSON

texts:
I'm having trouble getting services to recognize a POST to /comment.json.
I have a similar issue with creating nodes as well.

The following is the error I get:
HTTP/1.1 406 Not Acceptable: Missing required argument comment

This message comes from the file: /services/server/rest_server/includes/RESTServer.inc
Specifically, the lines:

  elseif (!isset($info['optional']) || !$info['optional']) {
    return services_error(t('Missing required argument !arg', array(
      '!arg' => $info['name'],
    )), 406);
  }

basically, it seems to think the "comment" argument is missing (and it's not optional).

This is one of many bits of JSON I've given it (posting a comment to node 8801)

{name:"test",language:"und",cid:"0",pid:"0",uid:"17593",nid:"8801",
comment:{subject:"Subject of the comment, if not entered it will be auto-generated",
comment_body:
{und:[
[{value:"value of the field comment in the comment, remember that in D7 we can create fields for comments too", format: "full_html"}]
]}}}

It's perfectly valid (based on other online JSON checks).  It also matches what I see in the services test examples at /services/test/functional/ServivesResourceCommentTests.test

however, I always get the same error message.
This seems similar to:  Drupal 7 services json node object

which is also unresolved.  Can someone help me with the proper JSON formatting?  Really, all I want to do is pass it something like:

{ nid : 8081 , uid : 17593 ,comment:{comment_body:"test",subject:"test"}}

my http headers seem ok and user/login worked fine.


texts: Remove nodes individually from Solr Search index

texts: I know you can choose which content types to exclude. However, is there a way of removing specific nodes from the Solr index?


texts: How to create a "read more" button using AJAX in a module?

texts:
I'm working on a really simple module in Drupal 8 to get the hang of things. What it does (or rather, what the page I'm asking about in this question does) is grab some data of a bunch of simple article-style entries, and display them.

What I would like to be able to do is to have it only display the first few (say, 5), and then have a "Read more" button, which uses AJAX to display the next 5, lengthening the page so it now shows 10.

Here is the controller as I have it at the moment. The routing.yml file points to MyController::build. For the sake of simplicity, I've left out exactly how it gets things from the database, and some simple processing (in particular, image gets converted from a managed_file in the database into a URL to the image).

class MyController extends ControllerBase {

  public function build() {
    $stuff = $this->getStuff();
    return array(
      '#theme' => 'my_theme',
      '#stuff' => $stuff,
      '#attached' => array(
        'library' => array(
          'my_theme/style',
          'my_theme/readmore',
        ),
      ),
    );
  }

  private function getStuff() {
    $stuff = getStuffFromDatabase();
    $result = array();
    foreach($stuff as $key => $item) {
      $tmp = new \stdClass();
      $tmp->id = $item->id;
      $tmp->title = $item->title;
      $tmp->description = $item->description;
      $tmp->image = $item->image;
      $result[] = $tmp;
    }
  }
}

Which then gets sent to a template file:

    {% for item in stuff %}

{{ item.title }}

        {% if item.image is not empty %}

        {% endif %}
        {% if item.description is not empty %}

{{ item.description }}

        {% endif %}

    {% endfor %}

<form method="post" action="" onsubmit="readmore()">
  <button name="read-more" type="submit">Read more</button>
</form>

What I want is a way to change this set up so that at first the controller only sends a few of the entries, but when the button is pushed, it sends the next few, and the template displays the new ones as well as the old.

Thanks

Okay, I think I may have worked out to at least make a start on this problem. I've followed this tutorial, and want to get a small message displaying at the bottom, to at least get a feel for how Ajax works with Drupal 8. I've added

to the bottom of the .html.twig file.

I created a file identical to his ReadMessageCommand.php, except named mine MyMessageCommand.php (and renamed the class inside it accordingly). The function render has myMessage in place of readMessage.

I added a method called myMessageCallback into MyController, which works the same as in that guide, but with my_module_load_message and MyMessageCommand in the appropriate places.

To readmore.js, I added the function from the above guide, but with readMessage replaced by myMessage. I also added the following, just so I can know more easily if the function is at least being called.

console.log(response.subject);
console.log(response.content);

And I added the core/drupal.ajax dependency to the readmore library.

My question is, how do I actually get this function to be called. As far as I can tell, the guide that I've used has no indication of it. How to I get a message to be displayed in the div at the bottom? Once I've figured that out, I feel extending it so that the button acts as a "read more" shouldn't be too much trouble.


texts:
I'm trying to understand how course connects to product in ubercart.

There is a module called Course Ubercart, and I'm trying to create my courses as ubercart products with no luck.

Here's the description of the module:

Course ubercart 7.x-1.0-beta3   Supports Course as an Ubercart product and restricts enrollment to paid courses.
Requires: Course (enabled), Chaos tools (enabled), Universally Unique ID (enabled), Views (enabled), Views Bulk Operations (enabled), Entity API (enabled), Rules (enabled), Entity tokens (enabled), Order (enabled), Product (enabled), Image (enabled), File (enabled), Field (enabled), Field SQL storage (enabled), Store (enabled)

How am I supposed to use this? I have tried creating new products, looking to see if there is anything in the course content type UI for it, and I see absolutely nothing.