texts: Getting Bootstrap Carousel to set Active class?

texts:
I have a Drupal 7 site that has 2 Bootstrap carousels.

One that rotates automatically and takes up the width of the page.
One that has 3 smaller items and only when the page is narrowed (e.g. on mobile device) does it need to rotate.

The first carousel works fine.
The second carousel does rotate until I manually add the "Active" to the class.  Once I do it then begins to auto-rotate between the items.

...

...

...

...

I am trying to figure out how to set one of the items as " active" when the page loads so that if the page is on mobile or resized to small enough it begins to auto-rotate.
I use nodequeue to order the items and bootstrap view to lay them out.
Thank you for any direction you can point me to.


texts:
I'm trying to add a simple checkbox in a Drupal 8 Entity Form that displays like the old Form API:

$form['approved'] = [
  '#type' => 'checkbox',
  '#title' => t('Approved'),
  '#description' => t('Check this to indicate this person is approved for membership'),
];

Using D8 style field definitions, this should be something like

$fields['approved'] = BaseFieldDefinition::create('boolean')
  ->setLabel(t('Approved'))
  ->setDescription(t('Volunteer is approved for trusted work.'))
  ->setSettings(array(
    'display_label' => TRUE,
  ))
  ->setDisplayOptions('view', array(
    'type' => 'unicode-yes-no',
    'weight' => -3,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'boolean_checkbox',
    'weight' => -3,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

This doesn't quite work; I'm getting a checkbox with the label "On".

How do I fix this?  Also has anybody gathered the various parameters used for setDisplayOptions() in one place and documented how these map to the Form API and the Render API?  I've been looking at the sources in core/lib/Drupal/Core, and I'm not finding much.  And there isn't even a test for the boolean_checkbox widget, so no code to look at there either.


texts:
I am in a custom tpl.php file [node--netrunner-card--Operation--full.tpl.php].
This is for a custom content type [netrunner_card].

I am trying to output the contents of the $body variable and unable to do so via the prescribed avenue. I copied node.tpl.php into my theme and renamed it. I can output the contents of body but I have to do this like so:

print render($body[0]['value']);

I should be able to do it like so:

print render($body);

But the second option renders nothing.

Any ideas?


texts: drush open_basedir restriction in effect on media temple

texts:
I'm using drush on mediatemple grid service. I think i've got setup drush correctly. At least to my knowledge. I've been able to use it; but with nagging errors/warnings each time.

And whenever i invoke drush i get these errors:

The following restricted PHP modes have non-empty values: check your configuration settings in /usr/local/php-5.2.14/etc/php.ini or in your drush.ini file

Anyone have any clues how to rectify this?


texts: Auto delete temporary files after 15 seconds of creation

texts: The default setting given to delete temp files is after 6 hours minimum. I have users upload files and I want that if it has temp status, delete it after 15 secs. Tweaking the file module code is risky, if I get the exact location to change 6 hours to 15 sec that will do the job.


texts:
Okay I managed to create a password token to be used on email registration message with a custom module. Works fine.

However, using this on commerce checkout (Commerce Checkout Login) where users are allowed for inline registration does not seem to work.

Aren't they the same event and the same form? Why would this custom module not work on registration form other than the one located in /user/register?

function my_module_token_info() {
    $info['tokens']['user']['password'] = array(
    'name' => t('Password'),
    'description' => t('The password by the user'),
    );
return $info;
}
/**
* Implements hook_tokens().
* */
function my_module_tokens($type, $tokens, array $data = array(), array $options = array()) {
    $replacements = array();
    $url_options = array('absolute' => TRUE);
    if (isset($options['language'])) {
        $url_options['language'] = $options['language'];
    }
    if ($type == 'user' && !empty($data['user'])) {
        $account = $data['user'];
        foreach ($tokens as $name => $original) {
            switch ($name) {
                case 'password':
                    $replacements[$original] = $account->password;
                    break;
            }
        }
    }
    return $replacements;
}


texts:
I'm building an webinterface for our ticket system and I'm stuck. When you view an ticket and object Ticket is being made (containing the mails and etc.). Now on that same page I have enabled block (writen in the same module) to display some extra information.

Now the problem is, that extra information is found in the Ticket object that page creates. It's stupid to let the block fetch the ticket id and create that object all over again.

My question is, what is the most efficient way to pass that data to my blocks on that same page?


texts:
I have a feed set to Replace existing node and when I upload a feed say about 400 records, I see that 400 nodes were created.

Now if I upload that feed again right after the first one, I see 20 nodes updated.

Then if I upload again I might see 8 nodes updated

Does anyone know why this happens?


texts: How to attach block to page provided by logintoboggan

texts:
I have the logintoboggan module installed. By default, Anonymous users will be presented with a login form along with an access denied message when they try to access a page which they do not have the permissions to. Please, how can i attach a block to this page?

Thanks


texts:
I just enabled the Gmap module in Drupal 7. You can see it in the picture below.

In Drupal 6, after the gmap is enabled, you can do the setting for any content type in /admin/content/node-type/story under location information.

But I don't see how to do it in Drupal 7.

I can't neither found it as a field type to add to content.


texts:
My page structure looks a little something like this:

www.site.com/sub-directory-1/page-1
www.site.com/sub-directory-1/page-2
www.site.com/sub-directory-1/page-3
www.site.com/sub-directory-2/page-1
www.site.com/sub-directory-2/sub-sub-directory-1/page-1
www.site.com/sub-directory-2/page-2
www.site.com/sub-directory-2/page-3

What is the easiest way to make the page's ID the name of the first subdirectory it's stored in?

For example, in the first case, the <body> tag should be like the following.

<body id="sub-directory-1">


texts: Migrating SQL dump from Drupal 5 into Drupal 7

texts:
My site went recently down, and all the data were lost (PHP installation of Drupal 5). What I am left is simple SQL dump from PHPMyAdmin.

I would like to "use" this disaster and finally migrate to Drupal 7. Because of this, I do not know how to continue.

Should I install Drupal 5 first, import SQL dump, and then upgrade?

Is there any way how to save stored data from Drupal 5 (SQL dump) to Drupal 7? If the answer is yes, can you please point me to correct procedure?


texts: I need to print individual fields from the $content variable in node.tpl.php file in separate div tags. How do I do that and how do I find out what the field's names are?


texts:
I want execute the query SELECT * FROM table WHERE type = 'AAA' AND id = 'BBB'.

The following code works.

$res = db_select('table', 's')
  ->fields('s')
  ->condition('type', $type)
  ->execute()
  ->fetch();

$res = db_select('table', 's')
  ->fields('s')
  ->condition('id', $id)
  ->execute()
  ->fetch();

The following code doesn't work.

$res = db_select('table', 's')
  ->fields('s')
  ->condition('type', $type)
  ->condition('id', $id)
  ->execute()
  ->fetch();

I get an error about the ID not being unique.

UPDATE:

Thanks and sorry. This code works well. I found error in another site.


texts:
Drupal version: Drupal core 9.1.5.
I am using Content Moderation and Workflows modules along with Workbench Email contrib module to generate the Email Templates. Workbench Email module uses Tokens for creating dynamic email templates. We have a requirement to provide the URL of the latest revision inside the email body to the reviewer so that he can see the latest updates.

If I create a node that needs moderation, the /node/NID/latest page does not exist. Here reviewer will need link to /node/NID.
When the content is already published and now if gets edited, the link in the email should be /node/NID/latest. If we just provide /node/NID in the URL, it won't show the updated content.

Since we can have only one template to handle both of the above conditions, I was looking for a token which could provide me either /node/NID or /node/NID/latest based on whether the content is new or already published.
Can someone please assist on how can I move further?


texts: drupal removes language key from variables in templates

texts:
I have a multilingual website using Drupal 7. The 1st développer didn't use Views.

I installed i18n modules (entity translation, etc )
Un templates I have been using variables like $vars['und' ] (for undefined)

I think drupal ran update and now the template system uses $var without the language as key..
I think I activated block translation..
Other thing : (I purged caches) template still work as disconnected user but doesn't work as administrator.

Do you know what's happend ?

Thanks for your help
Mario


texts: how to associate multiple nodes with one node

texts:
I have a content type "events" and all the node created under this content type will have further node.

The red boxes in the above pictures are node links which are associated to the "event node".

Every node created under "Event Content Type" will have relative information nodes as shown in boxes below.

How i should be doing this association? Should i create content types for all red boxes and then make entity/node references ?

any clue?
thanks


texts: What does parent::form($form, $form_state) do?

texts:
I'm not able to understand what parent::form($form, $form_state) does in a content entity form. If I comment it out, the entity form still get rendered.

class AdvertiserForm extends ContentEntityForm {
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);
    /** @var \Drupal\redirect\Entity\Redirect $redirect */
    $advertiser = $this->entity;
    $form['status_code'] = array(
      '#type' => 'textfield',
      '#title' => t('Redirect status'),

    );

    return $form;
  }

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

  }

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $this->entity->save();
    drupal_set_message(t('The redirect has been saved.'));

  }
}

What does parent::form($form, $form_state) do, exactly?


texts:
My latest module does not seem to be loading .install when enabled.  Here's the rundown:

I have a .module file implementing hook_menu() and hook_views_data().

Both appear to work fine, after enabling the module: navigating to the menu path works as expected and my new views base type is present.

I have a .install file implementing hook_install() hook_uninstall() and hook_schema()

None of the functions in the install file appear to run.  The new tables are not present after enabling  and there are no errors logged.

If I manually call the functions in the .install file with devel THEN I get an undefined error.  I can only assume that the install file is not being loaded.

Running the .install file through the command line PHP interpreter doesn't bring up any syntactic errors.

I'm at a loss to explain why the file is not loaded into scope when the module is enabled.

I'd appreciate any assistance.


texts: How to make fields of a cloned node available in Rules

texts:
I have a rule that clones a node once it's flagged. I can set certain parameters for this newly cloned node but not all. I read in other posts that you have to use a conditional rule to identify what the node type is of that cloned node and then you have access to all the fields. But again not to "all" fields.

I want to set the cloned node text field "student name" to the author's first name, a text field on the user's profile. Many fields from the flagging user's profile are available but not all.


texts:
i want to add some feature in drupal home page, like:
1) All new posts will be arranged greed
2) A thumbnail will appear from post photos
3) Text of content will be minimized to 150 words
so, how to do it?
Thanks


texts: Addresses Module - Province (State) Used to Be a Drop-Down

texts:
I am having trouble with the addresses module (version 6.x-1.12) running on my Drupal 6.28 site. Recently the addresses module stopped showing a drop-down menu for the Province (State) field on my custom content type. I am not certain when this happened, or what caused this change. I did some major upgrades to the site, tested everything, and thought this was working after the upgrade.

This above image shows what I'm talking about. This is from my profile, in case anyone cares about the confidential data I am showing the world.

The above image shows the configuration options for the addresses module I have installed. I don't see any options to make it so that the province is a drop-down, despite the fact that the module info page says it has all the provinces for all the countries it supports...?

The above image shows the address field configuration options for my custom content type using the address field. It's called a uprofile or user profile, and stores additional information about the user.

Thank you very much for taking the time to look at my question. I tried to be as complete as possible. If you want to try to create an account to see what I am talking about (or to be an extra in a movie filmed in New Mexico!) the site is here.


texts: Paypal integration with external paypal class

texts:
I have a paypal.class.php at SITE_URL/paypal/papal.class.php   getting this error :

  Warning: include_once(/var/www/clients/client1/web15/web/includes/bootstrap.inc): failed to open stream: No such file or directory in /home4/solution/public_html/taconsultant/paypal/paypal.class.php on line 3

  Warning: include_once(): Failed opening '/var/www/clients/client1/web15/web/includes/bootstrap.inc' for inclusion (include_path='.:/opt/php54/lib/php') in /home4/solution/public_html/taconsultant/paypal/paypal.class.php on line 3

  Fatal error: Call to undefined function drupal_bootstrap() in /home4/solution/public_html/taconsultant/paypal/paypal.class.php on line 4

I am not able to access the user_load() function or any other Drupal function or variable in it. Is there a way to access Drupal variables in that particular file?

I have included it like this.

    require_once '../includes/bootstrap.inc';

    global $user;
    $uid =$user->uid;

        class paypal_class {

           var $last_error;                 // holds the last error encountered

           var $ipn_log;                    // bool: log IPN results to text file?

           var $ipn_log_file;               // filename of the IPN log
           var $ipn_response;               // holds the IPN response from paypal
           var $ipn_data = array();         // array contains the POST values for IPN

           var $fields = array();           // array holds the fields to submit to paypal

           function paypal_class() {

              // initialization constructor.  Called when class is created.

              $this->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';

              $this->last_error = '';

              $this->ipn_log_file = '.ipn_results.log';
              $this->ipn_log = true;
              $this->ipn_response = '';

              // populate $fields array with a few default values.  See the paypal
              // documentation for a list of fields and their data types. These defaul
              // values can be overwritten by the calling script.

              $this->add_field('rm','2');           // Return method = POST
              $this->add_field('cmd','_xclick');

           }

           function add_field($field, $value) {

              // adds a key=>value pair to the fields array, which is what will be
              // sent to paypal as POST variables.  If the value is already in the
              // array, it will be overwritten.

              $this->fields["$field"] = $value;
           }


texts: Parsing bad dates automatically with feeds and date api?

texts:
My company is trying to load an event calendar with events from another company's online calendar's web service. I'm using the Feeds Module and everything's working, except the dates because their service returns dates in a text format like so: 'MM/DD/YY[ - Ongoing]'. The Dates API doesn't seem to know how to handle this, so it just defaults to today's date.

I've tried using the Partial Date module, but there doesn't seem to be a way of feeding Feeds results into a partial date field. I've also tried talking the other company into fixing their service and returning proper dates, but they have no idea what they're doing.

Any ideas?


texts: How do I automatically create content after checking out a product?

texts: Is there a way or any module out there that would enable me to automatically create content after checking out a certain product?


texts: Translation of a field overwrites the original language value

texts:
I have encountered a problem with translation. When I try to translate a custom field of a custom node type it overwrites the original value.

Here is how it looks like

The custom field

I create a node and enter following information

Then I click Save, the node appears, so far so good.

Next I click

I can see that translation not available now, click Add

Then I have the following url link

/node/8/translations/add/en/<my language>

Enter the following value

Now I have two nodes.

Let go to the original node and see what is the value of the field.

It is the same as it was before, but on the web page, I have two nodes with different translations.

The interesting thing that both of the two nodes in admin panel have the same translation as currently selected language, even if I click the edit button from the Translate tab, I need to switch the language via a switcher for example to get the content of a node for the selected language.

And that makes me crazy, I cannot understand what is going on really, how can I edit a translation of a node without changing the language ?

Please help me to solve this problem, I am completely lost with this stuff.

P.S.

Database entries are added correctly I guess

EDIT

My detection configuration before

And set it like this now

Logically, I guess the Interface Language should be responsible for translating Admin Panel interface and other helper popups that are used for the development purpose. But Content translation should be exactly what I am looking for, but when I switch off the Interface Detection and leave it to by default (uncheck session), but check Session in the Content translation section, my language switcher disappears.


texts:
Display suite (http://drupal.org/project/ds) allows you to modify the form display appliyng template layouts.
But if i chose (say) a 3 column layout, with say 6 field, the tab order is per column and not per field weight.

example:

left-----middle---right

field1 - field2 -field3

field4 - field5 -field6

if i press tab, the focus shift from field 1 to field 4, and not on field 2 as expected.
 it's possibile to set a tab order per row and/or per field weight?


texts: How to change the HTML Output of a view?

texts:
This view is a black book directory that will have a long list of links to static pages. The problem I am having is the output isn't coming out as an unordered list like I have set. Each link is set in a span and a row. Is it possible to output a simple ul with an id on it. I am having trouble matching my design.
Thanks


texts: Calculate commerce product sales price based on order quantity

texts:
The commerce price table module is meant for calculating the sales price on commerce products based on order quantities. But out of the box the contrib module commerce_price_table prices do not get calculated to sales prices. In my case I have a tax rate per product that is nicely applied to the standard commerce product price but not to the commerce_price_table prices.

Is there another way to calculate the product sales price based on order quantity? Might this be fully configurable with Rules?

For a related topic see www.drupal.org/node/1886080
There is also an alternative module www.drupal.org/project/commerce_pricelist but this one is still in alpha.


texts:
Can i use route ID for Link template 'edit-form' for entity type?

I'm following this tutorial

over there he use:

 *   links = {
 *     "edit-form" = "flower.edit",
 *     "delete-form" = "flower.delete"
 *   }

while flower.edit (i assume) is from below route.yml:

flower.edit:
  path: '/admin/structure/flowers/edit/{flower}'
  defaults:
    _entity_form: 'flower.edit'
    _title: 'Edit flower'
  requirements:
    _permission: 'administer site configuration'

but when i run, it throw me an error:

  Uncaught PHP Exception
  Drupal\Core\Entity\Exception\InvalidLinkTemplateException: "Link
  template 'edit-form' for entity type 'flower' must start with a
  leading slash, the current link template is
  'flower.edit'" at
  \core\lib\Drupal\Core\Entity\EntityTypeManager.php
  line 97

I know i can just use: /admin/structure/flowers/edit/{flower} to solve my problem.

but the question is: is it actually possible to use route (instead of path) in entity links config?


texts: Programmatically logout user without redirect

texts:
I have the following code in my module:

<?php

function MODULENAME_init() {
        if (!user_is_logged_in()) {
                global $user;
                $user = user_load(31);
                user_login_finalize();
        }
}

Purpose of this code is to log in all anonymous user as user with id 31. But with this code i can't even logout correctly:

if (user_is_logged_in() && request_uri() == '/user') {
    user_logout();
}

After i am visiting http://ggames.kz/user i am getting redirected back to the main page and so i am logged again as user 31. I want to log out any user when he's requesting http://ggames.kz/user and show a login form in order to log in as user with id 1.


texts: How to use dd(debug_backtrace()); for an error debugging?

texts:
I have this exact error on my site.
I am trying to troubleshoot the error using dd(debug_backtrace()); through the Devel module as is described on the link above.
Being the noob on developing I can't figure out how to print the output in a drupal_debug.txt file under the tmp folder in the root of my Drupal Installation (As is described in the in the link above).
I have tried dd(debug_backtrace()); but I don't see any error file being created so I also tried  dd(debug_backtrace('drupal_debug.txt')); but I get the error:

Warning: file_put_contents(): Only 0 of 1 bytes written, possibly out of free disk space in drupal_debug() (line 1793 of  /home/bigcypru/public_html/sites/all/modules/devel/devel.module).
Devel was unable to write to /tmp/drupal_debug.txt.

I created the file manually and set 777 permissions to be sure is writable but still get the same error and I am sure I have enough space in my hosting plan.


texts: How can I draw a donut chart based on the number of specific fields on a form?

texts:
Is there a module that can count results in a form, and then draw a donut chart like the following picture?

Note that I'm actually using content types and the Views module to create such forms. So I'm not using the commonly known Webform module to create them.


texts:
I am interested in using webform submissions as a data capture method versus creating new content types for each set of fields - I think it adds great flexibility and capabilities to tailor without having to mess with content types.
But ... what I can not do/figure out is version control on a webform submission.  In my use case a single data entry will start and then as a function of time (over like 1 year) be updated.  I want to track revision history like I can do with content types - is that a possibility?


texts: How to add two fieldConditons in Entity field Query?

texts:
Is this the correct way to add field Conditions

$query->entityCondition('entity_type', 'profile2')
   ->entityCondition('bundle', 'user_profile')
   ->fieldCondition('field_town_city', 'value', "%".$search_title."%", 'LIKE')
   ->fieldCondition('field_land_state', 'value', "%".$search_title."%", 'LIKE');


texts: Allow user to select field widget at node form

texts:
How can I allow user to select field widget type directly at node's form page?

I have entity reference field, and editor wants in some cases input values as multiple autocomplete fields, and another time as autocomplete tagging style. Is there any module for this?


texts: Set fields in uc_addresses checkout pane to disabled

texts:
I want to disable the billing address fields in uc_addresses so they cannot be altered by the user while they're checking out.  However, I cannot find a form to use hook_form_alter on.  It seems those fields are living inside a pane, but I don't know how to isolate and edit that.

I suppose this is one of those times they told me about where all I want to do is hack the other modules.

edit1:
If you're interested here's the function that controls the panes and calls up the form.  I don't really understand how it works.


texts: Form state cache breaks dependency injection

texts:
I have a class that extends FormBase and there are 6 services that are injected into the class via Dependency Injection (DI). My problem is when I submit the form it says to a class property that normally should be injected, it's NULL and can't be called the load() function on NULL. However when I debug, I clearly see all the dependencies are injected to the class and saved to the properties, but until the execution reaches the validation/submit function somehow it became all property to NULL. Why does this happen? How can I use DI in the form validation/submit phase? I'm really thinking if this class is not a deserialized cached version...
Extra info this form also has an ajax function where the DI works fine.

I went a bit deeper into the system, after the classfinder creates my form with the injected things and saved into this place: $form_state->getBuildInfo()['callback_object'], I found it out the problem is the cache. (/core/lib/Drupal/Core/Form/FormCache.php:149)

  protected function loadCachedFormState($form_build_id, FormStateInterface $form_state) {
    if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
      // Re-populate $form_state for subsequent rebuilds.
      $form_state->setFormState($stored_form_state);

      // If the original form is contained in include files, load the files.
      // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
      $build_info = $form_state->getBuildInfo();

The system loads the formstate from the cache with the following lines, the $stored_form_state contains the cached state, without any dependencies, and the $form_state->setFormState($stored_form_state); line overwrites my formstate which contains the right properties with the DI classes... And that's a problem.


texts: Issues when combining Reference Field Option Limit & Conditional Fields

texts:
I'm hoping there's a rocket scientist out there that can help me with this!!

I am using the following entities:

Machine Type (Taxonomy)
Ink Type (Taxonomy)
Ink Configurations (Taxonomy)
Machine (Content Type)
Customer Machine (Content Type)

The Machine Type, Ink Type & Ink Configurations taxonomies have an Entity Reference field added to them which references the Machine content type.

The Machine content type has entity reference fields for Machine Type, Ink Type & Ink Configurations.

I'm using Corresponding Entity References on the Machine content type & the 3 associated taxonomies to keep the references bi-directional.

The Customer Machine content type has the following fields (partial list):
 - Customer (Entity Reference)
 - Machine Type (Entity Reference)
 - Machine (Entity Reference with Reference Field Option Limit by Machine Type)
 - Ink Type (Entity Reference with limit by Machine)
 - Ink Configuration (Entity Reference with limit by Machine)

The user should first select the Customer, followed by the Machine Type.
Selecting the Machine Type should filter the available Machines.
Selecting the Machine should filter the Ink Type & Ink Configuration options.

All of this works as it should but then I tried to add Conditional Fields to the process.

The Ink Type & Ink Configuration settings should only be visible when certain Machine Types are selected as some Machine Types do not make use of ink.

When you choose the Machine Type, the Machine entity reference gets limited as desired but when you select a Machine, it exposes the Ink Type & Ink Configurations field regardless of the Machine Type selected.

If I remove the Reference Option Limits on the entity reference fields then the Conditional Fields module works as intended.

I'm guessing I could try adding each Machine to a new Conditional fields dependency but this makes maintenance a problem as I would need to modify the dependency each time a new machine gets added.

Sorry for the long post but I'm hoping that clarifies the details of my scenario.

I'm using:
 - Drupal 7.3x
 - Conditional Fields 7.x-3.0-alpha1
 - Reference Option Limit 7.x-1.x-dev (latest at time of writing)

I have also applied this patch to Reference Field Option Limit so that multiple fields can react to the same filtering field. In this case both Ink Type & Ink Configuration react to Machine.

Any assistance in this regard would be most appreciated because I'm somewhat clueless when it comes to module development & troubleshooting!!

So far, I've made a basic module that uses hook_form_alter to change the cardinality of the Ink Types & Ink Configurations fields by setting #multiple to false on the Create Customer Machine form but removing/disabling my module has no impact on the above scenario.

Just off the top of my head... Could Rules and/or Rules Forms Support be of assistance here?

Please help the noob!! :)

Unfortunately I can only post 2 links being a new member.

All of the module URLs start with https://drupal.org/project/ and end with their short names as below:

entityreference
cer
reference_option_limit
conditional_fields
rules
rules_forms


texts:
I created a drupal custom module for my website, the module functionality is it display list of students who have registered in my site. Now I want to update my custom module with search functionality, the search function should like google search function.

My custom module look like following structure

Now I want to implement the search function in my custom module. When I search using the fields of the table like student name, gender, author name, and status, how do I do this?


texts:
I'm trying to pass a variable to an user template, here is my code:

function template-name_preprocess_user(&$variables) {
  $variables['foo'] = 'foo';
}

It doesn't work. I tried adding these line in the core User module preprocess and it works!


texts:
Using Drupal 8 and hooks, I am able to send an email to the current user, thanks to How to send mail programmatically in Drupal 8
and
BCC For drupal mail function.
So, I define my message in hook_entity_update() and send it in hook_mail().
I am trying to send emails in the following case.

user U1 consult a node created by user U2 (the aim is to permit to U1 to give his impression to U2 thanks to a select field). When U1 gave his impression, content is registered.
I need to send a email to U2 (the node author), but since he isn't the current user, I cannot use \Drupal::currentUser().

In hook_entity_update(), how can I identify the author of the current entity, knowing that "author" is not provided by Drupal\Core\Entity\EntityInterface?
Is there a specific service?


texts:
I use this snippet to restrict block visibility from administrator

<?php
global $user;
if (user_access('access administration pages') || ($user->uid == 6)) {
  return FALSE;
} else {
  return TRUE;
}
?>

I also want to restrict this block from role 6. However, it does not work. Can somebody help?

Thank you


texts: How to mass update recurring date rules?

texts:
I would like users to be able to mass update recurring date rules possibly using VBO and Rule sets.

For example: user would like to add "exclude date = 01/01/2012" recurring date rule for all selected nodes' dates where date is a new field added to a content type.

How to do this ?

---=EDIT=---

I have already build a basic Rule with the following code:

{ "rules_change_end_date_for_selected_content" : {
    "LABEL" : "Change end date for selected content(s) (Test rule)",
    "PLUGIN" : "rule",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : {
      "node" : { "label" : "Content", "type" : "node" },
      "event_end_date" : { "label" : "Event End Date", "type" : "date" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_event_date" } },
      { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "event" : "event" } } } }
    ],
    "DO" : [
      { "data_set" : {
          "data" : [ "node:field-event-date:0:value2" ],
          "value" : [ "event-end-date" ]
        }
      },
      { "entity_save" : { "data" : [ "node" ] } }
    ]
  }
}

What should I put instead of node:field-event-date:0:value2 to modify the date rule end date ( not the first date enddate). I would like to change the date until this node repeats but I cannot see tokens for the date repeating rule.


texts: Make hierarchical menu using Taxonomy menu

texts:
I've vocabulary 'category'. I've terms in below orders:

cat1
  cat1-subcat1
  cat1-subcat2
cat2
  cat2-subcat1
  cat2-subcat2

I've menu item called 'category' which includes all terms.
So my menu structure should be like below:

Home

  Articles

cat1

cat2

It has displayed only parent terms. It doesn't included child terms of every terms. But i want to included these child terms.

How to do this?


texts: I've built an iOS app on the Drupal iOS SDK. That said, I want my logged in user to be able to send a message to another Drupal user. Right now, I'm successfully pulling received Private Messages from my services endpoint - but does anyone know how I would go about successfully posting a message to a specific user id? Are there any tutorials out there for this?


texts: How to trigger an email for a buyer or seller who has not performed any activity for 30 days or more?

texts:
Is there any way to trigger an email for any buyer or seller who have not had any activity for 30 days or something like that.

Also
Sending reminders to users that haven't logged in for 30 days.

Unpublishing content after user has not logged in for 30 days.

Deactivate accounts after user has not logged in for 30 days.


texts:
Possible Duplicate:
  How to list all the form IDs

I have been searching for a way of listing all forms that are hooked to a Drupal site. I have read this post How to list all the form IDs, saying that it is impossible.

Now impossible is a big word in my vocabulary;-) If need be I can scan every single module file for the hook_form () function. Yet I am seriously hoping there will be a less hack like solution no matter what the resource cost might be. Any suggestions?


texts: What is the variable format to reference Views field data in a Global PHP that resides in a footer/header?

texts: Currently its annoying to have to manually parse through the views results data by either doing a print_r() or a dsm() via devel. Does anyone know how to reference a field via PHP when you put in a Global PHP field in either the header or footer of the View?


texts: Does the tmp directory have to be shared between servers?

texts:
I am having a problem with multi file uploads and I suspect the issue lies in the fact the tmp directory is not not shared between servers.

Does it have to be shared between servers? I have 2 webheads (server boxes) and both have a local tmp directory (not shared between them).


texts: How can I override the markup of a view I printed in a template file?

texts:
I installed the Twig Tweak module on my site to render Views on the home page.
I want to make the display mode frontpage_tasks for the current user, his account, his stores and his groups.
{{ drupal_entity('user', user.id, 'frontpage_tasks') }}
{{ drupal_view('accueil_page_liste_des_taches_boutique', 'block_1') }}
{{ drupal_view('accueil_page_liste_des_taches_groupe', 'block_1') }}

Here is one of my Views :

The problem is that the Views module adds a lot of unnecessary markup that makes it impossible to display it correctly.
I just want to make the display mode, without any additional tags.
How to do this ? Is there a Twig code to render only Views without the additional View tags ?

UPDATE
I created an views-view--accueil_page_liste_des_taches_boutique.html.twig template. It only contains the following code :
{{ rows }}

I display the Views blocks with the code below, on my homepage :

                    {{ drupal_entity('user', user.id, 'frontpage_tasks') }}
                    {{ drupal_view('accueil_page_liste_des_taches_boutique', 'block_1') }}
                    {{ drupal_view('accueil_page_liste_des_taches_groupe', 'block_1') }}

I still have this damn markup :

                    ...

Is there a code in TWIG to remove this basisage ?
https://ibb.co/b1tKXhQ


texts: How to use titles instead of IDs in urls for nodes?

texts:
I am managing a site right now (Drupal 6) and the links are all coming out in the form http://example.com/blog/12553.

I'd like these urls to be based on the name of the article. I could swear that the site used to do this, but not sure at all where to find this setting or what might have gone wrong. I was looking into 'clean urls' but conclude that the urls are clean (Because they don't have PHP parameters), but I'm not sure.

I'm pretty familiar with PHP and programming... less familiar with Drupal


texts: Rendering a form using \Drupal::service('entity.form_builder')->getForm($entity, 'default') is returning a plain form, before hook_form_alter

texts:
I'm rendering a form programmatically. The following code works:

$addressForm = \Drupal::entityTypeManager()
  ->getStorage('profile')
  ->create(array('type' => 'customer', 'uid' => $uid));
$finalform =  $this->entityFormBuilder()->getForm($addressForm);

However, it is rendering the form before hook_form_alter() has been called.

For example, in hook_form_alter() we added a #after_build callback method and custom validations, but the changes made in these functions are not reflected in $finalform.

How do I ensure hook_form_alter() changes are made to the rendered output?

.module file

function custom_profile_form_profile_customer_add_form_alter(&$form, FormStateInterface &$form_state, $form_id) {
  $form['formtitle'] =  array(
    '#type' => 'markup',
    '#weight' => -100,
    '#markup' => '
Old Address Form
',
  );
  /* ....
.... */
}

function custom_profile_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'form_FORM_ID_alter') {
    $group = $implementations['custom_profile'];
    unset($implementations['custom_profile']);
    $implementations['custom_profile'] = $group;
  }
}

.routing.yml

I have created a new route for the Address page in /modules/custom/custom_profile/custom_profile.routing.yml,

commerce_add_address.get:
  path: '/checkout/{uid}/customer/add'
  defaults:
    _controller: '\Drupal\custom_profile\Controller\newAddressBook::commerce_add_address'
  options:
    parameters:
      uid:
        type: integer
  methods:  [GET,POST]
  requirements:
    _permission: 'access content'

Controller

in src/Controller/newAddressBook.php file

public function commerce_add_address($uid) {
  //To get profile Add Address form
  $addressForm = \Drupal::entityTypeManager()
      ->getStorage('profile')
      ->create(array(
        'type' => 'customer',
        'uid'  => $uid
      ));

  $finalform = $this->entityFormBuilder()->getForm($addressForm);
  $build['#theme'] = 'usernewaddress';
  $build['#data'] = array();
  $build['#data']['form'] = $finalform;

  return $build;


texts: How to use the same EntityListBuilder for entity A and an extended version B

texts:
I have used the content entity example coming from the example project.

This example define a Contact entity.

Next I have extended this Contact class in an Artist class with some added fields (let say a Bio and a Cv field).

class Artist extends Contact  {

My Idea was to share the list_builder defined in the Contact class in order to get an administrative list showing the Contacts and the Artists at the same place.

To do so, I have those annotations in the Artist class:

 * @ContentEntityType(
  * id = "mymodule_artist",
  * label = @Translation("Artist entity"),
  * handlers = {
  * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
  * "list_builder" = "Drupal\mymodule\Entity\Controller\ContactListBuilder",
  * ...

As you can see, ContactListBuilder is the list builder of the Contact entity... in other words, it is used in Contact and in Artist.

In the routing.yml I have the following

entity.mymodule_artist.collection:
  path: '/mymodule_contact/list'
  defaults:
    _entity_list: 'mymodule_contact'
    _title: 'Contact List'
  requirements:
    _permission: 'view contact entity'

Unfortunately, this is not working at all... the ContactListBuilder shows only the Contact entities; not the Artists. (I couldn't understand why)

After many tries, I drop this idea... My new plan was now to create a view that will show all Contacts and all Artists.

Thus, I added this line in the annotations of the Contact and the Artist classes (in the "handlers" section):

 * "views_data" = "Drupal\mymodule\ContactViewsData",

And here is my ContactViewsData class definition

class ContactViewsData extends EntityViewsData  {
}

As you can see it is empty: it only extends EntityViewsData. In fact I really don't understand what to do in the getViewsData() function. I couldn't find any doc on it (But this is maybe something I should ask in another question)

Anyway, this does the job, and I could create a view (in the UI) for the Contacts and another view for the Artists. But I have no clue on how to create a view that are showing both.

To summarize, my questions are:

Is extending the Contact class (for the Artists) a good idea? Maybe it is much simpler to just add the Artist's fields in the Contact Class.
What is the best way to list a Mix of 2 entities that are sharing some common fields (Ex: Name, Surname, ID,...): Is it a view?
Is it a good Idea to try to use the same ListBuilder for 2 entities (Of course, this Listbuilder will only list the common fields)
Where to find some doc on the getViewsData()` function, or at least, what is the purpose of this function.


texts: form submit hook handler not getting called in drupal

texts:
I have Drupal 7 site. It has custom module named say myproducts. This module has following hook

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

if(isset($form_id) && $form_id=='product_node_form')
{
   $form['#submit'][] = 'myform_form_submit';
}

}

function myform_form_submit(){
 echo 'test submit handler'; exit();
 }

But `myform_form_submit` is not getting called.

Any help highly appreciated.


texts: How to set the tabs on node pages to always display in the site's default language?

texts:
I don't want $tabs to be translated. How can I set the tabs on node pages to always display in default site language?

I've tried admin language module however the setting that works in that prevents menu items from been translated.

Is there a way to manually set the rendered language in the tpl?


texts: The function module_invoke returns null?

texts: The function module_invoke('facetapi','block_view',$delta) returned the blocks for the search . Then I have ran the apache solr. After that, it returns null. module_invoke returns null after indexing the data in solr. Why module_invoke returns null after running solr? How to debug it?How to fix it


texts: Pinterest-style image presentation page?

texts:
Any Ideas how to create pinterest style image presentation page(view)?

Basically, it is like a page that have images in columns, images in each column have same width but different height.


texts: How to get the Commerce Product type from the order object. D7

texts:
I am unable to find the product type when looking at the order object. I have tried

commerce_order_load($order_id);

This does not give the product type and neither does

commerce_line_item_load();

I have also looked for a function to achieve this here but can't see anything to achieve this.

I am able to get the line item type it seems but not the product type, seems odd


texts: How to make Feeds import only one post at a time when cron run?

texts:
I have a website which will import many images through Feeds. But Feeds import too much posts which affect the bandwidth.

I want Feeds import only one post at a time when cron run.

The setup:

feeds-6.x-1.0-beta10
Drupal 6.20


texts:
I'm trying to create a Migrate group with following code. But it is not detected & listed in admin/structure/migrate. Both migrate plus & Migrate tools modules are installed.  I"m trying to create migration from WordPress tables. The module is called migrate_wordpress & migrate group is defined in config/install with the name migrate_wordpress. migrate_group.wordpress.yml

id: wprdpress
label: WordPress Imports
description: Import from WordPress blog
source_type: Custom tables

What is wrong with above Migrate group configurations? What is the correct way to write an migrate group configuration file in Drupal 8?


texts:
I am looking for a list of the modules in the standard Open Atrium 2 install, something similar to those posted for Drupal Commons and Acquia Commons like:

https://drupal.org/node/2160755
https://docs.acquia.com/commons/module

Is one available? Where is it?

Thanks!


texts:
I need to make a different process for user registration in drupal.
1] set username, email and password.
2] send a verification email to user's email address.
3] by clicking on the link in the email direct to the site as a logged in user.

I mean I need to set password in the first step, not after clicking on the link in the email. although It's a bit illogical but users would be less confused in this way.

if there is a module for this please let me know otherwise I need to change it programmatically.


texts: Filtering Views to make several users see the node

texts:
I have a content type which contains files. I have a node with that content type which i want several, but not all people to be able to see it from a Drupal View. I know the list of the people i want to see the files, and am willing to input the names of users into any type of field of that node.

How do i filter a View to only show that node to that certain people listed in that field of users?

For context, the nodes contain some private documentation or architect design files, that not everyone should see, but also should be seen by several people, not only administrator and owner of the node.


texts: How to handle cache metadata in a cacheable response?

texts:
I have a custom controller action that returns the HTML for a search result. The action is invoked via AJAX on the search page and the results are inserted into the page body.

The problem is that a dynamic page cache entry is created for this controller action and it's not "busted" when the query string changes, so old results are always returned:

  public function basicPeopleSearch(Request $request) {
    $search = $request->query->get('search');
    $build = [];
    if (!empty($search)) {
      // Get search results and add them to the render array.
      $results = \Drupal::getContainer()->get('pu_search.people_search')->basicSearch($search);

      foreach ($results as $result) {
        $build[] = [
          '#theme' => 'pu_search_person',
          '#person' => $result,
        ];
      }
    }

    // The results will differ based on the "search" query string parameter.
    $build['#cache'] = [
      'contexts' => [
        'url.query_args:search',
      ],
    ];

    $rendered = \Drupal::service('renderer')->renderRoot($build);
    return new CacheableResponse($rendered);
  }

I suspect this has something to do with how I'm actually returning the response or rendering the output?


texts:
I have a problem/question.

My client need to sell one product but the price of this product (digital, so no shipping cost or other) is based on a field in a table. Explain: X categories and Y places. Each combination of X per Y return a different price for the only 1 product.

How can I set the price of this product at "checkout" ?
In node Z (where categories is 1 and places is 2, for example) I can write the correct cost value (via preprocess_node, or template function or other), but in the cart?


texts: How do I render a custom form in page--front.tpl.php?

texts:
I have a custom form with a button.

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

Now I want render this button on the front page. I've wrote this code in page--front.tpl.php.

print render(drupal_get_form('mymodule_get_subscribed_form'));

It doesn't work with Drupal 7.54, even after clearing the cache.


texts: Mini Panel Title Question for each region

texts:
Is there a way to move the title of each region to the side? instead of on the top having it go down the side of each region?

i.e
 Region 1   Region 2
T           T
E           E
S           S
T           T


texts:
I checked the other questions related to this topic, but half of them didn't get any useful answer and the other half didn't help me out.

I face with several issues building up a site using Drupal 8:

The view exposed date filter doesn't work properly in 8.3.x
The administrative theme doesn't work for roles other than administrator users

I wanted to upgrade a site from 8.3 to 8.4 as most of the patches are provided for 8.4, and I hoped that I would get less troubles.

Drupal 8.4 is just available as development snapshot, at this moment, and Drush didn't let me update the site to this version.

On top of all, the installed Drush version (v8.1.9) is not compatible with Drupal 8.4.

How do I update Drupal to 8.4 using the version of Drush I installed?


texts: How do I update a user profile with entity_metadata_wrapper()?

texts:
I got an error while updating user profile data such as name,password and email. I am using entity_metadata_wrapper() for processing update.

  exception 'EntityMetadataWrapperException' with message 'Unknown data property original.' in C:\xampp\htdocs\phone_bay\sites\all\modules\entity\includes\entity.wrapper.inc:335\nStack trace:\n#0

This is my code.

require './includes/password.inc';
function commerce_services_user_update($uid, $data, $flatten_fields) {
    $user = user_load($uid);
    $wrapper = entity_metadata_wrapper('user', $user);
    dpm($wrapper->value());

    $name = $data['name'];
    $password = $data['password'];
    $email = $data['email'];

    if ($name != null) {
        $wrapper -> name  = $name;
    }
    if($password != null){
        $wrapper -> pass = user_hash_password($password);
    }
    if ($email != null) {
        $wrapper -> mail = $email;
    }

    try {
        user_save($wrapper);
        $message = "successessfully update!";
    } catch (Exception $e) {
        $message = "not success! -> ". $e;
    }

    $reply = (array('status' => $status,'message' => $message));
    return $reply;
}


texts: How to create an Ubercart add to cart button programmatically with defaults?

texts:
I am able to create an add to cart button:

$nid = 27;
$node = node_load($nid);
$add_to_cart = array(
    '#theme' => 'uc_product_add_to_cart',
    '#form' => drupal_get_form('uc_product_add_to_cart_form_' . $nid, $node)
);
return drupal_render($add_to_cart);

This gives me an add to cart button, but with no attributes selected. How can I alter this code to allow for the defaults to be set to specific values. For example, if I have an attribute with aid = 1, called "action", and two possible value... oid = 3 = register ... and oid = 4 = transfer..... of which I want the default to be "transfer" for example?


texts: Drush installation - setting symlink to /usr/local/bin/drush is a must?

texts:
Refering to https://www.drupal.org/node/2132447, I would like to install Drush in /usr/slocal/abc directory, and I tried the following steps:

$ cd /usr/slocal/abc
$ wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz
$ tar -zxf drush-7.x-5.9.tar.gz
$ ln -s /usr/slocal/abc/drush/drush /usr/local/bin/drush

Then, I got this error:

  ln: creating symbolic link '/usr/local/bin/drush': Permission denied

I asked my system admin who said that the company policy does not allow to install stuff into /usr/local/bin.

I've searched many installation guides, all of them requires to create a symbolic link '/usr/local/bin/drush' in order to run Drush. Is there any other way I can do it?


texts: Multiple Field Widget instances on the same page, validation problem

texts: I have multiple instances of the same field widget attached to different entity forms on the same page. On validating one of these forms, when I set form_set_error($field_name, '...'), every one of these widgets get highlighted. Is there a way to get around this somehow?


texts: How do I remove duplicates when using the random sort?

texts:
I have created a view where I am displaying the the node title and a logo (a cck field). In the arguments I have passed the taxonomy term name.

In the result a node is displaying 2 or 3 times; I already checked the distinct checkbox in the Query settings but that also does not work. I have used the random sort, which seems to cause the duplicates; when I remove the random sort, it works fine.

How can I avoid the duplicates without disabling the random sort?


texts:
I just installed Drupal 7.2 on my localhost using xampp, made some pages, and installed a theme, I'm also modifying the CSS of the theme to my own convenience.

My front page has (at the end of the content, not the footer) a "Powered by Drupal" written over there. In WordPress I would just edit the content PHP file, and delete that; with Drupal, I can't find where the line is located.

I thought the index.php would give me some ideas, but I think Drupal works differently.

How exactly do I find my front page in the directories? I have a c:\xampp\htdocs\drupal7 main directory.


texts: Discrepancy between 'views preview' and actual rendered view with flags

texts:
I have some flags for the states Complete / Incomplete. There are 5 of these flags attached to a content type 'client goals'. The two roles, Editor and Admin are able to toggle these states through different views.

When I have the two different views open on multiple screens, the toggle immediately toggles in the 'views preview' and then if I refresh the preview of the other role (in views), this also reflects the changes that were made in the other view.

My problem is that when I actually display this view on the front-end of my site, the toggled alterations are not 'saved' and thus not reflected in the view. There seems to be a disconnect therefore with the display in views and the display on the site.

I was hoping that someone might be able to help me out working out why the toggles are not saving in each case and what the disconnect might be?

Thanks for your help.

I'm not allowed to post images due to my noob nature - but here are some links to the images

https://docs.google.com/file/d/0B5nWEQpoRUfuVkp5bHVGRlI0T2s/edit

https://docs.google.com/file/d/0B5nWEQpoRUfuT0dxVkxMREx4Y0E/edit

https://docs.google.com/file/d/0B5nWEQpoRUfuOTUtamZjeGJEY2M/edit


texts: How to have a button to open a modal popup from a table form?

texts:
I have a custom entity (contract_subscription) created in a custom module (amap) by a bunch of BaseFieldDefinition, one of which being a file field:

$fields['file'] = BaseFieldDefinition::create('file')
  ->setLabel(t('pdf file'))
  ->setSettings([
    'target_type' => 'file',
    'file_extensions' => 'pdf',
    'uri_scheme' => 'private',
    'file_directory' => 'contracts/subscriptions',
  ])

I created a form to "mass"update this entity.
In this form, the file field is defined this way:

$form['subscriptions'][$key]['file'] = array(
    '#type' => 'managed_file',
    '#upload_validators' => array(
      'file_validate_extensions' => array('pdf'),
),

wich gives this:

I'd like to replace the standard way the file field is presented by a simple button.
The click on the button would show a modal popup with the standard file field management in it.
How can I do that?

[Edit]
I updated my code this way.
Replaced the file field by a link and a hidden field:

  $form['subscriptions'][$key]['filelink'] = array(
    '#type' => 'link',
    '#title' => $title,
    '#url' => Url::fromRoute('amap.contract_subscription_file_form', ['file' => $fileId]),
    '#attributes' => [
      'id' => ['myLink' . $key],                     <-- New
      'class' => ['use-ajax'],
      'data-dialog-type' => 'modal',
    ],
  );

  $form['subscriptions'][$key]['file'] = array(
  '#type' => 'hidden',
  '#attributes' => array('id' => 'myFile' . $key),   <-- New
  '#default_value' => $fileId,
  );

Added this to amap.routing.yml

amap.contract_subscription_file_form:
  path: '/amap/contract/subscription/{file}'
  defaults:
    _form: '\Drupal\amap\Form\ContractSubscriptionFileForm'
    _title: 'Add file'
  requirements:
    _access: 'TRUE'

and this ContractSubscriptionFileForm definition:

class ContractSubscriptionFileForm extends FormBase
{
  public function getFormId()
  {
    return 'contract_subscription_file_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state, $file = NULL)
  {
    $form['file'] = array(
      '#type' => 'managed_file',
      '#upload_location' => 'private://contracts/subscriptions/',
      '#upload_validators' => array(
        'file_validate_extensions' => array('pdf'),
      ),
      '#default_value' => array($file),
    );
    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
      '#ajax' => [
        'callback' => '::ajaxSubmitForm',
        'event' => 'click',
      ]
    ];
    $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    return $form;
  }

  public function validateForm(array &$form, FormStateInterface $form_state)
  {
    parent::validateForm($form, $form_state);
  }

  public function submitForm(array &$form, FormStateInterface $form_state)
  {
  }

  public function ajaxSubmitForm(array &$form, FormStateInterface $form_state)
  {
    $response = new AjaxResponse();
    $html = '999';
    $response->addCommand(new ReplaceCommand('#myLink1', $html));
    $html = '<input data-drupal-selector="myFile1" type="hidden" name="subscriptions[1][file]" value="999">';
    $response->addCommand(new ReplaceCommand('#myFile1', $html));
    $response->addCommand(new CloseModalDialogCommand());
    return $response;
  }
}

And now I get:

when the file already exists

when there is no file

[Edit2]
The $html code in ajaxSubmitForm is hardcoded only for test purpose...
When I submit the modal, the original table form is updated accordingly (the link title = 999 and the link URI points to .../999.

My question is: I can get the value of file id from $form_state and replace the 999of my current code.
But I don't know how to retrieve the generated html for myLink1 and myFile1.
Any idea?


texts:
I'm having trouble with Drupal 7 and the calendar (version 7.x-1.0-alpha3) module. The default view is working. It is showing the nodes based on the time they were updated.

I added a date field called time1 to a basic page node type. I added some basic pages with date set for the current date.

I don't know how to make the calendar show the nodes based on the value of time1. I've tried to change the argument as in the picture.

The README.txt of the module says that look the documentation on the project page. However, there is no documentation that applies to Drupal 7 in here http://drupal.org/node/262062

Has someone drupal 7 and the calendar working? What am I doing wrong here?

I don't know could this be related to http://drupal.org/node/1096224
For me none of the month, week or day views are working.


texts:
I'd like to run a query using the EntityFieldQuery object. I need value from both the node and node_access table therefore I'd need to use INNER JOIN. From the d.o documentation I can't figure out how this is possible.

Here's what I have --

$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'node_access')
->propertyCondition('type', 'external_link')
->propertyCondition('status', 1)
->fieldCondition('gid', '3', '=')
->fieldCondition('realm', 'domain_id', '=')
->fieldCondition('grant_view', '1', '>=')
->range(0,1)
->execute();


texts:
I am using the Multisite Search module and have added some custom behaviour to it.
What I did was basically do another check in the multisite_search_search function and stopped
several nodes from reaching the $result variable. This stopped them from displaying.

My problem is that this causes the paging to fail. I know the paging is done in the do_search function, before I remove certain results from being displayed. This causes the result page to display varying amounts of results per page, depending on how many I took out from that particular page.

Is there a way I can fix this? Redo the pagination in the search function? Maybe not adding node to $result is not enough or should I have gone differently about it?


texts: I have on my website several roles and each of these roles have different levels of responsibility. How can I create a separate administration page for each role or access level?


texts: Zoom to location when setting a location in nodeapi

texts: In some instances I am automatically setting the wkt field on my content type. I am doing this in hook_nodeapi() when the $op is prepared. This is setting the the wkt fine. The map shows my marker in the correct location on the screen. However it does not zoom in on it (this is set in my preset). openlayers_render_map() does not see the change to the $node so uses the default settings where I am zoomed out on a world map view. Is there any way that when setting the wkt field programmatically to zoom to the marker? Once the node is saved and I edit it then it does zoom to the marker.


texts: Custom theme: variable not made available in menu template

texts:
I've created a custom theme, let's call it "mytheme" in the examples, with the "classy" theme as base. I use several templates, one is menu--account.html.twig, it's an override I made of the classy menu.html.twig template to display a menu. In that template I need the username and some other info from the currently logged in user.

I've tried different ways of getting it to output the username in the template, i.e. the preprocess functions like so:

<?php

function mytheme_preprocess(&$variables, $hook, $info) {
  $variables['current_user_name'] = $variables['user']->getDisplayName();
  var_dump($variables['current_user_name']); //ironically this does dump the variable
}

I've tried using the Bamboo Twig module and get the username like so:

<!-- Get Current User -->
{% set user = bamboo_load_currentuser() %}
<div>{{ user.name.value }}</div>

Both variants don't work for me. If I try to dump the username with

{{ dump(current_user_name) }} or {{ dump(user.name.value) }}

all I get is NULL in the template output. From searching online I'm sure that one of these variants should work, but they don't.

I've also cleared caches several times during the tests, so that can be ruled out too.

Do you have any other suggestions on how to output the variable in that template?


texts: How to implement node.js For updating data in my block?

texts:
I have one block in which I need to update data from database while on events like vote , comment , revision or creation of node?

I have set up node.js and can broadcast message to users accessing site but I have no idea how to use it for updating data in block.

Any help will be appreciated, please suggest?

Thanks!


texts:
I'm trying to install the Delete All module on Drupal 7 via Drush, but whenever I type drush dl delete-all I get the following error:

  No release history was found for the requested project (delete-all). [warning]

I thought it might have been related to case sensitivity, but trying other names like Delete-All and DeleteAll gave me the same error. Is there anything I'm doing wrong here, or is something wrong with my installation of Drush/Drupal?


texts: How do I access variables displayed in devel?

texts:
Using devel I'm able to retrieve the names of certain variables and how to access them.

For example I might want to use the book menu name. Devel has it listed as so

$...->book['menu_name']

But I'm not sure how to print that info in page.tpl.php or access it in general. I'm also not sure what to replace the $... with.

I've tried the following with no luck.

print $page->book['menu_name'];
print $node->book['menu_name'];
print render($page->book['menu_name']);
print render($node->book['menu_name']);


texts: How do I get a new database connection with a new setting?

texts:
I want to set the GLOBAL variable innodb_flush_log_at_trx_commit, and then run a migration after getting a new connection since changes to a global variable does not affect the current session.

So the raw mysql would go like this...

-- set the variable that speeds my migrate up by 40x
SET GLOBAL innodb_flush_log_at_trx_commit=0;
-- reconnect (starts a new mysql db session)
connect;

-- Do the import

-- at the end of the import
SET GLOBAL innodb_flush_log_at_trx_commit=1;
connect;

I've not tried anything yet, but I'm interested to see if anyone else has looked at this, and the issues encountered, and the end solution.


texts: Linking to a homepage when Drupal is located in a Directory

texts:
I have a problem with creating a proper link to the homepage of my website. I would like this code to redirect to my homepage:

Unfortunetaly it doesn't work, because it brings me to the homepage of my whole server and drupal is located in a subdirectory of the server. I tried to do this using php:

<a href="<?php print ('<front>');?>">

but it doesn't work too. When i click on the image it appears:

  Page not found The requested page
  "/drupal7/drupal-7.23/en/%3C?php%20print%20(%27%3Cfront%3E%27);?%3E"
  could not be found.


texts: Change class for dropdown menu as per region in Drupal

texts:
I used hook_menu_link for adding class for the drop down using semantic UI frame work. It will added class to all menu.
My code is:

function semanticUI_menu_link(array $variables) {
  //print'
';print_r($variables);die();
  $element = $variables['element'];
  $sub_menu = '';
 $element['#localized_options']['attributes']['class'][] = 'item';
  if ($element['#below']) {
    // Prevent dropdown functions from being added to management menu so it
    // does not affect the navbar module.
    if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
      $sub_menu = drupal_render($element['#below']);
    }
    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 1)) {
      // Add our own wrapper.
      unset($element['#below']['#theme_wrappers']);
      $sub_menu = '
' . drupal_render($element['#below']) . '
';
      // Generate as standard dropdown.
      $element['#title'] .= ' ';
      $element['#attributes']['class'][] = 'ui dropdown';
      $element['#localized_options']['html'] = TRUE;

      // Set dropdown trigger element to # to prevent inadvertant page loading
      // when a submenu link is clicked.
      //$element['#localized_options']['attributes']['data-target'] = '#';
      //$element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
      //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
    }
    elseif ((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] == 2)) {
      // Add our own wrapper.
      unset($element['#below']['#theme_wrappers']);
      $sub_menu = '
' . drupal_render($element['#below']) . '
';
      // Generate as standard dropdown.
      $element['#title'] .= ' ';
      $element['#attributes']['class'][] = 'dropdown-bottom';
      $element['#localized_options']['html'] = TRUE;

      // Set dropdown trigger element to # to prevent inadvertant page loading
      // when a submenu link is clicked.
      //$element['#localized_options']['attributes']['data-target'] = '#';
      //$element['#localized_options']['attributes']['class'][] = 'dropdown-toggle';
      //$element['#localized_options']['attributes']['data-toggle'] = 'dropdown';
    }
  }
  // On primary navigation menu, class 'active' is not set on active menu item.
  // @see https://drupal.org/node/1896674
  if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
    $element['#attributes']['class'][] = 'active';
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '
' . $output . $sub_menu . "
\n";
}

Is there any way to add class for specific region menu. If menu is in sidebar so is this possible to add different class for menu. Currently its working fine its drop down menu but i want for side bar it will show simple menu.

Any help would be appreciated.


texts: Using drupal 7 commerce feeds, how can I import the node reference images?

texts: I have followed the drupal commerce guide All of my products have been imported and show up in the store. When I attempt to import the Product Reference's everything is good except the images won't show up. Can someone point me in the right direction ?


texts: Difference between hook_node_view() and template_preprocess_node() with seeing messages

texts:
When I add a form to a node's render tree using hook_node_view(), eg

<?php

/**
* Implements hook_node_view().
*/
function MODULE_node_view($node, $view_mode, $langcode){
  if ($node->nid == 9 && module_exists('contact')) {
    module_load_include('inc', 'contact', 'contact.pages');
    $cForm = drupal_get_form('contact_site_form');
    //$cForm['#action'] .= '?destination=' .    request_path();
    $node->content['contact_form'] = array(
    '#markup' => drupal_render($cForm),
    '#weight' => 20,
    );
  }
}

then I get my messages displayed right after the submission.

I do the same thing with template_preprocess_node(), the messages are displayed one request after the submission.

I suspect this is related to the execution order.  Can someone shed some light on the difference here?


texts:
I'm setting up a OAuth2 Server using the OAuth2 Server module.  Everything tests out as expected.  I login, get the authentication code, which I then trade in for an access_token, which tests out successfully.

The issue comes when requesting a resource that's handled by the services module.  It looks like it's starting a session for the anonymous user instead of calling the other authentication hooks.

After all, if one authentication method fails, it shouldn't assume that it's the only authentication method possible.

Any ideas on how to use OAuth2 authentication code authorization to access services endpoints?

Here's the snip from services.runtime.inc line 116 where it's only looking for one authentication module, it seems.

foreach ($endpoint->authentication as $auth_module => $settings) {
  if (isset($settings) && $auth_error = services_auth_invoke($auth_module, 'authenticate_call', $settings, $controller, $args)) {
    return services_error($auth_error, 401);
  }
}


texts:
I have a VBO form that is embedded in an EVA field on a user page.

The VBO uses a Rules component with a text parameter to allow the current user to enter a value to be used as a variable to perform the rule component action.

The action of the VBO form (for user 55) is /user/55/55 , this means that when you run the VBO action, the page that allows you to add the variable is still the user page, and this causes a horrible busy page, when all I want is a plain page with the text field.

In light of this, I have tried setting my own new action using

hook_form_alter

and

$form['action'] = '/my/url';

but this results in a page not found on /my/url

Is there another way that I can control the parameter entry page URL for VBO?

More information:

The view doesnt have a path as it is an EVA (Entity Views Attachment) which is a view embedded inside the manage display settings of the User page. The issue im having is that after you select some rows and execute the VBO action, there is a text area variable (in this case, a message area to be included in the email sent by VBO) which appears in the same area as the rows you just selected.

This causes a bit of chaos as the URL for the form #action (FAPI) is user/55/55. What i want to know is if I can use hook_form_alter to change form #action to a new page, something like /send-rsvp where the user can fill in the text area and click send.


texts: How to get fields of certain content type in template file without writing iteration loops in tpls?

texts:
Here I'm getting all fields of certain content type in my .tpl.php file with the help of hook_theme.

return theme('carousal', array('carousal' => $fields));

And my template file is something like this:

<?php
global $fields;
foreach($fields as $key => $value){
echo $value['title'];
print render ($value['fields']['body']);
}
?>

Now, what I want is, I don't wanna use foreach loop in my template file. And if possible, not even any php tags.

How far is it possible to render fields in template file without using any loop?

Can't we write only "BODY" and we get "body" field rendered itself automatically?

I don't know whether it's possible or not. If it's possible, kindly let me know the way out of this.


texts: Importing nested XML using Feeds XPath Parser

texts:
I have some XML formatted as such:

<item>
    <title>Name</title>
    <id>12</id>
    <upgrade>
        <id>13</id>
        <level>2</level>
    </upgrade>
    <upgrade>
        <id>14</id>
        <level>3</level>
    </upgrade>
</item>

Ultimately from this example I want 3 nodes:

Title: "Name (1)" GUID: 12
Title: "Name (2)" GUID: 13
Title: "Name (3)" GUID: 14

I'm quite happy to do 2 runs of the file if necessary. I have one importer at the moment which sets up the "Name (1)" items. This works perfectly.

I have a second importer set up which I can successfully create the secondary "upgrade" nodes but only if I use \item\upgrade as the context, at which point I lose the title element so the nodes come through as " (2)", " (3)" etc.

If I use \item as the context like the initial importer, I can't seem to loop through the upgrade XML nodes.


texts: How to prohibit access to a view if the user is not the user in the account path?

texts:
I created a page view to display forms created by the user on his account.

I added a "Submitted by" context filter to this view to filter the user ID of the logged in user.

My problem :

When I disconnect and reload the page, the view is still displayed. How to prevent access to this page if the user does not match the user of the account path ?


texts: How to place a library in DRUPAL_ROOT/libraries?

texts:
In Drupal 8, when I declare a library in a .libraries.yml file, it seems the library files have to be located INSIDE the module or the theme folder with the .libraries.yml file.

For instance, if a MYMODULE module contains this .libraries.yml file:

form-alter-css:
  version: 1.x
  css:
    theme:
      css/form-alter.css: {}

The file css/form-alter.css has to live at DRUPAL_ROOT/modules/MYMODULE/css/form-alter.css.

Instead, for shared libraries, I'd like to place the files in DRUPAL_ROOT/libraries, like we did in Drupal 7. But how?

I have tried entering an absolute path in the .libraries.yml file (e.g. /libraries/css/form-alter.css) but it doesn't work. Any ideas?


texts: How to get a flag counter for anonymous users?

texts:
I'd like to have a counter for flagged nodes for anonymous users. I'd like to use a view. In this view I need a relationship to the anonymous user (session).

How can I get it?

Or is there another solution to get a flag counter for anonymous users?


texts:
I'm currently creating a website on Drupal 8, even if it's still in RC3.

I've been swimming in the sauerkraut since few days now and I still cannot figure it out how to override node output as I could do in Drupal 7.
Because Drupal 8 is not as used as Drupal 7, it's tough to find answers on Google.

So, I'd like to do the following in my twig file(s):

    <?php if ($field_images) { ?>
    <?php
      $img_url = $field_images[0]['uri'];
      $img_alt = $field_images[0]['alt'];
      $img_title = $field_images[0]['title'];
    ?>

      <a data-lightbox="galleryWrapper" href="<?php print image_style_url('lightbox', $img_url); ?>">
        <img src="<?php print image_style_url('album_thumb', $img_url); ?>" alt="<?php echo $img_alt; ?>" title="<?php print $title; ?>" class="media" />

    <?php } ?>

I've seen that I could, as in Drupal 7, override a template file with a specific filename, such as: "field--node--field-images--gallery.html.twig".

The thing is that I don't know where to create my variables that will be available for my twig files (MYTHEME.theme?).

I've already tried this in "field--node--field-images--gallery.html.twig":

{% if multiple %}

    {% for item in items %}

        {#  Before was {{ item.content }} instead of the 5 following lines  #}
        {% if item.content.url %}
          {{ item.content.image }}
        {% else %}
          {{ item.content.image }}
        {% endif %}

    {% endfor %}

{% else %}
  {% for item in items %}

      {#  Before was {{ item.content }} instead of the 5 following lines  #}
      {% if item.content.url %}
        {{ item.content.image }}
      {% else %}
        {{ item.content.image }}
      {% endif %}

  {% endfor %}
{% endif %}

I've tried to access to "url" with {{ item.content.url }}, because {{ content }} seems to call "image-formatter.html.twig", which contains the following:

{% if url %}
  {{ image }}
{% else %}
  {{ image }}
{% endif %}

As you can imagine, it doesn't work.

And, that's another issue, but I've already tried to dump variables but I got this famous WSOD (White Screen Of Death). So, that's very difficult to know what this $variables contains.


texts: .htaccess error on local site in docksal

texts:
I've built a Drupal 8.6.4 website within Acquia Dev Desktop, but moved it into a local Docker/Docksal setup to continue working (haven't used it before) - on a mac, if it matters. Everything seems fine, but for two issues. The first is a bunch of Security warnings in the logs about htaccess, saying to add an htaccess containing some specific code to the "/var/www/config/default" directory, but I don't have this file directory. It's a Docksal set-up: just ~/projects/projectname/docroot set-up on my computer.

The second issue, which I suspect may be related, is that I can't Drush archive-backup --destination=x/x/x.. It always tells me the file permission prevents it, Even if I give full read/write permission on the folder. But I can do it without the --destination added. It just puts it in a temp folder.

Here's the Error I see - it generates most any time I load an admin page.

    Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your /var/www/config/default directory which contains the following lines:
    # Deny all requests from Apache 2.4+.
    <IfModule mod_authz_core.c>
      Require all denied
    </IfModule>

    # Deny all requests from Apache 2.0-2.2.
    <IfModule !mod_authz_core.c>
      Deny from all
    </IfModule>

    # Turn off all options we don't need.
    Options -Indexes -ExecCGI -Includes -MultiViews

    # Set the catch-all handler to prevent scripts from being executed.
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
    <Files *>
      # Override the handler again if we're run later in the evaluation list.
      SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
    </Files>

    # If we know how to do it safely, disable the PHP engine entirely.
    <IfModule mod_php5.c>
      php_flag engine off
    </IfModule>


texts:
I'm using flag module to flags my nodes. Now, in frontpage the list of nodes (html) is get and put in the main DIV via AJAX,  so the flag module has not parsed these nodes. How can I say to flag module to re-get and process all flag link ? I know that I need to insert the call in my AJAX .get() function, but which is the correct flag-JS-function to call ?

Thanks.


texts: How can I check from a custom module if a specific view is enabled or disabled?


texts: How to use the view_mode in hook_preprocess_flag?

texts:
I'm using Drupal 7 and Flag.

I try to modify the output of my flags according to the view mode with preprocess_flag :

function mytheme_preprocess_flag(&$variables) {
  $variables['full'] = $variables['view_mode'] == 'full';
  if ($variables['full']) {
...
  }
}

But i have an error : Notice : Undefined index: view_mode dans publiu_preprocess_flag().

Do you know how to use the view_mode in hook_preprocess_flag ?


texts: How do I create a dynamic link for a block?

texts:
I have two dynamic links that I want to put in a block, e.g. http://domain.com/series/naruto/addreview ("series" is the content type, and "naruto" is the node title), http://domain.com/node/add/album/1 ("1" is the node ID).

I want to change the URL depending on what node is being viewed. How can I do it?


texts: What are best practices for Drupal 7 my.conf settings?

texts:
I posted the following wiki to GDO to try to consolidate best practices for Drupal implementations:
http://groups.drupal.org/node/289613

There's just so much written out there, but the documentation is often old or very personalized to one person's my.conf file.

What have other folks used.  Starting with https://tools.percona.com/wizard seems to be the best approach, but the Wizard doesn't know anything about Drupal.


texts: How to alter field values on a display page?

texts:
I am trying to alter field values in a page display.  I can get the field values easily using field_get_items(), but depending on the values of other fields, I may need to manipulate the text and/or display based on some PHP logic in my template file.  I am trying to do it using either hook_page_alter() or hook_preprocess_HOOK().

I cannot get the text to be altered when the page is displayed using hook_page_alter() or hook_preprocess_HOOK().  I can confirm those 2 functions are working and that I can pull the values from the DB ($page['content']), but I cannot override the variable to set them.  For example:

function standard_submission_page_alter(&$page) {
    $node = menu_get_object();
    $page['content']['system_main']['nodes'][$node->nid]['field_title_nickname']['#items'][0]['value'] = 'A new nickname title!';
}

function standard_submission_preprocess_page(&$vars) {
    $vars['node']->field_title_nickname['und'][0]['value'] = 'A new nickname title 2x';
}

Any ideas on why my altering of this field_title_nickname text field value isn't being accepted and displayed?  It keeps reverting back to whatever is originally in the database.


texts:
I just want to wrap checkboxes like this in all the forms, automatically.

    <input type="checkbox">
    Checkbox

How can I achieve this? Is there any hook available for this?


texts: Module for requiring some authors' texts to be approved by admin

texts:
I am developing a site for a client that wishes to have two levels of content administrators, editor and admin. The editor is supposed to be able to edit their own content but an admin has to approve it before it is published. All content is versioned on the site so one version would be displayed to the site visitor while a newer version is in review mode. Once it is approved by an admin it can be published.

Is there any module available for this kind of setup?


texts: Use taxonomy terms to set node access for a user

texts:
I have a vocabulary with two terms.

Vocab: A

Terms: b,c

I use them in two places.

  First in the registration: in the config->account->fields.
  And second one of my content type.

Now I want when a post tagged as b Just people that they are tagged with "b" in the registration can see that post.

And when a post tagged as c just the users that tagged as "c" can see the post.

Can I do this with context module?
How?


texts:
I have used https://github.com/drupal-composer/drupal-project to install a new website. I have now updated the core with the same information on the above link.

I was wondering where the backups are stored and how to use the "git diff" because I don't now where the old vs new files are located on my server (ie: .htaccess and robots.txt).


texts: Restricting certain files from appearing in search results in Drupal 7

texts:
I would like to upload multiple revisions of documents, but only for the Latest ones to be displayed in the search results. For example. I will have the following pages and policies on each:

Apples
 Apples price policy V3
 Apples price policy V2
 Apples price policy V1
 Apples growing policy V3
 Apples growing policy V2
 Apples growing policy V1

Pears
 Pears price policy V2
 Pears price policy V1
 Pears growing policy V4
 Pears growing policy V3
 Pears growing policy V2
 Pears growing policy V1

However, I only want the following files/documents to be searchable/displayed in the search results:

Apples price policy V3
 Apples growing policy V3
 Pears price policy V2
 Pears growing policy V4

How do I do this?


texts: Upload a file to Drupal server from (external) desktop client application (in c#)

texts:
I have an application written in Winform (dotNet) and I would like it to Upload File to Drupal 7.
I'm newbie in Drupal. Can somebody help me please?


texts: Removing all 'stable' theme's CSS from a Drupal 8 custom theme

texts:
I would like to remove all CSSs automatically included from stable theme:

/core/themes/stable/css/system/components/*

I can remove them one by one inside the .info.yml file:

stylesheets-remove:
  - 'core/themes/stable/css/system/components/ajax-progress.module.css'
  - 'core/themes/stable/css/system/components/autocomplete-loading.module.css'
  - ...

Is there a way to remove all of them at once?

Something like:

stylesheets-remove:
  - 'core/themes/stable/css/system/components/*'


texts:
Is it possible to combine a Bootstrap theme with an existing custom Drupal 6 theme?

I want to use Grayscale in my Drupal 6 website. But I already have an existing custom theme and I am not sure if I can simply use it. Or whether the styling will interfere with other stylesheets in Drupal.


texts:
I've made my own module to add commenting to a node (it opens modally in a colorbox - really nice). The form works great, but how do I save the comment?

I know it's got to be done using comment_save. But, as usual, drupal.org is great at showing the code for the function without giving an example...

Has anyone done this before?

I'm guessing it's something like:

$comment = new stdClass();

$comment->nid = $the_node_the_comment_is_for;
$comment->title = $my_comment_title;
$comment->body = $my_comment_body;

comment_save($comment);


texts: Hide label for input on focus and when has value

texts:
I have some simple jQuery working to hide labels for text inputs on focus, keyup and blur if (value !== ''). I am using replacement tokens in my forms to fill in a default value based on the currently logged in user. I need to hide the labels if the default value gets prepopulated. I can't get the right function to hide the labels if a default value populates the form. (I've installed jQuery update to get the .on() function.)  Here's the script in my js file:

(function ($, Drupal, window, document, undefined) {
Drupal.behaviors.my_custom_behavior = {
  attach: function(context, settings) {
/*------ Hide labels when user interacts with forms ------*/
    $(".form-item input", context).on({
      focus: function() {
        $(this).prev('label').fadeOut('fast');
      },
      keyup: function() {
        $(this).prev('label').fadeOut('fast');
      },
      blur: function() {
        if($(this).val() !== "") {
          $(this).prev('label').hide('fast');
        } else {
          $(this).prev('label').fadeIn('fast');
        }
      }
    });
/*------ Hide label if has default value on page load --------*/
    $(document).ready(function(){
      if($('.form-item input').val() !== "") {
          $(this).prev('label').hide();
      }
    });
  }
};
})(jQuery, Drupal, this, this.document);

Drupal outputs

  Email Address *
 <input type="text" id="edit-field-email-address-und-0-email--2" name="field_email_address[und][0][email]" value="foo@foofighter.foo" size="60" maxlength="128" class="form-text required">


texts: Other (related) nodes with the same taxonomy block grouping problem

texts:
Quick view: I want to create a views block that lists all other nodes that have the same taxonomy term(s) and I want to group the related nodes by term.

I have trouble while doing this:

The content type has some taxonomy terms fields and one of them is my_taxonomy_field. I can enter multiple values to this field.

What I basically want is to show all other nodes tagged with the term(s) on this node and group them by terms. I could do this by contextual filters (content: has taxonomy term ID + ) as explained here or here.

Let me explain:

This is my node list:

NODE 1 taxonomy term field: term 1, term 2, term 3
NODE 2 taxonomy term field: term 3, term 4
NODE 3 taxonomy term field: term 5, term 6, term 7
NODE 4 taxonomy term field: term 6, term 7
NODE 5 taxonomy term field: term 1, term 3
NODE 6 taxonomy term field: term 1
NODE 7 taxonomy term field: term 8
NODE 8 taxonomy term field: term 2, term 9

Let's look at NODE 1, it has these terms: term 1, term 2, term 3

And the terms are tagged on that nodes:

term 1: node 1, node 5, node 6

term 2: node 1, node 8

term 3: node 1, node 2, node 5

This is the related nodes block based on the taxonomy term field:

node 1 (excluded)
node 2
node 5
node 6
node 8

I want to group them by terms as that (note that current node (node 1) excluded):

BLOCK

TERM 1

node 5
node 6

TERM 2

node 8

TERM 3

node 2
node 5

I tried to this with that way: views -> style -> settings (grouping field) and I selected the taxonomy term field. It does what I want, not what I want actually, more than what I want because it creates a views block as that:

BLOCK

TERM 1

node 5
node 6

TERM 2

node 8

TERM 3

node 2
node 5

TERM 4

node 2

TERM 9

node 8

This views doesn't add any (irrelevant) nodes to the list, the nodes are the same with the un-grouped one but because node 2 and node 8 are tagged with other terms, other terms listed here.

How I could list related nodes as grouped but without this 'unwanted' terms, with only the terms in the current node?

(Note: I'm working on both two ways mentioned above, these are the screenshots of them):

Method 1:

Method 2


texts: D7 auto nodetitle, title with pattern node:nid and rules php node_save($node)

texts:
I want to make automatic title like node-333, using auto nodetitle module. When creating node there is no nid, so pattern node-[node:nid] gives me after saving new content "node-". When I edit again this node - title is changing as expected.

So I thought, that using rules I do simple "After saving node" condition "Node type is" and action Execute php node_save($node). But it is not working, I'm getting

PDOException: SQLSTATE[23000]: Integrity constraint violation

Does anyone deal with this or have some workaround?


texts: Updating other modules schema when creating custom module

texts:
I need to add a information to a content types within my module. Generally, is it good practise to update node_type schema or is it better to create my own and join it to the node_type via primary key?

Thanks.


texts:
While installing Aegir in a VM, during the hostmaster installation, I got the following error:

Do you really want to proceed with the install (y/n): y
PROVISION_SITE_INSTALLED                                             [error]
The external command could not be executed due to an application     [error]
error.
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: Unsupported operand types in
/var/aegir/drush/includes/environment.inc, line 916

Drush version 4.5


texts: Error running a PHPUnit test only under run-tests.sh

texts:
I'm working on an 8.x module that uses PHPUnit tests.  I've been running these from the command line using the embedded phpunit script that's installed with Drupal 8:

../vendor/bin/phpunit PATH/TO/MY/FILE.php

Both of my tests work w/o any problems under both PHP 5.5 and PHP 5.6.

But the Drupal testbot is failing both of my tests with the error

Fatal error: Trait 'Drupal\Tests\my_module\MockSessionTrait' not found in /var/www/.../PATH/TO/MY/FILETest.php

Using phpunit from the command line, this same trait is found w/o any trouble.

If I run the tests myself from the command line, but this time using run-tests.sh, I get the same error the testbot gets:

php scripts/run-tests.sh --url http://192.168.88.42/drupal --class 'Drupal\Tests\my_module\Unit\FILETest'

The stack trace looks like this:

PHP Stack trace:
PHP   1. {main}() /var/www/drupal/core/scripts/run-tests.sh:0
PHP   2. simpletest_script_get_test_list() /var/www/drupal/core/scripts/run-tests.sh:76
PHP   3. class_exists() /var/www/drupal/core/scripts/run-tests.sh:807
PHP   4. spl_autoload_call() /var/www/drupal/core/scripts/run-tests.sh:807
PHP   5. Symfony\Component\ClassLoader\ApcClassLoader->loadClass() /var/www/drupal/core/scripts/run-tests.sh:0
PHP   6. require() /var/www/drupal/vendor/symfony/class-loader/ApcClassLoader.php:114

I'm guessing that I need to help run-tests.sh to find my files, somehow.

Any advice from anyone as to why run-tests.sh behaves differently here from stock phpunit?


texts: Can I find the term depth via $node without resorting to a taxonomy_get_tree or an SQL query?

texts:
I'm trying to find all terms in a vocabulary associated with the current node, that do not have any children.

The most obvious way might be to use taxonomy_get_tree() and match with the returned array to find the childless. Another way is to use a function like this one, and it involves a MySQL query. While my current taxonomy is small and the performance concerns are minimal, I would like to avoid this if this info is already available somewhere.

So, how can I find the depth of a taxonomy term, in a more performance friendly way?


texts: Drupal View 3 / CiviCRM integration - block update depends on user authorization

texts:
All,

In my CiviCRM installation, I support both Individual Contacts and Organization Contacts. For the Drupal site, there is a block based on a view that exposes some information about Organization Contacts. This view is configured with a Global: Random sort criteria in order to expose three different Organization on each page visit.

When I am logged into the site (as an Authenticated User or Administrator), the block works properly. When I am not logged into the site, the block does not update. Just to be clear: When logged in, reloading the same page results in three different Organization Contacts being displayed. When not logged in, the same three Organization Contacts are displayed each time.

The issue seems to be tied to the cache. When I cleared the Drupal caches, the Organization Contacts for the non-logged in user changed (but then remained the same as described above).

Would you please suggest a fix for this problem. Thank you!


texts: It does not work when installed as "subsite"

texts:
I tried to install Drupal 8.03 on a windows 7 64 bit server, with MySQL, Apache and PHP 7.03, using the default install procedure / script.

Drupal is only one of the applications on the website and that is probably different from what Drupal 8 seems to expect.

The website is like https:/www.mysite.nl and overall root folder is x:\myroot\homepage. Drupal, however, is installed in x:\myroot\homepage\drupal and it is supposed to be accessible via https:/www.mysite.nl/drupal.

Back to the installation. To a "certain" extend that seems(!) to work. That will say the install script runs and ends. But than I want to access Drupal and that does not work. I can not access any thing "page missing". Both the base folder and the base url is not what Drupal expects (e.g. Drupal generates https:\www.mysite.nl\xyz where that should be https:\www.mysite.nl\drupal\xyz and I can not change that (at least not from the UI which is not accessible, assuming there is a setting for that).

So drupal seems is completely lost, does not understand what its base url is and does not understand where the files are (both at least the url should be a question during installation!!!!!).

By the way I never really used other drupal versions, but from a last year test install my impression is that this problem did not exist in drupal 7.

I do not know how to solve this. Hope you can help and perhaps initiate a few corrections/extensions in Drupal 8.


texts: separate the page title from page content

texts: I am using {{ page.content }} to print all my page content. It is printing my all content but I want to remove title from this content and print it separately in different div structure (without using  page.content). Currently its taking drupal default structure. Is it possible?


texts: I installed Drupal 7.4 through the interface on GreenGeeks. I am not a developer, more of a web designer/manager. The site installed fine, but when I login with the admin credentials, I am not presented with any admin functionality or options, just a generic view of the site. I tried following other instructions found on drupal.org that suggested resetting the admin password using myphpadmin, which I tried, but received an error message that the users file for my database had not been created. Can anyone offer some suggested solutions?