texts: Have Database Update ignore prefix for multisite with shared database

texts:
I currently have a multisite with a single database. Each instance has a different prefix for their tables, except for one with no prefix which is considered to be the main instance. Now there is a custom table I made that contains custom data. That table is meant to be shared across all instances. In a function I'm updating a field like so

$database = \Drupal::database();
$database->update('custom_table')->condition('id', $my_id, '=')->fields(['full_name' => $fullname, 'address' => $address])->execute();

This works on my main site. Unfortunately in the other multisite instances that's using the same function, this is causing an error. In the error I have

  Base table or view not found: 1146 Table
  'database.myprefix_custom_table' doesn't exist

I realize that it's trying to prepend the prefix for the table. But it's a table that every site is meant to share. I don't want a prefix to be used.

I noticed that the update method can use options as a parameter https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Database%21Connection.php/function/Connection%3A%3Aupdate/8.2.x

But I'm not sure if I can tell it not to use a prefix in the options I can supply.

I understand that I can just use the query method instead of using the update method (I think) but I would like to know:
Is it possible to force the update method for the connection object to not use the database prefix?

UPDATE: This was suggested as a duplicate:
How to identify multi-site programmatically?
But that isn't related to my problem.

In that example it's identifying what site it's on, but it's not performing anything with a database. I know how I can check what site it's on. That's not a problem. I need to call an actual database method and get rid of the prefix it's automatically applying.

In my code

$database->update('custom_table')->condition('id', $my_id, '=')->fields(['full_name' => $fullname, 'address' => $address])->execute();

I'm not even supplying the prefix. It's automatically applying it without my knowledge if it's being run on another site.


texts: Permission to People but not Account Settings

texts:
I am looking to give a user the permission to manage users (add/edit/remove) on the page /admin/people. But I do not want them to be able to access the Account Settings page on /admin/config/people/accounts. (As you can change the Administrator Role).

How would this be possible?

Note I have already installed the Role Delation module, so they can only assign new users a certain role.


texts: How can I use feeds tamper to remove currency ($) sign when importing prices?

texts: I have an integer field that I am using for price info (not commerce) and I am importing from a csv. I need to strip out the $ sign and a blank space after. "$ ". How can I do this with feeds tamper?


texts:
I have an issue with composer and Drupal 8.9.13. When I try to update Drupal, I always get the next error and I don't find a way to solve it:
#$> php -d memory_limit=-1 composer.phar update drupal/core --with-dependencies

Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package drupal/swiftmailer (locked at 1.0.0-beta2, required as ^2.0) is satisfiable by drupal/swiftmailer[1.0.0-beta2] but these conflict with your requirements or minimum-stability.
  Problem 2
    - Conclusion: don't install drupal/swiftmailer 2.0.0
    - Conclusion: don't install drupal/swiftmailer 2.0.0-beta1
    - Conclusion: don't install drupal/swiftmailer 2.0.0-alpha2
    - drupal/swiftmailer 2.0.0-alpha1 requires swiftmailer/swiftmailer ~6.1.3 -> satisfiable by swiftmailer/swiftmailer[v6.1.3].
    - Conclusion: don't install swiftmailer/swiftmailer v6.1.3
    - Conclusion: remove swiftmailer/swiftmailer v5.4.12
    - Installation request for drupal/swiftmailer ^2.0 -> satisfiable by drupal/swiftmailer[2.x-dev, 2.0.0-alpha1, 2.0.0-alpha2, 2.0.0-beta1, 2.0.0].
    - Conclusion: don't install swiftmailer/swiftmailer v5.4.12
    - drupal/swiftmailer 2.x-dev requires swiftmailer/swiftmailer ^6.1.3 -> satisfiable by swiftmailer/swiftmailer[6.2.x-dev, v6.1.3, v6.2.0, v6.2.1, v6.2.2, v6.2.3, v6.2.4, v6.2.5, v6.2.6, v6.2.7].
    - Can only install one of: swiftmailer/swiftmailer[6.2.x-dev, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.0, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.1, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.2, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.3, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.4, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.5, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.6, v5.4.12].
    - Can only install one of: swiftmailer/swiftmailer[v6.2.7, v5.4.12].
    - Installation request for swiftmailer/swiftmailer (locked at v5.4.12) -> satisfiable by swiftmailer/swiftmailer[v5.4.12].

I have updated (manually) switfmailer to 2.0.0 version, and I have changed composer.json to lock it to 2.0.0. But It doesn't solve the issue. Any suggestion?


texts:
$form['questionfield_form_fieldset'][$i]['answer_type'] = [
        '#type' => 'radios',
        '#title' => $this->t('Select Answer Type'),
        '#options' => array(
          'select' =>t('Drop Down'),
          'radios' =>t('Radio'),
          'rating' =>t('Rating'),
        ),
        '#description' => $this->t('Select the way answer will disply eg. in radio button or in selectbox(Dropdown)'),
        '#default_value' => $config->get($form_count . '.' . $drupal_form_id . '.' . 'answer_type'),
        '#required' => TRUE,
      ];

      $form['questionfield_form_fieldset'][$i]['answer_box_id'] = [
        '#type' => 'textarea',
        '#title' => $this->t('Answer for above question'),
        '#description' => $this->t('Add your answers for above question here.'),
        '#default_value' => $config->get($form_count . '.' . $drupal_form_id . '.' . 'answer_box_id'),
        '#required' => TRUE,
        '#states' => array(
      'visible' => array(
        array(
        array(":input[name='questionfield_form_fieldset[$i][answer_type]']" => array('value' => 'select')),
        'or',
        array(":input[name='questionfield_form_fieldset[$i][answer_type]']" => array('value' => 'radios')),
      ),
        ),
    ),
      ];

I want to make answer_box_id as not required when user click rating radio button .


texts:
I want to add a user to a role when a checkbox on the profile has been checked.
It's printing the dpm() message but not adding the user to the role. What am I missing.

function mycustom_form_user_profile_form_alter(&$form, $form_state, $form_id) {
  $form['#validate'][] = '_user_profile_validate';
  ...
}

function _user_profile_validate(&$form, &$form_state) {
  if (($form_state['values']['field_restricted']['und'][0]['value']) == 1) {
    dpm('role added');
    global $user;
    user_multiple_role_edit(array($user->uid), 'add_role', 6);
  }
}


texts:
Bit of an odd request. I want to somehow change/alias the URL of a node to an external website. We are importing a calendar of events from our booking vendor to show nicely on our page. In the end, the user must go to the booking vendor website to enroll though. While I want all the imported data to be able to be shown on our website (so we can show snippets in blocks, and so forth), I want the node link to go to the event on the booking website. Our import does include the booking URL for each event.

I tried using the rules module to overwite the node:url on import, but it obviously does not allow this. I assume I could work some wizardry in views, but I would need the URL to change for blocks, calendar views, list views, etc. Is there some way to make a node always redirect to an external URL based on the import I am using "Feeds import" with an iCal feed?

To make it harder, I also lack any code level access.

This is probably a hail mary, but I figured I would ask. Thanks!


texts: How do I get rid of "Body:" as highlighted bellow?

texts: what can be done to get rid of highlighted section from the top of content?


texts: Better tagging / taxonomy reference widget

texts:
The Term Reference field type has three stock widget types:

Select List
Check boxes/radio buttons
Autocomplete term widget (tagging)

We need an alternative to the autocomplete widget that shows all existing terms in a vocabulary and allows users to enter another.

Here is a sample of what I'm looking for (I just made this in Firebug—I don't have a viable option yet). In this option, the vocabulary would include two terms, banana and pear, and the user could enter a different term.


texts: Display Content Type Field in region--footer.tpl.php

texts: First of all I am overriding the default footer template with my own using region--footer.tpl.php. In the footer I need to display the fields I have in a content type named 'footer'. Can anyone help me with this?


texts:
For a "Page" node, I want to add an event that only acts on node edited by users who are not administrator user.

I use the following code, it doesn't work:

<?php [node:user-id] != 1 ? TRUE : FALSE; ?>

No matter what I change; for Admin the event is getting called. I've checked all permutations  and combinations of syntax (including return) but it seems that "Check a truth values" is getting ignored.


texts:
I have the following file named background_image_style.module

In my Drupal 8.3.3 site, paragraphs.module is at MySite/web/modules/contrib/paragraphs/paragraphs.module.

I installed the site and all contributed modules with Composer.

composer require drupal/paragraphs
vendor\bin\drupal module:install paragraphs

Where does my hook module go? (I just copied it in where the paragraphs.module is.) Are there any other overhead steps that needs to be done (e.g. editing other files)?

I tried several locations and cleared the cache each time.

    /**
     * Implements paragraphs().
     */
    function background_image_style_preprocess_paragraph__banner(&$variables) {
      $paragraph = $variables['paragraph'];
      if (!$paragraph->field_image->isEmpty()) {
        $image = $paragraph->field_image->entity->url();
        $variables['attributes']['style'][] = 'background-image: url("' .                 $image. '");';
        $variables['attributes']['style'][] = 'background-size: cover;';
        $variables['attributes']['style'][] = 'background-position: center         center;';
      }


texts: SweetAlert doesn't display content markup

texts:
The SweetAlert modal is not displaying the content as passed in the option array when returning a response from the controller. Please see the code config below:

//$options                      = array();
    $options                        = SweetAlertCommand::defaultOptions();
    $options['title']   = 'Appointment Details';
    $options['html']        = TRUE;
    $options['content'] = '
'.
                                                  '
'.
                                                    '
Last Name
'.
                                                    '
'.$results['last_name'].'
'.
                                                  '
'.
                                                  '
'.
                                                    '
First Name
'.
                                                    '
'.$results['first_name'].'
'.
                                                  '
'.
                                                  '
'.
                                                    '
Email ID
'.
                                                    '
'.$results['email'].'
'.
                                                  '
'.
                                                  '
'.
                                                '
';

    $response                   = new AjaxResponse();
    $response->addCommand(new SweetAlertCommand($options));
    return $response;

When the alert is triggered the alert comes as blank. Any leads? I am using the sweetalert module https://www.drupal.org/project/sweetalert


texts:
In Drupal 7.
I have the following code in my template.php file:

function mytheme_theme($existing, $type, $theme, $path) {
   return array(
   'comment_form' => array(
   'render element' => 'form',
   ),
 );
}

I also would like to use the following code to theme the Register page:

function mytheme_theme() {
  $items = array();
    $items['user_register_form'] = array(
    'render element' => 'form',
    'path' => drupal_get_path('theme', 'mytheme') . '/templates',
    'template' => 'user-register-form',
    'preprocess functions' => array(
       'mytheme_preprocess_user_register_form'
    ),
   );
 return $items;
}

How do I merge the two snippets of code?

Any help on this is greatly appreciated. :)


texts: i am creating a web service for user registration. I just add some fields in user registration form using profile2 module. How can i integrate this with services module. i just want to make a services with the new fields


texts: Form submit with radio in table has data in form_state['input'] and not in form_state['values']

texts:
While developing a form for Drupal 7, I need a few radio groups, placed inside a table (one radio group per table row). The radios are defined as '#type' => 'radio' (not radios) and grouped together using the same name attribute per group. Nevertheless, when the form is submitted, the radio selections are not in the $form_state['values'] array, but in $form_state['input'].

As you can see from the screenshots, all data is stored in input, with the radios being outside the 'undefined' array, even though I placed them in $form['undefined'][$key][x]. In values only the select and textfield data is retained.

Any ideas? It's been two days now that I'm trying to resolve this :(
Thank you in advance.

function game_insert_form($form, &$form_state) {
  dpm($form_state, 'form_state');

  $test_data = array(
    '2' => 'Alfa',
    '4' => 'Beta',
    '6' => 'Gamma',
    '8' => 'Delta',
  );

  $header = array(
      t('Name'),
      array('data' => t('Existing'), 'colspan' => 2),
      array('data' => t('New'), 'colspan' => 2),
  );
  $form['undefined'] = array(
      '#tree' => TRUE,
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => array(),
  );
  foreach ($test_data as $key => $data) {
    // Label
    $label = array('#markup' => $data);
    $children = array(&$label);
    $row = array(array('data' => &$label));
    unset($label);
    // radio 0
    $radio0 = array(
      '#type' => 'radio',
      '#return_value' => 0,
      '#value' => 0,
      '#name' => 'undefined-' . $key . '-radio',
    );
    $children['radio0'] = &$radio0;
    $row[] = array('data' => &$radio0);
    // dropdown
    $select = array(
      '#type' => 'select',
      '#options' => array(0 => 'Zero', 1 => 'One'),
      /*'#states' => array(
        'enabled' => array(
          ':input[name="undefined-' . $key . '-radio"]' => array('value' => 0),
        ),
        'required' => array(
          ':input[name="undefined-' . $key . '-radio"]' => array('value' => 0),
        ),
      ),*/
    );
    $children['select'] = &$select;
    $row[] = array('data' => &$select);
    // radio 1
    $radio1 = array(
      '#type' => 'radio',
      '#return_value' => 1,
      '#value' => 0,
      '#name' => 'undefined-' . $key . '-radio',
    );
    $children['radio1'] = &$radio1;
    $row[] = array('data' => &$radio1);
    // textfield
    $textfield = array(
      '#type' => 'textfield',
      '#maxlength' => 40,
      '#size'=> 40,
    );
    $children['textfield'] = &$textfield;
    $row[] = array('data' => &$textfield);

    $form['undefined'][$key] = $children;
    $form['undefined']['#rows'][] = $row;
    unset($radio0);
    unset($select);
    unset($radio1);
    unset($textfield);
  }
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => t('Test'),
    '#weight' => 0,
    '#name' => 'test',
  );
  return $form;
}

function game_insert_form_submit($form, &$form_state) {
  dpm($form_state, 'submit: form_state');
}


texts: Hide other user comments, but not to admins

texts:
I have created a node, anyone can able to comment on the node. Now, what I want is:

For Authenticated users, show their own comment only (not other user's comments)
For Administrators, show all comments. (I want them to see all comments)

For this functionality, is there any contrib drupal module available? or else show me a way to do in custom module.


texts: Every drush command I run hangs on wget. However, if I run wget outside of drush, it works just fine. I am behind an http proxy and suspect that's factoring into the problem. I don't understand why wget isn't looking at my http_proxy environment variable when run through drush.


texts: How can I alter a query adding an OR clause for a relational field?

texts:
I have an "Event" node type with a number of fields: title, date, location, description, etc.
Because a number of events are similar, we added a "Parent event" entity reference field. Child events inherit fields (e.g. location, description) from the parent, if set.
We have a block that displays all of the events for a location, using a contextual filter. The problem is that the child events have an empty location – it is inherited from the parent event when we render the event page.
How can I adjust the view query to select all events with either the contextual location ID, or with a parent that has the location ID?


texts: Best way to add a wrapper  to selected fields in a content type

texts:
I have a content type called resources which has a bunch of fields including a screenshot image field. When I order the items the screenshot shows at the bottom (or at whatever weight I set it). But what I want is for the screenshot to appear to the RIGHT of the text in the other fields (basically like a float:right with css). But although I have the class of the item using Firebug and have styled it float:right accordingly it still doesn't go next to the other fields, it gets placed below them...to the right.

I think what I need to do is find a way to add a wrapper  to the other fields so I can float that  left and my screenshot field right...but I don't know how to add a wrapper  to fields in a content type.

Anyone know of a good way to do this?


texts: Drupal Commerce "add to cart" form with complicated attributes

texts:
I'm creating a Drupal Commerce based solution with 2 product types. One product has a constant price; it will be added to the cart, and that's all. The other product has many attributes (more complicated than color and size), and usually price depends from the selected attributes. Prices for various attributes are set by the administrator users. These prices are then multiplied by various other attributes, and added to the product price. For example:

additional price = some attribute unit price * customer entered width
complete product price = customer entered width * customer entered height * product default price + additional price

First attribute is width and height, which is entered from the customers before adding to the cart; the default value is 1x1.

More complicated attributes contain checkbox. If customers check it, the radio buttons becomes visible (first selected by default with no price; if customers select a different radio, they will enter a custom value). Another complicated attribute is price set individually for taxonomy term. I have colors, and for each color I can set the price for the current product. Thus I can't set price as a field of taxonomy term.

Now I'm trying to accomplish this with the Commerce Option and the Commerce Product Attributes modules.
Is there any simpler way to get the result?

The biggest problem is that the Drupal Commerce module adds to cart products with different attributes as a single product. So administrator Commerce/Order, or even customers viewing the  cart don't really know what was added to cart.
Is there any simple way to distinguish the same product (ID) but with different attributes?


texts: Display decimal field without right side zeros

texts:
I have a decimal field for length (cm) with precision 2. If I enter number without '.' it should display as it is only. For example If I enter 23 it should display 23 only not 23.00. If I enter 23.14 it should display 23.14. How can I do that? Am I missing any thing here?

Sorry, editing my question:

It should display the numbers like following (in Full node view, Views, Forms and wherever it appears)

If any one entered 93 it should be displayed 93 only not 93.00 (cause of the scale 2).

If entered 93.40 it should be displayed 93.4

If entered 93.14 it should be displayed as 93.14 only

I know that the value will be saved with scale 2(As given in Fields Form) in the database. But the value should be displayed as a whole number etc


texts:
I'm trying to setup a ajax call with JS but without building a drupal form. Basically it will trigger when the user clicks a specific class element on the page.
I've looked through the documentation but it seems to only be talking about ajax with drupal forms. Is this the only way to setup a ajax callback? I will link my code below.
The code itself works when I click my element. I get hello world. But i'm trying to figure out how to setup a drupal js ajax callback but it keeps saying I need to make a form.
(function ($, Drupal) {

  Drupal.behaviors.modals = {
    attach: function (context, settings) {
      $('#ajax-dashboard-display--erc360_academic_institution_dashboard', context).each(function () {
        // Create HTML markup
        let container = document.createElement('div');
        container.setAttribute('class', 'dashboard-container-modals');
        let modal = document.createElement('div');
        modal.setAttribute('class', 'dashboard-modal');
        container.appendChild(modal);
        let image = document.createElement('div');
        image.setAttribute('class', 'document-modal-img');
        modal.appendChild(image);
        let status = document.createElement('div');
        status.setAttribute('class', 'document-modal-status activitycircle activitycirclegreen');
        modal.appendChild(status);
        let myTarget = document.getElementById('ajax-dashboard-display--erc360_academic_institution_dashboard');
        myTarget.appendChild(container);
        $(".dashboard-modal").animate({right: '-100px'},800);

        $('.document-modal-status').click(function(){
          alert("hello world");
        })

      });
    }
  };
})(jQuery, Drupal);


texts: Drupal put more values in #markup $form type

texts:
Is it possible to add more values into the #markup of a drupal form?

At the moment it is a link but I also want to add an image. When I add another #markup it only takes the last one, and when I add $image to the other #markup it doesn't work.

My code:

$image_options = array(
    'path' => 'img_url',
    'alt' => 'App logo',
    'title' => 'App logo',
    'width' => '56px',
    'height' => '56px',
    'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
);

$image = theme('image', $image_options);

$form["link$key"] = array(
  '#type' => 'item',
  '#description' => t('Registered token(s): @total_tokens <br> Total sent push notifications: @push_notifications', array('@appname' => $record->app_name, '@total_tokens' => $total_tokens, '@push_notifications' => $sentMessages)),
  // '#href' => "admin/config/services/push_notifications/stats/". $record->app_id,
  '#markup' => l($record->app_name, 'admin/config/services/push_notifications/stats/' . $record->app_id),
);

So I want to be able to add $image to the current #markup..


texts: Why can't I uncheck "Create new revision" on the content type edit page?

texts:
On Drupal 8, I created a new content type, MyContentType, and accepted all the defaults.

I noticed that Create new revision under Publishing options was checked but slightly grayed out and I could not adjust the value, even though I was logged in as user 1:

I don't know why I can't uncheck it, but this is fine because I always want to save a new revision every time the node is saved.

However, to test this, I then created a new node of MyContentType and saved it.  Then I edited the saved node-- and the Create new revision checkbox is unchecked!

So Create new revision is permanently enabled on the content type edit page, but on the actual edit pages for that content type, the revision box is not checked by default.

What is causing this bizarre behavior?

In Drupal 8.2, create new revision became checked by default, but it says nothing about making it "mandatory by default".


texts: How to set the behavior for Pathauto when a duplicate exists?

texts:
I'm creating a Drupal 7 site which will consist of information about many different organizations across North America. The profiles will be submitted by the organizations themselves and it is very likely that there will be duplicate names.

What I'd like to do is have Pathauto create the url: orgs/OrganizationName for the first such organization and after this create: orgs/OrganizationName-City.

Is there any way to change how Pathauto behaves when duplicates are found?


texts: I have used commerce kickstart and created product display page with facet filter.I have used Facet API Pretty Paths module to use simple URL.But it makes no result behaviour.Without facet pretty path, facet filter working good, but URL makes quite complex.


texts: Next/Previous button for nodes within a book

texts:
I want to have Next and Back buttons for nodes within a book.

What is the easiest way to achieve this?


texts: How to delete a content in a view with view rules?

texts: I got two views that displayed two different type of contents. Content A got a field "Title" and content B got the same field. I want to find and delete any number of content of type B that got the same title of a content A. I try to do this with view rules module with some view loops. I found some content B that got a title equal to a title of content. How to delete them?


texts: Field for sorting criteria in views with "node views count" module

texts:
I'm using Node view count module to get the count of each node being visited by users.

I have created a view which shows listings filtered with specific content type and I wanted to add most viewed field for sorting criteria but it looks like Node view count module does not provide such fields which can be used in views for sorting the list based on the most visited nodes.

Is it possible to achieve this with Node view count module or do I need to use any other module. Please suggest, Thanks In advance.


texts: Why does getActiveTrailIds() return nothing for view pages?

texts:
MenuActiveTrail::getActiveTrailIds, though it works consistently for node pages on a menu, doesn't return anything for Views that appear on the menu in exactly the same way.

See this demo site which (currently) dumps the expected menu trail for a node ("Hello") but nothing for a view (the default Archive view) at the top level of a main menu.

Question: why doesn't this work, and what method should we be using to get the active trail for view pages?

I am using MenuActiveTrail::getActiveTrailIds to get the menu active trail of the current page on the main menu, as in:

use Drupal\Core\Menu\MenuActiveTrailInterface; ...
$this->menuActiveTrail = $menu_active_trail; ...
... current route set in breadcrumb builder applies() function ...
$trail_ids = $this->menuActiveTrail->getActiveTrailIds('main');

almost exactly as it appears in the current (8.x-1.0-beta1) Menu Breadcrumb module.

I have now noticed that getActiveTrailIds returns an empty active trail, for all views under all conditions I'm testing (except, as I've seen so far, the Frontpage view when it is not the site home page).

As a simple test I activated the built-in Archive view on a site I've been using for a while and it returns an empty active trail ($trail_ids = an array with a single element, an empty string), no matter where on the "Main navigation" menu it is placed.  In Page Settings its "Menu item entry" is set to type "Normal menu entry" and it doesn't matter what I select as a Parent on the menu: its active trail is empty everywhere.

I must be using the wrong function to get the active trail when the current page is a view, but I can't determine how from the documentation of getActiveTrailIds.  Users are starting to pile up for the D8 version of Menu Breadcrumb, which has used this method to get the active trail since the Alpha version, so I can't understand how or why it wouldn't work for such an obvious test case.

The conditions of this problem should be easy to reproduce, since all you'd have to do is download the module, and see that the breadcrumb trail for the Archive view has no breadcrumbs (unless there's something about all my sites here that is messed up!).


texts:
In D7 I have a search view but would like to change some layout of it.

My current HTML situation is:

<div id="block-block-12"  .....

<div id="block-block-13"  .....

<div id="block-block-14"  .....

In the current layout:

 --------------------------
|            |            |
|     B12    |     B13    |
|            |     B14    |         |
---------------------------

I would like to change this into

 <div id="block-block-12"  .....

 <div id="block-block-13"  .....

 <div id="block-block-14"  .....

The reason for this is that I would like to have a 100% background color styling with the help of class xxtr.

I set the width of all block at 33.3% but then the display is:

 ------------------------------------
|            |            |         |
|     B12    |     B13    |   B14   |
|            |            |         |
-------------------------------------

While the result should be with all the same background color:

 ------------------------------------
|            |            |         |
|     B12    |     B13    |   empty |
|            |     B14    |         |
-------------------------------------

I add a custom tpl for this query but do not understand how to get that extra div around these blocks.

The tpl file.

<?php

?>
<div class="<?php print $classes; ?> view--page">

        <?php print render($title_prefix); ?>
        <?php if ($title): ?>
            <?php print $title; ?>
        <?php endif; ?>
        <?php print render($title_suffix); ?>
        <?php if ($header): ?>

                <?php print $header; ?>

        <?php endif; ?>

        <?php if ($exposed): ?>

                <?php print $exposed; ?>

        <?php endif; ?>

        <?php if ($attachment_before): ?>

                <?php print $attachment_before; ?>

        <?php endif; ?>

        <?php if ($pager): ?>
            <?php print $pager; ?>
        <?php endif; ?>

        <?php if ($rows): ?>

                <?php print $rows; ?>

        <?php elseif ($empty): ?>

                <?php print $empty; ?>

        <?php endif; ?>

        <?php if ($pager): ?>
            <?php print $pager; ?>
        <?php endif; ?>

        <?php if ($attachment_after): ?>

                <?php print $attachment_after; ?>

        <?php endif; ?>

        <?php if ($more): ?>
            <?php print $more; ?>
        <?php endif; ?>

        <?php if ($footer): ?>

                <?php print $footer; ?>

        <?php endif; ?>

        <?php if ($feed_icon): ?>

                <?php print $feed_icon; ?>

        <?php endif; ?>

<?php /* class view */ ?>

Any suggestion ?


texts:
I am trying to find a simple way to display the results of a simple checkbox form on the same page after submit. I know you can use the drupal_set_message, but I want to display the results formatted on the page, not in the message box.

public function submitForm(array &$form, FormStateInterface $form_state) {
        drupal_set_message($this->t('Your favorite car is @fav_car', array('@fav_car' => $form_state->getValue('fav_car'))));
      }
    }

Full code for form here;

/**
 * @file
 * Contains \Drupal\cars\Form\FavoriteCarForm.
 */

namespace Drupal\cars\Form:

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\cars\CarsStorage;

/**
 * Class FavoriteCarForm.
 *
 * @package Drupal\cars\Form
 */
class FavoriteCarForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'favorite_car_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['fav_car'] = array(
      '#type' => 'radios',
      '#title' => $this->t('What is your favorite Car!'),
      '#options' => array('Toyota' => $this->t('toyota'), 'Ford' => $this->t('Ford'), 'Subaru' => $this->t('Subaru')),
    );

    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message($this->t('Your favorite car is @fav_car', array('@fav_car' => $form_state->getValue('fav_car'))));
  }
}


texts:
I'm using Drupal Commerce (7.x-1.4) + Commerce Coupon (and old version 7.x-1.0-beta6)

I'm using a custom checkout pane to handle my coupons redeem (we have a particular usage of coupons) and manually call the coupon redeem function after checking some stuff.

It works perfectly fine except that i cannot figure out how to make sure my custom pane form submit button doesn't trigger the whole form (and trigger all the checkout pane validations), but only my particular form

    function hook_my_pane_checkout_form($form, &$form_state, $checkout_pane, $order) {
    $order = $form_state['order'];
    $pane_form = array();
    $pane_form['ticket_code'] = array(
        '#type' => 'textarea',
        '#title' => 'Tickets',
        '#description' => 'Blahblah',
        '#rows' => 10,
    );

    $pane_form['submit_ticket'] = array(
        '#type' => 'button',
        '#value' => t('Submit my tickets'),
        '#validate' => array('_my_custom_ticket_validate_order'),
        '#submit' => array('_my_custom_ticket_submit_order'),
    );

    $pane_form['coupon_code'] = array(
        '#type' => 'textfield',
        '#title' => 'Coupon code',
        '#description' => 'Enter your coupon',
    );

    $pane_form['submit_coupon'] = array(
        '#type' => 'button',
        '#value' => t('Use my coupon'),
        '#validate' => array('_my_custom_coupon_validate_order'),
        '#submit' => array('_my_custom_coupon_validate_order'),
    );

    return $pane_form;
}

So this works ! Except that when I click on one of the submit button, it triggers the validation of the other checkout panes on the page.

I would like to prevent this as the user is redirected to the same page after using his coupons / tickets anyway.

How can I prevent this ?

Many thanks !


texts: How to consistently style the titles of Views in my Panels sidebar?

texts:
My Panels website has a sidebar and I put several Views in there as Panes. Every View has a title and I would like to wrap this title in a h3 header. Until now, I manually overrode the Pane's title with %title and chose the h3 tag in the Pane's settings. This works fine, but sometimes I forget to make the adjustments and then things look ugly for a while. It is also possible that one day I prefer to use h2 instead and then I will be facing dozens of Panes to adapt.

Therefore, I would like to know whether there is an easier and more efficient way to achieve what I want. After reading Drupal 7 Views: Use one views.tpl.php file for multiple views, I thought about using a View template, but I cannot just tag the Views that will turn up in the sidebar, because some Views have multiple blocks and only one of them will be put in the sidebar.

Do you have any suggestions that might make life easier for me (or at least the website developing side)?


texts: Create table while installing my custom module

texts:
My custom module name is "person" and its .install file has the following code.

<?php
/**
 * Implementation of hook_install().
 */
function person_install() {

  drupal_install_schema('person');
}

/**
 * Implementation of hook_schema.
 */
function person_schema() {

  // Static (meta) tables.

  $schema['person'] = array(
    'fields' => array(
      'pid'            => array('type' => 'int', 'length' => 11, 'not null' => TRUE, 'default' => ''),
      'name' => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE),
      'city'        => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE),
      'country'        => array('type' => 'varchar', 'length' => 50, 'not null' => TRUE)
    ),
    'primary key' => array('pid'),
  );
return $schema;
}

But when I installed my module the table has not been created.Any thing wrong with this code?


texts:
I'm just doing a one-off script, but I'm wondering if there's a correct "Drupal way" to alter a table and a unique key.

For example, this is essentially the query I want to do:

ALTER IGNORE TABLE `node_revision` ADD UNIQUE(`hash`);

And then if I later wanted to remove the unique index on hash, how would I also do that?

Does it have something to do with updating the database schema? or possibly db_change_field()?


texts: Can I access public:// from inside a module?

texts:
I need to load an image that's uploaded to the public folder from within a module

In the module itself:

function mymodule_dashboard() {
   GLOBAL $user;
   $profile = profile2_load_by_user($user->uid, 'personal_information');
   $data['avatar'] = $profile->field_picture['und'][0]['uri'];

In my dashboard.tpl.php:

<img src="<?php echo $data['avatar']; ?>" />

The rendered content:

I can pull the image name and build the path myself, but I'm looking for a way to actually take advantage of this public folder business


texts: how to force drupal to create tables with ENGINE=MyISAM

texts:
this is a popular error in drupal that you guys might have seen this before :

PDOException: SQLSTATE[42S02]: Base table or view not found, table .... does not exist.

when I'm trying to install drupal7, it reports an error that semaphore table does not exist. I tried to create it manually by this query

CREATE TABLE IF NOT EXISTS `semaphore` (
  `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique name.',
  `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'A value for the semaphore.',
  `expire` double NOT NULL COMMENT 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
  PRIMARY KEY (`name`),
  KEY `value` (`value`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table for holding semaphores, locks, flags, etc. that...';

it reported the same error. I changed InnoDB to myISAM and it worked!!!
I found out that tables with the InnoDB engine are not supported in mysql on the server and unfortunately drupal7 creates all the tables with this engine by default. is there any way to change this default to MyISAM ?


texts: How to create user with role(s) through REST service?

texts:
I could able to create a new user by the following JSON format.(Using POSTER add-on to post this data to REST service.)

{
   "name":"user34",
   "pass":"3323",
   "mail":"sample@example.com",
   "status":"1"
}

My question is how to create a user with specific role. I tried with the following JSON format.

{
   "name":"user35",
   "pass":"pwds3",
   "mail":"sample2@example.com",
   "status":"1",
   "roles":{
      "2":"authenticated user",
      "4":"moderator"
   }
}

but the response gives the following error

  ["An illegal choice has been detected. Please contact the site administrator."]


texts: How do I add a custom field to the image field widget in Drupal 7?

texts:
I need to add a custom field (a simple text field) to the image_field widget in Drupal 7.

The structure is a standard node (called Article) which has zero or more images (related photos or graphics) attached via the image_field widget. The field I want to add is the source of the image, and is used later to figure out when it needs to be deleted.

I've tried the code from this post, but couldn't get it to work.


texts:
I am using ubercart guest checkout module. I am able to submit  the order as guest etc works fine.

After Reviewing the order and submitting it throws me this error

Recoverable fatal error: Argument 2 passed to db_query() must be an array,
string given, called in
/var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module
on line 263 and defined in db_query() (line 2342 of
/var/www/html/dev.demo.net/includes/database/database.inc).

This is the query which is causing that issue

db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account->uid);

I tried to change this query like this

db_update('users')
->fields(array(
    'name' => $name,
    'mail' => $mail
))
->condition('uid',$account->uid,'=')
->execute();

still no luck, it throws me same above specified error.

How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance.


texts: set up social login for multiple drupal sites?

texts:
I intend to set up multiple independent drupal installations, each of which could benefit from social logins. I like HybridAuth, but it requires me to set up multiple "applications" (one for Google, one for Github, one for Facebook etc) for each site.

Any thoughts on how to automate creating these "applications"? Or maybe a different solution? I've tried OneAll but the Drupal module seems quite buggy.


texts:
Reset button is not working after previewing the webform.
Means when we click on preview button on webform, then on edit button of webform and then if we click on reset button. it does not work at all. What could be the reason, kindly suggest any solution?
My code is as follows :

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

  switch ($form_id) {

    case 'webform_client_form_XYZ':
        $form['submitted']['reset'] = array(
            '#type' => 'button',
            '#value' => t('Reset'),
            '#weight' => 100,
            '#validate' => array(),
            '#attributes' => array('onclick' => 'this.form.reset(); return false;'),
        );
   }


texts:
Half of our content types have had their publication status fields overridden. The override is causing the fields to read "Publishing status" and have the description "A boolean indicating whether the node is published." I believe this is the same problem described in this comment. The row names are in the format core.base_field_override.node.[content-type].status in the database.

However, I am unsure of how to properly remove these overrides. Certainly I could just delete that row of the config table, but I am unaware of what consequences that may have or whether that would be the appropriate way to handle this one-time problem.

Can anyone tell me the correct way to remove base field overrides? Thanks!


texts: template file for content header of a view

texts:
I am using views 2. In views, it asks you for the title of the view and this title is displayed on the screen at
div id=content -> div id=content-inner -> div id=content-header -> h1 id=title
I would like to know if there is a template file which I can modify that can modify this title (ie: add some text to it). I think I can do this with javascript or with css using :after, but I would like to use a template if is available.


texts: Temporarily change the current language during a request

texts:
Background information

I am developing a multilingual Drupal 8 commerce site where only authenticated users (customers) can place orders (anonymous users can't place orders). Customers can edit their preferred language using the default language field on their account. After an order is placed, another user with a special role (webmaster) has to prepare the order and physically fill a box with the contents of the order. When the webmaster is ready, he performs a transition on the order changing it's state. This transition triggers an e-mail that is sent to the customer, informing him that his order is ready for shipment. This e-mail is triggered through an event subscriber that reacts on the shipping transition of orders. The e-mail is formed by rendering a custom template.

Problem

A customer who's preferred language is Dutch, has placed an order. A webmaster is using the website in English and sets the order 'ready for shipment'. The customer gets an English e-mail while he should get a Dutch e-mail.

Code

The code that triggers the e-mail:

/** @var \Drupal\commerce_order\Entity\OrderInterface $order */
$order = $event->getEntity();

$to = $order->getCustomer()->getEmail();
$langcode = $order->getCustomer()->getPreferredLangcode();
$subject = $this->t('Your order #@order_number is packed', ['@order_number' => $order->getOrderNumber()], ['langcode' => $langcode]);

$build = [
  '#theme' => 'commerce_order_shipped_mail',
  '#subject' => $subject,
  '#order_number' => $order->getOrderNumber(),
  '#order_date' => $this->dateFormatter->format($order->getCompletedTime(), 'default_date_only'),
  '#order_url' => Url::fromRoute('entity.commerce_order.user_view', [
    'user' => $order->getCustomer()->id(),
    'commerce_order' => $order->id(),
  ], ['absolute' => TRUE]),
];

$mail = $this->mailManager->mail('order_shipped_mail', $to, $subject, $build, $langcode);

The mail function of the mail manger (wrapper):

$name = \Drupal::config('system.site')->get('name');
$email = \Drupal::config('system.site')->get('mail');
$from = '"' . $name . '" <' . $email . '>';

$params = [
  'headers' => [
    'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' => '8Bit',
    'From' => $from,
  ],
  'from' => $from,
  'subject' => $subject,
  'body' => $this->renderer->renderRoot($body),
];

$langcode = $langcode ?: $this->languageManager->getDefaultLanguage()->getId();

return $this->mailManager->mail('XXX_general', $key, $to, $langcode, $params);

The custom template:

{{ 'Shipping confirmation'|t }}

{{ 'Dear customer,'|t }}

            {% trans %}
            Your order #{{ order_number }} of {{ order_date }} has been handed over to XXX.

            You will receive an email from XXX with the tracking information of your package.
            {% endtrans %}

{{ 'Order details'|t }}

The XXX team

As you can see a custom template is rendered that contains the body of the e-mail.

Actual question

How can I temporarily change the current language during a request so rendering happens in the correct language? I know I can give a langcode to a t-function but my rendered order URL would still be an English URL so this doesn't fix the problem. I have tried suggestions from here, and I thought the LanguageNegotiation Plugin would do the trick, but it doesn't.

Please excuse me if my question is malformed or if I provided to little information.


texts: Are changes to the user status stored somewhere?

texts:
I've made a pretty serious error of judgement creating a view for a client that shows users created before a date AND still active. The error was adding a date filter.

This was meant to be used at the end of each month, and it was, with an email of users sent to the client. Now, after many users have been blocked, they're showing back on the view I created.

With quarterly billing, this is an issue as new users get counted fine, but any old users who have been blocked since don't show. A year from now, this period could actually show zero users.

The accounts were blocked using the editable_fields module.


texts: How can I allow users to receive e-mails whenever I update my blog in Drupal 7?

texts:
I have a blog in English and Japanese in Drupal 7.  I created this blog using a custom content type and Views, not the built-in blog module.

I have an RSS feed (made in Views) for each language.  I would like to allow users to subscribe to receive all English-language updates to content type "blog" or all Japanese-language updates to content type "blog."  (I anticipate most users will only want one language or the other.  If a user really wants both languages, I don't mind making them subscribe twice.)

I looked into using Feedburner on the RSS feeds, but the Feedburner module has not been updated for D7 and I would rather not rely on an external service.  (When I tried setting up Feedburner without the module, it told me my RSS feed didn't exist even though the support link allowed me to validate it.)

I also looked at the Simplenews module, but that module apparently requires creating each newsletter post separately.  What I want to do is automatically e-mail subscribed users when I post an update to the blog.

I'm sure there are a lot of ways to do this, but there are so many "mail helper"-type modules that I'm at a loss as to where to get started.

To summarize my requirements, I want to:

Automatically e-mail subscribers when a new blog post in the appropriate language is added.
Both authenticated and anonymous users should be able to subscribe.
Subscriptions must require confirmation (legal requirement).
Compatibility with the MIME Mail module would be a nice bonus.


texts: Users can choose image style on content type?

texts:
I want to display image style list in particular content type. Users can choose their image style from the list provided.

Is it possible to achieve this?


texts:
I have created a Taxonomy vocabulary called "Model" that has some Term like: Beautiful - Cool - Cute - Awesome so-forth. Now, i want to show most recent 6 posts under "Beautiful" term from "Model" vocabulary using a views block. But can't understand how to build the views block. I came through this many Q like this

How do I show only 3 of the latest posts for each term in a view?
Show newest nodes for each taxonomy term in Views

but cant understand how to make a views block to show recent 6 posts under "Beautiful" term from "Model" vocabulary using a views block? Any idea? Thanks


texts: Evaluating whether a button was clicked with php code in Rules

texts:
Using the Publish Button module, I added Publish/Unpublish buttons to some of my nodes. I want the site to perform an action every time an admin clicks "Publish" after editing a node.

I followed some instructions from this answer, but my php code always evaluates to false. Since $form_state['clicked_button']['#value'] is deprecated, I tried another approach. I added a #name attribute ('publish') to the button (line 103 of publish_button.module) and wrote this function inside the Rules interface (execute custom php code):

function button_check() {
$values = $form_state['input'];
  if (isset($values['publish']) {
    return true;
  } else {
    return false;
  }
}

This is the code from the module file (line 103):

    function publish_button_render_publish_button() {
  $publish_button = array(
    '#type' => 'submit',
    '#access' => TRUE,
    '#value' => t('Publish'),
    '#weight' => '30',
    '#name' => 'publish',
    // Add the submit handler.
    '#submit' => array('_publish_button_publish_node'),
  );
  return $publish_button;
}

I am aware that I might be making some serious beginner's mistakes here, but I am new to Drupal and php.


texts: Can we use current views exposed filter values to prepopulate another form?

texts:
I've set up a view that displays users and has exposed filters user first and last names. If there is no user matching the filter values, I'd like to display a link to create a new user and prepopulate the name fields with the values searched in views.

I know there's the prepopulate module and likely other methods to do the actual prepopulating, but I guess this question is more centered on how to grab the filter values so they can be added to the new link url as properly formatted arguments.

EDIT: Got this solved with help from the answer below. Ending up grabbing the filter values with the "exposed filter values" module and populating the field values in a custom module with this code:

function hook_form_alter(&$form, &$form_state, $form_id) {
    if ($form_id == 'user_register_form') {

        //Prepopulate the name fields with url args
        $field_lang = $form['field_name']['#language'];
        if(isset($_GET['first'])) {
            $first = $_GET['first'];
            $form['field_name'][$field_lang][0]['#default_value']['given'] = $first;
        }

        if(isset($_GET['last'])) {
            $last = $_GET['last'];
            $form['field_name'][$field_lang][0]['#default_value']['family']= $last;
        }
    }
}


texts: How to display a field twice in a view mode?

texts:
I'd like to display a field_address in a view mode twice, once as the displayed address and once as a google maps directions link.  I suppose I could create one custom field formatter that outputs both components, but it seems excessive to create a formatter to display basically what should be two formatters.

Is there a way, say in hook_entity_view to display a field twice with two formatters?  Basically say $build['field_address_direction'] = $build['field_address'] and then change the formatter?


texts: 8: How to specify multiple css media types in a libraries.yml file

texts:
Entering the list "screen, print" doesn't work:

base:
  version: VERSION
  css:
    theme:
      css/styles.css: { media: screen, print }

The resulting HTML should be:

<link rel="stylesheet" type="text/css" href="css/styles.css" media="screen,print" />


texts:
I am trying to update Drupal core from 7.32 to 7.34 using drush. It initially appears to be sucessful, however the status report and /modules/system/system.info still show the version number as 7.32. I have tried running update.php but it says that there are no updates.

I have another Drupal site on the same server that is very similar and had no issues updating it to 7.34.

The output of drush when updating is:

drush5.5-sp pm-update
 Name    Installed Version  Proposed version  Message
 Drupal  7.32               7.34              SECURITY UPDATE available

Update information last refreshed: Thu, 11/27/2014 - 22:43
Code updates will be made to drupal core.
WARNING:  Updating core will discard any modifications made to Drupal core files, most noteworthy among these are .htaccess and robots.txt.  If you have made any modifications to these files, please back them up before updating so that you can re-create your modifications in the updated version of the file.
Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing.

Do you really want to continue? (y/n): y
Project drupal was updated successfully. Installed version is now 7.34.
Backups were saved into the directory                                [ok]
/srv/users/site/drush-backups/u7i6t765rib76nb7tionytbyi_site/20141127154450/drupal.
No database updates required                                         [success]
'all' cache was cleared.                                             [success]
Finished performing updates.                                         [ok]


texts: Possible to use tags/buttons as exposed filters?

texts: I have a view that will be a grid of a dozen content types. I would like to have a tag-like button or text link above the view of content to allow the user to toggle / filter between what content type they wish to see. I know that exposed filters allows you to use a dropdown or auto-complete, but is this possible with using tags as buttons?


texts: 8 - How to set page title for certain nodes?

texts:
I've created the following codes:

The first one is mymodule/mymodule.services.yml

services:
  mymodule.route_subscriber:
    class: Drupal\mymodule\Routing\RouteSubscriber
    tags:
      - { name: event_subscriber }

The second one is mymodule/src/Routing/RouteSubscriber.php with following code

<?php

namespace Drupal\eq_site\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('entity.node.canonical')) {
      $route->setDefault('_title_callback', '\Drupal\mymodule\Controller\MyModuleController::title');
    }
  }
}

mymodule/src/Controller/MyModuleController.php contains following code:

<?php

namespace Drupal\mymodule\Controller;

use Drupal\Core\Entity\Controller\EntityViewController;
use Drupal\Core\Entity\EntityInterface;

/**
 * Returns responses for Node routes.
 */
class MyModuleController extends EntityViewController {
  /**
   * The _title_callback for the page that renders a single node.
   *
   * @param \Drupal\Core\Entity\EntityInterface $node
   *   The current node.
   *
   * @return string
   *   The page title.
   */
  public function title(EntityInterface $node) {
    return 'Foo : '. $this->entityManager->getTranslationFromContext($node)->label();
  }
}

Devel route detail is:

stdClass Object
(
    [__CLASS__] => Symfony\Component\Routing\Route
    [path] => /node/{node}
    [host] =>
    [schemes] => Array
        (
        )

    [methods] => Array
        (
            [0] => GET
            [1] => POST
        )

    [defaults] => Array
        (
            [_controller] => \Drupal\node\Controller\NodeViewController::view
            [_title_callback] => \Drupal\mymodule\Controller\MyModuleController::title
        )

    [requirements] => Array
        (
            [node] => \d+
            [_entity_access] => node.view
            [_method] => GET|POST
        )

But, page title has not changed.
What I do wrong?
And how to determine the node type?


texts: File in field_file disappears after saving a node

texts:
Like I wrote in the title. After I upload the file it is being saved in my folder correctly, but after I save the node, it just doesn't remember I have uploaded it. The file stays in the folder I uploaded it to.

Is there any way to solve it?


texts: Is it possible to nest flexsliders? (with manual navigation?)

texts:
I have use case where I need to nest a flexslider into another flexslider; I'm not having much success and was hoping someone might be able to provide some insight. It should look something like this:

Basically, I have panelized nodes which each contain a flexslider pane generated by Views using the flexslider formatter. These panelized nodes with flexsliders also need to appear as slides in another views-generated flexslider on a landing page.

Unfortunately, the landing page doesn't seem to be processed correctly by flexslider's JS; <li> elements are getting rendered underneath the flexslider element, navigation controls the wrong slideshows, etc. I have I think I'm having a hard time finding the correct selectors to use for each flexslider. I see I can add an element id to the flexsliders in Views and I have set up unique presets for the inner node flexslider and outer landing page flexslider, but using a string like #innerflexslider > li in the advanced settings doesn't seem to work.

I'd appreciate any advice.

Thanks! :)


texts: How to make one field's appearance on form depend on another field

texts:
Please I need to create a field whose appearance on my form depends on the field immediately preceding it.

For example in field A the user is asked a true or false/yes or no question. E.g Do you like the English premiership?

If he answers true, a previously hidden field B (which is a taxonomy term)is presented to the user e.g Choose your preferred English Premiership club.

If he answers no, nothing happens.

P.S. Both field will be created via Profile 2 module.

Thank you.


texts: When I assign custom role to any user here impact protection user then after its expiry date it automatically assigns role to authenticated user. How can I remove or disable that option to not automatically assigns to authenticated user. If specified date expires then user will unable to login for that specified role impact perfection user?


texts: the URL 'admin/content/node' created by 'content' views in drupal 8 isn't available

texts: I'm beginner of drupal8.When I call the url "localhost/admin/content/node",  will show "The requested page could not be found". in the preview of this views,the url is 'admin/content' and it's available. Why did this change it？  someone can help me?


texts: Accessing Drupal.settings outside of attach function

texts:
I'm trying to make some of my Javascript in a Drupal 7 module a bit more modular, as I want to access a function inside Drupal.behaviors.attach() from another JS file. So first of all I need to move some variable declarations, and then the functions, outside of the attach function and hopefully access the variables from inside it with this.vars.myVariable - I'll try and explain a bit further with some slightly dummified code...

Initial, working code:

(function($) {
  Drupal.behaviors.myModule_someJS = {

    attach: function(context, settings) {

      var initial_page = Drupal.settings.myModule.initial_page;
      console.log(initial_page); // returns a value

    }
  }
})(jQuery);

However, this doesn't work:

(function($) {
  Drupal.behaviors.myModule_someJS = {

    vars: {
      initial_page : Drupal.settings.myModule.initial_page
      // Uncaught TypeError: Cannot read property 'initial_page' of undefined
    },

    attach: function(context, settings) {

      console.log(this.vars.initial_page);

    }
  }
})(jQuery);

It seems that outside of the scope of the attach function, Drupal.settings doesn't exist. Is there any way I can access these settings (defined in my .module file) from anywhere within behaviors.myModule_someJS ?

Thanks! Matt


texts:
I need to essentially trigger a context when a certain filter value is selected.  Basically, in a view, when a filter is selected, based on the value selected I need to display a certain block.

Does anything like this exist?  Or am I going to have to build my own extension to Context?


texts: Place custom content field only on sidebar

texts: i have created a custom content type "My_Content" with some custom fields. One of the fields in "My_field". Now, when the user is creating a content of type My_content, he/she is asked for the fields like title, body, picture, My_field etc...What i need is that the My_field always displays on the right sidebar. Is there a way to achieve this?


texts: Altering the type of a menu item to local task (tab)

texts:
I've searched for hours but I can't find a good answer on how to alter the type of a menu item to local task (tab).

The private messages 7.x module (when aided by privatemsg_filter) exposes the following tabs (local tasks):

Inbox (/messages)
Sent Messages (/messages/sent)
All Messages (/messages/list)

There is a 4th menu item (/messages/new) which is currently a MENU_LOCAL_ITEM and I want to make it a local task as well. But how? And what is the best way?


texts: Cannot run composer update after going from 8.3 to 8.5

texts:
Upon trying to run composer update drupal/core --with-dependencies, I get this error:

➜  docroot git:(core-upgrade) ✗ composer update --with-dependencies
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.

I've never had this error before, why is ext-gd required at all?

Edit:

I am currently doing this:

phpbrew install 7.1.15 +default+iconv+gd

php -m did not show gd as an installed extension. I've been fine for months until now, so, I am not sure if there was some change between 8.3 to 8.5 or possibly Symfony packages that suddenly requires this.

Edit 2:

This looks like it is also related to updating Homebrew/Xcode, as I had to take these additional steps in order to build a new version of PHP:

https://github.com/Homebrew/homebrew-php/issues/4590#issuecomment-346977512

Still does not explain why I suddenly need the gd extension to install or update a module with Composer for Drupal.


texts:
I have a paragraph with an image field. If the image field is empty, I want to display a default value. I do not want to just set the default image because an editor could remove that. Here is my code so far:

{% if content.field_image|render = true %}
    {{ content.field_image }}
{% else %}
    {% include "/themes/mytheme/img/my_img.png” %}
{% endif %}

How can I get the image at that filepath to show up in the template?


texts:
In the following code custom call back function is being printed twice. How to prevent submit call back function being called twice.

function my_module_form_alter(&$form, &$form_state, $form_id){
 if ($form['#id'] == "views-exposed-form-test-page"){
    $form['#submit'][] = 'custom_callback';
  }
}

function custom_callback($form,&$form_state){
    $form_state['redirect'] = false;
    dpm("insert record");
}


texts: Cant get desired results for multiple sort criteria in a view

texts:
I have created a points table for a race event and would like to sort the results in a specific order.

I am working with a table view that contains 3 sort criteria:

the race event (working fine done via table settings)
class of a car A, B , C and
the points each driver receives.

I would like the order to be A then points B then points C then points regardless of what class has the highest points.

Problem:

If for example a C class car has points higher than any B class car then the stacking order is ACB. As soon as any B class car gets higher points than the C class car then the order is ABC (how I would like it). This can be seen in class A where Driver 2 has the lowest points of all.

I have tried re arranging the sort order but that does nothing.


texts:
I have a pdf sharing site with a content type which called PDF. This content type has many fileds (such as author, description, rating, etc). These fields display in simple rows but I want to change either their form and css. for example I want to show Rating number much bigger (and in other color) on the top of each post. what can I do?
Am I able to define new css classes for these fields?


texts: Are node title & body instances update-able through the field API?

texts:
I'm guessing it's not possible, since what works on other instances won't for the title & body. (Trying to adjust widget weight.)

  $core_instances = array(
    // array(
    //   'field_name' => 'title',
    //   'entity_type' => 'node',
    //   'bundle' => 'article',
    //   'weight' => 1,
    // ),
    // array(
    //   'field_name' => 'body',
    //   'entity_type' => 'node',
    //   'bundle' => 'article',
    //   'weight' => 4,
    // ),
    array(
      'field_name' => 'field_tags',
      'entity_type' => 'node',
      'bundle' => 'article',
      'weight' => 7,
    ),
    array(
      'field_name' => 'field_image',
      'entity_type' => 'node',
      'bundle' => 'article',
      'weight' => 6,
    ),
  );

  foreach ($core_instances as $instance) {
  $instance_info = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
  $instance_info['widget']['weight'] = $instance['weight'];
  field_update_instance($instance_info);
  }

If I uncomment the title & body instances, I get the following error:

  FieldException: Attempt to update an instance of a nonexistent field . in         [error]
  field_update_instance()


texts: How to print the search results after form_submit, in a custom search module?

texts:
I am creating a custom search block, I have created a form in the block. Here is my form_submit. I need to print a html table of some of the fields in the $result array. I am using Drupal_set_message(), I need to show the results in a table instead, so that user can print the page

$text = $form_state['values']['text'];
$query = db_select('table_1', 'n');
$query->fields('n', array('id'));
 $query->fields('n', array('phone'));
$query->fields('n', array('name'));
$query->condition('n.p_id', $text, '=');
$column_name = $query->execute();


texts: create as many nodes when using user reference

texts: I have a User Reference field in one of my content type. When a user saves that content type selecting the users (we can select any number of users), I want to create another content type. The second content type has to be created by triggering a rule and has to be created as if the users selected in the first have created it. and if 3 users are selected 3 nodes of that type have to be created. how can we do this in drupal?


texts: Why I'm getting theme related error when trying to add external JS to form?

texts:
I'm trying to add Google Map API to node form:

/**
 * Implements hook_form_FORM_ID_alter().
 */
function mm_form_node_foo_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
    $form['#attached']['library'][] = 'google/maps';
}

Library config (mm.libraries.yml in module root directory):

google.maps:
  js:
    https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places&callback=initMap: {type: external, attributes: { defer: true, async: true, data-test: map-link } } }

and the error is:

  User warning: The following theme is missing from the file system:
  google in drupal_get_filename() (line 234 of
  core/includes/bootstrap.inc).


texts: How to display an image in a report created with the Forena module?

texts:
I created a report using the Forena module. In this report I want to display image which is saved in a private folder. I am fetching the image url from the file_managed table using file_load() method on the basis of file id.

How can I display the image in my report?


texts: How to send node as body content in email using Rules?

texts: I wonder if there is a way of inserting the contents of a node into the body of the email when using the Rules module?


texts: How to manage the display of a multiple value field in a individualy way?

texts:
I have a content type with a field called "anotations" which is set to have 2 values.

Im using display suite,then in admin/structure/types/manage/mycontenttype/display I'd like to show the 1st value of the "anotation" field in the "header" region and the 2nd value of the "anotation" field in the footer.

Is there any way to do this?

Just in case someone wonders why do I need to do this: I'm just trying to avoid to create new fields as much as I can, since I noticed that having too much fields affect the general performance of the site.


texts:
I'm using the simplecorp theme https://www.drupal.org/project/simplecorp but I suspect that this issue translates to other themes as well.

In the edit forms, the fields sets seem to overlap into teh next region to the right.  Is there a way to set teh correct widths on the fields sets?


texts: Trying to show multiple relationships with Drupal view

texts:
I have a website with Car manufacturers (c_manufacturer), each Manufacturer has car Models (content type: c_model), and each model has picture (content type: model_pictures).

I'm trying to create a view to display on every Manufacturer's page and show the car pictures of the car models that belong to that Manufacturer.
Using Contextual Filter for the Manufacturer node ID, I added 3 relationships:
Content: c_manufacturer  - reverse
Content: c_model  - reverse (Using Relationship: c_manufacturer)
Content: model_pictures  - reverse (Using Relationship: c_model)

I tried to show the Title field (something that all of the content types have on my site)
and I keep getting no result on the view Preview (when giving a manufacturer ID as an argument), what am I missing ?


texts: AJAX select field - $form_state not saved

texts:
SOLVED (see comments)

I have a form with a select field (where you can select a title of a novel). This select field automatically writes a the respective ISBN of the novel into a textfield when a title of the novel is chosen by the user. The user can add more novels via a button.

$form['fieldset-books'] = [
  '#type' => 'fieldset',
  '#title' => t('Books'),
  '#prefix' => '<div id="books-fieldset-wrapper">',
  '#suffix' => ' </div>',
];

if (empty($form_state['count_novels'])) {
  $form_state['count_novels'] = 1;
}

for ($i = 0; $i < $form_state['count_novels']; $i++) {

  $form['fieldset-books']['fieldset-novel'][$i] = [
          '#type' => 'fieldset',
          '#title' => t('Novel'),
  ];
  $form['fieldset-books']['fieldset-novel'][$i]['title'] = [
    '#type' => 'select',
    '#title' => t('Title'),
    '#empty_value' => '',

    '#options' => NOVEL_TITLE,
    '#ajax' => [
      'callback' => 'ajax_callback',
      'wrapper' => 'books-fieldset-wrapper',
      'event' => 'change',
    ],
  ];

  $form['fieldset-books']['fieldset-novels'][$i]['isbn'] = [
    '#type' => 'textfield',
    '#title' => t('ISBN'),
    '#attributes' => [
      'placeholder' => t('- will be automatically assigned -'),
      'readonly' => 'readonly',
    ],
  ];
}

$form['fieldset-books']['novel_add'] = [
  '#type' => 'submit',
  '#value' => t('Add Novel'),
  '#name' => 'AddNovelButton',
  '#submit' => ['ajax_submit'],
  '#ajax' => [
    'callback' => 'ajax_callback',
    'wrapper' => 'books-fieldset-wrapper',
  ],
  '#limit_validation_errors' => [],
  '#attributes' => ['class' => ['btn-primary btn-sm']],
];

function ajax_callback($form, $form_state) {
  if ($form_state['triggering_element']['#name'] == 'AddNovelButton') {
    return $form['fieldset-books'];
  }
  elseif ($form_state['triggering_element']['#name'] == 'DiseaseSelect') {

    for ($i = 0; $i < $form_state['count_novels']; $i++) {
      if (isset($form_state['values']['fieldset-books']['fieldset-novel'][$i]['title'])) {
        $isbn= ISBN[array_search($form_state['values']['fieldset-books']['fieldset-novel'][$i]['title'],
          array_keys(TITLE))];
      }
      else {
        $isbn= NULL;
      }
      $form['fieldset-books']['fieldset-novels'][$i]['isbn']['#value'] = $isbn;
    }
    return $form['fieldset-books'];
  }
  $form_state['rebuild'] = TRUE;
  return NULL;
}

function ajax_submit($form, &$form_state) {
if ($form_state['triggering_element']['#name'] == 'AddNovelButton') {
    if (!isset($form_state['count_novels'])) {
      $form_state['count_novels'] = 0;
      $form_state['count_novels']++;
    }
    $form_state['count_novels']++;
  }
  $form_state['rebuild'] = TRUE;
}

The problem is, that the $form_state of the novel title is not saved / reset when the user picked a novel title from the select list. After the rebuild the novel title field is empty again (and so is the ISBN field).

I tried to find the bug by reducing the code /complexity (e.g. removing the novel-fieldset) but nothing worked.
When setting the $form_state for the novel title manually like

$form_state['values']['fieldset-books']['fieldset-novel'][0]['title'] = 'Robinson Crusoe';

The correct ISBN gets resolved after the rebuild but the title field is empty again.

Any idea, what i did wrong?


texts: How to get absolute url with different domain language prefix

texts:
What is the best way to get absolute url with correct language prefix?
The url() function accepts language parameter but it seems that it is not using it to generate the prefix - only to get translated alias. I don't care about aliases - I need correct domain prefix.

When I'm on http://en.example.com/something and use this code:

<?php
$all_languages = language_list();
url('something-else', array('language' => $all_languages['nl'], 'absolute' => true));
?>

I will get this: http://en.example.com/something-else (en prefix).

How can I get this: http://nl.example.com/something-else (nl prefix).


texts: Allow SKU adjustments based on only one Attribute in Ubercart?

texts:
I have a product where customers can select six different flavors from six individual select boxes (there are eleven flavors listed in each box), and one other select box where they can select their package size (2 oz packs vs 5 oz packs). It's a food product that comes in two package sizes; on this product page they are ordering a mixed case and their size selection determines whether they are ordering a case of 2ox bags or a case of 5oz bags.

I need to adjust the SKU to MIXED-2OZ or MIXED-5OZ based on the "size" selected by the shopper, but I do not want the flavors to come into play for this SKU adjustment. How can I exclude the flavors attributes/options from the Adjustments tab so that only the size will affect the SKU?

I suppose one workaround would be to set a SKU for each size/flavor combination, but we would be talking about hundreds of available combinations. The sheer number of available combinations is also causing my Adjustments tab to timeout, as is described here: http://drupal.org/node/375019.

Thanks!


texts: Item list added by "Page_alter" disappear

texts:
I added a list item by HOOK_form and HOOK_page_alter. After cache cleaning, the list appeared and it did the job but when i changed page, this list disappeared for no reason. She never returned on any pages. To solve that i need to clean the cache again...

My url :    homeproject?projet=3737

My code :

function header_eltmission_form($form, &$form_state) {

    $elmissionvalues['AVC'] = "Avant-Contrat";
    $idPjt = $_REQUEST['projet'];
    //Get the missions of the project
    $mission = _getElementMissionNode_ByPjt($idPjt);

    if(isset($mission)){
      foreach ($mission as $value) {
        $elmissionvalues[t($value->title)] = t($value->title);
      }
    }

    $form = array();
    $form['list_eltmission'] = array(
      '#type' => 'select',
      '#attributes' => array('name' => array('list_eltmission')),
      '#prefix' => '
',
      '#suffix' => '
',
      '#validated' => TRUE,
      '#options' => array_unique($elmissionvalues),
      '#ajax' => array(
         // 'callback' is a function that will be called when this element changes.
         'callback' => 'header_eltmission_callback',
         // 'wrapper' is the HTML id of the page element that will be replaced.
         'wrapper' => 'replace_textfield_div',
      ),
    );

    return $form;
}

function header_eltmission_callback($form, $form_state) {
     $valeur = $form_state['values']['list_eltmission'];
     $idPjt = str_replace("/homeproject?projet=", "", $form['#action']);

     $node = node_load($idPjt);
    $node->field_pjt_element_de_mission = array('und'=>array(array('value'=>$valeur)));
    node_save($node);

}

function header_eltmission_page_alter(&$page) {
    if(current_path() == 'homeproject') {

    $liste = array();
    $liste = drupal_get_form('header_eltmission_form');

    $page['header'] = array(
        '#weight' => -10,
        '#markup' => drupal_render($liste),
    );
  }
}

Someone got this problem ? How can i solve this please ?

Thanks


texts: Sometimes CCK custom fields get lost although they appear normally in the database

texts:
I have pressflow 6.22.

When the editors try to create new node, they lose what they have inserted in CCK custom fields. I have checked node_load and the result is missing those values as well.

I checked the tables and the result is as below:

mysql> select * from content_field_headline_image where nid=380320\G
*************************** 1. row ***************************
                                  vid: 380322
                                  nid: 380320
  field_headline_image_imceimage_path: http://mywebsite.com/sites/default/files/im/Maven.jpg
 field_headline_image_imceimage_width: 0
field_headline_image_imceimage_height: 0
   field_headline_image_imceimage_alt: Maven
                                delta: 0

but this image doesn't appear in node_load result as well as in the preview of the node itself.
##EDIT##

I fixed it when I flush_all for memcache !!

Any idea of how to disable memcache for logged-in users only??

note:cache mode is disabled (cache mode in admin>>performance)

Thanks for your help


texts: page--front.tpl.php being ignore in favour of page--node--page.tpl.php

texts:
I've got an issue which I'm not sure how to address. I've got a specific page that I've set as front page. I've created a custom template for it and named it page--front.tpl.php and it was as expected until I've added page--node--page.tpl.php which seems to be overriding page--front.tpl.php.

Is this the correct and expected behaviour? How can I force it the page--front.tpl.php to be used?

I'm using Drupal 7 with and a child of the Bootstrap's theme.


texts:
I am trying to create a custom content pane where I would be able to specify 8 values and create 4 divs with 2 values in each one of them. For this I am extending cTools module by creating a plugin. I am already able to fetch input and store it in $conf variable. The problem is that it seems that everything I do in render function doesn't work. At first I though I had some naming problems. My module name is

  uzduotis

And here is my code for render function:

function uzduotis_render($subtype, $conf, $args, $context) {

  $block = new stdClass();
  $block->title = "4Divs";

  $html = '';
  foreach ($conf as $key => $items) {
       $html .= '
' . $items['text'] . $items['link'] . '
';
  }

  $block->content=$html;

  return $block;

  dpm($block);
}

I try to dpm my block and I get nothing, also another strange thing is that even a block title doesn't show up which I guess notifies that something is completely wrong. Can someone please point out what is wrong? If you need some additional information, please ask for it and I will update. Thank you in advance.


texts:
I configured a View showing all groups the user belongs to. I also added the name of the author and his/her role.
In the Preview of the View everything is OK, the same if Im logged as an admin (user1).
But if Im logged as an authenticated user, the view is not showing up the Role column.

Any ideas what can be wrong? Maybe some permissions, but which one?


texts: Override comment.tpl.php file with theme

texts:
Objective:
Override comment.tpl.php file output in drupal core modules.

Assumption:
My best guess is that I need to create a comment-[type].tpl.php file in my themes folder.

Requirements:

template.php can not be used
need to replace default comment.tpl.php html output

Questions:

how do i find the so called type of the comment for the tpl file?
is this the best way to change the html output of the file?
is there another way to change the output with the type or using template.php?

Links: http://drupal.org/node/190815


texts: How to translate node programmatically with correct revision translation affected value?

texts:
I have a question about create node translation programmatically.

First of all, the following is the database screenshot when we use drupal UI to create the translation.

The revision_translation_affected will be set to the language each time when the new one is created.

For example, I create an English article and then translate it with Chinese.

We can see the revision translation affected has been set with the Chinese version because of the translation is the latest created.

However, I use the following code to create a node and add the translation.

$post = \Drupal::entityTypeManager()->getStorage('node')->create(
        [
            'type' => 'page',
            'title' => 'test title',
            'langcode' => 'en'
        ]
    );
    $post->save();
    $source_translation = $post->getTranslation('en');
    $target_translation = $post->addTranslation('zh-hant', $source_translation->toArray());
    $target_translation->save();

I got the following database result

This result will cause the revision confusion when we want to see the revision record from each translation.

Does anyone have experience on how to handle this issue?


texts: Using confirm_form to lead into a batch process

texts: How can you use confirm_form from hook_menu and present the user with a Confirm action page, when clicked, goes and sets a Batch process?


texts: status report asks me to run update.php but getting 'no pending updates'

texts:
I'm on core version 7.58.

My status report says "Some modules have database schema updates to install. You should run the database update script immediately."

But when I run update.php (or drush updb) I get 'no pending updates'.

I'm not experiencing any problems with the site (except for a small bootstrap-issue that doesn't seem related) and the log doesn't display any errors or warnings.

What can cause this?


texts: Microdata showing empty itemscope and false values for itemref

texts:
I have installed Microdata 7.x-1.0-beta2 module, I am facing few issues in my structured data. I added all the fields in my content type for Microdata, but when I am viewing the source of my page it's showing the following lines:

I am not sure why it's showing the itemscope field blank and itemref fields as md1,md2,md3,md4.

What I am expecting it should show me the itemprop for my two image fields, because I have two image fields in my content type.

Please report if anyone is facing the same issue, and if anyone had fixed it please let me know how to get rid of this.


texts:
I've recently had to restore a website after a server crash. I have the majority of the website back up and running.

The problem comes when I flush the cache or disable a module. Images that were being displayed become missing. Looking at Chromes inspector it appears Drupal is looking in the wrong location.

Instead of looking in sites/default/files/styles/footer_blog/public/blog_images?itok=_ZPwwAOU it's looking in sites/default/files/styles/footer_blog/public/?itok=_ZPwwAOU. The images doesn't appear in the edit form either, although I know it's in the directory (sites/default/files/styles/footer_blog/public/blog_images)

The only thing that seems to cure it, is to restore the database but again when I flush the cache the same problem arises.

More Details

I appear to get the following error also

Warning: array_key_exists() expects parameter 2 to be array, null given in theme_image_formatter() in the file modules/image/image.field.inc line 605


texts: Why does my 'UUID, Webform, Node' Feature remain overridden?

texts:
The Feature I have created is stuck in the "Overridden" state. (I have also deployed the Prod Environment's database to the Dev Environment's database to ensure that everything was in sync during this test).

I am using Drupal 7 and am using the following modules in this situation:

Webform
Context
UUID
Features
UUI Features

Here are the additional dependencies:

Under "Configuration > Content Authoring > UUID Features Integration", I have selected the "Webform" Content Type as one of the "Exportable Node bundles" and "Files exported for Node bundles" on both my Prod and Dev environment.

When viewing the overridden page, the only component that is stuck in the "Overridden" state is the "Content" section (with the UUID of the two nodes listed):

When clicking "Revert components", it actually does revert the two nodes listed back to the state in the features. (Tested it by modifying the nodes and then clicking "Revert components" to see it revert back.

Despite that, it remains in the "Overridden" state.

In this particular situation, why does this remain Overridden?


texts: Duplicate Entry for Video Embed Field which not allow to save node

texts:
Content Type : VideoDisplay

  Fields : Name of Video(Type: String), Video(Type: Video Embed Field), Artist(Type : Node Reference Field)

User already created a record of type VideoDisplay. Now as per requirement I can add more

  Artist to Existing Video.

So I take this approach:-

$node_vids = node_load($videoId);
$node_vids->field_artist[LANGUAGE_NONE] = array(
               0 => array('nid' => $form_state['values']['nid']));
$node = node_submit($node_vids);
node_save($node);

But it gives me error saying:

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
  'node-143-0-0-und' for key 'PRIMARY'

This error comes up while inserting data in Video(Type:Video Embed Field). But here I want to save Artist(Type : Node Reference Field) field only. I get to know that node_save actually saves all the attributes of Content Type.

After searching net I try to use field_attach_update() but again it is throwing
same exception. Please let me know any solution to  get out of this problem.


texts: Hide content types in administration for certain user

texts:
I created a user role who can only create and edit a certain content type, this works as it should.

When they log in however, they can click the content box in the admin bar to see all content. I want them to be able to click there and get all the content that they have the permission to create, but other content types should not appear.

I can't find any setting for this is the user role and permissions setting, but perhaps I'm mistaking? How can I fix this?


texts: Change CSS rule for small screen with jQuery

texts:
I am making bacon menu for small screens. I need to initialize menu without showing menu links, so I hide them with jQuery. The problem is that on big screen menu links are still hidden and I don't want that to happen.

I use this code to avoid menu link removal on big screens, but it's not working:

scripts.js
    (function (Drupal, $, window) {

  // To understand behaviors, see https://www.drupal.org/node/2269515
  Drupal.behaviors.offer42 = {
    attach: function (context, settings) {

      // Execute code once the DOM is ready. $(document).ready() not required within Drupal.behaviors.
      // Burger menu for small screen
      $(window).resize(function(){
        if ($(window).width() > 720 ){
          $('ul.menu').css('display', 'none');
        }
      });

      $('#menuButton').click(function(){
        $(this).toggleClass('is-active');
        if ($(this).hasClass('is-active')) {
          $('ul.menu').css('display', 'block');
        }
        else {
          $('ul.menu').css('display', 'none');
        }
        });

} (Drupal, jQuery, this));

SASS:

.menu
  li
   display: block;
   text-align: center;
   background-color: #fff;
   @include media($medium-screen-up)
     list-style-type: none
     display: inline-block
     float: right;
     margin: 0 10px 0 10px
     @include position(relative, -50px null null null)
     background-color: initial;


texts:
i dont know why

the script node_load(7) output is :

public 'field_tags' =>
    array (size=1)
      'und' =>
        array (size=2)
          0 =>
            array (size=1)
              'tid' => string '2' (length=1)
          1 =>
            array (size=1)
              'tid' => string '3' (length=1)

why the field tags not filled with tag title ! it only shows tid's

does this is a normal behavior of Drupal node_laod that it only load's primary id's of relational contents like taxonomy terms
?


texts: I'm using Drupal 6 and I need to display a block with the most viewed nodes from the last 7 days. I've tried using views + statistics but I can only get the total count of views. How can I get a count of node views from the last X days?


texts:
I'm trying to uninstall the "Browsing History Recommender" but I get the HTTP 500 Server error. I want to remove this module completely from the database and FTP.

I have been searching for a solution but no luck, I have also read this question.
How to manually uninstall/purge modules?

Please Help. Thanks

Drupal 7
Ubercart 3


texts:
I have used the accepted answer on this post to create and enable a custom module, but the new formatter doesn't appear in the list when I edit the file field in my view.

My info file looks like this:

name = Link icons
description = Turn file icons into links for use in views.
package = Views
core = 7.x
files[] = mymodule_link_icon.module
dependencies[] = views
dependencies[] = file

; Information added by MPM on 2015-07-30
version = "7.x-1.1"
core = "7.x"
project = "mymodule_link_icon"
datestamp = "1438243200"

Have I missed something in my info file or do I also need to amend something in the File module?


texts: In a custom module, get return of hook for making it available in other hook

texts:
I had some similar questions here, but would like ultimately to know best practices and possibilities for this case.

I have my custom module, in which I use two contrib modules hooks. As I understood, hooks are self-invoked (looking from my module point of view), and as soon as I am declaring it, they get executed.

That said, how I can get return of an hook function ?

I am trying to make $foo1 available in other hook and vice versa for $hook2. I would like to avoid oop solutions if possible.

Example:

function mymodule_contribmodulehook1 ($parameter1, $parameter2) {
  //$foo2 here somehow ?
  $foo1 = 1;
  return $foo1;
}

function mymodule_contribmodulehook2 ($parameter1, $parameter2) {
  //$foo1 here somehow ?
  $foo2 = 1;
  return $foo2;
}


texts: How to apply an image style based on a condition (a date for ex.)?

texts:
I'm looking for a way to apply a grayscale image style to a content type image field when certain conditions are met. A date is reached (date field) for example

Can the rules modules do this ?

Thanks for the suggestions & ideas


texts: kpr() in my form validation and submit function is not being called

texts: In my form validation and submit functions, kpr() is not being called. Is there a better way to check that I'm in those functions? If kpr() isn't ideal to output my $form_state array, then what is ideal?


texts: Should I declare the usage of a new template.php file?

texts:
How should I declare the usage of a new template.php file in a Drupal 8 sub theme?
I ask since I didn't find anything about this in the documentation, like this example.
For example, I created a template.php file and put the following function inside, saved and flushed all Drupal cache, but the desired change did not occur.
function garku_process_html(&$variables) {
  $variables['styles'] = preg_replace('/.css\?.*"/','.css"', $variables['styles']);
}


texts:
I have static page and form but in each load in devel show a lot of query (select and Insert) in cache_form table I see form_set_cache and operation but I think may disable cache_form completely is a good work, I disable it in settings.php and don't reduce performance.
do you think is this a good idea to disable form cache completely?


texts: How Can I have Exposed filter for Taxonomy vocabulary in Heirarchical Select?

texts:
I use drupal 7 and simple hierarchical select module for filter views module result by taxonomy terms and taxonomy vocabularies.

my views have results only if select both vocabulary and taxonomy term from select list (exposed filter) .if I select only vocabulary from select list I have no any result for views.

So i want to have a exposed filter that can filter views by vocabulary (all its taxonomy terms) and taxonomy term (sub level of vocabulary)  .
please see this picture.

Is any other way for filter views result by both vocabulary and terms in heirarchically?

thank you beforehand.


texts: drupal_validate_form not validating more than one time on listing page

texts:
i am using drupal_validate_form on a node listing page .
it is validating it correctly only for 1st item after that it is not checking validation.

here is my code

     foreach($result as $r){
        $node_form = (object) array(
          'uid' => $user->uid,
          'type' => 'MY_CONTENT_TYPE',
          'language' => LANGUAGE_NONE,
        );
        $form = drupal_get_form('MY_CONTENT_TYPE_node_form',$node_form);
        $form['#submit'] = array('#type' => 'submit', '#value' => t('Next'));

        $old_fs = @unserialize($r->form_state);
        $old_fs['values']['uid'] = $user->uid;
        $node = (object) array(
          'uid' => $user->uid,
          'type' => 'MY_CONTENT_TYPE',
          'language' => LANGUAGE_NONE,
        );
        node_object_prepare($node);
        $form_state = array();
        $form_state['build_info']['args'] = array($node);
        $form_state['values'] = $old_fs['values'];
        $form_state['values']['op'] = t('Save');
        $form_state['submitted'] = 1;
        $form_state['complete form'] = array();
        $form_state['triggering_element'] = array('#parents'=>array('next'),'#button_type'=>'submit');
        unset($form['#token']);
        drupal_validate_form('MY_CONTENT_TYPE_node_form', $form, $form_state);
        $errors = form_get_errors();
        $noOfError = 'empty';
        if (!empty($errors)) {
          $noOfError = count($errors);
        }
        form_clear_error();
    }

thank You in advance


texts: Add theme_hook_suggestions only for nodes in content

texts:
I am developing a blog with different categories (taxonomy terms) and I wanted to have custom node templates for the nodes displayed on the blog page and category pages. Because my blog page has a view, I am able to use this template for nodes on that view: node--view--blog.tpl.php. But there is no template I can use for the nodes loaded in www.example.com/category/cat_name (alias for www.example.com/taxonomy/term/3).

I tried suggesting a node template in template_preprocess_node() like this:

if(arg(0) == 'taxonomy') {
  array_push($vars['theme_hook_suggestions'], 'node__view__blog');
}

The problem with this is that now all the nodes inside that page are rendered with that template, including the ones in my sidebar.

Is there a way to filter inside template_preprocess_node the only ones that are part of the "main content" of the page?


texts: How do I get the public url of a file from the uri or filename

texts:
I'm using php from with a view (Views PHP) I'm trying to extract the real url of a file from a file reference. I am able to get the the uri of the file and or the filename. What drupal function can I use to get thee actual public URL of the file?.

$videouri = db_query('SELECT filename FROM `file_managed` WHERE fid = ' . $nidvideo)->fetchColumn();
//drupal_set_message('<pre>'. print_r($videourl, TRUE) .'</pre>');
$realpath = drupal_realpath($videouri);
$videourl = file_create_url($realpath);
return($videourl);