texts: What is the underlying logic for generating an icon map for a custom registered layout?

texts:
There seems to be a dearth of information on the internet about how to generate an icon_map for newly registered layouts in Layout Builder.
I've gotten as far as finding a patch file from the project that includes a poorly-documented comment that unfortunately doesn't shed much light on this:
/**
 * Builds a render array representation of an SVG based on an icon map.
 *
 * @param string[][] $icon_map
 *   A two-dimensional array representing the visual output of the layout.
 *   For the following shape:
 *   |------------------------------|
 *   |                              |
 *   |             100%             |
 *   |                              |
 *   |-------|--------------|-------|
 *   |       |              |       |
 *   |       |      50%     |  25%  |
 *   |       |              |       |
 *   |  25%  |--------------|-------|
 *   |       |                      |
 *   |       |         75%          |
 *   |       |                      |
 *   |------------------------------|
 *   The corresponding array would be:
 *   - ['top']
 *   - ['first', 'second', 'second', 'third']
 *   - ['first', 'bottom', 'bottom', 'bottom'].

...

It doesn't say why we'd use keywords like first, third, and bottom — or even what each term actually means to the Layout Builder module. There doesn't seem to be any rhyme or reason as to how this is supposed to work. The documentation is also severely lacking.
What is the underlying logic behind the generation of icon maps, and how does it actually work?


texts: Difference between hook_page_alter and preprocess_page?

texts:
I don't completely understand when I should use hook_page_alter(&$page) or template_preprocess_page(&$vars, $hook) in Drupal 7.

What is the best practices about that to use in template.php?

Thanks


texts: How to have CCK "Select list" field on my content type?

texts:
I want to include in my content type a CCK "Select List" field.
Which module(s) should I enable so as to have it as a choice?
Thanks


texts: How does Drupal know which Entity View Mode to use?

texts: When Entity View Modes are defined, how does Drupal know which to use? Are they only useful with Views, or can they be used in the node display as well? If so, is that specified in the template, or somewhere else?


texts: How to port active configuration to module configuration

texts:
Scenario: I have a website which was initially developed with a single site (A) in mind. Now, because reasons, I need to make this a multi-site setup (A & B). So, I have functionality in A I want to share with B. We built A with all config exported to it's config sync folder, which means all config is intertwined.

Problem: How would I go about converting all sharable configuration to modules, which would allow me to maintain the modules from one codebase in both A & B? Putting everything into module_foobar/config/install/ will not work that easily for A, since it already has that config in it's active config.


texts:
I have a website, built as a non Drupal commerce website. I want to add functionality to my website so customers can buy books, and add checkout page and cart.
I mean add commerce functionality in a not Drupal commerce site.

Can I do that?


texts: Can the Feeds module work with get parameters?

texts:
Is there a way that I can use the Feeds module in Drupal 7 to connect to an API which requires specific get parameters to interact with?

The reply that the API gives will be in a simple XML format. The valuable information will be included in Content. This data will be in JSON format. I want to use this data to be put in a form which users can edit and submit back to the (API) server.

Is this possible? If not, what other solution can you recommend me?


texts: Is there a way to send a newsletter to those users who share a taxonomy term in there profile

texts: I need to be able to collect newsletters for a specific type of content. This content will have tags that the user will also check on when the sign up or edit their account information. I then need to send this newsletter to all those associated with that taxonomy list.


texts: Is there a way to write something like a fieldformatter/widget but for exposed filters shown in a view?

texts: Here for example, I would like to make a widget or some way, that I can use this type of drop down always for one type of exposed filter, such as a published status. Thanks!


texts: Search API for searching in existing Solr Core

texts:
I'm using Drupal 8 with Search API and Search API Solr Search.

I'm tasked with making an existing Solr installation searchable within Drupal. This core indexes PDFs and serves other systems, thus I may not edit the schema there. It can be assumed that this schema has fields like "author", "title" and "abstract".

I tried the following:

Add a server in Search API: This seems to work as I see the (correct) number of indexed documents in Solr.
Add an index with "Solr Document" as data source. I can see fields from the Solr core here.

However, in the View tab, I always see "0/0 Indexed".

Am I missing something here or is perhaps the wrong approach?


texts:
I want to load taxonomy terms by tid, but I didn't found how. Only how to load taxonomy by name, but now I have term id and I need to get value of fields.

I call this on public function build() for custom block.

My code:

$terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('menu');
foreach ($terms as $term) {
    //var_dump($term->tid);
}


texts:
I've created UnitTest based class for my service.

In one of my tested methods from service class I have code like:

if ($node->hasField('field_foo')) {
  $section = $node->field_foo->entity;
}

I've created mock for Node class and I know how to "emulate" hasField. However, how to mock this line:

$section = $node->field_foo->entity

I'd to set $section to be a Term object (or mock). Is this even possible?
Now my test falls with an error:

  Trying to get property of non-object

but this is clear why. I'm using just mock, not real Node object.


texts: How to enter text in a fieldset's summary?

texts:
Using the form api to create a fieldset:

$form['fieldset'] = array(
 '#title' => 'title',
 '#type' => 'fieldset',
 '#collapsible' => TRUE,
 '#description' => 'desc',
);

Drupal will output:

<fieldset class="collapsible form-wrapper collapse-processed" id="edit-fieldset">
  <legend>

        Hide
         title

  </legend>

      asdf
      <input type="text" id="edit-testelement" name="testelement" value="" size="60" maxlength="128" class="form-text">

</fieldset>

The #title in the form array will be the  you click on to expand the fieldset.  I want to put text in the , which puts additional, non linked text beside the title.  I can't seem to do this with the form api, as #description will only put text within the fieldset that is hidden when it is closed.

What's the easiest way to do this?


texts: Assigning a page title to forms created with the form API FAPI

texts:
I have a moule called newsl witch display a page containing a form.
I would like the way to specify the page title.
Is it with drupal_set_title() ? How to call it ?


texts: Disable profile field when module that created it is disabled?

texts: I have created a module that adds a field to the user profile. When I disable the module, I want the field to no longer be shown on the user profile. I do not want to wipe it out completely, since I do that on uninstall. I want it to come back with the original data when the module is reenabled I just want to have it not display when the module is disabled. Is there a way to do this? I am using Drupal 7 and the field is a text field and it is set to the default formatter when I create the instance. Is there a setting I can set the instance to in hook_uninstall that will hide it?


texts:
I have a view with exposed filters which only returns results when a filter is applied and it all works fine. I also have a block underneath the view which I only want to show before a filter is applied. I have set the block only to display on a url for example

  /view

which is the path of my view, when you apply filters the url path becomes

  /view?var=arg

at this point I don't want to display the block


texts: How to use different value from select options vs what's displayed? Name vs Realname

texts:
For adding multiple members to a group (course in opigno), I implemented the chosen module for better UX on the select options but instead of displaying usernames I want to display realnames.

Using $account-realname in the user loading loop displays them but after submission it breaks, as I think it expects to receive name instead.

  $form['massadd']['#options'][$account->uid] = $account->realname

$gid = current($form['group_ids']['#value']);
$node = node_load($gid);

$form['massadd'] = array(
'#type' => 'select',
'#title' => t('Select students to add to the group'),
'#required' => TRUE,
'#multiple' => TRUE,
);

$users = entity_load('user');
 foreach ($users as $uid => $account) {
  if ($uid && !in_array($uid, $exclude)) {
    $form['massadd']['#options'][$account->uid] = $account->name; // tried realname instead
  }
}

...

 $form['submit']['#weight'] = 0;
  // We validate our own way.
  unset($form['#validate']);
  $form['#submit'][] = 'opigno_simple_ui_form_og_massadd_massadd_form_add_roles';
  $form['#submit'][] = 'opigno_simple_ui_form_og_massadd_massadd_form_add_state';
  $form['#submit'] = array_merge(array('opigno_simple_ui_form_og_massadd_massadd_form_prepare'), $form['#submit']);


texts: Local simpletest drupalGet() always gives "returned 0 (0 bytes)"

texts:
I want to run tests locally with simpletest module.

I tried this with the cli scripts/run-tests.sh, and also in the admin UI.
I tried different tests shipped with Drupal 7 core, such as the ContactSitewideTestCase test.

Whenever a test wants to make a http request with $this->drupalGet(), the test reports a fail saying e.g. "GET http://d7git.localhost/user returned 0 (0 bytes)."

I think to remember that something needs to be configured for simpletest to make http requests. But I cannot remember what it is, and cannot find documentation that would explain it.


texts: login box appears as a drop down down box on clicking a tab in main menu

texts: i want to have the login box displayed on the front page as a dropdown box when login tab in menu is clicked...i have added the tab and now on clicking it takes me to node/user as i have set the path to it...however i want that when menu is clicked a drop down box appears having field to enter the username and password..and then login and forget password etc..can someone help me on this...have searched a lot on this but to no avail...


texts: How do I implement a one page navigation with anchors?

texts:
So the specific functionality I'm looking for is a link on one page (e.g. drupalsite/home) leading directly to a specific section of another page (e.g. a section on drupalsite/otherpage).

I believe that to implement this I need to use hash based navigation such that the content I want to link to is has it's css class name preceded by a hash (pound sign or number symbol)
 and is linked to by including the hash referenced content in the href attribute of an anchor tag. Such that
 on page drupalsite/mypage via .

Will this work without out of the box with just HTML changes? Or is additional JavaScript configuration necessary?

I know that more specific and fluid implementations will necessitate JavaScript and jQuery, but I want to know if the core HTML works without conflicting with Drupal's internals.


texts:
Hey my team is planning on moving our current project to Drupal and we're looking for what modules would help with our current functionalities. Here's a user story for more insight:

"User 1 has an inventory of items. Each item has a certain number of "points" attached to it. User 2 desires an item from User 1's inventory and has the appropriate amount of points to give User 1 for the item. An transaction occurs in which the desired item from User 1's inventory is sold to User 2 and the corresponding amount of points for the item are deducted from User 2's total points and added to User 1's point total."

I'm thinking we might have to end up adding our own custom code but if anyone knows of a Drupal module or anything that would make things easier, that would be greatly appreciated.


texts: How to add multistep registration form in default user registration

texts:
I need to create a user registration form in Drupal 7. My requirement is as follows:-

I want to use the default Drupal 7 User Registration Form i.e admin/config/people/accounts
Form must appear in popup/modal when user click on "Create new account" in User Login Form
Form should be Multistep i.e there will be 3/4 steps of filling the form.
Customize the form in such a way that UserName, Password and Email
appears on last step of the form.

Please let me know if it is possible in Drupal 7 default user registration form and how?


texts: Passing arguments to a node with an alias url

texts:
There is a similar issue in here:
Passing an argument to a node causes 404

But there is no real viable solution.
I tried using the sub-pathauto module but the restiction of 8 arguments is too little, since the urls will look something like this:

www.site.com/alias/key/value-1/key/value-2/key/value-3/key/value-4

and it can go on for a while.
It works when instead of alias i have node/nid.

Is it possible to have it work with any amount of dynamic arguments?


texts: Using a Third-Party API to dynamically create pages

texts: I have a Drupal website that I'm working on where for section of it, I want to pull data in from an external API and dynamically create pages with this data. Do I need to create a custom module for this? I'm not too sure where to start with this, so any advice would be appreciated!


texts:
I've created one menu to be placed on the left column and with context it will be repeated on the footer too.
The difference is that the footer menu has to be already expanded and show all the child.

I can use  this code below to make it as expanded

function mytheme_menu_link_alter(&$item, $menu) {
    if($item['menu_name'] == 'menu-about-us')
    {
        $item['expanded'] = 1;
    }
}

How do I targer the menu in the footer?
How should I use the function mytheme_preprocess_block(&$variables) ?

Thanks in advance.


texts:
I have a site on my local server which is served by Apache using virtual hosts. I am using an omega sub-theme. On the desktop everything works fine.  I try to browse to the site via the iPhone by changing the web proxy setting to point to my server. That works and I get to my site via Safari on the phone. Every link I go to on the site gives me a page not found. I'm using views on the site as well.  Looking at the Apache access log I see the entry for Safari that results in a 404 and then Chrome when I browse on my laptop which succeeds.

Any thoughts on where I should start looking for the problem?

octopus.dev:80 192.168.1.106 - - [01/Oct/2012:11:00:52 -0500] "GET http://octopus.dev/ HTTP/1.1" 404 5756 "http://octopus.dev/" "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3"
octopus.dev:80 192.168.1.147 - - [01/Oct/2012:11:01:30 -0500] "GET / HTTP/1.1" 200 7475 "http://octopus.dev/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4"
octopus.dev:80 192.168.1.147 - - [01/Oct/2012:11:01:31 -0500] "GET /sites/default/files/videos/original/output_file_2.mp4 HTTP/1.1" 206 390 "http://octopus.dev/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4"
octopus.dev:80 192.168.1.147 - - [01/Oct/2012:11:01:31 -0500] "GET /favicon.ico HTTP/1.1" 404 661 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4"


texts:
I want to use Drupal to make a forum where users can post either as text or upload images. This can be achieved with the Comment Upload module.

However if you attach an image and try to post without any text, you get an error message saying 'Comment field is required.'.

Are there any solutions to this? Is it possible to remove the validation causing this issue?


texts: View of most recent nodes, one per taxonomy term selected

texts:
Drupal 6 Views 2.x

I am looking to create a view that lists the most recent node from a selected list of taxonomy terms.  However, I only want it to display the most recent item from EACH term.

So if I select term 1, term 3, and term 7 it will list the most recent node that was tagged with that term, grouped and distinct.

Something like this:

Term 1:
Title
Body

Term 3:
Title
Body

Term 7:
Title
Body

Is this possible to do with a single view? I would prefer it to be one view instead of creating a bunch of different views that return 1 item per category which would be possible.  The other thing I am hoping it would do  is if a node is tagged with both term 1 and term 3, it would only show up once, ie on term 1, and then when it gets to term 3, it would select the next most recent node since the most recent one was already displayed.


texts: How to create statistical reports about data contained in various content types?

texts:
I have page in drupal for hockey league. Till now, there was only nodes, some specific content types, simple views, but now, they want to create full statistics for the entire league. I was looking for some modules, but unsuccessfully.

My friends from this league want to type final score of match and system will know who is winner, credit points and calculate any other statistics data for team. I was trying to create something like this with rules, but I failed. I dont know ho to get SUM of fields from one content type, then calculate some value and get it to another content type, filter some values in views and get it to another view for his filtering.

I think that rules, views are insufficient for this. I need help, what way to choose.. trying do this in modelus or best way is to learn module development and create my own module to do this?


texts: How do I change html structure of menu (primary links for example) to my own?

texts: The default HTML structure of the primary links menu is not what I'd like it to be. How can I override it with my own version?


texts: Image Field Style URL from EntityMetadataWrapper?

texts: Does EntityMetadataWrapper support reading the URL of an image field for a specified image-style? I thought I had done this before but I can't find it documented anywhere or any code in the tests for EntityMetadataWrapper.


texts:
I'm looking for the best way to approach creating relationships using Drupal 7.  I am looking for advice on creating the following:

1) A "letter" content type (as in an old fashioned letter)
  a) From Person (i.e. "John Doe")
  b) Associated From address ("12348 Street")
  c) To Person
  d) Associated To address
  e) Postage Date
  f) File attachment of scanned letter

2) A person can have one or more addresses (I am recording some family history of letters sent and people have changed addresses over time)

3) Ability to select the Person/Address in the Letter content type for the From / To Person.

I've been reading the documentation, but I'm just unclear on the best approach.  Would appreciate suggestions. For example, I started out creating a field for From Name and To Name and From Address and To Address, but realized I'd be creating a lot of redundant data and that it would be better to create relationships, but am not sure how to accomplish that.  Should I create a Person Content type?  If not explicit instructions, would appreciate a general point in the right direction.


texts:
On the server I am hosting my website, PHP was upgraded to a newer version which is not supported by Drupal version 4.
There is a script and a description for doing the upgrade in Drupal version 5, but this script does not run with the new version of PHP either.
Is there any other possibility to upgrade?


texts: How to do a Library Override in my theme for dialog.ajax.js

texts:
I’m trying to do a libraries-override to the dialog.ajax.js file appearing in /core/misc/dialog/. (Want to replace it with a js file from my theme, let's say at mytheme/js/dialog.ajax.js)
In my theme’s  *info.yml file, I tried
libraries-override:
  drupal.dialog.ajax:
    js:
      assets/js/dialog.ajax.js: false

as another post suggested (just to try and disable it). Didn't work.
My confusion comes from not knowing how to correctly target the /core/misc/dialog/dialog.ajax.js file within my override, and then correctly target my mytheme/js/dialog.ajax.js as a replacement.
I reviewed the documentation, but it's still quite unclear. Any tips? Thanks!


texts: Can a pager item point to an anchor on the page?

texts: I'm building a page where, somewhere down in the middle of it, there's a pager of some stuff.  The pager is working fine, but, when you click on one of the pager items, the page is redrawn showing the top of the page, which usually does not include the (now updated) contents of the pager.  This is because the pager item URLs simply refer to the page as a whole.  Is it possible to get a reference to an anchor inserted into the URLs of the pager items, so that the browser will redraw the page with the pager contents in view?


texts: how to use user_save with custom column?

texts:
I added custom column in users table, i would like to use user_save to create new user programmatically. How can i do that? This code doesn't work for custom columns:

$new_user = array(
                        'name' => 'Foo',
                        'pass' => $pwd,
                        'mail' => $email,
                        'signature_format' => 'filtered_html',
                        'status' => 1,
                        'language' => 'en',
                        'timezone' => 'Europe/Berlin',
                        'init' => $email,
                        'custom' => $custom_string,
                        'roles' => array(
                            DRUPAL_AUTHENTICATED_RID => 'authenticated user',
                            $role->rid => $role->name,
                        ),
                    );

                    $new_account = user_save(NULL, $new_user);

Everything except custom gets inserted, if i am not wrong it's default drupal columns for each user's table. Thanks


texts: What causes the error "Call-time pass-by-reference has been deprecated?"

texts:
My understanding is that objects in PHP 5.3 are all passed by reference so using the &$ notation is not necessary. My problem is using date_views module where I'm getting this error.

Deprecated function: Call-time pass-by-reference has been deprecated in
 _registry_check_code() (line 2701 of C:\wamp\www\cruzr\includes\bootstrap.inc).

The affected lines of the code are:

  // $type is either 'interface' or 'class', so we only need the first letter to
  // keep the cache key unique.
  $cache_key = $type[0] . $name;
  if (isset($lookup_cache[$cache_key])) {
    exit;
    if ($lookup_cache[$cache_key]) {
      require_once DRUPAL_ROOT . '/' . $lookup_cache[$cache_key];
    }
    return (bool) $lookup_cache[$cache_key];
  }

How do I test if a variable is passed by reference? With several classes being loaded how do I approach debugging this problem?


texts:
I wrote code to select records from the database, but it is causing the following error:

  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error
      in your SQL syntax; check the manual that corresponds to your MySQL server version for the
      right syntax to use near 'FROM pricepackages pricepackages' at line 1: SELECT FROM
      {pricepackages} pricepackages; Array ( ) in view_packages() (line 25 of D:\xampp\htdocs
      \talyllyn\sites\all\modules\pricepackages\pricepackages.module).

What is wrong with the code I am using?

function view_packages() {
    $list = '
';
    $query = db_select('pricepackages')->execute();
    $i = 0;

    while ($record = $query->fetchAssoc()) {
        $list .= '
';
        $list .= $record['packageName']."	";
        $list .= ''.$record['packageDescp']."	";
        $list .= ''.$record['pPrice']."	";
        $list .= '
';
        $i++;
    }

    $list .= '
';
    return $list;
}


texts: $user-> removeRole('administrator') doesn't remove role

texts:
I got php code that is suppouse to remove one role and add a new one to all users in given array. But unfortunatelly it just add new role but doesn't remove one. I tried alphanumeric values as $rid and straightforward numeric $id but still no effect. I tried putting error_logs inside loops and it's executed and printed to error_log.php.
Here's my code
foreach($users as $usr){
            $user = user_load_by_name($usr);
            $user->addRole('roleToAdd');
            $user->save();
        }
        foreach($users as $usr){
            $user = user_load_by_name($usr);
            $user->removeRole('roleToRemove');
            $user->save();
        }
}

Array
[0] => client1
[1] => client4

#edit
I think it is worth to mention that roleToRemove is assigned to every new user that is registered using registration role module
FIXED check answers


texts: Displaying a field of an entitiy reference

texts:
In my Page content type there is an image field called gallery, and an Entity reference field refering to a related page.

I need to display the images contained in the gallery field of the related page.

I have created a Display Suite a code field. In the tokens I found [node:field-related-page:field_gallery] but it seems to be empty (it prints nothing).

I have used Devel's dpm() method to display $entity's content but it does the related page fields do not contain any info about the gallery (which makes sense as recursion could be an issue):


texts: Why does the default image for an image CCK field not show in a view?

texts:
I have a File/Image CCK field with a default image set and the Use default image checkbox is checked.
I am rendering this field in a view- but the default image does not show for nodes where an image has not been uploaded.

How do I get the default image to show in a view?

Ive tried re-uploading the image, re-setting the checkbox, clearing cache. FYI, if I do upload an image, it does show in the view.

Any further ideas?


texts:
I'm using Drupal (v7.21) with Pathauto and Advanced Forum and would like the paths to be formatted like:

domain.com/forum
domain.com/forum/the_topic_name
domain.com/forum/the_topic_name/the_post_name

Under Forum Paths 'Pattern for forums and forum containers' is set as:

[term:vocabulary]/[term:name]

And under Content Paths I've set 'Pattern for all Forum topic paths' as:

[node:taxonomy_forums]/[node:title]

This is working except for the Posts which are missing the /forum/ part:

domain.com/the_topic_name/the_post_name

I could manually get this to work by setting the 'Pattern for all Forum topic paths' as:

forum/[node:taxonomy_forums]/[node:title]

But I'd rather have it set using a pattern if possible.

Any ideas?


texts: Sending email notification based on flagged node being linked via entity reference

texts:
I need to send an email notification to followers of a node, when another node that is linked, has been created.

Example:

Users follow "location" type (e.g London) by flagging that node using
the flag module and 'follow' type.
Author creates a "blog" type (e.g. Things to do 2014!) and links it to their location via field_location [entity reference].
When published, send email to all followers of
the "location" type.

Can anyone recommend the way to do this with rules or point me in the right direction?

Thanks,
Paul.


texts: Configuration Management Module Keeps Saying 'needs attention'

texts:
I've just started using the configuration module to keep my Drupal database in sync between my development and live environments.

Documentation for this module is sparse, and I'm trying to understand how it works.

I went to the UI and started tracking a single custom content type. It goes ahead an tells me it is tracking that content type, plus all its custom fields and everything which is great.

But then when I go to the 'tracking' tab, it lists all the stuff it is tracking, and in the side tabs, it says that things 'need attention', for example the 'content type' tab says '1 needs attention'. Yet, when I look at the status of the tracked configurations, it simply says 'In sync'.

What exactly 'needs attention', and how do I make it stop saying this?


texts: Drush migration no longer working in 8.5

texts:
I've been migrating a site from Drupal 7 to Drupal 8. The site was 8.4 when I ran the migrations. I've since updated the site to Drupal 8.5. Now, when I type drush migration-status or any migration-related command, I get the following error:

[error]  The file_entity plugin must define the source_module property.


texts: node.html.twig gets cached while other templates do not

texts:
I disabled cache with the command

  drupal site:mode dev

I have overridden html.html.twig and node.html.twig.

If I change something on html.html.twig and refresh the page, the changes take place.

If I change something on node.html.twig and refresh the page, the changes do not appear, unless I also clear the cache or edit the node.

If I open the same page with a different browser, changes do take place, but if I make another edit and refresh, it won't work.

So I thought of some kind of browser caching, but clearing the caches in Chrome doesn't help.

How can I force Drupal to re-read node.html.twig without clearing the caches or editing a node everytime?

Thanks!


texts:
I have noticed that users who upload their images from iPad or iPhone have their images sometimes rotated in odd directions. I am not a Drupal guru and I generally find that documentation on drupal "how to" is ..well.. scarce,,

I have spent some time looking into this and did not find anything that would effectively help me.

What I would like to accomplish seems simple in principle but I need help.

Rather then forcing users to rotate images (they find that to be clunky and awkward I have an average user who is interested solely to have things happen simply and without hassle) I would like to have ALL my images on the site checked for orientation and have them automatically display the images in proper orientation.

I came across a module called Imagecache Actions and it is supposed to have Autorotate capability but I have no clue on how to use it for what I need.

ALL help would be greatly appreciated!


texts: How do I wrap classes around taxonomy terms?

texts: I need to add CSS to individual terms for a taxonomy field.  Where is the best place to do that?


texts: Cache rebuild take a long time and block all user request

texts: The main problem I have is cache rebuilds, which take a while, and block all user requests until the rebuilds are complete. I would like to find a way to make it so the rebuilds aren't quite as deadly during high-traffic times


texts: Can a large amount of CSS using  tags in a template file slow page load time?

texts:
Front page of a site has a HUGE amount of CSS in the front.tpl.php file using  tags. Does this significantly reduce page load time? If so, why?

Thank you Drupalists! Or Drupaleers. Drupaleeros. Drupal-Heros!


texts: How to iterate over all the nodes from a content type

texts:
I want to recover some info from a field of all the nodes of a specific content type.
I know how to do it using a db_query and getting all the node ID then iterate over them.
What I would like to know is if there's is another way around this using drupal functions.


texts: Expiration of cached pages stuck at 6 hours

texts:
No matter what I change in the GUI, after clicking save the Expiration of cached pages under Performance options is reset to 6 hours. I checked my default VCL for Varnish suspecting this might be something set there, but couldn't find a 6 (hours) or value of 21600 (6 hours in seconds) there.

I'm pretty new to Varnish so not sure if it might be some default value, or what that could be called (or if Varnish is the culprit here at all, just a hunch).

We need to have Varnish keeping pages cached indefinately by default, and caches to only get cleared when content updates.


texts: Alter the result of a view with regrouping, supplementing original values

texts:
I tried to create a similar question before but it was unclear, hopefully I can narrow it a little bit:

So I'd like to create an authors-article webpage, such as: http://www.bmj.com/content/350/bmj.h2747 As you can see  workplaces (affiliations) are displayed as footnotes in a separate block, after the list of authors.

I'm working on reproducing something similar with views. I have two content types (article and author) and authors are connected to articles with a node reference field. All the necessary data have been queried with a view and I'd like to alter $view->result with the help of a views_pre_render() hook:

function mymodule_views_pre_render (&$view) {

    if ($view->name == 'publi_author_views' && $view->current_display == 'panel_pane_1') {

        $workplaces = array();
        $workplaces_clean = array();
        $workplace_display = "";
        $workplace_count = "1";
        $author_display = "";

        foreach($view->result as $authors) {
            $workplace = $authors->field_field_publi_workplace[0]['rendered']['#markup'];
            $workplaces[] = $workplace;
        }

        unset($authors);
        unset($workplace);

        $workplaces_clean = array_unique($workplaces);

        foreach($workplaces_clean as $wp_clean) {
            foreach($view->result as $authors) {
                $author = $authors->node_title;
                $workplace = $authors->field_field_publi_workplace[0]['rendered']['#markup'];

                if ($wp_clean == $workplace) {
                    $authors->node_title = $author." ".$workplace_count."";

                    $authors->field_field_fake_title[0]['rendered'] = array(
                        '#markup' => $author." ".$workplace_count."",
                        '#access' => TRUE,
                    );
                }

            }

            $workplace_display .= "".$workplace_count." ".$wp_clean;
            $workplace_count = $workplace_count+1;
        }
    }
   }

I have two problems:

How can I add to authors the number in superscript? As you can see in the code above I appended it to $authors->node_title, but it doesn't display HTML-entities. Then I created a "fake" field (field_field_fake_title) but it hasn't been rendered.
How can I add the list of workplaces to a separate block? I created the $workplace_display variable with the necessary HTML-code but I wasn't able to put it into $view->result since it doesn't really belong to any of the rows.


texts: How to keep checkbox checked after form submit

texts:
I am trying to keep checkbox "checked" after form submit and page load. I have following simple code from .module file.

    <?php

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

  $items['examples/my_module'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Example Form', //page title
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('my_module_form'), //put the name of the form here
    'access callback' => TRUE
  );
  return $items;
}

function my_module_form($form, &$form_state) {

$form['terms'] = array(
        '#type' => 'checkbox',
        '#title' => t('Your checkbox'),
    );
  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Click Here!'),
  );

  return $form;
}

function my_module_form_submit($form, &$form_state) {
  $form['terms']['#default_value'] = 1;
  }

?>

How can I achieve this?


texts: Display average using computed from multiple fields

texts:
I have multiple fivestar rating fields that I want to calculate using the computed fields module. I was able to display the average using PHP but I need to have the computed fields module input my average into the DB for the node.

   $total =
          $content['field_business_q1'][0]['user']['#item']['average'] +
          $content['field_business_q2'][0]['user']['#item']['average'] +
          $content['field_business_q3'][0]['user']['#item']['average'] +
          $content['field_business_q4'][0]['user']['#item']['average'] +
          $content['field_business_q5'][0]['user']['#item']['average'] +
          $content['field_business_q6'][0]['user']['#item']['average'];
            $total = $total / 6;
    echo "Total Average: " . $total;

 if ($total <= 20) {
      echo '';
      } elseif ($total >= 21 && $total <= 40){
      echo '';
      } elseif ($total >= 41 && $total <= 60){
      echo '';
      } elseif ($total >= 61 && $total <= 89){
      echo '';
      } elseif ($total >= 91){
      echo '';
      }

Thats the PHP I use to get the average of averages... But that is only an aesthetic display. I need to use computed to get the average into the DB so I can use that field for a search criteria. I've tried with the sample code the computed field module gives you out of the box.. but I couldn't even get it to display a string.. or display at all for that matter.

EDIT: So I've been able to wrap my head around the computed field after lots of trial and error. I realize that what I need to do is query the database and retrieve the value of specific fields from the content type. Problem is, am not sure of the proper way to do a query using the computed fields. I found a question on here that had the following sample code which i've modified to try and get the values I need. Another Problem is, I need to retrieve values from the comment of the node. So I'm not sure "$nid = $node->nid;" Will work. I will try this a post results.

$nid = $node->nid;
$result = db_query('SELECT field_buiness_q1_rating FROM hts_field_data_field_business_q1 WHERE entity_id = :nid', array(':nid' => $nid));
$entity_field[0]['value'] = $result;

RESULTS:

  Error message
      Notice: Undefined variable: node in eval() (line 1 of /sites/all/modules/computed_field/computed_field.module(394) :
  eval()'d code).
      Notice: Trying to get property of non-object in eval() (line 1 of /sites/all/modules/computed_field/computed_field.module(394) :
  eval()'d code).
      PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_buiness_q1_rating' in 'field list': SELECT
  field_buiness_q1_rating FROM hts_field_data_field_business_q1 WHERE
  entity_id = :nid; Array ( [:nid] => ) in eval() (line 2 of
  /sites/all/modules/computed_field/computed_field.module(394) :
  eval()'d code).

EDIT: Tried the following code;

$select = db_query('SELECT * FROM {hts_field_data_field_business_q1}');
$tally = "";
foreach ($select as $row){ $tally = $tally + $row['hts_field_data_field_business_q1']);}
$entity_field[0]['value'] = $tally;

RESULT: Didn't get a query error but it doesn't save anything into the db.


texts:
I have one node type and two page types for this node.

http://site.com/themes/*

and

http://site.com/years/*

And i want to hide one of the "view-filed" in all "years" pages using the css.

Found this but it doesn't work

function mythemename_preprocess_page(&$variables,$hook) {
  $alias = explode('/',drupal_get_path_alias(request_uri()));
  if($alias[1]== "years") {
   $vars['theme_hook_suggestions'][] = 'years';
  }
}

https://groups.drupal.org/node/130944#comment-762483

I would be very grateful for any help.


texts: What is a good module that allows maintainers of nodes?

texts: Im on D7. I have nodes on my site that represent businesses. I want the business owners to be able to edit info about their business even if they didn't create it and I want multiple people to be do so. It would be nice if I could assign a user to a business giving them per node permissions. Any suggestions? thanks.


texts: contextual and downward filterable tagcloud

texts:
I am not sure how I would properly and clearly explain this question. What I am looking for in general is a tagcloud that is sensitive to context. So it will only list the tags that are relevant to the content that you are looking.

Let's say you have a repository of links all of which can be tagged freely. On the highest level (the entry archive page) you will have a tagcloud that shows all the tags that exists. Once you will click on one of those tags, it will list all the links that are tagged with that specific keyword. However, the tagcloud will now not show ALL tags, but just an aggregation of all tags within the context of the tag on which you have already filtered. Quite an abstract explanation. Let me try to give an example. Let's say you have 5 links, which are tagged comma separated:

Link1: tag1, tag3
Link2: tag1
Link3: tag2, tag5
Link4: tag3, tag5
Link5: tag4, tag5

So, on the highest level, you will have a tagcloud that shows all tags: tag1, tag2 ... tag5. Let's say you click on tag3. On the archive page of tag3, you will only see tags that are relevant to that tag, in this case: tag1, tag3, tag5 (see Link1 and Link4, both are tagged with tag3, but have tag4 and 5 additionally)

I hope I could make it a bit clear. Any clues on how to accomplish this with Drupal?


texts:
my current menu links are generated but those are not the alias urls as follows:

theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('class' => array('nav nav-pills'))));

I would like that the menu generated is with alias urls instead the 'content/name-of-node'. How do you generated menu with alias path links? Is there function i can get only array of links for the main manu, so i can parse out the html myself? Thank You for help

p.s. This is Drupal 7.


texts:
I wonder if there is a good, and easy way to get all fields of an entity.

I have a taxonomy vocabulary. Its terms have a special field I want to make list in a select box in one of my modules, so that users can select a special value of the term. Therefore, I need a way to list the possible fields for this term.


texts: How duplicate order automatically with commerce 2

texts:
How do I automatically duplicate an order?
I use Drupal 8 and Drupal Commerce 2. I need to duplicate some orders, each week, automatically.

Orders have a Boolean field (recurrent_order). When the field is filled, the web site has to create the same order at the end of the week.

I have achieved this with rules and VBO on Drupal 7: On maintenance task, a rule finds an array filled by a VBO view, and a component duplicates the content.

In Drupal 8 there isn't VBO view access from a rule.

How can I achieve this? Regards,


texts: Missing tabs in Media Library widget in Drupal 8.8

texts:
I'm trying to set up Media Library widget in Drupal 8.8. But for some reason, no tabs are available for selection in the widget settings. Please see following screenshots:

Do I need to install some additional module? I wasn't able to discover any settings, which would allow me to do this.


texts:
I'm using Drupal VM and the Drush Launcher (0.6.0). Whenever I try to Xdebug, PhpStorm notices, but it never actually reaches my Drush command. It stops at running Drush. This seems to have started recently.

My command looks like:

XDEBUG_CONFIG="remote_enable=On remote_connect_back=Off remote_host=192.168.90.1" PHP_IDE_CO
NFIG="serverName=example.wizonesolutions.com" drush -l example.com module:custom-command


texts: "CSRF validation failed" when try to send POST request in custom module

texts:
This is my full codes. I want to create a node with service post method. But I cant post. "CSRF validation failed".

I followed this tutorial: https://www.youtube.com/watch?v=Wz2uaRF9RGc

Anyone suggest something.

<?php
/**
* Block Info
*/
function mymodule_block_info(){
$blocks['mymodule_testing'] = array('info' => t('Mips Testing Block'));
return $blocks;
}

function mymodule_block_view($delta = ''){
$blocks['content'] = '
MIPS Testing Block
';

/* POST Request */
$post_data_results = mymodule_create_requested_data();

return $blocks;
}

/* Create data with POST Method */
function mymodule_create_requested_data(){
$path = $_SERVER['HTTP_REFERER'] . 'serve/node';

$node_type = 'apply';
$node_title = 'This is title ' . date('c');
$node_body = 'Node Body';
$node_format = 'filtered_html';

$node_data = '{
    "type": "'. $node_type .'",
    "title": "'. $node_title .'",
    "body": {
        "und": {
            "0": {
                "value": "'. $node_body .'",
                "format": "'. $node_format .'"
            }
        }
    }
}';

$node_options = array(
    'headers' => array(
        'Content-Type' => 'application/json',
        'Cookie' => mymodule_application_authentication('test', '123'),
        ),
    'method' => 'POST',
    'data' => $node_data
);

return drupal_http_request($path, $node_options);
}

function mymodule_application_authentication($username, $password){

if(isset($_COOKIE['mymodule_authentication_name']) && isset($_COOKIE['mymodule_authentication_id'])){
    return '' . $_COOKIE['mymodule_authentication_name'] . '=' . $_COOKIE['mymodule_authentication_id'];
} else {
    $login_url = $_SERVER['HTTP_REFERER'] . 'serve/user/login';

    $user_data = '{
        "username" : "'. $username .'",
        "password" : "'. $password .'"
    }';

    $user_options = array(
        'headers' => array('Content-Type' => 'application/json'),
        'method' => 'POST',
        'data' => $user_data
    );

    $result = drupal_http_request($login_url, $user_options);
    if($result->code == '200'){
        $user_data = json_decode($result->data);

        setcookie('mymodule_authentication_name', $user_data->session_name);
        setcookie('mymodule_authentication_id', $user_data->sessid);

        return '' . $user_data->session_name . "=" . $user_data->sessid .'';
    } else return FALSE;
}

}


texts: How to create a content type with associated products and customized attributes?

texts:
I am creating a little CRM at work and I have two content types:

Offers - with some text fields and references to users and companies.
Products - very simple with SKU, Title, Price

Now I want to attached some products to Offers and then alter their attributes like price, add quantity and then display all this as a view with the total amount of all prices sum together.

The final goal is to have multiple offers referencing products but with own price and quantity.

I hope this is not to confusing? I tried already entity reference but then I cannot at a custom price or quantity to those products.


texts: How to add predefined text to contact form?

texts: I would like to add a couple paragraphs of predefined text (not an input field) to my contact page.  What are my options to do this in Drupal 8?  Until this point I've been using JS to get the job done.


texts: Display content by specific groups of users

texts:
Is it possible to display content by a group of authors without using a group module? I like the group module, but it's much more complex and robust than what I need it for.

Synopsis: We need to build a page that will display blog posts by not one specific author but by a group of authors dynamically and preferably contextually. The authors will not have control over this page or interact with it in any way. There will be dozens of these groupings of authors. The page will also display a view block of biographies for the authors that can be linked to the author's Drupal profile.

Edit: screenshot of my contextual filter using the selected answer below; pastebin of exported view


texts:
My D7 site uses Hebrew as it's default language, and though, an application such as SEOquake told me that the language is undetected. now, that's not an SEO question and it has really nothing to do with SEOquake, i just use it as an example for the given situation of an external device not detecting the language.

I have been told to add the following input, but i have no clue how to do it on Drupal, not even at the TPL files (if it's even a starting point), the input:

<html dir="rtl" lang="he-IL">

How could i apply this to all pages of the site?

Thank you very much.


texts: Create a CSV file dump/feed whenever item of Content Type A is created

texts:
I need to create a CSV dump/feed whenever a new item of "Content Type A" is created, with only that new item's info in the CSV. How can this be accomplished? For example, if 100 new items of "Content Type A" were created today, there would be 100 separate CSV files with the field values for each of those content items.

Thanks!


texts: looping an image field with multiple values? alt or text?

texts:
I am about to implement a img gallery in a  node template. The gallery has the usual HTML markup (a span with bgimage, wrapped by a div...) I do not have any knowledge on php, but - in the last 24h - i was able to modify some code snippets i found:

    <?php
$node = node_load($nid);
$image = field_get_items('node', $node, 'field_project_image');
$image_url =file_create_url($node->field_project_image['und'][0]['uri']);
foreach ($image as $key=>$value) {
$output = field_view_value('node', $node, 'field_project_image', $image[$key], array(
  'type' => 'image',
  'settings' => array(
    'image_style' => 'thumbnail', //place your image style here

  ),
));

print '
';
print '';

print '';

print '';

print 'title of the img???';

print '
';

}
?>

This works somehow. BUT: it always shows the same picture. (Apparently it is always the same image_url), plus: I don't have any idea how to implement the "title" or "alt" text for every single image. Please, I am in a serious need for help now...


texts: How to use simple modal jquery plugin to get a dialog of table?

texts:
I want to show a popup when I click on a link which is basically done by jquery plugin simple modal.
In my template.php file,

function theme_name_preprocess_page(&$variables) {
    drupal_add_js(drupal_get_path('theme', 'theme_name') .'/js/jquery.simplemodal.1.4.1.min.js');

    drupal_add_js(drupal_get_path('theme', 'theme_name') . '/js/theme_name.js');

}

function theme_name_process_views_view_field(&$vars) {
// $plus_icon is a variable defined inside this function.
 $output = "$plus_icon";
 $output .= "

";
 $vars['view']->result[$key]->field_field_flag[0]['rendered']['#markup'] = $output;
}

And in the theme_name.js file

(function($) {
    Drupal.behaviors.abc = {
('.abc-modal').click(function (e) {
                var key = $(this).attr('id').replace(/^abc-modal-(\d+)$/, "$1");
                $.post(Drupal.settings.basePath + 'queue-log', {nid : key},
                       function(data) {
                           if (data) {
                               $('#abc-modal-content-'+key).html(data.html);
                               $('#abc-modal-content-'+key).modal();
                           }
                       }, "json" );
                return false;
            });

.....
How can I get the simple modal jquery plugin working so that when I click on a link mentioned in $output variable() I get a popup displaying contents.


texts: drush Invalid argument supplied for foreach() backend.inc:709

texts:
I have aegir setup, I'm trying to cache clear on all the sites in remote platform machine but failed with below error.

drush @sites cc all
You are about to execute 'cc all' non-interactively (--yes forced) on all of the following targets:
Continue?  (y/n): y
Invalid argument supplied for foreach() backend.inc:709

Would be great if some one had any idea to overcome.


texts: What's overriding my local_settings.php?

texts:
I'm using a local_settings.php file, that includes several $conf settings. All of the settings were working as expected until just recently when the mail_system setting started getting overridden somehow.

Now, if I run $ grep mail_system local_settings.php -A2, I get:

$conf['mail_system'] = array(
  'default-system' => 'DevelMailLog',
);

...yet, the output of $ drush vget mail_system is:

mail_system: Array
(
    [default-system] => DefaultMailSystem
)

I've always assumed that whatever was defined in the settings.php (or in this case the local_settings.php) would trump the same variable defined elsewhere. I've checked all the other variables I'm setting inside the $conf variable in the local_settings.php and they're set as they are in the file.

Where else might mail_system be getting set that would override the $conf definition?


texts: In Drupal 8, I need to verify a route exists or not in a custom module. How can I achieve this?


texts: Getting the base drupal dir in JavaScript

texts:
I am writing a module that does ajax calls through the uses of javascript (not the Drupal ajax engine) to its Drupal installation, which in my case is {host}/drupal7.

My Ajax call should call "{host}/drupal7/notifications/get" from any page. Yet when I do my ajax call from javascript it calls "{host}/notifications/get" now this seems like an easy fix. Yet I can't think of a way to compose the right URL in a way that it will work in any installation.

Can anyone point me in the right direction?


texts: content type showing as link but not in "node_type" table

texts:
In the development of a Drupal7 site, I have used various methods of creating profiles for customers of the site. One of the methods involved using a rule to create content for user who creates an account.

Unfortunately, this method did not work out, so the plan changed. At this point, the content type that was created by the rule cannot be removed and is showing up in the list of options for creating content, but is not in the node_type table in the MySQL database. I cannot seem to be able to remove this content type from showing up on such list.

The content type is not showing up under the content types administration interface, but it is showing under the add content list given to users who want to add content.

What methods can i take to manually remove a content type from the list of options given to a user in creating content?


texts: Views Template for first Block being applied to all

texts:
I have a View called News which has about 10 different block displays in it serving various roles. I created a template for the first block (not block_1 and not the master) in order to apply some unique structure.

Though the changes are seen on all the blocks in News.

Based on the template suggestions for the block I need it to apply to, it suggests the following.

Display output: views-view.tpl.php, views-view--news.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--block.tpl.php, views-view--news--block.tpl.php

I'm using views-view--news--block.tpl.php since its the most granular of the options.

Is there another I should use?


texts:
I'm trying to load a user by it's uid via an Entity Query, this seems to work, however i'm missing my custom fields defined on the Entity User.

I'm getting all the default fields like 'username', 'email', ... but custom fields like 'field_firstname', 'field_lastname' aren't being loaded from the database.

I would like to keep using entityQuery, as the code is being reused for other entities, where the custom fields seem to load fine.

This code is being used in a module which dynamically loads entities based on mergefields used in an Email Template. If there is a mergefield {{user.name}} I need to dynamically load the user entity and fill in the value in the standard field name.

This works fine, but when using {{user.field_firstname}} the field field_firstname is not found.

This is my code:

$user = loadEntity('user', 'uid', $userId);

function loadEntity($entityName, $idField, $id) {
    $query = \Drupal::entityQuery($entityName);
    $query->condition($idField, $id, '=');
    $result = $query->execute();
    $store = \Drupal::entityManager()->getStorage($entityName);
    $id = array_shift($result);
    return empty($id) ? null : $store->load($id);
}


texts: Creating a view to show nodes with multiple aliases generated by Path Module

texts:
I got a tough problem that I don’t even know how to start, any help would be appreciated.

I am on a D6 site.  The Path Module is installed and there are articles that have more than one alias because the previous admin didn't overwrite the previous alias when saving the new ones.

I am doing a data migration and the migration is grabbing the old alias and not the new one.

What I need to do is find all NIDs that have more than one Path aliases, display them, delete the old one with bulk views

When I create a view to show field Path, it only displays the current one. Any thoughts how to display both aliases or any other way to tackle this.

Thanks for looking!


texts:
I have created a website for neighborhood on d7 for a society of 400 apartments. We need to collect data from each user (like is he a tenant or a owner, his profession, his car registration no, members in the family with age, and respective ID cards to verify and arrange facilities membership card, carparking,maid  access etc. I had accomplished this questionre by using webform,and only later I understand that this is more meant for survey one way. I cannot again use this data and give user a option of edit. example if the user changes his car / maid he should be able to change it online. Data collection from the users have not yet been started.  What would be the best way to collect this type of data and later be used in views, this also has conditions /logic based question example if he is a owner he has a different set of questions and if he is a tenant then different set. Around 3-4 logic questions are involved.

I don't know php. But love drupal.

Thanks.


texts:
In Webform 7 I was able to add classes to the Previous / Next Page button but can't seem to be able to do this with Webform 8.

Is there a way to do this?


texts: How do I redirect user_view_page to user_profile_form?

texts:
I do not really need the user_view_page on my site and I want to redirect calls to user/%user to the user_profile_form. I only want this change for regular users, not for administrators.

I already tried to accomplish this with hook_menu_alter, but that would change it for all users including the administrator.

How can I do this?


texts: Disable /Enable a multivalued paragraph field on Ajax calls

texts:
I have 2 fields in a form. One select list and another entity reference field referring to a Paragraph type (multivalued).
The on-change event should trigger an ajax callback which will disable some of the fields in the paragraph type.
I managed to achieve this on ajax callback. Now, the problem is when I add more values to the paragraph the previous disabled field goes back to the default state.
Any suggestions /examples will be helpful. Below is my code.
Thanks.

    function hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {
      //Ajax callback on change event
      if (isset($form['field_link_type'])) {
        $form['field_select_sample']['widget']['#ajax'] = array(
        'callback' => '_my_ajaxcallback',
        'event' => 'change',
       );
      }
     }

    function _my_ajaxcallback(array $form, FormStateInterface $form_state) {

      $response = new \Drupal\Core\Ajax\AjaxResponse();

      //disable field_htext of paragraph field
      $response->addCommand(new \Drupal\Core\Ajax\InvokeCommand('.field--name-field-htext input', 'attr', array('disabled', 'disabled')));

      return $response;
    }

Updated code -
In my callback -

    echo 'disabled - ' . $form_state->get('field_header_disabled');`
    $form_state->set('field_header_disabled', TRUE);`
    echo $form_state->get('field_header_disabled');
    return $response;

The output is something like - disabled - 1 on both first and second callbacks. On second callback I'm expecting the output to be something like disabled - 11


texts:
I need to display an image when a user is online. Like the button of skype that it say if the user is online on skype's system.

How can I "check" if a user is online ? Is there a light module or I need to create a new one ? I don't need any type of block o stats about this user, only know if he is online or not.

Thanks.


texts: How can I have a view reset when an exposed title filter is emptied?

texts: I have a view that simply lists content. I have one exposed filter "Title" for users to filter content that "contains" and text they insert. I have set the exposed filter to Autosubmit as they type with ajax turned on. The problem is that if the user deletes what they have added to the exposed title filter, the view isn't reset. It stills shows the results of their previous submission. I can of course add a reset button but is there any way to have the view reset itself when the exposed title filter is emptied by the user?


texts: How do I create translation without default language content?

texts:
In Drupal 8, my default language is English, but I also have German. How can I create a content item that will only be available for German, and not in English? In other words, how do I created "translated only" content?

When I add new content, I can use the Language select box, but it still creates content available in the English language.


texts: Why can't I access my custom fields in Rules?

texts:
What I want:
I want to give my products a weight and I want to calculate the total weight of the order.

What I did:

I'm using Drupal Commerce Kickstart 7.x-2.0.
I added a field 'weight' to the Product Variation 'Product'.
I created a custom Rule
Added a condition 'Entity is of type': commerce-line-item == commerce_product
Tried also to add or replace the condition above with the conditio 'Entity has field': commerce-line-item has field 'field_weight'
Create a Loop Action for commerce-line-items
Add a Loop Action but don't find the field 'field_weight'

Can someone explain me why I can't access my custom fields in Rules even though I added specific conditions?

Thanks in advance!


texts: Counting table entries that are not numeric in views

texts:
I have a table view which lists names of hotels in column A and in columns B-D I have columns that contain scores for 'location' 'room cleanliness' and other things. These particular fields are made up of text lists with the following reviews:

'no mention'
'positive'
'negative'

and are made up of Check boxes/radio buttons

What I want to know is how to count all the reviews up ('no mentions' 'positives' and
'negatives')

at the bottom of each column. I can't use Views Calc or aggregation as these are not numeric entries. It also seems extremely long winded to create a view for each scoring thing ('location', 'room cleanliness') then add a filter to each one with negative, positive etc etc

Does anyone know the best way to do this or if indeed I have set the fields up correctly?

Thanks for any advice.


texts: I have a custom field named "field_blurb." Is it possible to make this the text shown in a teaser instead of the default which is from the body field?


texts: Views Slideshow - How to add link on Pager that can link to original page?

texts: Views Slideshow on Drupal 7 has a feature that can “Activate Slide and Pause on Pager Hover”. How can I add link on Pager, so when click, it actually link Pager to original piece of content?


texts: Ajax returned values do not update when field value changes

texts:
I have an ajax form element, age, that I'm passing to a query within an ajax callback. The callback generates some product information and returns it as a part of the form array.

The problem is this: if I update the age field, the callback is fired, the query is re-run, and the wrapper is refreshed, however it isn't updating the wrapper div with the new information, it's reloading the initial information.

The code lives here: http://pastebin.com/vUrCMX7c

Any help is greatly appreciated.


texts: How to redirect to referenced entity form with Rules

texts:
I use drupal commerce. I have several entityform type. Each product has entity reference to one of these forms. How to page redirect to referenced form url when a product added to cart.

Thanks


texts: hook_menu parameter can contain a forward slash

texts:
I've built a custom module to get cloudinary images and it works great. However, a bug has cropped up. You can navigate to /cloudinary/resource/public_id and it gets the image with public_id. On cloudinary there is now the ability to specify folders, so a public id could be something like "unitedstates/public_id". This is wrecking my hook_menu:

function cloudinary_menu() {

    ...

    $items['cloudinary/resource/%'] = array(
        'access callback' => TRUE,
        'page callback'  => 'get_resource',
        'page arguments' => array(2)
    );
...

Is there any way to specify that anything after /% should be passed?


texts: How to clear page cache without rebuilding other caches

texts:
I have a large site which uses Drupal cores 'page caching for anonymous users'.  I have made some javascript changes which I need to deploy.  Since pages are currently cached I will need to clear the page cache.

I am wondering if there is a way of only clearing the page cache?  If possible I don't want to have to rebuild any other caches (e.g. menu).

I know Drush provides a certain level of granularity when it comes to caching; however, it would appear that Drush is not capable of only clearing the page cache

$ drush cc

Enter a number to choose which cache to clear.
 [0]   :  Cancel
 [1]   :  all
 [2]   :  drush
 [3]   :  theme-registry
 [4]   :  menu
 [5]   :  css-js
 [6]   :  block
 [7]   :  module-list
 [8]   :  theme-list
 [9]   :  registry
 [10]  :  metatag
 [11]  :  token
 [12]  :  views


texts: Is there any way to export user account information and content profile together?

texts:
I need to export all the information of a few user accounts and relevant content profile nodes together per user.
It doesn't matter what format it should be but I'll eventually import back to the same site.

It seems that View Bulk Operation does the job but in the Views I must include all the profile fields,CCK fields and all the rest of the information the account and the node has.
So it's just not realistic in my case.

Is there any way I can export all the data that belongs to one user ?


texts:
Creation of custom tokens / placeholder for Drupal 7. I searched many forums to get any help regarding the creation of custom tokens but I failed in getting a proper solution that's why I decided to post this topic to help drupal users.

hook_token_info
hook_tokens($type, $tokens, array $data = array(), array $options =
array())
token_replace($text, array $data = array(), array $options = array())

For creating custom token we will use three token api function.

<?php
/**
* Implements hook_token_info(). This hook will register tow token lname and fname.
*/
function myhook_token_info() {
  $info['tokens']['custom']['fname'] = array(
    'name' => t('First name'),
    'description' => t('First name re placer for fname '),
  );
  $info['tokens']['custom']['lname'] = array(
    'name' => t('Last name'),
    'description' => t('Last name re placer for lname '),
  );
  return $info;
}

/**
* Implements hook_tokens(). This hook will operate the token and replace it with it's value.
*/
function myhook_tokens($type, $tokens, array $data = array(), array $options = array()) {
    $replacements = array();
    $sanitize = !empty($options['sanitize']);
    if ($type == 'custom') {
        foreach ($tokens as $name => $original) {
              if (array_key_exists($name, $data)) {
                  $replacements[$original] = $data[$name];
              }
        }
    }
    return $replacements;
}

/**
* Here we will use the token_replace() function to get the actual content after replacement.
*/
function myhook_myfunction() {
    $custom = array();
    $custom['fname'] = 'Rajat';
    $custom['lname'] = 'Gusain';
    $data = $custom;
    $temp = "Full name : [custom:fname] [custom:lname]";
    $temp = token_replace($temp, $data);
// After token replacement $temp variable will contain " Full name : Rajat Gusain"
}
?>


texts: Facebook Oauth and sending messages to facebook users

texts:
I have Facebook OAuth and Facebook Connect installed on a site. We need to be able to periodically send a message to one of our member's Facebook inbox who logged in with the Facebook Connect.  I've looked all over, and haven't had much luck.

Can anyone point me in the right direction?


texts: Aggregated SUM from "Referencing entity" relationship, how to include nodes without relationship

texts:
I have two content types - contact and payment. Payment have field_contact that is an reference to contact and also field_payment_amount which is decimal.

In views I'm showing list of contacts (with filter by type = contact) but also would like to show SUM of payments for given contact. I added relationship: Entity Reference: Referencing entity to entities that are referencing my contact by field field_contact, turned on aggregation, and added to view field_payment_amount aggregated as SUM, and using my relationship. In this configuration all contacts are shown but field that should show my sum is empty.

Next I added another filter (by type), now using my relationship and for this relationship filtering by type = payment. In this configuration I can see my sums - great! But! If contact have no payments - it is excluded from table completely.

How can I show contacts without payments with "0" as sum of payments and calculate proper sums for contacts with payments? I feel like I'm missing something simple, or maybe not?

Added:

Ok, I reduced problem to most simple case, and analyzed query. Now interesting thing is that looks like the same query executed manually by me, and by view - gives different results O_o .

Query:

SELECT node.nid AS nid, MIN(field_contact_node.nid) AS field_contact_node_nid, 'node' AS field_data_field_payment_amount_node_entity_type, SUM(field_contact_node__field_data_field_payment_amount.field_payment_amount_value) AS field_contact_node__field_data_field_payment_amount_field_pa
FROM
{node} node
LEFT JOIN {field_data_field_contact} field_data_field_contact ON node.nid = field_data_field_contact.field_contact_target_id AND (field_data_field_contact.entity_type = 'node' AND field_data_field_contact.deleted = '0')
LEFT JOIN {node} field_contact_node ON field_data_field_contact.entity_id = field_contact_node.nid
LEFT JOIN {field_data_field_payment_amount} field_contact_node__field_data_field_payment_amount ON field_contact_node.nid = field_contact_node__field_data_field_payment_amount.entity_id AND (field_contact_node__field_data_field_payment_amount.entity_type = 'node' AND field_contact_node__field_data_field_payment_amount.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('contact')) ))
GROUP BY nid, field_data_field_payment_amount_node_entity_type
LIMIT 12 OFFSET 0

Views output:

Query manual execution result:

Does anyone have possible explanation of this interesting behavior?


texts: Adding taxonomy terms to multiple nodes at once

texts:
I've got thousands of nodes which i can filter down to smaller lists using Views.

I then wish to add multiple taxonomy terms to the subset of nodes as a batch process. Views Bulk Operations module gives me the ability to select each node using a tick box but no suitable action to apply to the selected nodes.

Is there any way to tag my selected nodes with taxonomy terms easily or do i need to build a module / Rule action in code to achieve this?

Older versions of Drupal appear to have had such ability: QEdit and Views Tagger came up whilst searching for a solution.

Thoughts...?


texts: Drupal 7 globalredirect not working for /node/ redirection

texts:
I want to redirect my site from URLs like

/node/530

to

/Services/TrainTickets.html

I installed GlobalRedirect module as I've read it would address this problem, but the same page is still accessible at /node/530 path.

Anybody knows what the problem could be and how I could resolve it?

I also want to make it impossible to access the site via

http://www.waytorussia.net/node?page=31 and so on...

Thanks!

UPDATE I use Drupal for Facebook module and I've seen there were issues with that as it uses custom url rewrite but did not find any resolution.


texts:
I am using Views and Drupal Commerce in Drupal 7 to display a list catalogue of products (books).

By default the price column is formatted "12.34 ZAR" which is a format that is only really used in an international currency trade context for South African Rand. How do I override the format so that I can display it as "R12.34" which is the more common format.


texts: Migrate multilingual Drupal 7 users to Drupal 8

texts:
I have Drupal 7 users that uses Profile module and has fields for individual languages i.e. presentation_sv, presentation_en that I would like to migrate to a proper Entity translated Drupal 8.

First migration file:

id: custom_user
label: "Custom User accounts"
migration_group: custom
migration_tags:
  - Custom D7
class: Drupal\user\Plugin\migrate\User
source:
  plugin: d7_user
process:
  langcode:
    plugin: default_value
    default_value: sv
  name: name
  pass: pass
  mail: mail
  created: created
  access: access
  login: login
  status: status
  presentation: profile_presentation_sv
destination:
  plugin: entity:user

Here is the translations migration file:

id: custom_user_translations
label: "Translated Custom User accounts"
migration_group: custom
migration_tags:
  - Custom D7
class: Drupal\user\Plugin\migrate\User
source:
  plugin: d7_user
  translations: true
process:
  uid:
    plugin: migration
    source: uid
    migration: custom_user
  langcode:
    plugin: default_value
    default_value: en
  name: name
  pass: pass
  mail: mail
  created: created
  access: access
  login: login
  status: status
  presentation: profile_presentation_en
destination:
  plugin: entity:user
  translations: true
migration_dependencies:
  required:
    - custom_user

The error I get:

Next Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'map.destid2' in 'field list': SELECT map.sourceid1 AS sourceid1, map.destid1 AS destid1, map.destid2 AS destid2
FROM
{migrate_map_custom_user_translations} map
ORDER BY destid1 ASC; Array


texts: View Title does not filter correctly by userid

texts:
I'm very new to Drupal and trying to learn how to create a view that is filtered by userid, then by whether or not it's been published. I've created a content type of "Lists" and have a link on the home page called "My Lists." When the user clicks the link, it should open a view (and I have it set up as a page) and the title of the "page" should be "My Lists" and show each set of lists the user has. I.e., the user could have a list for their favorite movies, and another for their favorite books. Both lists should be shown UNDER the title of "My Lists" and the user would then click on which list they want to view or update.

What is happening though, is that somehow I got the Title "Booklists for " & "User" name in the title so it shows up as the main title for ALL lists instead of the correct title of "My Lists." I've gone to my Administration menu: Home » Administration » Structure » Views and under Views I have it set up as a Page. The Display name: Page - My Lists. The Title = Title: View My Lists. Now, when I scroll all the way to the bottom of the View My Lists (Content) it has a section for the Title with a little gear wheel icon that you're supposed to click on to change the Title. I've done that and the Page - My Lists: The title of this view dialog box comes up. I've changed the title in that section to "View My Lists" and set it to save for all displays. Then , it goes back to the Title and in the box showing for the title (that I just changed) it STILL shows "Booklist for Ayliea" when it SHOULD say "View My Lists."

It isn't changing the title.


texts: How to change or influence the block id and class of a view block

texts:
I have a view with 2 blocks. One was cloned from the other.
I changed the machine readable name of both of the blocks (block_events_upcoming and block_events_upcoming_ical), but in the html i get as id and classes the beautys you see below.

<div id="block-views-d7410a6d5618e2d319a0eaab549b0ff2"
     class="block block--views
            contextual-links-region
            block--views-d7410a6d5618e2d319a0eaab549b0ff2">

Is there a way to change the ids and classes of the block. The css-class option in advanced settings only changes the css class in the block_content div not the top block-div.


texts: Prepopulating county/state field (ajax driven field)

texts:
Before I describe my problem, just going to mention that I tried Commerce Addressbook and Commerce Extra (address populate) modules.

The first one is not suitable in general for my project (because it's based on billing address when the mother address used in this project is always user's one entered on registration) and
The latter is in alpha stage and has many issues (and still doesn't sort my problem)

The problem is that I cannot prepopulate County/State field on commerce checkout billing address form.

When using hook_form_alter, I can successfully prepopulate all fields, except county. The reason for this is that county drop down is loaded with ajax and dependent on Country value. It's getting created when the form is built so before the hook_alter_form is applied.

So for example let's say my billing address defaults to Ireland (one can setup a default value under customer profile -> billing information). A user registered using address in USA. When the user comes to billing form on checkout, gets all fields prepopulated with the address he/she registered with and country says United Stated, but county/state dropdown stays defaulted to Ireland (lists irish counties).

One needs to select other country than USA and then select USA again for ajax to load the proper county/states dropdown

I cannot seem to find a workaround for this. Any advice?


texts: I'm looking for a module that provides a D7 field type that's an expandable list: a list where new values can be added at run-time. Is there a module for that?


texts: How to use addField function when the field name is SQL keyword

texts:
I have a field with name 'order' in the database. How to select it, using addField?

$query->addField('sco_groups', 'order');

Gives an error.


texts: how can I have a body with more than 64 Kb of data in it?

texts:
I've noticed that when I create a node with too much data in the body field subsequent edits will not save. Or rather, the save goes ahead and I am taken back to viewing the node, but the content hasn't changed.

After extensive trial and error I was able to determine that any save which had a body length of less than 64 Kb saved fine but anything more than that would not save.

What is the cause of this and is there any way to get around it?


texts: Custom token [node:customtoken] not available in rules action 'set a data value'

texts:
I've created module with hook_token_info() and hook_tokens(). Now i can see my token in list of all availble tokens:

$ drush token | grep customtoken
 node        customtoken         Node related token

But this token is not available in rules action 'Set a data value'. What is the problem with custom token?

My rule looks like:

Events: 'After saving new content', 'After updating existing content'
Conditions: 'Content is of type'
Action: 'Set a data value'


texts: Creating content types with fields that are other content types?

texts:
I have an existing content type in my current Drupal application, person. This contains all of the data you would expect, more or less - name, address, employer, etc.

I'd like to create a project content type. A project will consist of a name, description, and multiple members. Each of these members should be a person node that will already exist. It would be great if I could have the ability to add members by either selecting from available persons as a dropdown, or maybe some sort of autocomplete on name. I already know how to do autocomplete, but the issue then is that the field will be autocompleting just the person's name. I need a project node to actually contain multiple entire person nodes, so that I can get ALL of the info out of them - name, position, etc. etc. Is this sort of functionality natively in Drupal?

Alternatively, I could implement hook_node_load in this module, and add person nodes to any node loaded that happened to be a project node. Would this be a more viable alternative?


texts: "Call to undefined function fivestar_widget_form()" error

texts:
I am getting the following error - it's related to the fivestar module. As far as I can tell, it is using an obsolete function call (used in Drupal 6)

Fatal error: Call to undefined function fivestar_widget_form() in /home/SITENAME/public_html/sites/all/modules/contrib/views_php/plugins/views/views_php_handler_field.inc(202) : runtime-created function on line 5

The problem is that I've looked at all references to the widget in the template files, tried to change them.

I've tried the following, as said here, but I keep getting the error.

print render(fivestar_widget_form($node));
print render($content['field_vote']);
print drupal_render($content['field_vote']);
print drupal_render(fivestar_widget_form($node));

What could be causing the error?


texts: View by Taxonomy terms hide empty terms unless they have children

texts:
I am trying to get my views block to display terms under this parent term but only show the terms with nodes in them. I managed to get this to work by using the relationship content with term and requiring the relationship. However we have terms with children that are empty but the children are not empty. I want it to display the term(without showing the children)

How do I make my views block display terms under parent term, remove the empty terms but show the empty terms with children?


texts: Filter view based on several user profile fields (D7)

texts:
I’m trying to apply automatically several filters to a view based on the corresponding profile fields selected by the current user.
For example, the users can select a favourite color (yellow, blue...) and a favourite food (fruit, meat...). If a user have selected that he likes "yellow" and "fruit", he should see in the view only the nodes that match both criteria (yellow fruits): bananas, lemons...
This is pretty easy to do when there's only 1 field to match (following the process indicated here), but this same process doesn't seem to work for matching several fields (the content field of the view only allows 1 relationship).
I've tried creating relations between relationships (like "chain relationships") and doesn't seem to work, but maybe I'm doing something wrong (I don't have a really deep understanding of how relationships work).
Any ideas?
Maybe using the Relation or Entity Reference modules? Or some PHP code?


texts: How do I maintain persistent information over a multi-step input process?

texts: I don't have a multi-step form. I have many forms that are presented over many steps depending on decisions made in previous forms and user role. How do I best store persistent information across all forms? Should I use some type of ctools cache, store the information in a cookie or should I attach the information as a query string to each URL request? I am currently using Rules and Rules link for this. Also, I intend to use hook_form_alter() to manage the information through the steps but I not sure how to securely maintain persistent information.


texts: Can someone help me with contextual filters in profile2

texts: I would like to single out a second profile with a views page using basic taxonomy reference or user information. Can you help me get my contextual filter to work with either user id, profile id, or taxonomy reference. I have my view to show users of a particular roll type. All users of this type will have a unique taxonomy reference ( or tag). When I choose fields for this tag in contextual filters and test it using the tag I don't get any results.


texts:
Do I have to delete default folder which is located under /sites? Because I installed new theme and I think there is no need to keep the default theme.

And, if I can't delete it, please tell me why?


texts: 50 Variations of a Node with Access Restrictions Based on User Login

texts:
I'm creating a site where there are 50 variations of a basic page node. The site is not viewable publicly and the user has to login in order to view the site.

I have enable the URL login module, its setup where you can login to the site by going to a url.

Now there are 50 different users and each user has access to view only one of the variations of the node. I setup a taxonomy vocabulary called version with 50 terms in it and assign one of them to the node.

How do I restrict certain users to view only that content that matches the term they are allowed to?


texts: Node taxonomy now appears vertically in Drupal 7

texts:
After migration to Drupal 7 the taxonomy terms now appear vertically with the vocabulary names, and it seems to be the result of Drupal 7 converting taxonomies into fields.

Is there a way to revert to Drupal 6 behaviour, ie just display the taxonomy terms horizontally as before?


texts:
I want to re-order the results of a View using some arbitrary PHP ( the sort is not possible in SQL ).  I believe I could use either _views_pre_render(&$view) or hook_views_post_execute(&$view) to alter the order of the results. However the $view->result array only contains the number of results that the pager is set to, not the whole result set.

Is there some other method I can hook into the result generation process and alter the order of results using PHP ?


texts: I am trying to apply a rule to a certain content type with a taxonomy term selected from a list, this term is from a select list that selects the terms from a certain vocabulary that lists the terms from the vocabulary. I want the rule to only apply when international is selected......I have been at if now for four days, nothing doing. Tried a search but the results I found were not helping. I would really appreciate the help.


texts: Rules - send email when users role changes to x

texts:
I need to send an email when an admin changes a users role to role x. The email should not be sent if the users role is already role x and 'save' is pressed on the user page.

I have set up a rule:

Event: After updating an existing user account

Actions: Send mail

This works fine. Then I add a condition of type 'data comparison' account(updated user):roles with the operator 'equals' and the data value 'role x'. But for some reason the email now never sends when I change the user role to 'role x' and resave. I'm confused about why this is not working.

Then once this is fixed I assume I'll need to negate the condition that the account(unchanged user):roles equals 'role x'


texts: How to delete files when the node that displayed them is deleted?

texts:
Is there a way to delete files/images from the server automatically when the main node is deleted?

How do I implement this?


texts: How do I create and apply a configuration schema for an existing custom module?

texts:
I have a custom module, already running for a longer while, but I did not take into account that the configuration would have to support translation. I have had no config/schema/module_name.schema.yml file at the time of installation.

I created the schema file, looked into implementing hook_update(). I was just about to start implementing it, but I checked the output of \Drupal::service('config.typed')->getDefinition(DrupalHooks::CONFIG_KEY); just in case. The schema file was automagically absorbed by either drush cr, or loaded by the code snippet itself.

I don't find my module listed on the admin/config/regional/config-translation page. Also, the other modules shown in that list seem to always have a Translate tab on their configuration page. My module doesn't get that either.

What am I supposed to do to make it translatable? Is there any hook I should implement, or am I missing something else?


texts: How do I wrap a div around specific fields in a view?

texts:
I have to make a small website using drupal 8 for a school project but I keep getting stuck with the twig templating. I'm trying to wrap a div around certain fields in drupal 8 with twig.
The layout at the moment is as follows(this is an example);

Content type image

Content type Title
Content type Category

Is there any way to accomplish this using a twig template for the certain view?

The bottom two items have to go in a div.


texts:
I am using drupal 7, how to give permissions for the anonymous user to the view the fields of created from the OG module. The values doesn't show for the anonymous user. In the people permission page, there is no option to view the field name permission. There is only a permissions of creating, editing and deleting the node. Please help me resolve this problem.

Thanks.


texts: Debugging your code under SimpleTest when the behavior is different

texts:
I'm dealing with a weird problem where a few of my tests are dying from exceptions when run inside of SimpleTest, but I'm unable to reproduce the problem outside of the SimpleTest environment. In particular, it appears that exceptions that I'm catching in my module code get intercepted by SimpleTest before they even leave my try block.

I'm able to debug my test script using xdebug, but for whatever reason, I can't get SimpleTest to pass on the debugger info to my code when it's running under SimpleTest.  So when SimpleTest calls $test->run() on one of my tests, the test starts up in its own, SimpleTest-unaware process.  And my debugger sits on its hands (they have hands, right?) and runs as if everything is copacetic.

Is there some option in SimpleTest that will allow me to get the XDEBUG_CONFIG environment variable passed on to the subprocesses that SimpleTest spawns?


texts: How to assign roles in my own registration form

texts:
I know about assigning roles and permission in DRUPAL admin login where admin can add user and even add new roles (check here) to the new users.

I have a basic registration form in my page and while user register I want to assign roles to them for example - employee, superuser and admin roles.

How do I do it, do I have create a new module and may be use the ROLE module functionality in Core DRUPAL.

I have also checked this Link which explains about basic Users, roles and permissions in DRUPAL but it does not answer my question.

So

I need to create new user in Drupal from my own Registration form.
I need to have my own custom roles (eg. employee, superuser and admin roles) - This Link might help me in this
This new user which are registering from my own custom registration form, should be assigned with this custom roles(eg. employee, superuser and admin roles).

Can some please tell me how do I do this in Drupal 7 or Does anyone knows any Drupal modules which can help me do this efficiently or should I go with own PHP code.

which will be more efficient way for doing this.

Thanks in advance :)


texts: User profile form make custom form required

texts:
I'm trying to use a hook to make a user field (company name) required based on assigned roles so:

if($form['#id'] == 'user-profile-form') {
  dsm($form);
  if (!in_array('BPSA user', array_values($user->roles))) {
    $form['field_dealership']['#type'] = 'hidden';
    $form['field_company_name']['und']['#required'] = 1;
    $form['field_company_name']['und'][0]['#required'] = TRUE;
  } else {
    $form['field_company_name']['#type'] = 'hidden';
  }
}

It's not working and I can't find any other 'required' form elements?

Ps I know this would only rewrite if the user was not a BPSA user.

Thanks,

Steve


texts: AJAX Views with filter as path component

texts:
I have a view of Commerce products of type Print. The product type Print has a reference on a Taxonomy called Category. I setup the Category field as an exposed filter (dropdown) for my View page. The View uses AJAX and the URL is /prints.
If I want to load my View with a preselected category, I can go to http://d8.local/prints?category=1 which displays the View already filtered and with the corresponding category selected in the dropdown.
I could setup a contextual filter and a relationship on the View and set the path to prints/% so that I could filter and access it as http://d8.local/prints/landscapes where landscapes is one of the vocabulary terms, which feels better than ?category=1.
When I do so however, going to http://d8.local/prints/landscapes then using the exposed filter, it will filter the already filtered results. Also going to /landscapes doesn't select the option in the dropdown.
Is there a way to combine the 2 functionalities?
Edit:
To summarize the functionalities I am after:

I should be able to filter the products by category by adding the vocabulary term name as a path component, ie. /prints/landscapes.

When accessing the View with the category as the path component, the appropriate category exposed filter dropdown option should be selected, ie. Landscapes should be selected in the dropdown if accessing /prints/landscapes.

I should be able to filter the View using AJAX when manually selecting another category from the exposed filter dropdown.

The main page title must be updated based on the category whichever way the view was loaded (page load and AJAX reload)

Ideally, I would update the URL when manually selecting a category from the dropdown, but I suppose that's a separate question and it shouldn't be too hard to handle.


texts: Programmatically creating a node doesn't save custom fields

texts:
I'm using this code in Rules, after saving a certain type of content, in execute custom PHP code. By now, i'm just trying to create anothe node of that type after the first is created.
The problem is that this code creates a new node indeed, but without any custom fields. It has only language associated to it. Any idea on what's wrong?
I followed the tutorial at http://fooninja.net/2011/04/13/guide-to-programmatic-node-creation-in-drupal-7/

$nodo = new stdClass(); // Create a new node object
$nodo->type = "capitoli"; // Or page, or whatever content type you like
node_object_prepare($nodo); // Set some default values
$nodo->language = 'it'; // Or e.g. 'en' if locale is enabled
$nodo->uid = $node->uid; // UID of the author of the node; or use $nodo->name
$nodo->field_numero_capitolo[$nodo->language][0]['value']="2220";
$nodo->field_link[$nodo->language][0]['value']="aafafsf";
$path = 'node_created_on' . date('YmdHis'); // I prefer using pathauto, which would override the below path
$nodo->path = array('alias' => $path);
if($nodo = node_submit($nodo)) { // Prepare node for saving
    node_save($nodo);
    echo "Node with nid " . $nodo->nid . " saved!\n";
}

If I replace

$nodo->language = 'it';

with

$nodo->language = LANGUAGE_NONE;

this code create another node identical to the first one, not considering the values I used in the code and I can't figure out why.

EDIT:
I tried doing as suggested in comments

$nodo->field_numero_capitolo['und'][0]['value']="2220";
$nodo->field_link['und'][0]['value']="aafafsf";

And it seems to work. What i did was to insert directly 'und'. Generally I think it is not a good idea to write directyl 'und', but these two fields are a link and a number, that should not change depending on language.


texts:
I have Views Data Export installed, which creates a CSV file attached to every node. This file has all of the data from a field collection field arranged as a CSV.

The only user that should be able to download this CSV file is the admin (user 1) and the user that created the node.

In Views Data Export, I can select Role as a permission, and assign it to all "Managers", but that means each "Manager" can download other Managers data if they get the URL right. Anyone wanting to maliciously steal data, or sneak a peak at how much their colleagues are earning can simply guess the URL of the CSV file.

How would I restrict this download to the author of the node?

I have tried installing Path Rules, and creating a Rule that checks that the path of the CSV ends with CSV, and then runs a condition to check that the Nid of the currently logged in user matches one created by the author, but the download happens automatically regardless. There doesnt seem to be a path check before it is downloaded.

Stuck here scratching my head, would welcome even the slightest suggestion, or just a fresh pair of eyes! Thanks.

OK, some progression...

I delved into creating a views custom access like so...

Added files[] = couples_page_custom_access_plugin.inc to a custom module info file

Added the following to couples_page_custom_access_plugin.inc

<?php

  /**
   * Access plugin that provides property based access control.
   */
  class couples_page_custom_access_plugin extends views_plugin_access {

    function summary_title() {
      return t('Couples Page Check User is Author');
    } // summary_title()

  /**
   * Determine if the current user has access or not.
   */
    function access($account) {
      return couples_page_custom_access($account);
    }

    function get_access_callback() {
      return array('couples_page_custom_access', array());
    }

  }

Then added this to a custom module...

  function couples_page_custom_views_plugins() {
    $plugins = array(
      'access' => array(
        'test' => array(
          'title' => t('Couples Page Check User is Author'),
          'help' => t('this is a custom access plugin'),
          'handler' => 'couples_page_custom_access_plugin',
          'path' => drupal_get_path('module', 'couples_page_custom'),
        ),
      ),
    );
    return $plugins;
  }

  function couples_page_custom_access($account = NULL) {
    global $user;
    $access = false;
    $account = user_load($user->uid);
    $node = node_load(arg(1)); // Get the nid from the URL of the CSV file.

    // If the UID of the currently logged in user matches the UID of the node author return true.
    if ($account == $node->uid) {
      $access = true;
    }
    return $access;

  }

But its not really working. If I set $access = true it works, and $access = false, it doesnt, so I know the plugin is working. It must be the logic in the last bit here...

function couples_page_custom_access($account = NULL) {
        global $user;
        $access = false;
        $account = user_load($user->uid);
        $node = node_load(arg(1)); // Get the nid from the URL of the CSV file.

        // If the UID of the currently logged in user matches the UID of the node author return true.
        if ($account == $node->uid) {
          $access = true;
        }
        return $access;

      }

Perhaps I am not getting the author uid of that node correctly? I will look into it.