texts: cck delta values: delta with leading space = "historical change," no leading space = "multiple selection?"

texts:
One of our sites began exhibiting a periodic bug where users would try to save their profiles and get an error about an illegal value in one of the fields (a cck field for "industry," fwiw, that we disabled by removing edit permissions for it a month ago). The field has a number of possible values as checkboxes, so users were able to pick more than one when the field was available to them for editing, prior to us disabling it.

We noted that admin users could save the profiles, and that they would then begin to be savable by users with normal privileges.

We zeroed in on the content_field_industry table, and began running through cases with assorted users before we finally figured out that field records with multiple deltas sometimes suffered from the issue, but other times didn't. After more digging around, we finally observed that:

if the record had more than one delta and values in the field_industry_value column had a leading space, the record would fail to save for normal users
if an admin user saved the user profile, any delta records with a leading space in the field_industry_value column would be destroyed and the profile would become editable by a normal user
if the record had more than one delta and the values in the field_industry_value column had no leading spaces, normal users could edit their profiles with no error

We don't want to lose the data, but we don't want it to be edited by normal users anymore, either, and we don't mind the thought of losing meaningless deltas (the ones that serve a historic purpose rather than a "this is a multiple selection" purpose).

Is there a safe way to clean up this issue, perhaps by simply deleting leading-space deltas?


texts: convert a cck field from integer to string (text)

texts:
How do I convert an existing integer field to text without having to copy paste manualy each value on each node and then delete the old integer field
I´m using Drupal 7.9

I tried altering the database.. on the definition of the field and the value type
I'm still getting errors

Notice: Undefined property: stdClass::$field_ubi_gps_x_format en field_sql_storage_field_storage_load() (línea 360 de /modules/field/modules/field_sql_storage/field_sql_storage.module).

Notice: Undefined variable: regexp en number_field_widget_validate() (línea 389 de /modules/field/modules/number/number.module).
Warning: preg_replace() [function.preg-replace]: Empty regular expression en number_field_widget_validate() (línea 389 de /modules/field/modules/number/number.module)

that is because the validation and presentation of the field has remained as integer..
I can't find in the DB where it stores that to copy if from another text field

I've so far altered field_data_field_FIELDNAME_THAT_WAS_INT changing field_FIELDNAME_value
from int to varchar and paradores_field_config . copying the blob data field from a text to ID of the FIELDNAME and using text on type and module fields


texts:
I have a bunch of sites built off the same profile, and recently noticed the pages aren't being cached. I spent some time doing the usual: looking for drupal_set_message calls, disabling all the modules that might disable page cache, as defined here. I've also dug into drupal_page_get_cache. This lead me to the database, where it turns out the cache_page table is empty.

This is clearly the source of the issue, I'm just not sure how/what is preventing the page cache. What I'd like to do is to figure out where page cache is writing to the database, and do a debug_backtrace, or just dpm from that point backward.

A) Is there a point in drupal core where cache_page is written to?
B) Any other ideas for debuggings this? (please don't say disable all modules, then re-enable, we have upwards of 200 modules in place with a dozen custom module with interdependencies)

After posting this I opened my IDE and realized I had found the DrupalDatabaseCache->set method, and that the cache_page $cid is never called into that function.


texts: How to give to the users the opportunity to change role as desired

texts: As the title says, I would give to members a way to choose their own role as required via radio buttons in their profile page. Any suggestion?


texts:
I've been developing my Drupal site locally and am planning to migrate it to a proper live host server. When going through the guide to track Drupal with Git, I noticed that it says to put settings.php in the .gitignore because it contains sensitive database info, namely as login credentials.

My local database is open to anyone, so the commented-out privileges portion in the default settings.php file doesn't seem to matter now. However, the database on the live server will have a proper username/password combo. To my (limited) knowledge, it sounds like I'll have to put these in setting.php in order for my site to be able to log in.

My question is: Why is it safe to put these credentials in the public www folder under /sites/default/settings.php but not put them in Git? Is that not safe either? What's the proper, secure way to give my site access to my database?


texts: creating nodes with many to many relationship type with some fields?

texts:
This is in line with How to structure a "many-to-many" relationship between nodes.

To keep things in line with the example from the linked thread, what if i was a book warehouse and i had a list of all my books but i want to allow each seller to name his own price and show that book in the seller's store view with only the price that he set?

How would I allow him to edit the info of his entry without having access to anyone else's entry? I am trying to avoid associating nodes from different content types like creating a node type seller's price and reference a book inside of it.

I thought about a combination of field collection, content access, and TAC to try to make each seller capable of entering and editing their own price field collection. While I thought that field collection would create a new collection for every user, this doesn't seem to work: All sellers end up editing the same collection.

Do you have any idea?


texts: Using theme hook, how do I get block contents into the $comm line?

texts:
if ( isset($vars['content']['#block_content']) ) { // check for custom content
    if ($vars['content']['#block_content']->type[0]->getValue()['target_id'] == 'js_file_block') { // only run on js_file_block types
      $storage = \Drupal::entityTypeManager()->getStorage('block-content');
      $comm = current($storage->loadByProperties(['type' => 'block']));
      $route_match = \Drupal::routeMatch();
      $vars['inlinejs2'] = array();
      if ($comm !== false) {
        foreach ($comm->get('field_js_url') as $script_block) {
          $vars['inlinejs2'][] = $script_block->value;
        }
      }
    }
  }

I dont know what I am doing wrong, but it will not make the array.


texts: I have a multi-site setup with three themes. They look the same, but they are different in colors. What are best practices to setup my theme structure, in themes/custom/site1, site2, and site3, or in sites/site1/themes, sites/site2/themes, and sites/site3/themes?


texts: CKEditor configured MediaEmbed button doesn't appear in toolbar

texts:
I have updated my CKEditor profiles to display the MediaEmbed button. The profile is saved, but when editing content, the button doesn't appear in my toolbar.
I'm using CKEditor 4.4, oEmbed plugin 1.17, jQuery 1.10 and the latest version of the CKEditor module.

Here's a screenshot of the config:

And another screenshot of the actual toolbar:

Any idea why?


texts: How do allow an exposed filter to override another filter in Views?

texts:
I have a view that display content on the site. I have the following hidden filters on it:

Published: Yes
Posted Date: Relative 'today'

Then I want to add a second Posted Date filter but expose it for a user to enter their own custom dates Is between Start date and End date. I then want the view to ignore the hidden exposed filter that is set to 'today' and use the user defined dates.

EDIT:

The default one is a relative date format and the exposed one is to be a jquery date popup.

Thoughts?


texts:
I know this is possible in views -> style settings of a field, but what if you can't customize the fields?

I would like to add css to the mini calendar from the calendar-module depending on the value of a field called 'field_location'.

So class="fri mini future has-events " becomes class="fri mini future has-events field_location"

I copied the calendar-mini.tpl.php and on line 49 I changed

< td id=" < ?php print $cell['id']; ? >" class="< ?php print $cell['class']; ? >">

into:

< td id=" < ?php print $cell['id']; ? >" class="< ?php print $cell['class'] ' ' . $node->field_location['und'][0]['value']; ? >">

If I use $node = node_load(736); it works, but it adds the 'field_location' of that node to all classes.
I need to place the right 'field_location' in the right class.


texts: How to denote a user as a "system account"?

texts:
In the Unix world, there are "user accounts" for humans to use, and there are "system accounts" for software to use.

On a Drupal site, I have a couple of system accounts intended for use by services.module API calls.

I'd like these accounts to be able to log in via the services API (obviously), but I would like to block these accounts from being used to log in via the standard user_login form.  I'd also like to prevent these accounts from showing up in standard "active user" lists, such as the "Who's online" block.

How should I approach this?


texts: Multiple image are not upload in the live server

texts:
I had the problem in uploading the multiple images.

Create a content type called "Photo slideshow" and add the field called images.

In the "Photoimage field settings" -> if I selected the "Unlimited" under "Number of values" field, I cant upload the single image.

If I change the "unlimited" to "1" then I can able to upload the image.

  Note: This is the migrated website (6 to 7).

Please give a alternate solution for upload the multiple images with image caption.

Regards
JVRK


texts:
What's the proper method to render a field within the views?

In node templates I render php code using

echo render($content['fancy_field']);

But when I want to render php code within a view I was using

echo render($view->result->_field_data['nid']['entity']->fancy_field);

But it didn't works, any ideas?


texts: How to bulk update (delete) Product Variations

texts:
I want to bulk select product variations for deletion, just like we can do with content and products in admin.

I tried to duplicate the products admin view, and also creating my own, both throw various error pages. It seems there is a security system in place to prevent variation deletion outside of the product pages?

Is there any way to accomplish this?

This is error I get if I add and use a bulk update field (the view is getting "product variations")

    The website encountered an unexpected error. Please try again later.
Error: Call to a member function getPlugin() on null in Drupal\views\Plugin\views\field\BulkForm->viewsFormSubmit() (line 372 of core/modules/views/src/Plugin/views/field/BulkForm.php).


texts: Show Block only if it's a front page and GET variable is set

texts:
I am setting up a block in Drupal 7 to "show block on specific pages" through PHP.

What I want is that if it's a Front page and there is a GET (listed) variable, only then it shows the block otherwise not.

Hence, the block would only be shown, if the url is www.site.com/?listed=true

I tried this, but it doesn't work:-

<?php
if ( (drupal_is_front_page()) && ( !empty($_GET['listed'])  ) {
  return true;
}
?>

any idea?


texts: How do I generate-content of a particular type with drush 9.x+

texts:
root@0a581055a6ad:/opt/drupal# drush genc 10 --types=article

  The "--types" option does not exist.

devel-generate:content [--kill] [--bundles [BUNDLES]] [--authors [AUTHORS]] [--feedback [FEEDBACK]] [--languages [LANGUAGES]] [--translations [TRANSLATIONS]] [--add-type-label] [--skip-fields [SKIP-FIELDS]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify [NOTIFY]] [--xh-link XH-LINK] [--druplicon] [--] <command> [<num> [<max_comments>]]

root@0a581055a6ad:/opt/drupal# drush --version
Drush Commandline Tool 10.3.4

According to the documentation this was an option with drush 8.x, but I don't see any equivalent in drush 9.x and up. What is the intended way to invoke genc for a particular node type with this new version of drush?


texts: Google analytic module - demographic track does not work

texts:
I am building a drupal 7 site, and using the Google analytics module.

I installed it, and made the needed adjusments on my Google analytic account.

But, when I am on the Demographics tab on Google analytics, I can't see any data regarding the "overview", "Age" and "Gender".
Note: "Track DoubleClick data" was always enabled.

In addition, I get the following message:

Some data in this report may have been removed when a threshold was applied

Learn more

How can I solve this issue?


texts: Rules: How to access field values by language

texts:
I have content in two languages (entity translation). If I want to use it's field values in PHP, I can access them by code like this:

$node->field_name['en'][0]['value']

or

field_get_items('node', $node, 'field_name', 'en')

But Rules load only currently active language. How to access field value in particular language in Rules data selectors?


texts:
I am going to build a site using Drupal 7.8. I have some knowledge in PHP, but it is my first time I use Drupal, so I would like to ask your help regarding some basic functional questions I have

I want to have 2 tabbed blocks in my first page. One for "log in" and another for "sign up".
To create this blocks:
For "log in" block it s easy: I will use the out of the box functionality as is (removing create new and request password).
For "sign up" block I would like to remove and add some fields.
Is there any way to find inside user.module the fields used for "username","password","email" etc. and try to use them in my own module?
What are the minimum requirements to use these fields? In other words, if I find the name of these fields, can I use only the names on my module, or I have to override a form/function that maybe contains these fields?
I want to use these fields, but finally for the submission in the database I 'd like to use the default submit functionality. How that could be done?
3.And one last and very newbie question! Forms are implemented using functions or can be stand alone?
So to use an existing form, I have to find in which function it s declared or I have to override only that form?
I know that these are basic questions I should already know but after searching in google, I didn't manage to find a clear solution that works. Could you please help?


texts:
I have a site where a custom form is in opened in a modal, and when submitted calls an ajax function to POST to a REST service to create a node.

The problem is I keep getting "Forbidden" response upon submission.

I only want logged in users to be able to send these ajax requests and the auth should be different token for each user.

Here is my code:

$('#create-node-submit').click(function(e) {
    e.preventDefault();
    var newNode = {
        _links: {
            type: {
                href: 'http://mysite.dev/rest/type/node/article'
            }
        },
        type: {
            target_id: 'article'
        },
        title: {
            value: 'This is a test Article from REST'
        },
        field_description: {
            value: 'Here is some test description.'
        }
    };
    getCsrfToken(function (csrfToken) {
        postNode(csrfToken, newNode);
    });

    return false;
});

function getCsrfToken(callback) {
    $.get(Drupal.url('rest/session/token'))
        .done(function (data) {
            var csrfToken = data;
            callback(csrfToken);
        });
}

function postNode(csrfToken, node) {
    $.ajax({
        url: 'http://mysite.devdev/entity/node?_format=hal_json',
        method: 'POST',
        headers: {
            'Content-Type': 'application/hal+json',
            'X-CSRF-Token': csrfToken
        },
        data: JSON.stringify(node),
        success: function (node) {
            console.log(node);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("Status: " + textStatus);
            console.log("Error: " + errorThrown);
        }
    });
}

When running a test in POSTMAN it is successful, but the authentication was slightly different there:

As you can see in the picture, I get 201 created when using POSTMAN.

I believe it has to do with the CSRF token being used in the Javascript implementation.  I'm not sure what authentication method I'm supposed to use when POSTing to the same site via JS.

I used the information here.

I created a bug report as it seems the CSRF token check passes successfully and grants access, but access is denied from somewhere else.
Issue #2831251 Trying to create nodes via REST with ajax POST request returns 403 response


texts:
How to use Views to list all empty apartments, which do not have any tenant? So basically I have two content type: Apartment and Tenant as below.

Apartment content type:

Room
Tenant (entity reference to Tenant content type)

Tenant content type:

Name
Phone

Do you guys have any suggestion?


texts: How do I assign a role after user clicks a link?

texts:
I'm trying to get a behavior when a link is clicked, a role is applied to a user.

My use case is to allow a registred user to step into another type of user. Example is airbnb.com. You are a renter but once you click a certain menu link you become a host and get new menu items to then list your house.

I want to give permissions and access to certain areas of the site only when someone decides to unlock it.


texts:
I managed to lock myself out of drupal by removing the user login block.  Is there any file I can modify to enable myself to get back in?

Thanks


texts: What is the safe way to update to latest version?

texts:
I am taking over a Drupal project that's running on Drupal 8.8.5.
Can I upgrade to Drupal 9.1.5, or do I need to upgrade for each version that's been missed?


texts: How to change checkboxes options with ajax callback

texts:
I'm sorry if this is repeated somewhere, but I really did try to look and couldn't come up with anything.

My scenario:

I have a form, and within that form I have a div/wrapper, with two elements in it: a) a text field and b) a checkboxes element

I have two different elements that change the values/options of those using the #ajax attribute

1) a textfield that, when changed, updates the value in a) and populates the options in b)
2) a button that's pressed (after the user enters some data) that adds an option to b)

1) works fine
2) semi-works; when you add (x), it doesn't show up (though the data gets stored in the DB fine). If you immediately add (y), (x) shows up in the options, but not (y). Add (z), and (y) shows up, and so on; so, it's always one back....

1) and 2) use different callback functions, but utilize the same wrapper

The form:

function waiver_create_waiver($form, &$form_state)  {
  $form['id'] = array(
    '#type' => 'textfield',
    '#title' => 'ID',
    '#ajax' => array(
      'callback' => '_update_user_info',
      'wrapper' => 'user-info-wrapper',
    ),
  );
  $form['user_info_div'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );
  $form['user_info_div']['username'] = array(
    '#type' => 'textfield',
    '#title' => 'User Name',
  );

  $id = trim($form_state['values']['id']);
  $user = user_load_by_name($id);

  // Create the checkboxes
  $user_hardware = _get_users_hardware($user);
  $hardware_options = array();
  foreach($user_hardware as $h)  {
    $hardware_options[$h['hid']] = $h['hardware_type'] . ' (' . $h['manufacturer'] . ') ' . 'S/N: ' . $h['serial_number'] . ', Last Seen: ' . date('D, n/d/Y g:i a', $h['last_seen']);
  }
  $form['user_info_div']['selected_hardware_checkboxes'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Select Registered Hardware'),
    '#options' => $hardware_options,
  );

//...some textfields and selects for entering hardware info, removed for brevity...

$form['register_hardware_fieldset']['register_button'] = array(
  '#type' => 'button',
  '#value' => 'Register New User Hardware',
  '#ajax' => array(
    'callback' => '_update_hardware',
    'wrapper' => 'user-info-wrapper',
   ),
);

return $form;
}

Callback for 1) $form['id']['#ajax']

function _update_user_info($form, &$form_state) {
  $id = trim($form_state['values']['id']);
  $ldap_search = ldap_connector_query_ldap(trim($id)); // This is a custom LDAP query function
  $form['user_info_div']['username']['#value'] = ucwords(strtolower($ldap_search['cn'][0]));

  return $form['user_info_div'];
}

Callback for 2) $form['register_hardware_fieldset']['register_button']['#ajax']

function _update_hardware($form, &$form_state)  {
  $id = trim($form_state['values']['id']);
  if($id != NULL && $id != '')  {
    $user = user_load_by_name($id);
    // If the user isn't on the site yet, create an account for them
    if(!$user)  {
      $new_user = array(
          'name' => $id,
          'pass' => user_password(),
          'mail' => $id . '@email.com',
          'init' => $id . '@email.com',
          'status' => 1, // Active user
          'roles' => array(DRUPAL_AUTHENTICATED_RID => "authenticated user"),
      );
      $user = user_save(NULL, $new_user);
    }

// ...Find $hardware_type and $manufacturer from elements cut from above for brevity...

    // Insert the hardware in to the database...
    db_insert('waiver_hardware')->fields(array(
      'user_id' => $user->uid,
      'date_added' => REQUEST_TIME,
      'hardware_type' => $hardware_type,
      'manufacturer' => $manufacturer,
      ))
      ->execute();
  }
  return $form['user_info_div'];
}

EDIT: I've tried adding the options to the checkboxes element within the callback, as well as making the $form a reference call, but to no avail.


texts: How to add a pager template suggestion for current page number?

texts:
I'm trying to add a Twig template suggestion for list pages via pagers, so that I can theme the first page differently than the next pages.

I have been able to successfully add a template suggestion with the following code.

function MYTHEME_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  $path = \Drupal::request()->getRequestUri();
  $strip_path = parse_url($path, PHP_URL_QUERY);

  $new_path = str_replace("page=", "pager", $strip_path);
  $new_path = preg_replace('/[0-9]+/', '', $new_path);

  if (!empty($new_path)) {
    $suggestions[] = 'page__' . $new_path;
  }
}

At the moment I'm getting page--pager.html.twig as a suggestion on the pager pages only, not the first page of the list, (it is desired).

If Drupal URL is /something?page=[some-number] the above suggestion is provided, however, if it is just /something template suggestion is not suggested.

In Devel profiler, I have not seen any extra overhead or memory usage.

Is it the right way, or is there any better way?


texts: Adding a delete button for webform attachment fields

texts:
I have created a structure of field like below within code and not used webform UI. The reason of doing this pro-grammatically is because I have hundreds of forms and I wanted to do it once for all.

Here is my code:

            for ($i = 0; $i <= 4; $i++) {
                $form['submitted']['file' . $i] = array(
                    '#title' => t('File'),
                    '#type' => 'managed_file',
                    '#description' => t('Please upload a document or image.'),
                    '#default_value' => variable_get('file' . $i, ''),
                    '#weight' => 100,
                );

                $form['submitted']['remove_name'.$i] = array(
                   '#type' => 'submit',
                   '#value' => t('Remove'.$i),
                   //I NEED A WAY TO PASS $i AS ARGUMENT TO THE CALLBACK
                   '#submit' => array('form_remove_attachment'),
                   // Since we are removing a name, don't validate until later.
                   '#limit_validation_errors' => array(),
                );
            }

And here is the callback:

 function form_remove_attachment($i, &$form_state) {
  //dsm($form_state['complete_form']);
  $clicked = explode(' ', $form_state['clicked_button']['#value']);
  //dsm($clicked, 'clicked');
  if ($clicked[1] == $i) {
     unset($form_state['complete_form']['submitted']['file' . $i]);
  }
  // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
  $form_state['rebuild'] = TRUE;
}

Now what I need is a delete button for each attachment field to allow users to change their mind on regard the attached files. I can add it of course by JS but this way the attachments are not eliminated from $form_state.

Does anyone have some suggestions?


texts: How to print a JS flag as a simple link in full node view?

texts:
I have two flags which are set up as JS toggle in their settings.  That's how they appear in teasers.
But in my full view of the node inside the block I want them to print as a normal link (no JS).
How can I do that?

So far I have this:

<?php
//If in single node page
if ( arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2) ) {
global $user;
if ($user->uid == $node->uid) print flag_create_link('FLAGNAME', $node->nid);
}
?>

But it returns the JS toggle flag,rather than a simple link. Can you help?


texts: How to alter text filters conditionally based on content type?

texts:
How can I get the content type of the current node from within a text filter, so I can use it to conditionally alter how the filter is applied?

Getting the node ID from the arg() function and using it to load a node object does not work because the text filter is run multiple (30+) times and exhausts the available memory.

$node = menu_get_object();
if ( !empty($node) ) {
  dd('Have a node, do something');
}

The same is true with the following method of getting the content type: $node = menu_get_object();


texts: Associate a content type to a specific group in drupal commons

texts:
How is possible to create a content type associated by default to a group in Drupal Commons?

I will try to explain. I have two groups: literature and art. Literature will have three content types i.e. poetry, fiction and novels. Art will have painting, photography and drawings.

I've created contents types and i've tried to associate them with the respective group by flagging the group and group content checkbox but nothing changed. I also followed the steps described here https://www.drupal.org/node/2014781 but when I try to add some content I still see the "Post to specific groups" radio option and select.

Help please!!!


texts:
I thought this would be out of the box, but it doesn't seem so.

I'm looking for a way to be able to have a multiple choice poll where users can select more than one answer.

Is this even possible with the Drupal 7 Core Poll Module?

If Core Poll does not allow this, are there some other modules out there which are not in dev?


texts: views relationship to field collection field, gives no result for non-administrators

texts:
Using a view of field collection items, A relationship to a field collection field works fine for administrators but for other roles like authenticated users or anonymous users, the complete view is not showing, but does render the 'No results behavior' of the view. This sounds very much like a permission issue, but I have checked all permissions many times.

I have the impression that the following issues are about the same thing, but their solution to turn of views data caching, does not work for me: https://www.drupal.org/node/1973090
Help is greatly appreciated, thank you.


texts: Show the list of all users who edited a node in Drupal 7

texts: Usually, I display the name of the user edited a node at last, not the ones in the middle. I want to display a list of all the users who edited a node. Is that possible by using Views or any other way? They do so here.


texts:
I need to add sorting to a view in code but can't seem to get this to work. This is my code so far.

$view = Views::getView('name_of_the_view');
if (!$view) {
  // some irrelevant code to handle a non existing view
}
$view->setDisplay('name_of_the_display');
$view->setArguments([$searchString]);
$view->setCurrentPage($page);

$view->execute();

As far as I know, I need to add $view->sort and $view->filter before the execute method but don't know what to set this to.

Do I have to pass the name of the sort/filter handler (i.e. 'random') or the class name (i.e. Drupal\views\Plugin\views\sort\Random) or an instance of a sort/filter handler or something else?


texts: Only Publish a node in certain languages

texts:
In D8 I have a node with several translations - not all translations will be ready to publish at the same time.
If I unpublish one translation it unpublishes all transaltions and default translation. Is this a bug or do I have an incorrect setting somewhere?


texts:
I would like to add Nested bootstrap menu in my project. (I'm using the Bootstrap Business Theme.)
I already tried with the Superfish module.. But I don't like that much because the appearance of menu is not good looking and have to overwrite many CSS files.
I also tested with TB Mega Menu. It doesn't work. I put TBMenu Block in Navigation block. But the whole menu was totally disappear. I don't know why it happen like that.

Anyone knows other flexible dropdown menu for bootstrap theme?


texts:
I just want to create a new region in my theme on the top right side of page.
with height = 50 px and width=200 px

i'm using drupal version 7


texts: Is there any way to limit number of nodes a user can create in an Organic Groups?

texts:
I'm working on a site where users can submit content in many groups, each of them have to be administered separately. So I've chosen Organic Groups for this purpose. At the same time I have to limit the number of nodes a user can submit in one group.
Node Limit module would be a pretty straightforward solution but they don't and will not offer per OG limit. Is there any other way to achive this?


texts: Route that renders a node has title of route rather than node title

texts:
I have a route that takes a wildcard $product and then loads a default node that is stored in config. This is working (i.e. the node is rendered on that path) but instead of the node title it is displaying the route title 'Default Product List'.

Any ideas?

Routing.yml

default_product_list.generate_default_product_list:
  path: '/destinations/{region}/{area}/{town}/{product}'
  defaults:
    _controller: '\Drupal\default_product_list\Controller\DefaultProductListController::generateDefaultProductList'
    _title: 'Default Product List'
  requirements:
    _permission: 'access content'
  method: [GET]

Controller

 /**
   * Generatedefaultproductlist.
   *
   */
  public function generateDefaultProductList($region, $area, $town, $product) {

    $vars = [
      $region,
      $area,
      $town,
      $product
    ];

    $config = $this->config('default_product_list.defaultproductlist');

    $data = $config->get();

    if ($product === 'accomodation') {
      if (isset($data['default_accomodation_product'])) {
        $node = $this->defaultProductListUtility->loadDefaultNode($data['default_accomodation_product']);
        if (isset($node)) {
          $view_builder = $this->entityTypeManager()->getViewBuilder('node');
          $build = $view_builder->view($node);
//          kint(array($build));
          return array($build);
        }
      }
    }

  }


texts:
I am trying to set up a local server to try out drupal 8.1.3 and so far I was able to set up my profile and website but I cannot go to any pages other than the first page. (Welcome page, front page)

I have used the following link to install Drupal:

https://www.howtoforge.com/tutorial/how-to-install-drupal_8-with-apache-and-ssl-on-ubuntu-15-10/

Few things to note:

I'm not sure if I have CleanURL, tried to fix this issue but couldn't succeed I believe.
I have tried  multiple different approaches to fix issues like CleanURL, SSL connection, Apache2 (AllowOverride All) etc
I tried adding "?q=" and while this doesn't make the page crash, it just directs me back to the front page

Currently, I am playing around with four files to try to figure out my problem: ".htaccess", "apache2.conf", "drupal.conf" and "settings.php"

I want to be able to access the Drupal tools to modify the website and run it locally, I simply want to test Drupal, I wanted to share this because it may simplify the solution.

Some of the code that I have added while trying to fix my situation:

drupal.conf:

            <Directory "/var/www/drupal">
                    Options FollowSymLinks
                    AllowOverride All
                    Require all granted
            </Directory>

apache2.conf:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

.htaccess:

RewriteBase /

# homepage redirect
RewriteRule ^$ /SUBDIRECTORY/index.php?q= [L]

# if directory or regular file...
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} =/favicon.ico
# stop here
RewriteRule ^ - [L]

# if a regular file in SUBDIRECTORY directory
RewriteCond %{DOCUMENT_ROOT}/SUBDIRECTORY/%{REQUEST_URI} -f
RewriteRule .* SUBDIRECTORY/$0 [L]

# Redirect everything to /SUBDIRECTORY
RewriteRule .* /SUBDIRECTORY/index.php?q=$0 [QSA]

settings.php:

$settings['trusted_host_patterns'] = array(
  '^127.0.0.1$',
  '^localhost$',
  '^www.example.com$'
  );

PS. I have tried both localhost and an example website url like www.example.com but it didn't help.
PS2. I am only using Firefox currently but I don't think the problem is with the browser.

I hope I was able to follow the question guidelines, I am really trying my best to make it a question "suitable" to the website, I am sorry if I made a mistake.

Edit1: I have rewrite already enabled.


texts: How to add an element into a nested array in twig?

texts:
I've decided to include opportunities of the bootstrap library in drupal native forum and I'm trying to add new class into a nested array in twig.
Here is my code.

{%  set topics['#rows'][0][0]['class'] = topics['#rows'][0][0]['class']|merge(['col-xs-9', 'col-sm-6']) %}
{%  set topics['#rows'][0][1]['class'] = topics['#rows'][0][1]['class']|merge(['col-xs-3', 'col-sm-2']) %}
{%  set topics['#rows'][0][2]['class'] = topics['#rows'][0][2]['class']|merge(['hidden-xs', 'col-sm-4']) %}

But upon executing the page an error is being displayed.
Here is description of the error.

Twig_Error_Syntax: Unexpected token "punctuation" of value "[" ("end of statement block" expected). в Twig_TokenStream->expect()

Could you clarify me, how to properly add new elements into the compound array ?


texts: Background CSS images won't be changed after reuploading & Cache flushing

texts:
If I Download a css background image of my site, changing it with GIMP (or MS paint for that matter) and re upload it, nothing will happen. Moreover, even after I delete the file from the server, the image stays online... clicking "Flush all caches" nothing happens... I also note that the image basically stays the same --- Same filename and file extension, so it's extremely wired. What would you suggest of checking?

What I already tried and didn't help:

Turning off server external caching tool (for both static and dynamic cache).
Turning off AdvAgg from config/development/performance/advagg (Unchecked "Enable...")
Turning off Drupal's internal cache system.

Update: Working answer found... See below for the answer with green checkmark.


texts:
I need to scrub a production db to replace paths in the body field. Being a production database, it needs to happen in a time-sensitive, well-documented way with the solution frozen in code. I'd assume that a .install file would be the best way to do this.

What would a one time install script look like to search the database for "http://mysite.com" and replace with "https://www.mysite.com" in the default body field?


texts:
In Drupal 7.. I'm trying to create a rule that copies the user's profile picture into an image field on another content type.
How can I select the 'picture' from a user's account, as a source for copying?
The event is after updating an existing account, which provides the source 'account'.
The File Field Rules module provides the copy action, but it requires a source field, and the user-picture isn't a field.

Another approach I tried is with the file URL. The FileField Sources module allows the use of a remote URL in an image field, but if I try to set the value of the image field with the token [account:picture:url]  Rules doesn't allow it.

There is a similar question here Rules: Copying field from user's account to field in content type  but the solution is with an additional field attached to the user, not with the default 'picture' one.

thanks,
d


texts:
Wrapping one's head around the json/ajax/jquery relationship is quite a battle for someone new to it. But what a fun puzzle! One of the most confusing parts has been how to frame this question.

Using php in my module file, utilizing db_query function, the database query has been made, and now we're going to loop through the results, create json data and encode it and send it back to jquery for re-inclusion into our website.

$json = array();
        foreach ($query as $row) {

      $fid = $row->thefid;
      $file = file_load($fid);

      $jsonelement=array(

         'title' => $row->title,
         'path' => $file->uri,
         'style_name' => 'swatch'

        );
          array_push($json,$jsonelement);
    }

        // encode to json
        $jsonstring = drupal_json_encode($json);

        //output the json string
        drupal_json_output($jsonstring);

This returns this json string:

[{"title":"Test Swatch 5","path":"4DS_AB_BrittanyBeige_CAT.jpg","style_name":"swatch"},{"title":"Test Swatch 6","path":"4DS_AB_ArdennesGray_CAT.jpg","style_name":"swatch"}]

Where I am having trouble, is figuring out how to access each element.

A simple side example to illustrate the issue without an array :

var data = jQuery.parseJSON('{"title":"Test Swatch 5","path":"4DS_AB_BrittanyBeige_CAT.jpg","style_name":"swatch"}');

alert (data.title);
data.title returns the string Test Swatch 5, which is what I expect.

However, in the output I have (back at the top of the question) the json object(s) has an extra set of brackets around it suggesting another array that I am not sure how to access, but for now I will call it x.

My question is 2 parts and any one of the solutions will get me to where I need to be.

1) Is there a way to get the key value pairs out of the current output I have already created? Any example would be helpful.

2) Is there a way to frame the output in a way to utilize x as the name of the array so that the values can be accessed via myjson.x.title or myjson.x.path or myjson.x.style_name, etc..?

I noticed a very similar question here with no answer as well
https://stackoverflow.com/questions/1607937/how-to-parse-json-array-in-jquery


texts: How do I switch node templates based on arbitrary critera

texts:
I'm trying to switch the node template file based on a variable, in drupal 6 you could simply set  $vars['template_file'] = 'node-whatever'; from with the preprocess_node() and name the new node template file node-whatever.tpl.php.
I drupal 7 this is gone. I looked through the docs and it appears that in Drupal 7  its   $vars['theme_hook_suggestion'][] = 'node--whatever'; but this is not working for me. Am I doing something wrong? is there a naming convention that I'm missing? The documentation is a little confusing


texts: How does Drupal Commerce use the commerce_line_items field?

texts: I have been trying for some time to figure out how Drupal Commerce uses the commerce_line_items field.  It looks to me like this is the field that provides the link between  a commerce line item and the order to which it is attached, so that if all you had was the order_id, you wouldn't have to query the entire commerce_line_items table, but could just look at this field.  However, I cannot figure out how or where this field is defined, and where its values are set.  If anybody can get me pointed in the right direction, I will happily write some documentation so that others may understand what is going on.


texts:
I've been trying for quite some time now to get my drush to play nicely with my Drupal configuration and I'm having some problems. I'm attempting to perform cc all and uli on my Drupal directory and I keep getting the following error:

ssh: connect to host site.dev port 22: Operation timed out

The command I'm running is "drush @site.dev cc all" and "drush @site.dev uli"

Whenever I run uli I get a slightly longer version of the same error:

The external command could not be executed due to an application     [error]
error.
Illegal string offset 'site' backend.inc:1030                        [warning]
The command could not be executed successfully (returned: ssh:       [error]
connect to host site.dev port 22: Operation timed out
, code: 255)
current() expects parameter 1 to be array, null given                [warning]
user.drush.inc:415
parse_url() expects parameter 1 to be string, array given            [warning]
exec.inc:427
 does not appear to be a resolvable hostname or IP, not starting     [warning]
browser. You may need to use the --uri option in your command or site
alias to indicate the correct URL of this site.

I'm not really sure where to start with getting this to work. I've poked around in my Vagrant configuration and I'm able to SSH on port 22, so I don't really know where else to look to correct this error.

This is what my alias configuration looks like:

Vagrant.configure("2") do |config|
  mc_settings = {
    :domain => 'site.dev',
    :docroot => '/home/vagrant/docroot',
    :host_docroot => '../docroot',
    :database_name => 'site_dev',
    :vbox_name => 'site_dev'
  }


texts: Is there a module to provide node access based on Ip address?

texts:
I am looking for a module that provides node access or content type access based on the ip address of the user? So what would be ideal is that i can select the ip address range allowed for a particular node when creating it or i can define a range of ip address on a content type.

Once i select the ip address range then someone coming from outside of that range should not be able to access that page.

I have looked into several modules and couldn't find much. The closest thing i found is in sandbox https://www.drupal.org/sandbox/schlicki/1461406

Please let me know if i can clarify more?


texts: Drupal 7 Internationalization - why are my admin menus still in English?

texts:
I'm trying to make a fully bilingual website that will be administered by French and English users.

I've installed the internationalization module and all its dependencies and the localization update module, which claims to have installed French language support. I've successfully got all the front-end content, menus and views translated and language switching working, but no matter what I do, the admin menus remain in English. It doesn't matter whether I change my default language in the user preferences or set the site to French with a url parameter, I can't get the admin menus to change language. Many of the tutorials I've seen online seem to gloss over this as though it happens automatically.

Is it possible to display Dashboard, Content, Structure...etc in French as well as the default English or am I going nuts?


texts:
Adding a users' website link (URL) to a field.
Can somebody please clarify the best approach to this using Profile2 as I cannot seem to find any option for "URL" type in any field. Maybe I'm having a blond moment or just cannot see the wood for the trees, but to save us hours searching online, can somebody advise on the simplest and most obvious solution to users being able to enter their 'website' link (ie: to link to an external URL such as a homesite such as a bandname.com, mybusiness.com).

I am also using Field Collection but presume any created filed type will be similar in setup.

I would envisage the user being able to add such a URL into their profile detial post registration in a similar way to the user DB on drupal.org (ala "Mywebsite").

Thank you.


texts: Page not found when I try to access my custom module

texts:
I create a custom module in Drupal 8. It install/uninstall smoothly. But when I try to access that module then I'm getting that message

"Page Not Found." -
Failed to load resource: the server responded with a status of 404 (Not Found)

For debuging I made these entries in my setting.php file.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$conf['error_level'] = 2;

But getting no luck. Is there any other ways to debug my code in drupal 8.

Here is my routing file code:

custom_module.admin:
  path: '/admin/custom_module'
  defaults:
    _controller: '\Drupal\custom_module\CustomModuleController::custInformation'
    _title: 'Custom Module Title'
  requirements:
    _permission: 'access information'

custom_module.site_page:
  path: '/custom_module'
  defaults:
    _title: 'Custom Module Title'
    _controller: '\Drupal\custom_module\CustomModuleController::custInformation'
  requirements:
    _permission: 'access information'

and link.menu.yml file code:

custom_module.admin:
  title: 'Custom Module Title'
  parent: system.admin
  description: 'Brief description.'
  route_name: custom_module.admin
custom_module.site_page:
  title: 'Custom Module Title'
  route_name: custom_module.site_page
  menu_name: footer
  enabled: 0

& controller file

namespace Drupal\custom_module\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
 * Controller routines for contact routes.
 */
class CustomModuleController extends ControllerBase {

  /**
   * Render a list of entries in the database.
   */
  public function custInformation() {
    $header = array('Name');
        $rows[] = array("John");
    $content['table_brief'] = array(
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $rows,
      '#empty' => t('No entries available.'),
    );
    return $content;
  }
}


texts:
I am using #state values in a hook_form_alter() to disable field_2 if field_1 (a checkbox) is checked. It works and all is good.

Now I want to empty field_2 as well. I cannot see a way to do that with the #state.

How can I make sure that values don't get saved for fields that are conditionally disabled, even if the user enters a value first?


texts: Taxonomy: Show select options as a dropdown, not multiple

texts:
I am trying to display a dropdown where users can divide their article in a certain category. I have created a vocabulary called "category" and added s few fields to them.

I have added this to the content structure where the articles are defined. This works perfectly, however, the categories are not displayed as I desire:

When I inspect this element, there is a property used:

<select multiple="multiple">
    <option>...</option>
</select>

I don't want these options to be displayed together. I need a dropdown to let users select one of the categories.

I tried debugging and look for which html.twig file is being called, and tried to edit the select.html.twig but this did not solve the problem.

See select.html.twig

  How can I get these options to show as a dropdown?


texts:
I have a boolean field (a checkbox) in my user profiles. I have left it with the default settings (1= ticked, 0=unticked).

I have created an CSV export in Views of the user data. All the fields in the user profile work, apart from the boolean value, which is not exported (it just appears as "", for all users). If I look at user profiles however, the box is ticked (or unticked) so the data is there, just not being exported.

How can I get this field to export?


texts: Entity operations and redirect destination (using EntityListBuilder)

texts:
I have an entity collection page that's built with my own subclass of EntityListBuilder. My problem is that the operations links do not set a redirect destination, so after clicking e.g. on an edit link, it is hard for the user to find their way back to the listing.

Redirect destinations work fine with simple links. But I couldn't figure out an easy way how to tell EntityBuilder::buildOperations() to include the destination query string. Any suggestions?


texts: Pre-process drupal_goto or use hook_exit to stop redirect

texts:
I want to unit test some drupal custom modules but the drupal_goto() function is causing problems by creating header errors (e.g.: PHP Warning:  session_start(): Cannot send session cookie).

My question is, is it possible to stop the drupal_goto() function from redirecting to the destination page or somehow tap into hook_exit() to return the $destination.

I've tried something like (in addition to exit and die, but it stops the PHPUnit tests:

function custommodule_exit( $destination = null ) {
  return $destination;
}

Any help is appreciated.


texts:
OKay - I'm either brain fading or truly confused (probably both).

I need to filter a view based on the value of a field, but in a unique way. The content type (task) has a field (location) which is also used on the user profile. I need the view to only show those tasks which have the same value as the logged in user in that field. What the *&% am I missing?


texts: How to change the format that shows the autocompletion of reference entities?

texts:
I am trying to change the format that it shows by default in the text fields that have an associated reference entity.

I found an article where a format modification is made, I think it may be a good starting point, but this module changes the format of all the fields of the whole site, what I am trying to do is that I can define the format by type of content, that is, for Articles, it would have one format and another type of content, depending on what is most convenient.

For example, in the module mentioned, it changes the behavior of the autocomplete globally, is there a way to do it by type of content?

<?php
namespace Drupal\alter_entity_autocomplete\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;

use Symfony\Component\Routing\RouteCollection;

class AutocompleteRouteSubscriber extends RouteSubscriberBase {
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('system.entity_autocomplete')) {
      $route->setDefault('_controller', '\Drupal\alter_entity_autocomplete\Controller\EntityAutocompleteController::handleAutocomplete');
    }
  }
}

Is there any way to do it?

The github project of the module


texts: What is the correct way to update existing module's rules programmatically?

texts:
I want to provide an update for my custom module, which also has some rules provided via hook_default_rules_configuration.

Now, how can I update those existing rules? Can I re-import them? Override them somehow? I cant find anything about this in the documentary or an respective hook.

There seems to be a hook to respond to rules being updated, so I guess there must be a way to provide updates for custom rules...

At first I thought it was hook_default_rules_configuration_alter but it doesnt seem to work as expected since I just want to import JSON.

For instance, using views I can simply load all .inc files and save them via views_save_view like in this question - isnt there a similar way in rules?


texts: How can I load the entities shown in the following screenshot?


texts: Views Slideshow, show alternating content types

texts:
Does anyone have an idea how i might display a slideshow with alternating data (odd even style) of content type?

Currently the view is loading the fields, and i guess it could be one step closer to load the rendered node, but how can one alternate it, and limit it?

So like :
Slide 1: Article
Slide 2: blog
Slide 3: Article
Slide 4: blog
etc..


texts: View filtered by a Date field's value being in "last month" shows July content on July 31

texts:
A View is filtered by a Date field's value.  The Date field's month must be last month in order to match the filter.

On every day except July 31 it would return results from last month.  It should have returned results matching June.  We have tried "-1 month" but that didn't work either.

Why on July 31 does it jump ahead a month?


texts:
The page.tpl.php prints the header image like so. I need to change it so that it prints it as a background image. i.e

  When I make that change the value of $url changes and includes additional text, not just the path to the image as it does in this format. How can I change this?

if ($node->field_header_image && $node->field_header_image['und'][0]['uri']) {
        $url = file_create_url($node->field_header_image['und'][0]['uri']);
        echo '';


texts: How to redirect to content if view have 1 result?

texts:
Views page show content.
How to redirect to content page if views has only one result?


texts: I want to have a three column in node page, my page width is 940px, and one column is 300px + 20px right margin, so 3 column is 960px, but the main width is 940px, I want to 3 column in one row,  how to do that? how to modify node.tpl.php?


texts: Choose node item from list and add to form

texts:
I have content type 'Machinery' and I need to create the form for users where they can enter their name, email, phone number and to select some node from a list and attach it to form.

The user can select unlimited items and when click on 'Add' to add to form.

In this way, the user has the option to attach some machines to the form and send a request for renting those machines. Email that will be sent from this form needs to contain all fields along with the list of added machines.

Since I need this content type because I'm using it for another page to show the list of available machines, I need to create the form in this way so when I add new machine (node) it's automatically available on this list in the form.

Any idea how I can do this? Is there some way to create form through Views so I can add this list field?

I'm working on Drupal 8.


texts: Drupal View rewriting output of the field

texts:
I created a taxonomy vocabulary with several terms and it is assigned to a content type. So a node can have multiple terms from that vocabulary. After assigning it I have created a view to format the content type nodes into a json data.

Now in the JSON data the taxonomy field is showing multiple values. I want to separate those individual items by comma. Please help me out how to do it. I've tried adding this expression to the tpl file.

]+>/i', ', ', $output); ?>


texts: Entity reference view display is not displaying fields as expected

texts:
I have a number of registered users on my drupal 8 website who some of them are "active" and the others are "blocked".

I want to add a select list field inside the article content type displaying only user with the status= active (Easy job!)

Note: I have added a field to the user page (field_full_name) and I want to display the users using their
"Full Name" and not their "Usernames". (Still an easy Job!)

So I did the below:

Create a new view to show "users"
Create an "entity reference" display for the view.
Delete the "username" field created by default
Add the Full name field to the view (field_full_name)
Add the filter field "User: User status (= Yes)"
Inside the Settings of the "Entity Reference" View, check the "User: Full Name" as the search field.
Save the view.
Add the view as a user reference field to the article content type by selecting the Reference method: Views: Filter
by a entity reference view and for the View used to select the entities: Select the created view above.

Now, when you add a new article /node/add/article, if you try to select a user from the dropdown select list,
you will notice that all users are displayed using their usernames and not their Full Names.

In other words, I like to have something like this in the select list:

Full Name 1.
Full Name 2.
Full Name 3.
Full Name 4.

but actually I am receiving this:

Username 1.
Username 2.
Username 3.
Username 4.

Also I noticed the same behaviour when I tried to create an "entity reference" view displaying all the groups that the current
logged in user is a member of, by doing the below steps:

Create a new view and set the view to show: "Group content" of type: "All".
Add relationship: "The group containing the entity".
Add relationship: "Relates to the user entity that the group content represents".
Add a contextual filter: "User ID" and when the filter value is not available select: "User ID from logged in user"
Delete any available field created by default.
Add the field: "Title" (to show the title of the group)
Create an "entity reference" display for the view.
Inside the Settings of the "Entity Reference" View, check the "Group: Title" as the search field.

Now, add this view as an "entity reference" field to any content type for example "Article" and when you will add a new article
/node/add/article, if you try to select a Group from the dropdown select list, you will notice also that all
Groups are displayed using the username of the current logged in user and not by their Group titles.

In other words, lets say the current looged in username "Admin1" is a member of 3 groups titled:
(Group Title 1, Group Title 2 and Group Title 3)

you will see that the entity reference select list field is displaying:

Admin1
Admin1
Admin1

Instead of:

Group Title 1
Group Title 2
Group Title 3

What am i doing wrong ?!

Is there something wrong with the "entity reference view" display ?!

any help ?

It is worth mentioning that if you just duplicate the "Entity reference" display to a "page" display and you visit that
page, you will indeed see a list of users displayed using their Full Name or list of Groups displayed using
their group titles

Thank you in advance,


texts: Using Views to Display Taxonomy Terms Along with a single image field of the latest content type that has that taxonomy term

texts:
Let's say I have the following content type called Gallery that has an image field and a term reference field that can contain multiple terms from a single vocabulary.

In addition, I have several contents of these content types that share terms.

Would it be possible to create a view so that it satisfies the following conditions?

List all terms from a certain vocabulary
Have each term accompanied by an image (from the image field) from only the Gallery content type that uses that term
Term and Image should be listed once. If the term is being used by more than one Gallery content, the term should appear with the image from the latest content using that specific term.

The first two conditions are very straightforward to accomplish, independently. But once I try to accomplish both at the same time, I end with a display of all images paired with a single term it's associated with.

If that image is tagged with three different terms, then that same image appears three times, each instance using each of the terms.

Further, if one term is used for x number of different content, then that term will appear x number of times.

Was just wondering if there's a way to set it up so that it's 1 term, 1 image (preferably from the latest content type).


texts: How to write a CCK widget with more than one input element?

texts:
What I am looking for is not CCK flexifield or CCK Multigroup.
I am trying to develop a CCK widget that allows me to enter two or more input fields per value, kind of what Doublefield does for Drupal 7.
How would I develop that?


texts: Checkboxes in a simple form are not displayed

texts:
I have a simple form in a custom module that works well and is displaying my select as it should.

$form = \Drupal::formBuilder()->getForm('Drupal\efq\Form\FilterForm');
$form["container"] =  array(
    'categories' => array(
        '#title' => t('Select a Category'),
        '#type' => 'select',
        '#options' =>  array(
            1 => t('Option 1'),
            2 => t('Option 2'),
            3 => t('Option 3'),
        )
    )
);

I would like to change Select for Checkboxes. According to this, "Checkboxes" structure is the same as per "Select".
But when I change '#type' => 'select' for '#type' => 'checkboxes' there are no checkboxes created and I got the 2 following warnings:

Notice: Undefined index: #title_display in Drupal\Core\Render\Element\Checkboxes::preRenderCompositeFormElement() (line 20 of core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php).
Notice: Undefined index: #id in Drupal\Core\Render\Element\Checkboxes::preRenderCompositeFormElement() (line 30 of core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php).

Adding these in an array makes the notice messages disappear but the checkboxes are still not showing.

Any idea of what's going on ?


texts:
I have a Drupal 7 site and I'm thinking about upgrading it to Drupal 8. I want to refactor the site, so I just need to export the content.

So far, I've tested exporting content types using feeds module and a csv file, as I don't quite understand how to do the export using .yaml files. It did work: I exported the stuff I wanted using views in my current site, and then imported it back using Feeds.

I would like to know if there's a way of manually importing into Drupal 8 all the comments (where I already have imported the content).

I will appreciate any suggestion! Thank you!


texts: How to configure settings.php for Drupal site with Varnish and CDN?

texts:
I am completely new to the back-end issues, so I would appreciate any detailed answers with explanation.

We need to configure our settings.php file so that it works with Varnish and CDN.  Currently, it's commented out by default.  I read the comments over and over in the settings.php, and it doesn't make much sense, or I don't know how to provide the information.

  In  the most simple scenario, the proxy server will add an
   X-Forwarded-For header to the request that contains the client IP
  address. However, HTTP headers are vulnerable to spoofing, where a
   malicious client could bypass restrictions by setting the
   X-Forwarded-For header directly. Therefore, Drupal's proxy configuration requires the IP addresses of all remote proxies to be specified in $conf['reverse_proxy_addresses'] to work correctly.

  ...

  In order for this setting to be used you must specify every possible
    reverse proxy IP address in $conf['reverse_proxy_addresses'].
   If a complete list of reverse proxies is not available in your
   environment (for example, if you use a CDN) you may set the
   $_SERVER['REMOTE_ADDR'] variable directly in settings.php.
   Be aware, however, that it is likely that this would allow IP
   address spoofing unless more advanced precautions are taken.

Several things that concern me:

What comments do I need to uncomment?
Since I'm using a CDN, I guess I'll have to use: $_SERVER['REMOTE_ADDR'].  But what are the "advanced precautions" available that I can take to prevent IP spoofing?

Thanks


texts: Access denied to file in sites/all/default/files

texts:
I am getting:

access denied   04/30/2013 - 16:56  sites/default/files/styles/thumbnail/public/KRIS... admin

in my error message log when trying to do some file updating. I am guessing this is a permissions problem, but i am running on a local server. How do I change permissions in drupal for access to read/write to the files folder on a mac in terminal?


texts: Why am I getting a "page not found" error for this implementation of hook_menu()?

texts:
Here's the implementation of hook_menu() in my theme, "myTheme":

function myTheme_menu() {
    $items = array();
    $items['ajax'] = array(
        'title' => 'AJAX',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK
    );
    $items['blog'] = array(
        'title' => 'sonia blog',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK
    );
    return $items;
}

example.com/ajax is working fine, but example.com/blog is returning me a "page not found" error. I have cleared my cache.

Do you have any idea about what is going wrong?

EDIT
One of the commenters suggested that I need a page_callback property. However, the documentation on hook_menu does not say that it's required. Regardless, I tried adding this callback but still no luck. Here's the code with it:

function myTheme_menu() {
    $items = array();
    $items['blog'] = array(
        'title' => 'sonia blog',
        'access arguments' => array('access content'),
        'page callback' => 'myTheme_callback_blog',
        'type' => MENU_CALLBACK
    );
    return $items;
}

function myTheme_callback_blog(){
    return '';
}


texts: Can I pass a variable to the without() filter?

texts:
I would like to replace 'field_body', 'field_link' with a variable.

I am using the following code.

{{ content|without('field_body', 'field_link') }}

What I really want is passing a single string containing the names of those two fields, as in the following code, which doesn't work.

{% set foo = "'field_body', 'field_link'" %}
{{ content|without(foo) }}

Is there a way to achieve what I am trying?


texts:
I'm trying to use FFMPEG with the drupal video module, I'm using a Centos 6.4 VPS. I followed the Official compile guide "https://trac.ffmpeg.org/wiki/CentosCompilationGuide" and I have no errors. but after all the video module is not finding the FFMPEG I tried couple pathes but didn't find it
I tried these

$which ffmpeg:
/root/bin/ffmpeg

whereis ffmpeg return nothing

ffmpeg -version
ffmpeg version git-2013-11-29-6e7de11
built on Nov 29 2013 14:42:14 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-3)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/root/bin --extra-libs=-ldl --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libtheora
libavutil      52. 55.100 / 52. 55.100
libavcodec     55. 44.100 / 55. 44.100
libavformat    55. 21.102 / 55. 21.102
libavdevice    55.  5.102 / 55.  5.102
libavfilter     3. 91.100 /  3. 91.100
libswscale      2.  5.101 /  2.  5.101
libswresample   0. 17.104 /  0. 17.104
libpostproc    52.  3.100 / 52.  3.100

Any suggestions?


texts:
I've installed the Views Bootstrap module primarily so that I can easily create the same carousels that the Bootstrap/non Drupal parts of our site use. I would prefer to use Views Bootstrap or else I will have to use a different carousel module and try to style it so it looks the same.

I have for images in my result set. All I am getting right now is a page with one number for each image like this:

1.
2.
3.
4.

Below this I get the images, left aligned, one per row.

In the view settings I am using Bootstrap Carousel for Format and Bootstrap Carousel for Show. I get this same result whether I am using this view as a block or as a page. I don't know if it matters but I am using the Omega 3 theme.

Any help would be appreciated.

Thanks


texts:
I have a function in my template.php file but I've now created a module that manages these particular tasks so I want to move the function over.

This is what I have in my template.php file:

function MYTHEME_menu_tree__main_menu($variables){
    return '
' . $variables['tree'] . '
';
}

This works file but when I move it into my custom module (mymodule.module file) if doesn't work.

I've tried this:

function MYMODULE_menu_tree__main_menu($variables){
    return '
' . $variables['tree'] . '
';
}

and this:

function MYMODULE_preprocess_menu_tree__main_menu($variables){
    return '
' . $variables['tree'] . '
';
}

but not happening.

Can anyone see where i'm going wrong? or am I way off on this and it can't be done like this?


texts: Can't Rewrite the output of this field in views 7.x-3.3

texts:
I don't know if I am missing something, but when I check the box for Rewrite the output of this field or anything under the style options to customize the HTML nothing happens. I check it, save it, open it again and the boxes are unchecked. Anyone know what’s going on?

Edited for clarity. I create a new view, with the following settings: Page, Format:Unformatted list, Show:Fields, Fields is Content: Title. In the settings for Content: Title I check to create a label.
I click under “Style settings” Customize field HTML, Customize label HTML, Customize field and label wrapper HTML or even Rewrite the output of this field, but nothing happens. If I save the checkbox goes back to unchecked

SOLUTION Got it. Views 7-3.3 does not work with jQuqery 1.7+. It prevents the box from expanding after clicking the checkbox

Source: http://drupal.org/node/1494860


texts: chmod() and touch() operations not permitted

texts:
After updating drupal8 for 8.7.0 and then to 8.7.1 versions i have next errors:

Warning: chmod(): Operation not permitted in Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage->save() (line 76 of core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php).
Warning: touch(): Utime failed: Operation not permitted in Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage->save() (line 100 of core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php).

This errors appears for all twig templates and only at first time page loaded. For second and other times no errors and template created in cache folder.
I set 777 permission for all files. Checked files owner. Was Reading many forums and nothing ...


texts: Drupal 7: Custom Theme Failure on New Install (local to remote environment)

texts:
I've created a custom Drupal theme based on the Framework theme on a local Drupal 7 install. It's time to start developing more of the website so I created a fresh Drupal 7 install on a server that will be accessible by my coworkers for review and content creation. The new install went smoothly, the core themes all work, the base Framework theme even works fine, but my custom theme is having major issues.

When setting my theme as default the admin menu disappears, almost none of the actual HTML/PHP of the page loads, and the CSS file doesn't load at all.

I've cleared all the caches, I've given near full permissions on all files/folders in the theme, and nothing has changed a thing.

The Drupal error log spit out the following errors:

Warning: include(): Failed opening '/var/drupal/sites/cals.arizona.edu.herbarium/themes/dendritic/html.tpl.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in theme_render_template() (line 1517 of /var/drupal/includes/theme.inc).

Warning: include(/var/drupal/sites/cals.arizona.edu.herbarium/themes/dendritic/html.tpl.php): failed to open stream: No such file or directory in theme_render_template() (line 1517 of /var/drupal/includes/theme.inc).

And the same type of errors for the region and block tpl files.

I'm at a total loss and could use some help, I've been searching endlessly and without any progress.

Thank you.


texts: Load library dynamically depending on settings

texts:
My theme has a few settings that can be adjusted, one of them is style.

I want to load the libraries depending on the styles, but without writing them in the .libraries.yml

function my_theme_library_info_build() {
  $libraries = [];

  return $libraries;
}

function my_theme_library_info_alter(&$libraries, $extension) {
  $tmp_theme = theme_get_setting( 'my_theme' );

  $libraries['my_theme.theme']['css']['theme'] = [
      'css/themes/' . $tmp_theme . '.min.css' => [],
  ];
}

This is what I've got so far but I have to clear the cache after changing the style.


texts: Is it possible to load a library that is stored in public files directory

texts:
In my Drupal 7 theme I store a CSS file in the public files directory so that the submit handler of the theme settings form can write to the file to effectuate certain theme settings:

  // Load Theme Theme Settings CSS File
  $files_path = variable_get('file_public_path', conf_path() . '/files');
  if (is_file($files_path . '/example-themesettings-' . $theme . '.css')) {
    drupal_add_css(
      $files_path . '/example-themesettings-' . $theme . '.css', array(
        'preprocess' => variable_get('preprocess_css', '') == 1 ? TRUE : FALSE,
        'group' => CSS_THEME,
        'media' => 'all',
        'every_page' => TRUE,
        'weight' => 100
      )
    );
  }

Is this possible in Drupal 8 in a theme's example.libraries.yml file? I can't find any documentation about using tokens for paths in YAML files but if that possibility does exist that would be great.

If not I'll have to do it like color module does it and use hook_library_info_alter to add dynamic paths.


texts: Registration module, Rules, how to add the node-title of the registrated entity to notification mail

texts: I have a registration form built with registration module to enable users to reserve tickets for events. Now i want to send notification mails to the site administrators to inform them about new registrations. The mails are sent via Rules "After saving a new registration" and i have all fields included except the node-title... the only "hints" of this field are the tokens [registration:registration-id] and [registration:url]. Can i transform these to human-readable items somehow? Is there a way to connect the registration-form to the specific node?


texts: Trying to get property of non-object in i18n_langcode() (line 229 of i18n.module) and a bunch of other property of non-object notices

texts:
Recent logs lies to me.

I even did a dpm($node->title); with devel and indeed it's there.

I have like 6 pages of these notices that appear per page load. They are all different locations but they all have the same error type, property of non object. Has anyone experienced something like this?

I don't think it's a hack, at least not a Core hack, cause Core has been updated several times.

Ugh, soo strange.

This is hard to debug, here is another example

As you can see, I created a variable $test = i18n_language()->language and xdebug tells me $test = "en" yet on line 230 it fails to get the value according to the log.


texts: Views changefilter/argument when no results occur

texts:
i am using a date range filter which will list news for this week(Sunday to Saturday of current week). Am getting the results correctly.
Now am want to show the news for next week if there is no news for current week


texts: Override a view definition programmatically

texts:
I want to override a view definition programmatically (using the code that I get from "view export" in the views admin pages).

I've found examples for creating views using views_new_view(), but nothing on modifying views definition programmatically. Are there any examples / tutorials on this ?

Can I do this with views_get_view($name) / views_save_view() ?


texts: How to add 'font color' option to Buedit

texts:
I have used other text editors but BUEdit is my text editor of choice: lightweight and robust.

However, what I lack in its buttons is a function to enable users to colorize (and hence beautify) their texts. I'd be grateful to know how to do so.


texts:
How do I create a route that opens an external file?
As an example I have an XML file in my S3 bucket. I need to create a route to open that file from my website.
Is there a way to achieve this without calling a controller? Can I just set a property in the .routing.yml file for this?
my_module.index:
path: '/file.xml'
defaults:
  _controller: 'Drupal\my_module\Controller\moduleController::view'
  _title: 'file View'
requirements:
  _permission: 'access content'


texts:
I would like to add a form validation to an entity edit form. The entity has an entity_reference field on which I would like to perform a manual validation. I have successfully implemented a hook function to access the data entered into the widget, perform the required checks, and raise an error if necessary. The problem is that I do not want to make my function dependent on the widget that is used to alter the entity_reference field.

An entity_reference field with cardinality bigger than 1 (i.e. the ability to store a list of entries) can be edited using, e.g., an Autocomplete, an Autocomplete (Tag Style) or a Select List. The problem is that the data accessible in the validation function will differ depending on what widget is used.

The function $form_state->getValue('field_name') returns either

Array ( [0] => Array ( [target_id] => 2 ) [1] => Array ( [target_id] => 3 ) )

or

Array ( [target_id] => Array ( [0] => Array ( [target_id] => 2 ) [1] => Array ( [target_id] => 3 ) ) )

For a select_list or an autocomplete_tag, respectively.

I could obviously check what the structure of the array is to determine how to handle it, but I'm sure there must be a better way to obtain the data from this array.

My custom validation involves a check to be performed on a relation between the referenced entities and the user, so I do not need to perform any checks on the entered raw data. Basically, I just want to obtain a list of target_id's that I can interact with.


texts:
I am trying to get data from a submitted form - as far as I can tell, data is being passed correctly, but I want to look at and manipulate it.

I'm trying to print_r() it with no success - because it happens after form submission and it isn't on the previous page.

This is my submit function so far:

function multi_reg_pagecreate_submit($form, &$form_state) {

$form_state['values']['multi_reg_checkbox'];

}

The checkboxes are generated on the page /multiple-registration, but I have no way of checking my variables once this page is submitted.

Any help would be appreciated


texts: Set datetime timezone when posting data via JSON api

texts: I'm using core JSON api to POST/PATCH data from an Android App to my Drupal 8 site. When I need to fill a datetime field I use the next JSON, for example, 2020-02-20T13:15:00. But with this format, this time is UTC, but I need Europe/Madrid timezone. How should I do it?


texts: How to make a relation between nodes in drupal 7?

texts: I need to create a relation between to nodes in drupal 7 without taxonomy.. because I don't have taxonomy option for drealty_listing.. And after I need to create a view regarding these relation.


texts:
I have a theme set for view mode 'Teaser'. The theme name for this is named like this: node--teaser.tpl.php. So far so good.

Then I created content type 'something' and I would like to create a Teaser theme specific for my new content type 'something'. I have thus named my custom Teaser theme as node--something--teaser.tpl.php. I was expecting this more specific theme name to override theme node--teaser.tpl.php (broader, less specific), but it doesn't work that way. node--teaser.tpl.php has priority over node--something--teaser.tpl.php. Is this really the expected behavior for theme names priority? I would expect the more specific to 'beat' the less specific broader name.

Is it possible to force the more specific theme in template.php function theme_preprocess_node?


texts: How to migrate multilingual content from CSV to Drupal 8?

texts:
I come from read Using the new Drupal 8 Migration API / Module and Content Migration: CSV to Drupal 8 the process to create a migration is very clear and its works, but I can't find how to migrate content to a Multilingual site. In the Migrate API overview I can't find any information about this.

So, how can I migrate multilingual content?

UPDATE:
I found an example: https://github.com/drupal/drupal/tree/8.3.x/core/modules/migrate/tests/modules/migrate_external_translated_test

I was able for the moment to migrate the english content but not the translations.


texts:
We would like to place the aggregated CSS and JS onto a CDN as static resources.  To accomplish this we need to load these resources with a special hostname.  Let's say the base url of the website is www.foo.com.  We would like to load the aggregated CSS and JS using static.foo.com.  All assets associated with static.foo.com will be placed onto the CDN.

What is the best way to associate a unique hostname with aggregated CSS and JS?  The goal is to have href="//static.foo.com/.. in the resulting html.


texts: Drupal Commerce. Trigger shipping rules based on product field value

texts:
I'm really losing the will to live and hope somebody can help me.

I want to trigger a 'free shipping' rule based on a product field value, but for the life of me can not expose the free shipping field to rules.

I have read about bringing items into scope and have created a component which has access to the field. But when I attempt to add the component as a condition of my rule I am prompted to enter data selector -  none of which seem to lead anywhere. I think it was wanting a product ID, which does not make any sense to me.

What am I doing wrong?

MORE BACKGROUND

I have tried two scenarios, one of which is to create a shipping rule,based on the conditions below. The other is to create a component, as described above

Condition1 - Entity has field > Parameter: Entity: [commerce-order], Field: field_free_shipping

Condition2 - Date value is empty (also tried data comparison) > However this does not lead me to the field stated in Condition1


texts: Integrate core search block with search_api and Solr

texts:
Since search_api does not rely on the core Search module, the search bar (Search Form block) isn't used.  For a current project I want to use search_api, but the wireframes require the search bar at the top of the page.  The apachesolr module overrides that block so that it uses the Solr search instead of the core search when you specify that Solr is the default search.  Is there a way with search_api to enable the core Search Form block and have it use a specific search page?  In addition, you would also need to be able to keep the core Search module from indexing everything into the db, since that partially defeats the purpose of using Solr, but I'm guessing I could just form_alter that form (admin/config/search/settings) to add a 0 value.

Thanks.


texts: How can a user access only one specific node, and not all nodes of that type?

texts: I have a user with view and edit rights to a specific content type. This give the privilege to all users to view and edit all the nodes of that type. But actually, I want to create for each user a unique node, so that only that user may view and edit it. How can I do this in Drupal 7 ?


texts: Contextual filters with Entity reference

texts:
I have two content types called Basic Page and Contact Info.

There are around 5 nodes from Contact Info with some contact info (phone/fax/email/IM) in the body field.
In Basic Page content type there's an Entity Reference field that refers to Contact Info. So that for each page there would be a main contact person. When someone create a Basic Page node they can pick a Contact Info node from the dropdown (out of the 5 Contact Info nodes).

  Basic Page -> Contact Info (Basic Page content type refers to Contact
  Info content type)

Then I created a block view (added to the sidebar of Basic pages) which displays the contact info associated with that node.

Added a Relationship in the view (Entity Reference: Referenced Entity)

Right now it's displaying all 5 contact info nodes, not just the one associated with that particular basic page node. I tried to tweak the Contextual filter and relationships but couldn't get it to work.

I have a feeling that the solution lies in the php code that goes in Provide default value -> php code section.

Any help appreciated.
Thanks


texts: Is it possible to post a file with drupal_http_request?

texts: Is it possible to use drupal_http_request() to post a file? If not, what function can I use to submit a file to a webservice?


texts: Custom field: process submitted before storing

texts:
I've created custom field type and widget plugins in D8.

I am presenting an element in my widget as checkboxes, but I need to transform the resulting array into text delimited by pipes. i.e. a|b|c.

How would I approach this in the field widget?


texts:
I want to load coupons that have commerce_discount_reference=4. I find  that can load them by commerce_coupon_load_multiple but I dont know how I add condition commerce_discout_reference=4.
maybe something like

  commerce_coupon_load_multiple(array(), array('commerce_discount_reference'=>4));

what is correct way?


texts:
Just like the order data can be sent via email, I want to save the order data in a plain text file in a specific directory on the same server as the drupal installation.

Is it possible? How can I achieve this?


texts: How do I create slideshows for Youtube videos?

texts:
Like this website, I want to make a slideshow of you tube videos as done in LATEST VIDEOS section.

In order to achieve this:

I created a view of content type Video (in my case), added the field which has the video in the field's section.
To have the same videos as pager, I added the video field in the pager. But there is no option to resize the video to a smaller size so that it can be used as a pager.
And lastly, videos are also not getting displayed as expected in case of "SLIDESHOW"  formatter, vertical list of videos is getting displayed.


texts:
I copied files and database of a Drupal 7 site to another domain.
When I put the site in maintenance mode, and I login, I am redirected and logged in to the old site. I cleared the cache, also in the database, but the result is the same. When the site is not in maintenance mode, this doesn't happen.

Additionally, I have to say that I created an SSL connection and checked _Use a symbolic link from private_html to public_html - allows for same data in http and https_. I don't know if this has something to do with that.

Where is the responsible file? What do I need to do?


texts:
I need to reset userpoints for all users to zero now that the site is live. how can I do that? there used to be a userpoints_reset module for drupal 6, but it's not yet ported to drupal 7

thanks.


texts: Conditional field display in node template

texts:
I have a specific content type that I am overwriting the template node--contenttype.html.twig.

This conent type has 4 fields.

Title
Body
Image
Video

I am trying to hide the image field from displaying if VIDEO field has value. Which I am doing by using this code in custom twig template.

{% if node.field_video is not empty %}
{{ content.field_video }}
{% else %}
  {{ content.field_image }}
{% endif %}

The only problem is that I get one of the fields printed as needed plus I get both fields shown.

Video filed is displayed, plus I get an image and video shown again. Wherever those fields are positioned in MANAGE DISPLAY.

If I disable the two fields in MANAGE DISPLAY then, nothing shows up at all.

How can this be fixed?


texts:
On my drupal website every page with "/nl" in the url, give an error.
Only the home page works, because there is no "/nl" in the url.

Example:
Home page: http://wnl.be/
All other menus, links, ... on the website give errors, such as http://www.wnl.be/nl/wagenpark

The big problem is that the login page also "/nl" contained in the url. You can test it: www.wnl.be?q=user/login

How can I fix this?


texts: How do I implement a VIDEO gallery like gallery formatter but with videos?

texts:
I need to implement a gallery of videos in DRUPAL 7 like gallery formatter in Drupal 7 but with videos.

The videos are from YOUTUBE.  I created a content type named "video" and I have used the module:  http://drupal.org/project/video_embed_field for upload the code of video.  Have you any idea for create the video galleries?

Thanks for your help.


texts: Video Embed Field: Pull in Original Title & Description

texts: I'm using the video embed field in Drupal 7. I'd like to pull in the original title/description from youtube/vimeo, and then have an (optional) additional user description field. How do I get it to use the original title/description directly from youtube/vimeo?


texts: How to do I stop product URLs changing each time I delete and re-import?

texts:
Kickstart 2. I'm importing products using Feeds Importer. Every time I delete a product and re-import I get a sequential number appended to the end of the product's URL. For instance, I import MyProduct and its URL is mysite.com/products/MyProduct. I delete that product and import again and now the URL is mysite.com/products/MyProduct-0. Next time -1, etc.

I tested removing all products, truncating the commerce_product and commerce_product_revision tables and that didn't help.

So, how do I keep the URLs from changing? I'd prefer to fix the actual problem, not just use PathAuto or some other process afterwards to change the URLs.

Thanks.


texts: How can I display a node so that it appears as a regular page

texts:
When I am using Drupal through the standard user interface, and click on a node title, Drupal will show the content in the main content area and (depending upon permissions and configuration) will add some tabs between the title and the content. If comments are enabled for the node, a comment entry form will appear below the content field.  The tabs and the comment form can be seen in the image below, with the text in red coming from the node fields that resides in the database.

I want to do the same programmatically from the inside of a module.  I.e. I want to pull a node from the database, and then display it so that it looks the same as if I've clicked on its title in the user interface.

Here is a more detailed description of what I want to do: I am writing a module to display a node for the user.  This module have a button ("Get info") that the user may click. When the user clicks the button, it module pulls various data from a number of external sources, does some processing of this data, and stores the results as a new node object in the database (all this already works).

However, I want to show this node object to the user that pushed the button as soon as it has been created (i.e. to avoid having the user click through a link in order to view it). The user experience I am after his that the user clicks on a "Get info"-button, and then automatically is shown the new node that has been created programatically as a result of this click.

The last bit (showing the user the newly created node) does not work.  I am asking for help to get that part of this module right.

So far I've tried to use the following code (suggested here, but later deleted):

$node = node_load($nid);
$elements = node_view($node, 'full');
$full = drupal_render($elements);

This results in the follwing display on the page:

Note that there are no tabs ("View", "Edit", etc.)  between the title and the content, and no comment form below.  The blue "The title" is a hyperlink, i.e. it neccessary for a user to click through that hyperlink to get to a full node view with a comment form.


texts: How to expose field collection's items id or UUID to the front end?

texts:
I'm working with the Drupal 8 field collections and currently have setup a custom collection that is an editable widget on the edit pages. I'm trying to target these collection items via their unique item_id or uuid, but when inspecting the html code. I can't seem to find any source that shows these unique identifiers.

Below is the image of the database results of the field collection id's, just to show that they do indeed exist.

Since this is a Drupal 8 module, I tried to trace some of the elements that are being rendered to the front end. For instance the REMOVE button. I'm able to find it in the following file:

http://cgit.drupalcode.org/field_collection/tree/src/Plugin/Field/FieldWidget/FieldCollectionEmbedWidget.php

But from here on, I'm quite unsure of how to even expose the item_id or uuid. I tried to dpm() a bunch of arrays and variables, but I can't seem to find anything that matches what is in the database.

How would one go about finding the item_id or uuid in the following code for Drupal 8 Field collection?

And another screenshot of not being able to find these unique identifiers.


texts: Are there two identical .htaccess files in a Drupal installation?

texts:
I run a Drupal Commons site and I'd like to set it up on a new server. When I set this particular site up, I need to replace Drupal's base .htaccess file so that it runs in my server environment.

However, this answer states that the .htaccess is present in two places:

  The .htaccess files (which are present in at least two places) should have the permission 644.

Is this true? If so, where is the second one? Is it the one in sites/default?


texts: Link to content in views doesn't translated to fr

texts:
I made a content ( type = article).
I made a view ( list of articles) and i add link to content.
I activate fr language in the site => so

www.example.com/liste-des-articles => english page.

www.example.com/fr/liste-des-articles => french page.

My problem is the link to content doesn't work correcly in french => when i click to it => redirection to english page.

what shall i do ??

Thanks for the response.


texts:
I would like to build a custom menu structure based on cck fields.

lets say I have 2 fields in which I will type the menu item.

parent item = field_category
child item= field_subcategory

So in a node create form i use for 'field_category' apples or pears and for 'field_subcategory' green or red.

These items will also be made terms(i have a 3rd field containing tags that are equal to all menu items)

my menu structure is like:

apples

green
red

pears

green
red

my terms are: apples, pears,red, gree.

Then part 2:
These items must be linking to a term or multiple terms.

apples --> links to term apples

green --> links to term apples AND green
red --> links to term apples AND red

pears

green
red

I suspect i wuould need a custom module to do so, but i am not a programmer...so I really hope someone has a solution with contrib.


texts: How can I check in Twig if an advanced theme setting option is unchecked?

texts:
I've a list of advanced theme option(checkbox) to not display, such as search bar.
I did many research about custom advanced theme setting, but all the samples are
{% if remove_searchbar %}{% endif %}. This render if the option is checked but I want the opposite.
How do I make a statement for if an option is unchecked? I really don't want to do {% if remove_searchbar %}{% else %}{% endif %} or make everything checked by default.


texts:
I have a views table block within a panel.

The table is overflowing the panel and I am trying to understand how to constrain it. I have tried setting it's CSS to various widths but they are always ignored. I can change individual column widths, colours etc but not the width.

Do views tables ignore these settings and just display to the width of their content?
What is the best way to set their width?

Any tips for using views tables in responsive themes(within panels)?

I'm using Drupal 7.23 , Views 7.37 , Panels 7.33 , Omega-4

Update:
In my CSS for this table I have previously tried setting table {
  width: 100%; (and with !important). I know it is being applied to the table as when I have very colums it increase the width of the whole table to 100% of it's panel.

The problem occurs when there are a lot of columns and the content text of the column is wide. Then the table overflows past 100%. I can make it thinner by changing font size but I am trying to understand how the views table width is set.

In terms of Views table plugins / modules I am looking at FooTable , Responsive Tables and (sandbox) Better Views Tables. None of these are mature modules so I am quite nervous about using them.


texts: Search api solr result reordering on field value

texts:
I'm using search_api_solr and search_api_location. I have a view with exposed filters to perform geolocation searches.

I'm trying to reorder search result from a solr query based a referenced node's field. My question is witch hook to use, where i can access node fields and reorder the results.

I already tried:

hook_views_pre_render()
hook_views_post_execute()
hook_views_post_render()
hook_views_pre_view()

but reordering is effectless or i don't have access to node fields.
I'm doing something like this:

$results = &$view->result;
$to_search_top = array();
foreach ( $results as $i => $capacity){
  if ((int) $capacity->{_entity_properties}['field_free_capacity_company_ref:field_last_review'] > 1) {
    unset($results[$i]);
    $to_search_top[] = $capacity;
  }
}

foreach ($to_search_top as $capa) {
  array_unshift($results, $capa);
}

Thank


texts: Multistep form loses input when visiting previous step

texts:
I am developing a custom module with the ability to store data on an external database using Drupal 7 Form API.
I started with the multistep form example, added few more steps and other fields.

To implement the ability to edit those data I created a class that retrieves returns an array suitable to fill the $form_state['values'] element in order to have a default value for each form element. Here follows the code I have in the form callback when going to edit my data:

if( !empty($form_state['build_info']['args'][0]) ) ) {
    $a = new ind();
    $a->get_ind( $form_state['build_info']['args'][0] );

    $form_state['values'] = get_object_vars($a);
    unset($a);
}

Problem is when I hit the previous/next buttons because of the form is being rebuilt always with the data from the class so every change in a field is lost when hitting "Previous"; suddenly every change gets lost when I click "Next" after "Previous" (fields are empty!).

How do you achieve editing with multistep form with existing data? I am stuck here attempting to put the code above at submit and previous handlers with no success.


texts: Display terms in relation to the terms of the page

texts:
I created product sheets related to the terms of taxonomy. How to display a block of view, the products in relations with the currently visited page?
For example if my page is linked with the term "soap" requires that all products associated with the term "soap" appear in the block view.

I made a block view with a pop filter "tid" but I do not know how to parameterize.

version D7