texts: Using variable_get() still returning a form with the default value?

texts:
So, I have a form with a default value 'You have not enabled TFA' that is editable for the user. This works, and user input is recorded in the database, but when the form is returned it shows the default value again, and I think it would be better to return the form with the inputted values.

Here is my admin.inc file:

function my_module_admin_settings_form($form, $form_state, $nid = 0){
  $form = array();
  $form['subject'] = array(
    '#title' => t('Subject Line'),
    '#descirption' => t('Default email subject line.'),
    '#type' => 'textfield',
    '#size' => '50',
    '#required' => TRUE,
    '#default_value' => variable_get('subject', 'You have not enabled TFA'),
  );

...

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

  return $form;
}

Here is the code for variable_get function (for reference):

function variable_get($name, $default = NULL) {
  global $conf;

  return isset($conf[$name]) ? $conf[$name] : $default;
}

Can anybody see what is going on?


texts:
I'm trying to construct a shipping module for UK's Royal Mail (or at least the parts I need right now...!).  I've written PHP code for calculating what methods are applicable based on shipping address and weight, but plumbing this logic into my site is eluding me.  I should add that, as Royal Mail doesn't have an API for pricing, my module bundles the rate-tables for the various methods/services (CSV format) so I need to use code, not Rules, to implement it.

It seems the way to do this is to use the hook_commerce_shipping_* hooks, but it doesn't appear that I'm doing so correctly.

This is my first experience with using hooks (and Drupal on a serious dev level, TBH) but I have successfully implemented hook_commerce_cart_product_prepare() in another custom module, so I think what I'm doing should be working.  In my module I wrote the following, just to test that I'd successfully implemented the hook:

/**
 * Implements hook_commerce_shipping_calculate_rate()
 */
function royalmail_commerce_shipping_calculate_rate($line_item) {
    drupal_set_message(print_r($line_item, TRUE),'error');
}

...and it seems I hadn't, because the message never appeared when I progressed to the shipping pane of the checkout.

I also tried various other "canaries" I should be able to spot evidence of, including but not limited to drupal_exit(), echo, die(), var_dump() and so on, but nothing appears.  Same story for hook_commerce_shipping_collect_rates(), which I actually tried to implement first but ended up doing so with Rules instead while I was scratching my head (though I'd prefer this be in native code too, ideally).

Am I doing it wrong? Thanks in advance.


texts: hook_entity_presave showing error in commerce kickstart

texts:
I have created a field calculated price in commerce add product, the code used to save calculated price on saving product.
function custom_module_entity_presave($product, $type) {
  if ($type == 'commerce_product') {

$cal=commerce_product_calculate_sell_price($product);
$currency_code=$cal['currency_code'];
$amount=$cal['amount'];
$total_amount = commerce_currency_format($amount, $currency_code);

$product->field_calculated_price['und'][0]['value']=$total_amount;
//commerce_product_save($product);

}
}
But this code showing error on saving product


texts: Annoying general behavior: the width of the text-input-fields, when editing a node, can be up to 2X your screen's width / decentered

texts:
I was just wondering whether anyone else is annoyed by the curious & sporadic behavior of Drupal of making the widths of the text-input-fields very large, when starting to edit a node.

The widths of the text-input-fields (by default: "Body" & "Summary") get as much as 2 times the width of my computer screen.

Would anyone know how to get under the hood, to try and come up with a fix?

I am also not sure about the origin of the behavior, which sometimes does show up; and at other times don't.

Thanks.


texts: What is the best way to show category by image?

texts:
I have a online store with commerce module .
I have a category/taxonomylike this :

Writing Product

pen
pencil

Art Product

paper
something

All i want is to show writing product sub category in a page with image.
i've added image field to taxonomy and create a views from taxonomy .

How can i get sub category (image field) from views ?
Thx


texts: how to create a sub menu accordian using api

texts: I'm trying to develop an accordian sub menu, See image below. I've tried using the menu block module but i've found it a litte tricky to format. I'm wondering how can get an array of menu items base on a parent. So, say the submenu below were all children of /aboutus/ how would the php look? I'm using drupal 7


texts: Why I'm not able to delete all taxonomy terms tree?

texts:
I'm using custom drush command for flushing my custom vocabulary:

    function drush_mm_category_delete_all() {
  $vocab = \Drupal\taxonomy\Entity\Vocabulary::load('mm_vocab');

  if (! $vocab) {
    throw new Exception("Missing 'mm_vocab' vocabulary");
  }

  $tree = \Drupal::service('entity_type.manager')
    ->getStorage("taxonomy_term")
    ->loadTree('mm_vocab', 0, NULL, FALSE);

  drush_print('Amount of terms to delete: ' . count($tree));
  $counter = 0;

  foreach($tree as $term) {
    $term_entity = \Drupal\taxonomy\Entity\Term::load($term->tid);
    $term_entity->delete();
    $counter++;
  }

  drush_print('Amount of deleted terms: ' . $counter);

}

I'm getting error:

  Error: Call to a member function delete() on null

but WTF? I see that loadTree returns flat array of all vocab term. It seems that all items are object with tid property.

If I add:

if ($term_entity) {
  //delete here
}

I'm able to run command without error, but only small amount of terms are deleted. Why?


texts: How do I set a validation error on a component inside a composite component?

texts:
I have a webform with a composite component that allows multiple rows to be added. The structure is something like this, in case that makes it clearer:

webform
  sample_details - composite component which allows multiple 'rows', containing:
    sample_ref
    date_sampled (field I want to set the error on)

I followed 'method 2 - webform handler' on this guide. I'm able to do the validation itself and set an error on other components, but not on sub-components in the composite one.

This post addresses a similar problem, but the technique hasn't helped me.

I've tried

$form_state->setErrorByName( 'date_sampled', $this->t( 'must not have a sample date in the future.' ) );

and

$form_state->setErrorByName( 'sample_details][date_sampled]', $this->t( 'must not have a sample date in the future.' ) );

and a few other things but it seems like I'm missing something. It seems that setErrorByName can't work on sub-components because they don't have a standard #parents array? Is there a way of achieving this without having to switch to 'the old way'?


texts: How to send password expire notification to users regularly?

texts:
Working on Drupal 7, I want to get an alert every 3 months to users saying that:

  Password will expire in next 5 days, please change it.

I found a module called Password Expire (fulfill requirement but only in D6).

Is there any alternate of this module for Drupal 7?

(There is anothor module Force Password Change but this module do not send notification.)


texts: Adding a final review page to entityform, before submit

texts:
I have a complex entityform, where I'd like the user to see what has been entered on a final "review" page, before the data is written away.

As far as I can see the preview page, on entityforms, is shown AFTER the data is saved.

Can this be achieved?

So to be clear..

Step 1 : User enters data into form, and clicks "Review"

Step 2 : User sees all the data nicely presented, and clicks "Confirm", or "Edit"

Step 3: If Confirmed, data is written away, otherwise go to Step 1


texts:
I have some contents (organisms : a content type) to slide continuously... I already installed views slideshow 7.x-3.0 for another slider which has normal behavior.

Is it possible that I get my organisms rotate continuously like HTML marquee effect ?

with views slideshow or other modules ?


texts: Why did upgrading Drupal 6 cause a huge increase in database traffic?

texts:
Last week I inherited a several-year old messy implementation of a mid-sized Drupal site. Short version: 1 NFS/mysql server, 3 Apache servers. Everything was overloaded and crawling along. The first thing I did was add a memcached server to the mix which cut the network traffic to the mysql server a lot. Next I got the code all running on local file systems using VCS and only used the NFS mounts for the files directory. Again, network traffic went down.

The CMS was actually an extended install of Pressflow dated at v6.20. I had the bright idea to update this to 6.26, which I did using the Pressflow 6.26 package. Other than a few conflicts with other modules that had to be resolved, this went pretty smoothly. The site works fine.

However, looking at the interface stats on the mysql server, since the upgrade the ethernet traffic is about 100% more to handle the same site load. It's been three days now and the pattern is the same. The network traffic hugely increased corresponding to the upgrade to 6.26. The metric I'm using here is bytes transferred in and out of the DB server. Unfortunately I don't have stats about number of queries run.

What changed between 6.20 and 6.26 that would cause this and is there anything I can do to mitigate it?


texts: Advanced forum - Customize comment links alone

texts:
I am using advanced forum module. I want to customize the link in comments like reply, edit, delete.

I know I can use theme_links function, but it is affecting all places where $content['links'] is used.

I also used something like function mytheme_links__comment__node_forum($variables) but is not working too.

Any suggestion on how I can customize the html for link generated under forum comments alone?


texts: Cannot get any tweets using Twitter Block

texts: I have installed the twitter block module but I only occasionally get any tweets - if I do they disappear when the screen is refreshed.  I have tried all browsers and it is the same everywhere!


texts: When a path is associated to more routes, which route is used?

texts:
How does Drupal 8 decide which route to use, if there are two routes defined in Drupal 8 via routing.yml that lead to the same path?

Of course this sounds like a stupid idea or like a mistake in code to have two routes with same path. But I think about having one route with a parameter and a second route without parameter but with a path that the first route might deliver.

So for example there is node.add route in node.routing.yml

node.add:
  path: '/node/add/{node_type}'
  defaults:
    _controller: '\Drupal\node\Controller\NodeController::add'
    _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
  requirements:
    _node_add_access: 'node:{node_type}'
  options:
    _node_operation_route: TRUE
    parameters:
      node_type:
        with_config_overrides: TRUE

Now I am defining a route myexamle.nodeadd in myexample.routing.yml like this

myexample.nodeadd:
  path: '/node/add/examplecontenttype'
  defaults:
    _controller: '\Drupal\node\Controller\NodeController::add'
    _title_callback: '\Drupal\node\Controller\NodeController::addPageTitle'
    node_type: 'examplecontenttype'
  requirements:
    _node_add_access: 'node:examplecontenttype'
    _permission: 'access administration pages'
  options:
    _node_operation_route: TRUE
    parameters:
      node_type:
        with_config_overrides: TRUE

I added an additional _requirement in the second route. This is working for me like this, but I actually did not get how Drupal decides which of the two routes to actually use.


texts: Simple: How do I add data into custom field while creating new user with user_save

texts:
With each user I create when my form is submitted, I want to insert an id into a field/column I've added to the users table. Trouble is, the column isn't receiving the value. I've tried a few variations of user_save() to coax it into inserting the value, but at this point I think I'm missing something fundamental of drupal 7.  Later I also need to retrieve this value from the current user.

I'd appreciate any help. Thanks.

<?php
//Func called in form submit. Values passed from there
function fsa_create_sponsor_admin($sponsor_id, $a_fname, $a_lname, $a_email){

//Misc. code. . . .

//create a new user
$account = new stdClass();
$account->is_new = TRUE;
$account->name = $user_name;
$account->mail = $a_email;
$account->init = $a_email;
//$account->sponsor_id = $sponsor_id; (no error, but not working here)
$account->status = TRUE;
$account->roles = $new_user_roles;
$account->timezone = variable_get('date_default_timezone', '');

//First variation of user_save()
user_save($account, array('pass' => $sp_password, 'sponsor_id' => $sponsor_id));

//Second variation of user_save()
user_save($account, array('pass' => $sp_password, 'field_other' => array(LANGUAGE_NONE => array(array('sponsor_id' => $sponsor_id)))/*end 2nd array*/));
}
?>

Column added in hook_install()

db_add_field('users', 'sponsor_id', array('type' => 'int', 'size' => 'big', 'not null' => FALSE, 'description' => 'Sponsor to which user belongs',));


texts:
I am trying to create a gallery like this.

It's been a while since I worked on a D6 site I am sure I have done this before on a few 2/3 year old websites.

However, when I try configuring Views to generate my image gallery I don't get a slideshow style option. I have attached an image to show the View configuration area to see what I mean.

Can anyone help me with this, please?


texts: PDOException when populating file field programaticalily?

texts:
I'm creating a drupal commerce product programatically and trying to populate it with a file using the following code:

$new_product = commerce_product_new($product_type);

$new_product->created = $new_product->changed = time();

$new_product->field_pdf[LANGUAGE_NONE][0] = $extras['file'];

commerce_product_save($new_product);

This is the value of $extras['file'];

Keys: fid, uri, filename, filemime, uid, status, timestamp, filesize Values: 135, public://pdfs/test2_106.pdf, test2.pdf, application/pdf, 0, 1, 1356742160, 3908

My problem is I get this error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'field_pdf_display' cannot be null: INSERT INTO {field_data_field_pdf} (entity_type, entity_id, revision_id, bundle, delta, language, field_pdf_fid, field_pdf_display, field_pdf_description) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => commerce_product [:db_insert_placeholder_1] => 113 [:db_insert_placeholder_2] => 115 [:db_insert_placeholder_3] => policy [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 128 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => ) in field_sql_storage_field_storage_write() (line 448 of /var/www/clients/client1/web10/web/modules/field/modules/field_sql_storage/field_sql_storage.module).

I have absolutely no idea what the problem might be. Can anyone point me in the right direction?


texts: display custom order fields in a checkout pane of drupal commerce

texts:
I have added a custom field in orders and I can view and edit. I want to display this custom field in checkout panes, so users can fill them. but by default there is no relation between fields that we can add to checkout panes and the fields that we add to orders.

How can I display fields that I add to orders in the checkout form?


texts: How To organize Taxonomy Vocabulary with overlapping terms - Content Display pages and future proofing

texts:
I am trying to get a handle on Taxonomy Vocabularies and when to have a separate vocabulary vs when to have multiple fields feed into one vocabulary. How this relates to term pages and Views pages and diplaying content in general.

I have 4 fields:

Artist Name
Song Writing Credit
Song Performance Credit
Song Composer Credit

Most of the time the 'Artist Name' is the same as the 'Song Performance Credit' and most of the time there's a different composer and writing credit.

I have 2 options when creating Vocabularies:

have all fields feed to one Vocabulary called "Artist Name"
have a different Vocabulary for each field

The reason for option 1 is being able to display all content the artist is related to in a View. example: Artist Joe Blow performed on song 6 of an album. It's not his album but if a customer loves him they should be able to go to his artist page and see that album displayed. Therefore any time his taxonomy term is used on a performance credit or written by credit or composer credit it will be associated with that same taxonomy term and therefore be connected to that artist.

The reason for option 2 is if I want to display a list of all composers on the site, or all song writers or all performers. If i bundle everything into one vocabulary, then a taxonomy page for "Artists" will show all taxonomies in that vocabulary including the composers, performers and writers. So keeping each field associated with a unique Vocabulary will allow for this separation. However then Joe Blow might be in various vocabularies and not necessarily linked to his artist page.

On an artist display page I would like to show a list of all Albums he/she is associated with including their own album but also albums they are featured on. This leads me to believe I should have only one taxonomy term of their name in the system therefore only one Vocabulary where all artist names live.

Questions

what's the best practice with taxonomy and at what point is it good to have different Vocabularies for each field vs one Vocabulary that multiple fields feed into
How are they suppose to be entered and organized for future relational connections?


texts: Can't resolve "entity_name needs to be installed" on custom entity

texts:
I'm working on creating a custom config entity and I'm pretty confused. I created it via Drupal CLI, configured some fields, adjusted the schema.yml file, and everything is working.

I read that I need an update hook with \Drupal::entityDefinitionUpdateManager()->installEntityType. I'm now seeing the mismatched entity definitions error but after I run drush entity:update these errors do not go away and it still lists says that my entity type needs to be installed.

\Drupal::entityDefinitionUpdateManager()->installEntityType(new ConfigEntityType([
    'id' => 'my_custom_entity',
    'label' => new TranslatableMarkup('My Custom Entity'),
    'config_prefix' => 'prefix',
    'admin_permission' => 'permission string',
    'label_callback' => 'getLabelFromPlugin',
    'entity_keys' => [
      'id' => 'id',
      'label' => 'label',
      'uuid' => 'uuid'
    ],
    'config_export' => [
      'id',
      'label',
      'uuid',
      'field1',
      'field2',
    ],
  ]));

I'm a bit confused since I can already do everything with this entity (create, delete, etc) and export config related to it. Is running installEntityType() necessary? If so, what am I doing wrong since it continues to list my entity as needing to be installed?


texts: Modify price components from Commerce Shipping without altering the module itself

texts:
I use Drupal Commerce with Commerce Shipping and Commerce Flat Rate.

I have a client who wants the shipping line item in the commerce summary cart to come before the tax line item. My problem lies in that Commerce Shipping doesn't expose the weight of each shipping service when it implements the hook_commerce_price_component_type_info as seen below.

I have tried to use the mentioned hook in one of my own modules and with a lower value for the weight. This produces an error in the Commerce Price module where it tries to do the addition array(20, -50) + 1. Somehow, the Commerce Price module creates an array of the values instead of overwriting.

The weight I'm trying to overwrite is the one in the foreach loop.

Once I have solved this, I'll need to subtract the tax component on the shipping line item, but that's another problem which I can probably figure out by myself.

Line 110 to 135 in commerce_shipping.module.

/**
 * Implements hook_commerce_price_component_type_info().
 */
function commerce_shipping_commerce_price_component_type_info() {
  $components = array();

  // Define a generic shipping price component type.
  $components['shipping'] = array(
    'title' => t('Shipping'),
    'weight' => 20,
  );

  // Add a price component type for each shipping service that specifies it.
  foreach (commerce_shipping_services() as $name => $shipping_service) {
    if ($shipping_service['price_component'] && empty($components[$shipping_service['price_component']])) {
      $components[$shipping_service['price_component']] = array(
        'title' => $shipping_service['title'],
        'display_title' => $shipping_service['display_title'],
        'shipping_service' => $name,
        'weight' => 20,
      );
    }
  }

  return $components;
}

PS. Tax rate on shipping price is not the same as my problem. DS.


texts: Using the Drupal 7's Block "description" field as a CSS class field

texts:
I need to add a css class to my blocks and I know I can install a module, but i rather not as it doesnt work with features. I was thinking of just using the block config's description field to hold my css classes and just output it in my block.tpl.php file or should i do a preprocess thing?

Now the question is what is the variable to output the block's "description"?


texts: How to print custom text on search no result with search-results.tpl.php?

texts:
I want to print custom text if there is no result on search.

I'm using custom search-result.tpl.php and search-results.tpl.php.

My search-results.tpl.php is that:

     <?php if ($search_results): ?>

<?php print t($search_totals);?>

        <table class="views-table cols-4 search-results <?php print $module; ?>-results table table-striped">
.../* my results style here */

            <?php print $search_results; ?>

      <?php print $pager; ?>

    <?php else : ?>

<?php print t('Your search yielded no results');?>

      <?php print search_help('search#noresults', drupal_help_arg()); ?>
    <?php endif; ?>

It works correctly if there are search results but if there is no result it doesn't print anything although there is the <?php else : ?> part.

How can I print custom text if there is no result?


texts: How do you find out which module is causing a redirect?

texts: I have a Drupal 7 site and have a bunch of custom modules installed. Currently when I hit a specific node/9283 it gets redirected to another page. I'm not sure which module is causing this redirect. I also check URL Alias and nothing is there for redirection. Its definitely something custom. How would you go about debugging this and figuring out which module/code/function is being loaded on this redirect to another page on the same site?


texts: Change the wording of the registration page

texts: I want to change the wording of the default registration page.  I found some posts about completely customizing/re-theming the page but they seemed like total overkill for what I had in mind.  Specifically, this is designed to be a website for only students that go to my school, so I have already set it up so that you can only register with @myschool.edu email address.  But I can't figure out how to let people know that on the registration page.  I am surprised you can't edit the registration page through the configuration module at all.


texts: BaseFieldDefinition setDisplayOptions ... type = 'string_textfield' ... unable to set default placeholder or size?

texts:
I'm unable to get a default placeholder and/or size to register against a BaseFieldDefinition. I'm trying something like:

$fields['company_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Company Name'))
      ->setDescription(t('What\'s your company called?'))
      ->setDefaultValue('')
      ->setDisplayOptions('form', [
        'type' => 'string_textfield',
        'settings' => [
          'display_label' => TRUE,
          'size' => 10,
          'placeholder' => '',
        ],
        'weight' => '9',
      ])
      ->setDisplayConfigurable('form', TRUE);

But when I enable my module, and check the 'Manage Form Display' tab for the relevant entity, it shows the defaults (size = 60, placeholder = {null}).

Does anyone know how to get these working..? Especially the placeholder one.


texts:
Is there any module or plugin in Drupal that automatically creates Bookmarks for the PDFs. I made a Google and could not turn up with any related module. The print module does prints contents in PDF format, but what i need is a module that generated bookmarks in the PDF.

Thanks


texts:
I am studying how to create a custom module in Drupal7, so far I have created a simple module that will accept subscribers by registering.

These are the fields I have for my database, and has finished the function that will accept user input.

Table: simple_subscribe

sid , firstname, lastname, email

I then proceeded to create the function that will display all of the subscribers
so far this is what I got

function subscription_view_form() {
  $result = db_query("SELECT * from subscribe");

  $record = $result->fetchAll();
  echo '<pre>';
  print_r($record);
  echo '</pre>';
}

I am using print_r($record); to display the information, but all it displays is the objects on top of the website, before the navigation

Array
(
    [0] => stdClass Object
        (
            [sid] => 1
            [firstname] => John
            [lastname] => Doe
            [email] => johndoe@gmale.com
        )

    [1] => stdClass Object
        (
            [sid] => 2
            [firstname] => Test
            [lastname] => Beta
            [email] => betatester@delta.com
        )

)

edit

I am using the hook_menu() to display a form on /subscriptions but I can't output the subscribers inside the content area, I also wanted to list it in a table, I only did the print_r($records) to test if it is fetching the data. I wanted to know how to output it properly inside the content area not above it?

function subscription_menu() {
  $items[ 'subscriptions' ] = array(
    'title' => 'View the Subscribers',
    'description' => 'Subscription form available for subscribers',
    'page callback' => 'drupal_get_form',
    'page arguments' => array( 'subscription_view_form' ),
    'access arguments' => array( 'access content' ),
    'file' => 'subscription.pages.inc'
  );

  return $items;


texts: What css framework is better between 960gs and Blueprint?

texts:
For a new project what is better for drupal between Blueprint and 960gs?
I usually prefer 960gs, but for you?


texts: Populating the $variables['classes-array'] in preprocess_html function

texts:
It seems most likely that the following code is not working due to bad php but I just can't understand why. If I var_dump $variables['classes'] it returns that it is an array with the classes listed in it beautifully.

I debugged the $item and returns very nicely what I want as well. Then why don't these things get added to my $variables['classes-array'];?

    <?php

function mytheme_preprocess_html(&$variables) {
    dsm($variables);
    $path = url($_GET['q']);
    dsm(var_dump($variables['classes_array']));
    $path_items = explode('/', $path);
    foreach ($path_items as $item) {
        array_push($variables['classes_array'], $item);
    }
}

also tried array_push($variables['classes_array'][], $item);


texts: Problem with adding contextual link with option in yml file

texts:
In a custom module, I want to add a contextual link for all nodes, using the mymodule.links.contextual.yml file.

It works well with a route without options:

mymodule.test:
  route_name: entity.node.edit_form
  group: node
  title: Test

but I can't make it work with:

mymodule.test2:
  route_name: node.add:article
  group: node
  title: Test2

I tried a lot of different possibilities without success. Does anyone has an idea of what could be missing?


texts: How can I resolve "Could not rename the file cache/normal/www.example.com/_.html on your system" error?

texts:
I have enabled boost module as well clean url's also I got below error at admin/reports/dblog section:

  Could not rename the file cache/normal/www.example.com/_.html on your system (It comes sometimes.).

  The file permissions could not be set on cache/normal/www.example.com/test_.html.

I have set permissions for cache folder is 755.


texts: Change the Views exposed filter from link to select list depending on device size

texts:
I have a design that requires a select list for the exposed filter when on mobile/tablet and a link for the desktop version.

I am using better exposed filters for this.

My only idea would be to create 2 separate views, and hide/show them accordingly, however this doesn't seem ideal.

Is there any better solution for this?


texts: How to Add Block with Page on the same view?

texts:
Initially, I have displayed the contents in the Block on View. Now I am trying to display Taxonomy Term in the Page ,with Block on the same view.

There is a ADD button in the View, if I add the page for Taxonomy Term in that view, It's showing the same content information for the Page.

How do I add Taxonomy Term for Page and Content for Block on the same View.

Please anyone help me how to sort out this problem.


texts:
In a D6 site, when a user goes to node/add/forum, they find that the dropdown "Forums" just shows "Please choose" but there is nothing in that menu.

There is nothing in the PHP error log or in the watchdog.

I am sure the user has correct privileges - after all, the form does show. It's just that the dropdown that otherwise (for admin) shows all the different forums on the site, is empty, and the form cannot be submitted without it.

I've seen pretty much all the web searching for a solution, without success. Hope there's somebody in this new slick interface who will show me the right answer or direction.


texts: Issue with module's hook_uninstall (not uninstalling db entries)

texts:
I have a custom Drupal 6 module (based on this issue) that puts some custom date and time formats into the date_format_types table and then can be accessed from /admin/settings/date-time/formats.  This works nicely but I'd like to remove these from that table if the module gets uninstalled.

In my module's .install file, I tried this code:

<?php

/**
 * Implementation of hook_uninstall().
 */
function eventdates_custom_uninstall() {
  db_query("DELETE FROM {date_format_types} WHERE type LIKE 'eventdates_custom_date_%'");
}

This does not seem to work and the entries that had been added do not get removed from the date_format_types table when I uninstall the module but I am pretty sure I have the query correct.


texts: How to save commerce price field programatically?

texts: How to save commerce price field programatically in Drupal 8?


texts: Pass variables to template using hook_block_view_alter()

texts:
I'm trying the change the homepage path based on the current request. The system_main_block block renders the logo which is linked to the homepage. If the current path starts with /foo/..., I want to change the homepage path to point to /foo instead of the default /.

I want to pass a custom variable to a block using hook_block_view_alter().

The hook gives me the build array and the Block itself as arguments.

How can I add a variable to the build array that I can then access in the view (twig template)?

The build array looks like this:

array
    '#theme' => string 'block'
    '#attributes' =>
        array (size=0)
        empty
    '#contextual_links' =>
        ...
    '#weight' => int -3
    '#configuration' =>
        array (size=4)
            'id' => string 'system_main_block' (length=17)
            'label' => string 'Main page content' (length=17)
            'provider' => string 'system' (length=6)
            'label_display' => string '0' (length=1)
    '#plugin_id' => string 'system_main_block' (length=17)
    '#base_plugin_id' => string 'system_main_block' (length=17)
    '#derivative_plugin_id' => null
    '#id' => string 'my_id' (length=19)
    '#pre_render' =>
        array (size=1)
            0 => string 'Drupal\block\BlockViewBuilder::preRender' (length=40)
    '#block' =>
        object(Drupal\block\Entity\Block)[3592]

I can't see where I can assign an extra variable. Am using the wrong hook?


texts:
I want to allow my users to print a pdf with the nodes they want.
I thought to create a view and use the Print module to generate the pdf, but I don't know how to let them choose the nodes.
I tried with Panels, but it's a bit complicated for standard user.
I thought to use some cck field to manage this, but since the custom page is per user, this is not possible.
Did anybody face the same problem?


texts: Display a field of one content type based on another selected value

texts:
Screen Preview

I am using DRUPAL 7. I have created  custom content types credit card detail. When adding a new card I want to select the country first and based on that loads related banks in the second drop down. I need help to resolve this issue.Thanks.

Note: country list is loading from countries module, where banks from a db table.


texts: Unlimited values field - how to hide extra field on node edit

texts:
When creating a new node, I have this unlimited values field with the "Add new item" button.

That's OK, wonderful.
But when I edit an existing node, I get an UNDESIRED empty extra value added for me:

My real case is with a big compound field, but I thought using this small field as an example would be easier to understand.

I there any way to prevent this "extra" field from being intrusively added?


texts:
I am trying to upgrade my server from PHP 5.3 to 5.4. When accessing the Content Type export form in CCK with D6 the form does not display.

This issue is on first display of the form, not just on submit (as I have seen other questions online).

Here is the bad form.

Here is the correct form (on PHP 5.3).

I don't have any errors being thrown to the error_log or watchdog, and I am using Pressflow 6.26.


texts:
I am trying to figure out how to use this module.

I've downloaded it, installed it, etc. However, when I try to set up a webform, I'm not seeing anywhere where I can upload files and redirect to a link programmatically.

Where do I set this up?

I found this online, but I don't see "protected" anywhere.

  Configurations on my site:

  Installed the modules (Webform Protected Downloads, Private Upload)
  Changed 'Default Upload Privacy Setting:' to 'Public' under 'admin/settings/private_upload'
  Created a Webform > attached a file
  Under 'File attachments' selected 'Public'
  Enabled 'Protected' under 'Protected Downloads'.
  Enabled 'view uploaded files' permission for anonymous users under 'admin/user/permissions'


texts:
I want to make a search field for a form that automatically refreshes the form as you type with the answers that match the filter, like google does it.

I looked at https://api.drupal.org/api/drupal/includes!ajax.inc/group/ajax/7 and the examples module for the ajax related stuff but I can't find all the possible ajax events listed. The only ones I know of are blur, keydown and keyup.

I thought keyup would do the trick but every time I type a letter in the textfield the ajax event will disable the textfield, only to let me type another letter after the ajax callback is finished. I can't use this.

I want something like the autocomplete Drupal incorporates, it doesn't block the textfield at every typed letter, but as far as I know the native autocomplete uses a combination of ajax events.

Can someone please give me an idea of how I can accomplish such a task?

Edit:
Just to be clear, I'm not looking to autocomplete suggestions, I know how to do that, I want to update a paged table of results with each letter typed.


texts: How can I increase my hit ratio in Memcache?

texts:
Memcache has been up and operational on my production site http://goniseko.com for a few months now.  After getting everything configured and memory limits where they should be, I noticed that I have a very consistent 70% / 30% hit to miss ratio.

How can I improve this?

Also, I noticed that this is pretty consistent across other Drupal 7 sites where I have memcache installed.

What is it about Drupal, Memcache, or a combination of the two that won't allow for this extra 30% to be stored in the cache bins? How can I figure out what these queries are, and what can I do to get them in the bins?

I am hoping this is similar to APC.  I have that configured so that I have a 100% hit rate for this site. I would like to have Memcache that high, or at least higher than 70%. That's almost 1 out of 3 queries that have to hit the db.


texts:
How do I add "|" to views pager when you are displaying numbers. See the example
below

previous   1 | 2 | 3   next


texts: Reload a node override pane from a view selection in another pane

texts:
I have some nodes tagged with taxonomy terms.
I have those nodes in a node page override provided by panels. It displays them as the main content.
I also have an exposed dropdown selection list filter of the terms  mentioned on line 1 above provided by a view.
In that same node page override from line 2 I have the view mentioned on line 3 in the sidebar.

What I'd like to have happen is when a user selects a different term from the dropdown list it reloads the new node in the main content area.


texts: Why kpr() shows different content than var_dump()?

texts:
In one vital part of code I started to get "Trying to get a property on a non-object" type of errors. So I wanted to investigate it.

var_dump($download);
die();

Gives:

array(3) {
  [1]=>
  array(5) {
    [5]=>
    object(stdClass)#156 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [8]=>
    object(stdClass)#185 (11) {
      ["idDownload"]=>
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
  [2]=>
  array(5) {
    [5]=>
    object(stdClass)#186 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
  [3]=>
  array(5) {
    [5]=>
    object(stdClass)#184 (11) {
      ["idDownload"]=>
      string(1) "5"
      ...
    }
    [6]=>
    object(stdClass)#155 (11) {
      ["idDownload"]=>
      string(1) "6"
      ...
    }
    [7]=>
    object(stdClass)#151 (11) {
      ["idDownload"]=>
      string(1) "7"
      ...
    }
    [8]=>
    object(stdClass)#185 (11) {
      ["idDownload"]=>
      string(1) "8"
      ...
    }
    [10]=>
    object(stdClass)#177 (11) {
      ["idDownload"]=>
      string(2) "10"
      ...
    }
  }
}

But if I'll switch to kpr() like this:

kpr($download);
//die();

I get this:

Why can it happen? And can how I get kpr() to work? using var_dump() in form debugging is not really an option.


texts: Does Commerce Physical Convert Imperial to Metric?

texts:
Developing a commerce for an international audience and would like to be able to show the sizes (dimenstions of the pieces) in both SI and Imperial. I was approaching this by simply having to Height and Width fields for both SI and Imperial, but wondered if this was the best approach. At least right now, I don't have to figure the dimensions into my pricing logic so I wanted to know if Commerce Physical had conversion capabilities that might let me clean up my layout a little bit? I can forsee using their logic as the site develops, but for now it's unnecessary. So, does Commerce Physical convert units? and or does anyone have advice on approaching this?
Thanks!


texts: Drupal not detecting updated Trusted Host Settings

texts:
I've installed Drupal 8 via Softaculous, and after I logged in for the first time, I see a message:

  TRUSTED HOST SETTINGS Not enabled The trusted_host_patterns setting is
  not configured in settings.php. This can lead to security
  vulnerabilities. It is highly recommended that you configure this. See
  Protecting against HTTP HOST Header attacks for more information.

I edit /drupal-install-dir/sites/default/settings.php and add:

$settings['trusted_host_patterns'] = [
  '^smith\.technology8\.com$',
];

in order to make smith.technology8.com a trusted site.

However, after upload of /drupal-install-dir/sites/default/settings.php and refreshing the admin page, the original error remains.

Is there something more I need to do, or is my addition to settings.php incorrect?

Thanks.


texts:
Drupal 7. I have a radio button set. When one of the items is selected I would like it to set the node add title to some string. This is as far as I got, but I get the error: "TypeError: '[object Object]' is not a function (evaluating '$("#edit-field-i-need-help-with-und-printer-ink")')"

(function ($) {
      Drupal.behaviors.cgps_helpdesk_misc = {
        attach: function (context, settings) {
          $("#edit-field-i-need-help-with-und-printer-ink").change(function ($) {
              if ($("#edit-field-i-need-help-with-und-printer-ink").attr("checked")) {
                alert('Handler for .change() called.');
                $('#edit-title').val($('#edit-title').val() + 'bla bla bla');
              }
          });
        }
      };
    }(jQuery));


texts: allow specific user to access specific pages in custom module

texts:
I have created a custom module with custom database table in drupal 8 site.
It has add, update, list and search pages.

I want to restrict as only admin or sub-admin can access the add, edit, list pages. Any user(non-registered also) can access the search page.

How to achieve this in the module i have developed itself in drupal 8? Or is there any common way in drupal 8 to add permission for a particular URL?


texts: Programmatically find out what fieldset a field belongs to, if any

texts: There doesn't seem to be a way to join the fieldset table in the database to a fields table, nor any function that can be used to get fieldset info by field name. Is there a way to get fieldset info starting from a single field's information (as well as bundle and such)?


texts: Using MYTHEME_page_attachment_alter does not alter the favicon

texts:
Based on other similar stackexchange questions and documentation, I've implemented the following in the MYTHEME_page_attachment_alter function in MYTHEME.theme file to change the favicon based on the url (inside a condition statement):

    foreach($page['#attached']['html_head_link'] as $k => $v) {
        if (array_key_exists('rel', $v[0]) && $v[0]['rel'] == 'shortcut icon') {
            unset($page['#attached']['html_head_link'][$k]);
            $page['#attached']['html_head_link'][$k] = array(
                array(
                  'rel' => 'shortcut icon',
                  'href' => '/themes/fu/favicon_urbana.png',
                    'type' => 'image/png',
                ),
            );
        }
    }

Using Kint::dump($page) confirms that the shortcut icon is indeed updated.  Why then will the tab for the page not show the updated favicon?  I've cleared the cache, ran drush cr multiple times, etc yet the page continues to show the theme's favicon.

Am I missing something?  Any advice would be greatly appreciated.

On a side note, we had this working successfully in Drupal 7 in MYTHEME_html_head_alter() and I am migrating this to Drupal 8.


texts:
I'm currently working on a French website. French formatting requires a space before question marks. For some of my titles, this results in the question mark appearing on a line by itself.

  Why does it do this

  ?

It looks like trash. How can I preserve the &nbsp; in the title to have the question mark on the same line?


texts: Wich template to override for user account form

texts:
I am building a theme for my Drupal 8 site and I want to create a custom profile page with user information like this: http://bootsnipp.com/snippets/featured/profile-card but I can't find the correct template to override where I can have access to all the information needed like username, name, picture and for example his address. Also I can't find where is the user-edit form to change the HTML so I can display it as I want.

I am new to Drupal 8 theming and that's why my question may look kind of no sense.
Thank you

EDIT (add more information)

So, I want to make my user's profile edit page to a two column layout where I can have the user base information like name and picture on left and on the right having the form to change the rest of the information like user and password.
What is the best way to achieve that?


texts:
I used hook_form_alter to add a required 'confirmation' checkbox to the node deletion form and the #required status is not honored.

The fields/fieldset are property displayed 'node-delete-confirmation' form.

Here is the hook_form_alter content:

$form['warning'] = array(
    '#type' => 'fieldset',
    '#title' => t('Warning! - You Must Check The Box Below To Continue'),
    '#weight' => -30,
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
);
$form['confirm_delete'] = array(
    '#title' => t('I fully understand that this action cannot be undone and that statistics linked to this item will be permanently removed.'),
    '#type' => 'checkbox',
    '#required' => TRUE,
    '#default_value' => 0,
);

How can I enforce the 'required' status so that nodes cannot be deleted until the confirmation is acknowledged.

If I change the code, to completely remove the added fieldset everything works as it should.

Works:

$form['warning']['confirm_delete'] = array(
'#title' => t('I fully understand that this action cannot be undone and that statistics linked to this item will be permanently removed.'),
'#type' => 'checkbox',
'#required' => TRUE,
'#default_value' => 0,

);


texts: AJAXX AutoComplete joins and unions causing error

texts:
I am a bit out of my depth here.

I have successfully implemented my own autocomplete field of an entityform, the following link was my roadmap Textfield that uses AutoComplete.

But I am trying to do something much more fancier. I need to search for a users name, and autocomplete it for the user. The issue I am having is that I must check multiple tables for the user to select from, tables like: field_data_field_first_name, field_data_field_othername, field_data_field_nickname, field_data_field_fullname.

Because some people's names have changed, or have a nickname.

So I have begun checking multiple tables and think I got a good start, but I keep getting the following error: "SQLSTATE[21000]: Cardinality violation: 1222 The used SELECT statements have a different number of columns"

I want to be able to incorporate this:

 SELECT fn.*, ln.* FROM field_data_field_first_name as fn
    left join field_data_field_last_name as ln ON fn.entity_id = ln.entity_id
    WHERE fn.field_first_name_value LIKE '%bun%'
UNION
SELECT fn.*, fo.* FROM field_data_field_first_name as fn
    left join field_data_field_other_name as fo ON fn.entity_id = fo.entity_id
    WHERE fn.field_first_name_value LIKE '%bun%'
UNION
SELECT ni.*, ln.* FROM field_data_field_nickname as ni
    left join field_data_field_last_name as ln on ni.entity_id = ln.entity_id
    WHERE ni.field_nickname_value LIKE '%bun%'
UNION
SELECT ni.*, fo.* FROM field_data_field_nickname as ni
    LEFT JOIN field_data_field_other_name as fo ON ni.entity_id = fo.entity_id
    WHERE ni.field_nickname_value LIKE '%bun%'

into Drupal 7 db_select. I have some of this query in my Drupal query (not all of it, for the moment) but I am getting the column discrepency error (1222), my column counts aren't matching. Can't I just grab every field, like I do in my MySQL string and call it a day? I thought fields('alias') would of solved this, since that is grabbing every column, but it doesn't seem to be doing the trick!
This is what I got now:

$secondQuery = db_select('field_data_field_first_name', 'f') ->fields('f')
      // check the first_name_value, but we want to do a leftJoin to show the left_name_value as well! like Larry, Adams, not just Larry
      ->condition('field_first_name_value', '%'. db_like($string) .'%', 'LIKE');
    $secondQuery->leftJoin('field_data_field_last_name', 'l', 'f.entity_id = l.entity_id');
    $secondQuery->fields('l');

  // Make the query
  $result = db_select('field_data_field_user_name', 'u')
      ->fields('u')
      ->condition('field_user_name_value', '%' . db_like($string) . '%', 'LIKE')
      ->union($secondQuery)
      ->execute();


texts: How can I know that node is created or updated?

texts:
I had configured Drupal 7. I'm going to run cron when a node is saved/updated/deleted. How  I know that node is changed?

Thanks.


texts: Why do I get PDOException SQLSTATE[42S22] Column not found 1054 Unknown column 'tn.tid' in 'on clause'"?

texts:
$rtid = arg(2);

$query = "SELECT node.nid AS nid FROM node
  WHERE (node.nid IN (
    SELECT tn.nid AS nid
    FROM taxonomy_index AS tn
    LEFT OUTER JOIN taxonomy_term_hierarchy AS th ON th.tid = tn.tid
    LEFT OUTER JOIN taxonomy_term_hierarchy AS th1 ON th.parent = th1.tid
    LEFT OUTER JOIN taxonomy_term_hierarchy AS th2 ON th1.parent = th2.tid
    WHERE (tn.tid = :rtid) OR (th1.tid = :rtid) OR (th2.tid = :rtid)
  ))
  AND (node.status = '1') AND (node.type IN ('product'))
  ORDER BY node_created DESC
  LIMIT 1 OFFSET 0";

$result = db_query($query, array(':rtid' => $rtid));

After I tried some times with the help of other users' answers, I got lost. This is the code I tried, but it gives me an error ("PDOException SQLSTATE[42S22] Column not found 1054 Unknown column 'tn.tid' in 'on clause'").

$query = db_select('node', 'n')
  ->condition('n.type', 'product')
  ->condition(
    db_or()
      ->condition('tn.tid',$rtid )
      ->condition('th1.tid',$rtid)
      ->condition('th2.tid',$rtid)
  )
  ->fields('n', array('nid'))
  ->extend('PagerDefault')
  ->limit(1);

$query->join('taxonomy_term_hierarchy', 'th', 'th.tid = tn.tid');
$query->join('taxonomy_term_hierarchy', 'th1', 'th.parent = th1.tid');
$query->join('taxonomy_term_hierarchy', 'th2', 'th1.parent = th2.tid');

$result = $query->execute();


texts:
Yesterday I found that one article from my website is indexed more than once in Google, and I discovered that the URLs are like like the following ones.

http://www.techiestuffs.com/gadgets/best-racing-games-available-android?page=1
http://www.techiestuffs.com/gadgets/best-racing-games-available-android?page=2
http://www.techiestuffs.com/gadgets/best-racing-games-available-android?page=3

The same node is generated many times.

The original link is http://www.techiestuffs.com/gadgets/best-racing-games-available-android.

This doesn't happen for just a node; all other nodes are also indexed more than once.

I am afraid Google will penalize us for this.

Do you know of any solution to avoid this?
For which reason does Google generate this type of URLs?


texts: Create a link to the fist item of a specific view block

texts:
I have different view blocks on my front page and they contain number of contents such as images, articles, news etc.

I've managed to get the block list and the block object for each item in that list but how do I fetch the nodes of a view block and generate a link to it programmatically?

$blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme->getname(), 'region' => 'content']);
$block_list = array_keys($blocks);

$firstblock = $block_list[0]; // views_block__latest_image_galleries_block_1
// fetch the node list and create the link for first node for $firstblock here.


texts:
I have a product with an attribute called ID. This ID is a reference to an image the user has uploaded, its filename is id.jpg.

In the cart table where it lists attributes it has "ID: 4" for example but can I throw an img tag in there with src '...4.jpg'?

I'm a fairly competent developer however I haven't done any module development. Thanks!


texts: Ctools modal_form not working with webforms

texts:
i have been trying all morning to get my webform to open up within ctools modal_forms popup window. i’ve tried everything, but nothing has worked so far.

the module is working no problem. this form window displays as expected.

mywebsite.com/modal_forms/nojs/register

and my webform is published and working

mywebsite.com/webform/free-trial

but when viewing docs and tuts on the module,  the URL would seem to be

mywebsite.com/modal_forms/nojs/webform_free-trial

i’ve also manually created links such as this

Modal Login

Modal Login

even went to the config page and set,

PAGE ACTIVATION SETTINGS/Only the listed pages

webform/free-trial

Mondo Aggro! any help would be greatly appreciated, thank you


texts: A way to export workflow states globally?

texts:
My workflow and states weren't migrated from D6 so I re create them by hand.
But I need to use them on another D8 website, and I don't find the way to globally export them, only state by state...boring thing.

So I'm looking for a globally way (not sure about what feature does) and/or a way to migrate entire workflow from my D6 website.

Thanks

EDIT: I found an example for D7 and trying to apply it to D6 but it's not fully functionnal.
My starting point is here (similar code expect some of missing DB fields in D6) and I done a module like this:

migrate_workflow
      |
      |-- \src\Plugin\migrate\source\WorkflowMigrate.php
      |-- \config\install\migrate_plus.migration.upgrade_d6_workflow.yml
      |-- migrate_workflow.info.yml

Activation of the module is good and it find my records in the workflow_node_history table of D6.

Once migration created, I run it and I get this error:

The "" entity type does not exist. (/var/www/drupal-8/core/lib/Drupal/Core/Entity/EntityTypeManager.php:133)                                                          [error]
Processed 30 items (0 created, 0 updated, 30 failed, 0 ignored) - done with 'workflow'                                                                                [status]
workflow Migration - 30 failed.

How can I fix this ?
Thanks


texts: How can I theme an image inside a field formatter

texts:
I'm trying to change the output of an image field so that I can display it using a Javascript image gallery. I have the basic field formatter set up, but I'm having trouble finding the correct place to override the theme that displays the <img> tag itself.

I'm overriding the viewElements function of the core ImageFormatter:

class ImageGalleryFormatter extends ImageFormatter {

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items) {
    $elements = parent::viewElements($items);
    foreach ($elements as &$element) {
      $element['#theme'] = 'imagegallery_format';
    }

    $elements['#attached']['library'][] = 'imagegallery_formatter/light-gallery';
    return $elements;
  }

}

There I can set my custom Twig theme for each element, but that theme only writes the stuff directly around the <img> tag, not the tag itself. The theme provides access to an {{ image }} variable that renders the actual image. I tried accessing the variables inside the image like {{ image.uri }}, but that didn't work. I know the information I need is in there as I dumped the image variable in Twig and can see the array, but I can't access it from here.

From the Twig debug output I know that 'core/themes/classy/templates/field/image.html.twig' is the theme I need to override, but I can't find a way to do that from my module. I read the source of the core ImageFormatter viewElements function, but I don't see the image variable there and don't understand how I can modify it.

How can I override the theme that renders the <img> tag of an image field in my field formatter?


texts: Is there a way to create a custom view for Google Store View Locator

texts: I'm planning on using Google Store Locator module for a custom content (lets call it datacenter) I'm creating, however I'd like to use the existing functionality plus  allow the users to filter through other properties of the datacenter?


texts: I want to add JS functions to the body tag's onload and onunload attributes with a custom module. The only hook I found was hook_onload() from Drupal 4.7, but this method has been deprecated. What is the Drupal 7 way of achieving this?


texts: Strange Behavior : Drupal 8 Views with Contextual Filter and Path Alias Together

texts:
I am testing out a views page on core 8.0.5.  The path is set at job/% and the contextual filter is Content: Node ID.  This page view only displays a few fields for testing purpose.  The preview works perfectly whenever I input a node number, e.g. 165, at the "Preview with contextual filters:" prompt.  The preview path shows job/165.  Strange behaviour happens as follows:

No path alias used:  everything works accordingly.  I click the preview path (job/165) and it shows up the page mysite.com/job/165 with the few selected fields.  I change the 165 to another number at the url, e.g. 168, and it works.  This is perfect.
Path alias used:  the alias pattern is job/[node:nid].  The preview also works fine.  However, when I click the preview path job/165, it brings me to the same page at mysite.com/job/165, but this time it shows the whole content instead of the few selected fields of the view page.  Obviously it is displaying the node content instead of my view page.  If I change the node number at the url, e.g. 168, it still shows the whole node content exactly like mysite.com/node/168.

I've been struggling with this for the whole week.  Did I do something wrong?


texts: Hide Uploaded Files in File Field in Node Edit Form

texts:
I have a custom content type, Contacts. Under contacts I have a custom File field, Contracts.

I want to hide the any file that have been uploaded under the File Field, Contracts in the node edit form. It should be view-able only by the admin.

I want to display the upload option in the field to all the users, however, not the files that have already been uploaded under the node.

Please advice

Thanks

The modified code:

MODULE NAME = Hide_Uploaded_Files.

CONTENT TYPE = Candidates.

CUSTOM fIELD = field_resume.

<?php
function Hide_Uploaded_Files_form_alter(&$form, &$form_state, $form_id) {
global $user;
if ($form_id === 'Candidates_node_form' && !in_array('administrator', $user-
>roles) && $form['field_resume']['und'][0]['#default_value']['fid'] > 0) {
$form['field_resume']['#access'] = FALSE;
}
}
?>


texts:
As well as the three standard roles for a D7 site, I have created a role for a lesser admin / content creator.  This role is essentially an administrator role with some of the juicy bits taken away.

I would like that users assigned this role can manage other users, but I need to restrict it so that they cannot assign or remove the administrator role, or edit an administrator's profile and account.  I can't see a way to do that on the standard installation, is there a module that could help me?

Edit:
I have looked into the userprotect module.  While it does prevent a lesser admin from editing an administrator, it does not prevent them from granting the administrator role on themselves.


texts: passing a user id to user_is_logged_in function

texts:
I want to use the user_is_logged_in function to determine if a user is logged in but i want to determine if that user is logged in from a cron job/ module.

Essentially i have an array of user id's that i want to loop through to see if the corresponding user is logged in and if so execute some code.

My question is how does one pass an integer to the function to get a true or false from the function? all examples i have seen use the function on a page where the user is viewing to show them content or send message to them. Nothing i can see shows how to use it from a script.

Hope this makes sense.

Madmilner


texts: Views 2 - How to show exposed filters when results list is empty?

texts:
I have a page that displays all events after the current date. It has an exposed filter where you can set the date - all events after that date will be shown. This all works fine.

However, if there are no results on the initial page load (i.e. no events listed that are after the current date) then the exposed filter isn't shown (so you can't set the date to some time in past and view past events).

I found the relevant view theme template and over-rode the If($exposed) conditional but this did not do it - obviously the decision to show filters or not is made before the template but I haver no idea where.

Please could somebody enlighten me?

Thanks


texts: Drupal core language module, language switcher block

texts:
Can a preprocess hook convert the default ul of hyperlinks into a drop-down select list? Something like this hook.

function THEME_preprocess_links__language_block(&$variables)


texts: How to restrict taxonomy term reference with certain terms?

texts: In a node edit/add form, I need to show a field with dropdown/select list options (Cardinality unlimited). I do not want all the taxonomy terms of that vocabulary to appear. I want to show certain terms. The vocabulary has 2 level hierarchy. First dropdown in the form element shows only parent terms. On selecting parent term from the dropdown, certain child elements should show in the second dropdown.


texts: Implementing a callback after user registration

texts:
I want to run a database query in another CRM database after a user has registered. I have the following function in my sugar_crm module eg:

function sugar_crm_user_register_submit($form, &$form_state)
{
    // some code to run a database query in SugarCRM
    ddl("User registration form submitted to CRM");

}

However, the function doesn't appear ever to be called. What am I doing wrong here?


texts: How to add the current title to the breadcrumb without preprocess function?

texts:
I'm trying to get the title into my breadcrumb path without using a preprocess function. Drupal 8 Add the current title to the breadcrumb shows how to do it with preprocess function which is not what I'm trying to do.

I want my output be like this:

Here is what have been trying and have not work yet.

breadcrumb.html.twig

{#
/**
 * @file
 * Theme override for a breadcrumb trail.
 *
 * Available variables:
 * - breadcrumb: Breadcrumb trail items.
 */
#}
{% if breadcrumb %}

{{ 'Breadcrumb'|t }}

{{ 'You are here:'|t }}
            {% for item in breadcrumb %}

                    {% if item.url %}

                        {{ item.text }}
                    {% else %}
                        {{ item.text }}
                    {% endif %}

                {{ '>'|t }} {{title}}
            {% endfor %}

{% endif %}

And this is what I'm getting:

For some reason the title is not been display when I use {{ title }}.

What am I doing wrong?

Why is my title not being displayed on my breadcrumb title?


texts:
I was asked to use the Hansel breadcrumbs module to derive the breadcrumbs in a site, but I hardly understood the flow of the module. I cannot get a clear picture even from the modules documentation. I would appreciate any help to clarify my doubts about this module.

I have removed a custom breadcrumb module, and installed the Hansel breadcrumbs module.
I want to create breadcrumbs in specific page like Home->Bussiness->Faq and so on.

How is this possible with the Hansel breadcrumbs module?


texts:
In Pro Drupal 7 Development: Third Edition, the authors suggest moving custom modules inside subfolders of /sites/all/modules/custom/, i.e.

/sites/all/modules/custom/mymodule1
/sites/all/modules/custom/mymodule2
/sites/all/modules/custom/mymodule3

Does this have any special meaning for Drupal core? For example, is this folder omitted when checking for new versions of modules? I haven't checked this so far so I'm just curious.

Before I read the book I put my custom modules like this:

/sites/all/modules/mymodule1
/sites/all/modules/mymodule2
/sites/all/modules/mymodule3


texts: How to display the value of a report parameter in a Forena Report and in a CSV export of it?

texts:
Using Forena Reports I'm wondering if it's possible to include in a report the PARAMETERS passed by the URL?

I'd just like to output those parameters once in the report; probably at the top. Something like this:

You selected 'item a, item b, and item c'. (where items a,b, and c are the parameters passed).

Extra question: When I run the sample report with state=VA and then click 'CSV', the CSV download will not say which parameters were selected. Anyway to have the CSV download also include the parameters (+ their values) that were specified?


texts: How do I add a super admin, either programmatically or directly through the database or another

texts:
$new_user = array(
  'name' => 'Sg',
  'mail' => 'sg@email.com',
  'pass' => 'password123',
  'status' => 1,
  'field_custom_first_name' => array(LANGUAGE_NONE => array(array('value' =>'S'))), // This becomes $account->field_custom_first_name[LANGUAGE_NONE][0]['value']
  'field_custom_last_name' => array(LANGUAGE_NONE => array(array('value' => 'Doe'))),
  'access' => REQUEST_TIME,
  'roles' => array(), // No other roles than Authenticated
 //'roles' => array('10' => '10', '11' => '11'), // If you want to specify additional roles, the numbers are role_id's
);
user_save(NULL, $new_user);

I've seen this above code but where should I implement this code? I tried adding it and I got the error:

  user_save() is an undefined function.

I just need to be able to login to the system as a super-admin.


texts: How can I import fields into Drupal 8.4 user profile from a csv file that has identical values in the key row?

texts:
I'm using Migrate Tools, Migrate Plus and Migrate Source CSV. My CSV file looks like that:

"Stg";"Color";"Fruit"
"user1";"red";"apple"
"user1";"blue";"pear"
"user2";"green";"banana"
"user2";"black";"rotten banana"

I'm using the Profile Module (https://www.drupal.org/project/profile)

I have a migration within my migration group that looks like this (migrate_plus.migration.user_vorlesungen.yml):

id: user_vorlesungen
langcode: de
status: true
dependencies:
    enforced:
        module:
            - user_migrate
migration_group: hoevwa
label: 'HoeVWA Vorlesungen Import'
source:
    plugin: csv
    track_changes: true
    path: /config/Vorlesungsverzeichnis.csv
    # Column delimiter. Comma (,) by default.
    delimiter: ';'
    # Field enclosure. Double quotation marks (") by default.
    enclosure: '"'
    header_row_count: 1
    keys:
        - Stg
destination:
    plugin: entity:profile
process:
    type:
        plugin: default_value
        default_value: 'vorlesungen'
    uid:
        plugin: migration_lookup
        no_stub: true
        # previous user migration
        migration: user__hoerer
        # property in the source data
        source: Stg
    # These field have multiple values in D8
    field_color: Color
    field_fruit: Fruit

migration_dependencies:
    required: {  }
    optional: {  }

In my YAML file the content is printed like that:

...

    {{ content.field_color }}
    {{ content.field_fruit }}

...

When I run drush mim --group=hoevwa only the last values of user1 (blue, pear) are imported. How can I get running a process plugin to loop through the CSV and get all values imported. And finally how can I loop through all values in my TWIG Template?


texts: How do I sort a date field in views without the time?

texts:
Drupal 7

I have a view that sorts on three fields so the ORDER BY statement looks like:
ORDER BY

node_status ASC,
field_data_field_date_field_date_value DESC, field_data_field_sort_order_field_sort_order_value ASC

I need the sort of the date field to not be granular to the time. I just want it sorted by the date so that the sort order field will take it from there. When I run the query against the database itself, I see that the date field returned is showing the full value like: 2016-06-19 08:48:12, but some of the values are different by a second, causing the "incorrect" (not the desired) sort order.

How can I get it to sort on the date field without the "full date" field?

EDIT:
(adding screen shot of view)


texts: Custom php to handle url based on taxanomy terms

texts:
Our site uses taxanomy to maintain a blog page. And for now we use views to render the contents. Now we are planning to get rid of views and use templates. What we need is to have custom tpl.php only for request containing vocabulary. So for any request to my site of a pattern path/*,

I need my custom tpl.php to be used only when the path is valid vocabulary.
Let the default flow get executed when the path is not a valid vocabulary.

What would be right way to handle this?


texts:
I have a problem using page manager and tabledrag to change order of my blocks. When I place more than 20+ blocks, tabledrag stop working, one block has set "null" value in weight field. When I place next block to my page manager and once again change order, then two blocks have "null" value. Everything works good when number of blocks is less than 20. I have not got any errors in my console.
My environment:

Drupal 8.3.7
Page Manager 8.x-4.0-beta2


texts: Is there way to export block layout settings?

texts:
I created a custom theme and I was wondering if there is way to export my block layout settings (location and order of each block). This way will be easier to apply my theme in a different site.

I'm using the Features module to keep on track of my custom blocks and block types.


texts: Is there a simple way to add user access on a page level?

texts:
I'm still getting used to the way Drupal works, most of what I have read on adding User Level Security on a Drupal site seems to be either View based or by using a Module like Panels.  I am creating a site that is rather simple in structure, with some high level pages that differentiate out the content to different areas.  I am using Superfish to generate a drop down menu system at the high level, and underneath I have some content areas that will either contain only a few pages or one specific area that will have many.  I am also using shortened URLs to make site structure easier to manage, although in general it comes across as flat.  I may be wrong in thinking in terms of pages, and if I need to reconsider that for the site that's ok, I have only been using Drupal for the past 6 months but its a good fit as a CMS for the site I am working on.

The requirement is only for three types of Users - Admin, Group Leaders, and Members.  I'd like to give Group Leaders some access to pages for editing permissions, although mostly only at a second level or specific pages.  Members will have some editing rights but only on a few pages.  Group Leaders and Members will have access to content in one specific area, where I will have many pages, no one else should be able to get in.  Content pages on Member activities will be accessible by only those who have a login, those not logged in should ideally not see the links or not be able to access the pages.

With Drupal 7, and using the Bartik theme and some modules (Chaos Tools, Display Suite and Superfish for now) what is the best mechanism to be able to grant permissions to view and access content on only specific pages in the structure I have?  The site is still new, so if I have to make changes I'd like to do so now before it gets too complex.

Update:
Just to note in addition what happened.  I was looking for some sort of access that was simple to add in and allow me control on an individual node.  Content Access module gave me this in a way I can teach my Users to utilize.  Sorry if it seems a duplicate, I was looking for more of a description on what the modules did than I had seen before.


texts: How to get a paragraph to display fields labelled as odd/even?

texts: I am using Drupal 8 and I want to get odd/even involved in a simple paragraph that has unlimited fields. Any clue what I am missing?


texts: What rule to use to redirect users, unless already redirected?

texts:
I'd like users with certain roles to be redirected to the page /civicrm when they login, unless they've already been redirected elsewhere. For example, an email might have a link that directs them to the page /elsewhere.

When I tried the module 'login destination' I can only achieve one or the other, never both - either the redirect works but a regular login doesn't redirect to /civicrm or the other way round.

From browsing in Drupal Answers, I'm pretty sure that Rules could do this, but I've tried and failed so far.  The rule needs 2 conditions to be satisfied - user is one of the roles, and they are not already being redirected - then they should be directed to /civicrm.

Can anyone please suggest how a rule might achieve this?


texts: Add a CSS class to field in content type

texts:
I'm fairly new to Drupal and I want to add a custom CSS class to a custom field in content type.

I've created a content type called 'custom page' and I have a field called 'custom_page_main_title' the only thing I would like to do is to add a custom CSS class or iD to this

How can I do this please? Thanks!


texts: Hook for csv export view - flag exported items

texts:
I am using Views data export to export view with exposed filter, is there any hook or another way to run an action over these filtered items?

My goal: set "flag" (boolean field) for these exported items so I will know, they have been exported.


texts: Change drupal admin password for 100 sites using drush

texts:
I've a requirement to change admin password for drupal 7 sites which are over 100 and i would like to do it with drush. I know one method of doing it is updating user table with a shell script listing databases in a queue, but i want to achieve this with drush. Would be great if anyone can put me in some reference if they have any idea.

Cheers,

Swaroop.


texts:
In a Commerce project, I added some custom fields to the customer profile, and I’m using Addressbook. The customer profile is now displayed in the address book tab of each user page.

I need to change the display of this address book. Until now :

I changed basic display settings of the fields in the "Manage Display" form, and this had a surprising effect : setting a label as hidden removed completely the default theming of all the view.
I tried to use hook_field_formatter_info() and hook_field_formatter_view() as per that Clive answer : this is great but it alters only the native AddressFields, not the custom fields of the customer profile.
In the Commerce Addressbook Defaults  view, source of the display, there's only one field in the view : Commerce Customer Profile: Rendered Commerce Customer profile.

I could call the fields one by one in the view, but what if I want to alter directly the  Rendered Commerce Customer profile field ? Where is it built, and how can I theme or alter it?


texts: Error trying to update database after module update

texts:
After I update a module, and click at http://omroepzuidplas.nl/admin/update/ready on the 'run' button to do the database updates. Drupal sends me to this url:

http://omroepzuidplas.nl/http%253A//omroepzuidplas.nl/authorize.php%3Fbatch%3D1?op=start&id=2796

Which result in an 404 page not found error.

I use Drupal 7.50 on CentOS7.


texts: Taxonomy term View: How to NAVIGATE the pages with "Exposed filter"?

texts:
My problem is this:
I am trying to add EXPOSED FILTERS in the DEFAULT TAXONOMY VIEW.
I just clicked on ADD in FILTER CRITERIA. I added a couple of exposed filters . Apparently they work. So I can visualize them in the page.
example:

name_of_website.com/name_of_taxonomy/name_of_term_1

but from there if I use the EXPOSED FILTER and in the EXPOSED FILTER I want to change Content Type or Term I can't do that because the new URL generated will be:

name_of_website.com/name_of_taxonomy/name_of_term_1?type=All&...

To make it that works it should be:

name_of_website.com/explore/?type=All&field_year_value=All&fi...

The page "explore"
is the page where there is a VIEW that takes ALL the
content of the content that I've created before (and also there I added the EXPOSED FILTERS).

I hope I've explained clearly and I hope someone can help me.
Thank you very much for your work and support.
Gilles


texts: Ordering product only once Drupal Commerce

texts:
I'm just creating a commerce site in drupal. There are 25+ products in my site. Currently, a single user can able to check out the same product for multiple times. I want to restrict that. If a user buys one product means, he might not be able to buy the same product next time. Is there any way to do this???

Thanks.


texts:
I have this hook_menu implementation

$items['lablab/%level/%unit/%tab/%section/%exercise/go'] = array(
        'title'           => 'My lablab',
        'title callback'  => 'lablab_form_set_title',
        'page callback'   => 'drupal_get_form',
        'page arguments'  => array('lablab_form',1, 2, 3, 4 ,5),
        'access callback' => 'lablab_access_exercise',
        'access arguments' => array(5),
        'file'            => 'lablab.forms.inc',
        'file path'       => drupal_get_path('module', 'lablab').'/includes',
        'type'            => MENU_CALLBACK,
    );

And then in the access callback

function lablab_access_exercise($w_exercise){
    dpm($w_exercise->value());
}

Then when i enter the hook_menu page it shows me at least 4 dpms, is this normal?


texts: With a custom form, how to sanitize user input before query gets to URL?

texts:
I followed this tutorial to create a custom Search form that takes users to the main search page with a query in the URL (meaning it uses a get method). This gives me more flexibility than using an exposed filter, so I'd like this to work. One thing that I want to do, however, is make sure that if someone searched:

<script>alert('foo')</script>

that the query in the URL would not have the tags included. Drupal has plenty of sanitization functions, so I'm not worried about that. But I can't figure out WHERE in the custom form plugin I would actually add the sanitization.

Please help! I've included the code of my plugin below:

<?php

namespace Drupal\my_custom_search\Plugin\Form;

use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class MyCustomSearchForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'site_search_form';
  }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['#action'] = '/search';
    $form['#method'] = 'get';
    $form['#attributes']['class'][] = 'usa-search';
    $form['#attributes']['class'][] = 'usa-search-big';

    $form['fulltext_search'] = [
      '#type' => 'search',
      '#attributes' => [
        'id' => array('search-field-big'),
        'size' => '',
        'maxlength' => '',
      ],
      '#prefix' => '',
      '#suffix' => '',
    ];

    $form['actions']['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Search'),
      '#button_type' => 'search',
      '#attributes' => [
         'class' => ['usa-search-submit-text'],
      ],
      '#name' => '',
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

  }

}

UPDATE: I ended up adding 'pattern' => '[^/><\][\\\x22,;|]+', in the attributes array, and this at least prevents submission of text with characters I don't want. I may still try to find a JS solution that works better for the user.


texts: Advance Search form $form is not the same when invoked a second time?

texts:
I Want the users to have an expanded advance search form if no results are returned from a search. The advance search form on the search page always defaults to collapsed.

I found that I can check whether I have results in two different ways: theme or module, depending on the hook I want to use, I chose module because it fires earlier than the theme's.

I also can effect the advanced search form's attributes (whether it's collapsed, or maybe display other data inside of the advanced search form, etc) with drupal's hook_FORMID_form_alter() with MYTHEME_form_search_form_alter's first call. The issue I have is MYTHEME_form_search_form_alter() gets called before results are returned.

So I can alter the advance search form first, then I can check if we returned any results from the search... which doesn't help me, because I need it to be vice versa - If I know I have no results then I know to expand the advanced search form's collapsible form.

My quick solution was to invoke drupal_get_form() with drupal_get_form("search_form", "no_results"); inside of my module's preprocess search hook MYMODULE_search_preprocess_search_results(&$variables) and just pass in the variable "no_results". This (as most of you probably know) will invoke hook_form_search_form_alter again, where I can edit the advance search form now and I will alter the advance search form only if my variable "no_results" comes through.

Here is my crux though! Even though I am invoking that theme hook again and checking for the variable, when I go to edit the $form's "advanced" entry... its gone now. So it's clearly there when theme's hook is called, and I can indeed effect the arrays, but if I try to effect the advanced array when I invoke the theme's hook (inside of my module's hook) it's not there. Where would I invoke this theme's hook if not on the module layer? Hell, the theme's preprocess hook is fired AFTER the module's and has proven to be the same circumstance, seems in either of the two ways of checking my results I cannot invoke the form_alter hook and get the exact same form back.

This is before I check results when THEME's alter hook is first being called:

This is after I check results in my module's hook and invoke the THEME's alter hook once more:

You can see my new variable denoting that we have no result (in this case it's LarryU) under the action key, but there is no advanced key. I tried just remaking it but it doesn't to the form.


texts: How can I combine "concat" after "explode" in Migrate API YML?

texts:
I have a YML file for creating Commerce Variation and create their multiple images. However, I can not get "concat" to work after "explode" so that I can add the full file path to the exploded file names. This is what I have but it fails as the concat does not seem to properly use each exploded value:

  field_product_image:
    -
      plugin: explode
      source: Product Image
      delimiter: '|'
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_source_uri
        - Product Image
    -
      plugin: entity_generate
      entity_type: file


texts: Drupal 8: Template suggestion for form-element in a views exposed filter is not working

texts:
In Drupal 8 I am trying to add in a suggestion via hook_theme_suggestions_alter() like so:

function ua_sc_theme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
  print '<!-- hook: ' . $hook . '-->';
  if (in_array($hook, ['input', 'form_element']) && $variables['element']['#attributes']['id'] == 'edit-keys') {
    $suggestions[] = $hook . '__custom';
  }
}

...and then I give my template a name of form-element__custom.html.twig and put it in my theme it doesn't get used an instead the default form-element.html.twig template is used. Any thoughts on what is going on?


texts:
I want to change the default -select a value- from a text list to a something like -please select a choice-

This is what I have:

  function project_form_alter(&$form, &$form_state, $form_id){
    if($form['#id'] == 'edit-field-gen-list'){
    $form['field_gen_list']['#default_value'] = 'all';
    }
}

It's not picking up the value.

This is the HTML.


texts: I have migrated content from a non-Drupal system to a fresh Drupal site. Some of the content nodes however should in fact be revisions of another node, not a unique node of themselves.  Is there any quick and easy way to turn a node into a revision of another node?


texts: Is it possible to hide menu items based on path?

texts:
I am looking to hide a menu item based on the path of a couples pages. It would be similar to how blocks can be shown on or not shown on a path. My initial attempts revealed that the caching of menus does not permit one to have the ability to remove menu items per page load.

hook_menu_alter() only runs once after a cache clear and then the menu is retrieved from the cache. Does anyone have any ideas on how to accomplish this or is it a futile attempt?

Thanks.


texts: How can I add a new field from config inside hook_update_N?

texts:
I have to add taxonomy by php code. Taxonomy has to got 2 fields. I added new function to test_taxonomy.install, and it seems to work:
function taxonomy_update_8805() {

    $config_path = 'modules/feature/test_taxonomy/config/update/';
    $source = new FileStorage($config_path);

    \Drupal::entityManager()->getStorage('taxonomy_vocabulary')
        ->create($source->read('taxonomy.vocabulary.regulation'))
        ->save();
}

Added new vocabulary to taxonomy.
Content of file:
langcode: pl
status: true
dependencies:
  module:
    - test_remote_vocabulary
third_party_settings:
  test_remote_vocabulary:
    is_remote: 0
name: 'Test'
vid: regulation
description: 'Test desc'
hierarchy: 0
weight: 0

The problematic part is when i try to add fields to the vocabulary.
I created 2 files
field.storage.taxonomy_term.field_regulation_test.yml
langcode: pl
status: true
dependencies:
  module:
    - taxonomy
    - text
id: taxonomy_term.regulation.test
field_name: test_field
entity_type: taxonomy_term
type: text_long
settings: {  }
module: text
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

field.field.taxonomy_term.field_regulation_test.yml
langcode: pl
status: true
dependencies:
  config:
    - field.storage.taxonomy_term.field_regulation_test
    - taxonomy.vocabulary.regulation
id: taxonomy_term.regulation.test
field_name: test_content
entity_type: taxonomy_term
bundle: regulation
label: TEST
description: 'Tekst test'
required: true
translatable: false
default_value: {  }
default_value_callback: ''
settings: {  }
field_type: text_long

But i am not sure how can i load them in update_xxx function.
EDIT:
I tried
    \Drupal::entityManager()->getStorage('taxonomy_term')
        ->create($source->read('field.storage.taxonomy_term.field_regulation_abo'))
        ->save();

    \Drupal::entityManager()->getStorage('taxonomy_term')
        ->create($source->read('field.field.taxonomy_term.field_regulation_abo'))
        ->save();

but i'm getting Missing bundle for entity type taxonomy_term while trying to update module


texts: Why am I unable to define weights and why are my settings being reverting on save?

texts:
I am going to cry :(

I have built a number of sites in the last few months that are all starting to fall apart with the same issue.

There are no notices/errors and there is nothing in the dblog.

It appears to be affecting any Drupal form with  with a select list.

It's affecting everything from Core Search Settings, Block weights, Context Weights and Omega theme weights/region widths

I define block weights, press save and all of the weights are set to the same weight e.g. all of my 50 block weights show "-10"

I define the widths of my regions in omega, press save. They are all reverted to '1'

I change core cron settings to index 500 at a time, press save. It reverts back to 100.

The closest I can come to my issue (and I have definitely done my research) is:

http://drupal.org/node/1439134

It references a recent change to core at
http://drupal.org/node/1346760

However, it seems to be affecting damn near everything, so I am unsure if this is even the source.

If anyone has any suggestion of what might be happening or what I can even do to source the culprit, I would appreciate it.


texts:
I have a timeline using Ajax Timeline, which print Teaser of my body content. I don't see it on Views.

How can I print it as Full content and remove the read more?


texts: 2015: What am I missing to get a simple hit counter block by page?

texts:
I've tried every recommendation I can find; I've enabled statistics and advanced statistics and can see that hits are being counted. I can display lists by what nodes are the most hit, etc; but I just want to display the results for the given node I'm on. How can I do this? I suspect the solution is in using contextual filters for a view, but I can't get this working, either. Help appreciated.

Drupal 7.


texts: Which tokens can I use in a rule to email all suppliers mentioned in an entity reference field?

texts:
In my website, I need to send a notification email to suppliers. I’ve created a content type supplier with email, warehouse 1 and warehouse 2 as fields.

In commerce product, I’ve created a supplier field (entity reference).
Now, I need to send an email on the rule event ‘completing the checkout process’ to those suppliers for them to start preparing the products for pickup and I can’t find any related tokens on the Rules Action ‘Send email’.

Any suggestions?


texts:
In my sites comments are moderated so (anonymous) visitors sometimes get confused and try to resubmit it.
It happenens within say 5 minutes only.

What is the best way to catch and reject duplicate comments by the same user?

One way is to look for same body text from same session within say 5 minutes and reject it.


texts: How to create fields group as accordions?

texts:
Hello Drupal community,

I am trying to create a group of fields with an accordion, so that it can be visible/unvisible with a simple clic on the title of the field's group.

Does anyone know how to do it ? Or know a module that does it ?


texts: Operations in find content page not working

texts:
I am using Drupal 7 and I don't see any options listed down in the operations drop down in the find content page. The options are listed in content's tab, but when I move to files tab, the drop down is not shown.

Do you have the options to operate(delete, unpublish) files as we do to nodes? Any help would be appreciated.

Thank you


texts: Test class could not be found, namespace/autodiscovery issue?

texts:
I've got the following tests written for /core/modules/migrate_drupal_ui/src/Controller/MigrateController.php with
a new test file /core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php.

<?php

namespace Drupal\Tests\migrate_drupal_ui\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * Provides a base class for testing the Migrate Controller.
 */
abstract class MigrateControllerTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  public static $modules = ['migrate_drupal_ui', 'views'];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $account = $this->drupalCreateUser(['administer views']);
    $this->drupalLogin($account);
  }

  public function testRedirectDestination() {
    $this->drupalGet('admin/reports/upgrade');
    $this->assertUrl('admin/reports/dblog?type%5B%5D=migrate_drupal_ui');
  }

  public function testRedirectDestinationWithoutView() {
    // Delete the watchdog view
    $this->drupalGet('admin/structure/views/view/watchdog/delete');
    $this->assertResponse(200);

    $this->submitForm([], 'Delete');
    $this->assertResponse(200);

    $this->testRedirectDestination();
  }
}

Following https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial, an existing test runs as expected with ../vendor/bin/phpunit --filter testMigrateUpgradeReviewPage modules/migrate_drupal_ui/tests/src/Functional/MigrateUpgradeFormStepsTest.php.

However, when I do the same for my above test -- ../vendor/bin/phpunit --filter testRedirectDestination modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php -- I get

PHP Fatal error:  Uncaught PHPUnit\Runner\Exception: Class 'modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest' could not be found in '/Users/MrWeiner/Sites/DockerSites/testing/web/core/modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest.php'. in /Users/MrWeiner/Sites/DockerSites/testing/web/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:102

It looks like a namespace issue but I do not understand why it'd be looking for Class 'modules/migrate_drupal_ui/tests/src/Functional/MigrateControllerTest' instead of Class 'Drupal\Tests\migrate_drupal_ui\Functional\MigrateControllerTest'. Do I need to register my test somewhere or do something else to ensure that it's autodiscovered?

Original Question: We've got https://www.drupal.org/files/issues/2019-04-12/adding-custom-access-2904546-24.patch posted in https://www.drupal.org/project/drupal/issues/2904546 with the request "for a functional test with and without that view enabled". The patch itself is very simple so I'd assume that the test would be very simple as well. I just don't have any experience writing tests so I don't really understand what I'd be testing for/asserting here or how to test for both the view existing and not existing.


texts: prevent any user that doesnot belong to an organic group, to access any node outside his group with code

texts:
i have made the following custom module, in order to prevent any user that belongs to group 1, be able to view or edit a node that belongs to group 2. Still if one knows the url of the node, manages to view it regardless of which group he belongs to, and more important, edit it. Any resemblance to any other question posted here is just a coincidence, also to mention that each node belongs to one and only group.

What am i doing wrong in below code?

<?php
    /**
     * Implements hook_node_access()
     */
    function mymodule_node_access($node, $op, $account){
        if($op=='view' && isset($node->og_group_ref[und])){
            $user=user_load($account->uid);
            $node_og_group_nid=$node->og_group_ref[und][0]['target_id'];
            $user_og_group_nid=$user->og_user_node[und][0]['target_id'];
            if($node_og_group_nid!=$user_og_group_nid) return NODE_ACCESS_DENY;
        }
    }


texts: In which cases should I not call user_access() in a form submission handler?

texts:
Reading the code for user_register_form(), I see the following comment:

  Pass access information to the submit handler. Running an access check inside the submit function interferes with form processing and breaks hook_form_alter().

The code right after that comment is the following, where $admin is set to user_access('administer users').

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

Looking at comment_form_submit(), I notice that user_access() is being used.

  if (user_access('post comments') && (user_access('administer comments') || $node->comment == COMMENT_NODE_OPEN)) {
    // Save the anonymous user information to a cookie for reuse.
    if (user_is_anonymous()) {
      user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage'))));
    }

    // …
  }

Is there any difference between the first case, and the last one? If there isn't any difference, what approach should I use in my code?


texts: Programmatically set the number of Multiple Value CCK fields in node edit form

texts: I have a filefield multi-value CCK field and I want to be able to set the number of values that can be added based on some condition when the user is editing the existing node. Is there a way to handle this through a form_alter? I do not want to set the number of values to "unlimited" for this case.


texts: How to properly check the menu for emptiness in twig?

texts:
I use Simplify Menu to display the necessary menu markup. How do I make sure that the menu is not empty (there are items there) and if there are menu items, they are enabled?
{% set items = simplify_menu('main') %}

    {% for menu_item in items.menu_tree %}

      {{ menu_item.text }}

{% endfor %}

In my work, I use the Twig tweak module, but I can't do a check with it either:
{% if drupal_menu('main') is empty %}
{% endif %}


texts: For User i am giving option of color selections for a theme

texts:
I am giving user the option of selecting the color(color scheme option like bartik) for the theme.For multiple users how do i save there color values for the theme and show their values alone depending on their login ? Colors for their header ,footer etc...

Help me provide with a solution.Thanks in advance


texts: How do I retrieve the query parameters from a path?

texts:
How do I retrieve the query parameters from a path. Here's my path:

/search?keys=hello

Here is what I've tried:
$test1 = \Drupal::request()->request->get('name');
$test2 = \Drupal::request()->query->get('name');
$test3 = \Drupal::service('path.current')->getPath();
$test4 = \Drupal::request()->server->get('REQUEST_METHOD');
$test5 = \Drupal::request()->query->get('q');
$test6 = \Drupal::request()->request->get('keys');
$test7 = \Drupal::request()->query->get('keys');
$test8 = \Drupal::request()->query->get('destination');
$test9 = \Drupal::request()->request->all();
$test10 = \Drupal::request()->getRequestUri();

Here are the results:

Test 1: NULL
Test 2: NULL
Test 3: '/search'
Test 4: 'GET'
Test 5: NULL
Test 6: NULL
Test 7: NULL
Test 8: NULL
Test 9: array ( )
Test 10: '/search'

Why is this not working?