Drupal StackExchange

Create Taxonomy term with added text and date fields, then display them in "add content"

4 days 9 hours ago

I'd like to add a date field ("date") and a text field ("notes") to a taxonomy term ("Category"). Easy enough.

When I add content, I have the taxonomy term linked using term reference, and it is working fine.

What I can't figure out is this: I'd like the "date" and "notes" field to also appear on the add content screen once the "Category" is selected, and be fully editable. How would I go about this?

Specifically, when I add content, I select the category and enter all other relevant data. I then enter a date and notes that apply to that node being created, and also apply to any other node of the same category.

Thank you for help!

TitoNYC

rewriting results in view: trim from the back

4 days 11 hours ago

I am working on Drupal 7 Omega Subtheme, Panels Views. In one of my views I have a path field which displays the whole url and I need only the last 6 characters (6 digits, to be precise. Also, if it helps - part of the URL I want to get rid of is fixed.) Under REWRITE options there is 'Trim this field to a maximum length' but I need to trim it from the end (i.e. from the right). Do I have to use php? Do I require views_php module? Thanks.

Zel

Why isn't jcarousel.on() executed?

4 days 12 hours ago

I am using the following JavaScript code.

(function ($) { Drupal.behaviors.gsdOmega4ExampleBehavior = { attach: function (context, settings) { var jcarousel = $('.home-jcarousel'); console.log('executed'); jcarousel.on('jcarousel:create jcarousel:reload', function() { console.log('never executed'); }) console.log('executed'); }; })(jQuery);

jcarousel is correctly referenced. I don't understand why jcarousel.on() is not executed.

user320691

Is there any alternative of node_save to update database fields in iteration?

4 days 13 hours ago

In Drupal 7, we have big product catalog where we need to update price and stock frequently via Cronjobs.

If we update only 5000 prices then also it takes around 20 min. In each iteration we use node_load() and node_save() functions to update for each product in database.

It seems that these functions are consuming more memory and taking more execution time to just update 1/2 fields in database. It's drupal's API, so it would be integrated to some other stuff (like node revision) so I doubt that we can simply replace node functions with direct queries.

But I think, this scenario would be common when we manage large product catalog in drupal.

Can anyone suggest better/optimized approach for this scenario where it doesn't break the integrity with drupal platform?

Kulin Choksi

Sub-sub Theme Not Inheriting CSS

4 days 14 hours ago

I am trying to extend the Thunder Admin theme by creating a sub-theme in it. This is my first time making a sub-theme in Drupal 8 (other than from bootstrap starter kits).

I would have thought that a basic sub-theme would have inherited the css and js from its parent as is explained here

All I can see that I should need to do is to create a directory i.e. my_theme and create my_theme.info.yml and my_theme.libraries.yml.

The content of this file is as follows:

my_theme.info.yml

name: My Theme type: theme core: 8.x base theme: thunder_admin description: 'Extends Thunder Admin' libraries: - thunder_admin/global-styling regions: header: 'Header' pre_content: 'Pre-content' highlighted: Highlighted content: Content page_top: 'Page top' page_bottom: 'Page bottom' sidebar_first: 'First sidebar' regions_hidden: - sidebar_first

my_theme.libraries.yml

global-styling: css: component: css/style.css: {}

Can any one please explain to me where I am going wrong please? I have flushed every cache I can think of

Jimmyb_1991

How to update multiple fields using ajax?

4 days 15 hours ago

In content type there are three field . Each field are node reference to different content. Here I want to restrict value and create dependency on these field. For example: I have one auto complete field "Country". On change of "Country", select list(i.e. State) field value is updated. On change of "State", "county" field is updated. Everything is working fine.

When I change value of "Country", "State" value get change But "county" value hold previous value. How should I achieve this. How should I reset value of county

My code snippet is like

function module_form_alter(&$form, &$form_state, $form_id) { $form['field_country'][LANGUAGE_NONE]['#ajax'] = array( 'callback' => '_state_list_callback', 'event' => 'change', 'wrapper' => 'state-list', 'progress' => array('type' => 'throbber', 'message' => 'Please wait...'), ); $form['field_country']['#prefix'] = '<div id="state-list">'; $form['field_country']['#suffix'] = '</div>'; $form['field_state'][LANGUAGE_NONE]['#ajax'] = array( 'callback' => '_county_list_callback', 'event' => 'change', 'wrapper' => 'county-list', 'progress' => array('type' => 'throbber', 'message' => 'Please wait...'), ); $form['field_county']['#prefix'] = '<div id="county-list">'; $form['field_county']['#suffix'] = '</div>'; } function _county_list_callback(&$form, &$form_state) { return $form['field_county']; } function _state_list_callback(&$form, &$form_state) { return $form['field_state']; }
Sudha Bisht

Connect two different webforms, used by different roles [closed]

4 days 15 hours ago

Hey guys i have a challenge on hands that i need to exchange some ideas with you.

I have a website where users, with the role company, will fill in an big multistep form that i've built with webform and after submission other users with role moderator can change the "status" like: waitlist, eligible, not eligible, etc

The page where moderators can change the status needs to be a different form. So i need to connect both forms in some way that i still don't know.

How do you guys think i should do this? I was trying to prevent custom development, but if needed i can do it.

Thanks in advance and i will more yhan happy to discuss with you!

Hivvu

Node value from form state

4 days 16 hours ago

I have a node which I want to update from a form states values. I can set each value individually like:

$node->set("foo", "bar");

Is there a way to mass assign the values instead of setting each individually?

Bobert

Drupal Planet

#! code: Drupal 10: Adding Extra User Account Protection

4 days 10 hours ago

One of Drupal's strengths is its ability to create communities of users who contribute towards the content of the site. Whether you have an open forum, where users can create their own accounts, or a closed magazine site with just a few editors, you need to take the security of your users seriously.

Out of the box, Drupal has a number of account protection features that assist in making sure that users are authenticated correctly.

For example, the user login page is protected by a brute force system and will lock accounts after a number of incorrect password attempts in a short amount of time.

There are a few other things you can do to protect your site users that can be applied to any Drupal site. In this article we'll look through a number of different modules and techniques you can use to protect the user accounts on your site. We'll look at some of the pros and cons of each approach.

Flood Control

Drupal's login forms have built in brute force projection that will block any user account that fails to enter the correct password more than 5 times per IP address within an hour. This prevents automated bots from just guessing the password of a user account thousands of times until it hits the right combination.

The Flood Control module allows these settings to be tweaked to make them more (or less) restrictive.

Read more