texts: Display node Template with custom ajax module

texts:
I tried to realize a site using ajax to show its content following this guide.

The result is a module with following code:

<?php
    function simple_ajax_menu() {
        $items['simple_ajax/%/%node'] = array(
                'access arguments' => array('access content'),
                'page callback' => 'simple_ajax_callback',
                'page arguments' => array(1,2),
                'type' => MENU_CALLBACK,
        );
        return $items;
    }

    function simple_ajax_callback($js, $node) {
        // If the nojs didn't get changed to ajax, the user has no javascript.
        // Send them to the regular node page instead.
        if ($js == 'nojs') {
            drupal_goto('node/' . $node->nid);
        }

        // Get the render array for the node.
        $build = node_view($node);

        // Render the node into html.
        $html = render($build);

        // Prepare an ajax command to insert the node html into our ajax wrapper.
        $commands = array();
        $commands[] = ajax_command_html('#block-system-main', $html);

        // Render the commands into JSON and print them.
        print ajax_render($commands);
        exit;  // Exit so Drupal doesn't have a chance to build a whole page.
    }

This shows the correct node at the correct position but does not use the node template as it would when requesting /node/[nid]. I have set up a page for "/node/%node" with a variant "Product" that is shown when requesting a node and want this to be shown when called with ajax as well.

So far I tried setting the view mode to the Product variant.

        // Get the render array for the node.
        $build = node_view($node, "Product");

Without any effect.

Any suggestions what I am missing? Thanks in advance!


texts:
So, this is a newbie question. I'm using Automatic Nodetitles with a custom content type. I'd like the node's title to be equivalent to one of my fields. After some snooping around I came up with this:

<?php return $node->field_my_field ?>

I put this in the "Pattern for the title" field, but this just returns 'Array'. So, it must be an array. However, I'm not having any luck figuring out how to index it to get the value I'm looking for. Everything I tried just gives me 'Undefined offset' errors.

This can't be too hard.... Thanks!


texts:
We have the following mymodule_preprocess_node hook where we add two arrays with two key-value pairs. In twig, we would like to merge the values.

How would we merge the two arrays in twig?

Here is what we tried.

mymodule_preprocess_node

function mymodule_preprocess_node(&$variables) {
  // perform some logic.

  $variables['content']['ary']['foo'] = 'foo_value';
  $variables['content']['ary']['bar'] = 'bar_value';
}

node--article.html.twig

{% set twigAry = [] %}
{% for key, value in content.ary %}
  {$ set twigAry = twigAry|merge({ key : value }) %}
{% endfor %}

This results in twigAry only having the following. It basically prints the last key and value, which is bar and bar_value. Strangely enough, instead of setting the key to bar it results in the key being key.

[
  'key' => 'bar_value'
]

Desired Output

[
  'foo' => 'foo_value`,
  'bar' => 'bar_value',
]

In the twig template, we are adding an inline <script> tag that needs to have the array in the desired output as such we need to have in this format in twig. For example, when we load the Marketo form, we want to set some values like this. Rather than hardcoding items in twig, we will just use the ['foo'] and ['bar'] from the preprocess method.

MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
    // Set the value of the Phone and Country fields
    form.vals({ "Phone":"555-555-1234", "Country":"USA"});
});

Final twig:

{% set twigAry = [] %}
{% for key, value in content.ary %}
  {$ set twigAry = twigAry|merge({ key : value }) %}
{% endfor %}

MktoForms2.loadForm("//app-sjst.marketo.com", "785-UHP-775", 1057, function(form) {
  // Set the value of the Phone and Country fields
  form.vals({ twigAry });
});


texts: The connection was reset when creating a new node

texts:
On a localhost environment, when I try to create a new node, I get this message:

  The connection was reset.

There is some issue with css, cache and/or registry since when I disable the css aggregation it works for the next node and it stops for the next node creating. In order to work again for a new node it needs enabling the Css aggregation and so on.

Also when I clear caches I get this kind of messages:

  The following module has moved within the file system: views_test. In order to fix this, clear caches or put the module back in its original location. For more [warning] information, see the documentation page. bootstrap.inc:1128

Any suggestions?
Thanks.


texts: Storing the value of a form submission in a hidden field or the database

texts:
So I have created a form for user's to store some documentation about a node they have created but I do not want this documentation to be shown on the node's main page.  I would like the main page to have a link to either view or edit the form.

Now as far as I can tell there is no way to create a field that doesn't show up directly on the node create or viewing pages (this seems like it would be a misuse of a field anyway).  Is there anyway that I could store what the user enters in this documentation form as part of the content without it being displayed on the node page or would I have to create a database table that associates a nid with the documentation string?  Also, my form allows for use of filtered html in the form, will this be preserved if I store the filtered html as a string in the database?


texts: Drupal 7 Override Image Alt and Title attributes

texts:
In Drupal 6 I used the Imagefield Tokens module to set ALT and TITLE tags to default values if not specified (generally the node title).

I'm looking for applying this in Drupal 7, but I am having troubles. I found this thread, but it's a bit inconclusive.

Would it be possible to do this using a template preprocess or a field.tpl.php override?


texts: Unpublished taxonomy term keep showing in main menu and contextual filter

texts:
I'am creating a Drupal 8 multilingual side, i have a main menu and a contextual filter that uses taxonomy term. in english version i wont translate all those taxonomy, so i dont want theim to be displayed on the menu neither on the contextual filter.

i've tried to uncheck the button "this translation is published" for the translation but the taxo keep showning on the site :/

Any help please?


texts: How to add static content before the feed on the front page?

texts:
I want my front page to contain some static content (a short description of our association), and after that the normal feed of articles fed by "promote to front page".  How can this be achieved?

I know how to add content to the front page feed and I know how to change the front page to another page, but I couldn't figure out how to get both static content and the front page feed.  (It seems such obvious and often-wanted functionality for a front page...)


texts: Database error: Lost connection to MySQL server at 'reading initial communication packet'

texts:
this has driven me crazy, I just couldn't find out what is wrong with it.

I moved my site onto a test directory under my domain '/drupal_test', I have transferred the database over, set up everything properly, and then I got this error:

PDOException: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 111 in lock_may_be_available() (line 167 of /var/www/drupal_test/includes/lock.inc).

I have set up settings.php like this:

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'websitedb',
      'username' => 'websitedbnm',
      'password' => 'thepass',
      'host' => 'xxx.xxx.xxx.xxx',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

I am really sure all the data is right. I can connect to my database through command lines using this account and I can also see all the right tables in this database.

I also tried commenting and editing this line:

$base_url = 'http://www.example.com/drupal_test';  // NO trailing slash!

I still get this error and can't see my site...what could have gone wrong?


texts: How can I get a checkbox to return True/False?

texts:
I'm working with the form API and I have a series of checkboxes. I need them to return true or false instead of 1 and 0.

$form['checkbox1'] = array(
    '#type' => 'checkbox',
    '#return_value' => 'true',
    '#title' => t('Checkbox title'),
    );

This works if the box is checked, but if it's left unchecked it still returns 0. Is there a way I can get an unchecked box to return false?


texts: Creating a node that contains paragraphs / field collection / entity reference fields

texts:
The Services module is good for creating nodes via a REST API, but how can you create nodes that contains reference fields like paragraphs, field collections, or entity reference fields? I couldn't find any examples of someone doing this or a module that solves this problem.

What solutions are there to create nodes with reference fields using the Services module?


texts: Migrate-d2d UI - Where does sites/default/files source content go?

texts:
I am setting up a dedicated development environment on my home LAN where I can work on a Drupal 6 to Drupal 7 migration. So far, I have a clean Centos 7, LAMP stack, and Drupal 7 install and have configured periodic file and image backups to my local NAS. The D6 drupal database has been imported and connected in settings.php and appears to be recognized by the migrate_D2D UI.

What I am unclear about is how to migrate the D6 site's downloadable file content and images under sites/default/files.  Although the D6 site is live and remote, I was thinking about copying relevant portions of the sites/default/files path over to the development system, but I don't know where to put it or how to reference it as a data source in the migration process.

I would assume that the format or field mapping conventions for content in sites/default/files is different between Drupal 6 and 7 and source and destination content must remain separate, but I am not sure about this.  So can anyone advise me as to the best approach for incorporating this D6 content into D7?  I would be happy to either copy the content over or read it remotely from the live site if this is supported.  Thanks.

19 hours later:

I haven't resolved this yet so let me ask my question again with a couple of visual aids.  Here is the file tree of the sites/default/files section from my legacy Drupal 6 website:

Here is the file tree of the sites/default/files section from the clean install of the Drupal 7 website I am trying to migrate into:

My question is where migrate_d2d wants me to put the legacy (source) Drupal 6 files.  Do I put it inside the new sites/default/files tree or somewhere separate from where the post-migration Drupal 7 files will be?

Thanks again.


texts: control the view access permissions by field.tpl.php in D7

texts:
I would like to be able to control who can view a field by a custom field.tpl.php for a given field. Basically I would like to set a coditional at the beginning so that is displays nothing if the user does not have a given role (say, "registered-user").
I would think that this amounts to adding an "if" at the very beginning of the the field template, but I do not have much experience.
Is it possible to do it that way?


texts:
I tried to look for bulk page manager for Drupal 7, but I wasn't successful. More specifically, I'd like to change access settings for multiple pages in one step. Something similar to what VBO provides for entities.

Any suggestions?


texts:
I have updated today to the latest version of Advanced Forum and when trying to post a new topic got the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '329-node' for key 'PRIMARY': INSERT INTO {ip_posts} (type, id, ip) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 329 [:db_insert_placeholder_2] => 38932973 ) in ip_posts_insert() (line 162 of /home/thanatos/public_html/sites/all/modules/ip-7.x-1.4/ip/ip.module).

Could this be related to php timeout? I'm asking this because I took quite a while typing the Topic before posting it, because I was working it in HTML in Dreamweaver. However when I went back and created a new topic and posted it instantly, I had no issues.

Thanks in advance.

Miguel


texts: How can I programmatically get various common user profile related URLs?

texts:
I'd like to get the following URLs in Drupal 8:

/user/register
/user/login
/logout
/user

I already know I can use \Drupal::service('path.current')->getPath() to get the current path. I want to build links to redirect users.
How do I get these paths programatically?


texts: scheduled site backup at specific time / hour

texts:
How to schedule a backup of Drupal site (especially database) at specific hour on a shared host? I am using Backup Migrate module, but it doesn't support hours, only frequency. It currently makes daily backups around 8 pm.

I checked this shell script, which could be added to cron I think, but it doesn't send mail after backup and doesn't allow to specify "only structure" for cache tables.


texts: How can i change the secondary menu id, by default it has the same id like primary menu. My primary menu id is menu-main-navigation and when i print in twig the secondary menu like {{ page.secondary_menu }} it prints with same id.


texts: I want to add a slideshow in my Drupal website. But i dont know how to add jQuery file in Drupal.


texts: Service is being instantiated during installation with unknown entity type call

texts:
I have a module that defines two services. Service A has service B as dependency.

Service B has some dependencies, one of which is entity type manager.

In the constructor of the service B an entity storage is being called for entity type that is defined by this module as well

public function __construct(AccountProxy $user, EntityTypeManager $entity_manager, QueryFactory $entity_query) {
    $this->user = $user;
    $this->storage = $entity_manager->getStorage('entity_type_name');
    $this->query = $entity_query->get('entity_type_name');
  }

During installation I get error about unknown entity and the installation breaks. I have tried to backtrace the cause of this but so far it looks like everything is in order. The container is only parsing the service definitions and instantiates them when needed. What I think might be the issue is the order in which the entity definitions are processed and service definitions parsed.

I do not want to add any condition into service B constructor to check if installation is in progress. I think this should not be happening.

What would be a proper workaround?


texts: Which hook to implement to limit node creation?

texts:
I'm looking to limit the number of nodes that a user can create in Drupal 7.

Which hook should I implement to step in before the 'add node' page is shown?


texts:
I'm developing a module. I need to give to the users the option to download the coupons in XLS (Excel) format.
How I can do this?


texts: Manually changing URL alias values via phpmyadmin? What does this affect?

texts:
I have a bunch of aliases in my url_alias table. I want to change the source of certain rows, but I'm not sure if it would affect anything. What I need to know is if the column PID in the url_alias table is linked to anything else. Currently I just want to switch node/33 to node/2343, but im afraid I might break something if im doing it via phpmyadmin. I can't do it via the site as I have over 100+ entries I have to modify. The easiest way is by doing it in mysql.

Also is there a drupal database table map I can generate that shows me how each table is linked to each other?


texts: create views for a field submitted more than once in one row

texts:
I have a content type that only has one field. (for example weight)
The user submits this field multiple times.
now I want to create a view that shows all the weights submitted by the user in one row, not in separate rows.

How can I create this kind of view?


texts: How to display multiple default items for field collection with unlimited cardinality?

texts:
I have used following code and it works fine i.e 3 items are displayed, but the issue in my code is add another item button remains inactive on click.

<?php

function two_form_alter(&$form, $form_state, $form_id) {

  if($form_id == 'product_culinary_node_form') {
    $field_language = $form['field_tabs']['#language'];
    $items_count = 3;

    $field_name = 'field_tabs';
    $form_theme = $form[$field_name][$field_language]['#theme'];

    // Remove delete and add more buttons
    // $form[$field_name][LANGUAGE_NONE][0]['remove_button']['#access'] = FALSE;
    $form[$field_name][$field_language]['add_more']['#access'] = TRUE;

    $items = &$form_state['field'][$field_name][$field_language];

    // Generate required number of fields collection
    if ($items_count > 1 && $items['items_count'] != $items_count) {
      $items['items_count'] = $items_count;

      // $items['field']['cardinality'] = $items_count;
      $wrapper = $form[$field_name][$field_language]['add_more']['#ajax']['wrapper'];
      $field_parents = $form[$field_name][$field_language]['#field_parents'];
      $language = $form[$field_name][$field_language]['#language'];
      $after_build = $form[$field_name][$field_language]['#after_build'];
      $form[$field_name][$field_language] = field_multiple_value_form($items['field'], $items['instance'], $field_language, array(), $form, $form_state);
      // Reset theme function, as field_multiple_value_form hijacks it
      $form[$field_name][$field_language]['#theme'] = $form_theme;
      $form[$field_name][$field_language]['#after_build'] = $after_build;
      $form[$field_name][$field_language]['#language'] = $language;
      $form[$field_name][$field_language]['#field_parents'] = $field_parents;
      $form[$field_name][$field_language]['add_more']['#ajax']['wrapper'] = $wrapper;
    }
  }
}


texts: Do something conditinally on node.tpl.php depending on if the node is tagged with certain taxonomy vocabulary

texts:
I found how to do this if the node is tagged with certain terms here.
But what I would like to do is to do something conditionally in node.tpl.php only if the node is tagged with a certain vocabulary.

For example, I have a vocabulary called "Color" with terms "Red" "Blue" "Yellow". I would like to display the text "It has color" only if the node is tagged with at least one of those terms. Otherwise print nothing.

How can I do this in  node.tpl.php ?


texts: Reduce the amount of information returned from standard service actions

texts:
I have a Drupal 7 Services that my frontend call when I want to get (for example) all comments of node XYZ. All works, but I want to reduce informations that this call return (yes, from the backend). For example "hostname, mail, changed, registered_name, signature" are all data that I don't want to return back. Other example: if I call "user/X" service path it return "password, mail" and other informations that I consider private.

So, how can I intercept and remove this data before that service module send it back to the caller?


texts: Ajaxify certian content on the front page

texts:
My site uses dashboard as front page and loads boxes to show content. As there are many boxes, the page takes some time to load. So what i want to do now is to load the theme and interface first and then load the boxes using ajax.
Is there any kind of solution already available or something that needs to  be tailored.

My site is here


texts: I've got a page which returns X-Drupal-Dynamic-Cache: UNCACHEABLE, I've got a suspicion that this is related to a view that is embedded in the page. Though, this made me wonder; is there any way to see what invalidated actually the page cache?


texts:
I'm trying to create a hierarchical taxonomy from a perpared migration database table which looks like that:

ID | NAME | PARENT
------------------
 0 | FOO  |
 1 | BAR  |
 2 | LORE | FOO
 3 | IPSE | FOO
 4 | DOLO | BAR

It's a pretty messy data structure, but fact is there are parent and child terms in one table.

What I did so far is migrating the parent terms first. Now my custom taxonomy looks like this:

_
|_ FOO
|_ BAR

The migration code snipped I used to achieve this works like that:

$this->addFieldMapping('name', 'PARENT');

Until now everything works as expected!

Now, in a second migration step I want to add the child terms like that to my taxonomy:

_
|_ FOO
  |_ LORE
  |_ IPSE
|_ BAR
  |_ DOLO

What I tried is to add a hierarchical mapping to my migration:

$this->addFieldMapping('name', 'NAME');
$this->addFieldMapping('parent_name', 'PARENT')
    ->arguments(array('source_type' => 'name'));

But this does not work, the result is an unhierarchical list like that:

_
|_ FOO
|_ LORE
|_ IPSE
|_ BAR
|_ DOLO

Did anyone try to do something like this before? Any ideas? Thanks!


texts:
How do I print the output of a field as a link on node.tpl.php? I'm able to print the raw output of a field using this:

<?php $display = array('label' => 'hidden');
$view = field_view_field('node', $node, 'field_podcast_url', $display);
print drupal_render($view);?><?php $display = array('label' => 'hidden');?>

The problem occurs when I try to make it as a link using this method:

<?php $display = array('label' => 'hidden');
$view = field_view_field('node', $node, 'field_podcast_url', $display); ?>
<a href="<?php print drupal_render($view); ?>">text

The output looks like this:

http://www.podtrac.com/pts/redirect.mp3/feeds.soundcloud.com/stream/211653270-scott-johnson-27-tms-846.mp3
">text

and the link points to this:

http://controldaily.dev/<div class=

I've looked around at solving this issue and can't find a solution. Anything else just shows nothing.


texts: How can I set up an existing site from Pantheon on my computer?

texts:
I am a real newbie to all this so I appreciate all the help.

I am helping a company develop a Drupal website which already exists and is hosted on Pantheon. I have login access to the drupal site. How do I get the current codebase for the existing drupal site?

From what I understand, Pantheon automatically commits codechanges to the development section. However pantheon seems to use git so I downloaded git and then created an ssh key and pasted it into my account on pantheon. So I think I have created the connection between my laptop and pantheon.

So really all I think I'm missing is how to extract the codebase.

Thank you and let me know if I'm missing a whole bunch of other steps.

By the way do I have to use git? Or can I use github?


texts: Need help defining IE specific stylesheet with Zen Starter-kit and Conditional Stylesheet Module

texts:
I need help defining a conditional IE stylesheet in my .info file.

I am using the Zen starterkit as my base theme, and I have the conditional stylesheet module installed and enabled. I have added an ie.css file added to my css directory along with my other stylesheets. In that ie.css file, I have changed the background to an obnoxious color to confirm when the stylesheet is being used appropriately.

However, I have been struggling with what I need to put in my .info file. I have researched as much as I could and read the help.txt file multiple times.
I just want this stylesheet to target IE. I do not want to create one for each version. This site will not support ie6 and ie7 anyways.

Here is what I currently have defined in my .info file for it:

stylesheets-conditional[if IE][all][] = css/ie.css

I have also tried this that just results with that stylesheet loading for all browsers:

stylesheets-conditional[!IE][all][] = css/ie.css

So far with all of my attempts, I can either get it to act as a normal stylesheet, having it override my other styles, or not having it load at all. Is there something I need to add in my page templates that I am overlooking?

I have this in the head of my html.tpl.php as well (I have my actual theme name in there):

<!--[if IE]><link rel="stylesheet" type="text/css" href="sites/all/themes/THEMENAME/css/ie.css" /><![endif]-->

Other resources that I have used:

1) Conditional Stylesheets Set-up: Using the Module

2) Add conditional stylesheet CSS for internet explorer only (not trying to use this method)


texts: Is there a nodequeue module for ordering and selcting taxonomy terms instead of nodes for used in a view?

texts:
Currently I want to make a curated slideshow of taxonomy terms displaying the name of the term with an image field thats attached to the term. Typically this is easily done with a basic node and the module nodequeue. The thing is I want to be able to do this with taxonomy terms.

I found entityqueue module that could work, but its crashing on my site for some reason. It works on a new install and I cannot pin point the issue since the site is fully built out already. I was wondering what other ways or possible modules I can do this with?

What I'm building is just a curated slideshow view of taxonomy terms.

*edit -- found the culprit module that was conflicting with the entityqueue module. whenever i turn on the entityqueue module the entire site would crash and i would end up having to do a DB restore. The module that was causing this conflict was "admin_menu"! O_O


texts: How to add custom class in body tag on form submit?

texts: I have created custom module with custom form, in which I have added input type select. Form submission is working fine, but I wanted set select option value as custom class for BODY tag.


texts:
I have a view that receives some arguments from a questionnaire. In the questionnaire I calculate a list of nodes that's sorted by how well they correlate with the questionnaire. Once my view receives these arguments it will just sort them by their node id, and not the custom ordering I already applied when sending the arguments.

Is there any module that will display my nodes in a view, in the same order the arguments are received from the previous page?

I already tried views_arguments_extra, but this cannot achieve what I'm trying to do.

An example:

in my questionnaire I have determined that the 5 following nodes have the highest correlation:

7: 86%
8: 83%
12: 82%
1: 80%
2: 79%

I will then send this top 5 as an argument to my view.

So I also want my view to have that order:

7
8
12
1
2


texts: Managed_file form does not show #default_value

texts:
I am using managed_file in Drupal 7 for my custom module. Other than the form api and managed_file, I'm using my own custom tables for this module.

This will eventually be used on shared hosting via Dreamhost, so the requirements of using PECL extensions are probably not available at this answer suggests.

The behavior I want is when the file is uploaded by clicking the "upload" button, I at least want the image file to be a link that appears to indicate to the user that the file is uploaded. When I left the default #progress_indicator in place, the AJAX indicates it never uploads. However, this is false as I can see the file in managed_file table in the db.

I've looked through several searches for this and this is the form that I've come up and I cannot see what I'm doing wrong.

$item is the result of a database call of the previous object. Its genesis was derived from a post jaypan provided.

$form['#item'] = $item;

dpm($item); => //every attribute to the sponsor object in the database.

$uri = isset($item->logoFileID) ? fetch_name('file_managed', 'uri', 'fid', $item->logoFileID) : '';

$uri = isset($item->logoFileID) ? fetch_name('file_managed', 'uri', 'fid', $item->logoFileID) : '';
dpm($uri); => 'public://logos/myfile.gif' //to show valid return of $uri
dpm($item-logoFileID); => 'public://logos/myfile.gif'

  $form['logoFileID'] = array(
    '#title' => 'file key',
    '#type' => 'hidden',
    '#default_value' => $item->logoFileID,
    );
 $form['logo_fid'] = array(
    '#type' => 'managed_file',
    '#title' => t('Logo'),
    '#description' => t('Upload a file, allowed extensions: jpg, jpeg, png, gif'),
    '#upload_location' => 'public://logos/',
    '#progress_indicator' => 'none',
    '#default_value' => $file->uri,
    );

As I said, managed_file does save the file and returns an fid that I save with the sponsor record. The behavior I have gotten in this module is that the filename was showing in this part of a form, that when clicked in Drupal shows a popup modal of the image. My question is how do I get this back link back to appear in the form to show the user it has been uploaded?, thx sam


texts: Cannot create users as administrator. Users can register by themselves but I can't add users (site exported directly from Drupal Gardens)

texts:
I have a weird problem with my user registration in 2 of my sites. When I go to the "Add User" link under "People" menu, I fill in the information of the user and press the "Sign Up" button. The page refreshes, there is no error message or a confirmation message that the user has been added and the user is not added. I have checked the error messages in the "Reports" section and no entry is created there either.

When I turn on the user registration from "Configuration - Account Settings" a user can create a new account and I can edit the account as admin but I still can't create new user accounts.

Some extra information:

The site that I created is a direct export from Drupal Gardens. I did not mess with any code. It's pretty clean, direct export.

Any ideas on how to troubleshoot this and find out what is causing this strange issue?

Edit: for the time being I use the workaround to manually register through the regular user registration form and then disable the manual user registration and edit the users as admin but I'd prefer the normal functionality for obvious reasons.


texts:
I'm using "Unpublish comments with keywords" action. I've just noticed a PHP error on submitting any comment.

  drupal_render() expects an array but comment_unpublish_by_keyword_action() calls it with $comment object. And we have a WSOD.

That's part of error.log

  [error] [client 127.0.0.1] PHP Fatal error:  Cannot use object of type stdClass as array in /.../includes/common.inc on line 5672, referer: http://.../comment/reply/28

any suggestions?


texts: How to create a page to custom display of particular node type and add it to node context menu?

texts:
I created custom node type, let's say "My Node".
I created custom node display type (at /admin/structure/display-modes/view), let's say "Specialized Display".
Configured the "Specialized Display" for "My Node" - configured some fields, their order, etc.
How can I create a page on path "node/*/specialized-display" for "My Node" nodes using "Specialized Display"? (I.e. reject "node/123/specialized-display" if "node/123" is not "My Node", but e.g. "story".)
How can I make a tab appear in node context menu (the one which contains "View", "Edit", "Delete" tabs)?
Bonus question: how can I make URL automatic alias(es) "[alias of node/%]/specialized-display"?

What I tried

Created view page, path "node/%/specialized-display", use contextual filter (to reject different node types, use argument for node selection and to alter page title).

Problems:

Couldn't find out how to add it to the node context menu.
It creates redundant node title on the page (one for whole page and one for item in view). Couldn't find out how to remove it, but it's not that big problem, I'll remove is using CSS (although accessibility is going to be damaged).

My system: Drupal version: 8.8.3


texts:
So I'm trying to get an event subscriber working for EntityTypeEvents and I can't figure out why it's not firing.

This is a general outline of the code:

namespace Drupal\subscriber_class_module;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Entity\EntityTypeEvents;
use Drupal\Core\Entity\EntityTypeEvent;

class SubscriberClassModuleSubscribesToEntityTypeEvents implements EventSubscriberInterface {

    public function onCreate(EntityTypeEvent $event)  {
          //Do things on creation
    }
    public function onUpdate(EntityTypeEvent $event)  {
          //Do things on update
    }
    public function onDelete(EntityTypeEvent $event)  {
          //Do things on delete
    }
    static function getSubscribedEvents() {
         $events = [];

         $events[EntityTypeEvents::CREATE][] = array('onCreate', 100);
         $events[EntityTypeEvents::UPDATE][] = array('onUpdate', 100);
         $events[EntityTypeEvents::DELETE][] = array('onDelete', 100);
         return $events;
    }
}

Added class declaration and namespacing.  I should note that the same class that I am using has no probablem firing on kernel events, I'm just wondering if there is something special about entity events.


texts: Search API view in not returning all results for full text search

texts: I have a search API indexed content view. Which uses full text search exposed filter. I have selected few taxonomy term names and other field in the full text search. But when I search for a term name, it returns only few results but not all. Please see the below image for the filter field.


texts:
I tried to get the current language in the menu.html.twig template file.

The current language is not available in this template and a preprocess function is not existing for this template as far as I could see. So I did not manage to get the current language by using template_preprocess function as it is described here.

I tried a few things but ended up creating my own Twig function that delivers \Drupal::languageManager()->getCurrentLanguage()->getId() in this (and any other) template.

I could think of declaring a global variable maybe in template_preprocess(), but I believe this is not a good option if I only want it in one special template.

So my question is:
Is it a proper way for this to go via own TWIG function or is there another more easier way of doing this?

For reference I used code like this:

class MyLanguageCheckerExtension extends \Twig_Extension {

  public function getName()
  {
      return 'lang_check';
  }

  public function currentLang() {

    return \Drupal::languageManager()->getCurrentLanguage()->getId();
  }

  public function getFunctions() {
    return array (
      new \Twig_SimpleFunction('languagecheck', array($this, 'currentLang')),
    );
  }
}


texts: How to create additional base fields for ECK entity

texts:
For example I want to create a Vehicle ECK base type and Car and Truck bundles, but I want to define fields for the Vehicle base type that would be shared between Car and Truck.

In UI, by default, I'm limited to this

I want to create more fields and use them in this form


texts: I have a view of events and I want each event to have a "Register" button that brings up a webform form for the event. Obviously the filled out form should be saved so that I can tell who signed up for which event. I'm pretty new to Drupal so I'm not sure what the best approach is to associate each event with a webform.


texts:
I'm trying to customize user login form in /user/login page and I want to use a hook_form_alter function to add some awesome style and placeholder to each of user login form fields and remove or hide: "Enter your admin username" and "Enter the password that accompanies your username" description expressions under each of theme.
To resolve this issue I added something like below code to my ThemeName.theme:

function ThemeName_form_alter(&$form, $form_state, $form_id) {
  if ( $form['#form_id'] == 'user_login_form' ) {
    $form['actions']['submit']['#attributes']['class'][] = 'button glow button-primary expanded';
    $form['keys']['#attributes']['placeholder']['name'] = t('User name');
    $form['keys']['#attributes']['placeholder']['password'] = t('Password');
  }
}

I try out many different ways but I can't get any result.
in finally I want to achieve something like below image:

I read this pages but seems none work in Drupal 8:
How to modify the fields of user registration form and user login form?
Modifying the default user registration page
Customize user login block


texts: Added ajax to a Link but its not working

texts:
I added a class use-ajax to a link but Its not updating the wrapper `div. My Code is:

function custom_menu(){
  $items['testing'] = array(
    'page callback' => 'articlenodeform',
    'access arguments' => array('access content'),
  );
  $items['customajaxcallback'] = array(
   'page callback' => 'custom_ajaxcallback',
   'access arguments' => array('access content'),
  );
  return $items;
}

function articlenodeform(){
   drupal_add_library('system', 'drupal.ajax');
   drupal_add_js('misc/ajax.js');
   $link = l(t('Say Hello'), 'customajaxcallback/ajax', array('attributes' => array('class' => 'use-ajax')));
   return '
'.$link.'

';
}

function custom_ajaxcallback($type = 'ajax') {
  if($type == 'ajax') {
    $output = t('Hello World!');
    $command = array();
    $commands[] = ajax_command_append('#sayinghello', $output);
    $page = array('#type' => 'ajax', '#ajax_command' => $commands);
    ajax_deliver($page);
  }
  else{
    return t("Hello world in new page.");
  }
}


texts:
My view is showing the list of teasers correctly, but when I want to read more and see the full body text I get the "Page not found" error. I've been searching through all my settings, permissions etc. and can't find the error. It might have something to do with the view, but I can't see any error there either. Any ideas?

Screenshot of the view settings:

I can easily find the node body in the MySQL table field_data_body.


texts: Are service autowiring and class autoresolving not anymore supported?

texts:
In Drupal 8, I needed to define services via the mymodule.services.yml file only, if I wanted to use them via the service container. I could also autowire them and the classes were automatically resolved.
services:
  my_module.twitter_feed:
    class: Drupal\my_module\TwitterFeed
    autowire: true

  domcrawler.crawler:
    class: Symfony\Component\DomCrawler\Crawler
    public: false

In Drupal 9, it looks like I must define all my custom classes inside the mymodule.services.yml file. Drupal 9 seems not to be able to identify my classes without an entry within the mymodule.services.yml file. There seems to be no autoresolving anymore. Symfony 4 and 5 are able to do that and Symfony 3.x (Drupal 8) was definitely able to autowire services and find classes by its own. Drupal seems to have its own service container, which suppresses that functionality.
Defining every single PHP class within a *.services.yml file is a huge amount of work for upgrading and maintaining my project. I cannot believe that Drupal 9 requires this work, because the Symfony framework already does that automatically.
Do you know any way to re-enable PHP class autowiring and autoresolving in an upgrade from Drupal 8 to 9?
I hope that anybody else was struggling with autowiring during an upgrade from Drupal 8 to 9 and knows any solution.


texts: I have used   $(document).ready(function(){$.colorbox({inline:true, href:"/node/989386"});}); on page on load but i am getting empty content, Any pointers


texts: How to link the parent of a Nice Menu to nowhere?

texts:
In order to make a Nice Menu, I created a menu like this:

My Menu
   - First link
   - Second link
   - Third link

The menu works perfectly fine, but I also had to fill in a link for the 'My Menu' (I've set it to the frontpage). However, I'd like the parent link to be linked to nowhere. How can I do that?

This is the relevant code for the menu's parent:

    My Menu

Note: At first, I couldn't get the code from the accepted answer working, because I forgot to load my theme's MYTHEME.js file. After reading this, I learned that one can do that by adding scripts[] = MYTHEME.js to the MYTHEME.info file.


texts: How to create a tick list which one role can alter for 'lesser' roles to see?

texts:
I would like some pointers as to what might be the best approach to this issue please?

An admin role needs to be able to interact with a list of nodes for a fitness site. They need to be able to show/hide these nodes in a list for 'lesser' roles.
In addition to this the admin needs to be able to mark the node as complete so that the 'lesser' role can see this update. ie

Admin sees options to amend node list:

Lose 10 lbs - Show - Mark as complete

Attend 2 sessions - Hide - Not marked as complete

Run 3 miles this week - Show - Not marked as complete

'Lesser' role sees:

Lose 10 lbs - Complete.

Run 3 miles this week - Incomplete.

Obviously, I would like to be able to extend this list so that each user is able to see a list that is unique to them, which the admin role has interacted with to show/hide and complete/incomplete different sections.

I'm puzzled as to what approach I ought to take and would really welcome some suggestions to get me started.

Thanks.


texts: Drush sql-sync: Access denied; you need the SUPER privilege for this operation

texts:
I am trying to use drush to move my live database down to my dev database. I am doing

drush sql-sync @live @devel --sanitize

However I get the error:

  "ERROR 1227 (42000) at line 1478250: Access denied; you need the SUPER privilege for this operation"

I think it is due to the views in the db from uc_views module, is there any way around this?

I also tried to do

drush sql-sync --skip-tables-key uc_views @live @devel --sanitize

where uc_views is an option declared in drushrc.php with an array of the db views from uc_views, but to no avail.
Here is my drushrc.php

$options['skip-tables']['uc_views'] = array('uc_order_products_pair_vw', 'uc_order_products_qty_vw', 'uc_order_products_user_vw');

I would actually prefer to copy the database views from uc_views rather than exclude them if that is possible.


texts:
I'm managing a content sharing site built on drupal 7 and I would like to let users submit links as content.

Is there a simple way of creating a thumbnail / preview of the link (like on facebook)?


texts:
I have a form where we are displaying a static text like:
Please select the <icon> button to view X

Where the icon is a an image. I've added this piece to the form by doing the following:
$form['message'] = [
  '#type' => 'item',
  '#markup' => $message
];

However, when $message contains the icon like Please select the  button to view X, the image tag appears instead of the image. I can't do separate items because the text is translated, so how can I insert an image in the middle of a sentence like this?
The code that sets $message I tried is the following.
$message = 'Please select the  button to view this page';

$message = '
Please select the  button to view this page
';

$message = '
Please select the  button to view this page
';

I also tried setting the allowed tags with #allowed_tags as well, but it didn't work.


texts: Drupal nginx configuration. PHP files being downloaded

texts:
Problem

I'm trying to configure my nginx server. I've been building from the default rather than jumping straight into Perusio's because I don't understand a lot of it.

I'm trying to deny access or require authentication to access update.php, install.php and apc.php.

I think they're locked down but on navigating to the file it's downloaded instead of being run.

For example after entering my authentication for apc.php it downloads to my computer. The same thing happens for update.php.

I've taken a lot of the configuration from another excellent post on here: Is there a common nginx conf for Drupal 7 sites?

My Server Config

server {
      listen 8080;
        server_name website website.com;
        access_log /srv/www/website/logs/access.log;
        error_log /srv/www/website/logs/error.log;
        root /srv/www/website/public;

        location / {
           index index.php index.html index.htm;
           error_page 404 = @drupal;
        }

        ##drupal rewrite rules
        location @drupal {
            rewrite ^(.*)$ /index.php?q=$1 last;
        }

        ##secure private file directory
        location ~* /privatefiles {
             internal;
        }

        ##Add headers to advagg
        location ~* files/advagg_(?:css|js)/ {
            access_log off;
            expires    max;
            add_header ETag "";
            add_header Cache-Control "max-age=290304000, no-transform, public";
            add_header Last-Modified "Wed, 20 Jan 1988 04:20:42 GMT";
            try_files  $uri @drupal;
        }

        ## Replicate the Apache <FilesMatch> directive of Drupal standard
        ## .htaccess. Disable access to any code files. Return a 404 to curtail
        ## information disclosure. Hide also the text files.
        location ~* ^(?:.+\.(?:htaccess|make|txt|log|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
            return 404;
        }

        location ~ \..*/.*\.php$ {
            return 403;
        }

        ##deny access to update and install for everyone except the server
        location ^~ /update.php {
            allow 127.0.0.1;
            deny all;
        }

        location ^~ /install.php {
            allow 127.0.0.1;
            deny all;
        }

        ##authentication required to access apc.php
        location ^~ /apc.php {
            auth_basic "Restricted access"; #realm
            auth_basic_user_file /srv/www/website/public/.htpasswd-users;
        }

        ##rules for running php
        location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            if ($uri !~ "^/default/files/") {
                fastcgi_pass 127.0.0.1:9000;
            }
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /srv/www/website/public$fastcgi_script_name;
         }

 }


texts: Which hook/filter do I need to use to modify the 'add node' page title (This Title)?  For example, when viewing "/node/add/" I want to change the title from 'Create ' to 'Add New '


texts: The correct way to change the name of the language in the language switch

texts:
I try to change the name of language in language switcher from Chinese, Simplified(简体中文) to 中文. Changing name in admin/config/regional/language/edit/zh-hans affects only English. So the language switcher looks like this:

  en/Chinese, Simplified(简体中文)

I created a function, but on some pages (e.g. node/1), it causes errors.

function theme_preprocess_block(&$variables) {
   $variables['content']['#links']['zh-hans']['title'] = '中文';
}

The error I get is the following one.

  Fatal error: Call to a member function getText() on array in /var/www/mysite/core/includes/theme.inc on line 1697

How can I fix this?


texts:
I have Drupal 7 site using a custom theme, which was working just fine. I created some regions and then I went and extracted some parts of the html.tpl.php file and made them blocks to make them translatable. The idea was to display these new blocks in the new regions. But all of a sudden my theme stopped working and now drupal ignores my html.tpl.php file and uses the default. I have no idea what went wrong. Any help is much appreciated.

EDIT: I checked the logs and i noticed this error, just before the problem begun.

The directory /var/www/***********/tmp does not exist and could not be created.

I have a development server which runs the same site and this directory is specific to that. So i created a /tmp directory in the live site and set it in the configuration page but still the problem persists.

EDIT2: I am using a template.php file to send the blocks to the html.tpl.php. Something like this:

function <themename>_preprocess_html(&$variables) {
  $variables['footer_menu'] = block_get_blocks_by_region('footer_menu');
  $variables['info_bar'] = block_get_blocks_by_region('info_bar');
}


texts: WSOD when trying to configure menu with many items

texts:
I have a menu with many nested/multi-lingual menu items (I don’t know the exact number, probably something around 2000-3000).

Whenever I try to visit its configuration page in the backend (/admin/structure/menu/manage/menu-foobar), I get a WSOD after some loading time.

The site is hosted on a shared webhost (PHP memory limit is at 256M; max execution time at 120), so I assume it might work to move to a more powerful VPS, but I wonder:

Is there any way to access the menu configuration page without moving to a better server or changing the site architecture (i.e., using several menus instead of one)?

I tried the Menu Admin Splitter module, but it didn’t help.


texts:
I have a csv with a Date field that contains the date in one of the following formats:

dd/mm/yy (ex. 13/11/04)
dd/mm/yyyy (ex. 13/11/2004)

I need to import these dates to my field in the format dd-mm-yyyy, using feeds.

I've tried everything but without success. I have my date field set with my custom date format (dd-mm-yyyy).

What do I need to do in feeds (or even feeds tamper) to import this data?

Thanks.


texts: How to show a list of students: pairing entity references?

texts:
I'm working on a drupal page for an academic department, and I've created content types for Faculty, Students and Alumni.  Both the Student and Alumni content types have a field for "Advisor", which is an entity reference to a Faculty member.  In the student and alumni display, the advisor field then links to the advisor's page.

Now, I'd like to have the advisor page show a list of all their students (current and former).  Is there a simple module that will do this?  I don't want to write my own module - if there isn't a relatively simple way to do it, I can just have an entity reference in the Faculty content type and do manual entry.


texts: In Drupal 7 how do I add an anchor tag to a path alias menu link

texts:
I created a node in drupal 7 and given it a url path alias of 'testing'.   When I try to create a menu item that links to the path alias with an anchor, it throws an error

If I do node/1#this it works, but again not with a url path alias.

Is there a work around?


texts:
I want to remove "where" clause for city and postal_code in the views query. I found an example online for D6. I tried to change it a bit but it's not working. The "where" clause is still there.
Below is my code. It was originally for D6.

function distsearch_views_query_alter(&$view, &$query) {
  if ($view->name == 'search' && $view->current_display == 'page_3') {
    // Remove the exposed filter conditions from the WHERE clause (WHERE city = MyCityInput)
    // and remove the corresponding args that were passed via the exposed filters
    // This effectively turns the city and zip code exposed filters into just text fields
    // that get used in distprox_mini_exposed_filter_proximity();

    $city = $view->exposed_raw_input['city'];
    $zip = $view->exposed_raw_input['postal_code'];

    // Remove the city or zip arguments (from the exposed filters)
    foreach ($query->where[0]['args'] as $key => $arg) {
      if ($arg == $city || $arg == $zip) {
        unset($query->where[0]['args'][$key]);
      }
    }

    // Remove the corresponding WHERE clause additions
    foreach ($query->where[0]['clauses'] as $key => $clause) {
      if (strpos($clause, 'postal_code') !== FALSE || strpos($clause, 'city') !== FALSE) {
        unset($query->where[0]['clauses'][$key]);
      }
    }
  }
}


texts: Including a different jQuery version only on specific page

texts:
jQuery update module is including this script.

<script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?6"></script>

I need this on every page, except a certain template file which I am using fancy box, and need a later version of jQuery.

I need to exclude jQuery update from putting the above script in the $scripts variable ONLY on page-media-photos.tpl.php. How can I achieve this?


texts: Is there a hook to alter webform confirmation message?

texts:
In Drupal 7 using webforms, is there a hook that can alter the outgoing confirmation message shown to someone who has just submitted a form?

My thoughts are to put a text placeholder inside this textarea and do a str_replace to update the output based the submission itself.


texts:
I want to add a term to the the node whenever it is submitted or edited. I have the term id of the term I want to add.
My first approach of putting this code inside the custom node submit function is not working.

function module_custom_submit_function($form, &$form_state) {
   $nid = $form_state['nid'];
   $node = node_load($nid);
   $term_id = '73';
   $node->taxonomy[] = $term_id;
   node_save($node);
}

This does not insert the taxonomy term with ID equal to 73.

My second approach was to put query inside the submit function. Though this made changes to the database, the taxonomy terms were not added as tags on the website for the corresponding node.

function module_custom_submit_function($form, &$form_state) {
  $query = db_select('node', 'n');
  $query->fields('n', array('created', 'sticky'))
   ->condition('nid', $nid, '=');

   $result = $query->execute();
   foreach ($result as $record) {
     $time = $record->created;
     $sticky = $record->sticky;
   }

   db_insert('taxonomy_index')
   ->fields(array('nid' => $nid, 'tid' => $term_id, 'sticky' => $sticky, 'created' => $time))
   ->execute();
}

Are there any corrections, or alternative ways?

This approach seems to be working for now. I just added this to the submission handler.

   $node = node_load($nid);
   $term_id = '73';
   $node->field_tags[$node->language][]['tid'] = $term_id;
   node_save($node);


texts: How to fix error 'This site can’t be reached' for a site installed on Amazon?

texts:
I have just installed Drupal 8.1.3 on an Amazon instance using the instructions provided here.

I can connect via SSH (console) to my instance successfully.

However, when I try to browse my public DNS, I get:

This site can’t be reached

ec2-54-187-215-79.us-west-2.compute.amazonaws.com took too long to respond.

This is the first time I am performing this installation.

I have performed a DNS check and it says: Delegation not found at parent

I am wondering whether it is a Drupal related issue or not. How can I solve this?


texts: Custom validation rules for content entity fields

texts:
So I want to store an entity_type in a string field in my content entity.

Since the list of entities can change over time, I can't use a list_string field with allowed options. I don't know if calling out to entity_manager would even work properly in that context.

So my current plan just to use a string field and somehow validate that the values the system attempts to save are valid entity type machine names.

How can I perform this validation at the field level? At the entity form level, I will obviously have to add a custom select field and interpret/set the value in the (entity form class)::save() method.


texts: How to use a translated taxonomy in autocomplete term-reference fields?

texts:
When I translate a taxonomy to other languages, I cannot use it in autocomplete term-reference fields.

The auto complete field will show items only in the default language; if I try to fill the form from another language, nothing shows up in the field when I type.

It happens only when I use the autocomplete widget.

I am using Drupal 7.15.


texts: After forced login, return to first entered login

texts:
I have situation where i redirect user programatically on condition. After condition is met:

drupal_goto('http://www.mydomain.com/user/login');

But what it does, it forgets path that was initially entered by user.

Is there a way to redirect user to login (programatically), but to remember url ?
(as it works when you try to login to admin area).

BTW, i have Login Tobbogan also installed. (Drupal 7)

Thanks!


texts: Pass parameters to Drupal to Return XML data

texts:
Is there a module that allows the user to pass the parameters in POST or GET form, and Drupal will return in XML.

Like I have a view named table. table has fields named account_number and device_id. I would like to pass parameters in URL like

?view=table&account_number=123&device_id=d12

Then the Drupal would return in XML based on the searching criteria passed in URL.


texts: How to avoid regions overlapping in panels layout (or display suite) in Zircon Theme?

texts:
If a website window is scaled down by using mobile phones or reducing a browser window, some regions with fields in them (panels layout or display suite) start overlapping each other (they move onto each other).

Is there a way to avoid this effect? (tested on Zircon Theme Drupal 7)


texts: How to group taxonomy and node flags together?

texts:
I have 2 view block displays. One view displays flagged nodes and other displays flagged taxonomies. I need to print latest 8 flagged contents (nodes + taxonomy) in a single display sorted by title or term name, in ascending order.

Any suggestions about how to achieve this?


texts: How does core triggers cleanup of expired sessions in database?

texts:
core/lib/Drupal/Core/Session/SessionHandler.php defines a method (gc()) to clear expired sessions from the database (sessions table)

when is that triggered ? is there a way to trigger it from the interface ?

i know i can just truncate sessions manually or with a cron or a custom drush command..., but i wonder how does core uses it and what triggers it by default

Thanks


texts: Efficient and easy Drupal 7 Development to Production workflow

texts:
How would you put large existing Drupal 7 production site in some simple Development-Staging-Production workflow ?

I read through various documentation about the issue, but would like to know more efficient real life examples.

It is environment where only one person changes Drupal code (for now), and several editors do content publishing (they can edit content on live site and it seems it is ok to allow them).

I have in control Debian box with admin privleges (production site), and recently I did set up local Development/Staging Server (also a Debian box).

I am fond to Drush (haven't took advantage of drush make, though, but I had migrated some Drupal sites from server to server). I haven't used Features module, but I could implement it if neccessary. I have not used GIT yet, but I had read about it in theory. I am not sure is it a must for me to go with GIT, considering only one developer commits code.

My concern is about database updating, as I understood, GIT does not do that, and there could be enormous and critical differences between dev and production DB (settings change, site user inputs (registrations, comments etc, node creation etc)

Any advices?


texts:
I have a list field (category) associated with content type

Fruit|Good Fruit
Meal|Fantastic meal
Thai Coffee|Coffee

In views, I used sorting as category ascending. Now, I expected result to be sorted as: Coffee, Fantastic meal and Good Fruit. BUT it is sorting using value of list item as: Fruit, Meal and Thai Coffee.

Is there any way I can sort it using list item text but not with list item value?

Thank you.


texts: How to get the nodeid in node_grants so that it works in a view?

texts:
I am exploring the node_grants and node_access_records with the following objective:

I want to be able to hide nodes where the current logged-in user is not 'friends' with the node author. The node author selects if they want to limit it to friends or not with a boolean field. Here, the subtlety is that there are a few views which list nodes on my site, so I want it to work for views too.

I am using drupal 7, user relationships for the 'friends' relationship and here is my node_grants code. How do I get the node id, especially in the context of views?

function mymod_access_node_grants($account, $op) {
// Grants all rights if the author
$grants['mymod_access_author'] = array($account->uid);

    $value_friends = field_get_items('node', $node, 'field_friends_only');
    $value_friends = $value_friends[0]["value"];
    $value_friends = 1;

    if ( $value_friends == NULL) {
        $value_friends = 0;
    }
    if ($value_friends == 0) {
        $grants['mymod_access_public'] = array(1);
        $grants['mymod_access_friends'] = array(1);
        $grants['mymod_access_notfriends'] = array(1);

    } else if ($value_friends == 1)  {
        //if node is for friends only, then check if relationship exists...
        $current_user_uid = $account->uid;
        $node_author_uid = $node->uid;

        // Set up the parameters
        $params = array('between' => array($current_user_uid, $node_author_uid));

        // Get the relationships
        $relationships = user_relationships_load($params);

        if ($relationships) {
            $grants['mymod_access_public'] = array(2);
            $grants['mymod_access_friends'] = array(2);
            $grants['mymod_access_notfriends'] = array(2);
        } else {
            $grants['mymod_access_public'] = array(3);
            $grants['mymod_access_friends'] = array(3);
            $grants['mymod_access_notfriends'] = array(3);
        }
    } else {
    }
}

return $grants;
}

PS: although I have $node in my code, it is empty at the moment!


texts: Removing the dash/hyphen character from site search queries

texts:
I use Custom Search module 7.x dev.

When my visitors put a dash/hyphen into search keywords, Drupal can't find the results.

For example if they search for Station1 Station2, everything is OK, but if the keywords are Station1-Station2 nothing can be found as result.
(Putting a "dash" makes sense for my visitors because they want to search for timetables from Station1 to Station2.)

String Overrides removes characters but I suppose that module doesn't solve this issue.

What solution can I adopt?


texts: How can I limit query results in hook_views_pre_execute?

texts:
I am developing a Drupal 8 website where I have a block view displayed for certain content types that shows related information from other content types. I need to dynamically limit query results based on the moderation state of the node being visited (as opposed to the content in the view). My plan was to grab the node's moderation state from the page context and use that to limit the results of the view. However, the setLimit function seems to have no effect on query results:
function myModule_views_pre_execute(ViewExecutable $view) {
  // Only for my_view view.
  if ($view->id() == 'my_view') {
    $list_node = Drupal::request()->attributes->get('node');
    if($list_node->moderation_state->value == "approved"){

    }else{
      dpm("node is not approved, setting limit to 0");
      $view->query->setLimit(0);
    }
  }

UPDATE
I played around with trying different things in different hooks, inspecting the actual query generated via the view editing interface, as this exposes the "LIMIT #" expression. I learned 2 main things from that process:

Things can and will edit the query in other hooks. I found that putting the setLimit in hook_views_query_alter got overridden by some other module, and by the time hook_views_pre_execute came around, it would be changed from what I set it to earlier. However setting it in pre_execute is working fine.
Amazingly, calling setLimit(0) removes the LIMIT expression from the query entirely! However, any other value seems to work fine.

Is this expected behavior? Does Drupal prohibit setting the limit for a query to 0? Or should I be logging an issue somewhere?


texts: Webforms missing asterisk for required form components

texts: I have a form using the Webform module. But where are my (red) asteriks for the required form components? How do i enable those? My fields are set to required.


texts: How can I change the title of the site on Google search?

texts:
I have changed the site name to HoNESt, but when I search for the website on Google, the site name results HoNESt: Front Page.

How can I change this?


texts: How to get value from form field in rule?

texts:
I created a webform, and a rule. The rule works on the "form submit" event.

How do I get the value from a webform field in this rule event?


texts:
Drupal8 newbie here (using better login and system caching is on),

I wanted to just add a php page before the login page that says something like :

"Please follow the rules of our site, click accept button to agree and login in:"

                                   [Accept Button]

After pressing the button it forwards you to the normal /user/login page. Any tips would be great, it seems harder than it should be, we really don't want to use JQuery/JS.


texts: Add class to views row instead of replace system classes

texts:
I have this code:

function theme_preprocess_views_view_unformatted(&$vars) {
  $view = $vars['view'];
  $rows = $vars['rows'];

foreach ($vars['view']->result as $id => $row) {

    if (!empty($row->field_field_image)) {
      $vars['classes_array'][$id] = 'has_field';
    }
    else {
      $vars['classes_array'][$id] = 'has_no_field';
    }
  }
}

It works, but replaces all system original classes.

How to just add class?
I tried with $vars['classes_array'][$id][] but I'm getting: Fatal error: [] operator not supported for strings


texts:
Is it possible to reorder vertical tabs in the node edit page?  There are certain buried tabs that I am constantly needing to switch to, and it would make my life much easier (and that of my users!) if I could change the order to put the frequently used tab on top.

Note regarding similar questions:
I realize something similar has been asked, but he asked specifically about doing it by weight, and I'd be happy with any method of reordering them, in case there are other ways.  And no one answered his question, which leads me to hope there is some other way to do it.  If there's no way to do this at all, then I'll either delete this question--if that's the general consensus of the community--or accept the answer that it's not possible, as long as it is convincing and no one disputes it.


texts:
I recently build a web site with a small-medium profile of user access (around 150.000 pageviews/month) and sometimes, in the middle of the day I get the following error:

  PDOException: SQLSTATE[08004] [1040] Too many connections in lock_may_be_available()

The Drupal application is hosted with the MySQL on the same server, with an 2 CPUs Intel Xeon Quad Core and 8 GB of RAM.

I'm new on the Drupal world, and someone recomended me to use db_query() to throw my queries to the database. I don't know if this is the best pratice or even if this is the root of the problem. Can anyone help me?


texts: Image field in field collection not working

texts:
I have an image field inside a field collection (set to unlimited). After selecting the file to upload and clicking Upload the field reverts back to 'No file selected'.

There is nothing in the Drupal or Apache logs and there are no JS errors.

Even stranger, this works on my local dev environment but not on staging server. I have set PHP config to mirror local but again, still not working.

Image field appears to work okay when not in a field collection.

Absolutely no idea what this could be?! Only other difference I can see is PHP version on local is 5.6 and on staging is 5.5 but not sure why this would cause a problem.

EDIT: This is a field collection inside a field collection. An image field nested in a field collection does work.


texts: Use previously-submitted values as default values in a GET-method form

texts:
I have a custom form defined by the class below :

class MyForm extends FormBase {

    /**
     * @see \Drupal\Core\Form\FormInterface::getFormId()
     */
    public function getFormId(){
        return 'my_form_id';
    }

    /**
     * @see \Drupal\Core\Form\FormInterface::buildForm()
     */
    public function buildForm( array $form, FormStateInterface $form_state ){
        $form['my_textfield'] = array(
            '#type' => 'textfield',
            '#title' => t('My textfield'),
            '#default_value' => 'I want the current value here !',
            '#description' => t('Description of my textfield.'),
            '#required' => true
        );

        return $form;
    }

    /**
     * @see \Drupal\Core\Form\FormInterface::validateForm()
     */
    public function validateForm( array &$form, FormStateInterface $form_state ){
        // Not implemented yet...
    }

    /**
     * @see \Drupal\Core\Form\FormInterface::submitForm()
     */
    public function submitForm( array &$form, FormStateInterface $form_state ){
        // Not implemented yet...
    }

}

The form is then built in my page controller, using \Drupal::formBuilder()->getForm(). It overrides the form's #method attribute to GET because I want the field state to be present in the URL.

I'm looking for a correct Drupal-friendly way to assign the #default_value of my fields with the previously submitted state of the form.

Edit:

If I use a classic POST-method form and I add $form_state->setRebuild(); in ::submitForm(), I can get my values in ::buildForm() using $form_state->getValues(). And the form is automatically rebuilt with the previously submitted values, without having to assign the default values programmatically...

Could-be-related posts

Access data from previously submitted values in buildForm in FormBase plugin
GET method form is not processed


texts: Move Multi-lingual Content with Migrate Module

texts:
I've got a single MySQL table with mixed english/french content in each row.  I'm trying to figure how to migrate this into a proper i18n configured Drupal site.

I can get Migrate to import the content into one language, but I want it to import it into both languages.  There are 901 rows, so it should ultimately create 1802 nodes that are linked.

I just can't figure out how to set up the Migrate module to loop through twice & link the nodes.

EDIT: I used this and was able to merge the two:

public function postImport() {
parent::postImport();

// $ii should really be determined by $count_query
$ii = 2000;
for ($i = 1; $i < $ii; $i++) {
  // Confirm SQL in phpMyAdmin to verify
  $query = "SELECT n.nid, tid.field_bv_transfer_id_value
    FROM {field_revision_field_bv_transfer_id} tid
    INNER JOIN node n ON tid.entity_id = n.nid
    WHERE tid.field_bv_transfer_id_value = $i;";
  $result = db_query($query);

  // Reset for each import
  $currentRowCount = $current_translateid = 0;
  foreach ($result as $record) {
    if ($currentRowCount % 2 == 0) {
      $node = node_load($record->nid);
      $node->pathauto_perform_alias = FALSE;
      $node->tnid = $record->nid;
      $current_translateid = $record->nid;
      node_save($node);
    } else {
      $node = node_load($record->nid);
      $node->pathauto_perform_alias = FALSE;
      $node->tnid = $current_translateid;
      node_save($node);
    }
    $currentRowCount++;
  }
}

}


texts:
I have tried outputting code simliar to the custom_format example thats included with TinyMCE. I enabled the Autosave module, however I never see a "restore drafts" button. The only setting that doesn't wipe out all the buttons in the editor is using "theme_advanced_buttons3". Which also doesn't show a button with the 'restoredraft' value.

Edit: context


texts:
I am using domain_access module for multisite. I have two different domains (www.example.com, www.example1.com). If i created a view it will be displayed in both the sites. Now i need to create a view only for the particular domain (www.example.com), It should not be displayed in another domain (www.example1.com).
There is any solution in drupal?


texts: how to insert a search form in custom content

texts:
I'm trying to insert a search form in the middle of some custom HTML on a Panel Page.  There's already the Search Block on the page somewhere else.  The Search Widget is available, but it gets inserted after the custom HTML, which is not what I want.  I thought I could do something like
http://api.drupal.org/api/drupal/modules!search!search-block-form.tpl.php/7

<?php if (empty($variables['form']['#block']->subject)): ?>

<?php print t('Search form'); ?>

<?php endif; ?>
<?php print $search_form; ?>

or

<?php
drupal_get_form('search_form');
?>

but the PHP doesn't seem to execute (naturally, I have PHP selected as the input.).

Edit:
This produced a search form in the correct place, but the CSS conflicts with the existing Search Block.

<?php print render(drupal_get_form('search_block_form')); ?>


texts: Add a link in management menu for specific role

texts:
I can't find the way to display a link in the management menu for specific roles. The link shows up only for administrator, despite all the access callbacks I tried.

In the view displayed by the page callback I declared same path, menu  and access callbacks. As I don't know who is called last between module code and the view (?), I also tried with no menu nor access settings in the view.

If you could have a look at my implementation to check where I'm wrong ? Thanks a lot

function vts_dashboard_menu() {

  $items['admin/backoffice/production'] = array(
    'title' => 'Production',
    'description' => 'Edit catalogue',
    'page callback' => 'vts_dashboard_backoff_circuits',
    'access callback' => 'vts_dashboard_user_has_role',
    'access arguments' =>  array('éditeur voyages', 'éditeur taxonomie', 'administrator'),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'management',

    //2 alternative tests below. EVEN WITH TRUE, doesn't show up for non admin
    //'access callback' => TRUE,
    //OR ...
    //'access callback' => 'node_access',
    //'access arguments' => array('view', 1),
  );

  $items['admin/backoffice/production/circuits'] = array(
    'title' => 'Circuits',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
    'access callback' => 'vts_dashboard_user_has_role',
    'access arguments' =>  array('éditeur voyages', 'administrator'),
  );
  // ... more items...
);
//page callback function
function vts_dashboard_backoff_circuits(){
  $viewname = 'circuits_vts';
  $viewdisplay = 'backoffice_products_list';
  return views_embed_view($viewname, $viewdisplay);
}
//access callback function
function vts_dashboard_user_has_role() {
  global $user;
  $roles = func_get_args();
  foreach ($roles as $role) {
    if (in_array($role, $user->roles)) {
      return TRUE;
    }
  }
  return FALSE;
}

Precision : these roles can see the pages/tabs called if they access directly to the path.


texts: Dependent Dropdown based on Database Queries

texts:
I've been working through the Drupal 7 AJAX form examples in the Examples module, and am trying to set up a dependent dropdown form element with 2 select lists populated from the database.

Basically, I have Select called Specialties, that pulls a list of items, and a second Select called Physicians—which should be populated with Physicians tagged (via Node Reference field) with the chosen specialty. So, for example, the end user selects  "Back" from the Specialties select list, and the second should populate with a list of the 3 physicians containing this Node Reference.

From what I can tell, both queries are returning the right types of nodes, and if i place a condition in the Physicians query to hard-code the specialty field:

->condition('field_specialty_nodereference_nid', '90')

it populates the second list with all doctors tagged with that nodeference.

What I am struggling with is how to make that condition dynamic, so a value from the first select is passed through to the second on change. Thank you in advance for any help you can provide.

Here is my code:

<?php

function docappt_states_form($form, &$form_state) {

// Grab the list of specialties from the DB

  $query = db_select('node', 'n')
  ->fields('n', array('nid','title'))
  ->condition('type', 'specialty')
  ->orderBy('title', 'ASC');
  $results = $query->execute()->fetchALL();

  //define rows
  $specialtylist = array();
  foreach ($results as $result) {
      $specialtylist[$result->nid] = $result->title;
  }

// Let's call some docs by specialty reference
  $query = db_select('node', 'n');
  $query->join('field_data_field_specialty_nodereference', 'specnr', 'n.nid = specnr.entity_id');
  $query
  ->fields('n', array('nid','title'))
  ->fields('specnr', array('field_specialty_nodereference_nid', 'entity_id'))
  ->condition('type', 'physician_profile');
  $docresults = $query->execute()->fetchALL();

  //define rows
  $docfoptions = array();
  foreach ($docresults as $docresult) {
      $docfoptions[$docresult->nid] = $docresult->title;
  }

  $specialties = isset($form_state['values']['specialties']) ? $form_state['values']['specialties'] : key($specialtylist);
  $form['specialties'] = array(
    '#type' => 'select',
    '#title' => 'Specialties',
    '#options' => array(
      0 => t('- Select -')) + $specialtylist,
    '#default_value' => isset($form_state['values']['specialties']) ? $form_state['values']['specialties'] : 0,
    '#ajax' => array(
        'callback' => 'docappt_dependent_dropdown_callback',
        'wrapper' => 'filtered_doc_list',
        'event' => 'change',
        'method' => 'replace',
        ),
    );
  $filtereddoc = isset($form_state['values']['filtereddoc']) ? $form_state['values']['filtereddoc'] : key($docfoptions);
  $form['filtereddoc'] = array(
    '#type' => 'select',
    '#title' => $specialtylist[$specialties] . ' ' . t('Doctors'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#options' => $docfoptions,
    );

  return $form;
}

function docappt_dependent_dropdown_callback($form, $form_state) {
  return $form['filtereddoc'];
}


texts:
I need a feature for my website, I want that users can send pre-filled messages to others users.

Like in an user's profile page, they just have to click on a button and then, the pre-filled message is sent.

I'm using PrivateMsg module, I don't know if this module could do the job

(By the way I'm new to Drupal).

Thanks for your help !


texts:
I have two types of content every one with two taxonomies:

TYPE A with Taxonomy 1 (multiple)

TYPE B with Taxonomy 2 (multiple)

Now I created a view with 3 filters exposed:

Node type: A or B or both

Taxonomy 1

Taxonomy 2

Now if I choose, all the nodes A and B with the term x (taxonomy 1) and the term y (taxonomy 2) does not return nothing.

I tried to change the AND and OR, but nothing comes out from the query.

Do you think it is possible a query like this with views filters?


texts: How do I assign variables from FormatterBase-Interface to hook_page_attachments()?

texts:
I have created new field-types in drupal.

Therefore I have an Instance of FormatterBase, which gets the values from the database and tries to render the values.

but i want to pass the variables #wkt and #zoom also to the _page_attachments-hook of the .module file, because I need the variables in the drupalsettings variable. (js neededs this variables)

class GeoObjectWKTFormatter extends FormatterBase {

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    return array();
  }

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items) {
    $elements = array();
    foreach ($items as $delta => $item) {
      $elements[$delta] = array(
        '#theme' => 'myosm_block',
        '#wkt' => SafeMarkup::checkPlain($item->value),
        '#zoom' => SafeMarkup::checkPlain($item->zoom_level),
      );
    }
    return $elements;
  }
}

My hook:

/**
 * Implements hook_page_attachments().
 */
function mymodule_page_attachments(array &$attachments) {
    $attachments['#attached']['drupalSettings']['mymodule']['zoom'] = //here I want to assign the value;
    $attachments['#attached']['drupalSettings']['mymodule']['wkt'] = //here I want to assign the value;
}


texts: Multi-sites local dev alias question for Drupal 6 / OS X

texts:
With Drupal 7, it's fairly trivial to set up a local alias for a multi-site using the sites.php file. With Drupal 7, I can have a multi-site folder on my local dev be named:

subsite.com

... located in the /sites/ folder

so that it's: /sites/subsite.com/

Then in my sites.php file, I do something like this:

$sites['subsite.dev'] = 'subsite.com';

... but I can still view this local site in my browser as:

http://subsite.dev

This is good on many levels, it allows me to have a custom subsite (of a multi-site) as the actual name it will be on the remote server. Thus I can have custom modules and themes for the subsite in my Git repo. In addtion, if I clone the remote db back to local at any given point, any given site specific references do not need to be changed in the local DB.

The question then, is there any way to have similar local aliasing with Drupal 6.  I know Drupal 6 does not have the sites.php file so I am not sure how else to do this. Becuase of this, right now I am stuck with rendering my local Drupal 6 multi-site folder as subsite.dev. I know I could chnage my "hosts" file in OS X but then I am stuck having to change it all the time to view the actual ".com" remote domain.


texts:
I am migrating content from Drupal 7 to Drupal 8. Migration works fine except the changed date for node get changed to the current time. I want to set the timestamp to the Drupal 7 timestamp. I have tried out the following but it is not working.
        $changed_date = $node->getChangedTime();
        $node->set($source['parent_field_name'], $paragraph_target);
        $node->changed->value = $changed_date;
        // print_r($changed_date);die;
        $node->save();


texts: How to display the survey results created with the Webform module?

texts:
Does anybody know how to display the survey results created with the Webform module?

I have created a survey using the grid field and it works great. I want to be able to display the accumulated results (using my CSS styling) on the same page the survey question appears. Is there a way to do this?


texts: How to get a list of all Groups sorted according to latest comment created on any of the Group Content belonging to that Group?

texts:
I wrote the following custom query to get a List of Groups sorted according to latest comment created on any of the Group Content belonging to that Group (not on the group itself) .

However this query does not return the list of Groups for which there is no Group Content OR any comment on any of Group Content is created.

SELECT DISTINCT   group_view.nid AS group_nid,
                  group_view.created_date AS group_created_date,
                  discussion.nid AS discussion_nid,
                  comment.created AS comment_created_date,
                  comment.created_date AS comment_created_date
  FROM `node` AS group_view
      LEFT JOIN `og_membership` AS group_map
          ON group_view.nid = group_map.gid
      LEFT JOIN `node` AS discussion
          ON group_map.etid = discussion.nid
             AND group_map.entity_type = 'node'
      LEFT JOIN `comment` AS comment
          ON discussion.nid = comment.nid
  WHERE group_view.type = 'group'
  ORDER BY comment.created DESC

What changes do I need to make in this query to include a list of Groups with no comments

I do not want to use views.


texts: Hide conditionally hidden fields from custom node template

texts:
Case: I am using conditional fields module to hide some dependent fields based on the value of its dependee field. I have created a custom node--content-type.tpl.php template for my content type.

Field1

Field2

Here, Field2 is dependent on the value of Field1. Suppose in this case, Field2 is rendered only if Field1 has value 'jobs'. Otherwise, it is hidden from both node edit form and node page.

When using seven theme and its display(default or teaser) to view node, if the Field2 is hidden or the dependency was not triggered the Field2 is not rendered on the node page, which is correct.

But, when using my custom template, I am not been able to prevent the rendering of Field2 on my node. It is shown with its default value on the node.

Please help.

template code:

<?php if(isset($content['field_job_type'][0]['#markup'])):?>

Job Type: <?php print $content['field_job_type'][0]['#markup'];?>

            <?php endif;?>


texts: How to show/hide fields with the Rules module based on the user's language?

texts:
I have a multi-language support website.

My question: can I show/hide some fields based on the user's language choice with Rules module?


texts: Drush disable module updates email notifications

texts: Is there a Drush command to disable email notifications about Module updates.


texts: Second ajax button not working on user profile form

texts:
I have added a custom button which has an ajax callback with the following code to the user profile form.

$form['validate_2'] = array(
          '#type' => 'button',
          '#value' => t('validate 2'),
          '#ajax' => array(
            'callback' => 'example_validate',
            'wrapper' => 'validate-settings',
            'method' => 'replace'
          ),
          '#name' => 'user_validate_2',
          '#id' => 'user-validate-2',
          '#weight' => 10
        );

But when I click on it, it gives me ajax error in popup saying

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /system/ajax
StatusText: n/a
ResponseText:
( ! ) Fatal error: Call to undefined function user_profile_form_validate() in /includes/form.inc on line 1520

In my ajax callback I'm simply displaying the $form_state array. Any idea what I'm doing wrong?

The form's own submit button is not with ajax.

function example_validate($form, &$form_state) {
dsm($form_state);
}


texts: Anonymous users request to enter email to download files

texts:
I have a question that i thought originally i would able to answer myself.

I have a site that show some pdf help files. The files is open to anyone so they can download freely.

The question is how i can still leave it open but when a user click on a file they will requested to enter an email ( like a pop up) after that the could continue as normal.

I don't want in this stage to force the user to create a account.
I don't want the user to verified the email.
I don't want to create a private file system.

I think a first approach will be a javascript. But i want the drupal check and validate the user input {With ajax approach}. The reason is that in a later state i would implement some web service with another Db and it will be nice to have ready the site part.

The validation for now is just to be a valid email format. {abc@abc.abc}

I have already seen FileField Mail


texts: How to deny access if url is changed manually?

texts:
Maybe the way I'm doing this is not the correct one but here it goes.

I have a page in my site where I have a form. In that form I have a select list that I fill with user ids from a query.

So for example, my site has 10 users and the list will be filled with only user 3 and 7.

When I submit the form, the url is changed to have the uid as a parameter:
&user=3 or
&user=7

My problem is that I can change the url manually to other user I want and I'm not denied the access.

How can I deny access in this case?


texts: Webform twig template causes "the form has become outdated" error

texts:
We want to customize the theme of our webforms. We will want the ability to add markup around individual webform elements (like my_element_01 and my_element_02 in the example below)

Below is a very basic twig template that seems like the right path (based a little on How to access webform elements in webform.html.twig ). However, when I submit this form I get "The form has become outdated. Copy any unsaved work in the form below and then reload this page.".

I have read that the form_id and form_build_id has to be rendered in the template but I am doing that. I am not sure what is wrong or if there is a better approach.

{{ element.elements.form_description }}

<form{{ attributes }}>

{{ title_prefix }}

  {{ element.elements.my_element_01 }}
  {{ element.elements.my_element_01 }}

  {{ element.form_build_id }}
  {{ element.form_id }}
  {{ element.actions }}

{{ title_suffix }}

</form>


texts:
How can I create page with Drupal 7 - views 3 module where are descendant nodes of the parent node.
The structure of nodes is following:

Parent node

-Descendant 1

--Descendant 2

-Descendant 3

--Descendant 4

---Descendant 5

etd.

I would like to list all of these descendants.
Im trying it with book module, but without success.


texts: Non-existent URLs in Views 3 in drupal 7

texts:
I have created a page via views in Drupal 7. For example my page that is created via view is: http://www.example.com/staff. It's working correct.
When I put http://www.example.com/staff/dfasf it's also showing same data. But not going on page not found.


texts:
Is there a way to rewrite the content of a field displayed in a view?

E.g. If my title is long, like "[Product ID:5739] Ninja Stars" and I want it to display just "Ninja Stars" in the view, how can I do it?


texts: Language switching does not work when browser language is configuired in drupal 8.3.7

texts:
Language switching fails after enabling browser on  Detection and selection

  /admin/config/regional/language/detection

Exisiting :

On switching language from the browser the url changes but the content remains the same

E.g, Default language browser is Germen.

mywebsite.com mywebsite.com/about etc shows German content.

While swiched to English url changes to mywebsite.com/en mywebsite.com/en/about etc

It shows Germen content instead of English.

Expected

On browser configured with Germen as default language, the site url should be mywebsite.com/de.

When I swich to the English website, it should show English content

Please find the configuration.


texts:
I'm trying to embed a poll into the body of a node with PHP code:

$node = node_load(123);
print node_view($node, 'full');

That won't work. What's the trick?


texts:
Hello I need to create a pop up comment form for content type. I wrote this code

function ajax_comment_menu() {
  $items = array();
  $items['ajax_comment/%ctools_js/comment/reply/%node'] = array(
    'title' => 'Contact',
    'page callback' => 'ajax_comment_page_callback',
    'page arguments' => array(1),
    'access arguments' => array('access site-wide contact form'),
    'delivery callback' => 'ajax_deliver',
  );
  return $items;
}

function ajax_comment_block_info() {
  // First, we define our block
  $blocks['add_comment'] = array(
    // This title will show up on the block admin page
    'info' => t('Add comment'),
  );
  return $blocks;
}

but I'm not sure what to wrote in ajax_comment_block_view() and in ajax_comment_page_callback(). I need this pop up to add commnet to content type. Also I'm not sure what path in menu items[] shoul be


texts: How to add a button that jumps to an external link in the content type?

texts:
I would like to add a purchase button in the content type, the button is an internal link, for example:www.example.com/go/nodeid. And then add an external purchase link to the text field, for example:https://item.jd.com/2385876.html. Click the buy button (internal link) JS jump to the external links, because I do not want to search engine crawling the external link address.
For example,
 open the page（http://www.chong4.com.cn/read.php?18818）, showing the link（http://www.chong4.com.cn/cydb/go.php?18818_127334_22s）, click will jump to（https://detail.tmall.com/item.htm?id=536478627694&ali_trackid=2:mm_13376157_4604749_42838263,22s18818:1479362916_3k2_69258376）


texts: Ultimate Cron Background Process Taking a Long Time

texts:
I'm having background process on Ultimate Cron process various queue items, but the fastest it usually processes them is at least one minute, and sometimes 3 minutes per item.

This seems incredibly slow to me.

Should I increase the number of threads? I'm not finding much documentation on how to speed up the process - I don't mind if it requires a bit more processing power - this is a required operation for the Drupal install in question, and it has to be run pretty much all the way through every 15 minutes.

There are no errors, just very slow processing.


texts: Fatal error: in boostrap.inc line number 2913

texts:
I ma facing a Fatal error It says
 Fatal error: require_once() [function.require]: Failed opening required '/home/myapp/myapp.com/sites/all/modules/views/modules/user/views_handler_field_user_name.inc' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/myapp/myapp.com/includes/bootstrap.inc on line 2913

I am unable to login,or add content type or create a view. Please help to overcome this issue.

I am very much need in it.

My site works fine if not logined.


texts: How to prevent to create duplicate node on clicking submit button multiple time

texts:
I am using unique_field module.
If a node already created and i want to create node with duplicate title(title is selected as unique field), it work fine. But if i click on submit button multiple time(suppose 4 times) with node data, then 4 node created with same data.

I have already tried with hook_node_validate but it does not work.

Can anyone please help me out.


texts: What does cron error "exit status 4" mean in syslog? (Ubuntu)

texts:
I've never seen this before, my Status Report page says the last cron run was 35 minutes ago at 10:35 today. So I went to watchdog logs and could see that Cron run completed at 10:30.

I've set the cron to run on 0 and 30th minutes of every hour, so twice per hour using sudo crontab -e so it's using the root user's crontab with the following command (cron key intentionally removed):

0,30    * *   *   *     wget -O - -q -t 1 http://localhost/cron.php?cron_key=

I'm not using the cron.module aka poormanscron in D6

I've manually run the cron and it updated the Status Report page after that.

What could cause this weird behavior? I'll admit that I haven't tried flushing the caches, but could caching be the cause of this? Or is there something more sinister?

I've dug around in syslog and found an error relating to the cron, but I have no idea what this means (cron key intentionally removed):

Aug 16 10:30:01 drupal-1 CRON[31372]: (root) CMD (wget -O - -q -t 1 http://localhost/cron.php?cron_key=)
Aug 16 10:30:01 drupal-1 CRON[31370]: (CRON) error (grandchild #31372 failed with exit status 4)

I can see the grandchild #31372 is referring to the first line CRON[31372] but what does exit status 4 mean?

I just wanted to also let people know that the cron has run without any problems so far afaik. But it could be that this is the first time I've noticed this as well.


texts: Add new field to custom content entity type

texts:
I have created a custom content entity type called Course. When I installed my module, Drupal automatically created the table schema for my entity, so all the fields I defined in Course::baseFieldDefinitions() had their column in the database table course, as specified in the base_table annotation of my class.

Now I want to add an extra field to my entity. I edited the Course::baseFieldDefinitions() method to define my new field in the same way as I did with the previous ones. The problem is that I don't know how can I create the appropiate column in the database.

The relevant part of my Course entity is:

class Course extends ContentEntityBase implements CourseInterface {

  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);

    $fields['user_id'] = BaseFieldDefinition::create('entity_reference');
      // Settings and constraints for this field

    $fields['name'] = BaseFieldDefinition::create('string');
      // Settings and constraints for this field

    $fields['price'] = BaseFieldDefinition::create("float");
      // Settings and constraints for this field

    $fields['status'] = BaseFieldDefinition::create('boolean');
      // Settings and constraints for this field

    $fields['created'] = BaseFieldDefinition::create('created');
      // Settings and constraints for this field

    $fields['changed'] = BaseFieldDefinition::create('changed');
      // Settings and constraints for this field

    // New field being added
    $fiels["place"] = BaseFieldDefinition::create("string")
      ->setLabel(t("Place"))
      ->setDescription(t("The place of the course"))
      ->setSettings(["max_length" => 255, "text_processing" => 0])
      ->setDefaultValue("")
      ->setDisplayOptions("view", ["label" => "above", "type" => "string", "wegith" => -3])
      ->setDisplayOptions("form", ["type" => "string_textfield", "wegith" => -3]);

    return $fields;
  }

}

I've tried using the Drupal console command update:entities but it is not updating my database schema.

How could I add the place field to my database table?