How to give Permissions to User based on taxonomy selected while creating a content? I have a taxonomy called Projects and it has terms like Project1, Project2 etc.
I have added a user called ProjectUser1, and assigned a new role called ProjectRole with it.
Now I want to give Permissions to ProjectRole so that when ProjectUser1 logins, he can only see the content that has Project1 taxonomy and he can Publish, Unpublish, Edit or Delete only those content. He shouldn't be able to see the contents which doesn't have Project1 taxonomy.

Can anyone help?

I think you are looking for Taxonomy Access Control

Access control for user roles based on taxonomy categories (vocabulary, terms).

Automatically controls access to nodes (based on their taxonomy terms).
Three node access permission types: View, Update, Delete.


Intending to select user role while creating the node to control the node visibility I have simple requirement.

I have multiple user roles. What I want is that when I create a node, I could select a role of the user which is able to see this node.

Or may be by default all roles are selected and I could deselect them to modify the visibility.

Any module or help?

Best.

try one of the following:

Node Access:

  The modules provide roles and user specific security permissions for
  menus, menu items, nodes, and security integration into the
  administration and help systems.

nodeaccess:

  Nodeaccess is a Drupal access control module which provides view, edit
  and delete access to nodes. Users with the 'grant node permissions'
  permission will have a grant tab on node pages which allows them to
  grant access to that node by user or role.

Content Access:

  This module allows you to manage permissions for content types by role
  and author. It allows you to specifiy custom view, edit and delete
  permissions for each content type. Optionally you can enable per
  content access settings, so you can customize the access for each
  content node.


Display nodes even if it untranslated I've using default translate module. I enabled 2 languages, setted translation in nodetype. So now if i will setup view like this:

It will display only translated nodes. If I set all languages, it will show all nodes, but with duplicates (first and second languages).

How to set in this way: display translated nodes, but if some are not translated, display untranslated?

The trick is the combination of two things:

Instead of translation language, use the filter "Default translation", so that you only get the original/default/source translation for each node.
Then, in Language below Pager, for "Rendering Language", select "Interface text language selected for page". That will select the best available translation for the current language, just like accessing node/1.


How do I use absolute URLs? I created a view for node titles only. I have inserted this view in simplenews newsletter using the Insert view module. The node title in newsletter emails are relative and broken. How do I configure my view so that absolute URls are used?

1. Add Content: Link to Content field to your View . Your view fields will look as shown below.

2. Make sure that your Title field is outputted as plain text. In the Content:Title field settings uncheck the checkbox "Link to the Content". This is done because you'll use plain title text as a token for the link text. Exclude Title field from display, as it will be displayed later as an absolute link text.

3. Create settings for the absolute link output in Content: Link to Content field settings.

Open REWRITE RESULTS fieldset in Content: Link to Content field settings and check the following boxes:

✓ Override the output of this field with custom text (set {{ title }} as text)
✓ Output this field as a custom link
✓ Use absolute path


How can I create an entity reference field to list a subset of roles? I want to provide a field in a node to lists a subset of available roles. These roles could be used to decide how the node would be displayed to users with the roles selected here.

Is there a way to create an entity reference field of entity type user role? If yes, how can I restrict the field to display only certain roles? The usual way is to create a view with entity reference display and add conditions in the view to restrict the options. Is it possible to create a view of type user role?

Two parts to check here.

Is it possible to reference user role (a config entity)
Is there a way to restrict the available roles in the field level.

reg #1, yes! the out-of-box Drupal core allows creating an entity reference field with the target entity as a user role.

For #2, there is no easy way as the only way to restrict the available option(in core) is via views, but unfortunately, we can create views of the content entities. However, we can add a reference handler with config (as below) to restrict the available roles.

<?php

namespace Drupal\mymodule\Plugin\EntityReferenceSelection;

use Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provide configuration to select specific roles to reference.
 *
 * @EntityReferenceSelection(
 *   id = "default:user_role",
 *   label = @Translation("Role selection"),
 *   entity_types = {"user_role"},
 *   group = "default",
 *   weight = 1
 * )
 */
class RoleSelection extends DefaultSelection {

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);
    $configuration = $this->getConfiguration();
    $entity_type_id = $configuration['target_type'];
    $storage = $this->entityTypeManager->getStorage($entity_type_id);

    $options = array_map(function ($entity) {
      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      return $entity->label();
    }, $storage->loadMultiple());

    $form['target_roles'] = [
      '#type' => 'checkboxes',
      '#title' => $this->t('Allowed roles'),
      '#options' => $options,
      '#default_value' => isset($configuration['target_roles']) ? (array) $configuration['target_roles'] : [],
      '#multiple' => TRUE,
    ];
    return $form;
  }
    /**
   * {@inheritDoc}
   */
  protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $configuration = $this->getConfiguration();
    $target_type = $configuration['target_type'] ?: [];
    $entity_type = $this->entityTypeManager->getDefinition($target_type);
    $query = parent::buildEntityQuery($match, $match_operator);

    // Add condition, if set of roles selected.
    if (isset( $configuration['target_roles'])) {
      $query->condition($entity_type->getKey('id'), $configuration['target_roles'], 'IN');
    }
    return $query;
  }

}

Here is the field settings page:

and here is the final output:


Views relationship outputting duplicate nodes? I have a view of Planet content types. These Planets have a node reference field for Trade Routes to reference other Planets. I'm attempting to output both the current Planet's x/y coordinates, as well as the x/y coordinates of the Planets it references in it's Trade Routes field.

Setting up the fields with each Planet outputting its own x/y and the x/y fields again but using the Trade Route relationship this time results in each Planet being returned as a row once per Trade Route it is storing, instead of returning an array of x/y like I would expect.

What am I doing wrong here?

Maybe You can try to use the Query Parameter and check the "Distinct" option to have distinct result :


Programmatically render a panels page variant There is a Page with id: front_page, and a number of variants.

I want to programmatically load the page, evaluate the context and render the appropriate variant.

I have the following code to load the page:

$page_id = 'featured_content';
$page_storage = \Drupal::entityTypeManager()->getStorage('page');
$variant_storage = \Drupal::entityTypeManager()->getStorage('page_variant');
$page = $page_storage->load($page_id);
// ...

How can I build or render the $page?

Here is how :

$page = \Drupal\page_manager\Entity\Page::load('featured_content');
//all variants ids, for the example
$variants = $page->getVariants();
$variantIds = array_keys($variants);
// last variant... could have been $page->getVariant('{VARIANT_ID}');
$pageVariant = end($variants);
$viewer = new \Drupal\page_manager\Entity\PageVariantViewBuilder();
$arr = $viewer->view($pageVariant);
\Drupal::service('renderer')->render($arr);


How do I programmatically create a file and write it in the private:// folder? How do I programmatically create a text file and write to it in the private:// folder in Drupal 8.8? I found some examples, but all of them use deprecated functions and they don't work.

Here what I have now, but i't s not creating folder and text file in it with content:

use Drupal\Core\StreamWrapper\PrivateStream;
...
...
$output = 'Test Text';
$file_save_path_stream_directory =  'private://gmt';

file_prepare_directory($file_save_path_stream_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);

$fileLocation = $file_save_path_stream_directory . '/test.txt';

$file = file_save_data($output, $fileLocation, FILE_EXISTS_REPLACE);

If anyone need it, I make it work:

use Drupal\Core\File\FileSystemInterface;

...

  /**
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;

  public function __construct(FileSystemInterface $fileSystem) {
    $this->fileSystem = $fileSystem;
  }

  public function testCreation() {
    $request = 'test content';
    $path = 'private://gmt/';
    if ($this->fileSystem->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY)) {
      /** @var \Drupal\file\FileInterface $file */
      $file = file_save_data(
        $request,
        $path . 'requests.txt'
      );
    }
  }


Alter the menu_edit_item form I'm trying the alter the menu_edit_item (Edit menu link in a menu element) with a module. So far I tried

   function module_name_form_menu_edit_item_alter(&$form, &$form_state, $form_id) {
    $form['additional_desc'] = array(
        '#type' => 'textfield',
        '#title' => t('Additional Description'),
        '#maxlength' => 180,
        '#required' => TRUE,
        '#description' => 'Name of the Additional Description'
      );
   }

But it doesn't work. I'm new to Drupal. Thanks!

That code should work in both in Drupal 6, and Drupal 7.

If you edit an already enabled module, you should clear the Drupal cache, as the list of hooks implemented by modules is cached by Drupal; that means that changing the code of an enabled module doesn't cause Drupal to notice the new added hook.

As alternative, you can go to the page listing all the enabled modules (admin/modules), disable your module, click on the "Save configuration" button you find at the bottom of the page, re-enable your module, and click again on the the "Save configuration" button. This will force Drupal to clear the cache where it saves the list of hooks implemented by the enabled modules.


Modifying Drupal core (search module, image module) I have a couple of modifications I did to the Drupal core:

search module: I added a class to the <ul> that contains the "no-results" text.
image module: I changed the 'title' attribute to have a #maxlength of 500 for a specific content type, so that only nodes of that type can have a longer 'title'

The question is: how would I do that without modifying the Drupal core? Is there a way of overriding those default outputs in a custom module? I'm looking for a way of doing that without touching the core, or to confirm that a modification in the core was the only feasible way.

I'm not sure how the second one is Image module-specific, but you would override that maxlength like so:

function hook_form_[content-type]_node_form_alter(&$form, &$form_state, $form_id) {
    $form['title']['#maxlength'] = 500;
}

... where 'hook' is replaced with the name of your custom module, and [content-type] is the machine name of your content type.

The API function is hook_form_FORM_ID_alter()

For the search form theming, you probably want something like template_preprocess_search_results() in your template.php of your custom theme, and/or adding a custom search result template to the theme's templates folder.

Oh, and in case it needs saying again,

DON'T HACK CORE


Force using specific filter text on a content type How can I limit the text filter type upon a textarea field.

Example (the needed result would be like this) :

Authuser is a role that can change the value of textarea_1 and textarea_2 on contentTypeA
Authuser can't change the 'text filter' value of textarea_1 (it's on filtered HTML)
Authuser can change the 'text filter' value of textarea_2 with only (Plain text or ckEditor(WYSIWYG))

Is that possible? if yes, how?

Thanks in advance.

Using format permissions in combination with the Better Formats module should allow you to do what you are trying to do.

The Better Formats module allows you to set allowed and default text formats per field - so you can set different allowed formats for both of your fields.


How to add the paragraph parent field in the theme suggestions alter I've been spending a couple of hours from debugging the paragraph properties using kint and var_dumper however, the page is freezing and I'm unable to see what are the properties and methods available. Has anyone tried to add a hook theme suggestion to paragraph based on its parent field name?

I have added a paragraph type as well as added the fields, then I created a node and paragraph reference.

Here's a sample code:-

function THEMENAME_theme_suggestions_paragraph_alter(&$suggestions, $variables) {
    $paragraph = $variables['elements']['#paragraph'];
    $parent = $paragraph->getParentEntity();

    $suggestions[] = 'paragraph__' . $parent->bundle() . '__' .  $paragraph->bundle();

    // get the parent field of the current paragraph
    // assuming that the parent field name is field_test_paragraph
    $parent_field_name = 'field_test_paragraph';

    // field_test_paragraph should be added to theme suggestions
    $suggestions[] = 'paragraph__' . $parent->bundle() . __ . $parent_field_name . '__' .  $paragraph->bundle();
}

Expected output:

paragraph--nodetype--field-test-paragraph--paragraph-type-name.html.twig

You can get the parent field name directly from the paragraph:

Replace

// get the parent field of the current paragraph
// assuming that the parent field name is field_test_paragraph
$parent_field_name = 'field_test_paragraph';

with

$parent_field_name = $paragraph->parent_field_name->value;

As a side note, this is an entity base field like parent_id and parent_type you load the parent entity with in getParentEntity().


Loading block via ajax I have an custom module with Block:
namespace Drupal\generator\Plugin\Block;

use Drupal\Core\Block\BlockBase;

class GeneratorBlock extends BlockBase {

    public function build() {
        $form = \Drupal::formBuilder()->getForm('Drupal\generator\Form\ProjektForm');

        return array(
          'form' => $form,
          '#attached' => array(
            'library' =>  array(
              'generator/generator-css'
            ),
          ),
        );

    }
}

All it does is placing some From in there with additional .css file (from library). I can place this block via Admin -> Structure -> Block layout and it works fine.
What I want now is to load that block via Ajax (because I want to refresh the whole block in some cases). And by that I mean I want to load it into wrapper (like with $.load(...)) or get the content of the block in JS variable (not the whole page with block, but just the rendered block).
I've found the tutorial for Drupal 7 on drupal.org, but I failed to port it to Drupal 8.

You can use the #ajax attribute to load main part of the block via Drupal ajax.

namespace Drupal\generator\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\generator\Form\ProjektForm;

class GeneratorBlock extends BlockBase {

  public function build() {
    return array(
      'form_wrapper' => array(
        '#prefix' => '
',
        '#suffix' => '
',
        '#markup' => '',
      ),
      'load_form' => array(
        '#type' => 'button',
        '#value' => $this->t('Load form'),
        '#ajax' => array(
          'wrapper' => 'form-wrapper',
          'callback' => array(static::class, 'getForm'),
        ),
      ),
      '#attached' => array(
        'library' =>  array(
          'generator/generator-css'
        ),
      ),
    );
  }

  public static function getForm() {
    return \Drupal::formBuilder()->getForm(ProjektForm::class);
  }

}


Close the iframe after login with Shadowbox module I have installed the Shadowbox module and I use it to show the login page in a pop-up iframe.

The problem is when I click on the sign-in form submit button the iframe still appears and the page refreshing inside the iframe is not the original page.

How can I close the iframe after login and make the page reload?

The Ajax error is the following:

  An AJAX HTTP error occurred.
  HTTP Result Code: 200
  Debugging information follows.
  Path: /arabdc/system/ajax
  StatusText: parser error
  ResponseText:
  parent.window.location.reload(true);[ {"command":"settings","settings":{"basePath":"\u002Farabdc\u002F", "pathPrefix":"", "ajaxPageState":{"theme":"bartik", "theme_token":"PQ_SrF6skDNUXCQNOJJg54EPuosNo0QM5sX6fr2Sfko"}, "heartbeat_language":"ar", "heartbeat_poll_url":"http:\u002F\u002Flocalhost:8888\u002Farabdc\u002Fheartbeat\u002Fjs\u002Fpoll", "shadowbox":{"animate":0, "animateFade":0, "animSequence":"wh", "auto_enable_all_images":0, "auto_gallery":0, "autoplayMovies":true, "continuous":0, "counterLimit":"10", "counterType":"default", "displayCounter":1, "displayNav":1, "enableKeys":1, "fadeDuration":"0.35", "handleOversize":"resize", "handleUnsupported":"link", "initialHeight":160, "initialWidth":320, "language":"ar", "modal":false, "overlayColor":"#000", "overlayOpacity":"0.85", "resizeDuration":"0.35", "showMovieControls":1, "slideshowDelay":"0", "viewportPadding":20, "useSizzle":0}, "custom_search":{"form_target":"_self", "solr":0}}, "merge":true}, {"command":"invoke", "selector":null, "method":"myJavascriptFunction", "arguments":[  ]}, {"command":"insert", "method":"prepend", "selector":"head", "data":"\u003Cstyle type=\u0022text\u002Fcss\u0022 media=\u0022all\u0022\u003E@import url(\u0022http:\u002F\u002Flocalhost:8888\u002Farabdc\u002Fsites\u002Fdefault\u002Ffiles\u002Ffontyourface\u002Ffont.css?mmj0o1\u0022);\u000A@import url(\u0022http:\u002F\u002Flocalhost:8888\u002Farabdc\u002Fsites\u002Fdefault\u002Ffiles\u002Ffontyourface\u002Flocal_fonts\u002Fmyride-normal-normal\u002Fstylesheet.css?mmj0o1\u0022);\u003C\u002Fstyle\u003E\u000A", "settings":null} ]

Looks like a Closed [Fixed] bug in Issues for Shadowbox From the page here is a patch file.

shadowbox_login-additional_links-1488718-25.patch Or read the ISSUE alos check #6


Filename for the front page template file How do I create a theme for the front page only?
I only want to change what is in the content area but leave the rest of the stuff the same from page.tpl.php.

In Drupal 7, you need two dashes in your filename; try page--front.tpl.php.


drupal commerce separate shipping for different products We have a drupalcommerce website through which we sale

iptv box
qwerty key board

on adding first product it adds 15 dollars( base rate ) + 5 dollars per item in cart, so if we have 1 item in cart the shipping is 20 dollar but if we have 2 products the shipping will be 25 dollars and so on.

problem is, we want to setup separate shipping rate for qwerty key board if there is only a qwerty key board alone in cart the shipping must be 5 dollars.

I hope this can be done through shipping rules

You can add a shipping service dedicated for for qwerty key board and similar items and a shipping calculation that checks for a certain product in the cart. Use:
Event: Calculating a shipping rate
Condition: order contain a particular product.
Action:Add a rate for a shipping service to an order and select the shipping service that is dedicated for qwerty key board and similar items.

It may be easier for you to clone one of the existing shipping rate calculation and edit as needed.


Variation of Node Add Screen? How do I create a second version a node add page?

For example if have node/add and I want node/add-quick?

Some fields of the required fields form node/add  would be missing or not required on node/add-quick.

I know node add fields can be hidden based on user role or other variables but how do I create an entirely new page with a select set of fields.

with panels module you can select witch fields display and just do not add fields that you dont want, do not place "complete node form", also you can control what contentypes node/add form overrides.
If you do not use panels module you can add a custom module with the following code (D7), replace uppercase letters with your data. This code only affect "your_form_id", to find your form_id, inspect an element (right click on your form) and look for it.

 //if form id is YOURFORM_form hide elements
 function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {
      global $user;
        $uuid = $user->uid;
  /*  check that user is NOT admin (No1) */
     if ($uuid !='1') {

        if ($form_id == 'YOUR_FORM_ID') {
            hide($form['field_YOUR_FIELD']); // hides field to all but admin user
            $form['body']['#format'] = 'plain_text'; // forces body format to plain text
            //displays field in form, but disabled
            $form['YOUR_SECOND_FIELD']['#disabled'] = TRUE;
        }
    }
 }


Drupal 7 Forum - Allow Users to 'hide' their online status I am desperately trying to find a way for my users to 'hide' their online status from other users. Currently all users online are displayed in the drupal 'who's online' box.

Ideally I would look for a way to create a custom checkbox field (online_status) and then find a way for the who's online block to check that.

Any ideas, modules or approaches anyone can recommend.
My current thinking is to do it via Views and a custom block

thanks

You can use hook_block_view_alter to alter the content that is returned by who's online block. Ideally use the same logic that was implemented in user.module user_block_view function, delta who's online block but with extra validations.

Add a field called Show online status to User Profile. Let's say yes or no.

Read the above field value in the alter function for all users online and filter them before displaying.

Hope it solves !


Change user profile image on profile page to activate colorbox This is for Drupal 7.

Currently on the default user profile page, the profile picture just links back to their profile.  I'd like to change this so it opens a colorbox.  Thoughts?

SOLUTION

Add the following to your theme's template.php file.

<?php
function ccom_preprocess_user_picture(&$variables) {
  $variables['user_picture'] = '';
  $original_image = NULL;
  if (variable_get('user_pictures', 0)) {
    $account = $variables['account'];
    if (!empty($account->picture)) {
      // @TODO: Ideally this function would only be passed file objects, but
      // since there's a lot of legacy code that JOINs the {users} table to
      // {node} or {comments} and passes the results into this function if we
      // a numeric value in the picture field we'll assume it's a file id
      // and load it for them. Once we've got user_load_multiple() and
      // comment_load_multiple() functions the user module will be able to load
      // the picture files in mass during the object's load process.
      if (is_numeric($account->picture)) {
        $account->picture = file_load($account->picture);
      }
      if (!empty($account->picture->uri)) {
        $filepath = $account->picture->uri;
      }
    }
    elseif (variable_get('user_picture_default', '')) {
      $filepath = variable_get('user_picture_default', '');
    }
    if (isset($filepath)) {
      $alt = t("@user's picture", array('@user' => format_username($account)));
      // If the image does not have a valid Drupal scheme (for eg. HTTP),
      // don't load image styles.
      if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) {
        $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt));
        $original_image = image_style_url('large', $filepath);
      }
      else {
        $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt));
      }
      if (!empty($account->uid) && user_access('access user profiles')) {
        if (isset($original_image)) {
          $attributes = array(
            'attributes' => array('title' => t('View expanded image.'), 'class' => t('colorbox')),
            'html' => TRUE,
          );
          $variables['user_picture'] = l($variables['user_picture'], "$original_image", $attributes);
        }
        else {
          $attributes = array(
            'attributes' => array('title' => t('View user profile.')),
            'html' => TRUE,
          );
          $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
        }
      }
    }
  }
}
?>


Get all current tabs (node view) How to get all node tabs (MENU_LOCAL_TASK type) which available for current node?

I mean node/%/edit, node/%/translate, node/%/devel etc.

I've tried to use menu_local_tasks() but it shows only empty array.

Got it!

if ($node = menu_get_object()) {
    $tabs = menu_local_tabs();
}


How do you find where a module's directory is located? I have the following:

I want to find where the module "commerce_physical" is located in the modules folder, but I can't seem to locate this module. I did a find and a grep to locate where its files might be, but that doesnt seem to work. What are some other ways to find the location of a drupal 7 module?

Look at the {system} table.  In particular, the name column will be the module name (ie, the basename of the .info and .module files).  The filename column will be the full filename, with path, to the .info file for the module, relative to the DOCROOT of the installation.  See system_schema() for more information.


Download Confirmation Form I would like to add a confirmation page for downloads.
How can I achieve it?

Not easily because you are going direct to the path.

You could do it in a similar manner to sites such as sourceforge which show you the confirmation page first and use JavaScript to open the download. This method should also have a direct link option incase JavaScript is disabled.

The best way of doing this would be to add a menu hook which shows the message and then links to the path. You would need to add a .htaccess to capture the page downloads and perhaps pointing it to /download-confirm?link=(Base64 encoded link).


Send custom data to endpoint based on checkbox value via webforms POST handler Drupal 8.9, webforms 5.x

I'm trying to send some text data to a endpoint on form submission via a POST handler. It's based on the value of a (single) checkbox on a webform. The endpoint only accepts specific text values, so I need to somehow convert the 0/1 to those specific text values - if checked => "Signed up", else => "Not signed up".

I want the equivalent of

"key": [webform:elements:checkbox_machine_name:checked] ? "Signed up" : "Not signed up"

if you could have a ternary in the yaml format...

Is there a way I can do this via webforms?

I'm happy to install more modules, but if possible I'd like to avoid writing any PHP...

You could use a Computed Twig element to execute the ternary operator and set the value in the remote post data.

@see https://www.youtube.com/watch?v=rRlTTkwdP_o


how to programmatically check if a context is active I am reading through the API of the drupal 7 context module, and searching for examples, but I can't find a working example of how to programmatically test if a context is active for the current page.

I tried to call the context_isset() function defined in context.module, but what are the namespace and the attribute values? I only know about the context name and it's tag.

What can be done is to use the context_active_contexts() function.

Sample code, to see if the is_iframe context is active for the current page:

$contexts = context_active_contexts();
if (array_key_exists('is_iframe', $contexts)) :
    watchdog('te','context is_iframe is set');
endif;


How to solve "This version is not compatible with Drupal 7.x and should be replaced" error? I keep getting, "This version is not compatible with Drupal 7.x and should be replaced." error. Could you please look at the content of my .info file and tell me what is wrong with it:

name = jeanb
description = sub-theme based on Bartik.
base theme = bartik
engine = phptemplate

stylesheets[all][] = css/jeanb.css

regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted

regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second

regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last

regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
regions[footer_fourthcolumn] = Footer fourth column
regions[footer] = Footer

settings[shortcut_module_link] = 0

; Information added by drupal.org packaging script on 2013-04-03
version = "7.22"
project = "drupal"
datestamp = "1365027012"

Thank you!

As per Writing theme .info files, core is a required key. You just need to add

core = 7.x

to make your theme compatible with Drupal 7.


Easiest way to add color to a title field? I have 2 fields, one is an image and the other is just a title. Now the title hovers above the image, but the problem here is that the image might clash with the font color. If the image is predominately white and the text is white, you wont be able to see it.

I was thinking of creating a new field just for the user to select white or black. Then i would create a tpl just for this article page to parse the "color" field and expose it for css styling. I feel like this is the long way to do this.

What other possible ways can this be accomplished?

Why not play with the styling? You can add text shadow or 50% dark transparent background to the text or add text outline as demoed here: http://css-tricks.com/adding-stroke-to-web-text/ All these options will give you a better contrast.


Create a Views that displays all unused taxonomy terms I found this article about how to create a Views to display all active taxonomy terms: https://www.drupal.org/node/770782

I want to achieve the exact contrary: Get a list of all terms that are not used by my nodes.

Can I reach this with Views UI, relashionships, etc?

Any clue is welcome!

This can be achieved by View relationships and aggregation

1) Add a new view of view type "term"

2) Add Field Taxonomy: Term Name

3) Add Relationship "Taxonomy term: Content with term"

4) In the View : Advanced section , Enable Aggregation

5) Add new Filter nid, Aggregation type = Count DISTINCT , Select Relationship = node , Operator= equal to , Value= 0


Retrieve taxonomy terms with EntityFieldQuery for a given parent term I am retrieving a tid of a taxonomy term by using EntityFieldQuery. However, I need to cross-link the taxonomy_term_hierarchy table to list those terms which have a particular parent, but I am not able to get it. In the code below

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'taxonomy_term')
      ->propertyCondition('vid', $vocabulary)
      ->propertyCondition('name', $termino)
      ->propertyCondition('parent', $parent_id)

the last line is throwing the following (expected) error. The same code, without the last property condition, works correctly. How can I achieve the result?

The returned error is:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.parent' in 'where clause'

Using only the EntityFieldQuery class, you cannot because the information about the taxonomy hierarchy is not contained in the database table used for the entity data, but in the taxonomy_term_hierarchy table.

You would need to first get all the taxonomy term IDs having $parent_id as parent, from that table, and then use the EntityFieldQuery class for the other part of the query. Truly, the EntityFieldQuery class is excessive, in this case, since its purpose is to make a query involving the values of field attached to an entity. It also slower than a normal query done with db_select(), and you would not get any benefit, in this case.


Drupal 7 cache page for anonymous users causes issues when loading different css files based on browser version If you have "cache page for anonymous users" on and are using server logic(http_user_agent) to load different css based on the browser version, that logic will not fire and you will get the css that was cached from the last visitor. This seems as if this will also cause some issues when loading js and css based on browser version and for responsive design...more specifically to browsers that don't understand media queries....pre IE 9 browsers. Does anyone have any solution on a work-around for using anonymous cache and loading the correct css based on server logic?

Serving up different content based on request headers isn't the best idea in general, especially if you aren't sending back a Vary header.

The best workaround is to use markup rather than server side logic.  When you do this, Drupal will cache things properly.

For IE, this means either using HTML conditionals and/or Paul Irish's method and/or JS "cleanup".

Pre-IE9 support for media queries has a few popular solutions, including the the Respond library.

For Drupal, I would recommend using a HTML5-aware base theme like Omega, which wraps all of this up in a nice package.


Tips for Information Structure & Superfish Menu I am thinking of using the superfish menu module. The site will have three levels of navigation. Any tips for creating the nodes/pages so that the Menu structure works out properly? Or as long as I create all the level one pages and then use them as the parent menu for any child pages, will the menu be generated ok?

You can always rebuild the menu, so I would just start adding content and organizing the links.  The main advantage of a CMS like Drupal is that you are not "locked in" to a specific configuration and you can always change it around freely at any time.

One thing to be careful about is that the deeper your navigation structure, the harder it is for users (particularly older users and those not skilled in using mouse, etc. as well as those on mobile devices) to use the menus, but this is something you can only find out once you actually build the menus and do usability tests.

As you note, you will need to first create the parent pages before you can add links underneath them to the child pages.


making a custom page template I currently have a general template and a front page template. I made a custom node for a content type I made and it works just fine but then realized that I need an entirely new page template as well. I already made a page--[content_name].tpl.php file and cleared the cache but it wasn't read. Is there something I need to change elsewhere or is what I'm doing completely off? Thank you.

For Drupal 6 -- page-[content_type_name].tpl.php and clear the cache.

For Drupal 7 -- http://www.digett.com/blog/01/11/2012/overriding-page-templates-content-type-drupal-7


Add query parameter from url to all links on the page How to Add query parameter from url to all links on the page? Basically I want to get the Query parameter from url and then attach that on all the links on the page.
JQuery or PHP, Any solutions?

Please suggest. Thanks in Advance!

You can do it easily in a custom module, implementing hook_url_outbound_alter().

function mymodule_url_outbound_alter(&$path, &$options, $original_path) {
  $param = $_GET['q'];
  $path = 'build-path-as-desired.';
}

That should do it for you. The hook serves, basically, to alter outbound urls. You can look at the documentation for it in the system.api.php file, and I suggest you do that, as there are a couple of things to take into account when altering urls through it, but it's definitely an easy way of doing what you want to do.

EDIT: Online documentation for the hook - https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_url_outbound_alter/7

EDIT 2: Additional functions to work with the path being requested:
drupal_get_query_parameters() and drupal_get_path_alias($path).


Links to files breaking I just wanted to see if anyone could offer some thoughts or opinions on an issue we are having.

We are running Drupal 8 multisite via Aegir. We have a production environment and an identical testing environment set up. In our test environment we have our Drupal 8 multisite using domains such as site1-testing.com.

The issue is the file structure is set like /sites/site1-testing.com/files/. This poses an issue when we migrate to our production domain which would be site1.com. Anywhere where we inserted a link to a file would still be referencing /sites/site1-testing.com/files/filename.pdf, which would of course, cause all of our production links to break.

We use linkit as well to insert the files into nodes. I've tried using pathauto, pathologic in conjunction with url aliases but ultimately the direct paths remain the same.

Any thoughts on how we could get around this?

Site internal links should always use URIs relative to your base URL. This would avoid your specific issue. (File entities actually do use URIs relative to the configured public files folder, so that - depending on how you created your file URLs within CKEditor - clearing your caches might help already.)

However, in a mirrored multi-site environment, you can also use the sites.php file to define the base URLs and their respective target site paths. If not configured otherwise, your files folder should use the configured target sites path and all your environments will use the same files location.

Place a sites.php file in your [DRUPAL_ROOT]/sites folder (e.g. by copying and renaming the existing examples.sites.php file) and configure the $sites array keys to your requirements. Example:

$sites['site1.com'] = 'site1.com';
$sites['site1-testing.com'] = 'site1.com';


Why return AccessResult::allowed() ends up with "Access denied"? I'm having a strange behaviour while trying to use hook_node_access in Drupal 8 (Lightning to be more precise) and I can't figure out why is doing this. Let's suppose that I want to always allow people to edit a certain content type (I know I can setup role permissions to achieve this, but I'm just trying to understand why it's not working):

function mymodule_node_access($node, $op, $account) {
  $type = $node->bundle();
  if($type == 'service' && $op == 'update') {
      return AccessResult::allowed();
  }
}

I always get "access denied" while trying to edit a "service" node.

This is what I've tried to do in order to debug it:

in reports > status reports there are no node access permissions in use;
the current user does not have "bypass content access control" permission;
hook_module_implements_alter doesn't return any other module using hook_node_access.

Is there anything I'm missing?

Although I've checked for other modules using hook_node_access, I forgot to check for hook_entity_access as well. It turned out that the "content moderation" module is denying access. Thanks @4k4 for making me revisit this!

Just for the record, if you need to see which other modules are using a certain hook, you can use something like this:

function mymodule_module_implements_alter(&$implementations, $hook) {
  if($hook == 'node_access') {
    //do whatever you need to do (e.g. use kint($implementations) to see what other modules are using this hook)
  }
}


How to filter a View by Year and Month with Summaries for each one or How to remove the exception parameter of a View's contextual filter

Hi,

In Drupal 7 I have a View with two contextual filters (date field):

/view-url/YEAR/MONTH

When YEAR is the first argument and if there is none I make a Summary of the view, so the result can be something like:

* 2017
* 2016
* 2015

And MONTH is the second parameter, that if it's not present, the view also makes a Summary:

* January
* February
* ...

I think that I'm stuck replicating the same View in Drupal 8, because the first Summary has a default parameter "all" wich is the exception of the second parameter.

Is there a way to remove that default exception parameter from the url of the first summary? (I'm getting view-url/YEAR/all for each year of the list as its url).
Can I expose YEAR and MONTH so people can easily navigate trough the view?

Also if there is a better way to built that kind of view (like better performance) I'll apreciate the advice.

You can override the parameters in each individual display.
I'm not sure about D8, but in D7, the "display order" of the displays was important as well, such that you'd get the behavior of the higher priority display (lower display order) as desired. In D7, I had to go into the database itself, and change the "position" of these pages in the "views_display" table. (I know of no way to do this in the UI.)


Site emails state incorrect domain name I have a couple of drupal sites running from the same host, using apache vhosts to do domain name forwarding.

I have many domains/url's dns entries pointing to this server's ip address, some of which are not currently live websites (they fail/default over to my main website).

When a user registers on one of the sites, or the site sends me an email alert, it includes a link at the bottom of the email where I can click and view the user account, etc.

The problem is, it seems the domain/url in the link changes randomly, and is not always the domain/url of the actual site it's from. They are all domains I own and are pointing at the box, so it's like drupal does a DNS lookup on itself, then uses one of the returned domains to include in the email instead of the sitename set in the settings.

How can I fix this so emails will include a link to the proper domain they originated from?

Go to:

  admin>configuration>people>account settings

Scroll down and you will see 8 email options for account activities such as account activation, password recovery, etc..

The Default token inside these emails is [site:name] which I presume is what's giving you trouble? Or do you have it set to [site:url]?

Regardless possible next steps:

Manually set the link location by adding something like this to the emails ... (kind of hacky)
"http://www.mywebsite.com"
Add HTML functionality to your emails... and then apply above solution with nice html link markup (still hacky)
Try setting a specific domain as your $base_url in sites/default/settings.php. This will disable the dynamic detection of your base domain...
Failing the above investigate further here:- Your Drupal Site Pretending to be Another.


JavaScript and CSS settings fail unexpectedly: The files were not created Possible Duplicate:
  Drupal Commons site has no style after installation

See the Drupal Commons site running on boysday.org

well how to start. i am new to drupal and I have serious flaws during the installation; Tried it dozens of times.I get warnings about too many files open. Somebody gave me the advice to do the adjustments in the administrative section (admin/settings/performance).

On "Bandwidth optimizations,"  the option "Optimize CSS files" and "Optimize JavaSript files" were enabled. I have tried to switch off; for testing and customize my Drupal Commons install it's better to disable as to have CSS and JavaScript development support with tools like "Firebug" using Firefox.

I tried to do so, and got back a very interesting message.

  Performance

  The file could not be created.
  The file could not be created.

Can this be caused by the fact the folders in /home/vhost/WWW/mysite/sites/default/files were all owned by the wwwrun user? What can I do?

There are no pictures, and no CSS. Is there any right or permission problem?

  warning: array_map() [function.array-map]: Argument #2 should be an array in /home/vhost/WWW/mysite/modules/system/system.module on line 1020.
  warning: array_keys() expects parameter 1 to be array, null given in /home/vhost/WWW/mysite/includes/theme.inc on line 1832.
  warning: Invalid argument supplied for foreach() in /home/vhost/WWW/mysite/includes/theme.inc on line 1832.

As you already suggested, this is most likely a file permission problem. Make sure the entire directory under sites\default\files is writable by the apache user, often this is called www-data.

To get you going maybe download XAMPP for your platform and get your first Drupal installation working locally.


How to get or extract the link path for terms in View I have created a Taxonomy Term view in Drupal 7,  and list out all my terms through "Taxonomy term: Name" field.

Now, I wonder how to extract the link path of each term so that I can reconstruct and adding the passing value through the url.

e.g.

http://www.domain.com/fruit/apple?quantity=100

A quick solution will be:

Use "pathauto" to generate path for term pages (taxonomy/term/term_id => fruit/apple)
Use "global redirect" to force default path to custom paths
In your View build the URL like taxonomy/term/term_id?quantity=100 and should be translated at rendering time to fruit/apple?quantity=100

Thank you.


How do I only allow authenticated users to interact with Organic Groups "groups"? Organic Groups 7.x-2.6
Domain Access 7.x-3.11
Domain Access Bridge (module that ties DA and OG together)

Hello, I am using Organic Groups with Domain Access.
I found I was unable to only allow authenticated users to see/post/subscribe to groups.

Someone mentioned Access Control.  I am using Domain Access and tried installing Access Control on top of Domain Access and Organic Groups.  I was able to only allow authenticated individuals to interact with groups, but I ran into an issue where if a group was set to "private" only group admins could see the group, even if the non group admin was actually a member of the group.  With Domain Access and OG it is not recommended to install another access control module, so it is not surprising this combination failed.

This really seems like this should be a part of OG (a sentiment that I have heard quite a bit on the net).

I ended up answering my own question.
There is no access control with organic groups which disallows anonymous users from seeing public organic groups.
You can use the "Domain Strict" module and have the website that the organic groups is to be hosted on not allow "Anonymous" users to view that domain.  This is a configuration option with Domain Strict.

This has the desired effect.  The only downside is that your domain which hosts your organic groups will not allow anyone who is not authenticated to view any content on said domain.

To change this go to Structure-->domains-->User Defaults
find your domain that will hold your OG groups and uncheck "Anonymous User"
Click save configuration.

Tada!


How to force display of a specific page of paged data I'm displaying a table of dated items ordered from old to new and am using the full pager. How can I force my page to initially display those items that are current ie. on initial load, display the page containing items that are most current (which might be ?page=17). The user can then page back/forwards to get older or newer items. Drupal 8.

I'm half way there!
In hook_views_pre_build(\Drupal\views\ViewExecutable $view) I figured that the $cnt item was the most current; from there it was a simple matter to calculate which page that item would appear on and to set that as the current page.
$pager = $view->getPager();
$defaultPageNum = round($cnt/$pager->getItemsPerPage());
$pager->setCurrentPage($defaultPageNum);

This works like a charm; however, the pager links at the bottom of the page do not auto-magically update and still indicate that I'm on page 1 (instead of page 62).
Anyone know how I get these links to update?


Options set in dynamic multiple select field with ajax are not preserved I am working on a dynamic set of three multiple select list which will function as one field which can be placed inside a form.  The options in the second and third select lists will be set based upon the selection in the first and second selects.

Here is how I create the widget:

function multiselect_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    $options_first = multiselect_first_dropdown_options();
    $value_dropdown_first = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);

    $form['dropdown_first'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'First Dropdown',
        '#options' => $options_first,
        '#default_value' => $value_dropdown_first,
        '#ajax' => array(
            'event' => 'change',
            'callback' => 'multiselect_school_ajax_callback',
            'wrapper' => 'dropdown_second_replace',
        ),
    );
    $form['dropdown_second'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'Second Dropdown',
        '#prefix' => '
',
        '#suffix' => '
',
        '#options' => multiselect_second_dropdown_options($value_dropdown_first),
        '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',

        '#ajax' => array(
            'event' => 'change',
            'callback' => 'multiselect_class_ajax_callback',
            'wrapper' => 'dropdown_assignment_replace',
        ),
      );
      $form['dropdown_assignment'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'Second Dropdown',
        '#prefix' => '
',
        '#suffix' => '
',
        '#options' => multiselect_second_dropdown_options($value_dropdown_first),
        '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
      );

  return $form;
}

And here is an example of one of my ajax callbacks:

function multiselect_school_ajax_callback($form, $form_state) {
      global $classes;
      $index = array_shift(array_values($form_state['values']['dropdown_first']));
      $selected_school = $form['dropdown_first']['#options'][$index];
      $class_array = multiselct_get_subgroups($selected_school, 'organization_group');
      $form['dropdown_second']['#options'] = $class_array;
      $classes = $class_array;
      return $form['dropdown_second'];
    }

When I set the options of the dropdown_second in my ajax callback, it causes the widget to be re-rendered with the correct contents but when I examine the value stored in $form['dropdown_second']['#options'] from any other hook the values I set are not preserved.  If I set $form['dropdown_second']['#options'] from hook_form_alter() the values are preserved but hook_form_alter is not called after my ajax call.  Is there some way to make these changes stick around from my ajax callback or force a hook_form_alter?

You can refer the following example for creating Dependent select list

function multiselect_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    $options_first = multiselect_first_dropdown_options();
    $value_dropdown_first = isset($form_state['values']['dropdown_first']) ? $form_state['values']['dropdown_first'] : key($options_first);

    $form['dropdown_first'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'First Dropdown',
        '#options' => $options_first,
        '#default_value' => $value_dropdown_first,
        '#ajax' => array(
            'event' => 'change',
            'callback' => 'multiselect_school_ajax_callback',
            'wrapper' => 'dropdown_second_replace',
        ),
    );
    $form['wrapper'] = array(
        '#prefix'  => '
',
        '#suffix'  => '
',
    );
    if(!empty($form_state['values']['dropdown_first'])){
        // Code here or call function for  fetching value second and third dropdown
    }
    $form ['wrapper']['dropdown_second'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'Second Dropdown',
        '#prefix' => '
',
        '#suffix' => '
',
        '#options' => multiselect_second_dropdown_options($value_dropdown_first),
        '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',

        '#ajax' => array(
            'event' => 'change',
            'callback' => 'multiselect_class_ajax_callback',
            'wrapper' => 'dropdown_assignment_replace',
        ),
    );
    $form['wrapper']['dropdown_assignment'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#title' => 'Second Dropdown',
        '#prefix' => '
',
        '#suffix' => '
',
        '#options' => multiselect_second_dropdown_options($value_dropdown_first),
        '#default_value' => isset($form_state['values']['dropdown_second']) ? $form_state['values']['dropdown_second'] : '',
    );
    return $form;
}

The basic idea about above example is that use wrapper as a div which will have your second and third dropdown so on change of first drop down form state will be set so it will go into if condition than that will give you the value for the secoond and third drop down


How to override the system timezone in settings.php? I'm trying to override the site's timezone in settings.local.php.
Looking at the config file, this should be simple:
$ more system.date.yml
country:
  default: ''
first_day: 0
timezone:
  default: UTC
  user:
    configurable: true
    warn: false
    default: 0

but I've trying various combinations of this and none of them work:
$config['system.date']['timezone']['default'] = 'Europe/London';
$config['system.date.timezone.default'] = 'Europe/London';

The first example ($config['system.date']['timezone']['default'] = 'Europe/London';) is the correct way to override config values in your settings.php file.
It sounds like you've hit an issue noted in the config override system docs:

Note that values overridden via $config within settings.php will not be viewable from the Drupal administration interface (until #2408549: There is no indication on configuration forms if there are overridden values is fixed, until then you can use Configuration Override Warn or Config Override Inspector) or from inspection via drush (unless you add the --include-overridden flag). The administration interface displays the values stored in configuration so that you can stage changes to other environments that don't have the overrides.

So if you view /admin/config/regional/settings page or the drush cget system.date timezone.default command, it won't show the overridden value.
You can try something like drush cget --include-overridden system.date timezone.default or
drush eval 'print \Drupal::config("system.date")->get("timezone.default");' to confirm your overridden value is actually being set in your settings.php


Drush says it needs Composer, but Composer is already installed? I've recently re-provisioned my development box, and went to run a drush command but was met with

  Unable to load autoload.php. Drush now requires Composer in order to install its dependencies and autoload classes. Please see README.md

I then tested to see if Composer was installed and found it was (version 1.0.3).

Would anyone know what I can do here?

There is a Drupal core isssue about this: Catch error(s) from composer install not being run and return friendly error.

tl;dr

Basically, you need to run composer install from inside your docroot.


How do you expose/display a product type's custom field in a product display? I created a custom field in my product type, but how do i get it to display on my product display when my item is selected? The field doesnt show up in managed display in the product display.

I have been through my settings for my product & it's display to check my settings. I have several fields added to my product which I display on product display. I have Display Suite module enabled at my instance.

So what I have done is - I have checked Full content in my custom display setting tab at my product as well as product display in manage display. You can also do Product -> Manage display -> custom display setting -> full content(check) & save.

I have enabled all fields in my product in full content tab, which looks like --

After that when I visit my product display -> manage display -> full page, I find those field, which I have enabled to be visible. It looks like --


superfish not affected by css edits I am making a nav bar using the suckerfish module. I have installed the suckerfish module and have extracted the library into the necessary folders. I'd like to change the width of the individual columns in the nav, as some of my menu items are getting cut off. I'd also like to change the width of the nav bar as a whole, as it is not the same width as my header. However, when I try to make basic edits in the space-orange.css file, the edits do not seem to make any difference what-so-ever. I can change the style of the nav bar from the blocks menu, so I know the css files are in the right place. I have also looked at the suckerfish.css file, but it's not clear what, if anything, I could try to edit there. I am all out of ideas at this point. Are there any great tutorials out there pertaining to this? I can't seem to find any. Any help in getting me going in the right direction would be most useful and appreciated.

Thanks,

Kev

If some of your menu items are cut off, you should enable the supersubs plugin. You can do that on the block settings page for that particular menu.

If that's not what you want, copy over the stylesheets of superfish to your theme, include them in .info file and play around there.


what kind of views should I use? I am going to download the Views module for a Drupal 7 website I am creating, but there are 2 different versions: There is the alpha3, the development snapshot, and another one that doesn't have a name I can see (it is highlighted in green). Which these three versions should I use?

It is really a personal decision on which one you should download. It is recommended to always download the one's in "Green". However views3 offers a significant improvement in the user interface and if you are just starting out in views, this might be a better choice.

A good article on choosing modules http://drupalwatchdog.com/1/1/module-selection-in-the-wild


Target EntityBrowser in custom validation constraint Having a custom validation constraint on an entity reference field using entity browser as form widget, I am trying to get the field light up in the form on validation violation. This is not working for me.
Using the following code in an entity validation constraint:
      $this->context
        ->buildViolation($constraint->message, [])
        ->atPath('field_entity_reference')
        ->addViolation();

This works fine for fields that do not use the entity browser widget (the field gets marked red indicating an validation error). But for the entity browser widget the field is not marked in the form, though the validation itself is working correct. It seems to me this is related to the entity browser widget. There is this information about targeting specific properties in complex field widgets, which seems to address this matter. But I cannot seem to find a way to target the right property to make the field light up in the form. Entity Browser widget only have hidden form input elements and targeting does not seem to work on container or div fields as far as I can see, so maybe this is the reason this is not working?
Is there a possibility to have the entity browser widget light up in the form on validation violation?

I think this is a limitation of Entity Browser module. Drupal is ultimately using setErrorByName() to add the error to the form and Entity Browser does not provide a name attribute that Drupal can attach it to. So if a name attribute is added somewhere in the entity browser widget Drupal could attach the error. That is, Drupal does only visibly attach the error to (visible) input, select and textareas in the form. Other elements may be targeted and get the class "error" added, but this will not show visibly as an error in the form.
I have created a small module to provide the error flagging for the entity browser widget: https://www.drupal.org/project/entity_browser_validation


How to create a checkbox field in a node for Terms and Conditions I need a field to ensure the users who create a node accept my Terms and Conditions. I've gone as far as creating a boolean field and making it a required field but I don't know how to:

1) Disallow node creation if the checkbox isn't checked, and modify the node creation rejection message.

2) Only make the field required for non-admin roles.

3) Insert a label for the checkbox with html markup so that I can link part of the text.

There are several contrib modules available that enforce users to agree to terms or conditions. Wouldn't it be technically easier and more practical for users to agree to the terms once, when they register? The legal module is quite good for this and has a feature where if you (as the site admin) change the terms and conditions after a user has previously agreed to them, then they can be asked to re-agree to the new terms next time they login.

If you absolutely have to go down your system design path, then:

You could use hook_form_alter() or hook_form__alter() to set a custom validation hook.
Have a look at the conditional_fields module for making it required depending on users role. You could alternatively do this logic in the hook_form_alter() or hook_form__alter() as per #1.
I'm pretty sure the Drupal Forms API won't allow links in the field label, but feel free to correct me. Alternatively you could add the links in the field description or write some jquery to achieve this (albeit a little hacky).

Hope that can help.


How to save a new term with multiple fields while adding content? Not only do I want to add terms as I create content through the UI, but I want to add terms that have multiple fields (i.e. more fields on the taxonomy besides the 'Name' that populates the list). How can this be done?

I'm mixing a few concepts here:

Add terms through the Add/Edit Content page
Display the different fields of a taxonomy on the Add/Edit Content page.

You can use References dialog module with this patch

  This module extends reference fields like the user and node reference fields by adding links to add, edit and search for references through a dialog. This allows for a workflow where the user can create all the references to a node at the same time as she is creating it, a process which sometimes get's a bit backwards, when a user for instance needs to create all the facts for an article.


How can I filter content with a date that is somewhere this week by using Views? I am developing a project in Drupal 7, in this every content have date field by using the Date module.

I am trying to create a block by using the Views module in which I want to display content with its date field containing a date that is 'this week'.

How can I do this?

You simply add the filter criteria to view.

operator type: is greater than
value type: -7 days


Show View When Empty and Hide View When Not Empty! I have a webform as a block which sets a value connected to the logged in user. I want to display the webform if it hasn't been filled in yet by authenticated users, and hide it when it has (based on whether the value has been set or not).

I thought I could do it by using views with the Views Block Area to display the webform as a block when there is no result. But I want to hide the view when there is a result, which seems impossible?

If anyone can suggest how I might be able to achieve this, not necessarily using views.

Limit submissions to "1 ever" when you configure the Webform. I'm not sure if Webform Block module would automatically hide the block if the form is not shown, but it should. Webform will not show the form if it cannot be submitted.


Unable to recognize mysqlnd host I have installed mysqlnd when I try to use the drush command drush cc all, I get the following message.

  No Drupal site found, only 'drush' cache was cleared.

and when I run the command drush ws I get the following message.

  PHP Fatal error:  Call to undefined function module_exists() in phar:///usr/local/bin/drush/commands/core/drupal/environment_7.inc on line 187
  Drush command terminated abnormally due to an unrecoverable error.
  [error]
  Error: Call to undefined function module_exists() in
  phar:///usr/local/bin/drush/commands/core/drupal/environment_7.inc, line 187

If I try to run the above commands without the mysqlnd plugin, they work fine.

Also, if I run drush status I get the following:

 Drupal version         :  7.43
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  myapp
 Database port          :
 Database username      :  drupal
 Database name          :  web1
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.3
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :  /root/.drush/aliases.drushrc.php
 Drupal root            :  /var/www/html/site2
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default

The above won't show the theme name. Also if I try to run drush mysql-cli I get the following message:

  ERROR 2005 (HY000): Unknown MySQL server host 'myapp' (0)

I wonder if I can get the above commands running using the mysqlnd plugin.

The solution was adding the following code in settings.php. It will allow Drush to connect to mysqlnd.

if (drupal_is_cli() || basename($_SERVER['PHP_SELF']) == 'update.php') {
  $databases['default']['default'] = $databases['default']['ms'];
}


How to filter webform results Can someone kindly tell me how to filter the webform results page? For example how can I show only the submissions where column X has value Y.

I am new to drupal but I am an experienced PHP programmer. If someone kindly points out he right webform hooks I will try to figure out the rest.

Suprisingly, google could not help me. But I'm sure that others have faced the same problem before. Please assist.

I am not sure if you still need this information, but for the benefit of others...

You might want to look into the webform_mysql_views module.
If you are using drupal 7+, you can create a simple view of the "Webform Submissions" type. Then, under Fields you should be able to find Webform Submissions: Data Value field. Select that and then add the field you want to show up in your table. Do this for the rest of the fields you want. Finally, add the filters and/or sorts the very same way. NOTE: You might have to add a relationship (the very right drop-down) or two to show you relevant results.

Hope this helps!


Is there simple drupal 7 cart modules? I really need to create a cart system without payment methods , I only want to get an order email from the user. Is there any modules in drupal 7 to do this?

Maybe the Webform module is sufficient in your case?

With Webform you can create forms and form components from an UI. When a submission has been made from a user you can setup mails that should be sent.


Create View with a join on the same content type I am trying to create a View that produces 1 stop itineraries. I have a content type "Route", with the following fields.

From To Method

The data looks like:

From | To | Method
 A   | B  | Method 1
 A   | Z  | Method 3
 B   | C  | Method 3
 Z   | C  | Method 3

If a user searches "From: A", "To: C", the view should return:

From | To | From | To |
 A   | B  |  B   |  C |
 A   | Z  |  Z   |  C |

which ultimately results in B and Z as the intersection points (and a more friendly output to the user).

From | Via | To
 A   |  B  | C
 A   |  Z  | C

For the life of me, I cannot figure out how to produce this join against the route table.

Any advice? I have even replicated the Route content type to "Route 2", and attempted a relationship on the inner "From" and "To" fields of Route and Route 2, but cannot produce this expected output.
Any advice?

Install Equi Join module

  The Equi Join module allows you to create relationships between
  different entities based on an arbitrary field. This allows the use of
  relationships in Views without having to add Node References to a
  content type, which may not be an option when displaying data stored
  on a third-party database or data provided through custom Views
  handlers. That said, it works with nodes as well.

Using only a single content type Route create your view as follows:

Add your from and to fields.
Add a Relationship of Equi Join: Content and give it a name. Set Left field to field_to and Right field to field_from
Add a second set of from and to fields, but set the relationship on
them to the new Relationship you added.
If you wish you can then either remove the first To field or the
second From field.


Exporting menu structure using services Is it possible to to export the menu structure of my drupal site using the services module? This way the website structure can be generated on the drupal website -> make it available for webservices -> acces by mobile in order to build the same structure dynamically in the mobile app.

The Menu API is fairly extensive.  It is likely there is already a function available to return what you need.

For example, you can return an entire menu tree using the menu_tree_all_data().

$navigation_tree = menu_tree_all_data('navigation');

You could also return everything known to the menu router with menu_get_router();

$everything = menu_get_router();


Media Gallery – Gear menu unavailable I created a Media Gallery on my Drupal 7 site and I am using views to output the teaser of all my galleries. Everything works as expected, but the gear menu is missing, that enables the user to delete images from the gallery. The documentation page describes this menu:

Does anybody has an idea what to do?

Check if the Contextual links module enabled. That could be doing it, or if Contextual links is enabled check that you have permission for your account.

This may be related: https://drupal.org/node/1450840

Also check if Views UI enabled. (if needed, may not be relevant)


CCK Field Table in Database and Content Type I am creating some fields in a Custom Created Content type. What I have already seen as per my experience is that their is a table for each field that I have currently in the Content Type. But now I am adding new fields to that content type from 'Admin -> Content Management -> Content Type -> Edit Custom Content Type -> Manage Fields'. Here I am creating some fields but I dont get a table for them. Why is CCK not creating tables for these fields?

Assuming you're using CCK with Drupal 6 here...

Unless a field is set to multiple cardinality, or is attached to more than one content type, there won't be a table created for it. Instead, a new column will be created for it in the CCK table for that content type.

For example, if you have a content type called 'page' with a number field called 'field_number', with single cardinality and only attached to the 'page' type, there will be a column called field_number_value in the content_type_page table; that's where the data is stored.


Is it possible to add menu tab in any menu group? Any idea on how I can render the menu tab item into a menu group?

My goal is to add a user tab in navigation menu group. I tried hook_menu but I cant manage to make it work.

Here's my approach:

function lms_core_menu() {
  global $user;

  $items = array();
  $items["user/$user->uid/myresults"] = array(
    'title' => 'My Results',
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'navigation',
  );

  return $items;
}

Ideas will be greatly appreciated.

EDIT: See the image attached.

Just change

'type' => MENU_NORMAL_ITEM

to

'type' => MENU_LOCAL_TASK

and clear the caches.

The MENU_LOCAL_TASK option will make the menu item render as a tab in the user/% group. If you want to control the tab order you can use the 'weight' key in hook_menu().


How do I (in general) track down what happens on form submit? I am working on a site that uses the Chosen module. There is a field that I need to edit programatically. When I use the actual field edit interface, Chosen adds an option called "Apply Chosen to the select fields in this widget?" When I set that value and submit the form, all is well... it changes what I need changed. However, I need to be able to track down what this is actually doing on the back end so I can change the value of this option for this field programatically... once... in an update hook. The user needs to still be able to edit this value using the form... I just want to flip its value this one time. I don't know where to start looking. In the Chosen module, I can see where it adds the option to the form, but I don't know what piece of data that option is stored with, nor how to see what the form is doing when it saves it so I can duplicate that functionality. It's hard to even know the right terminology to ask this question.

You mean updating the field instance settings programmatically, in an update hook, hook_update_N(). Do it as follows:

function YOURMODULE_update_N(&$sandbox) {
  // First load the field instance.
  $instance = field_info_instance($entity_type, $field_name, $bundle);
  // Make the changes in the field instance configuration.
  $instance['widget']['settings']['apply_chosen'] = 1;
  // Save the field instance.
  field_update_instance($instance);
}


Is there any way to sort by Image Quality? The idea is to sort Images in views from lowest to the highest quality (not only size).

Ex:

Image A = 640x480 100ko (blurred darkened)

Image B = 480x320 50ko (detailed)

Sort

1 - Image B

2 - Image A

The only way that I see is calculate image quality when it's saving and use it later.
How to do it:

Extend your file entity via module File entity
Add special field to store value for image quality.
Save value of quality into this field each time when file is saving. For example via hook_entity_presave
Sort by this field in your views

How to calculate image quality? Here is good example
but you can use your own approach to do it.

P.S. Yes it looks a little tricky but I don't think that it's possible to do it easier. But if it's possible I'll be happy to hear it.


ajax form, send data from js modal to form I have the following form:

When I click the "Add Filter" button, I need to open a modal with a select input element. Then I need to send the user's choice back to the Drupal Form instance and extend the original form, based on the user's input.

I'm not sure of the best way to do this. 2 options I've thought of are:

Is it possible to have the "Add Filter" ajax callback send an "OpenModalDialogCommand" with a new form, then have the new form "submitForm" method send the data to the original form?
Another possibility would be to collect the data clientside and send it to the original form.

However I'm not sure how to get the user data into the original form in either of the options above.

I have worked on a similar case in D7.
Take a look at these tutorials.
https://www.deeson.co.uk/labs/insert-form-pop-modal-ctools-and-drupal-7
http://internetdevels.com/blog/big-manual-for-creating-ctools-popups-in-drupal-7


Are there migration plugins for D8 sources? I found 2 references here for migrating D8 to D8, but both are very outdated.

Certainly there will be a need to do D7 -> D9 or D8 -> D9 migrations for many, but there are also current use cases. One is migrating from a multisite to individual sites.

Mine is the site restructuring its content types, and it would be far simpler to add custom code to a source plugin than to do all of it in custom code.

Yes there is. Drupal core has a content_entity source plugin that's a part of the Migrate Drupal module.

The one caveat with this plugin is it can only handle scenarios where the source/destination DB is the same, which sounds like your scenario here.

If source/destination DB isn't the same, the Drupal 8 migration provides a d8_entity source plugin that does support this scenario.


How is a TypedData value validated? I do not understand how the Boolean (just for example) is validated. This is my code:

$tdm = \Drupal::typedData();
$data = $tdm->create(array('type' => 'boolean'), 1000);
drush_print_r($data->validate());

The $data->validate() returns a list of ConstraintViolations, but where is the logic of these constraints, per Drupal\Core\TypedData\Plugin\DataType\Boolean does not implements getConstraints method.

Thanks

Primitive types are special case.

By default, they get the PrimitiveType validation constraint in TypedDataManager::getConstraints().

<?php
// Auto-generate a constraint for data types implementing a primitive
// interface.
if (is_subclass_of($type_definition['class'], '\Drupal\Core\TypedData\PrimitiveInterface')) {
  $constraints[] = $validation_manager->create('PrimitiveType', array());
}
?>

Validation constraints are usually provided in one of the following places:

The plugin annotation (see e.g. EntityReferenceItem)
base field/property definitions (see e.g. Node::baseFieldDefinitions(), title field)
By overriding the getConstraints() method on a typed data class.


How do you embed an external URL (to a software application) in Drupal with 508 compliance? We need to embed a software application (by URL) into a Drupal 7 site. The resulting page needs to be Section 508 compliant. I have been told that iFrames are not Section 508 compliant. That is what we used in the past. Is there an alternative that is accessible?

I can't find a single reference on Google that says iFrames aren't section 508 compliant...however they will fail compliance if you do not:

  Provide alternative content for IFRAME elements

iFrames can contain nested alternative content, like so:

Description of the loaded content

The rationale listed for this is:

  Some browsers do not support the IFRAME element, or do not have the ability to load multiple documents together. It is therefore necessary to provide alternative content for this element even if the IFRAME only loads HTML.

This information came from here, but all of the other links I found on Google said exactly the same thing in one way or another.


Secure Way of sending argument from one page to another In my Drupal Page I have one l() function as follows:-

l('View Comments','admin/comments', array('query' => array('commentid' => $rinap_comm['record_id'])

So in this case I am passing the argument to new page 'admin/comments' using 'commentid'. The url will look like this:-

http://XXXX/someURL?commentid=15

In new page I will retrieve the value using

$commentId= $_GET['addUser'];

This is all fine to get and set argument using GET function.
But I didn't find it secure way to transfer confidential information from one page to another as the value will get appended in URL which can be visible to everyone.

Can anyone please suggest if there is more secure way of passing the information without visible to end user? If possible please brief me the steps.

You can symmetrically encrypt the data into a cipher before sending it, and decrypt it at the receiving page.  This will not stop anyone from seeing the encrypted data, but they will not have access to the encryption key and will therefore not be able to understand the data.

If the data to passed is short, the encrypted data can be passed in the URL.  To use an URL, just base-64 encode the resulting cipher so it can be represented by a string (and base-64 decode it at the receiving end to get back the cipher).  Remember to decrypt to convert from the cipher to the original cleartext.

If the data is too bulky to fit in an URL, you may use a session variable to transfer the cipher.  Then you can skip the base-64 encode/decode step.  A session variable is not secure. However, just as with the URL, encryption will keep the data confidential.

Or, you can simply use pass the data using the database.  This requires you to create a very small custom module that associates the data with a token that does not give away any information (e.g. an integer).  You then pass the token by means of the URL, e.g.:

http://XXXX/someURL?tokenid=15

The receiving page then use this token to look up the data in the database.


Make link translatable in Admin from a PHP string in a tpl-file In a custom user-login-block.tpl.php file i want to make a link in the Create an Account -button which links to /doctor/register. Here the link to the example page (you are redirected to this page from specific nodes who needs permission (by Content Access module).

How do i make this link in PHP so i am able to make it multilingual and translate it in Administration » Configuration » Regional and language » Translate interface to:

benl/doctor/register (for Belgium dutch site)
befr/doctor/register (for Belgium French site)

I think i need somehow the base_url because otherwise it gives the string from the restricted page (in this example benl/producten/injectables).

How do i manage this?

Update:

To make it more clear this is my HTML:

    <?php print t('Create an Account'); ?>

So where is written HERE THE LINK i have to insert the php-code.

You can use path aliases for this. Go to /admin/config/search/path/add and create a new alias with the following settings:

Language: Dutch (or whatever it is called in your site)
Existing system path: 'doctor/register'
Path alias: 'dokter/registreer' (or whatever suits your fancy)

Repeat for the French site. Drupal core and contrib modules should automatically pick up the language-dependent aliases. If you're creating a link in a template yourself, make sure you use the l() function to build the entire <a> tag. To get the result in your question, you need something like this:

<div class="well">
  <?php
    $link_options['attributes']['class'] = array('btn', 'btn-large',' btn-primary');
    print l(t('Create an Account'), 'doctor/register', $link_options);
  ?>
</div>


Twig & Drupal: state of art 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.

Twig is in Drupal 8 core, but you can use it in Drupal 7.
Check out this sandbox that provides twig as a theme engine.


Calculating Course cost per student My Scenario:
One admin user is entering these information.
I have 3 content types: student, register, course.
Student is obvious, i.e. student_number, personal_info, etc
Course contains: course_name & course_costs, etc.
Register contains: ref to course, course_date, ref to students who attend this course.

My question: How would I go about calculating/working out costs per student, per course?

Do I need to use rules? I assume commerce is out of the picture, as one admin user is entering this information. Any direction would help. Thank you.

Is this value stored on the Register Content Type?

You can use the computed_field module.

You will need to read every value in ref_to_course field. Load each of those nodes. From there, read the course_cost and add the values.

Then store the values on the computed field.

Another option is using views module. You can attach a View to the content type. The view can then use the node NID, read the ref_to_course. Add relationship, read the course_cost and add those.

I think the first might be better since you calculate it once.


Can a form triggering an ajax call reload itself on drupal 7? I'm trying to built a page to ask questions with a stream on top, so I need ajax to avoid the reload. It is actually simple. On top is a node with the stream and I add to blocks beneath.

A table with the questions, number of votes for the questions and an "add vote" button
A form to add a new node "question with 0 votes"

I have two problems.

A)When I click on the submit button of the 2. Block I add a question, I can update the table with the new question, but the add question form is not being emptied.

B)When I add a vote on the table (currently an ajax call from a checkbox) I get the database to have an increased counter and as far as I could check the callback delivers the new table, but the old one is never replaced. I thought it was the cache, but I even managed to avoid using the cached one, still no replacement. I get a few headers allready sent notices, but I don't understand why. I just want the form to be replaced by the new one.

(don't mind me getting a view instead of just a database result, it's just to built the table)

function questions_list_voting_form($form, &$form_state){
global $user;
$form['#prefix'] = '
';
$form['#suffix'] = '
';
$form['table'] = array(
        '#tree' => TRUE,
        '#theme' => 'table',
        '#header' => array(t("Title"),t("Votes"),t("Add vote")),
        );
    $view = views_get_view('questions_view');
}
$view->is_cacheable = FALSE;
$view->execute('block');
foreach ($view->result as $row){
    //['rows']['row-'.$row->nid]
    $question = array('#markup'=>$row->node_title);
    $vote = array('#markup'=>$row->field_data_field_votes_field_votes_value);
    $addvote = array(
    '#type'=>'checkbox',
        '#return_value' => 'add_vote'.$row->nid,
    '#ajax' => array(
      'callback' => 'ajax_addvote_callback',
      'wrapper' => 'question-list-table',
        'effect' => 'slide',
    ));
    $tab_arr = array(
            'question' => &$question,
            'vote' => &$vote,
            'addvote'.$row->nid => &$addvote
    );
    $tab_rows = array(
            array('data' => &$question),
            array('data' => &$vote),
            array('data' => &$addvote),
    );
            $form['table'][] = $tab_arr;
    $form['table']['#rows'][] = $tab_rows;
    $form['redirect'] = FALSE;
    $form['#rebuild'] =TRUE;
    unset($question);
    unset($vote);
    unset($addvote);
       }
     return $form;
}
function questions_list_voting_form_submitx($form, $form_state){
   if(substr($form_state['triggering_element']['#value'],0,8) == 'add_vote'){
    $tmp_node = node_load(substr($form_state['triggering_element']['#value'],8,2)); //question node
    $tmp_node->field_votes['und'][0]['value']++;
    node_save($tmp_node);
   }
}
function ajax_addvote_callback($form, &$form_state){
questions_list_voting_form_submitx($form, $form_state);
$form_state['no_redirect'] = TRUE; // avoid redirect?? maybe not working
$form_state['input'] = array('test'=>'etch'); //something to avoid cache
$form = drupal_build_form('questions_list_voting_form', $form_state);
$form_html = drupal_render($form);
return $form_html;
}

Your form id is 'questions-list-table' but you have 'wrapper' => 'question-list-table' (letter s is missing). You might also want to be explicit with 'method' => 'replace' since the ajax is causing problems.

You should add a '#submit' => 'submit_function' and modify your $form_state in that function instead of trying to modify it in the ajax callback.

Why do you rebuild and render the form in your ajax callback? I think you just want to return the part of the form to replace - in this case, $form itself.


Installing in a sub-folder of Angular I have an Angular 2+ application running. I would like to install Drupal in a subfolder and have my Angular application to iframe the contents.

Ideal Folder Structure:

/             - Angular
/content      - Drupal

I have an existing rewrite rule to rewrite all URLs to index.html. Drupal works fine with pages like http://myapp.com/content/admin, but if I am accessing a page like http://myapp.com/en/page, it will be redirected to the index.html file of the Angular application.

How do I configure Drupal to make it add /content to its URLs?

I am hosting them on IIS. These are the rewrite rules I have now.

<rewrite>
  <rules>
    <clear />
    <rule name="HTTPS Redirection" stopProcessing="true">
      <match url="(.*)" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
    </rule>
    <rule name="Angular Routes" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="./index.html" />
    </rule>
  </rules>
</rewrite>

Finally got it working, the following are the changes I've made. I am writing this here in case anyone faces the same problem.

I noticed there was another web.config file in root of Drupal folder (/content) and it contains a few rewrite rules.
I've changed the last rewrite rule which rewrite all requests to index.php, it now looks like this:

<!-- Pass all requests not referring directly to files in the filesystem to index.php. -->
<rule name="Short URLS" stopProcessing="true">
  <match url="^(.*)$" ignoreCase="false" />
  <conditions>
    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
    <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
  </conditions>
  <action type="Rewrite" url="/content/index.php" /> <!-- CHANGES IN THIS LINE, ADDED '/content'/ in front of index.php -->
</rule>

Modified .htaccess file in root of Drupal folder and added this line RewriteBase /content, below this line # RewriteBase /
Modified the web.config file in root folder of Angular App (/) to the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- Install IIS url rewrite module. -->
  <system.webServer>
    <rewrite>
      <rules>
        <clear />
        <rule name="Angular Routes" stopProcessing="true">
          <match url="(.*)" negate="false" />
          <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{URL}" pattern="^/content/(.*)$" negate="true" />
          </conditions>
          <action type="Rewrite" url="./index.html" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

</configuration>


CKEditor violates layout borders in Drupal 7 In Drupal 7 the CKEditor violates border of left column (where it should be) and penetrates into right column. Now, I can not resize it because when I resize borders of CKEditor by dragging resize button, the icons (image tabs) of CKEditor does not react and does not obey to this act and still remain in right column, although the very borders of editor are changed. In other words CKEditor icons not only violates borders of my site layout, but also it's own CKEditor borders. I should mention that this nuisance occurs only in my Chrome and Opera browsers, while, for example, in Firefox everything is ok. Version of CKEditor is 3.6.5. and by following some suggestions I tried to fix this problem by putting library of 3.6.6. version but no solution found. How can this be solved?

Install CKEditor module directly instead of use with wysiwyg module.


How do I resolve Access Denied message I created 2 roles on my site: Buyer and Seller

I used auto assign role to allow the user choose a role on sign up.

I then created an additional profile for seller using profile 2. (The buyer is supposed to be logged in immediately he signs up)

Using rules, i tried to redirect the user who chooses the seller role to the page setup with profile 2, but it comes up with access denied, you are not authorized to access this page.

Kindly assist.

The redirection is happening before the login is processed, hence the error. The way I'd handle this would be to do the check when the profile page is viewed, rather than during the login process. So the trigger for the action is on viewing a page, specifying the user view page and adding a condition that the user being viewed is a seller.