texts: Moving from custom CMS to Drupal and need to keep a myriad of old mod_rewrites

texts:
I am moving content from an existing custom built CMS into Drupal 7. There is a host of mod_rewrite rules in place. These rules expand path names in the URL. For example, the rule below effectively expands

RewriteRule ^abc/?(.*)$     /alpha/beta/confusion/$1 [L,R]

Ideally we'd like put these rules inside of /etc/httpd/conf.d/old_redirects.conf. However, the clean URL rules are in .htaccess and are processed first.

Can I remove dependence on .htaccess and move these rules to /etc/httpd/conf/httpd.conf thereby allowing me to import the old_redirects.conf into the httpd.conf file before the Clean URL set of rewrites executes?

(I've referenced the following question How do I use .htaccess to trigger mod_rewrites before D7's Clean URLs take over? and Drupal 7 .htaccess redirects; and while good, they don't quite cover this from the perspective the a need.)


texts: How to get user id of order from order entity metadata wrapper

texts:
I am implementing hook_commerce_cart_line_item_refresh(). It will be receiving line item and entity metadata wrapper for the commerce order.

How can I get user id of order from its metadata wrapper without loading user object like this

$uid = $order_wrapper->owner->value()->uid

With above line it will be loading user object. I would like to avoid loading user object and simply take uid directly.

Following line does not work:

$uid = $order_wrapper->uid;

Or should I think of loading order object? As it might be already in static cache.

Thanks


texts: How to add item to $vars[breadcrumb] in Drupal

texts:
The current breadcrumb only shows 'home'. I would like to update it so it shows 'home>shoes>Tennis Shoe' where 'shoes' is referenced content type(product display) and 'Tennis shoes' the instance(node) title of that content type

Here is how i tried to accomplish this.

I would push additional items(shoes, tennis shoe) into vars[breadcrumb] at page level(theme_preprocess_page) as following:

function THEME_preprocess_page(&$vars, $hook) {
...
$vars['breadcrumb'][] = 'shoes';
$vars['breadcrumb'][] = 'Tennis Shoe';
...
}

And then let my theme_breadcrumb() handle it as it walks through the array:

function THEME_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {
        $breadcrumbs = '
';
        $count = count($breadcrumb) - 1;
        foreach ($breadcrumb as $key => $value) {
            if ($count != $key) {
                $breadcrumbs .= '
' . $value . '/
';
            }
            else{
                $breadcrumbs .= '
' . $value . '
';
            }
        }
        $breadcrumbs .= '
';
        return $breadcrumbs;
    }
}

This doesn't work. Whenever I add the items to the vars['breadcrumb'] in the preprocessor function as showed above, it never goes to 'THEME_breadcrumb', instead displays 'array' text. (apparently, it expects non array at vars['breadcrumb']) How do you manipulate breadcrumbs? Whats wrong with my reasoning? Thank You

Drupal 7, base of boostrap theme


texts: Help getting node resources filter criteria exposed using services views modules

texts:
I am setting up an API using Drupal 7, Services module and services views module. I have got this largely set up and working fine.

I have also installed the module: Node Resources (https://www.drupal.org/project/references) which allows me to associate one node with another. For example, I have a content type called 'Companies' and content type called 'Metrics'. I have added a company node called 'Joe Bloggs Ltd' and have added a metric node 'Employees'. When I set up the metric node I selected 'Joe Bloggs Ltd' from the dropdown.

I have set up a service using service module and service-views (configured fields) to show a list of metrics when I hit: http://example.com/api/metrics/ I get the following:

<result is_array="true">
    <item>
        <title>Employees</title>
        <nid>19</nid>
        <metric>10,000</metric>
        <node is_array="true">
            <item>Joe Bloggs Ltd</item>
        </node>
    </item>
    <item>
        <title>Employees</title>
        <nid>2000</nid>
        <metric>20,000</metric>
        <node is_array="true">
            <item>Geoff Bills Ltd</item>
        </node>
    </item>
</result>

So far so good - however I want to be able to filter these records by the company node. (To be able to go to : /api/metrics/?company=Joe Bloggs Ltd

I thought this would be straight forward as I've done it with taxonomies etc straight forward. I added the Node (field_metric_node) to the 'Filter Criteria Section' and opened it up for exposure as follows:

I set the arg value to be 'company'

And end up with something like this

However when I go to the api endpoint and send the parameter ?company=Joe Bloggs Ltd

I get a blank XML returned.

Any ideas?


texts: Passing a variable content to a modal dialog

texts:
I have a iFrame with a embedded Youtube video on it. When the user click in a button while the video is playing I want to open a modal window where the user can enter some note related to the video position.
I have checked popup, popup_forms, and ctools. ctools appear to be the most useful to me.

I want to open modal dialog from my button (not the generated ctools link), and I need to pass a variable to my form from my jquery button.  Is it possible?


texts:
One of my content editors reported having trouble editing

However, I have allowed this group to edit any content of this node type.

I'm not seeing any separate permissions for fields. How might I over come this?


texts:
I am getting a WSOD after attempting to uninstall the Drupal Commerce module on Drupal 8.1.1 Has anyone seen this error before, and possibly point me a direction? Lost trying to fix this.

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The "commerce_product" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 125 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).


texts: How can I display nodes in a view both by title and by a short title

texts:
I am building a site where I need to display a list of diseases in a view, and I need to be able to display them both by their titles and by another field (an abbreviated title). The two fields need to display as if they were two separate nodes both linking back to the same node though.

For example: My users need to be able to find the "Immunosuppressive Drugs - Organ Transplantation" disease in my view under "Immunosuppressive Drugs - Organ Transplantation" and under "Organ Transplantation - Immunosuppressive Drugs".

When I have tried to just show the abbreviated_title field as well, I get the title and the abbreviated_title showing together when I need them to display as two separate nodes.
Does anyone know how I could do that?

Here are pics:
I need this node

To show up here
and here
when I click on the appropriate letters in this search box.
So it is the same node, but needs to show up two separate times in the view


texts:
I have an eform printing out some fields. I want to create a module to change layout of the eform using hook_theme(). So, I have hook_theme() in my mymodule.module file and mymodule-form.html.twig file in template folder. Since I'm testing it, I only want to print out one field. But it prints out all of the field which seems like hook_theme() or twig is not working. Here's my code.

mymodule.module

<?php

/**
  * Implements hook_theme()
  */
function gq_theme($existing, $type, $theme, $path) {
 return array(
    'gq_form' => array(
      'variables' => array(
        'first_name_field' => $form['field_first_name'],
      ),
    ),
  );
}

/**
 * Prepares variables for the gq form template.
 *
 * Default template: gq-form.html.twig.
 */
function template_preprocess_gq_form(&$variables) {
  $variables['first_name_field'] = $form['field_first_name'];
}

mymodule.html.twig

{{ first_name_field }}

Also, I only have two files, mymodule.module, mymodule.info,yml, templates/mymodule-form.html.twig in module directory. Are there some necessary files?


texts:
I have created a custom theme in Drupal. When the code runs on the server jQuery is not being added to the page so I am getting errors such as:

'jQuery' is undefined

I thought jQuery was updated to the page automatically? How can I go about seeing why jQUery has not been added?

Update
The code works on my local machine but not the test server.

The two missing files are:

  <script type="text/javascript" src="http://localhost:2013/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://localhost:2013/misc/jquery.once.js?v=1.2"></script>

When I pull the code from the server and restore locally I get the same problem. If I run drush cc all then it starts working again and the script reference appears.

The header section of my contains the following scripts:

<script type="text/javascript" src="http://mysite.com/misc/drupal.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/misc/jquery.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/misc/jquery.once.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/sites/default/files/languages/nl_c9aC92_wtuULa79-hTFcGPM53oqk1yKwciOa_Q3yO28.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/sites/all/modules/lang_dropdown/msdropdown/jquery.dd.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/sites/all/modules/lang_dropdown/lang_dropdown.js?mqdxrf"></script>
<script type="text/javascript" src="http://mysite.com/sites/all/modules/devel/devel_krumo_path.js?mqdxrf"></script>


texts: How to get notified when a user is locked?

texts: After 5 unsuccessful logins, a user gets locked. How can I get notified? I tried with the Rules module without success.


texts: I have a content type let's say content type 'A', I am using view to show some of the field on some page, Now the problem is that pages generated by the content type are just a junk because I am not showing it to uses , only i am showing it using view page/block. Problem: I don't want to show those junk page in Search result  , Plz let me know how to do it?


texts: Cache clearing takes too long: What can I do to improve it?

texts:
Everytime I clear all the caches, the process takes too long. This is from the log to a prod site I am currently working with.

  368829 | [someuser] | dbname | Query | 3376 | updating | DELETE FROM cache_page WHERE expire != 0 AND expire <= 1370891317

As you can see, it was executing for 3376 seconds. I am wondering if this is a known issue, or it is simply because there is just too much in that table.

Also, is there anything I can do to improve this?


texts: How do I select a certain View Mode for user edit page?

texts:
I am looking to create a paged user registration process but I would like the user edit page to be as normal.

I have tried Multi Step Registration, but there is compatibility issues with LoginToboggan.

I was thinking of using Field Group to create the pages for the registration, but I do not want the user edit page to use these Field Grouped pages as well. If I could create a custom View Mode where 1 would be for User Registration and 1 would be for User Edit, I think this would solve my problem.

I would use Entity View Modes to create the additional view mode, but how do I set the view mode for the User Edit page?


texts: Having problems with file_copy in Drupal 7

texts:
In my particular situation I am trying to use Drupal's API to import a bunch of files from my computer into a local Drupal installation.  Seems like a smart idea.  So I have the following function:

  function create_picture_file($filepath, $public_place) {
    global $pic_basepath;
    $filepath = "$pic_basepath/$filepath";
    $file = new stdClass();
    $file->filename = basename($filepath);
    $file->filepath = $filepath;
    $file->filemime = file_get_mimetype($filepath);
    $file->filesize = filesize($filepath);
    $file->uid = 1;
    $file->status = FILE_STATUS_PERMANENT;
    $file->uri = $filepath;
    $file->display = 1;
    $file->description = '';
    print_r($file);
    $file = file_copy($file,"public://$public_place",FILE_EXISTS_REPLACE);
    print_r($file);
    return $file;
  }

You'll notice the two print_r statements towards the bottom.  The first one prints the following:

stdClass Object
(
    [filename] => Arctic_HE0302_Central_bathy.jpg
    [filepath] => /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [filemime] => image/jpeg
    [filesize] => 516130
    [uid] => 1
    [status] => 1
    [uri] => /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [display] => 1
    [description] =>
)

Which looks good.  The second one, however, print's absolutely nothing.  Any pointers or tips as to what I'm doing wrong maybe?

UPDATE
So the public file directory to which this image is being saved in is region_images.  When this directory exists, nothing get's printed by the second print_r statement.  When I remove the directory and all of it's associated style directories, the second print_r statement prints.  However, it prints the following:

stdClass Object
(
    [filename] => region_images
    [filepath] => /home/lpeabody/unclos_data/pics/Arctic_HE0302_Central_bathy.jpg
    [filemime] => image/jpeg
    [filesize] => 516130
    [uid] => 1
    [status] => 1
    [uri] => public://region_images
    [display] => 1
    [description] =>
    [fid] => 2595
    [timestamp] => 1331828075
)

Which is wrong, as [filename] should be Arctic_HE0302_Central_bathy.jpg.  Hopefully this can help shed some light on the situation.


texts:
After having to restore from database twice b/c of a bug in the qtip module and extreme lack of documentation, I decided to implement the tooltips programmatically and completely bypass the qtip module.

I used js injector to add the js script to every page (footer).

I edited my theme's template.php file to as to include jquery.qtip.min.js and jquery.qtip.min.css (viewed source of page and verified loading)

Under Devel Settings I selected rebuild theme registry every pageload.

But I still get a rather odd problem:

In my JS Fiddle the code works as it should and the tooltips display properly.

However, when I view the same exact code in my drupal site only the speech bubble callout and part of the tooltip displays, not html content at all displays (doesn't work with basic text either).

I had to add a little bit of js to get the original script to work in Drupal, but I use the same script to execute bootstrap tooltips flawlessly.

Here's what's in JS Injector:

! function ($) {
$(function () {
    // Grab all elements with the class "hasTooltip"
    $('.hasTooltip').each(function () { // Notice the .each() loop, discussed below
        $(this).qtip({
            content: {
                text: $(this).next('div') // Use the "div" element next to this for the content
            }
        });
    });
 });
}(window.jQuery)

Here is the JS Fiddle

Is there something I am missing?


texts: How to pass contextual id value from one view page to another through Drupal menuing system

texts:
I use a view to display a list of books.
The view has three pages: /books/title, /books/date, and /books/popularity.
The pages are essentially the same with different sort criteria.
The pages use a contextual filter to select books by topic based on a taxonomy.
The contextual filter is set to use the query parameter topic when the filter value is not in the URL.
Each page of the view includes a Drupal menu block with the items "By Title", "By Date", and "By Popularity" and links /books/title, /books/date, and /books/popularity.
If I invoke /books/title?topic=5 (where 5 is the tid for the "health" topic)

A list of health books is correctly displayed.
The "By Title" <li> element in the menu is given the active and active-trail classes by the menuing system (which allows the use of CSS to highlight the active menu entry on-screen).

When I'm at /books/title?topic=5 and click the "By Date" menu entry, /books/date is invoked, so the topic id 5 is not passed to the "By Date" view (unsurprisingly), resulting in a list of all books sorted by date instead of just health books sorted by date.

QUESTION:

How can I pass the contextual filter value (5 in this example) from one page to another via the menu? For example, if at /books/title?topic=5 I click "By Date", I want to go to /books/date?topic=5. How can I set that up?

NOTES

This post is similar to an earlier one where I asked how to get the value coming through the contextual filter. I solved that. There is a twig variable available, in this case, {{ arguments.field_topic_target_id }}.
I used this twig value to rig up my own menu. But having done that, I find that I need the goodness of the Drupal menuing system, both because it makes it easy for editors to change menu items and because it handles the addition of the active and active_trail classes to the proper menu entry.
I have read and tried dozens of approaches to passing the filter value received on to another page via a menu, but none have been effective.

BONUS

Assuming this problem can be solved, I'd really like to use clean URLs. So instead of /books/title?topic=5 I want to use /books/title/5. This works to correctly display a list of health books sorted by title, but when used, the menuing system does NOT set the active and active_trail classes on the active menu <li>, which I need it to do.


texts:
I'm creating a search results page using the Search API. I want to set an url like this:

    /search/{text}

How should i set up my route? It must accept any combination of characters, including non-ascii, spaces, numbers, etc, but it must not be empty.

This is my current routing rule. As you can see, there is no restriction for the text parameter:

    my.search.results:
      path: '/search/{text}'
      defaults:
        text: NULL
        _controller: '\Drupal\my\Controller\SearchController::results'
        _title: 'Search Results'
      requirements:
        _permission: 'access content'


texts: Getting quick edit to work for custom fields in templates

texts: I have some custom content types and have made custom templates for them. I need to get the quick edit functionality working with the text fields on these custom templates, as it doesn't currently. I can't find very much information about this - can anyone give me some pointers about how I go about this?


texts: How to add a span before my menu title link

texts:
This is the default Drupal menu:

0.0 Bla

0.1 Bla

    1. Bla

1. Bla

2. Bla

3. Bla

          4. Bla

4-1. Bla

4-2. Bla

4-3. Bla

How to add a span after my menu link
For example

 0.0 Bla

 0.1 Bla

 1. Bla

 1. Bla

 2. Bla

 3. Bla

          4. Bla

 4-1. Bla

 4-2. Bla

 4-3. Bla


texts:
It seems like my data inside the autocomplete field is invisble for non-admins.

I tried targetting the autocomplete with CSS but nothing seemed to work

#autocomplete li:hover, #autocomplete li:focus{
background-color:#428bca;
color:green;
}

#autocomplete li.selected {
  background-color:#428bca;
  color:green;
}


texts: Translatable strings not appearing in the translation interface

texts:
I've recently started working on a custom D8 module. I've used $this->t() (or t()) wherever I had to output a text so that this text would then be translatable.

My module works correctly, but when I visit Drupal's "User interface translation" (admin/config/regional/translate) page, those strings are nowhere to be found.

Two examples:

_1. in the mymodule.module file, I have implemented the hook_help() function to display a help page in the admin:

<?php

/**
 * Implements hook_help().
 */
function mymodule_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.mymodule':
      return t('
Here is the (much longer) help text.
');
  }
}

?>

The help page is visible in the admin and shows the text; however this text cannot be found in the "User interface translation" page.

_2. the module has a configuration page in the admin, with several fields and a description for each field. This configuration form is defined in src/Form/mymoduleForm.php:

<?php

namespace Drupal\mymodule\Form;

use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;

class mymoduleForm extends ConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    // Form constructor.
    $form = parent::buildForm($form, $form_state);
    $config = $this->config('mymodule.settings');
    $form['field1'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('The first field:'),
      '#default_value' => $config->get('mymodule.field1'),
      '#description' => $this->t('
Description for this field.
'),
      '#required' => TRUE,
    );
    // and so on
  }
  // other code
}
?>

Here again, the configuration page works, all the fields are visible, but none of the strings in the code above appear on the "User interface translation" page (neither the title of the string, nor the description).

The same goes for strings declared in the *.yml files: they're supposed to be picked up automatically by Drupal, but I don't seen any of them in the interface... (e.g. the module description in the *.info.yml file.)

What am I missing?


texts: Apply coupon from an affiliate link to ubercart

texts:
Modules involved

Cart Links
uc_discounts_alt or uc_coupon (I like uc_discounts_alt better)
uc_affiliate2
Ubercart

I need to give the ability to have a coupon applied to the cart if the user came through an affiliate link.

Example:

I have a coupon giving 10% off to "Product 1".  I have a partner "Affiliate 1".

I have a link http://site.com/affiliate/1/cart/add/p1?destination=cart/checkout (which there is an issue there since the destination is redirected before the add to cart is applied)

I want to make it so that when that link is followed the coupon is added to the order.

I figured to do this with Conditional Actions, but the predicates/conditions/actions don't seem to exist.

I guess I need to build a predicate for "Item aded to cart", a condition of "Is there an affiliate" does seem to exist, an action for "Add discount".  But I also seem to need something to tie discounts to affiliates.

Any ideas on how to proceed here?  Are there any modules out there for this?  Any alternatives?


texts: How to import translated strings having dynamic variables?

texts:
Short: How can I import .po file having dynamic variables in strings like follows

$message = t('Hi @firstname, please follow @sitelink or mail me at @email ', $var);

Indetail:

I've written a custom module to send mail notification to users. In that module $message string has dynamic variables like follows (sample)

$var = array('@firstname' => $username, '@sitelink' => $GLOBALS['base_url'], @email => $email);
$message = t('Hi @firstname, please follow @sitelink or mail me at @email ', $var);

How can I import $message string to my site.

I could translate all the static strings to Spanish of other custom modules like follows.

#: mycustom.module
msgid "Are you sure to approve"
msgstr "¿estás seguro de aprobar"

But how can I write the same for Dynamic variables. Right now Spanish Users are getting their mail in English?

Note: I'm just using Drupal core Locale module.


texts: How to pass Webform elements from controller to custom twig template

texts:
I'm pretty new to Drupal and probably this is simple but I got stuck with this.

What I'm trying to do:
I have created a custom module where I have defined a custom route to display my webfrom in custom twig template.

How and what to return from Controller so my webform elements will be available in custom twig template.

my_module.module

/**
 * Implementation of hook_theme
 *
 * Since we have a lot to explain, we're going to use Twig to do it.
 */
function my_module_forms_theme($existing, $type, $theme, $path) {
  return [
    'my_template' => [
      'variables' => ['test_var' => NULL],
      'render element' => 'form'
    ],
  ];
}

my_module/src/Controller/MyModuleController.php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class MyModuleController extends ControllerBase {

public function content() {
    $my_form = \Drupal\webform\Entity\Webform::load('my_form_id');
    $form = \Drupal::entityManager()
      ->getViewBuilder('webform')
      ->view($my_form);

$build = [
  '#theme' => 'my_template',
  '#form' => $form,
];
return $build;

}
}

In my twig template, I want to be able to use form elements like below.
Please let me know how to achive this.

my-template.html.twig

{{ form.element.name }}
{{ form.element.email }}

Thanks


texts: I can't get the og_group_ref set in a node form rendered via a custom block

texts:
My block code is as follows:

mymodule_block_info() {
  $blocks = array();
  $blocks['my_contenttype_form_block'] = array(
    'info' => t('My CustomContentType Add Form'),
    'cache' => DRUPAL_CACHE_PER_PAGE,
  );
  return $blocks;
}

function mymodule_ui_block_view($block_name = '') {
  global $user;
  switch ($block_name) {
    case 'my_contenttype_form_block':
  module_load_include('inc', 'node', 'node.pages');
  // Create a node for the content type.
  $node = new stdClass();
  $node->uid = $user->uid;
  $node->name = (isset($user->name) ? $user->name : '');
  $node->type = 'my_contenttype';
  $node->language = LANGUAGE_NONE;

  $block = array(
    'subject' => t('Create New CustomContentType record'),
    'title' => t('Create New CustomContentType record'),
    'content' => drupal_get_form('my_contenttype_node_form', $node),
  );
    break;
  }

  return $block;
}

The "Groups audience" field is missing. It shows up in the standard add page (mysite.com/node/add/my_contenttype).

I've tried setting this programmatically via hook_form_alter, and also by setting the $form_state['values']['og_group_ref'][0], but nothing seems to work (although it makes sense that these approaches are failing when the field isn't even in the form.

Thanks in advance for the assist!
Any thoughts as to why it's missing?


texts:
So, I created a subtheme, and added a random logo.png (found a random icon online, and renamed it). It worked, of course. Then I got the .png that I actually wanted to use... and the site won't update. I replaced the old logo.png file in the root of the subtheme's folder. The old file doesn't exist anywhere (as far as I know), but it's still showing it over the new logo.png

I've tried clearing the cache probably 30 or 40 times.
I've tried clearing my browsers cache, and using different browsers and computers just to make sure it wasn't some local cache
When I upload a custom logo.png through the theme's administration page, it works, but when I go back to the "default", it goes back to the old one. (I'd like this icon to be the default, not to have to choose a custom one.)

I'm not sure what else to try.


texts:
I'm working on a custom module that allow anonymous users who add a new content, to register himself in the same form providing a simple email field (user name is the same as email).

In my module I hook the node_form_alter to add the email field from the user registration form:

function mymodule_form_node_form_alter(&$form, FormStateInterface $form_state) {
  if (\Drupal::currentUser()->isAnonymous()) {

    // Add drupal registration form
    $entity = \Drupal::entityTypeManager()->getStorage('user')->create(array());
    $formObject = \Drupal::entityTypeManager()
      ->getFormObject('user', 'register')
      ->setEntity($entity);
    $user_register_form = \Drupal::formBuilder()->getForm($formObject);

    //kint($user_register_form['account']);
    $form['user_registration'] = $user_register_form['account'];
    unset($form['user_registration']['name']);
  }
}

And this works good.
In node_presave I'm expecting the field to register, but i get an error "Field user_registration is unknown."

function mymodule_node_presave(NodeInterface $node) {
  kint($node);

  $email = $node->get('user_registration')->value; // This throws the error

  if ($email) {
    $email_user = user_load_by_mail($email);

    if (!$email_user) {
      /* Create user */
      $email_user = _create_user($email);
    }

    /* Set user as author */
    if ($email_user) $node->setOwnerId($email_user);
  }
}

What am I missing?


texts: How can I override an entity form with the same date?

texts:
I have an entity form that requires choosing from a date field.
I wanted to override a submitted entity form if there is an existing submitted form with the same date.
I was looking for a solution in the net, but I was not able to find anything useful.
Thank you in advance for those who can help!


texts: Print the secondary links as expanded in a template file

texts:
I'm trying to print the secondary links for the main menu as expanded in my template node--products.tpl.php. In my menu I have three levels.

-Products

--Product category

---Product

-Another menu link

The result should be a menu with all product categories with the child items. I don't want to print the root level in the menu; I only want the secondary level, and its children to appear.

I have tried to print the secondary menu like this, but the child items doesn't appear. Any help appreciated.

$secondary_menu = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array();
print theme('links__system_main_menu', array(
    'links' => $secondary_menu,
    'attributes' => array(
    'id' => 'main-menu-links',
    'class' => array('links', 'clearfix'),
  ),
    'heading' => array(
    'text' => t('Main menu'),
    'level' => 'h2',
    'class' => array('element-invisible'),
  ),
));


texts: How to get the node from the url referer?

texts:
I have a custom entity named Application that has an Entity Reference field named Product.

When I am on an Apllication page and click on a Product to see it, I would like to know that I come from the Application page and know its ID.

This would allow me to display information from the Application page on the Product page.

But how to do it ?


texts: How to customize the subject of a Commerce order confirmation e-mail?

texts: Here you can learn how to customize the content of the order confirmation mail, but what about customize the subject of the mail?


texts: Solving performance issue DrupalDatabaseCache::clear

texts:
I am facing a performance issue when I open some of the pages.  It is taking too long time. After checking the queries and the time for each query I found that these two functions are taking a long time:

DrupalDatabaseCache::clear
DrupalDatabaseCache::set

What to do?


texts: How to sort taxonomy terms by their tid?

texts:
I'm using a custom module to print taxonomy terms as filters inside a View.

I want to sort the taxonomy terms by their tids not by their names.

The below is from the custom-filter.tpl.php:

<?php foreach($data as $tid => $name): ?>
<div data-filter=".filter-<?php print $tid; ?>" class="cbp-filter-item">
  <?php print $name; ?>
  <?php print $text_counter; ?>
</div>
<?php endforeach; ?>

How can I sort the taxonomy terms by their tids?


texts: drush config:import "There are no changes to import." for "content" view

texts:
On a Drupal 8.7.14 system with Drush 9.7.2, I modified the "content" view and now want to roll it back to the previous version that was exported with drush cex.
Unfortunately, drupal does not roll it back to the previous state. drush config:import only says:

There are no changes to import.

I did then delete the "content" view, and the import said:

Operation create für views.view.content: "view" entity with ID "content" already exists.

To circumvent that, I created the view manually and tried to import the original configuration. Again, drupal thinks that:

There are no changes to import.

Why is that?
What can I do to force Drupal to restore the original configuration?


texts: How to run drush with cron (elysia cron)?

texts:
Problem

I can't get cron (specifically elysia cron) to run with Drush. I've been using this as a guide. What have I missed/done wrong?

My Crontab

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
COLUMNS=80

*/5 * * * * /usr/bin/drush @main elysia-cron
* * * * * env > /tmp/cronenv.log

Checklist:

I've used www-data for my crontab. This is the default nginx server user.
The path to drush (/usr/bin/drush), comes from which drush.
I've used an alias for the site, @main. I've tested this outside of cron and the command drush @main elysia-cron runs cron, although only once an hour (see this problem). This cron runs every five minutes so it should work once an hour.

I also tried the format in the docs above:

*/5 * * * * /usr/bin/env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin COLUMNS=80 /usr/bin/drush @main elysia-cron


texts: Are tests built into contrib modules a reliable way of testing the success of a module upgrade?

texts:
I have been updating some modules including Views and Feeds.  Given these modules are quite complex, I thought a good method of testing whether the update was successful or not was to run the tests which come as part of the module. This can be performed by using simpletest module which comes with Drupal core.

However the tests do not complete successfully (by this I mean that there was not a 100% pass rate).  I then rolled back to the previous version of Feeds, and low and behold it did not fully pass either.  This is a large site which has many visitors and I am certain that the Feeds functionality has been running fine, otherwise someone would have been complaining about it.

So it seems Feeds is working on the production site, but the built-in tests don't fully pass.

As follow up I did a clean install of Drupal 7.38 and then added latest versions of Feeds, Views, Features, ctools, Job scheduler and Feeds Tamper. Site is a standard install with no content.  After running the suite of feeds tests I get even more failures than on the existing site I mentioned previously. In fact almost all the tests fail.

This has got me wondering if in-built tests are a good measure of whether a contrib module is working correctly?  Or are they quite unreliable, as I now suspect?


texts: User-Profile-Form.tpl.php not working. Help!

texts:
I am not rendering any results. This is my template.php:

function fueldeluxe_theme($existing, $type, $theme, $path) {
  $items = array();

  /**
   *  Account edit Forms
   */

  $items['user_profile_form'] = array(
    'render element' => 'form',
    'template' => 'user-profile-form',
    'path' => drupal_get_path('theme', 'fueldeluxe') . '/templates'
  );

  return $items;
}

function fueldeluxe_preprocess_user_profile_form(&$variables) {
  $variables['account'] = drupal_render($variables['form']['account']);
  $variables['picture'] = drupal_render($variables['form']['picture']);
}

This is my user-profile-form.tpl.php:

    <?php echo $picture; ?>

    <?php echo $account; ?>

As you can see I'm trying to load the user profile field forms. However I'm not able to render any results. The page loads okay when I add dummy text but no account field forms.

Do I need a module for this to work?

Also what would the variable look like for calling the custom field added to a user?


texts: How to programmatically get the Title for a Local Menu Task?

texts:
I have a long list of menu items so i'll cut it short here:

$items['admin/skyview'] = array(
    'title' => 'Skyview Main Page',
    'type' => MENU_NORMAL_ITEM,
    'access callback' => TRUE,
    'page callback' => 'skyview_main_page',
);
$items['admin/skyview/tab1'] = array(
    'title' => 'Skyview',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'access callback' => TRUE,
    'weight' => 0,
);
$items['admin/skyview/tab5'] = array(
    'title' => 'Sites',
    'type' => MENU_LOCAL_TASK,
    'access callback' => TRUE,
    'weight' => 4,
    'page callback' => 'skyview_sites',
);

But my question is how do I programmatically get the title of 'Sites' for tab5? When I use menu_get_active_title it returns 'Skyview Main Page' instead.

I've looked through phpstorm for what options it gives me, but I really don't find anything to get the title of a menu local task, however I noticed this can be done in D8 but can it be done in D7?


texts: Notification and Messaging module for sending mails

texts:
I have installed send methods as html mail and i have set notification module with subscriptions to content type.

I am not receiving an email when notification actions get created.

have anyone pass through such scenario? Please let me know.


texts: Block machine name is in use that is not available

texts:
I have a Site Branding block I style in my theme. To do this I give it a specific machine name, in this case: sitelogo

On a site using that theme I am trying to create this block but when I try to edit the machine name of the block to sitelogo I am getting the following error:

The machine-readable name is already in use. It must be unique.

An actual block with that machine name does not appear to exist, or at least I cant find it on the site.

Is there a way to force the deletion of that machine name so I can re-use it? I am pretty sure I didn't create it and I need block to have that specific machine name...


texts: hook_field_formatter_view does not get called

texts:
I have a custom field, that hooks into profile2 and saves it's value in user data blob. Everything works fine, except the hook_field_formatter_view, that does not get called for a reason. As a result, when the field is viewed, it returns always an empty array. I have all declaration hooks in place.

<?php
 /**
  * Implementation of hook_field_info().
  */
 function profile_cal_field_info() {
  return array(
    'profile_cal' => array(
      'label' => t('Availability calendar'),
      'description' => t('Sets weekly available time.'),
      'default_widget' => 'profile_cal_cal',
      'default_formatter' => 'profile_cal_formatter',
    ),
  );
 }

 /**
 * Implements hook_field_formatter_info().
 */
 function profile_cal_field_formatter_info() {
  return array(
    'profile_cal_formatter' => array(
      'label' => t('Default'),
      'field types' => array('profile_cal'),
    ),
  );
 }

 /**
 * Implements hook_field_widget_info().
 */
 function profile_cal_field_widget_info() {
  return array(
    'profile_cal_cal' => array(
      'label' => t('Availability widget'),
      'field types' => array('profile_cal'),
      'multiple values' => FIELD_BEHAVIOR_DEFAULT,
      'default value' => FIELD_BEHAVIOR_NONE,
    ),
  );
}

 /**
 * Implements hook_field_formatter_view().
 */
 function profile_cal_field_formatter_view($entity_type, $entity, $field,     $instance, $langcode, $items, $display) {
  drupal_set_message('Called!');

  $element = array();

  return $element;
 }

 /**
 * Implements hook_field_is_empty().
 */
 function profile_cal_field_is_empty($item, $field) {
  return FALSE;
 }

 ?>


texts: Issues with theme on moving drupal website to new server

texts:
I have never used drupal before, and just have been tasked with moving a drupal website to a new server. I've moved the files and database successfully - had a bit of a fight with clean urls which were a pain to switch off, new host did not have them enabled.

The website is mostly working fine, except themes. Anything theme related (images etc) is not loading. If the direct url of a theme item is placed into the browser address bar it is opened successfully. I have a feeling its to do with the first item after the temporary address of the new server, the /~balliolj part, but have no clue where to fix this.

Old website: http://www.ballioljcr.org/
New website: http://31.193.134.90/~balliolj/

I'm trying to get everything working as before prior to moving the domain, hence the temp address.

Any input on how to fix this would be greatly appreciated


texts: How do I reset Drupal Commerce orders, profiles, carts etc?

texts:
I have a heavily customized commerce site that I have just completed and I need to hand it over to the client. It has a ton of test orders, profiles etc. How can I reset all of the orders, profiles (revisions), carts auto increments etc so that it's scrubbed and can start over?

There is a similar question asked here, but it only covers orders. How to reset the id of the orders generated by Commerce module

On a side note, I would imaging this would make a great contrib module as I would imagine many other would require this.

Note: Uninstalling and reinstalling commerce is not an option as there are a ton of other configs and commerce contrib modules already set.


texts: I need to verify the users session of Drupal on a Node.js server. The session ID has been hashed and it is stored in the Drupal 8 database. How can I hash the browsers session ID to compare it with the one stored in the database?


texts: Un-promote all other nodes when one node is promoted to front page

texts:
I have an instance for a specific content type that at any given time there can only be ONE item promoted to the front page. I have a view that looks for this value and displays the item in a block on the front page if it is promoted. The problem is that it is setup to only show ONE item, so the editor has to remember to go and UN-promote any other node after they promote the one they want. I'm trying to figure out a way that when the user clicks the promote to front page check box on the node edit form and saves the node, all other nodes are auto un-promoted. I tried to hook into hook_node_presave, but I can't seem to get the query right to un-promote all the other nodes, because I am using revisions, so I'm not entirely sure what to update.

This is what I have right now that is not working, I think because I am using revisions:

function MY_MODULE_node_presave($node){
  if ($node->type == 'career' && $node->promote == 1) {
    $sql = "
    UPDATE {node} n
    SET n.promote = 0
    WHERE n.type = 'career'
    ";
    db_query($sql);
  }
}


texts:
I have installed the quiz module in drupal 7 and I know that there is a permission to allow roles participate in all quizzes. I want that a specific role can participate in specific quiz, not in all quizzes, and other roles can participate in their own quizzes.

Is there anyway to accomplish this through the interface? If not, I would like to know how to solve it by coding.


texts: $form_state->set(), $form_state->setValue() doesn't save new value

texts:
Below you could find my code. It works fine until below the comment. I also tried countless combination of $form_state->saveValue(), but nothing works. Any ideas?
    function myforms_form_alter(&$form, FormStateInterface $form_state, $form_id) {
      if ($form_id == 'commerce_product_default_edit_form' || $form_id == 'commerce_product_default_add_form') {
        $form['#submit'][] = 'myforms_extra_submit_handler';
      }
    }

    function myforms_extra_submit_handler($form, FormStateInterface $form_state) {
      $events_dates = $form_state->getFormObject()->getEntity()->get('event_date')->getValue();
      $count = count($events_dates);
      if (empty($events_dates[$count-1])){
        $count = $count - 1;
      }
      if ($count > 0) {
        $start_date = date("j/n/y", strtotime($events_dates[0]['value']));
        $end_date = date("j/n/y", strtotime($events_dates[$count-1]['end_value']));
        if ($count == 1) {
          $count_suffix = "zjazd";
        } else if ($count == 2 || $count == 3) {
          $count_suffix = "zjazdy";
        } else {
          $count_suffix = "zjazdów";
        }
        $date = $start_date.' - '.$end_date.' ('.$count.' '.$count_suffix.')';

        $title = $form_state->getFormObject()->getEntity()->get('title')->getValue()[0]['value'];
        /* code above works, below is the code which doesn't */
        $form_state->set('title', $title.$date);
        $form['elements']['title']['#value'] = $title.$date;
        $form['elements']['title']['#default_value'] = $title.$date;
        $form_state->setRebuild();
      }
    }


texts: How to import decimal fields using Feeds?

texts:
I'm trying to import a decimal value from an XML feed to a Drupal decimal number field.

For example the XML feed source is: 7,6 Now I want to import it in a Drupal decimal field. So the field value will be the same: 7,6

Thing is, when I import the feed and the nodes are getting created - this field remains empty. Is this a bug or can someone point out what I'm doing wrong here?


texts: When is it appropriate to run a drupal_bootstrap?

texts: I have a static site with a drupal blog in a subfolder and I want to bring the latest posts into the homepage. I can run a drupal_bootstrap and then load the nodes I want. Is this an ok strategy? When is it appropriate to use drupal_bootstrap?


texts: Fatal Error: Undefined function variable_get();

texts: I have this, $metrics = variable_get('rbi_metrics_list_settings',array());, I have used this in 3-4 pages. And when I put in another file, when I wanted to see what's inside of $metrics , it said undefined function. I omitted it and it returned nothing. What seems to be the problem? Please help.


texts: Check if there's a content type published

texts:
How can I check (via PHP code) if a content type is published?

I have a content type called 'House' and a content type called 'People'. On the 'People' content type, there's a field called 'House'. If the user didn't publish a 'House' content type yet, I want to hide this field.

I thought I could do it by using a hook_form_alter, isn't it possible? If it is, I just don't know how to check if a content type was published or not. Something like: if (isset($node->type == 'House')) ... Of course it doesn't work.

Do you have any suggestions?


texts: How to add a UNION to a query in hook_views_query_alter?

texts:
I have a custom multiple-value field (via plugin) in a bundle that needs to have an dynamic entry added prior to rendering in the view.

I've tried render hooks. The problem is that if there are entries persisted in the field the render hooks never fire.

I've tried adding a row in hook_views_post_execute. The issue there is that the metadata for a row is so vast and convoluted that creating one in the hook has escaped me. Also, I could get one to appear if I cloned an existing row, but that was because the delta existed. If I did so and changed the delta, the cloned row would not appear.

I tried adding an element to the end of the element array in the field's formatter. This failed because the field item, equally convoluted, doesn't exist. Also, the formatter isn't called if there are no persisted values for the field.

I was going to hook user::load or user::view and do it there but Views doesn't use entity calls... it does straight sql.

The solution seems to be to do something like:

SELECT  subfield1, subfield2
FROM    field
UNION
SELECT  value1 AS subfield1, value2 AS subfield2

but Views uses the OO version of query structure, so in the alter hook I'm perplexed as to how to add the union.


texts: Configure inline images upload path per content type

texts:
There is a core feature that lets you configure where to save inline images uploaded using CKEditor:

Here you can specify the path where you want store inline images.

But this is global configuration, which works for all content types.

I want to have ability to control directory path per content type.

There is a module called File (Field) Paths which gives you ability to configure paths for only file fields under any content type but not for inline images.

Is there any module or a way to implement this?


texts: Why Drupal 7 does not log exceeding the allowed memory limit

texts:
Wondering why Drupal 7 does not logging exceeding the allowed memory limit?
Steps to reproduce:

create in the Drupal`s root folder file 'memoryCheck.php' with contents:

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

error_reporting(-1);
$conf['error_level'] = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

function exceedMemoryLimit() {
  $data = '';
  while(true) {
    $data .= str_repeat('#', PHP_INT_MAX);
  }
}

exceedMemoryLimit();

Open /memoryCheck.php throught browser
Open /admin/reports/dblog

Result: Not errors logged.


texts: How to redirect all URLs of all terms in a specific vocabulary to custom URLs

texts:
I am a newbie to Drupal and having hard time to understand how to redirect all URLs for all terms in a specific vocabulary to custom URLs.

I have tried to use Entity Path, but it did not work for me. By some reasons this module sets automatic alias field empty in a term edit form. This breaks Pretty Path module that I am also using.

I have also tried to implement custom hook as described here, but cannot understand how to make it work only for a specific vocabulary, the hook applies to all vocabularies on my site.

I would be greatly appreciate if someone can provide a step-by-step instruction to solve this issue.

edit after I tried to get it to work via Rues

Here is exported Rules

{ "rules_redirect_an_old_path_to_a_new_path" : {
    "LABEL" : "Redirect Categories Terms to Custom Path",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "existing_vocabulary_alias/[term:name]" } }
    ],
    "DO" : [ { "redirect" : { "url" : "custom_text\/custom_text\/[term:name]" } } ]
  }
}


texts: Creating Feature with content types imported by Feature

texts:
Exporting several content types (7) from old website and importing them to new one worked perfectly.

After that i have done some basic changes in imported content types (changed widgets in few text fields (all widgets are default type)).

Now i want to make fresh backup of content types.
"Create feature" / Edit components - Content types: node
Now i can only choose "Article" and "Basic page". Content types i imported are not visible as an option.

Any idea ?


texts: How do I conditionally change the print.css stylesheet to use media = all

texts:
I added this to my template.php, but it doesn't appear to be working.  I've also placed this code in theme_preprocess_html(),

<?php
  function theme_process_html(&$variables) {
    if ($_GET['print'] == 'true'){
      $variables['css']['sites/all/themes/mytheme/css/print.css']['media'] = 'all';
    }
  }
?>


texts:
I have created my custom entities using Entity Construction Kit module.

Is it possible to  render an HTML output of entity programatically? So I could display an entity for example in block?

I have found function entity_view, but it returns only array, not whole HTML output.

For now, I am using Views to achieve this. I create a view that displays one instance, and  I am using function view_embed_view to display HTML.

But is there any direct function, so I don't need to create a view?


texts:
Content type - article. I want to make articles split into multiple pages when the article itself becomes too long.
For example if we have an article "how drupal works" it would be huge :), I want to split it to several pages and at some point you get "continue to page 2 of 10" and then "continue to page 3 of 10" and so on. Hope you got me and can share some ideas.
Thank you in advance!


texts:
Hi I can't get Superfish to output anything in Drupal 7 Zen Starterkit Sub Theme

I've done everything : Installed the Module For Superfish, Libraries, and jQuery Update, I've installed the Superfish Library, created a Menu, called the Menu in Superfish Module, but no output.

I've tried putting in snippets of code in the page.tpl to call the Superfish menu, but they only caused errors.

Please help.

View here http://www.cambrianvacation.co.uk/safeside

Ant:-)


texts:
I have a module that creates HTML output. Does it need to support the Drupal 7 RDF module?
What are the functions made available from the RDF module that allows a module to integrate with it? What hooks does the module use?


texts: Remove Locale settings from Logintoboggan

texts:
I have Logintoboggan installed to handle login/registration.

Upon registering a new user it displays an option to set up Locale Settings - I would like to have this removed but cannot figure out how.

I have disabled the site-wide option for users to be able to change locale settings but it still appears at registration/authorisation.


texts: How do I add a payment view block to Commerce Order page?

texts:
At example.com/user/123/orders/993 the customer sees an Order #993 page to review the history of a particular order.

I already have a View with a block display of the payment information for a given order.

How can I attach this block to that particular form/page (which is generated in code) such that I can pass the UserID and OrderID to the view?

EDIT: What I want to do is 'inject' the Payment view/block I've created -inside- the form generated in commerce_cart.module (after the line items entity reference) so that I can theme it in a decent looking way.


texts:
I have Drupal 7.59 installed and CAPTCHA is visible for several forms. I want it visible only for the login form.

In this section: admin/config/people/captcha, I set the 'No Challenge' for other form-ID and login-form set on 'default challenge type' but the CAPTCHA gets displayed on all forms:
by this text : "CAPTCHA: NO CHALLENGE ENABLED".

How can I prevent the display of CAPTCHA for other forms except the login form?


texts:
Creating a view block for a specific content type  (for example, gallery) how can I filter it so that the view only shows gallery node that live under a certain path (for example, /business/gallery/christmas and /business/gallery/luncheon)?

I've tried to play around with contextual filters (using ID with various setting) and adding an ID filter criteria with no success.

What should I use to filter this?


texts: How to save file uploaded with plupload integration module, and make it managed?

texts:
As described here, I can use Plupload integration module to upload my files to server. They go there, I can see them in temp directory, and that's the point I'm stuck.

Code I'm using for a field is:

'DownloadFile' => array(
  '#title' => t("Download's download"),
  '#title_display' => 'invisible',
  '#type' => 'file',

  '#upload_validators' => array(
    'file_validate_extensions' => array( /* extensions */ ),
    'file_validate_size' => array(variable_get('max_size', 300 * 1024 * 1024)),
  ),
  '#upload_location' => 'public://mymodule/download',
  '#plupload_settings' => array(
    'runtimes' => 'html5',
    'chunk_size' => '10mb',
    'max_file_size' => variable_get('max_size', 300 * 1024 * 1024) . 'b',
  ),
),

In form validation function I get thus in $form_state['values']:

Since the Views for Drupal 7 got reasonably stable, I was using Drupal 7 and managed files. I have literally no idea how should I take this file and plug it into managed table for other functions to use. As you can see from the time difference, it been some time between the moment I was able to upload and now - all this time with no idea. Tried to treat it as '#type' => 'file', but functions for unmanaged don't get it. They require specific name and even if I add '#name' to plupload form element, it still fails.

Is there any way to add file to managed table knowing it's location in temporary://?


texts: Allow users to manage other users but all content is site-wide not based on group

texts:
I am building a website that requires a UserA to be able create UserB, UserC, etc...and have whatever content they create to be managed by UserA (edit, delete, update, etc...)

However I don't think role based permissions are the way to go. I only want UserA to be able to manage those subusers, not assign them a "manager" role where another manager (say, UserX) has created UserZ and if both UserA and UserX are "managers", UserX can change UserB's content.

It looks like the Subuser module is the way to go, however, it is hardly updated and seems to be incomplete. Is there another module or set of modules that can do the same thing?

Organic groups also gives me the access control I need, however, the content that all users should be site-wide and not actually tied to any group. I don't need a container to keep nodes, just the access control for users to manage other users within their own sphere.

Does any one have any other way in which this can be accomplished?


texts: How to add comma separated list for the select list check box field type

texts:
For my one site, I added a select list(text) > check box field type to my content. When I go to manage display tab(using display suite module), in the format column column for the field, I see drop down field with 4 values ( css class, default, key, list). I selected list. Next to that I also see a geared setting where it allows me to make a comma separated list. When I go to front end, I see the values listed separated by commas. It works fine.

I am trying to do the same thing for my other site. But as for the drop down field, I only see default and key. Also, I don't see the geared setting icon to make it comma separated list. I am not sure what I did wrong on my second site. Both site have the same field type.

Please advise.


texts: Populate article field based on user login

texts:
I am trying to accomplish a task with Drupal and I'm kind of stuck in how to implement this, so I'm wondering if anyone has any ideas or can at least point me in the right direction.

My company has over 60 locations.  I am using Views to dynamically create a single "profile" page for each location.  What I want is a way for the manager of each location to be able to log in and create articles for a kind of "What's Happening" section for their respective pages.

When the "manager" user accounts are created, I assign them a location based on a "Location" field that I added to the "User" content type.

What I want to do is add a field to the "Article" content type that is automatically populated with the "Location" of the manager that is posting the article.  From there I can filter in Views to complete the page generation.

I could easily just add a "location" field to the Article content type that the user could manually select, but I know my users, and people will be creating articles for other sites and cause big mess for me to clean up.  I'd like to have the "Location" field in the article automatically populate depending on the users' login.

Possible?  If so, how?


texts: Sharing Global Menu Links Menu to subsites

texts:
How to present a global menu across multiple subsites

I've been trawling the Drupal site for answers to this and because I'm only 4 days into my Drupal 7 adventure I'm sure half my battle is finding the right words to say to the community to get what I'm asking for.

This question seems to hit the mark http://drupal.org/node/1428516

But the only answer is something about Domain Access http://drupal.org/project/domain but that looks pretty complicated when all I want to do is to splat a small block of html at the top of all my sites.

So I'm thinking the architecture would be something like this.

master site
+ - menu-global-menu
+ - global-menu-module (looks in master site db for menu-global-menu
                        and fills variable $global_menu)
+ - corporate theme (requires global-menu-module)
|
+ - > subsite 1
+ - inherits corporate theme
|
+ - > subsite 2
+ - inherits corporate theme

Does this make sense? Or should I be achieving this some other way?


texts: How to create a list of users according their roles?

texts:
How can I create/see the list of user according their roles?

I'm interested in any answers to do this programmatically, or via any other way/technique I could use for this.


texts: "The pdf.js library could not be found." (PDF module)

texts:
I installed pdf.js with the PDF module in an effort to show pdf on the fly on my Drupal 7 site. I keep Drupal 7 constantly upgraded on Ubuntu on an instance an AWS.

I installed the module using drush which placed the module at sites/all/modules/pdf. I then copied pdf.js to: sites/all/libraries.

After installing I have created a new content type called PDF and I added a file field that is able to only include a pdf file.

I selected the display to show: "PDF: Default viewer of PDF.js". I then added a content with a PDF file in it selected and uploaded.

While trying to show it I get the message: The pdf.js library could not be found. And down the page: pdf: Please download and install pdf.js!

Can anyone help?
Where do I put the JS file?
Is there a problem with the FDF module?


texts: Send old Simplenews to newly registered users?

texts:
I have sent a Simplenews newsletter.

Added some new users since this mailing, and would like to resend it to some newly subscribed users. How can I do that?


texts: Node count published, unpublished and total

texts: I have been on this for a while, considering my low php knowledge. Anyway I would like a view that lists users with total number of articles created, total number of those articles that are published and total number of those articles that are not published per user. I have looked around for an answer to this and the closest I get is node view count which does not do what I need.


texts: How can I see the clean query of a view?

texts:
I created a test view. It displays data of a content type 'Anagrafiche (name for internal use: contatti)'. The view has the following fields (sorry for the interface language):

Contenuto: Immagine (Img)    it's an image field
Contenuto: Nome (Name)       it's a text field
Contenuto: Cognome (Surname) it's a text field

I used the proposed code for the following question, to get a 'clean' query: link

But the output was not what was expected:

SELECT
  node.nid AS nid,
  node.created AS node_created,
  node.changed AS node_changed,
  users_node.name AS users_node_name,
  users_node.uid AS users_node_uid,
  'node' AS field_data_field_immagine_node_entity_type,
  'node' AS field_data_field_nome_node_entity_type,
  'node' AS field_data_field_cognome_node_entity_type
FROM  node AS node
LEFT JOIN users AS users_node
  ON node.uid = users_node.uid
LEFT JOIN field_data_field_cognome AS field_data_field_cognome
  ON node.nid = field_data_field_cognome.entity_id
  AND (field_data_field_cognome.entity_type = 'node'
  AND field_data_field_cognome.deleted = 0)
WHERE (( (node.status = 1)
  AND (node.type IN  ('contatti')) ))
ORDER BY
  field_data_field_cognome.field_cognome_value ASC
LIMIT 20 OFFSET 0

I do not have very clear how the correct output should be, but by looking at the query, I gather that this piece is not correct

  'node' AS field_data_field_immagine_node_entity_type,
  'node' AS field_data_field_nome_node_entity_type,
  'node' AS field_data_field_cognome_node_entity_type

I also tried alternatives like the 'Devel' module and different types of hooks, but I never got what I wanted

@mikeytown2 I ran the query inside phpmyadmin
this is the result:

but the last three columns should not be node | node | node,
but something like thatimg | myName | mySurname


texts: How to set a new taxonomy term without overwriting an existing one when using Rules?

texts:
I'm using the Rules Action Set Data Value to set a taxonomy term for a specific user (uid= 75). The tag field exists in the user entity, and is set to "Unlimited".

There's nothing complicated about the rule, which looks like so:

{ "rules_invited_user" : {
    "LABEL" : "Invited user",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_presave" ],
    "IF" : [ { "data_is" : { "data" : [ "account:uid" ], "value" : "75" } } ],
    "DO" : [
      { "data_set" : { "data" : [ "account:field-user-tag" ], "value" : "27608" } }
    ]
  }
}

I can set the term, but if there's another term set already for that user, it's overwritten.

How can I set a new term without overwriting an existing one?


texts:
I have two content types Blog and Stay which use the same taxonomy Location. I have two or more posts use same term Cyclades.

Is it possible when a user clicks on a Cyclades term link in a Blog post to only show posts from Blog content on the taxonomy page? Likewise, when a user clicks on Cyclades in a Stay post, to show only Stay content on the page?

I know i can create two different taxonomy for each content type, but I dont want this solution.


texts: How to make uploaded file permanent to node without node submit

texts:
My module automatically save new empty node when user create new node and redirect to edit this node. Now, is it possible to make uploaded file on _node_edit form without submitting form?

edit:
When user visit "node/add/article" for example, my module save new node type article and redirect user to "node/NID/edit" to edit this node. In node have fields type "image" and "file". User upload image and file.
Now, how to alter their (ajaxified) upload process to make this files permanent to node without click on "Save" button on node edit form?


texts:
I customized the workflow summary view to make multiple views for different users/workflows.

When I try to export it with features, module.views_default.inc is not created, no error (nor notice) message is issued, and the workflow_summary view is deselected from the feature (re)creation form. I've created a feature with only this view, and then get an empty feature.

Is there a way to export it ?


texts: Restoring accidentally deleted content type

texts:
I am an absolute Drupal newbie, so please forgive my ignorance.

I have got an old Drupal site to manage (Drupal version 6.22).

While playing with the site I defined a new content type called My page and based on page.

After playing with it a bit I deleted it, from then on all my pages lost their content type and became uneditable.

After a lot of googling I realized that because My page was based on page, after deleting it I lost page type too. Seems a very strange logic to me, but not going to argue.

How can I restore the "page" content type? I tried to add it again, it was added OK, still all old pages remained typeless and uneditable.

The last site backup is from a couple of month ago and is irrelevant, as a lot of user content was added since.

I have an access as admin to the site's Drupal system, however I do not have a  remote access to the server. Should I request it? Where should I go and what should I change?


texts:
Since I moved my web site to another web hosting, Front page won't show their contents.
Problem persists either if I set some other page to be front page in Site Informations.
Do not know what to look. CMS is Drupal 6 updated to 6.28 just today.
I tried to uninstall PATHAUTO module and for once it showed content but on another attempt to open it, there's same problem.
Server supports CURLs

Please help,
I am ready to create some admin account to anyone who can help to resolve this.

Tnx.

Boris


texts: Text format filter for embedding links and videos into body copy

texts:
I would like to get a functionality similar to Facebook: when you include any link in a status update, post or comment it will replace it with a thumbnail, link and short description of the page.

The emfield module has that functionality but it requires an extra field and can't do the replacement within a body copy.

Video Filter does it for videos but it requires a special syntax [video:url] that a user would have to learn. It does offer Wysiwyg integration.

Is there any way of achieving a seamless (Facebook-like) experience?


texts: How to get translated field_storage_config

texts:
I need to programmatically set the translated values for several fields on a node. For that I would like to set their values in the fields field_storage_config. Adapted from another question's answer (Manage config translations programmatically) I tried the following, but without success:

$origLang = \Drupal::languageManager()->getConfigOverrideLanguage();
$lang = \Drupal::languageManager()->getLanguage($currentTranslationLanguageId);
$untranslatedStorage = \Drupal::entityTypeManager()->getStorage('field_storage_config')->load("node.$tagsBaseFieldId");
$untranslatedValues = $untranslatedStorage->getSetting('allowed_values');
\Drupal::languageManager()->setConfigOverrideLanguage($lang);
$translatedStorage = \Drupal::entityTypeManager()->getStorage('field_storage_config')->load("node.$tagsBaseFieldId");

I expected to get the field_storage_config of the override language that I set in the languageManager (different from the base language), but if I dump $untranslatedStorage and $translatedStorage after these commands, they are the same. $untranslatedStorage and $translatedStorage are the same object. How is this possible and how can I programmatically set the translations for my field(s).
It is a text list field (the one that translates to a selectbox in the UI).


texts: Difference between Media and Asset module

texts:
Today I saw a "new" module: Asset.

It looks interesting but I don't understand the difference between this module and the Media module, in the 7-2.x version.

Could someone help me?


texts: How can I dynamically disable a single required field from validation in a form?

texts:
This is an extension of this question:

Need help with AJAX callback function for text field validation in form_alter

I have a form with a Username autocomplete field (txn_user). The editors want to be able to enter a UID (txn_userid) as an alternative way of specifying the User for the form. They want to be able to enter the UID and skip the Username field altogether.

So in my form validation function, I want to be able to disable the required property (and all other validation) of the Username field during a Submit IF the editor typed in a UID field. In other words: the UID field should 'short-circuit' the Username field.

This is what I have so far (which doesn't work, obviously). Or do I need to do this via AJAX or straight JS?

function _validate_add_userpoints_userid(&$form, &$form_state) {
    $values = $form_state['values'];
    if( $values['txn_userid'] ) {
        $newuser = user_load($values['txn_userid']);
        if( ! $newuser) {
          form_set_error('txn_userid', 'You have entered an invalid UID. Either leave this blank and select a Username or enter a valid UID');
    }
    else {
        // this part works... the User Name is properly assigned.
        $form['txn_user']['#value'] = $newuser->name;
        $form_state['values']['txn_user'] = $newuser;
        $form_state['input']['txn_user'] = $newuser->name;

        // this part doesn't work... the User Name field is still required on submit.
        $form['txn_user']['#disabled'] = TRUE;
        $form['txn_user']['#ajax_processed'] = TRUE;
        $form['txn_user']['#required'] = FALSE;
        $form['txn_user']['#needs_validation'] = FALSE;
        unset($form['txn_user']['#process']);
    }
}

}


texts:
How should I go about making my custom Drupal 7 Form element support AJAX events, just like other standard FAPI elements?

For example, with a drop-down list, I would do this:

$element['book'] = array(
  '#type' => 'select',
  '#title' => t('Book'),
  '#options' => $books,
  '#default_value' => $default_book,
  '#ajax' => array(
    'wrapper' => 'replace-me',
    'callback' => 'replacement-callback',
    'method' => 'replace',
  ),
);

But now that '#type' is my own custom element, the '#ajax' property is ignored. This is what I have implemented thus far:

function mymodule_element_info() {
  return array(
    'customelement' => array(
      '#input'          => TRUE,
      '#process'        => array('customelement_process'),
      '#theme'          => array('customelement'),
      '#theme_wrappers' => array('form_element'),
      '#tree'           => TRUE,
    ),
  );
}

function mymodule_theme($existing, $type, $theme, $path) {
  return array(
    'customelement' => array(
      'render element' => 'element',
    ),
  );
}

function theme_customelement($variables) {
  // render some elements
  return $output;
}

function form_type_customelement_value($element, $input = FALSE, &$form_state) {
  // manipulate form values
  return $input
}

function customelement_process($element, &$form_state, $complete_form) {

  // build the compound form array
  $element['#tree'] = TRUE;

  $element['book'] = array(
    '#type' => 'select',
    '#title' => t('Book'),
    '#options' => $books,
    '#required' => true,
  );

  $element['chapter'] = array(
    '#type' => 'textfield',
    '#title' => t('Chapter'),
    '#size' => 3,
    '#maxlength' => 3,
    '#required' => true,
  );

  return $element;

}

Using my custom element in a form goes like this:

function mymodule_menu() {
  $items = array();

  $items['path/to/page'] = array(
    'title'            => 'Test form',
    'type'             => MENU_LOCAL_TASK,
    'weight'           => 30,
    'page callback'    => 'drupal_get_form',
    'page arguments'   => array('mymodule_callback_testform'),
    'access callback'  => 'user_access',
    'access arguments' => array('mymodule_admin'),
  );

  return $items;
}

function mymodule_callback_testform() {
  $form = array();

  $form['test_element'] = array(
    '#type' => 'customelement',
    '#title' => 'Custom element test',
    '#required' => TRUE,
    '#ajax' => array(
      ... // this has no effect :(
    ),
  );

  return $form;
}

But unfortunately it doesn't "magically" support AJAX. I would like to trigger a Drupal AJAX event when any sub-element of my custom element has triggered certain events.


texts: Looking for a workflow module that can control content access

texts:
I have a content type called "article".  It needs to go through some workflow states when people try to submit a new article:
submitted -> review 1 -> review 2 -> published.

During each workflow state, only certain roles should be able to see it, modify it, and comment on it.  This needs to be done independently by its current workflow state.  The workflow module appears to have access control based on states, but then the access control part does not work so essentially everyone can see the content no matter what state it is in.  Not sure if this is a major security bug, permission being overridden by another module, or me doing something wrong.

Any other suggestions for modules that can do workflow?  I heard Workbench is another good one.  Can it keep track of comments and separate out comments based on workflow states?


texts: How to customize exposed filter for date field?

texts:
I have a view that shows a table of members. I would like to have an option to filter by "new members", let's say members that joined in the last month.

If I expose the field I get an input box with "-1 month" which isn't ideal.
It would be better to have a "select box" with "Any" and "New Members" options. A previous DA question didn't show an answer for this option.

Alternatively, links for "All Members" and "New Members" would work for me too. If I expose the field I can make the link work. But then I have to somehow hide the text field.

Any other solutions?


texts: How to add redirect section to node edit on Drupal 8?

texts:
On Drupal7 using Redirect module there was a section on node/nodeid/edit view where we could add a "Redirect" section. This was helpful because it allowed redirects to be created from the node/nodeid/edit view.

In Drupal8 that option is not available. How do you replicate the redirect section on the node/nodeid/edit view?


texts:
How do I force certain roles to use exclusively administration theme? These roles are only allowed to add content in administration and there is no problem for that. But some pages, like the user profil page, still use the front office theme and I need them to always use the administration theme. Any good solution for that?

Thanks


texts: How to filter a view based on tags applied to

texts:
I'm working on an old (2009) Drupal 6 site that uses a custom module to add a field to the content creation pages for certain node types. That field lists a sub-set of the users of a certain user type.

Some of those users are now being free-tagged on the site. I'd like to be able to create a view that lists only the nodes that refer to users that have a specific tag.

If that sounds a bit complicated, here's an example. Imagine a D6 site that works as an intranet for a doctor's surgery. Each doctor has a user account on the site, as does each patient. A custom module lets patients be allocated to doctors. After every appointment, the doctor fills in a report. That report is a node type, and includes a field created by a custom module that allows the doctor to select the patient who had the appointment, from a list of all of the patients who are allocated to that doctor.

Now, imagine that each patient's account could be free-tagged, and tags such as "male", "female", "diabetic", "pregnant", etc. were added to the patients' user accounts. How would I go about building a view that would display all of the reports given to patients who are tagged as "pregnant"?


texts:
Does anyone know a way to change the value of a webform component after the submission is updated using rules?

For example:

Rule Triggers on Event: Webform Submission is Updated

Action: Change webform component value to X

Export of the Rule I have so far:

{ "rules_internship_agreement_form_updated" : {
  "LABEL" : "Internship Agreement Form Updated",
  "PLUGIN" : "reaction rule",
  "OWNER" : "rules",
  "REQUIRES" : [ "webform_rules", "rules", "php" ],
  "ON" : { "webform_rules_update" : [] },
  "IF" : [
  { "webform_has_id" : {
      "form_id" : [ "form-id" ],
      "selected_webform" : { "value" : { "webform-client-form-2" : "webform-client-form-2" } }
    }
  }
],
"DO" : [
  { "component_rules_check_internship_approvals_and_send_emails" : {
      "USING" : {
        "user_data" : [ "user" ],
        "faculty_approval" : "[data:faculty_approval-value]",
        "preceptor_approval" : "[data:preceptor_approval-value]",
        "student_email" : "[data:student_email-value]",
        "faculty_email" : "[data:faculty_email-value]",
        "preceptor_email" : "[data:preceptor_email-value]"
      },
      "PROVIDE" : {
        "faculty_approval" : { "faculty_approval" : "Faculty Approval" },
        "preceptor_approval" : { "preceptor_approval" : "Preceptor Approval" }
      }
    }
  },
  { "php_eval" : { "code" : "drupal_set_message($data[\u0027components\u0027][\u0027faculty_approval\u0027][\u0027value\u0027][0], \u0027status\u0027);" } }
]
}
}

So most of the middle part can be ignored, that's part of my conditional that is working, I just need the final "DO" or action where php_eval is.  Currently it is setting a drupal message, I would like that final action to instead, change the value of data:faculty_approval-value to a value (in my case I actually just want it blank).  If it can be done without custom php code execution, that would be great, but willing to do that if needed.


texts:
I wrote a ruby script to create a "Help" doc installation on a test machine (CentOS, VM).
On step of the process is to reindex the data for the "Help" doc installation (5GB of data).
The total amount of data to reindex is: (according to drupal search-status)
    1438 items

When running the reindex cron job manually:
    drush -v cron
I need to rerun cron a few times since not all data is being reindexed at one cron run. But in the end all data is being reindexed.

In the automation script I execute the shell command:
    session.exec!(drush -v cron)
and via the onetime login I can manually verify that data is being indexed.
However, after the shell command has been executed a few times, the cron job just hangs and does not pick up again. I even tried to run the drupal command manually, but it seemed that drupal was just horked. I actually needed to reboot my test machine to complete the reindexing.

Would it be better to run the shell command:
    drush -v search-reindex
to force a reindex and not even rely on the cron job to do the reindexing.


texts: Link Checker module not working properly

texts:
I am using Link Checker module to detect broken links. But the issue is its only showing those broken links that are going to a different domain.

For e.g my domain is www.xyz.com and if I used a link in body of a node like www.abc.com/sites/default/files/dummy_feb5.pdf.

In this case it it showing in broken link report but not displaying errors on same domain like www.xyz.com/sites/default/files/dummy_feb5.pdf.

What am I missing?


texts:
My nodes, with entity translation enabled, need to be able to handle a node where the content of the node is displayed differently regarding the labels and menus.

Let's say I am on a french page, displaying a list of all nodes, translated into french or not. If I click on a non-translated projects url I need the node to be displayed in a french environment (menus and labels in french) but displaying the node in its original language.

Any idea how to achieve this?


texts:
I am trying to add quick tabs from codes. I got the code from here Creating QuickTabs programmatically not working . But noone explains how to implement this , where to add the code. I am trying to add like this.

test.module

<?php
    function test_menu(){

    $items['test/quicktabs'] = array(
        'title'=> 'quicktabs',
        'page callback' => 'test_quicktabs',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
      );
    return $items;
    }

    function test_quicktabs(){
    $tabs = array();

    $tabs[] = array(
      'title' => t('Tab1'),
      'type' => 'freetext',
      'text' => 'Hello wecome to Tab1',
    );
    $tabs[] = array(
      'title' => t('Tab2'),
      'type' => 'freetext',
      'text' => 'Hello wecome to Tab2',
    );
    $tabs[] = array(
      'title' => t('Tab3'),
      'type' => 'freetext',
      'text' => 'Hello wecome to Tab3',
    );

    // Configure the QuickTabs options
    $quicktabs_options = array(
       'style'   => 'Bullets',
       'ajax'    => FALSE,
    );

    $quicktabs_name = 'dynamic_quicktabs_menu';
    $quicktabs = quicktabs_build_quicktabs($quicktabs_name, $quicktabs_options, $tabs);
    return $quicktabs;

    }
?>

I am not sure , this is a correct approach . How to implement quicktabs inside other modules?


texts:
File Framework is a collection of modules which allow uploading, converting and displaying different media type files as Drupal nodes.

  Metadata is extracted from uploaded files using EXIF, getID3, pdfinfo
  and stored as Resource Description Framework (RDF).

  A node of type file is created for each uploaded file. This gives a
  revision control and will integrate with views.

  Each file is converted to number of other MIME formats using available
  open source converters. For example a MS Word file can be
  automatically converted to PDF, OpenDocument Text (using OpenOffice
  daemon / LibreOffice + JODConverter), Plain text (using catdoc), Flash
  video (using SWFTools), JPEG (using GhostScript) and Zip (using gzip).
  Converted (derived) files are saved in the Bitcache and their metadata
  is extracted and saved in the RDF along with the relation to the
  original file. All derived files are listed and can be downloaded.

Unfortunatelly the module is available for Drupal 6 only.

Is there any similar solution available for Drupal 7 ?

Please follow http://drupal.org/node/1827110 if you are interested in File Framework port for Drupal 7.


texts: Theme CSS overrides my CSS. How do I fix this?

texts:
Trying to customize this theme called Emon, but any theme styles I write bootstrap.css/template.css takes precedence even if we use identical selectors. I don't want to edit bootstrap.css/theme.css obviously, or use !important all over the place.

The theme offers a "Write your own CSS" section which has it at an inline-level, but it's not the easiest to maintain this way (though it's looking more attractive every minute).  I saw libraries-override/extend, but wasn't able to accomplish what I want like this.

Again, I'm looking to tell Drupal to honor my stylesheet over the others without removing them.  What is the right way to accomplish this?


texts: How do I migrate the content of a SQL table?

texts:
I have a sql table which contains Visitor name, Afiliation, Start date and End date.

I have created a content type named "Visitors" which contains title (i.e Visitor name), Affiliation (Text field), Start and end date (Date field)

How can I migrate my sql records from tables to populate this content. Please share the online resource link and other material which can help me to achieve this objective.

I am using Drupal 7.

Thank you for your help


texts:
I'm doing a user migration from Drupal 7 to Drupal 8 (the data is in json format)
Most of the fields have been imported to the new website. Now, I'm in the process to migrate the password; this field is, of course, encrypted/hashed (as far as I understood, Drupal uses SHA512 by default with a salt).
So far, I have found this answer and adapted my code like below:
$users_json = file_get_contents("../import/users.json");
$users_array = json_decode($users_json, true);

foreach($users_array as $user){

    $values = array(
        'name' => $user["name"],
        'pass' => [
            'value' => $user["pass"],
            'pre_hashed' => TRUE,
        ],
        'status' => $user["status"],
        'mail' => $user["mail"],
    );

    $userStorage = \Drupal::entityTypeManager()->getStorage('user');
    $userEntity = $userStorage->create($values);

    $role = $user["roles"][0];
    $userEntity->addRole($role);

}

Now, my question is: Is it a good approach? How do I import this kind of field? Do I have to decrypt/de-hash the password?


texts: How to set shipping price to 0 when a specific field of product is enabled or has specific value

texts:
I am using Drupal Commerce 7. I need to set the shipping price to zero when a field of product is enabled/checked (for example free ship field).

I know I should use Rules and Collecting shipping rates for an order event is suitable for my job, but I really don't know how to set up a condition to check if my field is enabled or has a specific value.

I can set the free ship field widget as check box with enable/disable or select box with 2 value, whichever fits my needs. But my problem is how to set the condition according the value of product field.

Thanks for your attention


texts: Which field type should I use for a telephone number, and how can I ensure each entry is unique?

texts:
I have created a field (field_telephone) to store telephone numbers like 13712345678.

Which is the best field type to use?
I also want to make sure the values for this field are unique. How can I do that?


texts:
I'm a really newbie in Drupal world.
I use Plone since 2004 but now I've to learn also Drupal for various reasons.
I'm reading books and tutorials, using this CMS as power user and many more.

Now it's time to go deep and the first thing goal is: theming from scratch.
I've notice that PhpTemplate it's not exactly a clean pagetemplate system (for my point of view), while Twig seems very interesting, but I don't understand if Twig could be clearly used in Drupal7 or not.


texts:
I'm trying to create a filter within a view, which has multiple ranges;

i.e.

0-99
100-399
400-699
700-1000

I have seen this before when you Add filter criteria, you can select grouped exposed filter and I can set up the ranges in there. But in this instance, this option is not there and I'm not sure why not.

In the drupal code I found Drupal API which counts the options in $this->operator_options() - But I don't know what $this->operator_options() is meant to contain, or how you go about adding items to it through the back-end.


texts: How to link views module with customized mysql

texts:
I'm a newbie to drupal. I just got a web designing work. My client asked me to create a system somehow like this.

Basically, you enter your age and then hit submit; the result page will be a list of data that are automatically calculated based on the age value you provided.

I looked at the code, it seems the website uses drupal views module to list tables.

I want to know how did they achieve this. Did they put all data into nodes and retrieve them via views.

The deadline is almost there (Mar 21). I've already done the design of other part of the website using php and mysql. I want to integrate my development with drupal (because it's easy for clients themselves to maintain).

I don't need to complete the whole website design by Mar 21, but at least to demonstrate that I can build such system (perhaps a demo with fake data) so that I can extend the deadline a little bit.

Could anybody help? perhaps give me a direction on what to look and learn.

ps. I heard there's a data module in drupal, could I combine it with views to achieve the goal.


texts: Specify node.tpl.php file via template.php for a specific node.

texts:
I have two content types on my site:

NRG Shop display
Links

I have created a tpl.php file for NRG Shop Display and want to re-use this template for node 12 on my site. Node 12 is created from the 'Links' content type.

How can I do this?

I have tried the following:

function mytheme_preprocess_node ( &$vars ) {
  if ($variables['nid'] == '12') {
    $variables["theme_hook_suggestions"][] = "templates/node--nrg_shop_display.tpl.php";
  }
}

However it does not seem to work.

Any pointers?


texts: How to generate commerce add to cart form on a page with full functionality?

texts:
I am building a small site with very simple products, what I am trying to do is build a product list based on one product node, it's more easy to use an example to explain.

Like I have a product node with these fields, title, unit number, unit, price, we call it [base product].

Title:  juice
unit number: 100
unit: ml  /milliliter/
price: 3$

Now how to generate a product like this? Please note that the price are auto-calculated.

juice 100ml  3$  add_to_cart_form
juice 200ml  6$  add_to_cart_form  /* 3$x2 */
juice 300ml  9$  add_to_cart_form  /* 3$x3 */
juice 400ml 12$  add_to_cart_form  /* 3$x4 */
juice 500ml 15$  add_to_cart_form  /* 3$x5 */
juice 600ml 18$  add_to_cart_form  /* 3$x6 */
juice 700ml 21$  add_to_cart_form  /* 3$x7 */

Please note that this product is actually one product reference page but have several add_to_cart form buttons,  all the information is generate from [base product]

Because the product is so simple that I don't want the user have to increase the product quality themselves by input numbers or click the add_to_cart buttons again and again, just pick up a quality and add_to_cart.

However, this also can be solved by adding product nodes with different quality number, but it's a pain if you want to change the price information when you product reference page have a much longer list for displaying, especially when all the products have a same [base price].

Any insight or suggestions will be much appreciated. Thanks in advance.


texts: Embed unique custom form in all rows of a view

texts:
I want to create a custom form that will be embedded on each row for visitor to submit an email for that specific row.

I suppose I have to create a custom form (which I have done before) but how do I embed it on each row ?  hook_views_data_alter(array &$data) is the right way ?

Other questions (but not that important) are how do I make it unique (know which row the user has submitted) ? Another requirement is to be submitted without reload of whole page (ajaxy form).


texts:
I am trying to create a custom block using a module.

I have followed the instructions on the Drupal site but my block does not appear in the list of custom blocks, or at the bottom of the Block Layout page.

So I installed the Examples for Developers module. It seemed to install and enable correctly but again, there didn't seem to be any example blocks in the Structure, Blocks Layout screen.

Thinking that there must be something wrong with my installation, I used the demon site to test the example modules: https://simplytest.me/project/examples/8.x-1.x

Again, when I enable the Block Example module I don't see any block modules in the list of custom blocks, or at the bottom of the Block Layout page.

Am I doing something wrong, or is this broken in Drupal 8.0?


texts:
How is it possible to detect if the page, in which the form is, is refreshed and to detect if only the form is refreshed?

I tell you the whole thing: I'm building a module. The form in this module has ajax-ed elements. When the form is first loaded (or when the page containing the form is refreshed) a database query is executed (filling up the form), that is the thing i want. But when an ajax-ed element is triggered the query is executed again, and i don't want that.

How is it possible to stop the execution of this query when an ajax callback is executed?
The form is in an .inc file and called by the .module file via drupal_get_form().


texts: How to get file from managed_filed in drupal 8 generate image style and use as background image for a div

texts:
I had created a form filed to upload an image on a themes settings page like this

$form ['ad_tv']['tv_adbackground'] = array(
    '#type'     => 'managed_file',
    '#title'    => t('Hintergrundbild'),
    '#required' => FALSE,
    '#upload_location' => file_default_scheme() . '://theme/backgrounds/',
    '#default_value' => theme_get_setting('tv_adbackground'),
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg'),

),

Now I like to know

with preprocess function to use in mytheme.theme to make sure the file gets overwritten, if a new one is uploaded.
how to add the path of the uploaded file or its image style to add the path as background image to a div with a css id called advertisement

I hape that this is not to much for one question. I am new to drupal 8. So any help will be welcome-

thank you.


texts: How to edit content of panels Custom text that was made reusable?

texts:
I'v created a Custom text element for page manager and made it reusable, and I'm not able to edit it now in Panels. Is it possible to edit such Panels elements after they were made reusable?

Thanks


texts: Views Slideshow fixed 1st slide even though its random order

texts:
I'm using D7.15, Views Slideshow 7.x-3.0, jQuery Cycle 2.9999.8.

The problem is that when Slideshow initially starts, even though it is set to show random order of slides (~100 nodes linking via Views), the first slide is always the same and it is shown in a bit glitched way - it does not works as a link, it is shown for shorter amount of seconds and in general does look like it is shown while all the rest of slideshow is loading. Starting from the second slide the order is random and it works perfectly. It can also be recreated in case of page refresh - if you refresh the page in any browser you may get the same result no matter of what browser you use. You can check it here http://www.scanorama.lt (the main slider part).

I have searched for this issue registered at Drupal issue queue, but it looks like that there is none.

Any ideas, what could be the reason for such glitch?


texts: Entity Print Module: Create PDF from HTML

texts:
I´m trying to use the entity_print module for generating a PDF in Drupal 8.
I want to print out HTML. My module has no entities it gets data from a solr server and generates HTML output.

My first thing is to make a route and a sort of flag to fire the pdf generation:

mymodule.page_detail:
path: '/detail/{Title}/{ObjIdentifier}'
defaults:
_controller: '\Drupal\mymodule\Controller\myController::detailpage'
Title: ''
ObjIdentifier: ''
ViewPdf: '0'
...

mymodule.page_detail_pdf:
path: '/detail/pdf/{Title}/{ObjIdentifier}'
defaults:
_controller: '\Drupal\mymodule\Controller\myController::detailpage'
Title: ''
ObjIdentifier: ''
ViewPdf: '1'

...

Then in my Controller I check for

if (isset($myModuleViewPdf) && $myModuleViewPdf == "1") {
  ...

Now the entity Print magic should come into play.
I use the services and make a print engine and a print builder:

$print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')->createSelectedInstance('pdf');
$print_builder = \Drupal::service('entity_print.print_builder');

Now I´m struggeling somehow. When I look over the functions docroot/modules/entity_print/src/PrintBuilder.php

I see that they are using entities for the output but I want to use HTML.
How can I do this?

Greetings
Lars


texts: Add help text to radio button when it's disabled

texts:
I have two radio button groups that have a dependency.

When Button 1 is clicked, Buttons 4 and 5 should be disabled and vice versa. If Button 2 is clicked Button 4 and 5 are active and Button 3 is disabled.

How can I add help text to the disabled buttons that states the buttons are disabled because of your selection in Group A (Organization).

Here is the javascript that handles the buttons.

$(document).on('click', function () {
    // Organization and Data Classification dependency
    if($('#edit-field-organization-und-0').is(':checked')){

        $('#edit-field-data-classification-und-public').attr('disabled',false);
        $('#edit-field-data-classification-und-internal').attr('disabled',false);
        $('#edit-field-data-classification-und-confidential').attr('disabled',false);

        $('#edit-field-data-classification-und-btn1').attr('disabled',true);
        $('#edit-field-data-classification-und-btn1').removeAttr('checked');
        $('#edit-field-data-classification-und-btn2').attr('disabled',true);
        $('#edit-field-data-classification-und-btn2').removeAttr('checked');

    }
    else{
        $('#edit-field-data-classification-und-public').attr('disabled',true);
        $('#edit-field-data-classification-und-public').removeAttr('checked');
        $('#edit-field-data-classification-und-internal').attr('disabled',true);
        $('#edit-field-data-classification-und-internal').removeAttr('checked');
        $('#edit-field-data-classification-und-confidential').attr('disabled',true);
        $('#edit-field-data-classification-und-confidential').removeAttr('checked');

        $('#edit-field-data-classification-und-btn1').attr('disabled',false);
        $('#edit-field-data-classification-und-btn2').attr('disabled',false);

    }

}

enter code here


texts: Drupal views autocomplete filter inserts html tags

texts:
I have a site containing Free tagging field using text autocomplete widget option. A view is created with exposed filter for free tagging with autocomplete option. However the results provided via suggestions when entering a tag has html tags, in particular < p > tag.

Is there a way that the tags can be stripped off? Upon selecting the Unformatted dropdown and Unformatted suggestion in the filter option in views  option, it displays the numeric id instead of text.