texts: Set All Day checkbox on date field programmatically

texts:
I am importing events from an iCal feed and have managed to get everything working great except for events that take place all day. Currently they are coming in and defaulting to a xx/xx/xxxx 7:00pm to xx/xx +1/xxxx 7:00pm date when they should fall on the same day without a time. I've tried hardcoding 00:00:00 as the time but that get's ignored. I've also made sure that there are no default time settings on the field.

There is a checkbox for All Day but nothing seems to mark it as checked while I'm trying to create the node and it doesn't appear to be saved in the node object anywhere so not sure how I am suppose to set the checkbox while I'm creating the node.

Current code I am using while looping through each of the events in the feed:

// Use the UID to look up existing events.
if(!in_array($uid, $uids)){

    if(strtotime($startDt->format ( 'm/d/Y h:ia' )) > strtotime("-1 month")){
        try {
            $node = new stdClass();
            $node->type = "calendar_event";
            $node->uid = 1;
            $node->language = 'en';
            $node->title = $eventName;
            $node->body['und'][0]['value'] = stripslashes($eventLocation);
            $node->body['und'][0]['format'] = 'full_html';
            $node->field_uid['und'][0]['value'] = $uid;
            $node->field_date['und'][0]['value'] = $startCom;
            $node->field_date['und'][0]['value2'] = $endCom;

            // this doesn't work
            $node->field_date['und'][0]['all_day'] = 1;

            $node->status = 1;
            node_save($node);

            $values = array(
                'entity_type' => 'node',
                'entity' => $node->nid,
                'state' => OG_STATE_ACTIVE,
                'membership_type' => OG_MEMBERSHIP_TYPE_DEFAULT,
                'field_name' => 'og_group_ref'
            );
            og_group('node', $groupID, $values);
            $newCount++;
        } catch (Exception $e) {
            watchdog_exception('school_calendar', $e);
        }
    }
} else { // uid existed, maybe we want to update if needed.
}


texts: Set restriction on user by country for language translation content

texts:
How do I restrict individual user by country to see a restricted list of languages
in the Internationalization module? For example, I would like to restrict users from China, to see only Chinese translations.

I'm trying to get the country by global $user; but it is not working.


texts:
I have a view that I want to create a view template for in my theme.

So, I have created: views-view--homepage-suppliers.tpl.php

I have then several content items of content type: Supplier that the view uses.

The have various fileds, such as title, field_supplier_image

How do i then access these fields in this view template?

Is it something along the lines of:

$rows['field_supplier_image']?

thanks


texts: Node-insert check and alter value of other entities

texts:
I have a site I'm building where the admin can add sale "specials" (sales) to a store.  So there's the store content type - and the sales are entity references appended to the store.

Each "special/sale" has a start/stop date - naturally.

What the client would like to have is for the system to (upon insert of the new node) adjust the other sale dates if they conflict.

So imagine there's:

Sale 1: 1-01-2015 -> 1-15-2015
Sale 2: 1-16-2015 -> 1-30-2015

And now they insert a new sale with the dates of 1-13-2015 -> 1-25-2015

They'd like the end result to be where previously created sales 1 and 2 are now adjusted to:

Sale 1: 1-01-2015 -> 1-12-2015
Sale 2: 1-26-2015 -> 1-30-2015
(new Sale 3): 1-13-2015 -> 1-25-2015

How would I best go about doing that (checking other attached entity references and adjusting the date ranges for them).

Thanks!


texts: I'm migrating two blogs from WordPress to Drupal 7. How would one handle migrating user subscriptions from the WordPress blogs? I've already used the Migrate module and it looks like that only handles content.


texts: form field of type managed file cause error:- EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()

texts:
$form['field_image'] = array(
'#type' => 'managed_file',
'#name' => 'field_image',
'#title' => t('Block image'),

//  '#description' => t("Image should be less than 400 pixels wide and in JPG format."),
    '#upload_location' => 'public://',
  );


texts: How to bulk edit and save content drupal 8?

texts:
I have more than 80K nodes in drupal, I just want to open edit page and then save node. I want to change body content and add some common value to all of them.
How can I achieve this in drupal 8.


texts: How to map multiple existing term IDs to an entity

texts:
I'm trying to map multiple existing terms using their target_id values to an entity (Commerce Product) and I can only get the first value to map.

My yml file looks like this:

  'field_prod_category/target_id':
    plugin: explode
    source: tid
    delimiter: ','

And, for now, I'm hard coding two existing term ID values in through the source plugin like so:

$row->setSourceProperty('tid', '806,635');

But no matter what I try only the first term is referenced. And, yes, the term field is set to unlimited.

Any ideas?


texts: Field collection: Can I make a field mandatory depending on another field's value?

texts:
I'm trying to set up a custom solution using Field Collection consisting of:

term reference (autocomplete tagging style)
plain text.

What I need to achieve is to react to Javascript event of autocomplete (but only for that field) and - if the selected term title contains a string placeholder %1 - make the plain text mandatory, so that user is force to enter the substitution text.

Is that technically possible or would it require setting up a custom collection from scratch?


texts: Syntax highlighting for admin-side text areas (during node or block editing)

texts:
I'm trying to find a module that will highlight HTML (and preferably CSS/JavaScript inside of style/script tags, but that's an added bonus) when I'm editing a node or block in the administrative side of Drupal.

While I've searched on drupal.org for syntax highlighting modules and come across options like GeSHi and Syntax Highlighter, both of those seem to be for the public-facing end content and not the administrative side. Am I wrong and would one be suitable for me? I've also seen a few projects that highlight PHP code blocks, but that's less important to me than HTML/CSS/JavaScript.

I never use a WYSIWYG editor for my own HTML but some highlighting would be very helpful in editing my content.


texts: Seamless Responsive Photo Grid with Omega

texts:
I'm trying to create a responsive full screen gallery based on quite a simple idea, but without success. Idea is to have full screen view of many pictures that are adapting to screen resolution responsively.

The idea you can see here: http://css-tricks.com/seamless-responsive-photo-grid/

I'm working on D7.20, Omega 3.x

And what I want to do is to have content type, let's say, "picture" and create a view, which is displayed in a fluid full screen layout and is shown in such a way like in a given example.

But no success, it looks like it should be simple, but I cannot manage to understand how should I change the CSS to make it work...

It is probably possible to make similar effect using jQuery Masonry module, but I would like to do this with only CSS.


texts:
I'm in Drupal 7. I would like to execute an ajax function in my front-page. I've defined the block view in my ".module" file. When I change the selected option, the log gets two errors:

1.

  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'test_services_search_form' not found or invalid function name in drupal_retrieve_form() (line 842 of /var/www/html/test/html/includes/form.inc).

2.

  Notice: Undefined index: test_services_search_form in drupal_retrieve_form() (line 807 of /var/www/html/test/html/includes/form.inc).

test.module

function test_services_block_info() {
  $blocks['test_services_search_form'] = [
    'info' => t('Plan your trip'),
  ];
  return $blocks;
}

function test_services_block_view($delta = '') {
  $block = [];
  switch ($delta) {
    case 'test_services_search_form':
      module_load_include('inc', 'test_services', 'includes/test');
      $form             = drupal_get_form('test_services_search_form');
      $block['content'] = render($form);
      break;
  }
  return $block;
}

test.inc

<?php

/**
 * @file
 * TEST - File search inc.
 */

/**
 * Implements hook_form().
 */
function test_services_search_form($form, &$form_state) {
  $form['search'] = [
    '#type' => 'container',
  ];

  // Transfer.
  $form['search']['transfer'] = [
    '#ajax'       => [
      'callback' => 'test_services_search_transfer_callback',
    ],
    '#attributes' => [
      'class'    => ['js-select2', 'cancel'],
      'required' => TRUE,
    ],
    '#title'      => t('Transfer'),
    '#options'    => [
      0 => t('Direct trip'),
      1 => t('Stopover trip'),
    ],
    '#type'       => 'select',
  ];

  return $form;
}

/**
 * Callback handler for the direct/transfer trip select.
 */
function test_services_search_transfer_callback($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
}

/**
 * Callback function.
 */
function test_services_search_form_callback($form, &$form_state) {
  return $form;
}

The point is disable three fields if option two is selected, It's possible execute AJAX into a block view, and if so, what is going on? Why Drupal is not going into the function of the AJAX callback?


texts: Display all associated tags from content page

texts: I have found many similar questions, but not quite the right way around. I have a large number of tags that are associated with multiple content pages. When viewing these content pages you can only see the parent term, and not its children terms, which are equally as important. How can I display the entire list of terms, and not just the parent term in a content view?


texts: How should I balance Features and Installation Profile in a Code Driven Development workflow?

texts:
Drupal Installation Profiles (in Drupal 7) are pretty powerful and can do just about anything a module can do. I'm using an Installation Profile along with Features to develop my site, keeping everything in code so I don't have to version my database.

Given the power of Installation Profiles, many of the things you can do in a Features module can also be done in an Installation Profile. E.g., creating content types, configuring permissions, etc. How should you go about deciding whether something belongs in an Installation Profile or in a Features module when using a Code Driven Development workflow in Drupal?


texts: How to display a comma-separated list of multiple field values?

texts: How can I render for example each taxonomy terms value as an inline comma-separated list (or add between each of them a "/" Character) in my field template field--node--field-tags.html.twig file or even visually with css?


texts: Display a field of a node that is referenced on another node via a relationship

texts:
I have two content types, "Stores" and "Offers." In the "Offers" content type, there is a CCK node reference field type that references the "Stores" nodes.  So essentially, I create a store and if the store has an offer, I create the "Offer" node and select the store with which it is associated.

I have a view (a default glossary view) that displays a list of stores. I would like to display the node titles of any offers that are associated with it but I can't figure out how to do it.

I have tried to add a relationship on the node reference field then add a field that uses the relationship but the result just appears blank.


texts:
Can someone kindly tell me how to filter the webform results page? For example how can I show only the submissions where column X has value Y.

I am new to drupal but I am an experienced PHP programmer. If someone kindly points out he right webform hooks I will try to figure out the rest.

Suprisingly, google could not help me. But I'm sure that others have faced the same problem before. Please assist.


texts: Using form_set_value with commerce in custom form

texts:
I'm trying to change the value of a form within a custom Commerce Pane during validation but I get the following error:

  Recoverable fatal error: Argument 2 passed to drupal_array_set_nested_value() must be an array, string given, called in /var/www/vhosts/innovista.org/httpdocs/includes/form.inc on line 2514 and defined in drupal_array_set_nested_value() (line 6440 of /var/www/vhosts/innovista.org/httpdocs/includes/common.inc).

As far as I see my code is an array.

form_set_value($form_state['values'][$checkout_pane['pane_id']]['donation_amount'], array('und' => array(0 => array('value' => '999'))), $form_state);

I've been using $checkout_pane['pane_id'] . '][donation_amount' with form_set_error(), and it works fine. I can't understand why argument 2 is not working.

I have tried setting #parents as this question suggests:
Using form_set_value() in Drupal 7

In the following way:

$form_state['values'][$checkout_pane['pane_id']]['donation_amount']['#parents'] = array( 'values',$checkout_pane['pane_id'], 'donation_amount');

But this produces an extra error:

  Notice: Array to string conversion in
  donation_checkout_pane_pane_checkout_form_validate() (line 186 of
  /var/www/vhosts/innovista.org/httpdocs/sites/all/modules/donation_checkout_pane/donation_checkout_pane.module).

Do you have any idea?


texts: Custom field widget: hook_field_is_empty()

texts:
I'm creating a custom module that has implemented these hooks:

<?php
/**
 * Implements hook_field_widget_info().
 */
function MYMODULE_field_hook_info() {
  return array(
    'CUSTOM_field' => array(
      'label' => t('Custom Text Area'),
      'field_types' => array('text_long'),
      'behaviors' => array(
        'multiple values' => FIELD_BEHAVIOR_DEFAULT,
        'default value' => FIELD_BEHAVIOR_DEFAULT,
      ),
    ),
  );
}

/**
 * Implements hook_field_widget_form().
 */
function MYMODULE_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  switch($instance['widget']['type']) {
    case 'CUSTOM_field':
      $element['MYFIELD_field'] = array(
        '#type' => 'textarea',
        '#attributes' => array('id' => 'MYFIELD', 'rows' => '5', 'cols' => '3'),
        '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
      );
      break;
  }
  return array('value' => $element);
}

All it is supposed to do is provide a custom widget to the Long Text field type that enables some custom functionality. My custom widget appears in manage fields and I can enable it and use it on a node edit form. However, when I save the node with text in the field, nothing saves to the database the data saves to the database, but doesn't display in the field when the node is edited again.

After some searching, I found some posts that said hook_field_is_empty() is mandatory and is a common problem for values not saving. I attempted to implement the hook exactly as the API said:

<?php
/**
 * Implements hook_field_is_empty().
 */
function MYMODULE_field_is_empty($item, $field) {
  if (empty($item['value']) && (string) $item['value'] !== '0') {
    return TRUE;
  }
  return FALSE;
}

This immediately started throwing an error in Drupal:

  Warning: htmlspecialchars() expects parameter 1 to be string, array given in check_plain() (line 1573 of /includes/bootstrap.inc).

So I looked around some more on here and Google and changed the hook based on this answer:

<?php
/**
 * Implements hook_field_is_empty().
 */
function MYMODULE_field_is_empty($item, $field) {
  if ($field['type'] == 'text_long') {
    if (empty($item[$field['type']]['CUSTOM_field'])) {
      return TRUE;
    }
  }
  return FALSE;
}

This returns the same error and it also doesn't save the value of the field into the database display the field data from the database. Do I have to create a custom field with a MYMODULE.install and the appropriate hooks, or can I just use an existing field type like I'm doing. Why is the data not saving to pulling from the database?


texts: How to migrate files into a field with unlimited values (D6 -> D7)

texts:
I am currently migrating a D6 site into D7 and so far everything has gone smoothly. I use migrate and migrate_d2d.

But now I am stuck :-(. I have an image field with unlimited values (a slideshow) and into that field I need to import images from the corresponding slideshow in the legacy site. My problem is that after import only one image is imported (the last one in the slideshow). How do I make every picture end up in its own subfield?
In my prepareRow() I am trying to use the loop below. I fetch the field ID from $row->fields_productimages[#] (index > 2 are field ID's that belong to the slideshow). I then get the file path from the legacy database and use that path to import the image. But as I said, only the last image is attached to my field.
There are no error messages. Any help is appreciated.

$i = 2;
if($row->field_productimages[$i] != ''){
    while($row->field_productimages[$i] != ''){
        $fid = $row->field_productimages[$i];
        $filepath = Database::getConnection($target='default', $key='legacy')->query('SELECT f.filepath FROM {files} f WHERE f.fid = :fid',array(':fid' => $fid))->fetchAssoc();
        $this->addFieldMapping('field_bildspel_instrument')->defaultValue($filepath);
        $this->addFieldMapping('source_dir')->defaultValue('http://www.mysite.se/');
        $this->addFieldMapping('destination_dir')->defaultValue('public://instrument/bildspel');
        $this->addFieldMapping('field_bildspel_instrument:file_replace')->defaultValue('FILE_EXISTS_REPLACE');
        $this->addFieldMapping('field_bildspel_instrument:file_class')->defaultValue('MigrateFileUri');
        $this->addFieldMapping('field_bildspel_instrument:title', 'field_sensorimage:title');
        $this->addFieldMapping('field_bildspel_instrument:preserve_files')->defaultValue(1);
        $this->addFieldMapping('field_bildspel_instrument:urlencode')->defaultValue(1);
        $i++;
    }
}


texts:
I have 3 content types: "Files", "Actions" and "Templates".

In each "Files" node there's a entity reference to an "Actions" node
In each "Templates" node there' a entity reference to an "Actions" node

How can I setup a view that shows a list of links to "Templates" nodes on a "Files" node page, based on the entity reference to an "Actions" node for this specific "Files" node?

Edit - I couldnt get Felix' answer to work, so here's a more detailed description of my case:

I have a node called "BAG001", this node has content type "Files.
I have a node called "Procedure A1", this node has content type "Actions"
I have a node called "Form A1", this node has content type "Templates"

In "BAG001" I make an entity reference to "Procedure A1" (field name is "field_action")
In "Form A1" I make an entity reference to "Procedure A1" (field name is "field_related_action")

On the "BAG001" page there's should be a views generated block, showing all templates related to "Procedure A1". In this case that would be "Form A1".

I tried setting up a view using the following settings:

1) Relationship -> Entity reference: field_action
2) Relationship -> (Content entity referenced from field_action) Entity Reference: Referencing Entity [with a relationship to (1)]
3) Contextual filter -> Content: NID [with a relationship to (2)]


texts: I'm looking for the best way to programmatically hide a block. In Drupal 6 I'd normally use preprocess_block to do all my logic and then unset title and content/body from there. I've tried to do same thing in Drupal 7 but failed. What's the correct way of doing this? I'd like to avoid editing the settings through the UI as this change has to be deployed in code rather than database.


texts: Get Node ID in hook_field_formatter_view()

texts:
I'm currently working in a custom video player. For that I've created a content type which uses a field_collection (for the video file and other stuff) and a field_caption for a XML file.

The video file field uses a custom field formatter, which I'm using to theme up the player. I need the field_caption file to be added there so I'm trying to get the node id of the field_section Field Collection in the hook_field_formatter_view() to get that info....with no luck!

If I print $entity->vid from the function parameters I will have NULL, because the field is within a field_section I believe.

Is there a way round this?

Thanks in advance!


texts: How to theme each nodes in a taxonomy term page seperately in drupal 7

texts: I know there are many similar questions but none of them gave me a correct solution for my particular requirement. In drupal 7 in taxonomy term page nodes are displayed as a row of nodes one below another. But I want the first node to be displayed with a bigger image in the first row and the rest of the nodes as two nodes per row. How can i do that programmatically.


texts: How to modify field value in other nodes after node update?

texts:
After node update I need to modify a field value in several connected nodes.
As I know, I cannot use hook_entity_update() since $node->save() forms infinite recursion.
How can I modify node fields after a node has been updated? (besides hook_cron)


texts: what actions to take when someone uploaded php files in random drupal folders and sending out spam

texts:
I'm not sure how this happened, but my server techs notified me about some php files inside the includes folder sending out 50k worth of emails. I'm not sure how anyone would be able to upload that. I doubt its because my username/password was compromised for the domain. im finding these files littered through out the directories: http://prntscr.com/rhf93

In those files they contain all similar encoded php code:

http://prntscr.com/rgzmo

http://prntscr.com/rhfmq

Does anyone know what its doing or how i can decipher the code? And most of all how was it uploaded?


texts: Permission for private file to anonymous

texts:
I have an ad content type, with a file field that is in a private directory when saving the node.

Ads and their files are only accesible for authenticated users.

I wish I could allow anonymous users to see ads and their files that are promoted.

I use content_access module

I want programmaticly, change acces control foreach ads who is promoted and I don't how to achieve that.


texts:
How can I show Node Hits (Statistics_Counter) in Drupal 8 in a specific place?
I enabled statistics module and I now want to show user hits of a node (node view number/node visits count) in the submitted area instead of in the node links area.

I do this already in Drupal 7 with below code in node.tpl.php:

<?php print (int) $content['links']['statistics']['#links']['statistics_counter']['title']; ?>

What is the equivalent code for Drupal 8?


texts:
I am building a partially decoupled Drupal 8 site.  Drupal hosts all the content, but I also built mobile apps and a webapp in Ionic.  The mobile apps are working fine, and now I want to host the webapp on my Drupal site.
I want my Ionic app to take over all the paths from /webapp/*, and these should all redirect to Ionic's index.html and then be passed the relevant argument from the URL.
Before I made the Ionic app, I had a React app, which I embedded into Drupal as follows.
This is the code I am using.
MY_MODULE/src/Controller/PageController.php
  public function reactApp() {
    return [
      '#markup' => '

',
      '#attached' => [
        'library' => [
          'MY_THEME/react_app',
        ],
      ],
    ];
  }

MY_MODULE/MY_MODULE.routing.yml
MY_MODULE.myreactapp:
  path: '/webapp/{react_route}'
  defaults:
    _controller: '\Drupal\MY_MODULE\Controller\PageController::reactApp'
    _title: 'React App'
  react_route: ''
  requirements:
    _permission: 'access content'

MY_THEME.libraries.yml
react_app:
  version: VERSION
  js:
    js/dist/main.min.js: {minified: true}

This worked great for embedding a simple react app and giving it all the routes at /webapp/*.
However, a webapp built in Ionic generates an index.html that looks like this.
<!doctype html>

  <meta charset="utf-8"/>
  <title>Ionic App</title>
  <base href="/"/>
  <meta name="color-scheme" content="light dark"/>
  <meta name="viewport"
        content="viewport-fit=cover,width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  <meta name="format-detection" content="telephone=no"/>
  <meta name="msapplication-tap-highlight" content="no"/>
  <link rel="manifest" href="/manifest.json"/>
  <link rel="shortcut icon" type="image/png" href="/assets/icon/favicon.png"/>
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <meta name="apple-mobile-web-app-title" content="Ionic App"/>
  <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
  <link href="/static/css/4.21302a68.chunk.css" rel="stylesheet">
  <link href="/static/css/main.1d86f075.chunk.css" rel="stylesheet">

What I want to do

Put all the ionic build assets in a subdirectory (/webapp) inside my Drupal site (done).
Tell Drupal to redirect all requests to (/webapp) to Ionic's index.html. (how do I do this?)

I thought of using a theme hook, but I don't know how to add all the scripts and css in Ionic's index.html to the twig template.
If possible, I don't want to hard-code the Ionic script assets inside Drupal because the names will change every time the app is built, which will be often.


texts: Wrong dates in views 'Content: Created year + month' contextual filter

texts:
I have a view into which I'm trying to link to nodes via the date in the 'Authored on' date of that node.

I'm creating the nodes from another site and am wanting to reuse the dates upon which they were originally posted. In effect, I'm creating new nodes with dates from the past in the 'Authored on' field on each node.

I want to create a view block based upon the 'Authored on' date from the node, that groups the nodes by month. eg:

March 2015 (1)
February 2015 (3)
December 2014 (4)

etc...

I can create the view block with a Contextual filter of 'Content: Created year + month'

Display Summary
Sort order: descending
Sort by: date
Format: list
Display record count with link: checked

This all works fine, but the links that are created when I use this view block don't go to the posts in question, they simply return me to the entire list of nodes that make up this content type.

Do the link with the contextual filter 'Content: Created year + month' actually refer to the 'Authored on' date from the node?

Any thoughts would be really welcome.


texts: How do call the template for a module block

texts:
My goal is create a custom block that uses a twig template that you can pass info to via the theme function like so.

  public function build() {
    return array(
      '#type' => 'markup',
      '#markup' => $this->siteContent(),
    );
  }

  public function siteContent() {

    $source_text = some_function_returning_html_from_user();

    return array(
      '#theme' => 'scadfashblock',
      '#source_text' => $source_text,
    );
  }

I got the above code from a tutorial trying to render a template file for a custom page. The problem is this code throws an error saying that an array can't be returned this way, it must be a string.

I even tried doing it the drupal 7 way...

  public function build() {
    return array(
      '#type' => 'markup',
      '#markup' => $this->siteContent(),
    );
  }

  private function siteContent() {

    $output = array();
    $output['source_text'] = some_function_returning_html_from_user();

    return theme('scadfashblock', $output);
  }

This throws an error:

  Call to undefined function Drupal\<module>\Plugin\Block\theme()


texts: Commerce License not de-activating when expired

texts:
I'm using commerce license on one of my website. And I found out that some of the licenses that are expired didn't get de-activated.

As you can see, in the image below. License 113, 114, 115 should be inactive. But they are still Active (Actief). In the last column you will see that the expiring dates are past today (08/22/2016).

Using the modules Ultimate Cron and View Queue I'm able to see that the Commerce License module is adding the queue.

I also look in my logs but no errors are found. Does anybody know what the problem can be or what my next step in searching for the problem can be?

Thanks in advance,
Zeb


texts: Override Field.tpl.php for a specific node/add form

texts:
Basic Question

In Drupal 7, you can override all the fields of a specific content type by changing the field.tpl.php file name to field--YOUR_CONTENT_TYPE.tpl.php

How can you override the fields that appear on the "node add form" for a content type?

More Info

I am using Drupal Commerce Bulk Product Creation and with this module you create your nodes at yoursite.com/admin/commerce/products/add-bulk/PRODUCT_TYPE.

I want to over-ride the field.tpl.php file for this name, but I am not sure how to do it.

I know you can override the node.tpl.php for this "node add form" by using the following in your template.php file:

function YOURTHEME_theme($existing, $type, $theme, $path) {
    return array(
        'commerce_bpc_create_bulk_form' => array(
            'arguments' => array('form' => NULL),
            'template' => 'templates/add/node--add--bpc',
            'render element' => 'form',
            ),
    );
}

Is there a similar code that can be used to override the field.tpl.php file for this node add form?


texts:
On the /user page i've created two tabs:

function hook_menu() {

    $items['user/%/My-Courses'] = array(
        'title' => 'My Courses',
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'drupal_get_form',
        'page arguments' => array('hook_form'),
        'access callback' => 'hook_access',
        'access arguments' => array('access content'),
    );

    $items['user/%/Privacy-Statement'] = array(
        'title' => 'Privacy Statement',
        'type' => MENU_LOCAL_TASK,
        'page callback' => 'drupal_get_form',
        'page arguments' => array('hook_form'),
        'access callback' => 'hook_access',
        'access arguments' => array('access content'),
    );

    return $items;
}

What i'm trying to do is add a link to the my courses tab, and a privacy statement (just text) to the privacy statement tab.

function hook_form(){

$form['privacy'] = array(
    '#type' => 'textfield',
    '#value' => 'Privacy statement',
  );

 // returns whatever you want to appear in that tab.
 $form['link1'] = array(
     '#type' => 'submit',
     '#value' => t('This will show the customers courses.'),
 );

 return $form;
}

The problem is that it's adding both the link and statement to both tabs.

How would I go about targeting each tab individually?


texts: How do I disable tooltips for field help text in Bootstrap?

texts: On the user registration page, my help text for fields is displayed as pop-up text when I use the Bootstrap theme, but this doesn't work well on mobile devices, and most of my users are visiting through their phones.  How do I get rid of the tooltips?


texts:
I moved a drupal installation from one server to another.
Steps I followed:

Copied whole directory structure from old server.
Exported database from old server.
added files to newdomain/drupal
Imported database
edited settings.php with new database information.

As of right now the home page is working (Except for some broken non-db images, but I know the reason for that and can fix it) But none of the links to any of the nodes or any of the admin paths I know seem to exist. I get a 404 File Not Found error.

I wonder if it's related to the fact that this installation is in a subdirectory and the other one was not, but is that enough to make every page except the homepage not function?


texts: Importing products via Feeds csv import is generating error: "General error: 1366 Incorrect string value:"

texts:
I'm trying to import products using the import via csv functionality within feeds and am getting the following errors:

SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xB7 The ...' for column 'field_description_value' at row 1
Error message SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xB7 The ...' for column 'message' at row 1

I also have the commerce-feeds module installed.

There is quite a lot of stuff on this on drupal.org, but it all seems to be contradictory and I am more than a little lost. I am a non-coder and a relatively inexperienced configurator at best.

My csv is definitely encoded UTF-8. I have opened it in Notepad++ and converted it to UTF-8.

I found this post on stack overflow utf-8 database problem The line "It seems your connection is not set to UTF8 but some other 8 bit encoding like ISO Latin" seems to indicate to me that there may be a bug in the Feeds or Commerce Feeds modules in that the database connection cannot cope with csv input files encoded UTF-8. Could that be correct?

I'd really appreciate some sage advice on this. I am completely stuck.


texts: Node referencing: How do you display a node with all its references?

texts:
Ingredients:

Drupal7 + References + Views module installed
2 content types: magazine issue + magazine articles (for each issue)
Article c-type has a reference field: issue_no which displays the
issue it belongs
I made a Views to display me a plain list of issues only.

Requirements

When I click on the issue in the issue list I want to see all its references nodes(=articles) attached
I need to highlight the latest issue in the list by creating a separate page VIEW on the frontpage that contains articles of the latest view.

I would appreciate any help.

Here is a prinscreen on my content type > manage display


texts:
We are converting all of our images to the image type provided by media.  What I don't really understand is that there seem to be multiple ways to do this.  Am I supposed to give the 'image' media type a file field, and then use that?  Or, should I give the 'image' media type a 'file' media type field, and use that?  Or, is there something I'm missing and the 'image' media type already has support for images?

Based on my understanding, you're supposed to create a file field in the 'image' media type, and then you use that as the source.  Is that right?


texts:
On the checkout process, I have two payment option. When I select the other payment method, the default is still showing. And If I proceed the checkout it goes directly to the completion page without the payment validation. It was working before, what could have changed ?

Thanks


texts: How to convert date/time from timezone to another timezone in migration process

texts:
I'm using format_date process plugin to import data from external API to drupal 8 node.
The date/time in API is "Asia/Jerusalem" time - 2017-06-24 20:52:55
The date/time from the API is saved in drupal node as it was a UTC 2017-06-24T20:52:55
When the node is displayed (I have "Asia/Jerusalem" timezone defined for me) it shows 2017-06-24 23:52:55

This is the configuration file I used

source:
  fields:
    -
      name: status_updated
      label: 'Status updated'
      selector: status_updated
destination:
  plugin: 'entity:node'
process:
  field_ext_status_updated:
    plugin: format_date
    from_format: 'Y-m-d H:i:s'
    to_format: 'Y-m-d\TH:i:s'
    #timezone: 'Asia/Jerusalem'
    settings:
     validate_format: false
    source: status_updated

I need either to convert the source date first from "Asia/Jerusalem" to "UTC" and then pass it to format_date or change the configuration file in way that it will save the date as 2017-06-24T17:52:55so for users with timezone "Asia/Jerusalem" it will show the correct date/time 2017-06-24 20:52:55

How can I achieve it?
removing the comment for timezone: 'Asia/Jerusalem' not helped


texts: Empty view is rendered even though there is no result

texts:
I have created a view in order to create a block for slide show in drupal 7.
In my view I used a conditional field. This field gets the id of node from URL so I set "When the filter value is NOT available" to "Provide default value" and in TYPE drop down menu I set "Content ID From URL"

This view works with no problem. However, when the view is empty (there is no rows for fetched parameter value from URL) I see some rendered codes.

What is your solution for this problem? As far as I know when a view returns no row, it must not be rendered in source code. In above codes, you see there is no result but the codes of block are printed !!!

Thanks a lot for your guidance.


texts: Imported site doesn't displays CSS styles

texts:
I imported a site from pantheon to my localhost to work on it. The site pulls up just fine, however, it has no CSS styles at all. Its plain HTML through and through. Also i'm getting 30+ of these type of errors:

Warning: file_put_contents(temporary://fil739F.tmp): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1940 of C:\wamp\vhosts\cbirc\includes\file.inc).
The file could not be created.

How do I get the styling added back to the site?


texts: I've created a custom block with Div and P tags in which some have id and class attributes. I've tried use FULL & Filtered html formats for the block body however the id and classes don't show up once I've added the block.


texts: User can self-register unless email is on a blacklist

texts: I want users to be able to register unless their email address is on a blacklist (including wildcards), in which case an administrator has to approve the registration. How do I go about this?


texts: Display Suite Extra Fields not showing in content page

texts:
Display suite extra fields are shown in the manage display.  Fields such as author, user, AND submitted by, are enabled in the custom regions I have defined using a custom ds layout.  When I go to the full content page it does not show any of the extra ds fields that i enabled.  Does anybody know what the issue can be?

I'm using a custom ds layout

custom_article:
  label: article
  category: My Layouts
  template: templates/custom_article
  css: css/custom-article.css
  regions:
    header:
      label: header
    author:
      label: author
    body:
      label: body


texts: How to alert views output using custom module

texts:
I am using hook_views_pre_render() in order to calculate some values based on my $view->result and I can see how I can manipulate the arrays and I'm achieving some success with being able to drupal_set_message() my variables to the screen. However, I'm trying to actually alter the HTML output in the view - is this possible through the custom module?

I currently have a multi value field and in my Views table, I have a field for students which lists my students (nodes) in an unordered list - I'd actually like to only show the first student name and add "+ 8 more" (if there are 9 students altogether). While I can sort of drupal_set_message my variables - I'm unsure how you'd actually send this information to the view itself? Do you have to store the variables in the custom module and then send them to tpl.php files in Views?

I know this is possible using a pre made module but I'd rather know how it works myself.  I'm just struggling to see how you output these things into the view itself using a custom module.

Here is an image:

Cheers,
Garry.


texts: Exporting a custom module from one instance to another

texts:
I am new to Drupal. Currently I am using Drupal 7.4.

Hhow to export a custom module from one instance to another instance?

Note: copy the module to the new site didn't work.


texts: Drupal 8 \Drupal calls should be avoided in classes, use | | dependency injection instead

texts:
I used Drupal 8 and written a module.
in my form page I called.

\Drupal::service('library.discovery')->clearCachedDefinitions();
$cache = \Drupal::cache('discovery');
      $cache->delete('block_plugins');

It's worked, but I always see the warning.

  \Drupal calls should be avoided in classes, use | | dependency
  injection instead

I have the similar with File::load(), too.
I used:

use Drupal\file\Entity\file;
class BXBlock extends BlockBase {
public function build() {
...
$file = File::load($value);
...
}
}

Anybody can help me, please?
Thanks so much.


texts: Showing a message (perhaps using a redirect) after a Fileds form is submitted in Drupal 7

texts: I am using Drupal 7 + Rules. I have this form (creates a new node of some content type , dunno the correct jargon here) that users can fill to apply for a job. I want to show them a static message after the form submission. Apparently Rules is the way to go. How to do I achieve this ?


texts: URL encoding in admin overlays - breaks overlay

texts:
I have a fresh install of Drupal 7 with no content, and a few extra modules installed. Recently as I've navigated on the admin side, the URLs for the overlays have escaped HTML in them, like this:

http://mywebsite.com/#overlay=%3Fq%3Dadmin/config

Which of course is supposed to mean

http://mywebsite.com/#overlay=?q=admin/config

But still, the overlay doesn't show up properly.

I've found a few reports of this, but no fixes, other than to disable overlays. Can anyone offer anything?

What's tricky about this is that I can't get to administrative features because the overlays can't show up.


texts: What security should I double-check before opening my site to being multi-user?

texts:
I've been using my D7 installation as a single-user blog, and operated assuming that would always be the case.  In the process, I may have been sloppy with permissions in various places, such as viewing, authoring, input formats, etc.---I'm no longer sure.

Now, however, I am going to open my site to subscribers (for a mailchimp mailing list), and possibly allow another content author.

Before I undertake these, what should I go over to make sure I'm safe, and ensure my site stays secure and is well permissioned?  Can someone help me construct a security checklist for all items I need to verify to move from single-user to multi-user?


texts: How to avoid that a module encodes json puts out "\u0026" instead of "&"?

texts:
I am using a module to encode to json, but it puts out "\u0026" instead of "&".

How can I avoid that?


texts: How can I get all fields and values of a node at once?

texts:
I know how to get a particular field (title field) of a node by following code:

$publications = \Drupal::entityManager()->getStorage('node')->load($node_id);
$title = $publications->getTitle();

But I need to get all fields and values in that particular node. I tried print_r($publications). Is there any way to get this?


texts: Drupal 7, language changes back to EN after clicking on any link

texts:
I have 8 languages on my website. When I visit the website with different language prefix such as mysite.com/da and scroll down to click on any link. The language prefix changes to EN in URL. For example mysite.com/en/about

Can anyone please help me on it?

Thanks
Saeed Afzal


texts:
I have made multilingual site. When we redirect users to another domain, I see the following error:

  [Sun Feb 02 13:03:40 2014] [error] [client 192.168.1.80] PHP Fatal error:  Cannot redeclare i18n_variable_set() (previously declared in /var/www/html/UNI01JO2012031/sites/all/modules/contrib/i18n/i18n_variable/i18n_variable.module:116) in /var/www/html/UNI01JO2012031/sites/all/modules/i18n/i18n.module on line 894

Please note I am not changing any configuration.


texts: Apache solr is not accessible by my server but accessible by my localhost

texts:
I have a solr installed in my server(centos 6.5).and everything works fine and my conf files exist where they should be. I try to connect to solr by help of search_api_solr module in drupal. Everything works fine on my localhost and one other host I try my website on,but when I try to connect to this solr using a website on the same server as the solr I'm get error

  The Solr server could not be reached

where should I start looking for something that went wrong?


texts:
I'm trying to use a Display Suite field to wrap an image in a div.

What I also want to do is to htmlspecialchars on the token [node:field_mainimage].

It doesn't want to work for me. Is there any other way I can accomplish this?


texts: Restrict language content for a given role

texts:
I have a multilingual site (spanish/english). I created 1 role: translator.

I need the anonymous users to ONLY see the contents in english language and the translator users to see both.

How can I accomplish this?


texts: unable to see drupal home page when configured live site into in my local system?

texts:
I need to configured my live site into local system, I had configured database, settings.php and enable module rewrite and .htaccess file also there in my root folder etc.
But I'm unable to see the my site home page it's showing blank page, please help me I'm new to drupal.


texts: $entity_wrapper->save(true) vs. entity_save('node', $entity)?

texts:
Say I've got the following block of code:

$language = language_default();
$values = array([...]);

$entity = entity_create('node', $values);
$entity_wrapper = entity_metadata_wrapper('node', $entity);

$container = entity_create('field_collection_item', array('field_name' => 'field_container'));
$container->setHostEntity('node', $entity, $language);
$container_wrapper->save();
$entity_wrapper->save(true);
entity_save('node', $entity);

The above block of code invokes three different save() methods. Is this strictly necessary? Does entity_save cascade to $container_wrapper->save() and $entity_wrapper->save() if I do not explicitly call these? Are all three necessary?

Things appear to work find if I skip $entity_wrapper->save(true)...but am I missing something?


texts: When creating a Panel Page and selecting a layout, the page layout is not overidden

texts:
I'm using Omega theme and have built 4 custom layouts for my sub-theme. If I activate layouts and select one in the admin my Omega sub-theme, everything is fine.

Now I want to use those layouts as the base for a Panel Page. When I do that, it injects the layout into the content section of the main (default) .tpl theme file.

My expectation is that it will completely replace that theme file the same way it does if I activate and use the layout in my sub-theme admin.

I've made sure to check disable Drupal blocks/regions when starting to build the layout.

I even tried using the stock layouts that come with Omega and no luck.

I can't think of anything else to try, especially since the layouts work outside of Panels.


texts: Force node render with a template (giving template url not suggestion)

texts:
I need to change

$render_array = entity_view($entity_type, $entities, $view_mode, NULL, TRUE);
render($render_array);

in order to force drupal to use a specific template.tpl.php (giving a specific template url).

How can I achieve this?


texts:
after a form submission I want to redirect to an url. The "action" attribute of the form is ['#action']=homepage. How can I override this?

I have used this code

function custom_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id=='views-exposed-form-job-search-search-page') {
    global $base_url;
    $form['#action'] = $base_url.'/search/job';
  }
}

However it doesn't work, it still redirects me to /homepage. What am I missing?
Thanks


texts: How to call hook_theme_suggestions_HOOK_alter twice, if node is shown twice?

texts:
What I want to do is show the contact person responsible for a language in two different regions simultaneously, but with different twig templates.
I therefore have two regions: footer and sidebar
I have a node type of Contact Person (contact_person) with several fields and I create one content of this node type per language (using Only One module)
I started with creating a View which get's me the correct content, but with two blocks. This gave me the same issue. I tried to circumvent this issue by creating two Views (Contact Person (Footer) and Contact Person (Sidebar)) each with one block display.
I changed the system names in the views to be block_sidebar and block_footer instead of the default block_1 for added clarity.
I used these blocks in the Block Layout, where I added both blocks to their respective regions.
If I examine the theme suggestions, the blocks behave as expected
For Sidebar:
block--views-block--contact-person-sidebar-block-sidebar.html.twig
___________________________________^^^^^^^_______^^^^^^^
For Footer:
block--views-block--contact-person-footer-block-footer.html.twig
___________________________________^^^^^^_______^^^^^^
But when I examine the node theme suggestions, the are the same
For Sidebar AND Footer:
node--view--contact-person-sidebar--block-sidebar.html.twig
___________________________^^^^^^^________^^^^^^^
if the Sidebar block get's rendered first.
If I swap the blocks in their regions (Sidebar Block goes inside the Footer region and Footer block inside the Sidebar region) and clear all the caches, the footer block is rendered first and so the theme suggestions changed for both of them:
node--view--contact-person-footer--block-footer.html.twig
___________________________^^^^^^________^^^^^^
These suggestions seem to generated in the Views module itself
// File core/modules/views/views.module
// ...
/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function views_theme_suggestions_node_alter(array &$suggestions, array $variables) {
  $node = $variables['elements']['#node'];
  if (!empty($node->view) && $node->view->storage->id()) {
    $suggestions[] = 'node__view__' . $node->view->storage->id();
    if (!empty($node->view->current_display)) {
      $suggestions[] = 'node__view__' . $node->view->storage->id() . '__' . $node->view->current_display;
    }
  }
}
// ...

If I try to debug this I discovered that the hook_theme_alter function is only called once for the node. I isn't called a second time, because the hook_theme_suggestions_HOOK_alter was already called for this very node.
How can I say Drupal that I want these suggestion alter function to be called a second time, if one node is shown a second time on the same page?


texts:
I just migrate my website to a new hoster and I get many errors based on files/images problems. Can somebody help me with that ?

I have this error on every page :

  Notice: Undefined index: default_widget in
  FieldInfo->prepareInstanceWidget() (line 580 of
  .../www/modules/field/field.info.class.inc). Notice:
  Undefined index: default_widget in FieldInfo->prepareInstanceWidget()
  (line 588 of
  .../www/modules/field/field.info.class.inc). Notice:
  Undefined index: module in FieldInfo->prepareInstanceWidget() (line
  591 of .../www/modules/field/field.info.class.inc).

And this one :

  Fatal error: Call to undefined function file_field_load() in
  .../www/modules/image/image.field.inc on line 195

So, after some investigations line 195 of image.field.inc :

function image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age);
}

But I didn't change anything in my files.


texts: Is that possible to single sign-on with completely different domains?

texts:
we have multilingual Drupal 7 site.

  Swedish Domain : www.swedish.com

  English Domain : www.english.com

admin/config/regional/language looks like screenshot.

No Domain access is used. I have tried https://www.drupal.org/project/sso_multi_domain but seems there need sub-domains.

Please suggest is there way we can make login working with separate domains which are pointing to same site folder, same database etc

Thanks!


texts: Is there a way to add content templates for blog

texts:
I've been asked to add templates (where a blog post is pre-created with certain content) and the user simply selects it and make minor changes. Please note this is not a visual template, but a content one.

Thanks!


texts:
How to disable image caption in views block?

The image caption module is image field caption.

I apply it on my Drupal 7.

Enable module and add in caption.

In node, it looks good.

In View Block, it looks like this. How to remove the caption in Views block?

==================================

Add View configuration image

Below is Views setting:

Below is Configure field: Content: Image settings:


texts: "Place block" ajax error when using nginx

texts:
I'm having a lot of trouble configuring nginx properly for Drupal 8. Using the Drupal nginx recipe on the official site works well except for opening modal dialogs like the "Place block" dialog. This results in a 200OK response but an ajax error.

Here is a gist with the error.

I know this is an nginx configuration issue as I have a different conf file that doesn't cause this issue. This other configuration doesn't work with Drupal 8's active link javascript due to the way it adds the query parameters. Frustrating!


texts: PHP setting of datetime field in CCK through Rules, How to stop continuous updates?

texts:
Drupal 6. Using Rules and CCK

So, I have a content type that gets automatically generated with Rules. Several CCK fields get populated at creation time, including a datetime field. I want this field to get populated with the current date/time.

For some reason, the Global Token fields don't work, the interface throws an error when I try to use a token instead of a standard formatted date/time stamp.

So, I use advanced PHP code box to set the date/time value.

return array(
0 => array('value' => date("m/d/Y - H:i")),
);

This code works, but when I do it this way it seems that whenever I refresh the node page the date/time stamp in the field is updated to whatever the current time is. This is not the behavior I want. I want the date/time to get inserted at creation time, and have it remain unchanged for perpetuity.

Thoughts?


texts: How to prevent duplicate entity reference items from being entered on a field?

texts: How would you prevent a user from being allowed to enter duplicate entity reference items on an entity reference field?


texts: Using module_invoke for Menu causes Undefined index notice

texts:
I'm displaying a multi-level menu in the footer of my site using:

$block = module_invoke('menu', 'block_view', 'main-menu');
          print render($block['content']);

Which is displaying correctly, however I am receiving this warning message:

  Notice: Undefined index: main-menu in menu_block_view() (line 486 of /****/modules/menu/menu.module).

Any suggestions on how to suppress this message?


texts:
The "Public file system path" setting in admin/config/media/file-system was always reflecting the directory name of my multi site directory.

I don't know what caused the problem, but it doesn't automatically set the right dir anymore and I need to manually change it when I create a site.

Does anybody have an idea of what might cause this behavior?


texts: How to use uploaded images from an image gallery in an article?

texts:
Maybe I am not searching for the correct terms, but I am trying to use an image gallery and be able to reference the images in that gallery from an article.  I want to be able to upload the images one time, but then have specific images to be shown in the article, either as a "sub-gallery" or just inline with the text, depending on the context of the article.

Is it just as simple as creating an image tag and setting the source to the relative address inside the drupal site?  Or is there a better way to accomplish what I am trying to do?


texts: How to create a membership using rules, using membership entity module

texts:
I'm using the membership entity module, and the membership entity commerce module.

I am trying to create a membership using  rules, without success yet.

There is one membership action available..to activate the membership but thats all.

EDIT:
This is the rule I used for checking out a membership:

    { "rules_at_listing_import_create_user_and_membership" : {
    "LABEL" : "At listing import create user and membership",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [
      "rules",
      "commerce_cart",
      "commerce_checkout",
      "membership_entity_commerce",
      "feeds"
    ],
    "ON" : { "feeds_import_listing_import" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "user",
            "param_name" : "[node:field-first-name][node:field-last-name]",
            "param_mail" : [ "node:field-user-email" ]
          },
          "PROVIDE" : { "entity_created" : { "user_created" : "Created user" } }
        }
      },
      { "user_unblock" : { "account" : [ "user-created" ] } },
      { "entity_save" : { "data" : [ "user-created" ], "immediate" : "1" } },
      { "commerce_cart_product_add_by_sku" : {
          "USING" : {
            "user" : [ "user-created" ],
            "sku" : "Listingmember-1y",
            "quantity" : "1",
            "combine" : "1"
          },
          "PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
        }
      },
      { "commerce_checkout_complete" : { "commerce_order" : [ "product-add-line-item:order" ] } },
      { "membership_entity_commerce_activate_term" : { "commerce_order" : [ "product-add-line-item:order" ] } }
    ]
  }
}

Using this rule, I assume that the membership is created automatically because of the membership product being checked out.

Alternatively, I tried the method without using the membership product, by straight away creating an entity of type membership using rules. That does not work, the membership is not created.


texts: Dense and Complex: Using Boolean Fields Within A Content Type

texts:
I'm trying to output 9 separate datasets (which represent restaurant menus) while using just one content-type. The fields of this content-type are named according to day of the week, meals types (lunch, dinner) and a taxonomy of food options, i.e. 'field_monday_lunch_soup'. On the front-end, I intend to represent the data using accordions and tabs, which is why isolating specific fields is so important.

All fields (including the nine boolean fields) are part of the same content-type. When the admin submits a menu he can associate it with one of the nine restaurants.

How do I construct an if then statement to isolate fields so that I make it clear on the user-facing side that the data is associated with a specific restaurant? I want to avoid using views and various content-types because it quickly becomes overwhelming with all the various permutations.

So my php logic is something like this at the moment:

<?php if ($content['field_restaurant_one']['und'][0]['value'] == '1'): ?>

Any help would be hugely appreciated! I'm thinking EFQ (entity field query) is the way to go.


texts:
I want to add artwork song cover(image) to pushtape player.

This will be shown in the current playing song inside pushtape player block.

The image will be loaded from Image Field in the content type field_image

The module showing the current node title in the block and the module work in soundmanager2 library.


texts:
I have a view (table style) filtered three content types, added fields i want, but each type has a date field.

I needed to group all's nodes by date so i added a Global: custom text with replacement patterns i get what i need (one date field to three content types).

I grouped my view by this field but the problem is each content type has own table.

how can i group those three content types together in one table for every date value?


texts:
I'm overriding the Workbench default view of files, and trying to add a filter to let the user optionally show all files that have no usage on nodes.

I see that there are ways to filter and show file usage, but I don't see a way to provide a simple toggle to the user based strictly on whether the file is in use at all.

Is this something that can be accomplished via the Views UI or will this require a custom handler?


texts:
I am looking for a module that allows fields to be edited that are presented<,
preferably by a view. Basically what I am trying to acheive is as follows:

I have a content type as Meter Readings
Meter reading prepopulates by entity reference_prepopulate to a parent project
  ie.Building.
Idea is that a building has a meter say Electricity meter that records
  electricity readings(by Meter Readings Content type) that is presented in a view

I want to add meter readings in the view itself and not let the user to go to another screen,

Any  module to do this? Any references would be of great help.


texts: How to create flexslider slideshow as a background in drupal 8?

texts:
My slideshow is working but it is not in the background -- I am using paragraphs that I thought would make it easier for my client to add new images - the "flexslider" is in the header and I did create a twig template to put it in the background - "paragraph-frontage-flexslider.html.twig" ; the "flexslider" is there but not in the background (I modified a slideshow background twig that I found)

[section class="region-header.outer-wrapper" style="background-image: URL('{{file_URL(content.field_background_flexslider_imag['#items'].entity.uri.value)}}');"]
  [div class="overlay"][/div]
  [article]
    {{content.field_background_flex_caption}}
  [/article]
[/section]

Any help would be most appreciated!


texts: How to set node creation limit by user type in Drupal

texts:
I'm trying to set the limit on authenticated user for creating particular type of content(adding user limit on content type).

Node limit module has same functionality in Drupal 7 but i'm looking for Drupal 8.


texts: How to add item to cart programmatically, with attributes in Ubercart

texts:
So I know how to go about adding an item to the cart with PHP like this;

$product_nid = 2;
$some_data = NULL;

  uc_cart_empty(uc_cart_get_id());

  $data = serialize($some_data);

  uc_cart_add_item($product_nid, $qty = 1, $data, $cid = NULL, $msg = TRUE, $check_redirect = TRUE, $rebuild = TRUE);

but I'm uncertain how to add a product with a certain attribute/option such as if I have product "A" with options "1" and "2" I was hoping I could get a little help.
This is for Drupal 7, Ubercart 3.


texts:
I'm running the latest stable version of SimpleNews 7.x.

I realise there is an option to disable sending via cron tasks and set a throttle. The description underneath this option advises it should only be used for testing purposes.

My SMTP server relays through Amazon SES. The SMTP server itself throttles email sending by default to 20 messages per connection.

So I'm wondering, is the cron task email sending really necessary if the messages just get queued up and throttled by my SMTP server anyway?

If I disable the cron sending are there any substantial problems I might encounter?


texts: How do I configure the Stock module in and know how many products are sold out of stock?

texts:
I have installed the Stock module, but I don't know how to configure or include that to my product content type, nor do I know how to use it.

Do you have any idea or suggestion?


texts:
I'm running Drupal 7, Apache Solr module 1.2, Boost 1.3

When performing a search as an anonymous user, I (most of the time) just get redirected to the front page.
I suspect some conflict with the boost module as this only happens for anonymous users and removing the .htaccess rules for boost seems to fix the problem. Although the eratic behaviour is quite confusing.

I notice that the form submit action for the search is always "/"
In the access logs, I see that the normal flow is:
- POST on "/"
- 302 Redirect on node/search/...

When having the problem as anonymous user, the flow is:
- POST  on "/"
- 200 Status code and the boost cached index page is returned. No 302

Here are my boost .htaccess directives:

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

# Caching for anonymous users
# Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [S=4]

##Added as the front page was displaying the content of index.php instead of cached html
RewriteCond %{REQUEST_URI} ^\/index.php$
RewriteCond cache/normal/drupaltestsite.com/_\.html -s
RewriteRule .* cache/normal/drupaltestsite.com/_\.html [L,T=text/html]

# GZIP
RewriteCond %{HTTP:Accept-encoding} !gzip
RewriteRule .* - [S=1]
RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html,E=no-gzip:1]

# NORMAL
RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

As the action is a POST, none of these directives should be executed I think, so I am not sure where the problem is.
Where is the 302 redirect made to forward the request on search/node... ?

Any help appreciated.
Jerome


texts: Entity reference view that return set of views?

texts: I have a field in Entity reference type for selecting a view. It works well (allowing the user to select the view) but I want to narrow down offered values, to sub set of some specific views. When defining the field there is no option to select which views can be references, as i.e. for referencing nodes (supported list of content types). To do that I have to create a view that would list views in entity reference display type and add some filters to exclude views I don't want. But when I'm creating a view in "show" filed there is no "view" type?!? Is it possible to create a view that lists all views?


texts:
I'm using Drupal 7 with the FiveStar module to let users vote on a certain node type. When the user votes, I have a workflow rule that grants them some points to reward them for casting their vote.

The problem I'm running into is that if the user votes more than once on a given node, they are granted points again, each time they vote. There is currently no filter to check that they have already voted before awarding the points.

I could use some help building a workflow rule filter that checks to make sure the user has not already voted on the particular node.

Conceptually I would like to query the votingapi table for any records with the given node ID and given user ID and pass only if zero records are returned. But not sure how to do this in Drupal. Trying to avoid hard-coding a query too.

Thanks
BH


texts:
I have two content types:

post_image_on_right

post_image_wide

post_image_on_right has three different image fields and each image field has it's own image style.

What I would like to do is depending on what node type, image field and image style is being displayed give me the image full path within the node to push into pinterest link attribute.

I thought a switch would have worked but the switch is looking for a change in node type. I need to check for node type image field and image style and pass those values.

switch ($node->type) {
case 'post_image_on_right':
$image_field = 'field_image_right';
$image_style = 'medium';
break;

case 'post_image_on_right':
$image_field = 'field_image_vertical';
$image_style = 'medium_vertical';
break;

case 'post_image_on_right':
$image_field = 'field_image_tall';
$image_style = 'medium_tall';
break;

case 'post_wide_image':
$image_field = 'field_image_wide';
$image_style = 'large';
break;
}

$field_items = field_get_items('node', $node, $image_field);

<a class="addthis_button_pinterest" pi:pinit:url="<?php echo "http://" . $_SERVER['HTTP_HOST'] . $node_url ?>" pi:pinit:media="<?php print image_style_url($image_style, $field_items[0]['uri']); ?>" pi:pinit:layout="horizontal">


texts: A deleted image filename is printed to the top of SOME of my nodes

texts:
Background:

I once had an image file in the site (I think the image was added via an image-field I already deleted).

The problem:

This image filename I described is printed to the top of SOME of my nodes (I should note that these are nodes from different content-types). In some nodes it doesn't appear but in some others it does... Any idea why would this strange beahvior happen?

I already tried to flush all caches - didn't help.

Live examples (Images):


texts: Allow only certain user type to create account

texts:
I have to add new role, for users than can create accounts for others.

I create new role and add create profile content permission.

But when I am anonymous link 'clear new account' still appear and I can create account. I want only certain role to create account, not everyone.

Could somebody give me any advice?


texts: node update error before clearing the cache

texts: Sometimes when I try to update my nodes, I get an error which I am not sure of since errors are suppressed but when I clear the cache, I can again be able to update. What can be the problem?


texts: Feed importer: field collection processor settings

texts:
I'm trying to import field collection to profile2.

I do not understand where to get in the Field Collection Processor information for the "Field/property name of Host entity GUID" and "Identifier field name" settings to fill in the text box?

Please see the image below.

Thanks!


texts: Trying to display data from a module's table in views

texts:
I'm trying to show the purl.value value on a view's page.

It seems to be grabbing all of the data, however it isn't showing in the final results. Here's my code:

function mymodule_views_query_alter(&$view, &$query) {
  //watchdog("view information", print_r($view, true));
  if ($view->name == 'project_management') {

    $join = new views_join;
  $join->table ='purl';
  $join->left_table = 'node';
  $join->left_field = 'nid';
  $join->field = 'id';
  $join->type = "LEFT";
  $join->extra_type = 'AND';
  $join->adjusted = 'TRUE';

    $view->query->table_queue['purl'] = array(
    'table' => 'purl',
    'num' => 1,
    'alias' => 'purl',
    'join' => $join,
    'relationship' => 'node',
  );

    $view->query->tables['purl'] = array(
    'count' => 1,
    'alias' => 'purl'
  );

$view->query->add_field('purl', 'value');
  }
}

What exactly am I missing? Do I need a view handler? I was told that maybe using hook_views_data_alter() might be better for my purposes.

How do I add a visible custom piece of data from that column on my view page?


texts:
I've got an show/performance relationship, where a show can have multiple performances, and each performances has a single date (when the performance takes place).

I'm showing these in a Drupal view, but it's becoming a bit problematic.

I need to sort this list so that the shows with the closest performances to now appear at the top, the problem is that shows with only past performances also need to show.

The last part appears particularly problematic, I think I could just sort this by greater than or equal to now, but I don't think that will be sufficient in this case.

Is this possible? Or do I need to try and argue for a different way of displaying this content


texts: Is it possibile to link menu links to the div or block on the certain subpage? If yes what is the method to do this?


texts:
I'm working with Drupal 7 and Views 3 to build a simple video player. The view is fields-based, and is set to display one result (video) at a time. I'd like to provide a "Next" link as shown in the attached image, to allow navigation to the next video. Ideally, the Next link would be available in the row with the other field data.

Normally, pager info is at the bottom of a view. I could use CSS and absolute positioning to move the Next link, but the site is responsive, so it would be a lot cleaner to have the Next link appear with other field data.

Is there a straightforward way to do this?


texts:
When I look at one of my catalog pages (www.foo.com/catalog/category) - i get a grid listing of all the products with images (Content: Image product image linked to node).

However,  when I view any other taxonomy listing (www.foo.com/brand/xyz), I do get a grid listing of all products from brand xyz, but no image. I set up a view that has the same fields as uc_products and tied it to this taxonomy/term/%.

All of my fields show up (title, price, add to cart button), but there is no image link being generated.

Do you have any idea why the image is not showing up in the taxonomy listing, but it is for catalog/?

I'm using Ubercart 2.x, and Drupal 6.

If I add/remove other fields from the view, I see them; it is just the images that don't appear.


texts:
I'm a bit new to Drupal, but I'm on a project, where the most handy stuff is drupal. I only used it for 6 months, then I used mvc-s and stuff. Now I'm back to it.

The project is kinda simple. There is a site admin, who creates events and a registration form for that event (almost every registration form is different).

I want to display that entity form on the event page. I downloaded entityform blocks and it works, but I was just wondering if there is a module out there that creates a field type with the entityform types and the user can easily chose the entityform to display on the event page, when creating a new event.

If there is no such a module, then can it be solved by writing a custom field type? Thanks in advance!


texts: How to programmatically disable Global Theme Settings?

texts:
I am trying to programmatically disable logo and site name. I have seen some variables for these set in modules/system/system.admin.inc but haven't been able to disable them through my profile installer settings.

What is the proper way to disable them? I looked around the internet but found no one has really looked into this issue.


texts: How to add field classes from within template_preprocess_node

texts:
During template_preprocess_node I would like to be able to dynamically add classes to specific field wrappers.

Is this possible or does template_preprocess_node run after template_preprocess_field? I would much prefer to use template_preprocess_node if possible as the class relies on other fields.

I've tried adding:

$vars['content']['field_name']['classes']
$vars['content']['field_name']['classes_array']

but neither seem to take effect.

Were I to do the same within template_preprocess_field then I apparently would add classes to $classes_array which would automatically flatten into $classes, however these values don't appear to be available, or at least provided, to template_preprocess_node?

EDIT:

After investigation, it seems template_preprocess_node does run first, however it doesn't seem to have access to $classes_array as it appears in template_preprocess_field.


texts: Do I have to start a multilingual site with a precise Language

texts:
I run Drupal 8.7.8 and tried to make it multilingual.
Is it important in which language you start?
I think I once stated with English and changed to German
I have some problems, because some text is really not translatable.
Some Nodes show the language selector others don't specially nodes that I have translated via the UI

Any Help.
Where could I get hel.
Thanks


texts: How do I hide the download button on the audio player?

texts: I want to hide the "download" button on the audio player provided by the Media module in Drupal 8.  How can I do that?


texts: Linking content type nodes with each other

texts:
I have two content types that I want to link each other. I checked node references, but node references only allows me to link to others when creating a node of that content type. What If I wanted to link two nodes of content types that are already created?

Please let me know if it is possible in Drupal-6.

Thanks


texts: What is the suggested workflow for migrating (CMI) configuration from dev -> stage -> production?

texts:
We had a drupalcamp a few months back and someone asked about managing deployments with the new config (CMI) system. One possible ideal workflow would involve keeping the config in version control and still being able to migrate configuration between team members.

The best that we in the room were able to figure out (partially based on the presentation at DrupalCon Portland) was:

Tell version control to ignore active config directory.
Copy all Configuration over to staging directory and commit to version control.

And use settings.php to reverse active/staging directory between the 2 environments. However, while figuring out a deployment workflow from one server to the next was complex but doable, what is the suggested workflow from multiple local environments (ie multiple developers) into dev (or between each other) - A possible issue would be every team member would be sharing the same or similar environment so how do changes on one teammate's machine come over?


texts:
I need to show a video in a light box on a site and am having difficulty. I thought I would create a normal page with the proper code but when I go to load the video the screen grays out then goes and loads the page but gets stuck as if it cannot do it. I also tried just creating an html file and loading it directly but it couldn't read it or failed or something. I am using fancy box and html 5 if that matters.
How would I do this? If you need more info please let me know
Thanks for any help guys

Edit:
I have tried the solution below which is what i need it just isn't quite working yet.
the url of the node is: http://fourcemag.com/homme/video and http://www.fourcemag.com/homme/video-0/video
so the last part of the url is video

This is the code:

function fource_preprocess_page(&$vars) {
  $path = $_GET['q'];
  $path = drupal_get_path_alias($path, $path_language = '');
  $patharray = explode('/', $path);

  if ($patharray[2] == 'video') {
    $vars['template_files'][] = 'page--video';
  }
}

This is the error:

page--video.tpl.php

not sure what is wrong here.
Please help
Same error as before


texts: How to update a computed field in a rule's "set data a value" action

texts:
I have a custom field called field_balance in the user account form which is a computed field. It keeps the actual number of coins bought by the current user. That value is supposed to change (increase or decrease) if the user makes particular manipulations on my custom content type which is called Ads.

How do I increase the field's value? By setting up the field.

How do I decrease the value? I am using Rules module to make the field's value decrease. But it doesn't work well yet. This is what I have already tried:

The Event: After updating existing content of type Ads
The conditions: User has roles "ad editor"
The Action : Set a data value. But when I select the field called
"site:current-user:field-balance" and hit "Continue", The Data selector turns red and a notification appears.

Here is the illustration:

What is it about the computed field that does not continue the rule? Is there any other way to update a computed field with the Rules module?


texts: Display suite's adding custom fields loads eternally

texts:
In "Manage display" page of my product content type, I have the custom fields tab. In that tab I have some buttons... None of these buttons works. I tried both but the popup div loads eternally there.

Anyone with the same problem with any clue?

Thanks


texts: How to make EventSubscriber run on every page load?

texts:
Tripped up on how to make my EventSubscriber code run on every page load. In my src/EventSubscriber/RedirectAnonymousSubscriber.php file here's my code:

<?php

namespace Drupal\mymodule\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

/**
 * Event subscriber subscribing to KernelEvents::REQUEST.
 */
class RedirectAnonymousSubscriber implements EventSubscriberInterface {
  private $redirectCode = 301;

  public function checkForRedirection(GetResponseEvent $event) {
    $is_authenticated = \Drupal::currentUser()->isAuthenticated();
    $route_name = \Drupal::routeMatch()->getRouteName();

    if (!$is_authenticated && $route_name !== 'user.login') {
      $response = new RedirectResponse('https://example.com', $this->redirectCode);
      $response->send();
      exit(0);
    }
  }

  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('checkForRedirection');
    return $events;
  }
}

And then my .services.yml file:

services:
  mymodule.event_subscriber:
    class: Drupal\mymodule\EventSubscriber\RedirectAnonymousSubscriber
    tags:
      - { name: event_subscriber }

The weird thing is when I run drush cr and pull up my local env, the first time I log in the redirection works, however, anytime I log in after the first time running drush cr the redirection does not work correctly. I even put a breakpoint on my if statement in my function and it doesn't get hit after the first successful redirection. Hope that makes sense. Thanks!


texts: How to overcome a database error on field deletion

texts:
I have read the other SQLSTATE[42S22] questions here, and they seem to all be about modules that have not completed setup properly, but I think my issue is different.

Whenever I try to delete a field the following error shows up:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
'field_data_field_doc_file0.field_doc_file_value' in 'where clause':
SELECT field_data_field_doc_file0.entity_type AS entity_type,
field_data_field_doc_file0.entity_id AS entity_id,
field_data_field_doc_file0.revision_id AS revision_id,
field_data_field_doc_file0.bundle AS bundle FROM
{field_data_field_doc_file} field_data_field_doc_file0 WHERE
(field_data_field_doc_file0.field_doc_file_value = :db_condition_placeholder_0)
AND (field_data_field_doc_file0.deleted = :db_condition_placeholder_1) ;
Array ( [:db_condition_placeholder_0] => 61531 [:db_condition_placeholder_1] => 0 )
in field_sql_storage_field_storage_query()
(line 652 of /path/to/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).

It seems that perhaps some previous field deletion went awry or something?  If I hit the back button it does appear that my field has been deleted, but I fear that if I keep deleting fields, I may be digging myself into a much worse problem to untangle.  What would be the best course of action to resolve this issue, and get rid of these db errors?  I'll start by looking at the field_sql_storage module, but suspect I'm not familiar enough with drupal yet, to quickly ascertain what is going wrong via that route.

UPDATE: Line 652 of that module is the last line of the field_sql_storage_field_storage_query method:

return $query->finishQuery($select_query, $id_key);

UPDATE 2: I found the entity with the id in [:db_condition_placeholder_0] in a table called field_deleted_data_143, but I haven't find a column named field_doc_file_value anywhere yet (The deleted table has a field_doc_file_title_value table).  The FROM portion of the query is FROM {field_data_field_doc_file} field_data_field_doc_file0, but I don't know what table {field_data_field_doc_file} represents here.  Is it field_data_field_doc_file (which is an empty table), or are do those curly brackets mean that name is being replaced with something else?

I guess maybe the next step is to try adding the column to the table.


texts: How do I implement hook_views_query_alter()?

texts:
I try to implement hook_views_query_alter() in Drupal 8.
I found a hint, that it has to be in my_module.views_execution.inc.
I tried it, but the hook never gets called.

function mymodulename_views_query_alter(&$view, &$query)
{
    var_dump('foo');die;
}

Do I have to register the *.inc file anywhere? Do you have a documentation source on this topic?


texts: Unable to change submit callback for commerce_add_to_cart form

texts:
I'm building the commerce add to cart form programmatically, and I'm trying to use my own submit handler.

However, no matter what I try, I'm not able to do so. It's really weird - I can override the one that is generated by the commerce itself, but not this one.

Stripped code is below. Note: to test it, create one product and replace product ID in the constant defined at start.

temp.info file:

name = Temporary
description = Temporary module for testing.
package = Custom
core = 7.x
version = 7.x-1.0
dependencies[] = commerce_cart
dependencies[] = commerce_product
dependencies[] = commerce_line_item

temp.module file:

define('TEMP_CUSTOM_PRODUCT_ID', 1);

function temp_menu() {
  $items['temp'] = array(
    'title' => 'Temporary page',
    'page callback' => 'temp_page',
    'page arguments' => array(),
    'access callback' => TRUE,
  );
  return $items;
}

function temp_page() {
  // Create a sample product and use its ID here.
  $product_ids = array(TEMP_CUSTOM_PRODUCT_ID);
  $product = commerce_product_load(TEMP_CUSTOM_PRODUCT_ID);
  // Build the line item we'll pass to the Add to Cart form.
  $line_item = commerce_product_line_item_new($product, 1, 0, array(), 'product');
  $line_item->data['context']['product_ids'] = $product_ids;
  $line_item->data['context']['add_to_cart_combine'] = TRUE;
  // Generate a form ID for this add to cart form.
  $form_id = commerce_cart_add_to_cart_form_id($product_ids);
  // Add the display path to the line item's context data array if specified.
  $line_item->data['context']['display_path'] = current_path();
  // Build the Add to Cart form using the prepared values.
  $form = drupal_get_form($form_id, $line_item, TRUE, array());

  return drupal_render($form);
}

function temp_submit() {
  drupal_set_message('Custom submit handler is being called.');
}

function temp_form_alter($form, &$form_state, $form_id) {
  // Dirty, but this check works for testing.
  if (arg(0) == 'temp') {
    $form['submit']['#submit'] = array('temp_submit');
    $form['#submit'] = array('temp_submit');
    dpm($form);
  }
}

Every time you submit the form, it will trigger default submit handler.

Any ideas why this doesn't work?

Thanks!


texts:
In my backend, I have an error "node.field_descriptif need to uninstall", but I don't have this field anymore, but it is in the database. How can I do that?

EDIT :

I tried

  drush entup

This is showing me entity that needs to be updated, but when I try to press yes, I have this error :

  The command could not be executed successfully (returned:
  'C:/MAMP/htdocs/ext-partenaires/vendor/drush/drush/drush' n’est pas
  reconnu en tant que commande interne ou externe, un programme
  exécutable ou un fichier de commandes.

But drush is working if I do for example a "drush cr" (my variable is set to C:\MAMP\htdocs\ext-partenaires\vendor\bin), even if I set a variable to the expected path


texts: Adding a list of strings or entities to another entity

texts:
I need to be able to add a list of departments to an entity directly via the add form of that entity. Those departments don't necessarily exist in the application beforehand and could be strings or entities (being desperate, I've tried both, but entities would of course be the better choice here).

I first thought the map field type would be ideal for such a case, but couldn't find a way to display it in my form, since I couldn't find an example in the documentation.

I thought this would be fairly easy, but it doesn't look like it. Then again, maybe it's because I've only been using Drupal for a little more than a week.


texts:
I am migrating Paragraphs from CSV file. I have Paragraph called Text with two fields -> title and body.

The problem is that I would like to also migrate translations for them, which currently don't know how to achieve. Tried with the migration_lookup plugin and translations: true option, but receive error for duplicate primary key ids.

What is the way to do this?


texts: Modal windows module for Drupal 7 content?

texts:
I have looked at a bunch of modal window modules but they all seem to only apply to media such as images or videos.

Do any of the modal window modules (lightbox, shadowbox etc) for drupal 7 allow drupal content to be displayed within, for example blocks / webforms etc?


texts: Injecting database values with a non-Drupal application

texts:
I have a D7 site which I would like to allow a non-drupal application to be able to inject values into the database. Specifically, I would like to upload a file to a specific field and then associated that field entry with a predetermined user.

The external program is not running PHP either, so it's intended to be an entirely SQL based approach, and not touch Drupal code at all.

Is there a recommended or useful approach to this, for a way to extract the Schema from Drupal, or a CMS-agnostic method of tracking database updates / inserts?

Thanks!


texts:
I need to create programmatically order from other content like a
subscription node on cron task.

This is my code to get data from the subscription node called 'abonnement' and then create an order.

  $query = \Drupal::entityQuery('node');
  $query->condition('status', 1);
  $query->condition('type', 'abonnement');
  $query->condition('field_livraison', 3);//livraison le vendredi
  $entity_ids = $query->execute();

  foreach ($entity_ids as $entity_id) {
    $abo = Node::load($entity_id);

    //utilisateur
    $user_array= $abo->get('field_utilisateur')->getValue();
    $user = $user_array[0]['target_id'];
    //abonnement
    $nid= $abo->id();

    //ligne de commande
    $items = array();
    $items_array= $abo->get('field_abo_produits')->getValue();

    for($i=0; $i<count($items_array); $i++) {
        array_push($items,$items_array[$i]['target_id']);
    }

    //creation de la commande
    $entity_type_manager = \Drupal::service('entity_type.manager');
    $order_storage = $entity_type_manager->getStorage('commerce_order');
    $new_order = Order::create([
      'type' => 'default',
      'store_id' => 1,
      'placed' => time(),
      'state' => 'completed',
      'completed' => time(),
      'uid' => $user,
      'cart' => FALSE,
      'order_items' =>$items,
      'field_abonnement' => $nid
    ]);
    $new_order->save();
  }

It works, but line items are line items from the subscriptions. If I delete the order, I delete the line items in the subscription too.

How can I duplicate the line items (as with $cloned_items = clone($items);)?


texts:
I have a module which behaves much like question and answers. Each question needs to have a help image. So far, I have written the schema as this:

function mymodule_schema() {
  $schema(mymodule_questions) = array(
      'description' => 'Stores questions for my module',
      'fields' => array(
          'qid' => array(
            'type' => 'serial',
              'not null' => TRUE,
              'description' => 'Primary Key: Question ID.'
          ),
          'prompt' => array(
             'type' => 'text',
              'not null' => TRUE,
              'size' => 'normal',
              'description' => 'Question prompt',
              'length' => '1000'
          ),
          'option_type' => array(
              'type' => 'varchar',
              'not null' => TRUE,
              'description' => 'Option Type',
              'length' => '255'
          ),
          /* Image field schema goes here */
      ),
  );
}
?>

Now, I want to add an image field, i.e. a field where admins can upload images to be shown with each question. What should be the schema for this field? Should I use the Field API in the schema (is that possible?)? If yes, how?

Thanks.

Kaustav Das Modak


texts: Is there a module that can list all the views on a system?

texts:
Is there a module that can list all the views installed on a system and their pages as well? If it can specify whether the Views are installed by modules or enduser created that will be helpful.

I am looking for something that create a list along this lines.

Name | Type of View | Page Name | Type of Page | Path


texts:
I am using Views Calc for Drupal 7 to calculate duration. I have some questions:

If use Date (Unix timestamp) and subtract end date from start date of my date field with time it gives me seconds then I divide it with 86400 (the seconds in a day) it gives me number of days.

My code in Views Calc:

( %field_data_field_we_from_date.field_we_from_date_value2 -
  %field_data_field_we_from_date.field_we_from_date_value ) / 86400

which is great;

however:

If I use date (not UNIX time stamp) and with no time only year, month, and day then it gives me a number which I don't understand what it represents. If I divide it with 86400, the answer does not look correct. My problem is that we don't need to add time in the field. The end-user doesn't like to see time field with date.
When I try to use NOW() it give error in Views Calc setting which says NOW value is not allowed here! I need NOW() - my_date_field to get age and other duration which do not have end date field.
ROUND() function also doesn't seem to be working.

Any help would be highly appreciated.


texts:
Im am using rules to create a node entity when the user saves a status from the statuses module. The Status message is copied into the title of the new node and then this title is shown in my view. I'm doing this as I need to have the Status message as an entity and this is the only way I could fathom - I'm aware this is probably considered a bit of a hack by most, but its ok for me up to this point.

My question is would it be possible to have this node show up in my view when it is created by rules without having to reload the page? I am not a developer but I can get by with PHP and JS. A small amount of research has led me to AJAX and JQuerey as a solution, but Im wondering if anyone knows if there's anything else out there (such as a module) which may help me achieve the right solution without too much heavy programming?


texts: How to convert a unix timestamp field in views

texts:
I'm keeping a Unix timestamp in a text field.  In Views, I want to convert it to a readable date.  This is a commerce view, and the field is a custom field of an order.

Can I use hook_field_formatter_view() to use as my own formatter?  Something like:

function mymod_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {

    if ($entity_type == 'commerce_order') {
          // figure out field type and instance
    }

}

If that is a way to do it, I want to look at the params through Devel, so what can I return until I'm ready to operate on them?


texts: Select/Update column based on uid/nid (don't overwrite/ignore duplicates)

texts:
Short Overview

I'm (attempting) to build a video tracking system in drupal 7 but am having trouble with database inserts and updates.  I have my table with four fields from my .install which looks like:

UID   NID          stats                        progress
 1     9    ["1","2", ..."99", "100"]     0 (only 1 if stats = 100% completed)

On my front end, there is a script sending these three fields, excluding progress, to the back end and storing it. I then do a simple calculation based on the stats array, which determines the progress column for that nid for that uid in php.

Of course NID will change based on which node they are on, and UID changes based on each user.

My problem is writing a query for:

if($nid == ...->fields('nid') && $uid == ...->fields('uid'))

basically if an entry already exists for this user on this node, update and append to the stats column, not overwrite it.

and also to check something like:

if(empty(stats) && if($nid != ...->fields('nid') && $uid != ...->fields('uid'))

if an entry for this user on this node doesn't exist, then create a new entry?

I've looked into the schema api and am having trouble selecting a column based on these conditions.


texts:
I configured OG_theme in drupal 7. I set a default theme for a organic
  group and i'v got a message that is assigned to this group.

My problem:
After logging in with an OG group I see the group message and after clicking on this group message I notice the theme changes.

What I want:
After logging with a specific OG group i directly see the theme changes without clicking on the group message.


texts: I want to delete an order,but when I try to delete it notify me "This product is referenced by a line item on Order 40 and therefore cannot be deleted. Disable it instead" but I want delete it completely in my product list, It is not important delete an order item that is used in.


texts:
I have added primary links and enable as expaned . Which is working fine for me

> About
>  - test1
>  - test2
>  - test3

Now i want when i click on about or nay test1, test2, test3 page

I want a block on left sidebar containing  sub menu items

test1
test2
test3

Anybody have an idea how to do this

I am using Bootstrap 3 sub theme

Thanks


texts: Default fields missing from Account settings/Manage Fields page

texts:
I have spent a couple days trying to hunt down a very nasty bug.  I will have to add at least one other post involving the entity module afterwards, but I feel its too complex to put in one posting.

When I go into the home/administration/configuration/people/account settings, and click on the Manage Fields tab, I get the following errors:

Warning: array_keys() expects parameter 1 to be array, null given in taxonomy_field_extra_fields() (line 161 of /var/www/html/devel/modules/taxonomy/taxonomy.module).
Warning: Invalid argument supplied for foreach() in taxonomy_field_extra_fields() (line 161 of /var/www/html/devel/modules/taxonomy/taxonomy.module).
Warning: Invalid argument supplied for foreach() in FieldInfo->getInstances() (line 234 of /var/www/html/devel/modules/field/field.info.class.inc).
Warning: Invalid argument supplied for foreach() in FieldInfo->getInstances() (line 234 of /var/www/html/devel/modules/field/field.info.class.inc).

The line numbers may be off because of debugging messages.

There is a distinct chance that this is related to the errors I am getting in the Entity module that causes fatal crashes after a normal cache clear unless I execute drush cc all + a browser cache clear.

This is the list I get:

 (null)
 boolean
 date
 date (ISO format)
 date (Unix timestamp)
 decimal
 file
 float
 image
 integer
 list (float)
 list (integer)
 list (text)

Missing are the following:
     long text,
     long text and summary,
     Term reference,
     Text

I want to assume this must be a glitch in the database, but I don't want to have to rebuild from scratch.. Any help would be greatly appreciated.

Mike