texts: Copying field values from one EntityForm to another on submit

texts:
I'm using Drupal 7 and the Entityform module to build a form for people to fill in on my website.

This form will be filled in by a parent and contains some data about his child. There will be 2 buttons:

1 for submitting the form data (default submit button/function)
1 for submitting the form data + opening a new form (of the same type) for a 2nd child (custom submit button/function).

Since this 2nd child will have a lot of data (address, last name,...) that's the same as the first child I'd like to already have those fields filled in in the 2nd form (by using field values from the first form). The same can be repeated for a 3rd child, a 4th child,...

This is my code so far:

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

    if ($form_id == 'generiek_inschrijvingsformulier__entityform_edit_form'){
        $form['submit2'] = $form['actions']['submit'];
        $form['submit2']['#value']='Inschrijven en ook een broer inschrijven';
        $form['submit2']['#weight']=100;
        $form['submit2']['#submit'][1]='extra_inschrijving_default_wp_submit';
    }
}

This code added another submit-button and attached a submit handler (this works).

function extra_inschrijving_default_wp_submit($form, &$form_state){
   $values = &$form_state['values'];

   $prepopulates = array(
      'edit[field_entity_reference][und]' =>
            $values['field_entity_reference']['und'][0]['target_id'],
      'edit[field_1][und][0][value]' => $values['field_1']['und'][0]['value'],
      'edit[field_2][und][0][value]' => $values['field_2']['und'][0]['value'],
   );

   $form_state['redirect'] = array(
     'node/11',
     array(
        'query' => $prepopulates,
     ),
  );
}

Here I copy some field values from the form that will be submitted into the new form that has to be filled in. The parent should still be able to change the fields if he wants to.
Both the normal fields and the entity reference field (select list) are copied/prepopulated successfully, but if the parent changes the entity reference field on the new form it still contains the old, prepopulated value when he submits it (although visibly something else is selected in the list).


texts: Contact Forms - Change Recipient Address Dynamically - D8

texts:
I'm using the core contact forms module in Drupal 8, and what I need to do is add a select with multiple options, each option needing to change the recipient address.

How can I do this using the built-in module, or do I need a different module?


texts: What is the best way to calculate the price from selected line item field (a select line item field)

texts:
What is the best way to calculate the price from selected line item field (List field or maybe taxonomy) in final price ?

Example: we sell T-shirt. We define a color (list) as line item field, (red, blue, black)
Then we want drupal to calculate the price with multiplying to the value specified for selected color.
Red = 4
blue = 5
black = 6
The concept is that we don't want to make different product for each option, instead we want to use line item field (Select list) to calculate the price. Maybe for T-shirt doesn't make sense but it fits in our need.

How we can accomplish this and what is the best way of doing it ? Rules or own module ?
How we can specify a value for each color option?

I am more interested in coding approach, because there are a lot of different options and we don't want to make many rules for those.


texts:
I want to print only bits of a very big form, my first approach was as follow:

function THEME_preprocess_user_profile(&$variables) {
    global $user;
    $account = user_load($user ->uid);
    $variables['user_edit']  = drupal_get_form('user_profile_form', $account);
    $variables['user_edit']['field_about_me'] = 'invisible';
    .....
    $variables['user_edit']['field_some_filed'] = 'invisible';

}

This does work to hide certain element, the problem is that there is way more elements i want to hide than elements i want to show, so this process can be tedious..

Would anyone think of a better way to do so ?

UPDATE : Ideally i'd like to have a function similar to drupal_get_form, but that instead only return a targeted element.

Thanks a lot


texts: Need to enter title before I make blog entry

texts:
I have installed the Organic groups to make a multi-blog site. The problem is that when I try to create a blog entry, I only get a "Title"-field, which I need to save, and then edit the entry to enter the body text.

Any ideas how to fix this so I get the full blog entry fields when I click "Add content".

This is how it looks like now:


texts: how to fetch result into array or how to fetch 'nid' out of result?

texts:
Good day to everyone!

some help needed with fetching result out of EntityFieldQuery.
Have a unique value of the field. I try to get 'nid' of node by value of the field with help of EntityFieldQuery. my problem is that i dont know how to fetch result in a right way to get just 'nid'. then knowing nid i will be able to load the node and do some work with it.

$query = new EntityFieldQuery;
$entities = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'order')
->fieldCondition('field_reference_number', 'value', $titleref)
->execute();
$result= $query->execute();
drupal_set_message('nid: ' .print_r($result, true));

my result is:

nid: Array ( [node] => Array ( [2250] => stdClass Object ( [nid] => 2250 [vid] => 2252 [type] => order ) ) )

how to fetch it corectly to get 'nid' out of it?

Thanks for your time


texts: How to purge cached content every day via cache tag?

texts:
Drupal 8 page has a day specific element which is valid for current day. I would like to add a cache tag so that it can be purged in varnish/fastly periodically. Is there a way to invalidate cache tag periodically on Drupal8?

Here is few FAQs/As:

Why can't use max-age?

max-age can be used, but it's page level header which can get quite confusing when more than one component try to set it. Cache tag is kind of self-contained to the component.

Why don't run cron?

Trying to avoid explicit cron/job to do this as it's environment specific.


texts: If content type with specific field that is not empty has specific taxonomy term attach library

texts:
I would like to attach a specific library using a taxonomy term to a content type with a specific field that is not empty. The following is not working:

function lehigh_preprocess_page(&$variables) {
// Via taxonomy term: If the landing page is a node and has taxonomy
via a field named field_taxonomy
$current_route = \Drupal::routeMatch();
$node = $current_route->getParameter('node');
$target_taxonomy_id = 123;
   if ($node->getType() === 'standard_content_page') && $node->hasField('field_section') && !$node->get('field_section')->isEmpty()) {
     if ($node->get('field_section')->referencedEntities()[0]->id() == $target_taxonomy_id) {
     $variables['#attached']['library'][] = 'lehigh/financialaid';
}
}
}


texts: Creating Custom Object Record with Salesforce Connector

texts: I'm new to Drupal's Salesforce webform plugin. Can someone tell me what type of Salesforce Records a Drupal form can create? Is it limited to Lead and Case? Or can it create any standard or custom object? Thanks!


texts:
I have a list of nodes that I want to attach as a block to another node using a contextual filter. Depending on the URL alias I want a specific node to be attached to it. The problem is that I want the contextual filter to be based on a taxonomy alias as oppose to a taxonomy ID.

I looked at this solution: Contextual filter with a block view and this one: Views contextual filters taxonomy name  and I'm close however the second solution has an option that I can't find on my version. It reference a Filter Value Type option which would allow me to Term name converted to Term ID. This is exactly what I need, however I can't find this option.

I followed the instruction step-by-step; I tried creating different View and display versions, different items as my Contextual filter but nothing works.

These links are from 2011 and 2012, respectively. I'm using Drupal 8, so I'm wondering if this option has been removed or replaced with some other way to accomplish this task. Either way, I'd appreciate it any help.

Thanx


texts:
Problem

I have a two faceted searches on my site. They both use the database search module. The facets are set-up to only display on the relevant search pages.

(I've limited my paths with the block interface.)

But I just ran :

function mymodule_block_view_alter(&$data, $block) {
  dpm($block);
}

And I get 9 search facet blocks information appearing on all my non-search pages. (although you can't see them.)

What could I have set-up which means the facets are called on all pages and ignore the block paths?

My Set-Up

I have two faceted search pages, one with 9 facets and one with 11.

The 9 facet search is a user search. The 11 facet search is a node search.

I'm using the Database Search and Search API modules.


texts: A way to put a unique ID on a node based on the taxonomy it has?

texts:
I've been tasked with building a system that assigns job numbers categorized by client. Each job number is made up of a 3 letter abbreviation of the client, the current year, and a numerical number, starting from 0 and counting up for each job created.

For example a job # would look like this: ABC1400001

The 2nd job number under client ABC would be ABC1400002 etc etc

ABC = the abbreviated client name
14 = the current year
00001 = the first job created under client ABC

I'm trying to figure out a way to do something like this with drupal where each node would be a job and each client would be a taxonomy term. Grabbing the "ABC" is easy as it could just be the taxonomy term. 14 is easy as it would just be the year. The part that is tripping me up is how to get that numerical value of 00001, 00002, 00003 etc. Then lets say I had another client named DEF the first job under that client would need to start at 00001 as well. So its not as easy as just appending a node ID on to it unfortunately.

Any ideas on how I could accomplish this?


texts: How to use Webform's summed result in another node or block?

texts:
First-timer here, a little background: I'm a pretty seasoned builder using tons of modules, but not a developer. Want to start diving into PHP-coding, just not that far yet. Please keep that in mind if you'd be so kind to answer... For now, there's something I want done.

I use the Webforms-module to gather registrations for an event. One of the fields on the form is numerical and holds the amount of persons registering. Works great. Webform gives me a nice analysis in which the submitted values for this field are summed, so I can easily see how many people to expect.

Now I want to use this summed value somewhere else as well. For instance on a page that is accessible by non-authenticated users (as opposed to the Webforms results view, that contains all the personal data I do not want to be public). So I need either some token that I can use elsewhere on the site, or another way of programmatically incorporating that value in a block or a node. Did my share of searching and found a lot, but nothing useful.

I just learned from Klaus Harris' blog how to write a very basic module that can show a page. But how do I get this piece of data where I want it? I took a peek in the webform.report.inc-file that's part of the module, but was rather intimidated by what I saw there...

Is there some way to do this that I can handle without first graduating as a Drupal developer? Or is this too big a jump?


texts: Using the same form more than once per page with AJAX callbacks

texts:
I have a small email signup form made from extending FormBase that takes an email address and submits it to a mail service. I need to change the submit to AJAX so I can flash a success or error message.

I want to show this form more than once on a page. Once in a CTA near the top of the page, and there is a slightly different styled version in the footer.

When I added #ajax to the submit button, only one instance of the form seems to be affected. Here is the whole form:

$info = $form_state->getBuildInfo();

$form['#prefix'] = '
';
$form['#suffix'] = '
';
$form['#attributes']['class'][] = 'hl__single-input-form__form';

$form['title'] = [
  '#type' => 'label',
  '#for' => 'edit-email-address',
  '#title' => 'Stay in the know',
  '#attributes' => [
    'class' => [
      'hl__label',
      'hl__label--inline',
    ],
  ],
];

if (!empty($info['args'][0]) && $info['args'][0] == "show_tagline") {
  $form['tagline'] = [
    '#markup' => '
Sign up for email updates from MySite
',
  ];
}

$form['email_address'] = [
  '#type' => 'email',
  '#size' => NULL,
  '#required' => TRUE,
  '#attributes' => [
    'placeholder' => $this->t('Email'),
    'class' => [
      'hl__input',
      'hl__input--inline',
      'js-is-required',
    ],
    'data-twig-suggestion' => 'newsletter_signup_email',
  ],
  '#prefix' => '
',
];

$form['submit'] = [
  '#type' => 'submit',
  '#value' => $this->t('Sign up'),
  '#attributes' => [
    'class' => [
      'hl__button',
      'hl__button--small',
      'hl__button--inline',
    ],
    'data-twig-suggestion' => 'newsletter_signup_submit',
  ],
  '#suffix' => '
',
  '#ajax' => [
    'wrapper' => 'hl__single-input-form',
  ]
];

The block in the footer that pulls the form just has this build method:

  /**
   * {@inheritdoc}
   */
  public function build() {
    return ['form' => $this->formBuilder->getForm('\Drupal\harlib_newsletter_signup\Form\NewsletterSignup')];
  }

The preprocess for the Paragraph that outputs the form when being themed:

$variables['signup_form'] = \Drupal::service('form_builder')->getForm('\Drupal\harlib_newsletter_signup\Form\NewsletterSignup', "show_tagline");

How can I support having this form on the page more than once, both with the same AJAX action on submit? Also, how can I avoid overwriting the wrong wrapper with an AjaxCommand?

edit: validateForm method:

/**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $email_value = $form_state->getValue('email_address');
if (empty($email_value) || !\Drupal::service('email.validator')->isValid($email_value)) {
  $form_state->setError($form['email_address'], $this->t('Please enter a valid email address.'));
}

if (mailchimp_is_subscribed('XXXXXXX', $email_value, TRUE)) {
  $form_state->setError($form['email_address'], $this->t('You are already subscribed to our newsletter.'));
}
  }


texts: Upload a flash based banner as easy as image

texts: Is there a way to add a field that can process a Flash file just like an image and print that file for what it is, just like an image, in a node or whatever?


texts:
I have an app via Drupal 7 on Heroku. You know, myapp.herokuapp.com is default with SSL.

But when I try https://myapp.herokuapp.com get many errors in console like this:

 Mixed Content: The page at 'https://myapp.herokuapp.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://myapp.herokuapp.com/modules/system/system.base.css?ngonpd'. This request has been blocked; the content must be served over HTTPS.

I tried to add this code in settings.php but not working:

if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') {
  $base_url = 'https://myapp.herokuapp.com';
}
else {
  $base_url = 'http://myapp.herokuapp.com';
}

How can I fix this?


texts: Does entity_save() trigger the update event?

texts:
Not quite sure if calling entity_save() from code will trigger the update event or not.

So, does it?


texts: How to bulk re-index the whole site for core search?

texts:
I have a website that has about 100,000 nodes.
In the core search page (admin/config/search/settings) it shows that:

There are 80801 items left to index.

It index 100 (or at most 500) nodes per cron run but it's useless.
I want to bulk index the whole site (all nodes) for core search.
How can I do that?
The Reindex and Batch indexing modules are created for this but there are only a few users use these modules and I couldn't be sure to use them. And also there is a module called Elysia Cron for modifying the cron per job but it's still useless for me because there are thousands of nodes to index.
(Note: I want to do this for core search not for other search solutions).


texts:
I created a taxonomy called tags.  I added terms to the vocabulary list.

Then I created a content type called News Item.   You can apply tags to News Items.

I created a view to list News Items.

How do I set up a search box that let's people search News Items by tags?  they should be able to search by multiple tags.  So if the search words are "tutorial learning-resource", then show all news items that have both the tags tutorial and learning-resource.

How do I do this?


texts: Code for group programatically fields on edit form similar to Flexifield

texts:
I am looking how programmatically to group fields on edit form similar to Flexifield.  The idea is group in the edit form some fields unlimited.  I want to group the fields like as shown in the next link:

http://blog.merge.nl/2009/08/05/multiple-fieldsets-cck-multigroup

I have tried the Flexifield module but has a lot of errors and poor support.

I am working with drupal 6.x.

Thanks very much!!.


texts: Sending variable from php to js file not working

texts:
I've followed this : how to send variable from .php file to .js file?.

But following my code isn't working

What I want to do is whenever anybody logs in I want to send the login/password to browser javascript which will send it to another server.

It's only for a test case and not for production environment.

Details:

cyberoam.js

(function($) {
  Drupal.behaviors.cyberoam = {
    attach: function (context, settings) {

        alert(Drupal.settings.cyberoam.login) //on commenting this below alert works

      alert("hello");
    }
  };

})(jQuery);

In the cyberoam.module

function cyberoam_from_alter_submit(&$form, &$form_state)
{
     $username = $form_state['values']['name'];
     $password = $form_state['values']['pass'];

     dsm($username.':'.$password); //working fine

     drupal_add_js(array('cyberoam' => array('login' => $username )), 'setting');
}

What could be the problem? I've read same solution in multiple places but mine isn't working. In the Firebug console it shows TypeError: Drupal.settings.cyberoam is undefined


texts: how to add attributes of the parent taxonomy in the DOM?

texts:
I am displaying a taxonomy "category" on a node, a view of that node ,and a search facet.
This taxonomy has 2 levels.
How can i add to the rendered HTMLs, i guess using preprocessing hooks, an attribute indicating the taxonomy parent id ?
I would need to apply CSS differently to the taxonomy buttons depending on the parent.


texts:
I can't find a hook for overrideing drupal_page_header() in bootstrap.inc and it doesn't feel right to make changes in bootstrap.inc.

Is there another other way that I'm missing?


texts:
Followed the instructions on enabling SSL on Drupal 7 installation.

The SSL loads fine, all pages/links work but I'm unable to login.

When I try to login the screen just resets, go back to http and all works fine.

Any ideas what I may have missed?

Tried following the instructions twice now.

Regards,

Richard


texts: How to filter "Webform" drop down list selection pulling from taxonomy terms?

texts:
I have a webform which has users select a place from a drop down. I am wondering how to filter by these results? I have the relationship set up, plenty of other exposed filters working, but it appears the drop downs can only be sorted? The webform places is being pulled from Load a pre-built option list from taxonomies which has a bunch of city names...

Yes, the site is using Webform Module with views along with various other modules. The Webform was made pulling cities from a taxonomy list which is selected through the Webform under the pre-built list option.

I can filter the results that users have entered through a typical text field, however, when I want to filter the cities thats pulled from that pre-built taxonomy list,


texts: Cannot read nodes containing an email address

texts:
$email = "example@addresss.com";

    if (valid_email_address($email)) {
      $query = new EntityFieldQuery();
      $query->entityCondition('entity_type', 'node')
        ->entityCondition('bundle', 'my_content_type')
        //->fieldCondition('field_user_email_address', "email", $email)
        ->propertyCondition('status', 1);

      $result = $query->execute();
      dpm($result,"result");
      if (!empty($result['node'])) {
        $nids = array_keys($result['node']);
        $nodes = node_load_multiple($nids);

        foreach ($nodes as $node) {
          dpm($node,$node->title);
        }
      }
    }

The problem I have is with the fieldCondition (commented out above).  When it's commented out, the $result returns all of the matching nodes, as expected.  Looking at the second dpm output I can see results for "example@addresss.com" in $var->field_user_email_address[LANGUAGE_NONE][0]['email'] = "example@addresss.com".

However, when the fieldCondition is included in the search, it always returns zero results.   i.e. $result is an empty array


texts:
I'm having a question about the Block layout in Drupal 8. A couple of months ago (I don't know which beta it was) the block layout looked like this:

As you can see there's a list of blocks at the right of the page. Now in the current beta of Drupal 8 (beta 14) it looks like this:

The list of all blocks is gone. Why did they deleted this? And is there an easy way to get this back?


texts: Is it possible to use jQuery on filters (B.E.F.) in a view?

texts:
I am trying to add some special behaviours with jQuery to input type checkboxes in a view (using better exposed filters).
Ideally i need to make inactive all checkboxes when one of them is clicked. I`ve written a script but it did not do anything.
So i added a simple another code via drupal_add_js in template.php just to see whether it would be working:

jQuery('input#myid').click(function(){
alert("clicked");
});

it didn`t work and i am asking is it possible to use jQuery on checkboxes in a view?
Thanks in advance!


texts: Menu items Wildcards and Parameter Replacement

texts:
It is my module code:

<?php
function mymodule_menu(){
    $items['mymodule/%f'] = array(
        'title' => 'My account',
        'page callback' => 'mymodule_hello',
        'page arguments' => array(1), // The matched wildcard.
        'access callback' => TRUE,
    );
    return $items;
}
function f_load($arg){
    return "the argument is : ".$arg;
}

function mymodule_hello($arg){
    return t($arg) ;
}

From what I know, when visiting a page like /mymodule/12345, function f_load() is automatically loaded and the result of f_load(12345) is sent to the call back function mymodule_hello().

But the problem is visiting this page returns PAGE NOT FOUND error. what is the problem?


texts: Add link to topic list after new topic or comment submission

texts:
I would like that, when users submit a new topic or posts a reply in a forum, they would be redirected to the topics list.

How can I do this?


texts:
I have installed the module node compare. You can compare fields of every node type with this module. I selected about 19 fields to the comparison table but only twelve appear. I posted an issue but the maintainer has no time to help me. As I am no coder I am having some a hard time figuring this out.

I know that this is not a easy question but I don't see any other chance to get this problem solved. Does anyone has a advice what I can do? Or maybe somebody also uses the module and can share some experiences?

Thomas.


texts: How to apply sortable header to a table-style and paginated view?

texts:
I have a table of 250 employees created with views. It is sorted by their name. I'd like to sort it by other fields as well therefore I made them sortable in the view settings page. I also set it paginated (50 items per page).

When I click on the header of a sortable field the order changes as expected. But if I go to the 2nd page, several records from the 1st page appear again so the table becomes totally inconsistent. Is it possible to fix it somehow?


texts: How to get CSS to target new nodes being inserted?

texts:
I am customizing nodes for a blog entree's so they have a certain aesthetic look to it. However, I ran into a problem.

I can enter custom CSS code to style the nodes for already existing ones and set them with classes, but if someone is going to create a new node on the site, the blog CSS doesn't appear because I have to go in to each one and constantly hand-code it.

Obviously this is time-consuming and not the right way to go about it, because anyone who creates a blog would have to wait for me to style it for them. Is there a way where I can make a CSS code that will keep the look and feel every time someone creates a new blog entree?


texts: Using pre-process to wrap multiple regions in html

texts: I'm using Omega, and have 6 regions in a particular zone.  The first and second region span the width of the zone with 12 columns, and the other 4 are 1/4 in-line blocks.  I want to set the background for the 4 in-line blocks to a particular color.  How can I wrap those 4 regions inside a div so I can set the background color?


texts: What is the difference between Referenced Entity and Referencing entity in views

texts:
I just wanted to know what is major difference between

Entity Reference: Referenced Entity
A bridge to the Content entity that is referenced via field_FIELD_NAME

AND

Entity Reference: Referencing entity
A bridge to the Content entity that is referencing Content via field_FIELD_NAME

While using relationship in views or when I prefer to Entity Reference: Referencing entity


texts: How to tell Drupal to use tpl file from my module?

texts:
I have a custom module and placed comment.tpl.php here:

/sites/all/modules/mymodule/comment.tpl.php

But Drupal is not looking for that file in my custom module directory. How can i make it work?


texts: How can I add password fields to the account creation page?

texts:
My site has recently gone live, and I'm finding that a lot of users are getting confused while signing up for an account. I have "require email verification" enabled, so users are receiving their email with the one-time login link, but they don't seem be setting their passwords with this login. So they enter their details, save the profile and then, for whatever reason, log out and can't get back in as they never set a password.

I know they can request a password reset to get back in, but is there any way to add the password fields to the account creation page and still keep email verification?

Any help would be greatly appreciated,

Cheers,

Matt


texts: how to check files/images which are more than 400 KB

texts:
Related to QA part of our Drupal site performance, we need to make sure that size of images on the site are not more than 400kb.

I know there will validation and configs we can use while uploading images to site. but for already existing, is there any way to find out images size which are more than specified limit?

A non-code solution would be preferred.


texts: Adding fields to content type edit form (not to the node itself)

texts: In Drupal 8, how do you add fields to the content type edit form, i.e. where you define the content type?  I know how to add fields to the content type that wind up on the node edit form, but I'm looking to add a field to the content type itself.  Essentially, what I'm trying to do is add some data to content types that would allow me to group them together.  To do this, I need to add some additional metadata to the content type beyond name and description.


texts: Configuration Management module fails exporting

texts:
On a large multisite i have configuration management installed. But it fails to export large lists of e.g. tracked variables. When i click on the "select all" checkbox and proceed to "export to tar file" the site loads and then gets back to the unselected list offering no download file.

It works when the list is small (e.g. content types).

Nothing in the drupal logs.

Does anyone know why or how to debug this? Is it about memory? I have 1024M enabled on the site.


texts: Body class padding top, where is it coming from

texts:
I'm using Drupal 8.4.2 lightning-8.x-2.23 and Boostrap subtheme, Admin Toolbar.
The body class has an injected class of padding-top: 40.4px; for publisher user and padding-top: 79.4px; for admins. I want to make it the same padding. Does anybody know where this style is coming from? I dont see it in any style sheet. In Drupal 7 the admin toolbar had a settings page that allowed for padding top so that it pushes the body below the toolbar.

Logged in as admin body class

<body class="toolbar-tray-open toolbar-horizontal toolbar-fixed user-logged-
in path-workbench has-glyphicons" style="padding-top: 79.4px;">

Logged in as publisher body class

<body class="toolbar-tray-open toolbar-horizontal toolbar-fixed user-logged-
in path-workbench has-glyphicons" style="padding-top: 40.4px;">


texts: I've created a custom menu from the drupal admin panel, and have a custom module that uses drupal's form API. I'd like to render the custom menu in this module. Since this is using form API, I don't think it makes sense to use a template file, but I can't find any way to render a menu from the .module file itself. Not only would I like to render it, but I'd like to have control over which page region it's rendered in...How can this be done?


texts: How do I manage breadcrumbs when the node uses multiple vocabularies?

texts:
I have a blog in Drupal 8 and it uses the Categories vocabulary to display breadcrumbs as Home > Blog > [Category] > Post title.
I added taxonomies from the Tags vocabulary, which means every post can have one category, and multiple tags. Since I added the Tags vocabulary, it has taken over the breadcrumbs on individual blog posts, which are now Home > Blog > [Tag] > Post title.
Is it possible to control which vocabulary should have priority when it comes to displaying breadcrumbs?
Is it possible to control which vocabulary is displayed on blog posts based on where the user came from? For example, if the user is on the individual Tag page (Home > Blog > [Tag]) and clicks on a blog post belonging to that tag, the blog post should display the breadcrumbs using the Tags vocabulary (Home > Blog > [Tag] > Post title). However, if the user is on the individual Category page (Home > Blog > [Category]) and clicks on a blog post belonging to that category, the blog post should display the breadcrumbs using the Category vocabulary (Home > Blog > [Category] > Post title).


texts:
English is not my native language so please be patient.
Good afternoon, my Drupal 7 site is currently holding several articles, help topics, and document guides that are versioned, i.e search the "chocolate" word :
Product Cake:

title: Old aunt's Chocolate Cake. Version: 1.0
title: Old aunt's Chocolate Cake. Version: 1.2
title: Colombian Cake, Coffee, and Chocolate. Version: 1.0

Product Candy:

title: Chocolate candy for fitness. version: 1.0
title: Gretel's Chocolate recipe. version: 2.2
title: Gretel's Chocolate recipe. version: 3.0
title: Gretel's Chocolate recipe. version: 1.0

Product Beverage:

title: Milk & Chocolate. version: 1.0
title: Milkshake for the boys in the yard: Vanilla, Chocolate, and More. version: 1.0
title: Milkshake for the boys in the yard: Vanilla, Chocolate, and More. version: 2.1
title: Hot Chocolate for Cold Winters. version: 1.0

Currently, the site is using Apache Solr Search and related modules. I haven't been able to set a hook that would allow removing the duplicate results for versions with the same title but different versions, ideally I would like to have results for the latest version only.
The Apache Solr Sort module supposedly would do the trick, sadly I'm still getting the same results sorted by most recent creation, but due to those articles having (almost) the same score none of the duplicated versions are removed.
To handle the sort by most recent creation date I have modified the score using the creation date.
Also, is possible to achieve the sort using the Apache Solr search module.

But to remove duplicate results, still haven't found a solution. The documentation says that my necessity would be solved implementing Grouping, but no result comes from Apache Solr using the following hook_apachesolr_query_prepare which is based in the Sort module, Is this the correct way to implement Grouping? Is there another option to remove the duplicate versions?
/**
 * Implements hook_apachesolr_query_prepare().
 */
function custom_search_apachesolr_query_prepare($query) {

  $env_id = $query->solr('getId');
  $process_callback = apachesolr_environment_variable_get($env_id, 'process_response_callback', 'apachesolr_search_process_response');
  $group_field = apachesolr_environment_variable_get($env_id, 'group_field', 'title');
  $group_limit = apachesolr_environment_variable_get($env_id, 'group_limit', '10');

  if ($process_callback == "apachesolr_sort_process_response") {
    $query->addParams(
      array(
        'group' => 'true',
        'group.field' => $group_field,
        'group.limit' => $group_limit,
        'group.ngroups' => 'true',
        'group.sort' => 'ds_created desc',
        'group.facet' => 'true',
      )
    );
    // start params are different. You should move similar to the group.limit amount
    if (isset($query->page)) {
      $query->removeParam('start');
    }
    if (isset($query->page)) {
      $query->addParam('group.offset', $query->page * $group_limit);
    }
  }
}

Thanks in advance for your time.


texts: how to inform the community about new entries of a specific taxonomy

texts:
In my content type article there is a taxonomy field called "field_article_city".
In the user profile is the taxonomy field called "field_profile_city".

Now i want to create a rule, that informs all users with the same taxonomy "field_profile_city" when new content is created from the equal city "field_article_city".

I tried the condition "data comparison" to match these fields together, but there is no convenient selector for the users. i need a selector like "site:users" but there is only "site:current-user" or "node:author". But this wont work.

Someone can help me?


texts: I have a search field that sorts based on title when the user begins to type. This is fine for the search but I want to display the content type in the dropdown as well. As of now it only displays the title. Can the content type be appended to the title and if so where?


texts: Show a block of locations based off proximity search

texts:
I've created a map, using Geofield, Leaflet and proximity search.  This works great.  I also wanted to add a block view on the same page that shows an unformatted list based off the proximity search.  Image attached for clarity.

The block view on the right of the display is what I want filtered to show the exact same output as the main map.  I've tried every combination of contextual filters on the block view, just can't seem to make it work.  Any guidance would be appreciated.


texts:
Is there way to replace /taxonomy/term/% on search api views?

I was trying create new indexed views with Content datasource: Categories » Taxonomy term » Term ID but when i visit page, it's always return 404.

Please, any suggestions.


texts:
I want to create a menu that expands on click . ( For example, facebook, gmail, twitter all have menus at the top right where onl click the we get account settings , log out etc.)

What is the best way to do this in drupal? Is there any module for this or do I need to do it in theme?

Also, is there any special name for such menus?
Thanks!


texts: Mobile navigation works on desktop resize but not on mobile devices

texts:
I'm using the mobile navigation module for a responsive menu, and it works perfect if I resize the browser window on my desktop, but it won't work on actual mobile devices (tested on iPhone and Galaxy Note 2).  I've used the module before and never had any issues, and I'm using the same configuration, as far as I can tell. I can't figure out why it's not working.

This is the site I'm working on, and here's a screenshot of the problem on the Note 2. I recently upgraded my server from PHP 5.2 to 5.3, but I don't think that could be causing this issue (plus I needed to upgrade for a different module).

Other than that I really have no clue, so I'd appreciate your help.


texts: Adding few fields to custom content type problem

texts:
I've met some strange behavior while manipulating with fields of "sometype" content type. Sometimes after adding few custom fields one by one (and configuring them in few steps), after returning to "Manage fields" new field isn't listed, while Drupal message says Field added. Same with removing fields - Drupal message says that field was removed, but it is still on list.

Does anyone meet similar behavior and found the reason? I'm on D7(12) out of the box without overlay module.

In db after removing field from content type (using UI) still resides field_my_field and revision_field_my_field. Usually I remove it manually, but it seems weird.

ADDITIONAL INFO

db mysql 5.1.28, PHP 5.3.8, Webserver Apache/2

After x field created (text) I try immediately to add y field (text) and I'm getting

Page not found
The requested page "/admin/structure/types/manage/sometype/fields/field_y/field-settings?destinations[0]=admin/structure/types/manage/sometype/fields/field_y&destinations[1]=admin/structure/types/manage/sometype/fields" could not be found.


texts: Choosing a display format & printing a field in html.tpl.php

texts:
First question ever here... I'm so nervous!

I must display a field (field_asin) in the header of my page.

So I have added this to my template.php file :

function theme_preprocess_html(&$vars) {
  $node = menu_get_object();

  if ($node && isset($node->nid)) {
    $node = node_load($node->nid);

    node_build_content($node);
    $vars['field_asin'] = render($node->content['field_asin']);
  }
}

Now, I can print the field in html.tpl.php with

  <?php print $field_asin; ?>

Yep, it works! But how do I choose the display format for this field?

Thanks!

Alex


texts:
I have Content type A with these fields: Category and Amount. I want to add another field (Tax Amount) to calculate an amount based on Category and Amount inputted by user and sum of amount field of previously saved nodes.
In Tax Field, I used Computed Filed and trying to get sum of previously saved nodes by using two views, with category argument. Two views are 1) aggregated Amount of all previously saved nodes 2) aggregated Tax Amount of all previously saved nodes. Code I used inside computed field is below. But views_embed_view does not work I guess:
$arg = $fields['field_category'][0]['value'];
$amount = $fields['field_amount'][0]['value'];
$sum_nodes_amount = views_embed_view('views_machinename', 'block_1', $arg);
$sum_nodes_tax = views_embed_view('views_machinename', 'block_2', $arg);

$result = if ($amount + sum_nodes_amount) > 10,0000 {
print ($amount + $sum_nodes) * 20%
}

if ($amount + sum_nodes_amount) > 20,0000 {
print ($amount + $sum_nodes_amount) * 10%
}
else {
Print ($amount + $sum_nodes_amount) + $sum_nodes_tax * 1%

}

$value = $result;


texts: Custom Twig template for confirmation webform page being cached too hard

texts:
I've created a custom module which does some additional form handling and styling required for my project - this is all working fine.

Due to the size of the form - 50 odd fields - I'm setting up a Twig file in my module for the confirmation screen as it is far easier to manage it in my IDE than using the GUI. My confirmation page lists all the values styled in a specific way and laid out in a specific way. I've technically got it working by using hook_theme_suggestions_webform_confirmation_alter and hook_theme to point to my Twig template.

However, I've just recently discovered that, due to Drupal 8 internal page caching being so aggressive for anonymous users, the confirmation page is getting cached for everyone regardless of the actual submission values. So the first user gets it fine but the second submission from then on gets the cached version from the first.

I've read in other places to make use of hook_preprocess_webform_confirmation and set $variables['message']['#cache']['max-age'] = 0;. However, this is never called which I suspect is due to how I went about using my Twig template mentioned above.

Can someone help point me in the right direction here. Am I supposed to setup some kind of overwriting route in order to change the theme file or is it just a matter of tweaking what I've already done?

Functions in my .module file

function application_theme($existing, $type, $theme, $path) {
  $info = [
    'gib_application' => [
      'render element' => 'form',
      'template' => 'application-form'
    ],
    'application_form_confirmation' => [
      'template' => 'application-form-confirmation'
    ]
  ];
  return $info;
}

And

function application_theme_suggestions_webform_confirmation_alter(array &$suggestions, array $variables) {
  if (empty($variables['header'])) {
    $suggestions[] = 'application_form_confirmation';
  }
}

UPDATE

I've tweaked my hook_theme function to the below and also disabled hook_theme_suggestions_webform_confirmation_alter assuming it isn't relevant so long as hook_theme is defining the correct name.

function application_theme($existing, $type, $theme, $path) {
  $info = [
    'gib_application' => [
      'render element' => 'form',
      'template' => 'application-form'
    ],
    'webform_confirmation__application_form' => [
      'template' => 'application-form-confirmation',
      'base hook' => 'webform_confirmation'
    ],
  ];
  return $info;
}

Here are the Twig suggestions:

<!-- FILE NAME SUGGESTIONS:
   * webform-confirmation--application-form.html.twig
   x webform-confirmation.html.twig
-->

Unfortunately now my Twig template isn't being loaded at all now (due to dropping hook_theme_suggestions_webform_confirmation_alter.


texts:
I have profile 2 installed. I added a new field called "maiden name" to my profile form using the "add existing field" option. I had previously created this field in the default user registration form.

Now I want to delete the field (maiden name) from the user registration form. Please how can I transfer the data/values to the new field in my profile 2 form.

Thank you.


texts: What is the correct way to pass values from PHP code to javascript in Drupal 8?

texts:
I'm not talking about the library. That part is covered fairly extensive. What I want to do is generate the javascript based on PHP. But I can't, for example, do this:

$o = '<script> $data = [';
for ($i = 0 ; $i < 10; $i++) {
    $o .= $i.', ';
}
$o .= ']; </script>';

$form['mainText'] = array (
        '#type' => 'markup',
        '#markup' => $o,
    );

return $form;

How am I supposed to do this correctly?

And if you are wondering, the reason I am doing this is because I want to generate javascript that is to be used to plot points on a graph.


texts: How can I dynamically load options into a select list?

texts:
I'm creating form using drupal_get_form and I'm using the following code for creating a select list:

$form['select-user-group'] = array(
  '#type' => 'select',
  '#title' => t('Select a group'),
  '#options' => array(
    '' => t('-- Select a user group --'),
  ),
  '#ajax' => array(
  'event' => 'load',
  'callback' => 'selectuser_ajax_callback',
  'method' => 'replace',
);

and then I'm trying to define a function like following to dynamically add options to the select list:

function selectuser_ajax_callback() {

  db_set_active('drupal');

  $result = db_query("select * from {content_type_usergroup}");
  $record = db_fetch_object($result);

  $str = '<select>';
  while ($obj = db_fetch_object($result)) {
    $str .= '<option value=' + $obj->vid + '>' + $obj->field_p_group_name_value + '</option>';
  }
  $str .= '</select>';

  echo $str;
}

But it's not working. How to make this function work properly to populate the select list '#options?


texts:
I've created several webforms. 5 of them contain a field with same machine-name where 2 different rules check the value of the mentioned field. Depending on that value an e-mail is sent. My problem is that both rules run on all webforms, not just on the 5 I only want them to. As the field it tries to check is not present in the other webforms, I get an error message on all other webforms. How can I limit the rule to run on only these 5 of my webforms?

PS: In my rules under "Condition" I execute an PHP code to check the value.

I guess it could be solved with AND or OR but couldn't figure it out.


texts: How do I import editable copies of an existing "child-node" into a "parent-node"?

texts:
Here's what I need:
I want to be able to import content of selected existing nodes (let's call them child-nodes) into a new node (let's call it parent-node), and I want to be able to edit the child-nodes inside the parent-node without changing the original child-node. E.g. automatically create a clone or revision of child-node. I need to be able to edit the complete child-node, not just a specific field.

Here's what I have done:
I have set up the ability to import the selected child-nodes into the parent-node using Entity Reference, and I have set up the ability to clone the child-nodes from the parent-node. The problem I have run into is that when I clone the child-node from the parent-node, the parent-node still refers to the original child-node instead of the clone.

Is there any way to resolve this, perhaps by using rules? or should I consider a different approach?


texts: Our site has Varnish in front of Drupal for anonymous user page requests so that these pages are cached.  I know how to clear the Varnish cache within Varnish but my question is what benefit is it to clearing the Drupal cache now that I have Varnish in front of Drupal?


texts: How to add custom language specified text?

texts:
I'm using multilingual feature in D7.

Let's say...I have a word 'standard' that I like to use in other languages.

Where do I put the word and how do I load it in my templates?


texts: Subscribe flag to auto-subscribe authors

texts:
I have set up a flag so that users can flag certain types of nodes and receive an email notification if there is any activity on it, such as comments. It's paired with the answers module. What I can't figure out how to do is make is so that authors are automatically subscribed to those types of nodes that they author. Other associated modules are message_subscribe, flag_actions, message_subscribe_email,

Using flags version 7.x-3.9. Let me know if I left out any pertinent information.


texts:
Here's what I want to do, for context:

I want to go to mysite.com/groups/%gid/%nid and see the node specified by %nid with an OG menu and a header pane that get their context based on the %gid. So if I have, say, a "person" nodetype, I can show a person node that belongs to multiple groups with the header and menu of different groups based on the URL. This is useful because then I can change the links that I use in each group's "people" list to keep the header and menu the same after the user clicks on the person.

I am not able to get the two arguments to work together, though.

I have been able to create a Views pane that displays the node by taking nid as a contextual filter, and gets it from the URL via panels. However, when I try to add the %gid first, I get all lost. I can't figure out how to use it to tell OG Menu which menu I want, I don't know how to use it to pass the appropriate context to the header minipanel that I've created (that works when a valid context is passed in), and I get "page not found" instead of a person node.

What am I doing wrong? How do I get two arguments in a URL to work together to tell Panels what the context and content should be, respectively?


texts: How to change Title field label and description for Custom Content Entity

texts:
I've created a custom content entity (generated via drupal console), I can add custom fields just fine via the cms.

What I'm try to do now is change the default label from 'Name' to 'Artwork Title'.

I've tried the following, but I'm not seeing the changes.

class EntryEntityForm extends ContentEntityForm {

      /**
       * {@inheritdoc}
       */
      public function buildForm(array $form, FormStateInterface $form_state) {
        $form = parent::buildForm($form, $form_state);

        $form['name']['widget']['#title'] = $this->t('Artwork Title');
        $form['name']['widget'][0]['#title'] = $this->t('Artwork Title');

        $entity = $this->entity;

        return $form;
      }
...
}

Can someone please point me in the right direction?


texts: Development with git branches/ gitflow and new modules

texts:
I wonder if somebody found a solution for the following issue related to Drupal 8 development with Git branches:

You work on a new feature in a local feature branch
for that you activate a contributed module or you write a custom module. This maybe delivers an own entity type and therefore creates a table after installing
Meanwhile you need to fix a bug -> you change to a newly created bugfix branch which starts from the current dev branch
After checking out the bugfix branch you import the current configurations to have the current active configuration of the branch -> the module you installed in feature branch is not activated anymore, the files of this module do not exist in the current bugfix branch
You do your bugfixing and merge ths bugfix branch into develop branch.
you change to your feature branch. To bring your local Drupal project to the status of this branch again you will import the configurations again

And here it comes to an exception: the table already exists in your database. When doing a drush cim it stops every following processing and you need to restart drush cim to import any further configurations.

Who does work with different feature branches and found a solution during development process to deal with this kind of situation?


texts: How get empty record on date field with entityQuery?

texts:
I am on a custom entity with custom fields and i try to get all empty record on date field :

Field was create with CCK, so the field storage has a table.

  $query = \Drupal::entityQuery('test_entity');
        $query->condition('field_date',NULL,'=');
        $ids=$query->execute();

This doesn't work for date field.


texts: Drupal 7: adding html (image) to view's exposed filters fields

texts:
im having a little trouble theming the output of a view's exposed filter.

I have a node reference field, and in the exposed filter i want to show it as a checkbox list with, instead of the title of the referenced node, the image (that is a field, obvious).

Im doing the same thing for the node_edit form:

    // This function is called via #process fapi key
function _mytheme_theme_pittogrammi(&$element)
{
    $lang = isset($element['it']) ? 'it' : 'und';

    foreach($element[$lang]['#options'] AS $nid => $label)
    {
        $pittogramma = node_load($nid);
        $image_field = _dwork_field_get_value($pittogramma->field_image);

        $image = 'title .'" title="' . $pittogramma->title .'" />';

        $element[$lang]['#options'][$nid] = $image;

        $element[$lang][$nid] = array(
            '#label' => $image
        );
    }
    return $element;
}

and it works perfeclty; For the view_exposed_form i hat to make a little change in the function (becose the lang is not present), but is almost the same:

function _mymodule_theme_pittogrammi_view_form(&$element)
{
    foreach($element['#options'] AS $nid => $label)
    {
        $pittogramma = node_load($nid);
        $image_field = _dwork_field_get_value($pittogramma->field_image);

        $image = 'title .'" title="' . $pittogramma->title .'" />';

        $element['#options'][$nid] = $image;

        $element[$nid] = array(
            '#label' => $image
        );
    }
    return $element;
}

And this works somehow, but the problem is that the image HTML looks like is passed throught htmlspecialchars() or something like, and rendered as text.

Im wondering why and why only on view's exposed form...

How can i change this behavior?


texts: zoom and centre gmap output based on results (views+gmap+location modules)

texts:
I've got several nodes with location information attached. I am using the Gmap output form views to show the results on a map. Drupal is so great sometimes, I'm literally shocked at how little time it took to get that solution up and running!

At the moment the map is using the default centring and zoom no matter what the results are. I'm pretty sure I have just missed an option or setting somewhere, but can someone point me in the right direction to re centre and zoom based on the pins from the results?

I've had a search on here and Google and can't see this question having been asked. Probably because an available option is staring me right in the face!

Thanks


texts: How can i prevent field display on sign up while using profile 2 module

texts:
In my site, I used the profile 2 module to add some fields to the registration/sign up page.
Is there a way to exclude some of these newly added fields from being displayed at sign up, so that a new user will only see them when he wants to edit his/her profile ?

Thank you.


texts: Wrap teasers in a div (simple taxonomy page, no views)

texts:
I would like to know if there is a way to wrap the nodes teaser in a  without using jQuery.

Basically, this is how the DOM is :

        term description, others custom fields…

teaser content

teaser content

teaser content

What I want :

      term description, others custom fields…

teaser content

teaser content

teaser content

I'm using Display Suite for a better customization, I checked all the tpl files, but I found nothing…

Thx :)


texts: Save content with current user roles and add filter to show only content with current user role

texts:
Using drupal 7,
when creating new content of the type "Document"
the current user roles must be added so I can later on show only Documents of his current role.

For example, we have the following user: this is Jake, he is a Firefighter. He creates a document about the dangers and pitfalls of being a firefighter. This is only relevant for Firefighters. So in the list of documents (view) I want Jake and all other Firefighters only to see Firefighter Documents.

So if Jake create new content of the type "document" I want to add his user roles
and later on add a filter in the view so only Firefighters get to see Firefighter Documents

I want to have the following filter for the list Document view:

Published = true
Content type = Document
User role = current user roles (Firefighter in this case)

Access must be restricted for every user based on their role.
For example, Jake the Firefighter is not allowed to view Policemen Documents


texts:
Is there a way to find certain types of links and edit them from a custom module in Drupal 7? I want to add an attribute to all pdf links throughout my site. I tried the following:

function my_module_preprocess_link(&$link){
  if( substr($link['path'], 4) === '.php' ) {
    var_dump($link);
  }
}

But I suppose since the pdf links are contained in the node content of my pages, they aren't included here.

I'd like to add a custom class to all pdf links or maybe an inline onclick javascript event. Is there a way to do that?


texts: How to Rename "Request new password" link?

texts:
We want to rename the "Request new password" text on a Drupal's login page to some custom text.

In the user.module file, I see that this text is hard coded

if (variable_get('user_register', 1)) {
    $items[] = l(t('Create new account'), 'user/register', array('attributes' => array('title' => t('Create a new user account.'))));
  }
  $items[] = l(t('Request new password'), 'user/password', array('attributes' => array('title' => t('Request new password via e-mail.'))));
  $form['links'] = array('#value' => theme('item_list', $items));

Is there any other way of renaming this text rather than modifying the Drupal core?


texts: Rewrite a text field in "Manage display" of content type

texts:
This feels like it should be simple to do, but I can't work it out.

If I have a text field, how do I rewrite the output of the field on the "Manage display" tab of the content type? For example, I might want to add units, or convert a product ID into a link to an external website.

I know how to do this stuff in Views, but it would seem to make sense to be able to do it via the "Manage Display" tab for a content type. Am I missing something?


texts: Drupal's version of Wordpress' wp_insert_post()?

texts: I just started playing with Drupal and I'd like the user to be able to add a custom node(or content) outside the admin by providing a form and then add that to Drupal's database once submitted. How do I do this programmatically and securely? Wordpress has a wp_insert_post() function for this functionality, what's the Drupal version?


texts: I am trying to extract the vocabulary's name from it's vid. Is there a function that does that or do I have to create it?


texts:
My website has two designs and I not sure which one is better. I am thinking upload both of them.

Here is my question: Is drupal able to let 50% of the user see design A and the rest is able to view design B. After one month later, I am able to see a report which one is better.


texts: While adding new fields to a content type, When should I resue an existing field? for example if I need an image field for my content type is it always a good idea to re-use an existing image field?


texts: Programmatically create user in another Drupal site

texts:
How can I programmatically create user in another Drupal site?

The setup: multisite installation, userbase should be partially shared. Both websites have DB credentials setup in the settings.php file so I can query all tables from either site.

The problem: if I use db_set_active() to switch the database to the second site, calling user_save() will invoke all hooks of modules that are installed on the first site, not on the second one. This causes errors if the sites have different modules.

How can I avoid this problem? Any thoughts on workarounds?

Thanks!


texts:
i am creating a social network site. I want when the users clicks join after entering his initial details such as name, email and password (the user does not need admin approval for account to be created) he or she is taken to a user registration page which looks like:
http://imgur.com/fa31Xt1

i know how to add fields from admin/settings/people but should i use profile 2 module? if so how exactly...also once the user clicks save profile (as in link above) then he or she is taken to his profile page where he can view his profile


texts: view using the taxonomy of an organic group

texts:
I'm trying to create a view that displays content related to the taxonomy term the group page has i.e. if you were on the groups/group1 and group1 has a taxonomy term called technology, a list of content tagged with that taxonomy term would be displayed.

Thanks to a previous question I found out how to get arguments from the URL. But i'm not sure how I can use views to capture a taxonomy term related to a given group. Can you use views 2 to take the url query the database to get the taxonomy term and then use that as the argument for the view?


texts: How to make a sticky post on appear on top within a view

texts: I've created a view which is organised by date. All works fine, however I'd like to add the sticky functionality to it, where whenever a node is marked as sticky, it'll go to the top of the list regardless of the date. How can I achieve that?


texts: Restrict ajax throbber to specific form id

texts:
Can we restrict below code to specific form ,currently its working on all form wherever ajax is calling.

I am using ajax throbber module in drupal 7.

<?php
/**
* @file
* Drupal module file ajax_throbber
*/

/**
* Implements hook_page_alter().
*
* @param $variables
*/

     function ajax_throbber_page_alter(&$variables) {

    {
  // Preferred color to css.
    $throbber_selection =
    variable_get('ajax_throbber_selection',
    'circle');
  // 0, 174, 239, .8
  // 0,255,0, .8
    $bg_color = variable_get('ajax_throbber_bg_color', '255,255,255, .8');
  $item_color = variable_get('ajax_throbber_item_color', '0, 174, 239, .8');

  drupal_add_js(array(
    'ajaxThrobber' => array(
      'bg_color' => $bg_color,
      'item_color' => $item_color,
      'type' => $throbber_selection,
    )
  ), 'setting');

  // Add correct css file and return correct html.
  $html = _ajax_throbber_add_correct_throbber($throbber_selection);

  // Add the HTML.
  $variables['content']['system_main']['ajax_throbber'] = array(
    '#weight' => -10,
    '#markup' => $html,
  );
//}
}

/**
 * Add correct css file.
 */
function _ajax_throbber_add_correct_throbber($throbber_selection) {
  $module_path = drupal_get_path('module', 'ajax_throbber');
  $module_css_path = $module_path . '/css/stylesheets/ajax_throbber_';

  // Default HTML.
  $html = <<<HTMLTHROBBER

HTMLTHROBBER;

  switch ($throbber_selection) {
    case 'circle':
      // Last example.
      drupal_add_css($module_css_path . 'circle.css');
      $html = <<<LOADINGCIRCLEHTML

LOADINGCIRCLEHTML;

      break;

    case 'fading_circle':
      drupal_add_css($module_css_path . 'fading_circle.css');

      break;

    case 'square':
      drupal_add_css($module_css_path . 'square.css');

      break;

    default:
      drupal_add_css($module_css_path . 'three_dots.css');
  }

  return '
' . $html . '
';
}


texts: Get apachesolr module to work with solr 5.5 without reindexing

texts: I upgraded my drupal apachesolr search module from 1.8 to 1.11 and I also upgrade the apachesolr version from version 4.10 to 5.5, and managed to upgrade the index folder so that it can be used for 5.5 solr search. But once I change the drupal apache solr URL to connect to the new 5.5 solr search, it ask me to reindex everything again. Is there a way to avoid this step?


texts: Getting html tags in translated block display

texts:
I created a block and enabled its translation settings.
I followed this link

to add ckeditor at block translation.
When I view the translated block its shows block contents with html tags.
Eg: If the text is 'thai' then the translated ouptup is "< p >thai< /p >"


texts:
I have two user roles with profile fields.

Role 1
Name, Username, Password, Email, Address line 1, Address line 2, Website.

Role 2
Name, Username, Password, Email

I want to let anonymous user to chose user role on registration.
Upon user role selection, I want to show role-related fields interactively (with javascript).

I mean that when select Role 2, Address line 1, Address line 2 and Website fields will be disappeared, and when select Role 1, they will be appeared again.

I currently use 'user_role_field' module and 'autoassignrole' module.
Is there another module to achieve that purpose ?
I'm using Drupal 7.7.

Here is what I'm looking for.
Click here to download and view screen draft.

Thank you for any help.
Rgds/Sithu


texts: How to reduce HTML output on Drupal forms

texts:
How to let Drupal print only necessary HTML in forms. I want to override fields input.

This is the current code for node add form:

<form ...>
...

          Price
          <input class="text-full form-text required" type="text" id="edit-field-price-ad-und-0-value" name="field_price_ad[und][0][value]" value="" size="60" maxlength="55" />

Text

          Video
          <input type="text" id="edit-field-video-ad-und-0-input" name="field_video_ad[und][0][input]" value="" size="60" maxlength="1024" class="form-text" />

Text

...
</form>

I want something like this:

<form ...>
...

          Price
          <input class="text-full form-text required" type="text" id="edit-field-price-ad-und-0-value" name="field_price_ad[und][0][value]" value="" size="60" maxlength="55" />

Text

          Video
          <input type="text" id="edit-field-video-ad-und-0-input" name="field_video_ad[und][0][input]" value="" size="60" maxlength="1024" class="form-text" />

Text

...
</form>

Using theme_form_element I was able to remove third div (form-item). I cannot figure out how to edit first 2 div wraps.


texts:
I have a series of pages created through Views, all the view pages are relative to one piece of content. The content paths I have created are

 - mycontent/[nid]/overview
 - mycontent/[nid]/members
 - mycontent/[nid]/content

Not that whats inside the view is particularly important but in this example, the first one shows the basic information about the node, the second shows everyone who is referenced by an entity reference, and the third shows all nodes connected by an entity reference.

I have created a new menu called 'mycontent-submenu' which I want to fill with links of:

 - Overview
 - Members
 - Content

Obviously you cannot use the Views module's menu ability to provide this as a menu item (unless you want to use it as a tab, which unfortunately I don't). In a more general term, the first question would be, how can I put these pages into a proper Menu (ie, not a tab)?

I already know of 1 way in which to solve this, which is to use Menu Views, with that I made a view for each of the Overview, Members and Content page, set the limit to 1, applied a 'null' contextual filter, and forced the output of the view to be re-written as 'mycontent/!1/overview'. Which works, but its a little hacky for my liking, plus you're querying the database a lot, I've done it before and it ended up increase the page load time if you have multiple menu items.

What I want to try to do right now is try to make a menu item programmatically in my own custom module, but I don't know what I'm doing wrong. My current code is:

function mymodule_menu() {
  $items['mycontent/%nid/overview'] = array(
    'title' => 'Overview',
    'description' => 'View the item',
    'menu_name' => 'menu-mycontent-submenu',
    'page callback' => views_page('individual_item', 'item_overview'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'expanded' => TRUE,
  );

  $items['mycontent/%nid/members'] = array(
    'title' => 'Members',
    'description' => 'Item members',
    'menu_name' => 'menu-mycontent-submenu',
    'page callback' => views_page('individual_item', 'item_members'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'expanded' => TRUE,
  );

  $items['mycontent/%nid/content'] = array(
    'title' => 'Content',
    'description' => 'All the Content for this item',
    'menu_name' => 'menu-mycontent-submenu',
    'page callback' => views_page('individual_item', 'item_content'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'expanded' => TRUE,
  );
}

As far as I can tell, I've researched how you call a view within a page callback, which is views_page, and I've declared that I want my links to go into the right menu structure, but nothing actually appears. Is this block of code correct for what I want to do.


texts: Disable modules per environment / settings.php?

texts:
Is there a way to disable certain modules on different environments from settings.php or another means in Drupal 8?

For example, if I am not on prod, I don't want XML Sitemap enabled.


texts:
I would like to add a  around a menu block I am displaying on a section of my site to style it differently on a certain page only.

How do I do this? Can I target a certain page with a conditional somehow?


texts: Use drush to install a module on all of the sites of a multisite at once

texts:
I have a Drupal 8 multisite, setup with 6 different sites.  I want to install Admin Toolbar on all of them on my local dev environment (mamp / terminal / drush).  I have downloaded that module using composer:

composer require drupal/admin_toolbar

Is there a single drush command that will install this module on all six of the sites at once?  If not, what is the most efficient way to install it to each?


texts:
I am trying to get a menu via REST and I've created a new module and rest resource plugin that allows for GET on /entity/restmenu/{menu_name}.

I can successfully return this example json using this function when I hit the URL.

public function get(EntityInterface $entity) {
  $result = array();
  for ($i = 0; $i < 10; $i++) {
    $temp = array(
      'title' => 'Test ' . $i,
      'href' => '#/' . $i
    );
    array_push($result, $temp);
  }
  return new ResourceResponse(json_encode($result));
}

I cannot figure out how to load the menu based on $entity. If I hit my URL (http://dang.dev:8888/entity/restmenu/main?_format=hal_json) $entity's value is 'main' which is the machine name of the main menu.

I've tried using Drupal menu tree, but I am not having luck, and debugging this thing with only JSON responses is quite difficult.

How do I get menu item titles and paths based on the menu machine name?

EDIT

Ok, sort of figured it out.

public function get($entity) {
  $menu_name = $entity;
  $menu_parameters = \Drupal::menuTree()->getCurrentRouteMenuTreeParameters($menu_name);
  $tree = \Drupal::menuTree()->load($menu_name, $menu_parameters);
  $renderable = \Drupal::menuTree()->build($tree);
  $result = array();

  foreach (end($renderable) as $key => $val) {
    $temp = array(
      'menu_item' => $val,
      'route' => $key
    );
    array_push($result, $temp);
  }
  return new ResourceResponse(json_encode($result));
}

Right now that will output:

[
  {
    "menu_item":{
      "is_expanded":false,
      "is_collapsed":false,
      "in_active_trail":false,
      "attributes":"",
      "title":"Home",
      "url":{

      },
      "below":[

      ],
      "original_link":{

      }
    },
    "route":"standard.front_page"
  },
  {
    "menu_item":{
      "is_expanded":false,
      "is_collapsed":false,
      "in_active_trail":false,
      "attributes":"",
      "title":"Communities",
      "url":{

      },
      "below":[

      ],
      "original_link":{

      }
    },
    "route":"menu_link_content:139d0413-dc50-4772-8200-bc6c92571fa7"
  }
]

any idea why url or original_link are empty?


texts: Send a CSV file to the user on FAPI form submit

texts:
I have a FAPI form that collects some information from the user, then generates a CSV file. The intent is when the user clicks 'export' on the form, the CSV is downloaded straight away.

However, when the submit handler calls the CSV-generating function, the form just redirects, rather than serving the CSV.

Is there any way to make this form serve the CSV to the user directly, without generating a temporary file?


texts: How do I change my navbar from "left to right" to "right to left"?

texts:
I built an English language web site, and now I'm working on the Arabic version.

How do I change the navigation bar to be displayed right to left?
I'm using the Bootstrap theme 3.3.5.


texts: Single click function in a Drupal behaviour?

texts:
The following in a Drupal behaviour is working fine:

  $('.trigger', context).click(function(e){
    e.preventDefault();
    $('.target').toggleClass('open');
  });

However I know that I should be using the once function. Is the following correct? It does work but so did the code above so im not sure how to check if its been done with best practices.

  $('.trigger', context).once('toggle-name', function(){
    $(this).click(function(e) {
      e.preventDefault();
      $('.target').toggleClass('open');
    });
  });


texts: Saving node's fields without node itself in Drupal 8

texts:
So in drupal 7 we can update node fields without saving the node itself via
field_attach_update.
Here the link :
https://www.urbaninsight.com/2011/10/24/saving-nodes-fields-without-saving-node-itself

Is there a DRUPAL 8 version of this? example please.


texts: How to configure the existing search system to exclude content types and/or nodes from the search index?

texts:
As far as I see, the search api has no effect on the existing search. The video about State of Search Drupal 8 - Basic Usage of Search API  indicates that you have to supply an own view for the search results.

Isn't there a way to configure the existing search system to exclude content types and/or nodes from the search index?


texts: How to set default value for taxonomy autocomplete field?

texts:
I am using Drupal 7. I have created a content type with autocomplete taxonomy field. I need to set default value programmatically.
I am using this code under hook_form_alter:

$form['field_school_locality_city_level'][LANGUAGE_NONE]['names']['#default_value'] = tid;

It's giving me just term id, but I need it in format Bhopal[tid:8193].


texts: Is there a way to create hierarchical taxonomies checkboxes?

texts:
I have an issue where I want to keep sub category inside a parent category. Say, for preferred vehicle I want a checkbox like this in node creation form

[]Car
  []Volkswagen
  []Toyota
[]Bike
  []Kawasaki
  []Harley Davidson

Is there a way to implement this using taxonomy?


texts:
try using drupal 8.
I need todo some list of medical help centers.
on 1 page i need to choose "State"->"city"->"zip"->then choose page with medical center in this area.
If i create state,city,zip by taxonomy, how can i logicaly build this state to city to zip to page - linking?
Thank you for advice.


texts:
I've made a sub-theme of the Bootstrap theme; however, I am having trouble understanding where $variables comes from in the page.vars.php file. I made a little "debug" code to print out the variables - unfortunately, the output is exceptionally large and has some strange outputs. I have edited page.vars.php using the variables already retrieved from the $variables associative array, e.g. I edited the size of the main content section on the page:

 $variables['content_column_class'] = ' class="col-md-8 col-sm-6"';

This suggests there should be a 'content-column-class' in the $variables array; however, amazingly when I perform print_r($variables) it turns out there is none! Furthermore, every variable I have checked that is being accessed in page.vars.php seemingly does not exist.

I'd like to edit the class of the primary / sidebar_first sections; however, currently I cannot do this as I don't know how to access them from the $variables array.

In sum, why does print_r not output the expected? And, how do I find out what variables are actually in $variables?


texts: Failed validation redirects to normal path

texts:
I'm using the sub-pathauto module.

I can edit node 1 of type list from the path list/1/edit. However, when validation fails I'm redirected back to node/1/edit (the normal path).

Is this a known limitation of the module? Something I have to accept?


texts: How can I migrate URL fields to link fields?

texts:
I have run migration using drush migrate-upgrade by setting up Drupal 7 used module in Drupal 8 site and DB path etc. But one  of my content type use field https://www.drupal.org/project/url but now link field is in Drupa 8 and version of this module is not available in Drupal 8.

In support I have gone thorugh https://www.drupal.org/project/url/issues/1778224 but didn't helped much.

How I can transfer data along with revisions data related to this field and create/migrate similar field in Drupal 8 content type (rest of fields got migrated in 8 from 7)?


texts: Copy same content date fields values to separate content types by rules

texts:
What i want to do is this...

I have a content type (A) with two date fields (date_1 and date_2)
Then i have two more content types with existent date_1 field created.
(Must be this way)

Schema:
A: date_1 and date_2
B: date_1
C: date_1

An existing rule creates (every time a new node of content type A is created) a new content node of type B, copying the A:date_1 value to the B:date_1 value. That was easy... and it works just perfect.

Now, what i want to do is the (almost the) same with the content type C.
Except for the source field to be copied, that should be date_2

The rule should be something like this:
"Every time a node of content Type A is created:
Create a new node of content type C
and copy the date_2 value from node A, then paste it into the new entity field date_1...

Almost the same, except that when i want to select the source field, date_2 is not listed and i cant select him.

Is there any way to solve this?

Thanks a lot


texts: Can Drupal Commerce and Ubercart be installed on the same site?

texts: Can Drupal Commerce and Ubercart be installed on the same site or will they conflict with eachother?


texts: Drupal views grouping: amount by grouping

texts:
I have created a view, I have two separate tables based on this view.  I used "grouping" to get these two tables.  For the pager its asks how many items I want to display.  I want 10 total, the 5 most recent from each grouping.  What it ends up doing is giving me the 10 most recent between the two groupings.  So its uneven.  I wanted 5 and 5, but Im getting 7 and 3 based on published date.  Can I get 5 for each grouping?

thanks, M


texts:
I ran the following commands:

drush dl drupal-8 --drupal-project-rename=drupal_8
cd drupal_8
drush site-install standard --account-name=****** --account-pass=******** --db-url=mysql://*****:******@localhost/drupal_8 --site-name=Drupal_8

in windows 7 but I get following error:
Drush 6.7.0 does not support Drupal . See drush for more information.

Command site-install needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this

command.
The drush command 'site-install standard' could not be executed.

Am I doing something wrong or drupal 8 standard installation is not supported by drush yet?


texts:
I have an array...

    $my_array = array(1 => 'Value One', 2 => 'Value Two',3 => 'Value Three');

In Form API, I want to create checkbox for each value.

    foreach($my_array as $key => $value) {
      $form['custom_field'] = array(
        '#type' => 'checkbox',
        '#title' => $value,
        '#default_value' => variable_get('custom_field'),
      );
    }

by default is stores in value, '0' or '1'.
It should actuly be saving the $key as value.

I know this can be done simply using 'type' as 'checkboxes' but actuly I need to goroup it each time each check box with a text field.

    foreach($my_array as $key => $value) {
      $form['custom_field'.$key] = array(
          '#type' => 'checkbox',
          '#title' => $value,
          '#default_value' => variable_get('custom_field'),
        );
        $form['custom_field'.$key] = array(
          '#type' => 'textfield',
          '#title' => 'Limit',
          '#size' => 10,
          '#maxlength' => 10,
          '#default_value' => variable_get('limit_variable'),
          '#required' => TRUE,
        );
      }

`
Any help?


texts: set default timezone, date first day and date format medium via drush

texts:
Is there is away to set :

default timezone
date first day
date format medium

via drush instead of doing it via drupal web interface ?


texts: Fetch user's realname (from Name Field) within database query (or an alternative method)?

texts:
I'm building a custom field for a form based off of the values stored in a user reference field. The options for this field are being built from the following database query:

<?php
// Fetch the users referenced in the provided node
$args = array(':nid' => $nid);
$result = db_query("
    SELECT
        field_data_field_user_ref.field_user_ref_target_id,
        users.name
    FROM field_data_field_user_ref
        JOIN users
            ON field_data_field_user_ref.field_user_ref_target_id=users.uid
    WHERE entity_id = :nid", $args);
$arr = $result->fetchAll();

// Add these users as an array to be displayed
$users = array();
foreach ($arr as $val) {
    $crafters[$val->field_user_ref_target_id] = $val->name;
}

...returning the array in the form of...

uid 1 => name 1
uid 2 => name 2
uid 3 => name 3

This works fine, except for the fact that the user's username is displayed instead of their "real name." In my case, the Real Name is being generated by a Name Field (from the Name project). I can't seem to figure out a way to grab the real name from the database. Not sure if it is even stored in there.

Is there an alternative way to grab each user's real name? I'm assuming I could use some application of user_load but I don't know if there's a performance hit associated with loading an unknown number of users one by one just to grab their names. Probably will never be more than a handful of users, but I'd rather keep it optimized.


texts: How to create Scald Atoms media library for each content type?

texts:
I need to categorize the "Atoms Library" items in a way that there would be a "Atoms Library" for each content type. How  could create a Atoms Library for each conten type? or How I could categorize the items in "Atoms Library" according to content type?

Is this possible to create a "Atoms Library" for each content type?


texts: How to display a taxonomy term's immediate children on its page?

texts:
In Drupal 8, how can I display a taxonomy term's immediate children on its page?

For example, I have a hierarchical taxonomy vocabulary like this (simplified):

Animals
--Fishes
----Blennies
------Yellow Blenny
------Green Blenny
----Gobies
------Blue Goby
------Red Goby

On the page for the taxonomy term "Fishes" (e.g. drupal/fishes) I would like Blennies and Gobies (but not their children) to appear.

I have tried configuring Contextual Filters in Structure>Views>Advanced but not been able to do this.


texts: Recognize js files in the library folder

texts: If i put my .js files in sites->all->libraries folder. Will drupal recognize it ? Because i did not see the file in the source. Can i make it recognize ?


texts: With the help of Lorenzo Alberton tutorial, i get XHProf installed for drupal 6 on linux server. Now i need to get it installed on windows but i found that XHProf cant be installed on windows. Additionally, at drupal.org XHProf, is available for drupal 7 onwards. If anyone has installed XHProf for drupal 6 on windows then please share.


texts: Is it possible to find which user created an account?

texts:
I currently have a Drupal 7 site set up to allow users with the Doctor role to create users with the Patient role, via admin/people/create.
Does Drupal store data about which user created a specific account? If the answer is yes, how can I display this information in a view?


texts: Getting the field of a user based on uid or name

texts:
I'm trying to display some custom user fields of an author, of a content type's nodes. The only fields in $node that relate to the author seem to be $node->name and $node->uid. I tried this in node.tpl:
global $user;
print render($user->field_foo);

and it makes the field show up in Krumo, but it comes up as

field_foo (NULL)

When I get more specific, using what's available to me in the user page, $field_foo['und'][0] in this case, I'm given something similar:

field_foo (Array, 1 element)
und (Array, 1 element)
0 (NULL)

I'm thinking I need to target the UID or name somehow, but I don't know how. What's described in the answer here sounds like what I want, but I'm not sure how to do what they're describing. It sounds like I should maybe be using a node_submit function. Something like this maybe?
function MYMODULE_node_submit($node) {
  if (isset($node->name)) {
    if ($account = user_load_by_name($node->name)) {
      $node->uid = $account->uid;
    }
    else {
      $node->uid = 0;
    }
  }

  $node->uid->field_foo;

  return $node;
}


texts: Guard against infinite recursion in hook_node_load()?

texts: If I were to call the function node_load() inside a function implementing hook_node_load(), I'm assuming this would recursively trigger the hook_node_load() function. Is there some way of calling node_load() in such a way as to not trigger this hook? ...or, in hook_node_load(), is there some way of detecting recursive depth?


texts: I have logged out and the login block is missing,how do I login back?

texts:
I had created a block that has replaced the default block on the frontpage i.e. the login block and I have logged out of the site so how do I log in back?

I have tried:

sitename/user/login
sitename/?q=user
sitename/?q=admin
sitename/subdirectory/?q=user

All it shows is "Page not found" or "Access Denied"
Is there any other way I could log in back to my site?

And I'm using Drupal 8


texts: How do I programmatically add a product reference to a commerce product node?

texts:
I am trying add a commerce product to a node when a person fills out a content node. I am generating the product, but can't add it back to the node.

When I try to add the data to the node, there is no product reference field data when Do not show a widget is selected in the content type > Manage fields.

Do not show a widget seems to remove the field from the node completely.

If I try to load in hook_node_presave():

$product = commerce_product_load_by_sku($sku);

$field_studio_pass_product = array(
  LANGUAGE_NONE => array(
    0 => array(
      'product_id' => $product->product_id,
    )
  )
);

$node->field_studio_pass_product = $field_studio_pass_product;

It won't work since there is no current field. I don't want to show the field to editor as they can't change it.

Further. This above code does work if the product field has a widget, or the ideal code:

$node_wrapper = entity_metadata_wrapper('node', $node);
$node_wrapper->field_studio_pass_product->set($product->product_id);

Again, if you set the field type to Do not show a widget there is no property on the node object, and as a result no ability to add a value.


texts:
When creating a new node, I need to populate/fill a custom field with a value of the current node's id. What hook should I use to fill my custom field with newly created nid ($node->nid)?

I tried to use hook_node_presave but it was NULL, currently I am thinking to use hook_node_insert but as documentation says :

  after the node is inserted into the node table in the database,

Does that mean if I assign the new value to my custom field it will be/not be saved to database?


texts: I have PHP file and I need to include that PHP file in static page. Where is best place to store that PHP file so I can include it in a static page.


texts: Is there an easy way to serve low quality images for low-bandwidth users?

texts:
I'm designing a site that wants to use lots of images, but while some users will be on broadband, other user groups will be on dial up or similar.

Is there some trick/module that can serve lower quality images based on a cookie, for example?

I guess I'm thinking perhaps a parallel set of image styles that uses a lower quality (these could be provided by image style quality module) and something that detects when one style is requested and switches it for the lower quality version?

Long shot asking for a technical solution to a design-based problem, but thought I'd ask in case anyone else has come upon this problem.


texts: Computed code for some fields are not working in D8

texts:
I have a content type with 6 computed fields in it. Out of them only 2 are working ( That means trying to parse the php code given in the computed field settings). For other fields its not even entering to the php code given in the computed code. The type of the computed code is  varchar(32) for everyone.

Any idea why this happens, or how could i solve this issue?


texts:
I'm looking to add a field to a content type that lists nodes. Basically, I need that users are able to choose the node they want to link to, and then (in the template) output the link to that node.

This seems like a basic thing to do; I'm using Drupal 7 but can't for the life of me work out what I'm missing.


texts: Is it possible to get user uid in login form submit in DrupalGap?

texts:
I have altered the login form like

if (form_id == 'user_login_form') {
    form.submit.push('my_module_user_login_submit');
  }

In submit I need the uid.

function my_module_user_login_submit(form, form_state) {
   //I need the uid of login user here;
  if(form_state.values.name){
   form.action = 'user-dashboard/'+ uid;
   }
}

Tried

var uid = Drupal.user.uid; but not working.

More info

function my_module_menu() {
var items = {};
items['user-dashboard/%'] = {
    title: 'User dashboard',
    page_callback: 'my_module_user_dashboard_page',
    page_arguments: [1],
    pageshow: 'my_module_user_dashboard_pageshow'
  };
return items;
}

**
 * The user dashboard page callback.
 * @param uid
 * @returns {{}}
 */
function my_module_user_dashboard_page(uid) {
  var content = {};

  // Build an empty container where the user dashboard will go.
  var attributes = {
    id: my_module_user_dashboard_container_id(uid),
    class: 'user-dashboard'
  };
  content['my_widget_container'] = {
    markup: '
' +
      'Loading dashboard...' +
    '
'
  };

  return content;
}

/**
 * The user dashboard pageshow event handler.
 * @param uid
 */
function my_module_user_dashboard_pageshow(uid) {
alert(Drupal.user.uid);
  // Load the user account...
  user_load(uid, {
    success: function(account) {
    var content = {};
    content['txt'] = {
        markup: '
' + account.name + '

' + account.uid + '
'
    };

      // Inject it into the container.
      var container_id = my_module_user_dashboard_container_id(uid);
      $('#' + container_id).html(drupalgap_render(content)).trigger('create');

    }
  });
}

function my_module_user_dashboard_container_id(uid) {
  return 'user-dashboard-' + uid;
}


texts: problems with contextual filter backtracking node references

texts:
Drupal 7.19

I have two content types defined:  Package and Account.
In the Package type, a Node Reference field is provided as field_account.

I have two packages that each have a reference to one account.

In the Package display, a link is given for the Account.  Clicking on that link shows the Account.
--now my problem--
On that Account page, I wish to add a block that provides links back to the two Packages.

I have been trying and trying to use Contextual Filter and just can't get it...
Appreciate all the help,
--Scott


texts: How to remove all commerce coupon from database?

texts: Hi I have used commerce coupon module. I have lot of entries of used coupon. So, right now I want to delete all commerce coupon from database. I have 860000 coupon entries in database. How can I delete all entries using custom module functionality?


texts: Entity reference field changes not shown in diff?

texts: I installed the Diff module so see the changes to node revisions. Works fine, but when I change an entity reference field the diff of that field is not shown. What could I be missing? From everything I've see the modules should integrate with each other. Diff 7.x-3.2 and Entityreference 7.x-1.1.


texts: How do I ensure a Behat Scenario, that creates a new Node, navigates as expected?

texts:
My Behat Scenario creates new content, successfully simulating every step until the new Node is created. In doing so it navigates through every new page in the regular admin sequence as you'd expect.

But, after the Save button is pressed on /node/add/myContentType, even though the Node is correctly created, the page in the session remains at /node/add/myContentType and doesn't progress to /node/n as happens when done manually.

The scenario is tagged @javascript and I am using phantomjs

I'm baffled as to how to resolve this issue. I've tried adding waits for javascript inactivity. e.g like waiting for batch completion:

$this->getSession()->wait(180000, 'jQuery("#updateprogress").length === 0');

or like waiting for AJAX completion:

$this->getSession()->wait(1000, 'typeof(jQuery)=="undefined" ||
    jQuery("#autocomplete").length === 0');

... but I think waiting is not  the issue; more likely to do with the driver?

My workaround is to split this into two Scenarios; the second Scenario navigates explicitly to the newly-created Node. But ideally, to keep things as realistic as possible,  I would rather the person writing our test features can do creation and inspection in the same Scenario.


texts: Light box that is compatible with Views?

texts:
I've created a content type, let's call it Person.
I've got a View which generates a grid of thumbnail images, one for each Person.
When the user clicks on one of these thumbnails, I'd like to open that Person node in a lightbox (without all of the header and footer decorations, just the content of the node).

What lightbox modules are compatible with Views? I tried ColorBox, but I'm not seeing a colorbox option in the "Link Image to.." which is where I would expect to see it.

Is colorbox compatible with Views and I'm just looking in the wrong place?

If it's not, what modules are compatible with Views to do something like this?


texts: Calculate difference between two dates in Webform

texts:
I am trying to calculate a difference in days between (a) the date a Webform was completed and (b) an "Event Date" field on the Webform. I have added a Computed Twig field to the webform and attempted to use this code (similar to https://stackoverflow.com/a/27205095/1357555):

{% set difference = date(data.event_date).diff(date(completed)) %}
{% set leftDays = difference.days %}

However, I am getting an error message when attempting to save the field.

  Computed value/markup is not valid.

  Calling "diff" method on a "DateTime" object is not allowed in "{# inline_template_start #}{{ completed|date }} {{ data.date_needed|date }} {% set difference = date(data.event_date).diff(date(completed)) %} {% set leftDays = difference.days %}" at line 4.

  Failed to render computed Twig value due to error.


texts: Automatically fill fields taking value from user profile

texts:
I have a custom content type "Holiday". There is role for users, "Sponsors". Only the sponsor users can create this "Holiday". "Holiday" has many fields. Three of them are:

Sponsor Name
Sponsor About
Sponsor image

Also users have fields as name, about and image. Now i want that when a sponsor user is logged in and he/she creates a "Holiday" then the above three fields, i.e,
 1. Sponsor Name
 2. Sponsor About
 3. Sponsor image
are automatically filled in from the Sponsor user profile information, ie., Sponsor name is automatically filled in as the user name (who is logged in and creating the "Holiday"), Sponsor about from the User:about and Sponsor image from the image field provide for user.  How can i achieve this.

Any suggestions?

Thanks


texts: Views Panels exposed filter in configuration AND exposed to the user

texts:
I couldn't find an answer.
Is possible to make a views pane have a pre configured filter (using the views exposed filter and configuring using the panels) AND show the exposed filter to the users?

I want to have a views that a admin can place using the panels configuration, and set what filters they want for that views.
But, I also want to allow the user to change this filters when he sees the page.

Thanks in advance =)


texts: Acquia cloud installing a module: private key file

texts:
I'm currently building a CMS using Drupal 8 hosted in Acquia Cloud.
At this time of the process, the goal was to do the setup of URL Patterns.

In order to do this, I need to install the module Pathauto and its requirements (Token and CTools) [as it's shown here].

After some going around, found out the installation of modules isn't actually as straightforward as clicking a button, inferred from seeing the following screen (doesn't appear that functionality).

After some research, found that there's a page in Acquia documentation with an explanation of how to install a Drupal module on Acquia Cloud.

The approache I started doing was to develop the application locally using Acquia Dev Desktop, add new modules using local tools like Drush or the Update Manager, and then push the code to Acquia Cloud with Acquia Dev Desktop.

After installing Acquia Dev Desktop, I need to do the login using the Acquia Cloud credentials.

While on it, there's a button meant to allow to clone this site locally, which is what I want to do now.

After filling up all the details (sanitizing the database),

I'm asked to provide a private key:

In order to get that key, Acquia allows to generate automatically a public key (using the button "Generate" in this last image)

Once the public key was generated, to complete the process I'm redirected to this link. Following it I was able to generate the SSH key which appears under

  /app/profile/ssh-keys
   on my Acquia Cloud account.

After this, I'm in need of a Private key file to continue the process and i'm blocked.
Given this information bellow, what can I do to have it?

Attentively

Tiago


texts: image alignment of uploaded image in WYSIWYG

texts:
Sorry if this is an easily solvable question but I am struggling to get to grips with Drupal (this is my first attempt with this cms)

I am using Drupal 7 and have installed CKEDITOR (as well as required modules). I have also enabled an inset image field that is shipped with Drupal (sorry I don't know the correct terminology).

My issue is that when I insert the image URL into the image info > URL field, resize the image and select align the image does not align as requested (although in the preview text box it displays as expected)

For example

align image right

displays several lines of text then a large gap and the image sitting 2/3rd's along the first line of code displayed after that gap. Remaining text is displayed as expected

Looking at the html there is no class attribute being applied to the image. Do I need to enable something or do I need to alter the code of the module im using? either way where do I need to start looking?

EDIT

After further investigation I have found CKEditor is stripping the style attribute that has been added. After searching for a solution to this issue I found this and applied the solution but it has made no difference. Are there any other alternative solutions? (other suggestions are also in a very similar vein)


texts: Create block user flag, hide users from view

texts:
I have created a social site where users can flag other users as "blocked". The primary view for the site lists users along with a bit of profile2 data and a "block" flag link. Users cannot see themselves in the view.

What relationships and filter criteria do I need to add to hide blocked users from the view on a per-user basis?

Example use case: 4 users, User A blocks User C

User A's view:

User B
User C (message about how you blocked them)
User D

User B's view:

User A
User C
User D

User C's view:

User B
User D

User D's view:

User A
User B
User C