texts: EU Compliance for Drupal multidomain (each domain has its own language)

texts:
We have developed a multidomain drupal project and each domain has its own language. In other words, each language has assigned its own domain.

When we have developed multilanguage sites we have not found any problem to use "EU Cookie compliance" module to show an specific configuration for each language: in fact, if we change "/en/" for "/es/" in URL we can configure its specific EU Compliance.

But, as we told you, this is not a multilanguage... it's a multidomain platform. Our problem is if we try to implemnt "EU cookie compliance" module for each domain we cannot change it because this module only show us main domain of platform.

Anybody knows how I can implement it an specific EU Compliance for each domain?


texts: Remove unrelated terms from view's filter criteria (tag list filtering)

texts:
I have a content type with four main categories. Users can reach each main category from links.  These links are pointing to the default "/taxonomy/term/%" view. There are two filters that exposed to visitors. Filter by name and tag. My problem is that tag dropdown shows all tags, even those that belong to other main category. How can I limit the list to show only the available tags from the current view? Is there a module for this?

Example:

Contents

Name / Category / Tags (separated with "+" sign)

Drupal / PHP / cms+modular+complex
Wordpress / PHP / cms+modular+blog
Codeigniter / PHP / mvc+framework
Django / Python / great+python+framework

If I visit either the page that lists PHP or either Python category, the tag filter criteria shows all existing tags:

cms+modular+complex+blog+mvx+framework+great+python

However on the PHP page it should only show me:

cms+modular+complex+blog+mvx+framework (because "great" and "python" are not related to any PHP content.

This means Python page should allow me to choose only from:

great+python+framework ("framework" appearing in PHP too but that doesn't matter as the page already filter it to only Python category)


texts: When adding groups under the 'audience' list box for Organic Groups, i can see ALL groups created by everyone. How can this be limited so the user only see's his/her groups created in the audience list box? Help is much appreciated!


texts: I am working on a site that I inherited from someone else (i.e. I didn't design the theme). I've made a bunch of changes in the CSS to make the site look better, and everything seems fine, but after a couple days, the CSS resets to the old CSS. I then clear the cache and my changes reappear. I have to clear the cache every few days to get my changes to stay. I don't understand what could be causing this. I believe the theme is a ZURB Foundation subtheme.


texts: Preprocess views view to concat two dates and add variable

texts:
I've been trying to get a custom format placed upon a date range with particular rules (Explained in code comments) within Drupal 8 views.

What I currently have worked with regard to me being able to get the original two dates and to customize them but what I can't seem to do is pass the result ($display_date_range) forward to the fields view TWIG file (views-view-field--group-travel.html.twig)

What I have so far

/*****************************************************************************
 * VIEWS VIEW PRE-PROCESS
 * @param $variables
 *****************************************************************************/
function cazloyd_preprocess_views_view(&$variables) {
  $view = $variables['view'];
  $id = $view->storage->id();

  // Handle the Group Travel Listing view
  if($id == 'group_travel_listing'){
    foreach ($view->result as $key => $result){
      // Get start date from view
      $date_start = $result->_entity->get('field_start_date')->getValue();

      // Get end date from view
      $date_end = $result->_entity->get('field_end_date')->getValue();

      $months_are_same = (date('n', strtotime($date_start[0]['value']))==date('n', strtotime($date_end[0]['value'])))?TRUE:FALSE;

      if($months_are_same){
        // Month of start and end date are same, show only the day part of the start date
        // e.g. 11 - 23 July 2017
        $formatted_date_start = date('j', strtotime($date_start[0]['value']));
      }else{
        // Event crosses over into new month, therefore show day and month part of start date
        // e.g. 11 July - 5 August 2017
        $formatted_date_start = date('j F', strtotime($date_start[0]['value']));
      }

      $formatted_date_end = date('j F Y', strtotime($date_end[0]['value']));

      // Build final date range
      $display_date_range = $formatted_date_start . ' - ' . $formatted_date_end;

      echo '<pre>';
      print_r($display_date_range);
      echo '</pre>';
    }
  }
}


texts: Create fieldable bundle types for an entity with Drupal Console

texts:
I am trying to recreate the functionality of a NodeType/Node entity at a basic level.

I want to define entity types (FooType) which can be fielded individually, just like NodeType can be.

I used the Drupal Console to generate a config entity and content entity. Out of the box, it creates types and content entities of those types. However you can't field those types, I don't see a way to add that.

When I try to mimic the annotation in NodeType to allow fields, I get the following error when I try to save a field to a FooType:

Missing bundle entity, entity type foo_type, entity id foo.

Where am I going wrong? Is this something the Drupal Console can already do and I missed it?

Update:

So I think I am past the original issue... now when I want to add a field on a type, I get:

Attempt to create a field 'field_testfield' without a bundle.

The URLs don't seem to be correct, as it keeps dropping me back on Foo entity settings instead of stay within FooType, where I am trying to add fields to.


texts: Export set variables from site to include in install profile

texts: Is there a module, separate from Features, that can export currently set variables (as you can see if you run drush vget) - in the correct format so that I can copy and paste into the install profile. - e.g. as variable_set('admin_theme', 'minimal'); for example.


texts:
I know this question has been asked many times for the past versions of Drupal, but none of the solutions I've found works for Drupal 7.12.

I used to have an .htaccess file placed inside the document folder alongside with Drupal, and it partially worked on older versions when entering the front- and live-page of my website (which you can now only enter via "default-URL").
For reference, you were able to to enter the live page with http://pavescorner.com/live,
but after the patch and some other maintenances on my website, the link has to be like this http://pavescorner.com/drupal/live.

During those tests, when I tried to make another working .htaccess file, I accidentally destroyed the version working for me, and now you can only enter my homepage with the /drupal subdirectory.

What should I put in my .htaccess file so that /drupal doesn't appear in the URLs for my site?


texts: How do I show the size of an Image file in media2 after selecting the image?

texts:
After selecting an Image field using the media browser, in the edit form the selected shows image, an edit button, a delete button, and an "include file in display" checkbox.

How Do I add the size of the image in the same display?

Q2:
In a colourbox popup display, which seems to only pick the "title" , I cant get this to read html. Is there a way of enable html as I need some text in Italics, and in Bold?

Thanks.


texts: Cannot get value of form field of type 'file' in drupal form

texts:
I have a form field  such as  ,

   $form['fileTransfer_settings']['file_path'] = array(
    '#type' => 'file',
    '#title' => t('Choose file'),
    '#size' => 22,
    '#description'   => t('path for the csv file'),

  );

Now I am looking to save the path of the uploaded file in the submit handler ,

But when I look into the value of the form field in the submit handler I get null,

function transferfile_submit_handler($form, &$form_state) {

     dpm($form_state[values]); //other fields show value
     dpm($form_state['values']['fileTransfer_settings']['file_path']); //null
 }

What  am I doing wrong here?


texts:
I am developing a custom module with some entities inside. I created a form to edit them and I would like to use CKEditor in one of the fields.

I can see and use the CKEditor, but when it's time to save, it always saves the value 'Array'. You can find the code I am using below:

$form['description'] = array(
        '#type' => 'text_format',
        '#format' => 'full_html',
        '#title' => t('Content'),
        '#default_value' => $entity->content,
        '#weight' =>2,
        '#required' => FALSE,
    );

I'd say CKEditor changes the value before sending the form POST but I am not sure.

Any ideas?


texts: Drupal Commerce Line Item temporary delete?

texts:
I need to temporarily remove a few line items from an order.  I can remove them well enough, but they won't add back.  There aren't any error messages in watchdog, the error log, or on screen.

Here is the code I have currently:

$orderWrapper = entity_metadata_wrapper('commerce_order', $order);
$removedLineItems = array();

// Loop over each line item on the order.
foreach ($orderWrapper->commerce_line_items as $delta => $lineItemWrapper)
{
  $product = $lineItemWrapper->commerce_product->value(); // Get id to pass to line_item_delete

  if ($product->some_field[LANGUAGE_NONE][0]['value'] !== 'some condition')
  {
    $lineItem = commerce_line_item_load($lineItemWrapper->getIdentifier());
    $removedLineItems[] = $lineItem;

    commerce_line_item_delete($lineItemWrapper->getIdentifier());
    unset($orderWrapper->commerce_line_items[$delta]);
  }
}
commerce_order_save($order);

// Run some other code on $order
somePlugin_someFunc($order);

// Add back items removed for package calculation
if (count($removedLineItems) > 0)
{
  foreach ($removedLineItems as $lineItem)
  {
    commerce_line_item_save($lineItem);

    $orderWrapper->commerce_line_items[] = $lineItem;
  }

  commerce_order_save($order);
}

Anyone have an alterative to the above?


texts: Create destination directory with drush archive-restore?

texts:
I'm using this terminal command to restore an archive created on a remote server locally:

drush arr archive.tar.gz default --destination ./newdir --db-url=mysql://user:pass@localhost/db

The archive was created with drush archive-dump, and the restore is on a Mac running the MAMP stack.  The archive is in the current working directory when I run drush arr.

In general, this works fine, but for some reason, the new directory (newdir) isn't created. All files are restored into a folder named "1" (which is created). Drush reports "Archive restored to 1"

Is there some way for me to modify the syntax so that newdir is created, and all files are restored there?


texts: Is there a filter/search option available for navigating the 'Find Content > Files' page?

texts:
I have a site with thousands of files uploaded, and Drupal's admin view doesn't seem to offer a comprehensive filter for the Files view like it does with the Content view.

There also apparently isn't the option to search the files either.

Files view:

Is any such filter or search option available? This would make updating files 10 x faster!


texts:
I am creating real estate website and as exposed filter for search in views i have a price.

Core view options are sufficient but maybe not so user friendly (as i have to explain in details how to input price, like dont use dots or spaces) so i was thinking of using slider so user can pick price range (for example from 10.000 up to 100.000).

I am not good at coding so was looking for module that does this ?


texts: On export Managed_files With Features No UUID Added

texts:
I have a custom field  of type 'managed_file' along another field of type - 'file'. This node is exported into feature. The field with 'file' type gets UUID attached while it does not for 'managed_file' field. In the database table 'file_managed', there are UUIDs for all the files included ones uploaded with 'manged_file'. Why is it not including the UUID for managed_file custom fields in the feature? Is there a separate module for this? Any suggestions how to best export/import files? Your help is much appreciated

uuid 7.x-1.0-alpha5+17-dev, uuid_feature 7.x-1.0-alpha3+15-dev, strongarm - 7.x-2.0, Drupal 7.26


texts: Place or attach permanent file to the node edit form

texts:
I want to make an attachment available for download to the user who is filling out a node edit form. This attachment will be a file template that they will fill out, save, then upload to the filefield field at some point, so I want the attachment to ALWAYS be available on the node edit form.

I realize I could do this by placing a block on the page via the block admin ui, but I would like to accomplish this using hook_form_alter, because the file that is attach will be specific to certain field within that form having certain values when a user is editing the form. I've provided a visual mock-up for further clarification.


texts:
I'm getting results from a SOAP call, but cannot display the values in a  select list on my custom module.
This is a part of my code:

foreach($sxml2->NewDataSet->DepCity as $item) {
    $fromName = $item->Name;
    echo '
' . $fromName . '
'; //It displays correctly

    $form['from'] = array(
        '#type' => 'select',
        '#title' => t('From'),
        '#options' => $fromName,
    );
}

$sxml2 is a simplexml load string result and it's display correctly.
When I echo the result from the loop ($fromName), I'm getting all the strings properly, but If I try to put that variable in a custom form select, it doesn't display any data.

How can I get the results in a Drupal form select?

EDIT:

I've tried with this, but it still doesn't display anything in that select.

echo '
';
print_r($sxml2); //The whole simpleXML object with arrays is displaying properly
echo '
';

$options = array();
foreach($sxml2->NewDataSet->DepCity as $item) {
  $options[$item->Name] = $item->Name;
  echo '
' . $item->Name . '
'; //It displays correctly

}

$form['from'] = array(
  '#type' => 'select',
  '#title' => t('From'),
  '#options' => $options, //It doesn't display the data
);


texts: How can I delete a poorly named vocabulary?

texts:
I've created a couple of vocabularies programmatically, and accidentally included some spaces in the machine names (caused by bad data in an input CSV). I can't delete these vocabularies with Vocabulary::load($vid)->delete();, even though I can see the vocabularies names with
dsm(taxonomy_vocabulary_get_names());, while load($vid) returns NULL.
Any ideas on how I can delete these vocabularies? I was able to delete all the terms in a vocabulary, but the reference remains under admin/structure/taxonomy.


texts: Need to know if user is coming from frontpage using jquery

texts:
On a Drupal 7 site I need some jQuery-animation on a page, only if user is coming directly from frontpage. My programming skills are very limited and need some help on that. I found something with parent.history.back()-function, but I don't know if and how I can use that in an if-statement.
Any help is very appreciated


texts:
How to set the filter condition by default for specific condition in view i,e i have view with the filter condition STATUS drop down list has 1]live 2] discard,so here i want to filter by default for live status when i open this view can any please tell me how to do this?

Thanks a lot in advance.


texts: Are there terms to distinguish between the different levels of Drupal Core?

texts:
"Core" seems to cover over a multitude of things, encompassing all the modules that ship with the Drupal code base.  But there seem to be levels of "core"-ness, and I'm wondering if there is official terminology to distinguish between these. For example:

There is the code that is not part of any module.  Does "core" include this officially?  It's not clear to me.
There are required modules: without these (at least in Drupal 7) you can't really build a Drupal site.
There are all the default modules that are part of Core.  You can turn many of these off without a problem, but they're still considered "core".
There are modules that are turned off by default (PHP Filter) and which may even be considered a bad practice to use under normal circumstances (PHP Filter, again).

If I were naming these levels, I might call them

The Drupal Kernel
Deep Core Modules
(Normal) Core Modules ("Core Modules" would include 2 and 4 as well)
Outer Core Modules

But it seems like Dries may have an official terminology already.  Is there such a thing?


texts:
I have a simple panel page containing 4 blocks that are all translated (and set to translatable). However they are always displayed in English (default language).

The taxonomy term is passed as a context and is used to display the page title. And it is also translated (%taxonomy_term:i18n-name)

The rest of the page is translated correctly. I unfortunately don't have much more info to share as this is basically it...

What am I missing here? Thanks for your help!

I am using Drupal 7 and Panels 3


texts:
Is there a way to change this link to only a #. In the backend it's not possible to change this..

I want this only to be a activator for a dropdown and not a link to the content page because this page is not going to be used.


texts: Why doesn't my drupal 8 bootstrap subtheme show search results?

texts:
I have a bootstrap subtheme I'm using for the following site - kobejet.com.

Everything looks and has been working correctly, up until about 2 weeks ago, when the search results started showing only number, with no actual results.

It seems the results are being returned, as the numbering is correct for how many results there should be for any inquiry. For example, if you search for "computer" - there should be about 14 results, but only the numbering shows.

I've tried to go over my installation, comparing my child/subtheme to the base theme and CDN starter kit, but have yet to make any headway.


texts: Organic Group Notifications : Enabling OGN module render adding other category subscriptions dysfunctional

texts:
I enabled the OG-notifications module to enable notifications for the content being added to a particular group. It is correctly adding the subscriptions for Organic groups.

But, when the other category subscriptions are being added (i.e. Content Types / Thread), error prompts with message "Select existing group" appears. Thus, other subscriptions are not being added.

Any suggestions to set right adding other subscriptions are welcome.


texts: I would like to add library to my drupal 7 custom module. Library can be installed via composer, but i can't find a solution for install? How can i install this library? I have installed "composer manager" but i still can't get it running.


texts:
I wish know whether a drupal function/file can be executed using 'shell_exec()' from another drupal function.
Any help is appreciated.


texts:
Currently Drupal defines itself as a "Content Management Platform". My assumption is that they are trying to differentiate themselves from CMS which provide a much more specific goal, such as a wiki or pure blog.

I have found some research and other systems which also use the term but not a single definition.

Can anyone provide a noteworthy definition or provide one themselves which would match the current consensus? Do other broadly scoped CMS such as Joomla and WordPress fall into this category?

Thanks!


texts: entityform list fitting to selected node

texts:
After searching the web for hours I'm hoping to find the answer here for my problem.

So here is my goal:
I defined a content type, travel which contains a multiple values textfield for additional services and a entityform for booking additional services (e.g. train ticket to the travel starting point).
Each travel node has of course different number of additional services, after clicking on 'booking additional services' the form appears which should include a checkbox for each additional service to select by the customer.

I defined a text list in the form for the additional services.
Now my question is, how can I generate a list of additional services for the particular travel in my form.
I can only set the possible values for the list in the field settings but these values depend on the particular travel!

Could you give a hint?


texts: Fill the "Unpublish on" date field of the Scheduler module depending on list field

texts: I have a content type, where I want to give the user only three possibilities to unpublish content: in 1, 3 or 6 months. For the selection of the three options I use a list field. How can I transfer the selected value to the unpublish field?


texts:
I have a content type "Slide" that I use for a carousel in a view as a block. One of the field of the slide I have added is "country filter" that I intent to use as a filter for geo localisation. I use GeoIP2 for this.

My intent was to use a THEME_preprocess_SOMETHING() to alter the view and remove some of the slides that are not on the right country filter. For example some slides could be allowed to be shown only to user located in France. If the user is not located in France, I would remove those slides.

I tried to do this in a THEME_preprocess_view_view_fields() but I can seem to find a way to remove completely the slide. So I guessed I was not on the right hook.

Does anyone knows which hook I should use to do that?


texts:
I have a videos content type and I want users, who have watched this video, to answer some questions related to each single video.

How can I create a quiz for each single video node?
I tried the webform module and create a video block but there is a problem.
The  video will be shown in all forms and I can't insert video for next question.
Please help me.


texts: How to add a title attribute from a different field to a link produced by a view

texts:
I have a view that uses one field to produce a list of links to content.

I want to add a 'title' attribute to the link produced by the view that takes its value from a different field.

How does one do this in Drupal 8?


texts: Pre-cautions to take when manipulating table structures

texts:
There are some use-cases for modifying the tables manually in the database. One such, when using MySQL, is "downgrading" all cache_* tables from InnoDB to MyISAM, to get better performance.

Another use case is text fields storing data that require 4 byte encoding, instead of the normal 3 bytes. Manually this would look like:

ALTER TABLE t1 DEFAULT CHARACTER SET utf8mb4, MODIFY col1 CHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;

And then when interacting with this field ones need to issue SET NAMES 'utf8mb4' to ensure the connection passed data properly.

Is there any functionality in DBTNG to handle such odd use-cases, in part or in whole? Or will one need to handle them entirely manually? Are there any other pre-cautions one should take, to reduce the risk of future problems in this type of case.


texts: Add #theme_wrapper after drupal_render() is called

texts:
I have a render array:

$element = array(
   '#theme' => 'custom_theme_func',
);

drupal_render($element);

I have a preprocess function in which I'd like to add theme wrappers to this render array:

function my_module_custom_theme_func(&$element)
{
    $element['theme_wrappers'] = array('some_theme_func');
}

The problem that I'm running into is that some_theme_func() is not being called.  If I add it to the list of theme wrappers before I call drupal_render(), however, it works.


texts: How do I get a form field value out of a config entity data blob?

texts:
I am trying to add a form field in a existing config entity form.
The value of the field is stored in the data blob of the correct config entity but I am not able to get it out of it.

/**
* Implements hook_form_FORM_ID_alter().
*/
function my_module_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {
 $someEntity = \Drupal::entityTypeManager()->getStorage('some entity');
 $form['my-field'] = [
  '#type' => 'number',
  '#title' => 'some title',
  '#weight' => 1,
  '#min' => '0',
  '#max' => '50',
  '#default-value' => $someEntity->getValue('my-field'), // Here I would like to get the Value that is stored in the db
 ];
 $form['#validate'][] = 'my_module_field_config_edit_form_validate';
}

@Berdir

I tried your answer but the value still won't be set as default_value

    /**
     * Implements hook_form_FORM_ID_alter().
     */
function comment_limit_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {
  $comment = $form_state->getFormObject()->getEntity();
  $form['edit-limit-per-user'] = [
    '#type' => 'number',
    '#title' => 'Comment limit per user',
    '#weight' => 1,
    '#min' => '0',
    '#max' => '50',
    '#default_value' => $comment->getThirdPartySetting('comment_limit', 'edit-limit-per-user', FALSE),
  ];
  $form['#validate'][] = 'comment_limit_field_config_edit_form_validate';
  $form['#entity_builders'][] = 'comment_limit_form_field_edit_form_add_form_builder';
}

/**
 *
 */
function comment_limit_form_field_edit_form_add_form_builder($entity_type, FieldConfig $comment , &$form, FormStateInterface $form_state) {
  $comment->setThirdPartySetting('comment_limit', 'edit-limit-per-user', $form_state->getValue('edit-limit-per-user'));
}

comment.type.comment.third_party.comment_limit:
  type: mapping
  label: 'Comment limit per user'
  mapping:
    edit_limit_per_user:
      type: number
      label: 'Comment limit per user'

Did I miss something?

This works for me:)


texts: plupload upload fails with 500 Error code: 104, message: "Failed to open temporary directory."

texts:
I installed
"drupal/plupload": "1.x-dev@dev",
"drupal/plupload_widget": "^1.0",
"moxiecode/plupload": "^3.1"

and configured a upload form for Media items with the plupload_widget.
Uploading fails with a http 500 error message with the following response:
{"jsonrpc":"2.0","error":{"code":104,"message":"Failed to open temporary directory."},"id":"id"}

drush status returns:
Drupal version   : 8.9.13
 Site URI         : https://web-fresh.ddev.site
 DB driver        : mysql
 DB hostname      : db
 DB port          : 3306
 DB username      : db
 DB name          : db
 Database         : Connected
 Drupal bootstrap : Successful
 Default theme    : hw_radix_standard
 Admin theme      : seven
 PHP binary       : /usr/bin/php7.4
 PHP config       : /etc/php/7.4/cli/php.ini
 PHP OS           : Linux
 Drush script     : /usr/local/bin/drush
 Drush version    : 10.3.6
 Drush temp       : /tmp
 Drush configs    : /var/www/html/vendor/drush/drush/drush.yml
 Install profile  : minimal
 Drupal root      : /var/www/html/web
 Site path        : sites/default
 Files, Public    : sites/default/files
 Files, Private   : sites/default/files/private
 Files, Temp      : sites/default/tmp

I can't find any plupload.settings in config and don't know how to set the plupload temporary dir.
Tried to set it like that in settings.php:
$settings['file_temp_path'] = 'sites/default/files/tmp';
$config['plupload.settings']['temporary.uri'] = 'sites/default/files/tmp/';

But that didn't change the behaviour.


texts:
I'm using i18n and submodules to translate an English Language site to Spanish. I'm also using Automatic path aliases.

The issue is that menu links are directly to the node: node/42. When in the Spanish part of the site, /es/ the links take me to es/node/42, not to the aliased url.

The best answer I've seen is this "Afterwards, you can arrange your menu links as you need them. I use parent/child URL aliases based on menu hierarchy, so I make a mirror menu tree." I don't know what he means, but it sounds like what I'm trying to do.


texts: Display block on homepage depending on value in user profile field?

texts:
I'm currently displaying a block on my D7 site' homepage.

Now I've a requirement to display that block only if the logged in user has a specific value in their profile.

I know it can be done using php evaluation by navigating to the bottom of the block and then click (Pages > Pages on which this PHP code returns TRUE ) but have no experience in writing php scripts.

Can anyone help with this please.

thanks


texts: Content type with buttons such as "I'm going here" and "I have been here"

texts:
Is there a way to have a content type for a location (I've already set up the map part) so users can click a link and say whether they've been there or not and it will show on their profile as 'places visited' and 'places planning on going'.

Thanks


texts: How to return [error] in a rest api build with view?

texts:
I have a view which gives has an input:
email
key

The json returns a uid.

I would like to return [error] when the combination email + key is not found. Currently, it is only [].

How to do this?


texts: Adding link with image in the .tpl.php file

texts:
I have just started with drupal and have very little understanding and experience with it. I was able to develop a module by referring to sample modules available online. I have a .tpl.php file that is supposed to have a link in the form of an image, I am hoping to execute a php function (php function is ready) by clicking on that image.
So my question is how to add a link inside the .tpl.php file, do I have to implement a form? if so, what file should have this form? How to execute the php function on click from this link?

Please let me know if the question doesn't make enough sense.

Thanks


texts: How do I programmatically disable/enable a block?

texts:
I have the following code but its not disbling the block. It remains active and visible on the sidebar where i have placed it.

$theme="themename";
$block="client-block-1938";
$module="modulename";
$region="right_top_box";
db_merge('block')
        ->key(array('theme' => $theme, 'delta' => $block, 'module' => $module))
        ->fields(
                       array(
                              'region' => $region,
                              'status' => 0,
                              'visibility' => 0,
                           )
             )
->execute();
cache_clear_all();


texts:
I have created one content type named "collection", where I will be grouping the related articles into collection. The content type itself has other fields like title, tags etc.

To add article into collection, I have created field of type referenced entity and is working fine. Also use can add multiple articles into collection.

Now I wanted to provide the user to manage order of the articles in the collection, so that article can be arranged in proper order.

So at the time of selecting article, user also decides its order/weight.

Is there any drupal module that helps in achieving this or how can I achieve it if no module is there.

-- Thanks for your time


texts: How to change active theme based on taxonomy?

texts:
I have a situation where I need to change the active theme based on whether the current entity has a certain taxonomy tag. So when an entity is viewed and tagged with candy, I would like the Candy theme to be activated.

My research has lead me to believe that the easiest way to achieve this is to implement a theme negotiator in a similar way to the example given here.

I am able to switch the active theme based on the route and also the current uri, the problem is getting the theme to switch based on a taxonomy tag. I am not sure how to get the taxonomy tags for the current entity from within the theme negotiator. I would like to be able to do something similar to the following.

public function determineActiveTheme(routeMatchInterface $route_match) {
  // Get the current taxonomy tags.
  if (tag_exists) {
    return 'candy_theme';
  }
}

How can I achieve this?


texts: Create different user profiles with drupal 7

texts:
There are two user profiles, landlord and tenant. Both require different user role as well as different registration data.

Now tenant can search through landord's profiles and comment / rate on them as well.

How can I achieve this in drupal 7


texts: Use another token value if the first one is empty

texts:
I am using the [message:user:profile-fname] token to get the first name of the user, but some users are without first name; the value shown for that token is a blank string.

How can I use another token (e.g. [message:user]) if the first token is an empty string?


texts: How to get the content moderation entity related to node entity in drupal 8.2.x?

texts:
from a content moderation entity, i know how to get the associated node:

 if ($entity->getEntityTypeId() == 'content_moderation_state' ) {
     $article_id=$entity->get('content_entity_id')->getString();
     $article = \Drupal\node\Entity\Node::load($article_id);
 }

What i need to do is the reverse.
Being able from hook_form_alter, to get the content moderation entity related to the node:

 function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){
  if ($form_id='node_article_edit_form')
  {
    $node=$form_state->getFormObject()->getEntity();
    //$node->get_content_moderation_entity??

}

}


texts: Render a field of a "node_view" array in a block template file

texts:
I want to render a field_address field (text field) in a block template file. The node is loaded in a preprocess function.
I know I can print the field value with {{ front_nodeObj.field_address.entity.field_address.value }}, but I want to print it in the used language and with the label, as in the node display in the administration page, and without additional modules.
The code I am using is the following one.
function mytheme_preprocess(&$variables, $hook)
  $front_nid = 3;
  //node_load
  $front_nodeObj = \Drupal\node\Entity\Node::load($front_nid);
  //node_view
  $front_content = \Drupal::entityTypeManager()->getViewBuilder('node')->view($front_nodeObj);

  $variables['front_nodeObj'] = $front_nodeObj;
  $variables['front_content'] = $front_content;
}

The block.html.twig template contains the following code.
{{ front_content['#node'].field_address }} ???

The Drupal 7 code would be the following one.
<?php
  $nid = 3;
  $nodeObj = node_load($nid);
  $content = node_view($nodeObj, 'full');

  print render($content['field_address']; //how to do this on Drupal9?
?>


texts:
I am using Drupal 7, and I have a content type called Case Record that has the following fields:

Title  (title, Node module element)
Case Number (field_cr_case_number, Text)
Case Title (field_cr_case_title, Text)

When the user creates a new node of this type and enters in a Case Number, an AJAX call is supposed to fetch the Case Title and populate it on the Case Title textbox. Here is my module code:

<?php
/**
 * @file
 * Module for Case Records.
 *
 * @category Examples
 *
 * @package Example Modules
 */

/**
 * Implements hook_form_alter().
 */
function case_records_database_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'case_record_node_form':

      $form['field_cr_case_number'] = array(
        '#type' => 'textfield',
        '#title' => 'Case Number',
        '#prefix' => '
',
        '#suffix' => '
',
        '#ajax' => array(
          'callback' => 'case_records_database_ajax_callback',
          'event' => 'change',
          'method' => 'replace',
          'wrapper' => 'div-case-name-element-wrapper',
        ),
      );

      $cs_short_title = "";
      if (isset($form_state['values']['field_cr_case_number'])) {

        // Code omitted. Use db_select to query the database and
        // get the real case title, but for now we'll just call it
        // "Some Case Title".
        $cs_short_title = "Some Case Title";
      }

      $form['field_cr_case_title'] = array(
        '#type' => 'textfield',
        '#title' => t('Case Title'),
        '#value' => $cs_short_title,
        '#prefix' => '
',
        '#suffix' => '
',
      );

      break;
  }
}

/**
 * AJAX callback.
 */
function case_records_database_ajax_callback($form, &$form_state) {
  return $form['field_cr_case_title'];
}

The AJAX call does indeed populate the Case Title text field with the dummy "Some Case Title" text. However, when I save the new node neither the Case Number field nor the Case Title field are saved with any values. They are both blank. What is wrong with my code?


texts:
I am using drupal 7 and i am trying to override the pager.inc function like this .

function bartik_pager_first($variables) {
  $text = '';
  $element = $variables['element'];
//  $parameters = $variables['parameters'];
  global $pager_page_array;
  $output = '';

  // If we are anywhere but the first page
  if ($pager_page_array[$element] > 0) {
    $output = theme('pager_link', array('text' => $text, 'page_new' => pager_load_array(0, $element, $pager_page_array), 'element' => $element, 'parameters' => $parameters));
  }

  return $output;
}

As you can see i am just trying to print the image for the text "first". But its just displaying like

How do i tell drupal that display it as html image rather then just text.


texts: Has anyone successfully uninstalled multiversion/workspace?

texts:
I can't edit nodes with paragraphs because what appears to be an incompatibility with mutliversion. I need paragraphs more so have tried to remove multiversion, this means removing workspace, but as soon as I remove workspace entities:

  There is content for the entity type: Workspace. Remove workspace entities (admin/modules/uninstall/entity/workspace).

My site dies…

Error: Call to a member function id() on null in /web/modules/contrib/workspace/src/EntityAccess.php on line 104

I've run through the uninstall every way I can think of without any success… Any guidance would be most appreciated!


texts:
My site runs now on Drupal 7.9.
On the release notes (4th position) it is reported the following note:

  Restored height/width attributes on images run through the theme system

That is exactly what I don't want, because my images get distorted.

How can I prevent height/width attributes on images run through the theme system?


texts: How to use multiple submit within a CTools Modal

texts:
I'm using a CTools modal to add a holiday. The topside of that form in the modal displays the already defined holidays with an "X" that will allow you to delete a holiday. I have created a submit button for each that is put in a table with this code (the rows are rendered in a table afterwards).

foreach ($locationVO->Holidays as $holiday) {
    $fid = 'delete' . $holiday['id'];
    $form['holidays'][$fid] =
            array(
                '#name' => 'delete_' . $holiday['id'],
                '#type' => 'image_button',
                '#src' => $crossimg,
                '#attributes' => array('class' => array('delete_holiday')),
                '#return_value' => $holiday['id']
    );
   $field = drupal_render($form['holidays'][$fid]);

   $rows[] = array($holiday['name'], ISOdate2DutchDate($holiday['from']), ISOdate2DutchDate($holiday['to']), $field);
  }

Everything is rendered ok, but if I try to delete a holiday, the triggering_element and the clicked_button arrays in form_state still always refer to the main submit that I defined in the CTools form_info array. I therefor cannot distinguish between the submits for adding and deleting.

What do I need to do to get my triggering_element to correspond with the selected submit? I also tried specifying a separate '#submit' handler for the delete buttons, but that is never called either.

Other solutions are welcome as well, as long a I can do it without closing/leaving the modal (I already tried with a link to a separate delete handler which worked up until the referral back to the modal).

Thanks!


texts: How to stop CKEditor from removing alt and title attributes collected by Media Browser

texts:
I am using Media Browser to upload images and when I do there are two fields that collect title and alt attributes. When I save I notice that the attributes are not there and I have to go into CKEditors image properties to re add them.

EDIT:

On CKEditor I click the image icon from the tool bar and i get the Image Properties popup.

When i click the Upload/Browse Server another popup appears with Media Browser.

I Upload an image and see another form asking for filename, alt text, title text and url redirect.

When i fill this info out and press save i am returned to image properties pop up with the image URL filled out but the alternative text field is empty and on the advanced tab the advisory title field is empty.


texts:
i need to add class to image.

so i have 3 column in my site.

each column have block for news, i need to add class for each images.

first class is .imgsmall {width:355px; height:125px;}

second class is .imgmid {width:455px; height:225px;}

third class is .imgbig {width:455px; height:325px;}

how can add this class for image what i need


texts: Adding custom image field to Metatags D8?

texts:
I'm using Metatags module on Drupal 8, all text fields seem to be working just fine. I'm trying to set the OpenGraph Image tag from an image field in my content type, called field_thumbnail.

Here are the tokens I'm using (I installed tokens contrib module to make sure I was using the correct ones)

But when I view the tags, it's coming up empty or what seems to be a line break of sorts. See here:

Anyone have any ideas on how to solve this?


texts: Drupal Static HTML content not rendering

texts:
Hoping all is well..
I have developed a personal theme and enabled it in a drupal installation. However static html doesn't show up at all.

I have used wysiwyg with ckeditor and enabled full html and still nothing shows up after saving. This happens with nodes and blocks. Only Plain text works and of course that doesn't implement html.

This problem's just began with this project. I have tried to create a fresh website and the problem prevails. I have even tried enabling garland (one of the default drupal themes) and i am still facing the same problem.

Has anyone faced a problem like this before?


texts: Set Update Manager to install to sites/all/modules/contrib?

texts:
I am able to use Update Manager to install new modules, instead of having to manually upload them. I previously put everything in sites/all/modules, but now have reorganized my modules into sites/all/modules/contrib and sites/all/modules/custom (for the modules I write or modify).

However, Update Manager is still installing new modules in sites/all/modules. Is it possible to tell Update Manager to install new modules in sites/all/modules/contrib instead? I looked for a setting somewhere, but can't find one (D7).


texts: META tags module description [node:summary] doesn't work

texts:
I have a content type with title, image, body field (long text with summary). I use meta tag module and when I add in Description: [node:summary] or [node:field_body:summary] nothing appears in the meta description in view-source.

<meta name="title" content="..."
<meta name="image" content="..."

Title and image work, but not summary.

Does anyone have a solution?


texts: Need to migrate large, complex Drupal 6 site to Drupal 8. Suggestions for a good way to tackle this if the core Migrate Upgrade doesn't work for me?

texts:
I have a lot of experience with Drupal 5, 6 and 7 and am just starting with Drupal 8 and I have a large, complex Drupal 6 site that I need to migrate to D8.

I first tried using D8's Migrate Upgrade but it fails part way through. I didn't have high hopes for this to work but I thought if it could at least get the users and bulk content in then that would be a great starting point. It was unable to accomplish either.

So now I'm going to go the export/import route and try to rebuild the data manually. I've done this a number of times upgrading D6->D7 using XML Views to create the export and Feeds to map and import. It looks like Feeds is nowhere near ready for use yet.

Is using core Migrate module along with other contrib modules to right approach? Is what I'm trying to do even possible?

If so, could anyone point me in the correct direction to get started? I've heard migration plugins mentioned before, I'm assuming that I'll have to create custom migration plugins to make this work, correct?


texts: How do I restrict view/edit access to a custom content type node to only the user it belongs to?

texts:
There is a content type; let's call it Contract. I have an user role; let's call it Consultant.

I added a Consultant field to the Contract content type with Entity Reference.

How can I restrict access to view/edit that specific node to only the user it belongs to?


texts:
I have a custom module which adds a button to a node form. The button opens another node form in a modal and when submitted, it takes the entity created in the modal and fills in an entity ref field on the first node form:
function add_venue_form_node_master_events_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // only do this if from Modal
  if (!isset($_POST['_drupal_ajax'])) return;

  $form['actions']['submit']['#submit'][] = '_add_venue_ajax_submit';
  $form['actions']['submit']['#attributes']['class'][] = 'use-ajax-submit';
}

function _add_venue_ajax_submit(array $form, FormStateInterface &$form_state) {
  // get NID of Venue we just created
  $nid = $form_state->getValue('nid');
  $node = Node::load($nid);
  $value = $node->getTitle() . ' (' . $nid . ')';

  $response = new AjaxResponse();
  $response->addCommand(new CloseModalDialogCommand());
  $response->addCommand(new InvokeCommand('#edit-field-vcr-cert-holder-name-0-target-id', 'val', [$value]));
  $response->addCommand(new InvokeCommand('#edit-field-pcr-cert-holder-name-0-target-id', 'val', [$value]));
  $form_state->setResponse($response);
}

This works perfectly but the form doesn't validate (required fields that aren't filled in aren't highlighted in red and no message at the top of the modal to show errors).
I found wombatbuddy's response here: Showing Form Validation Errors inside Modal showing how to do validation. This does work, but then my submit function doesn't work.
Does anyone know how to add validation into my existing code?


texts:
I extended some functionality in the slick module, but I am looking to do it in a way that doesn't get erased each time I update slick.

I added a css file and edited the slick skin php file to use the css file depending on the user's choice. I also added a bootstrap class to the slick.html.twig template so that the slider would disappear on mobile devices.

Should I make a custom module that acts like slick_examples?


texts:
This piece of code:

->orderBy('weight', 'ASC');

orders the column by the weight ascending. However, the rows are sorted like: 15 - 2 - 20
of course this should be: 2 - 15 - 20

How can I achieve this, specifically for drupal(7)?


texts: How to add only the postal code field to the user registration page?

texts:
I have a custom template file successfully rendering the user account creation page. I am using the Location Module, which adds a field (which appears to be a field group) to the user. I want to add only the postal code field (zip Code) to the user registration page.

template.php code:

    function responsive_bartik_theme() {
  $items = array();

  $items['user_login'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-login',
    'preprocess functions' => array(
       'responsive_bartik_preprocess_user_login'
    ),
  );
  $items['user_register_form'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-register-form',
    'preprocess functions' => array(
      'responsive_bartik_preprocess_user_register_form'
    ),
  );
  $items['user_pass'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'responsive_bartik') . '/templates',
    'template' => 'user-pass',
    'preprocess functions' => array(
      'responsive_bartik_preprocess_user_pass'
    ),
  );
  return $items;
}

user-register-form.tpl.php code:

<?php
     print render($form['account']['name']);
     print render($form['account']['mail']);
     print render($form['account']['pass']);
     print render($form['captcha']);
     print drupal_render($form['actions']);
     print render($form["form_build_id"]);
     print drupal_render($form['form_token']);
     print drupal_render($form['form_id']);
?>

   Forgot Password

Already have an account? Log in


texts: Which hook to allow specific users to add/edit/view comments?

texts:
Is there a hook that I can use that would give specific users permissions to add a comment, or edit their own comment?  I was hoping there would be something like hook_node_access().

In my form, I have a select list with all the users that the submitter can choose.  If the person is selected, then that selected person can comment on that specific node.

I looked at the comment access module, but that does not work since it is still being controlled by role permissions.


texts: Does anyone know how to programmatically create a discount code in Drupal  Commerce?


texts:
I am trying to create a link in a Drupal views-view-fields.tpl that links to the original content but for some reason it's not working.  The code I have tried:

<a href="<?php $fields['path']->content; ?>">Read more

and

<?php $link = $fields['path']->content;?>
 <a href="<?php $link ?>"> Read more

as well as adding single quotes.  The above points the rendered link to the current page/ view.  When I echo $link_path i get /?q=node/1544 , which is correct.

I have also tried to create the URL by using

$link = $GLOBALS['base_url'] . '/node/' . $node->nid;
<a href="<?php $link ?>"> more

The above shows the correct link when I echo it but, again in the rendered link it points to the current page/ drupal view.

What am I missing? I have to add that I only have about 3 months Drupal/PHP experience so still lots to learn.

Thanks :)


texts: How can I hide the label saying "URL*" from content creation form when using the link module?

texts:
I'm using the link module to ask the user for a link. I have disabled the link text (I.E> the text that would be inside the anchor tag) so the user wouldn't be asked for a title. What I would expect to happen is that I wouldn't see the field label, followed by the label "URL*". However, it isn't so.

As an example, my field label is Download link. What I see in the node creation form is a label like Download link* and then another label with the text URL*. Is there a way to hide the latter (the one saying URL*)?


texts: Are node numbers in Advanced Forum stable or can they change or be reused?

texts:
We run Drupal as our CMS and use the Advanced Forum module to provide a forum to users of our software. One issue in our bug tracker related to a discussion thread on said forum, so one of our devs included a link to that thread in the description of the issue.
The link had the form "https://www.example.com/en/node/1405".

When the time to verify the fix for the issue came, the (other) dev in charge found that the link pointed to a completely unrelated thread. We've searched, but couldn't find the right one and, at this point, we don't even know whether the original thread still exists.

The question is, whether it's possible that the node numbers of discussion threads have changed, somehow. I doubt it, but I don't know enough about the Advanced Forum module to be certain. What happens when a forum thread gets deleted, for instance. Does the node number become free for reuse, or will it be forever blocked?

It is just possible, that the link was incorrect from the beginning, but there's no way to make sure of that now.


texts:
I have a views with three displays which sorts comments of a node in newest, oldest and most popular order. These views are shown below the content and works with contextual filters. I have used ajax_comment and rate and vote api module in order to add/reply comments by ajax and let users vote other people's comments too. Now I want to load one of these views at a time so I have created an HTML like this:

<select name="sort" onChange="return sort1()">
    <option value="newest">newest comments</option>
    <option value="oldest">oldest commenst</option>
    <option value="popular">most popular comments</option>
</select>

and a jquery code like this:

But it does not work.

I have tested quicktabs module too but comment reply link does not work with ajax_comment then. I have seen JQuery AJAX Load module too but it needs a url to load.

If my code is incorrect please correct it or if you have a better solution please let me know it.


texts: In Drupal 6, how to display two grouping fields such as Country then Province?

texts:
In Drupal 6, I have a view for certain objects with Location:Country and Location:Province fields, both set to Exclude From Display; sort criteria to sort first by country then by province; and Style setting Grouping Field to be Location:Province. That displays all the objects in the order I want, everything with the same country grouped together, then within each country objects are grouped by Province/State, each state's group of objects labelled with the name of the state.

However, I would like to have a group title displayed for Country, not just Province, so it would look like

Canada
  Ontario
    object 1
    object 2
  Quebec
    object 3
United States
  Arizona
    object 4
  California
    object 5
    object 6

I'm a newbie to Drupal. Is there a standard way to do this? I've tried search terms such as nested grouping and multiple groups but haven't found mention of this use case.


texts: How to set up Drupal Commerce to sell users the ability to create/post custom nodes (ex. classified ads)?

texts:
I am currently working on a classifieds D7 site, and I would like to sell users the ability to create/post a classified ad. With D6 + Ubercart this can be done using the UC Node Checkout module (http://drupal.org/project/uc_node_checkout), and following the instructions provided on the Drupal Easy website (http://drupaleasy.com/blogs/ultimike/2009/03/event-registration-ubercart).

Is there any way implement the same functionality with D7 + Drupal Commerce?

Thank you so much


texts: How to get block layout programmatically?

texts:
Sorry there won't much details but the title is self explanatory.

I need to fetch the block layout of the front page and build a menu from it.

So the question is: How can I get that list programmatically?


texts:
I want a five-star content rating system, for example:
if a premium user creates a content this will be rated with five starts, if a simple user creates a content this will be rated with three starts etc. I dont wont users to rate the conten.
Is something like this possible ???


texts: How to configure access to courses for teachers and students?

texts:
In my site I have teachers and students. The student can subscribe to max 3 courses.

I created cTypes:

Modules (which contains the actual information itself) and
Course (which contains a reference to the module)

I create rules:

The moment the student is subscribing to a module I create a instance
of Course. I set a field course.status to active. (list integer)
When the student is ending the course the field course.status is going to deactive.

Questions:

Which access module helps me to organize the student to denied access to the module while course.status is deactive?
Which access module helps me to organize teachers to see information only from students who followed or is following his course?

Everything should be organized by itself or  by rules.

I looked into a custom ruleset with the help of vbo's. I looked into Organic groups and I looked into workbench access and I do not know what to choose. How to keep it simple and effective...


texts:
I have a complex page with a few blocks including a Views block that I need to contextually filter on. How can I create a form in Drupal that passes arguments (selections from the form, i.e. text, checkboxes) to the URL of the page. For example:

PATH: http://example.com/test_page

FORM:

    $form['pages'] = array(
    '#type' => 'fieldset',
    '#title' => t('Data'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );

    $form['pages']['title'] = array(
    '#type'          => 'textarea',
    '#title'         => t('Title'),
    '#rows'             => 5,
    '#resizable'    => FALSE,
  );
  $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'));

I type in test "Test" in the 'Title' textbox and click 'Submit'. The current page url is changed to:

http://example.com/test_page/Test

Any ideas? Thanks!


texts: How to change logged-in user permission in hook_node_view?

texts:
Can anyone please let me know how can we achieve the following scenario

I want to change the role of the logged-in user before viewing the node. When you click on the node for viewing it, I want the roles to be changed and then display the content accordingly with the access permissions.


texts:
Is there a way to specify an argument to pass to a custom access callback, specifically an argument that isn't part of the path? Like in Drupal 7 you could do this:

function mymodule_menu() {
  $items['abc/$val'] = array(
    'page callback' => 'mymodule_abc_view',
    'access callback' => 'mymodule_abcdef_access',
    'access arguments' => array(1, 'test1'),
  );
  $items['def/$val'] = array(
    'page callback' => 'mymodule_def_view',
    'access callback' => 'mymodule_abcdef_access',
    'access arguments' => array(1, 'test2'),
  );
  return $items;
}

function mymodule_abc_access($val, $type) {
  return ($val['some_prop'] == $type);
}

So in Drupal 8 I would have this in mymodule.routing.yml:

mymodule.abc:
  path: 'abc/{val}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::abc'
  requirements:
    _custom_access: '\Drupal\mymodule\Controller\MyModuleController::abcDefAccess'

mymodule.def:
  path: 'def/{val}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::def'
  requirements:
    _custom_access: '\Drupal\mymodule\Controller\MyModuleController::abcDefAccess'

And in MyModuleController:

public function abcDefAccess($val, $type) {
  return AccessResult::allowedIf($val->someProp == $type);
}

But is there any way to pass 'test1' or 'test2' as $type? Otherwise I guess I would just have to make a separate access function for each type.


texts: how to submit a text field input from a user in a views filter form to a javascript ?

texts:
I am trying to fetch the user entered text value precisely a zip code which will be taken as input in the views exposed filter form and this value should be sent to the Java script function and I have this java script function which calculates the required LAT LON based on the zipcode and gives back the result.
The problem is I can use the drupal_add_js function to add the js file and also pass the value of zip code (I think so I am not sure though) I am wondering if I can send the zipcode value entered by the user only on form submit to the js file i.e can I send the value of zipcode to the js file only when the user submits the views exposed filter form by pressing the apply button?

I know that we can add a js file and send the values using drupal_add_js function but just not sure if this can be synced with the form submission button ?
 how can this be done?  please help me in this, any pointers in this regard are appreciated.


texts: How to change the name of uploaded file in my custom Entity?

texts:
I have a custom Content Entity created with

public static function baseFieldDefinitions(EntityTypeInterface $entity_type)

In the definition, there is a 'file' field:

$fields['file1'] = BaseFieldDefinition::create('file')
->setLabel(t('Fichier source'))
->setDescription(t('Source document (can be edited)'))
->setSettings([
'target_type' => 'file',
'file_extensions' => 'doc docx odt pages',
'file_directory' => 'contrats',
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => 7,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 7,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setReadOnly(TRUE);

And it works fine!
My question is: how can I change the name of an uploaded file?
I guess I should use hook_entity_presave.
But how to retrieve file information in hook_entity_presave?
Using the comments already given (thanks), I added this:

function tempo_entity_presave(EntityInterface $entity)
{
if ($entity->getEntityType()->id() == "amap_contrats") {
$sName  = 'Contrat-'.$entity->typecontrat->target_id.'-'.str_replace("-", "", $entity->datedebutcontrat->value);
$fid1[0]['target_id'];
$fid1 = $entity->get('file1')->target_id;
$file = file_load($fid1);
$sName1 = $sName.'.'.pathinfo($file->filename->value, PATHINFO_EXTENSION);
$result = file_move($file1, $sName1, FILE_EXISTS_REPLACE);
$sName2 = $sName . '.pdf';
$result =file_move($file2, $sName2, FILE_EXISTS_REPLACE);
}
}

And now, I get this error:

Argument 1 passed to file_move() must implement interface Drupal\file\FileInterface, null given, called in /Applications/MAMP/htdocs/JdP8M3/modules/custom/tempo/tempo.module on line 48 in /Applications/MAMP/htdocs/JdP8M3/core/modules/file/file.module on line 216 #0 /Applications/MAMP/htdocs/JdP8M3/modules/custom/tempo/tempo.module(48): file_move(NULL, 'Contrat-5-20170...', 1)

Any idea?

OK, I got it! My mistake:
I load '$file' and I try to file_move '$file1' :-(


texts: How to create a field which contains the entity created date

texts:
I need to create a field which contains the date an entity/node was created. I know some people achieve this by using a bit of code in their template, but I need this to be a real, accessible field I can use on the entity/node display, as well as in Views (sort, filter, etc). Additionally I would like a field for the last modified date.

How would I do this properly in Drupal?

We did create a bit of SQL that we ran in PHPMyAdmin (it was a one time script, we need to schedule it to be run daily), but I have a feeling I could be doing something in Drupal. Am I wrong?


texts:
I created a custom module with its own template file to display the content with the following code.

function mymodule_theme($existing, $type, $theme, $path) {
  return [
    'theme_mymodule_list' => [
      'template' => 'templates/list_mymodule',
      // name of the template file, minus the '.tpl.php'

      // these are the template variables that will available to your template
      'variables' => [
        'myvar1' => NULL,
      ],
    ],

  ];
}

With the code above I'm able to get the template from the module directory (sites/all/modules/mymodule/templates/list_mymodule.tpl.php), but now I decided to make a theme for the site, and I want to override the custom module template file with the usual approach of copying-pasting the file into the theme and clear the cache.

How do I override the template used from a custom module from a theme?


texts:
I've been learning Drupal myself for over a year now. I've mainly used templates all the time and changed the css. This time I made my own template and put php in it for the first time. Everything worked but I was wondering how I can expand my content box if a sidebar isnt used? Oh, I'm using Bootstrap's css

Snippet of php:

    <?php if ($page['sidebar_first']): ?>

    <?php print render($page['sidebar_first']); ?>

<?php endif; ?>

          <?php print render($page['content']) ?>

    <?php if ($page['sidebar_second']): ?>

        <?php print render($page['sidebar_second']); ?>

    <?php endif; ?>

They all have span4 but what I want is when sidebar 1 isn't used, then content id changes to span8


texts: How to create a module wide variable that refreshes every page load?

texts:
What is the best way to create a variable that is accessed by the different views of my module (block, page etc), but that is destroyed at every new page request?

I've been using variable_set to store information that is used throughout my module, but this seems to persist across page requests.  Is there a hook I can implement to call variable_del for every outgoing page, or is there a better way of storing variables in my module that do not persist across page loads?


texts: Can't get module configuration form into modal

texts:
I'm writing my first Drupal 7 module. I've successfully created the block's html and integrated that with the home page. I've also succeeded in creating a configuration form fo the block.

However, you can only access the configuration form by going to mysite.com/admin/config/content/mymodule and I would much rather have the user be able to access it in the modal that appears when they click the upper-right gear and click "Configure block."

Is there a good way to add my module configuration form to the block configuration?


texts:
I need add a footer to a view based on certain conditions. I followed this article and as per my understanding this should work. But this is not giving me any result.

Here is my code:

function utility_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  $item = array(
    'id' => 'area_text_custom',
    'table' => 'views',
    'field' => 'area_text_custom',
    'relationship' => 'none',
    'group_type' => 'none',
    'admin_label' => '',
    'empty' => NULL,
    'tokenize' => NULL,
    'content' => array(
      'value' => "Footer content is great.",
      'format' => "basic_html",
    ),
    'plugin_id' => 'text',
  );
  $view->setHandler($display_id, 'footer', 'area_text_custom', $item);
}

Update: Using the above hook the footer is getting called but renders as Array


texts:
The Problem
Using the i18n module, node translations are working, however Menu and Block translations are not showing up.
For example: I created 2 identical blocks. For one i set the Show this block for these languages to English and the other to Bulgarian. When i then go mysite.com it shows me the English block, but when i go to mysite.com/bg it still shows me the English block.
I have also tried the Make this block translatable but that doesn't work either.
The setup
Drupal version: 7.14
Related modules: i18n (all enabled apart from Multilingual Forum), pathauto, localization update, administration language, locale
Background
This is my first Drupal 7 website. The website im working on is a multilingual, multi-country website which is near completion. Hopefully that gives some idea of my exerpience, so if you could tailor your answers to that please.
Thanks in advance.


texts:
I am using the Flippy Module to build an article pager on a client website.

Everything is working well, but I have encountered an issue where several thousand articles have been imported, many of which without an attached image. This of course disrupts Flippy as it sources its thumbnail from the article content type's image field.

Unfortunately Flippy doesn't appear to have any kind of no results behaviour built-in out of the box.

Anyone else encountered this issue too, or may be able to point me in the direction of a patch that may add this functionality to the module?

I would like to set a default image as a fall-back if no image is found.

TIA.


texts: How do I sort the field value by null in Search API Solr?

texts: I want to alter the search API Solr query in Drupal 8 to order by field null in hook_search_api_solr_query_alter(). How do I add my sort expression in the Solr search query? Do I need to add it in hook_views_query_alter()?


texts: Output JSON views_field_view with Services?

texts:
I am using Services Views to render JSON for a view that has a views_field_view. The JSON output from Services for the views_field_view field is currently a rendered HTML view. How can I make views_field_view render a JSON version of the output to be included with the parent view's JSON output?

UPDATE:

The content in the sub-view has a Geofield, which is causing problems in a Services display.
The view is set as an unformatted list. A Page display looks like this:

node_title: Marquette
Geofield: 44.977297200000, -93.270110200000

Then if I create a Services display with the same view (same fields), the output looks like this:

  stdClass::__set_state(array(
     'node_title' => 'Marquette',
     'nid' => '1335',
  ))

In a Services display, anything I try to do with a Geofield just outputs the nid.


texts:
What is the best / easiest way to theme the user profile page? I'm building a talk radio website and registered members will provide news articles publically avail. eventually there will be thousands of registered users.

I'm worried that I will figure out an answer that works but isn't correct and will force me to go back and rewrite later on.

I don't know if I should use views or just straight code the page-user.tpl - if I straight code,  what function gets the uid from the /user/xx url? if I use views how do I assign the view to the pages in /user/xx

For some reason I cannot find any complete info on this; either it's a great secret or I'm missing something really simple. thank you!


texts: How to define another teaser for the second theme?

texts:
I have two themes: regular (1st) & mobile (2nd). Mobile theme binded with subdomain m.mysite.com.

I can't show my mobile node teaser in mobile theme.

I've created that teaser for mobile theme in Display Suite. Next I need to show this one in mobile theme taxonomy tag page. But I can't define theme in DS. When I use [taxonomy-term.tpl] in mobile theme to define mobile teaser, but vars doesn't works: changing $view_mode has no result (type machine name on mobile teaser), $content array is empty. I tryed to use Views, but in displays there is no options to define a theme.

What can I do? Thnx


texts:
I want to achieve this result in my Drupal front page:

[Headers]
[Welcome Block]
[View of contents]

So I created a Welcome Page (as a Basic Page), and put it as a Front Page from site configuration.
Then I add the view by the context module.

The problem is that the welcome page appears after the view, at the bottom of the page:

[Headers]
[SECTION Content]
  [View of contents] (view, added with context)
  [Welcome]          (Basic Page with path /welcome)
[/SECTION Content]

A possible solution is to make a Block instead of a page, but I would have no more welcome/ path where to link the front. I want also to use a page so that editors can edit, update and translate that when needed. With blocks I should add higher permissions. My purpose is just to show the welcome basic page before the view of contents.


texts:
I've read numerous answers to similar questions here but I can't for the life of me work out how to do this seemingly simple thing. I simply want to include a Twig template (theme_name/templates/system/footer.twig.html) from another Twig template in my custom theme (theme_name/templates/system/page.twig.html).

In my page.html.twig I've tried all of the following (obviously with theme_name as the actual theme name):

{% include 'themes/custom/theme_name/templates/system/footer.html.twig' %}
{% include 'footer.html.twig' %}
{% include 'system/footer.html.twig' %}
{% include directory ~ '/system/footer.html.twig' %}
{% include '/' ~ directory ~ '/system/footer.html.twig' %}
{% include "@theme_name/system/footer.html.twig" %}
{% include "/var/www/html/web/themes/custom/theme_name/system/footer.html.twig" %}

Each of these produces the following error, with the template varying on the method I've tried:

  Twig_Error_Loader: Template
  "themes/custom/theme_name/templates/footer.html.twig" is not defined
  (Drupal\Core\Template\Loader\ThemeRegistryLoader: Unable to find
  template "themes/custom/theme_name/templates/footer.html.twig" in the
  Drupal theme registry.) in
  "themes/custom/theme_name/templates/homepage/page--front.html.twig" at
  line 177. in Twig_Loader_Chain->getCacheKey() (line 115 of
  /var/www/html/vendor/twig/twig/lib/Twig/Loader/Chain.php).

I've even tried using hook_theme in my theme_name.theme file to no avail.

<?php

function my_theme_theme() {
  return [
    'footer' => [
      'variables' => [],
    ],
  ];
}


texts: How to fetch image from database in drupal

texts:
Let me know how to fetch image from database. actually i am trying to fetch image from database using this question.
I am try to fetch image from database using following code.
$fid is my $row['column_name']

 $fid=$r['field_upload_photo_fid'];
 $image = theme('image_style', array(
'style_name'=> 'small',
'path' => $file->uri,
'alt' => 'user picture'
 ));
 print $image;

Actual file url is http://example.com/sites/default/files/styles/Style_name/public/Chrysanthemum.jpg

but now it shows http://example.com/sites/default/files/styles/small/public/styles/Style_name/public/Chrysanthemum.jpg.
 thats why image not fetching from database.

Also what is a style in $variable.


texts:
I moved my website from my computer to another one, I moved drupal folder and the database with backup & migrate, I used to do it every day and now on the first call, The website worked, but after login with admin, I can't acces the website.
I tried changing $cookie_domain, but it was already commented, also rewrite_module is enabled on apache, I'm workin on localhost. help me guys, thank you


texts: How to form_later the user profile form to only allow 1 role to be assigned/removed

texts:
I want to restict my site editors ( a role ) to only be able to select/deselect the role 'subscriber' and not be able to meddle with the other role assignments.  I have tried the following to remove the other roles :

case 'user_profile_form':
  global $user;
  if(in_array('site editor', $user->roles)  && !in_array('administrator', $user->roles)) {
    unset($form['account']['roles']['#options']['3']);  // administrator
    unset($form['account']['roles']['#options']['4']);  // site editor
  }

However this has the effect of both hiding the checkboxes and un-assigning the roles.  I want any existing assignments to these roles to persist.

Your help appreciated.


texts: Javascript not loading in all links of the site

texts:
I've been struggling with this javascript error on my page for days.

Everytime I access the site as anonymous, I can click and access links but I'm getting a white screen and I believe this is because the site does not recognise or call its javascript. My main.js should load the animation on path: css/animsition.min.css.

This is the line where I'm getting the error.

$(".animsition").animsition({

When I am logged in as user, this error never shows up and site is fine.
Attached image is the chrome console result.


texts: PDOException: SQLSTATE[42S02] - Base table not found

texts:
So I am in a bind and have no idea where to go. I get the following message now after I tried to add a new field to a content type:

Error message
PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'wrrc-data.cache_field' doesn't exist: DELETE FROM {cache_field} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\\') ; Array ( [:db_condition_placeholder_0] => field\_info\_types:% ) in cache_clear_all() (line 167 of C:\data\htdocs\wrrc-data\includes\cache.inc).

I have looked everywhere and cannot seem to find the right answer for me, and am hoping someone who has dealt with this hellish nightmare might be able to help.

I have tried dropping the "non-existent" (even though I see it in the file directory) 'cache_field' table, it "supposedly" works and so I go on to create a new table (to replace the failed one). All the sites I went to for this problem suggested the following code:

CREATE TABLE IF NOT EXISTS `cache_field` (

cid varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
data longblob COMMENT 'A collection of data to cache.',
expire int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
created int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
serialized smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
PRIMARY KEY (cid),
KEY expire (expire)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic cache table for caching things not separated out...';

But after starting this sql command, I get the following error:

#1005 - Can't create table 'wrrc-data.cache_field' (errno: -1) (Details…)

Doesn't give me any more information (even the supposed "Details" page doesn't give me squat, all it talks about is the background for InnoDB, nothing to add to the error at hand.

Does anyone have any suggestions? I really don't want to recreate the site at all, as that is what some had suggested on other sites, but this is beginning to wear me down. If I do need to just create another site, is there a way to streamline the process of bringing over my data and formatting without having the error hitch a ride?

Thanks in advance, I really appreciate it. Matt


texts:
Page not found on user/login and user/register, but when i type /user it works. Whats wrong with my user/register page? I did no changes on the site http://ruh.kz/user/register try it

Update. Found error. I'm using TabTamer module and when you disable tabs on /user then it redirects all registrations and logins to 404 page not found.


texts: Hide fields on the user profile page with preprocess function

texts:
On the user profile edit page I can do something like this in my theme's template.php file to hide a field:

function MYTHEME_form_user_profile_form_alter(&$form,$form_state,$form_id){
//remove unwanted fields from the form (default value is still saved)
  $form['timezone']['#access'] = FALSE;
}

On the profile view page, I am trying to do a similar thing. I want to hide:

History
Member for 3 months 4 weeks

So I looked up the api function and it's hook_user_view

Based on this I try:

function MYTHEME_user_view($items) {
$items['member_for']['#access'] = FALSE;
}

... however, this does not work after I clear the cache. I'd also like to avoid hiding this using CSS display:none.


texts: How can I generate a usable dynamic PDF from a Drupal view?

texts:
My goal is to generate a PDF view of a content node. I've set up the Views PDF module with the TCPDF class, but performance is awful. Not just slow. I mean AWFUL. It's an aggravating experience when viewing a simple page of content as a PDF, and downright painful when viewing content that should be several hundred PDF pages long. Totally unacceptable.

Does anyone have a good solution for combatting this? All I'm looking to do is take a single node and offer a "view as PDF" link/functionality. It seems like this should be pretty straightforward, but I haven't been able to solve that yet.

Any help would be appreciated. Thanks!


texts: Display rendered node in view mode X in self node in View mode Y

texts: How can I render a node in itself in a different view mode?


texts: How to programatically get the product id of newly added product using the commerce form

texts:
I allow users to create their own products using the default commerce product add form (/admin/commerce/products/add/product). Programatically, I need to get the product ID and do more processing.

I have a submit handler attached like this (I use it to redirect users to a custom page):

$form['actions']['submit']['#submit'][] = 'my_module_redirect_handler';

However, I don't seem to have any information about the newly added node. How can I obtain it?


texts:
function heihachi_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'ipaper_node_form') {
           unset($form['body']);
        }
}

the code above removed body field in node/add/ipaper. But how can i remove body inside a node? (mysite.com/node/4420 for example).

And 2nd question is: i did print_r($form) inside mymodule.module and now im watching in the page source code and see this:

Array
{

    [#node] => stdClass Object
        (
            [uid] => 1
            [name] => heihachi

i am on the right way if i use this construction to print the name for example:
$form['#node'] => ['name'] ?? Guess not.. :) That stdClass Object is confusing me :(


texts:
Im new to the forum  Hope you are all well?

I have a really simple thing I want to do with drupal but for the life of me I cant seem to get it right (I'm a beginner with drupal)

So I have an about page, and I add the body to the page. But what I want is to add images of members of the company the site is for above the body of text in the about page, like in a grid. So it would be the grid (say 3x3 image grid) then the body text at the bottom of the grid. How do I do this? I cant seem to find an answer anywhere and I'm pulling my hair out here.

Can anyone help me?


texts: CSS\JS Aggregation "Shuts down" Firebug indication

texts:
I have CSS\JS Aggregation on, and I've installed the AdvAgg module and set it for Development mode. The site works fine, but now I can't really use Firebug...

Firebug no longer shows me, for example "Style.css, line 50", but rather something like "fdn_jkfdk_aaahjfdh.CSS, line 500". I guess it's the aggregated file...

Anyways, Is there any way to get "Style.css, line#" appearing again without disabling aggregation? I can't sacrifice the option to make CSS edits in the site just for aggregation... I guess no one can!


texts: Get current language of Drupal 8 in javascript?

texts:
How can I get the language code or name from the Drupal javascript object in a js script ??

I know I can get language using this in php:

  $language = \Drupal::languageManager()->getCurrentLanguage()->getId();

But I need to have the language in my scripts.

All i got so far is the Drupal Jquery variable

  Var d = Drupal;

Which when printed looks like this.

{behaviors: {…}, locale: {…}, throwError: ƒ, attachBehaviors: ƒ, detachBehaviors: ƒ, …}
Ajax:ƒ (base, element, element_settings)
AjaxCommands:ƒ ()
AjaxError:ƒ (xmlhttp, uri, customMessage)
ProgressBar:ƒ (id, updateCallback, method, errorCallback)
Views:{parseQueryString: ƒ, parseViewArgs: ƒ, pathPortion: ƒ, getPath: ƒ}
ajax:ƒ (settings)
attachBehaviors:ƒ (context, settings)
behaviors:{autologout: {…}, drupalDisplace: {…}, responsiveImageAJAX: {…}, AJAX: {…}, activeLinks: {…}, …}
checkPlain:ƒ (str)
debounce:ƒ (func, wait, immediate)
detachBehaviors:ƒ (context, settings, trigger)
dialog:ƒ (element, options)
displace:ƒ displace(broadcast)
encodePath:ƒ (item)
formatPlural:ƒ (count, singular, plural, args, options)
formatString:ƒ (str, args)
history:{fetchTimestamps: ƒ, getLastRead: ƒ, markAsRead: ƒ, needsServerCheck: ƒ}
locale:{}
stringReplace:ƒ (str, args, keys)
t:ƒ (str, args, options)
theme:ƒ (func)
throwError:ƒ (error)
url:ƒ (path)
views:{instances: {…}, ajaxView: ƒ}
__proto__:Object


texts: Block with articles from the same author

texts:
My websites publishes articles by third party authors. Articles are inserted by an admin. Every article has its author.
The authors' info are in a content type called Bio, which has these fields: title (full name of the author), picture, body, links to social networks. The path to each author's bio is /author/.
In each author page, I want to show all the articles this author has already published on my website. So I made a view that should display a block in each of those pages.

The problem with the view is that it works in preview, when I manually enter the name of the author, but it isn't working when in the page as a block. It doesn't retrieve the  from the url, I guess.

Here's some screenshots of my view:


texts: validating the Uploaded Image name in Image field of Content type

texts:
I need to validate the Image Name uploaded via Image field in Content type.How can i validate the Image name.

Any Help is Appreciated

Thanks,


texts: determine value differences between form submissions

texts:
I have an entity form that user can submit multiple times. What i would like to do is during validation get current values in the database and compare with the once that user just entered. I'm using

$form['#validate'][] = 'my_function';.

So really the questions is how do I get 'current values' that are already stored in the database to one array and 'about to be submitted values' (just updated by user) to the other array. The reason why I want those to be saved, temporary only, in the array is to do comparison.


texts: How to remove h1 tag from Drupal Garland theme in the header

texts:
I was shocked to see Bing Webmaster Tools notification that my site: http://www.articlesdirectoryindia.com using Garland theme has two H1 tags and that only one should be there for SEO reasons.

Actually the site name : "Free Articles Directory India" is wrapped within h1 on all pages in the header which I want remove.

I want to know if there is any standard & tested workaround for removing this h1 and replacing this with some div etc?

I tried to change h1 to div for 10 minutes but I could not do it. Even if I'm able to it'd be difficult to test of all browser versions.


texts:
I am using Rest web service . I CREATED a view called ART and specified its path (/viewpath) and I set the  http baisc authentication within that view's structure such that the results will be accessible only for a user whose role is RESTADMIN . Everything works fine when I curl using the path of that view and the username and password of the user (of role restadmin) :
curl http://username:password@example.com/viewpath

However , when I try to get a simple article using its nid :
curl http://example.com/node/2?_format=hal_json

I get no results and "The used authentication method is not allowed on this route" . Even when I put the username and password as before I still get this error. I do realize that the authentication I have set is just for the view ART. But I can't find the solution to let the other link work any idea why?


texts: Cache-Control response header includes "private"

texts:
Why does a vanilla Drupal 8 site add cache-control: must-revalidate, no-cache, private to all the pages?

A Drupal 7 site adds cache-control: must-revalidate, no-cache.

Is that addition of private for Drupal 8 somehow configurable? I'd like to not have it there.

It turns out that this response header in Drupal 8 is sent when system.performance:cache.page.max_age is set to 0. Setting it to anything greater than 0 (e.g 123) gives me max-age=123, public. The question still remains: Is there a way to get must-revalidate, no-cache?

The reason I want must-revalidate, no-cache without private is that I want browsers to always make requests for pages, and my cache server (fastly) to cache the content. Having private in the response headers bypasses fastly as per their documentation: https://docs.fastly.com/en/guides/cache-control-tutorial#do-not-cache


texts:
Let's say I create a function in a module file:

function _get_test() {
  return 'test';
}

How can I call this in any Twig file? For example *.html.twig, page.html.twig, node.html.twig etc.

OR

How can I pass a variable from PHP to Twig and display in any Twig file.
For example *.html.twig, page.html.twig, node.html.twig etc.


texts: How do I generate a custom content entity bundle?

texts:
I created a custom content entity with Drupal console version 1.9.2. Everything is working fine.

To use all the configuration and settings of my custom entity type in different bundles, I want additional modules that create bundles of my custom content entity.

I tried to execute drupal geb which creates configuration files within my custom module for a new node type (bundle of the node entity), but there is no option to create a bundle of my custom entity type.

Do you know how to generate boiler plate code for custom content entity bundles?


texts:
I have Drupal 8 site I need to migrate a bunch of data into from a different CMS.  What I'd like to do is write a basic SQL query and iterate through the results, creating a new node for each returned row.

Since it's a one time thing - do I need to write a full module for this - or can I just hook into drupal some other way (like through the main index.php file) and do the node::create([]) $node->save() stuff from within there?

Never done something like this before - and looking for the easiest way.  Any help/guidance is appreciated!


texts:
I'm trying to export my Webform settings to an Excel file by using the PHPExcel module, but it looks like it's documentation isn't modified for Drupal 7...

When trying to define the two-dimensional array $data[row][column] (as mentioned in the API), I keep stumbling upon an errors...

I try to add "John Doe" in Cell A1, "john@example.com" in Cell B1, etc.

$data = array(
    1 => array(
        'A' => 'John Doe',
        'B' => 'john@example.com'
    ),
    1 => array(
        'A' => 'Jane Doe',
        'B' => 'jane@example.com'
    ),
  );

But nothing ends up in the Excel file. Sometimes the first letter, but nothing more...
What does this module require as $data?


texts:
Currently I am working on a multilingual website and have already a multilingual set-up.
Now I have translated menu items and it is working great, however I also want the menu title to be translated.

This is how I get the menu titles:

$menuInfo = menu_load('menu-second-menu');

and I get the title through by $menuInfo['title'];

I print the links with the following code (and the title is displayed above):

print theme('links__system_main_menu', array('links' => $menu, 'attributes' => array('id' => $menuInfo['menu_name'], 'class' => array('links', 'clearfix')), 'heading' => array('text' => $menuInfo['title'], 'level' => 'h3')));

So the links are translated, but the $menuInfo['title'] not and $menuInfo does not contain any translated information.

Any help?

Edit: The issue is I do not know how to get the translated menu title (programmatically) I made in Structure -> Menus -> Second Menu -> click the tab Translate and gave a different Menu title for the different languages. I am using the Menu Translation (sub)module of the i18n Internationalization module.


texts: do some work when user login or register in drupal6

texts:
I want to set some fields in database when user registers or login. I know I don't have to change the drupal core and I guess I should use hooks for this purpose but I don't know how and where.

Should I write a new module and implement a hook inside it? What hook?


texts: How to:Pass arguments to views and use that as contextual filter-in code

texts:
I have a views created in code. I am passing arguments(for contextual filters) to this view from another view like this:

sitename/apage?ids=1,2

Q1. Is this the correct method? If not what is?

Q2. How do i retrieve 1 and 2 (above) in the view where i want to use them as filters(contextual) for products/nodes with these ids.

Please help!


texts:
I learn how to upload images by using IMCE Wysiwyg bridge module.

How about upload images and treat it as background picture?


texts: I am just looking for altering select query, created by any view just before its execute. For e.g. I want to add some manual filter which I can't add from Views' UI.


texts:
In Drupal 8 I have a custom content type, and I want to add a group of fields to it that are related to tracking. Since these fields don't have to do with the content displayed, I wanted to separate these options in the UI by having them on a different tab or panel.

This is an example of what I have in mind.

What is the best way to accomplish this? Is there some hook to achieve this?

I have done a lot of searching, but I can't find anything relevant.


texts: Module has conditional Checkboxes, need to remove value

texts:
I am building a module that will have a bunch of checkboxes to enable the addition of metatags like HandheldFriendly, MobileOptimized, etc.

I want to have the first checkbox only displayed. Upon checking that item, other options should appear. (if itemA == checked, then show itemB) I actually have that working. The problem is that if you check itemA and then check itemB and save, but then uncheck itemA, when you return to the configuration page itemB will still have a value.

Here is a simple timeline showing the issue

Snapshot #1:
itemA: unchecked
itemB: unchecked (invisible)

Snapshot #2:
itemA: checked
itemB: unchecked (visible)

Snapshot #3:
itemA: checked
itemB: checked (visible)

Snapshot #4:
itemA: unchecked
itemB: checked (invisible) // PROBLEM

Between each snapshot, the form was saved. How can I automatically hide AND uncheck the value for itemB when clicking itemA so that when I re-enable itemA, itemB is still unchecked?

If I need to  provide further clarification, I can.

module code for poetic_toolkit.admin.inc file


texts:
I set up a subtheme of Bartik in Drupal 7. I also set up the private file system. I was styling everything and when I went to upload a logo, the logo broke. Now the logo url is private://logo_0.png. I cannot remove the logo, disable it via the checkbox, or set it back to default.

I tried some of suggestions from around the net such as using [theme]_preprocess_node. I also tried using a default bartik "template.php" file. (I renamed all the prefixes in it to match my theme name.)

Nothing seems to work and this is the weirdest bug I've EVER encountered in Drupal. Anyone have some suggestions or a push in the right direction to try and fix this?


texts: In a view of products, add the word "Added" to all products already added to the cart

texts:
I have a view that lists all my products, I want to display the word "Added" below every product that has already been added to the shopping cart.

How can I accomplish this?


texts: How to Translate Content type name using i18n module?

texts:
I am developing a multilingual site that supports English and Norsk bokmal. I have set English as my default language. I wanted to translate the contents and the other things in the site.

My real problem started when I found that I was unable to see the translation of the content type's name. I went to admin/config/regional/translate/translate and translated everything, but still my content type's name is not translated.

I have attached a screenshot of the translation page. Still I don't find a way to translate the content type's name.


texts: How to edit e-mail settings for project issue content type

texts:
I am using the project and the project issue module on a Drupal 7 instance and ran into some trouble with the notification settings.

Apparently, the poject issue module saves for every content type a variable which contains information which e-mail sender address should be used for e-mail notifications on new issues etc.
The variable is named project_issue_reply_to_NAME_OF_CONTENT_TYPE.
How can I change this value for an existing content type?

As the variable is of type blob I can't change the value easily in the database.


texts: Changing Default Text of Fivestar Rating Widget

texts:
My fivestar rating says 'no votes yet' when no one has yet voted on the node. How is it possible to change this text to say something else, like 'vote this item'?

I thought this would be a simple problem to solve but wasn't able to find the answer to this anywhere and it's not immediately apparent how this is done when configuring the tool.


texts: Link to node for each of the items in a view

texts:
I have a D8.2.0 website with a view showing unformatted list of content of certain content type. For each item in the content two field values are shown.

I want one of the fields to be a link to the content item node. I used Rewrite Results > Output this field as a custom link and put the following value:

/node/{{ node.id }}

But no luck. I also tried nid. I cannot seem to find a documentation or a blog post that discusses different values that can be used in twig-enabled fields in D8 views.

If possible please add references to documentation or posts that explain what variable names are available in addition to what is the correct way to use the node id by twig.


texts: How to make node edit form meta panel accordions default to closed?

texts:
When editing a node the meta panel fieldset accordions default to being open if they contain data.
I understand why this has been done, but I think it makes for a very noisy and potentially confusing UI for my editors.
How could I go about making these closed by default?


texts: How to modify default login page using theme?

texts:
Version: Drupal 8.7.x

Currently, I am using a subtheme of the Bootstrap theme and I want to override the default login page because the interface doesn't look good. I was hoping to override the template file in Bootstrap theme responsible for login but there was no file with familiar name in the theme folder. Maybe Bootstrap inherited the login file as well? Then I created a file named page--user--login.html.twig and put that in my subtheme folder but there was no change in the login page. Maybe the file name is supposed to be different or it is something else entirely.


texts: How to output multiple files url entities on twig?

texts:
I have a file entity field that I can upload multiple files and I'm trying to render or display it inside my node twig template. The code below is what I'm trying to make it display. Tried clearing my cache but it still shows empty.

I can display the url/uri of a single file upload but I can't seem to figure out how I can display multiple upload files url/uri in the loop.

Single file here:

Download File

Multiple files Here:

{% for key,value in node.field_upload_file.value %}
  Download File
{% endfor %}

Is this a way to display multiple upload files url/uri in the loop? Please suggest to me.


texts:
I'm using Drupal 7 Privatemsg module.
To prefill the message body, I use the following hook but don't get anything displayed.

function MyModule_privatemsg_message_view_alter(&$vars) {
  module_load_include('pages.inc','privatemsg');

  $vars['message']['body'] = "Dear Friend,\n you rock!";
}

Any help ?