texts: How can I block custom menu from edit and delete?

texts: I have a menu import via Web Service from other Drupal site. I would like to use Menu API to import this menu but I must be sure that will be impossible to remove or edit the menu (even by site Admin)


texts:
I'm not a PHP developer, so I have a problem with customizing a theme.

I create a vocabulary "City" and a term "Shiraz", then a field "field_city" as a taxonomy term in my content type.

Now I want to print this field, so in the tpl file I write the following code:

<?php print render($content['field_city']); ?>

but nothing happens.
What am I missing?


texts:
I'm trying to find the best way to extend a field's data set (not even sure of the right terminology).

What I want, is to attach some other information to an existing field. Let's take a file field, called "my_file", and attach some "other" information to it.

The end result should be, when using node_load and entity_metadata_wrapper, I can get the "other" value.

So these code snippets should give me the value:

$node = node_load($nid);
return $node->field_my_file['und'][0]['other'];
// And this should work:
$wrapper = entity_metadata_wrapper('node', $node);
return $wrapper->field_my_file->other();

I'm not that familiar with the Field API, so if you can point me in the right direction that'd be good.


texts: How to display multiple fields from a taxonomy term on a node (and control the html)

texts:
I have a content type (product) with a term reference field (colour).

When I create a new product and select a colour I would like the display of that node to render the taxonomy items term name and an image that I've attached to each term + control the html markup.

Via the Display Suite module I've managed to render the term's title and colour on the node using "Rendered taxonomy term" format on the field (screenshot below), however I want more control in how the title and image are outputted in the html markup. This is halfway there.

[![enter image description here][2]][2]

The title and image appear right after each other in the markup (as it is correctly rendering the taxononmy term) but to achieve the layout the designer wants I need to be able to render the title and image individually (essentially separate fields "taxonomy title" and "taxonomy image" on my "Product" node's display, instead of just the single "Rendered taxonomy term" that I currently have configured.

Any help would be greatly appreciated.

Edit:

"Product" and "Colour" were just an example. In reality my site has a content type called a "lift" and it has a term reference field linking to a "location" vocab.

So if I add a "lift" and say the location is "Sydney" then when viewing that node I want to be able to pull the "Sydney" term's title and image..but as explained I need greater control over the positioning of the markup (specifically in relation to the "lift" nodes other fields)

Example of what I want the node to look like:


texts: Unable to retrieve node content with drupalgap

texts:
I've set up drupalgap on my website, followed all the instructions and got the Hello World example up and running via Ripple.  I've also been able to adapt that example to put a new logo and different menus on the front page.  However, when I try and view node content it just hangs, with "SyntaxError: Unexpected end of input" being reported via the console.  I've not written any code of my own to do this, I'm just trying to access nodes via the top-left menu provided in the tutorial example.

I've made sure the node entity type is enabled in the services.  I can view user entities (and if I disable these then I get a 404 so enabling nodes doesn't appear to be the issue.

So I've taken it back to basics and if I navigate to example.com/user/1/json I get the page I expect and likewise for example.com/node/1/json.  However when I use example.com/?q=drupalgap/node/1.json I get a blank screen, whereas for example.com/?q=drupalgap/user/1.json I get the JSON output for that user.  So I am concluding that for some reason nodes are not being output via drupalgap (returning null instead?) whereas users are.

Any clues?

David


texts: How to add a new join table by using a hook view?

texts:
How should we alter a query of a view by using the hook_views_query_alter, by adding a new join table.

I tried

 $join = new views_join();

but it seems to be for drupal 7 not 8.

Please help.


texts: Product catalog in views that is hierarchical but not mutually exclusive

texts:
I am trying to get views create a product catalog in taxonomy that is hierarchical but categories are not mutually exclusive.  For instance, lets say my hierarchy looks like this:

+---Color
|   +---Red
|   \---Blue
|       +---Sky Blue
|       +---Navye Blue
|
+---Shape
|   +---Cirlce
|   \---Quadrilateral
|       +---Rectangle
|       +---Square
|
+---Size
|   +---1"
|   +---2"
|   +---3"
|   +---4"

When browsing the view I want visitors to be able to drill down through the categories while still having the other categories exposed to be filtered without requiring the user to select size before shape or vice versa.  The site that is inspired me the most in this project is this: McMaster-Carr.  As you can see in that link, just browsing through the washer section is quite an adventure.


texts: how to view data row table related to user only?

texts:
Good day, I need to create a view, which only shows data related to the user logged in user.
When I have a user called "john smith", I create a contents as I like, BUT I don't want other users to see them.

A content can have multiple input from different users, so ONLY admin can see all content.
while, each user, can only see his OWN content which he posted him self.

Think of it like a database system, where each student can add projects for his own records, but each student can see ONLY his own.

I tried looking around first, and I came across this question https://stackoverflow.com/questions/20840490/drupal7-filter-view-based-on-current-users-roles which seemed bit related, but I got lost in the too much explanation because they not entirely related to what I want to achieve.

In user roles permission, I perfectly found (add content, edit own content) but its missing one more thing which I want.."view own content"!!

I think it has something to do with filed permission, or something like when adding a content, set its permission to be view my that user only.

In coding the view to show ONLY table rows related to the that user, maybe something like this:

global $user;
if (in_array (student_field_name  == $user))
//view the row related to that user;

if (in_array('administrator', $user->uid))
//show ALL data rows available

To summarize, I want the user to be able to SEE his own data only.
while admin will be able to see ALL content view of that page.


texts: node_access() returns FALSE but I can view the node

texts:
I got a view which gets rendered to a variable which then gets mailed to the user. A few days ago, I noticed that this functionality is broken (empty mails) and that for the administrator users everything works fine. So the problem got something to do with permissions.

Strangely enough, if I make the view a page normal users can visit it and see it. If the users try the mail feature, the mail is blank.

I tried to write a function which generates the desired output itself.

function my_function($node) {
  global $user;
  $output = '';

  if (node_access('view', $node)) {
    $output = 'yeah';
  }
  else if ($node->uid == $user->uid) {
    $output = 'meh';
  }
  else {
    $output = 'nai';
  }

  return $output;

}

The output is 'meh'. node_access('view', $node) returns FALSE. There is no problem for the logged in users to go on the site, and view the node.

I got the Content Access module installed. I configured it to grant every authenticated user access to their own content, and a master-user is allowed to view everybody's content.

I've already rebuild the permissions, but the behavior is the same. Has anyone an explanation how it can be that one can view the node/view without problem and at the same time for the same user node_access() returns FALSE?


texts:
I have this error after the installation of the tagadelic 7.x-2.x-dev module:

  Fatal error: Call to undefined function tagadelic_get_weighted_tags() in /home/www/2374fcf941c82d5986ed6d27587b81e0/web/sites/all/modules/cumulus/cumulus.module on line 120

How can I recover my site?


texts: Views - how to replace the pager with a slider

texts:
I have a view of events, and want to display 10 events at a time.

Instead of the clicking the pager, I want the view to cycle to the next 10 events automatically after a set number of seconds - the view will be displayed on a monitor without user interaction.

The views_slideshow module only allows me to do this with every single item in the view.
How would I best approach this - ideally with an existing module.

Please let me know if the question is not clear.

Any help appreciated!


texts: Permission denied for a route implemented by a custom module

texts:
Hello I have the same problem with the following code:

first_module.routing.yml:

first_module.content:
  path: '/first'
  defaults:
    _controller: 'Drupal\first_module\Controller\FirstController::content'
    _title: 'Hello world'
  requirements:
    _permission: 'access content'

and the Controller:

<?php

/**
 *  @file
 *  Contains \Drupal\first_module\Controller\FirstController.
 */

 namespace Drupal\first_module\Controller;

 use Drupal\Core\Controller\ControllerBase;

 class FirstController extends ControllerBase {

   public function content() {
     return array(
       '#type' => 'markup',
       '#markup' => t('Hello world'),
     );
   }
 }

And I receive the same "Access Denied" error every time I try to access this page.


texts: Importing PDFs into Drupal as content types

texts:
I'm new to Drupal and I have a question.

Is there any way to import table data on PDFs into Drupal, creating them as events?

I don't believe there is but I want to double check.


texts: How can I let registered users upload images using a form in Drupal 7?

texts:
I'm using Gallery formatter on my Drupal 7 site which allows administrators to upload images to my articles that are then shown on the article body. So great so far, but what I want is for the registered users themselves to upload images to the article using a form. I've been searching for a while, but haven't been able to find anything that would allow me to do this.

Is there a module that would allow image upload using a form that integrates with Gallery formatter (or just Drupal Image - both would work, I think, as the images are stored in a field), or do I have to create a custom module?


texts: Can I install Drupal Commerce as a site in a multi-site architecture, preferably using Commerce Kickstart?

texts:
Commerce Kickstart comes bundled with the latest version of Drupal and modules necessary for it to operate.

I already have a Drupal install where various sites make up a multi site architecture. Can I use Commerce Kickstart to install a store as one of those sites in that architecture? Note, this would be stand alone. I don't want the default install to be Commerce where there would be an attempt at a multi store setup, I just want one of the sites to be a Drupal Commerce site.

The CK project pages says, "Who should use Commerce Kickstart? Anyone who wants to skip weeks of configuration to build a commerce site on the Drupal Commerce framework."

Certainly I would like to avoid weeks of configuration and setup.

Is this possible? And if so, what's the best workflow to get it installed and the demo store setup?

If this is not possible, please indicate as much, and let me know if it's possible to install Drupal Commerce as a site in a Drupal multi site architecture nonetheless.  If this is the direction I need to go, what would be the folder structure under sites/store.mysite.com? Would I simply follow the directions on the Drupal Commerce project page as if it were an independent installation?

Thanks!


texts: Drush install fails within Vagrant Puppet

texts:
I originally posted this on SO but thought I'd probably get more traction on the Drush side of things from you guys.

I've just gotten a new MacBook running Mavericks.

Unfortunately, I can't get our current project running on it.

We're using Vagrant and Puppet and during the vagrant up phase, I get a message telling me err: /Stage[main]/Drush::Git::Drush/Exec[first drush run]: Failed to call refresh: /usr/bin/drush status returned 255 instead of one of [0] at /tmp/vagrant-puppet-1/modules-0/drush/manifests/git/drush.pp:32

I can successfully vagrant ssh into into the instance but it's clear that Drush doesn't exist.

The only difference between the 2 systems is the operating system. All other files are from the same git repo and same branch.

Any insight would be welcome as this is a total ball-ache.

Thanks,

Steven


texts: How to access custom line item field in rules loop?

texts:
I'm trying to perform an action on checkout for each line item in an order (fetched with Rules loop).
The action should set value to custom line item fields.

The problem is that those fields are not available in the list of tokens when I choose Set a data value. I tried accessing them but Rules won't let me save the data selector.

Any ideas on how can I access custom fields for line items?

Thanks!


texts: How to redirect a URL to the members page of a group?

texts:
Following this question :

How to limit access of a view about Group Memberships to the Group's administrator?

How to redirect URLs :

/group/memberlist/gid

To the members page of a group :

/group/gid/memberlist

thank you in advance


texts: Post/Upload file using Drupal Services Module without base64 (Using REST multipart/form-data )

texts:
I am sure its possible in Drupal also.

Here is the reference for Java code

https://stackoverflow.com/questions/5723429/use-rest-client-to-call-multipart-form-data-rest-web-service

and

https://stackoverflow.com/questions/8989937/form-post-through-rest-client-multipart-upload

But how can I implement for Drupal?

I want to upload/post a file to Drupal site using services module(without base64 encoding).

File uploading with base64 encode using Services module is working fine. I have followed this tutorial

But I need to Post file without base64 encode.

I have tried following steps.But that's not working  (I am using Chrome extension Postman)

Step 1:
I have added Header like:

Cookie: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
Content-Type: multipart/form-data
X-CSRF-token: O7XJHc4DZOVTLSpgRQgF-XD5VD7QFkBpo7QIW8pfN7g

Step 2:
Body parameters

file[file]: Choose files
file[filename]: myfilename.jpg
file[filepath]: public://my1.jpg

After following above steps I am getting error   "Missing data the file upload can not be completed"

I am using Drupal 7 and Services 3


texts: How to unpublish nodes 50 days after they are created by using the Rules module?

texts:
I've tried the method described at https://groups.drupal.org/node/240678#comment-782543 , but it is not exactly what I need. So i changed it a little bit :

Create a ruleset

Name it "Unpublish Content"

In the Settings/Variables:

Data type = "Node"
Label = "node"
Machine name = "node"
Save

... next screen...Add rule

Name = "Unpublish Content Rule"
Save
Conditions (1):

Content is published
Data selector = node
Save

Conditions (2):

Content is of type = node
Value = your-content type
Save

Actions:

Unpublish content
Data selector = node
Save

Create a rule

using /admin/config/workflow/rules
Name = "Unpublish Rule"
React on event = After saving new content
Save
Conditions:

Content is of type
Data selector = node
Value = your-content-type
Save

Actions:

Schedule component evaluation
Component Value = Unpublish Content
Data selector = site:current-date <-- "This is what I changed, I want the node to be unpublished 50 days after it's creation."
Identifier value = unpublish [node:nid] <-- removed this.
node Data selector = node
Save

But I don't have date field.

I have tried many methods but nothing seems to work, I don't want to use other modules like Auto Expire.

Any suggestions to get this to work?


texts: How to delete sites showing up in backend of Aquia Dev Desktop

texts:
Deleted sites still showing up with Aquia Dev Desktop even if I already deleted files and databases.

Any way to clear these?


texts: How to use hook_form_alter in the .theme file to alter the form fields?

texts:
I need to know how to use hook_form_alter in .theme file as i have to alter the form fields related to user_register_form.

I tried putting the below code in the .theme file but it does not even reach the function

/**
 * Implements hook_form_alter().
 */
function hook_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Adding custom validation for the welcome page type field.
  if ($form_id == 'user_register_form') {
     print_r('Reaching in here');exit;
  }
}


texts: Build a form with multiple choice answers (multiple submit buttons) and validation

texts:
Requirements:

User navigates to path "new-problem" and is presented with a math problem and multiple choice answers, one of which is correct.
There is one submit button per choice
If the user clicks a wrong choice, we record that to the database and the same problem is shown again (user gets another chance)
If the user clicks the right choice, we record that to the database and a new problem is shown.

I haven't been able to coax Drupal to accomplish this thus far. I'm sure the problem involves how the form is/isn't rebuilt. I believe this to be related to Submitting a form rebuilds (expensive) page upon submit

I tried using a validation function and form_set_error() when the user chose a wrong choice, but the form kept being rebuilt from scratch with a new problem (instead of the same problem). I tried setting $form_state['rebuild'] = TRUE to no avail.

The code below works except for the first time. When a user navigates to "new-problem", he is shown the form. Upon clicking an incorrect choice's submit button, the "incorrect" status message is shown, but a new problem is shown. Thereafter, clicking an incorrect choice correctly shows the"incorrect" status message and the problem he got wrong.

hook_menu()

function dfm_menu() {
  $items['new-problem'] = array(
    'page callback' => 'dfm_new_problem_page',
    'access callback' => TRUE,
  );

  return $items;
}

menu callback

function dfm_new_problem_page() {
  $node = dfm_get_new_problem(); // Returns a "problem" node

  return drupal_get_form('dfm_problem_form', $node);
}

form builder

function dfm_problem_form($form, &$form_state, $node) {
  $form['#nid'] = $node->nid;
  $form['#correct_choice'] = $node->field_correct_choice[LANGUAGE_NONE][0]['value'];

  $problem = $node->field_problem_mathml[LANGUAGE_NONE][0];

  $form['problem'] = array(
    '#prefix' => '
',
    '#markup' => check_markup($problem['value'], $problem['format']),
    '#suffix' => '
',
  );

  $i = 0;

  // One submit button per choice
  foreach ($node->field_choice_mathml[LANGUAGE_NONE] as $choice) {
    $correct = ($i == $form['#correct_choice']); // TRUE if this choice is the correct choice

    $form['choices'][$i] = array(
      'button' => array(
        '#type' => 'submit',
        '#value' => t('This one!'),
        '#submit' => $correct ? array('dfm_problem_form_submit_correct') : array('dfm_problem_form_submit_incorrect'),
      ),
      'mathml' => array(
        '#markup' => check_markup($choice['value'], $choice['format']),
      ),
    );

    $i++;
  }

  return $form;
}

incorrect submission handler

function dfm_problem_form_submit_incorrect($form, &$form_state) {
  // Create a new answer node to record the incorrect answer
  dfm_record_answer($form['#nid'], $form['#correct_choice']);

  drupal_set_message(t('Incorrect'), 'error');
  $form_state['rebuild'] = TRUE;
}

correct submission handler

function dfm_problem_form_submit_correct($form, &$form_state) {
  // Create a new answer node to record the correct answer
  dfm_record_answer($form['#nid'], $form['#correct_choice']);

  drupal_set_message(t('You got the last problem right!'));
}

Thanks for your time!


texts: Running into deadlock when using XDebug with Drush

texts:
For most of the Drush commands it is not too difficult to get XDebug and Drush working togethr and catch staff in your IDE, e.g. PhpStorm.

However, I ran into a deadlock when Drush is calling itself for a sub-process. This happens e.g. if you execute drush @site updatedb because this will invoke a second PHP task for the cache-clear all command. This second PHP task wants to connect to the Xdebug port as well which is still in use by the parent PHP task. This results in a deadlock: the child is waiting for the XDebug port to become available and the parent task is waiting for the child task - for ever or until Ctrl-C.

Is there a way around this?


texts: Drupal 7- How can alter the data when downloading views records (Data Export)?

texts: Any suggestions/solutions/hook for altering the data when downloading view records (Data Export)?


texts: RDBMS-independent way to get table primary key?

texts:
Let's assume we have Drupal instance with second database connection. Tables in that second database are shared between many systems and thus was not created using Drupal's schema functionality. How do I get the name of the primary key, in a universal way that doesn't dependent on the RDBMS? Is there a way that will be equally good for all databases?

For MySQL I can use db_query and:

SHOW INDEX FROM {table} WHERE Key_name = "PRIMARY"

and for SQL-92 compatible ones:

SELECT pk.TABLE_NAME, c.COLUMN_NAME primary_key
  FROM information_schema.table_constraints pk
  JOIN information_schema.key_column_usage c
    ON c.table_name = pk.table_name
   AND c.constraint_name = pk.constraint_name
 WHERE constraint_type = 'primary key'

Thanks to T I's answer on stackoverflow.

What happens with Oracle or Apache Derby? I know I can find specific solutions, but I wonder if there is a Drupal way. I couldn't find one outside schema.


texts: How do I use it in a system with 2 PHP-versions?

texts:
On my server there are two versions of PHP: 5.4 and 5.6. Using the shell PHP 5.4 is the standard and it can't be changed because of PLESK/ODIN. The websites I'm administering are using PHP 5.6 via PLESK, so Drupal 8 works fine. Drush doesn't,  because it uses the shell.

I have installed Drush with the following commands:

php drush.phar core-status
mv drush.phar /usr/local/bin/drush
drush init

How can I change this to use PHP 5.6 in /opt/plesk/5.6?


texts:
In D8, In Block Layout, Place Block of webform of webform form,

but when we see output display empty. Inspect element display span tag

data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&args%5B0%5D=webform&args%5B1%5D=full&args%5B2%5D&token=DAFi9sg2c3cBjy5LxuoPFFwM6MALQtu8KIca_a1b5E8"

how to display form?


texts: How to hide and/or prevent access to fields in a form,  such as group_audience for organic groups

texts:
This has been troubleing me for a while.. When i try to hide fields like the group audience field, or the publishing setting from a form, on validation the form set both of these field to a null value, even though the defaut value as been correctly declared.

I tried to use Invisible, #access, unset hidden nothing work! This is very troubleing because for my current project users can edit only small bits of their profile at the time, for instance just the address or the picture, so if i hide group audience the user ends up kicked out of the groups he belongs at every edit.

I ended up using the code below to hide these field while still keeping the user in their group.

$variables['user_edit_about']['group_audience']= $temp['group_audience'];
$variables['user_edit_about']['group_audience']['#prefix'] = '
';
$variables['user_edit_about']['group_audience']['#suffix'] = '
';

Would anyone think of a better way to achieve this ?

Thanks


texts: How to display the summary (teaser) over the body in a full content view

texts:
I want to display a teaser on the top of each article under the title,
as in following “full content” layout:

Title
Teaser (article summary)
Image
Body

Moreover the teaser should have its own formatting (for example italic and a bigger font)

I did not find any way to do that without editing tpl files or core files.

A solution would be to  add a new field "article_teaser" to my content type, then manage display in order to get my layout in “Full content” view. This works, but I do not like to have two teaser-fields in my input content form, because I should type two times the same text.

It seems that I cannot split the field body in its “text” and “summary” parts, but I can only display one or the other, but not both!

Is there any way (a module?) to do that?

(My environment: Drupal 7 with Zen sub theme.)


texts: how to subtract 2 months from current month?

texts:
I have used this :

  $date = date("Y-m", strtotime("-2 months"));

and it is gives "2016-12" but what i needed is "2016-11".


texts: Migrate multiselect taxonomy values from node with csv

texts:
I want to import companies with csv into Drupal 8 with migrate_source_csv module.

CSV:

company_name,company_categories,company_size
"Dummy Name","Category 1";"Category 2","2 people"

How to accomplish?
Do I need an other plugin: explode?

    process:
      field_categories:
        plugin: explode
           source: company_categories
           delimiter: ';'
        plugin: entity_generate
        source: company_categories

I also found this: https://www.drupal.org/node/2129651#handling_multiple


texts: Popup is not loading in Entity Reference View Widget

texts: I am getting this error "An error occurred while attempting to process /?q=system/ajax: params is undefined" while clicking attach button for Entity Reference View Widget. My jQuery version is 1.7.


texts: How can I have a multilingual URL for a views result page depending on the language?

texts:
I have a multilingual website that is currently in 5 languages. We are going to be adding more - a lot more.

Views has a Filter, "Language: Current user's language" to display content based on the language the user has selected to view the content in.

Currently we are not using that filter, and the reason is URL path setting for the Views result page. Instead, because we have to have the URL translated into the language being viewed as well, we have a block configured with an English URL page, for example, and the language filter set to English.

Instead, I need to be able to configure just one view to use the Filter "Language: Current user's language" and, when that page is viewed, I need the url to display correctly in that user's language regardless of the one entry I am allowed in the Views page configuration. I also need for this to show properly in the Menu I select there as well when the page is viewed as a translation.

How can I achieve this?


texts: Create a custom template for a custom URL

texts:
I'm using the Webform module and need to redirect users to a custom URL (with replacement tokens) once they have completed a job application in order to track conversions in Google Analytics.

I've set the URL to /application-completed/[job-ref-number]. This redirect works but I really want a custom template to be rendered rather than the default Webform confirmation message on a 404 page.

I've tried the following in my template.php file but the issue here is that it's a completely blank template (not rendering html.tpl.php), whereas I'd prefer to render the page.tpl.php template and simply replace the $page['content'] area with the custom template (would this be a node template?)

function MYTHEME_preprocess_page(&$vars) {
  if (drupal_match_path(drupal_get_path_alias(), 'application-completedy/*')) {
    $vars['theme_hook_suggestions'][] = 'page__mycustomtemplate';
  }
}


texts:
I have a question on views sorting.

I have two content type(TypeA TypeB) which has the same field.

And i use views to list all the content with the sort i want.

Right now my problem is i want to sort my content with A1 A2 B1 B2 B3 B4 A3 A4 B5 B6 B7 B8...

with ratio 2:4 and in each type with another sorting rule like post date or update date ...

How can i do that?

Could somebody give me a suggestion?

Thx a lot


texts: Using rules to Flag a Product Display Node on Checkout

texts:
Every user is supposed to purchase Particular product only once.
So i have a view to list the Product Display which by using FLAG module i can list only Unflagged  Product Display nodes (Products which are yet to be purchased).
The issue now is how to use Rules to Flag the Product Display node on checkout Completion.
Note: i am using Drupal 7.
Your help will be appreciated.


texts: PHP version changes and Drupal versions issues

texts:
i have installed drupal 7.1 on PHP Version 5.2.17 .....now the server people is going to upgrade the php/mysql to a higher version like 5.3.3 ..is there any problem to the current drupal 7.1 websites running ?

Please advice me.


texts:
Is it even possible to do this?

The goal is to group our visitors:

Group A sees Theme A
Group B sees Theme B

I am able to achieve this goal through cookies. But when caching is enabled (i.e. Site config > Performance > On), things are messed up. This is what happens:

1) Group A visits Page-1
-- Page-1 is not cached yet.
-- Cookies are properly checked.
-- Page-1 is displayed using Theme A

2) Group B visits Page-2
-- Page-2 is not yet cached.
-- Cookies are properly checked.
-- Page-2 is displayed using Theme B

3) Group A visits Page-2
-- Page-2 is already cached.
-- Cookies are ignored
-- Page-2 is displayed using Theme B (when it should be displayed using Theme A)

So now what I am thinking is, instead of using cookies, I'll use separate cache for each group.

Is this even possible? :S If not, any recommendations are welcome.

Inputs will be highly appreciated. Thanks!


texts: D6 + Services 3 + Appcelerator = Login help!

texts:
I am in the process of (slowly) converting a community forum site from vb4 to drupal. Before I can make the full switch I need to put together a mobile app similar to tapatalk as a large number of my users post almost strictly from their phones.

I had done a little work previously with Services 2 but only on one project that didn't end up coming to fruition.

I am using D6 and Services 3 on this project and I am having trouble figuring out how to login.

I have set my endpoint to 'api/user' for all user resources. That means my login url would be 'api/user/user/login', correct? Using Poster on Chrome I get a "406 Not Acceptable: Unsupported request content type application/xml" when I try to pass along POST data.

Are there any tutorials or docs out there that I am missing? Any clues on what I might be doing wrong? I am finding it extremely difficult to find much out there for Services 3.


texts: How to resolve notice : Undefined offset: 3 in user_node_load()

texts:
I have moved my entire site and got this when I want to add content:

Notice: Undefined offset: 3 in user_node_load() (line 3604 of /storage/content/39/170239/<mysite>.se/public_html/modules/user/user.module).

Can it have to do with the fact that I have different users now on my site and that some nodes is connected to users that may not exists?
If that is the case, can I resolve this by editing my DB?


texts: How should I read values from multi-field's subfield?

texts:
I'd like to access values stored in a Multifield programmatically. I use a Computed Field to do some calculations based on these values.

My current solution utilizes field_get_items(... ,'my_multifield') which returns a data structure containing an array of (sub)fields. Of course, I could extract values from that data, but I wonder if there is a better solution.

I took a look at the multifield source code, especially the tests, but I could not figure it out. What is the intended method for reading values from multi-fields?


texts: Create module with custom entity and CRUD

texts:
Using the Drupal CLI I've generated a D8 module. Now I want to generate a content type with additional fields, for which I can define my own CRUD, forms and other logic. I used drupal generate:entity:bundle
which generates the new content type and makes it possible to add new fields through the admin interface.

I don't want to add fields through the UI; I want to add fields through code, so I can add new logic in the (CRUD) controller. This will be adding fields, defining new views, adding validation etc. I tried to use drupal generate:entity:content, but it doesn't seem to get me anywhere.

How could I do this?


texts: I have 3 different environments such as Dev, Test and Stage. I'm currently facing an issue when trying to propagate my changes from Dev into Test and Stage envs. In order to propagate the changes i use the Features module. Within features i export all my Content Types. Some of them (e.g. Basic Page) are already exist into Test and Stage environments. When i'm trying to install the feature export from Dev into the other environments, the Basic Page content type of Test and Stage actually seems to be overridden. This means that the predefined fields that already has are not erased by the feature but it just adds the new created fields. How can i solve this issue. The desired functionality is to have the same fields after importing the future to all environments.


texts: How to order by a column with NULL values in it due to leftJoin?

texts:
If you have two fields on a content type, such as "publications" and "featured publications" and you want to display a single list merging the two fields with the featured content on top.

I'm using two left joins from the base entity table, which leaves the delta non-featured items as NULL in the results set.

The problem I ran into is that orderBy on a delta column doesn't work with NULL values as NULL values will appear before any value with an integer in it.

So given a query like this:

$query = $this->database->select('publication_field_data', 'pfd')
      ->fields('pfd', ['id']);

    $query->leftJoin('node__field_publications', 'fp', 'fp.field_publications_target_id = pfd.id');
    $query->leftJoin('node__field_featured_publications', 'ffp', 'ffp.field_featured_publications_target_id = pfd.id');

    $query->orConditionGroup()
      ->condition('ffp.entity_id', $current_nid)
      ->condition('fp.entity_id ', $current_nid);
    // Sorting by deltas on the featured field, then the non-feature field
    // and then the non-featured field will fail, as the NULL values
    // on the featured field will appear first.
    $query->orderBy('ffp.delta');
    $query->orderBy('fp.delta');

You won't get the proper order.

So the question is, how can we fix the query so that it will order properly, first showing the featured items, then the non-featured items (and not showing duplicates).

As I'm using paging, you can just use two queries.


texts: How to import user address profiles into Drupal Commerce?

texts:
I have users with their profiles in a CSV file, state, street, phone... etc.

I tried using feeds to import this into Commerce, but it does not work. The profiles are not attached to users. I did a 2 step process with 2 feeds importers, but it isn't working, any ideas?


texts:
I am very new in Drupal and still building site.

So, I want to test creating new user by clicking on below.

Entering new username and e-mail address.

Redirect to site's home and got this successful message.

I login as admin and activate the user.

I got the confirmation email and click the link sent there to reset user password.

Then tapping on login button, redirect me to this:

Why does this message appears?

  You have tried to use a one-time login link that has either been used
  or is no longer valid. Please request a new one using the form below.

It seems that the system can't remember that the reset link must be still in function. Is there any fix for this that I don't need to connect to Drupal's server remotely?


texts: Hi I would like to offer a toggle show/hide for some fields that are not mandatory. Is there is a modules for this or would it be a case of using a template and jquery.


texts:
Does any one have experience of implementing uc_recurring module along with paypal as I have configured it as per the documentation specified from module's documentation but its still not working.

Any insights on it would be helpful.

Tks,
Vil


texts: When posting OG content, how to choose only from Content Author's Groups?

texts: When a user is editing/creating a node, there is a field where the user can choose what groups to post the content to. I want this field to list only groups the user is actually a member of. Is there a setting for this? If there isn't, what is the best way to code this?


texts: How to automatically update entity that is created programatically?

texts:
Using Entity API, I can create entities easily like this:

// SomeEntity class extends ContentEntityBase
$entity = SomeEntity::create(['my_id' => 'id123']);
$entity->save();

Works fine as long as my_id is unique. When it's not, I get EntityStorageException with message complaining about my_id not being unique. I could first try to load entity to see if it exists and update it manually but that seems like unnecessary overhead.

Is there a way to automatically save or update existing entity programatically?


texts: How create Redirect pattern from old to new URLs?

texts:
D7: I'm going to update an articles path pattern (/articles/[node:uid] → /post/[new tokens]) but I need redirect users from old path to new one using tokens. And I don't know how to do that.
I tried using the Redirect module, but it allows set only separate URL for each node; no group redirect patterns are allowed. Also the Rules module doesn't allow to set patterns. How can I achieve this?

The problem partially solves by applying "Update url alias" option in admin/content. I do not find out how to show all selected type nodes at one page without pages, because it is terrible slow applying option page by page.
Anyway, by this way, old aliases still exist, work, and don't redirect to new aliases.


texts: YouTube media filed without remove media button

texts:
I'm using Drupal 7. The Remove media button on youTube media entry (field) is missing. This is for a field with name: Videos, field type: Multimedia asset (deprecated), widget: Media file selector.

I can add unlimited multimedia entries and the remove button only missing for youtube videos (in case of an image I have the remove button), as shown on the next image:

I'm using the media 7.x-1.4 and Media: YouTube 7.x-2.0-rc4 modules.

Can anyone help me how to fix this? Is this a bug or my mistake?

Here is a link to my issue/bug report: https://www.drupal.org/node/2459947

As I was creating new roles and tested on different browsers, I saw that the removal button is missing when I'm administrator of the site and I'm using chrome browser. With Mozilla as admin I can see the removal button.

With other roles (like content Editor) the button is visible in both browsers.

This post was suggested to be a duplicate and the solution can be found here: https://www.drupal.org/node/2137863


texts: xmlrpc() error: (-1001) unable to parse URL during Drush command

texts:
I have an odd error coming from Drush when I perform module updates and other commands (it's most consistently comes from module updates). Near the end of the command execution this message pops up:

  xmlrpc() error: (-1001) unable to parse URL

Some cursory Googling produces that its likely an error popping up in drupal_http_request. I'm not sure where however since I'm not too familiar with the Drush code base.

I ran drush with the --debug switch for more information but that didn't tell me much other than this message typically pops up after the drush_cache_command_clear() being executed.

What is causing this error?


texts:
I am asking this question because I have an autocomplete text field with #autocomplete_path set to a valid working path but key events are not handled by the misc/autocomplete.js file. When the form is being created, it apparently assigns all the functions to the respective variables, but none of those functions are executed. For example following function in the misc/autocomplete.js isn't executed.

Drupal.jsAC = function ($input, db) {
  var ac = this;
  this.input = $input[0];
  this.ariaLive = $('#' + this.input.id + '-autocomplete-aria-live');
  this.db = db;

  $input
    .keydown(function (event) { return ac.onkeydown(this, event); })
    .keyup(function (event) { ac.onkeyup(this, event); })
    .blur(function () { ac.hidePopup(); ac.db.cancel(); });

};

Hence, when a user types a letter, key up or key down handlers aren't invoked and nothing happens. So to debug, I want to know how autocomplete works.

Could someone please explain how this works?


texts: How to set a mini panel to display node fields?

texts:
I want to load node fields into a mini panel, but when I do what I think that I need to do, the mini panel (= MP) is invisible (because the fields aren't displayed, I guess).

So far I have:

Added a Content Type
Added fields to that Content Type
Created a Minipanel with Required Context = Node
Added my various Node Fields to that MP: Add Content > Node > Field: ___
Moved the MP into my Content range in the Blocks Editor

I don't see my MP anywhere. This user seems to have a similar issue, and solved it with the Context settings but doesn't answer the question at all, just closed it.  Other people seem to have this issue as well:

Can't get a mini panel containing node form fields into a panel page
Node fields and node tokens not showing up in a mini-panel

Can anyone clarify for me how to make my MPs show up with information populated from the node?


texts: Is it possible to set a field permission Per Option?

texts:
On Drupal 7. Let say I have a "field A" on a "Content Type A". with the following option and and permission. Is there a way to set a field permission based on an option?

Field A (Term reference: select list)

Option 1 Term A (all authenticated users are able to see and select this option)
Option 2 Term B (Only Editor and Administrator users can see and select this option)
Option 3 Term C (Only Administrator can see and select this option)


texts: add first/last classes when using theme_menu_link

texts:
Im building my own menu tree for various reason, but one think i miss is the first / last classes. I dont find anything about it in the API and i do have drupal_attributes($element['#localized_options']['attributes']) set.

Where and how would the first/last classes be called?

my function in template.php goes something like this (taken direct from the API)

function theme_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}


texts: Block Settings not applying to Zen sub theme

texts:
I've created a Zen sub theme using the Starter Kit enabled it, and set it as the default (I've changed very little from the Starter Kit). If I go to Structure > Blocks there is only a tab for the Zen theme (which is enabled, but not set to default). I can set blocks into different regions and save, but the changes are not reflected on the page. If I switch to the base Zen theme, the changes are there, but switching back to my sub theme shows just the default layout.

I'm new to Drupal, so should the sub theme be inheriting the base Zen theme's settings, or should there be a separate tab for the sub theme? And what do I need to do get the tab to show up? I've gone through numerous examples and tutorials without finding an answer.

Thanks.


texts: How to delete all data when uninstalling a module without going in manually in PHPmy Admin?

texts:
Whenever I have a troublesome module, I have to uninstall it, then delete the folder, then go play around PhpMyAdmin to delete junk it left in my database.

This is prone to causing errors and breaking stuff...

Is there a way to uninstall modules cleanly, to delete ALL data?

I have no access to Drush on the server also...


texts: How to insert one form in front of another (i.e. add a confirmation BEFORE a node add form)

texts: I am not exactly sure how to go about this with a form_alter hook.  What I want to do is insert a form prior to displaying the node add form.  This way, I can display a confirmation message prior to the node creation form.  I understand I can create a control key in the $form_state variable to keep track of where we are in a multi-step form, but how can I augment a non-multi-step default form (such as the node add form) to add in stages in front of it?  Would I have to override all the node add submit and validate callbacks as well?  Seems like a lot of effort to add a simple confirmation.


texts:
I am having issues with drupal and ckeditor. I would like to saev following code:

However due to ckeditor's filters almost everything gets stripped. I tried various advices - turning off advanced content filter or adding config.allowedContent = true; inside custom javascript configuration window. Nothing what I tried works.
Thank you for any advices.


texts:
I'm currently doing recruitment system by using drupal 7..

In my system have 3 role..
1) applicant
2) hr admin
3) interviewer

Applicant can apply the job and HR admin will shortlisted the applicant. The interviewer can evaluate the shortlisted candidate during the interview session..

My question is there any module that can show the availability of the interview session..the idea is same like confrence session where we can register for the confrence and we can set the limit of audience.. Because i want the candidate can choose the interview session..

I've tried the signup module but i seem not working for drupal 7.

Thank you very much.


texts: Adding Taxonomy terms programmatically with specific tid?

texts:
I would like to add a term to a vocabulary specifing the tid, already tried with Taxonomy CSV import/export and Taxonomy import/export via XML modules but both create terms with a new tid.

I even tried programmatically with taxonomy_term_save() but if i set the tid it just looks for a term with that ID.

I need to do this because then i'll import a lot of nodes, and all of them already have a relation with a term.

Any other way to do this?


texts: Why won't JS fire on ubercart checkout page and how do I fix?

texts:
I need some custom JS (jQuery to be precise) to run on ubercart's  /cart/checkout page. I turned off JS optimization and tried adding it to several different files that are already loading and the JS never fires. It is in the page as if I view-source I can search and find it. I did put $(document).ready(... so it should be waiting for the page to load before running. If I run the same JS from the console of firefox or chrome it does exactly what it's supposed to do. The JS files are all loaded with drupal_add_js().

My only solution at this point is the make a block that only contains that JS and only shows on that page, which it not an optimum solution, but will probably work. Anything else I'm missing on this though?


texts: Create a new user in LDAP, not wherever Drupal normally creates it

texts:
We have an already existing LDAP of users, that we wish to use for our new site. Amazingly, the login seems to be only finding the users we want it to, and not the users we don't. We have to figure out why, because we'll probably want to change this in the future. (I mention, in case it's related to my main issue.)

However, the more important problem is that, when we create a new user, we want it to be created in the LDAP, not wherever Drupal creates it. As I understand, when it authenticates against LDAP, it simply copies the user to it's own database, and uses that from then on, which is also not what we want, in case the user changes their data. However, we'd still like the admin user to work, even if the LDAP dies or something. The documentation isn't much help with this.

So, how do I make Drupal (I'm using 7, but I don't know if it's 7 specific) use the LDAP for the creation of new users, and for existing LDAP users? (Hopefully, without totally removing the ability to use the users already in the Drupal db.)


texts:
I see written everywhere that Path breadcrumbs https://www.drupal.org/project/path_breadcrumbs can be exported via features. But I am unable to see any Path breadcrumb option when I'm creating a feature, nor I see any export thing in Path breadcrumbs settings.

Do you know where/how?


texts: how to set default_value for list_boolean field equal to 1, not 0?

texts:
I'm using this code to add a list_boolean field to my user entities on D7.20.  The field is added, but the default value shows up as unchecked, whereas I've tried to be careful with

  'default_value' => array(0 => array('value' => 1)),

to make it show up checked.

Can someone explain what I'm doing wrong here?

Update: Actually this seems fine, see explanation in answer.

function MYMODULE_create_user_field_binary($myField_name, $label, $desc) {
  $field = array(
   'field_name' => $myField_name,
   'module' => 'list',
  'type' => 'list_boolean',
     'settings' => array(
     'allowed_values' => array(
       0 => '0',
       1 => '1',
      ),
     'allowed_values_function' => ''
     ),
     );
  field_create_field($field);

  $field_instance = array(
      'field_name' => $myField_name,
      'entity_type' => 'user',
      'bundle' => 'user',
      'label' => t($label),
      'description' => t($desc),
      'default_value' => array(0 => array('value' => 1)),
      'widget' => array(
        'active' => 1,
        'module' => 'options',
        'settings' => array(
                'display_label' => 1,
                ),
        'type' => 'options_onoff',
       ),
      'settings' => array(
      'user_register_form' => 1,
    )
    );
  field_create_instance($field_instance);
}


texts: Views with contextual filter ignores sort order and number of nodes per page

texts:
On my site I want to define tutorials. One tutorial consists of several nodes of the same Tutorial content type. The content type has a field taxonomy term reference and a weight, to determine the sort order.

My idea was to have a single view, selecting on Tutorial content type, ordering by weight, one node per page. So far this works. But to only show nodes for one specific tutorial I defined a contextual filter, on the tutorial field. Now only nodes for that specific tutorial are shown, as expected, but this also has the effect that:

The nodes are no longer sorted by weight.
I no longer have one node per page

I've been looking for workarounds, different settings, etc., so far to no available , so help would be greatly appreciated.

If this is a behavior of views that can't be helped, any other approaches to my use case would also be met with immediate gratitude.

Using: Drupal 7.39, Views 7.x-3.11


texts: Pass argument to view block within a minipanel

texts:
I am having a panel page, within the panel page there will be multiple minipanels in each row.
The mini-panels have 2 views both which displays content based on the argument passed.

Basically the all the minipanels are same. The views within are also same. Only the argument passed change. But I am not getting how to pass argument.

See the below picture for detail.

In the end we'll have something like this. A repeated series of same panels and views with different contents.

I am not able to find out whats wrong.


texts: How to map (yml) D7 nodes with terms, images, comments and references for migrating to D8?

texts:
To better understand how a custom content migration really works apart from all the tutorials showing how to install Drupal and press the migrate button with a 3 lines test import file or endless youtube talks loosing the focus, and to demonstrate how a very common migration hangs on the missing understanding of the migration set up first ... Can somebody please explain more structured and understandable, how a yaml file has to look like correctly (its underlying logic), to - let's say - map for migrating Drupal 7 nodes of content type "my_stories" with about 8 additional text and integer and term fields, including taxonomy terms references, images (unlimited count of images per node via file field), references to other nodes of other content type, the author, changed, created, and all the comments on the nodes? The fields have other names in D8 and the D8 installation has already all the users, fields and taxonomy groups build/set up. The different names for the fields make a custom mapping mandatory. I choose this example becasue it forces the yml file to be half self-explanatory since most explanations around are copy/paste's of other explanations and are often kind of broken, the code comments do not fit the code examples, etc.

My understanding of Drupal migrate is sadly still very basic (it's not only me, the adaption rate is low) because the yaml files and the most of the explanations in the web are confusing and not clearing things. They commonly are targeted to website-admins using standart migate settings or source import (like CSV) and are written like: do this and that without explaining the things behind. But I'm a web developer and need to understand what it does. What are the definitive requirements? Even this is often missing. Many tutorials are outdated or unclear about the simplest basic facts, maybe assuming everybody knows them.

One question which often keeps unclear in the tuts: Do I need a custom module for my custom migration mapping or not? Some tuts suddently involve a custom module without explaining why, some not. Can I migrate directly from the D7 database in this case (without changing the D8 project any further, apart from the content structure)? How to make sure that migrate will only "import" nodes, comment, etc without breaking things in D8 silently in the database, changing configs, etc.?

This (one of the better) example of mikeryan776 shows an almost complete project import of mostly everything regarding content, but its all splitted in multiple yaml files. I this required in this case? Or can I put it all in one yml file to my personal preference? This type of questions arise if the user does not understand the way it works behind the scenes or do not find the right entry point.

Is there a book or a real good webpage explaining the mapping and showing some more detailed diagrams (apart from the 3 steps diagram of "in - massage - out" kind of stupid thing) to make it clear how it works under the hood and where to start?


texts: How to include a CCK on a page using Panels

texts:
I am trying to add display a CCK on page using panels

Initially , i created a Contact Us form CCk. Now i want the contact form to be displayed on a page, so that anonymous users can input their information from that page.

UPDATE
yes i am able to show the contact form on the page, but it only displays when admin is logged in. But it must be visible to all anonymous users as well

Please help


texts: Spam users on drupal7 site being created automatically

texts:
I need some urgent suggestion. In my live site a lot of spam users are being created every few minutes. I will install captcha and MOLLOM but I need to delete the spam users. How can I identify them and how do I prevent this from happening again?

Please advice


texts: Avoid adding breadcrumb if title is empty

texts:
I created a view without the title but then the breadcrumb shows  as

Home>  >

If I add title to the view then it is showing as

Home> >Title

is there any way to avoid adding breadcrumb when empty title is present ?


texts: Grouping Exposed Filters (using Better Exposed Filters)

texts:
We have a view using Better Exposed Filters called Programs with an exposed filter on a taxonomy term "Level of Study". I'd like to group this so that the only values in the exposed filters are Graduate and Undergraduate.

I first tried to "group" the terms as follows

but then got errors as follows:

Warning: Illegal offset type in views_many_to_one_helper->ensure_my_table() (line 954 of /var/www/html/sites/all/modules/views/includes/handlers.inc).

I then tried to rearrange the taxonomy so that Graduate and Undergradute terms are parent to the others as follows:

Graduate
- MFA Degrees
- Professional Degrees
- Doctoral Degrees

Undergraduate
- Majors and Minors
- Modules
- Interdisciplinary Programs

And this still does not yield the desired result.

So I'm at a loss and opening up a bounty.


texts: How to customize pagination for the taxonomy term view page for different vocabulary?

texts:
I have 3 vocabularies as shown in this screenshot:

And I have default Taxonomy term view page with 10 items per page as shown in this screenshot:

I want to display 12 items per page only for the taxonomy term pages which are related to the terms of Categories vocabulary. Should I create new Taxonomy term view page for Categories vocabulary or is it possible to configure pagination using HOOK_preprocess_taxonomy_term ?


texts: Where and when in the User login workflow is the last Access time timestamp set?

texts:
I am trying to understand when exactly the last access time is set in the Drupal user login workflow.  I did notice that the following method is probably what is used to set the timestamp

  public function setLastLoginTime($timestamp) {
    $this->get('login')->value = $timestamp;
    return $this;
  }

However, I could only find the declaration but not the method call in the codebase and it has proven difficult to track it. It seems quite surprising it is not called anywhere. I am thinking that there should be a direct write to the field 'access'.

P.S The reason I am trying to get the value is to determine what all nodes are created after the user had last accessed the site.


texts: What is the purpose of the "token" custom display setting?

texts:
On the manage display page of a given content type, you can choose between various display settings. The most commons are "teaser" and "default" or "full content".

However, there's also a "token" display mode (disabled by default). I assume it's added by the token contrib module, but I have no idea what its purpose is and how we're supposed to take advantage of it?

Also: is it typically used somewhere that I'm not aware of? Can it be safely deleted if it's not activated?


texts: Why does Behat throw an error on "ucan "?

texts:
In our Behat tests we delete all test users in a before-hook. But sometimes our Behat test throws an error like:

  Could not find a user account with the name vN8eLbrd!

  Could not find a user account with the name some.wiredstuff-registration-test_10706!

Strange thing is that I get this user name direct from database. So I do not understand why this drush ucan command can not find it.

/** @beforeScenario */
  public function before($event) {
    $this->getSession()->getDriver()->resizeWindow(1280, 1024);

    // List all Scenarios which create the testuser.
    $scenarios = array(
      'Register for testing with Credit-Card',
      'Register for testing with Paypal',
      'Register for testing with valid Direct-Debit',
      'Register for testing with invalid Direct-Debit',
      'Access my subscriptions page',
      'Register for testing',
      'Register and use link from registration mail',
      'Logout',
      'Log in with username and password',
      'Recover your password'
    );

    $users_to_clean = array(
      'test@muster.de',
      'shaka@test.de',
      'some.wiredstuff+behat-registration-test@gmail.com'
    );

    $title = $event->getScenario()->getTitle();

    // Delete Testuser before the Scenario.
    if (in_array($title, $scenarios)) {
      foreach ($users_to_clean as $mail) {
        $user = user_load_by_mail($mail);
        if ($user) {
          shell_exec('drush ucan ' . $user->name . ' -y');
        }
      }
    }
  }

Problem with not deleted users is that other tests fail because a test user already exists.

Do you have a clue why this happens?


texts:
Functionally, what I want to achieve is to duplicate a node (with a different node-type) when creating/inserting.

To be more precise: I have two content types: news and press-release. What I want to achieve is that when a press-release is made in admin, a news item is automatically created as well.

I looked into D8 hooks (hook_ENTITY_TYPE_insert to be specific), but can't get it to work, the documentation is confusing to me. This is what my .theme file looks like:

<?php
/**
 * @file
 * Bootstrap sub-theme.
 *
 * Place your custom PHP code in this file.
 */

/*
 * Implements hook_ENTITY_TYPE_insert().
 */
function hook_persbericht_insert(Drupal\Core\Entity\EntityInterface $entity)
{
    if (isset($entity->field_duplicate_to_news) && $entity->field_duplicate_to_news[0] === 'on')
    {
        // create a new news-article here
    }
}

Any help and suggestions are welcome


texts: Unable to save content language configuration

texts:
My Drupal 8 website is multilingual and has many entity type bundles for nodes, taxonomy terms, paragraphs, media et cetera. This leads to a content language settings form (admin/config/regional/content-language) with more than thousand translatable-checkboxes.

Currently I'm not able to save this form. In the first place the form seemed to be successful submitted but changes have not been saved. This was caused by insufficient php setting value for max_input_vars, which could be solved by setting it to 6000. Now I'm struggling with a timeout. After submitting the form the request fails after some minutes.

Here are the php settings of my Drupal VM:

php_version: "5.6"
php_memory_limit: "1024M"
php_realpath_cache_size: "1024K"
php_opcache_enabled_in_ini: true
php_opcache_memory_consumption: "192"
php_opcache_max_accelerated_files: 4096
php_max_input_vars: "6000"
php_max_execution_time: "720"
php_post_max_size: '64M'

How can I get around this issue? Which resource bottleneck could cause this?


texts: Change checkboxes in a node edit form alter

texts:
I have a problem with an ajax function which doesn't work properly and I don't understand why. I done a similar thing long time ago in Drupal 7 and it seems I forget how it works.

I have a node type with terms references, a type and options. In the node edit, the selection for the type is a select list and for options it's a list of checkboxes. In function of this type, I want only show related options to my user.

Here my code:

function my_module_form_my_content_type_node_form_alter(&$form, &$form_state) {
  $form['field_options']['#prefix'] = '
';
  $form['field_options']['#suffix'] = '
';
  $form['field_types']['#ajax'] = [
    'callback' => 'ajax_options_choice',
    'wrapper' => 'options-choice',
    'method' => 'replace',
    'effect' => 'fade',
  ];
  if(isset($form_state['values']['field_types']) || isset($form['field_types'][LANGUAGE_NONE]['#default_value'][0])) {
    $type_tid = isset($form_state['values']['field_types'])? $form_state['values']['field_types']: $form['field_types'][LANGUAGE_NONE]['#default_value'][0];
    $type = taxonomy_term_load($type_tid);
    $type_option = $type->field_type_option[LANGUAGE_NONE][0]['value'];
    $bundle = "my_content_type";
    $results = db_query("SELECT nid, title FROM {node} as n inner join {field_data_field_is_$type_option} as fdf on n.nid = fdf.entity_id  WHERE n.type = :bundle AND n.status = '1' AND fdf.field_is_". $type_option . "_value = '1'", array(":bundle" => $bundle))->fetchAllKeyed(0, 1);
    $options = [];
    foreach ($results as $nid => $title) {
      $path_alias =  drupal_get_path_alias("node/$nid", "en");
      $value = ' ' . $title . ' ';
      $options[$nid] = $value;
    }
    $form['field_options'][LANGUAGE_NONE]['#options'] = $options;
  } else {
    $form['field_options'][LANGUAGE_NONE]['#options'] = [];
  }
}

function ajax_options_choice(&$form, &$form_state) {
  return $form['field_options'];
}

`

When I edit a content which have already a type, options are correctly limited. But when I change the value of the select list, the ajax doesn't seem work and options stay the same. I have no error in the firefox or chrome console so I suppose the ajax is simply not execute.

Additionnal questions:
Which ways can I test the ajax works or not? Is that possible to use dpm() in the callback?


texts: Database updates after pulling in code updates for modules

texts:
I've updated a bunch of modules in my local development environment and then committed the code changes using git.

On my test site, I've pulled the code and ran drush updb but it's showing that nothing needs to be updated and that the modules I updated are now current. In the past, every time I've performed updates, I was under the assumption that there was a database updating component to it and whenever I ran drush updb it would take the code that was just implemented with git and run the update. Not sure, why it's different this time, can someone explain? Am I missing a command? If there are no database updates needed, I can go on knowing the updates are truly complete?

If database updates aren't require for all module updates, can someone give an example of when updates do and do not touch the database?

Edit:
An example of one such update was to the address fields token or to the Google Static Maps module.


texts: How to manage exported block configuration that site users can override?

texts:
Using core config management, we export configuration from developer's site instances and put than under version control. Eventually, this configuration is merged and ends up in production, where we import it thru either Drush or the UI.
Trouble is, site owners have permissions to update block configuration, and this overrides our exported configuration.

What is the intended workflow in this case?

Put more generically: how to manage exported configuration that can be overriden by users (with a core CM workflow)?


texts: How do you move field content into another twig template?

texts:
This is specifically for Drupal 8. I know how to do this in D7.

I'm developing a custom theme. I know how to create and change individual Twig field templates, but I'm not able to find much info on consolidating field data from individual twig templates into one template.

Specifically, I'm trying to move the field_tag data from field--node--field-tags.html.twig into the same area as he breadcrumbs.

I have two Twig templates; one for tags and one for breadcrumbs. The tags need to appear on the same line and in the same block area as the breadcrumbs.

Any ideas on how to do this? I can't get the Tags data to render. I thought it would be as easy as using {{ content.field_tags }} to make it render, but that doesn't do anything.


texts:
I'm converting a site to D7 that does not currently have an RSS feed. I'm trying to find a way to create something that will help me avoid having to manually move over each and every page, but I'm coming up empty.

I thought of wanted to try to generate a feed, with the goal being to use the Feeds module to import the feed as pages, but I've not found anything to do that sufficiently.

Right now all the pages are stand-alone pages meaning that none of them are stored in a database, but it's all written up in PHP & HTML and it's a bit of a mess. So I'm having to work with the raw pages. That's why I thought creating a feed would be the way to go.

If I could get the existing pages in to a CSV or XML file I could work with them a little easier, but there are numerous pages and it would take forever to do that.

Thanks in advance for any help/advice you can offer!


texts:
I'm trying to show user info in node where this user name is set in User reference field.

I have content type where is User reference field (field_customer).

I have Views:

Show: Users
Contextual filter: (field_customer) Content: Customer
Relationship: User: Customer (field_customer) - reverse

In Contextual Filter I have: When the filter value is NOT available = Provide default value User ID from URL
In Relationship I have: Require this relationship

And I have fields like User: Email, User: Name etc.

I created node and set one user to User reference field.

Views does not work as it should. It shows all users. I tryed to play with Views settings but just could not find proper settings.

What I am doing wrong here?

EDIT

I also created another Views.

Show: Content
Contextual Filter: Content: Customer
Relationships: Content: Customer

In Contextual Filter I have: When the filter value is NOT available Hide view
In Relationships I have: Require this relationship

And it shows nothing on node page. Also tryed with different settings but no luck.


texts: how to show message in popup when user register to site?

texts: I just want to show message in popup when user register to site."Further instructions have been sent to your e-mail address". This message i want to show in pop-up.


texts:
While creating a new view and after added the specific content to it.It's not showing the content which I've created instead it's showing

"no front page content has been created "


texts: Gravatar does not work with anonymous accounts

texts:
I enabled the avatars_gravatar submodule from Avatar Kit and configured it to be the only available Avatar Generator in admin/config/people/avatars. The Gravatar is rendered for logged in users, but not for anonymous users that leave a comment.

Is this a configuration issue or do I need to alter a template? I'm using the standard Bartik theme.


texts: Access denied when I try to delete the user menu

texts: How can I delete a user menu in Drupal 7? It throws me an access denied error, though I am logged in as user #1. What's wrong with it?


texts: how to use image styling on a image url field

texts: I understand that on an image field, you can create a image style. However, I have a field which is a url and I use that url in a template to produce a picture. Is there any way for me to use the image style ui to style this?


texts: How do I make a link to switch the language, without using any modules? When users click on a language I want to switch language and redirect them to the same page not to front page.


texts: Pathauto menu token duplicated for a menu added in hook_node_insert

texts:
I have a content type using the following pathauto-token pattern: [node:menupath]/[node:title], I added manually a menu using a hook_node_insert (see my previous question: creating a menu in a hook_node_insert()).
When the node is saved it doesn't have the [node:menupath] token in the URL, just the [node:title]. I decided to generate the path using pathauto API and this code:
$options = array(
  'language' => isset($node->language) ? $node->language : LANGUAGE_NONE,
);
module_load_include('inc', 'pathauto');
$uri = entity_uri('node', $node);
$path = pathauto_create_alias('node', 'insert', $uri['path'],
  array('node' => $node), $node->type, $options['language']);

Doing this lead to duplicates in the url_alias table, the [node:menupath]/[node:title] alias being created first then the title.
I tried to add a $node->pathauto_perform_alias = FALSE; in a presave, but seems to be inefective.
Also I tried to set my new path in the hook_node_insert but had no success:
$path = pathauto_create_alias('node', 'insert', //...
$node->path = $path;

My code doesn't feel right, what would be the normal way to avoid duplicate and getting my pattern to work ?
Thanks


texts: How to force users to logout after X minutes of inactivity using Rules, Views?

texts:
How to force users to logout after X minutes of inactivity using Rules, Views or any other popular module ?

update 2012-01-27

Where can I find an example how to do the forced session expire using Rules module ?


texts: How to edit Advanced Search Form's Content Type checkbox-list using hook_form_alter

texts:
I have a Drupal 7 setup. I want to remove few Content types from the Content Type checklist that appears in Advanced Search form. I could see that advanced search form comes in 'advanced' field-set of 'search_form'.

I tried to implement the solution given here, but I am not able to find the advanced array in $form.

I would also like to add styling changes and prefix elements to default text-fields that comes within Advanced Search form

Please find the below code that displays content of $form ($form_id = search_form), as I can't find advanced array within it.

    Array
(
    [#action] => /demodrupal7/search/node
    [#attributes] => Array
        (
            [class] => Array
                (
                    [0] => search-form
                )

        )

    [module] => Array
        (
            [#type] => value
            [#value] => node
        )

    [basic] => Array
        (
            [#type] => container
            [#attributes] => Array
                (
                    [class] => Array
                        (
                            [0] => container-inline
                        )

                )

            [keys] => Array
                (
                    [#type] => textfield
                    [#title] => Enter your keywords
                    [#default_value] =>
                    [#size] => 40
                    [#maxlength] => 255
                )

            [processed_keys] => Array
                (
                    [#type] => value
                    [#value] =>
                )

            [submit] => Array
                (
                    [#type] => submit
                    [#value] => Search
                )

        )

    [#form_id] => search_form
    [#type] => form
    [#build_id] => form-wAV_M_UAj5lbJgb-6vcdpmtxls5NpioPam6uNtkzRnw
    [form_build_id] => Array
        (
            [#type] => hidden
            [#value] => form-wAV_M_UAj5lbJgb-6vcdpmtxls5NpioPam6uNtkzRnw
            [#id] => form-wAV_M_UAj5lbJgb-6vcdpmtxls5NpioPam6uNtkzRnw
            [#name] => form_build_id
            [#parents] => Array
                (
                    [0] => form_build_id
                )

        )

    [#token] => search_form
    [form_token] => Array
        (
            [#id] => edit-search-form-form-token
            [#type] => token
            [#default_value] => 374_q2sHn_uhIvUhwOdrriFMIM3UgfVoc7Jzsh_DHrE
            [#parents] => Array
                (
                    [0] => form_token
                )

        )

    [form_id] => Array
        (
            [#type] => hidden
            [#value] => search_form
            [#id] => edit-search-form
            [#parents] => Array
                (
                    [0] => form_id
                )

        )

    [#id] => search-form
    [#method] => post
    [#theme_wrappers] => Array
        (
            [0] => form
        )

    [#icon] =>
    [#icon_position] => before
    [#process] => Array
        (
            [0] => bootstrap_form_process
        )

    [#pre_render] => Array
        (
            [0] => bootstrap_pre_render
        )

    [#tree] =>
    [#parents] => Array
        (
        )

    [#validate] => Array
        (
            [0] => search_form_validate
        )

    [#submit] => Array
        (
            [0] => search_form_submit
        )

    [#theme] => Array
        (
            [0] => search_form
        )

)

Can anyone help me with this.
Thanks in advance.


texts:
Can I enter a non breaking hyphen in drupal?
If not, how can I avoid words with hyphens to be split up when I do not want that?


texts: When shouldn't you use t(), st(), etc. with readable string literals?

texts: Drupal coding standards dictate that nearly all string literals should be passed through t() or st() for translation;  however there are some exceptions, such as titles in hook_menu().  When isn't t() or st() necessary? I've posted a community wiki answer hoping people will edit it.


texts: I have a rating website and on every node i have two separate flags, one is Like, and another one is disklike, so that i can get a count of how many people likes that particular div and how many of them dislikes them. What i want to achieve is, that say if someone likes a node, the dislike should be disable or even invisible  , and vice versa. I am using a view to show the nodes a the moment, so will i have to uses pre process of views to do it or what is the way going about it?


texts: How can I programmatically get an entity's validation errors?

texts: I'm submitting an entity programmatically through a custom, non-entity form. How can I validate the entity before submission, and report the validation errors to the user if they exist?


texts: Preprocess taxonomy for a custom template file

texts:
In Drupal 6, I am customizing a view where I am trying to make the taxonomy terms work in all the page template files.

This is the code in the template.php file.

function getTermsName($taxonomy_id) {
  $terms = taxonomy_get_term($taxonomy_id);
  return $terms->name;
}

This is the code in the custom page template file.

$taxonomy_id = 'term id you got';
echo getTermsName($taxonomy_id);

Nothing happens.

I am quite bad at this; I hope in a very simple solution.

EDIT

With Boriana we found out that the mythemename_preprocess function is not working not taking effect in my drupal. If anyone has idea why, that will be the key to this problem.


texts: How do I set BCC in the email I am sending?

texts:
I am using Drupal 8. How can I add the BCC field in the mail function.

Using below code Bcc not working

$params['body'] = 'test body';
$params['subject'] = 'test subject';
$params['Bcc'] = 'test@gmail.com';
$message =  \Drupal::service('plugin.manager.mail')->mail('test', 'test_email_form', $to, $langcode, $params, $from);

hook_mail function code:

function mymodule_mail($key, &$message, $params) {
  switch ($key) {
    case 'test_email_form':
      $message['headers']['Bcc'] = $params['Bcc'];
      break;
  }
}


texts: Which hook for code after a node has been deleted from the DB?

texts:
I'm running Drupal 7 and I want to re-save the user account of the node author after deleting a node of content type picture.  I want to do this because I have some code called in hook_user_presave() that counts the number of pictures a user has added and saves it in an integer field in the user.

I looked at hook_node_delete() and hook_entity_delete() as suggested in this question, but when then are invoked, the node is not yet deleted, so if I save the user at that point, the int value is one more than it should be (because the deleted file has not actually been deleted yet).

Is there a hook for responding to node deletion after it has taken place?

Related question: Hook for reacting after adding node


texts:
I have built a multi-step webform which has some field on first page (checkboxes, selectboxes etc.). I tried to access $form_state on second page in MYTHEME_form_alter where is checked if $form['progress']['#current_page'] == 'second_page'.

When am I on second page I add custom element via $form variable

$form['custom'] = [
    'button_generate' => [
        '#type' => 'submit',
        '#value' => t('Download as PDF'),
        '#limit_validation_errors' => [],
        '#submit' => ['createPdfTemplate'],
    ]
];

this is how createPdfTemplate looks

function createPdfTemplate(array $form, FormStateInterface &$form_state)
{
    dd($form_state->getValues());
}

I'm trying to get data from $form_state from 'first_page' and put them into twig template, but somehow in createPdfTemplate I can only access info about my button (i mean: $form['custom']['button_generate']) that called the action.

Anyone who could give me a hint what am i doing wrong, please.


texts: How to theme table inside vertical tabs?

texts:
I have a simple test module:

function tabletabs_menu() {
  $items['tabletabs'] = array(
    'title' => 'Table Tabs',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('tabletabs_form'),
    'file' => 'tabletabs.module',
    'access arguments' => array('admin'),
  );

  return $items;
}

function tabletabs_form($form, &$form_state) {
  $form['tabs'] = array(
    '#type' => 'vertical_tabs',
    '1' => array (
      '#type' => 'fieldset',
      '#title' => 'Tab 1',
      'a' => array(
        'x' => array (
          '#markup' => '1-a-x',
        ),
        'y' => array (
          '#markup' => '1-a-y',
        ),
      ),
      'b' => array(
        'x' => array (
          '#markup' => '1-b-x',
        ),
        'y' => array (
          '#markup' => '1-b-y',
        ),
      ),
    ),
    '2' => array (
      '#type' => 'fieldset',
      '#title' => 'Tab 2',
      'a' => array(
        'x' => array (
          '#markup' => '2-a-x',
        ),
        'y' => array (
          '#markup' => '2-a-y',
        ),
      ),
      'b' => array(
        'x' => array (
          '#markup' => '2-b-x',
        ),
        'y' => array (
          '#markup' => '2-b-y',
        ),
      ),
    ),
  );
  return $form;
}

It gives me:

This is pretty much expected result. Now, if I add:

function tabletabs_theme() {
  return array(
    'tabletabs_form' => array(
      'render element' => 'form',
      'file' => 'tabletabs.module',
    ),
  );
}

function theme_tabletabs_form($variables) {
  $form = $variables['form'];
  $output = '';
  foreach ( element_children($form['tabs']) as $id_tab ) {
    if(is_int($id_tab)) {
      // Initialize the variable which will store our table rows.
      $rows = array();

      // Iterate over each element in our $form['tabs'] array.
      foreach ( element_children($form['tabs'][$id_tab]) as $id_row ) {
        $classes = array('');

        $rows[] = array(
          'data' => array(
            drupal_render($form['tabs'][$id_tab][$id_row]['x']),
            drupal_render($form['tabs'][$id_tab][$id_row]['y']),
          ),

          'class' => $classes,
        );
      }

      $header = array(t('x'), t('y'));

      $table_id = 'tabletabs';

      $output .= theme('table', array(
        'header' => $header,
        'rows' => $rows,
        'attributes' => array('id' => $table_id),
      ));
    }
  }
  $output .= drupal_render_children($form);
  return $output;
}

this cannot work. I'm rendering tables before vertical tabs, so of course they appear before, too:

But how do I render them to appear inside vertical tabs instead? I'm sure I'm missing something little and obvious (once you know it).


texts:
When using ajax for drop-down list, I receive the error message "Undefined index: #ajax in ajax_form_callback()". This comes from the Drupal core. What I noticed when debugging this error was that the 'triggering_element' is not the drop-down, but the form 'Submit' button. If I add another button before the 'Submit' button, it becomes the triggering_element.

Here is what I have as functionality:
Simple form with a button to 'Add drop-down'. When I click the button, a drop-down appears, but there is the problem with the '#ajax'. I want to be able to add more than one drop-down, and this is done, but for none of them the '#ajax' tag works.


texts: How to create a view showing content linked with an entity reference field?

texts:
I have 2 content types: Developments and Carousel Images. Carousel Images has an entity reference field to select the Developments page it is linked to.

I simply want to create a view which will display on all Development pages, but only show the images which are linked to it. So the Development page called 'London' will display a view with all Carousel images where 'London' is selected in the entity reference field.

I have tried using contextual filters and relationships but not been able to get this working.

Any ideas?


texts:
In a Drupal 7 custom module, I am updating a record in the database using a form, and I am using the following code to update, but for some reason it is not updating. Can anyone tell me why? I tried like 3 hours to change every possible thing but no luck.

function edit_job_form_submit($form, &$form_state){
  $id = $form_state['values']['id'];
  $job_title = $form_state['values']['job_title'];
  $description = $form_state['values']['description'];
  $cat_id = $form_state['values']['cat_id'];
  $job_type = $form_state['values']['job_type'];
  $company_id = $form_state['values']['company_id'];
  $description = $form_state['values']['description'];
  $location = $form_state['values']['location'];
  $Salary = $form_state['values']['Salary'];
  $benifits = $form_state['values']['benifits'];
  $Nationality = $form_state['values']['Nationality'];
  $Age = $form_state['values']['Age'];
  $join_date = $form_state['values']['join_date'];
  $date_added = date("y-m-d", time());

  $join_date_mod = gmdate('Y-m-d',strtotime($join_date));

  $num_updated = db_update('echelon_jobs')->fields(
    array(
      'job_title' => $job_title,
      'cat_id' => $cat_id,
      'job_type' => $job_type,
      'company_id' => $company_id,
      'location' => $location,
      'Salary' => $Salary,
      'benifits' => $benifits,
      'Nationality' => $Nationality,
      'Age' => $Age,
      'join_date' => $join_date_mod,
      'date_added' => $date_added,
    )
  )
  ->condition('id', $id)
  ->execute();

  //dpq($num_updated, $name);
  drupal_set_message(t('Vacancy Updated Successfully..  '));
}


texts: Always show image ALT-tag also when is empty

texts:
We are using Media upload module. We are able to insert ALT text, while we are uploading the image.

But for the Web Guidelines, they want the ALT-tag always visible like alt="". Also when it's empty!

How do I get this done?


texts: Use Rules to email all members of a role that is specified within a taxonomy field attached to a node

texts:
I tried to concisely explain what I am looking to accomplish in the subject, but will go into more details here. I think I'm really close but my Google-fu is failing me.

My question: How can I use the role reference field coming through field_responsible_team in a dynamic fashion opposed to the static fashion I've solved for currently?

Current Setup:

Content Type: Question

-- Taxonomy: Category (attached to Question content type)

---- Taxonomy Field: Responsible Team (user role) / (attached to Category taxonomy)

Example Question node:

Node Type: Question

Category: Training

Responsible Team: Learning & Development

    { "rules_XYZ" : {
    "LABEL" : "XYZ",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert--question" : { "bundle" : "question" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_category" } },
      { "AND" : [] },
      { "entity_has_field" : {
          "entity" : [ "node:field-category" ],
          "field" : "field_responsible_team"
        }
      }
    ],
    "DO" : [
      { "mail_to_users_of_role" : {
          "roles" : { "value" : { "4" : "4" } },
          "subject" : "XYZ [node:workbench-access-sections]",
          "message" : "XYZ"
        }
      }
    ]
  }
}

I got excited when this worked, but realized I had limited this to just users of role 4.

Preferred solution: Dynamically pull in the role from the new node created and use that for the role selection in the "mail_to_users_of_role" function. I would've thought I could've used the "node:field-category:field-responsible-team" data selector, but it's telling me that "The data type of the configured argument does not match the parameter's roles requirement." I'm using the Role Reference module.

Secondary solution (solved - see below): Create one rule for each of the roles and specify the categories within the rule set (not ideal).

{ "rules_XYZ" : {
"LABEL" : "XYZ",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_insert--question" : { "bundle" : "question" } },
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "node:field-category" ],
      "field" : "field_responsible_team"
    }
  },
  { "AND" : [] },
  { "data_is" : {
      "data" : [ "node:field-category:field-responsible-team" ],
      "value" : "4"
    }
  }
],
"DO" : [
  { "mail_to_users_of_role" : {
      "roles" : { "value" : { "4" : "4" } },
      "subject" : "XYZ",
      "message" : "XYZ"
    }
   }
  ]
 }
}


texts: How do I prevent a module from being loaded?

texts:
I am developing a custom module, from this module im trying to disable other modules (for certain reasons).

Let's say I want to disable the search module, how would I do this?


texts:
I have a drupal7 Site, in which I activated the services module to expose a SOAP service.
The problem is that I set up everything, the endpoints, the handling of the request, load the WSDL and set the class to get th efunctions, but I always get an error

function tigoapi_server() {

require_once 'ServicePort.php';
global $HTTP_RAW_POST_DATA;
$server = new SoapServer(drupal_get_path('module', 'tigoapi') . '/wsdl/TigoAPIService_1.wsdl');
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL after the server is initiated
$server->setClass('ServicePort');

error_log(print_r($server->getFunctions(),true),3,"/var/www/sites/tigo/sites/all/modules/services/tigoapi/tigoapi.log");
$server->handle($HTTP_RAW_POST_DATA);

I always get:

curl http://server/tigoapi?wsdl
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Bad     Request</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope

Now, if I try it , same server, same WSDL, same ServicePort class, just not going throug the Drupal router it works:

    require_once 'ServicePort.php';
global $HTTP_RAW_POST_DATA;
//$server = new SoapServer(drupal_get_path('module', 'tigoapi') . '\wsdl\TigoAPIService_1.wsdl',array('encoding'=>'UTF-8'));
$server = new SoapServer('wsdl/TigoAPIService_1.wsdl');
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL after the server is initiated
    $server->setClass('ServicePort');

    error_log(print_r($server->getFunctions(),true),3,"/var/www/sites/tigo/sites/all/modules/services/tigoapi/tigoapi.log");
//$server->handle();
$server->handle($HTTP_RAW_POST_DATA);

This works perfectly.

I'm using nginx and php-fpm, it would seem that the difference is in the way the requests gets here as with drupal I have a $_GET variable called 'q'

any ideas on this?


texts: Getting $content of content type in template.php

texts:
I am trying to get form that is used in content type template in template.php.
I am creating node collections with EntityFieldQuery, and I am pulling field values of content type without problem.

But i need to access form, and add it to html stream that i create in template.php

In content type i can do

print render($content['add_to_cart']);

To get form out.

But now in template.php i need that form for specific nodes (im pulling them with EntityFieldQuery) as html, so i can include it to rest of the stream and send the  data in variable, and simply output it where i need it (content type page.)

Thanks!


texts: How to get rid of the "Ago" in a time format?

texts:
When translating to another language, a lot of things are in place, so much that most of translating goes with ease. However one thing seems very hard get done: getting rid of the "ago" in the format: "2 hours 23 minutes ago" while keeping the translation as it is.

Such format is available when adding a field like: "Authored on" and choosing the "Time Ago" format.
in many languages, like French and German: ago's equivalent is supposed to be in the beginning of the time format: like "Depuit 2 heurs", meaning "2 hours ago".

Some of the terms like "hour" and "day" are already readily translated in many languages (if the language is added along with translation module), and some can be done in similar way: by visiting admin/config/regional/translate and searching in String contains: search area: For instance if Seconds are not translated , and hours are , seconds can be translated in a way similar to hours when searching for hours.

By searching for "ago" you can see %time ago but no changes are visible in the final page, removing ago or replacing it won't work, and nothing will change.

I came up with two solutions:

1-By changing the past format in the settings of authored on from @interval ago to [depuis] @interval [ago]. In this case @interval is accordingly translated depending on the language choosen here, but [depuis] and [ago] will show up in all languages.

2-
By changing the authored on settings of past format from @interval ago to just @interval and  changing the title in the English site from Authored on to Authored .. ago and in the translated version to something like Publié depuis.. (In that last one, just by placing this title as a translation of the title in the English site, like doing view's settings translations..)

Is there any more obvious approach?


texts: How to force a redirect (override the destination query string in the URL)

texts:
I have a custom form submit callback to redirect users to a specific page:

function MYMODULE_authfrontpageredirect_callback(array &$form, FormStateInterface &$form_state) {
  $url = \Drupal::service('path.validator')->getUrlIfValid('node/16');
  $form_state->setRedirect($url->getRouteName(), $url->getRouteParameters());
}

This works correctly unless the url has a destination query string, such as
/node/add/mynode?destination=/user

In this case, the user will be redirected based on the query string (to /user) instead of my submit handler destination (node/16).

How do I forcibly override the destination query string content for this submit handler?

This question is similar to this D7 question but since Drupal 8 has the Symfony routing system the answers there did not help me.


texts: 8 autocomplete pass current value to function

texts:
I am trying to use autocomplete in a custom form, but I don't know how to pass the current value of the field to the autocomplete function.

This is my form element:

  $form['gs_name'] = [
    '#type' => 'textfield',
    '#title' => $this->t("Name"),
    '#autocomplete_route_name' => 'gseight_autocomplete',
    //'#autocomplete_parameters' => array(),
    '#required' => TRUE,
  ];

Route:

gseight_autocomplete:
  path: 'gseight_autocomplete'
  defaults:
    _controller: '\Drupal\gseight\Controller\GsEightAutoComplete::content'
    _title: 'Autocomplete Results'
  requirements:
    _permission: 'access GS simple page'

Inside GsEightAutoComplete

public function content($q = '') {

    //get user
    $userCurrent = \Drupal::currentUser();
    $uid = $userCurrent->id();

    $selectthree = db_select('gs_plans','g');
    $selectthree->addField('g','gs_name');
    // Filter only current user".
    $selectthree->condition('g.uid', $uid);
    $selectthree->condition('g.gs_name', '%' . db_like($q) . '%', 'LIKE');

    $currentone = $selectthree->execute()->fetchAll();

    $jsonarray = array();

    foreach($currentone as $eachcurrentone) {
        $jsonarray[] = $eachcurrentone->gs_name;
    }

    return new JsonResponse($jsonarray);

    }

The array fills with items from the database that belong to the current user when i have $q = ''at the start. But how do I pass the current value of the field to q?


texts: Switch to admin theme based on path using hook_init() or template.php in Drupal 7

texts: I'm running a site that uses a separate admin theme. I'd like to include a couple additional pages that use the admin stylesheets. How can I apply the theme selectively to these pages. I'd rather do this in hook_init() or template.php. I don't want to add any more contrib modules to the site at this point. Thanks for any illumination.


texts: How to insert 2 answers using Quiz submodule Short Answer?

texts:
I am using the Quiz module and enabled its submodule Short Answer.

How can I insert two answers instead of one?

Note: Multiple choice is fine, but my problem is at Short Answer: I'm only able to add 1 correct answer, but my Quiz question has 2 correct answers.


texts: Twitter Cards with Metatag module not working

texts:
I've got the metatag module installed and enabled. I've also enabled the MetaTag: Twitter Cards sub-module so that it will render meta tags for twitter cards, but I'm not seeing any twitter: metatags in the head at all.

Here is a page on my site:

http://www.inadaydevelopment.com/app/ios/10bii-financial-calculator

Here is the export of the Node configuration, I believe the only thing I changed is that I set a creator value for my twitter account:

$config = new stdClass();
$config->disabled = FALSE; /* Edit this to true to make a default config disabled initially */
$config->api_version = 1;
$config->cid = '1';
$config->instance = 'node';
$config->config = array(
  'title' => array(
    'value' => '[node:title] | [site:name]',
  ),
  'description' => array(
    'value' => '[node:summary]',
  ),
  'og:title' => array(
    'value' => '[node:title]',
  ),
  'og:description' => array(
    'value' => '[node:summary]',
  ),
  'twitter:creator' => array(
    'value' => '@inadaydev',
  ),
  'twitter:title' => array(
    'value' => '[node:title]',
  ),
  'twitter:description' => array(
    'value' => '[node:summary]',
  ),
);

I created a new default metatag for content type App, here is the export:

$config = new stdClass();
$config->disabled = FALSE; /* Edit this to true to make a default config disabled initially */
$config->api_version = 1;
$config->cid = '2';
$config->instance = 'node:app';
$config->config = array(
  'twitter:image' => array(
    'value' => '[node:field_phone_screenshots]',
  ),
);

However, none of the twitter:card meta tags show up at all... what am I doing wrong?


texts:
I would like to add a section on my website (Drupal 7) which consists of articles with external links (as source). To avoid spam and duplicated content, I would like to avoid that users may add a URL more than one time. Basically, I need something which checks if the external URL is unique and not being used more than once.

I've looked for modules on Drupal.org, and tried googling some information. But I couldn't really find a solution. The Link checker module seems fine for checking if the URL is still available, but it doesn't avoid the same URL is used more than once.