texts: Field values added programmatically dispear after a certain time

texts:
I created a module that creates a block to show a schedule information. I need taxonomy terms to configure the block. I want that those terms are filled with preconfigured values when I install the module.

I have in my config/install folder the definition of my taxonomy:

core.entity_form_display.taxonomy_term.schedule_channels.default.yml
core.entity_view_display.taxonomy_term.schedule_channels.default.yml
field.field.taxonomy_term.schedule_channels.field_channel_id.yml
field.storage.taxonomy_term.field_channel_id.yml
taxonomy.vocabulary.schedule_channels.yml

Here the content of the file field.storage.taxonomy_term.field_channel_id.yml:

langcode: en
status: true
dependencies:
  module:
    - taxonomy
id: taxonomy_term.field_channel_id
field_name: field_channel_id
entity_type: taxonomy_term
type: string
settings:
  max_length: 50
  is_ascii: false
  case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: {  }
persist_with_no_fields: false
custom_storage: false

Also in my schedule_block.install I have:

class schedule_block_class{

  const schedule_block_channels_terms = array(
    array(
      'name' => 'Brava',
      'field_channel_id' => 'BRA001'
    ),
    array(
      'name' => 'DJazz',
      'field_channel_id' => 'DJA001'
    ));
  const schedule_block_channels_vid = 'schedule_channels';
}

function schedule_block_install(){
  $schedule_block_terms = schedule_block_class::schedule_block_channels_terms;
  $schedule_block_vid = schedule_block_class::schedule_block_channels_vid;
  foreach($schedule_block_terms as $schedule_block_term){
    $term = Term::create(array(
      'name' => $schedule_block_term['name'],
      'field_channel_id' => $schedule_block_term['field_channel_id'],
      'description' => '',
      'parent' => array(0),
      'vid' => $schedule_block_vid
    ));
    $term->save();
  }
}

function schedule_block_uninstall(){

  $schedule_block_terms = schedule_block_class::schedule_block_channels_terms;
  $schedule_block_vid = schedule_block_class::schedule_block_channels_vid;
  $terms = array();
  foreach($schedule_block_terms as $schedule_block_term){
    if($terms_name = taxonomy_term_load_multiple_by_name($schedule_block_term['name'], $schedule_block_vid)){
      $terms = array_merge($terms, $terms_name);
    }
  }
  foreach($terms as $term){
    $term->delete();
  }
  $taxo = \Drupal\taxonomy\Entity\Vocabulary::load(schedule_block_class::schedule_block_channels_vid);
  if(!is_null($taxo)){
    $taxo->delete();
  }
}

When I install my module, my taxonomy vocabulary is created and my terms are loaded with my values

... BUT ...

After about 24h the values have disappeared. Checking in the table taxonomy_term__field_channel_id confirms that there is no more any values. I still have my taxo vocab, and all the needed tables are present.

Why the values are not permanent?


texts: I have a form and I am using Drupal 7. I need to show this form in a popup when a user clicks a link. The user should then be able to complete the form whilst in the pop up window. I can use anything like Colorbox or modals or anything. I just wanted to know which is the better option and what options do I have for Drupal.


texts: Can I update from 7.34 to 7.41 directly? What is the safest way to do so?

texts: I have a site built using Drupal 7.34, and now I want the core to be upgraded to 7.41 and would like to know the safest way to do it.


texts: FormState getValue on checkbox elements in hierarchical / tabular form structures broken?

texts:
I can't seem to retrieve correct posted checkbox form element values using an array-style key in a call to the FormState::getValue method. If I flatten the elements into a non-nested structure, the getValue method works. But, I need to lay out the components using a table form element. The values that I get back (empty or "0") do not match the actual user-checked box states by the time they post in submitForm. I've also tried a zillion variants of reversed #parent array hints, #array_parent hints, #return_value, etc. It feels like there may be a bug in the getValues method in how it handles array-style keys? Or, am I doing something dumb?

class DataFsFolderSharingForm extends ContentEntityForm {

  // … stripped down to the bare essentials...

  public function buildForm(array $form, FormStateInterface $form_state, DataFsFolderInterface $folder = NULL) {
    // Documentation for for element attributes (eg: '#parents’, '#array_parents’, '#return_value’, etc):
    //   @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21FormElement.php/class/FormElement/8.2.x

    $form = [];
    $form['#tree'] = TRUE;

    // Show the current access settings as a table.
    //   @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21Table.php/class/Table/8.2.x
    $form['access'] = [
      '#type'    => 'table',
      '#caption' => $this->t('Sharing Access'),
      '#header'  => [
        $this->t('User Email'),
        $this->t('View'),
        $this->t('Edit'),
        $this->t('Operation'),
      ],
      // '#array_parents' => array( 'access' ),
      // '#name' => 'access',
    ];

    // Non-nested element structure doesn’t break getValue method.
    $form['flat'] = [
      '#type' => 'checkbox',
      // '#name' => 'check-2',
      // '#return_value' => 1,
      // '#default_value' => 1,
      // '#array_parents' => array( 'flat' ),
    ];

    // Nested element structure breaks getValue method.
    //   @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21Table.php/class/Table/8.2.x
    $form['access'][0]['view'] = [
      '#type'          => 'checkbox',
      // '#name' => 'check-1',
      // '#return_value' => 1,
      '#default_value' => 1,
      // '#array_parents' => array( 'access', 0, 'view' ),
    ];

    // ...more table elements added, who's rows are indexed by the middle integer array value...

    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    // The non-nested getValue returns the correct checkbox state (checked or unchecked).
    $checked = $form_state->getValue('flat');

    // The nested getValue returns the incorrect checkbox state (checked or unchecked).
    //  @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormState.php/function/FormState%3A%3AgetValue/8.2.x
    $checked = $form_state->getValue(['access', 0, 'view']);

    // Also tried ['access', '0', 'view’ ]
    // Also tried ['view’, 0, 'access’ ]
    // Also tried ['view’, '0', 'access’ ]
    // Also tried setting '#parents’ form element attribute.
    // Also tried not setting '#array_parents’ form element attribute.
    // Also tried reversed version of '#parents’ form element attribute.
    // Also tried reversed version of '#array_parents’ form element attribute.
    // Also tried setting '#return_value’ form element attribute (using 1, 0, TRUE, FALSE, '0’, '1’, etc).
    // Also tried setting '#default_value’ form element attribute (using 1, 0, TRUE, FALSE, '0’, '1’, etc).
  }
}


texts: How to debug hook_form_BASE_FORM_ID_alter not working?

texts:
I am at wits' end. I have a clean install of Drupal 7.28 and a custom module with the following two hooks:

/**
 * Implements hook_form_alter().
 * /
function mymodule_form_alter(&$form, &$form_state, $form_id) {
  dpm($form_state, 'form_alter');
}

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 * /
function mymodule_form_node_form_alter(&$form, &$form_state, $form_id) {
  dpm($form_state, 'BASE_FORM_ID_alter');
}

And that is all there currently is in the custom module.

I have verified that the the base_form_id for the Article node form is node_form, by printing it out (using dpm($form_state).  This is what is printed:

base_form_id (String, 9 characters ) node_form

And yes, I have cleared the cache (I've even restarted apache and rebooted the server).

I believe my code is identical to what is shown in numerous tutorials about how to use hook_form_BASE_FORM_ID_alter().

Still, when I open the form to create an article, the first hook (hook_form_alter()) fires, and the second (hook_form_BASE_FORM_ID_alter()) does not.

This hook is in 54 functions in the core, so it is very unlikely that it just does not work.

As I said, I am at wits' end.

Has anyone a suggestion for what to try next?


texts: How to override individual blogs/% page?

texts:
I've got a question about overriding the default blogs/username page with Views.
I've created a new view with a page display with blogs/% as path, and set arguments to user:name. I'm typing blogs/rustam, the default page of individual blog is displayed. How do I  correctly override the blog page with Views?


texts: Is there an easy way to have an image in a radio button label?

texts: I have a dynamic list of images, that I want to have a user select via associated radio button in a form. Is there an a way I can do this with the base form api, or is this the kind of thing I'd need to create a custom theme for?


texts: Connecting multiple data entities to the user object

texts:
I need to create a simple order system in Drupal 7. This will be a site for a meat wholesaler so I don't need a webshop.
Users are able to register and fill in a webform to order products. However I'll need to handle different shipping addresses for the users, and let them choose a shipping address upon ordering.
What I have in mind is connecting the shipping addresses to the user object (billing address is already on the user form).

Which method is better?

Create a field collection entity for the shipping addresses and add it to the user form
Leave the user form alone and create a new content type that can be added/edited by users and use the UID to decide which address belongs to which user

I'd like to let users edit their shipping addresses anytime on their user page, preferably independently from the other datas.

If anyone done something like this before, please share some ideas.


texts: Why do all auto created urls in my multilingual site cause a Page not found?

texts:
I have a multilingual site, using Drupal core 7.43 and the Redirect module, and the Pathauto module (and aliases are auto created without any problems).

Creating content translation I've got such problem: all auto created url aliases don't work.

When I change site language (as visitor) all seems Ok, I see all content has been translated. But if I (as a logged in user which is also an        administrator) try to open an article (for example), or any other translated content, I am always getting "Page Not Found". Auto created url leads nowhere.

What is wrong?

Note: When I am manually adding redirect (eg. from mysite/content/myarticle_1 to node/122), I am getting error "You are attempting to redirect the page to itself. This will result in an infinite loop." When I change article language from native to "All languages" then redirect could be saved and works as it should be.


texts: How do I redirect the "No Result" search page to Add node?

texts: I would like to redirect the "No result found" page of the drupal search to Add node. Basically I want when users search for an item using the search text box they get redirected to the Add node page when the item is not found.


texts: Creating mulitple contact forms in drupal 7

texts:
I have installed the contact and contact_forms modules.
I have created different categories in the contact settings page.

I want multiple contact forms as I have multiple domains. For each domain I should have a separate contact form.

But that categories displayed in the drop down of the contact form.

Is it possible with the contact module to create multiple contact us forms like contact/site1, contact/site2, contact/site3 etc?


texts: How to add a category in the FAQ_ask module

texts:
I am using the FAQ Ask the Expert Module on my drupal 6.  I am not very familiar with the drupal interface and have trouble setting up modules. I would like my ask a question for to have categories in which the asker can check off. The question would then be sent to the expert corresponding with that category.
 It seems like this is what this module would do except I cannot get the categories to show up. Can someone give me step by step instructions?

EDIT: I would like the categories to show up on this form:


texts:
These <h2> heading tags, in the canonical sense, should be used as headings only, right?

In Drupal, it seems these block headings get <h2> tags, but they aren't semantic headings insofar as being legitimate paragraph headings on legitimate paragraphs.

Surely as a search spider would not readily distinguish these tags, they in fact not be <h2> but standard <div>s?


texts: Update UI lists modules/themes that are already updated

texts:
I have a D7 (7.69) site. On both dev and production, I can update a module (using the web UI - /admin/modules/update), apparently successfully, yet afterwards, that module stays listed as requiring an update with Installed Version and Recommended Version exactly the same.

e.g.

  Adminimal - Responsive Administration Theme (Theme)
  Installed version 7.x-1.26
  Recommended version 7.x-1.26

(I've seen it with themes, such as the one above, and modules such as Views).

I've tried:

clearing the cache
downloading a clean latest version to a new directory, and comparing the md5hashes of all files between the two (as well as simpler checks like the module .info file.)
wiping the module/theme directory and replacing with a freshly extracted .tar.gz
checking if any database updates are pending (they're not)

Is there anything else that could be causing it to get stuck?

I've looked at the system table - specifically the system.info field - but nothing looks "wrong".


texts: How to change data type from varchar to text?

texts:
I'm trying to change the data type of column "mail" from table "simplenews_subscriber" from varchar to text using hook_update_N but its not getting reflected.

/**
 * Implements hook_schema().
 */
function simplenews_schema() {
  $schema['simplenews_subscriber'] = array(
    'description' => 'Subscribers to {simplenews_category}. Many-to-many relation via {simplenews_subscription}',
    'fields' => array(
      'snid' => array(
        'description' => 'Primary key: Unique subscriber ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'activated' => array(
        'description' => 'Boolean indicating the status of the subscription.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => "The subscriber's email address.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid that has the same email address.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Subscriber preferred language.',
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp of when the user is (un)subscribed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'changes' => array(
        'description' => 'Contains the requested subscription changes',
        'type' => 'text',
        'serialize' => TRUE,
      ),
      'created' => array(
        'description' => 'UNIX timestamp of when the subscription record was added.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('snid'),
    'indexes' => array(
      'mail' => array('mail'),
      'uid' => array('uid'),
    ),
    'foreign keys' => array(
      'uid' => array(
        'table' => 'users',
        'columns' => array('uid' => 'uid'),
      ),
    ),
  );

  return $schema;
}

Update Hook:

function MY_MODULE_update_7001() {
  db_drop_index('simplenews_subscriber', 'mail');
  db_change_field('simplenews_subscriber', 'mail', 'mail', array(
    'type' => 'text',
    'size' => 'medium',
    )
  );
}

Any help of this will be appreciated.


texts: Can't seem to get my plugin class include to load?

texts:
If I keep my plugin class in the mymodule.module, then the plugin works fine. However moving it out to mymodule.context.condition.inc prevents the condition from working.

I have added file[] entry to mymodule.info and I have added the following to my hook_context_plugins:

function mymodule_context_plugins() {
  $plugins = array();
  $plugins['mymodule_context_condition_bonus_discount'] = array(
    'handler' => array(
      'class' => 'mymodule_context_condition_bonus_discount',
      'parent' => 'context_condition',
      'path' => drupal_get_path('module', 'mymodule'),
      'file' => 'mymodule.context.condition.inc',
    ),
  );
  return $plugins;
}

As mentioned, if I shift the code into the .module file, and remove the 'path' and 'file' lines from hook_context_plugins, then the condition is recognized by context and runs without issue.

SOLVED:

Looks like my class definition should not have had a capital "C" in "Class". Quite frustrating since I'm using drupalcs which complains about the lower case "class".


texts:
I know it should be very simple, I know it was working in Drupal 7 but I can't make it work in 8.

I tried this but it is not working. "page--path.html.twig" is not used, Drupal is using the "page.html.twig" template. The page I'm trying to theme is "example.com/path" . This page is just a view page. I'm not interested in theming the view, just the page markup around it.


texts: Views Infinite Scroll content doubles up at end of scrolling

texts:
I have a View, with Views Infinite Scrolling.  It seems to be working fine, except when I hit the end, the content doubles up.

One interesting thing is they are nodes rendered with Display Suite.  These nodes have an image.  When I hit the bottom and the duplicate nodes display, they are missing the image.  If I go into Firebug, or resize my browser, they display.

How can I fix this behavior?

I'm running Views 3, jQuery 1.8, and Views Infinite Scroll 7.x-1.1+0-dev.


texts: Autocomplete widget - save id of suggested and accepted value

texts:
I'm writing a custom text field and widget module with ajax autocomplete from scratch. I want the lookup to work on one column, but I want another column's value (the looked-up item's id) to be saved as the field value in the node.

So, for example, user types for example Sams, they accept suggestion Samsung, but Drupal save its database identifier, say 145.

Conversely, when opening the node for editing, the saved value of 145 should be again looked up, converted and displayed as Samsung.

What is the key to get it working the Drupal way?


texts: How do I call an object in a prepressor only once

texts:
In drupal8 is there a way to call a function only once in the theme layer. Can I call this function only once and not on other preprocessor hooks or
am I using the wrong hook?

function template_preprocess(&$vars){
    //-- can I call this function only once and not on other preprocessor hooks
    _updateFieldOnNode('field_metatag_title');
}


texts: Programmatically delete field collection items

texts:
Is there any way to delete field collection items programmatically in Drupal 8?

I have created a field collection item and attached it to the user entity in the following method.

$user_id = \Drupal::currentUser()->getAccount()->id();
$user = User::load($user_id);

$fc = FieldCollectionItem::create(array(
  "field_name" => "field_hobbies",
));

$fc->set('field_name', 'Watch TV');
$fc->setHostEntity($user);

It works fine and the field collection item got created successfully. Now I want to delete this field collection item. That means, I want to delete the hobby from the user. Is there any way for doing this?


texts: How do I hide the body field in a node using hide()?

texts:
I'm using the following code, and it simply does not work:

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

I would like to hide the body field to show it elsewehere.


texts:
Is there a method of moving the aggregated JS files to the footer?   I've taken a look at hook_js_alter but that just gives me access to the individual files, not the aggregated ones.

I would prefer to not move the $scripts variable to the bottom of html.tpl.php

Any tips would be appreciated.


texts: Enabling a block to inherit the settings of a sub theme

texts:
Being relatively new to Drupal, I apologize in advance if what I'm saying is unclear, but I'd imagine that a fix should be simple enough:

Basically, I'd like to add a header block that functions identically to the other block regions on my Drupal site. At the moment, the text of that header is not responsive to window size, unlike the rest of the site. How can I inherit the default settings of my theme when creating a new block?

Thanks in advance, a solution to this would help me tremendously.


texts:
I use drupal 8, and Bootstrap theme.

I created a sub-theme.

I would like added one font that I downloaded, to use it in my sub-theme.

I read contradictory things to realize it. For example that it was enough to create a folder "font" in its sub-theme, and add the font in it, then add it in mytheme.libraries.yml, or that it was necessary to place this font in the folder vendor/ . I am a little lost.

How can it be done?


texts: How hierarchical taxonomy comparison works

texts:
I'm bit confused about how hierarchical taxonomy comparison will work when using Views.

For an example (using Taxonomy and Menu block modules) I've 2 level deep taxonomy:

1 Animal(10)
     1a Tiger(2)
     1b Deer(5)

What should normally be is whenever I want to search for Animal type then the View search should return total of 10+2+5 = 17 nodes.

I've just now checked that it will instead return 10.

How to get this correct functionality?


texts: Remove time filter in a date exposed filter in a view

texts: I have a view with a date field exposed filter but this date field in its content type configured to be date and time. Is there any way to make this exposed filter work only by date because now when I enter a date, didn't get any result.


texts: Reference Based on Two Fields of a Content Type

texts:
I have two content types account and device. device has a reference field named reference_account_number and it's referencing account_number in account, but the unique key for account is a composite key account_number and environment.

I used auto node title module to generate the node title based on account_number for account, and let reference_account_number map on to the node title of the account nodes.
So my problem comes up when I try to do feed import when there are duplicate account_number but different environment. The reference_account_number only map onto the account node that has matching node title.

Is there any way to reference another node based on two fields?
I was thinking about adding a environment field to device content type as well

Ideally, I would like this scenario happens when a user creates a new device content.

User enters the account number and environment, upon completion, user views the content just created, and reference account number provides a link to all existing account that matches the account number user inputted for the device content, same thing goes for environment

Thanks


texts: Colorbox grouping content linked from same page - how to stop it?

texts:
I have a page with two links on it that each open in Colorbox modals.

When I click on one of them, it opens them both, as if they were a gallery, with forward and back arrows to navigate between them.

I have looked through the Colorbox configuration options and I can't figure out how to stop this behavior.


texts: Controlling the display order of custom field sets that are shown both in a webform and in CiviCRM, via the webform_civicrm integration module

texts:
I've created a webform that is integrated with my CiviCRM implementation. The webform has five major sections to it, each of which is reflected by a custom field set within the CiviCRM module as shown below.

All five custom field sets are linked to a specific activity type as indicated in the first screenshot. The five custom field sets are ordered, by weight, in the list of custom field sets within CiviCRM because I want the summary information displayed first to the administrator viewing the activity.:

However I want the summary questions displayed at the end of the webform, as presented to the user, so I've used webform's flexibility to let me do that.

So far so good. But when I submit the webform, the CiviCRM activity record, when in view mode, reflects the field order as specified in the webform, rather than as specified in CiviCRM, which seems odd.

However, if I edit the activity record, the field order and field sets are as ordered in my original CiviCRM field definitions.

How can I set it up so that the field order in the Activity record, when viewed rather than edited, reflects the order specified within CiviCRM?

(I'm aware that this question is more about CiviCRM than it is about Drupal per se, but given that CiviCRM is a Drupal module, and there's no SE site dedicated to CiviCRM - yet - I hope you'll bear with me and allow answers to this question.


texts: How can I render [webform_submission:values] in a table?

texts:
I am trying to figure out from where [webform_submission:values] gets rendered. This is how it looks right now in the email submission.
Label 1
Value 1

Label 2
Value 2

I want this in a table format. Is there a possibility to change the render code to do this?


texts: Reasons for subsequent Broken/missing handler in Views?

texts:
In the process of upgrading Drupal 6.x to 7.x I'm facing a problem that makes all my views show nothing relevant. (I believe the problem is here but I'm not sure, I don't know. That's why I'm asking):

After using the migrate field from CCK module in Drupal 7.x most of my views end up with Broken/missing handler whether it is in Field, Filters Criteria or Relationships.

On the other side, when using the migrate field module, most of the fields have a message similar to this attached with them. (The field names change.)

  Missing formatter: The 'hidden' formatter used in 3 view modes for the field_phone field is not available, these displays will be reset to the default formatter.

Or I get this message.

  Changed field type: The 'field_source_file' field type will be changed from 'filefield' to 'file'.

Or I get this message one too.

  The field uses the view list_of_project_for_captain_log to determine referenceable nodes. You will need to manually edit the view and add a display of type 'References'.

Is this the reason why most the views have a Broken/missing handler than makes them not work properly? If yes, what can I do, if not what else could be the reason for such problems and what should be done?


texts: Authentication page before loading the main website

texts:
I am using Drupal 7. I need any user(who has not logged in) to just see the login screen only for authentication before he can traverse the actual website.

How this can be done?I tried to do it using Panels but without success.


texts:
I need a form that has a radio buton field. The field must not hard coded. Options must created dynamicly. The form will be a block and get radio buton options from given chosed node field.

For example if the form in node 1, radio options comes from node 1's given field, and so on.

Can you give me any advice to accomplish this? (entity form, web forms, custom form etc?)

(Sorry for my poor English)


texts: How do I template links and "tags" field?

texts:
I'm using the Zen theme to build my template, and I'm trying to get the tags appear after the "read more" link on the home page.

What's the best way to do?


texts:
I just made a simlple block by using block > custom block, so I didn't make it programmatically.

I am a Drupal 8 newbie, and I look for a simple and clear solution how to disable caching for that block.

What code should I use ? In what file to put the code ? How to target that unique block ?

Thanks !


texts: Managed File element empty in $form_state on submit for anonymous user

texts:
I have a form built with Drupal 8 FAPI. It's a sophisticated "contact us" type thing which includes the ability to upload files.

Among other things it includes several managed_file elements.

The elements are defined in buildForm() like this.

$form['myfile'] = [
    '#type' => 'managed_file',
    '#upload_location' => 'public://' . date('Y-m')
];

In submitForm() I look at $form_state->get('myfile'). If I'm logged in as admin (haven't tried other roles) this contains an array with one element who's value is the id of the created file entity.  That all works well.

If I am not logged in, $form_state->get('myfile') is an empty array in submitForm().

With anonymous, the file is successfully uploaded because it physically appears in /sites/default/files/2016-05. The file entity is created because I can see it in /admin/content/files.

I must be missing something related to permissions. I tried adding '#access' => true to my form element definition but that did not help.

I have a content entity which includes a file field. The add entity form derived from ContentEntityForm is basically the same as my form and works correctly even for anonymous. I probably could use that instead of my form but I prefer to use my own form. This is partially a learning exercise.

Thanks for any help.


texts: Drush make command error when unzipping superfish module / library

texts:
I am moving a website from my local machine to the prod server. I intend to do this with drush sync, looks like the most straightforward way. So, I've created a makefile on my local website, when i issue drush make myfile.make, I get this error :

superfish-7.x-1.9 downloaded.                                                               [ok]
Found makefile: superfish.make                                                              [ok]
superfish downloaded from https://github.com/mehrpadin/Superfish-for-Drupal/zipball master. [ok]
Unable to unzip /tmp/make_tmp_1386076010_529dd76a9b232/master.                              [error]

Then in tried another download link, fail with same message.

superfish downloaded from https://github.com/mehrpadin/Superfish-for-Drupal/archive/1.x.zip. [ok]
Unable to unzip /tmp/make_tmp_1386076010_529dd76a9b232/1.x.zip.                              [error]

I guess all zip files are not corrupt, something must be wrong, may be on my local install, but the error message isn't very helpful so I am stuck.

so what to do then ? anyway to fix this ? I guess the superfish module will not be installed if I move my website with drush sync ? can I reinstall superfish  with admin GUI then ?


texts: Create a layout 3 column with 2-1-2 teasers

texts:
I would like to create a layout like in this image.

It's all the same content type, and I am displaying images.

The columns have all the same width, the first columns -left- contains 2 teasers ( one below the other), the second one -center- contains 1 teaser, the last column -right- contains 2 teasers ( one below the other).

The image teaser on the center column has the same width of the other but it has the double of height, so I will need another image style or another field.

I can't achieve this just with css otherwise the images will look stretched/cropped.

I don't know how to approach to this issue. How to say that each two nodes, I need to display one with a different image style or another field image, using views.

Any help, suggestion, idea would be appreciate!


texts:
I am building a website where i generate a submenu based on my main navigation.
The structure looks like this:

Home
About
Work at

vacancies

contact

when you land on one of the level 1 pages, a submenu will appear in the sidebar with the children links of this page.
i want the title of the parent page to show above this menu.

also, on the vacancies page there's a overview of vacancies, and when you go to one of the detailed vacancies i want it to show
"Work at" and not "vacancies" in the submenu title.

i've tried alot of things but can't find the right solution for it.


texts: Failed to import Bootstrap Paragraph sub module configuration

texts:
I tried to implement the Hero with Xeno Hero in the Bootstrap Paragraphs in Drupal 8.  I encountered an error when I tried to import the config of the sub module.  I am not sure if I do it the right way but I ended up getting this error.

  The configuration cannot be imported because it failed validation for the following reasons:
  Configuration paragraphs.paragraphs_type.paragraph.xeno_hero.default depends on configuration (field.field.paragraph.xeno_hero.xeno_content, field.field.paragraph.xeno_hero.xeno_invert, field.field.paragraph.xeno_hero.xeno_offset, field.field.paragraph.xeno_hero.xeno_overlay, field.field.paragraph.xeno_hero.xeno_parallax, paragraphs.paragraphs_type.xeno_hero) that will not exist after import.

What I did is importing a single item, but I don't know which configuration type to go for, so I tried Entity Form Display and Entity View Display as well as Fields.

Could anyone just point me to the right direction or show me hints that I could follow to get this right?


texts: Render array in controller response without surrounding theme

texts: I have custom controller in which I would like to take a render array (as such returned by EntityViewBuilderInterface::view) and return it as HTML without anything additional page theming wrapping it. I'm using this with a custom ajax call and would like to fetch html fragments to dynamically render on the page. Is this possible?


texts: How to get the image from the url and store in the custom path?

texts:
if(empty($nodevalue->field_beachesimages)){
    $imageurl=array(explode(",",$nodevalue->field_beach_migrateurlhidden[$nodevalue->language]['0']['value']));
    foreach ($imageurl as $imagechange) {
        $countimagurl=count($imagechange);
        if($countimagurl>10)
            $imgdata=9;
        else
            $imgdata=$countimagurl;
        for($i=0;$i<$imgdata;$i++){
           $image =$imagechange[$i];
           $file = system_retrieve_file($image,'public://beachesmigration/', TRUE, $replace = FILE_EXISTS_REPLACE);
           echo "<pre>";print_r($file);echo "</pre>"; exit;
           file_save($file);
           file_usage_add($file, 'iks_beaches', 'beaches', $file->fid);
        }
    }
}


texts: Password request redirect to another page

texts:
I click on forgot password page

it redirect me to http://example.com/user/password which is fine

now when i enter email id . it redirect me to

"http//example.com/user */. I want it to redirect another page

http://example.com/request-access

Any idea?

Thanks


texts: Not quite sure how I should even google this. I've got a Content Type "Trips", the image shows what I want to see in my trips node page. Adventurus, relaxing, educational etc are my taxonomy term categories. It seems to me like each taxonomy term should have a scale of 0-5. Which is the better way to achieve this? Any module around? (using drupal 7)


texts: Force native taxonomy-term pages to only show  and not all content

texts:
Natural state ends with an ocean of duplicated content; at least in some cases, this could be an SEO disaster.

How do I force native taxonomy-term pages to show only the H1's and not all content (all nodes) associated with the specific term?

When I searched the UI I couldn't find a way to do so. Maybe it is possible with a module.

Note: I can use views for that, but my aim is to change the naturally-created taxonomy term pages without Views.


texts:
Anyone know how to control the width of a drupal fieldset that's in a block? I have a custom block that I've added 3 fieldsets to using the same exact fieldset code in each, however out of the three, the top one's width is fine, the middle one's is overflowing into the middle column, and then last one is fine. The screenshot shows the top block and the "broken one below it. I want the width to be the same as the top block, which is automatically setting it's width the same as all of the rest of the other blocks in the same column.

Screenshot


texts: Why is the subtheme_style.css not being called?

texts:
On a Drupal Commerce Kickstart installation, I have created a subtheme of Omega Kickstart, following the process described here.

Subtheme is saved to:
public_html/sites/all/new_theme

I kept only two of the *.css files for customization:

new_theme_style.css
new-theme-alpha-default.css

I updated the new_theme.info file as follows:

name = New Theme
package = Commerce Kickstart
core = 7.x
screenshot = screenshot.png
base theme = omega_kickstart

No changes to the Regions / Theme Settings. Updates to the Optional Stylesheets:
    ; OPTIONAL STYLESHEETS

css[new_theme_style.css][name] = New theme global style.
css[new_theme_style.css][description] = This file holds all the globally active custom CSS of Monkey theme.
css[new_theme_style.css][options][weight] = 12
settings[alpha_css][new_theme_style.css] = 'new_theme_style.css'

Changes made in new-theme-alpha-default.css are working, but changes made to new_theme_style.css are not showing. When I use "Inspect element" tools, I see that global.css is called instead.

Is this an issue with the weight I am assigning here? I copied the css over from another subtheme that is working. I cannot pinpoint the problem...but know it is likely a noobie mistake.

Thx - keb


texts: show image field twice with different image style

texts:
In my content type, I am using an image field.

But in display, I want to show this image twice. Once with large style, and another with medium.

How can I do this?


texts: how see left or right sidebar in search result page?

texts:
I'm sorry if it sounds like obvious question, but I cannot solve this... I'm using D7.15, customized Fusion subtheme and Display Suite to style the search result appearance. But all the times I get the search results page in fullscreen (no left or right sidebars) and I can't find the solution for this. No costomizations on search-results.tpl.php.

please help! :/

UPDATE: I'm using drupal core search, I have tried Search by page module too.


texts: Manually laying out specific articles on page

texts:
I'm making a newspaper site and would like to manually lay out and embed a specific set of articles for the front page. Is there a way I can manually code the layout in columns and embed specific articles?

I don't want or expect the articles to be automatically populated when new content is published; I'd like this to be a manual process. Here's an example similar to what I'm hoping to accomplish pulled from today's New York Times layout:


texts: What's your trick to document (in the UI?) variables overridden in settings.php?

texts:
If you define variable overrides in settings.php, there is no visible change to the admin UI. It's easy when overtired (or just inexperienced) to overlook this when changing some config through the UI, and getting an unexpected result.

Have people come up with a trick to document settings.php overrides right in the related admin form? I guess I could write a form_alter every time I define a settings.php override, but is there an alternative clever that devs are using? (I'm using D7, BTW.)


texts: How to add fields (variables) to users to be used in combination with data about events?

texts:
About my site:

I have a site about events where users can:

post and rate events.
confirm that they will attend (everyone can see who will attent).
etc.

Requirement 1: I want to make it so that you can add fields (variables with some value) to users, which resembles what they did. For instance: "User Anon had a red jacket and was drunk".

Requirement 2: Then I would like to have a drop down list:

that is unique PER event
with these fields (variables) which the users can use to add the appropriate values to their own profiles.

That way everyone can see what they did/had at that specific event.

Summary:

The following should be the desired result:

Add fields (variables) to users  .
Must be unique PER event.
Multiple choices possible.
Visible by other users.
Visible on own profile.

What I tried so far:

I tried to use the Views module with references and such. But it didn't work.
Then I tried to achieve it with a poll, which would work but is not unique per event.

My question:
Any ideas how I can get this done?


texts:
Basically I want to create A number of views in a single page pragmatically with each view containing nodes with a certain taxonomy term.

I created a view called mytestview and added to it a Contextual filter -> Content: Has taxonomy term ID.

then I added it to a tpl.php the code below:

  $terms = taxonomy_get_tree(6);
  $term_count = count($terms);
  for ($i = 0; $i < $term_count; $i++) {
  print views_embed_view('mytestview', $display_id = 'default',$terms[$i]->tid);
}

Unfortunately the view gets printed only once with the first argument being the first tid .

I would like to know how could I print the view more than one on the same page with each view having a different term id as a contextual filter and why didnt it print it more than once in the above code.

Thanks in advance .

Edit:
Will basically I just fixed the code like below and now it works I dont know how come it works it just works a little insight will be great

$categories=taxonomy_get_tree(6); ?>
<div><?php
  foreach ($categories as $categorie) {
  print views_embed_view('mytestview', $display_id = 'default',$categorie->tid); ?>
</div><?php
}

thanks again


texts: How to call a controller of custom module when a node is published?

texts:
I am planning to make a module whose controller is called or method in that controller executes when a node is published. The module should be able to get the title and other properties of article that is set to published. Here is controller:

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class myController extends ControllerBase
{
    //Function that should be executed when a specific node is published
    public function publish()
    {
     //here I should get title and other properties of the published node
    }
}

I am new to drupal, I have looked into web and found that the solution is related to hooks but I don't know how to use them. Any help regarding the issue will be appreciated.


texts: Can I use Views templates to theme the row style output of a specific display in my view so it doesn't affect the other displays I created? If so, how?


texts:
What are Drupal Entities in Drupal 7? I understand that Drupal Commerce built Products as an Entity. I know now there is a core Entity API and an contrib add on for Entity API.

I have a few projects this year where I would like to use Drupal 7, NoSQL and possibly the Entity API if it calls for it- but I am having trouble seeing where it would be needed.

Assuming you were building a job listing site- a job isn't necessarily like node content, could/would you make that an Entity?

Additionally, can you still get the ability to talk to modules with the Entity and how is that done? Like, a Job Posting entity getting aliased with Pathauto and exposed in Views as well as appear in XML Sitemap.


texts: Drupal 7 views Contextual filters with Page & Blocks

texts:
I have an issue and i'm hoping to get some advise.

I have a view created that show content based on the url:

eg:

domain.com/item/one

Shows fields for my node with the title one

domain.com/item/two

Shows fields for my node with the title two

etc etc.

The path for the PAGE in views is set to /item

What I'm having trouble with is I need to have a BLOCK (becuase I'm making it collapsable) show under that page with the specific URL show the body field for that node.

eg:

domain.com/item/three

Shows fields for my node with the title three as well as a block that show the body field for node three

I have set the Contextual filter for the PAGE to:

Content: Title

When the filter value is NOT in the URL
Show "Page not found"

Exception value : Empty (All removed)

Under More:
Case : Lowercase
Case in path : Lowercase

Transform spaces to dashes in URL : Checked

This works for the page but please let me know if I have set this up incorrectly.

I have set the same Contextual filter for BLOCK and it works in views preview but not on the page with the URL:

domain.com/item/three

I also tried adding Global: Null Contextual filter before the Content: Title filter which allowed me to put item/three in the preview and it works (before worked with just three). This also didn't work on the actual page.

Any advise on this would be greatly appreciated.


texts: how to change login destination to front page

texts:
I have disabled user login block. I use Menu link to user/login for login. I also used CAPTCHA for login page. But now when I log in to site it stays on user/login page not redirect to front page and gives me an error The webpage cannot be found. Then after refreshing page it shows Access denied
You are not authorized to access this page. Any one has idea to set login destination after login.


texts: How to compare Profile2 field with PCP percentage in drupal 7 while creating Rule?

texts:
I am using Rules, PCP & Profile2 Module in drupal 7. I want to send mail to those user whose profile is <60%, how to add condition for sending mail? How can i compare the profile2 field with pcp %. I already created a Event & Action. Problem in add contion. Please help. Thanks

I want condition like this i.e. $complete_profile<60. If by using php code then how can i implement.


texts: Backport of hook_library() for Drupal 6?

texts:
I've come to love the hook_library() of Drupal 7 as an extremely clean way of including assets etc. I'm fully aware of the many different ways to include assets intelligently (including the context_addassets module) but I'd love a near exact drop in backport for the hook_library() that Drupal 7 provides.

Note: Using mymodule_library() essentially defines a list of css/js (and their dependant libraries) which can be added in one simple call to drupal_add_library()


texts:
I am trying to find a lot on Google how to add Structured data to site and from all the tutorials I got an impression that there is RDF module in core which was supposed to do that work like providing structured data to search engines (Google).

That module is in core and already installed on site, still Google Search Console saying,

  We do not detect any structured data on your site.

Am I missing something? If RDF does not provide structured data to search engines, what is the right method to add structured data to a site? Please, correct me if I am wrong about RDF.


texts:
I have a views block which display user's detail like name, picture and about.
i want to give a read more link in "about" field, by click "read more" link the trimmed "about" will open in the same block.

"About" is a field from view, so in this field text will trim after 200 words if the about field is more then 200 words then after trimmed part there will be a read more link and after clicking this link the whole text will visible on the same position just increase the height of the block.

Thanks


texts:
I would like to pass values to Rules (eg an array of words) and then do some Rules magic with them (eg create new nodes if they dont exist already).

I found one solution here How to reference existing term if it exists or create new one if not exist via Inline Entity Form module?
that mentions creating custom tokens. Looks like the token approach can be involving as per https://www.drupal.org/node/1143842, although there is this module as well Custom Tokens.

Would there be any other way? Perhaps calling a url, and passing the values as GET variables or adding entity properties?


texts: Customizing Webform backend with defaults / hiding elements for simplified usage

texts:
Webform in Drupal 8 comes with loads of customiziation options in the backend which we don't want to show to an average content editor. Further we would like fixed default options because of frontend and accessabilty issues.
E.g for Datepicker we always want it to stick to the jquery Date Picker instead of showing this option to the content editor.

For Title or Description field we would like to always default to "before" and get rid of other options but keep "after"
I've created a custom module with hook_form_alter() on webform_ui_element_form. This works for hiding fields, but not really good for setting defaults.
I've seen there are already some defaults like the one for description text. So maybe this is a good starting point for re-implementing it for other defaults.
Dont't know if thats the way to go?
Maybe someone has done something similar already and could share the experience made so far.


texts: Authentication providers: no token_bearer

texts:
I created a custom resource for a Drupal 8 REST call. For some reason, I can't see either basic_auth or token_bearer from the authentication providers. I installed simple_oauth and still can't see either basic_auth or token_bearer.

The code I am using is the following one.

config/install/rest.resource.sample_index_resource.yml

id: sample_index_resource
plugin_id: sample_index_resource
granularity: resource
configuration:
GET:
  supported_formats:
    - json
  supported_auth:
    - basic_auth
    - cookie
    - token_bearer

src/Plugin/rest/resource/SampleResource.php

/**
 * Provides a Sample Index Resource
 *
 * @RestResource(
 *   id = "sample_index_resource",
 *   label = @Translation("Sample Index Resource"),
 *   uri_paths = {
 *     "canonical" = "/api/sample-response/{category}/{alias}"
 *   }
 * )
 */
class SampleResource extends ResourceBase {
/**
* Responds to entity GET requests.
* @return \Drupal\rest\ResourceResponse
*/
public function get($category, $alias) {
  // Return response
}

The HTTP Basic Authentication module needs to be enabled to be able to use basic_auth as authentication provider. I don't know which module I should enable to be able to use token_bearer.

What module do I need to install to get token_bearer as authentication provider?


texts:
I would like to validate the company name chosen in a form in a "select" form field.

When I try $form_values['submitted_tree']['company_1']; it shows me the key instead of the string value.

I tried the following code, but it still prints '1' (the key) instead of the value associated with the key.

    $_page_num = $form_state['values']['details']['page_num'];
    $key1 = $form_state['values']['submitted_tree']['company_1'];
    $value1 = $form['submitted_tree']['company_1']['#options'][$key1];
    $key2 = $form_state['values']['submitted_tree']['company_2'];
    $value2 = $form['submitted_tree']['company_2']['#options'][$key2];

    if (($_page_num == 2) && ($value1 == $value2)) {
      drupal_set_message(print_r($form['submitted_tree']['company_2']['#options'][$key2]));
    }

Could anyone help me to retrieve the actual text value displayed in select option chosen? I have tried $form_state as well, but it returns the same result.


texts:
By default the Privatemsg Module has three timestamp displays for various lengths the message has been sent. After a certain point the listed 'time' changes.

What I want to do is append the next timestamp to the end of the current one. This way it remains the details of minutes and date posted as time moves forward.

Example: after 24hrs, instead of it just saying 'Oct 8' I want it to say 'oct 8 12:45' and after a year '2014 oct 8 12:45'

I think I found the code in the module where timestamps are printing, I just can't figure out how to add to it.

function privatemsg_date_formats() {
  $formats = array('g:i a', 'H:i', 'M j', 'j M', 'm/d/y', 'd/m/y', 'j/n/y', 'n/j/y');
  $types = array_keys(privatemsg_date_format_types());
  $date_formats = array();
  foreach ($types as $type) {
    foreach ($formats as $format) {
      $date_formats[] = array(
        'type' => $type,
        'format' => $format,
        'locales' => array(),
      );
    }
  }
  return $date_formats;
}

function privatemsg_date_format_types() {
  return array(
    'privatemsg_current_day' => t('Privatemsg: Current day'),
    'privatemsg_current_year' => t('Privatemsg: Current year'),
    'privatemsg_years' => t('Privatemsg: Other years'),
  );
}

function privatemsg_format_date($timestamp) {
  if ($timestamp > ((int)(REQUEST_TIME / 3600)) * 3600) {
    return t('@interval ago', array('@interval' => format_interval(abs(REQUEST_TIME - $timestamp), 1)));
  }
  if ($timestamp > ((int)(REQUEST_TIME / 86400)) * 86400) {
    return format_date($timestamp, 'privatemsg_current_day');
  }
  if ($timestamp > mktime(0, 0, 0, 1, 0, date('Y'))) {
    return format_date($timestamp, 'privatemsg_current_year');
  }
  return format_date($timestamp, 'privatemsg_years');
}


texts: Trying to write custom handler to extend views_handler_field_term_node_tid

texts:
Edit: solved, see first reply for answer.

I am trying to write my views filter handler to extend the views_handler_field_term_node_tid class. I believe I have done everything correctly but I'm having no luck. In my module I have implemented hook_views_api()

/**
* Implements hook_views_api().
*/
function mymodule_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', mymodule') . '/views',
  );
}

Called the handler.inc file and the mymodule.views.inc in the module .info file:

files[] = views/mymodule.views.inc
files[] = views/mymodule_handler_field_term_node_tid.inc

This is the contents of that file:

class mymodule_handler_field_term_node_tid extends views_handler_field_term_node_tid {

  function option_definition() {
    $options = parent::option_definition();
    $options['convert_spaces'] = array('default' => FALSE, 'bool' => TRUE);

    return $options;
  }

  /**
   * Option to replace spaces with hyphens.
   */
  function options_form(&$form, &$form_state) {

    parent::options_form($form, $form_state);

    $form['convert_spaces'] = array(
      '#title' => t('Convert spaces in term names to hyphens'),
      '#description' => t('This allows links to work with Views taxonomy term arguments.'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['convert_spaces']),
    );

  }

  function render_item($count, $item) {
    return $item['name'];
  }

}

And finally I have implemented hook_views_data_alter() in the mymodule.views.inc

/**
 * Implements hook_views_data_alter()
 */
function mymodule_views_data_alter(&$data) {
  $data['node']['term_node_tid'] = array(
    'title' => t('Taxonomy terms on node'),
    'help' => t('Relate nodes to taxonomy terms, specifying which vocabulary or vocabularies to use. This relationship will cause duplicated records if there are multiple terms.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship_node_term_data',
      'label' => t('term'),
      'base' => 'taxonomy_term_data',
    ),
      'field' => array(
      'title' => t('All taxonomy terms'),
      'help' => t('Display all taxonomy terms associated with a node from specified vocabularies.'),
      'handler' => 'mymodule_handler_field_term_node_tid',
      'no group by' => TRUE,
    ),
  );

}

So the weird issue is that running dpm($data); in my mymodule_views_data_alter function before I alter the $data['node']['term_node_tid'] brings up no reference to that data at all. That is being originally defined in taxonomy.views.inc and should be existing in the $data array because I have added the Content: All taxonomy terms field to my test view. I've been pulling out my hair for the last couple hours trying to figure this out with no luck.


texts: Drush out of memory when php memory limit is 1024M on my dedicate server. (CentOS)

texts:
This happened when I restarted Apache because my site was down. Normally restarting Apache or other service doesn't break Drush, but today it happened.

I'm sure on my server my php.ini has memory limit set to 1024M, this is my own dedicate server, and the Drupal installation runs well, I check the status report on Drupal (admin/reports/status), the PHP memory limit is set to 1024M.

This happened on my Drupal sites on my server.

When I...

[root: sites]# drush st

I got

Drush command terminated abnormally due to an unrecoverable error.       [error]
Error: Out of memory (allocated 10485760) (tried to allocate 122880
bytes) in /home/mywebsite/public_html/modules/system/system.module, line 1336

I also tried...

[root: sites]#  php -i | grep memory_limit

And I got

memory_limit 1024M

Is there anyone has some ideas?

My Server:

CENTOS 5.9 x86_64
WHM 11.36.0 (build 14)
PHP 5.2.17
Drush 5.8

I've tried drush status --debug and it gave me :

  Bootstrap to phase 0. [0 sec, 3.02 MB]
  [bootstrap] Drush bootstrap phase : _drush_bootstrap_drush() [0.01
  sec, 3.23 MB] [bootstrap] Cache HIT cid:
  5.8-commandfiles-0-15880291c3f5c759ee66bf106fd77cbd [0.01 sec, 3.24 MB]        [debug] Bootstrap to phase 0. [0.04 sec, 7.43 MB]
  [bootstrap] Drush bootstrap phase : _drush_bootstrap_drupal_root()
  [0.05 sec, 7.49 MB]                [bootstrap] Drush command
  terminated abnormally due to an unrecoverable error.
  [error] Error: Out of memory (allocated 10485760) (tried to allocate
  122880 bytes) in
  /home/mywebsite/public_html/modules/system/system.module, line 1336 [0.06
  sec, 9.28 MB]


texts: How to set default value for route parameter based on configured value?

texts:
I have a route with optional parameter that has some default value:

# file @hello.routing.yml
hello.sayHi:
  path: '/hello/{name}'
  defaults:
    _title: 'Say Hi'
    _content: 'Drupal\hello\Controller\SimpleCallback::sayHiAction'
    name: 'there'
  requirements:
    _permission: 'access content'

I'd like to make there value for {name} parameter configurable. Let's assume that this default value for {name} is available in simple config variable.


texts: Pass a variable from a node to a block module that uses a custom template

texts:
I have a custom module "jsblock." When the page renders, the module should get the title of the page, pass it to drupal_add_js() and ultimately render an output in a block.

I tested the module with the template name suggested by the system. The output rendered in the block as expected. Now, I'm trying to add a custom template to the module but the variable appears to no longer be passed to the block.

Directory structure

I have been playing around with hook_block_view() and a helper function to handle the drupal_add_js() function, but I think I am not attaching it to the block correctly.

jsblock.module file

// Helper

function get_the_page_title() {
  if ($node = menu_get_object('node')) {
    $title = drupal_get_title();
    drupal_add_js(array('jsblock' => array('test' => $title)), 'setting');
  }
}

// Theme
function jsblock_theme($existing, $type, $theme, $path){
  return array(
      'jsblock_custom_theme' => array(
          'variables' => array('content' => NULL),
          'template' => 'jsblock_custom_theme',
          'path' => drupal_get_path('module', 'jsblock') .'/theme/',
      )
  );
}

// Print
function jsblock_block_view($delta = 'jsblock') {
  if($delta == 'jsblock')
    {
      $block = array();
      $block['content'] = get_the_page_title();
      $block['content']['#attached']['css'][] = drupal_get_path("module", "jsblock")."/css/styles.css";
      $block['content'] = theme('jsblock_custom_theme');
      return $block;
  }
}

I checked the console for Drupal.settings.jsblock.test and it is returning the expected value. I can see the block is printing based on an expected outline, but the data is not rendered.

How can I pass the JS variable from the page to the block that uses a custom template?


texts:
I have a select list with some options. But now I also want an option Other. And when you select the Other option there has to open a pop-up screen with the add term to vocabulary form in it. The term should not be added directly to the vocabulary, it should be "disabled" first so the administrator can approve them.

I know how to get the taxonomy form (taxonomy_form_term, drupal_get_form, drupal_render_form) but I have some other questions:

How can I open the popup and show call the function in my module to render the form? Should I add another option to my select list?
How can I make sure when you add it, it doesn't add directly to the vocabulary (admin has to click approve)


texts: Trouble getting a drupal 7 view template to render for a machine readable block

texts:
i'm using drupal 7. I have created a content type called Title and content navigation.

I have setup a template override in /sites/all/themes/themename/templates/views/title-and-content-navigation/block/views-view-fields--title-and-content-navigation.tpl.php which works correctly for all of the displays which are blocks.

I have one of the displays for this view which has a machine readable name of block_8. I am trying to have a separate template file for this but I cannot work out what I need to name the file. I have tried many suggestions from SO and I can't get this to work. I have been flushing all caches. What to name the template files is very confusing.

Thanks in advance


texts: Add Additional Logic To Node Save/Submit Process

texts:
Where can I hook into drupal to modify the value of a specific field just before it is inserted into the database?

For example, lets say I wanted to trigger an email or run an arbitrary piece of code just before the node is inserted into the database?

I've been looking at hook_node_presave and it looks like it will do what I want, but I need it to only apply to one content type.


texts: language back to default language after Ajax reload

texts:
To simplify the question and maybe reproduce the problem, I made a simplier version of what I am doing. I have a form field with ajax. When it triggers it reloads a small piece of html. In it is t('text in one of tree languages'); If I open the page for the first time the same html is loaded and it is in the correct language. But after the reload from the ajax call it is in the website's default language. This only happens when logged in. It is possible that this has to do with the administrator language module. Any help would very much be appreciated.

Ajax Code at hook_form

function hook_form($form, &$form_state) {
  $form['update'] = array(
    '#value' => t('Update'),
    '#type' => 'button',
    '#ajax' => array(
              'callback' => 'callback_function',
              'wrapper' => 'div-to-replace',
              'method' => 'replace',
              'effect' => 'fade')
  );

  // Other form elements

}

Ajax callback function

function callback_function($form, $form_state) {
    return t('test string that should get translated');
}


texts: Can a VBO form be integrated with the Commerce Add-to-Cart form to allow adding optional add-on products with checkboxes?

texts:
With VBO and Rules I can display a list of Commerce products with checkboxes and a button to add the checked products to the cart (see how).

Is there a way to integrate these checkboxes with the default Add-to-cart form from Commerce? I want to have a single Add-to-Cart form with one button, not two forms.

Alternatives I tried:

The module Commerce Product Add-on allows this, but it doesn’t use Views for the list, so I can’t customize the appearance (e.g., group the products).
The module Commerce Add to Cart Extras allows this with input fields for the quantitiy, but not with checkboxes. (The patch in Checkboxes instead of quantity doesn’t seem to work.)

Is there another way/module?

My goal is to display optional add-on products (with checkboxes) on a primary product page. If the user doesn’t select any add-on product, only the primary product is added to the cart; if the user selects add-on products, the primary product and the selected add-on products get added to the cart.

(The question Drupal Commerce - optional extra products on add to cart form seems to have the same goal, but OP seems to be fine with the Commerce Product Add-on module if it would work for him in his case. The question add to cart - multiple products at once seems to be for adding always the full set of products, so without checkboxes.)


texts: Drupal gives error while add content or edit node

texts:
Hi all i am facing this error when try to edit node or add content

Additional uncaught exception thrown while handling exception.

Original

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) 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, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] =&gt; 1 [:db_insert_placeholder_1] =&gt; node [:db_insert_placeholder_2] =&gt; %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] =&gt; a:6:{s:5:&quot;%type&quot;;s:12:&quot;PDOException&quot;;s:8:&quot;!message&quot;;s:238:&quot;SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] =&amp;gt; drupal_http_request_fails ) &quot;;s:9:&quot;%function&quot;;s:14:&quot;variable_set()&quot;;s:5:&quot;%file&quot;;s:74:&quot;/home/apetrdo6/public_html/Development/InfinityPups/includes/bootstrap.inc&quot;;s:5:&quot;%line&quot;;i:991;s:14:&quot;severity_level&quot;;i:3;} [:db_insert_placeholder_4] =&gt; 3 [:db_insert_placeholder_5] =&gt; [:db_insert_placeholder_6] =&gt; http://apetrailportfolio.com/Development/InfinityPups/node/add/dogs [:db_insert_placeholder_7] =&gt; http://apetrailportfolio.com/Development/InfinityPups/node/add/dogs [:db_insert_placeholder_8] =&gt; 103.63.25.150 [:db_insert_placeholder_9] =&gt; 1473159652 ) in dblog_watchdog() (line 160 of /home/apetrdo6/public_html/Development/InfinityPups/modules/dblog/dblog.module).

Additional

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 AS expression FROM {variable} variable WHERE ( (name = :db_condition_placeholder_0) ); Array ( [:db_condition_placeholder_0] =&gt; drupal_css_cache_files ) in variable_set() (line 991 of /home/apetrdo6/public_html/Development/InfinityPups/includes/bootstrap.inc).

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: UPDATE {users} SET access=:db_update_placeholder_0 WHERE (uid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] =&gt; 1473159609 [:db_condition_placeholder_0] =&gt; 1 ) in _drupal_session_write() (line 219 of /home/apetrdo6/public_html/Development/InfinityPups/includes/session.inc).

Uncaught exception thrown in shutdown function.

PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] =&gt; 80080962057cea1b962fce6.76953018 ) in lock_release_all() (line 269 of /home/apetrdo6/public_html/Development/InfinityPups/includes/lock.inc).


texts:
I'm trying to setup a new project using the Drush make command. I'm working on localhost (xampp) on a Windows 8.1 machine.

The problem is that if a module present in my make file requires an external library (e.g. colorbox or plupload), make will detect that and will download said dependency, but then will fail to decompress it, resulting in the following error:

plupload-7.x-1.7 downloaded.                                                [ok]
Found makefile: plupload.make                                               [ok]
plupload downloaded from                                                    [ok]
https://github.com/moxiecode/plupload/archive/v1.5.8.zip.
Unable to unzip                                                          [error]

As a result, the whole make operation is aborted.

I searched for a solution and found this stackoverflow answer that seems to address my problem but is not very detailed. I tried using Cygwin (x64), found an "unizp" package in it, tried to download it and copy the unzip.exe file in the Program Files (x86)\Drush\GnuWin32\bin folder, but now when I run my make project I have a new error message, this time as a dialog box (not in the console, then):

The program can't start because cygbz2-1.dll is missing from your computer.
Try reinstalling the program to fix the problem.

Followed by a unzip.exe has stopped working Windows dialog box.

I can find the missing DLL (cygbz2-1.dll) in the C:\cygwin64\bin directory. So I tried adding this path to my PATH environment variable (and restarted my computer to be sure), but I still have the same "missing DLL" error.

Is there something I'm doing wrong
(I'm not familiar with cygwin at all, so I don't know if I'm using it right...)?


texts: Lightbox 2 - Embeded Media Field / Media : Youtube can't play videos on LightBox2

texts:
I tried using both 'Embed media field' and 'Media : Youtube' module in D& website to create a content-type field to embed youtube videos and play in on lightbox2. Although images work well with the lightbox, there is some problem with videos.I enabling the videos settings under configuration/User interface/Lightbox2 but is of no use.

All i want is to play youtube videos in the lightbox


texts: How to override or change a view block/region based on my frontpage template?

texts:
I have 2 different frontpages templates based on user´s device so I have:

- mytheme/page--front.tpl.php
- mytheme/page--frontmob.tpl.php

and I have 2 different view blocks (even they are located in same region(Banner Home area 1) should work based on the frontpage that user is using at the moment)

- View: Available concerts operas ballets pages: Video main
- View: video main mobile

So actually I am using the following code in my template.php

function myclassiclive_preprocess_page(&$variables) {

  if (drupal_is_front_page()) {

     include_once ('sites/all/libraries/Mobile_Detect/Mobile_Detect.php');
      drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/bluemasters.js');
        $GLOBALS['conf']['cache'] = FALSE;

        if ($detect->isMobile()) {
             $variables['theme_hook_suggestions'][] = 'page__frontmob';
        }

   }
}

And the above code is working so when I visit the site on mobile it uses the page__frontmob template which is this=> mytheme/page--frontmob.tpl.php

My page--frontmob.tpl.php is different than my page--front.tpl.php but actually the biggest difference is that in my region Banner Home area 1 should appear the view block => View: Available concerts operas ballets pages: Video main only when site is using this front page=> page--front.tpl.php because I am using this template for desktop user´s BUT if the site is using the frontpage: page--frontmob.tpl.php then the view that should appear on the region Banner Home area 1 must be View: video main mobile but what is happening now that the even the site is showing the right frontpage template whether the site is displayed on desktop or mobile device... but STILL both of the views are displaying without caring the frontpage template using at that moment....

I thought because of the next setting in each one of the block´s configuration... would be enought in order system check´s by itself in what frontpage the user is in order to show only one of the blocks that are located in same region: Banner Home area 1

Both block´s configuration:
Setting:

Show block on specific pages:
Only the listed pages
<front>

So in summary what I want is:

this frontpage template page--front.tpl.php displays only the view: View: Available concerts operas ballets pages: Video main in the region=> Banner Home area 1
and this frontpage template page--frontmob.tpl.php displays only the view: View: video main mobile in the region=> Banner Home area 1

I already have checked the functions THEMENAME_preprocess_region and MYTHEME_preprocess_block(&$variables) but I dont if I have to use one of those? which one I should use in my problem case? and I dont know how I should use them?

Please help!!!!
My code is already tetecting which frontpage site uses based on user´s device so that is not the point but the block views displayed in same region based on frontpage site is using or also can be based again on user´s device.

Thank you everyone in advance for your help!

Liz ;)


texts: What to set up in a Kernel test to get custom content type to be available

texts:
I have a custom module that defines a service and a custom content type. I have successfully written a Functional test for the service. Now, I'm seeing if I can write a Kernel test instead.

The issue that I'm encountering is that my custom content type has custom fields (naturally). When I create a piece of content of that type in the Kernel test environment, Drupal is not recognizing the custom fields.

I am using the EntityKernelTestBase.
I have set public static $modules = array('my_custom_module', 'node');

What piece(s) am I missing? I'm guessing there is some schema I need to say to install or some other method I need to call so that those custom fields are recognized.

<?php

namespace Drupal\Tests\my_custom_module\Kernel;

use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;

/**
 * Tests the my custom service.
 *
 * @group my_custom_module
 */
class MyCustomServiceKernelTest extends EntityKernelTestBase {

  /**
   * Modules to install.
   *
   * @var array
   */
  public static $modules = array('my_custom_module', 'node');

  /**
   * {@inheritdoc}
   */
  public function setUp() {

    parent::setup();

    $user = $this->createUser();

    $container = \Drupal::getContainer();
    $container->get('current_user')->setAccount($user);

    // Create some aquifer pieces of content
    $node = Node::create(array(
      'title' => t('Some title'),
      'type' => 'my_custom_content_type',
      'language' => 'en',
      'field_my_custom_field_1' => 'Put stuff here',
      'field_my_custom_field_2' => 'more stuff',
      'field_my_custom_field' => 1000000,
    ));
    $node->save();
    $reloaded_entity = $this->reloadEntity($node);
    $this->assertSame('debug', $reloaded_entity);
  }
}

The debug assert statement shows that the reloaded entity does not contain my custom fields.

If I put a $node->set('field_my_custom_field_1', 'some value') statement in the code instead of passing those fields in the Node::create logic I get an error that the field name is not valid.


texts: How to assign a user a title based on the number of created nodes?

texts:
I want to set up a system where a user is given a title based on how much content they have created/published. So, for instance, if the user has published:

0 nodes  - Noobie
1+ nodes - Poster
10+ nodes - Frequent poster
20+ nodes - Super Poster
50+ nodes - God`

I'm wondering if there is a way to implement this in a Drupal site. I can think of a way to do it using database queries and a computed field, but I'm wondering if there might be a more efficient way to go about doing it.


texts: How to add a custom Save &  button to Node Add/Edit form?

texts:
I added the following code in hook_form_alter() and I get my button on the Add/Edit node form:

$form['actions']['save_add_lesson'] = array(
  '#type' => 'submit',
  '#value' => 'Save & Add a Lesson',
  '#name' => 'op',
  '#submit' => array('mymodule_node_form_submit'), /* NEED this */
  '#weight' => 1000
);

But, clicking the button doesn't seem to hit hook_node_submit() or hook_node_insert(). I'm assuming I'm missing a hook or something in the button creation...anyone have any ideas?

Then added this function:

function mymodule_node_form_submit($form, &$form_state) {
  // Do stuff before saving the node

  // Call this to save the node
  node_form_submit($form, $form_state);

  // Do stuff after saving the node
}


texts:
I'm altering different emails from my hook_mail_alter(&$message) function. But for some reason altering the email sent by commerce invoice module is not working. I'm trying to do it like:
switch($message['id']){
    case 'invoice_confirmation':
      $message['subject'] = 'Some other title';
      break;

I found the code that sends that email in invoice module:
  public function send(InvoiceInterface $invoice, $to = NULL, $bcc = NULL) {
    $to = isset($to) ? $to : $invoice->getEmail();
    if (!$to) {
      // The email should not be empty.
      return FALSE;
    }

    $subject = $this->t('Invoice #@number', ['@number' => $invoice->getInvoiceNumber()]);
    $body = [
      '#theme' => 'commerce_invoice_confirmation',
      '#invoice_entity' => $invoice,
      '#totals' => $this->invoiceTotalSummary->buildTotals($invoice),
    ];
    if ($billing_profile = $invoice->getBillingProfile()) {
      $body['#billing_information'] = $this->profileViewBuilder->view($billing_profile);
    }

    $params = [
      'id' => 'invoice_confirmation',
      'from' => $invoice->getStore()->getEmail(),
      'bcc' => $bcc,
      'invoice' => $invoice,
    ];
    $customer = $invoice->getCustomer();
    if ($customer->isAuthenticated()) {
      $params['langcode'] = $customer->getPreferredLangcode();
    }
    $file = $this->invoiceFileManager->getInvoiceFile($invoice);
    $attachment = [
      'filepath' => $file->getFileUri(),
      'filename' => $file->getFilename(),
      'filemime' => $file->getMimeType(),
    ];
    $params['attachments'][] = $attachment;

    return $this->mailHandler->sendMail($to, $subject, $body, $params);
  }

}

and there I saw that id should be 'invoice_confirmation', but like my hook function is never reached when this email is sent?! How to alter this email title?


texts:
I need to force IE to show my site in compatibility mode, and I know I can just add a META header. The problem is how... can anyone point me in the right direction please? I'm running a custom theme.

Thanks


texts: How to modify the language switcher block to only use the language code instead of its full name?

texts: In the Language selection block, I have only the possibility to use the full language name. How can I change it to use the language code, for example FR instead of French?


texts: How to theme the controls of an Openlayer map?

texts:
The Openlayers module comes with a default set of maps. It's possible to add layer templates, but it seems that the controls are always the same (see image). The controls exist of images that are located on a CDN such as http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/img/zoom-plus-mini.png

Is there a way to style the controls of Openlayer maps? In other words to apply your own CSS or images to it?


texts: How to keep underlying file when deleting a Filefield value

texts:
I have a Content Type with a FileField (Image, in particular). When one of these values is deleted, then Drupal deletes the underlying file as well (as long as no other nodes reference the same file).

I don't want the underlying files to be deleted, I want them to remain in the filesystem. Are there any hooks or other techniques I can use to make sure it remains after its FileField value is deleted?


texts:
I am rendering ajax link as follows:
l(t('Click here'), 'mypath', array('attributes' => array('id' => 'my-id', 'class' => array('use-ajax'))));

How to display confirmation dialog before ajax request is called?
I do it as follows in javascript, like I have found on this thread:
  Drupal.behaviors.module = {
attach: function() {

 Drupal.ajax['my-id'].beforeSerialize = function () {

      if(confirm('Are you sure?'))
          return true;
      else
          return false;

  }
 }
}

When I click on link, ajax request is not called but the dialog appears. It is ok. The problem is, that after I click "Cancel" in confirmation dialog, Ajax request is then called after closing the confirmation dialog.
Can anybody help, how to get the confirmation dialog work?


texts: Change a variable dynamically without it persisting in the DB

texts:
I am wanting to change a variable (google analytics ID) programmatically based on the environment, BUT I do not want to change the saved value, so variable_set() is not an option.

Ideally I would also like the value that I set to be cached so as to not undermine performance.


texts: If I'm creating nodes programmatically does Drupal deal with filter_xss(), or do I have to add the function to my code?


texts:
Why would Views not be showing its contents, for example...

Here's what I have in the source code, this is a straight view source from the browser.

<div class="view view-full-bg-homepage-slider view-id-full_bg_homepage_slider view-display-id-page view-dom-id-a6084598ca3a2b981c6f6344dfe47c51">

Whole bunch of whitespace here

</div>

I'm using Latest versions of everything. Views UI and Context UI are each turned off at the moment, as a test, but this hasn't seemed to help.

Could it be a memory error? Can provide more info, just not to sure what to provide at this stage.


texts: How to add multiple taxonomy terms to node?

texts:
I'm new to PHP and Drupal module development.
I'm having a site on which the users can create their own posts(nodes).

Can someone help me with how to save multiple taxonomy terms to a node. The users are filing their post in a form and the data is sent back through ajax. For example the taxonomy terms are sent to the server in this format: apple, banana, orange.
I don't know how to save all these terms to a node.


texts: Using Drush To Download Modules When You Dont Really Know The Name

texts:
Hello im a drush newbie and im enjoying ints functionality. Years ago i saw a video of someone using drush to download modules and if he got the project name slighly wrong t would show him some alterntives in his command line interface.

Did i imagine this or is it possible?

Thanks

ps i just use drush dl modulename at the moment


texts: How do I attach a link or image to a radio/select input element

texts:
I want to attach an image-link to every input element.
Is it possible to do it on entity fields or on webform fields?
I prefer to it on server side.


texts: Tabular data in Drupal: create a field with multiple attributes

texts:
Hello again

What I want to do is simply like creating tabular form, that the user can edit attributes of each row.

In detail, I have a content type lets call it Website, this content type should contain predefined Stages and Processes. For each Stage/Process the user should be able to check as done, or enter a reference or notes, or any another related operations.

As an Examples

Feed the cat ---- (checkbox) ---- Reference ---- Notes

So, how could I represent this tabular form in Drupal 7?

Is there any module specially made for this purpose?

Hope you can help guys

Best and peace


texts: How to add link to create relationship in a view

texts:
In my project, I have user relationship module installed. I created a view of online users. I then tried to include a link to enable users "add friends or create relationship" in the view by adding the following code

 global $user;
  $opt = '';
  $requestee_id = $row->uid;
  $requester_id = $user->uid;
  if (user_is_logged_in()) {
    if ($requestee_id != $requester_id) {
      //for friend request button
      $relationships = user_relationships_load(array('between' => array($requester_id, $requestee_id)));
      if (empty($relationships)) {
        $opt = l(t('Add Friend') , "relationship/$requestee_id/request/1", array('html' => TRUE, 'absolute' => TRUE, 'query' => array('destination' => 'user/' . $requestee_id), 'attributes' => array('class' => array('ur-link add-friend-btn user_relationships_popup_link'))));
      }
      else {
        foreach ($relationships as $relationship) {
          if ($relationship->approved == 1 && user_relationships_ui_check_access('view', NULL, $relationship)) {
            $opt = t('Friends');
          }
        }
      }
    }
  }
  print $opt;

When I try to create a relationship, i am informed that "this user does not exist". Please what could I be doing wrong.

P.S: I have 2 relationships on my site.
Thanks in anticipation.


texts:
So I was considering using hook_init() to do stuff but I'm not understanding what it means when it says that "This hook is not run on cached pages." Oh really?

So as an experiment I made sure caching was turned on for anonymous users, and went to the site in a browser window where I was not logged in. So I was definitely getting some cached pages, right? Then I added this to my module

function mymodule_init() {
  $num = rand(0,1000);
  drupal_set_message($num);
}

I figured if the hook wasn't being run, then I shouldn't get a random number each time I viewed the page. I wasn't sure if I should even get a message or not! But I am getting a different random number each time. So what exactly does it mean when it says that the hook isn't being run on cached pages? And when is it NOT ok to use this hook? Sorry if it's something obvious I don't know.

-- edit --

Thanks for the answer. I should have realized the drupal_set_message thing was causing the page not to be cached. So I went back and I also tried adding java script like this:

function mymodule_init() {
  $num = rand(0,1000);
  drupal_add_js(array('mymodule' => array('rand' => $num)), 'setting');

  $path = drupal_get_path('module', 'mymodule');
  drupal_add_js($path . '/js/mymodule.js');

  echo $num;
}

And in my javascript file:

(function ($) {
    Drupal.behaviors.mymodule = {
        attach: function(context,settings) {
            var num = Drupal.settings.mymodule.rand;

            alert(num);
        }
    }
})(jQuery)

It still seems to alert a random number every time. So is drupal_add_js also disabling the cache? I even tried using a simple echo statement in hook_init() and it still seemed to echo a random number. So are all these things causing the page not to be cached or does hook_init() still get run somehow?


texts: Have configuration form use a different theme than the currently set Admin theme

texts:
I built a custom configuration form with the following settings

The contents of my aaep_settings_main.routing.yml

my_settings:
  path: '/admin/config/system/my_settings'
  defaults:
    _form: 'Drupal\my_settings\Form\SettingsForm'
  requirements:
    _permission: 'administer site configuration'

And then inside my SettingsForm.php I have

class SettingsForm extends ConfigFormBase {

protected function getEditableConfigNames() {
    return array(
        'my_settings.settings',
    );
}

public function submitForm(array&$form, FormStateInterface $form_state) {

    $this->config('my_settings.settings')
         ->set('test', $form_state->getValue('test'))
         ->save();
}

public function buildForm(array $form, FormStateInterface $form_state){
    $config = $this->config('my_settings.settings');
    $form['test'] = [
         '#type' => 'textfield',
         '#title' => t('Test'),
         '#default_value' => $config->get('test'),
    ];
}

It works just fine, but when I visit the page it's using the admin theme instead of the regular theme. I'm assuming that's because it's using a configuration form and extending ConfigFormBase. I'm assuming that that's the default behavior. But is there a way to override that and have my configuration page use my site theme instead?


texts: How can I display the value of a variable inside a condition?

texts:
I have created a rule using the Rules UI. My rule is not working, and I need to debug it, displaying the values of my variables inside a condition where I make a comparison.

I see within Rules Actions that I can add a system message, but in condition how could I debug variable values?

Rules debug log doesn't show value of variables.

How can I do so?


texts: How can I link Fields in a View to the entity it belongs to?

texts:
How can I link Fields in a view to the entity it belongs to, along the lines of 'Node: Link' or 'Link this field to its node' in Views D7? Do I have to define anything special to give me a field in Views Field to pick from to enable this?

Also, instead of just link to the defaultUri, how could I use a pathauto aliased path if it exists instead of the entity uri?


texts: Accessing Drupal core functions in object-oriented code: Call to undefined function

texts:
I'm a Drupal procedural programmer new to OOP and enjoying it, so some of the techniques are new to me.

I'm getting a fatal error when I'm calling a standard drupal function from within code called within an object that creates a custom Rule. It appears that it's looking for the function drupal_json_encode_helper on the Action object rather than from where it's supposed to look. But why? And how to I tell it to search within Drupal-land rather than object-land?

I'm on D7 with xautoload and composer, modifying the fluxdropbox module that uses fluxservices to use PSR-0 for external libraries.

  "Fatal error: Call to undefined function
  Drupal\fluxdropbox\Plugin\Rules\Action\drupal_json_encode_helper()"

Here's the code:

<?php

/**
 * @file
 * Contains MakeNodes.
 */

namespace Drupal\fluxdropbox\Plugin\Rules\Action;

use Drupal\fluxdropbox\Plugin\Service\DropboxAccountInterface;
use Drupal\fluxdropbox\Rules\RulesPluginHandlerBase;

/**
 * Action for posting a status message on a page.
 */
class MakeNodes extends RulesPluginHandlerBase implements \RulesActionHandlerInterface {

  /**
   * Defines the action.
   */
  public static function getInfo() {
    return static::getInfoDefaults() + array(
      'name' => 'fluxdropbox_make_nodes',
      'label' => t('Make Nodes from Text Fiels'),
      'parameter' => array(
        'account' => static::getAccountParameterInfo(),
      ),
    );
  }

  /**
   * Executes the action.
   */
  public function execute(DropboxAccountInterface $account) {
            //here I build a nice array
            file_put_contents(drupal_json_encode_helper($feed_array), $path . '/novel.txt');

  }
}


texts: Create a real taxonomy with drupal taxonomy and pathauto

texts:
I'm creating a taxonomy for reptiles in drupal and wish to use pathauto for the term url's. The problem is to find the right tokens (I do have entity token installed). Lets look at an example of the taxonomy-tree for the vocabulary Reptiles:

Lizards
--Family
----Genus
------Species

So far so good:

[term:vocabulary]/[term:parent:parent:parent]/[term:parent:parent]/[term:parent]-[term:name]

result: /reptiles/lizards/family/genus-species

However sometimes there is also a subspecies, thus:

Lizards
--Family
----Genus
------Species
--------Subspecies

then starting at the lowest level and using [term:parent] doesn't work anymore.

Been looking for [term:child] and to generate the path from the opposite direction but I find nothing similar. Another way would be if I could define the term patters with levels in the hierarchy?

something like this:

    [term:vocabulary]/[term:level:1]/[term:level:2]/[term:level:3]-[term:level:4]-[term:level:5]

Maybe someone else knows how to crack this nut?

A better example on the outcome I seek:

/reptiles/lizards/gekkonidae/phelsuma-klemmeri

or as with a subspecies:

/reptiles/lizards/gekkonidae/phelsuma-klemmeri-subsp


texts: How do I remove a configuration object from the active configuration?

texts:
I'm writing a custom module for Drupal 8. It defines a field storage configuration object, in a file called modules/mymod/config/install/field.storage.bloom_stem.bs_twitter_ac.yml.

The problem is that this is not removed when I uninstall the module; it is apparently left behind because, when I re-install the module, I get a crash.

drush -y pm-uninstall mymod
drush cr
drush -y en mymod

  exception 'Drupal\Core\Config\PreExistingConfigException' with message 'Configuration objects (field.storage.bloom_stem.bs_twitter_ac) provided by mymod already exist in active configuration'

So it seems I need to some how manually remove this configuration object. Do I need to provide some more code that deletes it when the module is uninstalled?


texts: When using drupal_add_js with the 'setting' option, do the set variables apply for all users?

texts:
I am trying to find out if the following function will just set the JavaScript variable for that specific user, or if it will switch back and forth between usernames.

function my_module_form_submit($form, &$form_state) {
  $username = custom_get_username_function();
  drupal_add_js(array('user' => $username), 'setting');
}


texts:
I have followed the "hello world" module tutorial at https://www.drupal.org/developing/modules/8.  At the end of the tutorial, you create a custom page which gets generated from a render array you created in the module's controller.  The content is a single line of text, contained in the #markup field in the render array.

Now I'm trying to go beyond and create a more complex page, with some ajax-enabled elements.  Hard-coding a bunch of HTML and Javascript into the #markup field does not seem to be the way to go.  And looking through other modules, I see that most do not have a #markup field, but a bunch of other fields, some of which seem to be custom fields (possibly adhering to an unknown naming convention), and others which appear to be defined by Drupal core.  But in some cases it's not clear which are which, and after hours of searching the Drupal documentation and the wider internet, I cannot find a clear explanation of how the different fields in the array are interpreted and translated into HTML.  (It seems that "theme hooks" may be involved somehow, but it's not clear to me which hooks are needed or where those hooks should be defined)

Can someone provide or point me towards an explanation of how to get to a desired HTML layout and set of javascript behaviors using render arrays?


texts: Submit handler is not called from theme function

texts:
I am actualy trying to build up a dragable table, but for some reason after implementing the theme_function, my submit handler is not longer getting called.

This is what my Code actualy looks like:

function he_ministerienschalter_theme($existing, $type, $theme, $path) {
  $themes = array(
    'he_ministerienschalter_admin_form' => array(
      'render element' => 'element',
    ),
  );
  return $themes;
}

/**
  * Implements the ministerschalter admin form
  */

function he_ministerienschalter_admin_form($form, &$form_state, $form_id, $item) {

  $domainnames = he_ministerienschalter_domainselect();

  $count = 0;
  $form['ressortswitch'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
    '#tree' => TRUE,
    '#theme' => 'he_ministerienschalter_admin_form',
  );
  foreach ($domainnames as $key => $domainname) {
      $form['ressortswitch'][$key]['domainID-'.$key] = array(
        '#type' => 'value',
        '#value' => $domainname['domain_id'],
      );
      $form['ressortswitch'][$key]['domainname-'.$key] = array(
        '#type' => 'item',
        '#title' => $domainname['sitename'],
        '#size' => 60,
        '#maxlength' => 128,
      );
      $form['ressortswitch'][$key]['domainshort-'.$key] = array(
        '#type' => 'textfield',
        '#default_value' => $domainname['sitename'],
      );
      $form['ressortswitch'][$key]['weight-'.$key] = array(
        '#type' => 'textfield',
        '#default_value' => !empty($domainname['domain_weight']) ? $domainname['domain_weight'] : '0',
        '#size' => 3,
        '#attributes' => array('class' => array('item-row-weight')),
      );
      $count++;
    }

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

  return $form;
}

/**
  * Theme callback for the he_ministerienschalter_admin_form
  */

function theme_he_ministerienschalter_admin_form($variables) {
  $element = $variables['form'];
  drupal_add_tabledrag('ressortswitch_table', 'order', 'sibling', 'item-row-weight');
  $header = array(
    t('Domainname'),
    t('Domainshort'),
    t('Weight')
  );

  $element_items = array();

  foreach($element['ressortswitch'] as $id => $record) {
    if(is_int($id)) {
      $element_items[] = $record;
    }
  }

  $rows = array();
  foreach ($element_items as $id => $item) {
      $domainNAME[$id] = $item['domainname-'.$id];
      $domainSHORT[$id] = $item['domainshort-'.$id];
      $domainWEIGHT[$id] = $item['weight-'.$id];

    $rows[] = array(
      'data' => array(
        drupal_render($domainNAME[$id]),
        drupal_render($domainSHORT[$id]),
        drupal_render($domainWEIGHT[$id]),
      ),
      'class' => array('draggable'),
    );
  }

  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array('id' => 'ressortswitch_table'),
  ));

  $output .= drupal_render($element['ressortswitch']['submit']);

  return $output;
}

/**
  * Implements hook_form_submit
  */

function he_ministerienschalter_admin_form_submit($form, &$form_state, $item) {
  db_delete('he_ministerienschalter')
  ->execute();
  $count_domains = $form_state['values']['ressortswitch']['count'];
  $count = 0;
  // dpm($form_state);
  dpm($form_state);
  while($count < $count_domains) {
    db_insert('he_ministerienschalter')
      ->fields(array(
        'domain_id' => $form_state['values']['ressortswitch'][$count]['domainID-'.$count],
        'domain_short' => $form_state['values']['ressortswitch'][$count]['domainshort-'.$count],
        'domain_weight' => $form_state['values']['ressortswitch'][$count]['weight-'.$count]
    ))
    ->execute();
    $count++;
  }
  drupal_set_message('Eingabe gespeichert');
}

Any idea how to solve that?


texts: Can I use Views Bulk Operations or something similar to create an archive of files generated by Views data export?

texts:
Using Views Data Export, I have multiple CSV files generated/provided by several different displays.  Rather than setting up something where the user clicks a "Download CSV" button corresponding to each Views display, I'd like to have a single button where all of the files are zipped into a single archive file that is downloaded.

I know Views Bulk Operations has the ability to take multiple managed files and create a zip archive from them...  Is it possible to use custom actions or VBO somehow to achieve what I'm looking to do?  Or is there a better way to do something like this?  Any advice would be appreciated!