texts: How to print username into url after user logs in?

texts:
Currently, I am developing a site where I need to add the username to the URL after users log in. I am using the Login destinations module. Usually, users aren't redirected, but they stay on the page they were before logging in, with few exceptions. This unfortunately has to stay, so I cannot redirect them to users/username.

I need to add the username to the URL after users log in. For example, not logged-in users will be at content/main-article; logged-in users will be at content/main-article?username.

I tried that with the Menu tokens module, but the tokens aren't replaced. A relative URL like node/1 becomes node/1/%5Buser%3Aname%5D.

If you ask why, it is for Piwik to easily recognize logged-in users.


texts: Drop-down menu that shows the average of multiple rating criteria on Fivestar

texts:
I am working on customizing the Fivestar module, to allow the rating of multiple criteria.

The Fivestar rating should show a drop-down menu, in which the user could rate the object on 4 different criteria. The resulting rating should be the average value of those four criteria.

Can anyone point me in the right direction on where to start on this?

edit: i am running drupal 6


texts: Adding title to file field in a content type

texts:
I am making a change to an already existing site.

There is a content type called lesson, and one of its fields is called 'File'. It is being displayed using the "Generic File" format in the content type's display settings which results in a link with a file icon and the filename.

My task is to make the field label as 'Title' of the field instead of the "filename". So: I need to somehow add a file title field.. I could make this just another field in the display, but how would I include it in my display? Is there a preferred way of doing this?


texts: Simple Panels question on where the panels get placed on the page

texts: This is a silly question but how does Panels know where to insert the panels I just made? I didn't type a single line of PHP and yet there it is! It's like magic (woooh...)! On a side note, can I define where it gets placed through PHP? Thanks.


texts: How to hide product in drupal commerce with rules

texts:
I have a Drupal site with drupal commerce on it and I created a product with 2 price field.

If a user have role 'simple user' he sees the default price.
If user have role 'friend user' he sees the second price value.

I already create this rule but now I'm trying to filter the product in this way:

If user have role 'friend user' and the product don't have the second price hide it to him.
I'm not seeing any option in rule to hide a content.

How can I achieve this content filter?


texts: How do I find a vocabulary ID for use with tokens

texts: I need the Id for tokens. I know in Drupal 7 it is based on the label but when using tokens for rules the label doesn't work in the identifier. I don't need to find it programmatically. Is there another way?


texts: Grouping fields into Drupal block to appear in its node

texts:
I have a content type with several fields. I need to group some fields of each node into a block. The block will contain the fields values of that particular node only.

In this layout, AAA is a photo slider displaying some photos of that node. On the right, BBB is a block containing some fields. I am trying to create this BBB as a block.

Initially I thought this could be done with the fieldgroup module, just only a matter of configuring the fieldgroup setting for < div >? And in that form, this question is similar to earlier ones, and has also been well answered.

But on further research, this doesn't work. In the diagram, AAA and BBB are siblings. If the fields in BBB have a < div > but still under the larger container and not in their own block, then it can't float with the other AAA block since they are not siblings.

Therefore, I need not only to group with < div > for the fields but indeed must wrap these fields into a Drupal block. How to do that? Thanks.


texts: How to avoid module specific jQuery plugin script running globally?

texts:
This is my first time working with Drupal (Drupal 7).

I've created a jQuery plugin which populates a target div. The target div is added to the node via panelizer.

I only want to run the script for when it's needed. Just now it runs all the time. Even on the dashboard, this causes script errors.

I'm not sure what the best approach is for this.

EDIT (SOLUTION):

Thanks for the input. I decided to use a Javascript approach.

var elementExists = document.getElementById('target');

if (typeof(elementExists) != 'undefined' && elementExists != null) {
  // Script
} else {
    return;
}


texts: Cannot deal with multiple iterations of same form on one page

texts:
I am designing a site that has a variety of points in which I need to render "workflow" buttons that are used to send actions to an external application.

I used the form API to generate these buttons, and am using the #submit => option on my buttons to direct specific button types to custom functions. I am also using hidden fields to house data that I use to facilitate the action.

The problem I am having is that these buttons can and should show up multiple times per page, for different aspects of the application, and whenever I click one of the buttons Drupal attempts to submit all of the forms.

I guess what i am asking is, how can I have multiple instances of the exact same form on screen at any given time, and know with certainty that the submit buttons are only going to trigger actions for the specific instance of the form they belong to?

thanks in advance!!

Edit

So here is the crux of the problem - it appears that the getFormId needs to return a unique value, but I cannot figure out how to pass unique values into it.


texts:
I have a custom module called 'products'

I set the access options like so:

function products_permission() {
  return array(
    'access products' => array(
      'title' => t('TBYT Products'),
      'description' => t('Administer TBYT Products'),
    )
  );
}

In the admin I have enabled the module and gave everyone this permission.

Then I defined:

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

  $items['products/list'] = array(
    'type' => MENU_CALLBACK,

    'title' => 'Enjoy shopping',

    'page callback' => 'html_list_products',

    'access arguments' => array('access products')
  );

   return $items;
}

This works fine, however I need to now make the URI dynamic, so I added something like:

  $items['products/list/%/%'] = array(

I also added the appropriate page arguments:

'page arguments' => array(2, 3),

However when I rebuild the cache and I access:

products/list/23

it works fine but when I access

products/list

I get:

The requested page "/products/list" could not be found.


texts: Allow custom role (manager) to delete user

texts:
I'm required to allow custom roles (Manager and Editors) to DELETE authenticated user.
I have tried Administer Users by Role, but the Managers and Editors will be able to access the user setting (MYSITE.COM/admin/config/people/accounts/settings), and this is a big security penalty.

Do you guys know an other way to do this without security issues? I'm using also Role Delegation, but with it i'm just able to modify the roles per users

Thank you


texts:
I have an issue where I have the page for a specific role showing up on every page and additionally an error message.  These show up below the footer on the pages.  I've gone through the theme files and the blocks and I can't figure out what is causing them to appear.  I think the best way to show it is probably from the DevTools and inspecting the page.  You can see where the footer-bottom is and the EOF: #footer is for the theme.  Everything below that before /body and /html shouldn't be there.

Has anyone ever experienced something like this before?  I'm on Drupal 7, using Corporate Clean Theme.

Update:
The extra content also appears to append itself at the bottom when editing certain pages, so if I saved it without deleting it, it would appear within the main content and at the bottom of the page again.

Update 2:
It's definitely something that changed within the database and not the theme files.  When I import the last database before this happened, the extra content goes away, when I import the new one, it comes back again.  Additionally, there are a few pages when looking at in edit mode that are not showing up with the wysiwig editor, it looks like I'm editing them in plain text.


texts: How to show users list in content (view) or vice versa?

texts:
I want to show content as well as users in one view. I tried it by using entity reference and attaching 2 displays within a view, but no success. May be I am doing it wrong or it is not possible. I dont know. Is it possible anyway?

What I am trying to do?

I am creating an autocomplete view to use in search box.


texts:
I am new to Drupal7, and working on a site with different users.

And my probably I am currently encountering is when whenever someone creates a content, field, etc. It generates a machine name.

Using Drupal, it automatically generates one based on the given title of node.
But it won't be saved if the machine name already exist.

Is there anyway to know what machine names exist? And to which this machine name is assigned?


texts: How to make autocomplete return nid and name?

texts:
My question is about textfield autocomplete. I have this code:

function my_module_menu(){
  $items['my_module/textfield_autocomplete'] = array(
    'page callback' => 'my_module_textfield_autocomplete',
    'file' => '.\my_module\my_module.inc',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access example autocomplete'),
  );
  return $items;
}

In my_module.module:

$form['fieldset7-wrapper']['prop'][$i] = array(
          '#type' => 'textfield',
          '#title' => t('Nombre de propietario'),
          // The autocomplete path is provided in hook_menu in ajax_example.module.
          '#autocomplete_path' => 'my_module/textfield_autocomplete'
        );

In my_module.inc:

function inmoges_ofertas_propietario_autocomplete($string) {
  $matches = array();

  // Some fantasy DB table which holds clientes

  foreach ($return as $row) {
    $value = check_plain($row->name).' '.check_plain($row->surname1).' '.check_plain($row->surname2);
    //$value = $row->name.' '.$row->surname1.' '.$row->surname2;
    $matches[$value] = $value;
  }

  // return for JS
  drupal_json_output($matches);
}

This works perfect. But I want that json return callback {nid; name} instead of {name,name}, and also show the name in textfield, but I can save nid in my form.

If I change to this my function ajax

$matches[$row->nid] = $value;

The previous sentence returns {nid, name}, but if I choose one value of the list name, in the textfield is shown the nid value, not the name value.

Any suggestions?


texts: Trying to disable mail on contact form, but it's still required on submit

texts:
I am trying to make optional the mail field from the contact form. I manage to remove the asterisk by implementing the hook_form_alter:

function contact_field_form_alter(&$form, &$form_state, $form_id) {
    $form['mail']['#required'] = FALSE;
}

However on form submission, I get the message "You must enter a valid e-mail address". I seems that, although the field is optional on the form, it still tries to validate it. Can somebody tell me how to make it really optional?

Thanks in advance


texts:
I get access denied to admin user in my custom module. This is my routing yml file:

operatordb:
  path: operator-database
  defaults:
    _form: \Drupal\operatordb\Form\OperaDBForm
    _title: 'Operations over databases'
  requirements:
    _role: 'administrator+manager+superuser'

I have checked spaces and parameters. Users with role manager or role superuser can access to the form without problems and use it, but admin user (with role administrator - 1) get access denied. I don't know why It happens.
Some suggestions? Thanks.


texts:
In my drupal 7 site under Configuration » Content authoring

The following are available:
Filtered HTML
Full Html
Plain text
PHP code

However, under Content authoring » CKEditor

Only the following profiles are available:
Advanced - Filtered HTML
Full - Full HTML

Plain text and the PHP one are missing. Is this normal? Why would this be the case? I am happy to uninstall modules or redo whatever I need to in order for this to be as it should be.

Also, should Filtered HTML and Plain text input formats be editable in the Content authoring section?


texts:
Drupal 7

I am trying to add a new button or link to my log in form. The button would simply link to another page outside of the drupal framework. I am looking at the form_alter hook but I am not sure if I completely understand how to implement my update.

do I have to update the template.php page?

The form is the login form on the front page. Any help would be great.

I am pretty sure I need something like the following :

<?php
$form['preview'] = array(
  '#type' => 'button',
  '#value' => t('Preview'),
  '#weight' => 19,
);
?>

But I need to add the link. request.php to the button so when clicked it will go to request.php. Also I am not sure where to add this code and how to direct it to my log in form.


texts: Why 'excluded from display' fields in views are not available in template files?

texts:
There is a slide show in my website and I implemented it using views_slideshow module. its content type has 2 fields: 1. an address 2. and image. when user clicks on the image it must be redirected to the address.

this is views-view-fields--VIEWNAME.tpl.php

<?php
global $base_url;
$address = strip_tags($fields['field_site_link']->content);
$address = str_replace($base_url,'',$address);
print $address;
?>

<a href="<?php print $address;?>"><?php print     $fields['field_site_image']->content; ?>

I excluded the field_site_link from display but it is not available in this function. I also tested <?php kpr($fields); ?> and it was still unavailable. How do I can get its content?


texts: Send mail with attachment using the MIME Mail module

texts:
I am not able to send mails with an attachement using the MIME Mail module.
There isn't munch documentation about this module, but some people claim they have successfully used the module, and sent a mail with an attachment.

I've enabled and successfully configured:

Mail System
Mime Mail
Swift Mailer

I think I configured the modules correctly.

No mail with attachement is delivered. I call drupal_mail() in a cron job with the following code.

drupal_mail('mymodule', 'notice', $user_email, $lang, $params, $admin_email);

It should invoke any hook_mail() implementations, which it does, but without the attachment.

function mymodule_mail($key, &$message, $params) {
  $data['user'] = $params['from'];
  $account = $data['user']->name;

  $file_content = file_get_contents('some/file/path');

  $attachments = array(
     'filecontent' => $file_content,
     'filename' => 'example-' . $account,
     'filemime' => 'application/pdf',
   );

  switch($key) {
    case 'notice':

      $langcode = $message['language']->language;
      $message['subject'] = 'example submission from '. $account;
      $message['body'][] =
        '<p>'. $account .' has submitted an example.</p>';
      $message['params']['attachments'][] = $attachments;
      break;
  }
}


texts:
In the past I created hundreds of nodes in a specific language.
Finally, the website will have only one language and I think it is best to set them all to unassigned language for development reasons.

How I can change the language in bulk?
Is there any module for that, or some SQL queries to run directly at the database?


texts: Create custom display of element using field values

texts:
Lets say I have a Company content type that contains the following fields:

Company Name
Company Description
Company Logo Image
Company Website URL

I use the Entity Reference module to relate companies to Articles. When displaying an article page I would like to show the company logo which should link to the URL with the description on-hover. If I were using a view I'd do a rewrite for something like this:

[Company-Logo-Image]

[Company-Description]

How could I do something similar for the actual individual article page?


texts: Drupal 7 Views Organic Groups Complex Relationship

texts:
I have an Organic Groups setup with many relationships. My groups are separated into 3 primary group types..let's call them:

Trucks
Cars
Vans

All of these groups have group content:

Tires
Rims

I've created a view that is a list of Tires and I need to be able to sort by group type...so I need a list of tires for Trucks (for instance). How do I relate the bundle type?


texts: Move a taxonomy page field to a different region

texts:
I currently have taxonomy pages using a custom image field, field_icon, which by default displays in my content region.

How would I go about moving this field display to a different region (in my case the header region)?


texts:
I'm using Calendar module to display a list of nodes with fields related to that specific days. I am handling multiple date fields using contextual filters.
For example, if an item has a Preview Date of 7/1 and a Review Date of 7/2, the node item will show for each date.
The problem is each node item is showing for each date, i.e. 7/1  and 7/2 show the item twice.

How do I remove the duplicate items? So each date only shows one of each node? I've tried aggregated fields/Count Distinct and Query Distinct but had no sucess.


texts: How to implement Node Access based on a Term in the user's profile?

texts:
Some info about what I'm working on:

Nodes:
I have a content type that contains user_reference.
Taxonomy:
I have a vocabulary called cities, which is enabled for all users and contains terms like London, Paris, ...
Users:
All users are tagged with terms from the cities vocabulary, through the use of a taxonomy reference field added to their profiles.

What I am trying to achieve:

I want to give access to an administrative role to view/edit/delete nodes where the users referenced in these nodes are tagged with a certain term.

Example: I want to add a role called "London Supervisor".

Users who have this role can view/edit/delete any node where the referenced users have the terms London. So I want to give access to an administrative role to view/edit/delete nodes where the users referenced in these nodes are tagged with a certain term.

My question:

Anybody any suggestion about how to implement this?


texts:
I loaded a db to see settings of a view but can't access the site so wondering if I can view it via mysql?

OR can you reset the username and pass for admin in mysql?


texts: setting up autocomplete on content type using profile2 and entityreference

texts:
so, I'm creating a content type called "elearning", and I have some modules installed:

-ctools
-entity api
-entity reference
-profile2
-views

Then I create new profile called "teacher" with the field:

-full name

fields for "elearning" content type are:

-title (default)
-body (default)
-teacher: (with detail below)
field type : entity reference
widget : autocomplete
target type : profile
entity selection tab:
mode : simple (with optional by bundle)
target bundles : teacher
sort by : a field attached to this entity
sort field : full name (column value))
sort direction : ascending

I have one user with the role teacher, I gave the detail full name as "john pantau".

I created new content/node, when I tried to fill teacher field which is autocomplete, the list does not suggest from full name, I expected "john pantau" but not, it suggests "teacher" instead. after checking table, the suggestion ("teacher") is coming up from field "label" in table "profile".

what do I miss? I want to the suggestion comes up from full name field.
please help me.

thank you before.


texts:
I have installed Google reCAPTCHA on my local Drupal 7 site and have configured the keys appropriately and set it to run only on the registration form.

I keep getting the error:

  Google reCAPTCHA does not accept this submission. Try again please, or
  contact to Site support services.

See screenshot below:

I'm not sure why this is happening, I have tried both on my local server and on a hosted production site and I get the same error message.

Anyone know why this is? Or is there an alternative way I could prevent bots from creating spam registrations?


texts: Simple click alternative to Draggable views?

texts:
I'm trying to find an alternative solution to the Draggable views module. But instead of dragging the rows, you just click some simple up and down arrows once, and you click any of them to reorder them.

Any suggestions?


texts: How to get my custom module to recognized a exported view?

texts:
I have created a view and then exported it normally to a yml file. Then I put this yml file into my mycustommodule/config/install folder.

So current its named mycustommodule.view.user_assigned.yml

However when I uninstall the module and reinstall it to see if it will upload the view, it does not. What am I doing wrong?

Edit: I copied and pasted the yml file itself so there should be no errors there. The only thing I did was remove the UUID string since I read elsewhere it was not needed.


texts: Superfish menus getting clipped in blocks

texts:
I'm showing a Superfish block with a selected menu in the Homebox module.

The problem is that child menus are getting clipped in the left and right and using browser console I'm not able to remove this clipping either by z-index or using overflow-x/y css properties.

How to make it work?

The div enclosing the Quick Links Staff block has "overflow" set to "hidden". Now if I disable it then the sub-menus show correctly but now the block height drops :


texts: Including static pages in the search index?

texts:
I've got a page set up like this:

$items['mypage'] = array(
  'title' => 'My Page',
  'page callback' => 'mymodule_mypage',
  'access callback' => TRUE,
);

and then

function mymodule_mypage() {
    return 'This is a test! Also, pollywog.';
}

Now, if I go to /search/node/pollywog, I would like to see the above page as one of the search results. I currently don't, because I assume search just covers database content. Is there a way to make it also include specific pages? Something like the below would be amazing:

$items['mypage'] = array(
  'title' => 'My Page',
  'page callback' => 'mymodule_mypage',
  'access callback' => TRUE,
  'includeInSearchIndex' => TRUE, // <<----- this!!
);

Would it be possible to build in something like "includeInSearchIndex" and then make that index the static page?


texts: Avoid duplicate ID for a field that appears multiple times on the same form

texts:
I'm having a problem with duplicate ID's for a custom field widget.

The scenario:
I have an order form, that contains 2 field collections "pick-up" & "delivery".
Both these collections contain the same field "field_delivery_profile" which is a customer profile reference field with a custom field widget.
In the hook_field_widget_form regardless of whether I assign the element an id or not, the ID is the same for both occurrences of the field in the form.

One thing is the breaking W3C standard but the most crucial one for me right now, is that I need to check both fields value change through JS and have to be able at least predict the IDs. Is there maybe a way to get the parent field-collection (that's containing the field) information for assigning a better id?

Best,

Alari


texts: How the get all the child menu's Node IDs?

texts:
I've a very simple task to do in Drupal 8, but I've hard time to find the proper way to do that.

I have a simple menu like this (all basic pages).

Company

Organization
Values
Terms

Services
Team

And when we go to Company page, I want to display all three sub-pages content in there.

How do I get the sub page node ID from the current menu? In Drupal 7, I'd go with something like menu tree data, and parse the URL to get the node ID; I'm sure we can do something similar with Drupal 8, but I can't find a way.


texts: Set default text format for a content type

texts:
At "Home » Administration » Configuration » Content authoring"
I added a custom text format (news).

Now when I trie to enable this for a certain content type "Newsmessage"
"Home » Administration » Structure » Content types » Newsmessage » Manage fields"

I only see  "Plain text" or "Filtered text (user selects text format)" as options.
How do I set the "news" text format as a default for my "newsmessage" content type?


texts: Set a condition in views to remove title link

texts:
Currently I have a custom view that lists a series of nodes. One of my fields is "Content:Title" and I have checked "Link this field to the original piece of content". Everything works.

Question: For my list of nodes I would like to selectively "unlink" some of them and have the text remain. So in a way, it would be a preview of what's to come. Then when I am ready to link them I will "reactivate" the link.

Example:

Title 1
Title 2
Title 3
Title 4
Title 5


texts: scripts.js not doing anything in Zen subtheme

texts:
In a Drupal 7 site I have a Zen subtheme. The info file specifies scripts/script.js. I tested out some simple jQuery in the scratchpad and it works. But if I paste it into script.js, clear the caches, rebuild the theme registry, etc. when I reload the page, there's nothing. Even if the only content of the file is alert('debug text'); it's as if the file were just totally empty.

I don't know what else to do besides clearing all the caches, and I don't know where else to try debugging.


texts:
In Drupal 8, how can I create content programmatically ?
From the "Drupal 8" administration, I created a new type "House" (contain a description, an image, a reference field to users ...). How can I create a entity type "House" from a custom module ?

In my custom module, I have a form file (contain a class who extends FormBase). In the submit callback, I want create a new "house" and set values and save the new Entity.

I don't find examples on the web, in core...


texts:
I have some code in Drupal 7 what are using variable_get. Now I would like to write the code in Drupal 8. So I was reading this but its didn't help me a lot.

How to write this code in Drupal 8 from code in Drupal 7?

$types = array_values(variable_get('test_content_types', array()));

or this

'#default_value' => variable_get('test_content_types', array()),

Some suggestion.


texts: Remove image banner on individual pages?

texts:
I have zero experience with Drupal or any other similar systems. I have simply been given access to a Drupal website (that was created by an external company) at work and told to make changes. I have managed to somewhat figure out a few general basic things but having many problems that are making me lose my mind.

My current problem is this: there are a bunch of basic pages with the usual stuff, a side menu, content area, etc. They also have a banner image along the top (created as a field in the content type "basic page"). I need to remove the banner image from just one page. Simple. Or so I thought. I can't seem to figure this out. I tried making the banner image field not required and leaving it empty, but an image still appears.

Any sugestions?

PS. I'm not sure but I think it's Drupal 7 (that's right, I don't even know how to check that).


texts: Drush hangs when trying to bootstrap Drupal

texts:
Running Ubuntu 12.04 with the 14.04 backports for Drush (meaning we are running Drush 5.10.0)

After importing the database (with drush sqlc < dump.sql), Drupal is no longer able to be bootstrapped by Drush.

drupal-site@uat-previewweb1:/var/www/drupal/uat-preview/current$ drush st -v -d
Bootstrap to phase 0. [0.01 sec, 3.81 MB]                            [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 4.04 MB] [bootstrap]
Loading drushrc "/etc/drush/drushrc.php" into "system" scope. [0.01 sec, 4.04 MB]                                                                            [bootstrap]
Cache HIT cid: 5.10.0-commandfiles-0-42f7d1cb79623ad6de6c23932c9a4e2b [0.02 sec, 4.07 MB]                                                                        [debug]
Bootstrap to phase 0. [0.06 sec, 9.04 MB]                                                                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.08 sec, 9.04 MB]                                                                                [bootstrap]
Initialized Drupal 7.31 root directory at /var/www/drupal/uat-preview/releases/20140911-4 [0.09 sec, 10.69 MB]                                          [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.09 sec, 10.7 MB]                                                                                [bootstrap]
Initialized Drupal site uat-preview at sites/default [0.09 sec, 10.7 MB]                                                                                [notice]
Cache HIT cid: 5.10.0-commandfiles-2-c32acd775c18a90c5b41d0fc9accf5ab [0.09 sec, 10.71 MB]                                                                       [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.1 sec, 10.75 MB]                                                                          [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.1 sec, 10.81 MB]                                                                               [bootstrap]
Successfully connected to the Drupal database. [0.1 sec, 10.81 MB]                                                                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.12 sec, 11.92 MB]                                                                                [bootstrap]

The command hangs here and does not return.

Does anyone have any ideas on what could be causing this? Is it worth it to stray from debian packages and run Drush 6.4.0 here?


texts: Custom login redirect failed in hook_user_login

texts:
I'm trying to redirect to the user edit page just after the user logged in from the login block in the sidebar. I implemented hook_user_login, but no luck. It seems to me that drupal_goto() or $edit['rediect'] cannot take precedence over $_GET['destination']

function mymodule_user_login(&$edit, $account){
    if ( user role is employee and user has not completed profile yet ) {
        // both failed to redirect, although my condition is true
        $edit['redirect'] = 'user/'.$account->uid.'/edit';
        drupal_goto('user/'.$account->uid.'/edit');
    }
}

I was at my home page ( mydomain.com ) and tried to log in, but when I exit in my hook, I found that the URL was changed to mydomain.com/node?destination=node. My home page path is blank in site information.

[Edit]
My condition for redirect is that if the logged in user has empolyee role and his profile is not completed yet. My usecase is very similar to this, but i don't use content profile.

I think the way of overriding $_GET['destination'] would fix my issue.


texts: drupal on postgresql vs mysql vs mariadb

texts:
Anybody using PostgreSQL with Drupal? I know MySQL is preferred for Drupal but I have an existing PostgreSQL instance running on the server. I might as well use it rather than use more resources by running MySQL (MariaDB) unless there are major drawbacks in using PostgreSQL.

So, how does running Drupal on MySQL compare to Drupal on PostgreSQL?

Also, are there differences between running Drupal on Oracle's MySQL vs MariaDB?


texts: How to install two modules that depend on each other?

texts:
So let's say I have module A and module B.

A has a view in which B is used and B has a view in which A is used. The views are exported for installation on module install.
How do you write the dependencies? I can't install either of them cause they are dependent of one another


texts: How to add noindex / nofollow robot metatags to Views subpages

texts:
I have a big view with lots of filters, and Google and friends are killing one of my sites after a cache clear.

How could I add noindex and nofollow metatags in this views' subpages header? I would like to keep the views main page free of these tags.  As I understand the Metatag module is not yet up to the task.

Another idea just came to my mind: Adding nofollow to Views sorting links would achieve nearly the same.

I inquired and no such feature will happen in Views http://drupal.org/node/1758354


texts: How to use conditional not to print a field if empty in user profile?

texts:
As in node.tpl.php, I would like in user-profile.tpl.php to test if a field is empty or not to show my html.

I tried it :

<?php if (!empty($user_profile['field_myfield'])): ?>
<?php print render($user_profile['field_myfield']); ?>
<?php endif; ?>

But it does not work.

Have you the solution?


texts:
I'm using https://github.com/drupal-composer/drupal-project and get an error when starting drush:

[~/public_html/drupal]# alias drush="~/.composer/vendor/bin/drush"
[~/public_html/drupal]# drush
[error]  Drush command terminated abnormally due to an unrecoverable error.
 Error: Cannot declare class Drush\Commands\DrushCommands, because the name is already in use in /home/myuser/.composer/vendor/drush/drush/src/Commands/DrushCommands.php, line 12

What am I missing oder messing up?


texts: Why am i getting this Drush error after updating a site?

texts:
I use Drush 8.1.17 to update my Drupal 7 sites, and as I have been updating my sites today after the latest security update I have noticed that after I update a site if I try to run any update related command (ex: drush up -n | grep available) I get this error:

The external command could not be executed due to an application error.                                      [error]
The command could not be executed successfully (returned: PHP Fatal error:  Uncaught                         [error]
TYPO3\PharStreamWrapper\Exception: Unexpected file extension in "phar:///usr/local/bin/drush/includes/.." in
/srv/www/htdocs/fac-dev/misc/typo3/drupal-security/PharExtensionInterceptor.php:39
Stack trace:
#0 /srv/www/htdocs/fac-dev/misc/typo3/phar-stream-wrapper/src/Behavior.php(72):
Drupal\Core\Security\PharExtensionInterceptor->assert('phar:///usr/loc...', 'url_stat')
#1 /srv/www/htdocs/fac-dev/misc/typo3/phar-stream-wrapper/src/Manager.php(83):
TYPO3\PharStreamWrapper\Behavior->assert('phar:///usr/loc...', 'url_stat')
#2 /srv/www/htdocs/fac-dev/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(412):
TYPO3\PharStreamWrapper\Manager->assert('phar:///usr/loc...', 'url_stat')
#3 /srv/www/htdocs/fac-dev/misc/typo3/phar-stream-wrapper/src/PharStreamWrapper.php(401):
TYPO3\PharStreamWrapper\PharStreamWrapper->assert('phar:///usr/loc...', 'url_stat')
#4 [internal function]: TYPO3\PharStreamWrapper\PharStreamWrapper->url_stat('phar:///usr/loc...', 2)
#5 phar:///usr/local/bin/drush/includes/filesyste in
/srv/www/htdocs/fac-dev/misc/typo3/drupal-security/PharExtensionInterceptor.php on line 39
, code: 255)
pm-updatestatus failed.

Does anyone know why this error only appeared after I updated the site and how I can fix it?


texts: How often is settings.php called? And is $user available to it?

texts:
I'm thinking about adding some handling to the settings.php code, to set the ini_set('session.gc_maxlifetime', 2880); value based on the role of the logged it (or not logged in) user.

i.e. for admin role, moderator role, I'd set a real long value so as to basically not ever get logged out due to idling too long, while writing a long article, or whatever, while for "lesser" roles, like a regular member, they'll get a regular, shorter maxlifetime.

My 2 questions:

1) Is the Global $user var available within settings.php, so I can check it for the user's roles?

2) How often does it get called? Only once during initial site load? Or every time a user loads a page? I don't want to be (re)setting the value every time a page loads.


texts: Drupal install with composer (drupal-project)

texts:
I have used option A to install Drupal 8 on server:

https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies

https://github.com/drupal-composer/drupal-project

But the site is listed in public_html/drupal-project/web while the root folder for the site is public_html ...

What to do?

See screenshot below:


texts:
I use blocks in a panel with Drupal 8. With view generated blocks there are no problems: The block titles are translated accordingly to the view settings. With custom blocks, it appears to be problematic to get the block title translated. I hoped that these titles would be translatable via the user interface translation but they are not; plus, in the panel settings, I can set the block title, but I cannot translate it.

How can I translate block titles (and maybe block content) of custom blocks in a panel, with Drupal 8?


texts: Hooks called after installation profile is installed?

texts:
I'm stuck writing an installation profile.
There are certain things that I want to do only after the installation is completed.

I analyzed top ten installation profiles and checked the documentation, but I couldn't find it. I might be missing something small though.

Is there such hook? If not, how can I execute something at the end of the installation?

Thanks!

UPDATE

I know for hook_install and hook_install_tasks, and they are not exactly what am I looking for.

They both are called during the installation. I want to execute code after the installation has been completed.

For example, setup Backup & Migrate schedules. If I do this using hook_install_tasks(), the cron run at the end of installation does not seem to work properly/in full, and I get errors when backup_migrate tries to write to private directory. Private directory is set up properly and if I just re-run the cron afterwards, it works as it should.


texts:
I use the Drupal Commerce Stripe module to create subscription charges in a Drupal web, through the Stripe platform. Everything seems to work well, the clients are created, the charges are produced and appear in Stripe's Dashboard .... I also have a webhook that seems to work too. The problem I have is that I need to implement within the webhook itself the ability to complete certain fields with the response that Stripe sends to that webhook. These data must complete the profile of the user who made the payment. Any idea what this would be like?

I'm talking about Drupal 7

This is my webhook

<?php

require_once('vendor/autoload.php');
\Stripe\Stripe::setApiKey("sk_test_*************");

$input = @file_get_contents("php://input");
$event_json = json_decode($input);

$event_id = $event_json ->id;
$event_type = $event_json -> type;
$customer_email = $event_json -> receipt_email;

if ($event_type == "charge.succeeded") {
  $msg = "test webhook";
  mail($customer_email, "Test suscrip", $msg);

*/*Here I would like to be able to send certain data of the json object to certain fields of the user profile*/*

}

http_response_code(200);

?>


texts:
In a simple article content type, is there a way we can have a jsonapi query to return specific field only? The same as how REST export view is doing, we can select what field to be displayed in the output.

E.g. http://localhost:8080/jsonapi/node/article/<return body field value>

If not, is there a method I can create a list of string then I would want to call a jsonapi to get that list. Thanks in advance!


texts: How to add a Login / Logout link in Main navigation menu?

texts:
How can I add a Login link to the "Main navigation" menu?

When a user clicks on the link, it should take them to the /user/login page. Once they login, the link should change to say "Logout" instead of "Login".

Is there any way to add such a link?


texts: How to make the custom module effect on the node and only one content type?

texts:
The following code is used to output five images, according to what's number contained in $fen. I want to put the button in nodes of a specific content type (e.g. "company").
Which code should I use in my module to get this?

<form action="" method="get">
<input type="submit" name="fen" />
</form>
<?php
  $star = getStar($_GET['fen']);
  echo "<img src=\"xing_$xin.jpg\" />";

  function getStar($fen) {
    if ($fen < 10) {
        return 1;
    }
    elseif ($fen < 100) {
      return 2;
    }
    elseif ($fen < 1000) {
      return 3;
    }
    elseif ($fen < 10000) {
      return 4;
    }
    else {
      return 5;
    }
  }
?>


texts:
I am struggling on how to install Drush.

I have only seen this as a similar question which doesn't answer my question.

Drush's own tutorial from here, doesn't offer much. Its a little vague actually.

I have executed this line in my powershell windows 8:

  wget https://github.com/drush-ops/drush/releases/download/8.0.0-rc3/drush.phar

And it goes through smoothly.
When I execute the next line:

  php drush.phar core-status

I get this error:

  Could not open input file: Drush.phar

Other than that I thought by downloading the windows zip package 7.0.0 I would be able to simply install, but that didn't work either. I mean, I unzipped it but there was no executable file or anything to install. Maybe I did something wrong there.


texts:
I don`t know exactly when but it seems to me after upgrade of some modules and core, sitemap stopped working. Using latest Drupal 7.17 and XML Sitemap 7.x-2.0-rc1

You can see it with some kind of error here http://www.testtest.detect.by/sitemap.xml (Use Firefox to get it displayed)

How could i know what`s the problem?

Thanks in advance!


texts: How to prevent installing module in already installed module?

texts:
I have few modules that provide the same functionality in a different way and they would collide if they would be installed simultaneously.

So I want to prevent installation of multiple modules of this "type". I do not want to add hook_requirements into each one of these modules, I'd prefer to have a central logic(in a "central" module, or profile even).

What would be a good approach to this?


texts:
Currently, I have a single booking page (Booking content type) in Drupal. For example www.xyz.com/booking and booking page itself is handling error and confirmation page and falls on same URL www.xyz.com/booking. Few Question needs to be considered

1) For google analytics, it's how to track we booking is successful or got an error since we are using same URL www.xyz.com/booking? How can we setup google analytics with same /booking URL for confirmation and error page and normal booking page?

2) If I want to divide those two pages using two different content type
for example booking confirmation page - www.xyz.com/booking-confirm and booking error www.xyz.com/booking-error. I can easily solve google analytics issue. Does that make sense to creating two different content type for booking error handling and for comfirmation? Any other alternative solution to resolve the issue of google analytics and error, confirmation booking page?


texts:
As a programmer, I know a great deal about Drupals backend functionality, but little about theming. I'm using Corolla as a theme, and I want to add a single Views template to the theme.

Initially, I created a blank subtheme, but some of Corollas settings don't show up on my subtheme's settings page, so apparently this changed functionality.

Now I'm considering simply keeping my template as a local patch to Corolla as that's a way of solving the problem that I understand well.

How would you go about solving this issue?


texts: How do I prepopulate a field with calculated options, when user is editing node?

texts:
Say the user is creating a node. I want to display a drop down option list, with prepopulated options, based on a calculation (i.e. reference to user's groups, user's other nodes, etc...). Drupal 7.

I've had no luck with the rules, computed field, prepopulate field modules... maybe i'm missing something?


texts: Removing Divs of form elements with profile2 fields

texts:
I want to remove the extra divs that get added like in the following example (user-register-form):

    phone number *
    <input class="text-full form-text required" type="text" id="edit-profile-parent-field-phone-number-und-0-value" name="profile_parent[field_phone_number][und][0][value]" value="" size="60" maxlength="255" />

I already did YOUR_THEME_form and YOUR_THEME_form_element in template.php to get rid of extra divs. But this only works for the standard fields of a form it seems.

I am using profile2 and profile2_regpath modules and it seems as if they add themselves extra divs for the fields that are specific to the profile fields. But I can't figure out how to overwrite this behavior.

Any help or hint appreciated.

And just in case it is already written somewhere: I used the search function and could only find the standard solution for normal fields. Nothing specific to profile2 module.

Oh and some details: I'm using Drupal 7. If anything else is needed, please tell me.

Thank you, best regards.


texts: Getting Parse Error during installation of Drupal 8

texts:
I am getting the following error while Installing Drupal 8.

  Parse error: parse error, expecting T_CONSTANT_ENCAPSED_STRING' or'('' in var\www\html\core\includes\bootstrap.inc on line 3

When I checked the line number 3 in index.php I saw following two lines.

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

I don't know what is the meaning of above two lines and why these are creating the above error.


texts: How to progragrammatically get NodeType translated value in D8?

texts:
Fetching node translation

$node = Node::load($nid);
$node->getTitle(); // returns title in en(default language).
$translated_node = \Drupal::service('entity.repository')->getTranslationFromContext($node, 'es');
$translated_node->getTitle(); // Returns translated title in es (spanish).

If we want to fetch the bundle's translation. The above approach doesn't work.

Kindly advise?

$article = $node->bundle();
$article->label(); // returns "Article".
$translated = \Drupal::service('entity.repository')->getTranslationFromContext($article, 'es');
$translated->label(); // Also returns "Article".

Translation for bundles provided from /admin/structure/types/manage/article/translate/es/edit


texts: How to store a list of bundles in a select field (programmatically)?

texts:
I need to be able to present a list of available bundles (in this case, Commerce Line Item types) as a select field on an entity, so I can use the value in a custom module. Suggestions?

I've tried creating a select list (using commerce_line_item_type_get_name) and then populating the field's "allowed values" programmatically, but the problem is that when bundles are added/removed, I can't change the allowed values if data is already stored. I don't actually need this kind of data management, as it doesn't matter if stored values reference a bundle that no longer exists. Perhaps I don't need a select list, but a textfield with a dropdown menu input widget or something? I would appreciate any advice on how to proceed.

Thanks! :)


texts:
I have created a custom compound field which contains a managed_file element in the field widget form.

The issue I am having is not with saving the file, but with adding the file usage information.

I picked hook_field_presave based on some research, but this is not working for new content or translating the node.

function MODULE_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
  switch($field['type']) {
    case 'FIELD_TYPE':
      foreach ($items as $delta => &$item) {

        // save file permenantly
        if ($item['IMAGE']) {
          $file = file_load($item['IMAGE']);
          $file->status = 1;
          file_save($file);
          file_usage_add($file, 'MODULE', 'FIELD_TYPE', $entity->nid);
        }
      }
      break;
  }
}

The issue here is that when I save a newly created node, at this point, $entity->nid has not been defined. This number is required by file_usage_add.

Is there another hook that I can use to do what I'm trying to do?


texts: 8 - How do I check if a comment is from original poster?

texts:
I have a page where written articles are displayed. The following is a article written by Canada_Girl1993.

As you can see, the author of the article is displayed at the top.

Now, other users are able to comment on this article, as well as the author of the article. But how can I check if a comment is from the author of the article, so that I can add some styling or html to it?


texts: Displaying products per store in a marketplace

texts:
Don't know if I am skipping an obvious available feature but I am not seeing it.
I am building a marketplace, I have been struggling to display products of particular stores, visiting stores doesn't show the products of the store so I have been trying to make a view of the products belonging to a store. I want on the store page, products belonging to the store will be listed under the store profile. I am using commerce_marketplace. I have not been able to get the right contextual filters to display the products of a store on the store profile. What I am building is a showcase of stores, you click a store and find products of the store.
For store owners and admins, commerce_marketplace does a great job: on store profiles, there is a 'Product's tab. But for anonymous users and customers, no 'Products per Store' displays.
Is it me missing an obvious way to do this?


texts: How to use separate databases for Drupal tables?

texts:
So far, what I've read is you can config multisites to use different tables and share any table with other sites in that multisite config.

My question is if it is possible to get this config:

Database A has Site A's users and Site A content
Database B will only have Site B's content
Site B will use users table in database A.
Site B will have its content in database B.

It may not be a multisite question after all but rather, in short...

Is it possible for a Drupal site to use two different databases for some of its tables? How?


texts: Collapsed and collapsible Field Sets in Admin

texts:
I have created a fieldset (which groups a field collection). Because it has a few nested levels and many fields, I want it to be shown collapsed. I am trying this code but it does not work. The id is retrieved directly from the source code of the web browser. The fieldset is the top-level, and there are more fieldsets inside of it. The form is displayed in the Admin page, the node edit form. The field "field-seo-general" is a #container.

function hook_form_alter(&$form, &$form_state, $form_id){
    if($form_id == "my_form"){
        $form["field-seo-general"]['options']['attributes']["#collapsible"] = TRUE;
        $form["field-seo-general"]['options']['attributes']["#collapsed"] = TRUE;
      ...
} // function


texts: Why is my file upload always NULL in $form_state?

texts:
I've build a form where the user can upload an image as avatar for his profile. But I have an issue as the selected image is not being recognized at all.

I used the image example from drupal.org, this is my minimal code not working at all:

function my_edit_form($form, $form_state, $entity) {

  $form['picture']['picture_upload'] = array(
    '#type' => 'file',
    '#title' => t("Upload picture"),
    '#description' => t("Your virtual face or picture. Pictures larger than 150x150 pixels will be scaled down."),
    '#upload_location' => 'public://pictures/',
    '#size' => 48,
  );

  return $form;
}

Now, I'm trying to use the file() functions as described in the documentation but it seems my $form_state['values']['picture'] is always NULL.

function my_edit_form_submit($form, &$form_state) {
  dpm($form_state);
}

I have no idea how that's possible and I'm a bit lost here. Any idea what else I could try?


texts: Assigning permissions based on taxonomies

texts:
I have a hierarchical taxonomy that looks like this:

School>Class>Project

That is you could have a project that is part of a certain class that is part of a certain school.  I would like to make it so that only students that are enrolled in a specific class can submit content to that class/project.  Also, I would like to have a semi-adminstrator role called teacher that can only enroll students into a class that they are administering but cannot enroll students into other classes.

I have found a depreciated module called taxonomy based permissions but it seems like it was abandoned after drupal 5 (I am using drupal 7).  Are there any new modules that might help me accomplish these goals?  If not, this problem seems a little bit outside of the intended functionality of taxonomies, I am wondering if I am using the wrong kind  of model for my site.  Any feedback on this though?


texts:
I've tried with preprocess_page, preprocess_forums even changing drupal_set_title directly in forum.module but i can't get change that ugly page title "forums".

Any idea?


texts: Field_image empty after database export and import

texts:
I exported my previous D7 database (db1), and imported it into a new database (db2). That said, all of my data (pages, articles, content, etc) seems to have exported the way it should... EXCEPT for the images attached to my articles. Now when I navigate to an article, what was uploaded to my field_image previously is now a broken link (even though the fid in my database seems to be correct). Does anyone know why this might be or how I can fix it?

If it helps, this is the error message I get on the screen as well:

  Warning: array_key_exists() expects parameter 2 to be array, null
  given in theme_image_formatter() (line 605 of
  /modules/image/image.field.inc)

When I right click on the broken image and attempt to "show image address", it simply gives me my domain name. E.g. mydomain.com, and no real path to an image. Not sure if that matters.


texts: When using the Real Name module, how can I show the original (raw) username in a view?

texts:
The Real Name module allows a field in the user profile to be displayed as a user's name instead of the user name set upon registration.

This works great for my site as it allows people to set nicknames without having to worry about them being unique, etc.

However, I want to create a view for administrators that lists the actual (raw) username, not the real name.  When I add a User: Name field in views, though, the real name is displayed, and I don't see any option for the raw result.

How can I show the raw result in Views when Real Name is installed?


texts: Is it possible to have 2 different thumbnail image styles for the same field?

texts:
I'm importing videos and video thumbnails from a legacy site. A lot of video thumbnail have black boxes at the top and bottom due to the aspect ratio of the videos, for example:

I would like to crop all video thumbnails to remove those bars. I haven't done it yet but assume it's pretty easy to just modify the image style for "thumbnail".

Now, any new videos that will be uploaded (using the video module) or any of the images that use the thumbnail style don't need to be cropped that way. If I would change the image style for "thumbnail" after all videos are imported then I would lose the crop effect, right?

How can I solve this problem?
I'm displaying all video thumbnails using views. Do I need to do a template override where I manually apply a different image style to those "legacy" videos?


texts: Drupal for Bloggers: How can I achive getting such a little FB, Twitter, etc. Box on the left of my homepage?

texts:
How can I achive getting such a little, sticky FB, Twitter, etc. Box on the left of my homepage, like one can find on this site:
http://www.marieforleo.com/2010/04/real-online-paid/

Any ideas - or is there a module for that?
Sorry I don't know what this little box is called ...

Many thanks!
Soezkan


texts: "drush up" fails with "pm-updatestatus failed."

texts:
When I execute drush up, it returns the following error message.

  The command could not be executed successfully (returned: The
  filename, directory name, or volume label syntax is incorrect, code:
  1)   pm-updatestatus failed.

drush pm-updatestatus runs without errors.

Similarly, "C:\\Users\\user1\\AppData\\Roaming\\Composer\\vendor\\drush\\drush\\drush"
    --backend=2 --verbose --debug --root="C:\\website\\drupal7"
    --uri=http://default  pm-updatestatus 2>&1, which I extracted from the debug output of drush -d up (see below) also successfully runs.

What could I try?

The debug output is the following.

  Calling hook drush_pm_updatecode_validate [11.27 sec, 17.04 MB]
  Returned from hook drush_pm_updatecode_validate [11.27 sec, 17.04 MB]
  Calling hook drush_pm_updatecode [11.27 sec, 17.05 MB]
  Cache MISS cid: 8.1.2-alias-path--59067c616e8e4f3b7078e0502d77bf35
  [11.27 sec, 17.06 MB]   Backend invoke:
  "C:\Users\user1\AppData\Roaming\Composer\vendor\drush\drush\drush"
  --backend=2 --verbose --debug --root="C:\website\drupal7" --uri=http://default  pm-updatestatus 2>&1 [11.61 sec, 17.09 MB]   "C:\Users\user1\AppData\Roaming\Composer\vendor\drush\drush\drush"
  --backend=2 --verbose --debug --root="C:\website\drupal7" --uri=http://default  pm-updatestatus 2>&1 [11.61 sec, 17.09 MB]   The command could not be executed successfully (returned: The filename,
  directory name, or volume label syntax is incorrect., code: 1) [11.79
  sec, 17.09 MB]   pm-updatestatus failed. [11.79 sec, 17.08 MB]

I am using Drush 8.1.2, Drupal 7.50 running on Windows 7, PHP 5.6.23, and Apache 2.4.23.


texts: Custom form handler not found (call_user_func_array() error)

texts:
Currently on Drupal 8 beta 7.

I'm trying to build a form with separate "submit" and "cancel" buttons. The cancel button has some separate cleanup work to do. I've tried to follow the documentation and examples to create a custom form handler to manage this. Here's my actions block from my form.

    $form['actions']['#type'] = 'actions';
    $form['actions']['cancel'] = array(
      '#type' => 'submit',
      '#value' => 'Cancel',
      '#button_type' => 'cancel',
      '#submit' => array('uso_cancelForm'),
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => 'Submit',
      '#button_type' => 'primary',
    );

Then, in my form object, I define the custom handler.

public function uso_cancelForm(array &$form, FormStateInterface $form_state) {
    drupal_set_message("Editing cancelled");
    // Handle state information here
}

However, pressing the cancel button has no effect, except to log an error:

  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'uso_cancelForm' not found or invalid function name in Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (line 116 of /{redacted}/core/lib/Drupal/Core/Form/FormSubmitter.php).

So it looks like, for some reason, Drupal can't find my uso_cancelForm function, which is sitting in the form object definition right next to validateForm and submitForm. The "Submit" button calls submitForm without a hitch.

What am I doing wrong here?

I've figured out that if I move my custom uso_cancelForm function into my .module file, Drupal finds and runs it, but this solution won't work as a long-term solution, because I need to use $this in the code that the cancel function executes.
So, clearly, my form's public functions aren't in scope when the button press is being handled, although the standard validateForm and submitForm functions are. I tried adding include_once "src/Form/{my form filename}.php"; to my .module file, but this doesn't help.

Is there some other way I need to let Drupal know about this method, so that the FormSubmitter will know about it and call it?


texts: Filter content moderation view according to user roles that I currently login to the site

texts:
The view I try to filter is only accessible to authenticated users and they have defined roles, that is, it is an administration view.

I have several types of content and I want to show in the moderation view that the user has permission to edit. At the moment all the contents are shown and also those that can not be edited (based on role). I do not know if you understand.

Example:

Pepe has permissions on the content Articles
Juan has permission on the contents News

When Pepe starts the session, I want him to be able to see only the contents of the articles and not the news.

It applies in the same way when Juan starts a session, he only sees what corresponds to him.

From the configuration of the moderation view I did not find the way to filter according to the user.

Looking for information I found:

…that you can use HOOK_views_query_alter to change the query, but I have not managed to understand its operation.
…you can create a filter for custom view using view plugins.

Anyone idea of what form the solution can be implemented?

Greetings.


texts: Allow view access to current user and admin

texts:
I'm creating a view to list user sessions statistics. (Data selected from table myuserstat, there is UID field, myuserstat rows is not a Content Type, just table)

I want to make access url like /mystat/{user}, to list data of specified user.

How can I allow users to see their own stat, and admins see all users stat?
For now i only found how to limit to the current user:
contextual filter->UID->Provide default value->logged user id.
But in that case, how to allow admins to view all users?


texts: Tabledrag in Drupal 7 admin pages only working in Firefox

texts:
For some reason, in the last couple of days any table that is tabledrag enabled (in core admin interfaces like the menu editor, as well as custom modules) only works in Firefox.

In IE and Chrome there are no errors reported in the console, the row is highlighted on mousedown, but nothing happens when you drag.

Has anyone else encountered this and know of a fix?


texts: Invalidate Internal Page Cache at certain times in a day for anonymous users

texts:
Let say I have a webshop open from 9am to 11am (data coming from config).
When the shop is closed, I would like to display a message (shop closed) and when the shop is open, my commerce product should be available. (only for 'lunch' bundle)

I have tried to update the following code: https://cornel.co/article/drupal8/page-cache-cookies-or-anything-available-http-request

Here is my try (edited with a comment from 4k4:

protected function getCacheId(Request $request)
{
    if (! isset($this->cid)) {
        $cid_parts = [
            $request->getSchemeAndHttpHost() . $request->getRequestUri(),
            $request->getRequestFormat(NULL)
        ];
        // Only cache by State of Store for some path
        if (strpos($request->getPathInfo(), '/lunches/') != false) {
            $store_state = get_store_state();
            $cid_parts[] = $store_state['context']; //return a string like 'open' or 'close:9:30:11:00' if closed (like before 9:30 am or after 11:00am)
        }
        $this->cid = implode(':', $cid_parts);
    }
    return $this->cid;
}

As stated by 4k4, I must create a new context which will bubble up and will invalidate the Internal Cache page.

Here is the code of

class StateStoreCacheContext implements CacheContextInterface

stored in mymodule/src/CacheContext/StateStoreCacheContext.php

public function getContext()
{
    $storeState=get_store_state();
    return $storeState['context']; //return a string like 'open' or 'close:9:30:11:00' if closed (like before 9:30 am or after 11:00am)
}

And here is mys service declaration:

services:
   cache_context.state_store_context:
    class: Drupal\mymodule\CacheContext\StateStoreCacheContext
    arguments: []
    tags:
      - { name: cache.context }

And here is the way I add my context to my page (in mythem_preprocess_node(&$vars))

$vars['#cache']['contexts'][] = 'state_store_context';

Unfortunately, my page cache is not invalidate for anonymous users (but it is ok for logged-in users)


texts: Bots still register on website even though CAPTCHA is activated

texts: I have activated CAPTCHA but bots still register on the site. If someone can advise how this can be prevented.


texts: user hook node update to attach files to a node?

texts:
im using the following code to upload an array of files when a node gets saved.

function mymodule_node_update($node){
 $result = $query;

 foreach ($result as $record) {
$url = ($record['src']);
$name_arr = explode('/', $url );
$filename = end($name_arr);
$filepath = system_retrieve_file($url, 'public://my_files/');

$file = new StdClass();
$file->uid = 1;
$file->uri = $filepath;
$file->filename = $filename;
$file->filemime = file_get_mimetype($file->uri);
$file->status = 1;

$dest = file_default_scheme() . '://'.$filename;
$file = file_copy($file, $dest);
$file->display = 1;
$file->description = "";
 }
}

This uploads the files to my public directory, and creates an entry into files_managed in my database.

But now how do I link those files to a filefield on the node im updating?
I've tried variations of

  $node->field_file = (array)$file;

but nothing is working.

Thanks for any help


texts:
I'm trying to print the image field from a node using the nid in the url.

$nid = $_GET['field_item_request'];

Is there a specific way to do this?


texts: URL alias to access user profile as admin

texts: I realized that users on my site have their path ending in the form "user/number" (for example: user/3) when I check People in the Admin Toolbar and click on their username. I would like to use URL aliasing or some alternative that allows the path end with their username (for example: user/john_smith). How can I do this?


texts: Upgrading a simple drupal 7 module to drupal 8?

texts:
I am new to drupal and currently using version 8. I am trying to convert cricket feed widget module in drupal 7 to drupal 8 based on Community instructions.. But I am unable to understand the routing.yml files. I don't understand the parameters used in the routing.yml file to connect with the controllers. I checked out some of their examples..

I don't understand

what they mean by sub_name and
Path: Path to the page on site.How do I know that?
Is it that much difficult to convert a simple drupal 7 module to drupal 8?


texts: How to stop text-boxes in my custom block trailing past the block?

texts:
I am creating a module with a custom block.  Even through googling, I still could not find an answer to my question "how do you theme the elements in a form?"  I think it is the fact that I don't completely understand the array elements that need to be set on each textbox.

Image of my problem: https://www.evernote.com/shard/s188/sh/3bf8cc91-5341-4c55-91ca-41e0ddbd1922/feb9698ff407e60a064f92421510059d


texts: CPN: Replacing tokens in physical css/js files

texts:
Hi I have some css / js attached to a box with Code Per Node. CPN creates physical files for the code. In hook_preprocess_node I can see the CPN output, for example:

$vars['cpn']['css'] = token_replace($vars['cpn']['css']);
$vars['cpn']['js'] = token_replace($vars['cpn']['js']);

This successfully replaces the tokens in memory but the physical file is loaded up in the header and so the tokens aren't replaced in there and cause an error. Any ideas?

Thanks


texts: Can I remove unused core modules from Drupal?

texts:
I am about to start a new website that is supposed to handle thousands of users at once. It is having some mobile application, and I need to use web service.
As a matter of performance, and the link I found here, I am planning to remove core modules such as the Blog module, the Forum module, and maybe the Search module too.

Is it a best practice? What can I do to increase the performance, as I am not planning to purchase a VPS or something like that for hosting?


texts: How do I redirect to www and https in settings.php?

texts:
I want to include code in settings.php which would handle redirects to the www alias and also https.

Because it is for a distribution I would prefer not to have hard-coded URLs and I would also prefer not to be changing the .htaccess file so that core updates are easier.

I am using the code below, and I just want to be sure it doesn't have any security issues. Does it have any security issues, and I should therefore use different code?

// Redirect to www
  if (substr($_SERVER['HTTP_HOST'], 0, 4) !== 'www.') {
  header('Location: '.$protocol.'www.'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI']);
exit;
}
// Redirect to HTTPS
  if($_SERVER["HTTPS"] != "on")
{
  header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
exit();
}


texts: Global PHP "sort through" vs other fields

texts:
In drupal views, you can create a field called "global php" and insert your own php code. Also as well, it has a sort feature which is handy when your view style is a table.

However, the other fields does not have a "sort" feature on them. Is there a way to add it to them? Or does it just have to come with it, like global php does?


texts:
I'm trying to implement a search function with location in Drupal.

At the moment I have a base setup with a custom Content Type (Discount), which has a Geofield parameter. This gets indexed in Solr with the proper fields, filters and facets.

Then, after this I see there are two options:

One is using directly Search API, which creates a search page with the facets. (Ok, deadly simple and works). Problem: I can't do really strange things like showing stuff on a map.
Use Views with Search API: it is also quite simple and I can show the output in a map (as well as I'm more used to them). However, I don't have any idea on how to implement facets there... I took as a reference this project.

I've tried with both this options and I can make them work properly.

So, my question is, how do I add a map to the Search Page in Search API, or how do I add facets into the Views page. I'd rather prefer views if possible, as I'm trying to setup a system which detects all the Discounts in a certain distance in your area, depending on your geolocated IP.

The only idea I have would be to create a Taxonomy, with which I could tag the Discounts with Country and category, and then use that somehow in the view, but not quite sure on how to do so.

Thanks a lot!


texts:
I have Drupal 7 GMap based map, with many markers. I want to hide the map on windows load, an initialize on click. My problem is: after display map,  she don't remember coordonate of center, and map displayed with te bigger zoom. Please help, how to recenter the map, but keep the markers.
I tried this code in JQuery, but I don't need a new map.

function initialize(){
   // create the map
   var myOptions = {
     zoom: 8,
     center: new google.maps.LatLng( 32.8512705331102, -117.08586603100235 ),
     mapTypeId: google.maps.MapTypeId.ROADMAP
   }
   map = new google.maps.Map( document.getElementById( "gmap-mymap-gmap0" ),myOptions );

 }


texts: Lightbox2 image formatter in view not adding click event

texts:
I have a view with an image field in it. I also have two different image styles, "timelinr" and "timelinr-modal". What I want is the thumbnail image to be the first style, and when its clicked on have it come up in a modal with the second style.

I have setup my settings on my image like the following,

For some reason though, this is not adding a click event to my image in the view. Am I doing something wrong here, or should I go about this a different way?


texts: Webform updates CCK field, doesn't update in node edit

texts:
I have a CCK field used to track the number of volunteers needed for a specific position. Once someone signs up to volunteer for that position, the number needed is decreased by one.

The issue is that when I go to edit the original node, the # of volunteers needed is not updated with the new number from the database. I checked the database and I can see that the correct values are being written. They aren't being loaded into the node edit form.

It appears to be a caching issue since when I clear my cache the problem is corrected. Is there a way to fix this apart from turning off caching?

Thanks!


texts:
I want to make a site using Drupal for patients to give their feedback about doctors in the country. A doctor will be classified using say Taxonomy to be in State->City->Zip code and also his/her specialization using Taxonomy.

Are there any modules I can use to quickly make a feedback site up and running ?

EDIT: I want at least the features as in http://www.ratemds.com


texts: Unset widget tab from media browser programmatically

texts:
Need to unset a widget tab from media browser based on the condition of media type supported by the field.

Media types: Image and Video.

For example, There is a field which references image media type only. When the media browser appears on the form, it displays create embed tab as well to embed the videos.

As the field doesn’t reference the video media type, need to unset the tab programmatically to help the content author.

I have tried the form alter, but I don't get any information about the media type referenced by the field in the hook.


texts: Same Image in Multiple product with feeds

texts:
I like to upload a lot of commerce product from a csv file and I have one image for multiple product. I am importing images from a subdirectory of files, the field is in the csv: public://productimages/PRODNUM.jpg.
It is working very nice, but when I use the same photo for multiple images it is makes a new image for every product. (PRODNUM.jpg PRODNUM_1.jpg PRODNUM_2.jpg PRODNUM_X.jpg)

I like to use the same image for same products if the name is same.

I tried filefield path filefield source but not helped. If it possible I do not want to use the media module.


texts: How to display mini panes in specific pages of my site

texts:
I need to display mini panels only in selected pages.

Where and how should I mention it?

For Example:

In blog listing pages i need to display the panels in right side.

And in it's full view page I should not show the panels in right side.

How can this be done?


texts:
In Drupal 7, the module taxonomy_display allowed me to insert a content view via views display options under the taxonomy manage display. I am working on rebuilding my Drupal 7 views for Drupal 8, and the way they are built in 7, they depend on this function.

We are using a (term) view to display parent terms as links to navigate to:

either a child term view (parent/% path) displaying child terms as links to the content view when the content is ascribed to the child term.
or  our content view (also parent/% path) when the content is ascribed directly to the parent. We accomplish this in our content view by using no results behavior/global view area to inject the child term view when there is no content ascribed.

With the taxonomy_display module, you then simply go to the term page display and set that to the content view. It will show child terms when there is no content ascribed, and it will show content when there is content ascribed.

The module documentation for taxonomy_display for D7 says that the core function of this has been included into Drupal 8, and refers you to this issue for more information, but there I didn't find information there on how this function is implemented in Drupal 8. It seems that they are referring to the taxonomy/term view in now in core.

My question is, can i still accomplish this structure without the taxonomy_display module merely by what is provided by the taxonomy/term view in core?

Or can I ignore the taxonomy/term view all together and accomplish it a better way?  I'm new to D8, so any help would be appreciated!


texts: How do I resolve an unnamed requirements problem during an update?

texts:
I am attempting to update my Drupal 8.2 instance to Drupal 8.6.4.  I have faithfully followed the manual installations steps found here https://www.drupal.org/docs/8/update/update-core-manually.

I replace the core and vendor folders and replace all the files in the root with the 8.6.4 files.  I rename the 8.6.4 defaults.settings.php file to settings file, move my unique settings into that file and upload it to sites/default. I then visit update.php, but I get stuck at the requirements stage.

There is an error saying "Requirements Problem: Check the messages and try again."  There are, however, no messages.

I'm happy to keep troubleshooting this but I need to know where I'm going wrong.  How can I discover what the Requirements Problem(s) are?

Some Other Details

Both the database and the Drupal server are running in a AWS VPC.
The server is a linux machine: VERSION="16.04.5 LTS (Xenial Xerus)
Drush is not working or installed. The original sysadmin didn't install it as part of the Drupal installation and I haven't added it since.
Composer is installed but I've never used it to manage Drupal versions or dependencies.
Drupal is behind an nginx reverse-proxy.  I have the made allowances for Drupal in the nginx conf file as recommended here: https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/.  Mostly just this rule  location ~ '\.php$|^/update.php' {...}
There are other non-Drupal tables in the same DB that Drupal uses.
Drupal tables are prefixed: drupal_
We use drupal in a headlessly.  A separate Node.js app interacts with Drupal via Drupal Rest routes and is also connected to the same DB as Drupal.

Issues I've already resolved

Missing sourcecode for hello_world module. Removed hello_world from Drupal table: drupal_key_value
$settings['update_free_access'] = TRUE;

Things I've tried:

checking the apache2 error logs. No errors thrown.
checking the apache2 access logs. Just shows access to update.php

Let me know if I should post any more information.  Also, if using drush or composer would help, I'm interested in getting those going on my site anyway, and would be happy to install them.  In summary, during a Drupal 8 upgrade, Drupal complains about Requirement Problems but never lists them. How can I discover what the Requirements Problem(s) are?


texts: When using Views slideshow with videos I cannot get the slideshow to stop in order to play the full video

texts:
I have created a slideshow with images and videos using Views Slideshow.
 I slide through the content of a content type that has images and embedded youtube videos (using the youtube module).

I have one image or one video per content and it works fine. The only problem appears when I try to play a video. The slideshow passes to the next slide whilst the video is still playing.

Do I need to change the cycle options (within the slideshow options) in the view? or do I need custom code?

I have already tried many things within the slideshow options but nothing seems to work. Thanks in advance.


texts: How can I theme some blocks with the same theme?

texts:
I'm seeking the best practises for theming some blocks using a same template file, but my problem is that blocks may not be used in a same region, and they can also be used in one module that has a bundle of different blocks with different themes.

How can I achieve this?


texts: How do I alter a way node is rendered so I can add custom links/buttons?

texts: Sometimes I want to add custom links/buttons specific to a content type to a node when the page for that node is rendered, how would you achieve this when you write a module? An example code to achieve this by adding hello world link somewhere in the page when a node is rendered would be appreciated as the lack of documentation I can find for this is discouraging.


texts: View using views content pane not updating on node save

texts:
On the home page, I have a view content pane to display the latest 3 blog items.  When I save a new blog node I don't see my new item on the home page. The only way to get it to show up is to flush all cache.

Any way to force the cache on the home page alone to clear when the node is saved?


texts: Will a Fields form with many submissions make an overload of nodes?

texts:
I need to create some user submission forms, and I'm debating the merits of using a custom content type Fields API forms, or a custom module form like the ones in Examples module.

As I understand it, Fields API forms will create a new node for each submission. These forms will have hundreds of submissions every day all year long, and this will create a lot of nodes. I am wondering if this would present a problem in terms of database performance, and site management.


texts: How can I run a query with php before entering a view

texts: Is there any way to specify that a certain query has to run before entering a view?  in a module with php .


texts: What is the proper way of retrieving and handling sessions when making multiple calls to the API?

texts:
I can't log in consistently via Services 3 in Drupal 7.

POST http://<mydrupaldomain>/services/user/login.json
{
"username":"admin",
"password":"password"
}

The first time I make this request I get a session name and id back.
Which is what I want. I use the session information to make
successive calls such as update user.
The second time I make this
request the response comes back as HTML for the login screen.
The third time I get

  401 Unauthorized: Access denied for user anonymous

And at the forth time I get am able to login again with a NEW session name and id.

I make these requests within seconds of each other. I will have an application which will be making multiple API calls to Drupal per second.  This includes creating a user and updating a user both of which requires that I get a user session id in order for the request to be served by the API.

Questions:  Why the inconsistent behavior? On each login attempt I expected to get either a new session info back or, if the user is already logged in, the current session.

What is the proper way of retrieving and handling sessions when making multiple calls to the Services API?


texts: Enabling aggregate and compress CSS files resuls in vanishing theme

texts:
I used this module for more compression on css and js files but it does not work for me! so I disable and remove it entirely.
After that when I enable aggregation of css and js files, my site's theme will disappear! even my administration theme! what should I do now?


texts: D7 Mixed menu (entity and content translation)

texts:
In my main menu I have mostly links to nodes that are translated with entity translation, so one node with the fields translated.
But I have two nodes which are translated with content translation, so each node is actually three seperate nodes (three languages).
Now I don't know how to implement these content translated nodes in the hierarchy of the menu.
To clarify, my menu should look like this:

Main Menu
-Menu Item 1 (entity translation)
-Menu Item 2 (content translation)
--Menu Item 2.1 (content translation)
--Menu Item 2.2 (entity translation)
-Menu Item 3 (entity translation)

My question is this, how do I make a menu item for items 2.1 and 2.2?
Since item 2 is actually three seperate nodes I don't know what to configure as the parent of item 2.1 and 2.2.

Thanks, any help is greatly appreciated.

EDIT: I've been thinking about this some more. Would it be possible to programmatically change the link of a menu item based on the language that is currently used?


texts:
I need to scale image in Drupal 7.
IF the width is greater than the height, THEN scale the image to 200px height.
IF the height is greater than the width, THEN scale the image to 200px width.
and if the width and height are the same, scale to 200x200.
Please help me out.


texts: How to find out if an entity type is provided by core or a contrib/custom module?

texts: How can I find out which module is providing a particular entity type? I'm implementing hook_entity_type_alter() in a custom module, and I want to identify the entities that are provided by core. Is there a way to get information about the module that implements an entity type, so that I can gets its origin (set in core/lib/Drupal/Core/Extension/ExtensionDiscovery.php) or its package (set in module.info.yml)?


texts: How do I add another field after saving entity metadata wrapper?

texts:
I'm trying to do something like this:

function create_content($type,$content){
  $node = entity_create('node', array('type' => $type));
  $emw_node = entity_metadata_wrapper('node', $node);
  $fields = field_info_instances("node",$type);
  foreach ($content as $field => $value){
    if (array_key_exists($field,$fields)){
      $type=field_info_field_by_id($fields[$field]['field_id'])['type'];
      if ($type=='link_field') {
        $emw_node->$field->url = $value;
      }
      else {
        $emw_node->$field = $value;
      }
    }
  }
  $emw_node->save();
  $id = $emw_node->getIdentifier();
  $emw_node->other_field = $id;
  $emw_node->save();
}

With the idea of copying the node id to another field. However, I get an error:

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. Value at node(9999)->field_other_field: 9999. in EntityMetadataWrapper->set() (line 122 of /sites/all/modules/entity/includes/entity.wrapper.inc).

How do I do this properly, preferably while still using an entity metadata wrapper?


texts: How to force display of a specific page of paged data

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


texts: How to set a "must be greater than a value" condition in Rules

texts:
I need to check with the Rules module whether a field is greater than some value. To be more precise, if the size in cm of a product (the field size is created through the Commerce Physical module) is > than 5000.

How can I do this?  I tried to add a 'Data comparison' but i only get "equals" or "is one of" when i select the comparison operator. I would have expected an "is greater than".


texts: Using custom CSS3/HTML on generated pages?

texts: I created new pages on my (soon to be) photography website using Panels and Views. I want to have my own hover effects for pictures on my albums page. How am I supposed to use custom HTML and CSS3 animations like those found here on these images which are loaded by modules such as Panels and Drupal which are basically creating their own markup on the page load i.e. not in hard coded files which I can add markup to.


texts: Email field on registration page not working

texts: When I try to register a new account using the standard settings for my site no matter what I put in the email field it gets highlighted in red and I can't register a new user. Has anyone experienced this before or know any solutions to this?


texts: How to prevent an Ajax form from submitting

texts:
The below code blocks any non-ajax form from submitting.

$(this.form)
  .on('submit', function(event) {
    if (/* Some condition */) {
      event.preventDefault();
    }
  });

In Drupal 8, how can we block an Ajax form from being submitted?

Ajax forms do not trigger a form submit handler and I have not been able to block the click event on an Ajaxified form's submit buttons.

For reference, I am trying to fix Issue #3010084: Form submission finishes before file upload is complete


texts: How to use field_attach_update for users

texts:
I have read this post fast saving single field value about how to use field_attach_update to save nodes without the overhead of node_save().

I would like to use this for users (which it should work for, as per https://api.drupal.org/api/drupal/modules%21field%21field.attach.inc/function/field_attach_update/7) . However, I'm not sure how to apply the examples to users.

Currently, this is my code:

if (isset($uid)) {
    $user = user_load($uid);
    $user_og_groups = $user->og_user_node[LANGUAGE_NONE];
    $user_committee_positions = $user->field_committee_position_serno[LANGUAGE_NONE];
    $user_data = my_module_import_user($cust_info, $cust_attributes, $drupal_countries, $employers);
    $user = user_save($user, $user_data);
  }

The $user_data variable is an array of data, which is what user_save expects (https://api.drupal.org/api/drupal/modules%21user%21user.module/function/user_save/7). user_save() doesn't work exactly the same as node_save() and doesn't accept a user object.

How then can I use field_attach_update to programmatically update users?


texts: Update a field without changing the node

texts:
I need to change a field in a node without altering the 'changed' timestamp. I know this was possible in Drupal 7 using field_attach_update(), but that has been removed since then.

I could use an update query and change the field directly in the database, but I was wondering if there is a better way (or a replacement for field_attach_update()).


texts:
I have themed Drupal7 forms, cannot do the same with 6 ...

I have:

function _my_form() {
    $output="";
    $form=drupal_get_form("my_form");
    $output=theme("my_form",
        array(
            "element"=>array(
                "my_form"=>$form
            )
        )
    );

    return $output;

}

function MYMODULE_theme()
{
    $themes = array(
        'MY_form' => array(
            'template'=>'my_form',
            'variables' => array('element' => NULL)
        )
    );
    return $themes;
}

If i do a var_dump($element["my_form"]) in my_form.tpl.php i only get a superlong string with the html form already rendered, while i expected to have an array with all the single form fields... what am i doing wrong?


texts: Content loss in Drupal related with field_attach_update

texts:
Drupal field_attach_update seems to be the cause of a content loss in my application.

This function is used to save a node field instead of the whole node but if it is not used properly it can produce a content loss.

Normally, in Drupal the common way to save a node is using node_save function but this function will save all node fields and this consumes more resources.

Problem is node_save uses db_transaction function to create a db transaction and avoid concurrent accesses to the database. field_attach_update does not use db_transaction so, for me the proper way to update a field would be like this:

$transaction = db_transaction();
try {
    $node = node_load(1); // where 1 is the nid you want to change
    $update_node = new stdClass();
    $update_node->nid = $node->nid;
    $update_node->vid = $node->vid;
    $update_node->type = $node->type;
    $update_node->field_FIELD_NAME['und'][0]['value'] = VALUE_YOU_WANT_TO_CHANGE;
    field_attach_update('node', $update_node);
} catch (Exception $e) {
    $transaction->rollback();
    throw $e;
}

What do you think? Do you agree with this?


texts: Where to start on fixing a locations module not accurately displaying on a gmap with views

texts:
I have been having problems with my locations module displaying points on a gmap using views. I have a profile 2 profile that has a locations field on it to store locations. I collect that data using a views to display it on a gmap. But this all works.

The problem I am having is the location points are in most cases not at all accurate or do not show at all. I have a list of 92 countries that are not working correctly. Some smaller countries I could care less about but ones like Barbados and Finland are not working.

I cannot figure out how to start on fixing this issue. It may be a locations.xx.inc problem, or a geocoding problem or a gmap problem. I do not know where to start.

Any suggestions?

Thanks,
Greg


texts:
We migrated a site from custom CMS to Drupal. The content has been migrated successfully, but there is a problem with URL mapping.

In old site the URLs were like domain.com/artists/Artist_ID/Artist_Name (e.g. domain.com/artists/5/picasso), where the URL would work without the last argument part (picasso).

With the Drupal site all URLs use domain.com/artists/Artist_ID as format (e.g. domain.com/artists/5).

They have shared the old site's links on social media where URLs are like domain.com/artists/5/fabien-m%25C3%25A9relle which used to work fine in the old site because last part didn't matter. The same URLs do not work on the Drupal site.

So can I make Drupal ignore the last part of the URL?


texts:
I am building a custom form inside a block that has a clickable image as submit.

Here the screenshot of the outcome:

Here is the form code:

function my_form($form, &$form_state) {
  $image = '#';

  if (module_exists('my_base') && function_exists('my_base_get_form_settings')){
    $image = my_base_get_form_settings('IMAGE');
    $form['my_text'] = array(
      '#markup' => '<p>'.my_base_get_form_settings('BODY').'</p>'
    );
  }
  $form['submit'] = array(
    '#type' => 'image_button',
    '#src' => $image,
    '#attributes' => array(
                      'style' => 'width:80%',
                      'OnSubmit' => 'my_function();return false;'),
  );
  return $form;
}

I want the image to be clickable and to run the javascript, but without the ugly style of the default button. I didn't find any example that matched my needs.

How to I properly build an image submit in drupal 7? This is obviusly not the right way.


texts: How to delete blocks and why some you can delete and others you can't?

texts:
I'm probably missing something here....

But there is no delete option for blocks, either enabled OR dissabled.

Additionally, some blocks can be deleted, and some don't , they have the same exact settings.


texts: How can I fix, or troubleshoot, Fatal Error Class not found with XHProf Module

texts:
I'm seeing the following error when I enable xhprof in Drupal 8 either via Drush or via Composer.

  Class 'Drupal\xhprof\RequestMatcher\XHProfRequestMatcher' not found in /var/www/mysite/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 272

I had xhprof working for a day or so, and randomly started seeing this issue. This feels very much like a Symfony/Composer autoloader issue to me, but I'm struggling with a technique or strategy for fixing or troubleshooting this.

The Call Stack feels pretty useless in this context.

I'm looking for any fix to this issue specifically, but I'm also looking for some technique or strategy for troubleshooting the missing class fatal error. The missing class error seems to keep cropping up for me with Drupal 8. I've tried to trace through the object hierarchy via xdebug, but Drupal 8 and Symfony, have a very abstracted object hierarchy. This makes it nearly impossible to be able to logically backtrack from where the error is thrown.

Why is the class not found, even though the class is definitely here: docroot/modules/contrib/xhprof/src/RequestMatcher/XHProfRequestMatcher.php?

Update:

After trying everything I could think of, I decided to just try and rebuild my VM with:

vagrant reload --provision

Sure enough, the fatal error went away. Is there some cache somewhere that drush or Drupal Console wouldn't have access to? Maybe it has something to do with the RAM or OPCACHE as @cilefen mentioned?

Note that I do not have memcache or redis running on this VM. Per a conversation on the Drupal-VM issue queue I may have been able to solve the problem by restarting PHP or just doing a reload without having to do a --provision.


texts: How do I migrate users passwords from Drupal 6 to Drupal 7?

texts:
I am trying to migrate users from a Drupal 6 to a Drupal 7 site. My problem is how to change their password from MD5 to the hash one (used by D7).
Do you have any idea?


texts: During insertion of the field in the drupal view, there is image contained text but text is displaying not in image

texts:
During insertion of the New field in the Drupal view, there is content type field containing text and image but text is displaying not in image what to do ?

for example

Filed Name : text_field

During insertion of the that text_field in the Drupal view the new image not visible what to do? i wanted to display that new image also.


texts: Removing prefix for default language breaks all the link

texts:
Since I built the site I always used language prefix "en" for my site. English is my default language.

The thing is our SEO Expert said that this is content duplication for Google and we might get Panda penlty. Thus I removed "en" for English and now all my links are broken.

Thus, is there any way to do following:

*http://www.xyz.com/en/*business-opportunities/zimbabwean-supplier-beverage-flavourings-calls-financiers

automatically redirect it to "*http://www.xyz.com/*business-opportunities/zimbabwean-supplier-beverage-flavourings-calls-financiers". So that I can save


texts: Is it possible to override a field module's implementation of hook_field_validate()?

texts:
I need to override hook_field_validate() for a particular field (provided by the Video Embed Field module). The description for that hook states:

  Validate this module's field data.

So the idea is that it's only invoked for the module that implements a particular field, which makes sense.

Unfortunately there's no altering mechanism in place (that I can find) so the implementations of those hooks are pretty much hard-coded. Also the hook is never run through module_implements() (as you would expect), so in turn is not available to be overridden using hook_module_implements_alter().

Does anyone know of a way, however unclean, of overriding hook_field_validate() for a particular field implementation, without hacking any core/contrib modules?


texts: filter homepage content based on term id

texts:
I have two pages "homepage" and "countries", the default behavior is that when a visitor first visit my homepage all content is gathered regardless of the country.

But if the user went to the countries page, which is a view that's getting term ids from a taxonomy list, and selects a country, he/she will get redirected to the homepage and the homepage content will get filtered to the term id the person chose from the countries page.

I think I should be using contextual filters, but I'm confused right now.

my question is how can I do this filter on homepage based on a term clicked from another view.

any help will be greatly appreciated with hot cookies.