New answers tagged

0

I am trying to do this same thing for a very similar purpose: to provide documentation (articles, videos, etc) for two different versions of the same software product. My solution so far is to use field_group, and create horizontal tabs. Each tab contains a content textarea which has the documentation relating to THAT particular version. So at the top of ...


0

The arguments required by drupal_add_library() are the following. $module: The machine name of the module that registered the library in a hook_library() implementation $name: The name of the library to add For example, for the farbtastic library, the call to drupal_add_library() should be drupal_add_library('system', 'farbastic'), since that library is ...


0

The way core Drupal does this is to use '' for the first parameter of form_set_error(). So in the example you give, form_set_error('', 'error_message); would set the error message for the form, not tied to any specific form element. This is an undocumented feature of form_set_error(), but it's a feature that core Drupal has used forever, over many different ...


1

When users try to access a path that doesn't exist, for example /node/5/random-text-2, Drupal will show the parent page. More exactly, it will show the page for the first of the following paths that exists. (% is the wildcard character, used for paths defined from modules.) node/5/% node/%/random-text-2 node/%/% node/5 node/% node Normally, Drupal would ...


1

if your looking for a D8+ fix, the Menu Link Attributes module saves a lot of time. You can specify attributes and classes through a YML file or directly to individual links in Admin Menu UI.


0

If needs to check for a field in a custom webform, or existing form in Drupal 8: if (is_null($form_state->getValue('field_name')[0]['value']) { $form_state->setErrorByName('field_name', t('Please select a value')); }


0

For Drupal 8/9 this works $form['field_first_deposit']['#access'] = false;


0

I wrote this little script that replaces all langcode fields with a new language code across all tables in your Drupal 9 (and possibly 8) installation. Place it in your Drupal root Change the $newlang and $oldlang variables. Optionally add more conditions Execute it: php myscript.php Be aware that this does not do any checking or confirmations so be sure ...


2

I don't know about your PHPMyAdmin installation, but mine won't allow me to insert the data into the value column in the variable table, as it's a blob column. The data in that column is serialized as you can see in the implementation. As a result, adding it via the "Insert" tab is problematic. Instead, I'll explain how you can add it in the "...


0

The only way to pass values to a template file used for a theme function is adding them to the array passed as second argument of theme(). In the case of that chart_monitor theme function, theme('chart_monitor', array('classes' => array('new_chart_class'))); would add new_chart_class to the CSS classes. monitor_chart_preprocess_chart_monitor() doesn't ...


0

Requiring t() to translate the string in a specific language is perfectly fine. The function will return a translation, if the Locale module is installed and enabled, and that string is present in the site; it doesn't use a remote service to translate the string passed as first argument. Present in the site means: The translation has been added using the ...


0

If you are working with public repo you can play with the zip file generated by the repository You need to open the zip file to get the structure of files inside the zip. And reproduce the same structure in the subtree parameter(github for example add a prefix with the tag to the directory inside the zip) Example libraries[views_civicrm_documents][...


0

I just had to do something similar; I added a lang attribute to rows in a search result. Here's what I ended up doing: Created an override template for the rows in my View of interest. In my case the name was something like "views-view-unformatted--my-view.tpl.php" I copied the existing base "views-view-unformatted.tpl.php" code into that,...


0

You can use something like this in your .theme file: function mytheme_page_attachments_alter(array &$page) { $apple_sizes = [57, 60, 72, 76, 114, 120, 144, 152, 180, 192]; foreach ($apple_sizes as $size) { $favicon = [ '#type' => 'html_tag', '#tag' => 'link', '#attributes' => [ '...


0

For apple's favicons you can use something like this: function mytheme_page_attachments_alter(array &$page) { $apple_sizes = [57, 60, 72, 76, 114, 120, 144, 152, 180, 192]; foreach ($apple_sizes as $size) { $favicon = [ '#type' => 'html_tag', '#tag' => 'link', '#attributes' => [ '...


0

Since now there is a package for the PHPExcel on packagist.org, the alternative to using the Libraries API module is creating a composer.json file describing all the dependencies the module has. Supposing the only dependency for the module is the PHPExcel library, the content of the composer.json file could simply be the following one. (I only show the ...


0

Definitely not a solution I would rely on. "Securing admin account" is a wide topic that needs to be handled carefully, but answering specifically to your question, if what you want is to "protect" the password, you can run a cronjob that changes the password string to a random, SHA value, every X time. I've seen that in some clients. ...


0

an other solution (I had to loop on inputs) : $form['propositions_fieldset'][$i]['add_date_de_pose'] = array( '#type' => 'submit', '#value' => t('Ajouter une date de pose'), '#submit' => array('ajax_date_de_pose_add_more_add_one'), '#name'=>$i, '#ajax' => array( 'callback' => 'ajax_date_de_pose_add_more_callback', 'wrapper' =&...


0

This is an ancient discussion, but still pertinent to Drupal 8 (and I presume 9). I was able to solve it for my particular scenario with a minimal amount of code, only hooking into form_alter. Add a relationship to the view for the taxonomy term Add the taxonomy term name as a filter. This will make the URL argument work as expected, but the form field will ...


0

Simple! Add disallow in robots.txt file Disallow: /taxonomy/ & Add no follow no index on taxonomy pages using the metatags module (/admin/config/search/metatag) <meta name="robots" content="noindex, nofollow" />


Top 50 recent answers are included