texts: different views for different taxonomy vocabularies at taxonomy/term/%

texts:
I have two different content types: cars and boats. each one has a taxonomy vocabulary of the same name associated with it. I have two views, one for each, that shows listings based on this content type.  I have to use the taxonomy/term/% to use the taxonomy term or id as an argument.

My problem is that this would work if both views had the same fields, but they don't they are quite different.

How can I get views to show results based on my taxonomy term as well as show different fields for each view? I would prefer not to use an existing module to handle this. Maybe I can configure the views differently or use a php snippet?


texts: change entityform value via function before save

texts:
I have an entityform with a field call "IP" (field_ip is its machine name). Now I need to set a value before that the entityform is saved. I have thinked to use hook_entity_presave() in this way:

function mymodule_entity_presave($entity, $type) {
      if ($type == 'entityform') {
        if ($entity->is_new === true || 1==1) {
          $entity->field_ip = array('LANGUAGE_NONE' => array(0 => array('value' => $_SERVER["REMOTE_ADDR"],'format' => '','safe_value' => $_SERVER["REMOTE_ADDR"])));
          $entity->original->field_ip = $entity->field_ip;   //Try this, too.
        };
      }
    }

(1==1 is only for test/debug).

Via "devel" module I can see that the new value of field_ip is correctly set, but when I see the new version of the entityform entry (after the save action) I see the default value of that field and not my new value.
And infact if I re-edit the same entyform (id) I see the old value and not the new one. Where is my error ?


texts: Can I prevent a field from being disabled on the Manage form display page?

texts:
I have a custom content entity field that is required. I allow the form display to be configurable:

->setDisplayConfigurable('form', TRUE);

That lets a user configure the Textfield widget for the field; however, it also lets a user make the field hidden/disabled. Since this field is required, that breaks the form.

When I looked through Core to figure out how other modules might handle this, I found that the same problem exists for Taxonomy. The "Name" field can be disabled, but it's required, so disabling it causes errors.

Is there any way to fix this issue or do I just need to rely on Site Builders to not remove a required field from the data entry form?


texts:
When I am trying to catch an error i Drupal 8 I am unable to catch the error, I get a message: The website encountered an unexpected error. Please try again later. and the error get logged in the error log report:

   try {
      $decoded = JWT::decode($tokenOutput->access_token, $array_publicKeysWithKIDasArrayKey, array('RS256'));
    }
    catch (Exception $e) {
      die($e->getMessage());
    }

I tried the same code in a stand alone php app and everything is working properly.

It not the error itself that is causing me trouble but the fact that I cannot catch it and that my Drupal script die to a message such as The website encountered an unexpected error. Please try again later.

The error is the following : Firebase\JWT\BeforeValidException: Cannot handle token prior to 2017-04-04T15:51:13-0400 in Firebase\JWT\JWT::decode() (line 115 of /vagrant/drupal/vendor/firebase/php-jwt/src/JWT.php).. I want to be able to catch the error and manage it in order not to have the script break.


texts: How can I automatically rotate a picture?

texts:
apparently Drupal 7's built in image handling doesn't automatically rotate images based. Is there an option to do that?
If not, how can I make it easy for a user to rotate an image left or right?


texts: Custom Field API with multiple values - form generates two fields by default

texts:
I have a custom field that contains couple of fields (select, textarea, text). I've implemented hook_field_widget_form like so:

I've added a field to content type and set 'Number of values' to unlimited. When I open a node add page form /node/add/my_content_type this field is displayed twice by default and has option "Add another item" at the bottom. It should be displayed just once. When there are two containers it adds to database both entries for delta 0 and delta 1. This behaviour force opening third container with my field next time I edit the node and so on. Why is this happening?

function mymodule_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  switch ($instance['widget']['type']) {
    case 'solas_block_select':
      $element += array(
        '#type' => 'container',
      );

      $element['title'] = array(
        '#type' => 'textfield',
        '#title' => t('Block title'),
        '#description' => t('Override block title or leave empty to keep it\'s default value or place <none> for not providing any'),
        '#required' => FALSE,
        '#default_value' => isset($items[$delta]['title']) ? $items[$delta]['title'] : '',
      );

      $element['description'] = array(
        '#type' => 'textarea',
        '#title' => t('Description'),
        '#required' => FALSE,
        '#default_value' => isset($items[$delta]['description']) ? $items[$delta]['description'] : '',
      );

      $element['block_delta'] = array(
        '#type' => 'select',
        '#title' => t('Block'),
        '#options' => solas_block_field_get_block_options(array('solas_blocks', 'solas_block_field')),
        '#default_value' => isset($items[$delta]['block_delta']) ? $items[$delta]['block_delta'] : '',
        '#empty_value' => '',
        '#required' => FALSE,
      );
    }
  break;
  }
}

This is how I end up:


texts: How do I programmatically translate a string?

texts:
I am working on one custom module to alter the fields labels of user login form for visitors. I created a module to alter the labels in the user login form. The French language is enabled on the setup.
I am trying to translate the field labels on the user login form to French. I am using the following approach in a module.
I have included the namespace with use Drupal\Core\StringTranslation.
After that, I have debugged the $form variable inside hook_form_alter().
From this debugged variable, I am trying to translate the filed label 'E-mail' to French.
function hook_form_alter ({here goes all the parameters of alter hooks}){
  $form['name']['#title'] = t('E-mail');
}

I am not able to see the translated Email field label on the user login form.
Am I missing anything? What should I do to translate the strings using hook_form_alter()?


texts: How to adjust weight of profile 2 fields

texts:
I added some fields to the default user registration form. I then installed the Profile 2 Module through which I added three (3) fields- "first name", "surname" and "place of work".

Is there a way to make the first name and surname fields appear above the default user registration fields while the place of work appears below it?

Thank you.


texts: How to customize a specific content type display?

texts:
I have a content type which has many fields. My problem is that all fields displays in rows like this picture:

How can I customize these fields? for example I want them to arrange like this one:

Also I want to change some font-size (in the red box in second pic). What should I do?
thx.


texts:
How to split content into different pages.

node/test

into

node/test
node/test/features
node/test/images

Fields are grouped with Field group

Thanks,
Marius


texts:
In my site I want user to add a new album of images
he have to add
 1. title
 2. description
 3. sub form that contain Image and title and set to default (radio button) and he can add   more than one sub form

and only one image will be the default site that will appear in home page (Selected from radio button)

How can I make things like that


texts: We are making a accounting software and would like to know how we can use a open source API  or query to validate user email id by sending email to the specific email id and getting a activation response from the same using a weblink.


texts: How to send a newsletter to all email addresses attached to a content type?

texts:
I have a content type (customers) having an email field (field_email). I need to create a newsletter using those emails that every certain period increase.

I try to use the module Newsletter but I must to re-enter all emails again and new email every time a new customer is registered.
Is there a way to import all emails from my content type, to list the newsletter module?


texts: Drupal 7 - How do I parse JSON data from a website and import them as Nodes and have them update hourly?

texts:
I have drupal 7 with the Feeds and FeedsJSONParser module installed, but I can't seem to figure out how to configure this to parse the feeds.

I want to parse the following feeds into their own nodes: https://poloniex.com/public?command=returnTicker

{
    "BTC_LTC": {
        "last": "0.0237",
        "lowestAsk": "0.02383797",
        "highestBid": "0.0237",
        "percentChange": "0.00642712",
        "baseVolume": "5.69603109",
        "quoteVolume": "240.78778654",
        "isFrozen": "0"
    },
    "BTC_NXT": {
        "last": "0.00007000",
        "lowestAsk": "0.00007350",
        "highestBid": "0.00007000",
        "percentChange": "-0.06542056",
        "baseVolume": "0.84850609",
        "quoteVolume": "12014",
        "isFrozen": "0"
    },
    "BTC_NMC": {
        "last": "0.00403",
        "lowestAsk": "0.00489",
        "highestBid": "0.00404001",
        "percentChange": "-0.04952830",
        "baseVolume": "0.27214383",
        "quoteVolume": "64.24716761",
        "isFrozen": "0"
    }
}

I have the following settings for the JSONparser, but doesnt seem to do anything. Would someone be kind enough to take a snapshot of there setup?


texts: Drupal 8: how can I "eager load" Entities referenced via EntityReferenceFieldItemList field

texts:
Note: this is my first Drupal project as I am usually working with Laravel.

I have some entities my-nodes that have a field EntityReferenceFieldItemList (a multi-select linking to other entities of another content type related-nodes).

I want to query the my-nodes entities together with the related entities in 1 query (in Laravel I would describe this as eager loading the relationship).

The my-nodes entities all reference different related-nodes entities and I need to access related-nodes related values.

I'd like to optimize the amount of calls to the database to possibly only 1.

Method referencedEntities does not look like what I need because it's lazy loading, not eager loading:

$node->get($field)->referencedEntities();

Any idea?
Thanks in advance!


texts: How to Port customField PHP from Drupal 6 Views 2 to Drupal 7 Views 3

texts:
I have this piece of code that was in a Drupal 6 Views 2 customField PHP that I need to port to Drupal 7 Views 3 in a Global: PHP field but I can't figure why I get an empty ajax error upon building this code in the Global: PHP field value code.

Did the accessibles variables changed?

<?php
//var_dump($data);
if ($data->node_type=="project") {
echo "node/".$data->nid;
}
else
{
echo $data->node_data_field_slider_include_field_slider_link_value;
}
?>

ANSWER

You need to remove the <?php ?> tags.


texts: Drupal statistics does not count visits when I see the node from a custom panel

texts:
I have a web site where each node has three diferents designs (i do it through panels and arguments) and i use the statistics module, that way i can see how many visits has the node.

But the statistics module jus count the visits when they visit the main design. I can explain with a example:

website .com/node/01 <---when a user visit this url, a visit is counted
website .com/node/01/mobile <----- here is not counted the visit
website .com/node/01/lightbox <----here is not counted the visit

This was built for panels and arguments... so, is there anyway to put a php code in two panels that visitors don't have to start to count?

Best,


texts: Extending Core classes with the @internal tag

texts:
I need to make weights of Taxonomies translatable and only show translations of terms when you change language.

To do this I need to override the OverviewTerms class from the Taxonomy module to change some of its methods. However, when I try to extend the OverviewTerms class PhpStorm puts a strikethrough on OverviewTerms because it is marked as @internal, although I can still extend and use the new extension.

What does the @internal tag mean and what is the right way to extend classes with this tag?


texts: Is there a way to create custom page in panels with path "/search"?

texts:
Is there a way to create custom page in panels with path "/search" ?
I need to replace default drupal 7 search page with my own views page. But I can't because this path is already exist (duplicate).
Also I can't disable "Search" module, because I use in views filter providet by search module "Search: Search Terms".
Any advise will be appreciated.


texts: how do I add javascript to a specific panel-page

texts:
I have created a panel page (i.e using panels). I can add html content to it from the panel itself using add content->New custom content. I can also add css classes (add body css classes).

Now I would like to add a jquery button to that panel page. I could add a javascript to my theme but then it would be called on every page load not only this specific panel-page. So I would like to add my javascript through my module.

But how do I programatically check that the current page beeing viewed is that specific page panel? Is there a hook that lets me check that?

Thanks,

baba


texts: How to avoid CKeditor to change the HTML code?

texts:
I want to add code like

 to make the whole block as a link, but after saving it getting changed to

. I am using CKeditor module, have done changes in config/text-format/filter HTML to disable the Limit allowed HTML tag. In short I want that editor do not do anything with HTML code.


texts:
I am trying to add a field (middle name) into the field_schema of the contrib addressfield module (I initially didn't want to hack it, but was unsucessful in adding a field in from my custom module.). The module has the following hook_field_schema()

function addressfield_field_schema() {
  $columns = array(
    'country' => array(
      'description' => 'Two letter ISO country code of this address.',
      'type' => 'varchar',
      'length' => 2,
      'not null' => FALSE,
      'default' => '',
    ),
    'administrative_area' => array(
      'description' => 'The administrative area of this address. (i.e. State/Province)',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'sub_administrative_area' => array(
      'description' => 'The sub administrative area of this address.',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'locality' => array(
      'description' => 'The locality of this address. (i.e. City)',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'dependent_locality' => array(
      'description' => 'The dependent locality of this address.',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'postal_code' => array(
      'description' => 'The postal code of this address.',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'thoroughfare' => array(
      'description' => 'The thoroughfare of this address. (i.e. Street address)',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'premise' => array(
      'description' => 'The premise of this address. (i.e. Apartment / Suite number)',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'sub_premise' => array(
      'description' => 'The sub_premise of this address.',
      'type' => 'varchar',
      'length' => 255,
      'default' => '',
      'not null' => FALSE,
    ),
    'organisation_name' => array(
      'description' => 'Contents of a primary OrganisationName element in the xNL XML.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
      'default' => '',
    ),
    'name_line' => array(
      'description' => 'Contents of a primary NameLine element in the xNL XML.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
      'default' => '',
    ),
    'first_name' => array(
      'description' => 'Contents of the FirstName element of a primary PersonName element in the xNL XML.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
      'default' => '',
    ),
    'last_name' => array(
      'description' => 'Contents of the LastName element of a primary PersonName element in the xNL XML.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
      'default' => '',
    ),
    'last_name' => array(
      'description' => 'Contents of the LastName element of a primary PersonName element in the xNL XML.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => FALSE,
      'default' => '',
    ),
    'data' => array(
      'description' => 'Additional data for this address.',
      'type' => 'text',
      'size' => 'big',
      'not null' => FALSE,
      'serialize' => TRUE,
    ),
  );

  return array(
    'columns' => $columns,
    // TODO Add indexes.
  );
}

I found this post online for doing a field_schema update https://drupal.org/node/150215, but I don't know what the field name or table name is, its not listed in the file.
How can I do this?
My ultimate goal is to make a standalone plugin file to be used by addressfield, but I needed to update the schema first.


texts:
I have a custom tpl.php for my custom content type. As part of its content it also needs to show a (dynamic) value. The dynamic content is actually scraped from another website of ours.

My concern is, whether to have scraper logic inside tpl.php. My understanding is that the intention of tpl.php is to handle the view part.

What are the disadvantages of having my tpl.php to contain the logic of scraping(not just scraping. Basically anything apart from rendering)?


texts: Drupal accounts with dead addresses: how to de-activate?

texts:
on my drupal website, there are a lot of users with an invalid email address. I know because, either they have never logged in or their mails bounce. But I have to check manually, which is not good.

When a user signs up with an email address, they receive a confirmation email. Is there a way to automatically disable an account if the user does not log in within the first day after receiving this confirmation mail?

Alternatively, it would be OK to keep the accounts disabled until the user clicks a link on the confirmation mail.

Are there plugins or settings in Drupal to do this?


texts:
I am porting a module from Drupal 7 to Drupal 8. I was debugging using kint().

I am using hook_user_presave($account) and trying to access the values of $account using kint($account).

kint() is very confusing, compared to dsm() in Drupal 7.

How do I access values using kint()?


texts: How do I load a third party PHP library?

texts:
I have a third party php library which I would like to use in a module. How do I do that in Drupal 8? In drupal 7, I have done things like the following code, but libraries_get_path() doesn't exist in Drupal 8, and I'm not exactly sure how things change, not that we use namespaces (of which I am a beginner).

require(libraries_get_path('twitter-api-php') . '/TwitterAPIExchange.php');

And, where should I place my library? Should I create a new libraries directory and put it in the root, just like modules and themes are now in the root?


texts:
What or is there a hook that you can utilize right before rendering results to the php template?

Also, is this means of altering view results bad practice? I'm trying to avoid using the views php field.


texts: How to display $variables in drupal 6 preprocess function?

texts: I'm having difficulty trying to figure out what variables are within the scope of my hook_preprocess function.  I even tried to print_r($variables['fields']), but I keep getting this long recursive mess.  Is there a much easier way in drupal 6 to see what values I can use?


texts: Rest Export View multilingual content taxonomy filter fails

texts:
I am going to create a REST API using Drupal 8 Rest Export with Views.
It is working fine so far. I am showing some fields from content type article and added contextual filters for language and tags.

I get results like this

[
   {
      "title": "Autem Camur Inhibeo Typicus",
      "field_tags": "restapi, test",
      "field_image": "http://localhost/drupal_8_api/sites/default/files/2016-12/gen5431.tmp.gif"
   }
]

I made every field of my article translatable except the tags (they should be the same in every language). This works fine, too, the correct translation is shown and the tags change for all translations if I change them in one translation (I have english and german right now)

My problem:
When I filter by language it works fine and I get only german/english nodes. But if I filter for the tags and for german language I get no results. I could locate the problem a bit. If I set the tags-field to translateable, it works. So I think the problem might be that the german translation has no "own" tags and the filtering fails with this. The strange thing is that the JSON result is correct. (If I just filter for language I can see the correct tags in the german JSON)

Any help is appreciated (the tags should really not be translatable)


texts:
I am getting this error

  Fatal error: Call to a member function raw() on a non-object in one of my custom modules.

Following is my function:

function _gocoop_services_get_app_instance($wrapper)
{
  $instance_id = $wrapper->field_seller->field_application_instance->raw();
  if (!$instance_id)
  {
    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'application_instance')
        ->entityCondition('bundle', 'application_instance')
        ->fieldCondition('field_internal', 'value', 1);
    $result = $query->execute();
    if ($result['application_instance'])
    {
      $instance_id = reset(array_keys($result['application_instance']));
    }
  }
  return $instance_id;
}

Have used the above function at couple of places like shown below:

$wrapper = entity_metadata_wrapper('commerce_product', $entity);
$instance_id = _gocoop_services_get_app_instance($wrapper);

Can anyone help me whats wrong as this has occurred all of a sudden.


texts: Restrict Drupal Search to few content types

texts:
I am having drupal 7 site with search enabled. I want to restrict the search to a particular content type/types, by excluding which types i dont want to appear in the result. How can i do this?

And can i also disable the advance search feature? Are there any module for this?


texts:
how can I create a user defined domain?
E.g. user one will select for his shop the domain "shop1.example.com".
User two will select "shop2.example.com" etc.
How can I do this?I was thinking of Domain Access module but I am not sure which submodule to use.
thanks


texts: open node reference links in lightbox/ popup

texts:
I want in my node view pages, node reference links open in popup window or lightbox window.
Does anyone have a solution?


texts: Best Way to Handle Variables Per Environment

texts:
I have a custom module. It's FormBase to create a form. And on submit, I post values to an API. All this works. But I want to change the base URL variable (which is used in multiple methods) so that when you on any environment besides live you get a different URL.

I want to figure out the Drupal 8 way of doing this.

class EventSuggestionForm extends FormBase {
  // Needs to be different if not the live site...
  private $baseUrl = 'https://www.example.com';
  private $apiUrl = '/api/v1/';
...

Can I get some advice?


texts:
I have just started using the Simpletest module for Drupal 7.  I am trying to use the drupalGet function to pull a URL.  The URL is a views module URL.  I am able to pull other pages using the function.  But none of my views are working.

I think I am missing some small piece here.  Any suggestions please.


texts: Incorrect field of a content type in its display after migrating from a backup

texts:
The following two screen shots should explain the issue well:

Here I have a content type Poll, where the first field is Question with machine name title. However, in Managage Display tab, the second screen shot, the first field is named ShareThis. I'm sure that there is a problem has been occurred during migration. I have tried to fix the database using mysqlcheck -u root -p --auto-repair -o and I tried to look at tables of the database itself using phpMyAdmin to find any hint or solution but I could not find. This issue is found also in another content type named Photos.
Is there any way to fix this databases fault? I'm using Drupal 7.

Important Notice:
In all contents types, in Manage display tab, the title field is named ShareThis. i.e it is not only in Photos type.

Notice 2:
I observed also, the issue is not dedicated to title field only, it is extended to URL path & Metatags modules too. i.e the effected modules are Node, Path module and Meta Tag module. I have tried to create new Content Type, and also this issue appeared with it too.


texts: How to add dev modules to a distribution without getting security updates warnings?

texts:
I have made a distribution, which contains some modules which are in dev state. These modules are being by drush make checked out by git. So my drupal-org.make file contains something like:

projects[ctools][type] = module
projects[ctools][download][type] = git
projects[ctools][download][url] = http://git.drupal.org/project/ctools.git
projects[ctools][download][revision] = e720f61
projects[ctools][subdir] = "contrib"

(I need ctools' current dev version because of a batch that was commited shortly after 7.x-1.4 came out.)

This works ok but when using my distro I always get "security updates available"-warnings, which I would not get if I downloaded and used this same dev version on a standalone project.

What is the best way to handle this? Can I somehow tell drush make to download a specific dev version, as these dev versions are packaged by d.o. and are idenifiable: e.g. version = "7.x-1.4+4-dev"


texts: Override menu item weight (bring it to same level as 'user' link) that has user/% path and has to be in user-menu

texts:
I need a menu item living in the user-menu, has path like 'user/%something' but i dont want it to have "My account" link as parent (that has path 'user')

i can only change that through the administration but this is not an accepted answer...

Any thoughts?

thnx


texts: Use a search bar (exposed filter) to search for different node fields

texts:
I am trying to make an advanced search with exposed filters and views in drupal.

I am trying to achieve the following:

On the left textfield, the user would input whatever he wants to search, and the views will only search by the field selected in the list at the right (field_A in the picture example). (In short, the column by which to search would be the one selected in field to the right)

NOTE: field_A, field_B, etc, would be all from the SAME node type.

I can make it work easily if I only have 1 field to search by (this field is set by interface when you configure the autocomplete functionality in drupal).

What I want is to be able to dynamically supply the field to search by, because said field will depend on what the user chooses from the combo box at the right (as explained in the note, this combo box will have different choiches field_A, field_B, field_C....etc).

Would it be better to create a custom module instead of using Views with exposed filters?

Thanks.


texts: Language selector for Apache Solr search form

texts:
How can I do something like this with Apache Solr in Drupal 7?

This will be the front page of my site, and depending on the language the user chooses, he will be redirected to the language-specific subdomain of my site with the respective search results:

en.mysite.com/search/search=type+here&lang=en
es.mysite.com/search/search=type+here&lang=es
jp.mysite.com/search/search=type+here&lang=jp

Of course, only results with the user's language should be shown.


texts: Redirect exclusion rule in .htaccess does not work

texts:
I have a rule in my .htaccess to redirect all HTTP traffic to HTTPS,
and I'm trying to exclude some specific URL from redirect, so I added the negation exclusion rule:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/my_url
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

But this doesn't work, http://example.com/my_url redirects to front page example.com. Is it interfering with some other rules? All are standard Drupal core .htaccess.


texts: Inline Entity Form - start with first new node open

texts:
My install is using Inline Entity Forms and I would like it so that when a user visits the create node page, the inline entity form starts already visible but with all fields empty and ready to be created (no need to click "Add Node").

I would like to implement either a module or tpl  file in my theme to achieve this. Please can you advise on how to go about it.

I've used this patch https://www.drupal.org/node/2225675 but it only works when editing existing content.


texts: Page Not Found for anonymous (clear cache fixes it)

texts:
I'm getting reports from users that clicking a link gives them Page Not Found.

These are anonymous users.
Page caching is turned on (but not aggressive)
I log in, the page works.  I log out, the page does not work.
Three reports of unrelated pages in the past week (but all were different node types)
Clearing All Caches fixes it.
I could be wrong about this (because I didn't think to check until after I cleared caches), but I think it's returning error 406 in Recent Log Entries.

How can I begin to troubleshoot this?


texts:
I'm working on a custom theme which involves styling specific pages and nodes. At first, to target these specific nodes, I used the selector page-node-##, where ## is the node ID. But this was on my local machine, and when I exported these nodes, I found that the node IDs would be different on both the staging and production servers. Is it better to use the section-XX, selector instead?

I was wondering if there is a recommended CSS selector for this kind of use cases, where the CSS is applied on specific pages/nodes?


texts: How to set image style for media browser in node edit form?

texts:
I am using the media browser that is part of the media module to upload or select images on a node edit form.
I an image is already uploaded it is shown in the edit form in it's original size. If the image is large this makes the whole edit form unusable. Where can I set the images style, that is used for the edit form?


texts: Views contextual filter if field value is X then show this in views page Y

texts:
I have content type Ads.
I have multiple views pages.
I have Views which shows this content type Ads as a view block. Views has multiple block displays, each display for each views pages.

Admin need to choose when adding new node Ads where he want this ad to be shown. He need to choose it from the list. List has for example values X, C, Z

In the Views which shows these Ads as a view block. How to configure contextual filter to check field value? Contextual filter should be set on PHP code - but how to code it?

For example:

If field value is X -> show this view block on the path: categories/x (which is Views page, not node!)

** Solution **

I found my own solution to do something like this.

Added custom manual list field type (field_category). For example: X, Y and C
Add view block for each ad category and set filter field_category for each category. (field category = X)
Then in admin/block edit view block: Show block visibility, set PHP format and added this code:

<?php
if (arg(0) == 'products' && arg(1) == 'categoryX') {
return TRUE; }
else { return FALSE; }
?>

As my views pages path are: products/categoryX.


texts:
I'm creating a module to introduce a new field type. I downloaded the example module by drupal and i start programming.
But when I install the module the .install don't add colums to the dbtable related to new field.

 function field_instagram_field_schema($field) {

   watchdog('start field_instagram_field_schema()', 'We are in!');

   switch ($field['type']) {
    case 'instagram_gallery':
      $columns = array(
        'stream_type' => array(
          'type' => 'varchar',
          'length' => '25',
          'not null' => FALSE
        ),
        'input_tag' => array(
          'type' => 'varchar',
          'length' => '25',
          'not null' => FALSE
        ),
         'thumb_dimetion' => array(
          'type' => 'varchar',
          'length' => '25',
          'not null' => FALSE
        ),
        'thumb_number' => array(
          'type' => 'varchar',
          'length' => '25',
          'not null' => FALSE
        )
      );
      break;
  }

  return array('columns' => $columns);
}

UPDATED
When i install the module and create a field of this new type this function is not runned..


texts: Drupal 7 vertical tabs like the ones in Drupal 8

texts:
Is there a way to move vertical tabs in node forms to a right side column like in Drupal 8? I know one option is Renderable Elements module but last commit was 1 year ago and it says it is an expiremental module.

EDIT: I want to transform vertical tabs into accordions (like the ones in Drupal 8) because once the vertical tabs are in the right column they look awful.

EDIT 2: I just found an interesting sandbox project that does what I want: Responsive Vertical Tabs. However, it's not stable and breaks my ckeditor fields.

Thank you!


texts:
I am in the process of building a Commerce Kickstart 2 site and need some guidance.

From what I can see it is now recommended that e commerce sites are fully hosted on a secure server.

I have in the past looked after a non commerce Drupal site on a standard server.

So my question is apart from having a SSL certificate installed do I need to do any other work to the site or is it a case of just uploading via the hosts control panel onto the secure server as I would with a normal server.

If it's not going to be that easy any advice please


texts: How can I create newsletter template by Simplenews

texts:
I have Drupal v7 and installed the Simplenews module, but now when I send a newsletter, I need to edit the HTML format.

Where can I edit this template?


texts: Create Related Terms Block Showing Terms on Taxonomy Term Page

texts:
Hi i have been hunting high and low for years to create this and i still havent found an answer. I have seen folks looking for similar but these questions usually went unanswered as if the answer is still unknown.

Im using views 2 and drupal 6. I am using the 'related terms' bit of when i edit a term. I would like to show the related terms to a term when viewing a taxonomy term page. I dont want to show nodes just terms.

I have created a term view and have played about with the Taxonomy: Related terms argument and Taxonomy: Related terms relationship but to no avail.

It sounds like quite a simple thing for drupal and views but for some reason there doesnt seem to be a definate answer to this. all help appreciated. thaks


texts: translate the page title in search template file

texts:
What is the best way to translate the title in search template file

I use a commercial theme. In :

page--search.html.twig

I can modify the tytle by replacing :

{{ title }}

by

Recherche

It works but it is obviously not the best way.

Since search result page is not a node, where is this title ?

I’ve searched in blocks, content, module and I can't find this title.


texts: Language fallback to site default in internationalization

texts:
This should be simple enough; but, I'm trying it since a day now with no success.

My site contains listing pages or different content types. By default all the content is of language "English".
When a user (author) translates a content in the listing to other language (say Spanish), and switches to that language using "language switcher"; only nodes of that language are being listed.
This is because I've added Content: Language (= Current user's language) filter to the view.

What I require is when a node does not have a Spanish translation, it should show that node in English. In short I want "English" as a fallback language to all the views (and site). I've tried ORing the filters so that I could list "current language" OR "English", but it shows the both the translated nodes and their corresponding nodes in "English", which is obvious.

Note I've made it compulsory for a user to select content for every content type.

I've tried Language Fallback module, but it did not work.


texts: Passing a Taxonomy term via URL to add content form in Drupal 7

texts:
OK, I have a Drupal 7 site.  And the scenario is that, let's say I'm on a page of my site that happens to have a taxonomy term assigned to it - let's say it's term ABC.  Well in a block in the sidebar I have a link that sends the user to the ADD CONTENT form for a Forum Topic.  The Form Topic content type has a CCK field as well (same vocab).  I'm trying to automatically populate that field with the same term ABC as the page that they came from.

I was thinking this could be passed via URL as a GET parameter, but not sure if that would work and if so how to pull it off exactly.


texts: Parent theme hook is still being called when overwritten

texts:
I have a theme called hasta, and created a sub theme to customize certain aspects of it.  One of the things I wanted to do is change the behavior of one of the hooks, hook_element_info_alter.  The hasta theme defines this as hasta_element_info_alter in template.php.

My sub theme is called hasta_sub, and in that template.php I have overwritten this hook as hasta_sub_element_info_alter.

I put some debug statements, and I can see that my new hook hasta_sub_element_info_alter is being called, but the parent theme hook, hasta_element_info_alter, is still being called as well right before this.

Drupal helps says:

  Theme functions are called through theme('[hook]', $var, ...). When a
  sub-theme overrides a theme function, no other version of that theme
  function is called.

So according to this only the sub theme version of that hook should be getting called.  Can anyone please tell me what I am doing wrong?

Thanks!


texts: Latest update to 8.7 with Commerce caused Edit buttons to appear in place of shipping/billing information

texts: After updating core to 8.7, the input fields for shipping and billing information are now hidden and Edit buttons are in their place.  This has allowed users to checkout without entering shipping and billing information.  How can I show the required fields by default and get rid of the Edit button?


texts: How do I detect the language using node alias

texts:
I know to get the current language of a website:

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

However, given that I have a node alias

$alias = \Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$nid);

How do I get the language of that $alias node?


texts: Using GD w/imagecache vs. imagecache_optimize or imagecache_smushit

texts:
My understanding of PHP GD is that when it writes a file, no meta information is included.

If that's the case, is there any specific advantage to running imagecache_optimize or imagecache_smushit in addition to using GD as the selected API?  And if so, is the improvement more than negligible?


texts: Importing dates TO and FROM using Feeds module

texts:
I'm wanting to import some content to my drupal site. One of the fields for this new content type is a date field. The date actually has both to and from fields and in fact the nodes I will be importing have a start and end date...I've read about importing using the Feeds module (here for example: How to import date fields using CSV file? I haven't been able to find any material on importing a date range (for example, an event. The event begins on August 4, 2015 and ends on August 6). What would be the format for that?

I'm imagining something like MM/DD/YYYY - MM/DD/YYYY. Does anyone know the preferred format?


texts: How to create a theme function for custom HTML markup and then call it in my node template?

texts: Ive created an asses for my site in the content type tpl file. Its mainly HTML but also some simple PHP. What are the steps to move this to a theme function?


texts: Removing breadcrumb from the Homepage in Bartik theme (Drupal 7)

texts:
I am trying to remove the breadcrumb from the homepage (Home link). I am using a bartik theme. I have a page--front.tpl.php and have tried removing the following code snippets and clearing the cache, but the Home breadcrumb is still there. Any help would be greatly appreciated

<?php if ($logo): ?>
  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
    <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

<?php endif; ?>

and

<?php if ($breadcrumb): ?>

<?php print $breadcrumb; ?>

<?php endif; ?>

Edit: I just realised that my front page isn't actually picking up the page--front.tpl template. Why might this be??? :(


texts: What is the status code for "Draft" in content moderation?

texts:
I implemented Content moderation workflow for my headless D8 project and created workflows and enabled for all content types. Salesforce is the fronend application which uses graphql to get the content from headless drupal. Currently I'm able to show published content on salesforce application. But when I try to query draft content from salesforce graphql, getting error message "moderation_state" not found in Drupal logs.
Can someone please help? The following is the example query.
graphQlQuery Testquery :{"query":"{nodeQuery(filter: { conditions: [{field:\"title\",value:\"Test-Test\",operator:EQUAL},{field:\"type\",value:\"XXXX_content_type\",operator:EQUAL},
{field:\"status\",value:\"0\",operator:EQUAL},
{field:\"moderation_state\",value:\"draft,\",operator:EQUAL},]})
{count entities{entityTranslation(language:EN)
{... on NodeXXXXContentType{fieldXXXX body{processed summaryProcessed }title uuid }}}}}"}


texts: How to show the related tags in the node using when its load in drupal?

texts:
I am using cctags module  for getting all the list of tags , I already stored the several tags for each node separately using the content type, now i need to display the specific tag when the node loads , but the cctags module will display all the tags in the term data.

     if(empty($nodevalue->field_beachestags)){
    $tagvale=array(explode(",",$nodevalue->field_beach_migratetagshidden[$nodevalue->language]['0']['value']));
    foreach ($tagvale as $term_name) {
    foreach ($term_name as $termtag) {
        $terms_matched = taxonomy_get_term_by_name($termtag, 'tags'); // "beach_terms" is the machine name of vid 1.
        if ($terms_matched) {
            //We blindly use the first match. Not very elegant.
            $first_term = current($terms_matched);

            $nodevalue->field_beachestags[$nodevalue->language][]['tid'] = (array) $first_term->tid;
        } else {
            $term = new stdClass();
            $term->name = $termtag;
            $term->vid = 1; // Vid from the question.
            taxonomy_term_save($term);
            $nodevalue->field_beachestags[$nodevalue->language][]['tid'] = (array) $term->tid;
        }
    }
     }
 node_save($nodevalue);
 }

but there is a field called "field_data_field_tags " it does not contain any value for the reference of the node and the tags, I am not able to get the related tags to display for the node .

When i load the node i must display the related tags whichs is related to the field_beachestags. Any suggestion and help welcome .


texts: Alternative methods to creating Image Derivatives

texts:
I am importing many many images (300,000+). This number includes adding different crops for each image.

I might be wrong, but it seems that to get Drupal to know that a crop style has been set, I need to load the crop style and then create an image derivative. Without creating a derivative, the crop will be set for a media item initially, but on cache flush the crop is lost (even though the physical file still exists)

$hero_crop = ImageStyle::load('hero');
$hero_crop->createDerivative($file->getFileUri(), "s3://$stylePath");

I should highlight that we are using the S3FS module to connect and store the images in S3  and I am really hoping that isn't the cause.

However, this takes forever while importing my images. So much so that if my batch script is set to process more than 1 at a time it will still timeout. That means that importing one image takes 15-30 seconds which means the import will take on average 1250 hours to complete.

:/

So my question is, is there an alternative way of creating crop styles or does it need to be done with an image derivative?


texts:
I am using follow flag latest version and edited the view fbss_ur_stream. I also created a following and followers view with the help of this tutorial Twitter style follow following

I took the idea from it and implemented it in fbss_ur_stream view. I deleted the relationships and contextual filters and added the new ones. Relationship: Flag follow (current user) and (user) flag user & Cont. filter: (flag user) User: uid. I unchecked "only flagged content" as well as "require this relationship"

Now I am able to see the posts from the person I am following, but my posts are not showing. Why?

Do I have to clone it and create a new view within this master view? how?


texts:
I'm trying to figure out how migrating content from a Drupal 7 site to a Drupal 8 site works. I managed to understand how to create a custom module to migrate nodes with regular fields to my new D8 site.

But I also have one content type where I use paragraphs. And I can't seem to find a well documented example on how to do this. I found some examples but they all seem to use different methods. This one seems like the most up to date. But how to make the code from #9 work?

field_paragraphs:
plugin: sub_process
source: field_source_paragraphs
process:
  target_id:
    -
      plugin: migration_lookup
      migration:
        - paragraph_box
        - paragraph_grid
        - paragraph_text_embedded
      source: value
    -
      plugin: extract
      index:
        - 0
  target_revision_id:
    -
      plugin: migration_lookup
      migration:
        - paragraph_box
        - paragraph_grid
        - paragraph_text_embedded
      source: value
    -
      plugin: extract
      index:
        - 0

So the field_paragraphs and field_source_paragraphs I understand. But what are these paragraph_ items under migration? Is this where I set the paragraph bundles? And if not where do I set the paragraph bundles and there fields? So where do I begin? What are the right steps to take?

Thanks in advance


texts: How to find all Drupal modules which has dependence

texts:
I would like to know if it possible to find all contributed modules that depend, for example, on the Subform module.

This information could be useful if you are working with a module, and want to create yours because you don't know that the same module already exists.


texts: Custom MigrateMap to sync by field or property, e.g. SKU

texts:
Existing situation: MigrateSQLMap

Normally with migrate API, a migration will use MigrateSQLMap to identify imported rows with existing entities.

This means: A database table named like migrate_map_* will be created for each migration. The * part of the table name is based on the migration machine name. This table associates primary key of the source data (e.g. a primary key column of a csv file) to entity ids.

Whenever a row is to be imported, Migrate API will look into the respective migrate_map_* table, and check if a row with this id was already imported, and if the imported entity still exists. If it does, it will update this existing entity, and update the value last_imported in the migrate map table. If it does not, it will create a new entity, and create a new entry in the migrate_map_* table.

What I want instead: Map to existing entities.

Now what if instead of creating new entities, I would like to update existing entities which were previously created with another mechanism, unknown to Migrate API? E.g. these might have been created manually, or with a home-grown migration script.

In my case, these entities are commerce products, which were created with a custom script which is to be replaced with Migrate API.

The idea is:

Compute an SKU from the imported csv row.
Find out if a product with this SKU already exists.

If yes, update.
If no, create a new product.

If possible, save the import timestamp somewhere.

Solutions I can think of so  far

I can imagine two possible solutions.

A custom migrate map class SkuMigrateMap extends MigrateMap.
Seeing how many abstract methods MigrateMap has, this could be quite a lot of work.
Use MigrateSQLMap, but prefill the table based on existing products.

Question

Is there an existing or recommended solution for this somewhere?


texts: How can I untheme a fieldset provided by theme_fieldset()?

texts:
I'm allowing users to set their time zone upon registration.  However, I don't want to show the "Locale settings" fieldset that is provided (border, title "Locale Settings", etc.)  Is there a simple way to use hooks to remove the fieldset markup but not the content of the fieldset itself?

With theme_devel, I've been able to get the function that makes the fieldset (theme_fieldset()) as well as the form id (edit-timezone).  But I don't know what to do with these to hide the fieldset markup but allow the content to remain.


texts: Where to adjust number of returned results on the /admin/people page? I know, don't hack core

texts: I know, you don't need to tell me. Don't Hack Core but I just need to display 1000 user records rows on the /admin/people page temporarily and I'll switch it back. I promise...


texts: Is it possible to get rid of the Javascript code?

texts:
All nodes (Drupal 7) contain the following code:

<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/misc/drupal.js?nxe6cr"></script>
<script type="text/javascript" src="http://localhost:8080/myfeodor.de/sites/default/files/languages/de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js?nxe6cr"></script>
<script type="text/javascript">
    <!--//--><![CDATA[//><!--
    jQuery.extend(Drupal.settings, {
        "basePath": "\/myfeodor.de\/",
        "pathPrefix": "",
        "ajaxPageState": {
            "theme": "my_garland",
            "theme_token": "WTVBB9vMIjxgWuVheFjYXjuvpo1TgahCH62PRBBFGrA",
                "js": {
                "misc\/jquery.js": 1,
                "misc\/jquery.once.js": 1,
                "misc\/drupal.js": 1,
                "public:\/\/languages\/de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js": 1
            },
            "css": {
                "modules\/system\/system.base.css": 1,
                "modules\/system\/system.menus.css": 1,
                "modules\/system\/system.messages.css": 1,
                "modules\/system\/system.theme.css": 1,
                "modules\/comment\/comment.css": 1,
                "modules\/field\/theme\/field.css": 1,
                "modules\/node\/node.css": 1,
                "modules\/search\/search.css": 1,
                "modules\/user\/user.css": 1,
                "sites\/all\/themes\/my_garland\/style.css": 1,
                "sites\/all\/themes\/my_garland\/print.css": 1,
                "sites\/all\/themes\/my_garland\/fix-ie.css": 1
            }
        }
    });
    //--><!]]>
</script>

The file de_HizaMms-3Ux-y0M1w9o2_EvSFCBziqwcKzQq9_kzJ78.js
contains an associative array where error messages are translated.
But this appears not to be necessary since the page works also with
scripting deactivated in the browser.

This is WAMP, but under Linux the same code appears.

This code is also present if one is only reading without being logged in.
Is is possible to avoid this scripting?

Drupal 6 has been Javascript-clean for readers.


texts: Native Android app with Drupal backend and Login

texts:
I need to create a native Android app, this app will use Drupal as a back end.

The app must be native. All the back end functionality, will be taken care of in Drupal, even the login credentials. I will use JSON to get the data from Drupal

I have a few questions on what is possible.
Login credentials are stored in Drupal DB. How can i login to Android with these credentials? Can i use JSON and what about the password? The password need to be encrypted.

Is there something like a password protected JSON url? I don't want anyone not authorized to see the JSON url.

If you have any advice or suggestion please let me know.
I am new to Android and not an experienced programmer.
Thanks in advance


texts: I would like to know if it is possible to make a module install a separate theme as well. Should I just ask that whoever installs my module also downloads that theme to have a better experience?


texts: How do change address field titles to another language in Ubercart?

texts:
In D7 you could just rename the title and type them in a different language.

But in D8, there is no such option like in D7.


texts: Why are available updates of CKeditor not visible in the update report in Drupal 7?

texts:
/admin/reports/updates lists a few updates, but the ckeditor module is missing here. It runs in version 1.9, since then a few security updates have been released, but it does not matter how often I run the cron or update the list manually, the updates for ckeditor wont be listed here.

The module itself works perfectly fine. How come?


texts: how to add .install file to the new feature folder?

texts:
I have created new feature and needs to add .install file to create new table like create new module way

but the table have not been created

can you advice me with the right way to do or i have to create a new module along with the feature
thanks in advance


texts:
View with relationship to custom entity via computed property

I have nodes connected to a custom entity (called here "myentity") via a computed property, like this:

  $info['node']['properties']['myentity'] = array(
    'label' => t("Myentity"),
    'type' => 'myentity',
    'computed' => TRUE,
    'queryable' => TRUE,  // setting this to FALSE doesn't change anything
    'entity views field' => TRUE,
    'getter callback' => 'mymodule_node_property_myentity_get',
  );

The callback function extracts some values from the node and calls another function, which fills these values into an entity field query, returning the wanted myentity instance.

This entity connection is working, so I can get the property "myprop" of myentity via an entity API wrapper $node_wrapper->myentity->myprop->value().

Now I want to add myprop in a simple view for nodes. After creating a relationship to myentity, "Content: Myentity" shows up in the "Add fields" list, as well as all of myentity's properties.

Selecting "Content: Myentity" works - myentity's default label is displayed in the view output. (With some magic - the displayed SQL query is SELECT node.nid AS nid FROM {node} node).

However, selecting "Myentity: Myprop" does not work. Even before executing the view, Drupal shows a SQL error:

SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "myentity" LINE 1: SELECT node.nid AS nid, myentity.myprop AS myentity_myprop, no... ^

The displayed SQL query here is SELECT node.nid AS nid, myentity.myprop AS myentity_myprop FROM {node} node. myentity is referenced in the select clause, but not in the from clause, nor is there any join statement.

Has somebody managed to add properties of a custom entity, connected via a computed node property, to views?


texts:
I have a content type I created called News. The pathauto pattern is "news/node title".

I created a view page to list all the News. The path to the view page is "news".

When I go to the view page, all the articles are listed.

When I click on one article, I get "Cannot modify header information - headers already sent" errors, the view page is shown twice. The third repeat of the content shows the article. The full template, header and footer and everything is repeated for all three.

I tried renaming the view's path to "foo" but then I get file not found errors on all my "news/node title" pages.

I tried renaming my pathauto pattern to "content/node title" and the view to "news" and both the view and the news pages work.

Why can I not use "news" for the path to my view and "news/node title" for the path to the articles?


texts: How can I have a second alias for a node to be displayed in a different view mode?

texts:
I have nodes whose content type is X that I would like to render differently based on the node path.  I'd like to use the default view mode for a path alias and a custom view mode for the other path alias.  These aliases were created using the Pathauto module; both of them point to the same node.

/url/alias1/path => /node/123 (default view mode)
/url/alias2/path => /node/123 (custom view mode)

I tried using mymodule.routing.yml to do this, but it does not appear to be picked up by the route system.

mymodule.program:
  path: '/url/alias2/path'
  defaults:
    _controller: '\Drupal\mymodule\Controller\RoutesController::setViewMode'
  requirements:
    _access: 'TRUE'

When I click on the alias with the custom view mode, I get the default view mode.  I put a logger statement in the routes controller setViewMode function and it is not reached. This suggests that the routing is not being 'tripped'.

Am I missing something or trying to do something Drupal 8 cannot handle?

I looked at Routing and path aliases but that doesn't quite address my question.


texts: Ubercart Marketplace vs Ubdercart Affiliate?

texts: We want to implement a multi-seller, affiliate-like shop but I'm stuck at which module to proceed with. What exactly is the difference between the two? Documentation is quite general and one can not tell which one is better.


texts: how to reorganize with twig a form builded in a custom module and keep working ajax callback?

texts:
I've a form created programatically with a few fieldset and some inputs in these use ajax callback. The structure is like this :

$form['global']['controls'] = [
  '#type' => 'fieldset'
];

$form['global']['info'] = [
  '#type' => 'fieldset'
];

$form['global']['description'] = [
  '#type' => 'fieldset'
];

I've defined a theme template in my .module file and created the twig template. This is the twig template :

  {{ form.global.info }}
  {{ form.global.controls }}
  {{ form.global.description }}

The form display correctly but ajax callback don't work : the callback are executed but don't change the elements.

All callbacks work with this :

  {{ form }}

But I can't rearange the form with this twig code.

What I want is the possibility to rearange the order of the fieldsets in twig : put the fieldset 'description' before 'info', or 'controls' before 'info', etc. And keep ajax callbacks working.

Is it possible? And how?


texts: How to use hook_form_BASE_FORM_ID_alter() to save variable?

texts:
I am attempting to use hook_form_BASE_FORM_ID_alter() to 1) add a field to the node edit form, which then is 2) turned into a token, and 3) used in Rules. This question is only about the first part of this process.

The following code is in place. It creates a field, but nothing is getting saved to the variable in question, additional_email, after the node edit form is submitted. I know I'm doing something very wrong here, but I don't know what.

How can I save the variable entered by the user to be accessed by a different function in my module?

Edit Form Code

function MYMODULE_form_node_form_alter(&$form, $form_state) {
   $email_default = 'john@example.com';
   $form['additional_email'] = array(
      '#title' => t('Additional E-mail'),
      '#type' => 'textfield',
      '#default' => variable_get('additional_email', $email_default),
      '#description' => t('If you would like to notify an additional person, please supply the e-mail address.'),
   );

   $form['options']['additional_email'] = $form['additional_email'];
   $form['options']['additional_email']['#title'] = t('Additional Notification');

   $form['#submit'][] = 'MYMODULE_submit';
}

function MYMODULE_submit($form, $form_state) {
   if (isset($form_state['values']['additional_email'])) {
      variable_set('myvariable', $form_state['values']['additional_email']);
   }
 }

Token Creation Code

 function MYMODULE_tokens($type, $tokens, array $data = array(), array $options = array()) {
    ...
    $notify_email = variable_get('additional_email', '0');
    $concat_array = implode(' ',$notify_email);
    $section_users['add_email'] = $concat_array;
    ...
  }

Update: I added a submit handler, shown above (and clarified the variable I accidentally omitted when copying the code). Unfortunately, I'm still getting the old garbled array that was somehow saved in there previously.

The code which assigns the variable's value to the token is above, in case that's the problem.


texts:
I can't find if it is possible or not to change the log in system by using the couple (email, password) instead of (username, password).

I think people never remember their usernames when not available as they wanted and so had to add a number at the end of it ...


texts: Permission issues with Custom Content Entity exposed to REST API

texts:
I hope it's not a duplicate entry.

I've recently created my Custom Content Entity within a Custom module and I'm currently having trouble with permissions. (Please see permissions below)

The permissions work perfectly when using the add/edit/delete Drupal forms. It throws a 403 if the current user has not the permission, which is great because everything is normal here.

But when I expose the Custom Content Entity via RESTui module : GET, POST, UPDATE. (please see screenshot below). Anonymous users don't get 403 and are able to create, edit.

Are the permissions defined under mymodule.permissions.yml only for Drupal entity form ?

How do we define REST permissions for a Custom Content Entity ?

Thank you very much for your help


texts: How to expose non Drupal tables in Views?

texts:
I wonder what is the best way to allow the Views module to access external tables not in Drupal?

I tried the Data module, but it doesn't allow for a datetime datatype.


texts: Does "exclude from display" on views affect performance?

texts:
I really wonder if it differs in calculation time to exclude an item from display.

For example:

I have 500 rows in a view.
Each row has two fields: title and author.

Does generating the same view with excluded "author" field takes the same time as displaying "author field"?


texts:
I am developing a website which basically has the main data source from wikipedia. The website currently needs users to copy paste text from various data sources (like wikipedia). But the problem which I realized out of it is that soon the data in the primary datasource will be outdated when people enter

Instead, I am looking in developing a module for wikipedia interface with a following workflow:

User will create a new page (a species page in this instance) and link it with its corresponding wikipedia page.
The local database will have 2 more tables (lets say) apart from the content type information of the current page of the Drupal powered website's node, in this case a species node.

a. A table for storing the RAW wikitext of the linked wiki page with the most recent timestamp.
b. A table for storing the processed wikitext which will be mapped into the Drupal node's appropriate fields.

Provide a button in the species page which will check if the 2(a) wikitext is the current in the wikipedia's corresponding article. If not, 2(a) will be updated and user will have to perform the task of 2(b) which is mapping the new wikitext into Drupal node's fields - This can be accomplished by injecting tags in appropriate way.
Provide a module where the wikitext of 2(b) is pulled into the various fields of drupal's content node.

Now my questions:

Is it feasible?
How should I get going?
Any scope for enhancement in the requirement analysis?
Loopholes?

Please see, I know my question is very broad but I would need suggestions, pointers and guidance for going ahead. I believe a proper plan is much necessary before starting to implement it.

Thank you.

EDIT:

We have released IndianSnakes application in both Android and iOS. This is possible coz we had information of species formatted across different fields which can be visualized in the above links which I have pasted. Now, the whole point of my question stands, I need some ideas in developing a middleware with which the wealth of wiki information can be formatted across different fields for each species.


texts: Facet block is not getting display on search page created by view

texts:
I am using the Search API module with an Apache SOLR server. On my search page, the search results are rendering properly, but the content type facet block is not getting render in any defined region.

I followed the same steps as mentioned in Enable facets.

Is there any version compatibility issue?

I am using the following versions of the dependent modules.

drupal/search_api 1.14
drupal/facets 1.4
drupal/search_api_solr 3.7
drupal/search_api_autocomplete 1.2


texts:
I created a view that dynamically displays some nodes depending a wildcard in the path.
The view path is something like /fruits/%
So /fruits/apples would show all the apple nodes, /fruits/oranges all the orange nodes and so on.

Works great when I directly go to a path like www.mysite/fruits/apples but I can't create a menu item with the path 'fruits/apples', I always get the message The path 'fruits/apples' is either invalid or you do not have access to it.
Also tried creating URL aliases for the path but same message.

/* Update */

I use this code to get the argument I need to load the right 'fruit', it returns false when no term_id is set, and that seems to be a problem. When return true, I can set the menu item but then the view will always try the display the page in stead of showing the 'No Results Behavior'

$term = taxonomy_get_term_by_name(arg(2), 'fruit_type');
$term_id = key($term);
if(isset($term_id)){
  $handler->argument = $term_id;
  return TRUE;
}

return FALSE;


texts: How do I display the domain owner of a node in a view?

texts:
I have a view that's generating a block showing upcoming events. On the main site those events might be coming from multiple domains (the site is using Domain Access) and I'd like to show the domain owner as a link to their site sub-domain.

Example:

Aug. 14 - Sample Event
Domain Owner (http://owner.mydomain.com)

Is there a way that I can add this directly to the view? If not, what is the most effective/correct method for coding that into a view template override?


texts: I want to give registered users permission to access, but not edit a certain page. Ideally what I want is this: create a link or a menu item that is only seen and or accessible by certain signed in users. I would like to create a role to give to these people as they sign up, but I have noticed that Drupal is not quite like other content management systems I have used in the past. On a platform such as DotNetNuke you were able to assign a permission for a user to access a web page but not edit it. It appears from what I have seen that you can only add permissions for users to edit the webpage/content of which you give them. Is it possible to give someone access to a page without giving them any administrative privileges? Any modules that could help me out? Thanks!


texts:
I am using the full pager in views module. I am displaying 40 items per page.
The full pager display links like this

1 2 3 4 5 next last

I want to change it to this

1-40 41-80 81-120 next

How will I do this? Any idea about this?


texts: Forced rendered node view results in empty node links

texts:
In order to send html email using drupal/swiftmailer I load and view a node.

Then I pass it to the rendere. In the email sent, generated node__links are empty. As node_links uses #LazyBuilder, Im then not sure to use the correct way.

hook_mail

function mymodule_mail($key, &$message, $params) {
   switch ($key) {
       case 'mail_node':
           $message['from'] = \Drupal::config('system.site')->get('mail');
           $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed; delsp=yes';
           $message['subject'] = t('Mail subject');

           $node = Node::load($params['nid']);
           $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');

           $body_data = [
               '#theme' => 'mymodule_mail_node',
               '#content' => $view_builder->view( $node ),
           ];

           $message['body'][] = \Drupal::service('renderer')->render($body_data);
       break;
       }
 }

mymodule--mail-node.html.twig

 {# simply render the whole body #}
 {{ body }}

output results in mail

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'links__node' -->
<!-- FILE NAME SUGGESTIONS:
    x links--node.html.twig
    * links.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/content/links--node.html.twig' -->

<!-- END OUTPUT from 'core/themes/classy/templates/content/links--node.html.twig' -->

When I render the same content into an html page, node__links are correctly filled.

Any recommandation would be appreciate.
Thanks


texts:
I am trying to configure the Kaltura module in Drupal 7. If I try adding the partner ID, email ID, and password (which I have received from Kaltura's website), it gives me the following error:

  Class 'KalturaUser' not found

I also added the library but it's not working. Could anyone tell me how to configure the Kaltura module?


texts: How do I limit access to a custom field type I have created so that it can only be attached to certain bundles of content?

texts:
I have a custom field class. I would like to limit it to specific content types and bundles that I will choose when my custom module is installed and as other content types meet certain criteria. I don't want it to be available at /admin/structure/types/manage/article/fields/add-field
Is hook_form_alter on the add-field page form my only option or is there an Annotation or API I can use to mark my field as "not available to this content" similar to the way FieldWidgets can be marked as applicable to only certain field types?
Note: I was also planning to add a ConstraintValidator to the field so that it won't validate if added to the wrong content.


texts: Invalid address: return even on successfully sent e-mail

texts:
Need help ASAP.
My function is sending e-mail on successful quit. E-mail is sent well. The problem is that i'm always getting "Invalid address:" before my normal exit message.
Code is following:

$message_text = array(
'id' => 'modulename' . '_' . 'key',
'to' => '2@example.com',
'subject' => "OK",
'body' => array("OK"),
'headers' => array(
    'From' => '1@example.com',
    'Sender' => '1@example.com',
    'Return-Path' => '1@example.com',
          ),
);
$system = drupal_mail_system($module, $key);
$message = $system->format($message_text);
$system->mail($message);

Thanks.


texts: How do I alter a form submission handler?

texts:
I want to alter the form submission handler submit for the search block with a custom module.
Setting  $form['#attributes']['class'] works, but the submission handler doesn't seem to be triggered with any of the methods that I have alternatively found in many core and third-party modules.
/**
 * @file
 * Redirect search from search block to XXX.
 */

use Drupal\Core\Form\FormStateInterface;

/**
* Implements hook_form_FORM_ID_alter().
*/
function search_redirect_form_search_block_form_alter(&$form, FormStateInterface $form_state) {
    $form['#attributes']['class'][] = 'test-class'; //Working
    $form['#submit'][] = 'search_redirect_search_block_form_submit';
    $form['actions']['submit']['#submit'][] = '_second_submit';
}

function search_redirect_search_block_form_submit(&$form, FormStateInterface $form_state) {
  \Drupal::logger('search_redirect')->notice("the function is triggered"); // Not happening
  \Drupal::service('messenger')->addStatus("the function is triggered"); // Not happening
}

function _second_submit(&$form, FormStateInterface $form_state) {
  \Drupal::logger('search_redirect')->notice("second_submit"); // Not happening
  \Drupal::service('messenger')->addStatus("second_submit"); // Not happening
}


texts: Sort by one criteria and have another to fall back on

texts:
I'm trying to configure a view (using the Views module) that sorts the content by content weight, then by total content views (loading a max of 6 items).

For a quick explanation, this is to list the most popular 'resources' on the resources page (PDFs). I'd like the list to be sorted by total views, which I've already achieved. However, I want to be able to give a weight to specific resources (resource is a content type, I've created a weight field using a simple list(integer) field that goes from -3 to 3) which the 'Popular Resources' view sorts by first before loading by total views.

I've tried giving the view 2 sort criteria, which are:

Content: Most Popular Resources Block Weight (asc)
Content statistics: Total views (desc)

I have 1 resource with a popular resource block weight set (the rest don't have a weight set), but the view isn't showing this resource as it has a lower number of total views than the others being loaded.

If possible I'd like the view to sort by resources that have a weight set, then when it runs out of blocks that have a weight, use total views to load and sort the rest of the resources. I've tried looking for a way to do this but haven't found anything yet.

Any assistance would be greatly appreciated.


texts: How to save POST variables securely using entity api

texts:
I am creating a module that connects Drupal Commerce to Shipworks (a shipping management system). They communicate with each other using HTTP POSTs via a single endpoint URL on Drupal. One aspect I am trying to understand is how to handle the POST variables returned from Shipworks in a secure manner.

For example, when a shipment is created in Shipworks the corresponding order id ($_REQUEST['order']) and tracking number ($_REQUEST['tracking']) are posted to Drupal at the endpoint. How do I save the tracking number in a secure manner using the entity api? Can I use the following code?

if (is_int($_REQUEST['order'])) {
  $order_id = $_REQUEST['order'];
}
else {
  _outputError(40, "Not a valid order id.");
}

$order = commerce_order_load($order_id);

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);

$tracking = $_REQUEST['tracking'];

$tracking_number = str_replace(' ', '', strtoupper($tracking));

$order_wrapper->field_tracking_numbers->set($tracking_number);
$order_wrapper->save();


texts:
I need the user to choose a serial number from a drop down when viewing the product display. For example there is a product SKU of unxm_12 for Uncanny Xmen #12, there are 3 in stock and each one has a serial number, all are the same price.

We want the user to be able to choose a serial number from a drop down and then we can view that serial number on the order later to determine which comic book they actually want.

This needs to be custom for each product, each SKU can have multiple serial numbers. There are many products. What is the best way to do this?


texts: How do you print the view name on a "view page"?

texts: I have set up a custom template for my new view and need to print the views title at the top of the page. What is the best way to do this?


texts:
I’m trying to redirect users in Drupal 8 as I was used to do in Drupal 7 with a simple drupal_goto().

This is my code.

$response = new \Symfony\Component\HttpFoundation\RedirectResponse(\Drupal::url($url_redirect));
$response->send();

Executing it, I get the following error:

  Symfony\Component\Routing\Exception\RouteNotFoundException: Route http://mydomain.es/participar?utm_source=RTB&utm_campaign=&utm_medium=banner&utm_term=1
  does not exist.

The alias /participar exists. What am I doing wrong?


texts: Are there any easier ways to update a site than following the official instructions?

texts:
For tech people (like sys admins) the are the official instructions about How to update Drupal Core for how to update a site. But what if the user is inexperienced and just wants to maintain the site by installing security updates?

I can follow these steps myself but if I'm not available it's important that anyone (in the organization I'm volunteering for) can do it.

So, are there any easier ways to update a Drupal 7 site than following the official instructions?


texts: How to Resolve CORB Issue using Drupal Docker Container

texts:
I'm running the latest version of the Drupal docker container.
I'm trying to make a GET API call via Javascript and I'm receiving back CORB (cross-origin-read-blocking) errors in the Console when trying to make a get request and displaying the output in console.log.
I'm using JSON API module to query the API.

Everything is being done on localhost.
I have Drupal running on port 4700 and just testing with a local HTML file and JS file.

In Firefox, I can see an actual response in the Network tab, but under Console I'm receiving a similar message about CORS/CORB.

How do I modify the Access-Control-Origin-Allow in Drupal to *

Here is the JS I'm using for my call:

  // Create a request variable and assign a new XMLHttpRequest object to it.
  var request = new XMLHttpRequest()

  // Open a new connection, using the GET request on the URL endpoint
  request.open('GET', 'http://localhost:4700/jsonapi/node/espot_html/fbaab7dd-09c2-4aa0-852d-4b9462074a45 ', true)

  request.onload = function() {
    // Begin accessing JSON data here
    <!-- var data = JSON.parse(this.response) -->

<!-- data.forEach(processed { -->
  <!-- // Log the repsonses -->
  <!-- console.log(processed.block) -->
  }

  // Send request
  request.send()


texts: Code with Extracting Thumbnail from video is not working in a node

texts:
PHP script when run from linux shell is working fine. But when the same code is put in a node its not displaying anything.

Below is the code:

<?php

 /*$videopath=$_GET['videoname'];
   $imagepath=$_GET['imagedestination'];*/

   if(file_exists('/opt/lampp/htdocs/mydashboard/guitar_file.avi'))
      {
       print 'entered';
       $path_ffmpeg = '/usr/local/bin/ffmpeg ';
       $offset = '-itsoffset -4  -i ';
       $video_file_location = '/opt/lampp/htdocs/mydashboard/guitar_file.avi';
       $add_params = ' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 ';
       $thumnail_filename = '/opt/lampp/htdocs/mydashboard/test_thumbnail.jpg';
       try
         {
          $command='/usr/local/bin/ffmpeg -itsoffset -4  -i /opt/lampp/htdocs/mydashboard/guitar_file.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 /opt/lampp/htdocs/mydashboard/test123sdasd.jpg';
          $return_value = exec($command, $output);

 ?>

Any help is appreciated.


texts: How do I set start date with the core date field?

texts: I need set the start date (e.g. now +1) for my date field. How can I do this on Drupal 8.1.x?


texts: I have a question regarding the webform module. Is there a way to automatically attach a webform to a type of content? I have done something similar through adding it as a field in that content type, and making it required when creating content of that type. However, is there another way to automatically embed it into a content type?


texts: How to change the product type of selected Drupal Commerce products (without direct DB updates)?

texts:
In order to apply a price calculation rule for certain products only, I have created a new product type. But I am having problems changing the product type for the selected products. Right now it seems to me that the only way to apply the new product type to these products is to delete them and then re-import them (using Feeds) with the new product type selected. This works as expected.

But there are hundreds of products and it seems to me that there should be an easier way. I have read this post How Can I change the machine name of product type but I am a bit wary that I might break something by changing things in the database.

Does anybody have a cleaner solution for this?


texts: Views Contextual filter for matching taxonomy names

texts:
I have a view of content type slideshow items. Each item has a taxonomy term fromslideshow_category vocabulary. I also have another content type: articles, which has it's own taxonomy article_categories.

I'd like to create a view that will match the names of those taxonomies and display the slideshow items accordingly.

For example on articles taxonomy page news the only slideshow items displayed are those which marked news .

What I'm doing right now:

I have created a contextual filter on the slideshow items view

When is NOT available

Content: field_slideshow_category
Provide Default value > Raw value from URL
Path component > 2
Use Path alias > checked

When IS available

Specify validation criteria > checked
Selected the slideshow_category
Filter value type > Term name converted to Term ID

PROBLEM

This works fine on page like /articles/news/ (using my previous example ), but obviously because I pass RAW value this view also appear on /articles/news/news-item (which is the actual article page). What I need is for this view to show up only on taxonomy pages. Is there a way to limit "Raw value"? should I be using a different "Provide Default value" ?

Thanks in advance :)


texts: The directory sites/default/files is not writable on Mac OS X

texts:
I had my website developed by someone else and it is currently working with no issues on our web server.  I'm trying to set the same site up on my Mac OS X 10.6 using the preinstalled Apache server, MySQL, and PHP5.  Also, it's Drupal 6.22 we're using.  I copied all of the website files (including Drupal and the .htaccess file) and put them in /Library/WebServer/Documents/website.  I then did a mysql backup on the server and imported that file on the local machine with phpMyAdmin.  I configured the settings.php file and everything else to work nicely so it can connect to the DB, etc.

Most of the site works as expected, however, there is a couple of nodes that won't work at all.  Instead I get this message when I go to them:

"The site is currently not available due to technical problems. Please try again later. Thank you for your understanding."

The weird part is if I enter in the URL to go to the edit page for that node it works, but I still cannot view the page.

When trying to search for problems that only issue I found anywhere is in the "Status Report" page it says the file system is not writable.  I get this message:

"The directory sites/default/files is not writable."

I checked the permissions and that folder has drwxr-xr-x set for it.

Any ideas as to what might not be set properly would be greatly appreciated.


texts: Are there any modules available or any procedures available so that node reference fields can be incorporated into a webform?


texts: using profile2 login information as billing information in commerce

texts: I have a site where people able to buy anything are already loged in. How do I collect from profile2 and apply this information in commerce billing automatically?


texts: Importing nodes with different field names from Drupal 6 to 7

texts:
I need to import certain nodes from a Drupal 6 site to a Drupal 7 one. I have a particular situation:

I need to import only nodes of a certain type
Node types have different names in the sites ("Question&Answer" in the drupal 6 site, "Answers" in the drupal 7 one)
The 2 types have the same fields, but some fields have different names (The drupal 7 nodes have additional fields, but they are not required)
I need to put the id of the drupal 6 nodes in a field called "orig_id", the drupal 7 nodes need to have different IDs
Nodes have 4 taxonomy relations: 2 use Hierarchical select, 1 (tags) can have new terms added when creating a new content (and the 2 sites have a different set of tags at the moment).
Taxonomy vocabularies have different names, but (except for tags) contain the same terms.
Node Authors are the same in both sites, but they have different IDs. Importing authors references is not a must, so it can be skipped

I am fairly new to Drupal, i have tried searching for some import modules and/or articles about importing, but i can't find a guide that suits all my needs.


texts: Changing an exposed filter to use check_plain() or filter_xss()

texts: I have a view with a search filter. I am using Acunetix scanner to scan for vulnerabilities, which reports me an issue about the search filter. How do I alter it to use check_plain(filter_xss($string)) or filter_xss(check_plain($string)) in view exposed forms (a block, in my case)?


texts: How to programmatically modify fields of taxonomy terms?

texts:
In D7, how do I programmatically add/modify fields to taxonomy terms? They are clearly fieldable and in UI I can add and edit fields in them just like I do in nodes but it proved to be no easy task in the code. Say I have a vocabulary named Fruit with terms like Apples and Bananas. I've added a field to it named main_article_id, so all terms have Name, Description and Main Article Id. When I create a node named Apples that has a reference to the Fruit vocabulary (field_fruit) and Apples term is selected, the code should update Apples term and set its main_article_id field to $node->nid. Here is my code:

//hook_node_insert fires after new node has been inserted into db
function MYMODULE_node_insert($node)
{
    $taxonomy_term_id = $node->field_FRUIT[LANGUAGE_NONE][0]['value'];
    $taxonomy_term = taxonomy_term_load($value['tid']);
    if($taxonomy_term != FALSE)
    {
        //doesn't work
        $taxonomy_term->field_main_article_id[LANGUAGE_NONE][0]['value'] = $node->nid;
        taxonomy_term_save($taxonomy_term);
    }
}


texts: I'm trying to set a $page variable but it's not working.

texts:
i'm studying, trying hard to understand what is show in the kpr($page) output. So as an exercise, I'm trying to change #show_messages element. by default, i get this

....(Array, 10 elements)
◦ #show_messages (Boolean) TRUE

so in the theme_hook_alter() function i did this (before the kpr() output).

$page['show_messages'] = FALSE;

but when i refresh it's not changing the output. why is that.

also, i don't really understand the difference between elements with a # before them and the ones without.


texts: How to display uploaded files with uncommon extensions using file field?

texts:
I have a standard Drupal file field to upload different files via this field.
I have set the "allowed extensions" to:
txt, pdf, doc, docx, pages, key, ppt, pptx, numbers, xls, xlsx, csv, tar, gzip, tgz, gz, zip, ics, html, css, inc, srt, yml, xml, plist, config, patch, info, ico, mp3

But not all uploaded documents of these files show even though the user has the permissions to view any. The user is not anonymous user.
For example txt and pdf files show but NOT numbers files even though the Numbers file is visible on the form after uploading, saving and editing.
My intermediate solution for now is to zip those specific extension files and upload them as a zip but I'd like to understand why they don't show.
Does anyone know why?


texts: How to enable Drupal site to be in an iframe?

texts:
How can I enable a Drupal site to be in an iframe and place it in basic html page.

If I try this:

<iframe src="drupal-site.com"></iframe>

then it doesn't show any result.

Any suggestions?


texts: How to handle free and paid orders with post processing?

texts:
I'm going around in circles trying to use Drupal Commerce to make an ecommerce site where some orders cost money and some don't (because some users have coupons that make products free).

I've set up the Checkout process as seen in the screenshot below and have created a rule as such

Rules Event: Process checkout pane
Rules Conditions: Price comparison (commerce
order = $0)
Rules Actions:

Change pane properties (disable billing
information, off-site payment redirect, Payment)
Update the order state to (pending/complete)

With this setup when the user goes through without a coupon it all works fine. When the user uses a coupon to get the price to zero on the Checkout page the user presses the Continue to next step button and goes to an empty Review page (the panes have been set to disabled so there is nothing to see) and they can't progress any further.

Pressing the Continue button on that page just bounces them back to the same page. If they press Cancel and go back to the shopping cart, then on through checkout and press "Continue to next step" again (the coupon has been remembered and the total is still $0) then get sent to the Checkout Complete page and hook_commerce_checkout_complete($order) is called.

I've tried adding extra actions to the rule, to complete the checkout or change the order status, but they have strange side effects like going to the Review page anyway, or calling that hook twice.

Can anyone help me set up the checkout and rules so that a free order goes straight to complete from the checkout page, whilst still maintaining the normal path for orders that require payments?


texts: What is the purpose of _services_controller_execute_preserve_user_switch_anonymous()?

texts:
I have been having a problem persisting the authenticated session after a successful registration using Services 7.x.3.11 in Drupal 7.

I've sort of solved that issue by commenting out the call to _services_controller_execute_preserve_user_switch_anonymous() inside of sites\all\modules\services\includes\services.runtime.inc. The file's comments read:

  As authentication methods should authenticate user themselves changing global $user variable we preserve incoming session authenticated user and his session so changes made by authentication do not interfere.

Aside the grammer, I do not understand the purpose of this method nor how Services authentication works and integrates with Drupal's core. Can anyone explain why this is necessary for Services to honor Drupal's roles and permissions.


texts: Would having the display errors setting turned on in the following admin page admin/config/development/logging cause Varnish to generate cache misses?


texts: $form_state->setRedirect not working after a $form_state->setResponse

texts:
In the submitForm of a custom form, I have this:

$sFileName = 'sites/default/files/_private/bulletins/' . $form_state->getValue('adherent')[1] . ".pdf";
$response = new BinaryFileResponse($sFileName);
$response->setContentDisposition(
  ResponseHeaderBag::DISPOSITION_ATTACHMENT,
  'bulletin.pdf'
);
$form_state->setResponse($response);

This triggers the download of a pdf document and it works.
Then, I try to execute:

$form_state->setRedirect('<front>');

and that is not working!
In FormState::setResponse documentation, I read « If a response is set, it will be used during processing and returned directly. The form will not be rebuilt or redirected ».
I guess it is why my redirection to  doesn't work...

How can I do it anyway?


texts: Same View, different displays, One page, same exposed filters. Possible?

texts:
I want to list my content categorically within view. The problem is that I want all of it to be filtered through exposed filters.

Here is what Content Type looks like:-

Content Type (MyContent)

Title
Body
Category (it has three categories in it "Category1, Category2 and Category 3". User has to selects one when entering the content)

Now I created a view which lists all of the content linearly (like a normal list) and I have exposed filters on top, which filter the content, but now I am not sure how to proceed when I have to show the content as:-

Any Idea what I should do to achieve this? What should I do in this scenario?

I'll be grateful to you valuable assistance.

Best.


texts: Two different front pages with different themes

texts:
So I have the following problem. I created an entry page with module front that has two links. To categoryA and categoryB. Now I want these two categories to have different front pages with different themes.

Any ideas on how I can achieve that?


texts:
short version:

how can I add multiple items to a cart from a served string that provides the product ids and their quantities? I suppose a rule could handle this somehow?

long explanation:

hey guys,

I'm trying to make some bigger changes to the add-to-cart form and the way it functions, for my client and I have specific needs here.
Usually the form only let's you add one type of product variation at a time, but I want visitors to be able to set multiple product variations of the same product node, and the 'Submit' button submits all of them, instead of just the currently selected variation.

To put this into perspective: Let's say I have a product (display node) called

Brick

This Brick holds three variations:

Brick (Front) , Brick (Side) , Brick (Top)

Using a Custom Line Item, it gets these options added automatically (taxonomy term list reference):

Red , Green , Blue

Here, we want users to be able to (for example) click Side and select Green, then hit Front and choose Red, and when they hit Submit, both of these get added to their cart. By default however, of course only one - the last selection - is added.

Now, using a hook_form_commerce_cart_add_to_cart_form_alter() and custom JavaScript, I've gotten to a point where my JS automatically stores the entire selection inside a JS Object. But from hereon, I'll need your help guys.

I can easily print the JS Object into the DOM as a string with a format such as VariationID:LineItemOption:Quantity[_repeat].
For example the string could read 31:2:1_32:3:1 (which for humans would read Side:Green:1, Front:Red:1).

From hereon, though, I dont really know how to progress. My idea would be to perhaps create a custom rule that (replacing the action of the default Submit button) receives that string, filters it and adds matching items to the cart.

Really hope someone here has an idea on how I could progress. Any suggestion and recommendation would be highly appreciated!


texts:
I have a page with a table of nodes each one with it's own submit button. When pressed the button should call a custom ajax function which creates a cookie with the corresponding orm ID as its value.

My code:

function custom_cart_form_alter(&$form,&$form_state,$form_id){
    if ((stristr($form['#form_id'], 'uc_product_add_to_cart_form')) != FALSE){
        $form['#submit'][] = 'set_custom_cookie';
    }

    return $form;
}

function set_custom_cookie($form, &$form_state){
    user_cookie_save(array($form['#form_id'] => TRUE));
}

However, when the set_custom_cookie() function is called it receives the last value of $form['#form_id'] and not the ID of the corresponding form.

To clear things up: if I add the following at the end of hook_form_alter() :

function custom_cart_form_alter(&$form,&$form_state,$form_id){
    if ((stristr($form['#form_id'], 'uc_product_add_to_cart_form')) != FALSE){
        $form['#submit'][] = 'set_custom_cookie';
    }

    $form['#form_id'] = "test123";  //Added this line to demonstrate the issue
    return $form;
}

then function set_custom_cookie() will receive "test123" on call as the value of $form['#form_id'].

How can I make set_custom_cookie() receive the corresponding form ID?

I'm using Drupal 7.


texts: How to select specific entities from a view made as an REST export

texts:
I have made a REST export from a view, which is fine when I set it up to SHOW "FIELDS", which I select and define myself.

My issue is if I set it up to show: "ENTITY", then I get a HUGE result set which loads very slow.

Is there a way where it is possible to also select/define the specific entities you are interested to use in the result set, instead of everything? Pretty much just like when the SHOW option is set to FIELDS?


texts: How to sort null field values in Drupal?

texts:
I have a content type with one field of type text.

I add content for 5 nodes.

For 2 nodes among 5, I entered nothing in text-field.

So scenario is 3 nodes have data in that field and 2 of the nodes are empty.

Now I'm sorting on behalf of that particular text-field in my custom module and the result is:

It hides node with empty content.

It means only 3 nodes are visible, empty values are not visible.

Expected result should be, the fields that don't have any value inside should also get sorted and the resulting nodes would be seen either at the top of all sort-able content or below it.

How can I achieve this?


texts: call javascript function after ajax form submit

texts: How do I call a javascript function after a successful ajax form submit?  I want to call a function in a file that I added with drupal_add_js() in my_form_name_form($form, &$form_state).


texts: Webforms - '[+] Add more fields' (up to 5) button to file upload form control

texts:
I managed to add fields to submit attachments in a webform.
Now all I need is to restyle them to only allow one upload per charge plus a 'add more button'. I need to restyle the 1 into 2.

How can this easily achieved?


texts: Loading a large node body sequentially for better performance

texts:
I have a few very large nodes on my Drupal 7 site. In some cases the body field contains about 2MB of raw HTML (about 250,000 words). Despite the site performing well as a whole, the sheer size of these nodes causes a complete page render to take about 20 seconds, both due to the amount of content being downloaded and the time it takes the browser to render that much HTML.

The only way I can see to improve performance on these nodes is to load the node body sequentially in small bits, fetching bits of HTML as the user scrolls down the page. Is something like that even possible when all the data is contained in one row in the database? Perhaps this is more of MySQL question, but I'm curious if anyone has encountered this before or has alternate solutions to this problem.