texts: Set a default font family and size in ckeditor

texts: Its been 4 days I am trying to set a default font family to the ckeditor(not set default label) but I am not able to do the task. Also i tried working with content.css but its not working. Please need a help


texts:
I want to alter product variation view and want to display a new form which value depends on variation price. I can add the field to the node using hook_node_view_alter() but i want to add it to the product variation right after the price field. I just need to display an integer dependent of the price.

Any help with this?

Thank you


texts: passing page arguments to drupal 8 from controller to form controller

texts:
This is my code in routing.yml file

test.check-test:
  path: 'node/{node}/test'
  defaults:
    _form: '\Drupal\test\Form\Test'
    _title: 'Test'
  requirements:
    _permission: 'access test'

I need to get the value of node in the form controller buildForm function.

How can I access that? Any help?


texts: Why can I not disable any module via the admin menu?

texts:
Any module can not be disabled via admin menu (admin/modules page). This problem appeared after succesful instalation and customising site functionality.

I'm logged in as administrator, using Drupal 7. Switching off programatically seems works.

Any idea what can be a reason and how it could be solved?


texts: Show exposed sort by at the Header of view

texts:
Drupal 7, views-7.x-3.7.

I have a exposed sort by item in the exposed form block.

I wish to show the sort by item at the top of the view result page instead of in the exposed form block.

How to do that?

Thanks!


texts: How to remove the core stylesheets from a theme

texts:
I am developing a Drupal theme and noticed the following CSS files are added automatically by Drupal. I would like to them to be removed.

<link rel="stylesheet" href="/core/themes/stable/css/system/components/ajax-progress.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/align.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/autocomplete-loading.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/fieldgroup.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/container-inline.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/clearfix.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/details.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/hidden.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/item-list.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/js.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/nowrap.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/position-container.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/progress.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/reset-appearance.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/resize.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/sticky-header.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/system-status-counter.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/system-status-report-counters.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/system-status-report-general-info.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/tabledrag.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/tablesort.module.css?owah24" media="all" />
<link rel="stylesheet" href="/core/themes/stable/css/system/components/tree-child.module.css?owah24" media="all" />

I have tried two ways to remove it. First one is using libraries-override

libraries-override:
  system/base:
    css:
      component:
        /core/modules/system/css/components/align.module.css: false

The next one is using hook_alter_css

function hook_css_alter(&$css, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
  unset($css[drupal_get_path('module', 'system') . 'css/components/align.module.css']);
}


texts: How can I add a way to jump months using the calendar module

texts: I have a calendar being shown by month. How can I add an exposed filter or dropdown so users can jump ahead to any month and year?


texts:
I just did a fresh Drush installation, and now I have version 8.1.15.

When I run drush rr, I get the following error message.

  The drush command 'rr' could not be found.  Run drush cache-clear drush to clear the commandfile cache if you have installed new extensions.

Even after running drush cache-clear, I still get that rr is not a known command.

Is this still available in Drush 8?


texts:
I've created a views page named "Search" with a path of "product-page". Then I created a views block named "Sponsored Ads".

With the "Search" page, I exposed some fields for the filtering, then assigned the "Sponsored Ads" into the region and shows to only page listed "product-page".

I only want to display the "Sponsored Ads" into the "product-page" only, then exclude it from the results with "?"
(Eg. /product-page?title=test&field_category_tid=All)

How can I achieve this? Please help...


texts: Cant create View with Many to Many Relationship

texts:
I have a situation with three content types. (Simplified)

A Person is referenced in many Transactions, and a Transaction also has a reference to a Company. I.e. Person -< Transactions >- Company

Here the Transaction holds the entity reference to a Person, and a reference to a Company. I need to create a view that given a value from the Company content type, returns all the Person entities.

In SQL I would do something like this, to give me Persons who have had Transactions with a specific company:

  SELECT P.*
    FROM Person P
    JOIN Transaction T on T.PersonId = P.Id
    JOIN Company C on C.Id = T.CompanyId
    WHERE C.Name = 'Drupal Co.'


texts: How to restyle GeoField's proximity filter controls?

texts:
Background
I am using the modules: geocoder geofield addressfield geophp ip_geoloc libraries to create a store locator view. The user can search the available stores using an exposed GeoField proximity filter.

Question
How can I restyle the GeoField's proximity filter controls? I would like to change the edit box for distance to a select with fixed values, and hide the distance units select defaulting it to miles.


texts: How do I auto enable modules within an install profile

texts: I have created an sample installation profile (based on one that I grabbed from the Acqua Drupal install profiles. Thus far I understand the basic architecture. I add dependancies, but I cant figure out how to enable the modules. For instance, I want to require views, views_ui, and features, and I want those modules to be automatically enabled when I install the profile. I'm assuming I add code somewhere in my .install file within the profile. Can someone give me an example of how I would require and enable views for instance?


texts: File (Field) Path settings to rename multiple images with their alt or title

texts: The module File (Field) Path allows me quite nice to rename a single image file with its "alt" or "title". But if allow the image field to accept multiple downloads, I cannot get the individual alt/title for each file (with some kind of loop) as there seems no variable token for the delta. Am I missing something or is there really no chance to rename the files that way?


texts: URL variable not respected when ajax call happens in user registration form

texts:
There are some fields (some required, some not) I need to (conditionally) hide in the user creation form:

function hook_form_alter(&$form, &$form_state, $form_id){
    switch($form_id) {
    case 'user_register_form':
        //variable_name is sent using hook_menu_output_alter()
        if ($_REQUEST['variable_name'] == 'variable_value') {
            $form['field_id'][LANGUAGE_NONE]['#required'] = FALSE;
            $form['field_id']['#access'] = FALSE;
        }
}

This generally works but not when I override a (required) entity reference field in the form to change its autocomplete path:

//in another module:
function hook_alter(&$form, &$form_state, $form_id){
    $form['entity_ref_field'][LANGUAGE_NONE][0]['target_id']['#autocomplete_path']= 'custom_autocomplete';
    $form['entity_ref_field'][LANGUAGE_NONE][0]['target_id']['#ajax'] = array(
            'callback' => 'custom_callback',
            'wrapper' => 'custom_wrapper',
            'method' => 'html',
            'effect' => 'fade',
    );
}

function hook_menu(){
    $items = array();
    $items['custom_autocomplete'] = array(
        'title' => '',
        'page callback' => 'custom_page_autocomplete',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}

function custom_page_autocomplete($string) {
  $string = array(':s' => $string . '%');
    if ($string) {
        $results = db_query("SELECT title, nid FROM {node} as n WHERE type = 'custom_type' and title LIKE :s", $string);

        $items = array();

        foreach ($results as $result) {
            $items[$result->title.' ('.$result->nid.')'] = $result->title;
        }
        print drupal_json_encode($items);
    }
}

function custom_callback(&$form, &$form_state) {
    //if an entity reference field value is set, then find & assign values to some other fields, based on that entity:
    $entity_id = $form_state['values']['field_id']['und'][0]['target_id'];
    if ($selected_entity = node_load($entity_id)) {
        $form['field_somefield1'][LANGUAGE_NONE][0]['value']['#value'] = $selected_entity->field_someotherfield1['und'][0]['value'];
        $form['field_somefield2'][LANGUAGE_NONE][0]['value']['#value'] = $selected_entity->field_someotherfield2['und'][0]['value'];
        $form['field_somefield3'][LANGUAGE_NONE][0]['value']['#value'] = $selected_entity->field_someotherfield3['und'][0]['value'];
    }

    $commands = array();
    $commands[] = ajax_command_replace("#edit-field-user-somefield1", render($form['field_user_somefield1']));
    $commands[] = ajax_command_replace("#edit-field-user-somefield2", render($form['field_user_somefield2']));
    $commands[] = ajax_command_replace("#edit-field-user-somefield3", render($form['field_user_somefield3']));
    return array('#type' => 'ajax', '#commands' => $commands);
}

So, whenever an AJAX call is made by the overridden field and I then submit the form, all the (previously hidden) fields are visible again and the required fields become required again.

Any ideas why this is happening?


texts:
i want to assign permissions to a role in my hook_install() , but the permissions that i'm adding are part of my modules hook_permission()
 don't exist yet?
so how to grant permissions role created in hook_install after hook_permission ?

NB :

i have D7.23
     -
my module create the role and his permissions .

Thanks.


texts: How to dynamic change the size of the icon marker when using Leaflet maps and views

texts:
I am using the module Leaflet and its sub-module "Leaflet views" and IP Geolocation Views & Maps (IPGV&M for short), which provides a nice way to assign icon images to, in my case, content type in order to get a map displaying markers. I have set it up so to show different markers depending on the content type. I have also a field linked to the nodes, displaying a number, which is the number of users subscribed to that node.

What I need is to change dynamically the size of the marker, so that the nodes with more people subscribed (bigger int) will appear bigger than others with lower number.

I am using a view to display the map and the markers.

Any help would be greatly appreciated!


texts:
How I can include Commerce SKUs in search result?

I am using “Search API and Search API Solr” modules.

Any suggestions?


texts: How do I use CkEditor layout on textfield input?

texts:
I have a content type with a "Text (formated)" field. When I try to write something in it, all my HTML is ok. But I want to use the buttons of ckEditor to make it more "user friendly". I don't want to always have to write all my tags manually.

On "Text, long (formated)" field, there is no problem.

You can see what I mean in this screenshot.

I already tried to switch text format under my field. Nothing changed, except I got more tags allowed.


texts: I have a standard form structure with fieldsets etc. I'm trying to populate my form into various nodes. This means that the same form will be displayed on more than one nodes. For every node, the form's fields will be enabled or disabled. This depends from XML files where it is described which fields will be enabled or disabled. This is a complex problem where i don't know how to start searching.


texts: Can drupal be setup for users to interact with and submit suggested changes to an article?

texts: We will have static content. But we want the content dynamic in the sense that users can submit suggested revisions and the "community" can either vote or comment on that suggested change.


texts: Site redirects to old URLs after moving to a new server

texts:
I am in the process of moving a Drupal site to a new server.
I copied the database and moved all the files.
The old URL for the site is http://www.sniffingmusicians.echidna-band.com/ and the new is http://www.sniffingmusicians.com/, which point to a different server.
Even though the frontpage of new is there, when I log in, I am redirected to the old domain.
Additionally, all the content is using the old URL. I changed the value of $base_url in settings.php, but there is no real impact.
Where else can I reconfigure my site's URL?


texts: Ckeditor images use different image sizes based on device screen size

texts: For images embedded into the Ckeditor body. I want images to load that have been specifically sized for the user screen based on breakpoints. Just like the Responsive Images module in Drupal 8. Is this possible? This module comes with core but is not enabled by default and it only works with fielded images. This seems to be on the right track https://ckeditor.com/cke4/addon/imageresponsive


texts: Print all the pages in the same level in a book

texts:
I am have a book like this

About Us

  --Overview
  --Vision
  --Mission

I want there to be menu like this in the left side when the user is in any of there page.

  --Overview
  --Vision
  --Mission

Now the links are visible when in About Us page, thats the main parent page. I have spend 2 hours already in google and drupal documentation but no use.


texts: Can´t create more than one content type group

texts:
I am using Drupal commons for a community social network. I am trying to create a second group based on a content type named Leagues. In order to create that group I went to: /admin/structure/types/add, gave the group a name and selected the group check box (as the example given on this page: https://www.drupal.org/node/2014777).

But for some reason every time I try to create a new league and save it, I get this error:

  EntityMetadataWrapperException: Unknown data property field_og_subscribe_settings. in EntityStructureWrapper->getPropertyInfo() (line 335 of /home2/jane/public_html/devpage/profiles/commons/modules/contrib/entity/includes/entity.wrapper.inc).

It seems that the field field_og_subscribe_settings is attached to the content type group which I am not exactly sure what it means, but it seems I can´t create more than one group based on a content type.


texts: How do I get results in Views (Contextual Filters) regarded titles in URL?

texts:
I want the Views module to give me results by criteria of title of the node. I want to display all results from the nodes with the same title.

So I used the Pathauto module, and put what is in title fields into url.

But when I tried to set contextual filters it doesn't return any results. I tried many options, for example : Type - Raw value from URL, Path component: 1, and did some variation with that, but nothing worked.

What do I have to do?


texts:
I have a custom content type with a date field that includes year, month, day, hour and minute. If I create a view of all the node start dates I get something like this

2014-10-23 13:00:00
2014-10-24 18:30:00
2014-10-24 21:00:00
2014-10-25 09:30:00
2014-10-25 10:00:00
2014-10-25 13:00:00
2014-10-25 18:30:00
2014-10-25 21:00:00

I want to create a view that lists only the unique days in ascending order. If possible I'd also like to rewrite these as links. Ideally I'm looking to generate something like

Thursday, October 23 2014
Friday, October 24 2014
Saturday, October 25 2014

or even better

Thursday, October 23 2014
Friday, October 24 2014
Saturday, October 25 2014

I've tried aggregating but I have to install extra modules to get the day granularity and even then I can't sort by date ASC. I've tried grouping but that just add extra headers I can't rewrite as links plus it means I still output a line for each node like this

Thursday, October 23 2014

Thursday, October 23 2014
Thursday, October 23 2014
Thursday, October 23 2014

Friday, October 24 2014

Friday, October 24 2014
Friday, October 24 2014

Saturday, October 25 2014

Saturday, October 25 2014
Saturday, October 25 2014
Saturday, October 25 2014
Saturday, October 25 2014
Saturday, October 25 2014

because the view is only using one field and if I hide it the view doesn't work. I've also used 'Distinct' and 'Pure Distinct' but they don't seem to do anything.

Is there something I'm misunderstanding? I don't get why this is so much trouble to do.


texts: How to redirect to external URL upon form submission

texts:
I've extended a FormBase and I've defined the submitForm method. In this method I want to redirect to an external URL (https://example.com/my/path?amount=33&gift=0&product_id=1)

$myurl = "https://example.com/my/path?amount=33&gift=0&product_id=1";
$redirect = Url::fromUri($myurl);
$form_state->setRedirectUrl($redirect);

And I get the error:

Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.

Ok, no problem, let's create one:

$myurl = "https://example.com/my/path?amount=33&gift=0&product_id=1";
$redirect = new TrustedRedirectResponse($myurl);
$form_state->setRedirectUrl($redirect);

Here's the error:

Argument 1 passed to Drupal\Core\Form\FormState::setRedirectUrl() must be an instance of Drupal\Core\Url

So it appears we've gone full circle. Is there a way that maybe I can convert the TrustedRedirectResponse to a Url object?


texts:
I'm a Drupal themer, learning how to develop for Drupal. Currently I'm reading a book called Drupal 7 Module Development in which the following code is used.

/**
 * Implements hook_block_view().
*/
function first_block_view($delta = '') {
  if ($delta == 'list_modules') {
    $list = module_list();

    $theme_args = array(
        'items' => $list,
        'type' => 'ol'
    );
    $content = theme('item_list', $theme_args);

    $block = array(
        'subject' => t('Enabled Modules'),
        'content' => $content,
    );

    return $block;
  }
}

Its a simple module that returns a ordered list of all the enabled modules. Notice they are using the theme() function.

As a themer, I wanted to know more about this function, so I looked it up on drupal.org, and saw this:

  Avoid calling this function directly. It is preferable to replace direct calls to the theme() function with calls to drupal_render() by passing a render array with a #theme key to drupal_render(), which in turn calls theme().

So I tried replacing it with drupal_render(), and came up with this:

/**
 * Implements hook_block_view().
 */
function first_block_view($delta = '') {
  if ($delta == 'list_modules') {
    $list = module_list();

    $theme_args = array(
        '#theme' => 'theme_args',
        'items' => $list,
        'type' => 'ol'
    );
    $content = drupal_render($theme_args);

    $block = array(
        'subject' => t('Enabled Modules'),
        'content' => $content,
    );

    return $block;
  }
}

This however, is giving an error: Theme hook theme_args not found.
Am I missing something? I would appreciate any help, and if possible, an explanation of what I did wrong. (since I'm learning this stuff.)

I've seen a similar question posted here, and followed its instruction, but no success.
How to rewrite this theme call to drupal_render


texts: Removing the email validation requirement

texts:
I'm building a premium membership site where a visitor can purchase a role, and gain access to the privileged content using the Ubercart module. I've got all that working fine, but the last tiny snag that my client wants to remove is to remove the validation email requirement that's fired when someone signs up on the site in Login Toboggan (6.1.9). I've got nothing set that is forcing this extra step and I've come to believe that this may be a feature in Drupal (Acquia distro 6.22) core for any user that registers. I was hoping that this module (Logintoboggan) would eliminate that step but I've not as of yet been able to do so.

I can allow the newly registered user access by setting that in the module, but the notification and validation email requirement still remains. Can anyone recommend a way around this? I just want them to be able to come to the site purchase their membership without any validation/confirmation email. Is this possible?


texts: Slider for Select List (Text, Numbers etc) in Views Exposed Filters

texts:
I am trying to implement a vertical slider-like select list inside my views-exposed-filters as shown in the image below (on the left sidebar, vertical slider)

I am using Drupal 7 and Views 3. I have tried Better exposed filters module but I don't think it has such a feature. How can I achieve this? (See updates below)

Thanks

UPDATE: I have also tried Views Contextual Range Filter and Select with Style modules but couldn't get any of them working as desired.

UPDATE 2: One thing I have realized is, I am trying to show a an exposed filter for a term reference field, named 'Style' (based on a taxonomy term), so actually the field itself is not a multi-value field, hence it is not a select list. That is why Select with Style module doesn't work here. Is there a way to tweak my field/Views to make it work with one of mentioned modules?


texts: How to create a module that shows some fields of profile2 type?

texts:
I want to create a module that shows some fields of profile2 type, in fact I want to show some information about any user in profile page of theme.
Profile2 type is "stores", field machine name is "field_store_name" and my module name is "profile_header".
I put below code in profile_header.module

 <?php
function profile_header_block_info() {
  return array(
    'profile_header' => array(
      'info' => 'profile stores header',
      'cache' => DRUPAL_NO_CACHE
    )
  );
}

function profile_header_block_view($delta = '') {
  $block = array();

    global $user;
    $account = user_load($user->uid);
    $user_fields = user_load($uid);
    $profile = profile2_load_by_user($account, $stores = NULL);
    $field_store_name = field_get_items('profile2', $profile2['stores'], 'field_store_name');
    $block['subject'] = 'profile stores header ';
    $block['content'] =  theme(
          'profile_header',
          array(
            'field_store_name' => $field_store_name,
          )
        );
     return $block;
}

function profile_header_theme($existing, $type, $theme, $path) {
  return array(
    'profile_header' => array(
      'template' => 'profile_header',
      'path' => $path . '/theme',
      'variable' => array(
        'user_fields' => NULL,
      ),
    ),

  );
}

and put below code in profile_header.tpl.php, and clearly I put this file in profile_header/theme directory.

<?php
?>

            <?php print $field_store_name ; ?>

But unfortunately this module doesn't show anything.


texts:
I am working on a site that has a registration form (created with Webform) for 4 different conferences.

The registration goes to everyone on the list (there are 8 people on the email list). But we just added another conference that should only go to 3 people in particular.

Is there a way, to write a rule (we have custom ruleset module) to have the registration email for a particular conference go to a specific person?  I am working on Drupal 7.

Any suggestions would be greatly appreciated.


texts: How to add "Add to Cart" button using Ubercart?

texts:
I'm building a website on Drupal 8 that involves kids videos, that can be sold as separate files. I'm using Ubercart module.

I'd like to know how I can put an "Add to cart" button, linking the video content page with the appropriate cart page.

Please put forward your opinions.


texts: Taxonomy View - show only terms with children

texts:
I have a view of terms where I show in a grid terms form the highest level (those with parent = 0). I have to limit this view to only show those terms that contain at least one child term. I can't figure out how to do this. Anyone?
Thanks!


texts: Links in second language not working when logged out

texts:
I have inherited a Drupal web site with a lot of modules installed. Part of these modules have been setup to allow for translation of web site elements between English and French.

The site is configured to use paths prefix (mywebsite.com/fr) to indicate items from another language.

When I am logged in as administrator, I can access mywebsite.com/fr and see the french version of the homepage. When I am logged out, trying to get to the same address just redirects me to the english root (mywebsite.com).

Any ideas on where there may be a setting that would only allow logged in users to see translated content?


texts: How to programmatically read the display name of a CCK field from the allowed list?

texts:
For example if a CCK text field is configured to have the following allowed values:

US|United States
UK|United Kingdom

The node has the corresponding field:

node->country

and its value can be found by accessing:

node->country[0]['value']

which will return 'US' or 'UK'. What is best way to return the display name which was specified in the allowed list (i.e "United States" or "United Kingdom")?


texts: I am new to Drupal, I wonder how can I post file(s) that should be viewable to specific user? for example upload a pdf invoice to a specified user? Thank you!


texts: How to load file, when I know it's filename, but not fid?

texts:
I create filenames using some ID and timestamps. I don't want to add additional table to "remember" associations, as filename keeps them pretty well:

$filename = get_symbol_by_id($id) . ' ' . get_modified_by_id($id) . '.xml';

Also, I don't care if they will be managed or not. And I don't care if they get deleted - I can recreate them on demand. They are small, so leaving older ones behind does not create any cost worth taking care of. What is the proper course of action?

"Unmanaged" files seems to be generally discouraged in 7, but using them is pretty straightforward with tools like:

file_unmanaged_save_data
file_exists($uri) in a manner shown here
file_transfer takes $uri, not $fid, so it's even easier to use it on unmanaged files

With managed files, I'm afraid I would be forced to use

EntityFieldQuery, overly complicated for such simple task or
$conditions in file_load_multiple, marked as deprecated.

So what's the proper course of action, if I want to avoid both deprecated functionality and overly complicated code?


texts:
In admin/structure/menu I created a menu. Is it possible to render this menu (with machinename: my_menu) in a twig template? Somehow like:

{{ my_menu }}


texts:
I am using the syntax highlighter, which is convenient. I was wondering if there is a module for a console style rendering. For example, in a wordpress site, I saw

I highlighted it just to show that it is not an image of an actual terminal.


texts: Adjust a view so there is one image of size normal and other images are thumbnails

texts: I have created a gallery for every user. I would now like to alter the view so that one of the images is a medium size and the other images are thumb nail size. I know you can adjust the layout in a view but I am not sure how to change the size of one image and keep the others as the default thumbnail.


texts: How do I get fields of a certain field type?

texts:
I've seen how to get lists of fields by entity and bundle with field_info_instances() and field_info_field(), but I'm not seeing a way to get all fields of a particular type.

I was able to cook this up to do exactly what I want:

function field_get_fields_of_type($type) {
  $fields_info = field_info_instances();
  $return = array();
  foreach ($fields_info as $entity => $bundles) {
    foreach ($bundles as $bundle => $fields) {
      foreach ($fields as $field_name => $info) {
        $more_info_because_type_isnt_included = field_info_field($field_name);
        if ( $more_info_because_type_isnt_included['type'] == $type) {
          $return[$field_name] = $more_info_because_type_isnt_included;
        }
      }
    }
  }
  return $return;
}

dpm(field_get_fields_of_type('entityreference')); // prints out all entityreference fields

But that seems to be an awful lot of code, and and awful lot of looping to get something that should probably be reachable through the field API.

Does anyone know of a Field API function that will more efficiently retrieve the data I'm looking for?


texts: How do I list modules on my site that are not covered by the Drupal security advisory policy?

texts:
We have a number of contributed modules installed on a Drupal 7 site, but there doesn't seem to be an easy way to see those covered by the Drupal security advisory policy, without copy-pasting each module name into the address bar and manually checking the page.

Is there a way to do this with Drush?


texts: How can I show all registered users per event in Calendar?

texts:
I am using Entity Registration together with Calendar. I'm trying to list all registered users in the event, but I don't know how to configure the view properly. Take a look at this image:

I only want one listing of the event and then all the registrants inside that entry. Now it lists one event per registrant.

The view is like this:


texts: How can a user join a group in Drupal Commons?

texts:
I'm using Drupal Commons (unfortunately 7.x-3.0-beta1).

In Drupal Commons, how can a user join a group?

Either my site has been customized out of all recognition or I simply can't see where a normal authenticated user goes to join a group.


texts:
I have to update a website from 7.14 to 7.31.

I feel like this contains a lot of risks. As anyone updated so many versions? What are your recommendations ?

I figured it would be better to update version per version instead of applying the 7.31 update right away.
I made sure the core was not modified.

Thanks,


texts:
I would like to pass path alias as arguments to a views page. I tried the two methods one and two but unfortunately this doesn't works.

What I want to do is, example.com/box/portfolio link should show the example.com/box/45, 45 is node of portfolio. My views page path is box/% and I used the arguments as Node Id.


texts: How to show Comments (created with entity form) only to the Admin user and logged in?

texts:
I'm cool fresh drupal :)

I'm trying to filter views in a content type entityform for the user logged in and admin. In practice this form through the admin and user login should communicate.

problem: On page dein results I see only the one who wrote the admin, but the user responses.

Then I node (private area) with filtered content to the user, so each user sees the content added by the administrator for each user.

I would like each user to comment on the content that the administrator has reserved for each user.

Now I tried with modules or with the comments of core drupal views of seeps into single user comments and the admin.

example:
There are three users, User "A" User "B", User "C",
Each of these users comments posted content dall'aministratore reserved for them. The administrator shall have commmenti User "A".

The same node (private area) would like to display the comments and views with only the user "A" and the responses made administrator user "A". And so also for users B, C, D, F etc. ...

I hope to be as clear as possible. :)

Where am I wrong?
help me. :)

Sorry for my bad english


texts:
I'm using Drupal 7.
When I POST request to remote site (services_endpoint/user/login) I am able to receive a session name and session id and all other information about user. After that when I open a tab in the same browser OR do automated redirect, I am not logged in to the remote website. I think I need to set cookie somehow to a browser. I try with setcookie($session_name, $sessid) but it's not working!

Any help?


texts:
I'm trying to get Drupal to work with the S3 File System module.

I downloaded the AWS SDK files and put them in the libraries folder. I don't know why I'm getting the failed to load error.

I tried using the https://github.com/aws/aws-sdk-php/releases/download/2.6.3/aws.zip as suggested. It fixed 1 of the 2 errors, but it fails to load the AWSSDK.

I tried to clear the cache, but it didn't help
I checked the admin/reports/dblog page, in the case the errors were related to file permissions on the SDK files), but nothing shows up


texts: Path Redirect Import module getting "Line 1 contains invalid status code"

texts:
I created a CSV file without the headers:

From URL    To URL  Redirect Status Redirect Language

But the file doesn't import and I get error messages:

  "Line 1 contains invalid status code"

My CSV file:

“file/sitemap.xml”, “sitemap.xml”,  “301”,  “en”


texts: Views module: How to limit access by user

texts:
I'm using the Views module to create a view that only specific users should be able to access.  I know that Views includes access control by role or permissions, but I need something more fine-grained: Basically, I want to be able to say only user "x" and user "y" can access a particular view (or else someone with a site administrator role). So this would function very similar to how ACL module acts for individual nodes.

Is the best approach to create a custom views access plugin?  I don't have much experience with this.

Also, I'm wondering about using an argument with some validation to accomplish this (so that I don't have to create dozens of separate views). For instance, since this view will be a tab on a specific node path, I'm wondering about setting up a user reference field on that node that specifies who could see the view. I'd just need a way for the view to only validate if the current user equals a user specified in the user reference field.

Any ideas?  Or am I making this more complicated than it needs to be?

Thanks,
Ben


texts: Jquery in ajaxed loaded content referencing incorrect node id

texts:
I have a list of nodes each with a click. The click sends a node reference argument which loads a new view using ajax. Jquery collects the node reference number via a hidden input value on the content-type-tpl.php. Likewise the nodes in the new view each have a click which sends a node reference argument which loads a new view using ajax. However while the clicks in the original view work correctly, the clicks in the newly called view do not reference the correct node. Instead of referencing the node id for the node which is clicked, the node id of the next node in the view is collected instead. Oddly when placing <?php echo $node->nid;?> on the content-type-tpl.php, the correct node id is echoed on the page. But sadly this is not the one sent to the view argument. So clicking any node in the the newly loaded ajaxed view, sends the id for the next node. Here's the javacript:

 Drupal.behaviors.ajaxlinks = function (context) {
    $('.morelink:not(.togg-processed)', context).addClass('togg-processed').each(function () {
      var myindex = $('.morelink').index($(this));
      var target = $('.newthing').eq($('.morelink').index($(this)))
      var nid = $(".mynid").eq(myindex).val();
    $(this).click(function() {
if (($('.hiddenrows').eq(myindex).is(":hidden"))
|| ($('.shownrows').eq(myindex).is(":visible")))
{
    $('.hiddenrows').eq(myindex).show();
    $('.newthing').eq(myindex).show();
      var toLoad = Drupal.settings.basePath + 'replies/' + nid;
      xhr = $.ajax({
        url: toLoad,
        success: function(data) {
        $(target).css( "height","200px" );
        $(target).html($(data));
     Drupal.attachBehaviors(context);
}
});
}
else
{
    $('.hiddenrows').eq(myindex).hide();
    $('.newthing').eq(myindex).hide();
}
    return false;

It's the same code so I can't see why it works differently in the newly loaded view. Can anyone spot what I am doing wrong?


texts: How to change a views block ID attribute to use it as anchor

texts:
I have a views block with id=block-views-block-services-block-1 which I used in the menu link.

The menu link is now shown as https://example.com/gb/#block-views-block-services-block-1

As you can see it's really not looking nice with long hyphend words. Is there any easy way to change it to something like this https://example.com/gb/#services

I read an answer for Drupal 7 where we need to edit template.php to change the ID. But in Drupal 8 it seems that template.php is replaced with twig.html. I'm not very sure as I'm new to Drupal.

Could anyone please explain few steps on how to do it?


texts: entityQuery where a translation with a different value returns incorrect nodes

texts:
The title seems a bit odd, I know, but I couldn't find any issues similar to this and that's the best I could come up with.  We are running into an odd instance of entityQuery returning nodes that shouldn't be returned.

We have a site with 3 languages installed, EN, PT-BR and ES.  I have an entityQuery where I'm trying to select nodes with conditions for two entity reference fields (genre and platform, both custom vocabularies, being queried on the custom field 'field_shortname'), in one of the 3 languages.  There are currently 3 nodes.  The first 2 nodes reference 'arcade' and 'ps4' in all languages.  The third node references 'arcade' and 'switch' in EN and PT-BR, but 'arcade' and 'ps4' in ES.  I'm trying to query for nodes in EN with reference 'arcade' and 'ps4' - Here's the entityQuery code:

$query = \Drupal::entityQuery('node');
$query->condition('type', 'game');
$query->condition('status', 1);
$query->condition('langcode', 'en', '=');
$query->condition(
  $query->andConditionGroup()
  ->condition('field_genre.entity.field_shortname', 'arcade')
);
$query->condition(
  $query->andConditionGroup()
  ->condition('field_platform.entity.field_shortname', 'ps4')
);
$query->execute();

I expect the query to return the 2 nodes that reference 'arcade' and 'ps4' in EN.  Instead, all 3 are being returned - I'm assuming since the 3rd node references 'ps4' in one of the translations.  I've tried adding the langcode into the conditions, which fixes the EN query but breaks the queries when I try the other languages - they return nothing instead:

$query->condition(
  $query->andConditionGroup()
  ->condition('field_genre.entity.field_shortname', 'arcade', '=', 'es')
);
$query->condition(
  $query->andConditionGroup()
  ->condition('field_platform.entity.field_shortname', 'ps4', '=', 'es')
);

Anybody have any ideas?  Seems like it should be a pretty straightforward query, but I just can't seem to get anything to return the correct results.  This is on Drupal 8.3.7.  Thanks in advance!


texts: Are regions and features automatically created when creating a sub subtheme?

texts:
I want to inherit everything from a main theme except the layout.
When I create the .info file and specify which regions and features I want are these generated automatically by drupal or do I have to specify each one in a separate .tpl file like the diagram below?


texts: commerce multicurrency module currency menu selector not switching currency in Shopping cart

texts:
I am using commerce_multicurrency module for multi currency support. This module provide two blocks for switching currency of site. One currency menu selector which give enabled currency as links and another block which give enabled currency as select list. I enabled both of the block in header block of site. When i choose any of the currency from these blocks it switch currency of all the products displayed in pages either through views or any other way.

Selecting currency also switch the currency of the cart page in <site-url>/cart but it doesn't switch the currency of shopping cart block placed in header of site. Currency switching in this block is very inconsistent. Sometime it display the selected currency sometime it not. Sometime it show the previous selected currency when i switch any of the currency. This currency switching behavior in shopping cart block works fine when i switch currency on /cart page. It switch the currency of the cart at both places

Total displayed in cart page with individual product price.
Total displayed in header shopping cart block.

But on other pages of site this shopping cart block on header doesn't work as expected. I searched for this issue but didn't find any. I googled this issue also searched the module issue queue and https://drupalcommerce.org/discussions

Thanks in advance.


texts: Contrib statistics: Reported installs and downloads

texts:
I've noticed that the number of reported installs is usually (not always) somewhat larger than the number of downloads. I figured maybe this is because of multi-site installations in which one download runs on several sites. On the other had, there have to be cases where a module is downloaded and not implemented in production, which perhaps would account for cases where there are more downloads than installs.

But I just noticed that "CKEditor Link" has over 50,000 reported installs and only 658 downloads. That doesn't make any sense. Does anyone know what's going on there?

These statistics are relevant to the decision of which modules and themes to use in a system. (Edit: They are relevant for me because I can't afford to be in a situation where my sites go down because a Drupal revision breaks a module and the module maintainers don't get it fixed pronto. This is much less likely to happen with an installed base of 50,000 than 500.)


texts:
I am trying to achieve two things
I have 4 sites all with the same shared docroot code.

3 sites are of deferent sections in the company (we'll call them sec_1,sec_2,sec_3) and one site is the main admin site (internal site for me as an admin to monitor some things)

1) I created a view for a list of all users of certain roles on my site, and I would like to save it in code, so every site sec_1, sec_2, sec_3 will have this view. By saving this in code i'll be able to create more sec_x sites that will have this view in the future.

Any ideas how to do so? View's export does not seem like the right way to go about this.

2) I would like to expose the result of the view to the admin site, so I can present all lists in one page of the admin site.
I was thinking on something like this

$test = drupal_http_request('http://sec_1_URL/my_view');

but this results in

[code] => 403
[error] => Forbidden


texts: How to leave user profiles even when there are several pages?

texts:
The profiles of my users have several fields (bio etc.) and several pages which I add with views (following, followers etc.).

I try to leave the profiles of users even when we change page, a little as here :

https://disqus.com/by/iamfrancisyo/ (when you click "followers", the information of the user remain posted at the head of page (avatar etc.)).

Yet, the profile disappears when we change page.

I tried to add the variable $tab to user-profile.tpl.php, but naturally it also disappears during the change of page.

Have you a solution?


texts: Move from utf8_general_ci to utf8mb4_general_ci

texts:
I'm in the prosess of moving several Drupal 7 sites from one hosting provider to another. It appears the new provider only supports utf8mb4_general_ci (MySQL 5.7.18). Is there a simple way to convert utf8_general_ci databases and start using utf8mb4 on existing D7 installs?

I've looked into this old question.

This documentation page tells to convert all database tables. Can the "Steps to convert MySQL tables" be performed without Drush?

This comment is the most promising guide I’ve found so far (without Drush)

I have SSH access on both servers, but no Drush. I am also able to move the site to localhost (Mamp) if that makes anything easier. I will be updating all installs to the latest Drupal 7 versions (currently 7.54). Should I update before converting the database?


texts: Bootstrap theme doesn't work on mobile device (but work on computer, even when resize browser to min width)

texts:
While on mobile device:

Main Menu (the default one): On top I see the site name with beside the "toggle navigation" button (which don't respond) and above a vertical list of
menu items. And the menu has no more border, background-color, etc...
Views carousel: I see a vertical list of images id ("1.", "2.", "3.", etc...) and above a vertical list of my images.


texts: Custom entity types with multiple value properties

texts:
I'm creating a custom entity type, that has the following base field (defined in a class that extends ContentEntityBase)

public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
  $fields['recipient_id'] = BaseFieldDefinition::create('entity_reference')
    ->setLabel(t('Recipient(s)'))
    ->setDescription(t('The recipient(s)'))
    ->setSetting('target_type', 'user')
    ->setSetting('handler', 'default')
    ->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
    ->setDisplayOptions('view', array(
      'label' => 'above',
      'type' => 'entity_reference_label',
      'weight' => -3,
    ))
    ->setDisplayOptions('form', array(
      'type' => 'entity_reference_autocomplete',
      'settings' => array(
        'match_operator' => 'CONTAINS',
        'size' => 60,
        'autocomplete_type' => 'tags',
        'placeholder' => '',
      ),
      'weight' => -3,
    ))
    ->setDisplayConfigurable('form', TRUE)
    ->setDisplayConfigurable('view', TRUE);
}

I've set the field to have unlimited cardinality. I'm trying to create the getters and setters for this field, however I'm not finding any examples of entity types with multiple values.

I need to create the following getters and setters:

// Add a single recipient to the entity
public function setRecipient()
// retrieve all recipients for the entity
public function getRecipients()

Does anyone have an example of how to set up these functions to work with a multiple value field?


texts: How do I output view (page display) content in page--.tpl.php?

texts:
I have a view called sabk__view whose path is /sabk. It has a page display mode. I created a page named page--sabk.tpl.php in order to display the content of view, but I don't know what code displays the content of view.

I also checked modules/system/page.tpl.php to see if there is any useful variable (e.g. print render($content)), but none of them displayed anything about view.

How can I display view's output in a specific <div> tag? Do I need to implement <theme>_preprocess_node?

I am using Drupal 7, if that makes any difference.


texts: "Valid date is required for date_1" error while using drupal_form_submit()

texts:
Field : field_date_1
Type : Date
Widget : Pop-up calendar
The settings for date field is as shown in 2 images

I get the values of a form_state into the $source_node and move that to $fs variable.The $source_node has date field stored as follows :

 [field_pt_date_1] => Array
        (
            [und] => Array
        (
                    [0] => Array
                        (
                            [value] => 2010-08-27 00:00:00
                            [timezone] => America/Phoenix
                            [timezone_db] => America/Phoenix
                [date_type] => datetime
                        )
             )

)

 $fs['values']['field_date_1']['und'][0]['value'] = date('m/d/Y', strtotime($source_node->field_date_1['und'][0]['value']));
  $fs['values']['field_date_1']['und'][0]['timezone'] = $source_node->field_date_1['und'][0]['timezone'];
  $fs['values']['field_date_1']['und'][0]['timezone_db'] = $source_node->field_date_1['und'][0]['timezone_db'];
  $fs['values']['field_date_1']['und'][0]['date_type'] = $source_node->field_date_1['und'][0]['date_type'];

.........
The errors I am getting after executing the above code is as follows :

A valid date is required for date_1.

 drupal_form_submit('form_id', $fs, $source_node);
  $errors = form_get_errors();

And when checked the $errors variable I get

$errors = Array
(
 [field_date_1][und][0][value] => A valid date is required for date_1.
)


texts: Disable user registration in /user/register, but allow registration during commerce checkout?

texts:
Only users who paid can finish registration and they get a role applied to their user.

Problem is that, users can still register through default registration form.

Disabling registration for in Account settings will disable the registration globally everywhere?

How to disable it only in /user/register? But allow during commerce module checkout process?


texts: Add the inquiry number into the enquiry form email subject (entity forms)

texts:
The emails that come from the enquiry form on my drupal website have the exact subject and it's difficult to sort through the enquries.

I have the enquiry form set up using entity forms and rules. I just don't know how to add the inquiry number to the subject.

Looking through the database of enquiries, they do have a number associated

Thanks


texts: How can I override JavaScript settings used by a contributed module?

texts:
I am using the Fivestar module for rating purpose in my project.
In that module there is a function called fivestar_add_js(), which is used to add the necessary terms to Javascript. The function is given below:

function fivestar_add_js() {
  static $js_added = FALSE;

  // Add necessary javascript only once per page.
  if (!$js_added) {
    $settings = array(
      'titleUser' => t('Your rating') .': ',
      'titleAverage' => t('Average') .': ',
      'feedbackSavingVote' => t('Saving your vote...'),
      'feedbackVoteSaved' => t('Your vote has been saved.'),
      'feedbackDeletingVote' => t('Deleting your vote...'),
      'feedbackVoteDeleted' => t('Your vote has been deleted.'),
    );

    drupal_add_js(drupal_get_path('module', 'fivestar') .'/js/fivestar.js');
    drupal_add_js(array('fivestar' => $settings), 'setting');
    $js_added = TRUE;
  }
}

In that function I need to replace the word from vote to rating.
How can I do this?


texts: Is it possible to use a list of values from a views display as exposed filter of another view?

texts:
I have a view with a page display where I have some fields showing. One of the fields is field foo. I want the user to be able to filter the view by the foo value, choosing one or multiple values. I want the items of foo to be available in a list. Can I accomplish this using the data of another display where I have all the unique values of foo?

Thanks!


texts: Is it possible to get the fid of an image from a taxonomy term?


texts: Call hook when changing hierarchy in taxonomy terms overview

texts:
I created a two-level hierarchy in a taxonomy vocabular and used it in an entity referenced field for a type of content, let's contextualize with an exemple. The hierarchy look like this :

Tools 1

Theme 1
Theme 2

Tools 2

Theme 3

Let's admit that we have a content "Test" which is attached to Tools 1 and Theme 1. If i update the hierarchy in the taxonomy terms overview (with drag and drop), i will obtain a new hierarchy, for example by moving Theme 1 into Tools 2 :

Tools 1

Theme 2

Tools 2

Theme 1
Theme 3

If we take a look at the example content "Test", it's attached to Theme 1 (which is correct for my use case) and always to Tools 1 (which is my problem).
So there is my question : when updating the parent of a taxonomy term, what's the best solution in order to update the "Tools 1" towards "Tools 2" (in my example) for all content which used the "Theme 1" (which moved to "Tools 2").
I already have a solution but it seems difficult for me (i don't have huge knowledge in Drupal) by implementing a custom submit in a hook_form_alter (accorting to the comment on this page https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.api.php/function/hook_taxonomy_term_update/7.x) but i can't figure out how to detect if a taxonomy term changed parent.
Thanks for your answers !


texts:
I have installed the core Forum module in Drupal 7.  When I go to:

http://www.mysite.com/?q=forum

The forum list is displayed, however the links that allow me to post are not being displayed.

I'm surprised that I haven't been able to find a tutorial on the net on how to set up a Drupal 7 forum.

What am I doing wrong?


texts: How to redirect to another drupal site/alias after file upload

texts:
I use the drupal standard to upload files + File Entity. After uploading file eg this is the current URL: https://blabla.com/en/file/abc.pdf. I want to redirect the users to file/add.

Matroschker


texts: Programmatically submit user reset password form

texts:
I have a register form that I am able to submit programmatically without any problems.

However when I try to do the same with the user reset password form, it doesn't send me any emails, nor does it do any validation.

Here's the code I'm using:

$form_state = array();
$form_state['values']['name'] = $_POST['username'];
$form_state['values']['submit'] = t('E-mail me new password');

drupal_form_submit('user_pass_form', $form_state);

Note: I've tried using user_pass instead of user_pass_form.

What am I doing wrong?


texts: Display values of custom fields created on media entity in a template file

texts:
I'm trying to display the values from the custom fields that have created on my Media Entity to my page--media.html.twig file. The fields that I'm trying to output are Location and Photographer

I tried using this code below, to make it work.

{{ node.field_photographer.entity.value  }}

Also tried an alternative

{{ content.field_photographer.entity.value  }}


texts: Drupal 6 to Drupal 7 migration redirect not working

texts:
I am migrating a D6 site to D7 and for some odd reason the redirect module is not creating the redirections. Any ideas? I am not getting any errors, warnings or notices

This is what I have:

class MyNewsMigration extends MyNodeMigration {
  public function __construct(array $arguments) {

    parent::__construct($arguments);

    $this->addFieldMapping('field_tag', '8')
         ->sourceMigration('Tag');
    $this->addFieldMapping('field_tag:source_type')->defaultValue('tid');
    $this->addFieldMapping('field_tag:create_term')->defaultValue(FALSE);
    $this->addFieldMapping('field_tag:ignore_case')->defaultValue(TRUE);

    // Redirect module to issue a 301 for each changing path
    $this->addFieldMapping('pathauto')->defaultValue(1);
    $this->addFieldMapping('migrate_redirects', 'path');

  }
}

Note: I added the migrate.redirect.inc using patch from here https://www.drupal.org/node/1116408


texts: Commerce Extra Pane wont drag in checkout UI

texts:
I have created a Drupal Commerce pane using the Commerce Extra Panes module. I created a group and field and they show up on the UI. However, its listed in the Disabled section. I tried to drag it into the Checkout pane and when I save it reverts back to the Disabled section.

When I look in the database it does list it correctly in the Checkout pane, but it doesn't actually appear on any page pane.

What is happening here and what can I do to debug more?


texts: How to rename a view returned by REST API

texts:
Very new to Drupal (running 8.5.6) and inherited some code I need to tweak. We invoke the API request like so (which may wrap the Drupal API..I am not sure)
https://api.mysite.org/backend/api/constants/en?_format=json
I get a fairly large JSON object returned.  There is a view I created called myview that is returned in the json with the name of view_35. I have two other test instances where I created the same view by name referencing the same fields.  But in one instance the name is returned in the JSON as view_38 and in the other view its view_31.  I noticed that I could alias the fields.  Is there a feature like that for views?  In other words, I want to name the view so it can be consistently referenced in the code that consumes the JSON.  The client side of the app that invokes the api is Angular, if that makes any difference.


texts: How can I add a textbox in Site Information configuration

texts:
I'm altering the following form, admin/config/system/site-information.

I need a textbox in the site details section, below the email address textfield. The name of the textbox should be site_organisation. This textbox needs to save to variable when the save configuration button is clicked. Its saved value should be displayed when the page is reloaded.

How can I do this? Is there a module that can do this?


texts: Convert a SQL database design to a drupal schema installation file

texts:
I have a, rather big, application that I would like to integrate into Drupal reusing the current database design / logic.

Is there a tool out there that can help me to build the PHP part of the hook_schema definition taking the current database model or an SQL file with the DB declaration as a starting point ?

From what I know it should be pretty trivial to convert a SQL file to a PHPish definition compatible with drupal.

The utility should convert SQL types to Drupal types and declare primary keys, unique keys and index ala drupal.


texts: how to change output html of variable $output on file views-view-field--field-image.tpl.php

texts:
dpm($output) ->  on file  views-view-field--field-image.tpl.php so how to I can add

 =>


texts: How to allow users have only alphabetical "username"?

texts: I suddenly realized that username can be any character after seeing someone just made his or her account in Japanese characters. I don't really have a problem with that but just would like to let them register only with alphabetical characters to keep the things tidy. Is there anyway to do this?


texts: How to add an "apply for a job" button to a content type?

texts:
I am trying to add an apply button to a content type, like job, so when the user visit the content he could click "apply button", and his resume will be send automatically to the author of the content.

I would prefer this be achieved with AJAX. How can I make something like this?


texts:
I want to have a simple WYSIWYG when people add comments and when people edit the body of a basic page.
Something that looks like this:

Any ideas?


texts: How to prevent 'drush up' from deleting non native inodes in a sub-theme folder?

texts:
I installed the theme Basic, did drush up, updated this theme, and BAM, the sub-theme folder I created was deleted.

Gladly, I restored most of it, but why would drush actually delete any non-native folder when it's updating my theme?

Is there something to do to prevent drush from deleting non native inodes in a folder?


texts: Bypassing internal cache via query parameter

texts:
I'm attempting to bypass drupal's internal page cache and dynamic cache when a given url parameter is in a URL (as an anonymous user). The page in question is a view, and occasionally, when a user clicks a link to load that view, the URL has the associated query param. I've tried a number of different ways to add the cache context like below:

$vars['#cache']['contexts'][] = 'url.query_args:dynamic_trials';

I've added this in a hook_preprocess_node, I've added it in a preprocess on the view itself I've added it in a function tibco_views_utils_views_pre_view with a call to

view->element['#cache']['contexts'][] = 'url.query_args:dynamic_trials';

None of these have worked. I noticed this on one of the drupal docs pages:

Note the Internal Page Cache assumes that all pages served to anonymous users will be identical, regardless of the implementation of cache contexts. If you want to use cache contexts to vary the content served to anonymous users, this module must be disabled, and the performance impact that entails incurred

Is this true? There's no way to do what I'm trying to do above without disabling the internal page cache entirely?


texts: How to add block-like visibility settings to nodes?

texts:
I have created a custom content type 'campaign' in my module using hook_node_info() and added fields using hook_field_group_info(). This campaign content type will be shown to users site wide in modals/pop-ups using CTool modal on page load (hook_init()).

What I'm looking for is, to give an option to admins to restrict this pop-up/modal for different roles or paths. Same like block section is doing. For example whether to show a block on node/104 or not, or wether to show a block for (anonymous) users only or not. Like shown in the screenshot below.

My aim is that, while creating 'campaign' nodes, admins should be able to select pages or roles to show that particular campaign or not.

Can you please guide me how can I use Drupal block logic here? Or do you maybe can make some code suggestions I can start with in my custom module?


texts: Why doesn't the node object have the field name?

texts:
When I use the following code in page--front.tpl.php, it doesn't show the name of the field label, why? What code should I use to print the field label?

$node = node_load(1);
print_r($node);

The output is similar to the following:

    [field_sq] => Array(
      [zh-hans] => Array(
        [0] => Array(
          [value] => 250
        )
      )
    )


texts: What if a rule doesnt fire or is interrupted because of server down etc?

texts:
I have several rules that need to be fired after certain events.

When an event occurs and the rule starts execution, and something happens to the server, it may not finish.

Is there a way to make sure a rule will always execute?

I am asking for a method like a transaction occurs in MySQL. I need to be sure that a rule is executed to ensure data integrity.


texts: Get Organic Group roles of the current user

texts:
It seems a few different versions of this question exist so apologies if it seems I am repeating but I dont think I am. I am trying to use the api to get the og role(s) of the current user, not just which groups the user belongs to. I hope to able to create an array that looks like this for the current user:

Array
(
['Group 1'] => Array
    (
        [0] => 'OG Admin'
        [1] => 'OG Member'
    )

['Group 2'] => Array
    (
        [0] => 'OG Moderator'
        [1] => 'OG Member'
    )

['Group 3'] => Array
    (
        [0] => 'OG Member'
    )

)


texts: Is there a stable way to fill a filefield/imagefield via bulk upload in D7

texts:
OK, here's the deal. I've implemented image gallery nodes in D7 the straight-forward way, i.e. create node type 'gallery' and add an imagefield with unbounded number of values. Nice markup via Views/EVA, done.

Now, to make the image upload convenient, I tried the following ways and got the respective results:

Multiupload Filefield Widget: The uplaod goes through, images appear on server side, but php runs out of memory while computing the ajax response for the upload.

Plupload widget: Upload works, but side crashes on save. I get lot's of visible json instead of the saved side.

Plupload via Fielfield Resources: Upload goes through, after that no visible response. On save, I get a long list of copy/rename error messages above the actual side.

The problems are present for pure file fields, on a otherwise pure D7 installation, so image processing is off the table as well as memory polluting modules (up to the ones mentioned above, appearently).

So the question is, why is it so memory consuming to compute a not so lengthy ajax response? The side shall collect several galleries containing each around 200-400 pics, so a nice way to bulk upload those jpgs would be great.


texts: File fields are not indexed - apache solr attachments

texts:
For indexing files, I enabled the module like apache solr attachments. In my stage enviroment, files are getting indexed. Search results shows the file results.

In apache solr index also no of fields indexed are 100 (includes ss_filemime,ss_filesize etc)

But In my production enviroment, files are not getting indexed. In apache solr index i cant find the fields like (ss_filemime,ss_filesize) . I uninstalled and again installed still it doesnt index.

The same thing is working in stage. So i cant reproduce the issue.

It would be helpful if someone have idea to fix it.


texts: How can I more efficiently save nodes programatically with my custom module without cron?

texts:
I have a scraper I created that aggregates data found on various sites, feeds, and databases. So that I don't hammer the servers to death that I am connecting to I have it set to sleep 5 seconds between requests.  When it finds what I need it saves it as a new node.  I have program set to fire on a cron run using hook_cron().

It's works fine but now I have added significantly to the sources I am searching through. The problem is this process could days, especially doing it in series. I have even had the case be that I get an error that cron tried to run while cron was already running.

How can I make this process go more efficiently? More quickly? And not depend on cron? Before I wrote a module for this I simply created several scripts - one script for each source -  and I fired them off simultaneously in terminal windows.

How can I do this with my module? I know I could run php's exec() function. In fact this is the commanad was calling with it when I was doing it manually:

php myscripts/search1.php < /dev/null &
php myscripts/search2.php < /dev/null &

When I try this in the module I get bootstrap errors.

When I wrote the module my individual scripts simply became functions in the module. I'm happy to go back to firing off the scripts simultaneously if someone can help me understand how to do that correctly in the module. Or, if you have another suggestion on how to do this quickly and efficiently, I'm all ears.  Realistically, I need to process a couple million items of content a week.


texts: Invalid CSRF token using flag.link_builder service (Flag module)

texts:
I have a REST route that returns a list of user accounts. I have a flag setup called 'following' as you can follow and unfollow other members. In my REST route, I use:

$flag_link = \Drupal::service('flag.link_builder')->build('user', $member->id(), 'following');

which generates the link correctly as far as I can tell. In my javascript object I can see the link that was created. This is an example of the JS object of a user that I use on the front end:

0:
  flag_link:
    #access: true
    #action: "flag"
    #attached: {placeholders: {…}, library: Array(1)}
    #attributes: {title: "", href: "/flag/unflag/following/3?destination&token=LEfyLe9PPaQfgNNRSXUA82k4SVHQGRmBEI0adgBva9g", class: Array(1)}
    #cache: {contexts: Array(1), tags: Array(0), max-age: -1}
    #flag: {id: "following", label: "Following"}
    #flaggable: {}
    #theme: "flag"
    #title: {#markup: "Follow this person"}
  id: "3"
  name: "ronnie"
  url: "/user/3"

When I go to click the link it 403 forbiddens with the message message: "'csrf_token' URL query argument is invalid."

The HTML I am outputting is:

  Unfollow this person

Any idea what I am doing wrong?

Here is a screen shot of my request when I click the anchor


texts: Storing uploaded files according to node ID

texts:
When a file/image is uploaded via Drupal, they go into a common directory specified by the administrator.

However, is there a way to specify where the files will be uploaded, according to their node ID? For example, say, a person creates a page and Drupal assigns it an ID of 1234; thus, the uploaded files will go into {specified_location}/1234_files/.


texts: Drupal does rewrite url but can't load css/themes

texts:
I have an url rewriting issue with my drupal 7

I'm trying to rewrite for example index.php?q=categorie&categorie=laars to categorie/laars.html

So I downloaded the default drupal 7 .htaccess file from https://code.google.com/p/drupalgooglecode/source/browse/trunk/.htaccess

Then in the section

# Various rewrite rules.
<IfModule mod_rewrite.c>
</IfModule>

I added:

RewriteRule ^categorie/([^/]*)\.html$ index.php?q=categorie&categorie=$1 [L]

Above the default (I also tried below but that didn't rewrite the url):

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

But it doesn't seem to work. When the rewrite rule is added, my site's layout is all messed up. As if the themes/css is not loaded anymore.
The url does rewrite as I want, but it looks like drupal doesn't know where the theme files are. What may be the cause of this?

Thanks!
Stece

UPDATE: is it possible that url-rewriting of .htaccess conflicts with the drupal clean-url's module? Because theming that doesn't load, feels like something is conflicting. Not sure...

UPDATE2: also tried using a custom module with the hook_url_inbound_alter, but that's not working with me either (https://stackoverflow.com/questions/17176589/drupal-hook-url-inbound-alter-not-altering-my-url). That question is on stackoverflow, for some reason I hoped to get a quicker solution their.


texts: Monthly calendar is now entitled "Friday, August 1, 2014"

texts:
My monthly calendar is now entitled "Friday, August 1, 2014" for all views and blocks that use the monthly calendar.  All other views like day, week, year are all fine I believe.  I just now noticed this when I updated just a few minutes ago to D7.31 from 7.29.  I also allowed the date module (and one other one and I can't remember right now...) to be updated.  Any ideas how to fix it?

Dave Niemeyer


texts: How do I use only a taxonomy term in the path alias?

texts:
I have content that is tagged with multiple terms from the same vocabulary.
How can I use only the first term the node was tagged with, in the URL structure, e.g. domain.com/first/term/with/depth/node-title?

I am trying to do this with the Pathauto module and Drupal 8, but I can't figure it out. It either grabs all the terms used in that node or none.


texts:
I want to alter the User login form of drupal 7.
I want only two fields Email ID and password. I don't want a username field. Please any one have idea to how to do these changes in User login form.


texts:
If I add a Node Reference field to a node content type (with Reference from URL as a widget,) this field appears in the rendered content and can be used to jump to the referenced node.

I am trying to get a similar result in the rendered comment of the same content type: If I add a Node Reference field with Reference to URL in the Comment Fields edit page of the content type, it doesn't show up in the rendered comment page.

Why do I want to do this? Because when one leaves a comment in the rendered content, a message is sent to the author of the post that a comment was posted. In the email, there is a link to see the comment. The link is of the form example.com/comment/000#comment-000 and that's not the original post with the comments below.

So I am trying to add a link to the comment page that would send the reader to the rendered node where the comment was originally posted.

Does this mean one cannot reference a node from the same node's comment page?

Or does it mean there is another way to accomplish this?


texts: Rules not working with multiple OR condition

texts:
I am using rules & profile2 module.There are profile types like personal information, contact deatails. Now,I want to send email notification to user to fill out empty profile fields. If any one of the profile field is empty,user should receive a mail regarding profile completion. For this, i have created a rule where i  tried "Data value is empty" with multiple OR condition for muliple profile fields in rules condition.But the rule with multiple OR condition is not working.Is it possible with rules or is there any php coding to do this? Since I am new to drupal,not getting how to do this.Please help.
Thank you.


texts:
I want to hide one of a node's field when the node was published. I copied and renamed the node.tpl.php as node--app.tpl.php cause the node's content type's machine name is app.

I tested it by add the code at the beginning of the node--app.tpl.php file. yeah it works.

<?php print $node->field__iap_dl['und'][0]['url']; ?>

In order to hide the field I added one line in the existing code.

<div class="content clearfix"<?php print $content_attributes; ?>>

<?php
  // We hide the comments and links now so that we can render them later.
  hide($content['comments']);
  hide($content['links']);
  hide($content['field__ipa_dl']);    // I added!
  print render($content);
?>
</div>

This time it didn't work. What's wrong? I am newbie to code the Drupal.


texts: Paste field content directly to node.html.twig?

texts:
The content type article has a field called field_kategorie.
It should be output in the URL in the title of the node with.

node.html.twig doesn't work as expected.

{{ field_kategorie }}{{ label }}

How to do that?


texts:
I have a view configured with a custom template. Now I need to represent the same information arranged in two different ways. What I want is for the user to have an option to change between the three different templates. This doesn't seem to out of the ordinary but I am having trouble finding an example.

Using Drupal 7.


texts: How can I build a subscription product selling system with drupal commerce

texts:
I'm creating an Drupal commerce website, I want to sell subscription to internet via satellite service.
Sincerely I'm confused and I don't know what modules I should to use for this kind of product.


texts: Exclude a block from specific parts of the website with the Context module

texts:
I have a view/block that is showing on the right sidebar. I don't want to show that block on specific parts of the website.

I do know there is the "Show block on specific pages -> All pages except those listed" option where you can put the URL and shouldn't appear, but it does not work.

This Drupal site is using Context to draw the content, so the problem may be there; I think there is another place where I can configure the URLs the same way I explained before on the context, but I cannot find it.


texts: How to remember the selected foo before and after a registration process?

texts:
I have a view with 50 objects available for anonymous members.

I the user clicks "Yes, i want to see more of this nice foo" he should register himself with only a email and/or password or even only a email is enough. Then a rule is needed to run and adds the role of member to the user.

The member should now be returned to the selected foo/row.

How to remember the selected foo before starting the registration process starts so I can redirect the user the foo correctly?

Any suggestions great appreciation.


texts: There was a problem creating field: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

texts:
I've recently downloaded a Drupal website to work on a local host (xampp).
After importing the database, changing the base_url and running the update.php script, I managed to make it work.

However, after a few tests, I've found a bug: the add new field feature is not working, because whenever I try to add a field to the user, the dashboard shows the following message: There was a problem creating field Comments: SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value

How do I fix it? Is it database related problem?
Thanks

UPDATE 1

After trying to delete a field, the website shows two messages, one success message and error message: the first is the following The field Office has been deleted from the Employee content type., while the second is

Error messageException: Invalid field name given: field_mentorship_program is not a Field Collection field. in FieldCollectionItemEntity->__construct() (line 101 of C:\xampp\htdocs\website\sites\all\modules\field_collection\field_collection.entity.inc).

UPDATE 2

I was able to solve the problem by re-uploading the database as suggested in the comments.


texts: What is the best choice to create a node through code?

texts:
The scenario goes this way, I have a node type which has lot of Taxonomy term fields in it. It does also have other fields like text, date etc but 90% of it is a taxonomy field. I am aware that a node can be created programatically in two ways,

node_save() -  Creating a node object and saving it

$node =  new stdClass();

$node->type = 'article';

$node->field_term[LANGUAGE_NONE][0]['tid'] = 3128 // term id of the term

node_save($node);

Form submit - creating a form array and submitting using drupal_form_submit

$node[field_first]['und'] => chennai;

$node[field_second]['und'] => "iphone5";

$node['type'] = 'article';

$form_state['values'] = $node;

$form_state['values']['op'] = t('Save');

drupal_form_submit($node_type . '_node_form', $form_state, (object)$node);

with $node having the POST values.

Advantage of using form submit method is Drupal will take care of creating new terms in vocabulary (I am supposed to get more new terms). Form submit can follow form validations which is needed for creating a node.

Is there any method to create nodes faster in to Drupal system which supposed to get more terms in it?

If there is no other method than the above mentioned, what is the best one?


texts:
I am trying to insert my chart.js into a Drupal page.
Here is the fully functional fiddle:
http://jsfiddle.net/vy0yhd6m/80/

When I enter that into a basic page content item in Drupal, the chart will not display.
However, if I remove scaleLabel(), it works and displays perfectly on the Drupal page. For some reason, adding that function in the Full HTML content item makes the chart disappear, even though it works perfectly in the above JS Fiddle.

scaleLabel: function(label){return  ' $' + label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}

Does anyone have any idea on why this is happening?


texts: Drupal 404 redirect to a custom PHP file

texts: Is there any possibility to redirect Drupal 404 to a custom php file without sending actual 404 headers.


texts: Custom theme css separate from editor css

texts:
I have a custom css file in my custom theme folder which has a few changes I made throughout site but does not affect the tinymce editor but probably overrides it making so no changes in text.

I have two problems, one I don't actually know what to put in separate custom css to make buttons work in tinymce editor. I am used to finding a specific div or creating one and then adding the css. I am not familiar with setting up classes for this editor (as it offers in wysiwyg profiles) and correct syntax to do so. Also I would have thought I needed to bring over a generic copy of the css for the editor into my custom theme folder (?) And two I am unclear on how to set the path in define css for the editor profile, if ever I manage to create of find the correct file.

I hope I am making some sense and my question is clear enough.


texts: Pre-process to change the name of a file field in node

texts:
I have a file field in a node and I would like all instances of this field to have a different display name.

I use the file field to upload images that users can download - e.g. flower.jpg, horse.jpg.

Instead of the field displaying " flower.jpg",I want it do display the text "download".

The machine name of my field is "field_source" and the name of my theme is " kickstart". The content type is " resource".

What would a pre-process function in my template.php look like to do this?

This is as far as i get:

function kickstart_preprocess_node(&$vars){
  if($vars['type'] == 'resources'){
    $vars['content']['field-source']['#title'] = 'download';
  }
}

Thanks!


texts:
Similarly to what described in https://www.drupal.org/node/244924, which is for Drupal 7, is there any script to set the right permissions for Drupal 8?

How can we take care of the file permissions for contributed modules? For example, I know a few modules which would have different permissions for files like .htaccess and other private folders in the modules. Is there a way we can reset the file permissions to initial versions?


texts:
I'm trying to integrate the new Facebook SDK4 for PHP in my Drupal 7.34 website, where I have successfully installed it using the libraries API but after that instead of the code execution I'm getting this error:

Fatal error: Class 'Facebook\FacebookSession' not found in mymodule.module on line 122

Where on line no 122, I've used this:

FacebookSession::setDefaultApplication('my_app_id', 'secret'); Line - 122
$session = FacebookSession::newAppSession(); Line - 123
$request = new FacebookRequest($session, 'GET', '/' . 'my_fb_page_id' . '/feed'); Line - 124

This use to get work perfectly when I was intergrating it in this way:

require (drupal_get_path('module', 'social_feeds') . '/facebook-php-sdk-v4-master/src/Facebook/autoload.php');

Below are the steps that I've used for integrating the Facebook SDK with libraries:

In mymodule.module

/**
 * The minimum version of Facebook SDK required.
 */
define('MYMODULE_MIN_PLUGIN_VERSION', '4.0');

/**
 * Implementation of hook_libraries_info().
 */
function mymodule_libraries_info() {
  return array(
    'mymodule' => array(
      'name' => 'PHP SDK for Facebook APIs',
      'vendor url' => 'http://developers.facebook.com/',
      'download url' => 'https://github.com/facebook/facebook-php-sdk-v4/archive/master.zip',
      'version arguments' => array(
        'file' => 'facebook-php-sdk-v4-master/src/Facebook/Facebook.php',
        'pattern' => "/const VERSION = '([\d.]*(?!-dev$))/",
        'lines' => 60,
      ),
      'files' => array(
        'php' => array(
          'facebook-php-sdk-v4-master/src/Facebook/autoload.php',
        ),
      ),
    ),
  );
}

and in mymodule.install file I've mentioned this:

/**
 * Implements hook_requirements().
 */
function mymodule_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();

  $library = libraries_detect('mymodule');
  $error_type = isset($library['error']) ? drupal_ucfirst($library['error']) : '';
  $error_message = isset($library['error message']) ? $library['error message'] : '';

  if (empty($library['installed'])) {
      $requirements['mymodule'] = array(
        'title' => $t('MyModule'),
        'value' => $t('@e: At least @a', array('@e' => $error_type, '@a' => MYMODULE_MIN_PLUGIN_VERSION)),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('!error You need to download the !mymodule,
        place the mymodule directory in the %path directory on your server
        and extract the archive
        .', array(
          '!error' => $error_message,
          '!mymodule' => l($t('MyModule'),
          $library['download url']
          ),
          '%path' => 'sites/all/libraries')),
      );
    }
    elseif (version_compare($library['version'], MYMODULE_MIN_PLUGIN_VERSION, '>=')) {
      $requirements['mymodule'] = array(
        'title' => $t('MyModule'),
        'severity' => REQUIREMENT_OK,
        'value' => 'v' . $library['version'] . ' installed',
      );
    }
    else {
      $requirements['mymodule'] = array(
        'title' => $t('MyModule'),
        'value' => $t('At least @a', array('@a' => MYMODULE_MIN_PLUGIN_VERSION)),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('You need to download a later version of the
        !mymodule and replace the old version located in the %path directory
        on your server.', array(
          '!mymodule' => l($t('MyModule'),
          $library['download url']),
          '%path' => $library['library path'])),
      );
    }

  return $requirements;
}

I have also got this in my admin/reports/status

MyModule    v4.1.0 installed

Which means I have integrated the Facebook SDK correctly.

The only issue is with this error "Fatal error: Class 'Facebook\FacebookSession' not found in"

Does this mean I have to use xautoload


texts: The Calendar module doesn't recognize fields

texts:
I created a content type "events", with a date field and other normal settings.

I am trying to use the Calendar module to create a calendar on my Drupal site, but I am facing an issue.
When I try to edit the basic calendar, and change its argument from date:node (node updated time), then in the list of date_fields it does not show the field that I had created above. It only shows the following fields:

Node: Last comment time
Node: Post date
Node: Updated date
User: Created date
User: Last access
User: Last login

I have tried this again and again by recreating my content type, or by disabling/enabling the Calendar module, but it does not seem to work. I am using Date 7.2.x and Calendar 7.2.x.


texts: How do I delete files using the Content > Files interface?

texts:
I got a ticket from our stakeholders that certain outdated PDFs are googlable, and this is causing problems with people going on old information.

Navigating to admin/content/files, I am able to find entities(?) for the files, by searching on their filename and extension (MIME type). There is also a seemingly handy column "Used In". However, when I click through the values in the "Used In" column (e.g. "2 places"), the paths are like render elements or something similiar: {Content Type} > Paragraphs (previous revision) > Column Content (previous revision) > Column Wrapper Content (previous revision) > Accordion Section (previous revision) > Accordion Section Body.

From this information, I am not able to navigate to the page where the file resides, in order to remove it.

Furthermore, one of the files is used in 0 places, and there appears to be no interface that allows me to delete it. I am able to open the PDF from the file path link in an incognito window, so I conclude that, even though a user can't discover this PDF by navigating on our site, they still might get to it through a google search.

My question is different from this similar question, How do I delete files the correct way?, because in that question, the asker already knows which node it is that contains the file they want to delete. In this case, I don't know where on the website the file is actually attached. I'm trying to get that information.

One proposed solution might be to google for the files, and find out where on our site they are from Google's search results, but I want to know how to delete these files through Drupal, so in a future case, where I can't find them through google, I still have a way to delete them.

Edit even after googling search terms for the files, I find that the top search results are direct links to the PDFs themselves. So even using google, I'm not able to determine which page or URL on our site has them on.

How do I delete these files, listed in the "Files" tab of the admin content screen?

Edit 3 So Clive's first answer "didn't work" for me, because it turns out, as Clive deduced, that the reference to the files were broken. But I was able to confirm that the code did indeed work by testing a node whose attached image I was certain of. I've deleted "Edit 2" expounding on the broken reference information I got from the code.


texts:
I have a form alter function, it seems working fine, but, i am getting this strange error, i am not able to figure this out. Please help me out. I have a dependent dropdown. I am pulling 1st level vacabulory in 1st dropdown. 2nd dropdown is basically the childrens of the parent chosen from the 1st dropdown. The code works, but give me error.

function teacher_form_alter(&$form, &$form_state, $form_id){

  if($form_id == "teacher_profile_node_form"){

        $form['field_teacher_city'] = array (
           '#title'   => 'City',
           '#type'    => 'select',
           '#options' => _teacher_city_options_list_taxonomy(),
           '#ajax'    => array(
                'event'=>'change',
                'callback' =>'_teacher_location_list_dropdown',
                'wrapper' => 'edit-field-city',
                'method' => 'replace',
                )
          );

      $form['field_teacher_locations'] = array(
           '#title'   => 'Location',
           '#type'   => 'select',
           '#options' => get_dropdown_list(),
           '#prefix' => '
',
           '#suffix' => '
',

       );
     }

    return $form;
}

function get_dropdown_list() {

      $options2 = array(
        0 => t('Zero'),
        1 => t('One'),
        2 => t('Two'),
        3 => t('Three'),
           );

return $options2;
}

function _teacher_location_list_dropdown($form, $form_state)  {
  // use this method to populate the demo list from the list of courses
  $vocab = taxonomy_vocabulary_machine_name_load('locations');

  $vid = $vocab->vid;

  $sel = $form_state['values']['field_teacher_city'];
  drupal_set_message($sel);

  if (!isset($sel)) {

      $options = array(
        0 => t('four'),
        1 => t('five'),
        2 => t('six'),
        3 => t('seven'),
           );

  }
  else {
      $terms = taxonomy_get_tree($vid,$sel,1,FALSE);

      $options = array();
      foreach ($terms as $term)  {
    $options[$term->tid] = $term->name;
      }
  }

  $form['field_teacher_locations']['#options'] = $options;

  return   $form['field_teacher_locations'];
;
}

Error is below

Warning: array_values() expects parameter 1 to be array, string given in _field_filter_items() (line 515 of C:\wamp\www\drupal-7.19\modules\field\field.module).
Warning: Invalid argument supplied for foreach() in list_field_validate() (line 392 of C:\wamp\www\drupal-7.19\modules\field\modules\list\list.module).


texts: How to clone any standard webform element

texts:
I've been able to copy the example webform element, as detailed at Create webform element.

Although I've not tested submission yet, I think it's all looking good.

What would be great is if I could clone any of the standard webform elements.

I've made a copy of src/WeformElement/Email.php - and it appears in the list of webform elements available to be inserted into the webform - but when viewing the actual webform, it is not rendered.

It may be that I have to use the example webform element to create a new copy, and then change stuff in there to render an email field instead, but as mentioned I'd appreciate any pointers towards being able to clone any of the elements.

(The reason we need to clone them is due to styling. One text field might be used for a name, and another for a completely different purpose which will be styled differently, and as the cloned element has a new id then we can use the module Themable forms to provide more template suggestions.)


texts: Why don't hook_file_insert() and hook_file_presave() need the cache cleared to work?

texts:
I think all hooks need the cache tto be cleared to work (or at least I thought until now), but it seems that these particular hooks don't need the cache to be cleared. I tried this even on a clean Drupal 7 installation.

Does anybody knows how this magic happens? I thought may be cache iscleared when files or nodes are saved, but I didn't see that.


texts: Rewrite results for user picture to except tokens

texts: I have a user role called "Residents" in D7, and created a view the show profile information. I want to add colorbox to the User Picture, but there is only one token available [picture]. How do I add the image path as the destination if I can only use one token (see attachment)?


texts: How can I conditionally override the field description?

texts:
I am using the Reference Field Option Limit module in Drupal 7 and I want to change the explanation text that says:

No options are available for the current form values..

I want to  put instead:

Please select a value below.

I tried hook_form_alter but the new phrase is appearing even when there is an option selected in the matching field, which is not what I want. So any idea which hook function should I use?
PS: I don't want to change that from the module core.


texts: I cannot add a new CSS class to the classes_array array

texts:
I'm using Drupal 7, and a Bootstrap sub-theme. I am using the following code to add a new CSS class (taxonomy-[vocabulary-name]) to the classes_array array.

template.php

function bootstrap_gstt_preprocess_html(&$variables) {
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    $results = _bootstrap_gstt_taxonomy_node_get_terms($node);
    $taxonomy_vocab = $results->name;
    if (is_array($results)) {
      foreach ($results as $item) {
        $taxonomy_vocab = "taxonomy-".strtolower(drupal_clean_css_identifier($item->name));
        $variables['classes_array'][] = $taxonomy_vocab;

        $variables['classes'] = implode(' ', $variables['classes_array']);
        dpm($variables['classes_array']);
      }
    }
  }
}

function _bootstrap_gstt_taxonomy_node_get_terms($node, $key = 'tid') {
  static $terms;
  if (!isset($terms[$node->vid][$key])) {
    $query = db_select('taxonomy_index', 'r');
    $t_alias = $query->join('taxonomy_term_data', 't', 'r.tid = t.tid');
    $v_alias = $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid');
    $query->fields( $t_alias );
    $query->condition("r.nid", $node->nid);
    $result = $query->execute();
    $terms[$node->vid][$key] = array();
    foreach ($result as $term) {
      $terms[$node->vid][$key][$term->$key] = $term;
    }
  }
  return $terms[$node->vid][$key];
}

html.tpl.php

<!DOCTYPE html>
<html<?php print $html_attributes;?><?php print $rdf_namespaces;?>>

  <link rel="profile" href="<?php print $grddl_profile; ?>" />
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>

  <?php print $scripts; ?>

<body<?php print $body_attributes; ?>>

    <?php print t('Skip to main content'); ?>

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

With dpm($variables['classes_array']);, the new CSS classes I added appear in the array, but they aren't output as body CSS classes.

Is there anything I need to change in my code?


texts: I installed ckeditor and all went well but now the issue is it can not allow me to upload an Image : when I drag and drop an image it shows a blank line . and if I click on the image icon, it opens but when i try uploading and image it takes me to the page where I was. and nothing happens.do I need any other module to help it upload ? . please I am asking for any help


texts: How can i integrate geofield module in entityform?

texts: Actually i have to add multiple locations in a form of a route and show it after the submit button in a single map using geofield module. How do i do that???The map should locate multiple markers after submit button in one map with their latitude and longitude... the image mentioned in the second is my first image which i am getting now whereas the image been showed at first should be my output image...


texts:
If you visit official website of Dries Buytaert https://dri.es/ and look into the source you will see very clean and minimal markup with no unnecessary tags and classes, eg:

When I create a simple custom block it has lots of junk under each field,  eg:

How to strip and delete all the junk and leave or add only classes and wrappers you need?

I did look up Fences, but it's latest version is in alpha since 2016 (and not sure if it does that) and cannot figure out how to strip at least classes with Display Suite extras module, it seem that it doesn't do anything, went though all settings.

Did Dries use any of known public modules or is it all custom code?


texts: Custom views field handler with relationship support, but without table

texts:
I created a custom field handler following the very useful explanations here,
Custom views handler without table

The field handler picks the entity from each row and renders it in some way. (For simplicity lets just assume it renders a link to the entity using entity_label() and entity_uri(). It actually does more awesome stuff, but this is irrelevant here.)

Unfortunately, I found that I cannot configure a relationship when using this field handler. E.g. if I have a relationship "The node author", then I might want to render the title + link for the node author instead of the node.

Is there anything more I need to enable support for relationships?

/**
 * Implements hook_views_data().
 */
function EXAMPLE_views_data() {
  $data = array();
  $data['EXAMPLE']['table']['group'] = t('Custom');
  // #global is a special flag which let's a table appear all the time.
  $data['EXAMPLE']['table']['join']['#global'] = array();

  $data['EXAMPLE']['custom_handler'] = array(
    'title' => t('EXAMPLE field handler'),
    'help' => t('EXAMPLE field handler'),
    'field' => array(
      'handler' => ExampleViewsFieldHandler::class,
    ),
  );

  return $data;
}

I could also post the code of the field handler class, but I supposed it is not really that relevant..


texts: What is correct way to override the field required error messages on custom form?

texts:
I have installed clientside validation contributed module in my Drupal 8 Project. Now all client side validations are looking uniformed throughout the site.

The only issue I am facing right now is about overriding Default error messages.

I have googled about how to override but everywhere I am getting suggestion of removing #required = true from the field definition and then in form_validate I can set error message with the help of form_error_message like below:

$name = $form_state->getValue('name');
if (empty($name)) {
   $form_state->setErrorByName('name', $this->t('Email is required.'));
}

But is there any way to just override error message without removing required true & writing obvious logic once again like if ( empty(field) ) then set custom error message.

Please provide if any other way than above