texts: Views 3 + field collection: relate only the first referenced field collection item

texts:
I'm using Views 3 and Field collection 7.x-1.0-beta3.  As a simplified example, say I've a field collection called Image - which itself has two fields, an image file and a text caption.  My content type, Page, includes a multi-value field to reference one or more Image(s).

In my view, I want to list several Page nodes, and display the image file field taken from only the first of each node's referenced Image field collection entities.

This works, but...

I have one solution that does work but feels clunky and indirect: Add the Image collection-reference field, and use the multiple-value settings to restrict to the first value (a la this post). However, then I have to have a view mode for the Image field collection that prints only the image file field, in the desired image style.

What would be awesome:

I've tried a different route using the Relationships settings. I can add a relationship from node to its Image field collection. Then, I can add the image file field, pulling from the relationship. BUT, that creates a new result for each of the Image field collections being referenced... and I can't find an option to key the relationship off the first value only (similar to displaying only the first value when I'm just going through adding the field, in my "this works" solution above).

I realize this may be impossible - if Views can't create the necessary query? Just wondering if I have missed something though I've gone through the settings several times.

Edit: Drupal 6 / Views 2 does it!

Okay, I'm not crazy - see screenshot. I think that's exactly what I'm looking for here.


texts: Hide a block when viewing own profile page - Show when viewing other people's profile?

texts:
I have a "Feedback" form implemented on a block. This block displays only when viewing the user profile page.

To stop people rating themselves, I would like to hide this block when the logged in user is viewing their own profile page.

This block should only show when viewing other people's profile pages.

I am using Drupal 8.

How can I do this please?

Here is the code I am currently using:

The issue is a person should not see the block when viewing their own profile page. They should see the block only when viewing another person's profile.

/**
 * Hide feedback form to prevent self voting.
 */
 use \Drupal\block\Entity\Block;
 use \Drupal\Core\Session\AccountInterface;

function zup_hide_feedback_form_block_access($block, $account) {

    $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
    $uid= $user->get('uid')->value;

    if ($operation == 'view' && $block->getPluginId() == 'block-webform-3') {
        if($account->id() != $uid){
            return \Drupal\Core\Access\AccessResult::forbiddenIf($block->getRegion())
            ->addCacheableDependency($block);
        }
    }
      // No opinion.
      return \Drupal\Core\Access\AccessResult::neutral();
}


texts: How do I change the default value of a field with AJAX?

texts:
Related to my previous question: Form fields created via Ajax are missing element attributes

I have a date field and a series of text and number fields which need their default values to change based on the value of the date field. I've updated my code so it functions this way:

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['date'] = array(
        '#type' => 'date',
        '#ajax' => [
            'callback' => '::dateCallback',
            'wrapper' => 'wrapper',
        ],
        '#default_value' => date("Y-m-d")
    );
    $form['wrapper'] = [
        '#type' => 'container',
        '#attributes' => ['id' => 'wrapper'],
    ];

    //insert logic to determine value of a variable called $field1
    $form['wrapper']['options'] = array(
        '#type' => 'fieldset',
        '#attributes' => array('class' => array('options'))
    );
    $form['wrapper']['options']['field1'] = array(
        '#type' => 'textfield',
        '#title' => "Field 1",
        '#value' => $field1
    );
    $form['wrapper']['table'] = array(
        '#type' => 'table',
        '#title' => t('Table'),
        '#header' => array("H1", "H2", "H3"),
        '#attributes' => array('class' => array('custom-table'))
    );
    //insert logic to generate table rows
    return $form;
}

/**
 * Implements callback for Ajax event on date selection.
 *
 * @param array $form
 *   From render array.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   Current state of form.
 *
 * @return array
 *   Date selection section of the form.
 */
public function dateCallback(array &$form, FormStateInterface $form_state) {
    return $form['wrapper'];
}

There are 2 problems I am having with this:

1) Implementing it in this way, such that the #value property is changed when the date field is changed, technically works, however if the user then chooses to modify any of the textfield values, that is not reflected in the $form_state object and is overridden by whatever #value was last set to in buildForm().

2) I have also tried using #default_value instead, but the value in the field will not update if it already has something in it (which it usually does from the first time #default_value is set in buildForm()). I have seen some threads like this one suggesting to unset the value in $form_state before setting #default_value again, however all such suggestions are for Drupal 7 where $form_state is a completely different data structure.

Is there a known way to do what I am trying to accomplish?

Update: I tried method 2 again by adding $form_state->unsetValue('field1'); before declaring $form['wrapper']['options']['field1'], but this did not change the behaviour.


texts: How to make specific custom table data searchable in Drupal 7?

texts:
I just created custom module with name  example , And it has a form to enter data to it's specific  custom table.
I want to make the data in this custom table searchable with Drupal default search feature.

Please guide me.

Thanks in advance.

Update

I already skimmed through the Drupal api docs and followed the instruction but I couldn't make it working.


texts:
In my application, all mails aren't sent via the Drupal default mail system or SMTP. We have a third-party API which sends all emails. So, whenever the plugin.manager.mail service is called, the class I define in a custom module should be used.

How can I achieve this?


texts:
I'm running Drupal 7, and I am using the Acquia Marina theme. I am having issues with the drop-down menu (using superfish). The menu items with children simply remain expanded.

Every tutorial and user post I've looked at, the Primary Link Configuration table always comes up.

I cannot find this screen, anywhere. Can anybody help me?


texts: Restrict what content can be added to a panel page (using panels & organic groups)

texts:
We are using Organic groups and Panels with Drupal 7.

We want each group to have one panel node (that is, a node which content type is "Panel"). The group administrator can then use different kind of layouts and display existing content.

I created two groups A and B. I also created panel node (a node which content type is "Panel") for each group and some nodes that belong to group A and some nodes that belong to group B

Now, when admin of group A edits the panel node's content (through a tab "Panel content") of group A and selects Existing node when adding content to a panel pane, he can choose nodes that belong to group B. Is there a way to make panels respect OG access control? So that group A admin could not select contents of group B to be displayed in a panel pane of group A.

The content in the groups still need to be public so that if anonymous user visits content belonging to each group he will be able to see them.


texts:
I want to make a rule that check if the user of the currently viewed profile, have flagged the currently viewing users profile.

So basicly, have viewing user been flagged by the profile owner of the viewed profile.

So lets say this rule returns true, then there will be a text box when user is viewing profile "This user have flagged you!!".

I have tried all sorts of things in the Data selector of "User who to check" (the field in the buttom of image.


texts:
I am using the Date Repeat Entity module for generating a checklist for users.  I am able to use Views to display the list in chronological order for tasks relevant for the current user using a Contextual Filter.  Could I also use a Contextual Filter to only show the current nodes that have a date equal to the current date?

I would think this could be done by entering some PHP code as shown here:


texts: Core update installs 8.6.0-beta1 instead of 8.5.6

texts:
Using composer I tried to update Drupal 8 to 8.5.6. The update wasn't working, so I changed the dependencies to explicitly require 8.5.6. The update began, but it installed Drupal 8.6.0-beta1. The command I used was composer update drupal/core --with-dependencies -v.

The updates page still says Drupal 8.5.6 is required. I'm not sure where to go from here.

Should I try to roll it back? I tried requiring Drupal 8.6.0-beta2 and Drupal 8.6.0-rc1, but an error suggested not to update to these versions. I want the site live ASAP, and updated to Drupal 8.5.6.


texts: Implementing Multi Select List as a popup for Views Exposed filter (field of type taxonomy)

texts:
I am trying to implement

http://demos.jquerymobile.com/1.4.5/selectmenu-custom/#popupDemo&ui-state=dialog

in a Views Exposed Filter .
Screenshot of Desired Implementation:
 http://awesomescreenshot.com/00d593vsa8
 http://awesomescreenshot.com/09c593vwae

I have used better exposed filter to show dropdown as checkboxes but I am unable to show the exposed filter as a popup

Is there a way I can do to show filter as a popup as shown in the link above.

The page where I need to implement is :- Original Site

Can anybody point me on how can I show the exposed filter as popup same as that shown in the demo of jquery mobile


texts: PHP - If a field has a certain text value then print something

texts:
The following PHP in a node tpl file:

check_plain($node->field_room[$node->language][0]['value'])

Will print this in the page:
Value1

What I want however is if the field has a value of 'Value1' then I want to print something else on the page. Ive tried the following but I think I have a syntax error:

if ( check_plain($node->field_room[$node->language][0]['value']) == "Value1" ) {
                        echo "<p>Print something else </p>";
                    }


texts:
I have a content type "Company", each company will have a login page that show the logo of the company and a login form via Restful.

I have created a module that define a route:

company_md.login:
  path: '/{company_slug}/login'
  defaults:
    _controller: '\Drupal\company_md\Controller\DefaultController::login'
    _title: 'Company XX Login'

When I go to that URL it give me Not Found 404, whats wrong in my routing?

EDIT 1

This how the path look:

http://companies.local/node-13-company/login4

EDIT 2

My routing file:

testd8.name:
  path: '/node/{node1}/login'
  defaults:
    _controller: '\Drupal\testd8\Controller\DefaultController::login'
  requirements:
    _access: 'TRUE'
  options:
    parameters:
      node1:
        type: entity:node


texts: hook_theme_suggestions_hook_alter() not working for Views

texts:
I'm trying to create a custom template for a view page in Drupal 8.3.x. It's going in a custom theme, and needs to be a view-level template (so not page- or node-).

I've been fighting with it for a while and figured it might be an issue with the specific name, so I've made the code as sparse as possible - still no luck.

I have the following code in mytheme.theme:

function mytheme_theme_suggestions_views_view_alter(array &$suggestions, array $variables) {
  $suggestions[] = 'test_template';
}

And the following file structure:

- mytheme
  ~ templates
    * test-template.html.twig
  ~ mytheme.theme
  ~ mytheme.info.yml
  ~ ... etc.

I know that the theme_suggestions alter function is working properly; I have Twig debugging enabled, and when I pull up my site and look at the code, I can see the following: (note the "X" next to views-view.html.twig showing that as the currently used Twig file)

<!-- FILE NAME SUGGESTIONS:
   * test-template.html.twig
   x views-view.html.twig
-->

So it's adding the suggestion. And the template file is named correctly. I know it's not a directory issue, because I have other .html.twig files in that /templates/ folder that are working correctly.

Does anyone know why the file name suggestion is working, but the matching file isn't?

Edit: Kevin pointed out a possible duplicate ticket in the comment below. That's only half-related. It does solve the symptom in this particular example - I have been able to pull in one of the templates mentioned here, and it works for this case.

However, the title of the ticket and general issue still holds. I can't get the hook_theme_suggestions_hook_alter() to work with my custom theme_suggestion / template. While it turns out the view I used as my example could be solved another way, there are other instances where that won't be the case.


texts: publishing links in menu makes them disappear

texts:
I am using drupal 6. I created a bunch of pages and made them unpublished. I then created a menu with links to those unpublished pages. When each menu item's path was set to those pages, the menu item would disappear from the menu. I was told not to worry, this was only because the pages were unpublished, once they would be published they would reappear.
When I was ready to publish the pages, I initially went to each page, clicked the edit tab, edited the "publish" section to publish the pages and they did indeed reappear. But as there were a lot of pages, I wanted to be more efficient. I went to the content page, searched for my unpublished pages and published them all at once. While they did all become published, none of those newly published menu items showed up in my menu again. Why was this so?


texts: how to implement facet search api on content types feilds?

texts: Is it necessary to build taxonomy for each field of content type to show it in search option in sidebar in facet search api ?


texts:
I have a scenario where I need to perform some redirection of a not found url
http://localhost/drupal9/node/1/search

the word search is added though a plugin I am using and it is a front-end route not a backend so upon refreshing this url I get Not Found which totally makes sense what I need to do is remove the word search from the URL and redirect to,
http://localhost/drupal9/node/1/

as search is a common word and can be used in other content type I first need to check whether the URL is of my custom content type. let me show you a piece of implementation I already have.
function [module]_preprocess_page(&$variables) {
  $query = \Drupal::entityQuery('node')
  ->condition('type', [module]);
$nids = $query->execute();
if(array_search(2,$nids)){
echo "yes";
}
}

so over here what I am doing is grabbing all the nodes with my content type and grabbing the Nid from URI and matching them and this does work but there is another problem with this.
In the page properties we have an option of ALias so if the user uses a custom alias, then I dont get the Nid in the URI anymore so this logic breaks,
the question may seem a bit tricky but the requirement is simple.I am looking for a unified solution to parse the URL into some drupal API and simply getting back the content type name.The Url may contain a custom alias or a Nid


texts: Don't repeat yourself: Natural place for clculations on the FieldItemList of a custom FieldType wanted

texts:
I have a custom field type that contains a number field, among others.

class MyFieldItem extends FieldItemBase {
    public static function propertyDefinitions($field_definition) {
        $properties = [];
        $properties['some_number'] = DataReferenceTargetDefinition::create(
            'integer'
        );
        ...
    }
    ...
}

I need the sum of all values of the property some_number. A function adding the numbers would look like this:

function addAllNumbers($items) {
    $sum = 0;
    foreach ($items as $item) {
        $sum += $item->get('some_number')->getValue();
    }
    return $sum;
}

I need this sum for many purposes, like to display it in the formatter, or to validate forms.

Now, I've found that I'm calculating this sum in several places in my code. But an important programming principle tells me: "Don't repeat yourself!"

Where is a natural place to perform calculations on the FieldItemList of a custom FieldType?

I see several candidates for such a place.

The .module file. However, this is hardly connected to the custom FieldType and often a confusing collection of random things.
The MyFieldItem class defining the custom FieldType. Here, the iteration would go over $this->parents. However, I don't see a way to access the FieldType object from within the Formatter.
The formatter. However, then it would be necessary to somehow format the FieldItemList during the form validation.
Some utility class. But probably, other developers would find that strange in the future.

  There should be one-- and preferably only one --obvious way to do it.
  (The Zen of Python, by Tim Peters)


texts:
I need to migrate a json feed with following example structure;

{
   "data":[
      {
         "id":"11028",
         "first_name":"Foo",
         "last_name":"Bar",
         "functions":{
            "group_function":{
               "data":[
                  {
                     "group":"1",
                     "function":"Scrummaster",
                     "active":"1"
                  },
                  {
                     "group":"2",
                     "function":"Developer",
                     "active":"0"
                  }
               ]
            }
         }
      },
      {
         "id":"11029",
         "first_name":"John",
         "last_name":"Doe",
         "functions":{
            "group_function":{
               "data":[
                  {
                     "group":"1",
                     "function":"Project manager",
                     "active":"1"
                  },
                  {
                     "group":"2",
                     "function":"Project owner",
                     "active":"1"
                  }
               ]
            }
         }
      }
   ]
}

For this, I was thinking of having a teammember node, and a teamfunction paragraph type for the functions for each team member.

If i understand migrate api correctly, i create 2 migrations for this. One for the node and one for the paragraphs.

How can I iterate over the group_function/data array within my paragraphs migration?

I tried:

source:
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: json
  headers:
    Accept: 'application/json; charset=utf-8'
    Content-Type: 'application/json'
  urls: example.com/team.json
  item_selector: data/functions

But I get following response on a 'drush ms':
Could not retrieve source count from team_function: Passed variable is not an array or object

How would you do this?


texts:
I am using Drupal 7 and apache solr for one of my sites. I am using tomcat with apache solr to search the contents in my site. For testing purpose i use http://localhost:8080/solr to connect to the solr server. But i would like to change this to http://development.site:8080/solr. I have no big exposure to apache solr. It would be helpfull if some one can guide me.

Thanks.


texts: How to print YAML form in custom block under drupal 8

texts: The accordion section was created in custom block under drupal 8. And I want to show yaml form in description of that accordion section. So, I would like to ask how to print YAML form in custom block.


texts: Drupal 8 Ajax Callbacks misbehaving when form element in table

texts:
I have a form containing the following element:

  $form['check'] = array(
    '#type' => 'checkbox',
    '#title' => t('Test'),
    '#ajax' => array(
      'callback' => array($this, 'updateTestCallback'),
      'event' => 'change',
    ),
  );

With the following simple Ajax handler:

  public function updateTestCallback(array $form, FormStateInterface $form_state) {
    $triggering_element = $form_state->getTriggeringElement();
    $ajax_response = new AjaxResponse();
    $ajax_response->addCommand(new AlertCommand($triggering_element['#name']." = ".$triggering_element['#value']));
    return $ajax_response;
  }

This works perfectly when the control is on a plain form, but I want to have a checkbox on every row of a table, and this is where I'm having problems.

I tried using a #table entity, and the checkboxes display correctly, but the Ajax callback event only gets called on every other click (i.e. one click it works, the next nothing happens, the next it works again).

So I should the problem might stem from from the #table entity, so I changed the form to build the table manually using #prefix and #suffix containing the table elements, but this is behaving exactly the same way, so it seems to be the presence of the table elements rather than the way they were generated that's causing the problem.

Here's the current build_form function:

  public function buildForm(array $form, FormStateInterface $form_state, $mid = NULL, $key = NULL) {
    $form = array(
      '#prefix' => '
',
      '#suffix' => '
',
    );

    // Test checkboxes outside table:
    $form['check'] = array(
      '#type' => 'checkbox',
      '#title' => t('Test'),
      '#ajax' => array(
        'callback' => array($this, 'updateTestCallback'),
        'event' => 'change',
      ),
    );
    $form['check2'] = array(
      '#type' => 'checkbox',
      '#title' => t('Test2'),
      '#ajax' => array(
        'callback' => array($this, 'updateTestCallback'),
        'event' => 'change',
      ),
    );

    $form['table'] = array(
      '#prefix' => '
',
      '#suffix' => '
',
    );

    $form['table']['tbody'] = array(
      '#prefix' => '
',
      '#suffix' => '
',
    );
    // Retrieve data and builr one table row per record.
    foreach ($entries = MyStorage::myListLoad() as $entry) {
      $mid = $entry['mid'];
      $is_paid = $entry['is_paid'];
      $row = array(
        '#prefix' => '
',
        '#suffix' => '
',
      );
      $row['first_name'] = array(
        '#markup' => SafeMarkup::checkPlain($entry['first_name']),
        '#prefix' => '',
        '#suffix' => '	',
      );
      $row['last_name'] = array(
        '#markup' => SafeMarkup::checkPlain($entry['last_name']),
        '#prefix' => '',
        '#suffix' => '	',
      );
      $row["is_approved_".$mid] = array(
        //'#attributes' => array('name' => 'is_approved_'.$mid, 'id' => 'edit_is_approved_'.$mid),
        '#type' => 'checkbox',
        '#title' => t('Is Approved'),
        '#title_display' => 'invisible',
        '#ajax' => array(
          'callback' => array($this, 'updateTestCallback'),
          'event' => 'change',
        ),
        '#prefix' => '',
        '#suffix' => '	',
      );
      $form['table']['tbody'][$mid] = $row;
    }
    return $form;
  }

Has anyone come across this problem, and can you suggest a way around it?

James


texts:
There are a bunch of WYSIWYG edirtors available. I've tried CKEditor so far (and tinyMCE with wordpress). CKEditor is a very fancy one but fairly complex and weights 6Mb including source files.

What is in your experience the most buggless and stable?

It needs to have a support for IMCE bridge module to be able to get images from disk.


texts:
I just updated drupal core on website and my drupal alias do not work unless the full path to a directory is included

Example:
http://michael.tsikerdekis.com/ (works)
http://michael.tsikerdekis.com/publications (doesn't work)
http://michael.tsikerdekis.com/home/tsikerde/public_html/publications (works)

Why would the second option stop working.


texts: I am using Drupal 8 theme and i am wondering is there any way to change the phrase Sticky at top of lists which appears when creating new posts, to something different like Appear in Search Results or Trending?


texts: Using group and rules modules to automatically create group for new user

texts:
I am using the Group (not OG ...) and rules modules for this task. I created group type, Applications Support. Then I created a rule, After saving a new user.
Under the rule, I used the following configuration, but it did not create a group.

My previous question was related to the OG module, this one is for the Group module. So I think it is a different question.


texts: Disable select drop-downs, display names only

texts:
I am looking for a way to remove the select drop-downs from the datepicker popup and display only months (and the year). As for the appearance, it can be altered in datepicker.1.7.css.

How do I disable the select drop-downs and show only the names?


texts: How do I get my accidentally disabled side menu back?

texts:
I accidentally deactivated the left side menu for every page. I think it's still there, just deactivated.

How do I get it back?


texts: Contextual filter and exposed filter related

texts:
I am facing a real problem and i can't manage to solve it.

I have some checkboxes in user profile based on a vocabulary.
I want to display all articles that have this tags in a view .
If user wants to see all articles he should choose on a select list what he want to display.
So i want to make a default for that page and if user wants something else to display based on a select option.

Ex: user X has checked in profile page options : management.
then he goes in news view and see all articles with tag management. If he change his mind and want to see other categories this should be done from a select.

I have done the first part that with default articles (i make a contextual field with default get ID from logged in user ->relationship from user and display content that have that terms-> this is a user entity view that displays related articles) when i put the exposed filter and select another value i get nothing. I think that view searches for that value in user checkboxes preferences in user profile.

What can i do to achive my goal?
Thank you


texts:
I am using view.

Every view needs path and i want to set that path to my base url.

For example i want to make a view which will take a Car as a argument and show result at

www.example.com/Car

Any help will be appreciated.


texts:
In Drupal 6, I am using the following code.
$rows[] = array(
  array('data' => drupal_render($form['collected'])),
  array(
    'data'=> drupal_render($form['count']) . drupal_render($form['submit']),
    'colspan' => 3
  )
);

In Drupal 8, I am trying to use the following code, but I see the HTML markup of $form['count'].
$rows[] = [
  ['data' => \Drupal::service('renderer')->render(($form['collected'])],
  [
    'data' => \Drupal::service('renderer')->render($form['count']) . \Drupal::service('renderer')->render($form['submit']),
    'colspan' => 3,
  ]
];


texts: Outputting a link as a button in node.tpl.php

texts:
I am trying to rewrite the output of node.tpl.php.

I am using field link. I cannot figure out how to get the field to render as a button. I did find that the field is output as an array

I tried this but it just makes the link just a link to the page I am on:

<a class="btn btn-danger btn-lg" href="<?php print render ($content[field_amazon_link][LANGUAGE_NONE][0]['display_url']); ?>">Buy Now

The devel module gives me this info. Keep in mind php is my week area. This is my first time rewriting a node file as I used to have a helper and he has moved on.

field_amazon_link (Array, 1 element)

0 (Array, 5 elements)
    url (String, 142 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re...
    title (String, 83 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re...
    attributes (Array, 1 element)
    html (Boolean) FALSE
    display_url (String, 83 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re...

And this is from the object devel tool
 field_amazon_link (Array, 1 element)

und (Array, 1 element)
    0 (Array, 5 elements)
        url (String, 142 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re...
        title (String, 83 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re...
        attributes (Array, 1 element)
        html (Boolean) FALSE
        display_url (String, 83 characters ) https://www.amazon.com/gp/product/B00ZGUBN3C/re..


texts: Is it to possible add placeholder text for link fields?

texts:
Been trying to add placeholder text for my link fields.

Using hook_form_alter to add the attributes. It works fine with text fields

$form['field_first_name']['und'][0]['value']['#attributes']['placeholder'] = t( 'Your First Name' );

But not able to get it work with link fields

$form ['field_twitter_link']['und'][0]['#attributes']['value']['placeholder'] = t( 'Your Twitter profile link' );


texts: Customizing tableheader.js Sticky table Header

texts:
As I am having a custom "position:fixed" top navigation bar in my admin pages, the sticky table header are being hidden behind it when I scroll-up.

I went through tableheader.js and saw there is a Drupal.settings.tableHeaderOffset that helps change the "top" property, but I don't know where I should override it. Possible to do it in my template.php?

Also, I would like to change the position that triggers the sticky header to change visibility from hidden to visible...

  // Track horizontal positioning relative to the viewport and set visibility.
  var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft;
  var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - this.vPosition;
  this.stickyVisible = vOffset > 0 && vOffset < this.vLength;
  this.stickyTable.css({ left: (-hScroll + this.hPosition) + 'px', visibility: this.stickyVisible ? 'visible' : 'hidden' });


texts: Drupal says "There was a problem creating field ZZZ: Table field_data_field_ZZZ already exists"

texts:
I've run into this periodically:  I'm working on a new site and go to add a field that I've created at some point in the past only to find out that it's not available.
When I try to add a 'new' field (usually using the same title & machine name, because they pop up when I start typing), I get this message:

  There was a problem creating field ZZZ: Table field_data_field_ZZZ already exists

There are several posts out there on this issue, but none of the solutions really tell the whole story.

Why did this happen and how do I fix it?


texts: Select field descriptive or numeric keys

texts:
I have created a field of type List (text) with widget Select list.
After editing most of its settings, it came to complete its Allowed values list.
Following the help's text instructions, the values should have this form key|label and here is my question:

Should I use descriptive or numeric keys for the values (and why)?

  The key is the stored value

Does this (keys) selection will have any impact in the future if for example I want to use these values for aggregation (with views or not)?


texts: Associating Ubercart products with site content

texts:
I'm working on a Drupal/Ubercart e-commerce site where I'm selling access to site content.

What I would like to do is have a My purchases page where I have a list of products that the user has purchased, and then links to the landing page for that content.

I currently have the My purchases page setup as a Drupal view, where the view has a relationship for products and orders - then the field being displayed is the (products) Ordered product: Title.

However I haven't been able to figure out a way to add a custom link to each product that can be displayed on this page so the user can simply click on the product they purchased and go to the landing page for that content, which is then access controlled by role.

Any help is appreciated


texts: Drupal 8 supports Multilingual (i18n) in core. I was wondering, is it possible to restrict users to be able to add/edit content for only one specific language?


texts: Form state redirects do not respect https

texts:
on some forms I added custom redirects, for example on the user login form:

function my_module_user_login_submit(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form_state->setRedirect('view.my_custom_view.page_1');
}

This is working well even with https on my test server: the user will be redirected after login to the view page with https, let's say https://my-domain.de/my-view-page

On another server the same is not working: on this server the domain is only reachable via https - not via http. This means calling http://my-domain.de will lead to a server error only using https://my-domain.de the project will be displayed. Now when I login I will be redirected to http://my-domain.de/my-view-page (without https) which leads to this server error.

I am sucessfully logged in: when I enter https://my-domain.de/my-view-page manually I can reach this know. When logout (I did not any changes here) the same appears: After logout the user gets redirected to http://my-domain.de.

Can somebody give me a hint what can be the problem on the second server?

Best,
Tobias


texts: Drupal7: How to add the alt and title attribute to an image by code

texts:
I am using the file_create_url() function to create the URL for images.
The code is:

<img src="<?php echo file_create_url($node->field_history_image['und'][0]['uri']); ?>">

But I just noticed that the alt and title attributes are not added to the HTML output, eventhough I added them for the image in the admin.

How would I change the above code, so that it adds the alt and title attributes if they are filled in the Admin interface. Or what other function should I use?

Thanks.

Boutros.


texts:
How do i send HTTP POST/GET data to drupal?

for example:
I've got a html form:

<form action="mydrupalcite.com" method="get">
    <input type="text" name="title" />
</form>

how do i get the title 's data into drupal's answers module?(or any module?)

I'm looking for the drupal way of doing this(i'm relatively new to Drupal and how it really works)

Does it have anything to do with Services module?


texts: Rewrite output for view field only when certain condition is met?

texts:
You have a list with Views
It contains titles of nodes.
When clicked those titles redirects to the nodes.

How to make a condition that if e.g. a checkbox is selected in the node saying something like e.g. 'Don't link this to the original content, redirect it somewhere else instead', then overwrite the default path of that node title to something custom?

I found a module https://www.drupal.org/project/views_conditional does it do what I'm trying to achieve?

So e.g. you have a list with 10 nodes titles, 9 of them links to its content, but 1 links somewhere else because it has a checkbox/term selected in the node's settings?


texts: Best way to build pages, or page equivalent

texts:
I manage a Drupal 6 site that has various content types and is set up to display them in various methods, all of which work just fine.

However, marketing likes to generate specific campaign based landing pages.  These are primarily static pages, and historically have had no usability extras at all.

Using drupal, the design team has started to request a higher level of interaction, different blocks depending on role, use of the customers name if we have it... little things for the most part.

The solution I'm seeking:

...ideally lets the designers to be able to do this themselves.  Dropping in the html and images, css, video, whatever.

...is potentially free of the site theme... this is trickier.  I'd like them to be able to not include the header and footer if they didn't want it... or use a different body background.

...doesn't require a large number of modules.  I stated this in a way that confused people before... we use a lot of modules.  I don't mind modules.  But I'd to find a solution that isn't a kludge of 8 modules mashed together in a way that isn't exactly what they were designed for and doesn't deliver exactly what you want.

Or as mtro put it as concise and eloquent as possible: designers regularly give me html/img/css packs that need to live on a single page within the site, and you want to streamline creating those pages without recurring template work?

My question is what do other What do other Drupalers do when you have non-standardized content that is regularly added and has partial or no theming?


texts: How to get view by tag sorting the same as main view sort criteria

texts:
I am new to Drupal 7. I have a view set up at /people with the sort criteria set to a field called surname. This is working fine, listing people out alphabetically by surname.

I have tags associated with people and /people/tag/x does list out just the people with tag x (I can't remember whether I had to do anything special to get that working).

However, when viewing people/tag/x, the entries are no longer sorted by surname. I'm not sure what order they are in.

How can I get the main view sort criteria (surname here) to persist when viewing a certain tag at people/tag/x?

Here is an export of the view: http://pastebin.com/8eBSkvn7

Screenshots of view config below, after I tried to add the contextual filters suggested by awm. I have also tried changing the first tag filter to 'Content: has taxonomy term ID'. I had no contextual filters originally.

Many thanks for your time.


texts:
How can I do a MySQL date function in Drupal?
I have this now:

$select = db_select('someTable', 'st');
$select->addExpression('DATE_FORMAT(FROM_UNIXTIME(created), "%Y-%m")', 'createdMonth');

$date = $select->execute()->fetchAll();

When I run this I get an exception that says:

"SQLSTATE[42S22]: Column not found: 1054 Unknown column '%Y-%m' in 'field list'"

But if I print the $select object I see it should run

SELECT DATE_FORMAT(FROM_UNIXTIME(created), "%Y-%m") AS createdMonth FROM {someTable} st

And when I copy this to Sequel Pro it just runs.

What am I missing?


texts: PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined:

texts:
I get "PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined" using the below db_query() call.

db_query("SELECT image.:field1_fid as fid, image.:field2_data as file_data, image.:field3_list AS list FROM {content_:field4} AS image WHERE vid = :vid AND nid = :nid", array(':field1' => array_values($field), ':field2' => array_values($field), ':field3' => array_values($field), ':field4' => array_values($node_type), ':vid' => array_values($vid), ':nid' => array_values($nid)));

I also tried like this.

db_query("SELECT image.:field1_fid as fid, image.:field2_data as file_data, image.:field3_list AS list FROM {content_:field4} AS image WHERE vid = :vid AND nid = :nid", array(':field1' => $field, ':field2' => $field, ':field3' => $field, ':field4' => $node_type, ':vid' => $vid, ':nid' => $nid));

Wny idea what's wrong in my query?


texts: Additional actions when logging using watchdog

texts:
Is there a way to perform additional actions every time watchdog logs something? For example, I wanted to record, parse, and compile logs with additional information elsewhere, but still have watchdog perform its default function.

Is there any hook I could use?


texts:
Content type: Webform
Allowed grants: View, Edit
Allowed roles: Anon, authorized, admin

Go to the webform node eg. node/20
Click Grants tab
Tick authenticated and admin users can View, anonymous is unticked
Page is still accessed by anonymous?

node/20:

Global Nodeaccess settings:

At the bottom Webform is ticked to View for anon/authenticated/admin because we want anonymous to see all webforms by default, except one that needs to be logged in. Doesn't really matter because unticking View for anonymous, anonymous can still view the page?!


texts:
I was wondering, I have a panels using the "Node template", is there a way to have "node author" as a selection rule, now I only have "node type".

I'm using Drupal 7.9.


texts: Dump raw select query with parameters values

texts:
I would like to debug select query and I use the next code, for example:
$connection = \Drupal::service('database');
$query = $connection->select('node', 'node');
$query->fields('node', ['nid'])
  ->condition('node.type', 'page')

// Debug.
dump($query->__toString());

But this print the query with placeholders, that is, with ":db_condicion_placeholder_1", etc. I would like to get the query with its custom parameters values. For example, if I add a condition for some field equals to "M", I would like to get the raw sql with this condition: some_field="M".
Is there any way to get it?


texts: Show User Information in Block from View

texts:
I have a block that shows some data from the User area (People) in Drupal 7. I have a rewrite setup that shows "VACANT" if there is no user selected for the content type. When logged in, I see users for 3 of the 4 contents I have created, which is correct. When logged out, I see VACANT for all of the contents.

Is there some restrictions on showing User data to the public? How can I make a certain Role visible to everyone?

EDIT::: Thanks to @Clive: View user profiles [x] for anonymous.


texts:
Ok, trying to process a script, both PHP and JavaScript, where I am moving a particular content type NODE from one reference to another. This is the structure:

I have a PROJECT
Inside each PROJECT are PAGES
Inside each PAGE are CALLOUTS
and Inside each CALLOUT are PRODUCTS.

What I want to do is take a PRODUCT from one CALLOUT to another CALLOUT. I am able to merge these, but now what I want to do is delete the first instance. An example:

I have PRODUCT AAG-794200 that is on PAGE 6 CALLOUT A. I am merging that PRODUCT with PAGE 6 CALLOUT B.

I can get the product to merge, but now I need to remove it from CALLOUT A. Here is my code:

$merge = explode(',', $merge); //Merge SKUs
$mpages = explode(',', $mpages); //Merge Pages
$mcallouts = explode(',', $mcallouts); //Merge Callouts
$mcallout_nid = explode(',', $mcallout_nid);  //Merge Current callout

$length = count($merge);
$e = 0;
while ($e < $length) {
    //Where is the SKU going to?
    $to_callout_letter = strtoupper($mcallouts[$e]);
    $to_page_num = $mpages[$e];
    $sku = $merge[$e];
    $from_callout = $mcallout_nid[$e];

    //Where is the SKU coming from?
    $other_callout = node_load($from_callout);

    //Need page ID of current callout for project purposes
    $page_nid = $other_callout->field_page[0]['nid'];
    $page = node_load($page_nid);
    //Need the project NID
    $project_nid = $page->field_project[0]['nid'];

    //We need to get the NID of the page we are going to
    $page_nid = db_query('SELECT * FROM content_type_page WHERE field_page_order_value = "%d" and field_project_nid = "%d" ORDER BY vid DESC LIMIT 1', $to_page_num, $project_nid);

    $page_nid_res = db_fetch_array($page_nid);
    $to_page_nid = $page_nid_res['nid'];

    //We need to get the NID of the callout here
    $co_nid = db_query('SELECT * FROM content_type_callout WHERE field_identifier_value = "%s" and field_page_nid = "%d"', $to_callout_letter, $to_page_nid);
    $co_nid_res = db_fetch_array($co_nid);
    $to_callout_letter_nid = $co_nid_res['nid'];

    $callout = node_load($to_callout_letter_nid);
    $long = count($other_callout->field_skus);
    $deletecallout = array();
    foreach($other_callout->field_skus as $skus) {
        $s = 0;
        while ($s < $long) {
            if($skus['nid'] == $sku) {
                $callout->field_skus[] = $skus;
                $s++;
            }
            else {
                $deletecallout[] = $skus;
                $s++;
            }
        }
    }

    foreach($other_callout->field_images as $old_image) {
        $callout->field_images[] = $old_image;
    }
    foreach($other_callout->field_line_art as $old_image) {
        $callout->field_line_art[] = $old_image;
    }
    foreach($other_callout->field_swatches as $old_image) {
        $callout->field_swatches[] = $old_image;
    }

    $callout->field_copy_text[0]['value'] .= $other_callout->field_copy_text[0]['value'];
    $callout->field_notes[0]['value'] .= $other_callout->field_notes[0]['value'];
    $callout->field_image_notes[0]['value'] .= $other_callout->field_image_notes[0]['value'];
    $callout->field_status[0]['value'] = 'In Process';
    node_save($callout);

This causes the PRODUCTS to MERGE, but not delete the original.

Thanks for any help. I know it's something simple, and it will be a palm-to-face moment.


texts:
I have done my due diligence, but can't find an answer anywhere. I am trying to pop an array in a field collection and then implode it. Here is my code, which is not working. Also, I am not sure if this is the way to use count. Any help appreciated.

/**
* Implements template_preprocess_entity().
*/
function mytheme_preprocess_entity(&$variables, $hook) {

$function = 'mytheme_preprocess_' . $variables['entity_type'];
if (function_exists($function)) {
$function($variables, $hook);
    }
}

/**
* Field Collection-specific implementation of template_preprocess_entity().
*/
function mytheme_preprocess_field_collection_item(&$variables) {

// Return a comma separated list of donors
if ($variables['view']->current_display != 'bookplates_landing_page') {
if ($variables['#field_name'] == 'field_collection_donor') {
}
// nothing below here works
// render text for single donor
if (count($variables['row']->field_field_collection_donor) == 1) {
      $variables['output'] = $variables['#field_name']->last_render_text;
}
else {
// get all the donors
$donors = array();
foreach ($variables['row']->field_field_collection_donor as $donor) {
$donors[] = $donor['raw']['safe_value'];
}
// append the last donor with an "and" before it
$donor_last = array_pop($donors);
$variables['output'] = implode(', ', $donors) . " and " . $donor_last;
         }
    }
}


texts:
I've created a "Staff menu" with various menu items. However I want to add it to the "Main menu" as a drop-down list (e.g. set Staff as Vertical, while Main is the navbar / horizontal menu).

Is it possible to just add a menu to a menu by creating a new menu item in the "Main menu" and linking it to "Staff menu" ?


texts: Core updates and module updates: Does order matter?

texts:
I inherited a badly out-of-date Drupal 6 multi-site instance.  There is only the production instance. (yeah, that gives me a warm-fuzzy!)

Many modules are several versions behind and the core is several versions behind.

Does the order in which I perform the updates matter?  I'm thinking update core first, then update the modules, but I'm just not sure.

Anyone care to advise?


texts:
I have pages generated by Views with some page url: e.g. /testimonials.
When I search the word 'testimonials' I want in results page to be shown the link to testimonials page.

How it can be done this feature?

I use Drupal 7.


texts: Print password confirm field in user register template file

texts:
I'm trying to theme the user registration form in Drupal 8.
I have defined a custom template for user registration form and printing the fields with the following code.

{{ form.field_profile_title }}
{{ form.field_profile_first_name }}
{{ form.account.mail }}

When I try to print confirm password field it's not printing the field.

{{ form.account.pass}}

What could be the issue?


texts: Defining Devel generation rules for custom nodes

texts:
I have Devel module installed, I use it mostly for generating content.

I wanted to know if it was possible to define some custom rules to generate content for my custom nodes.

For example: I want the node titles to be fetched from a php array or another source instead of the automatic Lorem Ipsum fragments.

I've done some google researches but I can't find a starting point to do this.

Thanks


texts:
I load my main menu programmatically with the following code :

    $menuTree = \Drupal::menuTree();
    $menuTreeParameters = $menuTree->getCurrentRouteMenuTreeParameters($name);
    $menuTreeParameters
        ->setMinDepth($minLevel)
        ->setMaxDepth($maxLevel);

    $tree = $menuTree->load($name, $menuTreeParameters);
    $tree = $menuTree->transform($tree, $this->getDefaultManipulators());

    return render($menuTree->build($tree));

I would like to get all my menu items, included thoses which are disabled. When I inspect $tree variable, I have all my menu items.

I don't know why but after the call to the build method, I get only my enabled items.


texts: How to export the config files of a content type to a module?

texts:
I have a custom module. I created a content type and added some fields to that content type. I also enabled the layout builder on the manage display of the content type

Then I run drush -y cex to export the config files.

Then I copy all the config files related to my content type to the module's config/install director

Now if I make some changes to content type, their config files should be added/updated/exported in/to the module's config/install directory and should not be added to the site's default sync directory.

Is this possible?


texts: How to create simple dynamic Views in Drupal 7

texts: I have a Drupal 7 photo gallery that I would like to auto simulate a View to be created once new photo gallery content has been saved/published for it. For instance, I have a content type called "Gallery" with your basic fields: Title, Taxonomy and Image(w/ unlimited values).  I want to be able to have a dynamic View fire off and create the new gallery once  gallery content has been saved. So this way I don't have to login to create the view manually every time...it would instead pull the necessary unique values for new gallery View from the content:  Taxonomy, URL Alias and Title. I'm thinking this is possible to do in some way with Token, Rules, View rules, or VBO.  Perhaps even a hook may be necessary? -Thx


texts: How to add a block to a region in html.tpl?

texts:
I'm using Drupal 7.

I have a custom template html--custom.tpl.php.

I have a custom block that contains the main menu. This block is enabled in the header region of block admin.

Up to this point, everything but the menu block prints.

How can I print the custom block in the header region of the html.tpl file?


texts: Import orders from xls/csv to drupal commerce

texts: I am trying to import orders from xls file to drupal commerce store.Is there any existing module for this, I found commerce_migrate and commerce_feeds module I am not sure if they can be helpful here could not find if any of the two module provides this functionality as not mentioned on project page.


texts: Webforms - Integrating conditional fields into select options

texts:
I'm looking for a way to have fields show up if a user selects a particular option, inline with, or directly below the option.

For example:

I would like to teach (if selected show a list of grades directly below or inline with question).
I would like to mentor (if selected show a list of grades directly below or inline with question).
I would like to supervise (if selected show a list of grades directly below or inline with question).

I've tried to do it using conditionals, but it can only show fields at the end of all of the select options.


texts:
I have inherited a drupal 6 site with some custom modules, all of which are making use of db_query() commands.

Now I'm porting the site with all it's modules to drupal 7, and consequently have to adjust most of the database queries to work with the new DBTNG abstraction layer.

That's fine, but a very tedious task. Is there any automated way to do this, or a module to at least help you on the way?

E.g.: is there some way to turn this

$query = "SELECT * FROM mytable WHERE id=1";
$result = db_query($query);

into this:

$result = db_select('mytable','t')
    ->fields('t')
    ->condition('id',1)
    ->execute()
    ->fetchAll();

Thanks a lot in advance!


texts:
On my Drupal 7 site I have some heavy performance problems. I found out (with XHProf) that the cause of that problem are some Views. The strange thing is: not the query build time nor the query execute time are to slow, but the views rendering time:

Query build time    4.83 ms
Query execute time  3.29 ms
View render time    1175.82 ms

The view is complicated because it has 7 relations. So that its build and execute time is as long as it actually shows up in the example above, is what one would expect. But the rendering can not depend on the complexity of the query, right? But only on the complexity of the resulting array or something else.
So, my question is, where to start to optimize View render time?

ps.: If the view is cached it much faster. But I have to optimize its over all execution time, when it's not cache or can't be cached.


texts: Get a list of available migration destination plugins

texts:
how can I get all available migration destination plugins?
A way to ask with drupal console?

like listed on Migrate destination plugin examples


texts:
I have a new OA site spun up and have some content available for the few users I have. One of the requests from the user's is to be able to view (and most likely edit) the documents via the web browser.

I was able to open a Word document in the browser when using IE, however I was unable to edit the document. Also, opening project files was a no go.

I am pretty new to Drupal, however any research I did on this issue just brought me different file manager modules.

Is it possible to view/edit files in the browser with Drupal/Open Atrium?  I know it is possible with SharePoint but that utilizes a back end office.

Or is it possible to have it so people can open files automatically in their client side applications (Project, Word etc.) and have it save to the OA file system?


texts: How I can create a user programatically using user registration form?

texts:
How I can create a user programatically in drupal 8. I am using the following code to generate user registration form.

$account = $this->entityTypeManager->getStorage('user')->create([]);
$form = $this->entityFormBuilder->getForm($account, 'register');

and form_sate values using the following code.

$form_state = (new FormState())->setValues(['name' => 'user1', 'pass' => 'pass']);

Now how can submit this form using the above form_state values?


texts: How to remove ul li formatting from list of attributes in Ubercart order email template?

texts:
I would like to update my customer order email and printable invoice so that each product line item looks like this:

1 x SHIRTRED | Red | Tshirt

1 is the quantity ordered
SHIRTRED is the SKU
Red is the attribute option that was chosen
Tshirt is the product name

I have already updated my uc-order--customer.tpl.php code to look like this:

<b><?php print $product->qty; ?> x </b> <?php print $product->model; ?> | <?php print $product->title; ?> | <?php print $product->details; ?>

The attribute options are printed as a ul list, which causes them to wrap to the next line below the other info for this product. I would like to remove the ul li formatting from the product's attributes in the customer order email and the printable invoice so that the info can be on a single line/table row. I found this in uc_order.module:

$product->details .= theme('item_list', array('items' => $attributes));

Would I just change 'item_list' to something else in a template.php function? If so, what would I change it to? If not, how else can I accomplish this change?

Thanks!


texts:
I have a view with one field that shows rendered nodes, and a contextual filter (multiple values allowed) that provides the nids that should be used in the view.

Each node (with nid from the context filter) contains a node reference field with multiple values (nids of related products).

My problem is that a number of these related products, are in fact unpublished nodes. So how can I exclude these unpublished nodes from showing up in the views result? Just adding the filter Published = Yes does not work since the field in the view always is published. It is some of the rendered nodes, produced by that field, that in their turn are unpublished.

UPDATE: in a custom module I have now added this snippet:

function mymodule_views_post_execute(&$view) {
  if ($view->name === 'my_view' && $view->current_display === 'related_products') {
    foreach ($view->result as $result) {

      foreach($result->field_field_add_products as $key => $product){
        if($product['rendered']['#node']->status == 0){
          unset($result->field_field_add_products[$key]);
        }
      }
    }
  }
}

...and this does actually exclude the unwanted products. BUT they don't just leave gracefully. They leave a gap in the (repsonsive) grid that I use to show these products. How do I exclude them AND the space they occupy in my views grid?

UPDATE: this is my PHP snippet in the contextual filter:

$node = menu_get_object();
$value = null;
if(empty($node->field_lagg_till_givargrupp['und'][0]['nid'])){
    $node->field_lagg_till_givargrupp['und'][0]['nid'] = NULL;
    return FALSE;
} else {
    $groups = $node->field_lagg_till_givargrupp['und'];
    foreach($groups as $group){
        $group_nid = $group['nid']; // hämta node-id
                $value .= $group_nid.",";
    }
    return rtrim($value, ",");
}

It works well and supplies the nids wanted (the node ids for the nodes with multiple products grouped in node reference fields).

And this is a partial screenshot of the view:

I use the field Innehåll: Titel (Content: Title) to group the result by the title of each product group. The field Innehåll: Koppla givare (Content: related products) produces all the nodes present in the node reference fields. If there are 20 products entered in that multiple value field, I will have 20 rendered nodes as a result, of which some are not publised. See the resulting view below. The gaps are unpublished nodes that I succeeded in excluding with my snippet above.

So how do I rebuild the view result so that there are no gaps?


texts: How do I get an array of user roles to use in #options?

texts:
Trying to convert my module to D8 and running into a problem using the D7: user_roles() function. Here's my D7 module code:

$form['role_vis_settings']['tynt_roles'] = array(
  '#type'          => 'checkboxes',
  '#title'         => t('Add tracking for specific roles'),
  '#default_value' => variable_get('tynt_roles', array()),
  '#options'       => user_roles(),
  '#description'   => t('Add tracking only for the selected role(s). If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked.'),
);

And what I've got so far for D8:

$form['role_vis_settings']['tynt_roles'] = array(
  '#type'          => 'checkboxes',
  '#title'         => $this->t('Add tracking for specific roles'),
  '#default_value' => $settings['tynt_roles'],
  '#options'       => user_roles(),
  '#description'   => $this->t('Add tracking only for the selected role(s). If none of the roles are selected, all users will be tracked. If a user has any of the roles checked, that user will be tracked.'),
);

But get:

The website encountered an unexpected error. Please try again later.

I've looked at:

https://api.drupal.org/api/drupal/core!modules!user!src!Entity!User.php/function/User%3A%3AgetRoles/8
https://api.drupal.org/api/drupal/core!modules!user!user.module/function/user_roles/8

The second was closet but not a format the #options array would allow (https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/8#options).

Anyone have any ideas?


texts: Drupal 6 CCK fields export/import in between environments

texts:
I have a Drupal 6 website that uses a lot of custom content types and along with a lot of CCK fields. Now with each new hotfix/patch/amendment new content types and CCK fields are added. Once the new code is developed in DEV Server it is moved to another to test. Then again after testing it is moved to QA then to the Production.

But with the increasing Content Types and CCK fields we are finding very hard to manage all those in moving to server to server.
So I googled and found
http://www.lullabot.com/articles/moving-cck-field-changes-from-dev-to-live
But the problem is, this tutorial is based on Drupal 5 and an older version of devel module packaged with macro module.
Now a days, macro is a separate module and it is not working as expected, its giving a lot of errors and the available patches are not able to solve it.

So is there any way to track all the Content Type Addition or Changes and the New Field or Existing Field addition or changes?

It would be really helpful if any solution is provided. Thanks!


texts: Auto Complete displaying wrong for non-admin users

texts:
I've recently started a module that runs an autocomplete via the taxonomy. It's attached to a form textarea element:

$form['bb_occupation'] = array(
    ...
    '#autocomplete_path' => 'taxonomy/autocomplete/field_occupations_list',
);

My issue is as follows, The options returned from the auto complete display correctly for admin/logged in users:

Full size image

While, if a non-admin/non logged in user visits said site, they're greeted with this:

Full size image

Where the options appear well off screen. I did a little research on Drupal & Google and came up with these:

Autocomplete fields appear in wrong place for non-admins in...

Which lead to an answer that did the following sort of deal (taken from here):

$($input).parent().addClass('autocomplete-wrapper');

in the autocomplete.js and this:

.autocomplete-wrapper {
  position: relative;
}

to the system.base.css files. That didn't work for me, and I've been playing with positioning for practically the whole day now, do you guys have any suggestions as to how I can amend/fix this?

It is not related to anything like this:

(custom )Autocomplete won't work when the user is not logged

as it isn't a custom function doing the autocomplete, it's through the taxonomy.
It can't be a permissions error either because the menu with suggestions shows up, just not where it's supposed to.


texts: What is the alternative to file_unmanaged_save_data()?

texts:
In a custom module, I use this code.
file_unmanaged_save_data($data, 'private://' . $path, FILE_EXISTS_REPLACE);

The documentation for that function has the following warning.

Deprecated
In drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\FileSystemInterface::saveData().

So I tried using \Drupal\Core\File\FileSystemInterface::saveData($data, 'private://' . $path, FileSystemInterface::EXISTS_REPLACE),
which gives the Non-static method cannot be called statically.
Adding use Drupal\Core\File\FileSystemInterface; at the beginning of the module doesn't change anything.
In the same page, I found also a link to Unmanaged file functions replaced with a service which explains that file_unmanaged_save_data($data, $destination, $replace)
has been replaced by \Drupal::service('file_system')->saveData($data, $destination, $replace). It seems to work, but I'm still wandering:
Is there another way to do it?


texts: How to implement a hit counter for all 'Article' type nodes? I want to display number of times (could be unique) a node was visited - perhaps within the teaser and at the bottom of the node.


texts: ajax_command_invoke addClass changes lost after form validation

texts:
I am currently trying to build a form which has a series of select elements, each of which triggers display of a textarea specific to that select element which is initially hidden.

Currently the select element has a callback to a function which is using ajax_command_css (to toggle the view of the textbox) and also ajax_command_invoke to add a class to the textbox so that it is still shown after validation errors are triggered. Currently after a validation event, the classes added using this method are lost so the textboxes remain hidden.

Select and textareas are created like this:

$form['2og_select'] = array(
    '#prefix' => $blurb,
    '#title' => t('2OG'),
    '#type' => 'select',
    '#options' => array(
      t(' '),t('1'),t('2'),t('3'),t('4'),t('5'),
    ),
    '#ajax' => array(
      'callback' => 'show_comments_js',
      'event' => 'change',
      'effect' => 'fade',
      'progress' => array(
        'message' => '',
        'type' => 'throbber',
      ),
    ),
  );
  $form['2og_textarea'] = array(
    '#type' => 'textfield',
    '#maxlength' => 512,
    '#suffix' => ('

'),
    '#attributes' => array(
      'class' => array('comments'),
    ),
  );

Callback function looks like this:

function show_comments_js($form, &$form_state) {

  $commands = array();

  $triggerName = $form_state['triggering_element']['#name'];
  $triggerValue = $form_state['triggering_element']['#value'];

  $name_bits = explode('_',$triggerName);
  if ($triggerValue != '0') {
    $commands[] = ajax_command_css('#edit-' . $name_bits[0]  . '-textarea', array('display' => 'inline'));
    $commands[] = ajax_command_invoke('#edit-' . $name_bits[0]  . '-textarea', addClass, array('show-comments'));
  }
  else {
    $commands[] = ajax_command_css('#edit-' . $name_bits[0]  . '-textarea', array('display' => 'none'));
    $commands[] = ajax_command_invoke('#edit-' . $name_bits[0]  . '-textarea', removeClass, array('show-comments'));
  }

  return array('#type' => 'ajax', '#commands' => $commands);
}

I have also noticed that the id of the form has '--2' appended to it after submitting, could this be related?

Would using an ajax validation tied to the submit button have the same effect?


texts: How to let admin upload background image for view page and webform page?

texts:
I would like admin to upload background image for each and every different pages in my drupal 7 site.

For normal content type like basic page, BackgroundField module works perfectly where admin can upload images in the file field.

But in webform pages and pages created by view, BackgroundField module can't be used.

Is there any way admin can upload their background image for both webform pages and view pages? As currently I'm using css to set the background images for these pages.


texts: Is there a way to do concurrent editing?

texts:
Is there a MediaWiki-like method for supporting concurrent editing of text bodies in Drupal 7?

If no feature currently exists, what are some decent PHP diff libraries that could be wrapped up by a Drupal module that could do the job?


texts: Drilling down into an Entity Reference Field in Rules Actions

texts:
I have the following setup where I have 2 content types called BRIEFS and IDEAS. On BRIEFS, I have a list of users selected in a field called brief_recipients which is a user reference field.

IDEAS has a entity reference field (associated_brief) that references a BRIEF.

Currently when I create an IDEA, it will email the author of the referenced BRIEF. This works using the following rules setup:

Now I'm trying to add in a LOOP to access the entityfield associated_brief's > brief_recipients field and email them too.

But the problem seems to be that Rules cannot drill down into an entityfield's fields as I can only get to body and author only as seen here:

Now the question is how do you drill down into an entity field's fields? Or is there another suggested way of doing this?

Which hook would I need to tap into if I had to write this custom?


texts:
I am using the Gmap module to display a map on the page; however, it works on the PC, but not on the iPhone.
I checked the iPhone debug console, and got the following error:

  Drupal.gmap [undefined] is not an object

Could anyone please suggest me the way to solve this problem?


texts: How do you use tabledrag API in a multi-page environment?

texts:
As you can see in the image below, I'm using drupal_add_tabledrag to allow admin to sort node order by dragging. But how do I drag the items from one page to another? Is there additional Drupal API, or if not, how would you go about this?

There can be hundreds of nodes, I cannot fit them on a single page.


texts: Views: Display block based on taxonomy term

texts:
I have a vocabulary (Alive or Deceased) that has 2 terms (alive and deceased).
If the node is under "alive" category there should be displayed block A, otherwise no block should be displayed.

How can I do that using views?

Thanks.


texts: How do I get the content type name using code?

texts:
I'm working on Drupal 8 and I want to get content type machine name and label. Here is my code:

$cont_type = node_type_get_types();
foreach ($cont_type as $key => $value) {
  $label = $value->name;
  $machine_name = $key;
}

I get the following error message:

  Cannot access protected property Drupal\node\Entity\NodeType::$name

Hoe can I get the content type name?


texts: Why should we avoid theming forms with template files?

texts: The issue was raised in this question. Why not exploit the advantages that template files offer in the case of forms?


texts: How change views exposed filter drop down format?

texts:
I'm working on a D7 site where I am trying to implement a simple view of a custom content type. I want to have a drop-down select list of taxonomy terms to be able to filter the content by. At the moment, I just seem to have a box with the taxonomy terms in it. They filter the content appropriately when selected, but the UI seems bad to me and I'm not sure how to change it. It has the same UI implementation whether or use Better Exposed Filters or not.

What I'd like to implement is just a scrollable drop down select list but I'm not sure how to go about this.


texts: How do I get the output of a single field?

texts:
How do I get the output of a field of a node?
I have some weird subpage construct using entity references (one 'main' node and a few 'sub'-nodes).

Each of these nodes have a header image to be displayed above the content. What I am trying to do is for the sub-nodes to 'inherit' the header image of the main node.

I implemented hook_node_view and I have got the node, I just don't know how to build the renderable array for it.

function hook_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
  if($view_mode == 'full'){
    if((!isset($build['field_headerimage']) || !isset($build['field_headerimage'][0])) && $entity->hasField('field_location')){
      $location = $entity->get('field_location')->referencedEntities();
      if(is_array($location) && isset($location[0])) {
        $node = $location[0];
        dsm('yay, now what?');
        dsm($node->label());
      }
    }
  }
}


texts: How do I keep fields from being in the same row?

texts: I've attached a pic to show what I'm talking about.  I'm using 'fluid-grid' in Views.  Drupal 7.  Thanks so much![1]


texts: Language switcher links are hidden for anonymous users

texts:
I'm trying to add a language switcher to a Drupal 8 site menu (it's switching between English and Spanish). I have the links working when logged in as admin but they're not shown for anonymous users, even though the language switcher block displays fine, as well as adding a language switcher through twig. However, I'd really like to get this working and be able to add it to menus through a custom module.

As an anonymous user I am able to view the translated content (by clicking the Default Drupal language switcher options) but these links that are created are not rendered.

Here's my code for the custom module:

MYMODULE.links.menu.yml

MYMODULE.switch:
  class: Drupal\MYMODULE\Plugin\Menu\MenuLanguageLink
  menu_name: MENUNAME
  route_name: '<current>'
  options:
    attributes:
      hreflang: 'en'
MYMODULE.switch_2:
  class: Drupal\MYMODULE\Plugin\Menu\MenuLanguageLink
  menu_name: MENU2NAME
  route_name: '<current>'
  options:
    attributes:
      hreflang: 'es'

/src/Plugin/Menu/MenuLanguageLink.php:

<?php
/**
 * @file
 * Contains \Drupal\MYMODULE\Plugin\Menu\LanguageSwitchController.
 */
namespace Drupal\MYMODULE\Plugin\Menu;

use Drupal\Core\Menu\MenuLinkBase;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MenuLanguageLink extends MenuLinkBase implements ContainerFactoryPluginInterface {

  /** @var array Available languages */
  protected $languages = [];

  /**
   * {@inheritdoc}
   */
  public function __construct(
    array $configuration,
    $plugin_id,
    $plugin_definition,
    LanguageManagerInterface $language_manager
  ) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->languages = $language_manager->getLanguages();
  }

  /**
   * Dependency injection.
   */
  public static function create(
    ContainerInterface $container,
    array $configuration,
    $plugin_id,
    $plugin_definition
  ) {
    return new static(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('language_manager')
    );
  }

  /**
   * {@inheritdoc}
   */
  public function updateLink(array $new_definition_values, $persist) {
    return $this->pluginDefinition;
  }

  /**
   * {@inheritdoc}
   */
  public function getOptions() {
    $options = parent::getOptions();
    $langcode = $options['attributes']['hreflang'];

    if (isset($this->languages[$langcode])) {
      $options += ['language' => $this->languages[$langcode]];
    }

    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    $langcode = $this->getOptions()['attributes']['hreflang'];
    if ($langcode == 'es') {
      return 'Español';
    } else {
      return $this->languages[$langcode]->getName();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->t('Switch Language');
  }

}


texts: I can find reference that there is no loop UI for Rules but that it is implemented in the module using expressions (https://www.drupal.org/docs/8/modules/d8-rules-essentials/for-developers/expressions). What I cannot find is how to use the built in rules expressions in my code.  If someone could point me to a simple example of how to loop in rules, I can go from there.


texts: How to create nodes "emulating" form submit

texts:
I usually create and edit nodes, programmatically, using node_load and the node_save, and addind data to fields in this way:

$node->field_custom['lang'][0]['value'] = 'My value';

But in this way I've to check lang, and even if my node is "it" same fields (as terms, or other fields) need "und" and something like this.

Is there way to create and edit nodes loading the form and the submitting the form with new values?


texts:
Problem: Need to run my own searches programmatically with Search API. Every google result I find is geared toward teaching non-developers how to use the module with Views with no results on doing it like I want.

Information:

Using local database service instead of Solr or any other.
Have data not stored in database that will appear alongside other results.
Content will be grouped in "type" tabs.
Not using Views for various reasons.
Have Facets API enabled but no clue how to use it either.

Why: Because I want to have the search page be at /site-search and without /node/keyword after the page argument. Also will be asked to customize this beyond the scope of other modules that may provide the same type of functionality. And I want to learn how to do this but have not found any tutorials or other insight on how to accomplish it.

The rest:
I have created my search page and on it I am executing the search with:

$term = $_SESSION['my-search']['term'];
$server = search_api_server_load('database');
$index = search_api_index_load('default_node_index');
$query = new SearchApiQuery($index);
$query->keys($term);
$query->fields(array('title','body:value'));
$srv= new SearchApiDbService($server);
$result = $srv->search($query);

The session variable is set when a search form is submitted then redirects the user to /site-search to perform the search and show the results.

If I output $result I see it's an array with different information including a result set that is an array of node ids and their scores.

I could run through those, grabbing the node and displaying the results myself but I figure there's got to be some other method for rendering the results of the search. I haven't found it though and that's the problem.

I've been looking through the different classes in Search API and Facet API and can't find anything in them that seem like they would build result output.

Any help with this will be appreciated.

Results example:

Array
(
[result count] => 11
[results] => Array
    (
        [37] => Array
            (
                [id] => 37
                [score] => 15.7503318786621
            )

        [39] => Array
            (
                [id] => 39
                [score] => 7
            )

        [40] => Array
            (
                [id] => 40
                [score] => 5
            )

        [31] => Array
            (
                [id] => 31
                [score] => 4
            )

        [33] => Array
            (
                [id] => 33
                [score] => 1
            )

        [36] => Array
            (
                [id] => 36
                [score] => 1
            )

        [1] => Array
            (
                [id] => 1
                [score] => 1
            )

        [15] => Array
            (
                [id] => 15
                [score] => 1
            )

        [16] => Array
            (
                [id] => 16
                [score] => 1
            )

        [27] => Array
            (
                [id] => 27
                [score] => 1
            )

        [35] => Array
            (
                [id] => 35
                [score] => 0.980873763561249
            )

    )

[warnings] => Array
    (
    )

[ignored] => Array
    (
    )

[performance] => Array
    (
        [complete] => 0.0033111572265625
        [preprocessing] => 0.00053095817565918
        [execution] => 0.0027379989624023
        [postprocessing] => 4.2200088500977E-5
    )

)


texts: Cloning the request when taking preview of a node

texts:
I have a weird issue in Drupal 6 that when taking the preview of a node, it's cloning and make another node type with exact same details. Any idea why this happens?

I guess the below code is working when clicking the preview button :
modules/node/node.pages.inc

/**
 * Generate a node preview.
 */
function node_preview($node) {
    if (node_access('create', $node) || node_access('update', $node)) {
        // Load the user's name when needed.
        if (isset($node->name)) {
            // The use of isset() is mandatory in the context of user IDs, because
            // user ID 0 denotes the anonymous user.
            if ($user = user_load(array('name' => $node->name))) {
                $node->uid = $user->uid;
                $node->picture = $user->picture;
            } else {
                $node->uid = 0; // anonymous user
            }
        } else if ($node->uid) {
            $user = user_load(array('uid' => $node->uid));
            $node->name = $user->name;
            $node->picture = $user->picture;
        }

        $node->changed = time();

        // Extract a teaser, if it hasn't been set (e.g. by a module-provided
        // 'teaser' form item).
        if (!isset($node->teaser)) {
            $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format);
            // Chop off the teaser from the body if needed.
            if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
                $node->body = substr($node->body, strlen($node->teaser));
            }
        }

        // Display a preview of the node.
        // Previewing alters $node so it needs to be cloned.
        if (!form_get_errors()) {
            $cloned_node = drupal_clone($node);
            $cloned_node->build_mode = NODE_BUILD_PREVIEW;
            $output = theme('node_preview', $cloned_node);
        }
        drupal_set_title(t('Preview'));

        return $output;
    }
}


texts: Programmatically set date fields in Drupal 7: Date, Date (ISO Format) and Date (Unix Timestamp)

texts:
Using the Form API and hook_form_alter(), how can I manually set (force) the values for each of Drupal 7's date field types using a valid Unix Timestamp?

When the form is finally submit the field_date types are always empty arrays.  Below is the broken code I'm working from.

hook_form_alter(&$form, &$form_state, $form_id) {

    // http://drupal.org/node/1455576 - Date
    $form['field_date'][LANGUAGE_NONE][0]['value'] = time();

    // http://drupal.org/node/1455576 - Date (ISO Format)
    $form['field_date_iso_format'][LANGUAGE_NONE][0]['value'] = time();

    // http://drupal.org/node/1455576 - Date (Unix Timestamp)
    $form['field_date_unix_timestamp'][LANGUAGE_NONE][0]['value'] =time();
}

I should mention the fields widget is set to text and it's format is 'Y-m-d H:i:s'

I have also tried date('Y-m-d H:i:s', time()) instead of time().

Example dpm() output.

I should also note that as a workaround I can set the field if I modify it in hook_node_presave().  To do this I set $node->field_date['und'][0]['value'] = date('Y-m-d H:i:s', $my_unix_timestamp); I would still like to understand how to do this using hook_form_alter instead.


texts: Why are the thumbnail images not loading?

texts:
I am using Drupal 8, and have just moved my site to shared hosting. When I upload a standard image field on my shared hosting environment, the thumbnail image does not show up. This works perfectly on my local (WAMP) development environment.
The full sized image is in sites/default/files/2017-02/redstart.jpg and is displayed correctly.
The thumbnail address is /sites/default/files/styles/thumbnail/public/2017-02/redstart.jpg and does not display (I assume it cannot create it).
I have checked all file permissions on the server, but cannot see anything wrong (directories are 0755, files 0644)
Any ideas anyone? Is there another setting somewhere that I need to update?


texts:
I am trying to figure out if it is possible to do a checkout via API for Drupal commerce 2.
In Drupal 7 there was a module Commerce Services Resources.

I found some posts, but they don't answer my question:

Can I connect via REST services with a mobile app I will develop?
Is there any module for Restful API in drupal 7 with commerce

I also found a not finished / maintained repository containing some web apis doing similar stuff, https://github.com/solody/commerce_checkout_api


texts: Rule for sending email when order exceeds a defined weight

texts:
I set up some shipping tariffs (with module shipping weight tariff). But now i want to define a rule that sends an email to the shopowner in case the order total weight is over a certain weight. How should this rule be defined? The one i made is not working, it is not kicking in (for sake of simplicity in the below example I chose to show a message instead of sending an email):

    { "rules_shipping_weight_alert" : {
    "LABEL" : "Shipping Weight Alert",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-8",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_physical", "commerce_shipping" ],
    "ON" : { "commerce_shipping_collect_rates" : [] },
    "IF" : [
      { "entity_is_of_type" : { "entity" : [ "commerce-order" ], "type" : "commerce_order" } },
      { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "field_physical_weight" } },
      { "commerce_physical_rules_order_weight_comparison" : {
          "commerce_order" : [ "commerce-order" ],
          "operator" : "\u003E",
          "value" : "9",
          "unit" : "kg"
        }
      }
    ],
    "DO" : [ { "drupal_message" : { "message" : "Shipping weight alert!" } } ]
  }
}

Any help would be much appreciated!


texts: Allow non-admin users to view an EntityForm submission

texts:
I've created an EntityForm wich authenticated users can submit.

Then I've created a view wich list every entityForm submissions and everyone can see this view.

Now I want to add a field to this view. This field will contain a link to this specific EntityForm submission.

2 solutions:
-Display the direct link "Entityform Submission: Link"
-Display an URL "Entityform Submission: URL"

As an admin:

Those solutions both work, but only as an administrator!

The link is invisible for non-admin persons.
The URL leads to a "Access denied - You are not authorized to access this page."

As a non-admin:

Question : How can I allow non-admin users to access entityForm submission pages?

Thanks!


texts: How to add a line item to show total cost in Ubercart 2?

texts:
I am using Ubercart 2 and I want to add a line item, which should add the total cost of all items instead of sell price. I tried to take the code from generic line item hook and used this to callback:

for each($op->products as item) {
  $cost += $item->cost;
}

I want this line item to appear in the AJAX cart, which I am using now. It should appear in the user panel before checkout and it should also shown in the user and store admin order emails. It is not working as of now. Is the code I am adding correct or I have done any misplacement?


texts: How do I create a page using Views and Drupal Commerce, where every listed term is a search term?

texts:
I am setting up a site using Drupal Commerce, for an online medicine store. I need to create a Views display page that displays around 30 product titles, (maybe chosen randomly and) arranged alphabetically. The challenge, however is that each of the displayed titles, when clicked, leads to a search results page, which then displays all products that have the title as part of their name. The display page is similar to the following link:

http://www.progressiverx.com/store/prescription-otc.php

If you will click on any of the displayed medicine names, you will see the search results page that I am talking about.

I am not sure if there is a specific module or some configuration/logic that I can use to achieve the same using Views. Any help will be deeply appreciated. Thanks in advance.


texts: Should I use underscore or hyphenated tokens?

texts:
When displaying tokens that can be used I often see this type of thing:

I have seen that there are a number of d.o issues on this; one in particular is extensive and detailed. But is there a reason to use the dashed one or the hyphened one? There may be a D8 migration reason for all I know?


texts: How to render only markup in region template?

texts:
I have created a region--footer.html.twig template which only contains the static markup for the footer. Now I would like to render this region at the bottom of each page so I have added the following to the end of page.html.twig:

{{ page.footer }}

This works fine as long as I have connected a block to the footer region under admin/structure/block. If no blocks are placed in the region it is regardes as empty and is not rendered. How can I change so the region--footer.html.twig is used even if there is no blocks placed in the region?

I was thinking of using a preprocess function for the region doing something like this:

function template_preprocess_region(&$variables) {
  if ($variables['region'] == 'footer') {
    $variables['content'] = 1;
  }
}


texts: A way to choose a block title's format (HTML tag)

texts:
What I would like to do is be able to choose what type of Headline HTML element (h2, h3, etc) to use for each block's title. The only way I can find to change a block's Title is in block.tpl.php.  But this forces every block on the site to all have the same Headline.

I've Google'd and searched Drupal.org for a module or manual way to do this but have not found one. Does anyone know of a module that does this?


texts: How do I get translated strings into Drupal.locale.strings?

texts:
So I'm trying to use the Drupal.t() function in some of my custom Javascript code (in my theme).

How do I get the strings I need populated in the Drupal.locale.strings object? I see some strings in there, but of course the entire database can't be loaded. What's the best way to add to it? I would like to use the PHP t() function so that the strings added can be edited in the Translate interface.


texts:
I've created a view that lists the content based on the first letter of that title matching an argument passed to the page. Now I'm trying to do the same, but with a 0-9 so when the user selects 0-9 the view gets all content types which begin with a number in the range 0-9.

I'm currently looking at hook_views_query_alter(), but I don't get back the results I am expecting. The function I've written is the following one:

function module_views_query_alter(&$view, &$query) {
  if ($view->name == 'custom_page' && $view->current_display == 'page_1') {
    if ($view->args[0] == '0-9') {
      $query->where[0]['conditions'][2]['field'] = 'SUBSTRING(node.title, 1, 1)';
      $query->where[0]['conditions'][2]['value'] = array('0','1','2','3','4','5','6','7','8','9');
      $query->where[0]['conditions'][2]['operator'] = 'in';
    }
  }
}


texts: Ajax div update to insert JS for subsequent asynchronous request to external site

texts:
I wanted to use the postscribe library (https://github.com/krux/postscribe) to make an asynchronous request to google trends, which would update a div with a graph without requiring a page reload.

Using the library on its own through a few methods (drupal_add_js or a custom block) works just fine, but I wish for the js code to be reloaded everytime the appropriate ajax callback is initiated.

$form['trends-visual'] = array(
  '#prefix' => '
',
  '#suffix' => '

',
  '#ajax' => array(
    'effect' => 'fade',
  ),
);

$form['trends-graph'] = array(
  '#prefix' => '
 '
',
);

$form['submit'] = array(
  '#type' => 'submit',
  '#value' => 'Submit',
  '#ajax' => array(
    'callback' => 'trends_ajax_submit_callback',
  )
);

The callback

function trends_ajax_submit_callback($ajax, &$form, &$form_state)  {

 $form_state['rebuild'] = TRUE;
 $commands = array();
 $commands[] = ajax_command_html('#trends-visualization-container',
   '\');
         }
       }
      })(jQuery);</script>');

return array('#type' => 'ajax', '#commands' => $commands);

Triggering the Ajax with $form['submit'] results in the following JS error:

Uncaught SyntaxError: Unexpected token ILLEGAL

This is referencing my JS code, specifically this line:

postscribe('#trends-graph', '


texts: Multistep module not works for User Edit form (Edit Profile)

texts:
The Multistep module works well for nodes in content types, like Article, Page, etc.

But when I tried to use Multistep for Account fields, it failed. I cannot find anything about "User form" in Structure->Block (while other content types Multistep form will be shown here).

How could I make the "Edit Profile" form as multi-step?


texts: Why is $node->taxonomy not populated when implementing a custom hook_nodeapi?

texts:
I have implemented a hook_nodeapi in a Drupal 6 site. When looking into the node, I found out the node->taxonomy is not loaded. This means taxonomy_nodeapi is not invoked before my hook even though the weigh of my module is greater than taxonomy.

Edit Adding code:

hook_nodeapi(&$node, $op, $arg = 0) {
if ($node->type == 'articles' && $op == 'load') {
  dpm($node)
 }

I think this may be default behaviors. Invoking taxonomy_nodeapi() directly works for me but I am still wondering as to why this is the case.


texts: Creating a very specific custom Views argument handler

texts:
I've been employed to help fix and finish a D6 site. It's already late so any answers like "you need to change the underlying DB structure" - well, we can't we're stuck with it. (It was built by idiots and we're doing the best we can.)

This is for an educational establishment with a curriculum that has changed in the past (we're migrating from an older system and all the data has to come over) and will change in the future. Each version of the curriculum has a version number. Every student is on one of those versions depending on when they started, so they are all active.

There's a taxonomy term for each of the three versions (D6 remember) which is attached to each Course Module. Each user has a User Profile node which has the user's version.

I am trying to create a Views 3 argument handler which takes a user's UID and delivers the NIDs of all the Course Modules tagged with it.

UID -> User Profile node -> TID -> Course Module NIDs

The complexity comes for example where the TID must be from the Version taxonomy (user profile's have other tags).

Now I accept I may be overthinking this, maybe it can be done with relationships, but I feel using this would be so much easier to understand for any future developers because the views concerned are complicated and already have lots of relationships in them.

A solution would be great (I know, presumptuous) but I have contributed quite a bit to the community including modules and bug-fixes (lots on Search API last year). I have produced Views handlers before but it's never easy, and I have read most if not all the various websites and documentation.

Any help would be much appreciated.


texts: Creating view filter that lists most recent, except the x most recent

texts:
I'm trying to create a view that will go on a front page where the three most recent articles will be featured content displayed in a slideshow. I've got that working, but my issue is displaying the rest of the most recent articles in another view, as a list formatted normally as they appear in the teaser display. My problem isn't achieving that display, it's filtering the articles properly so I get most recent - 3 most recent. I'm trying to not be redundant on this articles page.

If my approach of creating two different views to achieve this effect is totally misguided, or if there's some other glaring way to do this more easily, please correct me. I'll be very grateful.

For clarity, I'm including a rough sketch, where the numbers indicate the recentness of the article and the top unit is the featured content slideshow display:


texts:
I am trying to create custom compound field with a text field and a date popup.

I've tried the following code:

 $element['year'] = array(
    '#title' => t('date'),
    '#type' => 'select',
    '#default_value' => $options['year'],
    '#options' => $options,
    '#weight' => 2,
  );

...

function _universitydegrees_values_year() {
    $options = array(
        'year',
        1970,
        1971,
        1972,);
    return $options;
}


texts: Single sign on between different Drupal versions

texts:
Is it possible to have this module working with different Drupal versions?
We have some big projects in Drupal 6 and we want to start with a migration plan. Without being able to migrate parts of our sites, the task is much more complex than being able to do small migrations and tests.

I have seen there is the Bakery Single Sign-On System, but I don't know if it can be used when the subdomains use different Drupal versions.

UPDATE: bakery works like a charm for that. You can install it on different Drupal version sites, different fillet on same domain and, of course, different sub domains.


texts: How to prevent that import with Feeds and Elysia cron gets stuck

texts:
I have several Feeds which are called by Elysia cron.
The feeds are called at a given time, and later the last two feeds are called each 2 minutes, because it was the only way of preventing them from stopping. However, when data has increased in size and complexity, the cron process is stopped because one or both of the last Feeds are stuck and never ending.

I have seen that by updating the database table elysia_cron by setting the field running to 0, the Feeds are completed.

So my idea was to create a daemon to regularly update the process and thus prevent the hanging of the Feeds process.

What am I missing, shouldn't this check had been already incorporated into the module itself? What other ideas could prevent the failed import?


texts: What it's the easiest way to add a flash frontpage without alter Views node page?

texts: I'm using Views to render content in frontpage, but now, I want create a single flash presentation page as frontpage that links to the current frontpage.


texts: How to display a field collection as a responsive table?

texts:
I'm using field collection and field collection table modules to show the data as a table, but I want that the table is be responsive.

How I do it? I don't found a good solution.

For example, for views table I use responsive_table_filter module that accomplishes this task.


texts: How do I overwrite the particular webform submit event in template.php?

texts:
I want to control a particular webform submission event, and I am trying to use the following function in my template.php file.

function bartik_form_webform_client_form_7_submit(&$form, &$form_state) {}

The function is not working. How can I achieve this?


texts: Features_extra: after enabling fe_block, no Machine Name field appears on block edit form

texts:
I installed and enabled fe_block 6.x-1.x-dev, but when I reload one of my blocks' edit form, no machine name field appears. I tried clearing the cache; no dice.

What's missing? Thanks.


texts: How do I make a horizontal user login block for the top user region?

texts: I'm not sure why but Drupal doesn't provide for a horizontal user login with the register or forgot password links. How do I do this?


texts: Add values to an existing custom entity bundle

texts:
I've created a custom entity with bundle and added 3 fields to the bundle(namely recipient, sender, flag). How can I add values to it programmatically.
Any help would be appreciated.

Thanks


texts:
In essence, I'm trying to make a view of the moderation state "Drafts", (using Content Moderation).

The catch, I'm trying to do so in a Content view for maintainability purposes.

However, it won't show content that has been set the "Published", then back to "Draft". (Because the default revision is still "Published".)

I've played around with the "Content Revisions" relationships, but no success.


texts:
In Drupal 7 with a developed custom module that insert data into a postgreSQL db, I use the following query :

$query = Database::getConnection('default', 'move')
  ->query("INSERT INTO clients (client_ref,client_lastname,client_firstname) VALUES('E11366235','DUPOND') RETURNING client_id")
  ->execute();

But the returned client_id is always 1.

If I set INSERT INTO clients (client_ref,client_lastname,client_firstname) VALUES('E11366235','DUPOND') RETURNING client_id in pgAdmin 3, the returning id is correct.

In both case data are inserted into database but Drupal doesn't return the good id.

Any explanation ?


texts: how to add 'OR' operator in views sort criteria

texts:
How to add 'OR' operator in views sort criteria?

Is there any ui setting or have to do some custom work?

Any suggestion?