texts: Remove wrapping div from field type radios (Drupal 7)

texts:
I am trying my hand at theming form output and am stuck on radios. I am attempting to remove the div that wraps a set of radios,

div.form-item > div.form-radios > div.form-type-radio > input[type="radio"]+label
                ^^^^^^^^^^^^^^^ <- Remove that

I have a sample form:

function no_name_form($form, &$form_submit) {
    $form['radios'] = array(
        '#type'    => 'radios',
        '#title'   =>'Question text',
        '#options' => array(
            '1' => t('yes'),
            '0' => t('no')
        ),
        '#theme'   => 'no_name_radios',
    );
    return $form;
}

and I register the theme functions for both the radios group and individual radio buttons:

function no_name_theme($existing, $type, $theme, $path) {
    return array(
        'no_name_radios' => array(
            'arguments' => array('element' => NULL),
        ),
        'no_name_radio' => array(
            'arguments' => array('element' => NULL),
        ),
    );
}

Then I define the theme functions:

function theme_no_name_radios($variables) {
    $element = $variables['element'];
    $attributes = array();
    if (isset($element['#id'])) {
        $attributes['id'] = $element['#id'];
    }
    $attributes['class'] = 'form-radios test';
    if (!empty($element['#attributes']['class'])) {
        $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
    }
    if (isset($element['#attributes']['title'])) {
        $attributes['title'] = $element['#attributes']['title'];
    }
    return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
}

function theme_no_name_radio($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-radio'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}

When I use even the stock code from Drupal 7 to build the theme functions, the radios come out blank, and at this point none of the code has changed.

Ultimately, I want to end up with this:

div.form-item div.form-type-radio > input[type="radio"]+label

I am not sure where I went wrong.


texts:
I did a fresh Drupal(v7.39) installation on Nginx server. Everything seem fine until the WordPress Migration process with "Migrate", "WordPress Migrate", and "Migrate Extras" modules. The error message I got is
 An AJAX HTTP error occurred. HTTP Result Code: 502 Debugging information follows. Path: /batch?id=83&op=do StatusText: Bad Gateway ResponseText: 502 Bad Gateway 502 Bad Gateway nginx.

Even I got an error, all the content did migrate correctly except the url alias. The URL was set for "Set path aliases to their original WordPress values" during the process, but they came out like node/101, node/103....

What may causing the error and how can I fix this?


texts:
This may be a trivial question, but I haven't been able to find a clear answer how to do this in Drupal 8.

How can I organize nodes in a hierarchy like this?

Node
- child
- child
- - child
- child
Node
- child

I know about Node Hierarchy and several other modules which seem to offer this functionality, but I haven't found anything for D8.

It would also be good if this would work in a way allowing for listing chilren of a given node (like "In this section:", followed by a listing of child nodes.

Still, this seems like such a must-have ability to me, it's possible that Drupal can do it out of the box and I just don't know about it. Am I missing something?


texts: Simple debug results in internal server error

texts:
All I want to do is print a view out so I can check the variables and see the structure of what's being created but it results in an internal server error.

I'm using Acquia Dev Desktop. I've checked the .htaccess file and it has the rewritebase uncommented. I've tried updating max_execution_time, and memory_limit. Nothing helps.

I have Drupal 8 installed fine and haven't had any issues except when trying to inspect variables.

BTW here is my function in theme file:

function theme_preprocess_views_view(&$variables) {
  $view = $variables['view'];
  print_r($view);
}

What am I doing wrong?


texts: Server side Drupal install as git local repo

texts:
I have a Drupal install on a shared server and would like to do some version control on it, namely git.

I'm a beginner at Drupal and only just starting with git so I've become a bit overwhelmed with any instructions on the web for doing this, as they assume you're proficient with one or the other.

What I want my setup to be is

The hosted Drupal install is my git's "local" repo.
Make changes, commit
Push to github

The problem is that as it is a shared server, I don't think I can install git. So, firstly, is this workflow possible without installing git on the server? And, if so, secondly, could somebody please point me in the right direction for setting this up.

As always, if somebody has a better way of doing it, please say!


texts: Omit the Front Page when Using Contextual Filters?

texts:
Content on my site is set up via taxonomy term, and I've created a view using contextual filters which does a fabulous job of sorting all the content to the appropriate page.

However, on the front page we want to present that content differently, so I have created a block which presents anything marked "front" to appear inside it.

The two are mutually exclusive, as I have filtered the data so that ONLY front page stuff appears in the block, and NO front page items appear in the page view.

This is problematic, however, as some of these highlighted items should appear on other pages in the Web site.  Removing the 'exclude home' filter from the page view, however, makes the page view of items marked "front" appear beneath the block, which we don't want.

In order to get the content on the home page AND elsewhere content owners are required to enter the data twice -- unless I can get this fixed.

Any ideas?

Thanks!


texts: Why does "Barrio" subtheme already include some templates?

texts:
I'm creating a subtheme for Barrio, based on the subtheme included in the Barrio theme folder.
It has already a template folder with some templates in it but, in my experience with other base themes, subthemes don't come with any template override, since the point is that you override only those that need to be changed.

Inside "templates" subtheme folder, there is a "ds" (display suite?) folder with 6 templates that actually are identical with the ones in the base theme. And there's also a _page.html.twig themplate that has some differences with the base theme page.html.twig, but that is not being used because of the underscore.

So what's the point of overriding templates with identical ones? And why is the page template included and not being used?


texts:
Setup: I have two contextual filters, service area and ID.
In my view if I send {service_area}/{id} i get back the OR query, which is what I want. My question is, when I try to use Jquery to return this query, I do not get back the expected result, which is the OR of these two arguments.
Here is my code:
(function($) {
  Drupal.behaviors.searchresults = {
    attach: function (context, settings) {
      $('.currentFilters', context).once('search').click(function () {

        //hard set variable for this example.
        let args = [];
        args[0] = 'antelope valley';
        args[1] = '221';

        $.ajax({
          url: '/views/ajax',
          type: 'post',
          data: {
            view_name: 'webform_submissions',
            view_display_id: 'page_1',

            //This is where it may be causing an issue. I pass an array with the arguments, but no avail
            view_args: args,
          },
          ...
        });
      });
    },
  }
})(jQuery);

In my view I am able to see this OR if I preview with contextual filters as as seen in the image below:

If I just send service_area by itself as the argument, it will work. So my question is, what is the correct way of sending multiple arguments in ajax, any references/blogs to help me would be appreciated. Thank you!


texts: I am using drupal commerce for e-commerce site. When node(product) is created SKU id of the product must be node id. How can I achieve it. Thank You.


texts: Hide the header of a view block when there is no content

texts:
On a page, a views block should show some text on top of the view when the block doesn't hide and there is content to show:
Title •
.
Now, when there is no content in the block, this text should be hidden.
I've tried to do this with putting the header in the view as 'unfiltered text' in 'header' and then setting the view to hide when there's no content. This doesn't work or could it be that I'm doing something wrong?

Update, I got it to work, and think the following is happening:
It is possible to just put this text in the header of the view as 'unfiltered text' in 'header' and it will hide when there are no results.
However, when the view is based on a taxonomy relationship as it was with mine, and 'require this relationship' is not set, there will always be a result, so the header will show eventhough those results are filtered away.


texts: How to clear search API textfield after each search

texts:
I am using Drupal 8 with the Search API module. Everything works as expected but the search terms remains in the search textfield after every search. This makes using the search function a bad user experience since the user needs to clear the text before entering their new terms.

I would like to the search textfield clear itself after every search but haven't figured out a way to do so. So far I have tried using hook_form_alter but can't seem to alter the input. Here is my code:

function mytheme_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    if ($form['#id'] == 'views-exposed-form-search-content-page-1') {
      $form['keys']['#default_value'] = '';
      // $form['keys']['#value'] = ''; also tried this but it didn't work
    }
  }
}

Clearing the default value didn't work. I also tried setting the value to an empty string as well but that totally killed search from working altogether. I feel that I am overlooking something really simple. Any suggestions?


texts: How to display custom token in custom block

texts:
In a Drupal 8 website I created a custom token that is working in basic page.

Then I created a custom block with a WYSIWYG field :

class Myblock extends BlockBase {

  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  public function getMachineName() {
    return 'my_custom_blcok';
  }

  public function label() {
    return $this->t('Block label');
  }

  public function blockForm($form, FormStateInterface $form_state) {
    $form = parent::blockForm($form, $form_state);
    $config = $this->getConfiguration();

    $form['my_field'] = [
      '#type' => 'text_format',
      '#format' => 'content_manager',
      '#title' => $this->t('Field name'),
      '#default_value' => isset($config['my_field']['value']) ? $config['my_field']['value'] : '',
    ];

    return $form;
  }

  public function blockSubmit($form, FormStateInterface $form_state) {
    $this->setConfigurationValue('my_field', $form_state->getValue('my_field'));
  }

  public function build() {
    $config = $this->getConfiguration();
    $content = $config['my_field']['value'];

    return [
        '#theme' => 'simulator_block',
        '#content' => $content,
      ];
  }
}

If I type My content [module:my_token] in the WYSIWYG.

The following content is display :

My content [module:my_token]

How can I replace the token ?


texts: Is there a clean, "hands-free" way to have a ticker full of logotypes desaturated in normal view, but colored on hover? Or should I prepare CSS sprites by myself and go the "dirty" way?


texts: Disable reaching a node by its internal path

texts:
I want a node to be reached only by its alias but not its internal path. The reason behind this is that I will create a node type, allow anon users to create such nodes, but the alias will contain a random text, so that only the user with the actual url information can revisit this page. Example:
www.example.com/node/9 -> only accessible by admin
www.example.com/34h356hrgc35yh4geg -> only accessible to anon users with this information.

If an anon user tries www.example.com/node/9, they should see Forbidden error or Not Found.


texts: How can I programmatically place blocks?

texts:
I'm migrating a Drupal 7 site to Drupal 8.

The old site uses $ drush block_configure (available in Drush extras) to put blocks in regions while deploying, as well as $ drush block-disable to remove unwanted blocks. Unfortunately, Drush extras is no longer available for Drush 8, which seems to be the first version supporting Drupal 8.

The site will be deployed multiple times by multiple people, so adjusting region settings manually in admin view is not a solution. Everything needs to be done in an Ansible playbook so it can be passed on easily.

It seems that configuration management can be used to move blocks, but this would require all the environments to have up-to-date copies of a master database. While this is not impossible, it does feel like a hassle and a possible security risk. The developers don't really need to have all production data in their dev environments, and I wouldn't want to put production data on servers using developmental (and possibly vulnerable) code.

Twig Tweak seems to have an option to render a block anywhere regardless of regions. However, if I hardcode all blocks on templates, admins can no longer use admin block management.

Would it be possible to write a custom module and use block alter functions to set regions on blocks created by core modules? Are there any examples of this?

Are there more ways I'm not aware of? What is the best practice?


texts: How to get the string value from the function CountryManager::getStandardList()?

texts:
Input :

 $li = array();
    $list = \Drupal\Core\Locale\CountryManager::getStandardList();
    foreach($list as $key => $value){
        $li[$key] = $value;
    }
    // print_r($li);

Output :

[AF] => Drupal\Core\StringTranslation\TranslatableMarkup Object
        (
            [string:protected] => Afghanistan
            [translatedMarkup:protected] => Afghanistan
            [options:protected] => Array
                (
                )

How can I fetch String value from the above structure?


texts:
I need to import a Simple Machine Forum 2.0.3 into Drupal Forum, and my client need to have the possibility to moderate section in the new forum. He want to assign 1+ moderator for section.

Is this possibile in drupal forum (with some modules) ?

Thanks.

M.


texts: Can you hide date field when its date matches with the sites date?

texts:
I have a date field in my site and I want it to hide/be invisible when the date I have set is now or matches the sites date.
I hope there is a way to do this using Rules.


texts: selecting a referenced node from 1000's of nodes

texts:
I've a cck field "address" of node type Address within Building node type.
My site may have tons of such addresses. So let me assume that already 10000 nodes of type Address exist and then one visitor tries to create a node of Building.

In the node reference field of address how'd one be able to select the correct address from 10000 addresses from "auto complete text field" address field?

As far as I know auto complete address would show only the node titles and  many addresses can have same titles so how one would be able to select a particular address in the address auto complete text field ?


texts: Problems rendering radio buttons after an ajax call

texts:
I'm going to be linking this D.O issue.

I found that when changing an attribute other radio buttons would not update properly. Specifically that when there was two possible options for these buttons but each were only available if another option in the form was set, changing the first attribute resulted in the second one not being rendered as checked. If you went to add that item to the cart the proper variation would be added so this  seems to be just visual.

I was able to use xdebug to find that the default value of the buttons is set correctly.
I've been digging through the rendering trace of this element but am getting quite lost.

Does anyone know why after an ajax call a radio button would be rendered incorrectly and not be marked as checked?


texts: Dynamically Caclulated Values with Entity Field Query

texts:
Is there any way to query by dynamically calculated values using Entity Field Query? Take the following:

I want to query where the sum of field_some_number and a user-provided variable are greater than or equal to 5. Right now I'm only able to do the following:

$my_variable = -7;
$query->fieldCondition('field_some_number', 'value', 5, '>=');

But obviously this doesn't include my user-provided variable. How can I calculate this on the fly? Could hook-query-alter help me with this? I have not been able to figure out how to properly implement it. I'm using this with the Restful-Drupal module.


texts: Redirect user page to user/edit and user/login

texts:
I want to do page redirect when user access /user page. When user anonymous user access the /user it should redirect to user/login page and when logged in user access the /user page it should redirect to user/%/edit page.

I have tried the following the code

function my_user_menu_alter(&$items){
   $items['user']['page callback'] = 'my_user_page_redirect';
}
function my_user_page_redirect() {
  global $user;
  if (user_is_logged_in()) {
  drupal_goto('user/'.$user->uid.'/edit');
}
 else {
   drupal_goto('user/login');
 }

}

For logged in user it redirects to user/%/edit page. For anonymous user it displays webpage redirect error

How can I do this. Thank You


texts: Use Tokens to get the title of a node a form was submitted from

texts:
I have a bunch of nodes that contain forms on them that when submitted will create further nodes of another content type.

Using Token fields is it possible to have a field on the newly created nodes that will display the node title of the page that the node was created on (e.g its parent node)?

Another option is to do this, lets say I have a page called Foo, on the page "Foo" I use a form to create page "Bar" I want the url of page "Bar" to be something like www.drupal.com/Foo/Bar.

Is this possible?

Thanks


texts: How to rearrange the user registration form fields

texts: I want to Rearrange and Rename the default fields with added fields on user registration form in drupal7 site, I could rearrange only the fields which is added by me but i want to rearrange combining both the default and added one. can anyone help on this.!


texts: Allow user to fill out node form, then force registration

texts:
I'm making a classified website.

Have a button that say "Make a ad"
I would like the Anonymous  user to be able to
fill in the text for the ad.

But the  Anonymous users after filling in advert.
has to sign up for the ad to be posted

How can  do this with drupal please?

many thanks for your help

Best Regards
Charles


texts: How do I send data using JSON as output format?

texts:
There are separate web forms created on the basis of the Webform module (Drupal 7), sending by default goes to the required e-mail. Everything is within the module.

In addition, there was a need to send the data of the webform application (field) to various CRM (custom) based on JSON.

Request format

{
    "aCode": "zzz",
    "importdata": {
        "id": "zzz",
        "user_data": {
            "name": "zzz",
        },
        "contact": {
            "phone": "zzz",
        }
    }
}

How do I properly implement this functionality?

Process:

External url for accepting JSON lead requests (example): http://example-server.com:8083/api/submit

After the webform has been filled in, it is necessary to automatically send the field data in the raw postdata format to the external CRM with the JSON request format specified above in the code.


texts: How do I hide "View most recent blog entries"

texts:
If you enable the contributed Blog module, a link with the anchor text "View most recent blog entries" shows up on every post.  I want to hide this link using PHP (i.e. not resorting to css or javascript).

So far I've tried this in hook_node_links_alter():

unset($links['usernames_blog']['#links']['blog_usernames_blog']);

It doesn't work. I don't think the offending link is in the links array, but somewhere else (I've yet to figure out where).


texts: Webform data tables name change d7 to d8 tables to delete records from

texts:
I have converted my d7 webforms to d8 with custom modules ... looks great
Previously I pulled data down from the database daily and deleted records from the webform_submissions and webform_submitted_data tables. (worked flawlessly for years)
With d8 the names are webform_submission and webform_submission_data.
Does anyone know if deleting the records from these two tables affects any other tables?  I intend to do as before... read daily, delete daily.
Thank you


texts: Custom migration: Getting error SQLSTATE[42S02]

texts:
I'm quite new to Drupal and tried my first Migration from Drupal 6 to Drupal 8. I didn't want to migrate the entire page but only some nodes.
So i got a tutorial and wrote a custom migration module (with dependencies of Migrate Plus and Migrate Drupal) with the following files in it:

one migration-group.yml
two .yml with the field mapping definitions for my entities
an .info.yml for my module

When I do a migration-status with drush, i can see my two migration entities. But when I try to migrate-import one of them, I get the following error:
 SQLSTATE[42S02]: Base table or view not found
But actually the table is right there in the db.

I executed the following drush commands:

vendor/bin/drush ms --uri=mydrupal8-site.test

The result is:
So everything's fine.

Then i run the command:

vendor/bin/drush migrate:import external_page_01 --uri=mydrupal8-site.test

...and i get the error.
I have to use the --uri-param because i have a multisite-installation.
I have put the legacy-Database connection into my settings.php-file, like so:

    'database' => 'd8',
    'username' => 'root',
    'password' => '',
    'prefix' => '',
    'host' => 'localhost',
    'port' => '3306',
    'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
    'driver' => 'mysql',
);
$databases['legacy']['default'] = array (
    'database' => 'd6',
    'username' => 'root',
    'password' => '',
    'prefix' => '',
    'host' => 'localhost',
    'port' => '3306',
    'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
    'driver' => 'mysql',
);

I read a post according to this topic which unfortunately refers to a D6 to D7 migration, so those anwers don't work for me.

Does anybody know how to solve this for D8?

Thanks and best regards
Rebekka


texts: How do I add a color hex code field to a product attribute using drupal commerce 2?

texts:
How to add a color hex code field to a product attribute using drupal commerce 2

I can add the form field but do not know how to create the field type: color or the corresponding hex code.

Thanks


texts: Contextual filters with multiple taxonomy vocabularies

texts:
I have vocabulary "City":

New York
London

and vocabulary "Places" i.e.:

restaurants
cafes

The menu link is, e.g. mysite.com/london.

When a user click on a tag, e.g. cafes, I want the term city term to stay them same
in the url mysite.com/london, but to add the places term on the end, e.g.: mysite.com/london/cafes in London, so that it only shows cafes. I.e. not mysite.com/cafes, which will show cafes anywhere in the world.

How can I do this please?


texts: I created a page in Drupal 7 using two pictures and would like to display them with color box. The link: http://quaaoutlodge.com/content/salmon-run now two problems: There for some reasons seem to be 4 pictures in the group, two of which are totally out of size and get stretched to 650 x 800 px but I just want them to show in their original size. How can I get rid of the stretched ones?


texts: Why are non-required fields still showing up in my node_edit template using Page Manager

texts: I am stumped. Certain fields are NOT required and yet they still show up if I add the base form to a node_edit variant in Page Manager (Node add/edit form).


texts: Detect front page in Drupal 6 with javascript

texts:
Using javascript in Drupal 6, is there a way to detect whether the present page is the front page? I have a custom Drupal 6 module that outputs different javascript codes based on whether the present page is front page or not. It adds a single javascript file to drupal, so I need to put the check in the javascript.

The site will be served through Varnish cache, so I don't want to add the check in PHP, though I know that would have been way easier with drupal_is_front_page().

Is there any Drupal-native way to do this? jQuery based suggestions will be highly appreciated.

Thanks.


texts: How to limit Node refernce field selection to user own nodes?

texts:
If there are 3 content types that user can create A, B and C. A is main content, B and C  are secondary content types, each time B or C created they automatically have reference to A. My goal is to make possible optionally create reference on C node to B, by displaying check list (when C node is edited/created) with B nodes from same A node. This nodes can have only 1 author and only 1 main A node, so C2 can not be referenced to A1 or B1, only to A2-B2, even if they have same author.

What can be the best way to create such reference filter/pernissions?

Thanks


texts: How to calculate the sum of the values of a multi value field without page reload

texts:
For a content type with a decimal field with unlimited values
(rows), how can I have another field in that same content type that shows the sum of all of the decimal values from the multi value field?

The goal is to keep a tally of the decimal values as the user enters them so they know the total before hitting save on the node.

When the node is saved, the final sum should also be saved in the database.

Modules used are Entity Api and Field Collection.


texts:
I'am working in web services in Drupal 8 using Guzzle.
I found the information how to GET and POST the node but the PATCH( update the node) and the DELETE , i did not find it.
The configuration in the rest.settings.yml is correct, the permissions are also good configured  and all modules are activated.
I have a doubt in the uri in patch. So there is my code in the controller.

public function guzzlePatchExample() {
    // Prepare entity data.
  $serialized_entity_to_modify = json_encode([
    'title' => [['value' => 'title modified with rest']],
    'body' => [['value' => 'body modified with rest ']],
    'type' => [['target_id' => 'article']],
    '_links' => [
      'type' => [
        'href' => 'http://example.com/rest/type/node/article'
      ]
    ],
  ]);
  // Modify the Node.
  $response = \Drupal::httpClient()
    ->patch('http://example.com/node/1', [
      // Username and password for HTTP Basic Authentication.
      'auth' => ['admin', 'anis'],
      'body' => $serialized_entity_to_modify,
      'headers' => [
        'Accept' => 'application/hal+json',
        'Content-Type' => 'application/hal+json'
      ],
    ]);
  // Check for the correct status code.
  if ($response->getStatusCode() == 204) {
    drupal_set_message($this->t('Node modified successfully!'));
    return $this->redirect('system.admin_content');
  }
   return array(
      "#markup" => "Hello PATCH with Guzzle",
    );
  }

Thanks for response.
Matio89


texts: Is possible to use multiple taxonomy terms name (not tids) as contextual filter in Views?

texts:
For example: example.com/TermName1+TermName2+TermName3.

It seems that the "Allow multiple values" option only works with tids.


texts: How to sum vote values from a single field?

texts:
I use a single field Vote Results: Value (with some relationships and contextual filters) which outputs the amount of votes every node has, in a list, like this:

5
3
4
2

However, I want it to look like this:

14

I tried to use the aggregation SUM on the field, but it didn't change.


texts:
Why do we use $block['content'] while attaching css or js files to block ?

$block['content']['#attached']['css'][] = drupal_get_path('module',
                                          'mymodule' . '/mymodule.css');

What does that 'content' mean ?


texts: Running 'composer update' replaces module folders

texts:
I'm going through the nightmare of trying to update a site to 8.4.4 from 8.3.2. It seems like the best way forward is to delete vendors and composer.lock and let composer replace everything. However, when I do this, it also goes through and replaces all of my module folders as well. A number of them are patched, so replacing them straight out of the gate simply doesn't work.

Is this normal behavior for composer? Is there some way to specify that I only want to replace what's going into the vendor directory?


texts:
I have an events content type, and from it, I have a view that lists events. We're using a bootstrap theme, and the format of the display I'm concerned with is Bootstrap List Group. This allows us to use a field as a grouping header.

Since we want the end user to see events grouped by month, we have the display of the grouping field set to Year Month. So for example, one header would be "July 2018".

We also have the view paged, so that it shows 15 events per page. We've added a "Show More" button at the bottom.

However a problem arises when the next page of events start in the same month as the previous set ended in. So for example, the user might see this:

 August 2018
  - Labor Day Holiday
  - a cookout
  - a meeting

[ Load More ]

Then when they hit "Load More", they see this:

 August 2018
  - Labor Day Holiday
  - a cookout
  - a meeting

 August 2018
  - Ice Cream Social
  - a party
  - ...

[ Load More ]

How can I prevent the Grouping header from repeating on loading more?


texts: login programmatically with remember me feature

texts:
I'm trying to create a custom login form, since I need it to be ajax based. And I can't use the existing modules that do this. So far I have achieved this by setting the global $user object to the loaded user and calling user_login_finalize(). But now I need to make the login persist and I have no idea how the default drupal login does it. Any tips are appreciated. Thanks

UPDATE:

The duplicate question indicated by Pontus Nilsson does not mention in any way how to make the login persist nor how to use the default drupal remember me or the RememberMe module functionality.

UPDATE 2:

I must elaborate that I have installed Remember Me module to make the persistent login optional for the user. Is that a reason why I needed to go through all this hassle explained in my answer to make the programmatical login persist?


texts: How do I create a view of all user accounts who have zero orders?

texts:
I would like to create a view of all users and their total Commerce orders particularly including all those who have no orders so that they can be filtered for. I found a related question that solves the issue for users who do have orders but it does not include those who have none.

What I need to see:

I need a list of users and whether they have ever ordered anything. Order Count is one possible way to show this. A simple yes or no is all fine. Sample below.

Filter: none
uid   order_count
0     12
1     5
2     1
3     0
4     0
5     2

Filter: order_count=0
uid   order_count
3     0
4     0

Things I have tried:

Creating a base view of users and attempting to add a relationship to orders. This relationship is not available to select.
Creating a view with base entity commerce_order with a display of type entityreference_filter. Trying to reference this view using an entityreference_filter filter in a base view of users. This did not work because the base entities of those views do not match.

What is not working:

Getting a filter based on the non-existence of a commerce order/order count of zero into a view of all users.


texts: Show "Log in" link all the time (even for logged in users)

texts:
I have a menu item "My Shop" which redirects to the user/login page. But custom Drupal behavior hides this link whenever a user is logged in.
I would like to show this menu-item all the time. Is there a way to do so?

The reason why I do this is the following. It's a site with a webshop-portal. To access this portal, users need to log in. Whenever they are on their portal/webshop, he should keep seing the menu-link and when they return to the front-end of the site, the user should be able to go his webshop without loggin in again.
I hope I make myself clear on this one. If I don't, please let me know!


texts:
I recently organized my modules in /sites/all/modules in 4 differents subfolders: contrib, custom, patches, migration.
It works very well, but after using the update manager, the new updated modules appears in /sites/all/modules instead of /sites/all/modules/contrib, so I have to move it manually to contrib.
How can I set the default module location to /sites/all/modules/contrib ?

Thanks.


texts: Drupal 7 comments spam with Captcha installed

texts:
I have a multilanguage - multidomain website developed in Drupal 7, and the database have been flooded with spam comments, even if I have Captcha module (image) installed. The spam comments are from 60 different IPs, and I have seen attempts to add node and add user (which is blocked) in the incidents reports.

So I cannot block so many IPs at the risk of them being dynamical and loosing potential users.

What could I do to prevent the spam and also to prevent the attacks? Thanks


texts: Get the value from $node inside two objects

texts:
I have an array output like this from drupal, how do I access the value of [name] from
field_episode_tags, I have this so far

print $node->field_episode_tags['und']['0']['taxonomy_term']->['name']

When I get up to 'taxonomy term' there is another object i tried using another -> poitner but that did not work.

stdClass Object
    (
        [vid] => 25
        [uid] => 1
        [title] => Is there any cosmos theory?
        [log] =>
        [status] => 1
        [comment] => 1
        [promote] => 0
        [sticky] => 0
        [nid] => 25
        [type] => tv_episode
        [language] => en
        [created] => 1380610491
        [changed] => 1381115053
        [tnid] => 0
        [translate] => 0
        [revision_timestamp] => 1381115053
        [revision_uid] => 1
        [body] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [value] => summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text
                                [summary] =>
                                [format] => filtered_html
                                [safe_value] =>
summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text summary text

                                [safe_summary] =>
                            )

                    )

            )

        [field_video_category] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [tid] => 25
                            )

                    )

            )

        [field_featured] => Array
            (
            )

        [field_kaltura_video] => Array
            (
            ) und 0 taxonomy term->name

        [field_episode_tags] => Array
            (
                [und] => Array
                    (
                        [0] => Array
                            (
                                [tid] => 95
                                [taxonomy_term] => stdClass Object
                                    (
                                        [tid] => 95
                                        [vid] => 1
                                        [name] => zen
                                        [description] =>
                                        [format] =>
                                        [weight] => 0
                                        [vocabulary_machine_name] => tags

                       [rdf_mapping] => Array


texts: Unable to send user-entered data to PayPal along with credit card info

texts:
I need help. I used this as a guide. When my user fills out and pays for something on my site using a product form the information they supplied in the form (other than their payment) is not being sent to PayPal. So I built this module to send the information using the module I'm supposed to hook into. However, it throws no errors but still sends no data to PayPal.

    if ($payment_method['base'] == 'commerce_paypal_wpp') {

    $order_wrapper = entity_metadata_wrapper('commerce_order',
$order);
    $shipping_info = $order_wrapper->customer_profile_billing-
>commerce_customer_address->value();

             $nvp += array(
                    'ORGANIZATION' => $shipping_info['field_organization'],
            'NAME' => $shipping_info['field_name'],
         );
    }
}

Am I perhaps referencing my user-entered data incorrectly?

Here's how the fields show with dpm($form) [before the user submits the form]:

Name:

$form['customer_profile_billing']
['commerce_customer_address']['und'][0]'name_block']['name_line']

Organization:

$form['customer_profile_billing']['field_organization']


texts:
I want to expose a vocabulary to an external server using services module. I have followed this question How to create test_endpoint, and checked every checkbox, and enabled the `REST Server Module.

The only endpoint that I interest is getTree. But I don't know how to compose the URL. I can't find any document describing the detail (please tell me if you know).

Which HTTP method should I use? GET or POST? I think it should be a GET, but I got nothing
how to specify the vid? /taxonomy_vocabulary/[vid]/getTree ? /taxonomy_vocabulary/getTree/[vid] ? or /taxonomy_vocabulary/getTree?vid=[vid]? any other params?

I have try some URL,

GET  [endpoint]/taxonomy_vocabulary/getTree will response [false] (what is this mean?)

POST [endpoint]/taxonomy_vocabulary/getTree will response 401 Unauthorized, but whatever I disable or enable the Session Authorization, I got the same response.


texts: How can I add extra information for each term reference?

texts:
I'm trying to create a content type that matches a product. The product can be made of several thing in different percentages:

Eg.

material 1:
    material 1.1: 5%
    material 1.2: 0%
    material 1.3: 20%
material 2: 75%
material 3: 0%
material 4:
    material 4.1 0%
    material 4.2 0%

I've built the materials hierarchy using taxonomies.
How can I add a parameter to a taxonomy so I can do this?

I've tried using Field Collection, but the problem I encountered was the inability to work with Solr


texts: How can I print the views title in node.tpl.php?

texts:
I could print the view with this code in node.tpl.php.

<?php
$view = views_get_view('view_name');
print $view->execute_display('view_display_name', $args);
?>

How can I print the views title ?


texts:
I have created a flag for my comments named HELPFUL. If users find a comment helpful they vote it as such.

The challenge that I have is how do I show the total votes for the flag next to the button? If a comment was voted as helpful 5 times for example, show that next to the helpful button.

If there are no helpful votes for a particular comment show nothing (do not display 0) but only the HELPFUL rate button (flag)

I have tried to add [flag-action:count] and [flag-helpful-count] as the token under the flag setting (/admin/structure/flags/manage/helpful >>edit>> Flag link text) but it does not work.

Looked at COMMENT tokes and I see this available: [comment:flag-helpful-count]
It still won't work. It shows this text [comment:flag-helpful-count] instead of a total number.

Any help would be greatly appreciated.


texts: How to link price to the product display?

texts:
I have a page of product teaser links (image, title, price) and I was able to successfully link all except the price to the content with the module Linked Field.

The price field acts differently. The settings are pulled from the Variation settings, and even when a link is set there, the price display remains as before - no link.

Is there a way in Drupal commerce to link the price to the product display?


texts: webform submitted by the user the email that is sent is wrapped after around 75 characters

texts:
I am using a Drupal 7 webform and when the webform is submitted by the user the email that is sent is wrapped after around 75 characters.  The confirmation page which is displayed and uses the same elements as the webform does not wrap after 75 but instead continue on the same line.
How can I get the webform email that is sent to not wrap after 75 characters.


texts: jQuery csv file export fires multiple times

texts:
I have a custom form, and I just want a button in the form that fires a jQuery plugin that generates a csv file for download. The problem I'm having is that it seems to fire multiple times for some reason, and I haven't been able to figure out why. I've tried both a button and a link, but I keep getting the same result.

Here's the form button:

$form['export_csv_button'] = array(
  '#type' => 'button',
  '#value' => t('Export to CSV'),
);

And here's my jQuery behavior:

(function ($) {
  Drupal.behaviors.ons_line_item_export = {
    attach: function (context) {
      $("#edit-export-csv-button").click(function() {
        $("#ons-line-item").tableExport({ type: "csv" });
        return false;
      })
    }
  };
})(jQuery);

Is there something obvious I'm missing that is making this happen?

Thanks.


texts: Custom panels-pane tpl based on some identifier

texts: Is it possible to create a pane template based on some kind of identifier? Just Like you can create a page--node--123.tpl.php file to render a different page for a node with nid 123, i'd like to make a panels-pane--pid--123.tpl.php to render a specific pane with pid 123 I have tried looking on google but i have found nothing about this possibility.


texts: How to compare with the data that has been encrypted by Real AES

texts:
I stored some serial numbers after encrypting them by Real AES.

$data1 = 'S45Qaz6635';
$profile = EnryptionProfile::load('my_encryption_profile');
$result = Drupal::service('encryption')->encrypt($data1, $profile);

$query = INSERT INTO ... VALUES ($result)

Then, I have a form for user to type serial number. If the number does not exist in database, I should return some error messages.

First I came up with an idea is to encrypt that number which user typed, and compare with all numbers in database.

$data2 = 'S45Qaz6635';
$profile = EnryptionProfile::load('my_encryption_profile');
$result = Drupal::service('encryption')->encrypt($data2, $profile);

$query = SELECT * FROM ... WHERE column = {$result}

But I found the result of $query is always null. Because the result of encrypting $data2 is not as same as the result of encrypting $data1.

Second idea is to select all numbers in database, decrypting them, then use in_array() function to figure out the result. But I think it's too inefficient.

Here are some pictures of the setting!

I generated 256-bit key on the website.

Setting of Key:

Setting of Encryption Profile:

I'm using drupal core version 8.

What can I do to work around this issue?

Thank you.


texts: Google web font imports breaking with advagg

texts:
I'm trying to pass Google Page Insights, and they keep saying we have render blocking CSS.  When I try and inline the CSS, it breaks my fonts I'm importing from Google Fonts.  I've tried a million combinations, but the inline is the culprit for some reason.

Here is the CSS code from one of the aggregated files:

@import url("http://fonts.googleapis.com/css?family=Pontano+Sans");@import url("http://fonts.googleapis.com/css?family=Roboto");

I tried it with and without quotes.

For the time being, to keep my client happy, I moved the $styles variable below in my html.tpl.php template, right before the close of the body.  It works fine, but there is a nasty flicker on the page load before the CSS loads, so inlining makes the most sense to me.

I use Omega 4 and use @import in my SASS.


texts: How to enable bootstrap tooltip and popover (on a bootstrap based theme)?

texts:
I'm using a theme based on Bootstrap 3.

I want to use Tooltip and Popover features that come with Bootstrap but I couldn't.

It's said on the Bootstrap Javascript page that:

  Opt-in functionality

  For performance reasons, the Tooltip and Popover data-apis are opt-in,
  meaning you must initialize them yourself.

  One way to initialize all tooltips on a page would be to select them
  by their data-toggle attribute:

$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})

I tried to add the code above to my node.tpl.php (inside of  tags) but it didn't work. I also tried to save that code as script.js and added it to my theme info file but it didn't work.

How can I enable these features? Where to use the above code?


texts: how to display a media description in a twig template?

texts:
i want to display the media description available in the file field of a media ( media of type video, audio, image, etc...), it is an option to activate:

Enable Description field
The description field allows users to enter a description about the uploaded file.

i already print other fields that i want in the media twig template, but i can not find the value of that "description" field attribute, because it's not a field, but some sort of attribute of the file field.


texts: Customize content page in backend with more filters

texts: I need to add more filters like content type, Taxonomy to back end content() in drupal. Hacking the core is not a good method. Is there any alter hooks are available?. Can create a new view page with exposed filters and do a views bulk operation on it?


texts: Bootstrap 3 sub theme - missing header for banner?

texts:
I am new with Drupal Bootstrap 3 sub theming, and I checked the view source and noticed:

<div class="main-container container">

  <header role="banner" id="page-header">

      </header> <!-- /#page-header -->

I wanted to move header outside main-container - how or where can I edit that?

thanks


texts:
I'm trying to cache an object returned after a 3rd party API call via HTTP. The API charges based on calls, so I'm trying to cache the information returned for some period of time.

However I don't seem to be able to get cache_set() to ever store anything. I've enabled "Cache pages for anonymous users" and "Cache blocks" in the performance configuration, as I read somewhere that the cache API may depend on those being set.

I'm using code inside a function called in hook_block_view():

  $cache_key = 'custom_module'.$index;

  $conditions = cache_get($cache_key);

  if (!$conditions) {
     $conditions = API_CALL($index);
     cache_set($cache_key, $conditions, 'cache',  REQUEST_TIME  + (60 * 10)); //stores in cache table and expires after 10 minutes
  }

However this still results in an API call per page load with testing from a logged out browser.
I added some minimal test code:

  cache_set('testing','foo','cache',CACHE_PERMANENT);
  var_dump(cache_get('testing'));

And the output is "bool(false)".

Looking in the database shows the 'cache' table is empty.

I'm about to start digging through the function calls being cache_set() to see what is happening, and intend to report back what I find. However if this is a common problem perhaps someone already has an answer?


texts: What could stop a component appearing on the front end?

texts:
I'm new to Drupal and have been given a task beyond my knowledge.

I am trying to transfer a component (simple image gallery) from one site to another. I've simply copied the component files (.tpl, .module, .inc) into the new site's equivalent directories.

The back-end appears fine: I can add the component to a Panel and adjust its settings. I've replicated exactly what was on the previous site. But nothing appears on the front end.

I've tried clearing the cache and rebuilding the registry, of course.

Would anyone know what file/function I should be looking at to get this working?


texts: Proper use of hook_menu_breadcrumb_alter()

texts:
I have a situation where I need to mess with a breadcrumb on a page and insert some items in the middle.  In my instance drupal_set_breadcrumb() can't be used, so I need to implement a hook_menu_breadcrumb_alter().  I am a little confused about proper usage with this, though, and am not terribly familiar with the guts of how the menu module works.

Is there a proper method for building elements that go into the $active_trail array, eg

$foo = array(
  'title' => $node->title,
  'href' => 'node/' . $node->nid,
  'link_path' => '',
  'localized_options' => array(),
  'type' => 0,
);

title and href are easy enough, but I don't quite get how the other play into this particular context.  It is easy enough to figure this out from what is there, but I would like to do "the right thing".

Is there a proper method (or best practice) for testing whether $item is a node and to load it?  Again, I can dpm($item), poke around, and get what I need.

I have what I need working, but it is messy and would like to fix it for the long term.


texts: How to upload multiple files and predefine filetypes?

texts:
Does someone know how it is possible to upload multiple files with the dropbox client module for drupal 7?

It would be nice if it could be integrated with plupload.

Also i would like to know how i can predefine the filetypes users can upload?

I'm a n00b in php, can someone give me some tips or solutions?

Here is the part of the upload funktion in the dropbox client module.

function dropbox_client_upload_form( $form, &$form_state ) {

  $form[ 'upload' ] = array(
    '#title' => t('Upload file'),
    '#type' => 'file',
    '#size' => 20,
    );
  $form[ 'submit' ] = array(
    '#type' => 'submit',
    '#value' => t( 'Upload' ),
    );
  return $form;
}

function dropbox_client_upload_form_submit( $form, &$form_state ) {

  global $user;

  $dropbox = dropbox_client_get_client();

  //Process files
  $uploads_dir = dirname( $_FILES[ 'files' ][ "tmp_name" ][ 'upload' ] );

  $tmp_name = $_FILES[ 'files' ][ "tmp_name" ][ 'upload' ];
  $name = $_FILES[ 'files' ][ "name" ][ 'upload' ];
  $filename = "$uploads_dir/$name";
  move_uploaded_file( $tmp_name, $filename );

  $dpath = (isset( $_GET[ 'dpath' ] )) ? $_GET[ 'dpath' ] : '/';
  $result = $dropbox->add( $dpath, $filename );

  if ( property_exists( $result, 'error' ) ) {
    drupal_set_message( $result->error );
  }
  else {
    drupal_goto( $_GET['q'], array( 'query' => array( 'dpath' => $dpath ) ) );
  }
}

Thank you!

Best regards,
meckl


texts:
I have those menu elements declared in hook_menu function:

$items['submission/%/id/%'] = array(
    'title' => 'View submission',
    'title callback' => 'fr_form_view_submission_page_title',
    'title arguments' => array(3),
    'page arguments' => array(1, 3),
    'page callback' => 'fr_form_node_object_id',
    'access arguments' => array('content access'),
    'type' => MENU_NORMAL_ITEM,
    'weight' => 100,
  );

  $items['submission/%/id/%/view'] = array(
    'title' => 'View submission',
    'title callback' => 'fr_form_view_submission_page_title',
    'title arguments' => array(3),
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );

  $items['submission/%/id/%/edit'] = array(
    'title' => 'Edit submission',
    'page arguments' => array(1, 3, 4),
    'page callback' => 'fr_form_node_object_id',
    'title callback' => 'fr_form_edit_submission_page_title',
    'title arguments' => array(3),
    'access arguments' => array('content access'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 100,
  );

As you can see the first menu item has a fr_form_view_submission_page_title() function to set the title. And the function looks like this:

function fr_form_view_submission_page_title($id) {
  return t('View submission ID: @id', array('@id' => $id));
}

Second item makes the first one default.

Third menu item has a title callback function which looks like this:

function fr_form_edit_submission_page_title($id) {
  return t('Edit submission ID: @id', array('@id' => $id));
}

When I go to page /submission/10/id/1 I get the result. Two tabs next to each other with text on it:

first tab: View submission ID: 1
second tab: Edit submission ID: 1

And the page title is: View submission ID: 1

And if I go to the edit tab (/submission/10/id/1/edit) I get exacly the same, so:

first tab: View submission ID: 1
second tab: Edit submission ID: 1

And the page title is: View submission ID: 1

What I want to achive is to have tabs always signed:

first tab: View submission

second tab: Edit submission

And the page title depending on path, so for /submission/10/id/1 I should get:
View submission ID: 1

And for /submission/10/id/1/edit I should get:
Edit submission ID: 1


texts: Cannot run an update: entity_test module is missing

texts:
I've got this error after trying to update to the last Drupal 8 (8.3.2):

  Drupal\Component\Plugin\Exception\PluginNotFoundException: The "entity_test" entity type does not exist. dans Drupal\Core\Entity\EntityTypeManager->getDefinition() (ligne 133 de /var/www/prod/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

How can I install or uninstall this module?

it seems a system module, so I cannot install it.


texts:
I have a view which is a block on a page and I want to style the view. I tried using the rewrite output however I ran into a problem with it removing the style="" tag. So I had to resort to a .tpl.php to modify the display as I please.

Currently I am using

$d = $view->result;

    // Loop through it
    foreach($d as $r) {
        // Get values
        $position = $r->_field_data['nid']['entity']->field_position['und']['0']['value'];

        $name = $r->_field_data['nid']['entity']->title;

        $image = file_create_url($r->_field_data['nid']['entity']->field_picture['und']['0']['uri']);

        $path = drupal_lookup_path('alias',"node/".$r->nid);

        print "

".$name."".$position."
";
    }

And as you see this is extremely ugly and I am dependent on 'und' not changing... which it does.

Is there another way to get the view field data besides having to go through the array and find it? I tried render() and that didn't work. I also tried using entity_metadata_wrapper('node', $view); and that didn't work (the fields where not attached to the array).

I can't figure out how to do it without the hacking code... Help!


texts: Is the Search API module able to do range facets on numeric values?

texts:
I'm using Drupal Commerce, Search API, and Facets API; I'd like to put the product prices as a facet. Configuring my search API index, I managed to get this facet, but the Search API module doesn't seem capable of handling price ranges facets. This is how the facet looks like.

1230,23
340,21
...

I'd like it to be like the following.

From 10 to 100
From 100 to 200
...

It seems that there is existing code for handling ranges, but not decimal ranges.

Did I miss something?


texts:
I am building an organisational website.
I just came across a situation wherein I need to build a page containing:

A list of links (each link has title (linked to a different website) + image)
Pager at the bottom

Should I create a view of a new content type that contains these two items? Is there another way to do this? Since the link is to another website, should I take the RSS feed from that site and display content on my site ?

Kindly suggest whether to use a module or not and if not then how to link the title part to another site.


texts: Background images using Breakpoints and Picture

texts:
I want to serve my background images by breakpoints.  I can't seem to find an out of the box way to do this using the Breakpoints and Picture modules, which I'm using for some node images.

Has anyone implemented this using Picture/Breakpoints?


texts: Restrict Menu Item from anonymous users and redirect to Login page

texts: I created a simple menu link and need it to be visible for both authorized and anonymous users. But when a unauthorized/anonymous user click it should check authorization and if not it should redirect to login page. How can i do this. Thanks


texts: Inserting user registration fields for app development

texts:
I need to insert the value as below.. but not working..

$fields['field_clinic_hospital_location_d']['und'][0]['field_telephone_number']['und'][0]['value'] = $telnum;

I am inserting the user registration fileds from external php file. field values inserting successfully in below 1st case, but not working in 2nd case. I picked this below data from the firebug name attribute which the field is <input tag name="field..." attribute.

Case1:- $fields['field_first_name']['und'][0]['value'] = $firstname;
case2:- $fields['field_contact_address']['und'][0]['thoroughfare'] = $contaddr;


texts: What is the right way to implement google_analytics with the eu_cookie_compliance and categories?

texts:
I'm having difficulty configuring eu_cookie_compliance with multiple categories on a website with Google Analytics tracking. The GA tracking depends on selection of one of the categories.
When the category 'analytics' is enabled, google analytics cookies should be allowed and vice versa.
This comment in a thread for google_analytics shows how to implement the hasAgreed() check within the google_analytics module; in the 'Code Snippet (before)' field:
document.addEventListener('DOMContentLoaded', function(){
    if (!Drupal.eu_cookie_compliance.hasAgreed()) {
        window['ga-disable-UA-0000000-00'] = true;
    }

and in the 'Code Snippet (after)' field:
});

several others in the thread have confirmed that this works for them. In my case however, google analytics is never triggered.
I added the following before the 'if' statement to debug it:
console.log("General: " + Drupal.eu_cookie_compliance.hasAgreed());
console.log("Analytics: " + Drupal.eu_cookie_compliance.hasAgreed('analytics'));

The console shows false for both of the above, no matter what I select, and the google analytics is never triggered.
What could I be doing wrong?


texts: Is it possible to add a button to a field_collection?

texts:
I've created a custom entity module, and the form for it uses field_collections. The only form field I've defined programmatically is the title, the rest of the fields and field collections for this form I've defined via the Drupal 8 interface.

I have a particular field collection with 8 dropdowns and a large textarea. I want the person using the form to be able to set the 8 dropdowns to certain values automatically based on the contents entered in the textarea, but only by clicking a button since they should also be able to manually set the dropdowns. The field_collection itself has unlimited allowed values, so there should be one button for each instance of that field collection in the form.

It was my plan to just get an inactive button into the form and add a front-end script to have it trigger a Javascript function, but I can't seem to figure out how to get a button in the form. It doesn't seem to exist as an option in field_collection field definitions. I had a prototype of this working in jQuery, but I'd rather not use jQuery to insert elements into the form if I can avoid it. So far Googling has proven fruitless. Is it possible to do this with hook_form_alter() perhaps?


texts:
How do I change the link for products in the cart, currently they link to the product nodes but I'd like them to link to a custom view?

I can create a custom template, page--cart.tpl.php, but I don't know what the original code would be, and adding the following displays just the cart on the page, no other blocks:

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

I'd like to be able to create a custom template, to give me more control, but I only really need to change the link to the product page and the product image.


texts: how to return a db_query as an option list and display it

texts:
<?php

/**
 * Define callbacks that can be used as custom select list options.
 */
function webform_contacts_webform_select_options_info() {
  $items = array();

  if (function_exists('webform_options_contacts')) {
    $items['contacts'] = array(
      'title' => t('Contact List'),
      'options callback' => 'webform_options_contacts',
    );
  }

  return $items;
}

/**
 * Option list containing Contacts.
 * Pull a list of users where status=active and rid=5 from database.
 */
function webform_options_contacts() {
  $items = array();

  $query = db_query("SELECT realname.realname AS realname_realname, realname.uid AS realname_uid, users.uid AS uid, 'user' AS field_data_field_gal_phone_user_entity_type FROM {users} users INNER JOIN {users_roles} users_roles ON users.uid = users_roles.uid LEFT JOIN {realname} realname ON users.uid = realname.uid WHERE (( (users.status <> '0') AND (users_roles.rid = '5') )) ORDER BY realname_realname ASC");

  $results = $query->execute();
}

I created a custom module for displaying an extra option list. The example provided by Drupal 7 Webform Cookbook I used worked; using a hard coded list and it displays fine.

I want to use a db_query to populate the list. I have this code (shown above) but am unable to see anything displayed. Help! I am sure I am missing the command to properly get this to display as a list.


texts: Adding title attribute to #type password_confirm

texts:
Is it possible to add a title attribute through a form_alter to element #type 'password_confirm'?

For example, I have a form with the following fields:

email
password
password confirm

To apply a title attribute to the email element is fine...

$form['account']['mail']['#attributes']['title'] = 'enter your email address';

When I dump the contents of $form in search for the input elements for 'password_confirm', I only get the following:

[pass] => Array
                (
                    [#type] => password_confirm
                    [#size] => 25
                    [#description] => We will not spam you or give your email address to third parties.
                    [#required] => 1
                )

I'm not seeing 'pass1' and 'pass2' in the array.

Please could someone point me in the right direction?


texts:
I have a 4 seperate calendars created on drupal; each with their own content type. Each of these need to be able to be viewed on their own but I'd also like to be able to combine all of these calendars into one master view and can't seem to figure it out.

ie. Meetings calendar, Holidays calendar, Staff Events calendar.

Any help would be greatly appreciated. I'm new to Drupal so please be gentle.

Thanks


texts: How can I have all drupal links work on ajax based?

texts:
Is it possible to have all drupal internal links work on ajax based without any page refresh?

If there is any ready module, please share the link. Your help is really appreciated.


texts: Instantiate and load a block programmatically in twig template

texts:
I created a simple block that shows some text grabbed from an external source, and it renders as expected when I place it from the back-end (Structure->Block Layout).

But I want to be able to place it via code only inside a twig template from the theme directory. I thought I would use {{ drupal_block('id defined in Block.php') }} from the Twig tweak module but it never works unless the block is first placed from the back-end which assigns it a machine name then I can display it anywhere using that machine name in drupal_block() instead of the id I defined in its source code.

So how can I instantiate it programmatically first and then place it the the twig template I want?

During my search I came across Plugin Derivatives, I don't know if it is the solution I want, or how to use it.


texts: Drush 8 raises an error while running 'drush runserver'

texts:
I just installed Drush (globally) as described here: http://docs.drush.org/en/master/install/,
on Ubuntu 14.04 (PHP 5.5.9).

Then I created a new Drupal 8 web site and database with:

$ drush dl drupal --drupal-project-rename=example
$ drush si standard \
    --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]'
    --site-name=Example

When I run the built-in server within the project directory:

$ drush rs 8000

And I try to access http://localhost:8000, I get this error:

  PHP Warning: Unknown: failed to open stream: phar error: invalid url or non-existent phar phar:///usr/local/bin/drush/commands/runserver/d8-rs-router.php in Unknown on line 0
  PHP Fatal error:  Unknown: Failed opening required 'phar:///usr/local/bin/drush/commands/runserver/d8-rs-router.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

What's wrong?


texts: Overwrite file_directory_temp function without touching the core?

texts:
I need to modify the file_directory_temp() function, but I can't touch the core.

My drupal-site runs in Microsoft Azure Cloud and I need to exclude all temp files from drupal-root into a absolute location.

I basically want to prefix the value from variable_get('file_temporary_path') with an absolute file-path: "C:\temp" + "\sites\default\tmp"

Because the absolute part of the path is a dynamic value, which depends on environment and is returned by function Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp') it can't be stored in database, due to changing enviroment.

In a nutshell:

I need file_directory_temp() function to return:

$temporary_directory = Microsoft_WindowsAzure_RoleEnvironment::getLocalResource('Temp') . variable_get('file_temporary_path', NULL);

instead of:

$temporary_directory = variable_get('file_temporary_path', NULL);

The prefix is dynamic and can't be stored in database, due to changing enviroment setup.


texts: user edit page on quick tab crashes when uploading images

texts:
I'm using quicktabs and in one of the tabs I'm using a callback the callback is the client profile2 edit page user/%1/edit/client

The form is correctly rendered but it crashes when I try to upload images in an image field of the profile I get the following errors

Notice: Undefined index: user_profile_form in drupal_retrieve_form() (line 807 of /home4/tse/public_html/troubleshootexpress.com/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_profile_form' not found or invalid function name in drupal_retrieve_form() (line 842 of /home4/tse/public_html/troubleshootexpress.com/includes/form.inc).
Notice: Undefined index: #user_category in block_form_user_profile_form_alter() (line 575 of /home4/tse/public_html/troubleshootexpress.com/modules/block/block.module).
Notice: Undefined index: #user_category in profile2_form_user_profile_form_alter() (line 348 of /home4/tse/public_html/troubleshootexpress.com/sites/all/modules/profile2/profile2.module).
Notice: Trying to get property of non-object in profile2_form_user_profile_form_alter() (line 348 of /home4/tse/public_html/troubleshootexpress.com/sites/all/modules/profile2/profile2.module).
Notice: Undefined index: #user_category in system_form_user_profile_form_alter() (line 1968 of /home4/tse/public_html/troubleshootexpress.com/modules/system/system.module).
Notice: Undefined index: #user in tse_form_alter() (line 454 of /home4/tse/public_html/troubleshootexpress.com/sites/all/modules/tse/tse.module).
Notice: Trying to get property of non-object in tse_form_alter() (line 454 of /home4/tse/public_html/troubleshootexpress.com/sites/all/modules/tse/tse.module).
Warning: in_array() expects parameter 2 to be array, null given in tse_form_alter() (line 454 of /home4/tse/public_html/troubleshootexpress.com/sites/all/modules/tse/tse.module).
Notice: Undefined index: profile_client in file_ajax_upload() (line 271 of /home4/tse/public_html/troubleshootexpress.com/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /home4/tse/public_html/troubleshootexpress.com/modules/file/file.module).

I read in other topics that adding the file path would solve the problem, so I did a hook_menu_alter like this:

function tse_menu_alter(&$items) {
  $items['user']['file path'] = drupal_get_path('module', 'user');
  $items['user/%user_category/edit/client']['file path'] = drupal_get_path('module', 'user');

}

but it does not have any effect the menu is correctly altered but it does not fix the problem.

Any ideas?


texts: How come Drupal Console is not downloading all commands?

texts:
When adding Drupal Console using Composer, we are finding that the list of commands is not complete. How can I resolve the issue?

Installation steps:

change to root directory (/local/path/drupal-site)
run composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
run composer update drupal/console --with-dependencies

Steps to reproduce:

Change to either Change to drupal-site/vendor/bin/ or drupal-site/vendor/drupal/console/bin directory
run drupal generate:form
error message below is returned.
change to root directory (/local/path/drupal-site)
run vendor/bin/drupal generate:form
error message below is returned again.

  [ERROR] Command "generate:form", is not a valid command name.

Versions:

Drupal core v8.5.5
Composer 1.6.3
Drupal console 1.8.0

output of drupal list


texts:
I'm making an Ajax call to a route that performs an entityQuery.  I know that when a node is added, it will change the results of that entityQuery, but until then, I want the route to return cached data so it doesn't have to perform the full query every time.  What is the fastest way to do this?

Is there a way to put a cache tag on the route itself, that I can invalidate on node creation?

Should I do a $cache = \Drupal::cache()->get($cid) kind of thing in the route itself?

Thank you for reading.


texts: Preventing user creation, but allowing edit

texts:
I have defined a role in which I'd like to grant:

1) Permission to edit users

2) Prevent from creating new users

Is this possible? I only see one permission under User called "Administer users" which looks like grants both abilities.

Thanks


texts: Trying to get content type from a node entity

texts:
I'm trying to get the content type from a node entity.

The entity is being loaded as follows:

$synclist = entity_load_single('entity_synclist', $qid);

Now, how would I then get the content type? Would it be as simple as:

$contenttype = $synclist->type;

Or do I have to do some other Drupal magic?


texts: How to add conditional javascript to theme?

texts:
I'd like to use Selectivizr script to emulate CSS3 selectors in IE6-8.

But I'm having a hard time adding it to my theme. So far tried:

1) Forcing this into html.tpl.php head section:

<!--[if lt IE 9]>
<script src="<?php print base_path() . path_to_theme(); ?>/js/selectivizr.js"></script>
<![endif]-->

But base_path() doesn't seem to return anything in D7 (at least in html.tpl.php - maybe in page.tpl.php...). And I know this isn't the Drupal way to do it anyway.

2) Adding to my theme's .info file:

scripts[] = selectivizr.js

But then it's unconditional, of course :(

3) Using drupal_add_js() in my template.php.

But again, I'm not sure that it can be set conditionally there?


texts: Any way to add more than one text entry to select fields

texts:
In a form that a site user (i.e. not an administrator) fills out I want to have a section like this (the "[ ]" represents a checkbox in the form):

Certifications

[ ] Type 1 Certification

[ ] Type 2 Certification

[ ] Type 3 Certification

[ ] Other Type 3 Certifications [text box entry]

[ ] Type 4 Certification

[ ] Type 5 Certifications

[ ] Other Certifications [text box entry]

So the user would check as many of these as apply to them, and if they had a different Type 3 Certification than the one that was listed, they would check the "Other Type 3 Certification" checkbox AND fill out the text box with the type of Certification that wasn't listed.

And they would also have the option of checking the last text box and typing in other types of certifications in that text field.

I found Select or Other (https://www.drupal.org/project/select_or_other), but it doesn't appear to allow for two text options.

Perhaps I should simply do the list of options with Select or Other, put the Type 3 option last in the list, and add Other Certifications as a separate field?


texts: Select previous/next nodes of same content type programmaticaly in Drupal 7

texts:
there are modules out there for my problem, but they are not stable and also i need to be able to manipulate the result so here we go:

i need to provide a block on a certain node type which offers a previous and next link to cycle through the nodes of the same content type.

how can i select the previous and next node programmatically using db_query() and then output the links to them?

thanks in advance for your help


texts: Prefix html before radiobutton (input field)

texts:
I'm looking to insert some extra html before an input radio button. This is my html now:

        <input type="radio" id="edit-field-geslacht-und-female" name="field_geslacht[und]" value="female" class="form-radio">
        Female

        <input type="radio" id="edit-field-geslacht-und-male" name="field_geslacht[und]" value="male" checked="checked" class="form-radio">
        Male

        <input type="radio" id="edit-field-geslacht-und-other" name="field_geslacht[und]" value="other" class="form-radio">
        Other (transgender...)

Now I would like to add the following html before every radio input:

But how can I do this?

UPDATE:

I've tried to do it with theme_form_element function and now have this:

function theme_form_element($variables)
{
    if($variables['element']['#type'] == 'radio')
    {
        dump($variables);
    }
}

My dump shows me this array:

array (size=1)
  'element' =>
    array (size=27)
      '#type' => string 'radio' (length=5)
      '#title' => string 'Female' (length=6)
      '#return_value' => string 'female' (length=6)
      '#default_value' => string 'male' (length=4)
      '#attributes' =>
        array (size=0)
          empty
      '#parents' =>
        array (size=2)
          0 => string 'field_geslacht' (length=14)
          1 => string 'und' (length=3)
      '#id' => string 'edit-field-geslacht-und-female' (length=30)
      '#ajax' => null
      '#weight' => float 0.001
      '#input' => boolean true
      '#process' =>
        array (size=1)
          0 => string 'ajax_process_form' (length=17)
      '#theme' => string 'radio' (length=5)
      '#theme_wrappers' =>
        array (size=1)
          0 => string 'form_element' (length=12)
      '#title_display' => string 'after' (length=5)
      '#pre_render' =>
        array (size=1)
          0 => string 'ctools_dependent_pre_render' (length=27)
      '#after_build' =>
        array (size=1)
          0 => string 'conditional_fields_element_after_build' (length=38)
      '#defaults_loaded' => boolean true
      '#tree' => boolean true
      '#array_parents' =>
        array (size=3)
          0 => string 'field_geslacht' (length=14)
          1 => string 'und' (length=3)
          2 => string 'female' (length=6)
      '#processed' => boolean true
      '#required' => boolean false
      '#name' => string 'field_geslacht[und]' (length=19)
      '#value' => string 'male' (length=4)
      '#ajax_processed' => boolean false
      '#sorted' => boolean true
      '#after_build_done' => boolean true
      '#children' => string '<input type="radio" id="edit-field-geslacht-und-female" name="field_geslacht[und]" value="female" class="form-radio" />' (length=119)

I've tried to change the #children variable and add my html before it. But when I do that no element on my page is showing ... .


texts: Theme multiple rendered nodes as item_list

texts:
I am retrieving/rendering multiple nodes successfully with the following code:

$nodes = node_load_multiple($nids);

$rendered_nodes = node_view_multiple($nodes, 'custom_view_mode');

return render($rendered_nodes);

I would like these nodes to be rendered as an item list. I have attempted to set the #theme property of the array to 'item_list' but it does not seem to be working. What is the correct way to theme this array of nodes returned by node_view_multiple()?


texts:
So it looks like drupal menus only have a active trail depth of one, which is problematic for my nested pages since my menus wont be marked active once I drill into the nest. Is there a module or setting to fix this?

What I mean is if I have the following pages:

about/board-directors/john-smith

and a menu that shows:

about
board of directors
something else

I could be on "about" and the about link would be active. I could be on "about/board-directors" and 'board of directors' would be active. But If Im on the page "about/board-directors/john-smith" I would like the 'board of directors' menu item to be active. How can I accomplish that? Im a bit of a noob so I'm in the dark here.


texts: Can Profile2 present fields on registration?

texts:
I'm looking at using Profile2 on a D7 site, so that we can have private fields, and different fields per role.

Is it possible to have Profile2 present its fields on the user registration page? New users are going to default to a particular role, so the fields would be that of the default role.

I've looked at the introductory and documentation pages, but they are very sparse. All I could find for configuring Profile2 on a site where it's installed was simply specifying the per-role fields.


texts:
I am using Search API. I make a view of all the indexed entities and uses Taxonomy term as Contextual Filter. But the path of view is not SEO friendly. The path is like http://www.example.com/en/Real%20Estate.

I want to make this path SEO friendly and convert this space(%20) to dash.
In views I am getting configuration "Convert dashes into spaces" for contextual filter.

I tried to alter the views  and implement hook_views_pre_render, hook_views_post_render, hook_views_post_build and hook_views_post_execute. This time it is not showing the results.

Can anyone help me regarding this?


texts: Cron not working when called from SSH php curl - Elysia cron module activated

texts:
I have Elysia cron module activated, with some cron task scheduled.

I have a crontab pointing to an sh every */2 minutes. The sh executes a php with a curl call to cron.php?cron_key=CRON-KEY. It was working perfectly some weeks ago. Suddenly, it has stopped working. When I launch the same cron.php address by browser, it works perfectly, executes the cron with all the scheduled tasks in order as defined by Elysia config.

But when the same cron.php is called via the SSH php (console or just through the cron daemon), it does not work. It gives no error or hint, just does not do anything. I have tested curl in the same domain, with GET parameters, to a different php file, and it is working. I have no idea what can be happening, I have re-installed Elysia cron, and the same results. I cannot understand why Drupal knows that the script is called via a non-browser script and why it stops working.


texts:
I have got a problem.  I have been upgrading my site from Drupal 6 to 7 and I've reached about 75% of the way.  I have updated all my 3rd party modules and custom modules and while I was configuring some setting for my 3rd party modules, like Taxonomy Image, I noticed that in my front page the teasers where displaying a view that I wanted to embed only in the full node view.

I looked at my node.tpl.php, which is where I was adding the view and the if/else for the view looks good, but for some reason, when I debugged it, the if ($teaser) is not the one that it is going to when I load the front page, it is actually going to the else.

This is the code in my node.tpl:

    <?php if (!empty($content['links'])): ?>

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

    <?php endif; ?>
        <?php if($teaser): ?>
            <?php print render($content['comments']); ?>
        <?php else: ?>

                <?php print render($content['comments']); ?>
                <?php $related_by_term_block = block_load('views', 'related_by_term-block_1');
                    $block_content = _block_render_blocks(array($related_by_term_block));
                    $build = _block_get_renderable_array($block_content);
                ?>

                <?php
                    print render($build);
                ?>

        <?php endif; ?>

I have no idea if any of the 3rd party modules I have are getting in the way.  This is the list of my 3rd party modules:

FLAG
DATE
CAPTCHA
MOLLOM
ADVANCED HELP
BETTER FORMATS
FLAT COMMENTS
FORWARD
SEARCH CONFIGURATION
SHARED EMAIL
VOTING API
WYSIWIG
AUTHOR PANE
PUBLISH CONTENT
WORKFLOW
THEMEKEY
CHAOS TOOL SUITE (CTOOLS)
VIEWS
ENTITY API
VIEWS BULK OPERATIONS (VBO)
VIEWS ATTACH (EVA)
SIMILAR BY TERMS
ADVANCED FORUM
RULES
LIBRARIES API
GRAMMAR PARSER
GRAMMAR PARSER LIBRARY
HTML PURIFIER
TOKEN
INVITE
FIVESTAR

Any input would be greatly appreciated.  Thanks.


texts:
After updating Drupal from 7.15 to 7.16, I noticed a strange behavior.

If my custom module is enabled, the website design is broken in Internet Explorer. I don't see some parts of website: The front page shows only slideshow, I don't see filters or even the whole pages. If a custom module I am using is disabled, everything is OK. I tried to downgrade again to 7.15, but I still have the same error.

I really don't understand why it happened, as I didn't have any problems with Internet Explorer, and my module before the update.

Can anyone help me with my problem?

This is the code used from my custom module.

/**@file This module provides custom functions    */

/** Unset these form elements from the comment_form using hook_form_alter */

function custom_module_form_comment_form_alter(&$form, &$form_state) {
  $form['author']['name']['#access'] = FALSE;
  return $form;
}

/** Implements hook_block_info(). This hook declares what blocks are provided by the module.*/
function custom_module_block_info() {
  $blocks['contact_block_form'] = array(
    'info' => t('Contact Form'),
  );

  return $blocks;
}

/** Implements hook_block_view(). This hook generates the contents of the blocks themselves. */
function custom_module_block_view($delta = '') {
  //The $delta parameter tells us which block is being requested.
  switch ($delta) {
    case 'contact_block_form':
      $block['subject'] = t('');
      // Load contact pages inc as the form definition sits there.
      module_load_include('inc', 'contact', 'contact.pages');
      $block['content'] = drupal_get_form('contact_site_form');
      break;
  }

  return $block;
}

/** Views - Exposed Filter Form Theming  */

function custom_module_form_views_exposed_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'location') {
    $form['field_location_tag_tid']['#options']['All'] = t('- choose region -');
    $form['field_poselok_tag_tid_option_limit']['#options']['All'] = t('- choose city -');
$form['field_poselok_tag_tid_option_limit']['#states'] = array(
      'disabled' => array('select[id="edit-field-location-tag-tid"]' => array('value' => 'All')),
    );

    $form['type_1']['#options']['All'] = t('- choose gallery type -');
    $form['field_author_tid']['#options']['All'] = t('- choose gallery author -');
    $form['field_author_tid']['#states'] = array(
      'invisible' => array('select[name="type_1"]' => array('value' => 'gallery')),
    );
  }
}


texts:
I'm having trouble connecting to my databases. It worked a few days ago but can't seem to figure why it doesn't work now. It's a D8-site. Drush version is 8.1.12.

I've double-checked both the alias-file and settings.php-files (both on server & local) and database settings all appear correct. My local site runs on Mamp 4.1.1. and network access is allowed.

Here's the error I get when running sql-sync drush sql-sync @local @dev. Rsync works fine.

Unable to load class Drush\Sql\Sql                                                                                [error]
exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your database connection details.' in /vendor/drush/drush/commands/sql/sql.drush.inc:541                [error]
Stack trace:
#0 /vendor/drush/drush/commands/sql/sql.drush.inc(252): drush_sql_get_class()
#1 [internal function]: drush_sql_dump()
#2 /vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_sql_dump', Array)
#3 /vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#6 /vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#7 /vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /vendor/drush/drush/drush.php(12): drush_main()
#9 {main}
sql-dump failed.

And here's the aliases.drushrc.php (my local copy of course includes credentials:))

<?php

/* Tambourhinoceros Site */

$aliases["local"] = array (
 'root' => '', // local path
 'uri' => 'local.tambourhinoceros.net',  // local uri
 'path-aliases' =>
 array (
   '%dump-dir' => '/tmp',
   '%drush' => '/usr/local/bin',
   '%site' => 'sites/default',
 ),
 'remote-user' => 'tamb_dev',
 'ssh-options' => '-T',
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', // local database
        'username' => '', // local database user
        'password' => '', // local database pw
        'host' => 'localhost',
        'port' => '8889',
        'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);

$aliases["dev"] = array (
  'root' => '', // remote path
  'uri' => 'drupal-85630-297475.cloudwaysapps.com', // remote uri
  'path-aliases' =>
  array (
  ),
  'remote-host' => '', remote IP
  'remote-user' => '', remote User
  'command-specific' =>
 array (
   'rsync' =>
   array (
     'mode' => 'rlptzO',
     'verbose' => true,
     'no-perms' => true,
   ),
 ),
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', remote database
        'username' => '', remote  user
        'password' => '', remote pw
        'host' => 'localhost',
        'port' => '',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
)
?>


texts: How do I get a direct download from a path like /media/?

texts:
i'm wondering how anyone using drupal 8 is handling files using the newly added to core media module. For example, uploading a document using media module, to be linked to by multiple pieces of content, and not having to upload the same file on every page. I just want to be able to link to /media/{media id} and have the doc download or open in the browser.

Any idea on how to get this done?


texts: Alter a template whether a user is logged-in or not

texts:
In a theme, I am using the following preprocess function.

function dtv_preprocess_node(&$vars) {
  // Determine if the user is logged-in.
  if (user_is_logged_in()) {
    // Add a theme hook suggestion.
    $vars['theme_hook_suggestions'][] = 'node__youtube_media__auth';
  }
}

Inside /templates/node there are two files.

node--youtube_media.tpl.php
node--youtube_media__auth.tpl.php

By now there is no change happening whether a user is logged-in or not.

Does someone see the error and is able to enlighten me?


texts: Pseudo-field for custom entity without hook

texts:
I developed custom entities in the code, using entity references :
A <- R -> C. Entity "R" contains references to "A" and "B".

I'd like to add a pseudo-field in entity "A", configurable in view display, that could render referencing entities (mean "R" entities referencing "A" with a given field "F").

Since I made my own classes for the entities, I'd really like to continue that way and prevent using hooks. I know I could achieve this with views, but it seems more logical, reusable, and quicker, to put it in entity code.

Is there a way to add the display field to my entity without using hook_entity_extra_field_info() ? For example could I create my own FieldEntityManager ?
Is EntityViewBuilder the right place to render the field with my own data ?
In a more generic way, would it be possible to develop a custom field type "referencing_entities" that I could reuse in every referenced entities I have ?
Would it be only a field formatter since I don't need to store anything ? Is it possible to access to the entity from the field to query referencing entities ?


texts: Drag and drop content on user side in drupal 6

texts:
I am developing a Drupal 6 site in which I need to allow user to drag and drop
blocks of content, but the arrangement of the content for each particular user should be persistent whenever they visit the site. I have completed the drag and drop functionality but after each refresh the content reverts to its original layout.

Here is the example site: http://portal.opera.com/

How can I make the results of D&D functions persistent?


texts: Alter/insert into the links variable in a field_collection

texts:
I am currently working with the Field Collection module, but I have stumbled into a small problem.

I am trying to alter the links variable (currently there is Edit & Delete links) on a field_collection, as I want to add a link to it. I believe I have tried everything, such as hook_entity_view_alter(), or a preprocess function, but nothing seems to work.

Is there a way to solve this, without hacking core?


texts: Add CSS-class to current node in module logic

texts:
In a custom module, I add some logic to the node rendering. Based on this, I would also like to add some appropriate CSS-classes to the current node.
The below code expresses  what I would like to do, but don't know how to do.

$node->classes[] = $class;

Because I already have the appropriate logic in my module, it seems to me like the adding of classes should be handled in the same place. I could do this in a template instead, but that would require me to duplicate all the logic.


texts: Are $form_state values cleaned of malicious code even if #limit_validation_errors is set?

texts:
I'm building a multi step form with a bunch of required fields on each step. The user has to be able to save the current step of the form, even if they haven't filled out all the required fields.

I will then save it to a custom entity I've created.

I'm using code like this:

#limit_validation_errors => array(),
#submit => array()

to disable validation. So will Drupal's internal code still clean these values of malicious code when I trigger a submit/save them to the entity? Or do I have to do it myself?

I'm using $this->set('key', $value); to save the data.


texts: Check if there are any elements with a certain class in the form array of unknown depth

texts:
I'm new to Drupal and still have to figure out a lot. This might also be just a general programming question.

I wrote a module that has some js-libraries which should be attached to forms on different conditions. For one of those libraries, I want to add it in case the form array has an element with the class "remove-button", which could be at any depth.

I searched for different recursive approaches, but it doesn't work somehow. I was able to attach the library without a condition so it attaches to all forms, so the problem lies within my recursive function.

Snippet from hook_form_alter in my .module file:

function my_module_form_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id)
{
  // remove-button
  $hasRemoveButton = containsClass($form, 'remove-button');
  if ($hasRemoveButton) {
    $form['#attached']['library'][] = 'my_module/remove-button';
  }
}

Recursive search function (last code I tried):

/**
 * Search a class in $form.
 */
function containsClass($array, $class)
{
  if (!is_array($array)) {
    return false;
  }
  if (isset($array['class']) && in_array($class, $array['class'])) {
    return true;
  }
  foreach ($array as $subarray) {
    containsClass($subarray, $class);
  }
}

Anyone an idea how this can be achieved? Maybe with a different approach than a recursion?


texts: Alternative for Node Gallery in Drupal 7?

texts:
Will I be able to have show an image gallery for a multiple value image field on the node display in drupal 7 with some alternative module?

http://drupal.org/project/node_gallery is only available for drupal 6

that´s anoying, every alternative that I´ve found is eighter abandoned or only for D6


texts: Do migrate module migrations continue in background if terminal session ends?

texts: I'm working on a migration that involves some long migration times - many hours to migrate some tables. I use the drush commands to perform my migrations, but often something happens in the middle. The window closes by accident, or I lose my Internet connection for a minute, whatever. When I open a new terminal and run 'drush ms' I see my migration marked "importing"... but is it really going to finish at some point?


texts: How to allow a block on a page to load another block on same page in Drupal 7?

texts:
This is what I am looking for: On a page that has a block, I want the ability of a link within that block to load another block on the same page. (Specific case: a static page has a Views block containing a grid of team members with a 'see more' link under their picture. I want that link to load the user profile as a block, but on the same page - presumably this should use ajax).

Any help on how to do this would be supremely appreciated. Thanks.

Can't post images on Drupal.stackexchange yet but here are two screenshots to illustrate what I am looking to do: http://goo.gl/WBgcR


texts:
I'm a programmer with medium skills in Java-C# with few knowledge about web development. Now I want to create a news site for our corporation.

I searched a bit and found that Drupal is a good tool to create a news site but I don't know if I can do this or not.
Currently I know nothing about PHP and Drupal.

So my questions are

Is it possible to create, manage and maintain a small news site using Drupal without (or with few) PHP skills?
If Drupal is not a good choice, what other options I have?


texts: How to develop a page which displays data from more than one content type/table

texts:
how do I develop a view/page which displays the data like below.

I have the Image, blogger name ( this is my join field) , profile photo and details as one content type(table)
and Blogs are in different content type (table). Blogs content type has also blogger name.

I'm newbie to drupal and we are using Drupal 7.

Bloggers are not going thru user registration process and as admin's we enter the blogger details as bloggers content type (for those who enter more blogs).

Any help/hints on how to accomplish this


texts: Dynamically change the "access denied page" title and body

texts:
This is not a question about changing or preprocessing the twig template of the 403 page.
I have a controller with an access function called by the _custom_access key of my route.
In some circumstance, this function is returning AccessResult::forbidden("a good reason"); which lead to my default 403 page.
Most of the case, this is the behavior I would like to have, but in few cases, I would like to have another title and another message for this page like "You can not access because you eat too much chocolate"
Should I create a new custom error route and send a new response to this route from my access function? (hint: I tried without success)
Any idea?
Edit to add: Thanks to 4k4, I have added a custom ExceptionHtmlSubscriber extending DefaultExceptionHtmlSubscriber in order to override the on403() method.
Here is my code:
class TXSExceptionHtmlSubscriber extends DefaultExceptionHtmlSubscriber {
  /**
   * {@inheritdoc}
   */
  public function on403(ExceptionEvent $event) {
    $my_condition=extract_from_event($event);
    if($my_condition){
      // I am not sure it is what should be done here
      $this->makeSubrequest($event, '/my_custom_error_path/my_custom_error_code', Response::HTTP_FORBIDDEN);
    }else {
      parent::$this->on403($event);
    }
  }
  /**
   * {@inheritdoc}
   */
  protected static function getPriority() {
    return 1000;
  }
}

So far, I have 2 questions:
1-Unfortunately my custom on403() method is never called (on the other hand, the on403() method DefaultExceptionHtmlSubscriber is called): What I am missing?
2-Let say that my custom on403() method is called: what should be the code to redirect the user on my custom 403 page containing my custom message (ie: it could be nice to display the reason of the AccessResult AccessResult::forbidden("a good reason");


texts: How do I add CSS files only to the front page?

texts:
I am trying to add a CSS file to the front page. I have seen Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme; I just need to know the HOOK machine name for the front page.

function THEMENAME_preprocess_HOOK(&$variables) {
  $variables['#attached']['library'][] = 'CSSPATH';
}

What name should I use for the preprocess function, in order to make Drupal calls it only for the front page?


texts: How can one Delete Drupal content page (article/basic page) without actually visiting the page. Without Drush or visiting the database (which is a little complicated in D.7).