texts: Set the message field as not required in a custom contact form

texts:
I have tried many things to set the message field as not required.

1-The more obvious in form_alter

$form['message']['widget'][0]['value']['#required']=false;
$form['message']['widget'][0]['#required']=false;
$form['message']['widget']['#required']=false;
$form['message']['#required']=false;

2-Set a white space as a value (if field is empty) in form_validate

$msg= $form_state->getValue('message');
if(!isset($msg['value'])){
    $form_state->setValue('message',
        [
            'value' => '  '
        ]
    );
}

3-Set not required in after build

function alter_contact_ds(&$form, FormStateInterface $form_state, $form_id)
{
    $form['#after_build'][] = '_remove_msg_required';
    ...
}
function _remove_msg_required($element){
    $element['message']['widget'][0]['value']['#required']=false;
    $element['message']['widget'][0]['#required']=false;
    $element['message']['widget']['#required']=false;
    $element['message']['#required']=false;
    return $element;
}

4- In form_alter, I have used the #state to set the required property

$form['message']['#states'] = ['required' => ['select[id="edit-object"]' => [
    'value' => 'info'
]]];
//Note that ['select[id="edit-object"]' => ['value' => 'info']]]
//is used succesfully on another field (but not the requied part)

The best I could get is not having the regular behavior explaining that the field must be completed (and no red asterix near the field to mark it as required)

But each time I press on the submit button, I get a drupal_set_message("This value could not be null",error) [freely translated from french]

SOLUTION:

Following the idea of Alireza Tabatabaeian, I could solve this problem by

1-Set the field as not required in form alter

$form['message']['widget'][0]['value']['#required'] = false;

2-Set my validation function de first one in form_alter

$form['#validate'] = ['my_validate_contact','::validateForm'];

3-In my validate function set the value of the field equal to a space if the field is empty (it is not really nice, but I could accept it)

$msg = $form_state->getValue('message');
if (! isset($msg['value'])) {
    $form_state->setValue('message', [
        [
            'value' => '  '
        ]
    ]);
}


texts: New user email notification not being sent

texts: This is my first day using Drupal, and I apologize in advance for such a basic question.  I am using Drupal 7.26 with no modules installed and when I try to sign up new users the e-mail notification is not being sent.  I tried signing up with two different e-mail addresses and checked the spam folder in each account.  I also tried to find an answer on the internet but I'm not having much luck.  Can anyone provide some suggestions on how I might troubleshoot this issue?  I've been to my Administration>Account Settings and Administration>Site Information but I'm not seeing anything that looks obviously amiss.


texts:
I need to create a page which is completely empty (no HTML returned at all). I need this for a POST callback (when using jEditable).
I would like to still have access to the global variables (such as $user) and the modules that I have installed as I have a module installed which lets me access my REST service.

However, even though there should be not HTML returned per default, I should be able to return a string.

Does anyone know of a way to do this?


texts: How to hook into core's "log in to comment" link

texts:
I'm running Advanced Forums on D7, and when an anonymous user views a forum post (lets say nid 101) there is link under the post that says "Log in or register to post comments".

The problem is it is supposed to point to 'user/login?destination=node/101#comment-form' but the url encoding causes it to become 'user/login?destination=node/101%23comment-form'

I looked inside core's comment module, under function theme_comment_post_forbidden  line 2387 says:

$destination = array('destination' => "node/$node->nid#comment-form");
return t('Log in or register to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));

but I think it should make the #comment-form a url fragment:

$destination = array('destination' => "node/$node->nid");
$fragment = 'comment-form';
return t('Log in or register to post comments', array('@login' => url('user/login', array('query' => $destination, 'fragment' => $fragment)), '@register' => url('user/register', array('query' => $destination, 'fragment' => $fragment))));

How I can create a hook to this and change the link?


texts: How do I create a local menu action to node/add/page?

texts:
Here is the code in mymodule.links.action.yml to add a local action in a custom page (generated by the Views module).

amidori_utils.add_content:
  route_name: 'node.add_page'
  title: 'Add Content'
  appears_on:
    - view.admin_blogs.page_1

The above page will create a local action menu, which will take you to node/add page which will again list links to various content that you can create.

What I want is to create a link to node/add/blog as a local action. How can I do it?

After watching to the content of the node.routing.yml file, I understand I need to use node.add as route, but I can't figure out how to pass blog as parameter to the end of the route.


texts:
I have term refference in user fields. I would like to show under name of author's node that field.

I try this code:

<?php print $node_author->field_NAME[$node->language][0]['taxonomy_term']; ?>

But this won't work.

Anyone can help me?

Thank you!


texts: Populating select list from a taxonomy term field

texts:
I'm trying to populate a select list dynamically by pulling its values from a taxonomy term field linked to the current-user account. Just to clarify, below function is a hook defined by a module that came with a custom installation profile. It is basically used to create fields on a specific form.
So, my custom module has-

function some_function_attributes() {

      global $user;
      $user_fields = user_load($user->uid);
      $termid = $user_fields->field_user_organization['und']['0']['tid'];
      $taxonomy_term = taxonomy_term_load($termid);
      //dsm($taxonomy_term);
      $options = field_get_items('taxonomy_term', $taxonomy_term, 'field_org_environment','select');
      dsm($options);
      return array(
        'environment' => array(
        'type' => 'select',
        'options' => $options,
        'name' => t('Environment'),
        )
      );
    }

Allowed values in the field (for this user)-

E1|Env1

E2|Env2

Here's the devel screenshot for dsm($options);

So, its populating the right field but not in the way it should.

Actual form element looks like this-

Currently, its just returning the array and I can't figure out what I missed. Been banging my head to the wall for this-
How would I populate Env1 and Env2 in this select-list ?


texts: How to use JW Player Video Module, To Stream Video Intelligently, w/ bitrate switching. Is it possible?

texts:
I'm not a developer, so excuse any terminological or module reference errors, but as I understand things, the title sums up our primary obstacle. We can store video files on AmazonS3 and distribute via CloudFront etc. and access a single streamed video file. However, how does one set things up so that JW Player (through Drupal) can intelligently serve differently encoded video files (of the same underlying video file content), based on end user system/bandwidth conditions/constraints, as per the benefits of RTMP or http-pseudo streaming or some other analogous approach (i.e. make the setup handle bitrate switching)?

As I understand it, there are no obvious 'exposure points' within the JW Player Module for Drupal that would allow us to do this.

Is this possible and, if so, any pointers? We're totally lost at this point, and would immensely appreciate some help....

Alternatively, how does one use the HD 'plugin' through the Drupal JW Player Module approach, to 'display' an HD 'option' overlay, thus allowing the end user to 'select' his/her own video quality preference? We don't see how.

Yet a 3rd, and least desirable, option would be to upload two differently encoded videos, one using a preset for lowest common denominator usage and the other for HD - and then simply label them accordingly. In essence have duplicate files for everything, labelled SD and HD...Not elegant.


texts: Render a CCK field with only the node object in Drupal 6

texts:
If I have a node object and would like to render just a given CCK field, how would I do so? I don't mean on a node template page or in a nodeapi hook, just in general.

My custom CCK field's theme_mymodule_formatter_default function takes an $elements array - when this function is called on the node page, $elements is an array with keys including the following:

#formatter
#node
#field_name
#theme
0
1

...where 0 and 1 point to arrays of values in the multi-valued CCK field.

Now if I want to render this field, and all I have is my formatter function and a node object, how do I format it? If I call theme('mymodule_formatter', $node->field_my_cck_field[0]), what gets passed to the $elements array of my formatter function is an array with only the following keys

0
1

But rather than even having to call the theme() method, I'd like to call something like drupal_render() that will pick the default theme formatter function. I imagine there's a way to do something like this, I just don't know how.


texts: How do I implement the login, register and "Forgotten password" forms?

texts:
I'm trying to implement the three Drupal 8 user forms : login, register account and forgotten password forms.

I'm creating custom pages in my module for each one of them because I want to display content around those forms, change titles, hook the forms.

I'm having a hard time to do it, especially to get those forms in order to send them to the template and render them.


texts: How to render html tags in field collection items?

texts:
How is it possible to render also the html tags of a field collection item?
If i do something like this in a textfield (Full html) of an item:

TEST

I also get this in frontend, with no rendered html tags.

Node Theme:

{% for details in node.field_cv %}

{{ details.getFieldCollectionItem().field_cv_title.value }}

{{ details.getFieldCollectionItem().field_cv_details.value }}

{% endfor %}

Thanks for helping!


texts: Drupal 7.14 on IIS 7.5, MS SQL Server 10.5

texts:
I have been tasked with seeing if Drupal can be made to run on IIS (specifically, IIS 7.5 running on Windows Server 2008 R2) and MS SQL Server (2008 R2). I'm aware of Microsoft's WebPI Drupal package, but since we have an existing site which we wish to migrate to this new environment I'd prefer to add the pieces that are needed so that they can go into the source control environment with the others rather than use a black box package. I am doing the experimentation with Drupal 7.14, which is the latest release at this time.

I have got basic PHP scripts to run (Hello World, phpinfo, etc), and installed the sqlsrv driver 7.x-1.2 (recommended at the present time) into Drupal. The Drupal installation process gets as far as to the database settings screen without any complaints. However, if I select MS SQL Server as backend:

if I enter invalid database credentials I get an error back, as expected.
if I enter valid database credentials, after clicking proceed I get a HTTP 500.0 error from IIS saying about php-cgi.exe The FastCGI process exited unexpectedly.

I have enabled request tracing in IIS and found the error code GENERAL_READ_ENTITY_END Reached the end of the file. (0x80070026) in the resulting log file. Googling for the hexadecimal error code produced very little in terms of helpful information.

drupal.org reports 4772 sites reporting using the sqlsrv module, so the module obviously works. Any hints on how to get it to work, preferably other than "use the WebPI packages"?

By setting Instance MaxRequests to 1, keeping Standard Error Mode at ReturnStdErrIn500, disabling friendly errors in IIS and ditto MSIE (thanks for the link @DigitalFire which pointed me in the right direction for this), I was able to get at what I suspect is the actual command output, or at least as close to it as I can easily get in the web browser. What is shown in MSIE's "View Source" is a plain, almost-empty, boilerplate HTML document with an empty body. Before I turned off MSIE's friendly HTTP error messages (who came up with the idea of having that turned on as standard on Server, anyway?) it showed HTTP 500, so this is probably pretty close to the truth.

Using SQL Server's Profiler, I traced the database calls made and toward the end was the following, ignoring pure SELECT statements:

-- repeated a number of times
INSERT INTO system ([filename], [name], [type], [owner], [info]) VALUES (@P1, @P2, @P3, @P4, @P5)

UPDATE system SET [status]=@P1
WHERE  ([type] = @P2) AND ([name] = @P3) AND( ([status] <> @P4) OR ([status] IS NULL ) )

UPDATE system SET [bootstrap]=@P1
WHERE ( ([bootstrap] <> @P2) OR ([bootstrap] IS NULL ) )

INSERT INTO registry ([name], [type], [filename], [module], [weight]) VALUES (@P1, @P2, @P3, @P4, @P5)

The final INSERT occurs only once, with EventClass SQL:StmtRecompile. I'm not sure this helps much...


texts: Where are entities stored in MySQL by default?

texts:
Drupal 8 has a powerful entity API that manages all the content of the entities.

How can these entities be accessed outside of Drupal? Which are the tables and what is the format?


texts: Style block based on configuration setting

texts:
I'm writing a module for Drupal and a bespoke theme. The blocks of the modules either float to the left or the right of the region their in. Currently I do that by hard coding specific css styles, e.g.

#block-myModuleName-myBlockName {float:left; background: red;}
#block-myModuleName-anotherBlockName {float:right; background: blue;}

I want to be able to set left/right (and maybe something else like background colour). So I've created an admin form that saves a persistent variable, such as variable_get('myBlockName-left', 0).

I can use that in the block content. I can wrap the content in a div that is based on the var such as <div class="myModulesetToLeft">, but that will not include the title, and it's a bit messy because it's deeper into the DOM of the block.

Do I need to create a template file for blocks? But that code will need to know what block it is displaying, so that it can check the right variable to know which class to add to the block div.


texts: Create a new facet block from Taxonomy terms

texts:
Hi I am using recruiter distribution, I have creates a new taxonomy named as trades, having few terms, Now I want to create a facet block from these taxonomy terms, could anyone please suggest me any tutorial for doing this. I already have few default facet blocks provided by recruiter distribution. I could not find any proper tutorial regarding creation of facet from taxonomy terms.

Thanks


texts: How to convert Mutual User Relationship to Reciprocal?

texts:
I had a relationship set up on my website (let's call it "Friends"), and many of my users have used it. It was a Mutual relationship. That relationship is being used to provide access to the user's nodes via Panels... for example, if User A and User B become friends, then User A can see User B's nodes, and User B can see User A's nodes.

I recently converted the (mutual) Friends relationship to One Way with the possibility of Reciprocation, because I now need to allow User A to request access to User B's nodes without giving User B access to User A's nodes. If User B then decides to request access to User A's nodes, they can do so because of the reciprocation setting.

That functionality is working fine for any new Friends. The problem I am having is that any Friend relationships that existed before the relationship was changed from Mutual to One Way/Recip are not acting like reciprocated relationships; they are acting like One Way relationships. Therefore, if User A was the one who requested the original mutual Friend relationship, they now own the One-Way relationship with User B, and User B does not own a reciprocal relationship with User A.

I need for the formerly Mutual Friend relationships to now be One Way with Reciprocation. How can I do this? Is there a way for me to edit it in the database perhaps? I definitely cannot ask all of the users to un-friend and re-friend their existing relationships.

Thanks!


texts: Difference between .info files hook_menu() file key?

texts:
What is the difference between declaring the files[] in a module's .info file and declaring the file inside a hook_menu() item?

According to the Drupal Documentation on .info files...

  When a module is enabled, Drupal will rescan all declared files and index all the >classes and interfaces that it finds. Classes will be loaded automatically by PHP >when they are first accessed.

And the documentation on the files key for hook_menu() is...

  A file that will be included before the page callback is called; this allows page >callback functions to be in separate files. The file should be relative to the >implementing module's directory unless otherwise specified by the "file path" >option.

This sounds a little redundant to me. Aren't the files being "included" when you declare them in the .info file? So why would i need to list the file location for a function inside hook_menu when it should already be included?


texts: Create a faceted search like eRecruiter without solr?

texts:
I am in need to create a search results page & filter like the eRecruiter demo page: http://drupaljobs.epiqo.com/search/job

The filter on the right hand side shows the amount of results for specific tags or taxonomy terms, clicking enables that filter, updates the number of results for each filter etc ..

I am using D7 and views3

I do not have apache solr on my server and I wonder if it is possible to create the filters (in my case by taxonomy terms attached to the nodes of a specific type) like they are in this example using mysql and search api?

So far I have used exposed filters in views, but I really need the amount of results for each term behind it.

I have tried something along these lines:

Add new view
Show -> taxonomy terms
Continue
Relationships -> Taxonomy term: Content with term
Use aggregation:Yes
Taxonomy term: Name -> Group results together
Add field -> Content: Nid
Aggregation -> Count DISTINCT
Make your own style for Content: Nid field (Set prefix to "(" and suffix to ")" to get
the count between brackets)

but without getting the right results.

Is this possible at all?

Thank you all in advance!


texts: Is there any way to create validation function in system_settings_form

texts: Creating a form having two file type element, i want to check that if user uploaded file any file, then user must upload both file, so is there any way to add a validate function in system_settings_form.


texts:
I'm trying to add a new sitemap variant using Simple XML Sitemap referenced here.

For the most part I understand it but I'm not sure where to actually place my definition and use the simple_sitemap.generator service to add it.

If I place it inside of an alter hook it never gets recognized by the site. I'm not sure how/where to add this new variant.

Thank you for your help.


texts: Programmatically load 'add content' form for custom content type in form or block plugin

texts:
I understand that users could use 'add content' from the admin menu, but I'm building a custom block plugin or form so the add content form can be displayed in a block on the page instead of requiring users to use an actual admin page. I've done this before by manually creating forms in a render array in a form plugin that save the field values into a node upon form submit, but it'd nice to actually be able to just grab the actual add node form and render it directly.

In my research I found code to do this for Drupal 7

module_load_include('inc', 'node', 'node.pages');
$node_form = new stdClass;
$node_form->type = 'yourContentType';
$node_form->language = LANGUAGE_NONE;
$form = drupal_get_form('yourContentType_node_form', $node_form);
return $form;

But I need a way to do this in Drupal 8.
I've loaded custom form controllers before like so

$content = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\MyForm');

But I'm not sure how I would add a specific 'add content' form. How would I get the form of any 'add content' for a specific content type?

UPDATE: I found a path to something called 'NodeForm' and I tried to use it like so

$content = \Drupal::formBuilder()->getForm('Drupal\node\NodeForm\publication');

Where publication was a content type I wanted to load the form for. But I receive an error

  The form argument Drupal\node\NodeForm\publication is not a valid form

And out of curiosity I tried

$content = \Drupal::formBuilder()->getForm('Drupal\node\NodeForm');

But that gives me the error

  Fatal error: Call to a member function getEntityTypeId() on null in /Library/WebServer/Documents/aaep/web/core/lib/Drupal/Core/Entity/EntityForm.php on line 77


texts: Is it possible to trigger an Ajax CallBack Function After a Link is Click

texts:
I have a simple link in my form.

$form['myid_print']['myid_print_search_idnumber_wrapper'] = array(
  '#type' => 'item',
  '#markup' => 'Im a link....',
);

Is it possible to trigger an ajax callback function after a link is click? If yes, how?


texts: How can I specify background color and image for a block or node?

texts:
My web page consists of vertically aligned blocks. Each of these blocks/nodes may have  a custom background color or image. I am entering the background color/image within the specific block. How can i then apply these CSS attributes on that specific block? I would like to simply render the block as

[...]

I played with block template but was not able to persuade the color or image attribute to appear where i needed them, both the values were wrapped in the useless

markup.


texts: How do I add custom keywords in the URL?

texts:
For a sake of SEO, I need to be able to dynamically pass random keywords to the URL. For example, instead of the classic variable=value couples in a query (e.g. /my-node-title?selected=random-seo-keyword), I need to use a good-looking path like /my-node-title/random-seo-keyword, where my-node-title is a URL / path alias of node/xxx but random-seo-keyword does not exist in the structure and may not be predefined.

Then, on the server I handle and split the URL parts with a script. The only problem is that currently Drupal 7 returns a 404 error in such cases.


texts: Content type title field not available in manage display

texts:
I have two customized content types, both having a title field. Yet this field does not appear in the Manage Display panel. Moreover, they are not displayed when the content is displayed.

Is this normal? How can I access those title fields? How can I have them displayed?


texts: Can filter by file upload description but not sort by it?

texts:
I have a simple page/content type where a user can upload files and give them a description.

I then hide that field on the page and display the files using a view in a block.

I can get it to show the files no problem and display them with a custom output, however I just can't seem to be able to sort by the text description, rather than the filename - the field just isn't there to sort by.

The description field does however show up in Filter Criteria where I've exposed it to allow users to search for files using the file description rather than the file name.

I'm not really sure how/where to look as I've tried all sorts of combos of the fields I have and none of them seem to be what I need.

Any help appreciated!


texts: Address field tokens and country display

texts:
I have some user profiles with address fields attached. I created a view of these profiles, with the country as a contextual filter. I'm showing a summary of the results in one of my Views displays, so I can show the countries represented in my data set, with the number of matches for each:
US (12)
CA (6)
DE (3)
and so forth.
I'd prefer to be able to show these as country names rather than 2-letter codes (though the 2-letter code is useful for linking to another part of my view...)

Is there a way to get Views to output the country names in this scenario?
It does just fine when displaying them in fields or full content modes, but not in the result summary.

Any advice appreciated.


texts: How to check for entity access when displaying views fields?

texts:
I have a custom entity. There is an access callback defined in hook_entity_info() and it is called when I access the entity. Also in views when I select to display rendered entities, the entity is only shown when the user is allowed to see the entity.

However when I change the view to show 'fields' instead of 'rendered entities', the access callback is no longer called and users can see all fields (and properties) of the entity, regardless of any permissions. Looking at the executed query this makes sense, the field values are joined in and the entity is never really loaded.

So, how should one implement entity access for views when displaying fields (in Drupal 7)?

I've found How to check for entity type in Views when using hook_field_access?, but I assume that only works for joined fields and not for base entity properties, so that would be only a part of a solution.


texts: Disable caching of attached css/js libraries for custom module?

texts:
I have been trying to disable caching during development so I followed drupals guide step by step: https://www.drupal.org/node/2598914

After doing this I would assume that the caching is completely disabled but when I am loading a js/css file for a specific module in mymodule/mymodule.libraries.yml I still have to clear all caches for me to see any updates.

How do you disable caching for attached libraries in custom modules?

test_module.routing.yml

test_module.test:
  path: '/test-me'
  defaults:
    _title: 'Testing module css cache'
    _controller: 'Drupal\test_module\Controller\TestController::test'
  requirements:
    _permission: 'TRUE'

test_module.libraries.yml

test:
  version: VERSION
  css:
    theme:
      test.css: {}

TestController.php

<?php

namespace Drupal\test_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Render\Markup;

class TestController extends ControllerBase
{
    public function test()
    {
        return [
            "#markup" => Markup::create("
Hello World
"),
            '#attached' => [
                'library' => ['test_module/test']
            ]
        ];
    }
}

test.css

.test-class {
    padding: 40px;
    background-color: blue;
}

If I change the background-color to red for example, and refresh the page (F5, Ctrl+F5, Ctrl+Shift+R, Right click refresh -> Clear cache and Hard Rest), it will not change to red until I clear all caches.

What piece am I missing to make this work? Or is it just not possible?

Note: It doesn't matter if I clear my browser cache at all (I currently have it disabled with devtools open)


texts: Youtube videos are not streamed on Lightbox2 on Safari

texts:
I have a strange problem, which I don't know how to solve as it looks like nothing I can do about it... I am using Lightbox2 to play videos on my website and it's working perfectly if I watch Youtube videos on Ubuntu (Chrome, Mozilla, Safari, Opera) and Windows (Chrome, Mozilla, IE 7,8,9, Opera, Safari) but not on Safari in OS X. - it just go white screen and sometimes (very rarely) the video loads, but most of the time it doesn't.

The link of embeded video example is here: http://www.scanorama.lt/lt/mirties-signalas

do you have any idea, what could be the problem?

And sorry if it's not Drupal issue (then could you please direct me to the right source of info).

thanks


texts:
I am using hook_menu() to generate a series of MENU_CALLBACKS for processing data at various points in my sites operations. However, while these work for the admin, when trying to access the pages I get the following error message:

You are not authorized to access this page.

I am trying to get this so that the pages can be reached by all users (one is used for submitting a form and processing the results), the other is used for logging outgoing data. The code is as follows:

function modulename_menu() {
  $items = array();
   $items['data/update'] = array(
    'page callback' => 'dataupdate',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
   $items['onthewayout/forward'] = array(
    'page callback' => 'register_click',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  return $items;
}


texts: How to trigger batch job from the command line

texts:
I have a batch job that is triggered as soon as I open a specific url of my site, let's call it "http:\mysite.com\job"

The last code of that page is:

batch_set($batch);
batch_process('/');

I need to trigger it but from another machine (CentOS). Tried wget and curl but without success.

Is it possible with those commands or is there another way?

Thank you.


texts:
I've been having an issue with a file field that is not accepting any file uploads -- it ends up returning a 500 ISE on the specific field call (see image of the returned upload error). 1

The actual field itself is left over from a Database import of the site on an Acquia Cloud install. I know that it may be possible to re-create the field, but we stand the risk of losing existing records. Server configuration wise, it looks like the file directory is writable by httpd, so I don't see any issues there.

It doesn't help that the Acquia logs don't give anything useful. Any ideas?


texts: Altering add_to_cart_form_submit() and random PDOException while adding to cart

texts:
I have created a customized product with lots of attributes to set for it.
I also altered hook_add_to_cart_form_submit() where I collect all selected attributes and calculate a new price based on the selected and configured attributes.
So in my

function MYMODULE_add_to_cart_form_submit($form, &$form_state) {}

I create a big array and:

if (empty($form_state['line_item']->line_item_id)) {
    if ($attributes)
        $form_state['line_item']->data['context']['attributes'] = $attributes;
    $line_item = commerce_product_line_item_new($product, $form_state['values']['quantity'], 0, $form_state['line_item']->data, $form_state['line_item']->type);
    //   ...
}

I'm not sure if I am doing it right, I just want to store that array in the line-item table.
While adding product to cart randomly I get:

"PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_line_item-177-0-0-und' for key 'PRIMARY': INSERT INTO {field_data_commerce_unit_price} ..."

error.
Should I use some special format for this $attribute array? Everything is stored as BLOB in commerce_line_item.data field.


texts: Instead of using HTML underline tags, I want the WYSIWYG editor (CKEditor) to wrap a span around the highlighted text. Does anyone know how I can achieve this? Thanks!


texts: Way to tell render() to use a different .tpl file?

texts:
I am working on a Global module (used by many sites). I have two .tpl files (list.tpl and product.tpl) that both use a 3rd .tpl (product-images.tpl).

In both list and product .tpls, this is called like:

  <div id="product-images">
    <?php print render($element['productImages']); ?>
  </div>

However, I want to change the way product-images.tpl appears in product.tpl. I want to say something like

  "If productImages is rendered within product.tpl use
  product-page-images.tpl".

The tricky thing is a I cannot add any logic to the actual module's code it's self, as it is being used by many other sites and I don't want to break anything. I can only really alter the .tpl files within my site's theme.

Is there a way to provide perhaps and additional parameter to render() to have it use a different .tpl file?

Any help or advice is much appreciated! Thanks!


texts: How do I stop HTML entities appearing in an e-mail client's subject header?

texts:
If I send an email with drupal_mail with the subject header:

Let's go

It appears in my email client:

Let&#39;s go

This is okay:

Let’s go

The most convincing explanation I've read is:

  The behavior you are seeing is because the subject line is being run
  through check_plain() (via t()), which calls the PHP function
  htmlspecialchars().

Here's the link.

What changes should I make to my hook_mail code to correct my header in the email client:

$message['subject'] = t('Let's go');

Code that threw the error:

$message['subject'] = t('@responder has responded to: @title', array(
  '@responder' => $params['responder'],
  '@title' => $params['title'],
));


texts: How to make image alternative text as required be more web accessibility?

texts:
In Drupal 7, how can I set image alternative text as required in "Body" field (CKEditor), "image" field and file upload by using "Media" module?

---- updated info for betherwisser on Aug. 20, 2014 @ 12:17pm
I know there is a file types section in Media but it is different from what you mentioned. However, It does not have the Alt text field option there. Please see screenshot for details.

ALSO, there is an option on image file for Alt Text but I'm not able to make that as required. See below screenshot.


texts: Pass variables from one preprocess function to another in .theme

texts:
I am developing a theme in Drupal 8 and I have 2 twig files. One is page.html.twig and the other is status-messages.html.twig.

The problem is that status-messages has a variable named message_list (an array) but this variable is protected, so other files don't have access to it. I have tried to call this variable from theme_preprocess_page() like so  $variables['testvar'] = $variables['message_list']; with result of $variables['testvar'] = null.

In the next step I tried to copy the functionality of status-messages.html.twig from Drupal\Core\Render\Element\StatusMessages to mythemem.theme file, like so:

use Drupal\Core\Render\Element\StatusMessages;

function MYTHEME_preprocess_page(&$variables) {

  // Create Dynamic path for project root elements (in general files that are in our theme project)
  $variables['theme_path'] = base_path() . $variables['directory'];

  // this here gives us the array of renderMessages() but  '#message_list' has no data in it
  $variables['testvar'] = StatusMessages::renderMessages();
}

function mythemem_preprocess_status_messages(&$variables) {

  // this here dose gives the value but it can be accessed  only in status-messages.html.twig
  $variables['mymessages'][] = $variables['message_list'];

  // same as in mythemem_preprocess.page
  $variables['testvar'] = StatusMessages::renderMessages();
}

My aim here is to understand how to correctly use .theme files, how to pass protected variables from one preprocess function to another.

To be more clear I would like to know/understand how to get the same effect for my custom.html.twig file as it is here

To achieve this, I want to take $variables['message_list'] to process it as I want.


texts: How to get all linked nodes from all terms in a vocabulary

texts:
I have a content type "News entry", which has a term reference "News category", which is of course a taxonomy vocabulary.

I’m not sure if I get this whole taxonomy thing right, but I’m able to render and theme each category correctly (/news/category-a).

Now I want to theme the overview or home page, which displays all news entries of all categories. Easiest way for me would be selecting the right rows out of the database, but I reckon that’s not very much the Drupal way.

So I figured out how to get all terms of a vocabulary. In the preprocessing function theme_preprocess_node_news_overview() I tried taxonomy_get_tree(). Now I've got an object for each term with the following contents:

http://i.stack.imgur.com/cbT8c.png
(can’t post images yet)

The news entries are preprocessed in theme_preprocess_node_news_post(), It’d be great if this function could be reused for the news overview.

And now I’m stuck. How do I get Drupal to behave like it’s displaying a category/tax. term, but instead of the nodes of one term get (and display) the nodes of all terms?


texts:
I'm having trouble figuring out why the following code isn't working in Drupal 7. _queue_processor is a cron queue processor function:

function _queue_processor($uid) {

    $transaction = db_transaction();

    watchdog('debug', 'transaction created'); // This will not be called.

    try {
      user_delete($uid);
    }
    catch (Exception $e) {
      // A problem occurred. Rollback transaction.
      $transaction->rollback();
      throw $e;
    }
    // Rollback intentionally.
    if (variable_get('some_var', FALSE)) {
      $transaction->rollback();
    }
}

The code never makes it past the $transaction = db_transaction(); line. However, if I remove the transaction and try/catch, user_delete() is called just fine, and the transaction that user_delete_multiple() creates within itself works as well.

Is there something wrong with putting user_delete() within a transaction? I know it already uses one, but I need to be able to run the deletion and then conditionally rollback afterwards, and I'd rather not do this by throwing an exception in an implementation of hook_user_delete() to force rollback.

I am using MariaDB.


texts: How to restore form values from $form_state['values']?

texts:
I save the $form_sate['values'] in a data base. When my users come back to the form I want to show the values that they put before. Something like:

function my_form($form, &$form_sate) {
  $form_state_saved = get_form_state_values_from_db();

  $form['my_field'] = array(
    ...
    '#default_value' = $form_state_saved['my_field'];
    ...
  );

  return $form;
}

With a textfield seems that works fine, but I have some custom fields. Is there a way to set the default_value from db? Or should I implement the default_value independently for each field?


texts: How does Drupal determine the context in which to display the admin theme?

texts:
One of the great things about Drupal 7 is the inclusion of an admin theme, Seven. But how does Drupal determine whether to display the administration theme, or to display the site's theme?

Is it path-based (i.e., everything under admin), or something else?


texts: MEGA MENU please help trying to assign it the right region but no luck :(

texts: Hey can you guys please help me out iv tried researching and asking other but unfortunately have screwed it up many times and cant seem to get an answer out of anyone. Can someone please help me understand how to create a new region? I have mega-menu atm but when it was created in the files it went driectly under the menu bar which is not desirable... all im trying to do is put the mega-menu "menu" over the default one so it looks nice and professional anyone that can help me out, thanks.


texts: Grant temporary permission during function call on registration page

texts: I am geocoding an address supplied by an anon user on the registration page through ajax and then displaying the point on a map for them. I don't want to have this geocoding permission open to anon users though and just want to make an exception for it in my ajax function. I remember seeing something like this on my past Drupal travels but can't find it for the life of me now. Can someone point me in the right direction?


texts:
Im trying to use querypath module with my node and not having much luck. I have this code and I tried applying it to my node.tpl file but it only crashes the site.

Am I using this incorrectly?

global $base_root;
$path_url = $base_root . request_uri();
$qp = qp($path_url);

$qp2 = $qp->find('body'); // Find the body tag.

// Now the surprising part:
if ($qp === $qp2) {
  // This will always get printed.
  print "MATCH";
}else{
    print "...";
}

If this is incorrect can someone please provide a working example?

Thanks


texts: How do you show/hide delete(remove) product button in the Cart?

texts:
I have an issue with the delete/remove product button from the Shopping Cart. Some of my products show and some don't (see screenshot below). I checked the rules and can't find this anywhere.

What I am trying to achieve is to have the Remove on another collection I created. It only works for Postpaid Collection which is the BLU Studio X product. However, the Remove link doesn't appear on the top product (above the red arrow where I want the Remove to show on that product as well).

There is a rule set somewhere and I can't find it. I even created a new product variation and content, and it doesn't show the link in the shopping cart. It only shows it for the Phone product that was created by the previous user.


texts: How to install a third party library for Printable module using composer (D8)?

texts:
I installed the "Printable" module but it doesn't work. When I try to configure the PDF for the Printable module it says:

"You are seeing no PDF generating tool because you have not installed any third party library using composer".


texts:
I wanted to add a word in front of the title for certain nodes.
So I run an update sql statement on nodes table. The result can be seen in the attached image.

I empty the cache (flush all) but my new titles still do not appear on the website.
Should I update in a different place in database also? Do I have to do something else to see the new titles?

Thanks in advance for helping me out with this !


texts: Trade-offs between Job Queue vs. Drupal Queue

texts:
Anyone familiar with both Job Queue and Drupal Queue enough to offer an idea of the tradeoffs between the two?

In case it makes a difference, the site I'm working on uses Drupal 6. The queue I'll be creating will check a batch of user accounts with a REST API, to verify whether the users have logged into another system. Until the API gets updated (hopefully soon) each user requires a separate request, which is why I'm batching them.


texts: Render content to multiple nodes from one input

texts:
I'm looking to create a dropdown of country selects each with two fields: field_item_title and field_button_link across multiple nodes. The content is populated by repeating nested paragraph fields.
(I've simplified the twig names for ease of reading)
{{ page-name.html.twig }}
<form id="countryForm">
  <select id="countryForm" name="countryForm">
    <option disabled selected value>Country Select</option>
      {{ content.countrySelect }}
    </select>
  <input type="submit" value="GO" id="submit">
</form>

{{ paragraph-country-select.html.twig}}
{% block paragraph %}
 <div{{ attributes.addClass(classes).setAttribute('id', 'paragraph-id--' ~ paragraph.id()) }}>
    {% block content %}
      <option data-url="{{ content.field_button_link.0['#url'] }}" value="{{ paragraph.index }}">{{ content.field_item_title }}</option>
    {% endblock %}
  </div>
{% endblock paragraph %}

I've currently got the content being input on each page separately, meaning that when this needs to be updated the user will have to change it in several places in the same way.
I've been researching best practice to have this filled in from one central place, but I'm hitting a wall with my understanding of how to render content from taxonomy/another central place in multiple nodes. I know its likely I'll need a .theme function but I'm struggling to achieve this.
I've found this How to render field of one type of node to another type node, but I feel what I want to achieve is slightly more complex than this.
I understand I have little actual code to show with regards to centralising the input, so just suggestions at what to read/what direction to go in would be appreciated!
I'm also not over completely overhauling this method if there's a simpler, best practice one I don't know about. Thanks in advance!


texts: Multi-site installation and one theme: how to know on which multisite user is?

texts:
I have Drupal multisite, where I have three different sites. THey all use same theme. Now I would need to do small changes to templates that only visible on some sites. How can I tell on template level that what site is used.

For example on site 1's front page I would like to have:

Some content

But then on site 2's front page I dont want that div to be showed at all. Can I achive this somehow? Is theere "native" way to find out thie right site inside template, maybe in template.php?

Thanks.


texts: how to get all the fields that have been modified on entity save (form submit)?

texts:
I am trying to figure out an efficient way to get the fields names/values that have been updated. It's kind of similar to what the diff module does to calculate changed on a node but not as detailed. I just want to see what fields have been updated when a user saves an entity. For example a user may not change the title but could change the body. I would like to build an api function returns that. something like this pseudo code:

// possibly on presave or form submit.
function my_module_entity_presave() {
    // Return only the fields values that are not similar to the original node:
    $modified = $entity->getModifiedFields();
}

and the method could be something like this psudo code:

public function getModifiedFields() {
  $original = $this->originalFieldsValues();
  $new = $this->newFieldValues();
  // compare original with new
  // finally return only modified fields name values.
  $modified = ['title' => 'new value', 'body' => 'new value' ...];
  return $modified
}


texts:
I want to create a new menu in Drupal 8 when I install my module. How can I achieve this?

I don't want to add a link to an existing menu, but create a new one.


texts: Clearing drupal's cache causes an error 403 in some pages of my site

texts:
When I empty all drupal's caches in my website,  I get a 403 error in some pages of my site, I solved this problem by enabling or disabling the views UI Module, but it gets very annoying to do this manipulation every time the cache is flushed.

Someone has an explanation for this problem ?

Thank you.


texts: Omega - Debugging blocks only for specified role

texts:
Is it possible to see debugging blocks only for specified role?

IDEA
I made special role "theme developer" to see debugging blocks of Omega only for this role. When I check in *admin/appearance/settings/my_subtheme -> Debbugging* options:

Enable the debugging (placeholder) blocks for the selected roles.
Enable the grid overlay for the selected roles.

and select "theme developer" role debugging blocks will be seen by granted users only.

PROBLEM
If I am an administrator I can see debugging blocks even if I'm not in "theme developer" role. Why?

After documentation http://drupal.org/node/1298690 it should work as I wrote in idea but it is not.


texts: How do we configure SElinux to not break Drupal?

texts:
I've installed Drupal on Red Hat 7 in Amazon Web Services, using a database on a separate RDS instance.

My original problem was that I couldn't make the Drupal installer recognize the /sites/default/ or /sites/default/files directories as writable, even after I confirmed they were writable by the ''apache'' user or temporarily set the permissions to writable by all. (This year-old issue may be similar.) When I filled in settings.php myself, then Drupal gave this connection error:

  PDOException: SQLSTATE[HY000] [2003] Can't connect to MySQL server on
  'my-database-endpoint.rds.amazonaws.com' (13) in
  lock_may_be_available() (line 167 of /var/www/html/includes/lock.inc).

Disabling SElinux allows the installer to finish and allows Drupal to work. Re-enabling SElinux ('''setenforce 1''') stopped the installer; re-enabling SElinux after installation breaks Drupal, resulting in the same connection error given above. Drupal.org mentions the problem, but doesn't give a specific solution for this case.

I figure many other people must have run into the same problem when installing Drupal.

Obviously I have to re-enable SElinux, so does anyone already know how to modify SElinux configurations to enable Drupal to work properly (and not degrade security)?


texts:
How do I remove Home from the page title?

I added in page.twig.html this part of code.

{% if not is_front %}

      {{ page.content }}

      {% endif %}

The title appears as follows.

I just want it to be Nekretnina.ba, without Home |.


texts: Breadcrumbs customization without use of any module

texts:
I have following code in my theme.inc file to generate breadcrumbs from menu url trail. It is working perfectly except for a particular content type nodes. For content type CT1 I am using url alias as home/page1/page2/[node:title]. But that is not reflecting on the CT1 content breadcrumb trail at all. Please advise what I am doing wrong:

function mytheme_breadcrumbs($variables)
{
    $breadcrumbs = $variables['breadcrumbs'];
    $crumbs = null;
    if (!empty($breadcrumbs)) {
        $array_size = count($breadcrumbs);
        $i = 0;
        while ($i < $array_size) {
            $crumbs .= '
' . $breadcrumbs[$i] . '
';
            $i++;
        }
        $crumbs .= '
' . menu_get_item()['title'] . '
';
        return $crumbs;
    } else {
        return '
home
';
    }
}


texts: Organic Groups (OG): Make public group posts visible to everyone (outside the group)

texts:
I’m using the OG module for my site where users can create groups and make them either public or private. But one feature I miss from the group environment when creating a public group is, to make all the posts in that group visible to everyone – not only group members.

I’ve looked in the OG admin settings and found the setting “Visibility of posts:” with the radio button option to “Visibility chosen by author/editor using a checkbox on the posting form. Checkbox defaults to Public.” This function is exactly what I want but when choosing this option and try to create a post inside an open, public group, I don’t get any options to select it to be visible or not. The field just isn’t there.

I’ve browsed Google and Drupal.org for an answer and have discovered that I’m not the only one with this question. But unfortunately I haven’t been able to find a solution, so I will try again to post the issue and maybe there is something I’ve overlooked.

Any help would help.
Thanks

Sincere
- Mestika


texts: Render simple php function in twig template

texts:
I am rebuilding a website in Drupal 8 and the website shows some content with bootstrap classes according to a conditional php function based on time of day

function openStatus(){
$open_str = 'Open until 5pm';
$closed_str = 'Closed - Open Mon-Fri 9AM-5PM';
if(gmdate('N') <= 5 && gmdate('H') >= 8 && gmdate('H') <= 16){
echo $open_str;
} else {
echo $closed_str;
}

This is what I have so far, which I think works but not sure how to do day of week.

{% if "now"|date('H', "Europe/London") >= 8 && "now"|date('H', "Europe/London") <= 16  %}
Open until 5pm
{% else %}
Closed - Open Mon-Fri 9AM-5PM
{% endif %}


texts: How do I move a Composer-managed site to a new server?

texts:
I have a Drupal 8 site on an Ubuntu 18.04 server and want to move my site to a new server with Ubuntu 20.04.
With Drupal 7 I did these steps
Create a set of keys (on the new server) :
$ sudo ssh-keygen -t rsa -b 4096 -C root@www-example-com
$ sudo cat /root/.ssh/id_rsa.pub

Add the public key (on the old server) :
$ sudo nano /root/.ssh/authorized_keys

Export the database (on the old server) :
mysqldump -u root -p www_example_com > /var/www/www-example-com/share/www-example-com_$(date +%F).sql

Repatriate the site file (on the new server) :
$ sudo scp -r -p root@xxx.xx.xxx.xx:/var/www/www-example-com/ /var/www/www-example-com/

Import the database (on the new server) :
mysql -u root -p www_example_com < /var/www/www-example-com/share/www-example-com_2020-08-10.sql

That's all, with these intructions, the Drupal 7 site works.
The problem
Now with Drupal 8 there is Composer with a new folder and file tree present in the var directories and in home.
How to move a Drupal 8 site to a new server ?


texts:
I have a requirement in which there are two fields for search. One is text field and other is select box. The text field is for keywords and the select field are taxonomy terms. I need to fetch the values in both fields from text file and it should be autocomplete and display the results accordingly.

Please Help.
Thanks in Advance

Riya


texts: Install multiple apps on a Bitnami stack

texts:
I am currently transitioning from my Ubuntu 16..04 LAMP Server to a Bitnami 7.59 Drupalstack. However, I discovered that Bitnami does NOT provide instructions / FAQ on how to install multiple Drupal apps onto a single Bitnami Drupalstack, while "snubbingly" providing an instructional FAQ on how to add multiple Joomla Apps onto a single BitnamiJoomlastack... :0

(I am using an Ubuntu 16.04 host with Virtualbox5.1 and Ubuntu16.04 guest to run Bitnami drupalstack7.59)

Therefore, for all you hardcore drupalers I would like to write my own set of docs on how to add multiple Drupal apps onto a single Bitnami Drupalstack.

One Problem:

How do I actually install multiple Drupal apps onto a Btinami Drupalstack?

I was told by Bitnami Community folks that I should simple exchange "joomla" for "drupal" and follow this FAQ which of course did not work.

Along the way, I created my documentation but troubleshooting back-end Bitnami servers is out of my league.

Below are my own configuration notes, derived from attempting follow the bitnami joomla instructions  (i feel dirty..)

Can anyone troubleshoot where I am going wrong?

All I get is error code 404 when I try to visit the newly configured Drupal App... http://127.0.0.1:8080/drupal1/

My Steps To Create Additional Drupal Apps in Bitnami Drupal7Stack

New Document Root  /opt/bitnami/apps/joomla1/htdocs  translates to /home/username/drupal7stack/apps/drupal/htdocs/

Rename default drupal app

sudo mv /home/username/drupal7stack/apps/[drupal-site-name] /home/username/drupal7stack/apps/[drupal1-site-name]

Modify config file located at /home/username/drupal7stack/apps/[drupal1-site-name]/conf/httpd-prefix.conf

gedit /home/username/drupal7stack/apps/[drupal1-site-name]/conf/httpd-prefix.conf

FILE CONTENT{truncated}:

Alias /drupal/ "/home/username/drupal7stack/apps/[drupal1-site-name]/htdocs/"
Alias /drupal "/home/username/drupal7stack/apps/[drupal1-site-name]/htdocs"
Include "/home/username/drupal7stack/apps/[drupal1-site-name]/conf/httpd-app.conf"

Modify the .httpd-app configuration file at /home/username/drupal7stack/apps/[drupal1-site-name]/conf/httpd-app.conf to use the new path:

File Content {truncated}:

    Include "/home/username/drupal7stack/apps/[drupal1-site-name]/conf/banner.conf"

Include "/home/username/drupal7stack/apps/[drupal1-site-name]/conf/htaccess.conf"

Modify the Apache .htaccess file at /home/username/drupal7stack/apps/drupal1/conf/htaccess.conf to use the new path:

File Content {truncated}

RewriteBase /drupal1

Change the name of default db to via phpmyadmin accessible at http://127.0.0.1:8080/phpmyadmin/   (use root login).  Also, create username/pwd of site specific drupal installation

N/A  phpmyadmin GUI

Adjust the settings.php file found at /home/username/drupal7stack/apps/[drupal1-site-name]/htdocs/sites/default/settings.php to the db specific user created in step five

sudo gedit /home/username/drupal7stack/apps/[drupal1-site-name]/htdocs/sites/default/settings.php

restart the drupalstack (apache/mysql), then view new site at http://127.0.0.1:8080/[drupal1-site-name]

For drupalstack use ~/drupal7stack$ ./manager-linux-x64.run , then visit new website


texts: Call to a member function access() on null in ...BlockAccessControlHandler.php

texts:
I am getting two errors on my local Drupal 8 site.

First error: "The website encountered an unexpected error. Please try again later."

Second error: "Fatal error: Call to a member function access() on a non-object in ...block\src\BlockAccessControlHandler.php on line 124"

First error I get when php version is 7.
Second error I get when php version is 5.

BlockAccessControlHandler.php:

      elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
    // Delegate to the plugin.
    $block_plugin = $entity->getPlugin();
    try {
      if ($block_plugin instanceof ContextAwarePluginInterface) {
        $contexts = $this->contextRepository->getRuntimeContexts(array_values($block_plugin->getContextMapping()));
        $this->contextHandler->applyContextMapping($block_plugin, $contexts);
      }
      $access = $block_plugin->access($account, TRUE);
    }
    catch (MissingValueContextException $e) {
      // The contexts exist but have no value. Deny access without
      // disabling caching.
      $access = AccessResult::forbidden();
    }

Line 124:

  $access = $block_plugin->access($account, TRUE);

I am not sure how to fix it. How can I fix the above errors so I can launch my site?

Update

Added the code in settings. php and then reloaded the page.

$config['system.logging']['error_level'] = 'verbose';

  The website encountered an unexpected error. Please try again later.
  Error: Call to a member function access() on null in
  Drupal\block\BlockAccessControlHandler->checkAccess() (line 124 of
  core\modules\block\src\BlockAccessControlHandler.php).

Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 365)
Drupal\Core\Entity\Entity->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 669)
Drupal\Core\DrupalKernel->handle(Object) (Line: 22)


texts: Aquia Desktop - How to import a MySql database that is too big

texts:
I am using Aquia Dev Desktop. I have a MySql database dump that is too big to upload into Aquia Dev Desktop. What are my options? I am using a Mac, so would appreciate Mac based options

Steps I have tried:

I think the problem is the cache table. If I could empty (not delete) this table, I should be able to upload it into Acquia Dev Desktop.

1) Downloading MySQLWork Bench to delete the cache table.
MySQl Work Bench has a Data Import option. However, it requires the password of the Acquia Dev Desktop, which I don't have.

2) Downloading Sequel-Pro to delete the cache table
Again this requires the username/password of the database.


texts:
I'm trying with this:

$block = module_invoke('user', 'block_view', 'login');

It returns an empty array.


texts: Move “Submitted By” from node.tpl to page.tpl

texts:
I'm looking to move "Submitted By" info from node.tpl to page.tpl however when I add the following from node.tpl into page.tpl I get errors. Im assuming I dont have access to those variables, but would like to know how I can set up a pre-proccess to get it to display as it does in the node.tpl

  <?php if ($display_submitted): ?>
    <div class="submitted">
      <?php print $submitted; ?>
    </div>
  <?php endif; ?>


texts: total sum of textfield values of field collection(with unlimited values) in another field out of field collection in same form

texts: I am creating a form. it has a field collection. it has a field age in field collection that can be filled unlimited times in single form. I want to add the total of those field values(age) in another single textfield(out of field collection). I don't know how to that as it has same class but always ask for input:ID which is different everytime.


texts: How to know which file to delete in a submit function?

texts:
I've got a managed file field in a form like this:

$form['source_file'] = array(
  '#type' => 'managed_file',
  '#title' => t('Source File'),
  '#default_value' => isset($data['source_file']) ? $data['source_file'] : 0,
  '#upload_validators' => array(
    'file_validate_is_image' => array(),
    'file_validate_extensions' => array('png gif jpg jpeg'),
  ),
  '#upload_location' => 'public://imagemerge/merge/',
  '#required' => FALSE,
);

My submit function looks like this so far:

function imagemerge_merge_submit($form, &$form_state) {
  $source_file_fid = $form_state['values']['data']['source_file'];
    if ($source_file_fid != 0) {
      $source_file = file_load($source_file_fid);
      $source_file->status = FILE_STATUS_PERMANENT;
      file_save($source_file);
    } else {
      //some logic to determine previous fid?
      //and then a call to file_delete()
    }
  }

The docs for Forms API under managed_file say that it is up to the module to call file_delete. How do I know when and which file to delete?


texts: How to use Rules to populate reference product after creating a Commerce product?

texts:
After a Commerce product is created I need to create a new product display node and reference the product in a field.

This is my first time using Rules. I can create a new product display node but I cant figure out how to populate the 'referenced product' field.


texts: Restricting blocks to certain URL paths without sub paths

texts: How can it be achieved, to make a block appear for the URL path /foo/* but not for /foo/*/bar?


texts: How to change user badge when 'total User Points' increase?

texts:
I am building a community site, in Drupal 7, and using the User Points module and the User Badges module.

My goal is that every user will always have only one badge, that will be presented near the user's name, everywhere on the website.

These are my specifications for the badge to be selected according to the amount of User Points:

0-50 points = first badge
51-100 points = second badge
101-200 points = Third badge
201-300 points = Forth badge
301 points and more = Fifth badge

I tried to use User Points Contributed modules but unfortunately there is no Drupal 7 upgrade.

I tried using the Rules module, but didn't find a way to compare the current total amount of points of the user to my specifications, (for Rules Event "User was awarded points"), so that based on the result of that comparison, the Rules Action would eventually change the badge assigned to the user.

Any suggestion to get this to work?


texts: After Creating A new User inside RULES, I can not access to UID

texts:
In my rule, I have an action that is "create new entity" with "user" bundle.

every thing works fine a new user create with provided information (user and email)

it's variable name is new_user

in next action, I unblock the new user and it works correctly.

but in next action when I tried to debug "new user" via devel action, It seems it doesn't collect the information of new user

I have attached the devel result. I see no UID and no other information from new user.
Also send welcome messages actions don't work and no email is sent to new created user.

Please tell me what my mistakes are.

Thanks a lot


texts: Filter criteria not working on new field because data table is not storing data

texts:
I have a view based on a content type. I added a new boolean field Premium to the content type that I wanted to add to the view as filter criteria. However when I added it I got no results in my view, no matter whether I set its filter value to '1' or '0'.

After doing some investigation, I queried the tables and found that field_data_field_premium had no values, while field_revision_field_premium was storing values. I tested checking and unchecking the Premium checkbox on various nodes. The state of the checkbox was preserved on the node, and I confirmed that data was being stored in the revision table, and still there were no rows in the data table. After checking and unchecking the box and saving several times on a single node, the data only stays in the revision table and rows are never inserted in the data table.

This causes my view not to work, because the query that views creates does a join on the data table, not the revision table. Since there are no rows in the data table, the query returns no rows overall since there is nothing to join to.

Thinking that the field was somehow broken, I deleted it and re-created it, but I am still getting the same behavior of data only being stored in the revision table. For further testing, I created another stock Drupal site, with a content type that has a boolean field. My test site is storing data in both the data and revision table.

What is going on? Is the field screwed up somehow on this site? The content type I'm adding this field to is in a feature -- could that be the source of the problem?

Edit I just exported and reverted the feature with my field added, and I still get the same behavior of values, either 1 or 0, only being stored in the field's revision table.


texts: Simplenews logs out when sending test newsletter

texts:
I am trying to send a test newsletter through simplenews and it logs me out from my website everytime I hit the send button. I am logged in as admin. I have successfully sent test newsletters before and I dont think it is a permissions issue since I have necessary permissions.
The only thing I changed was install simplenews related modules like simplenews-statistics,etc. I also copied the .tpl.php files from simplenews's module folder to my theme folder.

What could be the problem?


texts: How to add custom stylesheet to print pdf output?

texts:
I have a view, displayed as table on single page.

HTML print view looks ok (I want border on every td), but it seems that I can't apply any styles to print pdf, I try to use HTML attributes and it seems, that only this is changing appearance of generated PDF.

Any chance to use CSS files to theme PDF output?

I am using Print module with additional PDF module (https://drupal.org/project/Print)

PDF library: tcpdf

EDIT

I just used old plain table attributes and it works inside PDF


texts: Is it possible to use multiple indexes with Apache Solr? We want to use different indexes depending on the environment id.


texts:
How can I share data from a view to an excel file. I just need a report.

Or can anyone suggest a solution from which I can extract the data from a view?


texts: How can I render a form via javascript without outputting the entire page markup

texts:
I'm trying to load a custom form into a div, but when I do, the entire page markup (menu, header, footer, etc) is being output in the div. Is there a way I can only output the form?
This is my javascript call:
jQuery('#tile-form-container .content').load('/tile/edit/2');

This is my route:
tiles.edit:
  path: 'tile/edit/{id}'
  defaults:
    _title: 'Edit tile'
    _form: '\Drupal\tiles\Form\TileForm'
  options:
    _admin_route: true
  requirements:
    _permission: 'administer tiles'

In my buildForm function I have added this line:
$form['theme'] = 'tile_form';

And that file looks like this:

            {{ form }}

Any help is greatly appreciated.


texts: Is it possible to export organic groups global roles using features?

texts:
I like to keep functionality that I build in features, both for version control and deployment.

I'm new to using Organic Groups and I wanted to know if it's possible to add an organic gorups global role to a feature.  I couldn't see any mention of this when I tried to recreate my feature through the UI or drush.


texts: Is there a way to partially load nodes based on the view mode? Say I've got a lot of fields, but for the list view I need only 3 of them ... node_load fetches them all, which doesn't make sense. Or does it? I think about using computed_fields, but when it comes to larger lists I'm a little concerned about performance.


texts: Transfer field from Organic Group to group content

texts:
I have a field on an Organic Group and I want to transfer the field to a piece of content related to the group and have it stored in the database rather than being referenced. I've been able to do that with the Field Reference module, and the referenced field shows up when the view is rendered on the content node; however, I can't seem to pull that field into a "schedule evaluation date" in Rules Scheduler because I think it is not a hard-coded value.

So, is there any module that just takes a field from one entity/node and stores it in another entity/node when you save a new piece of content?

Or would the Computed Field module let me do this? I know I don't see a "date" type to store in the database there.

Thanks in advance!


texts:
Is there a project or something that already integrated a cart similar to:

http://interface.eyecon.ro/demos/cart.html

or an integration of jcart:

http://conceptlogic.com/jcart/

I tried ubercart but despite the fact is an overkill it doesn't work like these.


texts: Contact form - leaving the form and resuming it later

texts: Is it possible to have a contact form in drupal, which you can save, and resume later?


texts:
send email using webform.
if email does not exist get failure message in inbox
Do we need SMTP
which module we need
and settings(gmail) what we need???


texts: Using PHP ImageMagick with ImageCache Custom actions - Returning image

texts:
I'm trying to composite some images using ImageMagick - I know imagemagick via PHP, i'm trying to return the image via PHP but it seems to overwrite the original source file - not ideal as it can apply the filter over and over.

Ideally, I'd like to write the original file with _thumb after it, then call this file via Drupal for display, where it would copy to the appropriate imagecache directory and display from there. Anyone with ImageMagick experience, would be appreciated if you can help.

$location = $image->source;

$newImage = new Imagick($_SERVER['DOCUMENT_ROOT'].'/'.$image->source);

$distort = array( 0.0, 0.0, 0.16, 1.0  );
$newImage->distortImage( Imagick::DISTORTION_BARREL, $distort, TRUE );
$newImage->resizeImage(1600, 1600, Imagick::FILTER_CATROM, 1);
$newImage->cropImage(1500, 1500,60, 50);

$extension_pos = strrpos($fileName, '.'); // find position of the last dot, so where the extension starts
$thumb = substr($fileName, 0, $extension_pos) . '_thumb' . substr($fileName, $extension_pos);
$newImage->writeImage($thumb);

return $thumb;


texts:
I use Site-Install to quickly setup a Drupal Site for Profile Installation Development, but I use phpMyAdmin to drop the database. I figured I might as well use Drush since it would properly be faster than using GUI.

However, after doing drush sql-drop, it says "No Tables to drop". I do drush status and I am connected to my database. I check phpmyadmin and tables are clearly seen. What's the issue here?


texts: How do I create a multi site web site in drupal 7 with diffrent admin panel ?

texts:
Possible Duplicate:
  Redirecting a user to a different home page

Can anyone please tell me how to create a multi site website in Drupal 7 with diffrent admin panel?

I want to create a new website which has different front ends , links and different admin panel for each user login.

I want to do this for 4 different users.


texts:
I want to create a site where users can sell their products.

How best to do this kind of system?

Is it a good idea to use Ubercart or it may be better to use something else?


texts:
On Drupal 8, I created on my content a personal flag "I like".

I installed Search API and I created an index view.

I want my content sorted by the number of "likes" received on each node.

How to do this ?


texts: How can i customize the output of "repeat rule" for human readability (german)?

texts:
I'm using the Calendar Module, which comes with a date-repeat feature. Showing the "repeat rule" in a view results in e.g.

  Wiederholungen jede Woche jeden Mittwoch !repeats_every_interval, 10
  mal .

which is rather unacceptable. Is there a way to rewrite the output of this? Which replacement patterns do i have to use to reproduce the repeat rule?


texts: Fieldsets 'IF ELSE' based on checkboxes?

texts:
So i have a custom form with 3 fieldsets built from FORM API. each fieldset holds its own "mini" form for users to fill out. what i want is the second 2 fieldsets should not display unless either checkbox 2(fieldset B) is clicked or checkbox 3(fieldset C) is clicked. but fieldset one holds the checkbox field and i have it set up as a #tree

$form['Contract'] = array(
 '#theme' => 'form_panel_table',
 '#tree' => TRUE,
 '#title' => t('General Information'),
 '#collapsible' => TRUE, // Added
 '#collapsed' => FALSE,  // Added
);
$form['Contract']['first'] = array(
 '#type' => 'checkboxes',
 '#title' => t('Products applying for:'),
 '#options' => array("Product B", "Product C"),
 '#required' => TRUE, // Added
 );

//if statement should hide this part of form unless checkbox above is clicked
    /* second fieldset starts here for product B */

    $form['Contract']['product B'] = array(
     '#theme' => 'form_panel_table',
     '#type' => 'fieldset',
     '#tree' => TRUE,
     '#title' => t('product b'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE
    );
    $form['Contract']['product B']['first'] = array(
     '#type' => 'textfield',
     '#title' => t('Zip/Postal Code'),
     '#size' => 30,
     '#maxlength' => 6,
    );

//one more else if statement for last fieldset should be here?
    /* End of product B. Begin product C */

$form['Contract']['product C'] = array(
 '#type' => 'fieldset',
 '#tree' => TRUE,
 '#theme' => 'form_panel_table',
 '#title' => t('example'),
 '#collapsible' => TRUE,
 '#collapsed' => TRUE
);
$form['Contract']['product C']['first'] = array(
 '#title' => t('example'),
 '#rows' => 39,

using php how would i write the if else statement in my custom form(tried it my way didnt show up on my site) in a druapl way?


texts: How to add link around each rows in views?

texts:
I have article' views with fields like this:

Content Image

Content Date

Content Title

Link to content

I can access to article by my link but I want to render clickable all of row to link .

This is my views-view-unformatted.html.twig file:

{% if title %}

{{ title }}

{% endif %}

{% for row in rows %}
 {%
   set row_classes = [
    default_row_class ? 'views-row',
  ]
 %}

   {{ row.content }}

{% endfor %}

and I think I want this:

{% if title %}

{{ title }}

{% endif %}

{% for row in rows %}
 {%
   set row_classes = [
    default_row_class ? 'views-row',
  ]
 %}

 <a href="path to node"

   {{ row.content }}

{% endfor %}

But I don't know how it's possible. Any known workarounds?


texts: Remove status messages from content output?

texts:
I want to move status messages into a region, but I can't seem to get it to stop being output as part of the main content output.

I tried this:

function mytheme_preprocess_region(&$variables) {
  if ($variables['region'] == 'content' && isset($variables['elements']['messages'])) {
    unset($variables['elements']['messages']);
    //$variables['elements']['messages']['#printed'] = FALSE;
  }
}

While that removed it from the array, it is still being rendered.


texts:
Is there a way to add a dynamic URL token to images so that the move from local host to live doesn't require code change?

When uploading images in content, the path changes form localhost to live, how can I have it consistent so the database can be exported without changes?

I would like to leave out the name of the site in the path


texts:
I have declared two items in my hook menu.

//Calls a function that enables inputting/updating data of a particular template.
$items['user/%user/myid_inputting'] = array(
    'title' => 'MyID Inputting',
    'description' => 'Inputting data for a particular data',
    'page callback' => 'myid_inputting',
    'page arguments' => array(1),
    'access arguments' => array('perform_regular_task'),
    'file' => 'includes/myid_inputting.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -20,
);

//Calls a function that enables ID printing
$items['user/%user/myid_printing'] = array(
    'title' => 'MyID Printing',
    'page callback' => 'myid_printing',
    'page arguments' => array(1),
    'access arguments' => array('perform_regular_task'),
    'file' => 'includes/myid_printing.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => -19,
);

I had used two separate files for the two items. Is that best practice in Drupal?
I just notice some functions that I used are redundant when separating the code between the two. What are advantages and disadvantages of doing so?


texts: Adding a custom js file to a core theme like Seven

texts:
I've copied over the Seven theme to my /theme folder on Drupal 8 and I'm trying to customize it by adding in my own js file called custom.js. I added it to the seven.libraries.yml file as shown below, but I don't see it loading up on any of the pages. I even did clear the cache. Nothing shows up. I did add a custom.css file and that is showing. What could be wrong or that I'm missing?

global-styling:
  version: VERSION
  js:
    custom.js: {}
  css:
    base:
      css/base/elements.css: {}
      css/base/typography.css: {}
      css/base/print.css: {}
    component:
      css/components/admin-list.css: {}
      css/components/content-header.css: {}
      css/components/breadcrumb.css: {}
      css/components/buttons.css: {}


texts: Adding a field without the field_ prefix (Drupal 7)

texts:
I am using the organic groups module which adds a field with machine name: group_audience to the user entity which can be seen at:

/config/people/accounts/fields

Somehow after install some other modules, this field disappeared.  I would like to add it back the field's machine name was simply group_audience instead of field_group_audience.

When I try and create a new field with the Drupal 7 interface builder it always prepends field_ to any field that is create.  How can I create a field that does not have the field_ prefix?


texts: How to change the html of threaded comments?

texts:
I want to display the comments on a node in a thread.

Not sure if I should use views or a template.
I want to change the html so that it matches boostrap markup
By using comment-wrapper.tpl I can change some of the html,
but I cant change the indent class.


texts:
I have a visibility problem.
I have a taxonomy/term page managed with panels. There are 2 panel pane who display 2 views.
The problem is that I [the admin..] can see the page correctly but all the other users see nothing except a block I putted on top of panel pane for test.

I read the markup and I can see the panel but not the panel panes. This panel panes have no visibility rule and the views inside it have the default Access rule.

How can I find where is the issue?
Why only the user 'admin' can see this pages?


texts: How to add an additional wrapper div within a Views row?

texts:
I have a Views page with a format of ‘unformatted list’. For a views row I’d like to add an additional div to act as an additional wrapper. The resulting mark-up would then look like

I’ve looked in the various views template files located in the views module folder within the view module but am not seeing a place to add such a div.

Does anyone know how this can be achieved?

I guess I could use an HTML list and make that work but I’d prefer what i just described above.


texts:
I have a  classic contact form. I can add for example some custom placeholder like this :

function my_theme_form_contact_message_about_your_project_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    // placeholder
    $form['field_contact_name']['widget'][0]['value']['#placeholder'] = t('Saisir votre nom');

}

It works very well and I can also easily modify wrapper, name, etc.

But for a reason I can’t understand, I am not able to modify the text of the submit button.

Here is what I’ve tried among a lot of things and I think it should be the right thing (as seen on other answers) :

$form['actions']['submit']['#value'] = 'hello world!';

Here is the html of the button :

<button data-drupal-selector="edit-submit" class="button button--primary js-form-submit form-submit btn-primary btn" type="submit" id="edit-submit" name="op" value="Envoyer">Envoyer</button>

I use a custom theme based on Bootstrap theme.

Of course, I can do it with jQuery :

$('#edit-submit').text('lorem ipsum');

But I would like to know how to do it the Drupal way.

EDIT :

The solution is :

form['actions']['submit']['#value'] = 'hello world!';

It works on a clean Drupal install but not on the website I am currently working on.


texts: How can I call node id in template file?

texts:
Using Drupal 7.

I have a page--front.tpl.php template file. And I want import a node in this file.

How can I do it?


texts: How can I obtain the "latest" vid when on Revisioning's "View latest" tab?

texts:
I am using the Revisioning module to handle content revisions and I am creating a custom block that needs the vid of the node that the user is viewing to generate the appropriate content. I was trying to use menu_get_object() to obtain this and it works fine for a node with no revisions.

When I have a pending revision in Draft that I am looking at via the "View latest" tab, the node->vid I obtain from menu_get_object() is the vid of the "current" version, not the "latest". What would be the best way for me to obtain the vid of the version that is actually being displayed to the user?


texts: How to configure a Slideshow with thumbnails in modal window

texts:
I have tried to get the following scenario to work, with no success.
I have 3 images. They are displayed in thumbnail form, in the bottom of a div. A main, preferred image, is displayed in a larger size above the thumbnails.
I need that, when clicking on the thumbnail, the main image will change. So, in the image included, if I click on the green image, the main image will change from red to green.

Also I need that when clicking on the larger image, a modal window will appear, with a Slideshow of all the images, starting from the one clicked.

I have managed to make it work very easily with PHP-Javascript alone (10 minutes of programming) but I am not able to do it with none of the following modules: Colorbox, FlexSlider, Lightbox2.

Even when launching a View with FlexSlider content using Lightbox2, it works but it takes ages to load the content, even if I have disabled all extra HTML stuff by making a template tpl suggestion.

Sincerely, I don't think it is so complicated behaviour. Also there is the approach of FlexSlider with thumbnails, but I cannot manage to include the lightbox (modal window) effect.


texts: How to check if search_index's solr is running?

texts:
To prevent fatal errors, I need to check if solr is running.

Given:

$solrIndex = \Drupal::entityTypeManager()
  ->getStorage('search_api_index')
  ->load('global');

How do I check if the solr server that $solrIndex is pointing to is online?

There is an ->isAvailable() method on the server object when you call the $index's ->getServerInstance() method, but it returns a false positive when the solr server is stopped:

I'm surprised I can't check it from the server object, but this returns a false positive when solr is stopped:

$false_positive = $solrIndex->getServerInstance()->isAvailable();


texts: Query and load entity by Entity Type Manager

texts:
Currently I am firstly "searching" for an taxonomy term entity with the Entity Query in Drupal 8:

$termIds = \Drupal::entityQuery('taxonomy_term')
  ->condition('field_code', $code)
  ->condition('vid', 'computer')
  ->execute();

And then I am loading the taxonomy term entity:

      $termId = current($termIds);
      $term = \Drupal::entityTypeManager()
        ->getStorage('taxonomy_term')
        ->load($termId);

Is there a way to do it in 1 step, instead of these two?


texts: Checkbox left hand navigation drill down

texts:
Does anyone have an idea on how I can go about creating this navigation? I have a section of a website that has subwords of a top vocabulary word that I would like to show in a left hand menu in order to drill down to the content with checkboxes.

[]Topic 1 ---> if checked show excerpts of all articles with this topic in the content area.
[]Topic 2 ---> if checked show these articles...

[]etc...

The user could check 1 or all of the topics and get the articles.

Sort of like: https://wordpress.stackexchange.com/questions/18484/checkboxes-in-the-category-list

Thanks for any direction, help or the like!


texts:
How can you create a successive batch job in the Batch API?

For example, if I wanted to queue and assemble 1000 nodes as a batch, then process them in a second batch when the first batch is done, automatically? Do I just call the second batch job in the finished callback? Can it be passed arguments?


texts: I have been working on a D8 project and been wondering what the best course of action would be in order to produce a complete project package that can be easily set up in a new drupal installation. The theme part is pretty straightforward but what about all the specific content types that accompany a project with a specific theme? Is there a way I can have those being created on theme installation?


texts: Trouble with implementing contextual links

texts:
I have a block with dynamic content and two contextual links.

I have at the moment two problems:

The second element is not visible.
The first link does not allow to pass a date. I have to set a prefix e.g. "_"

How can I fix this problems?

Here is the main part of my module:

define('MY_DIR', 'somedir');

function mymodule_menu() {
    $items[MY_DIR] = array(
        'page callback' => 'status_page',
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
    );
$items[MY_DIR.'/%'] = array(
    'page callback' => 'status_page',
    'access callback' => TRUE,
);
    $items[MY_DIR.'/edit'] = array(
        'title' => 'Edit item',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('mymodule_object_edit_form', 2),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );
    $items[MY_DIR.'/%date/update'] = array(
        'title' => 'Edit date',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('mymodule_object_edit_form', 2),
        'access callback' => TRUE,
        'type' => MENU_LOCAL_TASK,
        'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    );

    return $items;
}

And here is my status page:

function status_page($date=null) {
    $object=new stdClass();
    $build=array();

    if(empty($date)) {
        $day=get_next_match();
    } else {
        // parse data
    }

    // set title
    $title="Title for ".$day->format("j.m.Y");
    drupal_set_title($title);

    $object->title = $title;
    $object->content = "Some dynamic content";

    $build[0] = array(
        '#theme' => 'filteredusers_object',
        '#object' => $object,
        '#contextual_links' => array(
            // contextual link 1
            'update-option' => array(
                MY_DIR,
                array("_$date"),
            ),
            // contextual link 2
            'edit.option' => array(
                MY_DIR.'/edit',
                array(),
            ),
        ),
    );
    return $build;
}

If something is unclear feel free to ask.


texts: Only show block if View or nid has certain term referenced to it

texts:
I have a tricky one here and looking for some suggestions.

I have a Page view which uses a contextual filter on the nid (which is in the URL).

These nodes have a term reference field which contain various terms.

I have a block which I only want to be displayed on this page if the node has this specific term referenced to it. Bare-in-mind this is not the actual node page, this a dynamically created page/view based on the nid in the url.


texts: How to access Machine name fields in PHP?

texts:
If I go to admin/config/people/accounts/fields I can see a lot of fields being mapped for LDAP on my server.

For example - for first name there is a machine name "field_fname".

How can I access this on my webform using PHP?

Like I want to display something like this on my webform through PHP:

  "Hello first_name last_name, how are you ?"


texts:
Can't figure out how to construct a query to obtain a sum of a field programmatically. The folowing code works fine for counts:

$count = Drupal::entityQuery('node')
  ->condition('type', 'artefacts')
  ->condition('status', '1')
  ->condition('default_langcode', 1)
  ->condition('field_city', $id)
  ->count()
  ->execute();

but no matter how I try I can't figure out how to obtain the sum. There is a lot of examples for Drupal 7 but can't find a single one for Drupal 8.

$sum = Drupal::entityQuery('node')
  ->condition('type', 'cities')
  ->condition('status', '1')
  ->condition('default_langcode', 1)
  ->condition('field_country', $id)
  ->aggregate('sum(field_artefact_count)', 'total')
  ->execute();

seems to return '1' in any circumstances. The documentation on Query class is terse to put it mildly. Apparently execute() is supposed to return an array of entity id's but what's the entity id of a single total of a table of a 1000 records?


texts: Can't get the authenticated user cookie session to be used when creating a new node via Services 3 endpoint

texts:
My application is sending this header to Service 3 endpoint when creating a new node:

{
  'Cookie': 'SESS255f42d9a87a0df5bf8959d25909fe8c=St8o29NI9Hx84kPo8NuZbpdHWuRgNSS9qy9cQ-QM4rA; expires=Sun, 15-Jun-2014 00:39:27 GMT; path=/; domain=.mydomain.local; HttpOnly',
  'Content-type': 'application/json'
}

Nonetheless, the newly created node user is set to anonymous.

Is there anything wrong with the header I am sending?


texts:
In my theme I'm already using the hook_form_alter to customize the form fields but now I want to customize the validation error messages.

After some research, the only way I'm finding is to write a whole separate function and custom error handling of each form field.

I don't want to reinvent the wheel.  Isn't there just a simple way to change the default form validation error so I can get away from "XYZ field is required?"


texts: Send newsletter action - after saving simplenews node

texts:
I would like to do the same thing that described here: http://drupal.org/node/1427246

So, I use drupal 7, simplenews, schedule, and import modules.

I want to import my simplenews nodes, and they have scheduled date and time to publish...

But the problem for me is there is no way to set "send newsletter" status for the newsletter nodes automatically. I should click on each and every node to approve it to send.

On the link above there is a solution:

  "Create a rule that is triggered when a node is inserted (update makes
  no sense as you can't resend a newsletter, add a condition on the node
  content type and then execute the Send newsletter action."

My question: how can I activate the "Send newsletter action". It is not appear on the list of available actions.


texts: hook_query_alter, AJAX, views_get_view : have to submit twice

texts:
A view is embedded in a page template via this code. It's AJAX enabled and uses exposed filters which I have to mess around with for business purposes :

$view = views_get_view('rechercher', $reset);
$view->set_display('default');
$view->set_use_ajax(TRUE);

$set_exposed_input  = array();
if (isset($_GET['commune'])) {
  $set_exposed_input['field_commune_value'] = filter_xss($_GET['commune']);
}
if (arg(1) == 646 && ! isset($_GET['raz'])) {
  $set_exposed_input['field_type_vente_value'] = 'LOCA';
} elseif (arg(1) == 645 &&  ! isset($_GET['raz'])) {
  $set_exposed_input['field_type_vente_value'] = 'VENT';
}
if ($set_exposed_input) {
  $view->set_exposed_input($set_exposed_input);
}
$view->execute();
print $view->render();

It works perfectly.

Now the query must be altered via hook_query_alter :

function my_module_views_query_alter(&$view, &$query) {

  // Unrelevant stuff here

  if ($view->name == 'rechercher') {
    $view->query->add_table('field_data_field_cp');
    $view->query->add_where(1, 'field_data_field_cp.field_cp_value', '%' . $_SESSION['filtres']['field_commune_value'] . '%', 'LIKE');
  }

As soon as I uncomment this code, I have to submit the view twice to have the results refreshed.

Except for this, the view behaves as expected (query returns the right data, etc.).

I guess it's some kind of cache and/or form caching issue but can't figure what exactly.

Any help would be appreciated.

EDIT : Some more details

Please forget AJAX : it has nothing to do with it, as the behaviour is exactly the same without it.

One more info : the query is correctly altered on the first filters form submission. Dumping proves it.

So it boils down to something that happens AFTER query altering. The mistery remains as to what and when.


texts: A view only shows if a certain filter criteria does not exist?

texts: I have a view that I am using to list events, specifically "today's events." I used a filter criteria to allow me to only display events that were happening "today" (as asked by an earlier question. I have recently realized that there will not necessarily be an event "Today", and if there isn't, I have a problem, because nothing is displaying. what I want is to have either a separate view (or do it in the current view if it is possible) that only displays if there are no events "today" what I want it to display instead is "upcoming events." that way, if there are no events on the day that you are looking at the site, than ou will see future events instead.


texts: Why are comments not a node content type?

texts:
So Drupal has a 'special' commenting system.

  Comments are second-class citizens in Drupal compared to nodes...

But why did the core team not just create a default Content Type, Block and View for comments, and allow the site administrator add in a comment block as necessary? Just like the 'Article' and 'Basic Page' content types, which we can create blocks and views for. Why are comments so different?


texts: Move label to RIGHT of checkbox in Webforms

texts:
When setting the label to "inline", Webforms will place the label to the left of my checkbox. Is there any way I can move it to the right?

Here's what it looks like right now, I want the label to be to the RIGHT of the box.

thanks


texts: How to display referenced field data in view?

texts:
I have two content types named as "abc" and "xyz" respectively.

"xyz" content type having field called "field_abc".
Its a referenced field to "abc" content type.

I create a view by taking "abc" contents.
Is it possible to show the title of "xyz" in which "abc" taken as referenced field?

I think the reverse may works. Means if I create a view by taking "xyz" contents. But i need to know if I create a view by taking "abc" contents. It will work on not?


texts: How do I enable rich text editing on all my long text fields?

texts: I have a node with 3 long text fields and I want to make rich text editing available on them all. So far all my experiments with Wysiwyg have only resulted in one of the long text fields getting an editor. So what editor/configuration will give me rich text editors on them all?


texts: Adding tokens to autoreply message of contact form in Drupal 7

texts:
I would like to switch on the core's contact form category function and ad some extra category to my contact form but I was wondering that in auto reply I can't use tokens or acess the field values like sender's name wich would be very great!
For solving this issue I don't like to use webform module becouse I would like to keep things as simple as I can.
Is it possible to send html mail from here somehow?
I think a module must be exists for solving this but I can not find.
I would be appreciate any good idea.

Thanks
Adam


texts: how to get translated content in twig [views.view.unformatted]?

texts:
I am trying to get translated node title in my custom views-view-unformatted twig file.
Here is the way I am retrieving my node title in twig file

    {% for row in rows %}
   {{ row.content['#row']._entity.title[0].value }}
    {% endfor %}

By the above code I can only retrieve the English node title but translations aren't there even though my query selecting based on Interface text language selected for page


texts: Unwanted data show after add password-comfirm

texts:
In my form I would like to add comfirm password field, the pic below show is before adding comfirm field, there is no data in waiter name field, after adding comfirm-password field there are data in waiter name field and password field, where do they come from. Anyone could please to help me to solve this problem.

function waiter_form($form, &$form_state= NULL) {

$form['waiter_name'] = array(
'#type' => 'textfield',
'#title' => t('Waiter Name'),
'#maxlength' => 70,
'#description' => t("You Need To Add Waiter Name. "),
'#required' => 'true'
);

$form['pass_fields'] = array(
  '#type' => 'password_confirm',
  '#description' => t('Enter the same password in both fields'),
);

$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);

return $form;
}

Screen shot of before adding confirm password field

Screen shot of after adding comfirm password field


texts:
I need to change the BasePath in drupal 8 of all views and all node in such a way that it contains a variable (which will manage as country)
Like this:

site.locl/{lang}/{variable}
site.locl/en/testvar/node/100
site.locl/en/testvar/myview