texts: Correct way to get field definitions for entity types

texts:
I'm still pretty new to D8 so I'm getting to grips with the new way it deals with fields and the OOP way of doing it etc.
I've got a hook in my module which I'm trying to add a submit handler to different types of form submission (user registration, comment forms, webforms etc) and I'm trying to write something which will go through each of the admin added fields (eg, all fields that start with field_ ) and deal with each field type so that I can do something additional with it at the end
In pseudo terms
foreach ($fields as $field_name => $field) {
    if (substr($field_name, 0, 6) === "field_") {
      switch ( //field type ) {
        case 'boolean':
          // if it's a boolean, do this
          break;

        case 'entity_reference':
          // if it's an entity reference, do this
          break;

        default:
          // for everything else, do this

          break;
      }
    }
  }

But where my switch statement is, I'm basically having to check against the field definition to determine what type of field I'm checking against, because if I just check against the submit handler answers, it only gives me the response.
Currently I'm getting the definitions by doing this
$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('entity_type', 'bundle');

Is that the best method to do it? When I tried to run dpm() on this for a custom comment form type, it just seems to kill my site, not like a requirement error, but it just seems to have a memory leak when I try to do it or something.


texts: How to add extra new term into multiple nodes

texts:
I got 100 nodes. They all have Term reference field. 50 nodes are set to term 'A' and other 50 to term 'B'. So with that it helps me to filter those nodes via Views to display A nodes in one page and display B nodes in other page.

So now there's an update needed to be done. All those 100 nodes has to have a new term selected 'C' (A and B stays selected as it is). So all A's has to have now C and same with B's.

So how do I do that instead of going through all 100 nodes single by single and selecting it manually?


texts:
I've creating an intranet module for Drupal 8 and I want to use a custom theme for it, like an admin theme(with page/node/field templates) where I can map region like menu, header, footer... but only for my module.

I didn't find any specific doc about this.

Thanks for your help!


texts:
I have a custom form for with media selector from media module. The form field is as below.

$form['image'] = array(
      '#title' => t('Image'),
      '#type' => 'media',
      '#description' => t('The uploaded image will be displayed on the page unless it is marked as "removed".'),
      '#default_value' => array('fid' => $current_image),
      '#media_options' => array(
        'global' => array(
          'types' => array(
            'image' => 'image',
          ),
          'enabledPlugins' => array(
            'upload' => 'upload',
            'media_default--media_browser_1' => 'media_default--media_browser_1',
          ),
          'schemes' => array(
            'public' => 'public',
          ),
          'file_directory' => 'subpage_banner',
          'file_extensions' => 'png gif jpg jpeg',
          'max_filesize' => '1 MB',
          'uri_scheme' => 'public',
        ),
      ),
  );

When I select an image and post the form, I get the field value as an empty array. below is the print shot of my $form_state variable.

Array
(
    [identity] => 9
    [path] => contact
    [image] => Array
        (
            [fid] => 0
        )

    [fid] => 0
    [language] => en
    [removed] => 0
    [submit] => Save
    [form_build_id] => form-zFkFCgBCHtesrAYOQrQXC3Ug_sMBg68dwgWwRE-Y2Ls
    [form_token] => i_aIpfgcwSz-7d_H0U48C5SUOkWlVAkBTz1M8yokXtg
    [form_id] => sitegeneral_settings_banner_sub_update_form
    [op] => Save
)

How do I get the selected image's fid?


texts: How to hide group header in grid style View?

texts:
How can I hide the headers of the groups in views (Art, Society and Culture) ?

this is a grid style view of taxonomy grouped by parent term (Drupal 7)


texts: How to run code on every page request - after modules are loaded?

texts:
I want to write a module that redirects visitors to another page based on the geoip module.

There is hook_boot() which runs on all page requests, but before the modules are loaded. There is also hook_init() which isn't run on cached pages. I'd need something that runs after all modules are loaded - but before cached pages are served. Did I miss another hook in the documentation?

Note: Turning off the cache is not an option for performance reasons.


texts: Author image not rendering in node twig file

texts:
I have created node for a Article content type. And I am trying to extract out author information in node--article.html.twig file.

I am sucessfully able to fetch out Author name {{ author_name }}, author bio {{ node.Owner.field_bio.value}}.

But I am facing issue to find out author image. When I tried to print {{ kint(author_picture) }} it returned me null. But when I vistited link: http://drupal-site.com/user/2, I can see author image there. I am bit consfused on need help on showing author image in node.

Any help is appriciated.


texts:
I want prepend one div using jQuery, But the div has to be generated dynamically, so I can not add it in html.tpl file.

I have tried below code

drupal_add_js('jQuery(document).ready(function () { jQuery("body").prepend("'+download_list()+'"); });', 'inline');

function download_list(){
    $output = "I am testing my div prepend";

    return $output;
}

But it is not working , whats the correct way to do this, please help

I am using Drupal 7

Thanks


texts:
What I need:

I have a Drupal + Ubercart setup, with one product and different attributes. I need prices calculated by weight attribute, displayed on the cart page & carried through to checkout. I've found numerous attempts at this as results in the past, but no-one seems to have posted their solution. Here are some example figures:

250g:$10
500g:$19 #+9
750g:$27 #+8
1000g:$34#+7
1250g:$44 #notice, $34 + $10. Starts again.
1500g:$53
1750g:$61
2000g:$68
2250g:$78 #notice, $68 + $10
2500g:$87

What I have:

After a lot of searching, I found this module:
https://drupal.org/project/uc_custom_price

In python, this would be easy:

total_weight = price = thousands = hundreds = 0

for item in cart:
    total_weight += item[item.index("weight")]
if len(total_weight) > 4:
    print "Contact wholesales dept. for discounted rate."
if len(total_weight) == 4: thousands = int(str(total_weight)[0])
hundreds = int(str(total_weight)[1])

price += thousands * 34
if hundreds == 7:
    price += 28
if hundreds == 5:
    price += 19
if hundreds == 2:
    price += 10

print price

>> total_weight = 1500
>> 53

>> total_weight = 5750
>> 198

Any ideas on how I could do this with Ubercart, Drupal & PHP?


texts: When more than one Shipping Rules applies, select the highest

texts:
I am using Drupal 7 with Drupal Commerce to manage an eshop.
I have 8 product types and I manage the shipping per product type with price variations.
Product type 1 when price is lower than 50 euros has 5 euros shipping, product type 2 has 3 euros shipping when the price is lower than 30 euros etc
I manage doing that by adding rules after a product is placed at the cart , using
"Price comparison" and "Order contains products of particular product types" conditions, and action "Apply shipping rate to an order".

It seems to work fine but when I add multiple products from various categories, the shipping rule that prevails is the rule applied to the first product added to the cart.
What I want is to compare all Shipping rules and keep the one with the highest cost.

Is this possible?


texts: How to give image instead of text in pager?

texts:
I need to change the text in to image in pager.

For example:

<< First < Previous  4 5 6 7  Next > Last >>

Now instead of the above i need to print as below:

<< <  4 5 6 7  > >>

Note: Consider the less than and greater than symbol as images.

Here is the syntax :

theme_pager_next($text, $limit, $element = 0, $parameters = array())

Here is my code :

$li_next = theme('pager_next', theme_image(drupal_get_path("theme", "fluid") . "/images/text.gif"));

My output is as follows for the above code :

<img src="/sites/all/themes/fluid/images/text.gif" alt="" title="" width="7" height="13" />

But my desired output is to print the image which is in the image tag.

Any help will be thankful and grateful.

Thanks in advance.


texts: How do I show webform component labels in a chart using Views chart format?

texts:
Drupal 7.50, Webform 4.12, Webform Chart 2.0, Views 3.13, Charts 2.0, with Google Charts as the charting engine, so not Highcharts.

I have a webform that collects simple drop down list values for each question. The values are 1, 2, 3, 4 and 5. There are around 10 questions.

The labels for each component are not displayed on the chart. It seems the Label of the very last field added to the list is used for all fields, and they are only shown when the bar is hovered over.

I created a view and added the webform submission data fields then enabled aggregation and set the format to Chart. Limited the number of records in the pager settings to 1 (So we get just one Webform instance). Example below shows how the first series is called "Governance Framework" but when hovered over, the bar shows the last label "Organisational Structure1".

Can anyone advise how I can get the Webform Component Field labels to show up on the left of each of the bars, or fix the hover over issue? Many thanks!

P.s. not sure which module page I should log an issue, so any pointers on how to patch the relevant project would be appreciated.


texts: In order to specify a PHP validation criteria for a View - do I need some additional module? In previous installation of Drupal I had this position in select box. Now there is everyone of them apart from PHP code. Where did it go?


texts: How can I disable jquery_update when my admin theme is in use?

texts: I have installed jQuery Update but it breaks some core functionality that makes the admin UI a struggle to deal with. Is there a way to keep jQuery Update enabled but disable it when the admin theme is visible?


texts: How do I configure the Sendgrid Integration module?

texts:
I have two Drupal 8 sites. Both have sendgrid integration installed via composer and both are using the same version (1.2). I have a Sendgrid account created and an API Key has been saved to the config for both sites.

The problem is that only one site is able to send mail while the other fails. I tested the functionality by sending test emails to myself and the site that failed always gave this error.

  No API Secret key has been set

I've traced the error to the following code where the first if statement always fails.

$site_config = $this->configFactory->get('system.site');
$sendgrid_config = $this->configFactory->get('sendgrid_integration.settings');

$key_secret = $sendgrid_config->get('apikey');
if ($this->moduleHandler->moduleExists('key')) {
  $key = \Drupal::service('key.repository')->getKey($key_secret);
  if ($key) {
    $key_value = $key->getKeyValue();
    if ($key_value) {
      $key_secret = $key_value;
    }
  }
}

I'm confused because this is only happening on one of my sites, not on both even though they are configured the same way. Does anyone know what might be causing this issue?


texts: How to add fields from other modules in Drupal 6 Views?

texts:
I have a Drupal 6 website with Ubercart 2 and the "Delivery time slots for Ubercart" module installed, and I have created a View to pull a custom report of order info. I need for that report to also include the delivery time slot chosen by the shopper on each order, but that module apparently does not have Views integration. Is there a way for me to pull the time slot value (and/or any other arbitrary database field that related to the other data I am pulling in, I assume based on the order ID) for each order into the view?

I appreciate any feedback! Thanks!


texts: How do I check the entered quantity before the checkout phase in Drupal Commerce?

texts:
How to check product quantity before checkout ?

I want to avoid the order if a required quantity is not reached.

Nota : I use Commerce Physical Product module.


texts:
I'm currently building websites with the Administration Language Module. For the first time, the admin language is different than the default language but it doesn't work. For example, my default language is English and I'll set Spanish for the admin menu. My admin menu (and all administration dashboard) is partially translate.

As you can see, sometime item's menu are in English and in Spanish.

However, "People" is correctly translate in Translate Admin.

Can you help me?


texts: How do you modify the label of field collection items?

texts:
I have a field collection rendered as a table that contains Username followed by marks in 5 subjects. During form edit, I wanted to modify the title for each 5 marks entered as the subject name corresponding to the semester selected in the node form containing the field collection items. Each semester contains list of subject names. The number of subjects per semester is fixed.

I created a tpl.php file for the form. However setting the value of the #title field using the form array does not work. Any help would be appreciated. Thanks.


texts:
Trying to understand the default ajax behavior on drupal forms. Let's say I have a form builder function that creates few textfields and a submit button. Before form elements are generated I'm running few functions that call the database and feed some data that decides which fields are displayed, which are not. And let's say that submit button has an ajax callback that is supposed to add another field to the form depending on the value from one of the fields.

Is ajax really just injecting the new field into the 'wrapper' or is it reloading the whole form (which means it also repeats the database call?)

Example

function mymodule_form($form, &$form_state) {
    $result = do_some_database_stuff();

    $form['myform']['field1'] = array(
      '#type' => 'textfield',
      '#title'  => 'field 1',
    );

    $form['myform']['field2'] = array(
      '#type' => 'textfield',
      '#title'  => 'field 2',
    );

    $form['myform']['field3'] = array(
      '#type' => 'textfield',
      '#title'  => 'field 3',
    );

    if($result == something){
       $form['myform']['field4'] = array(
         '#type' => 'textfield',
         '#title'  => 'field 4',
       );
    }

    $form['myform']['fieldset'] = array(
      '#prefix' => '
',
      '#suffix' => '
',
      '#type' => 'container',
    );

    $form['myform']['submit'] = array(
      '#type' => 'submit',
      '#title'  => 'Press me',
      '#ajax' => array(
        'callback' => 'ajax_callback',
        'wrapper' => 'fieldset',
        'method' => 'replace',
      ),
       '#submit' => array('myform_submit'),
    );
}

function myform_submit(&$form_state, $value){
   $form_state['rebuild'] = TRUE;
}

function ajax_callback($form, $form_state){
  if($form_state['values']['field1'] == true){
    $form['myform']['fieldset']['newfield'] = array(
      '#type' => 'textfield',
      '#name' => 'New Field',
    );
  }
  return $form['myform']['fieldset'];
}


texts: I am using Drupal 7.12 and Webform2PDF 7.x-3.0. Is there any feature to save the PDF file to server using this module? Or how can I do this with this module? Or is there any other module ?


texts: Attaching a field of a node type in another form

texts:
I have content type 'story' which have an upload field. I have workflow modules installed.

I want the upload field to be presented within the workfloaw form. So within form alter function I did:

field_attach_form('node', $node, $form['append'], $form_state);

then unset all other fields of the story node and appended validation and submit handlers:

$form['#validate'][] = 'node_form_validate';
$form['#submit'][] = 'node_form_submit';

on submission I get this error:

"EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7409 of /var/www/site/includes/common.inc)."

I tried by specifying 'bundle' and 'entity_type':

$form['#bundle'] = 'story';
$form['#entity_type'] = 'node';

and

$form['append']['#bundle'] = 'story';
$form['append']['#entity_type'] = 'node';

but did not help. What can I do?

Thanks.


texts: Adding more values to Drupal user status

texts:
Are there any modules available for adding more values to the standard Drupal user status?

By default we have "Active/Blocked" values, but I would like to extend it with more values.


texts: Entity access controler not called from custom route

texts:
I define a custom entity named "Politician", where I set the class PoliticianAccessControl as an access handler. This is working fine for the canonical url of the entity set in the following way:

entity.politician.canonical:
  path: '/politician/{politician}'
  defaults:
    _controller: '\Drupal\pw_basic\Controller\EntityViewController\PoliticianViewController::view'
    _title_callback: '\Drupal\pw_basic\Controller\EntityViewController\PoliticianViewController::title'
  requirements:
    _entity_access: 'politician.view'

See the entity access requirement? Here the method PoliticianAccessControl->checkAccess() ist called, everything works just fine.

But when I try the same with another custom route the PoliticianAccessControl class gets not called and I always get an access denied message:

entity.politician.about_me:
  path: '/politician/{politician}/about-me'
  defaults:
    _controller: '\Drupal\pw_basic\Controller\PoliticianFrontend\AboutMe::build'
    _title_callback: '\Drupal\pw_basic\Controller\PoliticianFrontend\AboutMe::title'
  requirements:
    _entity_access: 'politician.view'

What do I forget?


texts: How to update a module's view programmatically using hook_update_n?

texts:
We're writing some update functions for a custom module. This custom module provides some views:

/**
 * Implements hook_views_default_views().
 */
function mymodule_views_default_views() {
  $views_dir = drupal_get_path('module', 'mymodule') . '/views';
  $views_files = scandir($views_dir);
  $views = array();
  foreach ($views_files as $filename) {
    if (substr($filename, -4) == '.inc') {
      include_once $views_dir . '/' . $filename;
    }
  }
  return $views;
}

There are several .inc files from the view export ui and all those views are provided.

Now: some of those views should be updated. We usually just export and re-import them using the view ui (and override existing views). We wondered, how would this be possible programmatically? How to tell views which files to import again and override?

function mmodule_update_7001() {
  // what goes here?
}

Thanks for any ideas!


texts:
I installed Drupal via the following command.
composer create-project drupal-composer/drupal-project:8.x-dev
projectfolder --stability dev --no-interaction

As a result I'm getting this structure.

../projectfolder/vendor/drupal
../projectfolder/vendor/bin/drush
../projectfolder/web/
etc. ...

Perfect structure, but what I'm missing the index.php file. Also, the common files like sites/default/settings.php are not part of my install or perfectly hidden.
How can I get those files? What I'm doing wrong? I tried to use Drush for an standard site-install, but it failed also.


texts: How can I parse an URL from the Link module?

texts: I am developing a website, my website, powering Drupal 7 and I know that the Link module already has something like displaying a link from http://website.com/some-article-here to website.com but I want to be able to display something like that and to manually add the same field in to a  tag. To sum up, I need the first long link http://website.com/some-article-here provided from the link field to go in an  tag and the parsed one website.com to simply show on the website as it is. Got it? Please help!


texts: How to detect the region of a block programatically

texts:
I need to create a custom submit handler when blocks that are assigned to a certain region are saved (whether an existing or a new block)

I am using :

function MY_MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  if ($form['#id'] == 'block-admin-configure'){

    //If the block being saved is in region "Header" then do something
  }

Can someone tell me what to replace my commented line with please ?


texts: Automake forum on node creation with rules

texts:
I'm desperately trying to programmatically add a new forum (in the 194 tid specific container) on node creation with rules.

I run php script when adding new node with rules, but I'm really newbee with php. I'm trying to use form_forum_form and form_forum_submit putting this variables :

require_once 'modules/forum/forum.admin.inc';

$autoform = array(
     'name' => '[node:title]',
    'description' => 'Forum du projet [node:title]',
    'tid' => 194,
    'weight' => 0,
);

$form = forum_form_forum($form, &$form_state, $edit = $autoform);
forum_form_submit($form, &$form_state);
print_r(drupal_get_messages());

This link doesn't helped me and there is nowhere on the web where the answer is explicitely given.
How to programmatically create forums and containers (not forum topics)?

Thanks for helping


texts: In one of the sites I have created, I am using a specific made up 404 page instead of the default one that comes with the server. This 404 page contains an image, and then a block containing text next to it. I then made the url alias for this page "404." Now when I go into the configurations, and set 404 as the 404 error page, it automatically saves it as "node/4." The problem then arises when you go to a page that doesn't exist. If the page is something like www.yrambam.org/nonexistentpage then there is no problem. The page works. But if the page is something like www.yrambam.org/something/nonexistentpage then the page displays without the image, and the formatting of the page becomes all messed up. I am wondering why this happens, and if there is a way to fix it.


texts: Get/print current Ubercart currency via template.php

texts:
I am using Ubercart on D7.

Does anybody know how I can get the current Ubercart currency (e.g. $, €, etc) in template.php?

I am overriding the add to cart button via hook_form_alter, and need to print the site's current currency (in case of multi-currency) in the button markup.

thanks


texts:
Very similar to this question except I need to save users, not nodes.

Use case: I added a field (single boolean) to a feature so that the field is added to user profiles.  I then pushed the feature to my staging server.  However, existing user accounts do not have the default field value for this field assigned.  Re-saving each account fixes the problem, but there are 1000 users.

How can I quickly re-save all users on my site?


texts: Print list of attached taxonomy terms on search result items

texts:
First off, let me start by saying I am fairly new to Drupal, I come from a heavy Wordpress / Joomla background. On to my question:

I have looked for hours for a way to print a list of the taxonomy terms attached to a search result item. I need it to be as automated as possible (i.e. I need get the nid & vid from the node automatically if possible). I was able to get the nid using the following:

$nodeID = $variables['result']['node']->nid;

I do not need any fancy formatting, or hierarchy, I just need a comma separated list of the attached terms for each item on the search results page. If possible, I would also like to limit the depth to 5, but that is not a primary concern.

Here is what I have so far:

// Add List of Terms to Search Result Items
    $vid = 4;
    $terms = array();
      if (isset($node->taxonomy)) {
        foreach ($node->taxonomy as $voc) {
          if ($voc->vid == $vid) {
            $terms[] = $voc;
          }
        }
      } else {
        // check db in case node doesn't have terms
        $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
      }
      return $terms;

    $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
    // To store the new terms (if necessary...)
    if ($terms) {
        foreach ($terms as $term) {
            // Each term has the properties:
            // $term->tid
            // $term->vid
            // $term->name
            // $term->description
            // $term->weight
            // To just print the results use something like:
            print $term->name . ',';
        }
    }

Any help you guys can provide would be immensely appreciated!


texts: Alternative to FieldCollection and FieldCollection Table

texts:
i have a fieldcollection field in a entity form type with FieldCollection Table display, and its set to unlimited value. In this field collection there are 5 fields.
After some research I found that after insert 20/30 items, field collection slows down considerably. Infact, in my entityform, after 40 items of fieldcollection, increases the data loading time.

I'm looking for an alternative to fieldcollection with the ability to display the field in table such as field collection table.

can you help me?

Thanks


texts: allow user to choose from his own referenced nodes

texts:
I have two content types: business listing, product listing.
"Product listing" has an Entity Reference field. This field points to the nodes of "business listing".
I want to allow user to choose from his own "business listing" nodes (during adding a "product listing" node).
I have created a view to list the nodes of "business listing" type and have Added a Entity Reference display to the view. Then have selected the view Under "Entity selection".
Now, I have a problem in adding proper contextual filter.
I have added a contextual filter of "Content: Author Uid" and selected "provide default value".

a) if I select "USER ID from logged in user" as default value:

This solution will break if an admin is editing the node. The field will then show only nodes the current user (admin) has created.

b) if I select {"User ID from URL" and "Also look for a node and use the node author"}:
This solution will break if an user is adding a new node. The field will not show any nodes!

How can I achieve this?


texts: Cannot add a file with Search API Attachments

texts:
I'm using Search API with Solr and Tika under D8 to build a search engine on my website.

I could not find any tutorial under D8 for that, so I followed one I've found on D7. However, when I try to add a field "file" to my index, it appears in a section called "Skipped fields" with the following message :

  The following fields cannot be indexed since there is no type mapping
  for them:

  Source » File (type "entity:file")

  If you think one of these fields should be available for indexing,
  please report this in the module's issue queue. (Make sure to first
  search for an existing issue for this field.) Please note that
  entity-valued fields generally can be indexed by either indexing their
  parent reference field, or their child entity ID field.

Has anyone managed to index files using Search API Attachments ? I cannot understand how to fix this message.

Also, it does not make sense to me to "index their parent reference field" because this will put an ID in Solr, and not a real text file metadata ..


texts: How do I display multilingual logos in D7?

texts:
I have read almost every tutorial on the net about how to setup multilingual logos. Yet, I cannot get anything to work.

How do I get multilingual logos to display in D7? I have added

$conf['i18n_variables'] = array(
    'logo_path',
    'theme_XXX_settings',
);

I have also uploaded using the form for the theme settings while in the langauge of the logo I want to display. All languages are set to whatever file I upload last.

Do I need to use a different variable in the conf array? Do I need to print a different variable other than $logo in the theme?

Can someone who's done this give some very specific instructions or provide a link to a recent d7 tutorial?


texts: How to use views taxonomy contextual filters with menu tabs?

texts:
I have a CT (let's call it Article) with a Status taxonomy field (let's say with values Open, Closed and Cancelled) and I want a view of Articles with menu tabs for each status value. And I would like to have it work with contextual filters on Status term name.

The URLs of the tabs should be like articles/open, articles/closed etc but the last argument should act also as the contextual filter value. I cannot make it work since drupal takes articles/open as part of the url and I should type articles/open/open to have it use the argument.

Is it possible to be implemented with contextual filters somehow? I would like to avoid hidden filter criteria with taxonomy term value preselected, as I want to track it with features and I do not want the id of the preselected taxonomy term tracked.


texts: unable to load the field_media_img properly within the bootstrap style

texts:
While creating a view I would like to add {{ field_media_img }} in a
.
Therefore I created a view with 5 fields, all "exluded from display". And a global: custom text field.
The view should be in a card structure, using a custom bootstrap barrio theme and drupal 9:
According to bootstraps documentation:
.card-img-top places an image to the top of the card. With .card-text, text can be added to the card. Text within .card-text can also be styled with the standard HTML tags.

  {{< placeholder width="100%" height="180" class="card-img-top" text="Image cap" >}}

Some quick example text to build on the card title and make up the bulk of the card's content.

I attempt to translate this for my view, wich result in a unexpected image load. without a width

{{ title }}

{{ body }}

     Go somewhere

The "cards" view works as expected altough I'm unable to load the field_media_img properly with the bootstrap style.
What am I missing?


texts: Drupal 7 completely offline, avoid Boostrap via CDN

texts:
I need to move my Drupal site to completely offline environment.
 The bootstrap library takes the correct Bootstrap JS and CSS from sites/all/libraries, but there is a CDN call to download Bootstrap that screws up the bootstrap functions (ex: popup is undefined) in other JS.

So, I have all necessary JS files locally, they are correctly loaded but when I switch off internet, bootstrap functions are undefined.

As far as I see in Bootstrap module, there is no way to avoid this CDN call. I setup in boostrap module settings[bootstrap_cdn] = 0  but it's still calling.

Would appreciate a lot any idea, its kind of urgent.


texts: How do you perform a rules action by the quantity of a specific commerce product?

texts:
I'm working on a module which is going to be used alongside Drupal Commerce so people can buy a set number of digital products. I've written a custom rules action, which will be run once for each purchase of a specific commerce product. How can I add this to a loop, so that the action gets run n times (n being the quantity purchased for this product, as you could purchase more than one).

So far I've added this action to a loop for commerce-order:commerce-line-items but even if I purchase more than one, the action is only run once. How can I make the action run 'quantity of this product purchased' number of times?

Many thanks


texts: Array to string errors on hook_views_data()

texts:
Why do I get these errors/notices on my hook_views_data() implementations?

Notice: Array to string conversion in format_string() (line 1550 of C:\wamp\vhosts\mydrupal72\includes\bootstrap.inc).

(4 instances) on defining

$data['mytable']['table']['group'] = t('Group name');

and:

Notice: Array to string conversion in views_ui_edit_page_title() (line 273 of C:\wamp\vhosts\mydrupal72\sites\all\modules\views\views_ui.module).

(4 instances too) on defining:

$data['mytable']['table']['base'] = array('field' => 'field_id', 'title' => t('title'));


texts: hook_schema is not creating database table

texts:
The following function is contained in process_login.install as part of a custom module called process_login. The module works if I manually created the database table, but naturally I would like the table created automatically on install.

The function itself does not generate a schema error on installing the module. But neither does it create the database table process_login_register in the Drupal 7 MySQL database.

There are no other errors I can see, or problems reported by Site Report.

I have removed it completely and reinstalled numerous times. I have searched the web extensively, and consulted two books I have on Drupal development. I can't see anything wrong with this function (listed below).

NOTE: I have also tried defining 'id' as serial but get the same result (i.e. no table created).

I have run out of ideas. Does anybody know why this function isn't working?

function process_login_schema(){
  $schema['process_login_register'] = array(
        'description' => 'Register a specific computer with the system.',
        'fields' => array(
                'id' => array(
                    'description' => 'Primary identifier.',
                    'type' => 'int',
                    'unsigned' => TRUE,
                    'size' => 'normal',
                    'not null' => TRUE,
                    'default' => 0,
                ),
                'ip' => array(
                        'description' => "The user's IP address at registration.",
                        'type' => 'varchar',
                        'length' => 32,
                        'not null' => TRUE,
                        'default' => '',
                ),
                'user_agent' => array(
                        'description' => "The user's browser user agent string at registration.",
                        'type' => 'varchar',
                        'length' => 255,
                        'not null' => TRUE,
                        'default' => '',
                ),
        ),
        'primary key' => array('id'),
  );
  return $schema;
}


texts: How to add Facebook share/like icon in Blog Entry header?

texts:
I want to add a header to my "blog entry" content type that will have a couple icons for sharing with Facebook, Twitter, email, and Google +1.

How can I do this?

I currently have the icons in a block in the sidebar.


texts:
I use Media + File Entity projects.
I have content type with field_media_picture (widget: Media file selector) which then connected with Media image file.
The Media Image file type has field_picname (text).
I've Managed display for the Media Image file type to display: image file and field_picname.
I've created field--field_media_picture.tpl.php:

<?php print render($items);?>

This code show image + field_picname. It's OK.

But how can I get these fields (image and field_picname) separately in PHP?
I want to theme these fields individually.


texts:
I am wondering how to implement a Hook after the import of one of my importers is finished. The last imported node and the name of the importer itself would be the parameters that i need to have at this time.

Background/Usecase:

The site I'm working on is built to control IT-projects. After the user imports the bill-positions (each one a row in a CSV file => node in Drupal), which happens monthly, the site has to check if all bill-positions for a customer have been invoiced.

This is only one example, there are many other examinations that need to be done after an import is done.

I read the Feeds API & documentation, but I didn't find anything useful.

P.S. I'm pretty new to open source and Drupal itself; so please correct me if I am missing any guideline.


texts: creating a function that can create GET url variables as object when I need it

texts:
I am trying to parse my form's GET method and create a function that can get all the parameters from the URL in DRUPAL 8. I have a form that I am gonna use it to filter my library items as search( I know I can use search api or advanced search but my client wants this way ) So I have a few fields such as keyword, title, description, location, author, from, to, collection. and when I add all the fields after the redirection to result page

http://example.com/advancedsearchresult?keyword=test1&title=test2&description=test3&author=test4&location=test5&from=&to=&collection=&media=all

I would like to do nice job with using OOP and Symfony service features. My question is how could i create a function in my controller for this result page that is gonna parse all the parameters from the URL so I can use them to create an object in service to create individual query for each parameters to make search mechanism for this form?

UPDATED:

After @oknate pointed out, I updated my controller like this:

namespace Drupal\advancedsearch\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\advancedsearch\AdvancedSearchQuery;

class SearchResultController extends ControllerBase {
 protected $advancedsearchSearchResult;

public function __construct(AdvancedSearchQuery $advancedsearch_search_result ) {
 $this->advancedsearchSearchResult = $advancedsearch_search_result;
}

public static function create(ContainerInterface $container) {
return new static(
  $container->get('advancedsearch.search.result')
);
}
private function setupAdvancedSearchQuery() {
$params = \Drupal::request()->query->all();
foreach ($params as $key => $value) {
  if (!empty($value)) {
    $params[$key] = $value;
  }
}
}
}

on the other hand, I created my service file, I created my variables which matches with parameters, so am I gonna be able to use setupAdvancedSearchQuery() when I call the object for each parameters, if so can anyone give a hint?


texts:
I installed Drupal 8 minimum.
Create content type. Like normal there is one field. The body field.

I can't add an other field. In extend/modules all field types are enabled. Also fields and fields UI. What am I missing or have to enable to add fields to content type like: Image, link, references, etc.

I ran drush cr a couple of times.


texts: FormState object gets no values from embedded form placed with AJAX

texts:
I have a form which is added to a node edit form via AJAX; a controller builds it, renders it, and sends it back to the node edit with the following code.
$rendered = \Drupal::service('renderer')->renderRoot($form);
$response = new Response();
$response->setContent($rendered);

return $response;

In the AJAX .done function, one of the values (a <select>) of this form is set. The remaining values can be set by the user. I then execute a custom submission handler when the entire node edit form is submitted.
In that submission handler, I tried $form_state->getUserInput() and $form_state->getValues(). In both the cases, the keys representing the from that was ajax'd in have empty values.
Is there something special I have to call before submit handlers run to populate $form_state with these values?
Digging into the FormBuilder()->buildForm() code, I noticed that when
$form_state->isMethodType('get') ? $request->query->all() : $request->request->all() is executed, the field with the embedded form is likewise empty.


texts: In drupal 7, what does make a menu link a stale item?

texts:
I'm creating menu links with this kind of code:

$item = array(
  'link_path' => drupal_get_normal_path('link-path'),
  'link_title' => 'link-title',
  'menu_name' => 'menu-name',
  'weight' => 0,
  'expanded' => 1,
);

// Look the table first if the data does exist
$menuId = db_query("SELECT mlid from {menu_links} WHERE link_title=:link_title AND link_path=:link_path", array(':link_title' =>
$link['link_title'], ':link_path' => $link['link_path']))->fetchField();
if ($menuId === FALSE) {
    $menuId = menu_link_save($item);
    echo "New entry " . $menuId . PHP_EOL;
} else {
    echo "exists " . $menuId . PHP_EOL;
}

Later on, if I call any of these functions:

menu_rebuild()
drupal_flush_all_caches()
Or if I clear the cache from the web ui.

All my menu links are deleted. According to the documentation, these functions "remove stale items from {menu_links}". And I am unable to find out what is missing in the parameters of menu_link_save or if I need an extra step. If I stop the script before flushing, the content table menu_link looks OK.

I'd like some explanations about the workflow of menu_rebuild that causes some objects to be deleted (i.e. is there a flag or something, etc.).


texts: How to run a Drush command with the full site path?

texts:
Im trying to get Drush working. When I type 'drush' into terminal I get a list of commands so I know its installed.

I dont have any path aliases set up yet so im trying to use the full path. When I type the following into terminal:

cd path-to-my-site drush dl views

I get this message:

unknown:omegav3 my-user-name$

Should the path-to-my-site be the base path? Im working locally with MAMP. I have different sites that arnt in the root folder so my local url for this site im trying to target is:

http://localhost:8888/omega/omegav3/


texts: programmatically exclude new fields from render()

texts:
I need to render a limited number of fields from a given content type, without exposing the new ones I may add some day in the future.

Now I have:

print render($page)

When a new field is added to the content type, I have that added to the render($page) as well. I don't want this to happen.
Aside hiding the field from "admin/structure/types/manage/CONTENT_TYPE/display", how can I programmatically exclude new fields from render.


texts: Is it possible to create multiple submission forms for one content type?

texts:
I want to allow my users to submit different type of content using different types of templates (like in tumblr.com where you get a specific template/form for each content)

At first, I was thinking about creating custom content types, but this is a workaround because I dont really want to make different content types (all nodes are blog posts). I just want to create different forms for the content submission.

What is the proper "Drupal way" of doing that?


texts: Have alias URL remain alias instead of resolving to target URL

texts:
I have a Drupal site with an Event content type. This content type has an Event Categories taxonomy field on it, which, as you can guess, categorizes events.

When you navigate to the URL of a particular term of that taxonomy, you see a sort of calendar view of Events that are tagged with that term.

These term pages have aliases set up, so that instead of, for example, taxonomy/term/436, you can see the taxonomy term page by navigating to, say, /calendar/special-events.

This aliases are used to populate a menu which is used to navigate the calendar and see events only pertaining to one particular taxonomy term.

I am now tasked with integrating this sort of 'virtual calendar' (the menu and the taxonomy term pages) into an internal section of the site, which users have to log in to see.

We've created the internal section using the context module, using the URL  (and user roles) as a condition of the context. For instance, the page /internal/calendar triggers the context to add blocks and other features that make up the internal part of the site (because the URL begins with internal).

However the problem arises when I want to use the calendar menu to place the calendar inside the internal site. The menu links are set to /calendar/special-events-- which, if an internal user navigated to, they would lose all the context that makes up the internal site. They will have navigated out of the internal site at that point.

I began to create a second menu, which was essentially the same as the Calendar menu, but all of the links began with /internal/calendar, /internal/calendar/special-events, etc. Sure, it's duplication, but it's more or less manageable.

The problem arose when I tried to add a second alias to the taxonomy term page. I went to admin/config/search/path and added an alias, so that the taxonomy term had two aliases:

/calendar/special-events             /taxonomy/term/213
/internal/calendar/special-events    /taxonomy/term/213

However, when I navigated to /internal/calendar/special-events, the URL in the browser became /calendar/special-events, which is the alias set on the taxonomy term page (the default, or primary, I guess you could call it). So because the URL doesn't contain /internal, then the context didn't trigger, and I effectively navigated out of the internal site.

My question: How can I set up a second alias for a taxonomy term page so that it doesn't get re-written to the default alias?

I also tried setting up a URL pattern at /admin/config/search/path/patterns:

Internal calendar   internal/calendar/[term:name]   Taxonomy term

Vocabulary is event_categories

But with the pattern, when I navigate to internal/calendar/special-events, The URL remains as such, and the page renders the context items, but the content itself is rendered as a 404. So this does not appear to be a solution each.


texts: Organic groups, group content types and pathauto

texts:
In pathauto module settings I have

  localhost/[node:group_group]

for all group types. I have few group types:
Ex Technology, Arts, Design etc and within each group type you can create as many groups as you want.

So when I create a group named google, the path looks like this :

  localhost/technologies/google

.

I want to have any article created within that group and to have a path like this

  localhost/[node:group_group]/[node:title]/[content-type]/[title]

Ex:

  localhost/technologies/google/article/some-article

How to achieve something like this?
I could not find any token replacement pattern for my use case in pathauto module. Is there some trick here?

Thanks


texts: Can I export token through features from one environment to another


texts: multistep registration from in drupal 7 need to add a user and role

texts:
Here is my method

test_two_submit($form, &$form_state) {
  $page_one_values = $form_state['page_values'][1];
  drupal_set_message(t('The form has been submitted'));
  $page_one_values = $form_state['page_values'][1];
  drupal_set_message(t('The form has been submitted. name="@username @email", password=@password', array('@username' => $page_one_values['username'], '@email' => $page_one_values['email'], '@password' => $page_one_values['password'])));
}

What i am trying to do is to add a user to my multi-step form.

I guess my two questions are how to add a user and also assign that particular user to a role.

Would it be possible for someone to give a short example.


texts: Check if a node exist where field_a = Sessionvalue && field_b=arg1

texts:
Hello I need a an if else statment to check if a node with 2 given field values exist.(1 value from a Session and 1 from an Url argument)

I dont need to load the node I only want to check if it exist.

thanks for your help.


texts: Extending image field to support additional content

texts:
We need to add a field to the standard Drupal Image field. This field will be used to store an id number of that particular image (so we can display a link to that image on the service: flickr, shutterstock, whatever).

We already have thousands of images stored across three different image fields. Would it be more efficient to alter the schema of the standard image field (how would we even do that?), or would it be better to setup a custom image field and migrate all of the content to the new field?


texts:
I have a restaurant with a Drupal site and would like to post coupons for patrons to use.  They would have to create a user account to view it.  The coupon would be an image field and if a user wants to use it they would click use coupon and it would hide it from that user only.  Is this possible?

Thanks


texts:
In drupal 7, I defined a field for a custom content type and am trying to display its value via page.tpl.php.  Nothing is appearing in the rendered page.

Here's the relevant piece of page.tpl.php.  The field is 'field_mast".  Note that I added print $title just so I could be sure that this template is being used.  It is.

Perinote&trade; <?php print $content['field_mast'] ?>

       <?php print $title ?>
Organize Your Way

My content type fields are:

Label  machine name field type            widget
Title  title        Node module element
mast   field_mast   Text                  Text field
Body   body         Long text and summary Text area with a summary

And for Manage Display, I have:

Field   Label        Format
Body    <Hidden>     Default
mast    Above        Default

Finally, for my actual content, I have:

Title: Notes contacts....
mast: User Guide
Body
This user guide...
Text format: Full HTML

Any ideas on what I need to do to get 'mast' to print?


texts: My site logo looks pixelated even though the image has been sized exactly. When I open the image url in a separate window, the quality is as per expected, however, the display on the site is low quality. Is there any settings I should be tweaking in Drupal?


texts: Change the default image based on certain condition

texts:
I wonder if I could provide two default images -one for boys & other for girls.

In the registration form they can choose their sex from a Boolean field.

Is it possible with conditional fields ? How?
I'm not  a programmer, so please make your answer detailed.


texts: What module can create a gateway or doorway popup AD page before viewing content for Drupal 7?

texts: I'm looking for a module that can create gateway or doorway pages like on many publication sites where you have to view an AD first before letting you view the article.


texts: Filter node link in the menu by term tid

texts:
I created one vocabulary is "Mercedes" and create some term for the vocabulary:

- C-Class
- A-Class
- E-Class

I created a menu and create the links no path:

- Front
- Specifications
- Furniture
- Exterior

Then I create one content type "new car" and added one term reference data fields used "Mercedes" vocabulary and configuration allows attaching links to the menu above when creating new node.
Now I want when I visit a node of a term does the menu will only show articles of taxonomy term. Other articles which are mounted on the menu will not show up.


texts: Is there a way to use grouping settings for Bootstrap Tabs in Views?


texts: How to delete a field from field collection programmatically?

texts:
I am using Drupal 7.2. I have to delete a field from a field collection programmatically.
is there any function which can be used to delete it?


texts: Display discount ad when people visit the page

texts: A client of mine wants to display a discount advert on top of the site when user visited the page, so I imagine it will be triggered by the onload handler of my front page.  I thought I can display the ad content in a colorbox to raise it even more above the content. How can I trigger a colorbox to show up with the onload handler of the site?


texts: Website is getting very high load due to "UPDATE cache SET data..."

texts:
It's a high traffic website, but I guess high load is not because of traffic because many times it runs smooth on same traffic. I researched a lot and optimized Apache, switched off logging modules to save resources and done whatever may be cause of load.
Then finally I installed devel on site and check using "Collect query info", "Display query log" and I found that this particular query taking too much time (more than 2000 ms)

UPDATE cache SET data = 'a:2:{s:7:\"profile\";a:36545:{s:32:\"c21f969b5f03d33d43e04f8f136e7682\";a:17:{s:6:\"layout\";s:7:\"default\";s:14:\"layout_desktop\";s:7:\"default\";s:15:\"layout_handheld\";s:2:\"-1\";s:13:\"layout_iphone\";s:2:\"-1\";s:4:\"menu\";s:13:\"primary-links\";s:10:\"menu_style\";s:4:\"mega\";s:11:\"option_font\";s:1:\"0\";s:14:\"option_layouts\";s:1:\"0\";s:11:\"option_menu\";s:1:\"0\";s:13:\"option_screen\";s:1:\"1\";s:13:\"option_t3logo\";s:1:\"1\";s..........................................................

and page getting loaded and loaded to infinite time, it never completes.
I am sure this is the only reason for high load on server.

APC is already installed on my seerver.


texts: Can I change the default tab at /admin without losing access to /admin/tasks?

texts:
Below I have changed the default tab at /admin to /admin/index, but now /admin/tasks is 403.  Even if I change $items['admin/tasks']['access callback'] to TRUE I'm still denied access.

function hook_menu_alter(&$items) {
  $items['admin/tasks']['page callback'] = 'system_admin_menu_block_page';
  $items['admin/tasks']['access arguments'] = $items['admin']['access arguments'];
  $items['admin/tasks']['file'] = $items['admin']['file'];
  $items['admin/tasks']['type'] = MENU_LOCAL_TASK;

  $items['admin']['page callback'] = $items['admin/index']['page callback'];

  $items['admin/index']['type'] = MENU_DEFAULT_LOCAL_TASK;
  unset($items['admin/index']['page callback']);
  unset($items['admin/index']['access arguments']);
  unset($items['admin/index']['file']);
}

How can I both restore access to /admin/tasks and set the default tab to /admin/index?

Resolution: The admin module was the problem.  It's enabled by default in my installation profile.


texts: Best way to enter(insert) the content in drupal, so a non techie can edit the content

texts: I am some what new to drupal tho familiar with CMS tho drupal way is to put into views tho i dont see how best a non techie can edit such content what am i missing  thank you


texts:
I am building a drupal 7 site.

Lately I made a lot of changes and install many modules.

Currently, when I enter into a view, everything looks fine.
but, when I enter a field settings inside a view, I see that some of the option are not available - meaning the collapsible option is not available.

I tried to replace the views folder on my server with a folder I backed-up 4 days ago.
ran cron, flushed all caches, ran upadte.php - nothing helped.

Can someone please help me solve this issue?

Here is a screen-shot (you can see they are not clickable and not collapsible):


texts: Field formatter to display base 64 data image


texts: How to integrate an exported Rules component in a custom module?

texts:
i have created list of component fields in a Drupal 7 module, copied the exported Rules code and then pasted it into our custom module

But it is not working. Any ideas how to get it to work?

This is my exported Rule:

$rule = '{ "rules_faircent_rules" : {
"LABEL" : "Faircent Rules",
"PLUGIN" : "rule set",
"OWNER" : "rules",
"TAGS" : [ "Faircent Rules" ],
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : {
  "fc_home_city" : { "label" : "Home city ", "type" : "integer" },
  "fc_pin" : { "label" : "Pin Code", "type" : "integer" },
  "fc_loan" : { "label" : "Loan Type", "type" : "integer" }
},
"RULES" : [
  { "RULE" : {
      "PROVIDE" : { "result" : { "result1" : "Calculation result", "result" : "Calculation result" } },
      "IF" : [
        { "data_is" : { "data" : [ "fc-home-city" ], "value" : "10" } },
        { "data_is" : { "data" : [ "fc-pin" ], "value" : "5" } },
        { "data_is" : { "data" : [ "fc-loan" ], "value" : "12" } }
      ],
      "DO" : [
        { "data_set" : { "data" : [ "fc-loan" ], "value" : "35" } },
        { "data_set" : { "data" : [ "fc-home-city" ], "value" : "15" } },
        { "data_set" : { "data" : [ "fc-pin" ], "value" : "25" } },
        { "data_calc" : {
            "USING" : { "input_1" : [ "fc-home-city" ], "op" : "+", "input_2" : [ "fc-pin" ] },
            "PROVIDE" : { "result" : { "result1" : "Calculation result" } }
          }
        },
        { "data_calc" : {
            "USING" : { "input_1" : [ "result1" ], "op" : "+", "input_2" : [ "fc-loan" ] },
            "PROVIDE" : { "result" : { "result" : "Calculation result" } }
          }
        }
      ],
      "LABEL" : "Calculate over all "
    }
  }
]

}
}';

$configs['commerce_checkout_order_email'] = rules_import($rule);
echo '<pre>';
print_r($configs['commerce_checkout_order_email'] );

Above code is not working for me. What will be exact solution?


texts: How to output from custom module without rest of theme

texts:
What the proper method of outputting a page from your module without any additional theming beyond your template, for example to make a page that is good for printing?

I've tried a few different methods based on Drupal 7 versions. The only one to work being to render the build array and the kill further PHP loading, however this doesn't feel right. In Drupal 7, I could set up a 'delivery callback' in the hook_menu() - but I can't seem to figure out how to replicate that behaviour now.

my_module.routing.yml:

my_module.user_timesheets:
  path: '/my_module/timesheets/{weekOf}/{uid}'
  defaults:
    _controller: '\Drupal\my_module\Controller\MyModuleAdminController::timesheets'
    _title: 'My Module Timesheets'
  requirements:
    _permission: 'admin'

my_module.module:

  $theme['timesheets'] = [
    'render element' => 'build',
    'template' => 'timesheets',
  ];

MyModuleAdminController.timesheets:

public function timesheets($weekOf, $uid = null) {
    $build['#theme'] = 'timesheets';

    ...code building values...

    $build['#staff'] = $staff;

    $build['#title'] = 'Timesheets - ' . $weekOf . ' to ' . $this->dateService->getWeekStartDate($weekOf);
    $build['#attached']['library'][] = 'my_module/timesheets';
    //print render($build);
    //die();
    return $build;
  }

my_module.libraries.yml:

timesheets:
  css:
    theme:
      lib/timesheets.css: {}

Edit:
   To over-ride something like page.html.twig in your module, you make a template called page--my_module--html.twig and then declare it in your modules my_module_theme() function.

/**
 * Implements hook_theme().
 */
function my_module_theme() {
  $theme['page__my_module__timesheets'] = [
    'template' => 'page--my_module--timesheets',
  ];

   return $theme;
}


texts: How can I print e-mail messages sent by Drupal to the screen for debugging purposes?

texts:
For debugging, I'd like to print the values being used to send e-mail messages to the screen.

After enabling the devel module, I tried this code (modified as per Letharion's comment):

function MY_MODULE_mail_alter(&$message) {
  dpm($message, 'email_test');
}

I don't get any error message, but I don't see any output, either.  How can I print the value of '$message' to the screen?

More details about my site:

I'm trying to debug the e-mails sent upon user registration.  There should be one sent by Drupal itself via the Logintoboggan module and another sent by the Rules module.

Anonymous users have the same permissions as admin to view debug messages; I tested this by adding a dpm() in my page.tpl.php.

I tried setting Display redirection page to on as per Clive's comment but the workflow is unchanged from before.  If I add debug($message) to the MY_MODULE_mail_alter() then debug() will print the message from Drupal/logintoboggan but not the message from Rules.


texts: Selecting First Name of Billing Address in Rules with Data Selector?

texts:
How do I use data selector for Billing Address > First Name in Rules for Commerce?

I want to use the order owner's first name in automatically generated emails.

For example:

  Hey Scott,

  Thanks for your order...


texts:
I have a context set up:

Condition > taxonomy term > vocabulary.

Reaction > some blocks displayed somewhere

This works ok for path like taxonomy/term/term_id but it doesn't work for something like taxonomy/term/term_id_1+term_id_2

Any ideas?
Thanks


texts: How do you add a form to a content type?

texts:
I have a view that had a list of equipment.  Each equipment node in the view needs a form so I can upload equipment drawings.  I would like the form to belong to the node because it makes it easier for submission to understand it's context.  Is there any way to do this?

I have webforms installed and I can create a webform for each node individually, but for some reason I can't find a way to add a webform for the content type.

Thanks!


texts:
Drupal newb here.

I'm trying to rebuild an existing site into the drupal architecture.
For the sake of context, it is a site for a non-profit organisation that wants to make insights in a certain field of scientific research accessible to the general public.
Because the organisation is not large I would like to keep the current structure of the site. Now, my first problem is with creation of a menu item for news item. Clicking on that item is supposed to display news items. That's all I want for now.

What I've been trying to figure out reading pfds, surfing the web, watching videos about menu creation and taxonomy et.. for a little more than a DAY now, what is the best way plant this in Drupal (7.7 by the way)?

1.
 - Create content type called "news item"
 - Create a node using the basic page content type and give as title "News" enter "Latest    news" in the body field
 - Go to admin>structure > Menu and create a menu item and assign
   as path www.domain/news/news item
 - Each time a news item would be created, the author could then choose "News" as parent menu item.

This approach is obviously ignoring taxonomy. But how does one apply taxonomy to this anyway? As I understand, you can't create a vocabulary and then assign a menu item to that vocabulary name itself, simply because there doesn't seem to be a node that represents a vocabulary name. Correct me if I'm wrong(I kind of hope I'm wrong here).

Of course, You could create a vocabulary called "News" but and then one level below          "News" would have to be something like types of news as terms and then use those terms as nodes that I can assign menu items to. The problem is the types of news would be already too granular for the site that I want to rebuild with Drupal. I just want to have a content type newsitems to be children of of a menu item in my main menu called "news".

2. Just create a "content" taxonomy and have terms like News, and About, media, bios as terms (and thus menu items) and branch off from there.

This approach also seems besides the point of what taxonomy is trying to accomplish. The uberparent of any vocabulary is "content" for each and every site on the web anyway and doesn't describe anything at all, so what would be the use making a vocabulary out of it then? But then again, does it have to describe anything just as long is works and would it be a relatively decent "creative" solution?


texts: How to enable configuration translation on custom module

texts:
I wrote a module where I using a form for editing my module's configs. My current goal to be able to translate some of my config field's values with configuration translation. I already implemented the followings:

For the menus:

mymodule.links.menu.yml
mymodule.links.task.yml

For the translation:

mymodule.config_translation.yml
config/schema/mymodule.schema.yml (I indicated also which should be translated and which shouldn't)

I also added language into my config, however, I don't think there's any meaning for it

My current problem is: when I going to my settings page, I go to the translate tab, add a language and that form is totally empty. There's no field listed where I can write anything, just a save button... what am I missing?

config/install/mymodule.mymodulesettings.yml

service_id: ''
normalized: true
success: 'Successfully subscribed!'
langcode: en

config/schema/mymodule.schema.yml

mymodule.mymodulesettings:
  type: config_object
  label: 'Mymodule settings'
  mapping:
    success:
      type: string
      label: 'Success message'
      translatable: true
    normalized:
      type: boolean
      label: 'E-mail address should be normalized?'
      translatable: false
    service_id:
      type: string
      label: 'Service id'
      translatable: false

mymodule.links.menu.yml

mymodule.mymodule_settings_form:
  title: 'Mymodule Settings'
  route_name: mymodule.mymodule_settings_form
  description: 'Configure Mymodule integration'
  parent: system.admin_config_system
  weight: 99

mymodule.links.task.yml

mymodule.mymodule_settings_form_tab:
  base_route: mymodule.mymodule_settings_form
  title: 'Mymodule Settings'
  route_name: mymodule.mymodule_settings_form

mymodule.routing.yml

mymodule.mymodule_settings_form:
  path: '/admin/config/system/mymodule-settings'
  defaults:
    _form: '\Drupal\mymodule\Form\MymoduleSettingsForm'
    _title: 'Mymodule Settings Form'
  requirements:
    _permission: 'manage mymodule settings'
  options:
    _admin_route: TRUE

mymodule.permission.yml

manage mymodule settings:
  title: 'Manage mymodule settings'
  description: 'Allows users to configure mymodule'

mymodule.config_translation.yml

mymodule.mymodule_settings_form:
  title: 'Newsroom Mymodule Form'
  base_route_name: mymodule.mymodule_settings_form
  names:
    - mymodule.mymodulesettings


texts: Red Herring Error : Class name must be valid object or string

texts:
After just having spent two days trying to get to the bottom of a particularly weird bug I thought I'd post up what my question would have been — if I had taken the time to write it — and then post my answer also, just in the hope of helping other people avoid the headache.

  PHP Fatal error: Class name must be a valid object or a string in /includes/common.inc on line 7522

This was the starting point. I got this error — along with a typically pleasant WSOD — after creating a new install of my site on a localhost. The strange thing about it was that I had almost exactly the same setup working on another machine. The code was served by GitHub and so was identical, the database was a direct dump from the original site, php was configured as expected and versions were only a 0.0.5 out (5.3.15 and 5.3.10), both Drupals were version 7.9 ... everything should be working.

What made this weirder still was the fact the site would work directly after a drush rr, however, it would break immediately after a drush cc all, or on refresh.

This led my collegue and I traipsing in circles, debugging common.inc and modules.inc trying to find a clue as to what was going on. What we discovered was that after the reset registry the correct entity_info array was built, but after the clear cache, we only got part of the full entity_info array.

Investigating further we found rather ridiculously that the following code — taken from module.inc — could not find particular functions in particular module files that we knew to exist.

foreach ($list as $module) {
  $include_file = isset($hook_info[$hook]['group']) &&
    module_load_include(
      'inc', $module, $module . '.' . $hook_info[$hook]['group']
    );
  // Since module_hook() may needlessly try to load the include file again,
  // function_exists() is used directly here.
  if (function_exists($module . '_' . $hook)) {
    $implementations[$hook][$module] = $include_file ? $hook_info[$hook]['group'] : FALSE;
  }
}

This could only mean that at the point this code was being executed certain files that should have been included by now, weren't. What made this even more baffling was that if we called the following outside of any of the caching code, it returned the correct entity_info array.

$entity_info = module_invoke_all('entity_info');

This meant that there wasn't anything wrong with the files, it just seemed to be the caching system. To cut a rather long story short, because we didn't have anything modifying the core drupal caching system, we decided to resort to the good old trial and error disable all modules and enable one by one. Great.

This took some time but we managed to whittle everything down to one bespoke module, which we then trial and errored function by function call. Until we got the culprit:

/**
 * Helper function to redirect an actual submit to the ajax handler
 */
function microsites__admin_settings_submit(&$form, &$form_state) {
  return microsites__admin_settings__ajax_button(&$form, &$form_state);
}

So I guess my question — apart from being, what can cause PHP Fatal error: Class name must be a valid object or a string error — would be what out of the above function could cause such a disastrous error, and in such a weird manner?


texts: Remove caching for newly created node and updated page and block for quick access

texts:
I have caching enable. However I wanted my changes to show up without delay.
How can I remove caching for specific :

page like the home page (too dynamic)
blocks any time they are updated
new created node which are not accessible immediately to anonymous because of caching.

DRUPAL_NO_CACHE was added to the specific block code to no avail ...

function mm_video_block_info() {
  $blocks['mm_video_hero'] = array(
  'info' => t('Hero Video'),
  'cache' => DRUPAL_NO_CACHE,
  );
return $blocks;

}


texts: Custom reference field settings in different content types

texts:
I have a field called booked user and two types of content types, event-type-A and event-type-B.

I am referring to the same field from both content types. However, along the process I figured out that I want to have multiple values for this field in event type-A and single value for event-type-B. Initially both had multiple values.

Whenever I change the field settings in one content type, it also changes in the other.

How can I overcome this? Considering that I have content created in type-B and I can not really add a new field to replace that one, cause I will lose all the previous field content for that user.


texts: CKEditor image properties missing using Image resize filter with media 2, WYSIWYGs

texts:
The Ckeditor image properties is missing. I have checked the following:

Clear the cache
Alter the order filtering according to the image resize filter recommendations. recommendations for integrating the filter with ckeditor
See if the permission are ok
The image resize filter does add the link to the original image, but the image is still showing in the original size, not respecting the width and height set.
Upgrade to ckeditor CKEditor 4.0.3
It works fine with full html. Same order for the filtering.

what am I missing?

I am using WYSIWYGs, ckeditor, CKEditor 4.0.3 and media 2.


texts: How can I track a "DatabaseSchemaObjectExistsException" error message?

texts:
How can I track this error message which is shown when I run drush cron in terminal?

example@d565:~/www$ drush/drush cron
WD cron: DatabaseSchemaObjectExistsException: Table field_data_field_product_category already exists. in DatabaseSchema->createTable() (line 657 of /home/example/www/includes/database/schema.inc).

I found this: https://www.drupal.org/node/1594138 but I have not enabled the modules:media and file_entity modules
AFAIK: is not drupal core bug but it could related to any other module, problem is that I don't know which one.
The site is using the Drupal commerce module. It is the Commerce Kickstar distribution.
I just run this to find which module is asking for 'field_data_field_product_category? but get nothing at all:
example@d565:~/www$ grep -Rin 'field_data_field_product_category' *


texts: Adding accessing getSummary within a paragraph

texts:
I'm using the Paragraph module as part of Drupal 8.

I have the following method to load the individual paragraphs when i match on a certain type

  try {
  $query = \Drupal::service('entity.query')->get('paragraph');
  $query->condition('type', $type);
  $paragraph_ids = $query->execute();
} catch (Exception $e) {
  throw new \Exception('cannot get paragraphs of type: ' . $type);
}

subsequent to this, I loop through each $paragraph and check the results of

$paragraph->getSummaryItems()['content']

and filter accordingly.

What i'm looking to do is a more efficient way of filtering the entity by adding an additional condition on the $query
eg

$query = \Drupal::entityQuery('paragraph');
$query->condition('type', $type);
$query->condition($field, $value, $operator);
$paragraph_ids = $query->execute();

whilst this query works fine for a text or integer, i am having some real issues trying to get it to filter when adding a taxonomy term which is associated with the paragraph.

As i know the values i am trying to filter (and can see them in the content of the getSummaryItems()['content'] array), is there a way to add a filter that can give me access to this getSummaryItems()?

Alternatively, is there any documentation to describe how to add a condition to reference a taxonomy term attached to a paragraph?


texts: Changing the path of jQuery to use a CDN instead of the local file system

texts:
I am creating a custom theme and I would like to know how to update the path of jQuery to use a CDN like the following:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

I don't want to use another module. I just want a simple way to change the path of the script.


texts: Build user avatar thumbnails after Drupal 5 to 6 to 7 upgrade

texts:
I'm upgrading a Drupal 5 site with nearly 100,000 accounts to 6 and then 7. After upgrade to 7 is complete I don't see user pictures/avatars displayed with user profiles or with forum posts/comments.

So far, I've confirmed that

User pictures are set to display on posts/comments in the theme's settings.
User pictures for new D7 accounts are stored, generated, and displayed.
New user's pictures are generated and stored in sites/default/files/styles/thumbnails/.
I've tried running drush "drush image-flush" without effect.

How can I force the generation of existing users' picture thumbnails?


texts: How to programmatically create a custom token in a module

texts: How would you go about programmatically creating a token? I wish to add some custom tokens for my module.


texts: Inline css on cck field..where was it set?

texts:
oenter code hereDrupal 6:

I have a form (inherited site) and one field named "Status" shows the word New in red and Production in green.

Inspecting the field in Firebug, the class is generic:

New

and obviously has that inline css. I cannot find where in Drupal or anywhere in the css files where to change that.

I have added a new field "Features" and want to colorize the text that appears as the value but the class is:

.field-item-content

Which is too generic. I don't want to get too complicated with my selectors for browser compatibility and using jquery to tag it seems overkill.

I saw a thing drupal.org about using the field name as the class, but as seen, that class doesn't appear, just the generic class.

So I'm trying to figure out where that inline css could have been added and where I can do the same. It has to be somewhere as in the example, two different words have different colors.


texts: After run the cron sitemap links are not work properly

texts:
After ran the cron i am not getting any error but it did not display the xmlsitemap links properly.please help me what will i do now?

I checked in dblogs, there I got this error:

  You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use
  near 'FROM uc_orders uc_orders WHERE .uid = 1 LIMIT 0, 5' at
  line 2 query: SELECT FROM uc_orders uc_orders WHERE .uid = 1 LIMIT 0,
  5 in
  sites/all/modules/views/includes/view.inc
  on line 807.

Not display the link proprely means:
suppose mysite is www.example.com. In url i typed www.example.com/sitemap.xml under this link i got inncorrect links.


texts:
I have 3 fields.

I've set them with view table, set their labels and they are displaying in this order:

field1 label      field2 label    field3 label

field1 value   field2 value  field3 value

They are in three columns.

How can I set them in this order like on the screenshot?


texts: Save button missing on User Account Edit form

texts:
I have months old problem of missing "Save" button on the user account edit form. Which is annoying to the point that now I have to find the solution.

I don't usually use account edit form since there is only one user. I have updated many modules and different cores but problem always remained there. Right now I am running latest core which is 7.23. And all modules are updated. This is a multilingual website.

Since this problem has appeared I am unable to save any change in any user account. Please have a look on the image attached.
Please help.

Thanks.


texts: Different payment methods for different product types

texts:
Is there a way to have different payment methods available for different product types?

This is my scenario and what I've figured out so far:

I have two product types on my Drupal Commerce site, for selling bus travel passes. One type is just to book the bus pass where you select the date and times (custom line items) for your buss tickets. The other type is for actual payments, where you can choose a buss pass, add additional tours (with custom line items too) and then pay with Paypal.

I am using a customized version of the example payment module, for the booking payment type, and using the Drupal Commerce Paypal module for the actual payments.

What I need is to have the custom booking payment method available for one product type, and the paypal payment method for the other product type.

I have tried to add a condition for the product type and haven't been able to do this. We can add a condition for a particular product, but not for a product type. This would be ideal: https://skitch.com/ipwa/eywxa/add-a-new-condition-chasquibus

What I have done for now is to clone the Paypal rule for each payment product type, and selected that products SKU as a condition. This is not ideal, because if a user has more than one payment product, we get a duplicate Paypal payment method available for each additional payment product on the order. I guess this makes sense since we have a payment method rule for each one.

My solution would be able to have a condition for product type on the payment method rule, or be able to have the four payment products SKUs in a 'Order contains a particular product' condition.


texts:
I have created a custom theme for my website. Now, I've started getting some strange problems.

After installing Profile2 module, I am not getting view & edit option but it work fine if I use Bartik theme.

Another problem is that if an authenticated user logs in, his defalut home page changed to 'user/18' & couldn't able to access front page (as defined in page--front.tpl.php). But this works fine in case of Bartick.

I don't know what did I miss in my new custom theme. Any suggestions?


texts:
I'm trying to use: Memcache API and Integration | Drupal.org w/ my Drupal6 and unable to determinate what am I doing wrong as when I hit memcache.php (MEMCACHE INFO) my Cache Usage shows me 100% of Free.

here is my info:

settings.php

$conf['cache_inc'] = './sites/all/modules/contrib/memcache/memcache.inc';
$conf['memcache_servers'] = array(
        '192.168.52.153:11211' => 'default'
);
$conf['memcache_bins'] = array(
        'cache'         => 'default',
        'cache_filter'  => 'default',
        'cache_menu'    => 'default',
        'cache_page'    => 'default',
        'session'       => 'default',
        'users'         => 'default'
);

drush

 Performance and         Memcache (memcache)                                 Module  Enabled        6.x-1.10
 Performance and         Memcache Admin (memcache_admin)                     Module  Enabled        6.x-1.10

system

# rpm -q php-pecl-memcache memcached
php-pecl-memcache-3.0.5-4.el6.x86_64
memcached-1.4.4-3.el6.x86_64
# service memcached status
memcached (pid  1482) is running...
#

SELinux

# getsebool httpd_can_network_connect_db
httpd_can_network_connect_db --> on
# getsebool httpd_can_network_memcache
httpd_can_network_memcache --> on
#

iptables

# iptables -L -n | grep 11211
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:11211
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           state NEW udp dpt:11211
#

netstat

# netstat -an | grep 11211
tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN
tcp        0      0 :::11211                    :::*                        LISTEN
udp        0      0 0.0.0.0:11211               0.0.0.0:*
udp        0      0 :::11211                    :::*
#


texts:
I have a Drupal 8 multilingual site (Spanish [default], English, Italian and Ukranian).

On admin/config/regional/translate I can translate to Spanish, Italian and Ukranian but not to English.

How can I translate strings to English with this UI?


texts: How to alter query of block inside a panel

texts:
I have a View that contains many blocks. I want to customize the query for a specific block.
I have tried views_query_alter() hook and $view->query->add_where, but in this case the query will be modified for all blocks.

Any idea of how to customize the query using add_where for a specific block?


texts: How to share saved data from 2 different input fields

texts:
This is hard to explain...but i will try.

I want users to be able to input their age in 2 different ways:

Date of birth field (this will display age with computed field)
Age with drop down integer (age from 18-99)

I want the age to be displayed on the same field in the User View Display.

Please ask for clarification if not clear.


texts: Help with basic hook for my first module

texts:
I am having problems with understanding if my hook is activating/running. I have watched and read many things about hooks but until I get something to work I am very confused.

I'm trying to use the hook here:
http://api.drupalcommerce.org/api/Drupal%20Commerce/sites!all!modules!commerce!modules!checkout!commerce_checkout.api.php/function/hook_commerce_checkout_pane_info_alter/DC

/*  Hello World
*/
function commerce_admam_commerce_checkout_pane_info_alter(&$checkout_pane)
{
dpm("hi");
}

All I want to have happen on checkout is to see if that message shows up. I have tried other hooks as well. MY filename is commerce_admam.module and it's enabled in the backend. I can move the dpm() out of the hook and it fires off the message (everywhere though because its running it all the time)


texts: Multiple Entity Reference creation using Services and Autocomplete Widget

texts:
This is in reference to:
Entity Reference create problem with REST server using Services
and
How to use Services to create new node with Entity Reference field?

What if I want to create multiple entity references in a certain field with widget type Autocomplete (not Autocomplete with tagging)?

for example, this doesn't work and results in only the 1st reference being added, not the 2nd reference:

"field_nodes_list": {
    "und": [
        {
            "target_id": "Title (8756)"
        },
        {
            "target_id": "Description (12983)"
        }
    ]
}

I tried using Autocomplete tags style by doing the below, which works, but only if the field is less than 1024 characters. I want to use the non-tag Autocomplete method above to do the same thing:

"field_nodes_list": {
    "und": "Title (8756), Description (12983)"
}


texts: Styling page-wide sections of an arbitrary page

texts:
Normally, the main content container is "centered" so that the page is, by default, not page wide. This works in 95% of the cases.

Except for when design calls for a page-wide section (i.e. centered content, but whose background spans the viewport width) on some arbitrary page. This requires hacks that look like the following, which I'd like to avoid.

// Introduces an uncalled for horizontal scroll bar
.page-wide {
  position: relative;
  left: 50%;
  transform: translate(-50vw);
  width: 100vw;
}

On the other hand, another approach is to keep the main container always page-wide and have the content (types or individual pages), use layouts that do the centering. Works on anything that uses the Layout API but doesn't cover the cases that don't use the Layout API (e.g. system pages like the login screen, user screen).

What's the "canonical" way to do this in Drupal? How does one center content by default, but arbitrarily "break out" of this centering on certain pages without introducing odd hacks?


texts: Hiding a field title label of a field collections field?

texts:
I have created several fields using the field collection module, but I cannot hide one of the field labels (within a collection). I've tried it in the UI and I've tried hiding it programmatically with hook_form_alter, but it continues to be displayed.

Is their a 'trick' to hiding the field labels created by this module? Thanks.


texts: Passing an extra element to $edit array when creating an account

texts:
I added an extra user registration validation critera in my custom module by implementing hook_user

if ('validate' == $op && 'user_register' == $edit['form_id'] && 'account' == $category && !$edit['remote_create_user']) {

    // Is the mail address OK?
    if ($email_in_use) {
    // No, set error on mail form field
    form_set_error('mail', t('Your email address is already associated with a account.'));
    }

I added the !$edit['remote_save'] because I don't want this extra validation if I am creating accounts programmatically. The code I am using to create accounts is

 $form_state['values'] = $account;
    $form_state['values']['pass'] = array(
      'pass1' => $account['pass'],
      'pass2' => $account['pass'],
    );
    $form_state['values']['op'] = t('Create new account');
    $form_state['values']['remote_create_user'] = TRUE;
    $ret = drupal_execute('user_register', $form_state);

As you can see, I tried to add an extra form element called 'remote_save' $form_state['values']['remote_save'] = TRUE;. However, in the hook code above $edit['remote_save'] is empty so I can't use it to stop the extra validation. How can I pass a value from $form_state to the $edit array? Or is there a better way to do this?

EDIT: So I tried to use hook_form_alter with the code below

function module_form_alter(&$form, &$form_state, $form_id)  {
  if ($form_id == 'user_register') {
    $form['remote_create_user'] = array('#type' => 'value', '#value' => FALSE);
  }
}

However this code $form_state['values']['remote_create_user'] = TRUE; which is in a separate module, does not set the value of $edit['remote_create_user']. The value of $edit['remote_create_user'] is still false.


texts: Which table stores info about hook_update_N?

texts: I want to re run same hook_update again. For example hook_update_8005. I am not sure where Drupal put info to track.


texts: Modify widget in Entity Reference field select box?

texts: I am using an Entity Reference field to refer to users in another content type. The default widgets for the field use the User Name as the label for the dropdown, but I'd like to change that to another field from the user profile entity (ideally combining 'first name' and 'last name' fields). I've looked at Entity Reference Views, but it isn't released and I could not get it to work based on available docs.


texts: How to share Redis cache across Drupal servers?

texts:
I have configured 2 Drupal servers to share the same Redis cache. One of the Drupal servers is being used for editors within the local network, the second server is used to serve up guest traffic. However, I noticed that Redis is storing cached based on the host key, so each of the two servers is storing separate keys in Redis.

What Redis configuration would be used to have it share the same keys and either override hostname to a single host or have it not use host as the key?


texts: In my drupal8 site iam using arabic email  for signup,login,forgot password etc.I have get arabic email content.The email content is left aligned.I am using PHP Mailer in my site to sending emails.When i have tried with Mail Systems+Mime Mail+SMTP,then showing an error like "reply-to" is not set.Is there any possible to align arabic email content from right to left using default PHPMailer?


texts: Make a field state change depending on the moderation state field

texts:
I am trying to use the states to change another field depending on the moderation state, I tried this, but didn't catch it.

$form['schedule_publish_date'] ['#states'] =  array(
 'invisible' => array(
  ':input[name="moderation_state"]' => array('value' =>"published"),
 ),

I'm not sure what the correct field name of the moderation state is, this is the source code

      Moderation state
        <select data-drupal-selector="edit-moderation-state-0" aria-describedby="edit-moderation-state-0--description" id="edit-moderation-state-0" name="moderation_state[0]" class="form-select"><option value="draft" selected="selected">Draft</option><option value="needs_review">Needs Review</option><option value="approved_to_be_published">Approved to be published</option><option value="published">Published</option></select>

      The moderation state of this piece of content.


texts: What is the front page path of the Recruiter Distribution?

texts:
I am using the Recruiter distribution and I want to find the path of the front page so as to add it to the 404 redirect settings of the site.
However,there is no panel page as homepage.There is only used the context module that says if path=< front > then etc.Also I tried the path /node with no luck.

So how can I find the path of the homepage?


texts: How can you alter the display of Flag confirmation dialog messages?

texts:
One of the options for Flags is to have the flag automatically accept when the user clicks the link, or you can have it send the user to a confirmation dialog box where they have to click another button to confirm.

The default text for this dialog message is "Flag confirm", with a button to confirm and then a link for "Cancel".

"Flag confirm" is pretty obtuse, is there any way to alter the display of this dialog box? Thanks!


texts: How to use Less and Omega theme together in a right way?

texts:
I know there is a similar question here and I don't mean duplicate. But I have the problem that @ril44 posted in that question.

  Using stylesheets[all][] = example.css.less is problematic. This
  usage, while >generally correct, causes example.css.less to load
  before Omega's stylesheets.

I'm using the method (but not working...)

Create global.css.less in your theme's css folder (important!).
Create a stanza like this in your theme.info file:

    css[global.css.less][name] = My Project styles
    css[global.css.less][description] = LESS CSS stylesheet for My Project.
    css[global.css.less][options][weight] = 10
    settings[alpha_css][global.css.less] = 'global.css.less'


texts:
I am trying to create a navigation with a sub-menu in Drupal 9. I added the top level nav item with and used # as the value for the link, and checked "Show as expanded"
Then I created a new item and chose the Top Level Item as the parent nav.
Top Level Item
Sub Item
On my menu now the Top Level Item has an arrow, but the sub item is not there. And in dev tools under inspector I do not see the code for the sub item.
Is there a step I missed?


texts:
I installed FlexSlider as suggested on the module's in Drupal7. I try to put a slideshow on my home page with no luck. I tried to create the FlexSlider Example content but it does not create a slideshow, but only lists the images.

The FlexSlider libs are version 2.4.

The website is here: http://projects.busoniu.net/

the images are uploaded in the FLEXSLIDER EXAMPLE SLIDESHOW and I didn't upload any of it in the FLEXSLIDER EXAMPLE IMAGE.

I get an error when I try to edit the content:

  Notice: Undefined property: stdClass::$name in flexslider_add() (line
  395 of
  /data/home/buso01/domains/busoniu.net/public_html/projects/sites/all/modules/flexslider/flexslider.module).
  Notice: Undefined property: stdClass::$name in flexslider_add() (line
  398 of
  /data/home/buso01/domains/busoniu.net/public_html/projects/sites/all/modules/flexslider/flexslider.module).

In console chrome I can see this error:

  Uncaught TypeError: undefined is not a
  functionflexslider.load.js?nk4e6d:41 (anonymous
  function)jquery.js?v=1.4.4:34 b.extend.eachjquery.js?v=1.4.4:27
  b.fn.b.eachjquery.once.js?v=1.2:55
  $.fn.onceflexslider.load.js?nk4e6d:34
  _flexslider_initflexslider.load.js?nk4e6d:24 Drupal.behaviors.flexslider.attachdrupal.js?nk4e6d:76 (anonymous
  function)jquery.js?v=1.4.4:33 b.extend.eachdrupal.js?nk4e6d:74
  Drupal.attachBehaviorsdrupal.js?nk4e6d:412 (anonymous
  function)jquery.js?v=1.4.4:30 b.extend.readyjquery.js?v=1.4.4:38 u


texts: Filtering by User Reference with JSON API

texts:
I try to filter some data by User Reference. My problem is, it return me an empty list
"data": []

It only works if the authenticate user own's the data...
My request :
{{url}}/api/node/artist_availability?filter[artist_user.entity:user.id]=user_id

I replace "user_id" with the real data.
I tried a lot of synthaxes :
{{url}}/api/node/artist_availability?filter[artist_user.entity.id]=user_id
{{url}}/api/node/artist_availability?filter[artist_user.id]=user_id
{{url}}/api/node/artist_availability?filter[artist_user.meta.id]=user_id

None of them work.
So my question is : Is it possible to filter by user reference without the current user owning the data ?


texts: How to validate node title field Drupal 7

texts: I want to add validation to the node title field. When the user enters the character X and submits the form they should get a message saying "you are not allowed to enter special character X".


texts: How do you override the add or edit node for a particular content type

texts:
I want to format the editing or adding form for the article content type. i.e. node/add/article path and editing the same article.
I copied over the node-edit-form.html.twig template from core/modules/node/template and renamed it node-edit-form--article.html.twig.
I also tried node--article-edit-form.html.twig and some other flavors.
I can override the node.html.twig file by simply copying it to my themes template folder.
But since I couldn't get the edit file to work I also tried overriding the form alter function by adding this in my theme file.

use Drupal\Core\Form\FormStateInterface;

function newsass_form_node_form_alter(&$form, FormStateInterface
$form_state) {
  $form['#theme'] = ['node_edit_form'];
}

This code is from here-
How to override node add template for custom content type?

I added some text on top of the code, but I still can't get the article 'edit' or article 'add' page to display the text.

Drupal 8.6.1, and have debugging enabled. Full explanation of requirement: I have a user entity reference field in the article content type with a list of users that the article can be assigned to. For the most part they have an 'article' role. But if the person leaves, their role will be changed to 'Away'. The article can/will still be assigned to them but I need to indicate that they are no longer with the company or 'Away'.
Within views entity reference I am able to re-write the user with the users role but this information doesn't get back to the entity reference field in the editing node.
I thought of editing the article node and adding a hook to call the assigned users role..... Which I still need to figure out how to do.
With debugging I tried suggested template page--node--add--article.html.twig but I still couldn't get the content revealed and yes I cleared cache. Using page level though doesn't allow granularity for each field.

QUESTION: By mytype is that the machine name of the entity reference field in the content type? I am also not quite understanding this function, where is the call to query the roles? I enabled kint and added this to the function.

kint($elements); die();

but get nothing returned. How do I check if this function is actually being called.
I tried something else also. I have users in the entity reference and in the entity reference views for users I added the roles, made them hidden and rewrote the users to include the roles. I works nicely in the views preview, but the roles detail doesn't get carried back to the content type add/edit pages.


texts: How does the register form in the user module load ImageWidget?

texts:
I want to use the user picture widget on the user register form to capture an image. So for my custom entity form I'm using the managed_file as such
modules/custom_module/src/CustomEntityForm.php

public function form(array $form, FormStateInterface $form_state) {
      $form['deal']['image'] = array(
          '#type' => 'managed_file',
...

the above code does not add the widget as seen on the register form, i.e  It does not have the preview functionality widget which I think it comes from the image widget.

This line seems to be responsible for the output of the widget on the register form
ContentEntityForm.php Line 122

public function form(array $form, FormStateInterface $form_state) {
$this->getFormDisplay($form_state)->buildForm($this->entity, $form, $form_state);

after buildForm() the $form array has a new inner array keyed 'user_picture'. This is var_dump

 'user_picture' =>
    array (size=7)
      '#type' => string 'container' (length=9)
      '#parents' =>
        array (size=1)
          0 => string 'user_picture_wrapper' (length=20)
      '#attributes' =>
        array (size=1)
          'class' =>
            array (size=3)
              ...
      'widget' =>
        array (size=6)
          0 =>
            array (size=28)
              ...
          '#after_build' =>
            array (size=1)
              ...
          '#field_name' => string 'user_picture' (length=12)
          '#field_parents' =>
            array (size=0)
              ...
          '#parents' =>
            array (size=1)
              ...
          '#tree' => boolean true
      '#access' => boolean true
      '#weight' => int -1
      '#cache' =>

this is way up in the core code. how does the user module configure all this to use imageWidget?  Do I need to configure something for EntityFormDsiplay?


texts: Modifying creation and edit date of nodes by using Views Bulk Operations

texts:
I use Views Bulk Operations (with Views 7.x-3.x-dev) to modify my nodes. I need to edit the created and edited on dates of the nodes. I checked bulk operations field, but I couldn't find the related fields.

Is it possible to edit these dates with VBO?


texts: Recover content from a deleted user and assign ownership to other user

texts:
There is a user that needs to be deleted but I need to keep his content. I want to know if there's a way to transfer the ownership of all of his content (nodes, userpoints, etc.) to another user? I tried views bulk operations, but there is no option there.

I know that I can delete the user and keep the content and give it to the Drupal anonymous user, but it´s possible to set up an specific user?


texts: Can I connect to MySQL Fabric managed nodes?

texts: How can Drupal application make use of MySQL Fabric setup using one of the provided connectors from MySQL?