texts: Two questions that I guess are both a part of one bigger idea. When creating a content type, I've been trying to figure out how to both indent a field and create a line break after a field both by default. For indenting I have tried adding spaces before the field name, but because it's empty space they are disregarded and displayed as normal. For the line break, I've tried adding a custom code field with br or p, and simply adding a blank field, but in both situations as there is no text to display, the field is not displayed at all. Any suggestions?


texts:
I am working on Drupal 8 custom block. I want to print the site name in this custom block.
MyBlock.php
public function build() {
  return [
    '#markup' => t('This is a simple block!'),
  ];
}

How can I get the site name?


texts: Does "composer remove drupal/module" actually uninstall the module first?

texts:
Does composer remove drupal/module actually uninstall the module first,  especially in  multi-site environments?

On the other hand, does composer require "enable" the given module for all sites?


texts: Apache solr search integration at live site

texts:
I have a Drupal site configured to use the Apache Solr module for searching.  I developed it using a local server on my machine.   This works fine once everything is indexed.

I need to make this live, but I have shared hosting, which doesn't support Tomcat.

What can I do in this situation?  Does the Apache Solr module support running the webserver and Solr server on different hosts?


texts:
Possible Duplicate:
  Theming Drupal fatal error messages

Whenever a user upload an image that doesn't match the requirements, Drupal throws an exception.

How can I customize the message, and the style of that page?


texts: How to assign IDs to each radio button in drupal form radios?

texts: I am using drupal form radios, I can use Prefix and Suffix to assign IDs to group, how can I assign different IDs to each radio button inside the radios element? Thanks


texts: How to make main navigation selector sticky?

texts:
I have a page with a main menu and a sub navigation. Now, whenever I click on a menu point in my main menu, the text becomes bold (as long as the main page of the sub menu is selected ) but as soon as I hit a menu point in my sub navigation, the main menu selector (bold text in main menu) disappears. How can I make it sticky throughout all my pages within that certain menu point's sub navigation?

edit 1
Url: http://www.quaaoutlodge.com/


texts:
Configuration view:

As you can see Search API uses site base url as SOLR host which is obviously wrong...


texts:
I have changed my site email address from admin@example.com to team@example.com in config>system>site info.
The emails are sent to user via the new account; however the core emails (such as Subject: New release(s) available for example) on my old email.
Any idea how I might be able to change this.
I understand that there is bug with rules How to change Site Wide email address and get it to work in rules
but is this to do with that?
also I understand that this might be changes through setting.php; however there are no emails accounts listed in my setting.php!
Thanks
PS: I am using the latest version of drupal commons.


texts: Get list of available options in a select field of custom content type

texts:
I created a custom content type called 'slide' that has a custom select field called 'field_category'. I would like to be able to load the available options of 'field_category' into the select field of a block form.

I'm currently attempting to follow the instructions of an answer to a similar question here but I'm still having trouble.

I'm grabbing the content type definitions like so

$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'slide');

However when I spit out

print_r($definitions->getFieldDefinition('field_category'))

I can't actually find any of the options to grab. Is there a way to grab the available options of a field of a custom content type programmatically?


texts: dpm function doesn't display results for arrays

texts:
I need to work over the hook_menu_alter function and I found that the dpm() function is not working for arrays. I have devel and admin_devel enabled. I flushed all cache to make sure the hook is fired.

function MY_MODULE_menu_alter(&$items) {
  dpm('hello'); // This is printed
  dpm($items); //This one is not printed at all
}


texts: How can I have different templates for newly created content?

texts:
I am using Drupal 7 and I need to show a different content for a custom entity depending on if the recently created content is being shown after submitting the form or if I visit the URL afterwards.

Is there a way to have different templates or is there a variable to check that tells you if it's newly created content?

I need this because I'm going to let the user share the page on social networks from that page, and I need to show a different content when people visit it afterwards.


texts: Drupal 7 - Autoslave Master/Slave Failover Issue

texts:
I am using Autoslave (https://drupal.org/project/autoslave) project for implementing mysql high performance and failover. I have successfully setup the mysql master/slave replication at the server and it is working perfectly. With the following settings taken from Autoslave documentation (https://drupal.org/node/1952990) for Master/Slave, I am trying to implement the following use cases:

If Master is up and slave is down, master should entertain all the traffic (working fine)
If Master is down and slave is up, slave should entertain all traffic in readonly mode (NOT WORKING).

With 2, what happens is as soon as the master db is down, the requests to slave also stops. The following are the contents of autoslave-invalidation-default.inc file after i take master db down:

<?php
$databases["default"]["slave"][0]["status"] = FALSE;
$databases["default"]["master"][0]["status"] = FALSE;

Its showing that both servers are down, where as slave is up and running. I tried with manually changing this file and changing slave status to TRUE, and the traffic is then successfully routed to slave.

Following are the relative contents of my settings.php file:

$databases['default']['master'] = array (
  'database' => 'dbname',
  'username' => 'username',
  'password' => 'password',
  'host' => 'master.ip',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',
);

$databases['default']['slave'][] = array (
  'database' => 'database',
  'username' => 'username',
  'password' => 'password',
  'host' => 'slave.ip',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => '',
  'readonly' => TRUE
);

$databases['default']['default'] = array (
  'driver' => 'autoslave',
  'master' => array('master', 'slave'),
  'slave' => array('slave', 'master'),
  'invalidation path' => 'sites/default/files',
  'flag all tables' => TRUE
);

Following is the error shown:

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

Error message

The system is currently in read-only mode. Any changes you make will not be saved!
Warning: mt_rand(): max(0) is smaller than min(1) in DatabaseConnection_autoslave->rand_weighted() (line 1233 of /includes/database/autoslave/database.inc).
Warning: mt_rand(): max(0) is smaller than min(1) in DatabaseConnection_autoslave->rand_weighted() (line 1233 of /includes/database/autoslave/database.inc).
Exception: No master connection has been chosen in DatabaseConnection_autoslave->determineMasterTarget() (line 703 of /includes/database/autoslave/database.inc).

Kindly guide me of the any solutions/suggestions and/or possible reasons why is point 2 not working, where it's suppose to.

Thanks.


texts:
I found that the best way to store a guid is as a char(36) data type for MySQL.
What is the equivalent to char(36) in drupal 7?


texts: Drupal 7 form api > Display part of tree outside tree

texts:
Very hard to explain by title, but this is what I mean:

I have a form which shows packages and their add-ons. A simplified version:

foreach ($packages as $package) {
  $form['package_' . $package->nid] = array(
    '#prefix' => '
',
    '#suffix' => '
',
    '#tree' => TRUE,
  );
  $form['package_' . $package->nid]['select'] = array(
    '#type' => 'radio',
    '#return_value' => 'package_' . $package->nid,
    '#prefix' => '
',
    '#suffix' => '
',
    '#tree' => FALSE,
  );
  $form['package_' . $package->nid]['title'] = array(
    '#prefix' => '
',
    '#markup' => $package->title,
    '#suffix' => '
',
  );
  $form['package_' . $package->nid]['addons'] = array(
    '#type' => 'container',
    '#prefix' => '
',
    '#suffix' => '
',
  );
  foreach ($addons as $addon) {
    $form['package_' . $package->nid]['addons']['addon_' . $addon->nid] = array(
      '#prefix' => '
',
      '#suffix' => '
',
    );
    $form['package_' . $package->nid]['addons']['addon_' . $addon->nid]['select'] = array(
      '#type' => 'checkboxes',
      '#options' => array($addon->nid => $addon->title),
      '#return_value' => 'addon_' . $addon->nid,
      '#prefix' => '
',
      '#suffix' => '
',
      '#tree' => TRUE,
    );
    $form['package_' . $package->nid]['addons']['addon_' . $addon->nid]['title'] = array(
      '#prefix' => '
',
      '#markup' => $addon->title,
      '#suffix' => '
',
    );
  }
}

This results in the following HTML:

...

...

...

      .. second addon .. and so on ..

.. second package .. and so on ..

The problem is that I want the add-ons to be displayed BELOW the package container it belongs to, but still have the values within the tree. So I want:

...

...

...

    .. second addon .. and so on ..

.. second package .. and so on ..

I thought about doing this with CSS first. But it's getting a mess. Second I thought about using jQuery to move the package_addons element. But actually I hope there is a better solution by Drupal / PHP, so I don't have to mess around with CSS or jQuery.

Any thoughts?


texts: Redirect for single page with htaccess file not working when url has spaces

texts:
Im trying to add a redirect to my site from one page to annother using the .htaccess file. From the documentation at http://drupal.org/node/38960 I tried the following but it doesnt appear to do anything. Thanks

# RewriteBase /

#custom redirects (this is where the code ive added begins)

RewriteRule http://mysite.com/one http://mysite.com/two [R=301,L]

#end custom redirects (this is where the code ive added ends)

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


texts: How do I remove outer/container divs from a view?

texts:
I have a view which uses "unformatted list" as it's output format.

...

Now I want these divs to be stripped.

I tried the solution in this answer, but I just want to change the format. I do not want to use Semantic views as that does not help at all in my case.

I manually created a views theme (copying unformatted list) and changing its code as:

<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"';  } ?>>
    <?php print $row; ?>

<?php endforeach; ?>

to:

<?php if (!empty($title)): ?>

<?php print $title; ?>

<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>

<?php print $row; ?>

<?php endforeach; ?>

but that deeply craps out my overall design.

What is the most appropriate and simplest way to do this?


texts:
A product in Drupal Commerce 2 has limited stock. Users can add-to-cart so long as there is a current stock value > 0, and stock is decremented at the order-placed stage. If a second concurrent user passes the order-placed stage first and has used all available stock, when user 2 gets to the order-placed stage I want to take action  (remove item from cart, show a message, do something if no other items in cart..).

I am catching 'commerce_order.place.pre_transition' event, and can manipulate order items, but I'm not sure if I'll mess up other DC processes. Would it be better to have a CheckoutPane plugin to do something pre-placement at/after the Review stage, or something else? The action needs to be taken just pre payment attempt.


texts: Where do I set anonymous checkout without users hit the login page?

texts: After adding an item to the Drupal Commerce cart, I hit the cart review page. Then I click on checkout and I'm hit with the login page, is there a setting where users don't have to login and just checkout anonymously. And if they already have an account on the site their order would be added to their account in reference to their email.


texts:
I use Drupal 7. I have read dozens of questions that revolve around the need to incorporate relationships among tables in Views (even many where the person asking the question phrased it differently, and the person answering the question said "just use Relations in Views").  I have also read various books that nearly always use single tables in example of pulling data from databases. I rarely see any understandable explanation of the use of "relations" in views. What's the point of using a relational database if it is so difficult to use joins? Can anyone shed any light on this? I've read the explanation in Pro Drupal 7 Development, which is arcane at best.

Bruce


texts: "Uncaught TypeError: Cannot read property 'getAttribute' of undefined"

texts:
There are some posts about this error for Drupal 7, but I'm using Drupal 8.1 and those solutions don't work for D8.

I tried this patch (coded for D7) and doesn't work.

The effect of the error is that QuickEdit doesn't work: sometimes the quick edit link doesn't appears, sometimes it appears but when edit some fields I get error.

Can anybody help?

UPDATE for neograph:
I haven't changed anything about the loading of the javascript. The only thing I did is edit the my_theme.libraries.yml for adding JS plugins:

global-css:
  css:
    theme:
      #css/style.css: { }
      dist/css/style.css: { }

global-js:
  js:
    #js/script.js: { }
    bower_components/slick-carousel/slick/slick.min.js: { }
    bower_components/slicknav/dist/jquery.slicknav.min.js: { }
    bower_components/superfish/dist/js/superfish.min.js: { }
    dist/js/script.js: { }
  dependencies:
    - core/jquery


texts: Is there any way to set a node to be shown in 2 menus?

texts:
I have a node "my-node" which I set to be shown in the Main Menu so far so good.

I created another menu: "My Menu".

Is there any way to show my-node in both menu: Main Menu and My Menu

If I edit the node and go under Menu settings it allows me to choose just 1 Parent item


texts: How set a time type field programmatically?

texts:
I create a custom content entity type.

I want one field for the event time.

Since there is no time field, but a dataTime_type, I create a plugin for a custom field :

  FieldType : TimeItem.php

/**
 * Plugin implementation of the 'time' field type.
 *
 * @FieldType(
 *   id = "time",
 *   label = @Translation("Time Field"),
 *   description = @Translation("Permet la creation d'un champ de type time"),
 *   default_widget = "time_widget",
 *   default_formatter = "time_formatter"
 * )
 */

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return array(
        'columns' => array(
            'value' => array(
                'description' => 'The time value.',
                'type' => 'int',
                'length' => 6,
            ),
        ),

    );
  }

I try to change type to time (for mysql) but mysql error return me a null for the type.
So I use int for store time in seconde.

  FieldWidget : TimeWIdget.php

/**
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = isset($items[$delta]->value) ? $items[$delta]->value : '';
$element += array(
'#type' => 'time', //HTML5 input
'#default_value' => $value,
'#size' => 4,
'#element_validate' => array(
array($this, 'validate'),
),
);

return $element;
}

My entity :

 $fields['heure_evenement'] = BaseFieldDefinition::create('time')
        ->setLabel(t('test'))
        ->setDescription(t('test'))
        ->setRequired(TRUE)
        ->setDefaultValue('')
        ->setDisplayOptions('view', array(
            'label' => 'above',
            'type' => 'string',
            'weight' => 3,
        ))
        ->setDisplayOptions('form', array(
            'weight' => 3,
        ))
        ->setDisplayConfigurable('form', TRUE)
        ->setDisplayConfigurable('view', TRUE);

All is working except one thing, the HTML5 input type time

Drupal know some input in html5 but not all... type tel, email, number, range, color, date, datetime is ok but not the type time alone.

So I was hoping get it with a custom plugin, but no...

Edit 1

The only way I have found is to create 2 select for this type :

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = isset($items[$delta]->value) ? $items[$delta]->value : '';

    //heure
    for($i=0;$i<=24;$i++){
        $hour[]=$i;
    }

    //minutes
    for($i=0;$i<=59;$i++){
        $minutes[]=$i;
    }

$element += array('hour'=>array(
    '#title'=>t('Hour'),
    '#type' => 'select',
    '#options'=>$hour,
    '#default_value' => $value,
    '#element_validate' => array(
    array($this, 'validate'),
    ),
)
);

    $element += array('minutes'=>array(
        '#title'=>t('Minutes'),
        '#type' => 'select',
        '#options'=>$minutes,
        '#default_value' => $value,
        '#element_validate' => array(
            array($this, 'validate'),
        ),
    )
    );

return $element;
}

Any idea about this?


texts: Multilingual websites - Hiding site till ready

texts:
I am having basic workflow problem in creating translated website in Drupal 7. A site was handed to me which was already live(lets say www.mywebsite.com). It is having two languages already (English-www.mywebsite.com and Finnish-www.mywebsite.fi).

Now I need to add new language translation(Swedish). www.mywebsite.se already point to old D6 site (www.oldmywebsite.se). Also in language interface(admin/config/regional/language) Swedish domain entered is old one(i.e. www.oldmywebsite.se) to help visitor still access old site.

Question:
So how can I create new Swedish dev site, something like se.www.mywebsite.com which will be hidden from public but I can still work on translations and it will later replace old Swedish site. Which modules to use or what I need to do at Drupal and domain level?

I have not worked on any translation setup before so I am feeling completely lost.
Any help will be appreciated.

Summary :

www.mywebsite.com      :   new English
www.mywebsite.fi       :   new Finnish
www.oldmywebsite.se    :   old Swedish site

se.www.mywebsite.com   :   Want to create dev Swedish site which will later replace old swedish site


texts: Convert Entity embed image drupal-entity tags to image tags for Json API

texts:
When adding image into CKeditor using Entity Embed the source code looks like this,

<drupal-entity data-embed-button="media_browser" data-entity-embed-display="view_mode:media.embedded" data-entity-type="media" data-entity-uuid="2766d77e-6ada-45b2-8706-54e92bcf686d"></drupal-entity>

The html output in Json APi looks like this,

"body": "<drupal-entity data-embed-button=\"media_browser\" data-entity-embed-display=\"view_mode:media.embedded\" data-entity-type=\"media\" data-entity-uuid=\"2766d77e-6ada-45b2-8706-54e92bcf686d\"></drupal-entity>\r\n",

How to ensure the images would be shown in img tags in Json API so other systems like Angular or Mobile apps can readily use it.


texts: How can I programmatically add CiviCRM contacts as Drupal users?

texts: In the process of migrating a Drupal 6 and CiviCRM installation to Drupal 8, the decision was made to host the new D8 CiviCRM instance remotely. I'm now tasked with developing the functionality needed to import contact data into Drupal, as well as events and products, all managed in the CiviCRM instance. My feeling thus far is that it's a mistake to separate the two applications, since we're really now having to develop a lot of custom functionality using the API. Nevertheless, I'm looking for some insights as to how to begin this kind of development, because we've already embarked in this direction.


texts: Where does Feeds cache the source and how do I disable this cache feature?

texts:
I've found out that Feeds caches the sources. Even when I change the content of the source, emptying the imported items and reimport, it imports the old items.

Where does Feeds store this cache and how do I disable this cache feature?

I need to disable this caching feature because I am dealing with sources which change often.


texts:
There is a template file in the quiz/template/quiz-report-form.tpl.php of Quiz module.
this is the code:

<?php

/**
 * @file
 * Themes the question report
 *
 * Available variables:
 * $form - FAPI array
 *
 * All questions are in form[x] where x is an integer.
 * Useful values:
 * $form[x]['question'] - the question as a FAPI array(usually a form field of type "markup")
 * $form[x]['score'] - the users score on the current question.(FAPI array usually of type "markup" or "textfield")
 * $form[x]['max_score'] - the max score for the current question.(FAPI array of type "value")
 * $form[x]['response'] - the users response, usually a FAPI array of type markup.
 * $form[x]['#is_correct'] - If the users response is correct(boolean)
 * $form[x]['#is_evaluated'] - If the users response has been evaluated(boolean)
 */
// $td_classes = array('quiz-report-odd-td', 'quiz-report-even-td');
// $td_class_i = 0;
$p = drupal_get_path('module', 'quiz') .'/theme/';
$q_image = $p. 'question_bg.png';
?>

<?php print t('Question Results');?>

<?php
foreach ($form as $key => $sub_form):
  if (!is_numeric($key) || isset($sub_form['#no_report'])) continue;
  unset($form[$key]);
  $c_class = ($sub_form['#is_evaluated']) ? ($sub_form['#is_correct']) ? 'q-correct' : 'q-wrong' : 'q-waiting';
  $skipped = $sub_form['#is_skipped'] ? ''. t('(skipped)') .'' : ''?>

      <div class="quiz-report-score-container <?php print $c_class?>">

          <?php print t('Score')?>
        <?php print drupal_render($sub_form['score'])?>
        <?php print t('of') .' '. $sub_form['max_score']['#value']?>
        <?php print '
'. $skipped .''?>

<?php print t('Question')?>:

      <?php print drupal_render($sub_form['question']);?>

<?php print t('Response')?>:

    <?php print drupal_render($sub_form['response']); ?>

    <?php print drupal_render($sub_form['answer_feedback']); ?>

<?php endforeach; ?>

<?php print drupal_render_children($form);?>

Now I want to change this codes and I need a function to return the nid(number of id) of quiz that the user is seeing.
please help me.


texts: How to put a Token in a path in a view Path setting?

texts:
I have a view page display to show some content and I added a contextual filter to filter by user id [uid]. It works fine.

I need to create the path to be shown in the Main Menu including the token for user id at the end of the path. Something like /tus-lotes/[uid]

If I try with: /tus-lotes/% I get this error message:

Views cannot create normal menu items for paths with a % in them.

But I see that the path doesn't accept token. How can I accomplish this?

Please look the capture:


texts: How do I change the price of a flat rate shipping fee depending on a type of Product?

texts: I am trying to create a different price for shipping of heavy items. I have light and heavy items and they are categorized via taxonomy heavy/light. How do I change the shipping price via Shipping Rules to detect if its a heavy or light item?


texts: How to make a block only appear for a certain content type?

texts: I have a content type and what I want to do is show a block on the right hand side only if the user is viewing that content type using a custom module. Any general pointers as to where I should start looking?


texts: How can i make my comments field allow images as part of the comment? (drupal 7)

texts: I would like to allow users to put images into their comments but I can't seem to find a module or anyone who has done such a thing.


texts: Show WebForm Block through a link on a Page

texts:
I have a WebForm Survey which I want to show in a page through LightBox.

The LighBox part is all sorted but I am stuck in getting a link to the WebForm Survey.

Here  is what I did:-

Created a WebForm Survey
Made it available as block (It can be seen in Structure>Block as Webform: Self - Assessment Survey)

Now on a Page (About Us), I have a link "Open Survey". What I want to do is, that when this link is clicked, my Survey should open in a LightBox.

I tried doing this
Open Survey, but this never opens my WebForm, and instead shows a 404.

What should I Do?

Many Thanks.


texts:
I'm trying to use this snippet I found, but it throws this error:

function mytheme_init() {
  // Hardcode the administration theme onto the blocks page
  if ($_GET['q'] == 'admin/build/block') {
    global $theme;
    $theme = 'rubik';
  }
}

Fatal error: Unsupported operand types in /var/www/clients/client4/web39/web/modules/block/block.admin.inc on line 39

The $theme = 'rubik'; line appears to be the culprit in some way, as it doesn't throw the error if I comment it.


texts: How to set due date based on number of dates out from event

texts:
I am building a website for planning events. Each event is in its own space to separate groups. These events are planned almost identically. For example Invitations need to be sent out 42 days before every event.
What I would like to do is calculate the due date for tasks based on the event date minus the days before the event the task needs to be completed. I know I can do this by hand but since there are 100ish tasks and about 15 events a year, I would like it to be automated.

Ex.
"A Task" is due 30 days before event date.

Event 1 is April 30 so "A Task" is due April 1
Event 2 is June 30 so "A Task" is due June 1

Any Help would be greatly appreciated.


texts: How to check if view is added in a feature?

texts:
For Drupal views is there any way/field which tells us if your view is added to a feature or not. And if yes in which feature it is added?

I have a view which I need to check if it is added in a feature or not.I have lot of features on my site and I am searching all the features one by one to check if the view is added in any of them. Is there any other efficient way to check this?

Any guidance is appreciated.


texts: How to add text as page variable to node add form? Or in other works print explanation/guideline text

texts:
I want to include my content type's explanation/submission guideline text on node add form/page.

I need to insert it into header element and therefore a variable would be suitable.

I would assume it should already be available on page--node--add--special-content-type.tpl.php but I think it isn't.

Also, this text is automatically appended on the end of the page which is silly and why I wan't to change it.

And to mention following doesn't print it:

  <?php print render($page['help']); ?>


texts: Programatically upload/link images and attatch to Ubercart's product node?

texts:
One of the things my Ubercart module needs to be able to do is programatically upload or link (this being preferred as it means I don't have to mirror it) an image and attach to Ubercart's product node. The user will give me some information, and my module will fill in the name, description, and product image. The product image is a big hurdle which I have no idea how to conquer.

The core Ubercart module product has a dependency on Drupal's core Image module, which is where I'm assuming is handling all the images. I thought I could learn how to do it by looking at the product module's code, but I'm having trouble wading through and understanding the thousands of lines of code. I'm not even sure of any other module that does something similar to what I'm doing, so I'm out of example code.

Does anyone know of a way to accomplish what I'm wanting to accomplish?


texts: How to create a custom content type with a quiz field?

texts: I'm pretty much new to Drupal 8, is there a way of creating a custom content type with a quiz field?


texts: Internet Explorer 11 Overlay does not close

texts:
I am experiencing an issue where the overlay wont close when saving a piece of content. This only happens on Internet Explorer 11. I've tested it on Chrome Firefox and IE 10 and it is working fine.

The problem is when I save content, the overlay modal disappears and I'm left with a grayed out page and cant click or do anything. Also when I save a setting everything saves but I cant exit the modal and if I click another admin link the site forces itself to non-overlay mode. Weird stuff! Anyone ever experience this problem? Again its only on Internet Explorer 11.

I thought it might be jQuery related so I checked every version of jQuery that I use with the jQuery update module and it didn't fix it.


texts:
I have a migration that pulls in a PDF with it and populates a content type. When I rollback the migration, it does not delete the PDFs with it.

How can I tell a migration on rollback to clean up after itself? Is there something I can put in the YAML? Is there an event I can hook into?


texts: Thumbnail generation with nginx reverse proxy

texts:
I'm using nginx as a reverse proxy for a Drupal 7 site running on Apache2.

When I try to view a thumbnail I get the Drupal 404 page saying that the location is not found.

I have implemented the location rules to rewrite requests to the thumbnail to index.php and the error message includes this rewritten request.

These are my nginx location blocks:

location @rewrite {
    rewrite ^/(.*)$ /index.php?q=$1 last;
}

location ~ ^/sites/.*/files/styles/ {
    try_files $uri @rewrite;
}

# Try to serve files with Nginx if possible
location / {
     try_files $uri @proxy;
}

# Pass on php to Apache
location ~* \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    proxy_pass http://127.0.0.1:8000;
    include /etc/nginx/proxy_params;
}

location @proxy {
    proxy_pass              http://127.0.0.1:8000;
    include /etc/nginx/proxy_params;
}

The url of a thumbnail looks like this:

http://example.com/sites/default/files/styles/thumbnail/public/pictures/picture-1-1437996028.jpg?itok=19uLP_Ax

The error message displayed is:

The requested page "/index.php?q=sites/default/files/styles/thumbnail/public/pictures/picture-1-1437996028.jpg&itok=19uLP_Ax" could not be found.

I have tried setting the flag to allow insecure content generation (without a token) to test with.  Obviously I've removed that flag.


texts: How to avoid _0 _1 when editing a media entity and changing the file?

texts:
Say I add an image using the built-in Media module.

A couple months later, I have to change the image file for some reason.  So I edit the media entity, delete the existing file, and upload the new file.  The new file has the same name as the old file.

This creates a new file, filename_0.jpg.  How can I cleanly replace the file without adding a new suffix?


texts: Should I use a 'URL', 'Path', or other form field type when the field is used to define the location that a file should be saved

texts:
I have an administrative form that allows a user to set the save location of a file. I'd imagine that valid locations would be public://foo, private://foo, and /foo/bar/foo. What is the proper form field type to use in this situation, and would this option provide validation or would I have to write it myself?

My initial thought was to use a path field, but I'm not really sure how that would handle public/private paths. Would I need to convert those to routes somehow before passing the value through? I guess I'm also not sure if it's even possible to save a file outside of the public/private folders.


texts: How do I find if a taxonomy term is used?

texts:
I'm using drupal6 taxonomy.The content type 'B' is using a tag field which can use the title of the some of nodes of the content type 'A'.If any node of 'B' tagged a name or title of a node of content type 'A', I want to display one message in the respective node of 'A'.

Alternatively, is there any way to find if www.mysite/category/tag/term doesn't gives the "Page not found" error? This is to find if the term is used, or not.


texts: Trigger a pop-up or recenter in Openlayers (version 7.x-2.0-beta5) from outsite the map

texts:
Is it possible to trigger the pop-up of a marker or center the marker in an Openlayers map through an anchor-tag outside the Openlayers map.

Example:

Create a view that lists some nodes
Click on the title of a node
Recenter the map or open the pop-up of the marker of that node.

I found this solution but they work with an older version of Openlayers and can't get it to work...


texts:
I've implemented this mobile redirection logic but for the past 10 days I've been getting weird behavior(with www version, mobile data is shown sometimes).

Here is Mobile Theme return logic

Also I find different behavior if I uncomment "return 'bartik' in the last line below.

  function mobile_detect_custom_theme() {

        if (strcasecmp(substr($_SERVER['HTTP_HOST'], 0, 2), "m.") == 0)
        {
            return 'mobile_theme';
        }

//return 'bartik'; //IF I uncomment it I find different behavior
    }

In Hook_book I've setup this redirection logic:

//wantdesktop is set if user has specifically selected Desktop version
if (@$_COOKIE['wantdesktop'] == 'true') {
        if (strcasecmp(substr($_SERVER['HTTP_HOST'], 0, 2), "m.") == 0) {

            $url = "http://www.example.com/" . $_SERVER['REQUEST_URI'];

            header('Location: ' . $url, TRUE, 302);
            exit(0);
        }

        return;
    }

//wantmobile is set if user has specifically selected mobile version
      if (@$_COOKIE['wantmobile'] == 'true') {
        if (strcasecmp(substr($_SERVER['HTTP_HOST'], 0, 2), "m.") != 0) {

            $url = "http://m.example.com/" . $_SERVER['REQUEST_URI'];

            header('Location: ' . $url, TRUE, 302);

            exit(0);
        }

        return;
    }

//BROWSER DETECTION LOGIC HERE which fills $browser['ismobiledevice'] with true/false

    if ( $browser['ismobiledevice'] == 'true') {
        //check the current domain
        if (strcasecmp(substr($_SERVER['HTTP_HOST'], 0, 2), "m.") != 0) { //not a mobile url
            $url = "http://m.example.com/" . $_SERVER['REQUEST_URI'];
            header('Location: ' . $url, TRUE, 302);
            exit(0);

        }
    } else { //desktop
        if (strcasecmp(substr($_SERVER['HTTP_HOST'], 0, 2), "m.") == 0) { //is a mobile url

            $url = "http://www.example.com/" . $_SERVER['REQUEST_URI'];
            header('Location: ' . $url, TRUE, 302);
            exit(0);

        }
    }

What is wrong with this logic?


texts: THis module is separate from the devel module that gives ability to dpm() variables etc. What is it?


texts:
In page.tpl.php I'm displaying a link for user page. For an example:

<?php echo l(t("My offers"), 'user/' . $user->uid . '/offers'); ?>

So when a user clicks on the link it goes to user/uid/offers.

Now I want to show this link only based on a role.
Let's say we have a role "Seller" that has unique ID 5 in the database.
How can I set

<?php echo l(t("My offers"), 'user/' . $user->uid . '/offers'); ?>

to be visible only when a user has a role "Seller"?-


texts: Can not access to the nth product's variation ( n > 1) programmatically

texts:
I have a product type called gift with 3 different variations.

I add an attribute to it so that a user can choose a custom variation based on the attribute, attribute (A, B, C).

I also have a custom checkout pane, If a user choose the first variation (by choosing the attribute), i can access the variation that is selected. for example by using 2 lines of code below:

<?php
$variations = $gift->variations->getEntity();
?>

Or

<?php
$gift->variations->target_id
?>

But if a user choose another variations except the first variation (for example: variation B), I can not access to that variation.

<?php
public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
    $pane_form['#order_entity'] = $this->order;

    $order_items = $this->order->getItems();
    /** @var \Drupal\commerce_order\Entity\OrderItem $item */
    $item = $order_items[0];
    $gift = $item->getPurchasedEntity();
    $gift = Product::load($gift->id());

    $variations = $gift->variations->getEntity(); // Just works for first variation
    drupal_set_message('bundle: ' . $variations->bundle());

    // This line of code works for just first variation too
    // $id = $gift->variations->target_id;
}
?>

Regards


texts: What is the benefit of Panels Everywhere

texts:
Several websites advocate the benefits of Panels Everywhere (I have put them at the end of this question).

However, I have tried the module out out and cannot see the benefits.

A regular Panel page gives you the option to Disable Blocks. It also lets you display things like Menu Links, Footers and User Log-ins.
So I'm not sure what Panels Everywhere brings.

I could never see the benefits of Panels, but Drupal Answers enlightened me and now I wouldn't dream of making a Druapl site without it, so I'm hoping it can shed some light on the benefits of Panels Everywhere).

Sites Advocating Panels Everywhere

AWebFactory
Druapl Answers Thread
Lullabot


texts: Drupal 8, "view ui query" to drupal code query api ?

texts:
When we build a view from the view ui, we can show what is the "hard query" is executed, example :

SELECT node__field_house_count_added.field_house_count_added_value AS node__field_house_count_added_field_house_count_added_value, node_field_data.nid AS nid
FROM
{node_field_data} node_field_data
INNER JOIN {node__field_house_tags} node__field_house_tags_value_0 ON node_field_data.nid = node__field_house_tags_value_0.entity_id AND node__field_house_tags_value_0.field_house_tags_target_id = '4'
INNER JOIN {node__field_house_tags} node__field_house_tags_value_1 ON node_field_data.nid = node__field_house_tags_value_1.entity_id AND node__field_house_tags_value_1.field_house_tags_target_id = '5'
INNER JOIN {node__field_house_tags} node__field_house_tags_value_2 ON node_field_data.nid = node__field_house_tags_value_2.entity_id AND node__field_house_tags_value_2.field_house_tags_target_id = '16'
INNER JOIN {node__field_house_tags} node__field_house_tags_value_3 ON node_field_data.nid = node__field_house_tags_value_3.entity_id AND node__field_house_tags_value_3.field_house_tags_target_id = '6'
LEFT JOIN {node__field_house_count_added} node__field_house_count_added ON node_field_data.nid = node__field_house_count_added.entity_id AND (node__field_house_count_added.deleted = '0' AND node__field_house_count_added.langcode = node_field_data.langcode)
WHERE ((( (node__field_house_tags_value_0.field_house_tags_target_id = '4') AND (node__field_house_tags_value_1.field_house_tags_target_id = '5') AND (node__field_house_tags_value_2.field_house_tags_target_id = '16') AND (node__field_house_tags_value_3.field_house_tags_target_id = '6') )))
ORDER BY node__field_house_count_added_field_house_count_added_value DESC
LIMIT 2 OFFSET 0

Is there a way for get quickly the query, but in the query api format ? Like :

$query = db_select('users', 'u')
  ->condition('u.uid', 0, '<>')
  ->fields('u', array('uid', 'name', 'status', 'created', 'access'))
  ->range(0, 50);

Thanks :)


texts: .info file having a name that is different from the name of the theme's folder

texts:
My .info file is prosperpro.info, but my theme's folder is named prosperpro8. I had not realized this difference because the code was working. When I realized this, and tried to changed the .info file back to prosperpro8.info, the code would no longer work.

I thought that the .info file required to have the same name of the theme's folder.

Am I wrong? If they must have the same names, how can I correct it? (Changing the file name will result in code break.)


texts: I have created a views to listing fixtures but i want date filter exposed to users to select date, to filter fixtures respect to that value. I have created a date filter in filter criteria section but it shows only label not showing popup calendar..how can i make it work?Thanks in Advance


texts:
I am using the privatemsg module to send messages and mails with questions about plants. The subject is automatically filled in with the token of a node title, which is always a plantname. They always have 2 single quotes in their names and that is turned into ' when it comes in the subject field of the private message.

What can I do about that?


texts: How do I access $this in a dataProvider method?

texts:
Is it possible to access $this in a PHPUnit BrowserTestBase data provider method to get access to properties defined in the testBase class? It seems that the sequence of processing during startup of the tests means that the properties in my test base class are not available at the dataProvider stage, they are only available after the test function has actually started, and received its first test data parameters. But by this time it is too late and NULL has already been passed as the value.
Example, my TestBase class has
  /**
   * @var string
   */
  protected $valueAsConstant = 'some predefined value';

  /**
   * @var string
   */
  protected $valueInSetup;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();

    $this->valueInSetup = 'value given in setUp method';

  }

The actual test is
  /**
   * @dataProvider dataQuestion()
   */
  public function testQuestion($value) {
  }

  public function dataQuestion() {
    $data = [
      [$this->valueAsConstant],
      [$this->valueInSetup],
    ];
    return $data;
  }

This produces the following (url shortened for ease of reading)
Testing modules/d8testing
Test 'D8testingTest::testQuestion with data set #0 ('some predefined value')' started
Test 'D8testingTest::testQuestion with data set #0 ('some predefined value')' ended
Test 'D8testingTest::testQuestion with data set #1 (null)' started
Test 'D8testingTest::testQuestion with data set #1 (null)' ended


texts: Can "No front page content has been created yet. Add new content" be removed totally?

texts:
I noticed that if there is content placed in the main content block, "No front page content has been created yet. Add new content" will appear on front page or perhaps any page. Most templates will be done in blocks, except node pages.

Can it be totally removed? If yes, how?


texts: How to create a directory during a module install?

texts:
I need to create a directory in public:// when the module is installed via file_prepare_directory(). I used this code in function mymodule_install():

$mydir = 'public://mydir';
file_prepare_directory($mydir, FILE_CREATE_DIRECTORY);`

Upon uninstalling, clear the cache, and installing the module it does not create mydir.


texts: Check for IE8 in theme_preprocess_page function

texts:
I'm trying to use inline svgs for a number of logos and icons, and I was considering adding the inline svg code in a preprocess function. This seems like a good place to check for svg support (namely, whether or not it's IE8) and provide a png if needed.

Are there any native Drupal functions available to check for this in a preprocess function? Or should I instead rely on a regex match using $_SERVER['HTTP_USER_AGENT']?

I tried to search here - https://api.drupal.org/api/drupal/functions - but didn't have any luck, so any suggestions or links to other resources would be much appreciated!

Edit: To clarify on what I mean by 'inline svg code' - I want to use actual <svg> and <path> tags, not <img src="example.svg" /> to allow for greater styling control with CSS.

@AyeshK -
I agree that there are many pitfalls in user-agent and feature detection, mainly related to keeping an up-to-date library of user-agents and features. In this specific case, SVG seems to have broad support moving forward, and I'd like to only serve the png version of images to those few browsers (within our support matrix) who don't support it, avoiding additional HTTP requests for the many browsers that do. The idea of putting this on the server side comes from Adaptive Web Design / Responsive Design on Server Side (RESS).


texts: overlay does not work after enabling my custom module

texts:
I am using latest Drupal 7.

I just noticed my admin overlay is not working.

First I thought its due to Jquery Update contrib module installation however that not it.
 Its apparently due to my custom module, overlay works if I uninstall my module.

My module consists of few basic hooks like hook_menu, hook_form, etc and a simple js file with delete confirm popup code in it.

Also in Home » Administration » Structure » Content types » Basic page, in manage fields tab, 'select a widget' select list (dropdown) shows all options. It is suppose to show options according to field type selected.

$(function() {
 $(document).ready(function () {

  $(".del-link").click(function () {
   var answer = confirm("This action will delete this record?")
    if (answer){ // if yes is clicked on the confirm box.
     var del_record_id = this.id; // get record id that needs to be deleted.
      window.location = "/delete_url/" + del_record_id; // go to url which trigs the delete function and the record is deleted.
    }
  });

  $("#edit-my-form-field").click(function () {
    $("#edit-my-form-field").is(":checked") ? $("#show-hide-div").hide() : $("#show-hide-div").show();
  }); // end of click function.

 }); // end of  $(document).ready(function ().
}); // end of $(function().

Has anyone come across similar issue?


texts: Redirect After User Registration if Referred from Specific URL

texts:
I have been trying to redirect users after filling out the user registration if referred from a specific page on the site with form_alter like so

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

if($form_id == 'user_register_form' && strpos($_SERVER['HTTP_REFERER'],
'/resources/price-sheets') > 0 ) {

    $form_state['redirect'] = 'node/50';

    }
}

If I dpm($form_state) on the user/registration page it shows the $form_state['redirect'] = 'node/50'; as it should. But when I submit the form it redirects me to the home page. I also tried replacing $form_state['redirect'] = 'node/50'; with $_GET['destination'] = 'node/50'; with the same results. I've found a few similar questions, but none of those answers are working for me either, does anyone have a good working solution?


texts:
I'm attempting to add a checkbox to a field settings form in D9. I have the following code:
function my_module_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $element = array();
  print '
HERE
';

  if ($plugin
    ->getPluginId() == 'text_textarea_with_summary') {
    $element['my_setting'] = array(
      '#type' => 'checkbox',
      '#title' => t('test'),
      '#default_value' => $plugin
        ->getThirdPartySetting('my_module', 'my_setting'),
    );
  }
  return $element;
}

I then edit an instance of a body field (admin/structure/types/manage/article/fields/node.article.body), and the hook doesn't fire...no debug text nor stopping at the breakpoint on that same line.


texts: Drupal 7 returning empty array because of the database connection

texts:
I am able to connect to the remote database and fetch the results when I am using core PHP-MySQL connection.

But Drupal 7 returns empty array when I am using the same remote database connection. The local database is working fine.

Below is my database connection in settings.php

$databases['default']['default'] = array (
      'driver' => 'mysql',
      'database' => 'test',
      'username' => 'test',
      'password' => 'test',
      'host' => '*****',
      'port' => '3316',
      'prefix' => '',
);

When I am accessing my site, it is just returning Arrayas output. Is it a problem with my database user permissions or should I make any changes in Drupal database settings with port?


texts: Two-factor authentication with code sent to email

texts:
I'd like to ask you if there are any possibilities of a two-factor authentication with authentication code sent to email. I've found TFA module  which can send an SMS, and according to their documentation, also email:

  The TFA code can be sent out over mobile phone SMS (recommended) or
  via email.

but I haven't found any settings for email, it seems they just provide "API to customize the communication chanel". I've also found Rules module, which could be maybe used combined with other module.

Are there any other possibilites how to do the two-factor authentication with email?


texts: Using node_save to update an existing node saves cached data

texts:
I am using Conditional Actions in Ubercart on Drupal 6 to create a node when a certain product class is purchased.

Everything is firing correctly. I have check and double-checked the code to see what might be wrong and I can't see it. I'm hoping you might know something that will help.

Here is the code:

$spons_node = node_load($sponsorship['sponsorship_nid']);
$spons_node->field_body[0]['value'] = "Online recurring payment added (".date("m-d-Y H:ia", time()).")\n".$spons_node->field_body[0]['value'];
$spons_node->field_sponsor_amount[0]['value'] = number_format($product->price,2);
$spons_node->field_sponsor[0]['uid'] = $order->uid;
$spons_node->field_payment_type[0]['value'] = $order->payment_method;
$spons_node->field_recurrance_type[0]['value'] = str_replace("every","",strtolower(str_replace(" ","",$product->data['attributes']['Donation Frequency'][0])));
$spons_node->field_initial_order_id[0]['value'] = $order->order_id;
$spons_node->field_recurring_item_id[0]['value'] = (int) $new_query['pfid'];
node_save($spons_node);
$message = "Sponsorship for ".$product->title." has been updated.";
uc_order_comment_save($order->order_id, '0', $message, $type='admin', $status = 1, $notify = FALSE);
unset($spons_node);
unset($new_query);
$spons_updated = TRUE;

I used drupal_set_message("
".print_r($spons_node,TRUE)."
");, inserted just before the node_save command, to ensure the node was being built properly. All of the fields were updated correctly.

But something is going on with node_save. My Drupal installation is telling me that the node in question was updated, but none of the changed data is being stored. It looks like it's defaulting to the cached data.

I've also tried using node_load($sponsorship['sponsorship_nid'],NULL, TRUE); to force a cache reload, but that's not working.

Ideas welcome.


texts: Using taxonomy term value as title for the view

texts:
I created a taxonomy, called Galleries for images on the web site:

Our Rooms
Our Food and wines
Our Services

Then I created a gallery for each of the terms, using views. I wanted to override the title of gallery to the term value, as it is shown in this subform for Contextual filters:

But the id of term is used in the url:

http://hotelcentralpark.ro/gallery/1

http://hotelcentralpark.ro/gallery/2

etc

So, instead of words: "Our Rooms", "Our Food and wines" I get "1" and "2", if I check the box "Override title".

How can I show the value of the term instead of it's id? But keep id in the url.


texts: How do I get rid of a staged configuration import?

texts:
I have a staged import that I can't apply and I would like to get rid of it and be clean in my configuration management screen.
How do I get rid of the staged import? Can I go to sync folder and delete the .yml files and the export the current configuration again?
I am extremely nervous about breaking the site.
I know it is saved in the db but I don't want to go in and delete it from there either, unless that is an option.
I wont be able to apply any other import because of this staged one sitting here.


texts: Jquery for form with multiple save/submit buttons

texts:
I have created a form using fields with two action buttons; one for the default submit functionality ('Save'), and the other one for custom submit functionality ('Submit').

When the user clicks the submit button a confirm box is displayed asking the user whether he wants to submit the form or not. If the user selects yes, the custom submit callback for the button should execute.

I am using the jquery-alerts plugin to display a customized confirm box on the click event of 'Submit' button. I used the following jquery code for this

$('#recommendation-letter-node-form #edit-save').click(function() {
  jConfirm("Once you submit the application, you will not be able to modify it any further. Are you sure you want to submit?", "Application Confirmation Dialog", function(confirm) {
    if (confirm) {
      $(this).submit();
    }
  });
  return false;
});

the .submit() function doesn't work for buttons other than default form submit button and I need that the other button submit callback should be triggered when the confirm value is true.


texts: How to build a dynamic hyperlink within a Page (Panels)?

texts:
On a Drupal 7 Site with Panels and Tokens I have a content-type for Events. For the "Page" (Panels) of a Event I like to add a hyperlink / button to add the event to the personal Google Calendar. This requires to build a hyperlink with some query-parameters in it. Eg:

My approach is to create a custom block with "Full Html" and add the above snippet. Then add tokens like [node:title] that should get replaced with the node's title etc. Afterwards I add this block to the Events page (Panels). The problem is that the tokens don't get replaced.

Any idea how I can build this links the most easiest way?

Thanks for help,
Marc

Update:
Got one step forward: I don't use a block but a "Custom Content" pane from Panels. Within this replacement is supported. The problem I now have is that the date/time doesn't get formatted right. I use "date" field-type (Date module). Any idea how I can format that date correctly?


texts:
I have downloaded the Webform Localization module from Drupal.org, but it is not working to translate form, and I want to keep a single webform across all nodes.

How can I do that?


texts: I want hide comment form on node pages but show it in popup when a comment link is clicked.If the user is not logged in, the comment link should display login form. Should i do it inside preprocess function?i am using comment form in panel and hook_page_alter is showing rendered output of the comment form when i dsm it...any tips or help?


texts: What should I do to use a more recent jQuery version?

texts:
I am trying to use this jQuery Bubble script plugin with my Drupal 7 site. The plugin requires Jquery 1.6.2 (Drupal 7 only comes with 1.4.4).

There are some solutions on the net but none seem to work:

jQuery Update: It only updates jQuery to 1.5. There is a sandbox version that will update it to jQuery 1.8, but its too complicated to use.
jQuery Multi: I have installed 1.6.2 using this module; however, my site still loads the default jQuery 1.4.4. Version 1.6.2 does not seem to load.
Using Newer Versions of jQuery: This is a technique for loading multiple jQuery in Drupal 6. Although it works in Drupal 7, my Bubble plugin wont run.

My site is only a simple 1 page webform, so I would be happy if I could supress the default 1.4.4 and then just link to 1.6.


texts: Architechture/ Foundation help for a drupal project

texts:
I am thinking to develop my drupal website for various products like camera, mobile and others.

For this i will have various content types like camera and mobile and others and have term references for feature of products so that it will be helpful in filtering the products.

Now my big problem is here.
1. Each product i.e camera, mobile should have its rating properties like camera will have its own set of rating properties and mobile will have its own rating properties. How do i attach these rating properties to a content type ?
2. When user goes to the product page, He should give ratings for properties and add comment against each property. How ill i do this ?
3. If he has already given ratings and commented on the product it should be default displayed.

Main problem is that how do i attach rating properties to the content type and make user comment on these properties.

If i create separate content types will it be a problem to create a search on all products


texts: modal pop after a user click 3 times in any links on a site

texts:
I am trying to make pop a modal window after a user as click on 3 different links on a site.
I am not too sure how to achieve it.
I am using this JS script to track the click

window.onload = function() {
    var clicked = readCookie('popunder');
    if(clicked == null) {
        clicked = 0;
    }

    if(clicked >= 3) {
        return;
    }

    var allLinks = document.getElementsByTagName("a");
    for(i=0;i<=allLinks.length;i++) {
        allLinks[i].addEventListener("click",countClicks,true);
    }

    function countClicks() {
        if(clicked == 2) {
            popunder(); //something to do
        } else {
            clicked++;
            doCookie('popunder', clicked, 1);
            alert(clicked);
        }
    }

    function popunder() { alert('thats 3 clicks!'); }

    function doCookie(name,value,days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime()+(days*24*60*60*1000));
            var expires = "; expires="+date.toGMTString();
        } else {
            var expires = "";
        }
        document.cookie = name+"="+value+expires+"; path=/";
    }

    function readCookie(name) {
        var readName = name + "=";
        var cSplit = document.cookie.split(';');
        for(var i=0;i < cSplit.length;i++) {
            var sc = cSplit[i];
            while (sc.charAt(0)==' ') sc = sc.substring(1,sc.length);
            if (sc.indexOf(readName) == 0) return sc.substring(readName.length,sc.length);
        }
        return null;
    }
}

I am using ctools on a site to manage modal on a particular links but i don t know how to link this action on a 3rd click, which could be any link.


texts: Aggregation with count that includes empty field values

texts:
I saw other questions regarding the aggregation but i didn't found anything similar to what i need.
I've a view with enabled the aggregation, results are grouped by a field value (a text field) with also the count for that field.
Everything is ok, but i'd like to include also the count for the empty values, and i can't make this thing to work...
Now i've something like

| FIELD VALUE | COUNT |
|-------------|-------|
| value 1     | 10    |
| value 2     | 3     |

And i'd like to have something like

| FIELD VALUE | COUNT |
|-------------|-------|
| value 1     | 10    |
| value 2     | 3     |
| -empty-     | 5     |

Is there any way to achieve this? i tried writing something like "-empty-" in the no results behaviour, but the only thing i manage to have is a line with always the counter to 0, like

| FIELD VALUE | COUNT |
|-------------|-------|
| value 1     | 10    |
| value 2     | 3     |
| -empty-     | 0     |

I really don't know what to try now..
Thanks!


texts: No results behavior not working when using contextual filter with content id from url

texts:
I have a problem displaying the no result behavior.
a view gives me an image depending on what page i am on. So i have setup a contextual filter of "content:nid". When the filter is not validated, i add a default value:"content ID from url".
When i go to the nodes, the image is shown. Nodes who do not have an image should show my default image that i put in the "no result behavior" section.

The problem now is, that the filter does not validate when there is no image and just shows nothing. How do i get my view to show the "no result" ?

Kind regards


texts: Content Type - turn in to Form on front end to be used

texts:
Im fairly new to Drupal.
Coming from Joomla.
I created content type that works flawlesly and now i would like to take that form thats in the admin area and show it on front end for public to fill out.

Is this easely possible or do i need to use the Form API and rebuild the form and some how map to the fields in DB ?

Please let me know whats the best way to go about this.

Thanks In advance


texts: Temporary files directory not fully protected .htaccess

texts:
I've been getting this error on my status page since I updated to 7.24 (I'm on 7.34 now).

I do have my other files directories protected. I just am having a real hard time figuring how to shut this one off. I've checked at admin/config/media/file-system for the temp file directory, and it's set to /tmp. I think that's the default. But I checked /tmp, no file of that name exists, nor is it in my sites/default/files.

Nothing seems to be broken, at least with file manipulation and storage, so it seems like Drupal is handling things fine, I just am not sure where this folder is supposed to be, or if it's supposed to be a physical file, and if not, how can I protect it with a .htaccess file if it's not a physical folder.


texts: Views of Node Revision with Revision Update Date Expose filter

texts:
I have a Views of Node Revision with Revision Update Date Exposed.

Exposed form rendered as "textfield" widget by default, I want to have Date popup calendar instead.


texts: What is the best way to start from scratch?

texts:
I have a drupal 7 instance at work, and one at home. I added content to both sites BEFORE installing the "menu breadcrumbs" module. On my Drupal instance at work the breadcrumbs don't work properly (they are skipping a level etc) while on my drupal instance at home, the same module works perfectly.

I've already tried uninstalling, and then reinstalling the module on my drupal instance at work, but didn't have luck getting it to work. Still skipping the breadcrumbs in between. What is the best way to fix this on my work instance? Should I delete all the content? If so, how? Is this likely to make any difference?


texts: Sort Search API results by taxonomy reference field name (and not TID)

texts:
I have a views index page that when displaying results without a text search I want to display sorted alphabetically by a taxonomy reference fields name. I can get it to sort by this reference field using the Search API Sort module, but it sorts by the term ID instead of based on the term name. I've also tried to do the same using Views sorting but it doesn't work. I tried creating a relationship to the term in Views but it wouldn't let me sort by fields added via that relationship.

Is this possible to do?


texts:
I'm trying to automate the setup of Drupal multi-site installations as much as possible, we're using each multi-site for a separate country so would like the languages localised for each.

Is there a way to programmatically set the default language? It normally defaults to English. For a Spanish multi-site I would like to set it to Spanish.

The default language seems to be set in SelectLanguageForm.php .Since this happens so early on in the installation process, I can't use hook_form_alter() because no modules, profiles, or themes would be loaded at that point.

The default language will be defined basing on the subdomain where Drupal is going to be installed.


texts: $_FILES superglobal array key is not what file.inc expects

texts:
I'm trying to do some custom stuff with a file upload field via the form API. I call to file_save_upload() but it thinks that the upload is empty because it's examining $_FILES['files'] but for some reason, my file is actually in $_FILES['CSV_file'] even when the file I uploaded is not a csv.

How might files superglobal end up with a CSV_file array key?

UPDATE

So apparently the form array

$form['my_menu_csv'] = array(
  '#name' => 'CSV files',
  '#type' => 'file',
  '#title' => t('Choose a CSV file'),
  '#title_display' => 'invisible',
  '#size' => 22,
  '#theme_wrappers' => array(),
  '#weight' => -10,
);

was causing the field to have the following HTML:

<input type="file" id="edit-my-menu-csv" name="CSV file" size="22" class="form-file">

and apparently the files array goes like $_FILES[$name], where $name = whatever the name attribute is in the HTML element. Makes sense! What doesn't make sense is why file_save_upload() expects to only ever encounter $_FILES['files'] but the form API uses a custom field name. Is this a bug in the form API?


texts: Creating a module: form config class invalid?

texts:
I currently have a working module that parses iCal links to events. This part is working. What I am trying to do now is creating a configuration page for my module that allows me to input the link to this iCal file.

I have followed multiple guides and always seem to end at the same spot:

InvalidArgumentException: Class "\Drupal\google_calendar\Form\GoogleCalendarConfigForm" does not exist. in Drupal\Core\DependencyInjection\ClassResolver->getInstanceFromDefinition() (line 24 of /home/vagrant/Sites/gordon/core/lib/Drupal/Core/DependencyInjection/ClassResolver.php).

I'm unsure how to troubleshoot this. I can see in my form file that I have named it GoogleCalendarConfigForm. It's in the /modules/google-calendar/Form folder. What part am I missing?


texts: Views duplicate result if multiple entity reference

texts:
case: I have 2 content types A & B and there is field in B which is entity reference of A and this field can hold multiple values from A "Multiple Values",
so i created view to show records from B and i added some fields from A based on relation i made in the view "Entity Referenced", the problem is i get duplicated result if this field has multiple values even if i checked distinct in the view.

so is there direct way to solve it, or i have to fix it with custom code in custom module ?


texts: For someone who is not a programmer or is starting how can he/she contribute to Drupal.org?

texts:
I have been talking to people who are starting in the university about Drupal. But they are beginners in programming. so they told me how they can contribute to Drupal or being more involved.

What would be the best advice for them to contribute..or how they can start if they have limited program skills? Do you have any advice?


texts:
Can you explain how to use the Views Bulk Operations module, and create a search form for admin content.

search form at admin/content

thanks


texts: Putting new configuration files in module hook_update_N upgrade?

texts:
If I release a new version of a module, and want to include new configuration in the new version (particularly new fields, and updates to views to rely on those fields) by either making Drupal update the config.whatever.yml files, or writing something in hook_update_N() that will install them, how could I do it?  I would want to make sure it only installs the new fields if they don't already exist, since I would want to include the fields' yaml files.

Or, should I require features and use that for adding new fields?

It's confusing to me, because I want to include a config.yml that has the most recent config information, right?  Yet, I want to update anyone already using the module by installing the new fields that they don't have.

EDIT 2:

Okay, no, never mind. Don't use the below code.  I thought it worked, but really the fields were just installed via the yml files when I installed the module.  I don't know why I didn't realize that would happen.  My update function never really ran.  When I retried it the correct way, it failed, because FieldConfigStorage can't be loaded in this way.  I still don't know how to install fields in a way that will create the tables.

EDIT:

The code resulting from Berdir's example:

// Don't forget to include a use-statement if you haven't already:
use Symfony\Component\Yaml\Yaml;

function some_module_update_8101() {
  $message = "";
  if ( !FieldConfig::load('example_field') ){
    $config_path = drupal_get_path('module', 'some_module') . '/config/install/field.field.node.some_node_type.field_example_field.yml';
    $data = Yaml::parse($config_path);
    \Drupal::configFactory()->getEditable('field.field.node.some_node_type.field_example_field')->setData($data)->save(TRUE);
    $message .= "FieldConfig installed for module some_module.\n";
  }
  else {
    $message .= "It didn't work!\n";
  }
  if( !FieldConfigStorage::load('example_field') ){
    $config_path = drupal_get_path('module', 'some_module') . '/config/install/field.storage.node.field_example_field.yml';
    $data = Yaml::parse($config_path);
    \Drupal::configFactory()->getEditable('field.storage.node.field_example_field')->setData($data)->save(TRUE);
    $message .= "FieldConfigStorage installed for module some_module.\n";
  }
  else{
    $message .= "That didn't work either!\n";
  }
  return $message;
}


texts: Gmap won't show infobubbles when clicking markers (with View Module)

texts:
First some information:

Drupal Version - 7.41
GMap Version - 7.x-2.10
Location Version - 7.x-3.7

I'm using the gmap module on a webshop i'm creating.

I made a custom content type for this (gmap) which simply has basic fields + a location field I've added. So far so good.

I've added one of this custom content, with the locations I need added through  the location tab in the options. I've made a view that displays these all of these custom contents (there's only one, but still displays it) which is working fine. The  problem is that, one clicking on the marker, it doesn't show the information while I've set it up to do so.

The issues start when I go to the configuration of my GMap Location. I get these errors

Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).
Warning: htmlspecialchars() expects parameter 1 to be string, object given in check_plain() (line 1571 of /Applications/MAMP/htdocs/kickstarter/includes/bootstrap.inc).

So I'm guessing i'm giving in something which is an object instead of a string, which should be a string in fact. If I scroll down, I notice the that it says "Marker for " but doesn't give any content type after saying just that. I'm assuming that is the error? I'm also getting a few errors in my console

I really have no clue what to do, if i installed the wrong version or if I have some wrong settings somewhere?

Quick edit: using blocks in my regions, not really touching the PHP code I don't think that's a real issue.


texts:
Task section is one of OA section types. But after creating task sections all of users in task section page has permission to create task or changing task assiging person. Are there any solution for creating authority or creating task updating ....?
What is this section page's configuration options?


texts:
Drupal 8.4.x

I have a custom language file I'd like to add to Geshi.

I've gone through the Geshi docs and can't seem to find anything on adding custom languages. But maybe I am just missing that section...

I'd like to figure out the proper way to get custom language files into Geshi. Has anyone accomplished this?

I am using composer, and am wondering if I should look at the proper way to include custom files via composer, or should this be a task completed with a custom module?


texts:
I'm using views in my drupal site and I want to show a popup window containing custom information (the information from the content type I guess) when I click on a view item.

Something really similar to this: http://conference.99u.com/#speakers

Is there an easy way to do this in Drupal? Which is the best module for that?

Thanks you in advance!


texts: Adding filter criteria under Views-Frontpage

texts:
Im watching youtube video #40 in the Drupal 8 Site Building Course.
Instructor is adding a Filter Criteria under Views, then Frontpage. So we click on ADD, then he wants us to search for "Node" and select "Type".
But we can't find "Type" when doing this?
 We are on the version 8.7.1.


texts: Change the email address drupal sends to when a user signs up for my site

texts:
I have a Drupal website, and it sends me emails when someone signs up for my site, but I want to change the email address that drupal sends me emails to because I don't check that email often enough. I keep finding how to change the from address, but not how to change where drupal emails me to.

Thanks!


texts: How do I let users with a certain role add nodes but use the front end theme (not the admin theme)

texts: I have a role that allows users to create nodes themselves. What is the standard practice way to let them add nodes but not see the administration theme (I am using adminimal), and rather use a different theme on the node/add page.


texts: After importing a content type from Features, What's the correct way to manage it?

texts:
I've taken control of a project recently, and I see a workflow I've not used before.

The original developer would create content types on his dev machine; use Features to export the content type's code, and upload that as a module (with related functionality) to the production server. Enabling it, the content type is created.

Now that the content type is created, I'd like to add / adjust / delete field configurations. What's the correct workflow to work with the content type from that point? Once the content type is created, is it part of the db as if I had created it normally through the UI? Can I safely delete the Feature generated content type code? Can I manage fields through the UI, or would I have to fiddle with the Feature generated code?

Thanks!


texts: Oauth_server authenticates but subsequent requests return "True" with 403 Unauthorized status

texts:
I have successfully setup Oauth2 in Drupal 7 and I am able to get token from the Oauth2/token endpoint. I need to implement, Implicit Flow (Client-Side Flow) as this endpoint will be used by client-side Js application. Though I have turned on the Oauth as authentication provider in Services and also enabled it at the resource settings, I am getting the response as below:

[
    true
]

However, this endpoints work when authentication is disabled and used anonymously.

The failed request is below:

Not able to find any further details. I somehow need to use services using Oauth2 as the authentication method.


texts: How do I change status from "Pending" to "Completed"?

texts:
Ubercart is install without any payment gateway. The workflow is to take user orders via out website and payments are handled offline. Once we received payment and shipped the product, we'd like to mark the order as Completed.

Here is the doc:

  When a customer moves from the checkout form to the review order page, a new order is created with their information in the default
  status for the in_checkout state. (By default, this is "In checkout.")
  When a customer completes checkout, the order gets moved from the default in_checkout status to the default status for the post_checkout
  state. (By default, this is "Pending.")
  The rest happens manually by order administrators, but the other two default statuses are "Processing" and "Completed." Processing is
  actually just another status in the post_checkout state while
  Completed is the default status for the completed state.

However, I don't see a status dropdown list or similar UI element for changing an order's status when editing an existing order:

  http://shop.example.com/admin/store/orders/100001/edit

How can I change the status from Pending to Completed?


texts: config-import error: These entities need to be deleted before importing

texts:
I have two Drupal environments with the same system.site:uuid

In the main Drupal I export the configuration with command:

drush config-export deploy -y

In the destination drupal I import the configuration with command:

drush config-import deploy -y

But I have this error

  Entities exist of type Shortcut link and
   Default.
  These entities need to be deleted before importing.

And:

  Unable to install the mytest theme since
  it does not exist.

My test was a test for create subtheme, but then I delete mytest form drupal. And I don't know what it exports now, and, placeholder I don't Know what is it

I followed this article And I have the same issue of this comment


texts: Can I set a status message to be displayed when a user clicks a link?

texts:
Here's my setup:

I have a page about Pineapples.  There is a link to the Pineapples page in the main navigation menu. When a user clicks that link, they go to the page.

I also have a separate link on the homepage to the Pineapples page.  When a user clicks the homepage link, I want to send them to the Pineapples page, but I also want to show a status message with a little more information.

Is there a Drupal-y way to do this?


texts: How to use the Time ago view formatter when you have an end date collected in your date field?

texts:
I have a date field in a content type with a collected "end date" and I want to show the end date in a view with the Time ago view formatter.

The problem is that I don't find where to select the end date only display, like in the date and time formatter. Because when I select the Time ago formatter, I don't see the options for select the end date. So when I go to see the view output the Time ago always use the "start date".


texts: How to use Represenstive Views to display users representative nodes?

texts:
Main view (User entity):
Fields:

(Representative node) Content: Nid
(Representative node) Content: Type
(Representative node) Content: Post date
(Representative node) Content: Title
other fields

Filter criteria:

user roles, user active

Relationships:

User: Representative node

Represantative view (Content based)
Fields:

Content: Nid

Filter criteria:

Content: Type (in Innovation, ...)
Content: Language (= Current user's language)
Content: Promoted to front page (Yes)

Sort:

Content: Post date (desc)

Generated query: http://pastebin.com/cvKD3zzB
Error:

Error message SQLSTATE[HY093]: Invalid parameter number: number of
bound variables does not match number of tokens

Could someone give me any advice?


texts: How does the tmp folder work? It stores lots of junk files and takes space

texts:
My tmp folder is set to /sites/default/files/tmp/ and I checked what's inside and for example there is folder inside called /update-cache-b2903cc4/ it keeps all modules in .zip that I installed via 'Install from a URL'. So why are those modules .zip files are kept there in tmp folder, isn't it a waste of storage? I don't really like it when the site is full of unnecessary files.

Am I supposed to delete these by myself all the time?


texts: Is there some module which detects untranslated strings?

texts:
I am using the Admin en/admin/config/regional/translate/translate tab to translate strings of a multilanguage site.

As I have quite a few languages (9), and collaborators send the translated texts in Excel, and I enter manually the strings, I was wondering if there is some way (via options, contributed modules, etc.) of detecting untranslated strings, so I could avoid reviewing different Excels sent, and could collect in a fast and easy way those original strings (English) which do not have a translation in a given language.

I understand that Drupal should go through all the files in which a t() appears, but maybe some module does do exactly that?


texts: Why are store translation files stored in the database?

texts:
I have set up a fresh minimal Drupal 7 site. When I add 2 more language files e.g. French and German the database increases up to 3MB.

Why does Drupal store translation files to the database? What about performance? Wouldn’t it be much faster to load language files from the file system?


texts: Taxonomy is not selected after imported csv data from phpMyadmin

texts:
I created Taxonomies and assign them on Page field with radio buttons and "unlimited" number of values. Meaning each node can have more than 1 taxonomy. And these taxonomy fields did show on "add content" or "edit" content, which is right. So, I was trying to mapping these taxonomy with pages by phpMyadmin. Imported CSV data into "taxonomy_index" table(just like the way they listed), and these pages did show under each taxonomy term. However, when I try to edit these nodes, these taxonomies are NOT selected. Am I missing something?

here is my csv file should look -

"166","61","0","1276016485"
"166","53","0","1276016485"
"170","53","0","1276016485"
"170","51","0","1276016485"


texts: Can't declare uniquely named class.. because it's "in use"

texts:
I'm trying to figure out how to make a processor for facets in Drupal 8.3. I've got this, but I have a couple issues. The first is a fatal error I get after activating the module, and navigating to a page with the facet on it:

Fatal error: Cannot declare class Drupal\facets_change_labels\Plugin\facets\processor\transform_labels, because the name is already in use in Drupal/modules/custom/facet_change_labels/src/Plugin/facets/processor/TransformLabels.php on line 22

It doesn't make sense, because this is the only place in the entire site that transform_labels or transformLabels is used. As an experiment, I changed the function to a completely random name, and the issue persisted.

What am I missing, or not understanding?

The code:

<?php

namespace Drupal\facets_change_labels\Plugin\facets\processor;

use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;

/**
 * Provides a processor for transforming labels.
 *
 * @FacetsProcessor(
 *   id = "transform_labels",
 *   label = @Translation("Transform labels"),
 *   description = @Translation("Transform labels"),
 *   stages = {
 *     "build" = 35
 *   }
 * )
 */
class transform_labels extends ProcessorPluginBase implements BuildProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function build(FacetInterface $facet, array $results) {
    $config = $this->getConfiguration();

    /** @var \Drupal\facets\Result\Result $result */
    foreach ($results as $result) {
      if ($result->getRawValue() == 'shape') {
        $result->setDisplayValue("leaf shape");
      }
      elseif ($result->getRawValue() == 'type') {
        $result->setDisplayValue("leaf type");
      }
      elseif ($result->getRawValue() == 'color') {
        $result->setDisplayValue("leaf color");
      }
    }

    return $results;
  }
}


texts: How to break up long words in a views display?

texts:
I have a "related discussion" block view. Long words like links are breaking my layout.

Is there a way to force line breaks on those long words?

I could limit the length of links that then they wouldn't be as useful.

Update:
Turns out that the CSS doesn't work across all browsers and also wraps regular words in funny ways sometimes.

Is there a way to do this in Drupal?


texts: Prefill taxonomy term reference field while in term page

texts:
I have a content type A with a required term reference field (vocabulary: category, widget: radios). I would like to accomplish the following:

In every term page (of this specific vobaulary) i will have an "add type A" link.
When the node/add form appears (upon clicking on this link) i want the value of taxonomy term reference field to already be chosen as the category term which corresponds to the specific term page. Ideally i would like the above and also to dissapear this field from the form.

Any help?


texts: Update Drupal Nodes fields from Gatsby JS using JSON:API (Drupal 8)

texts:
I am trying to update a nodes fields from JS code within Gatsby using HTTP PATCH and I have run into many different issues such as CORs and I was hoping somebody here could point me to a working example. Also note that I did enable patching on the JSON:API module with Drupal. The exact objective is when I check a checkbox on the table within Gatsby it also updates the field within Drupal for the node. Here is my current code:
x.open("PATCH",proxyurl + url);
x.setRequestHeader("Accept" ,"application/vnd.api+json");
x.setRequestHeader("Content-Type" ,"application/vnd.api+json");
x.send(value_of_checked);


texts: Sorting non-english characters in multilingual website

texts:
I'm having an issue with finding good approach to make sorting works
  in a Drupal Views.

  I've multilingual website (1 database for all languages). Few
  languages are sorted wrong.

  I've read that the real issue is on database layer, however I can't set
  any specific encoding there, since database contains many different
  languages.

  What would be the most correct approach to make sorting works?
  The minimum I need atm is a sorting in a Drupal Views.

Any good approach of solving such issues?


texts: When is the filter value available to a context filter in a view?

texts:
There is very odd negative grammer for setting up Context filters in views.

I set a context filter to take a value from the URL (perhaps context filters are primarily for something else?)

However when I go to set it up I need to put my details into the field labelled

WHEN THE FILTER VALUE IS NOT AVAILABLE

This seems very odd to me, could someone explain to me When the filter is available?

I may not be making any sense but then again neither does that page!


texts: Problem using entity reference to show links to content types associated with a content type

texts:
I have a content type called module and a content type called lesson.  Module can contain unlimited lessons.

I installed entity and entity reference module.
In module, I created a field type of entity reference and set target to node, entity selection to simple and lesson.
I saved these settings and found I now have select box which allows me to add select lessons when I edit a module type.

However, when I go to the module page I don't see any lessons or even a label for lessons.

Does anyone have any idea how I can troubleshoot this, or what might be wrong?  Also, would i be better trying to create a view rather than using entity selection simple mode?

Thanks in advance,


texts:
I'm trying to implement bonus calculation system to my website. It should calculate bonuses for users.

This is how it should work:

User1 can get 2% bonus
User2 has for example 100 points
The bonus for User1 is calculated as User2 points * User1 bonus % * level x%

There are different levels of bonuses.

Level1 x% bonus: User1 gets amount x% of bonus from three users who have registered after User1. So User1 gets bonus from User2, User3 and User4.
Level2 y% bonus: User1 gets amount y% of bonus from nine who have registered after User1, User2, User3 and User4. Like this: User1 gets bonus from User5, User6, User7, User8, User9, User10, User11 and User 12.

There are 9 levels and it continues like explained above. Users are multiplicated by 3 so users where User1 gets bonuses are: 3, 9, 27, 81.. etc.

Any ideas how to implement bonus calculation? I was thinking about using the Rules module, but I am not sure how it can handle this. Does performance suffer, if there are ten of thousands or even more users?

The Userpoints module will be used.


texts: Copy nodes of content type into Commerce Products

texts:
I currently have a Drupal website for an art gallery with a content type of Listing (A piece of Art work). Each Listing has a price in a decimal field type.

We are now looking to convert the website to ecommerce using Drupal Commerce, but there is about 500 Listings.

Is there a way to bulk copy/create all the Listings into Products and auto create the product reference and copy the price over as well?


texts:
I need to switch my theme based on the users screen size instead of their user agent. Currently I'm using the Browscap & Mobile Switch modules and they work perfectly. My problem is that for tablets, I want users to use the desktop site. For mobile phones or anything under a 7 inch tablet, I want users to use my mobile site. What modules can help me with this OR how can I create the switch based off screen size?

UPDATE: I've just found ThemeKey. Anyone know if using this in conjunction with Browscap/Mobile Switch will cause issues?


texts: I got a view listing nodes of the content type "Job". Every node is tagged with different "Jobtypes" that are listed too. Now I want to style every taxonomy different (colors, icons, etc.) so it would be nice, every taxonomy would have his own class. At the moment I don't see a way to do this. Some ideas? Thank you!


texts: How can I retrieve the current node ID on a custom route?

texts:
I have a new route and the yml file looks like this:

rsvplist.form:
  path: '/rsvplist'
  defaults:
    _form: '\Drupal\rsvplist\Form\RSVPForm'
    _title: 'RSVP to this Event'
  requirements:
    _permission: 'access content'

From the module root directory, I have src/Form/RSVPForm.php, and inside is where I have the build form function that looks like the following:

public function buildForm(array $form, FormStateInterface $form_state) {
    $node = \Drupal::routeMatch()->getParameter('node');
    $nid = $node->nid->value;

    $form['email'] = [
        '#title' => t('Email Address'),
        '#type' => 'textfield',
        '#size' => 25,
        '#description' => t('We will send updates to the email you provide.'),
        '#required' => TRUE,
    ];

    $form['submit'] = [
        '#type' => 'submit',
        '#value' => t('RSVP'),
    ];

    return $form;
}

When I clear the site cache and refresh the page: mylocal.com/rsvplist, I see the following error:

Notice: Trying to get property 'nid' of non-object

I initially used the following code to get the node

$node = \Drupal::routeMatch()->getParameter('node');
$nid = $node->nid->value;

If I change the last piece of code to this:

$nid = $node->id();

I see the following error:

Error: Call to a member function id() on null

How can I get the node id when am on the new route?

Reference here


texts: How to set roles of drupal "and" with each other?

texts:
I need to show a block to users who have multiple roles. For example: accountant and employee.
I do not want to use permissions. I need a simple solution.

is there anyone who can direct me?


texts: How to translate only the interface back to English?

texts: My site default language is Hebrew (RTL), the problem is that it's all the site, and I want my sites admin-interface to be in English (American). how could I re-translate it to English?


texts: How to fetch/load a node form using jquery/ajax?

texts:
In my previous question, I asked on how to fetch views blocks, now I would like to do the same with the node form but somehow this is the code that almost worked for me:

setTimeout(function(){
  $('.custom-form').load('?q=node/add/custom #custom-node-form', function() {
    Drupal.attachBehaviors();
  });
}, 1000);

The ajax/jquery of the form doesn't work anymore, for example: date field - popup calendar, unlimited field.

I also tried this:

setTimeout(function(){
    $('.custom-form').load('?q=node/add/custom #custom-node-form', function() {
         Drupal.attachBehaviors($('#custom-node-form'));

      });
    }, 1000);

still not working.

Are there other ways to load the node form with all it's ajax/jquery settings?

I'm using this kind of approach because I have a super long form. When I try to print it on the template or on the regions/blocks, it affects the load speed. I don't want this to be part of the page load.

UPDATE:
I'm also trying to load the formblock module using the method I used on the ajax views as an alternative, I also can't get it to work.

Thank you.


texts:
I allready download gmap, location and some other modules that in this catagory and still I dont succeed to add a field in gmap type to my webform page so users could put it their location (not in the register of the users, in the form that I build!

How do I do it? I saw this:
https://drupal.org/project/webform_gmap
but it's for Drupal 6 and I'm using 7.


texts: Print diferent site logo depending on the language

texts:
I have two logo. One logo for ENG and one logo for another language.

How to print diferent logo on page depending on the language?

Does I need to put some if function who would checks language or there is some easier way?

Below is my code for printing logo in Drupal 8 with Twig.

function acton_preprocess_page(&$variables) {
      $variables['logopath'] = '/' . drupal_get_path('theme','acton') . '/logo-eng.png';
    }

In my Twig template, I do this:

<img class="img-responsive" src="{{ logopath }}" />


texts: Page manager selection rules for a variant for the front page

texts:
I'm trying to make a Ctools page variant for the front page but I'm not sure of the of the selection rules I need to use to make it apply to the front page.   I've tried making it apply to everything BUT any of the existing content types but that didn't work.

Does anyone know of a set of selection rules that can let me target the front page?

Thanks


texts: Migration script to move data (user accounts, roles) FROM Drupal 6 to Drupal 7

texts: I need to write a migration script to move the data from Drupal 6 to Drupal 7. I only need to move user accounts and roles.


texts: show/hide field based on user's attribute

texts:
how do I show/hide field of the form based on currently logged in user's field?
my users' profiles have start_date_field.

my form has 5 questions:

day_1_activity -> drop down
day_2_activity -> drop down
day_3_activity -> drop down
day_4_activity -> drop down
day_5_activity -> drop down

Now I would like to do a simple comparison:

start_date_field of logged in user with current_date.

if start_date_field = current_date show day_1_activity only.

if start_date_field + 1 = current_date show day_1_activity and day_2_activity only.

...


texts: How to insert html inside form element div

texts:
I want to enhance the login form fields with icons from Font Awesome. For this I need to add some html inside the div of the name and pass fields (to be able to position accurately with css). The html part is for example something like

I tried using #suffix with hook_form_alter, but then the html is added after the div. I also tried with a user-login.tpl.php, but it seems you can only render individual form elements with drupal_render, for example drupal_render($form['name']); But this also outputs the entire div.

What I want to end up with is something like this:

  <input id="edit-pass" class="form-text required" type="password" maxlength="128" size="60" name="pass" placeholder="Password">

I'm using Drupal 7.


texts: What are the minimum requirements for a custom Drupal 8 theme that can be enabled

texts:
I'm testing creating new themes in Drupal 8 and I'd like to know the very minimum it takes to create one that can be enabled. I'm not worried about any actual styling yet.

I've created a theme folder in themes called uktheme and I currently have a uktheme.info.yml file in that folder.

the contents of that file are

name: UK Theme
type: theme
description: 'Test theme'
package: Core

regions:
  header: Header
  primary_menu: 'Primary Menu'
  feature: 'Feature'
  content: 'Content'
  page_bottom: 'Page Bottom'
  footer_first: 'Footer first'
  footer_second: 'Footer second'
  footer_third: 'Footer third'

However I receive

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

when attempting to go into the appearance settings. I do not believe it's my folder structure and location because I successfully created another theme copying the content of Bartik.


texts: Sharing sets of fields among content types?

texts:
I know it's possible (and often recommended) to re-use fields across multiple content types, if those fields do indeed do the same thing.

I'm wondering if it's possible to re-use "sets" of fields: say you have 10 content types, all of which use the same 8 fields at the beginning (eg. title, description, cover image, author...), and then go on to each have their own fields afterwards. It would make sense to be able to say "fields A,B,C,D,E,F,G,H are re-used in the same order in content types 1 through 10", and only have to specify their characteristics in one spot, instead of adding each field (even if it's a shared field) to each content type separately.

I imagine this is possible with a field collection, but this doesn't seem to be the best solution:

the fields aren't semantically linked to each other other than being common to all node types
problems could arise if one of the shared fields is a field collection itself

Is there another solution to this?


texts: Ask users what menu they want while drupal is being installed

texts: I am working on installation profile. I wanted to give user choice to choose what menu items he wants like home, about us and another. Is this possible ?