texts:
I have a server which I want to run drupal site on it.

The default http port 80 was block and it does not have a static IP address.
I have to run Drupal on non 80 port, let's say 8765.

Since I do not have a static IP, I apply a sub-domain name from noip which is
drupal8.myftp.org.
So finally my domain name should be
drupal8.myftp.org:8765

First, I read the tutorial here

From line 46

  Note that if you are installing on a non-standard port number, prefix the
  hostname with that number. For example,
  www.drupal.org:8080/mysite/test/ could be loaded from
  sites/8080.www.drupal.org.mysite.test/.**

So In my scenario, I should create a directory like
sites/8765.drupal8.myftp.org/
and put the settings.php here.
Then I also need to create a 8765.drupal8.myftp.org.php file under “sites” directory to tell Drupal to looking for the settings.php within sites/8765.drupal8.myftp.org directory.

I did create the directory and the file.

But Drupal still looking for the settings.php under default directory, why?

Questoin1: what content should be in the 8765.drupal8.myftp.org.php file?
Since I can not find any tutorial about this, I just leave it blank, I assume it's just a symbol to let Drupal know it should look for the settings.php in the  8765.drupal8.myftp.org category.

Question2: Why Drupal doesn't look for the settings.php under 8765.drupal8.myftp.org directory? Do I did sth wrong?

Since I need to add

$base_url=”http://drupal8.myftp.org:8765”

in the settings.php and the file under sites/8765.drupal8.myftp.org directory doesn't work.
So I have to add it to the settings file under default directory.
But still, If I open the site drupal8.myftp.org:8765
and view the source code

<link rel="shortcut icon" href="http://drupal8.myftp.org/core/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="alternate" hreflang="en" href="http://drupal8.myftp.org/node/3" />
<link rel="alternate" hreflang="zh-hans" href="http://drupal8.myftp.org/zh-hans/node/3" />

We can see all the link are still point to drupal8.myftp.org,
therefore, all image and css info are gone.

So could anybody give me some instructions, I have be stuck in this for three days, any help is highly appreciated.

Thanks in advance.

@Pathak,

Thank you for your kind reply.

Yes, I create a folder called 8765.drupal8.myftp.org and place settings.php within it. So the path is

sites/8765.drupal8.myftp.org/settings.php

I also create a file call 8765.drupal8.myftp.org.php reference to example.sites.php.

The path is

sites/8765.drupal8.myftp.org.php

According to example.sites.php

  The array is written in the format: '..' =>
  'directory'. As an example, to map
  www.drupal.org:8080/mysite/test to the configuration directory
  sites/example.com, the array should be defined as:

  $sites = array(
      '8080.www.drupal.org.mysite.test' => 'example.com',   );

Then in the 8765.drupal8.myftp.org.php, I write the $sites array as follow;

$sites = array(
    '8765.drupal8.myftp.org' => '8765.drupal8.myftp.org',
  );

But still, if open the site drupal8.myftp.org:8765, the settings.php under the default directory was read. All links are point to drupal8.myftp.org without the port number.
Could you please point out on which step I was wrong?


texts: How to disable the "clear log messages" functionality for administrators?

texts:
For a production site, for auditing purposes, I would like to disable the "clear log messages" functionality for all administrators. This function is shown within admin/reports/dblog (within the "Recent log messages" report).

How to do this?


texts: Changing CCK field value(s) by clicking URL - possible? Advisable?

texts:
I'm trying to figure out if it's possible/advisable to create URLs that get sent out in user notification emails which, when clicked, carry out actions like changing a CCK field value.

So for example - say you have an issue tracking system. There's no activity on one issue for a week, so the system sends an email to the person who posted the issue asking if they consider the issue closed.  And if so, please click here to close the issue.

They click on the "close the issue" link in their email, the CCK status field for the issue is changed to "closed," and they're taken to some arbitrary page on the site.

Is something like that doable?

In Drupal 6?


texts: How translate custom email programmatically?

texts:
I'm on a D9 Site. I've created a module, where I define a hook_mail, a hook_theme and a preprocess for swiftmailer twig:
/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return [
    'my_module_mail' => [
      'variables' => [
        'brand_name' => NULL,
        'brand_message' => NULL,
        'date' => NULL,
        'start_date' => NULL,
        'end_date' => NULL,
      ],
    ],
  ];
}

/**
 * Implements hook_mail().
 */
function my_module_mail($key, &$message, $params) {
  $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed; delsp=yes';
  $message['from'] = $params['from'];
  $message['subject'] = $params['subject'];
  $message['breakout_room_title'] = $params['breakout_room_title'];
  $message['breakout_room_body'] = $params['breakout_room_body'];
}

function my_module_preprocess_swiftmailer__my_module__my_module_mail(array &$variables) {
  $variables['breakout_room_body'] = $variables["message"]["breakout_room_body"];
  $variables['breakout_room_title'] = $variables["message"]["breakout_room_title"];
}

In a custom rest resource then I send the mail:
  public function post($data) {
    $params['from'] = $this->configFactory->get('system.site')->get('mail');
    $params['brand_message'] = $data["brand_message"];
    $params['subject'] = 'my_subject';
    $params['my_mail_body'] = [
      '#theme' => 'my_module_mail',
      '#brand_name' => $data['brand_name'],
      '#brand_message' => $data['brand_message'],
      '#date' => $this->formateDate($data['br_date'], 'd/m/Y'),
      '#start_date' => $this->formateDate($data['br_start'], 'H:i'),
      '#end_date' => $this->formateDate($data['br_end'], 'H:i'),
    ];

    $params['my_mail_title'] = '
' . $data['title'] . '
';

    foreach ($data["mail_to"] as $user_mail) {
      $result = $this->mailManager->mail('my_module', 'my_module_mail', $user_mail, $this->getUserLanguage($user_mail), $params, NULL, TRUE);
      if (!$result['result']) {
        throw new HttpException(400, 'Impossibile inviare email');
      }
    }
    return new ResourceResponse(['email_sent' => TRUE]);
  }

In the my-module-mail.hmtl.twig and swiftmailer twig I have some translated string, e.g.
[...]

    {{ 'Hello'|t }},

    {% trans %}
        you have confirmed your appointment with {{ brand_name }} on {{ date }} from {{ start_date }} to {{ end_date }}
    {% endtrans %}

The email is successfully send, but I can't find a way to send the translated version of that, the email are always send in Italian - the site has Italian as default language and English as other.
I've already found some questions on the argument, but they couldn't solve my problem: trying to use the ConfigOverrideLanguage orrenderRoot or both don't change anything for me.


texts:
I've run into the following:

User uploads are among the uploads from the admin / editors.

Is there a possibility to show uploaded files from the webform module in a different module than the Media module, or a different directory in the media module? The files are already in a different directory on the server, but not in the back-end of drupal.

Any help is much appreciated :-)

Thanks!


texts:
I have several Apache Solr search configurations, filtered to different Content Types to be used on a variety of view pages. These "pages" provide their own search form, but I need to be able to embed these search fields as blocks, so they can be implemented in page layouts within Context.

So, create a block and load the form with drupal_get_form:

/**
 * Implements hook_block_info()
 * @return [type] [description]
 */
function example_block_info() {
  $block['mwb_video_block'] = array(
    'info' => t('Example Search Block'),
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );

  return $block;
}

/**
 * Implements hook_block_view()
 */
function example_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case "example_search_block":
      $block['subject'] = "";
      $block['content'] = example_render_search_block();
      break;
  }

  return $block;
}

function example_render_search_block() {
  $form = drupal_get_form("search_form");
  return drupal_render($form);
}

Simple, right? Well, I tried that with varying results, none returning a form. A DPM of the loaded form object loads in the form, but nothing renders in the return output. Is there a process that i'm missing out on here that only seems to be tied to the Apache Solr search form?


texts: "SELECT DISTINCT node.nid AS nid" killing MySQL performance?

texts:
My database server's CPU has been pegged for the last two hours and the site is down as a result. Looking at the process list, I see dozens of queries that all begin "SELECT DISTINCT node.nid AS nid," and from my reading, it appears that this should not be a common occurrence  because these queries are very expensive and this could be the source of my problems.

Is it safe to say there is a view or module making a query incorrectly and if so, how can I can track that query down?


texts: Administrator users can add records, end users can view them

texts:
How can the administrator users add few records into the database (through a form), and how can the end users view them in the front end?

Administrator users will be adding records of training classes, through a form in an administration panel.
The end user will be viewing the list of training classes in the front end, in a block.

How to achieve these tasks?


texts:
Viz.js is GraphViz converted to JavaScript. There is a demo at http://webgraphviz.com.

What I would like to do is send a string (dot syntax) created by a PHP function to Viz.js to produce svg output for display as "content". I know zilch about JavaScript and my trial and error attempts with drupal_add_js() and Drupal.behaviors are getting me nowhere.

Hoping someone can guide me through this. (The string from my PHP function is valid - it displays correctly if I paste it into the demo site).

Some background:

I have a working system using locally installed GraphViz and the PEAR Image_GraphViz class. The problem is shared hosting providers don't want to install GraphViz -- so this js conversion could get around that.

I have a link on a Views display that calls a function to build a chart through calls to methods in Image_GraphViz. At the end of the function I do

<?php
return $gv->fetch();
?>

which opens a page displaying the chart in the site theme content area.

In my attempt to use Viz.js I have first placed scripts[] = Viz.js in my .info file -- that seems correct to me and does get Viz.js into the html header. According to the author I only need one line of javascript like svg = Viz("digraph { a -> b; }", "svg");.

My problem is: where do I put it? Obviously, I need to pass a string to replace the 1st parameter and that is easily obtained by

<?php
$gvdata = $gv->parse();
?>

Pasting such a string into the demo site produces correct results.

Does the one-liner need to be in a separate file or can it be tacked on to the main function?

I tried this:

<?php
$gvdot = $gv->parse();
$gvdata = array('gvdata' => $gvdot);
drupal_add_js(array('ftree' => $gvdata), 'setting');
return drupal_add_js('jQuery(document).ready(function () {
Viz(Drupal.settings.ftree.gvdata, "svg"); });', 'inline');
?>

gives a blank screen.

I also tried calling a separate file:

<?php
$gvdot = $gv->parse();
$gvdata = array('gvdata' => $gvdot);
drupal_add_js(array('ftree' => $gvdata), 'setting');
drupal_add_js('dot2viz.js');
return;
?>

that contained:

(function ($){
  Drupal.behaviors.ftreeBehavior = {
    attach: function (context, settings) {
      var gvdata = Drupal.settings.ftree.gvdata;
      document.body.innerHTML += Viz(gvdata, "svg");
    }
  };
})(jQuery);

also returns a blank screen.

And that's where I am -- hoping someone can explain what I'm missing and/or doing wrong.

p.s. a better formatted version is at https://drupal.org/node/2153353


texts:
I need help setting up a notification system for when a user requests to join a group.

At the moment, when the user types in their message and click the join button, the administrator receives no email notification of a users join request.

Can anyone help ?


texts: how to add form action twig template form

texts:
I have created a module in which I create a form and then rendered it in twig template I  want to know how to give form action in a twig template i.e  how to pass form action attribute in twig form.

any help will be greatly appreciated .

mymodulename-form.html.twig file

<form>

   {{form.first_name['#title']}}

        {{form.first_name}}


texts:
On Drupal 8 site, I have a exact copy of the below excel example table made with views but without the yellow cell yet.

The view is displaying one content type: Client where all the below fields are available:

Date
Client Name
Client ID
Amount ($)

Now, as you can see, the yellow cell is displaying the total SUM of all amount ($) rows.
which basically is: 15+29+97+115+45+67+23+11+5+91+44 = 542$

How can i achieve this exact calculation in my view ?

I have tried to enable the Use aggregation option under the advanced section on my view, but it seems it doesn't do what i am asking for!

any help please ?

Note: I believe the use Use aggregation option doesn't add a row at the bottom of the table calculating the sum of all above rows and therefore this question Making a colums total (SUM) with Views is not a possible duplicate of this one.

UPDATE #1

After following the answer of @Stef Van Looveren, I am encountering a new error:

InvalidArgumentException: Field field_money_amount is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 587 of /home/####/public_html/#####/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php)

Knowing that: field_money_amount is the id of the field taken from the content type being used inside the view.

Complete code in the .module file:

<?php

use Drupal\views\ViewExecutable;

function my_module_views_pre_render(ViewExecutable $view){
  if ($view->id() == "view_id" && $view->current_display == 'display_id') {
    $total = 0;
    foreach ($view->result as $value) {
      $number = $value->_entity->get('field_money_amount')->value;
      $total += $number;
    }
    $view->attachment_after = [
      '#markup' => '

Total:	'.$total.'

',
      '#allowed_tags' => ['table','tr','td']
    ];
  }

}


texts:
I am trying to load libraries in my Drupal 8 site, but it does not seem to be working. Here is my library yaml, is this correct? Why can't I load dexp.slides?

dexp.slides
  version: 1.x
  css:
    theme:
      css/plugins/font-awesome/css/font-awesome.min.css: {}
      css/admin.style.css: {}
      css/plugins/rs-plugin/css/settings.css: {}
  js:
    js/dexp.layerslider.js:  {}
    js/plugins/rs-plugin/js/jquery.themepunch.revolution.min.js:  {}
    js/plugins/rs-plugin/js/jquery.themepunch.tools.min.js:  {}
  dependencies:
    - core/jquery
    - core/jquery.ui.draggable
    - core/jquery.ui.dropable
    - core/jquery.ui.sortable
    - core/jquery.ui.dialog
    - core/jquery.ui.tab

I am trying the above way but the dependencies are not being loaded.


texts: How to trace the raw data of each element in a web page we want to check?

texts: I'm a beginner of Drupal8, and I've encountered lots of difficulties till now. One of the biggest one is that when I enable the Theme Debug, I always confused about where the selected part comes from. Together with the twig file, I know that a basic page grows up from the "html.html.twig", which bears the "page.html.twig", and there're regions we defined in the info.yml. Now in the region level, most of the time I lost my way to find where the next level element comes from because there only gives a simple code of "{{content}}" in the twig file. Is there a general method to better trace all level elements?


texts:
I would like to build a view (slideshow) of profiles, which is relatively easy to do. However I would like to filter them based on a node field of the page the view will be displayed on.
I defined a new content type called Category, where I describe categories in more detail. One of the node fields is called category.

My profiles also have a field category. The idea is that when a user views the node Category A, I would like to display a view showing all the profiles belonging to Category A. When the view Category B, I would like to display all the profiles belonging to Category B.

Can this be done via Contextual Filters? If so, how?

I'm not sure if this helps but the Category values are stored in Taxonomy.


texts: implementing user has password in hook menu

texts:
we are implementing a web service for a Drupal 7 site (the web service code is not part of drupal installation folder).

one of the web services needs to sign up the user on the site.
the main hurdle was getting  a hashed password that Drupal will also recognize.

for that , am following a suggestion made on stack overflow to Implement a REST service inside drupal and call that from the outside service code . (that part also seems possible and achieveable).

have implemented a password hashing service with following code:

function GetHashedPassword($string)
{
    require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');

    $hashedpw = user_hash_password($string);

    $data = array(
        'password' => $hashedpw
    );

    header("Access-Control-Allow-Origin: *");

    drupal_json_output($data);
    drupal_exit();
}

the main issue now is that whenever this service is called even with same string , it returns a new hashed value each time..

kindly assist if what we need is actually even possible and if so, then what could be fixed in the above code

any help appreciated


texts: How can a site programmatically detect if cron has not run in a long time?

texts:
I'm developing a module intended to proactively warn the admin if there are problems with the site. The idea is to periodically check the system status report and sends an email notice if certain statuses have gone from REQUIREMENT_OK to REQUIREMENT_WARNING or REQUIREMENT_ERROR. I'm planning on firing this check in hook_cron().

But what if the problem with the site is that cron is broken? What is a safe and performant way for the site to periodically check if the 'cron_last' variable is too old, that doesn't rely on cron?

I would like to keep the module self-contained and avoid external dependencies or "phone home" solutions.


texts: Using php if else statement in display suite

texts:
Ok i purchased a theme from themeforest called wunderkind.

I liked most of the things about it except for the blog page.  I liked the more traditional look of the summary image/video on the right and the blog summary on the left. Instead of one on top of the other.

So I am using display suites to layout the blog teaser and everything is working fine except that the blog article content type is dynamic.  You can have either a standard post or a video post.  If you choose video then a video URL field appears, and if you choose image then an image field appears.

I am trying to figure out how to create a code field in display suites that will either display the image or display an iframe with the video url.

The other route I am considering is simply creating a field in the blog called summary image and have it display on the main blog page.

Any help would be appreciated.


texts: How to create twig files content type specific in Drupal8?

texts: I have created a content type in Drupal 8. How should I write content type specific twig file?


texts:
Possible Duplicate:
  How do I update jQuery to the latest version I can download?

I need to upgrade jQuery from 1.5 to 1.7 in Drupal 7.

In Drupal 6 I could implement a hook_preprocess_html() function and alter the $variables['scripts'] to do this; but after inspecting $variables in Drupal 7, I can see there is no index called 'scripts'.

How can I do the same thing in Drupal 7?


texts: Creating a block with visibility set to "Only the listed pages"

texts:
I have the following code. It does create the block but I still cannot figure out why it is not adding that block to the desired region and also pages visibility settings are not working. What am I missing?

function my_module_block_info() {
  $blocks = array();
  $blocks['lp_sidebar'] = array(
    'info' => t('Lesson Planner'),
    'status' => TRUE,
    'region' => 'nav_column',
    'visibility' => BLOCK_VISIBILITY_LISTED,
    'pages' => "lesson-planner\r\n"
  );

  return $blocks;
}

function my_module_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'lp_sidebar':
      $block['subject'] = '';
      $block['content'] = _my_module_get_steps();
      break;
    }

    return $block;
  }


texts: Custom module files written in Windows aren't being recognized when migrated to Linux

texts:
I've developed several custom modules in my development environment. My current development environment is Drupal 8 in XAMPP running under Windows and I write the code in Netbeans. I'm getting close to production and I wanted to setup a development environment that mirrors production, so I setup Drupal in CentOS running in VirtualBox.

The problem is, is when I copied over my custom modules Drupal won't recognize them. They don't show up at all under Extend in the list of modules to install. I'm able to open and view the files in VIM and they don't look corrupted in any way. Also, If I create a module natively in CentOS it is recognized just fine. I'm reasonably confident permissions aren't the issue, I've tried setting everything to 777. I'm not 100% sure being written in Windows is the root cause however all the evidence points that way.

Is this a common problem? If so, what can I do to make Drupal recognize these files?

Thanks!


texts: Trying to edit the breadcrumbs for views using Custom Breadcrumbs module

texts:
I'm trying to use the custom breadcrumbs module with Drupal 7, and I'm having issues generating a custom breadcrumb - it only seems to want to let me edit nodes/add custom bread crumbs to nodes.

How would I go about adding a custom breadcrumb to a view?


texts: How do I fetch all users in a comment thread?

texts:
I want to send notifications to users that have posted in a comment thread. I need to get the user IDs in an event subscriber that will be triggered when comments are created/edited, so performance might of importance.
After some investigation, I realized there is the loadThread() method in the CommentStorage class, and I came up with the following implementation.
$original_comment = $event->getEntity();
if ($original_comment->hasParentComment()) {
  $commented_entity = $original_comment->getCommentedEntity();
  $comment_field = $original_comment->getFieldName();
  $mode = $commented_entity->getFieldDefinition($comment_field)->getSetting('default_mode');
  $thread = $this->commentStorage->loadThread($commented_entity, $comment_field, $mode);
  $recipients = [];
  foreach ($thread as $comment) {
    // I keep them in a keyed array so that i won't need to reiterate for unique values.
    $recipients[$comment->getOwner()->id()] = $comment->getOwner()->id();
  }
}

As far as I can see, there is no way to avoid loading all the comments in the thread, but just get the comment IDs. At least, this isn't provided by the storage and manager classes implemented by the Comment module.
Is there any way to get the list of all users who posted a comment in a comment thread without loading all the comments?
Edit 2: Following up on Jaypan's comment, there is indeed no notable performance hit, since, as he explained, Drupal entities are cached upon generation and thus, loading them is not the end of the world.


texts:
I am trying to understand the Drupal database schema because I need to access the database via MySQL by another system and I do not have access to the original Drupal developer of the site nor do I know Drupal well at this point (I did work with it 8 years ago) and it will be much easier to access with MySQL than to set up a server to have to host a PHP-based API or similar.

file_managed

In the file_managed table there is a field uri where the data all appears to be in the same of two formats:

public://<filename>, OR
public://<directory>/<filename>

My two questions related to file_managed are:

What is public:// mean here?  Does it translate to some root URL like http://example.com/files or similar?
When there is a directory in the uri, what do they represent?

UPDATE: I do not have access to the working Drupal system, I only have access to the database.


texts: Candidate page template filename for particular custom content type entry

texts:
I'm working on a Drupal 7 website. I created custom content type for works. I have many fields, and some of them are related to page layout like particular page bg for each entry. So I need custom page.tpl for this particular content type.

So I activated and opened Theme Developer module, and clicked the body area to get candidate name for this particular content type page entry. and it gives me the screen below which doesn't mean anything to me :/ When I click the node area, it is fine, it gives node--work.tpl.php, but I need for page. I tried "page--work.tpl.php", it didnt work.

What am I missing?


texts: How do you get and submit a webform in React?

texts:
I am planning to build a Drupal 8 site fully decoupled using Gatsby (a site generator for React). So I will use Drupal only to structure (content types, paragraphs), enter and update all the content and data and use React for the frontend.

The website also needs a (simple) form. I want to use the webform module for this.

But how do you get a Drupal form in React and after submitting send all completed fields to the database?


texts: How to add a custom vertical tab to node edit form?

texts:
How can I add a block with some HTML to the Node Add/Edit form? I've tried adding a new #markup field but I couldn't position it where I need by using weight.

See image below for desired location: just below the vertical tabs displayed to the right in the Seven theme.


texts: Conditional form states in hook_form_alter()

texts:
I have a node with a field, whose widget uses select boxes and multiple choices are possible. The values are coming from a taxonomy entity reference field. There is another field, a text field, which needs to be hidden.
/**
 * Implements hook_form_alter().
 */
function mijn_condities_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if($form_id == 'node_bedrijf_form' || $form_id == 'node_bedrijf_edit_form'){
    $form['field_afstand']['#states'] = array(
      'visible' => array(
        ':input[name="field_openbaar_vervoer"]' => array('value' => '236'),
      )
      );

  }
}

A select box should be added according their choice. For example, when they choose bus or tram, there should be a field to enter the distance in meters. When they choose airport, the range must be in kilometers.
The field isn't hiding.
I already tried to make the field invisible, but this doesn't work.
Does anyone know what is wrong?


texts: Taxonomy Access Control module - don't display term instead of disabling it

texts:
I'm using Taxonomy Access Control module to manage allowed categories of content user can create/edit. I want to change default behaviour of this module which disables term which user cannot assign ("black" in this example) but still displays it.
I know, it can be hidden via CSS or removed via JS, but I want to remove it on the module level.


texts:
I use Drupal-7.14 and the default theme,Bartik 7.14.
I added "my content type" as a new content type.
Then I could see a new content foo by the url hostname/content/foo.

The content foo shows the author and the date
because I checked

Structure > Content Types > my content type > edit > Display Settings > Display author and date information.

Only the date should be shown from logouted users.
The author should NOT be shown for logouted users.

How can I hide the author information from the non-member.


texts: How to display user submitted nodes in the node detail view of the same user?

texts:
I'm aware of such modules as Relation and Entity reference but I can't figure out how I make automatic relation between nodes that depend on the user that submitted those nodes.

Site has users A, B, C ... Let's say user A submits 10 nodes. When any user clicks on any of his nodes you can see his other 9 submitted nodes in the detailed view. When you click on node submitted by user B you can see his other submitted nodes and so on. This should work automatically without manually building relations between nodes.

How do I achieve this?

Thanks a lot
Ray


texts:
I've started my first custom theme and I pulled the main-menu print statement from the default page.tpl but it didn't display. Curiously, if I create a region and add the main menu to that region via the blocks administration it will show up. Why won't this show when hard-coded?

<?php if ($main_menu || $secondary_menu): ?>

    <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Main menu'))); ?>
    <?php print theme('links__system_secondary_menu', array('links' => $secondary_menu, 'attributes' => array('id' => 'secondary-menu', 'class' => array('links', 'inline', 'clearfix')), 'heading' => t('Secondary menu'))); ?>

<?php endif; ?>

If I switch the theme over to Bartik, that uses the exact same print statement, the menu seems to work fine.


texts: How to improve comments when using Acquia Marina theme

texts:
I'm using Acquia Marina theme but comments( sample here) and their replies look awful. It is difficult to distinguish between a comment or it's reply.

Is there any easy solution beyond a custom theming from my side.


texts: How to access Views administration in Commerce Kickstart 7.x-2.9

texts:
I can't seem to get into the Views administration panel from any place in Commerce Kickstart 7.x-2.9.  There is no menu entry even with Administration menu installed.  Trying to configure via the link for Views on the modules admin page simply sends the page to the Administration menu with no "Views" option.  Likewise directly entering siteurl/admin/views goes to the same place.

I guess the Views access is overridden by the Kickstart configuration.

Does anyone know a way around this?


texts: What html code can I use to create a form for readers to submit their contact information (e.g., phone number, email address, etc.) and type a question?


texts: My drupal 7 messed up after installing a module and I just get an error, how do I debug it and trace the source of that error?

texts: If I have a module that I installed and its causing a conflict with another module, how do I trace it down to see which is causing the conflict? Let's say the error message doesnt' give any useful information in finding the culprit module. How would one go about find the module causing the issue?


texts: Why is the replacement not happening when using the Search and Replace Scanner module?

texts:
I am using Search and Replace Scanner module to perform replacement of links in my website. When I run this module, It says replacement successful  and 250 fields are replaced. My site includes English and Dutch as well.But when I see in the database its not at all reflecting, No changes in the links. I referred this but no success. Give some other suggestions to achieve this.

I tried Drush Search & replace, it works awesome, but I dont want to replace all the links, only body content links should get replace. This filtering option is not there in Drush Search and Replace.

Any suggestions?


texts: Global Variable with a dynamic value set by variable_get() in multisite

texts:
My question is, if I have a multisite environment what is the expected behaviour of global variables set like:

define('GLOBAL_VARIABLE' , variable_get('myvar'));

'myvar' is set in a module configuration page, all the sites share the same module.
Will each site use an independent value for 'GLOBAL_VARIABLE'? Which is what I want, each site to have different values for these global variables.

I can't seem to find any documentation on how this would work, or any previous questions either. It's something that would significantly affect how my module is structured, as there's a rather large amount of customization settings.

Any input is greatly appreciated.


texts: Autologin and "Require e-mail verification when a visitor creates an account."

texts:
I'm trying to avoid users getting emails when their account is created, so I've unchecked the Require e-mail verification when a visitor creates an account setting in Registration and cancellation.

The problem I have now is this. Users are created with a custom form in my module. If an admin creates them, everything is fine. However if another type of user does it they automatically get logged in as the newly created user.

How can I disable this autologin?

Alternatively I'd also be happy with any other way to disable email notifications when a new user is created. Apparently using

$conf['user_mail_*_notify'] = FALSE;

in settings.php will not do the trick. I replaced the * with values from here


texts:
As instructed, I am looking at porting Message to Drupal 8. It uses token to generate the message arguments and so they are HTML escaped. This is the current code:

  foreach ($matches[1] as $delta => $token) {
    $output = \Drupal::token()->replace('[' . $token .  ']', array('message' => $this), $token_options);
    if ($output != '[' . $token . ']') {
      // Token was replaced and token sanitizes.
      $argument = $matches[0][$delta];
      $tokens[$argument] = FilteredMarkup::create($output);
    }
  }
$this->setArguments(array_merge($tokens, $arguments));

The message gets loaded and the message text API returns this for the message text:

new FormattableMarkup($output, $this->getArguments);

The test is as follows:

$token_messages = array(
  'some text @{message:author} ' . $random_text,
  'some text %{message:author} ' . $random_text,
  'some text @{wrong:token} ' . $random_text,
);

$replaced_messages = array(
  'some text ' . Html::escape($this->user->label()) . ' ' . $random_text,
  'some text ' . Html::escape($this->user->label()) . ' ' . $random_text,
  'some text @{wrong:token} ' . $random_text,
);

I get a double escaping fail if I do not use FilteredMarkup on save because in Token::render

$replacements[$token] = $value instanceof MarkupInterface ? $value : new HtmlEscapedText($value);

And remember, $value itself is a token replacement so it's already escaped! So I used FilteredMarkup but is marked @internal. How am I supposed to do this?


texts: pass argument through url and use it in exposed filters in views

texts:
I have  select box with taxonomy term ID's in it and when i change the term the respective content appears. This work well.

I am having the same term id's as click-able links on Left side block. I was thinking if i could pass a argument to a view from the URL and make the view content change as per the argument. Is it possible ?


texts: Contextual Filters > Default option: PHP Code input option is missing

texts: I have two drupal 7 sites.  I'm able to select the PHP Code option to input a default value for a contextual filter on a view on Site A....on Site B I'm unable to find this option.  Is this a version issue or a settings issue?  I'm at a loss to find out how to retrieve this option.


texts: Extracting a specific data part of a Field Collection Item

texts:
I've been playing around with this for the better part of a few days now with no luck. Here is my Collection data:

Collection name: field_video_collection

Within the collection there is a field called: field_video_file_col

My fields print fine in my custom field-collection-item--field_video_collection.tpl.php template, I followed the documentation according to this issue to get my template name and I simply print the fields as <?php print render($content['field_video_file_col']); ?> etc... within that template.

Now for the fun part, I'd like to extract the fid for each field_video_file_col item in the collection in any given node and render it as a printed variable. I followed the answer in this question here on Stack but it does not seem to work for me. if I do:

print '<pre>';
var_dump(get_defined_vars());
print '</pre>';

I see I have this as part of the data available to me for field_video_file_col

["field_video_file_col"]=>
          array(1) {
            ["und"]=>
            array(1) {
              [0]=>
              array(12) {
                ["fid"]=>
                string(3) "888"

So it looks to me that the FID is 888 in this case and I want to render that in my template. My node preprocess function is as such:

function MYTHEME_preprocess_node(&$vars, $hook) {

    $entity_type = 'field_collection_item';
    $bundle_name = 'field_field_video_collection'; // Field name the collection is attached to
    $field_name = 'field_video_file_col'; // Field name within the field collection
    $video_file_fid = field_info_instance($entity_type, $field_name, $bundle_name);
    if ($video_file_fid) {
      $my_fid = $video_file_fid['fid'];
    }
}

The end result needed is that I need to render the variable in my field-collection-item--field_video_collection.tpl.php template as:

<?php print $video_file_fid; ?>

... but this does not seem to work.  I've searched all over and tried many different incarnations of this code and combinations but still no joy.


texts: Rewrite labels on fields rendered via php

texts:
So I'm designing a specific node page where I'm manually inserting every field (to ensure I can customize it as the client wants) and I'm having a bit of trouble with certain areas.

Essentially I'm curious if there's a way to rewrite the label of a field while I'm including/rendering it.. see the code below for what I'm currently using:

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

I should also mention that I'm using Drupal 7 & the DisplaySuite module.

UPDATE: Is it possible to make it display HTML in the title area?


texts: Services 3 File upload, create/return image styles

texts:
Ahoy all!

So, long story short, I'm uploading files to drupal through services from an angular app, and getting a response/url/etc no problem. My question is, how do I enable image styles to be created on REST upload from services? I'm receiving an empty response in the image_styles array. I am assuming it likely isn't something I need to add into the POST request, but happy to add POST request code if needed.

I am coming up a little short on my google-fu on this one, and any help appreciated!


texts: What is the substitute for update_sql() in D7?

texts:
I am using update_sql() in hook_update of drupal .install file (D6) ?

Can update_sql() be used for D7 ?


texts: How to speed up tracking in elastic search?

texts: I have been experiencing extremely slow rebuilds of the search index on our client site which is currently indexing almost 4 lakh nodes, before indexing we need to complete the tracking process. But it is taking days. Is there any alternative solution?


texts: How to validate field in inline entity form referenced field

texts:
I have created field "Referenced"  which is entity reference field of other content type. Also this field have inline entity form functionality means its giving two button "add new node" and "and existing node"

Once we clicked on "add new node", publication content type node form will open. i want to make field_author entity reference field inside the inline entity form


texts: Relative and broken image with simplenews and mime mail

texts:
I have a content type with an image field. When I send a test mail with the simplenews module I get an image with an absolute path in email and see the image, but when I send it with cron I get a broken image because image url is relative. How can I solve this problem?

I am using simple news 6.x-1.3.


texts: Update query with a dynamic expression in Drupal 7?

texts:
db_update('warrior_members')
          ->fields(array('points' => 'points' +1))//This is not working
          ->condition('uid', $liv_user)
          ->execute();

How to increase the cell at 1?

Sorry for my bad English


texts: How do I redirect users and show a message?

texts:
I want to redirect users with RedirectResponse and display a message, but the message is not displayed.

$response = new RedirectResponse($url);
$response->send();

After little debugging I found that my initial (source) URL is loaded twice, and the messages (added with drupal_set_message()) are removed from the session in drupal_get_messages(). So I have no messages on my target $url.

How can I achieve this?

I'm doing it in hook_field_widget_form_alter().


texts: How to reference a view using entity reference field type?

texts:
I have two content types, courses and tutors.
Tutors contains a biography and a large photo

Courses contains lots of other information but more importantly contains a tutor field which is a entity reference field type.  It creates a dropdown list containing all tutors.

The problem I have is that when I create a new course page and select a tutor from the dropdown list, it displays the full biography and large photo.

What I want it to display is the first say 100 characters of the biography and a cropped version of the tutor photo (I have set up a image style which crops the photo to 100px)

I’m guessing there may be 2 ways of doing this.
1)  Customising a teaser
2)  Creating a view but I’m not sure how you reference it and how you would get the view to just show the selected tutor (from the dropdown list above)

I am using Drupal 7

Any advice much appreciated.


texts: I would like my homepage to seen by every user. But anonymous users should be redirected to a login page if they click on any link.  How can I achieve this?


texts: How can I add a view to the front page news feed?

texts:
I have created a view and I would like to promote the link to this view on the front page. How can I do this?

Thanks

UPDATE 1

I would like the view to show up in the front page news feed like in line along with other content that is "promoted to front page"


texts: Custom module blocks: where to put html code?

texts:
I have a custom module that implements hook_block_view. I would like to know where should I put extensive html code for a block content.

For example:

$block['title'] = t('TEST');
$block['content'] = '
';
$block['content'] .= ... 50 LINES OF HTML.
$block['content'] .= '
';

What I did so far was to create a .tpl.php file and put all this code there, and then only call:

$block['title'] = t('TEST');
$block['content'] = theme('user_custom_block');

Is it correct?

If yes, so far, so good. But what if I have a "complex" logic inside of this block content?

For example:

$block['title'] = t('TEST');
for...
  $block['content'] = '
';
  if:
    $block['content'] .= ... 50 LINES OF HTML.
  endif;
  $block['content'] .= '
';
endfor;
etc
etc

Is this still ok to use in a .tpl.php file? If not, which approach should I use?

Should I use something like this?

/**
 * Implementation of hook_block_view().
 */
function custom_block_view($delta='') {
  $block = array();
  switch ($delta) {
    case 'my-block-id':
      $block['subject'] = t('Block Name');
      $block['content'] = custom_contents();
      break;
  }
  return $block;
}

/**
 * custom html block
 * @return string
 */
function custom_contents() {
  return '

        Hello World, this is a example custom Block

    ';
}


texts:
Does anyone know how to extend the ckeditor to add the youtube plugin in Drupal-7?
I am talking about this plugin http://ckeditor.com/addon/youtube.
What is the drupal way of adding this?


texts: How to loop through comments using the Rules module?

texts:
I have created a rule (using the Rules module) using Rules Event "After updating existing comment" and some comment fields must be changed.

Loop node:comments is used but nothing happens when component is used to change a field (list_item is considered as Any entity (parameter) to use it in the component). node:comments doesn't work in that case. What can be done?


texts: Drupal Commerce - Product Variation Type missing Nodes

texts:
I've installed kickstart 2.0 with the demo data.
I tried creating my own product variation types and product displays.
I can't see to get my products to display in the same way to the commerce built-in demo products.

I think this is my custom product variation type seems to be missing the correct "Node: Product list" and "Node: Full Content" options (Product Variation Type -> Manage Display section)

Please see attachments.
"Tops" is the built in product variation type delivered with CK 2.0.
"Photos" is a product variation type i created.

Drupal commerce is my first exposure to drupal hence my knowledge of nodes isn't sound, please let me know what I'm missing?


texts:
I have one node in that link image filed and video file fields are included and i have created custom page that page will be redirected by link image field which loads jwplayer video.

I want to load a that particular node video file entity in that custom page?? how to do that


texts: I want to hide error and warning message from admin panel. I have checked the option None in admin panel for error reporting and still it showing error and warning messages in admin  panel. let me how it can removed.


texts: How do I tear out the existing menu in a theme and replace it with super-fish (v7.x)

texts:
I know this is similar to the Bartik/menu question but I do not believe it is the same, here is the requirement. I am using "the morning after" theme in Drupal 7. This theme looks the way the client wants it but we need a drop-down ability on the "main menu", the menu that runs horizontally across the top of the page. This theme does not have a "navigation", "main menu" or similar region to pop super-fish into. I have tried all the instructions in the Bartik/Super-fish post and I can get super-fish to show up in an region but I have not been able to get it to REPLACE the existing embedded-in-the-theme menu. Any help is greatly appreciated.

This site would not let me post an answer, so as an edit, here is the answer I found.
This did not get me 100% where I wanted but found this on another post. It is for a different theme but it seemed to be essentially the same. hope it helps

Im using Drupal 7 with the Busy Theme and I can't figure out how to set Superfish to replace the existing main menu with itself. I can add Superfish to other regions of the theme and it works great, but there is no way to replace the main menu with Superfish that I can find. This may be a problem in that the main menu area of Busy doesn't seem to have a region set to it, so perhaps that could be the problem...

Thoughts? I want to use a drop-down menu for the main user menu, but nothing I do will allow Superfish to replace that main menu.

Description Login or register to post comments Comments

1
Posted by Mehrpadin on April 1, 2011 at 7:54pm Hey there,

Well, normally you should ask the theme developer, but as I see there are a number of similar requests in the issue tracker of the theme, I think I should help you myself:

Create a new region by putting the code below somewhere in busy.info regions[navigation] = Navigation You may need to rebuild your theme registry. /templates/page.tpl.php , line #52 to #58: $main_menu, 'attributes' => array('id' => 'main-menu', 'class' => array('links', 'clearfix')))); ?> Replace with this:
Voila!


texts: How do I create a URL from a form field?

texts:
I am getting too much escaping. The url is created in a module that redirects the for result.

$form_state['redirect'] = url('studio/' . $studio_profile->field_studio_name[LANGUAGE_NONE][0]['value']. '/class-timetable');

I am getting this

http://localhost.dev:8888/studio/John%2527s%2520LazyBoy%2520Tester/class-timetable

Not this

http://yogahive.dev:8888/studio/John%27s%20LazyBoy%20Tester/class-timetable

That is - the escapes look escaped in John's LazyBoy Tester.

How do I correctly redirect?


texts: Is making field.tpl.php print the URL of the node the displayed field is attached to possible?

texts:
Currently I have this setup with Views but I would like to take views out of the picture to optimize the site and fix a couple of problems that occure as a result of using Views.

What I am trying to achieve is if my nodes have content in a Body of Text called excerpt that it will show a button that links to the node's url and append the text "/excerpt" at the end of the node's url which will then display a different page with the content of excerpt on it.

I'm using Drupal 7 and am modifying a Zen subtheme.


texts: How do I delete an upload from an order?

texts:
I have a situation where the customer uploads a file with their order, using a file field attached to the order. The only way currently on our site to delete the artwork is to delete the order or delete files through FTP.

Neither of these are ideal, it would be best to have an automatic rule set up that deletes all uploads after a certain amount of time, say 1 week after the order, but does not delete the order as these need to be kept in record.

Either this or a manual way to achieve this, I have had a look around for modules but there doesn't seem to be one to achieve this.


texts: Give an individual cron task for each Feeds import

texts: Can I separate different import tasks? I have feeds module installed and it runs multiple import jobs per cron. So I would like to at least order them (give different weights to them).


texts: Exclude from list view some articles based on their content type?

texts:
i’m listing in a view a list of article filtered with taxonomy terms.

The result is like this :

taxonomy term 1
- article A (content type 1)
- article B (content type 1)
- article C (content type 2)

taxonomy term 2
- article D (content type 1)
- article E (content type 1)
- article F (content type 2)

taxonomy term 3
- article G (content type 1)
- article H (content type 1)
- article I (content type 2)

How can i exclude from this list some articles based on their content type ? For example, remove "content type 2".

Also, i’ve created a view which contains article C, F, I. How can i add a specific view to this list ?

Here is my view settings :

Here is the result in front-end :


texts:
I got to be missing something obvious. I want to display in my view 0 items until they use the Filter Criteria exposed filter with a search parameter.

Under Pager Use Pager I can't see how to display 0 items?

Is it possible?


texts: Change database column type in hook_update_N

texts: I have a column in my database, its type is int. Now I need to store decimal numbers. How can I change its type to decimal with hook_update_N?


texts: I am using an EntityFieldQuery with ->tableSort() and then adding a few columns to each row programatically. Is there a way to have tableSort() sort by my computed fields instead of only raw db fields? (Note: I don't mean the module Computed Field - which I now realize is probably the solution.)


texts: Views to display different text than field

texts:
I have added a field in Article content type,

field_url : contains external URL

I made a view to display the items in table format, Now my problem is to display as small text as possible in table.

I want to display Yes or No for field_url. If somebody have filled the field while adding content then instead of displaying whole URL I want to display only Yes with a link, if the field was empty I want to display No.


texts: Programmically populate select list with hook_form_alter

texts: I have no trouble populating other fields, but am struggling with populating a select lists #options. Anyone know of a slick way of going about that or have any good reference material?


texts: More template suggestion for views exposed form

texts:
Using the debug function I have found only one template suggestion for view's exposed form:

form--views-exposed-form.html.twig

I need to make changes to particular view, but I dont have other default suggestions like:

form--views-exposed-form--view-name--display-name.tpl.php

Should I write a function like hook_views_exposed_form_alter()


texts:
This morning my Drupal 7 site suddenly not working. I get the
"PDOException: SQLSTATE[08S01]: Communication link failure: 1153" error. The error goes away when I disabled "Aggregate JavaScript files." in config/development/performance page. I clear the cache several time, but when I re-enable "Aggregate JavaScript files" the error comes back.

This error happens only on certain pagee.

Can anyone shed some light on this problem? It doesn't make any sense to me. Thansk.


texts: How can I print the value of the node body using PHP with the text format applied?

texts:
I am printing the node body using PHP on an admin view via a template; however, when I do this, the text comes out as one giant block (spacing is ignored).  However, when I go to edit the node, the content is spaced properly.

My code looks like this:

print "Body: " . $body[0]['value'];

What do I need to change to make sure the spacing/formatting is printed out properly?


texts: How can I create a user with a term reference field in a Behat test when using the Drush Driver

texts:
My Behat test has the following Given statement. (field_regions is a taxonomy reference field)

Given users:
   | name      | mail             | roles         | field_regions |
   | Joe User  | joe@example.com  | region        | Midwest       |

If I used the Drupal driver locally it created the user and adds Midwest to field region.  If I use Drush driver it never adds it.  I think it may be because it is an entity reference and the Drush driver can't handle this.


texts:
I have a CCK field with a data type 'text', that I want to change to 'decimal'.

I have used a hook_update_N and db_change_field in order to do this.

Here is an example how I tried to do it:

function ptm_foo_update_6005() {
  db_change_field(
    $ret,
    'content_type_',
    'field_foo_value',
    'field_foo_value',
    array(
      'type' => 'decimal(10,2)',
      'description' => 'Foo'
    )
  );
}

But when I execute the update, it gives me the following error message:

  User warning: You have an error in your SQL syntax; check the manual
  that corresponds to your MySQL server version for the right syntax


texts: How to create a custom Aegir Drupal interface

texts: I'm interested in using Aegir to deploy Drupal websites. I'm wondering if there is a way to customize the user experience of setting up a new site, while still maintaining the Aegir mechanism. Probably something more like the standard Drupal setup screen.


texts: Headless Drupal 8.3 - Allow a user to choose their own password via the user registration endpoint, while also sending an email activation link?

texts:
The planned user registration process is as follows:

The user enters their email address and chooses their password using the registration form. After registering, an email containing an account activation link is sent to them.

We're using React Native on the front-end.

I'm not sure about the best way to achieve this. Is there an existing module(s) for this?


texts: Does having too many content types negatively affect site speed and performance?

texts: I building a site that could potentially utilize 20 different content types. The content types are very similar, but may only utilize one or two fields that are unique to that content type, and they would use the same 5 fields with each other. Does having 20 different content types slow the site down? Would it be better to build one content type and display the unique fields on a case by case basis using FAPI or the conditional fields module?


texts: Single SQL query to pull recent two nodes from each node type

texts: As mentioned in the title, I was wondering how this can be achieved with single SQL query. All I need is the node ID from node table that matches the given criteria.


texts:
I have a Drupal 6 site with different content types, and node references. I also have a custom theme. I want to migrate to Drupal 7.
I use the Node export, and Node import modules, but they are not working perfectly, as I am not able to import node references.

Is there any easy way to do this?


texts: Drupal 8 does not create path alias' valid for all languages

texts:
I have a Drupal 8 multi lingual site setup using the module Pathauto to generate path alias for taxonomy terms. The alias are created form the name of the tags, which are not translated but rather are in all languages the same. So I want all those alias be valid  for all languages.
The settings page of the module Pathauto lets me either leaving all languages unselected or choose specific languages for which the created path should be valid for. But unfortunately the pathes are created only for English and do not work if a user has a different language selected.

Is that a bug, or am I not doing it correctly?


texts:
Is there a way to use a custom template for each block by title? For example, if I named my block "test1", and it is in the region "left1", I want to use the following template suggestions:

block-left1-test1.tpl.php
block-left1.tpl.php
block-test1.tpl.php

Is there a list of template suggestions for blocks?


texts: Use a twig template instead of a render array in a custom module admin page

texts:
I have a Drupal 8 custom module, and I want to display its configuration page using the admin theme.

Usually, for this kind of pages I use, in the _controller property of my route, rather :

a class that extends \Drupal\Core\Form\ConfigFormBase (for a simple form-like config page)
a custom controller that extends \Drupal\Core\Controller\ControllerBase and returns a renderable array

For this module, I need to use complex HTML structure and a Javascript library for its configuration page. Writing all this directly in a #markup property of a render array would be too much work and highly not-maintainable.

Is it possible to write a custom template (twig or not), to render it programmatically and insert the result into a container element or in a #markup property ?
And, as I use the Seven admin theme, I would like to do this without affecting the theme.

[Resolved] Final solution :

Combining leymannx answer and the elements mentioned below, I ended up with something that meet my requirements.

mymodule.routing.xml

mymodule.admin_ro:
  path: '/admin/config/mymodule/readonly'
  defaults:
    _controller: '\Drupal\mymodule\Controller\ReadOnlyController::index'
    _title: 'Module configuration - read only'
  requirements:
    _permission: 'view mymodule configuration'
  options:
    _admin_route: TRUE
    no_cache: TRUE

ReadOnlyController.php

class ReadOnlyController extends ControllerBase {

    public function index(){
        return array(
            '#type' => 'container',
            '#theme' => 'test-template',
            '#test_var' => [ 0, 1, 2, 3 ] // I needed an array type variable
        );
    }

}

mymodule.module

// Implements hook_theme()
function mymodule_theme( $existing, $type, $theme, $path ){
    return [
        'test-template' => [
            'render element' => 'container', // To render a simple container element
            'template' => 'test', // My template file name
            'variables' => [
                'test_var' => [] // Default value for my variable
            ]
        ]
    ];
}

And finally, my test template : templates/test.html.twig

Hello !

{{ dump(test_var) }}

Related doc or posts

hook_theme
Form and render elements | Drupal API
Create custom twig templates for custom module
How can I programmatically display a block?
StackOverflow - Drupal 8 custom block (module) create twig template file


texts:
I have some custom form in a page ( sign/signup),first I try render them with  google API instruction

Paste this snippet before the closing  tag on your HTML template:

>

Paste this snippet at the end of the  where you want the reCAPTCHA widget to appear:

everything was ok for only one form, but recaptcha in another form not rendered.
I search for a solution and found How do I show multiple recaptchas on a single page
Then I'm trying to implement it with Drupal structure.what I do is
part of  mytheme_libraries.yml file
global-script:
  js:
    https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit: { type: external, minified: true ,attributes: { defer: true, async: true} }
    js/myload-recaptcha.js: {}

and myload-recaptcha.js file
Drupal.behaviors.myrecaptcha = {
    attach: function (context, settings) {
        (function ($) {
            alert('Hello,I am fine');
            var CaptchaCallback = function () {
                $('.g-recaptcha').each(function (index, el) {
                    grecaptcha.render(el, {'sitekey': 'my_key'});
                });
                console.log(grecaptcha);
            };
        })(jQuery);
    }
};

and some  part of  header.html.twig

alert fire correctly and it mean file loaded correctly, I take look and  js files, also  https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explici exists in loaded js files.
where is the problem and how can I render two Captcha in Drupal 8 theme  programmatically ?


texts: Relationships between content types based on existing field (not using entity reference field)

texts:
Example: I want to build a data structure doctors (which will be a node of content type "doctor" not a user) who, if he becomes a user, will post to 3 other content types 1. articles, 2. case examples and 3. testimonials from patients. The Doctor will create all three content types or admin will create them and then change author to the appropriate doctor. (This is important because the creator is not always the author).

I know I can accomplish this with an entity reference field in every content type that references the doctor. However, I want the doctor's input form to be as simple as possible and they may forget or make a mistake in entering the entity reference field data.

It seems to me that I should be able to create a relationship in views (a join) based on the author field. Example: a "testimonials" view" that includes a picture of the doctor from his profile node not his user entity, that will link to his profile.

I know there are other ways to accomplish the solution (ie through user ID, which is available) but this only an example. There are other places in my site that I need to connect two different content types in a view based on an existing field (think city or state or color).

In database design this is easy.  In a query, I can join two tables based on any field I want.  How do I do the same thing in Drupal?  This driving me crazy and there must be a simple answer.


texts:
How can I store php query result into an array in Computed field code(PHP)?

For example:

$query = db_query('SELECT field_holiday_date_value FROM field_data_field_holiday_date');

how can I store it into an array?


texts:
My goal is to have a menu block on my blog pages with a list of the terms used in the blog posts. So far I have set up a node view for the blog postings. And a term view called topics to display the terms.

It's working, but when I click on a term listed in the block the resulting path is category/topics/term-name. I would like to have a path such as blog/topics/term-name or even better just blog/term-name.

I have looked at the Taxonomy menu settings under the taxonomy/edit/vocabulary but haven't figured out if I can change these settings to get what I want.

I'm using the Pathauto module. Not sure where else to look for an answer. I'm using 6.


texts: Disable the Drupal 7 overlay for some administrative links

texts:
Is there a way to disable the Drupal 7 overlay for some administrative links by not others?

For usability reasons the site I'm working on would benefit from some administrative links using the default overlay behavior while 1 or 2 would benefit from having it disabled.  Since the vast majority of the links make more sense for users to experience in the overlay I'd like it to be generally enabled for them, but be able to keep a couple specific links embargoed so the JavaScript does not update their behavior.


texts: Within a view listing, how can I denote whether a node's date is upcoming, current or past?

texts:
I am working on an art gallery site in which we have two views that are filtered based on the date range of an exhibition. One view filters current exhibits (now >= start date && now <= end date) and another that filters upcoming exhibitions (now < start date).

We would like to combine these into a single page view. This is simple enough to do with this date filter: now <= end date. However, I would still like to denote which events are upcoming (be it a CSS class or by rendering the date field as "Opens on Dec. 12th").

Is there a way to render/rewrite the date field differently based on the field's value relative to today's date?

For example, if today's date is Nov. 1, 2015, I would like these two nodes:

Exhibit #1 (Oct. 1, 2015 - Dec. 1, 2015)
Exhibit #2 (Jan. 1, 2016 - Feb. 1, 2016)

To render like this:

Exhibit #1, Ends Dec. 1 2015
Exhibit #2, Opens Jan 1, 2016


texts:
Is there a module to automate exporting/importing a batch of Views (for import onto another site?)

I have a Commerce Kickstart site with demo data. I can't figure out how to remove the demo data without resetting the site, so I'm going to start over.

I want to take some Views I created myself with me. (Unless someone has the magic trick to remove all Commerce Demo data...including Product Types without using Reset() of course. :D )

TIA.


texts: How can I set “This block (override)” programmatically on a view's display

texts:
I need help about a specific implementation in Drupal 8.

I have been trying for two days to create a view programmatically, or more precisely to create a new display of an existing view.

The objective is to create (at the same time as creating new content) a duplicate display of a view, which is almost the same than the original, with just the title and a condition in filter criteria (a node id) changed, in order that the final user never needs to add display or modify the view.

The issue that I am coming up against is that the generated view's display lost an important property, the “This block (override)” parameter is replaced by the default state “All displays (excepts overridden)” so once I have generated the second view’s display programmatically, the first view’s display has its properties (title, filter criteria) replaced inevitably by the values of the second.

So I would like to programmatically set the parameter “All displays (excepts overridden)” at “This block (override)” but I haven’t found anything of relevance in the D8 API.

Thank you in advance for any ideas or suggestions.

function HOOK_node_insert(Drupal\Core\Entity\EntityInterface $node) {

if ($node->type->target_id == "SPECIFIC_CONTENT_TYPE") {

    $node_title = $node->getTitle();
    $node_id = $node->id();
    $machine_title = strtolower(str_replace(" ","_",$node_title));
    $block_id = 'block_'.$machine_title;

    $view = Views::getView("api_domain");//"api_domain" is the view's machine name
    if (empty($view)) {
        return;
    }
    $display_id = 'default';
    if (!$view->access($display_id)) {
        return;
    }

    $view->newDisplay('block',$node_title, $block_id);
    $options_array = array(
        'id' => 'field_api_domain_target_id',
        'table' => 'node__field_api_domain',
        'field' => 'field_api_domain_target_id',
        'relationship' => 'none',
        'group_type' => 'group',
        'admin_label' => '',
        'operator' => '=', 'value' =>  array('value' => $node_id));

    $view->setHandler($display_id, 'filter', 'field_api_domain_target_id', $options_array);//works
    //$view->setTitle($node_title);//doesn't works
    $view->display_handler->setOption('title', $node_title);// works
    //$view->display_handler->overrideOption('title', $node_title);// works too, but the "override" problem still persists
    $view->save();
}

}


texts: migration plugin works but fail to migrate in drupal database

texts:
I try to migrate old blog article to a drupal website here is my migration class :
class Article extends SqlBase {

  /**
   *{@inheritDoc}
   */
  public function query() {
    $query = $this->select('news', 'n')
      ->fields('n', array(
        'id',
        'title',
        'content',
      ));
      return $query;
  }

  /**
   * {@inheritDoc}
   */
  public function fields(){
    $fields = array(
      'id' => $this->t('Autoincrement ID'),
      'title' => $this->t('Article name'),
      'content' => $this->t('HTML content'),
    );
    return $fields;
  }

  /**
   * {@inheritDoc}
   */
  public function getIds() {
    return [
      'id' => [
        'type' => 'integer',
        'alias' => 'n',
      ],
    ];
  }
}

my migrate_plus.migration.article.yml :
#Migration metadata
id: article
label: Migrate list of articles
migration_group: article_migration

#Source plugin, id defined in the @MigrateSource annotation
# in the src/Plugin/migrate/source/Article.php file.
source:
  plugin: article
  key: migrate

 # Process plugin
process:
  title: title
  body: content

# Destination plugin
destination:
  plugin: entity:node
  default_bundle: article

# Nothing needed here, it is a single table without any other relation.
migration_dependencies: {}

when i lunch drush ms i have this :
$ drush migrate-status
 --------------------------------------- ----------------------------------- -------- ------- ---------- ------------- ---------------
  Group                                   Migration ID                        Status   Total   Imported   Unprocessed   Last Imported
 --------------------------------------- ----------------------------------- -------- ------- ---------- ------------- ---------------
  article_migration (article_migration)   article                             Idle     290     0          290

  Default (default)                       block_content_type                  Idle     1       0          1

So the multiple database connection is working yet  when i run $ drush migrate-import article
i have that error that i don't understant :
 [error]  Migration failed with source plugin exception: SQLSTATE[42000]: Syntax error or access violation: 1049 Unknown database &#039;jiyblog2&#039

article migration failed.


texts: complex content references: which solution? views (big query) OR non-views db_select() OR many node_loads OR

texts:
I have content type that links to several other content types

Report -> Plot -> Dataset -> Citation (biblio).

This type has a conditional field which selectively links to to possibilities each with field collections and entity references.

I want to show information from each of these together.  These are the options I'm considering:

1) I can do this with views.  It turns out that the 'table' type (a $rows array makes it easy than inspecting the $views object) and several relations can put something that works together.  The query is quite big with at least 10 LEFT JOINs, and it does seem a bit kludgy (I have to modify the 'tables' template and strip out the  html and a lot of the class info.  The solution I want isn't a table, and I'm not sure this is the best way.)

2) I could skip views and develop my own module/block use db_select(). This would allow me to simplify the query with a UNION.  But I have to so a lot more work on my own when views does a lot of the work for me.

3) I could skip views, develop my own module/block use a smaller query and with enough entity_loads and node_loads I can get all the info I need.  The problem having so many 'mini-queries' with all the node-loads seems like an inefficient way of doing things..

What is the recommended solution for something like this?

thanks!


texts:
I've got a rule link in a view
Rules link generates me this link per user displayed by the view

http://localhost/drupaltest/addequpier/18/14/6OwljLX8KLBfNPrW37bzulzuue25VJmkzWtGiPmR-mc

18 is the user id
14 the node id (i've added this parameter with rewrite url)

How can get those parameters from the url with rules ? Do i have to rewrite the url ?

I'm using Drupal 7


texts:
I need to recreate the behavior drupal has when you create a translation but programmatically.

Doing $node->addTranslation('de'); on a hook insert create an empty node but I need the field to be filled with the untranslated node content.

Is there a way to achieve this instead of having to repopulate every field from the main node ?


texts: How to replace current symbols with font awesome icons in every pager?

texts:
I want to replace current symbols with font awesome icons in every pager on my site. Problem is, the icon tag is printing as text, not as html. Here's my code:

function default_preprocess_pager(&$vars, $hook) {
  if ($vars['quantity'] > 5) $vars['quantity'] = 5;
  $vars['tags'][0] = '<<';
  $vars['tags'][1] = '<';
  $vars['tags'][3] = '>';
  $vars['tags'][4] = '<i class="fa fa-arrow-double"></i>';
}


texts: Entity Tokens + Date Field + Custom Format... unable to use spaces

texts:
I have a content type (Question of the Week)... with a Date field (Used for "Publish Date". Questions won't be published until that date).

I am trying to custom format the Title for it without changing the default (Long, Medium, Short) date formats.

For "Pattern for the title"...
If I [node:field-jcqotw-date:custom:l] it shows the day (ex: Sunday).
If I [node:field-jcqotw-date:custom:lF] it shows the dayMonth, no space (ex: SundayJune).
If I [node:field-jcqotw-date:custom:l F] it shows "[node:field-jcqotw-date:custom:l F]" (ex: SundayJune).
If I [node:field-jcqotw-date:custom:l F] it shows "Sunday June" (ex: SundayJune).

I've tried "l F", 'l F', l\ F,   (non breaking space),   (Space), etc... Nothing I do seems to let "Custom" use a space.

Edit: After some research... it seems to be an Entity Tokens + CCK Date Field issue... I'll have to put an issue up in those places.

Why can't I use a space in the "Custom format"?

Also... I've created a "Date Type" simply called "myDate" => 'l F j, Y' ('Sunday June 5, 2011'). Is there a way to get Token to show that format? Long, medium, raw, short... "myDate"...

Edit: Updated Title and Question to be more correct. The problem has something to do with Entity API, Context, Date Field


texts:
I tried using the entity_metadata_wrapper, but most of the fields can't get imported. Most of the time only the title is imported.

if (isset($result['node'])) {
  $exclude_fields = array(
    'nid',
    'vid',
    'is_new',
    'language',
    'url',
    'edit_url',
    'comment',
    'comment_new',
    'changed',
    'comment_count',
    'comment_count_new',
    'is_new',
  );

  $default_values = array(
    'language' => 'fr',
    'translate' => 1,
  );

  $nids = array_keys($result['node']);
  $entities = entity_load('node', $nids);

  foreach ($entities as $entity) {
    $entity = entity_metadata_wrapper('node', $entity);
    $keys = array_keys($entity->getPropertyInfo());
    $keys = array_diff($keys, $exclude_fields);

    $values = array();
    foreach ($keys as $key) {
    if ($entity->$key->value() !== null) {
      $value= $entity->$key->value();
      if(isset($value->summary)) {
          unset($value->summary);
        }
        $values[$key] = $value;
      }
    }
    $values += $default_values;
    dpm($values);
    $return = entity_property_values_create_entity('node', $values)->save();
    dpm($return);
  if($return === false) {
    dpm($values);
    }
  }

If you any other approach, I'm willing to test it.


texts: How to nest Rules, call a rule from another rule and how to choose between 2 Rules Actions?

texts:
Is there a way to nest Rules, or make them behave more like an if / then / else functionality.

Currently I can only figure out how to trigger a Rules Action based on a Rules Condition, but not how to choose between 2 Rules Actions.

In addition, is there a way to call one rule from another?


texts:
I am trying to retrieve the details of the last user who registered to the site. There is a similar question here: How to get the uid of a newly created user?
but it assumes that the registration is also done programmatically, while I don't have any such assumption.

The only way I saw how to do it was to go to the DB directly (not recommended by basically every resource I read). Is there a way to do this through some other interface?


texts: How to create a custom content type region template?

texts:
I built a sub theme based on Omega's adaptive Alpha theme. I made a content type called "project". For that content type I need to edit what gets displayed on the project detail page. What is the best way to do this?

I currently have a page--type--project.tpl.php file that I can edit, but Ideally I would like to just edit the region, like with using something like region--content--project.tpl.php file or something. Is that possible? I haven't found anything online with modifying a region based on the content type.


texts: "Add link" attempt for a Menu yields 500 error

texts: I have tested with fresh installs of Commerce Kickstart down to version 2.6, the error happened. I even disabled all modules related to the Menu module or with menu in the name, no luck. I also disabled and then enabled the Menu module, no luck. However, I tested version 1.19 and it did no yield this error.


texts: How do I set a custom input format for a field?

texts:
After using Drupal 7 for years, I am now handed a Drupal 8 site to do some editing. I have created a custom input format (Plain HTML), and I want to print this field with this input format in a custom template. How can I achieve this?

With {{ content.field_mapka_markery }}, it prints plain text. There is no choice to select my newly created input format in the Manage display settings. Why is that? In Drupal 7 there is always a new formatter,  but not so in Drupal 8.

I also tried {{ content.field_mapka_markery|raw }} or .value. |raw doesn't  work at all, and .value does the same as without it.


texts:
I am trying to use the Openlayers Feature Popups module  for my map.

Just ran into some issues which I am yet to find a solution. Under the behaviors tab of the map I have tried to adjust the settings so that the popup can have the name of the node on the popup all I get is a blank popup on click and .undefined on hover.

How do I get the node title and any other field for that matter to show up on the popup just for a starting point at least.


texts:
I am having a view of users, in that I have added a field "Status" which is from the core Drupal 7 to display the user which are "Active" or "Blocked".

What I am trying to achieve is that:

I should get a clickable link to the field value status, assuming if its "active" Achived, here I have just rewritted the output "user/[uid]/edit?destination=admin/people" checked with Use absolute path itself in the View.
When I click on it I should only get a page with only value of "Status" where I can change the status of the clicked user; here I am stuck, any idea how can I achieve this?


texts:
If you need to restore a Drupal 8 site from a backup, which files are essential?

core -> -
modules -> +
profiles -> +
sites/default/ -> +
sites/default/files/config_* -> -
sites/default/files/css -> -
sites/default/files/js -> -
sites/default/files/php -> -
sites/default/files/styles -> -
sites/default/files/field -> + (and any other user uploads)
themes -> +
vendor -> -

"-" means not needed, because Drupal core or cached files; "+" means files necessary to restore a Drupal 8 site.

For a backup script that allows to restore a site on another server in case of a server crash, can I leave out all cache data, or should I backup some of them to run Drupal without problems?


texts:
I have just migrated a Drupal 8 site. Everything works, except for the login. When I submit the login form, I receive "Access Denied" page from the theme. Similarly, I get some SMTP module errors when I try resetting the password.

My .htaccess files are identical between the source and the new site. I have also tried truncating the "sessions" table in the database.

When I run drush watchdog-show command, I get the following, which I think corresponds to my trying to login and reset the password.

 2053  28/Feb 16:23  user      notice    Session opened for admin.
 2052  28/Feb 16:23  php       error     RuntimeException: Failed to start the session because headers have already been sent by
                                         "/var/www/html/modules/smtp/src/PHPMailer/SMTP.php" at line 800. in
                                         Symfony\Component\HttpFoundation
 2051  28/Feb 16:23  mail      error     Error sending email (from careers@maa.org to xxxx@xxx.org with reply-to
                                         xxxxxxxx@xxx.org).
 2050  28/Feb 16:23  smtp      error     Error sending e-mail from careers@maa.org to xxxx@xxx.org: SMTP Error: Could not
                                         authenticate.
 2049  28/Feb 16:23  smtp      info      Sending mail to: xxxx@xxx.org
 2048  28/Feb 16:23  user      notice    Login attempt failed for admin.
 2047  28/Feb 16:22  user      notice    Session opened for admin.
 2046  28/Feb 15:23  page not  warning   /phpmyadmin/scripts/setup.php
                     found
 2045  28/Feb 14:48  cron      notice    Cron run completed.
 2044  28/Feb 14:48  mail      error     Error sending email (from xxxxxxx@xxx.org to dev+startupgrowthd8@morethanthemes.com with
                                         reply-to not set).

What else can I try to fix this?

Edit:

I have been able to deduce that this behavior only occurs in Chrome browser. Others like Firefox and IE work well. Similarly, the problem only occurs only in AWS EC2 instance. However, I still do not have a solution.


texts: How to configure multisites for the console?

texts:
Most of console commands are not listed when using

drupal list

Drupal Console version 0.11.3

It issues a warning like so:

[WARNING] In order to list all of the available commands you should install
       drupal first.

Drupal is installed , as multisites.

   drupal multi:debug

Tells me this error:

 [ERROR] There aren't multisites configured

How can I configure multisites for the console ?

     https://hechoendrupal.gitbooks.io/drupal-console/content/hu/using/how-to-use-drupal-console-in-a-multisite-installation.html

EDIT:

a mapping must be done in sites/sites.php for

drupal multisite:debug

to display the list

sites.php

 /**
 * Multi-site directory aliasing:
 *
 * Edit the lines below to define directory aliases. Remove the leading hash
 * signs to enable.
 */
$sites = array (
    'my_domain_name.fr'=>'my_folder_name_in_sites?'
);

What is the exact format of this array values i dont know

i dont have drupal multi:debug error nomore mais drupal list is still restricted


texts: Nodewords: how do I use hook_metatags_default_values_alter?

texts:
I posted this question a week ago on the nodewords issue queue, but have had no reply and I'm stumped.

I want to programatically set the default value for a couple of tags, but the code comments for hook_metatags_default_values_alter read like hieroglyphics to me. An example would allow me to understand clearly. If I want to set the og:latitude tag to the value 43.701536, what should the call look like?

Thanks!


texts: Drupal 6.19 - cannot add node links to primary-links

texts:
I have a problem that is driving me crazy. I've been trying to solve it for a week now without luck.
The problem is, I can't add any internal (node/xxx) links to primary-links. After I add one, it appears, but I cannot edit or add any nodes until I delete that menu item. If I try to edit a node, i get the message "username admin does not exist". It looks like this triggers an effect that is causing admin user to lose permisson for node_access. After I delete the created menu item, everything is back to normal... until I add another menu item.

Here's a summary:

I can add external links to primary-links, no problem
I can add internal links to seconday-links, no problem
It doesn't matter if I add the menu item manually or by specifying one on the node edit page, the effect is the same
The language, weight and position of the menu item doesn't matter, as long as I add an internal link to primary-links, the above problem appears
I tried to rebuild the menu, disable modules, clear the cache, rebuild permissions, no luck
I double checked the menu_links table, there were some orphan items (had no parents) which I deleted, but otherwise everything is fine

I am using Drupal 6.19 with only one user (the admin), a bunch of modules and 11 languages. I must solve this problem soon as we need to add another language and it'll definately need some internal links in the menu.

Edit: Here are the modules currently enabled:

CCK

Content   6.x-2.8
Content Copy  6.x-2.8
FileField 6.x-3.7
FileField Sources 6.x-1.2
Node Reference    6.x-2.8
Number    6.x-2.8
Option Widgets    6.x-2.8
Text  6.x-2.8

Location

IP to Locale  6.x-1.0-rc1
Smart IP  6.x-1.3

Meta tags

Nodewords 6.x-1.11
Nodewords - basic meta tags   6.x-1.11

Multilanguage

Block translation 6.x-1.7
CCK translation   6.x-1.7
Content type translation  6.x-1.7
Internationalization  6.x-1.7
Menu translation  6.x-1.7
String translation    6.x-1.7

Other

Custom Page   6.x-1.17
Custom Page Admin UI  6.x-1.17
GeoIP 6.x-1.4
Global Redirect   6.x-1.2
Menu attributes   6.x-2.0-beta1
Menu breadcrumb   6.x-1.3
Page Title    6.x-2.3
Path redirect 6.x-1.0-rc2
Token 6.x-1.15
Webform   6.x-3.14

I can provide any information if you can help, just ask!

Thanks in advance


texts:
I need to use feeds importer to import csv file. But there's single quote in the values like doesn't. Is there anyway to escape the single quote?

Thanks


texts: Content type / block or page .. how do we create a small text for a page in D8

texts: Let's say, I have a footer where I want to show a simple text not menu or link just a simple block of text. So, since it's neither a page, an article or block ... is there any way to create a text and show it somewhere in D8?


texts:
So I'm using the Views module to list inventory items that include:

Name
Photo
Description
Sales document

I noticed that each item in the view is formatted differently because of size of text, image, etc.

Can I force a specific width/height with CSS, or is there an option within views? Here is an example of the situation.


texts: Modifying the default user registration page

texts:
I previously asked this question about modifying the default user registration form. The default form is largely fine, I just want to add some text and some links above and below the form (i.e. instructional advice etc).

One of the answers to my previous question suggested creating a module with the hook form_alter. I did this, however, it seemed all that achieved was adding adding new text fields to the form. I don't want to add new text fields, just some additional text/html before and after the form.

Is there any way to do this with form_alter, and if so, could you detail the code I'd need to do this (such that is does not add another user visible field)?

If there's another way to modify the page directly (not just the form) could you detail it? Keep in mind I want this to work with all themes, so when I change themes my changes do not disappear (which is why I was hoping to be able to do it in a module).


texts: How to recalculate uploaded files' sizes in KB and update the values in the database?

texts: I use a shell command to look for all uploaded JPEG files above 500 K.B. (originals) and do JPEG compression on them. They get smaller in size, but Drupal still shows the originally uploaded file size. How to force a recalculation and update the database accordingly after JPEG optimization?


texts: How to list entities and sort them by delta?

texts:
I have a "stations" and "railways" node types and a custom "notification" entity type.
In "railways" node type I have an entity reference field ("field_stations") where I can select "stations" nodes which is good.
In "notification" entity type I have an entity reference field where I can select related stations. (entity reference to "stations" nodes)
I would like to create a view to list "stations" nodes with grouping and sorting. I would like to group them by "railways" and sort them by delta ("field_stations").
I tried it but I could not get the right order and get a lot of duplications. I have tried views_order_by_delta module as well with no luck.
Do you have any recommendations?


texts: How To Place One Forum Topic in Many Forums

texts: I have a forum system created with D6 and the Advanced Forum module. I would like to have a special forum topic posted in all the forum sections that describes the site rules and how to use the various forum features. It would be perfect if this could be done using a single node that appears in all forums at once because that way all the comments would be contained in a single discussion.


texts: How to shadow a core function used in two different tests files?

texts:
I have two tests files with tests that need to shadow the t() function in the Node Revision Delete project, one test file is placed in:

tests/src/Unit/Utility/TimeTest.php

And the other in:

tests/src/Unit/NodeRevisionDeleteTest.php

At this time I shadow the t() function with the same code at the end of each test file because the t() function is needed to run tests in both files.

namespace Drupal\node_revision_delete\Utility;

/**
 * Shadow t() system call.
 *
 * @param string $string
 *   A string containing the English text to translate.
 *
 * @return string
 *   The translated string.
 */
function t($string) {
  return $string;
}

When I run each test file all is working fine, but when I run all the project tests I get an error as I have declared the t() function twice:

  PHP Fatal error:  Cannot redeclare
  Drupal\node_revision_delete\Utility\t() (previously declared in
  /Users/adriancid/Sites/drupal84-test/modules/drupal.org/node_revision_delete/tests/src/Unit/NodeRevisionDeleteTest.php:357)
  in
  /Users/adriancid/Sites/drupal84-test/modules/drupal.org/node_revision_delete/tests/src/Unit/Utility/TimeTest.php
  on line 195

The only way that I found to make these works is to pass the tests that need the t() function from one test file to the other, but doing this I will have a mix of tests from diferent classes and I won't be able to use the @covers section in the test definition.

So, what is the correct way to shadow a core function used in two different tests files?


texts: How to increase delta value of a multiple valued field +1?

texts:
I would like to output the delta value of a multiple image field as a affix for the image title in a view, but increased with 1. So, it should start with 1 not with 0. How can I do this?

Why do I need this? I need to reference to the images from articles using the scheme Fig. 1, Fig. 2 etc. There for the view output should look like:

+----------------+
|                |
|    an image    |
|    delta 0     |
|                |
+----------------+
Fig. 1: Image Title

+----------------+
|                |
|    an image    |
|    delta 1     |
|                |
+----------------+
Fig. 2: Image Title

+----------------+
|                |
|    an image    |
|    delta 2     |
|                |
+----------------+
Fig. 3: Image Title

The first thing I tried is, to sort the view by delta and than output "Global: View result counter", but this does not work if a filter is applied to the view. If a filter is in action, the numeration would not be concordant with the delta anymore.

Do I have to write an custom formatter? And when, where do I start, I don't have an idea.


texts: How do I set up a view to filter on URL path?

texts:
Can views show me all menu items with paths that match a particular pattern?

I have a documentation section which is mostly basic pages, but there's some views that belong here, too. I have set the views' paths to doc/some-view-name.

I would like to use a View to find all documentation pages (including pages created by Views) identified by the path doc/*

Is this possible?


texts: Copying over all the elements to a new page

texts: I have a website where we post our events. We would love to copy the 2018 event post and then edit it, rather than copying over all the elements to a new page. Is this possible?


texts:
I am working on a multi lingual site. I had installed the i18n (Internationalization). I wanted to get the taxonomy terms translated. But I was not able to do so.
In the translation mode I had chosen " Localize. Terms are common for all languages, but their name and description may be localized. "
Can anybody help me please...


texts:
I'm struggling to set up a decent search using Search API. By "decent" I mean a small block that performs a multi-index search (nodes and taxonomy terms). I want to free visitor from defining what they want to search through, instead I want to provide a no-brainer which does the search and displays results in categorized, paged manner.

Even though I installed the multi-index submodule, when creating a search apge, I'm still limited to select one index. Then I found kind of confirmation in the README file that currently only Solr can take advantage of that. So the question is: is it possible to create a multi-index search without Solr?


texts:
Is there a way in the testing framework to define a generic form intended only when tests run?

I have created some custom form item Element classes. I have working Unit tests with them, but I would also like to provide Simpletests for them as well.


texts: Can I use my own template for a view mode?

texts:
I'm creating a cusom module that loads a node  through a view_builder. However, none of the available view_mode display the elements like I'd like them to be, so I'm about to create my own view mode. However, I have parsed quite a few tutorials about view_builders, but none talked about using a custom template (or I missed it)

So, is it possible to use your own template, and how do you do so?

Thank you in advance


texts: Views - group/aggregate by field with multiple content types

texts:
I currently have a block view that I am using as an index. I have 2 content types that I am displaying in this block, and these are grouped together by their type, as an unformatted list of fields. The types are not displaying the same field.

The second content type needs to be grouped further, as they represent items relating to the same thing which will be displayed together on the page.

I am struggling to perform the second grouping. I have tried the unformatted list settings and adding in a second group, but that removes the items for the first group. I have also tried playing with aggregation and the query distinct settings, but that doesn't seem to do anything. I have also tried the Views Distinct module, also with no success.

Edit: It's the value of the field that's duplicated.

What I've got:

*Group1
    -Title1
    -Title2
*Group2
    -FieldValue1
    -FieldValue1
    -FieldValue1
    -FieldValue2
    -FieldValue2

What I would like:

*Group1
    -Title1
    -Title2
*Group2
    -FieldValue1
    -FieldValue2

Is this possible, and if so, how would I go about doing it?

Thanks


texts: Skipping form validation with a custom action button

texts:
Related to my previous question -- I've got the button added to the form properly (thanks googletorp!), but now I'm having separate validation issues beyond just adding the button.

I have added a "Cancel" button to my custom content entity add/edit form, using
hook_form_id_alter. When clicking this button I want it to leave the form completely and return to another admin-side page:

function mymodule_form_myform_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    $form['actions']['cancel'] = array(
        '#type' => 'button',
        '#weight' => 10001,
        '#submit' => array('cancel_submit'),
        '#value' => t('Cancel'),
    );
}
function cancel_submit() {
    $response = new Symfony\Component\HttpFoundation\RedirectResponse(Url::fromUri('internal:/admin/mymodule/list', array('absolute' => true))->toString());
    $response->send();
}

I can't get this to work because it's still trying to validate the form.

In my form code, my validation code will only execute if if ($form_state->getValue('op') == 'Save') is true, and this evaluates to false for the Cancel button. However, while this is stopping my custom validation code from running, it isn't stopping built-in validation for fields that I defined as required in the Drupal interface. The cancel_submit function doesn't seem to be doing anything, and clicking the Cancel button just loads the form again with a validation error on a required field.

I also tried adding '#limit_validation_errors' => array(), to $form['actions']['cancel'] as recommended here, but this just refreshed the form without showing validation errors instead of redirecting where I want it to go, so I have no idea what this code is actually doing or if this is even applicable for Drupal 8.

I am not sure where to go from here.


texts: What do the js-text-full and text-full in the StringTextAreaWidget class do?

texts:
I am planning to create a field type to use as hidden captcha: a field that is hidden to users using a browser with enabled CSS, used to verify if the user registration is not done by a human being. I though to derive its widget from the StringTextAreaWidget class, but I noticed that StringTextareaWidget::formElement() uses two CSS classes: js-text-full and text-full.

What do those CSS classes do?

I would like the widget to be very similar to the textarea used to enter a long string, except that a CSS class I add would make it invisible. I would not want that the existing CSS classes would interfere in some way.

Alternatively, is there another class I should use? I see there is a TextareaWidget class, but it seems for text with an input format associated, while I would need just plain text, without any input format associated.


texts:
How do you bypass customer profile duplication when editing a profile that has already been referenced on a few orders.

I know it is a design feature to protect historic data as mentioned
here
I am editing the profile trough the ui

Is there a easy way to achieve this without module editing?