texts:
I want to style the label of my select list with bold font and give it some color.

This is the code for rendering form which I am using in a hook_block_view

  $form['dropdown_first'] = array(
    '#type' => 'select',
    '#title' => 'City',
    '#options' => $options_first,
    '#prefix' => '
',
    '#suffix' => '
',
    '#default_value' => $selected,
    '#ajax' => array(

      'callback' => 'get_citylocations_dropdown',
      'wrapper' => 'dropdown-second-replace',
    ),
  );

The #prefix and #suffix is wrapping entire select list and effecting/applying the select list which is not I want. I just want to style the City to something likeCity

Its not working as I expected.

How do i do it?


texts: Where to save larger module content/settings?

texts:
I'm creating blocks in modules and wish to have the block body (content) editable by admins. I'm using hook_block_configure and hook_block_save to accomplish this. Where is a good place to store the block body when edited by the admin (variable is apparently not suitable for larger values like this)?

I was thinking of just creating a custom table in hook_schema but that seems a lot for just one or two rows of data. Plus I would be doing this for several modules that need to provide blocks but also have their content editable by the admin. That's why it would be nice if there was a general storage table like variable but for larger values.

What would be a better way to accomplish this?


texts: How to hide the right and left regions from a customized login page?

texts:
I'm working on Drupal 7, and trying to create one customized login page. I don't want to display the right and left regions in this page; I want a login page with only header, footer and content, where the content would be the "Username" and "Password" fields.

How can I do it?


texts: global static variable to be accessed in comment.tpl.php, node.tpl.php and in page.tpl.php

texts:
I wanted to show some ads inside the content (node, comments) and body.
I decided to add them using the template by adding some lines to comment.tpl.php, node.tpl.php and page.tpl.php

for example in comment.tpl.php I have:

print render($content);
if($id%3 == 1){
  echo "<iframe width='720' height='80' src='#####'></iframe>";
}

I think this is a good way of adding ads

Now that the ad code is repeated in these 3 files, I want to use a Global static variable so that the ad code can be placed in one place and can be access from these 3 tpl.php files

Can somebody please point me how to do it? Or an alternative Method of achieving it?


texts: slideshow images for one specific view, with alot of fields

texts:
I have a product content type which has like 10 fields, so I want to show it in my main page with view, the problem is, I want to show it's multiple images as a slideshow, It's not only images that I can use views_slideshow or nivo_slider or any other slideshow modules, I only want the images to be shown as slideshow, along other text-fields of my node.

I would really appreciate any help, thanks


texts: How to display a Leaflet map in modal window?

texts:
I produce geospatial data in a content type with addressfield and geofield. I can display this data in a Leaflet map as field without any problem. But I have to use here a modal, therefore I render the map programmatically:

<?php
$map = leaflet_map_get_info('google-high-res');
$map['settings']['zoom'] = 15;

$lon=$entity->field_terkep['und'][0]['lon'];
$lat=$entity->field_terkep['und'][0]['lat'];

$features = array(
   array(
        'type' => 'point',
        'lon' => $lon,
        'lat' => $lat
      )
    );
print leaflet_render_map($map, $features, $height);
?>

When I display this map as a field, everything is OK, visitors can see the map as intended (marker in the middle etc.) But if I place it in a modal, multiple issues appear (see in the attached screenshot): Only one map tile is generated and the marker is in the wrong place in the modal as well, it's in the top left corner. I have tried Bootstrap Modal and Colorbox, it doesn't make any difference.


texts: Add CSS file to certain pages only with theme.info file?

texts: If I want to add a CSS file to certain pages only I know how to do this with the drupal_add_css function in the template.php file, but can you also do it with the theme.info file? Or is the theme.info only for adding CSS files globally?


texts: How do I install modules using a module?

texts:
I wanted to install few modules when my module is installed. How can this be achieved?

I am creating a module which requires few other modules to be installed. I want to install them when my main module is installed.

I have placed all those module folders inside one main folder, and I want to create an install file to install those modules when this main install file is executed.


texts: How to call preprocess functions from my custom module

texts:
I have created a custom module that declares a custom image formatter. Now I need to call the Core image module preprocess function 'template_preprocess_image_formatter'. How would I do that?

I tried to add it in the list of preprocess functions of my custom theme but it doesn't fire unless I clear the cache:

 /**
  * Implements hook_theme().
  */
 function foo_theme() {
    'image_formatter_foo' => [
          'variables' => ['item' => NULL, 'item_attributes' => NULL, 'image_style' => NULL],
          'file' => 'foo.field.inc',
          'preprocess functions' => [
             'template_preprocess_image',
             'template_preprocess_image_formatter_foo'
          ]
    ],
 }


texts: Is there a module/Drush command for updating multiple field settings at once?

texts:
Just for convenience I wish change all required fields to optional at once.

Is there module or even better, a Drush command supporting module to do so?


texts: What tpl should I choose for this faq page?

texts:
What's the template that controls the /faq-page (from the FAQ Module in Drupal 7)?
I've read the explanation at the top of each tpl file inside the module, but can´t understand what file should I override.

When I enter the /faq-page url, I have the categories. When I click each category, they open in a new page.
So I've tried the faq-category-new-page.tpl.php

But it won't work. I've copied the tpl into my theme, opened it and added some css classes. They won't work (even when I've flushed cache).

What template should I choose? Thanks!
Rosamunda


texts: Why does node_access_view_all_nodes() return true for anonymous users?

texts:
On a Vanilla Drupal install (tested on D8 and D9), this will print "1":

drush eval 'echo node_access_view_all_nodes() . PHP_EOL;'

Stepping through the code reveals that it happens because there is a default grant for ALL nodes (nid = 0) for anonymous users in the node_access table (as far as I can see).

My question is about the rationale of behind this. The function description states:

  Determines whether the user has a global viewing grant for all nodes.

Why would the anonymous user have the permission to view all nodes by default? Why does this not correspond to what I see when trying to access various nodes as the anonymous user? Some nodes (e.g. unpublished nodes or anything blocked by a node_access hook) do return 403 when trying to load them as the anonymous user, so it obviously does not have access to all nodes. Is there another level of access checking hidden somewhere?


texts: new product display content type not showing in products view

texts:
I've just started playing with drupal commerce which seems pretty good.
I'm using Kickstart v2-rc1. I created a new product display type (content type with a product reference field). Everything seems to work, I can create a new node of this type and create/add variation. I can see my product under the correct category.
However, when I use the product view (all product), my product doesn't appear in this list. What am I missing ? Is it an permission problem or the products view which is filtering my product ?


texts:
I just add a Node view_unpublished module for providing access to view unpulished node . After instalation i set the Permission View any unpublished content and MyType: View any unpublished content .
After doing this there is no change in access .Role still didn't access the node.

Any suggestion will be most appreciable.

thanks in advance ...:)


texts: How can I change the drupal form action based on Radio button selected?

texts:
I have developed a custom form in my module. Now I have to change the form action based on radio button selected. Suppose if I have 3 radio buttons saying
1. ABC
2. DEF
3. XYZ

If i select ABC and submit form, my result should display on www.domainname.com/abc

Thanks.


texts:
I've created a website in a dev-environment with a generic domain name and have recently moved the site to the production environment by just copying over the public_html folder.

Everything works except JuiceBox and the Plupload integration module don't show on the website (it's just blank). All I get are the errors below:

Uncaught SyntaxError: Invalid or unexpected token
Uncaught ReferenceError: jQuery is not defined
    at js_xeOt4HeIpEI0bFGorNg4JgdnWBSWP0hr-DA_a_DRSzo.js:4
Uncaught ReferenceError: Drupal is not defined
    at js_BLxotNs2yt7YGlf9QRI9L9AMfdnkQfnN-_ADBTW3SiE.js:116
    at js_BLxotNs2yt7YGlf9QRI9L9AMfdnkQfnN-_ADBTW3SiE.js:778
Uncaught ReferenceError: Drupal is not defined
    at js_nd8T7IjV_42lQdGnEwc3XNCech9Hjagy-6Y7Hoou9Eo.js:1
Uncaught Error: Bootstraps JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4
    at js_uqRgtjNVU0Yel0hoh587qzn-ybcZ5logPIpmByaAZ-Y.js:15
    at js_uqRgtjNVU0Yel0hoh587qzn-ybcZ5logPIpmByaAZ-Y.js:17
Uncaught ReferenceError: Drupal is not defined
    at js_v89jUZ_l2LR8NzEXW2kWQ6me12tC-jCbLw8O3mpuQ2A.js:7
    at js_v89jUZ_l2LR8NzEXW2kWQ6me12tC-jCbLw8O3mpuQ2A.js:12
Uncaught ReferenceError: Drupal is not defined
    at blog:34
Uncaught TypeError: Cannot set property 'bootstrap' of undefined
    at js_OTdL_00eEtQq3wzsUAHLDYwgtcHpzbgUFYeJRcQf8f8.js:13
    at js_OTdL_00eEtQq3wzsUAHLDYwgtcHpzbgUFYeJRcQf8f8.js:272

The files referenced seem to me that they come with the modules. Therefore I have reinstalled and configured the necessary modules, but the errors won't go away.

The only difference I see between my dev and production is that I HTTPS in production.

What can cause these errors? And how can I fix them?

Thanks for having a look


texts:
I have a View which outputs the node creation date. But the site is multilingual. The problem is that I cannot choose a custom date format, as the Views just accepts one of a list. If I use a custom PHP format like j F Y (day month year in friendly format), I have prepositions, for example, in Spanish, that I cannot use: it should read "18 de Enero de 2015" instead of "18 Enero 2015" and if I put "j \d\e F Y", this will show a "de" which should not be present in other languages, like English.

Is there some module to just translate dates to multilanguage human friendly dates ? As I said, trying with Regions, Date Formats, Custom Date Format, etc., I cannot achieve what I need. If I use other formats, I have the extra time displayed, which I don't want, etc. etc.


texts: Problem with storing values in multiple textboxes

texts:
I'm having problem while storing values in multiple text-boxes, its stores value only in 1st text-box, here i'm using following JSON format of drupal 7 services.

"field_raoster_travel_time":{"und":[{"value":"8"},{"value":"81"}]}

( Note : I have set "Number of values" : "Unlimited" for text-box )


texts:
Am using the register module to create an alternate registration page which requires admin approval. The pending approval mail is not sent to the user registering through the page.

Wish someone could help me here. I've also created an issue in the module page. Thanks

The problem is not with the module. The pending approval mails are not sent even registering with default drupal path while rest of the mails are delivered.


texts: How to enable the php option in Views contextual filters, provide a default value option?

texts: I have a text field called campaign and I want to set a contextual filter for this field, but I don't see a PHP option here. How can I turn this feature on? I don't see it anywhere.


texts: Creating a Batch with multiple functions

texts:
i'm trying to optimise my setup of a Drupal Batch process.

I am reading in thousands of rows of data from an Excel spreadsheet, from multiple worksheets, and creating nodes from the Rows. My import functions work fine, and I can create a Batch, but at present I am creating a batch operation for each row. This means that my batch is very slow (because I'm having to bootstrap Drupal on every row).

What I can't seem to figure out is a way to setup my batch to deal with 'chunks' rather than individual rows.

An example of my import function (of which there are 18) is:

function governbim_coordinate($value){
    module_load_include('inc','phpexcel');
    global $user;
    $project = $_SESSION['governbim']['projnid'];
//Load the required worksheet from the excel file passed to the function as $value
    $result = phpexcel_import($value,TRUE,TRUE,array('setLoadSheetsOnly' => array('Coordinate')));
//Define some common values for our entity
    $values = array(
            'type' => 'coordinate',
            'uid' => $user->uid,
            'status' => 1,
            'comment' => 0,
            'promote' => 0,
            );
//step through each row in the worksheet
    foreach($result['Coordinate'] as $coordinate){
        $title = $coordinate['Name'];
//check to see if this is a new row or if we are updating an existing entity
        $action = governbim_node_actions_node_check('assembly',$title);
        switch($action['op']){
            case 'new':
                $e = entity_create('node',$values);
                $entity = entity_metadata_wrapper('node',$e);
                break;
            case 'update':
                 $e = entity_create('node',$values);
                   $entity = entity_metadata_wrapper('node',$action['nid']);
                break;
        }
//*** Here is where we write everything to the database with the entity values and $entity->save() ****/
    }
}

My batch is setup (currently) as:

function governbim_excel_import_batch(){
    drupal_set_message("Importing Data...");
    $path = 'public://imports/';
    $file = 'COBie-UK-2012-example1.xls';
    $datafile = $path.$file;

       $operations[]=array('governbim_coordinate',array($datafile));

        //another 17 $operations[] defined as above

    $batch = array(
        'operations' => $operations,
        'init_message' => t('Constructing batch operation...'),
        'progress_message' => t('Importing Excel data'),
        'finished' => 'governbim_excel_import_batch_finished',
        'error_message' => t('Importing of Excel data encountered an error.'),
        );
    return $batch;
}

I realise I need to get some $context stuff into the import function, but I can't seem to figure out how to setup that aspect properly.

Is anyone able to assist me in re-tuning things so that I can get the batch (with 18 function calls) to display progress of the overall batch and get the batch to execute (say) groups of iterations (as in $limit = 10)?


texts: How do I specify an image style in my preprocess function?

texts:
In my current project, whenever a node's image field is empty, I'm filling it with the image from an entity referenced in the node. To pull this off, I'm using this magical piece of code in template.php:

// Implements hook_preprocess_node();
    function mycustomtheme_preprocess_node(&$vars) {

      $node = $vars['node'];
      $field_name = 'field_main_image';
      if (
        isset($node->$field_name) &&
        empty($node->$field_name)
      ) {
        $node_wrapper = entity_metadata_wrapper('node', $node);
        if ($node_wrapper->field_master_reference->raw()) {
          $project = $node_wrapper->field_master_reference->value();
          $vars['content'][$field_name] = field_view_field('node', $project, $field_name);
        }
      }
    }

It works superbly - but with one small problem: it doesn't give the image its correct image style. In fact it just spits out the original image.

How can I force it to use the field's image style?


texts: Class not found in Drupal\Component\DependencyInjection\Container->createService()

texts:
I have a custom module (srs) that has an event subscriber as a service. That event subscriber class uses other custom helper class files after it catches the event. I tried to register the helper class in the srs.services.yml but its giving me:
Error: Class '\Drupal\srs\MyModule\SRS\SRSServicesRepository' not found in Drupal\Component\DependencyInjection\Container->createService()

My Helper class SRSServicesRepository has a name space of Drupal\srs\MyModule\SRS
my srs.services.yml file looks like:
services:
  srs.services:
    class: \Drupal\srs\MyModule\SRS\SRSServicesRepository
  srs.event_subscriber:
    class: \Drupal\srs\EventSubscriber\CartEventsSubscriber
    arguments: ['@messenger', '@commerce_cart.cart_manager','@srs.services']
    tags:
      - { name: 'event_subscriber' }

Inside my main srs module folder I have folder structure of  src\MYModule\SRS\SRSServicesRepository.php. I am not sure if that helps.


texts: Custom module over ride blazy.html.twig template

texts:
I have a small custom module that needs override blazy.html.twig that comes from the Blazy contributed module in Drupal 8. The code below shows what I have so far, can anyone give me some direction on how to go about this?

/**
 * Implements hook_theme().
 */

function slider_overlay_text_theme($existing, $type, $theme, $path)
{
    // In the template file I have blazy.html.twig
    $templates = $path . '/templates';

    return [
            'template' => 'blazy',
            'path' => $templates
    ];
}

/**
 * Prepares variables for blazy.html.twig templates.
 * Implements hook_preprocess_HOOK() for field templates.
 */
function slider_overlay_text_preprocess_blazy(&$variables) {

    // This variable is in the template ready to be printed
     $variables['display_hero_text'] = 'right-hero-text1';
  }


texts: Drupal Webform is sending emails but there are no values

texts:
The email that my webform is sending only has this... no actual values as entered into the form?

Submitted values are:
[submission:values]

Please help!


texts:
Is there any way to generate Drupal commerce coupon code bulky?
I found commerce_coupon_batch module but it require Commerce_coupon_ui module that there is not exist in sub module of  commerce_coupon version 7.x-2.0-beta1.

I don't try anything yet, How can I generate coupon code bulky?
I look at db and found there is a table for coupon ,commerce_coupon is just sufficient to add record to this table programmatically?

I try below code to create one coupon , but nothing added to coupon list in admin/commerce/coupons :

$No=$form_state["values"]["code_NO"];
    $type_id=$form_state["values"]["type"];
    $record['type']='discount_coupon';
    $record['code']=commerce_coupon_generate_coupon_code($type_id);
    $record['commerce_discount_reference']['und']['0']['target_id'] =$type_id;
    $record['commerce_coupon_conditions']['und'][0]=Array('condition_name'=>'commerce_coupon_usage_evaluate_usage',
            'condition_settings' =>Array( 'max_usage'=> 1),
            'remove_condition'=> 'Remove',);
ym(entity_get_controller('commerce_coupon')->create($record));


texts: How to show only the comment form, not the comments

texts: Right now in Drupal, at the end of each article, there are the comments which users has put on that article and also the comment form. I just want to have the comment form at the end of each article, I do not want the comments be shown at the end of each article. Does any body know how can I do it?


texts:
My site has a node type called "Resource". This node type has a field called "Reviewed"; this field is a single on-off checkbox:

I've created a view that lists all of the nodes of node-type "Resource". I'd like to filter that view so it only displays nodes that have the "Reviewed" checkbox checked. However, when I try to add that field to my view, I'm shown the following:

I would expect the "Options" select box to be a checkbox that I could either check or leave empty. Instead, I'm given a select box with "Select all" in it. Whether I select this or not, I'm then presented with an error message saying that there are "No valid values found on filter: Content: Reviewed.":

I've tried the "exposing the master display trick" at http://technology.blue-bag.com/top-tip-drupal-views-no-valid-values-found-filter, but that hasn't worked: there's no "unknown" filter in the master display, so there doesn't appear to be anything to fix.

Any idea as to how I can achieve the result I'm looking for? And what's the deal with the strange UI with the select box rather than a checkbox? Would be good to know if there's some logic to it; if not, I'll post an issue to the appropriate drupal.org issue queue.


texts: How to add custom theme to module block on Drupal 7?

texts:
I saw lot of questions and answers on this but I can't find solution.
I need to show last posts trough tpl file and I can't figure how to do it.
Also I don't know what to put in my tpl file.

Edit!:
This is my hook_block_view () function and if I send data at the end of it like theme('item_list', ... it works perfectly. But I need to send it to my custom tpl file and when I do that it won't properly display list. I think that there is problem in .tpl file.

<?php
function last_5_user_posts_block_view($delta = '') {
$block = array();

switch ($delta) {
case 'last_5_user_posts':

  // Capture the image file path and form into HTML with attributes
$image_file = file_load(variable_get('last_5_user_post_image', ''));
$image_path = '';

if (isset($image_file->uri)) {
$image_path = $image_file->uri;
}

$image = theme_image(array(
    'path' => ($image_path),
    'alt' => t('Image description here.'),
    'attributes' => array('class' => 'class_name'),
    'width' => '12',
    'height' => '12',
    ));

  $block['subject'] = t('My last posts');
  if (user_access('access content')) {
    // Use our custom function to retrieve data.
    $result = last_5_user_posts_contents();
    // Array to contain items for the block to render.
    $items = array();
    // Iterate over the resultset and format as links.
    foreach ($result as $node) {
      $items[] = array(
        'data' => $image.l($node->title, 'node/' . $node->nid),
      );
    }
   // If there is no nodes
    if (empty($items)) {
      $block['content'] = t('No posts available.');
    }
    else {
      // Pass data through theme function.
   //   $block['content'] = theme('last_5_user_posts_output', array(
   //       'items' => $items));
        $govno = 'Govno!';
        $listitems = array('items' => $items);
      $block['content'] = theme('last_5_user_posts_output', array(
          'items' => $items));
    }
  }

  return $block;

}

}

And my .tpl file for now contain just:

 <div class="field-items"<?php print $content_attributes; ?>>

 <?php foreach ($items as $delta => $item): ?>

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

 <?php endforeach; ?>

If I create array:

$test[1] = 'Test!';
$test[2] = 'Test2!';
$test[3] = 'Test3!';

And send it trough $block['content'] like this

$block['content'] = theme('last_5_user_posts_output', array(
          'test' => $test));

It works pefectly!
But for $items it won't work. How to optimize $items to get it in .tlp??


texts: Programmatically get the date field value

texts: All I want to do is get the value out of a date field in Drupal 8, but they have done an expert job of making this impossible. The error I get is that 'dateTimeObject' is protected so I have no access to it.


texts: Unrecoverable error when deleting fields

texts:
I've copied a working site and trying to modify to make a new one. To do so I've deleted all nodes, vocabularies etc  but when deleting custom fields using field-delete in drush I'm getting the following error. Even from site UI I'm getting similar message. What could be the problem?

D:\xampp\htdocs\ido>drush field-delete field_posts --yes
Do you want to delete the field_posts field? (y/n): y
WD php: DatabaseSchemaObjectExistsException: Cannot rename field_data_field_posts to field_deleted_data_30: table field_deleted_data_30     [error]

already exists. in DatabaseSchema_mysql->renameTable() (line 307 of D:\xampp\htdocs\ido\includes\database\mysql\schema.inc).
Cannot modify header information - headers already sent by (output started at C:\ProgramData\Drush\includes\output.inc:37)                [warning]

bootstrap.inc:1212
DatabaseSchemaObjectExistsException: Cannot rename field_data_field_posts to field_deleted_dat
a_30: table field_deleted_data_30 already exists. in DatabaseSchema_mysql->renameTable() (line 307 of D:\xampp\ht
docs\ido\includes\database\mysql\schema.inc).
Drush command terminated abnormally due to an unrecoverable error.

                                                                [error]


texts: Make block appear on some pages but not others

texts: How can I tell a block to appear on user profiles, like /user/1, but not on other pages where the beginning of the path is the same? So for instance, if I have a view set up at /user/1/articles, or user/1/messages, how can I tell the block to appear in the main user profile but not on the articles or messages pages?


texts: The missing modules don't get installed after updating with Composer

texts:
To update a site locally, I cloned the code base with git to my local computer and imported the database, then ran "composer update --with-dependencies", there were no errors, then I went to /web directory and ran "drush updb -y", it showed me 8 missing modules:

The following module is missing from the file system: add_to_head    [warning]
bootstrap.inc:276
The following module is missing from the file system: context        [warning]
bootstrap.inc:276
The following module is missing from the file system: context_ui     [warning]
bootstrap.inc:276
The following module is missing from the file system: libraries      [warning]
bootstrap.inc:276
The following module is missing from the file system: menu_target    [warning]
bootstrap.inc:276
The following module is missing from the file system: panelizer      [warning]
bootstrap.inc:276
The following module is missing from the file system: phpmailer      [warning]
bootstrap.inc:276
The following module is missing from the file system: site_verify    [warning]
bootstrap.inc:276
The following module is missing from the file system:                [warning]
special_menu_items bootstrap.inc:276
No database updates required                                         [success]

I tried to log in to the local site, but first ran "drush pm-uninstall captcha", but the site returned the white screen and:

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

I thought that the problem was due to the missing modules and started running "composer require" for each of them.
But they either didn't get installed or returned:

 Using version ^3.0@beta for drupal/phpmailer
./composer.json has been updated
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating drupal/phpmailer (dev-3.x 950f2af => 3.0.0-beta2):     Update failed (The .git directory is missing from web/modules/contrib/phpmailer, see https://getcomposer.org/commit-deps for more information)
    Would you like to try reinstalling the package instead [yes]? yes
  - Removing drupal/phpmailer (dev-3.x)
  - Installing drupal/phpmailer (3.0.0-beta2): Cloning 8.x-3.0-beta2 from cache
Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles

I don't what else to do. Is the "unexpected error" caused by those missing modules? What should I do to fix it?

UPDATE:
I looked at /admin/reports/dblog and here's the php error I saw:

  Symfony\Component\Routing\Exception\RouteNotFoundException: Route ""
  does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName()
  (line 201 of
  /sites/bak/web/core/lib/Drupal/Core/Routing/RouteProvider.php).


texts: Very slow cache processing: Is there any alternative?

texts:
I have some Drupal sites and the one common problem on them: very large cache with very slow processing and therefore the sites work very slow. I have enabled all caches and set them to long lifetime. But the sites are still slow.
My server has 4GHz frequency and 4G RAM. DB queries log shows me that all queries takes 100-300ms summary.

When I perform profiling with xhprof I see that the largest part of wall time is used by serialize, unserialize and array_map functions. So i suppose it is because of large amount of serialized data stored in cache. So the data can be get from DB quickly but is processed by CPU very slowly.

So what should I do with the issue?
How can I reduce cached data amout or store not serialized data in cache?


texts:
I've made a module to create organic groups and step by step content types inserting ,, at the end of the wizard I made a function to create og_menu for every group which get created fine.

but my problem is with showing the menu for each group!!

I tried to place the Single block ,, but nothing happened?

Am I missing something here?

any help would be appreciated

Thanx


texts: CCK doesn't find the Image module on Drupal 7

texts:
After successfully migrating from Drupal 6 to Drupal 7, I wanted to migrate my CCK fields to core fields. I downloaded CCK for Drupal 7, and its field migrate module.

However, for all of my image fields, I got this error:

  Missing field module: 'image'. This field cannot be migrated.

What is that module 'image' that is missing? There is no more imagefield for Drupal 7, as it is supposed to be part of core.


texts: Drupal Internationalization / Translation

texts:
When you translate a website using the i8ln module it doesn't automatically translate all the words in fields correct?

Also, what do you need to do to efficiently translate all the words ?

Is it a process that requires manually translating all the text with the i8ln module?

I reviewed some drupal documentation about this but it seems to only be germane to contributing local translations to the server: http://drupal.org/node/11130

I'm looking to have the localization server automatically translate it for me.


texts: How to get the file ID using managed_file on custom form?

texts:
In Drupal 8, I have a custom form that I built using the Form API in a custom module. I am trying to upload a file using managed_file field. For some reason I can't get it to give me the file ID no matter what code I try. The file does indeed get uploaded and saved, but only as a temporary file.

Please see below for the code I am using. The value of the form field is always NULL.

buildForm:

public function buildForm(array $form, FormStateInterface $form_state, $event = NULL) {
  $validators = array(
    'file_validate_extensions' => array('jpg jpeg png gif'),
  );
  $form['event_image'] = array(
    '#type' => 'managed_file',
    '#name' => 'event_image',
    '#title' => t('Event Image'),
    '#upload_validators' => $validators,
    '#upload_location' => 'public://event-images/',
  );

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

  return $form;
}

submitForm:

public function submitForm(array &$form, FormStateInterface $form_state) {
  $event_image = $form_state->getValue('event_image');
  if ($event_image) {
    $file = File::load(reset($event_image));
    $file->setPermanent();
    drupal_set_message('Filename: ' . $file->getFilename());
  }
  ksm($event_image); // Returns empty array??
}


texts: How to show an empty editable view form when no rows are returned?

texts:
I am using the Editable Views module to create a form that has editable fields from a two custom defined content types linked by a entity ref.

This works fine as long I have at least one row returned by the query.

1) Is it possible to have the form show up empty when the rows returned is zero?

2) Is it possible to have an "editable view" without using the editable table as the format?


texts: I am creating a form which consists of 3 tabs.In the first tab form submit is by clicking on save button of type submit,in the second tab the submit is by jQuery,in the third tab the submit is by clicking on save button of type submit.My problem is i want the save button to appear on only two tabs i.e., only on first and third tab.I dont want the save button to appear on second tab bcoz that second tab form i submit using jquery.how can i remove save button in second tab?plz help


texts:
Our former website (that was hooked with Google Analytics) had the following URL (i.e. Example URL) for a staff member:

http://www.example.com/research/teams/staffname.html

I have recently re-designed the website using Drupal 7 (Views 3) and other required modules. While designing the website, the structure of the most URL addresses changed.

Google already had indexed the old website and had/have the old URL addresses. After the complete re-design of the website, I did the following:

Enabled the Google Analytics module (supplied it the same Google Analytics ID used for the former website)
Installed/Enabled the xmlsitemap module, configured the content types to provide URL for and generated a new sitemap.xml file
Created Google Webmaster Tools (and Bing Webmaster account) and uploaded the sitemap.xml

Google has so far indexed 23 URL out of 63 (More indexing to be done!). At the moment googling the site, show up the website with some new links (probably the recently indexed links) and some older links. Clicking the OLD links of course display

"The requested page "/studentships/studentships1.html"

Hopefully by the time Google index all 63 links, there will be no OLD links left however, there happen to be another issue.

In the new website, I have a View page which is composed of a few View Attachments where each attachment lists a group of Scientists/staff. Visiting Research page

http://www.example.com/research

Renders four/five Science types sections and then under each section there is a list of Scientists. Each staff/scientists profile has a custom URL (yes I do use pathauto but, not for staff content type) as follow:

/research/group/{staffusername} hence http://www.example.com/research/group/{staffusername}

If you notice there is a partial match in the URL of old website and new website

  http://www.example.com/research

The problem I am having with the above URL is that, requesting any of the following URL variation would work (View Page is rendered) as if the above URL is requested

  http://www.example.com/research/*
  http://www.example.com/research/*/*
  ....

When I click the old URL for accessing a staff profile which looks as follow :

 http://www.example.com/research/teams/{staffusername}.html

That executes the following

http://www.example.com/research

Even though after /research there is no match (I should see an error there for URL mismatch). Why I want strict URL matching:

Accessing a staff profile using old link and ending up in the research page where all the staff is listed, is not a good navigation
Google bot will never come across a 404 hence, will consider the OLD staff URLs as valid and probably will never get rid of them from their search index/history (Google has listed most of the links of Old website as 404 but, not listed any of the OLD staff profile URLS).

What should I do to instruct the View page to only display /research page when the URL perfectly matched?

The view should run only when the request URL is exactly as follow

http://www.example.com/research

The staff content type nodes has the following Custom URL

research/group/{staffusername}

The Research View Page path is research, this issue of not doing strict URL matching is true for all of the Views of type Page in the new Drupal site. For example, the following is valid Career view URL

http://www.example.com/career (with View Page path as "career"

But any of the following URL requests work

http://www.example.com/career/*

Is this default behaviour of views?

Sorry for the level of details, probably too much. Thanks anyway.


texts: How do I copy the values of one field collection field to another content type with the same field collection?

texts:
I have one content type with a multi-value field collection entity on it.

On the event that this content type is flagged I would like to fire a rule that will create a new piece of content and copy all of the field collection lines to the same field collection type on the new content type.

The rule I have included bellow fires and creates the new content however the field collection is not copied.

{ "rules_generate_pal" : {
"LABEL" : "Generate PAL",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "flag_flagged_generate_pal" ],
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "flagged-node" ],
      "field" : "field_project_personnel_needed"
    }
  }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "project_activity_log",
        "param_title" : "[site:current-date]",
        "param_author" : [ "flagging-user" ]
      },
      "PROVIDE" : { "entity_created" : { "entity_created_pal" : "Created PAL" } }
    }
  },
  { "drupal_message" : { "message" : "BOOM!" } },
  { "LOOP" : {
      "USING" : { "list" : [ "flagged-node:field-project-personnel-needed" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "list_add" : {
            "list" : [ "entity-created-pal:field-project-personnel-needed" ],
            "item" : [ "flagged-node:field-project-personnel-needed:0" ]
          }
        }
      ]
    }
  }
]

}
}


texts: Form state redirect to node path plus fragment

texts:
How can I redirect a form to the canonical node path + fragment?

Redirect: /nodepathalias#tag

$form_state->setRedirect('entity.node.canonical',
  array('node' => $node->id()),
));

Where should I add the fragment information?


texts: Taxonomy Terms More than one level and Clean Class throws error

texts:
I am using clean_class and clean_id in twig. It was working with Parent Taxonomy Terms fine, but when I use Child Taxonomy Terms and try to render to Twig Template, I get this error message:

Recoverable fatal error: Object of class Drupal\Core\Field\FieldItemList could not be converted to string in Drupal\Component\Utility\Html::getClass() (line 72 of **core\lib\Drupal\Component\Utility\Html.php).**

Drupal\Component\Utility\Html::getClass(Object) (Line: 259)
__TwigTemplate_4f47122ce7aa9a8c20dea186eff4ea8b5e46cc06c44f4f280e0f32c345504034->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 434)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/cpv3/templates/page--node--community-plan-update--actualizacin-del-plan-comunitario-de-boyle-heights.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 109)
__TwigTemplate_0352d110804239c4a7412c9a9a76a1e3fccf9ff4943b7c48bf7ef5beaa137b28->doDisplay(Array, Array) (Line: 455)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 422)
Twig\Template->display(Array) (Line: 434)
Twig\Template->render(Array) (Line: 64)
twig_render_template('themes/custom/cpv3/templates/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 437)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 693)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Line 72 in Html.php is the function regarding Clean Classes

* @param mixed $class
   *   The class name to clean. It can be a string or anything that can be cast
   *   to string.
   *
   * @return string
   *   The cleaned class name.
   */
  public static function getClass($class) {
    $class = (string) $class;
    if (!isset(static::$classes[$class])) {
      static::$classes[$class] = static::cleanCssIdentifier(mb_strtolower($class));
    }
    return static::$classes[$class];
  }

Is this a bug in Drupal Core or could it be my theme? How can I debug this?


texts:
I created user-login.tpl.php file in my custom theme.

Then I add this code :

<div class="profile"<?php print $attributes; ?>>

<?php print ($user_profile['field_nom']);  ?>

    <?php print_r($user_profile); ?>

It display my name correctly but, when I inspect in the browser its look like this ...

My name:&nbsp;

Branquet

I just want to have the text, not a bunch of unless divs


texts: Fivestar rating for anonymous user should redirect to login or register

texts: When anonymous users tries to rate a node with fivestar rating, they will be asked to either login or register to continue. How to achieve it???


texts:
I want functionality where editor will be able to upload files and name that files whatever he wants, I just want additional field next to file upload field, is there any module which can do that?

Thanks.


texts: Register form breaks after changing submit button value with jQuery

texts:
I need to change the submit button value (text) based on the selection made in a certain register form field. I accomplished this by using jQuery:

(function ($) {
$(function() {
$("#edit-field-registrierung-als-und").change(function() {
if ( this.value == "2") {
$("#registersubmit").val("Kostenpflichtig registrieren");
}
else {
$("#registersubmit").val("Jetzt registrieren");
}
});
});
}(jQuery));

The submit button value changes as expected. But the form is not sent anymore after submitting. The page refreshes and the entered data is still in there. I don't get any error in the console or error log.
I think drupal expects the very term and is 'confused' to get a different one. Does somebody know how to resolve this?

This is my register page: https://my-business-location.com/registrierung
The first field on the page influences the submit button value (option 2).


texts: Module to create nodes that are lists of other nodes?

texts:
I'm looking for a way to allow users on my site create a piece of content that is a list of current content. For example a user can create a "favorite articles list" content piece and then select his favorite existing articles that will populate this new content type.
Is there an exisiing module that does this or something similar?


texts: How to modify the subfields of a custom field in hook presave

texts:
I have a custom field in a custom module that consists of 4 varchar type values. Each of these subfields are called 'prefix', 'suffix', 'body' and 'header'.
In the hook presave, I want to modify only one of them, 'prefix', however, I can't do it:
function custom_field_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  switch ($entity->bundle()) {
    case 'custom_object':
      //This seems to modify all de field instead only the subfield 'prefix'
      $entity->set('field_multifield', ['prefix' => '55555']);
      break;
  }
}


texts: Adding a class to a menu item where the class name is set in the node

texts:
I want to add a field to a content type where the editor can select a class name from a drop down or simply enter a class name into a text field. I want this class name to then be added to the menu item's li tag.

The purpose is so that the editor can select an icon (based on Font awesome) when they are authoring a page of content.

The class should be added on the content authoring page, and not via a secondary step by editing the menu item itself from the menu manager. Note, I'm also using taxonomy menu to build the links.

Any suggestions would be appreciated.


texts:
I'm getting a strange error with my Drupal site. The error is as follows:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1 no such table: router: SELECT name, route, fit FROM {router} WHERE pattern_outline IN ( :patterns__0 ) AND number_parts >= :count_parts; Array ( [:count_parts] => 0 [:patterns__0] => / ) in Drupal\Core\Routing\RouteProvider->getRoutesByPath() (line 344 of core/lib/Drupal/Core/Routing/RouteProvider.php).

I don't know much about what's causing the error. I took a look at the file the error references, but I can't figure out what to change.

Here are the steps I took that led up to the error:

I started with a Drupal 7 website.
I deleted all of my files from the website directory.
Note: The "sites" directory would not delete no matter how many times I tried.
I uploaded my Drupal 8 release candidate 1 hoping that that new "sites" directory would overwrite the old one.
I reloaded my website page and was presented with error above.

Any ideas?


texts: Services Module Authentication with Username and Password in URL

texts:
I have to match the following format when implementing Services to maintain some legacy APIs that were poorly written. I understand this is horrible practice and we're going to provide a new better OAUTH2 option going forward but that doesn't change my issue.

https://www.example.com/service/ServiceController.svc?username=YOUR_USERNAME&password=YOUR_PASSWORD&travelCode=TRAVEL_CODE

Short of writing my own authorization module that works with Services can anyone think of a method for getting this done using existing modules and Services.

I have tried Services Basic Authentication and Secure Services and either I am missing something or they don't do what I need.

Any help would be appreciated, I really don't want to customize something if I don't have to.


texts: Complex Views / Field Collection question

texts:
Is there a way to do a subquery in a View that filters entities based on a filter value in a field collection, but also by another value attached to that field collection item?

For example, people are searching properties. Property rates are stored in a field collection that references dates, the price, and if it is available.

When a user uses the view and searches by a particular date, I only want to return the entities that have both that date AND an available = 1 on that field collection item. Just adding the 'available' filter on the View is not enough, because it needs to search the value attached to the field collection item id that the date is attached to.

My first thought was to use hook_views_query_alter:

$lookup = new EntityFieldQuery;
    $lookup->entityCondition('entity_type', 'field_collection_item')
        ->entityCondition('bundle', 'field_property_booking');
    $lookup->fieldCondition('field_property_booking_basis', 'value', 'Weekly', '=');
    $lookup->fieldCondition('field_property_booking_period', 'value', 1348891200, '=');
    $lookup->fieldCondition('field_property_booking_available', 'value', 1, '=');
    $rates = $lookup->execute();

Okay, so, based on the timestamp from the form submission, I get 5,172 results. I am not sure where to go at this point. I want to say something like the main entity has field collection item IDs IN () with the item id's above, but I am not sure how to do that.

Can I plug in somehow with $query->where conditions? Or is there a better way to do this?


texts: How to access the value of a Drupal\Core\StringTranslation\TranslatableMarkup object within a form?

texts:
I tried this : dpm($button['#value']->string
but got this error:
 access protected property Drupal\Core\StringTranslation\TranslatableMarkup::$string

Within a form object I need to be able to read that value and also change it.  how can I access it?
thanks


texts:
Does OG Mailing List "Domain Name" configuration setting allow different mail list address than address Drupal is installed under

In OG Mailinglist 7.x-1.1-alpha2 for Drupal 7 there is a setting under OG Mailinglist configuration called "Domain Name".  This allows you to set the domain name for incoming/outgoing emails as seen here

I didn't see in the documentation on OG Mailinglist any details about this configuration option.  Intuitively you would think that it would allow you to have a different domain name set up for your mail lists than the domain name that Drupal is currently installed under.

I am curious if anyone has done this and set up a different domain name for their mail lists as per this configuration setting than the domain that Drupal is installed under?

I could change the domain name in this configuration option to be different from our current environment we are developing under, but we would then have to update our mail exchange record, which costs money and it a bit complicated, since we currently only have the Domain name for incoming and outgoing mail to be the same as the domain name that Drupal is installed under.

If you have done this can you respond and let me know that this configuration option really works?

Thanks,


texts:
I have a number of content Types (Basic Pages) and a region (right sidebar)

What I'm looking to do, is display a particular fields content in this block depending on what page I'm on.

I know I could do this for a block for each page, but I have over 200 pages, and doing this for all of them would be time consuming.

I have created a field collection named 'rightcol' which is a text field.

So ideally, what i need is when I'm on a particular page, in the right-hand region, that pages 'rightcol' content will display.

Am I correct in thinking I'd need to create a view for this?


texts: Drupal 7 prepopulate form values for embedded field collection

texts:
I need to prepopulate my embedded field collection values in a specific form.
Here is what I've got so far:

<?php
// Hook form alter
function mp3_template_form_alter(&$form, &$form_state, $form_id)
{
  // Pre fill profile mp3 form with mp3 template data
  if (isSet($form_id) && $form_id == 'profile_mp3_node_form')
  {
    global $user;
    $user_full = profile2_load_by_user($user->uid, 'artists_profile');

    // Get field collection entity ids from the user
    $entity_ids = $user_full->field_copyrights_mp3[LANGUAGE_NONE];

    // Load field collection entities
    $entities = entity_load('field_collection_item', $entity_ids);

    // Here I want to prepopulate the $form['field_copyrights_mp3'] form field with my collection items that contain the data for field_copyrights_mp3
    $form['field_copyrights_mp3'][LANGUAGE_NONE][0] = $entities[0]; // 1 field collection
    $form['field_copyrights_mp3'][LANGUAGE_NONE][1] = $entities[1]; // 2 field collection
    // etc...
  }
}

I have searched a lot and tried multiple approaches to prefill my field collection with multiple rows of data. Hopefully someone can point me into the right direction of what I should do next.

Image of what I'm trying to prepopulate with multiple owners:


texts: exposed filter result : how to check the results is lesser than 20 or greater than 20...?

texts: i have created the content type named candidate_profile, included fields like Current_Salary_Range and  i have created a view named display_candidate and also i am using better exposed filter for current_salary_range field the filtered the result print in view throw the Header->Global:Result summary.hence how should i proceed to check the results is lesser than 20 or greater than 20...?


texts: How to prevent applications from uncovering the technologies used on the website

texts:
Here is a super hard question, probably for the most experienced people:

Can we prevent applications from uncovering the technologies we are using.

We all know that making sure to keep the core and contributed modules up to date is one of the most important aspect of web development. But meanwhile hiding information about the used technologies will another layer of the security.

Looking in the https://drupal.stackexchange.com/ and Google I can see the last time people talked about this topic was 2013, I think this is the time to ask this question again with hope that someone now have a solution for this.


texts: How to add an additional class to each element in the menu-local-task.html.twig template?

texts:
I need to change the admin tab template by adding my wrapper and class to it.
This is the default code:

{{ link }}

My code:

{{ link }}

Currently, the "DefTabs__tabItem--active" class is added to the active link, but I need to add an additional CSS class "DefTabs__tabItem" to each DIV element. How can I do this?


texts:
I searched a lot for auto-save functionality which will direclty save in to db, but I am not getting anything like what I want, so I am posting my query, any help is very appreciate.

The requirement is like after every 1-min entire node should be save in db.

The problem I am facing:  For content type(Story) has many field collection(Unlimited), Image field. So how to auto-save this in db, as I am not understanding how to track how many field collection content added, how many deleted base etc. so how to save this.

For this requirement I have done like this:

 - Calling Ajax after every 1 min and pass form by serialize.

setInterval(function () {
        jQuery.ajax({
            url: Drupal.settings.basePath + '?q=ajax/autosave',
            data: jQuery('.content .node-form').serialize(),
            type: 'POST',
            async: true,
            success: function (returnData) {
            }
        });
   }, 60000);

 - Accept post data, loading node and save the node.

/**
 * Implement hook_form_menu()
 *
 */
function autosave_menu() {
    $items['ajax/autosave'] = array(
        'title' => 'Autosave',
        'description' => 'Autosave',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('save_node_automatically'),
        'access callback' => TRUE
    );
    return $items;
}

function save_node_automatically($form, &$form_state) {
    $node = node_load(2);

    $bundle_name = $node->type;
// Get fields array
    $field_instance = field_info_instances('node', $bundle_name);

    try {
        $node->title = $form_state['input']['title'];
        $node->body = $form_state['input']['body'];
        $node->body[LANGUAGE_NONE][0]['format'] = $form_state['input']['body'][LANGUAGE_NONE][0]['format'];
        $node->body[LANGUAGE_NONE][0]['summary'] = $form_state['input']['body'][LANGUAGE_NONE][0]['summary'];
        $node->body[LANGUAGE_NONE][0]['value'] = $form_state['input']['body'][LANGUAGE_NONE][0]['value'];

        // Traverse from fields
        foreach ($field_instance as $field_name => $field_details) {

            // Check field Type
            $field_type = $field_details['display']['default']['module'];
            switch ($field_type) {
                case 'entityreference':
                    if ($form_state['input'][$field_name]['und'] != '_none' && $form_state['input'][$field_name]['und'] != '') {
                        $node->{$field_name}[LANGUAGE_NONE][0]['target_id'] = $form_state['input'][$field_name][LANGUAGE_NONE];
                    } else {
                        $node->{$field_name} = array();
                    }
                    break;
                case 'taxonomy':
                    if ($form_state['input'][$field_name]['und'] != '_none') {
                        $node->{$field_name}[LANGUAGE_NONE][0]['tid'] = $form_state['input'][$field_name][LANGUAGE_NONE];
                    } else {
                        $node->{$field_name} = array();
                    }
                    break;
                case 'list':
                    if ($form_state['input'][$field_name]['und'] != '') {
                        $node->{$field_name}[LANGUAGE_NONE][0]['value'] = $form_state['input'][$field_name][LANGUAGE_NONE];
                    }
                    break;
                case 'text':
                    if ($form_state['input'][$field_name]['und'][0]['value'] != '') {
                        $node->{$field_name}[LANGUAGE_NONE][0]['value'] = $form_state['input'][$field_name][LANGUAGE_NONE][0]['value'];
                    }
                    break;
                case 'field_collection':
                /**
                 *  Field Collection code
                 *
                 */
            }
        }
        $node->revision = FALSE;
        node_save($node);
    } catch (Exception $ex) {

    }
}


texts: Calling a grandparent JS function that includes jquery from a nested iFrame. D7

texts:
I'm calling the grandparent_func from a second-level nested iframe like so.
This works in a non-Drupal environment, but am getting the following errors when running in drupal. (yes. I did remember to include the jquery file ;-)

parent.parent.grandparent_func( Date.now(), Date.now());

ERRORS:

For the following, I get a "TypeError: $ is not a function" error

<script>
    function grandparent_func(){
        $("#fancy_regit_link").attr("href", "/my/actual/path");
        $("#fancy_regit_link").trigger('click');

    }
</script>

So, I enclosed jquery like so to make it drupal-friendly and get:
TypeError: parent.grandparent_func is not a function

<script>
(function($) {
    function grandparent_func(){
        $("#fancy_regit_link").attr("href", "/my/actual/path");
        $("#fancy_regit_link").trigger('click');

    }
})(jQuery);
</script>

For good measure, I double enclose it with jquery's ready function.
TypeError: parent.grandparent_func is not a function

<script>
(function($) {
    $( document ).ready(function() {
        function grandparent_func(){
            $("#fancy_regit_link").attr("href", "/my/actual/path");
            $("#fancy_regit_link").trigger('click');

        }
    });
})(jQuery);
</script>

Any thoughts?

Thanks.


texts:
I forked a repo from a third party development team that I am taking over for, and inside the "profiles" folder is a file just named foo.

When I open it, it as this ../../foo and nothing else.

Is this a symlink to the install profile?

There is an install profile, just not in the docroot folder, it sits outside of it with the grunt and build files.

If so, is there a difference on how Nginx and Apache handle symlinks?  They used a Nginx server to develop and I'm using Apache.

Thanks everyone.


texts: How do I disable some available countries in Commerce Shipping?

texts: I am using Commerce Shipping and I need to disable all countries, except for Canada and the US. How do I make it so only those two are available in the Shipping Info on checkout?


texts: I have issue with commerce_order_load_multiple function

texts:
The way i am using this function is

foreach ($mms as $mm) {
    $orders_of_user += commerce_order_load_multiple(array(), array('uid' => $mm->uid, 'status' => 'cart'));
  }

But i am not getting anything output from this and when i use static value of integer in place of uid i am getting result..

 $orders_of_user += commerce_order_load_multiple(array(), array('uid' => 421, 'status' => 'cart'));

I don't understand what causing the problem in foreach


texts: How to duplicate image file in the same folder

texts:
i want to duplicate a image file in the same folder programmatically , so i'm used file_copy() function for this but the original file image replaced or renamed and in file_managed table on database no row created.

if ($form_state['values']['image'] != 0) {
            $fileo = file_load($form_state['values']['image']);
            $fileo -> status = FILE_STATUS_PERMANENT;
            $file = file_copy($fileo,'public://img_files/',FILE_EXISTS_RENAME );
            file_usage_add($file, 'image', 'file_img', 1);
        }

Thank you :).


texts: How do I let end users create and manage arbitrary connections between their user account and an entity

texts: I have an event content type and I want to allow users to 'add' themselves to it the same as Facebook users would join an event. Any ideas?


texts: Published checkbox only available for administrator

texts: Only the administrator can publish a node of content type Report. It is not using content moderation or groups though other content types are. All permissions are set for the "site admin" to create/edit own/others of this type. The only buttons available are "Save" and "Preview" and the published checkbox doesn't show for non-administrator users. Save sets as "Draft" even though it's not using content moderation.


texts: "The website encountered an unexpected error" right after login in

texts:
So I recently bought a very cheap host just to run a not-important website on it. but when I login to admin, it shows

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

message, since its a shared host I checked into my cpanel for error logs, there were just two errors regarding my .htaccess files (in root and also sites/default/files) regarding FollowSymLinks not being available here, so I commented out those lines and all error logs now are gone. but still I get the error message after I try to login.

I contacted the webmaster regarding FollowSymLinks and he said we are using SymLinksIfOwnerMatch .

however with or withought FollowSymLinks I still get the error message while my error logs in cpanel is empty.

Any Ideas or hints?


texts: Show specific gmap in block based on node id

texts:
I am trying to show a gmap for a specific location, using the content: mapping coordinates for gmap in a view in drupal 7. The map itself shows fine in content for the page view, but if i clone it to block it shows all maps for that content. I cannot figure out how, without using php, to filter by the current node.

For example, node id 2 has coordinates so show the map for that node in the view for the block. and only node 2, not nodes 3,4,5,7.

I am really trying to do this using views and block and not php code in blocks.


texts:
I'm using Drupal 7.
I have created two content types (A & B); content type B is referenced from content type A.
I want to create a view, I need to filter the nodes of content type B by showing the last node only (by date), for every node from content type A.

How can I achieve this?


texts: Set form value to empty on validation fail

texts:
I have a requirement to set a single field to empty, if it fails validation. The form is built using Drupal 8's Form API.

In my validateForm() function, I have the following:

public function validateForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state->getValues();
  if($values['myfield']!='something') {
     $form_state->setValue('myfield', '');
     $form_state->setErrorByName('myfield', $this->t('Sorry, this field value is not correct.'));
  }
}

Unfortunately, the above has no effect - when the form is rebuilt myfield still contains the user submitted value.

I assume this is something to do with the order in which these functions are called? Or perhaps, because $form_state is not passed by reference? (I cannot do this, as it's then no longer compatible with the FormBase class I'm extending).

One solution I've found is to access the form element from the $form array in my validateForm() function:

$form['myfield']['#value'] = '';

But the above doesn't really feel like the correct solution?


texts:
I want to add a 'like' button to a table. I get as far as the like button appearing on the page, but I can't figure out how to build the link into that spot.

The problem is, the only way to do that (that i've found so far) is to make a full html field on the content item and place the code for the iframe in there. I can't figure out how to make that a link to the node itself.

I tried using the view to add a field Global text, but I can't get an iframe to load from there. If I could do it there then I could use replacement patterns to build the proper link.

If it helps unmuddle it to remove some context: I want to create a table of nodes that pass a filter. I want that to be a table of iframes loading the node the table row represents.


texts: Use relationship for Views taxonomy term filter

texts:
I'm using the Commerce module, and I'm trying to create a view that displays the nodes with several exposed filters that should apply for the products.

Now, the node has a term field that references to a category. A normal taxonomy term filter works just fine for this case.

The products has a term field that references to a color.

What I would like to do is adding another taxonomy term filter for the color vocabulary (just like the one described above) that uses a relationship to the product. AFAIK, it's not possible to use a relationship for a taxonomy term filter.

Can I achieve what I am trying, in any way?

I'm using Drupal 7.2 and Views 3-beta3.


texts: How can we change the default URL what we get through the view blocks on a basic page?

texts:
I am working on a site, I had used a view block on a basic page, this view block has a pager. When we navigate through the pager links we are getting url structure like this

http://www.website.com/page-name?page=1
*http://www.website.com/page-name?page=2*

I want to remove this ?page=1 from the url and want to modify it to page-name-1 and so on.


texts:
I like to show a message on 1 page of my website after login. Therefore I made a rule. To determine the mobile device I use module : mobile_detect.
I installed the corresponding library. Checking the status is saying it is available.

They module readme shows the example code:

$detect = mobile_detect_get_object();
$is_mobile = $detect->isMobile();

So when I rewrite this in a message with php eval like this:

#
<?php
$detect = mobile_detect_get_object();
$is_mobile = $detect->isMobile();
print ($is_mobile);
?>
#

So the result should be : #TRUE# or #FALSE# but I get back # #.

What can I do to solve this?


texts: Theme a view of one content type with node references to another

texts:
I'm attempting to theme a view containing of content type 'Activity' which includes Node References to a second content type 'Category'.

When using the views-view-list template it appears I cannot access or the fields which are included through Node References.

Any help would be appreciated.


texts:
I am using Drupal 7, and I used hook_form_alter() to add the following markup.

  $form['linkb'] = array(
    '#type' => 'markup',
    '#markup'=>"<a href=''>Click here </a>",
    '#title' => t('something'),
    '#name' => 'linkb',
    '#ajax' => array(
      'method' => 'html', // this is important without this if else condition for ajax will not work.
      'effect' => 'fade',
      'callback' => 'clicktell_verification',
      'wrapper' => 'replace_textfield_div',
    ),
  );

I want to run AJAX when I click on Click here, but this is not working. I have also created a callback function, but it doesn't still work.

Why isn't the AJAX callback being called?


texts: How do I get the image path inside a jsonapi response?

texts:
I a content type for movies that includes plain text fields, and an image. The field name for the image is field_movie_poster.
Using the JSON API, How do I include the image path in the request?
If I put this Postman I get the correct response:
https://drupal-api.ddev.site/jsonapi/node/movies?include=image_field

But the same does not work with JavaScript
getMovies() {
    fetch('https://drupal-api.ddev.site/jsonapi/node/movies',{
        include: 'image_field'
    })
    .then(res => {
        return res.json()
    })
    .then(res => {

        this.movies.push(...res.data)
        console.log(res.data)

    })
    .catch(err => console.log(err))
}

How do I include the image path in the request?
If you look at the image attached, you will see that field_movie_poster is under the relationships attribute, and it does not include the image path.


texts: Cron tasks don't work: Could the Domain Access module be the cause?

texts:
I have an issue with a website running Drupal 8. I cannot seem to get cron working. If I go to the status page and click 'run now' it works. If I try to open the cron settings (/admin/config/system/cron) I get an error. The log reports the following:

  Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "key" for route "system.cron" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 202 of /var/www/exin.com/files/core/lib/Drupal/Core/Routing/UrlGenerator.php).

I looked up the system.cron path in the core files and found it attached to /cron/{key}, so that is not the settings page. It is the URL I was supposed to use for the cron tasks. Calling that URL (replacing {key} with my token) generates a permission denied error, even if I open it when logged in as administrator.

I found the key on the status page by looking at the URL of the 'run now' button (/admin/reports/status/run-cron?token=mytoken). Is this the correct token?

I'm running Drupal 8.3.7, which was updated from version 8.3.1, where I had the same issue.

I'm also using the Domain access module and some creative nginx configuration to open different "domains" through a proxy, which (for example) takes users from www.mysite.com/fr/ to fr.mysite.com. This was necessary since the Domain access module could not work with subdirectories. It caused a lot of issues which we managed to resolve, but this one sticks. So I'm not sure it is caused by either this module or the nginx configuration, but I feel it is important information.


texts:
I got this error in my log file.  It was on a select element for an exposed View filter:

Illegal choice 24alert(0) in field_item_type_tid element.

Is it someone trying to hack my site?


texts:
I am getting the following error when image styles are being created on my Drupal 7.24 site:

  mod_fcgid: stderr: PHP Fatal error:  Allowed memory size of 134217728
  bytes exhausted (tried to allocate 73834563 bytes) in
  modules/system/image.gd.inc on line 237"

My style is doing a scale and crop down to 300x200.

I know this could be a problem with my memory limit, which is currently 128M.  As this is high, this doesn't seem like an issue.

Could it be from the use of the File (Field) Paths" module for my image names?


texts:
I have emerged me a problem with a page view and maybe someone can help me solve.
Following this tutorial:
http://codekarate.com/daily-dose-of-drupal/multiple-views-part-3
I created a view showing a content in 2 ways (such as poster and poster with text). For this purpose uses a javascript file that is responsible for displaying two different ways the contents of the view.
Everything worked fine until add a pager and save the view with ajax enabled. Suddenly everything stopped working. It works only on the first page, if you press the Pager (with ajax) the next page and nothing works.
The script is as follows:

(function ($, Drupal, window, document, undefined) {

Drupal.behaviors.my_custom_behavior = {
  attach: function(context, settings) {
//Sets default class for course views and toggles class when changing view.
$('#content').once('course-view', function() {
  if ($(".view").hasClass("course-view")) {
    $(".view").addClass("grid-view"); // Sets .grid-view as default class on the view

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

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

  }

    };

})(jQuery, Drupal, this, this.document);

Can somebody help me? Why only works on the first page?


texts:
I am unable to call PHP files inside the Drupal directory. My task is maintaining staff's old pages on the new platform. With pages written on clear HTML, there is no problem: I place files in a folder I created (domain.org/sites/default/files/share/staff_folder).

In sites/default/files/.htaccess I added DirectoryIndex share and now the link to the domain.org/sites/default/files/share/staff_folder/index.html can be used. When I import pages written in PHP, e.g. calling domain.org/sites/default/files/share/staff2_folder/index.php, I get a 403 error:

  Forbidden

  You don't have permission to access /sites/default/files/share/staff2_folder/index.php on this server.

While /sites/default/files/share/staff2_folder/index.html still works.


texts: Twitter Widget profile script outputting white screen?

texts:
Does anyone know why I'm receiving a white screen when I added the following code into a page panel?

<script charset="utf-8" src="http://widgets.twimg.com/j/2/widget.js"></script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 4,
  interval: 30000,
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#333333',
      color: '#ffffff'
    },
    tweets: {
      background: '#000000',
      color: '#ffffff',
      links: '#4aed05'
    }
  },
  features: {
    scrollbar: false,
    loop: false,
    live: false,
    behavior: 'all'
  }
}).render().setUser('Twitter').start();
</script>


texts: How to insert conditions into Global Custom Text?

texts:
I am new to drupal and getting hang of it. I have a custom text in one of my view and I need to display the title based on a condition.
This is what I have right now,

 <h1>[title] | [field_annual_number] </h1>

But I need to display this only if the title doesn't contains the work "multi".
So basically, the pseudo code is like this,

if([title].contains('multi')) then <h1> [title] </h1> else <h1> [title] | [ Field_annual_number] </h1>

Any help would be appreciated.
TIA.
Srividhya


texts:
I have the following code:

$query = new EntityFieldQuery();

$result = $query
    ->entityCondition('entity_type', 'field_collection_item', '=')
    ->propertyCondition('field_name', 'field_version', '=')
    ->fieldCondition('field_version', 'entity_id', '105', '=')
    ->execute()
;

The first two conditions are fine, but the fieldCondition() is causing the following SQL exception:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_version0.field_version_entity_id' in 'where clause'...

The problem seems to be that 'field_version' is prepended to the column 'entity_id'.  I have looked inside _field_sql_storage_query_field_conditions() and there appears to be no way to stop it from prepending this. This is the table I am trying to perform the fieldCondition on:

+-------------+---------------+---------+-----------+-------------+----------+-------+---------------------+
| entity_type | bundle        | deleted | entity_id | revision_id | language | delta | field_version_value |
+-------------+---------------+---------+-----------+-------------+----------+-------+---------------------+
| node        | shopping_cart |       0 |       105 |         123 | und      | 0     |                   5 |
| node        | shopping_cart |       0 |       108 |         126 | und      | 0     |                   8 |
+-------------+---------------+---------+-----------+-------------+----------+-------+---------------------+

How may I perform this query correctly?


texts:
How I could make from my template.php author/user field in comments required for those who are anonymous users

I tried with this but it didn't work for me

  function MYTHEME_theme() { $form['author']['_author']['#required'] =
  TRUE; }

I've been searching around but can't find a proper answer :/


texts: How do I create a user relationship to show author name in Views?

texts:
I want to show node title and it's author but I'm not able to find how to show the author name. I don't see Content:Author in Relationship.

How do I configure Views to show it?


texts: Access item url in views-view-fields.tpl.php

texts:
I'm using views-view-fields.tpl.php to theme the output of a content type.

What I need to do is the below, except I don't know how to get 'url_for_this_item' without either printing all the variables and referencing it in a long array lookup, ie like $fields[smth][ddd][0][44][ui][uri].

Is there a simple, clean way to get the url in the template?  I have tried outputting a link but then views still insists on giving the full link with an closing tag on the end.  Of course, I can parse this and remove the closing tag but it just seems too hacky.  Is there not a better way?

print '';
    print $fields['title']->content;
    print $fields['field_this']->content;
    print $fields['field_that']->content;
print '';

I want to to get the url for


texts: Is there a way to show a page dynamically when hovering on it's link?

texts:
Just wondering if there is a module or some way in general to do the following:

When hovering on a page link show the content of that page as a tooltip or some kind of small dropdown window.

Thanks.


texts: Programmatically create a comment form for a node

texts:
I'm trying to port a theme from Drupal 6 to Drupal 8, and I find code like the following.

$edit = array();
$edit['nid'] = $node->nid;
$form = drupal_get_form('comment_form', $edit));

How do I load the form in Drupal 8? I get the following error:

  Fatal error: Call to a member function getEntityTypeId() on null in /www/site/core/lib/Drupal/Core/Entity/EntityForm.php on line 77

The line causing the error is the following one:

\Drupal::formBuilder()->getForm('Drupal\comment\CommentForm');

I can't work out how to pass the node object to the form builder. How can I do it?


texts: What's the default workflow for layouts in Drupal Bootstrap theme?

texts:
Panels/Page Manager and Display Suite are probably the two most popular approaches to layout of items in Drupal. Both, however, are officially not supported by the popular Bootstrap theme (as opposed to Zurb Foundation, which actively recommends both Panels and Display Suite).

I've been right through the Drupal Bootstrap documention, and beyond this "what not to do", I can't find anything on what to do. I know how to work with vanilla-Bootstrap's rows, columns etc using classes; I'm just struggling to find the standard, going-with-the-flow expected approach to doing this in the context of Drupal.

Is there any official guidance on best-practise layout in Drupal Bootstrap, or failing that, what's the expected approach to applying the row and column classes to elements?

I've seen Views Bootstrap, which is kinda-sorta supported. It's the next step up from that I'm not sure about, and I'm wary of just attempting something then finding I'm going against how the theme is designed and expected to work.


texts:
I am new to Drupal and I am trying to create a theme for it (Drupal 8). I have a few questions:

What does it mean to pre-process a variable?
Do all variables have to be pre-processed?
How do you figure out how to pre-process a variable? I understand some come from the Drupal config. Where else can variables come from?

I have read a few articles and searched the Internet but it seems Drupal  8 documentation is still being worked on. It's not very explanatory. Are there any articles you can suggest to learn how to theme Drupal 8 from the ground up?

Thank you


texts: How do I set up a shipping condition that accesses the value of a specific field in product?

texts:
I have a term reference field in product called "Weight" with values "Light", "Medium" & "heavy". I am using flat rate shipping service and trying to check the value of "Weight" field in Calculation rules.I know that I need to expose it by using "entity has field" but I end up having

commerce-line-item:order:commerce-line-items:0
commerce-line-item:order:commerce-line-items:1
commerce-line-item:order:commerce-line-items:2
commerce-line-item:order:commerce-line-items:3
commerce-line-item:order:commerce-line-items:0...
commerce-line-item:order:commerce-line-items:1...
commerce-line-item:order:commerce-line-items:2...
commerce-line-item:order:commerce-line-items:3...

I was able to get to the weight field by using any of them and then did a Data Comparison

commerce-line-item:order:commerce-line-items:0:commerce-product:field-product-weight

this condition worked ok first time but not after that. can anyone please help me on this or if you think of another solution please let me know. Thanks


texts: I want to filter to show orders that their ending date is today

texts: I am using Drupal 7 and I have a webform where people can order a product and they enter the date that they will pick up that product. I want to make a view that will show me the poeple that are picking a product today, but when I try to make a filter for that the fields that are given are only the date that they submited the order not the date_field. Here is a picture of which fields are given to select.


texts: Force using specific filter text on a content type

texts:
How can I limit the text filter type upon a textarea field.

Example (the needed result would be like this) :

Authuser is a role that can change the value of textarea_1 and textarea_2 on contentTypeA
Authuser can't change the 'text filter' value of textarea_1 (it's on filtered HTML)
Authuser can change the 'text filter' value of textarea_2 with only (Plain text or ckEditor(WYSIWYG))

Is that possible? if yes, how?

Thanks in advance.


texts: How do I use Gitlab server as a central staging server?

texts:
I just installed a Gitlab instance on my LAN.

I want to use it as the central repository for a Drupal dev->test->prod staging setup.

So, 1st step, I want to push my local "dev" workspace to the Gitlab repo.

Following instructions at Gitlab docs, I try

cd ./drupal8
git remote add origin https://gitlab.example.com/user1/drupal8-test.git

But that fails and returns

fatal: remote origin already exists.

Checking in the drupal dir

cd ./drupal8
git remote -v
    composer        https://github.com/drupal-composer/drupal-project.git (fetch)
    composer        https://github.com/drupal-composer/drupal-project.git (push)
    origin  https://github.com/drupal-composer/drupal-project.git (fetch)
    origin  git@github.com:drupal-composer/drupal-project.git (push)

I want to be able to push to the Gitlab repo, but I still obviously want composer etc to work in my dev env.

What's the right setup & workflow for using Drupal with a central Gitlab repo, making sure that I keep the ability to manage my site in 'dev' with composer?


texts:
My XML looks like this:

    <dynamic-element name="link-extern" >
      <dynamic-element name="link-extern-text" type="text">
         <dynamic-content><![CDATA[Myfirst title]]></dynamic-content>
      </dynamic-element>
      <dynamic-element name="url-extern" type="text" >
         <dynamic-content><![CDATA[http://www.myurl.com]]></dynamic-content>
      </dynamic-element>
      <dynamic-element name="new-window" type="boolean">
         <dynamic-content><![CDATA[false]]></dynamic-content>
      </dynamic-element>
    </dynamic-element>

I have a Drupal 8 link field.
The source looks like:

   -
     name: link_extern_text
     label: 'Link extern text'
     selector: 'article_content/*[@name="link-extern"]/*[@name="link-extern-text"]/*'
   -
     name: link_extern_url
     label: 'Link extern url'
     selector: 'article_content/*[@name="link-extern"]/*[@name="url-extern"]/*'
   -
     name: link_extern_target
     label: 'Target of external url'
     selector: 'article_content/*[@name="link-extern"]/*[@name="new-window"]/*'

My YML process configuration looks like:

'field_link_extern/uri': link_extern_url
'field_link_extern/title': link_extern_text
'field_link_extern/options/attributes/target':
  plugin: static_map
    source: link_extern_target
    map:
      'false': '_self'
      'true': '_blank'
    default_value: '_blank'
    ignore_case: true

These settings work in the case when there is only one link-extern element. On multiple links it breaks. Perhaps using the sub_process plugin could be done, but i have no idea how. Can someone point me in the direction?


texts: Need help with import problem on Aquia DEV desktop for Windows

texts:
I am trying to import a DEV version of a site using the import function on Aquia Dev Desktop

I can successfully import the codebase and the sql dump file, but every time I go to the site, I get this error

**Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required '/var/www/xhprof/header.php' (include_path='.;C:\php5\pear') in Unknown on line 0**

We have tried this on three different laptops, all using the same Windows 7 configuration. We get the same result every time. This leads me to believe that there is something wrong with the files that I was given to import

Does anybody have any insight into what might be happening?

Thanks!


texts: Rules: use a View's result as a condition?

texts:
How can I use the results of a view as a condition in a rule?

I have rule that fires off a daily digest email with contents from a view (using Views Rules). The view simply returns nodes that have a specific field value. When the view doesn't return any nodes, the rule still fires off what is essentially an empty email. I want to prevent this. I need a condition like "View has no results" (negated)… but I don't see anything like that. What's the workaround?


texts: How to programmatically use the "between" operator in Drupal Views

texts:
I have a price field and I want to see if the value of this field is between multiple price segments.

E.g.: (price BETWEEN 0 AND 100) OR (price BETWEEN 150 AND 200)

So how can I use the "between" operator in Drupal Views to programmatically alter a query?


texts: How to let users post questions and appear anonymous?

texts:
I want logged in users to be able to post questions or answers using the Answers module "anonymously"... that is, to appear anonymous but actually still be logged in, be able to follow their post, etc.

Edit: I thought this module could already do this but am not finding any settings for it.

Using Answers 7.x-4.0-rc2

Criteria:

anonymous/not logged in users should not be able to post
I want to give users the option to post anonymously but default to show the author
if a user posts "anonymously", the post would have do something about their avatar

on a per-post basis

Our site is complex with many other features, such as blogging, so changing usernames isn't an option; we want their usernames to show up everywhere else


texts: How to collect and publish input from user, using webform and views?

texts:
I want to build a form, with a lot of fields that can collect data from a lot of users.
than, I want to have the option to play with this data and publish it through views (with sorting options).

How to do that (general steps)?

This is what it tried so far:

I built a new content type, with a few specific fields, that allow me to publish all the data in a lot of ways through views. but, I don't know how to make a form from this content type and these fields, in order to allow anonymous and other users to insert data.

and if I use webform module, I can collect data from users, but I don't know how to publish this data through views (if this possible at all).


texts:
I want to add a Gift Card product to my Cart but assign a value the user typed in (so for example Product ID 3 would be gift card for $1, and I would then make it $25,$50, and so on).

How can I do this? I looked at uc_cart_add_item but it is just NID, and I don't want to make 500 different products for each amount possible.

Any help!?


texts: How do I make theme suggestions for pagers?

texts:
I am trying to create theme suggestions function for pagers in my *.theme. Is this possible in Drupal 8? If it is possible, what is wrong with the following code? Is suggestions_pager_alter the right way to access the hook call so I can add a theme suggestion to a page, so I can override the template. I am not worried about the functions logic.

function mytheme_suggestions_pager_alter(array &$suggestions, array $variables) {
  // Add template suggestions based on the current view mode.
   print_r(); exit;

}


texts: How to delete Panel variant programmatically

texts:
I have a "node_view" panel pane, with a few variants.

Say a variant called node_view_panel_context_9, and I would like to delete this variant programmatically using code (from a hook_update_N hook to be specific).

What are the correct API functions/methods to use?


texts: Sum up views custom text field using aggregation

texts:
Would it be possible to set the custom text field value in views? I have a simple calculation in custom text field. It gives me the correct calculation, but when I'm trying to aggregate the views to calculate the total sum from custom text field it returns 0 value.

I'm thinking that custom text field has no value in the first place and it's only output an HTML. Would it be possible to set custom text field value from the calculated output? Or is there any other way to achieve this without using the hook system?

Please note that I'm also attaching another view into custom text field which returns a total sum from another field.


texts: How can I update the block content programmatically?

texts:
I have created a block plugin.
/src/Plugin/Block/Myblock
/**
 * Provides a 'Download component' block.
 *
 * @Block(
 *   id = "my_custom_block",
 *   admin_label = @Translation("My custom block"),
 * )
 */
class Myblock extends BlockBase {
  // Other code
}

The above block has a settings form also where I am uploading some files to the block.
I placed this block in two different regions on a page with different settings. (Uploaded different files)
Now I want to update the content of one of them i-e add a new file programmatically.
How will I do that? Because I can't load the block and update the field and save the block again because both returns me the same id my_custom_block.
$this->entityTypeManager->getStorage('block_content')->load('my_custom_block'));

And also this returns me null.
Any idea how will I do that? Just like we update the nod entity, I want to update an instance of this block plugin.
Updated code:
I get the block like this
$node = \Drupal::routeMatch()->getParameter('node');
 if ($node instanceof \Drupal\node\NodeInterface) {
    /** @var \Drupal\layout_builder\Field\LayoutSectionItemList $layout */
    $layout = $node->get('layout_builder__layout');
    $block = $layout->getSection(0)->getComponent('1bb8e7b4-8253-40bc-a1f9-7f02e90edb2f')->getPlugin();
    $block->setConfigurationValue('file', ['6338, 6336']);
 }

Now how will I save the node using the block new configuration values?
I tried this.
 $node->get('layout_builder__layout')->getSection(0)->getComponent('1bb8e7b4-8253-40bc-a1f9-7f02e90edb2f')->setConfiguration($block->getConfiguration());
 $node->save();


texts: I am trying to update Drupal core using Composer, but I am not able of doing it. I have followed a few blog posts, but nothing worked for me. This is the output of composer update drupal/core --with-dependencies.


texts:
When configuring a webform submission URL by using tokens, I noticed this entry that specifies a link template:

[webform_submission:url:?]

  The URL of the webform submission. Replace the '?' with the link
  template. Defaults to 'canonical' which displays the submission's
  data.

What is a link template? Can I customize or define my own? How would I know what other tokens can be used in place of 'canonical'?


texts: How to display current pages the media entity is referenced during deletion?

texts:
We are using Media Entity module that provides a Document media bundle. On our Article content type, we have created an Entity Reference field to Media that is set to Document media bundle.

When you click Delete on this Document media entity, you are taken to a Are you sure you want to delete the media <media name>? page for confirmation (not sure of the official name, but let's call it Confirm Deletion page). On this page we would like to display all the pages where this media entity is currently being referenced.

How would we display the list of nodes that are referencing the media that content editors are attempting to delete?


texts: How do I embed a view as a form field and pass the information on

texts: I have a view that lists a number of nodes with images, I would like to take a grid view version of this and utilize it as a form. When the user clicks on an image, it will act like a selection box. Then, when the form is submitted that information will be passed on. What is the best way to do this?


texts: How do I add a conditional ie 6,7,and 8 stylesheet to my feature?

texts: Where and what code do I need to add to include a conditional ie 6,7,and 8 stylesheet directly in my feature?


texts: How to add login form to the Access Denied page?

texts:
I'm trying to add a login form to the access denied page, and wonder if this is possible via the UI.

Any suggestions/ideas?


texts:
Does anyone know - using SQL only - how to output the link to a drupal node?

If I was using PHP I think it would be something like this:

print l($node->title, 'node/' . $node->nid);

But I'm not using PHP, I need to use SQL only because the report module I'm using requires it.


texts:
Call me stupid, but I currently have a site that is using both Joomla and Drupal (long story). The site uses a number of sub-domains to represent different geographic locations.

For the main menu in Drupal, I have some items linking to pages within Joomla. However, Drupal doesn't allow to to specify a relative URL if the link is external to Drupal. This means I have to put the full URL including http scheme and hostname. Consequently, clicking these menu items results in a new window or tab being opened up, which is not what I want!

Does anybody know of a way I can have Drupal accept an external URL without needing to include the domain? For example: "/myJoomlaURL", instead of "http://www.mydomain.com/myJoomlaURL"?

Currently using Drupal 6.


texts:
I have views with table display, the table consist of two column(name[string], salary[float]).
How can i set a auto increment for the table rows?
like this want i want  .
Thanks.


texts: Gmap Error "Javascript is required to view this map" when embedding the node in another node

texts:
In my drupal 6 site, I use finder embedded in a node, to search for another node.
When user select a result the node is loaded in the same page.
The final structure is

parent node

finder embedded
parent node description

resulting node

Everything works fine, except that the Map loaded in the resulting node is not displayed.
I get this error "Javascript is required to view this map".
Obviously I've checked what's wrong, and I've seen that the required JS are missing (gmap.js, marker.js, etc..).

How can I force GMap to load js if they are missing?
Why do you think this is happening?

UPDATE

The problem is related to Ajax.
If I take the same scenario and hit Enter instead of Find, the request is made without using Ajax and the map is shown correctly.
Using the Find button (Ajax request) the problem persist.

Any solution?


texts:
I'm working on a site in which I'd like anon users to be able to create nodes of a certain type, but I only want them to be able to see/edit some of the fields on that content type.

I can't go into details just yet, but the goal of the site is to crowd-source the collection of information and then have a few administrators who will approve and groom the data. That's why I want anon users to be able to create nodes and only access a few fields. Then admins will be able to supplement that data by adding values into the other fields and then publish that node.

How do I restrict access to fields basing on the roles the users have?


texts: How do I programmatically remove menu tabs from the user login page?

texts:
In Drupal 7 I could remove tabs using hook_menu_alter() like below:

/**
* Implementation of hook_menu_alter
*/
function MY_MODULE_menu_alter(&$items) {
  $items['user/register']['type'] = MENU_CALLBACK;
  $items['user/login']['type'] = MENU_CALLBACK;
  $items['user/password']['type'] = MENU_CALLBACK;
}

This hook has been removed from D8 and is now handled by altering routes. However, I cannot figure out how to remove the these tabs from the user login page. The following page gave examples of altering a menu item's title and permissions, but I haven't been able to find any clues to remove a tab from a page.

https://dev.acquia.com/blog/coding-drupal-8/defining-and-altering-routes-in-drupal-8/22/03/2016/9891


texts: How to change the title and add a placeholder to password and confirm password field through hook_form_alter?

texts:
How can i remove the label of the password and the confirm password field through hook_form_alter functionality ?
Tried the below:

$form['pass']['#title']= t('');   $form['pass']['#description']=
t('');
$form['account']['pass']['pass1']['#attributes']['placeholder']=
t('Password');
$form['account']['pass']['pass2']['#attributes']['placeholder']=
t('Confirm Password');

But no change in the behavior.
This is the exact code that i have written in my .theme file.
   function THEMENAME_form_user_pass_reset_alter(&$form, &$form_state, $form_id) {
  // Get default process function array:
  $element_info = element_info('password_confirm');
  $process = $element_info['#process'];
  // Add our process function to the array:
  $process[] = 'port_process_password_confirm';
  $form['account']['pass']['#process'] = $process;
}

function port_process_password_confirm($element) {
  $element['pass1']['#title'] = t('New password');
  $element['pass2']['#title'] = t('Confirm new password');
  return $element;
}

The output that  i am getting is as per the below image