New answers tagged

0

Those tables are generated dynamically by the field API, and as such don't have a pre-built DDL. This is essentially because fields can be added through the UI/programmatically after installation. Rather than keeping a monolithic registry of those fields and values, the architectural decision was made to split them out into dynamically-created tables with a ...


1

Just ran across this in a local dev setup.. turned out to be the $cookie_domain setting that was committed in settings.php... if this is set to the production URL, you will not get a valid cookie, and therefore access will never be granted. Overriding $cookie_domain to match the local dev environment in local-settings.php did the trick!


0

Your version of Commerce Discount is too outdated to support discount compatibility. However, it's so old, that the upgrade process may be complicated. Drupal Commerce itself is also currently at version 1.15, so that will need to be updated, too. I'd recommend creating a copy of your website and bringing those modules up to date, maybe even one version at ...


0

I have managed to do it via MY_MODULE_my_file_element_process: function sfb_antibody_my_file_element_process($element, &$form_state, $form) { $element = file_managed_file_process($element, $form_state, $form); // Do cool stuff here. return $element; } and adding '#process' => array('MY_MODULE_my_file_element_process') to my managed_file form ...


0

Wherever that "Illegal access" Ajax error comes from, I recommend to rebuild node access from the command line instead. With Drush the following command should do it. $ drush php-eval 'node_access_rebuild();' With that many (600k) records in your database it may also be better to have that done by some more advanced process like the one provided by the ...


0

I cannot reproduce this problem. Attached is an export of a rule which fires when a comment is added to an Article or when a comment on an Article is updated. The Rule simply prints a system message containing the CID so that you can see the Rule was able to access the CID. I have tested this and I always get the message, with the CID, when adding or ...


0

The section of migrate_plus.migration.mysite_user.yml that reads this: roles: plugin: migration_lookup migration: d7_user_role source: roles has to be edited by switching "d7_user_role" for the id of your user role migration, which in your case is "mysite_role" roles: plugin: migration_lookup migration: mysite_role ...


0

hook_custom_theme()'s documentation says : The return value of this hook will be used on all pages except those which have a valid per-page or per-section theme set via a theme callback function in hook_menu(); the themes on those pages can only be overridden using hook_menu_alter(). so i guess that what you need here is having your custom rules ...


0

You wrote: settings.php is not in the sites/default directory nor is the files directory. The structure is not standard D7 at all. That's incorrect. From the Aegir documentation: Aegir installs sites on a platform, which means it places the site directory in /var/aegir/platforms/<your_platform>/sites/<yoursite.com>. Many sites can all be ...


0

You could simply do it from within a page callback with inline JS. drupal_add_js('jQuery(document).ready(function () { jQuery("body").addClass("foobar"); });', 'inline'); Alternatively use template_preprocess_html to add a body classes depending on the current path. /** * Implements hook_menu(). */ function MYMOUDLE_menu() { $items = []; $...


1

To request the uncached client IP I recommend providing a JSON endpoint that has drupal_page_is_cacheable(FALSE) set. Then get the IP from there with an Ajax request and do whatever you need to do now with JavaScript. First, provide a route. /** * Implements hook_menu(). */ function MYMODULE_menu() { $items['myip'] = [ 'page callback' => '...


0

//Get The Results by View Name and Contextual Filter nid here $viewr = views_get_view('top_block_on_product_display'); $args[] = $myarg; $display_id = 'default'; $viewr->set_arguments($args); $viewr->set_display($display_id); $viewr->execute(); $view_content = $viewr->result; See the doc for more reference: https://...


0

Have you seen the Smart Trim module, that allows you to trim text fields to a given length, in words or characters, you can also add a read more link. From the module description: After installing and enabling Smart Trim, you should see a "Smart trimmed" option in the format dropdown for your text fields. This is located in the "Manage Display" section ...


0

Is there another way? In Drupal, there's always another way. In fact, easier ways are often overlooked. How can I remove tabs from the user's profile menu? You could hide the Drupal generated tabs specifically from the user pages and add in your own: Go to /admin/structure/block Find "Tabs" Block in the "Content" region and click configure. Under the "...


3

There's no single function that will extract the value for you, but field_info_field() will get you an array that contains the data: $info = field_info_field('field_foo'); if (isset($info['columns']['value']['length'])) { // Do something with $info['columns']['value']['length'] } It it's a core text field, value will always be the name of the column you ...


2

As 4k4 mentioned in the comment there is an issue for this you should check out. In the meantime you might implement a workaround (outside of Views) with the help of the Query Parameters To URL, or outside of Drupal through your server configuration and redirects.


2

When you create a block using views you can add it to the page through the interface. Go to, admin/structure/block and find the region you want to add the block to, then click place block. Now find your block in the list and configure it to only show on the specefic page. There are some tabs where you can configure where the block is shown, then tell it to ...


1

Title does not use a template, but is rendered directly in page.tpl.php by default. Display Suite can be used to override this behavior. Many examples available. Here's one for D8, but the principal is the same in D7: https://www.webwash.net/using-display-suite-drupal-8-how-to-use-display-suite-fields/ You may also find using preprocess hooks in template....


-1

I have a question: How to highlight the keywords in search results and show excerpts according to the keywords? I have implemented the above comments. Any solutions?


0

I found the solution here You can enable i18n_node module that is included in i18n module. Then: Go to edit the content type (admin/structure/types/manage/page). Open the 'Multilingual settings' tab. Check the 'Require language' checkbox. Done. Multilingual content must be installed at first and then in content type, Multilingual settings tab ...


0

You can also use - https://www.drupal.org/project/ckeditor_nofollow module, which provide an widget, which can be used to add rel="nofollow".


0

In your profile settings: uncheck the "Use the overlay for administrative pages." option under "Administrative overlay".


0

Try to add this console.log($(".org-chart-detail-box").length) and check the console output. If it is zero then this command runs before the generation of the chart. You should look for an event that is fired after the generation of the chart. Usually you can find it in the documentation.


1

For other people reaching this post, the answer to this is to use some kind of authentication on the REST endpoint, that only allows trusted users to create new users. Otherwise anonymous users would be able to create admins and crash the site. So this code is correct, "roles": [ "5", "6" ] but the problem is that the user calling the endpoint has to ...


1

You can do this directly inside hook_form_alter, like this: function security_question_form_user_register_form_alter(&$form, &$form_state) { $form['questions']['#weight'] = -47; } Then there is no need to create a custom function to do it. Another thing, you can't implement hook_form_FORM_ID_alter and then use $form_id inside that. You must ...


0

The uc_attributes module, which has been part of Ubercart for 12 years, was specifically designed to handle this situation. Enable the uc_attributes module. Edit your product, then go to the "Attributes" tab and add a "textfield" type attribute to your product. Your customer will then be able to add text to the purchased product. This textfield will be ...


0

if your group entity is a node which I'm guessing it should be change your code to: $gid // your group's node id. $allowed = og_user_access('node', $gid, 'create resource content');


0

In my case, I have separates field for first and last name. I use addExpression with havingCondition: $query->fields('u', array('uid')); $query->addExpression("CONCAT(ln.field_last_name_value, ' ', fn.field_first_name_value)", 'full_name'); $query->join('field_data_field_first_name', 'fn', 'u.uid = fn.entity_id'); $query->join('...


1

This is taken from the funciton description This hook is primarily intended for modules that want to store properties in the serialized {users}.data column, which is automatically loaded whenever a user account object is loaded, modules may add to $edit['data'] in order to have their data serialized on save. Then I think that you should do like this, to ...


2

multiple repos is best option, I recommend even custom modules or themes (for Drupal 8) have individual repos that way you can better manage these and re-use them in other projects more efficiently. assuming your using composer for package management.


0

If a theme doesn't define any region, Drupal expects the theme is using the following regions: header highlighted help content sidebar_first sidebar_second footer If by required you mean required to be defined, then none of the regions must be defined, but in that case Drupal assumes the theme has a set of predefined regions. If by required you mean ...


0

Drush 9 does not work with drupal 7, but drush 8 does work with it. I installed it by creating a new ubuntu user and making sure composer is installed globally then install cgr via: composer global require consolidation/cgr then add to your ~/.bashrc file export PATH="$HOME/.config/composer/vendor/bin:$PATH" then cgr drush/drush:8.x-dev --prefer-source ...


0

Here's the correct static cache to clear in order to solve the issue : drupal_static_reset('views_exposed_form_cache'); I guess since the exposed filters are not supposed to change during a request, the developpers did not anticipate this.


-1

In the db_select you still need to fetch the results after execute() with something like ->fetchAssoc() or ->fetchAll(). See the examples in the comments of the documentation: https://api.drupal.org/api/drupal/includes!database!database.inc/function/db_select/7.x


0

I found the issue. For anyone in the future running into this error, I found that you must have both the push and pull submodules enabled for the mapping to work. I was only planning to push records into Salesforce so I mistakenly assumed I didn't need the pull modules enabled. With it enabled, the mapping worked like a champ.


2

Flood control is just for failed login attempts and some other stuff like forms being filled out. It will not keep your bad bot from the site. Assuming you have an Apache server, you can modify the .htaccess file in the root of your site to block specific ip with the DENY FROM {ip} directive. E.g. adding something like this to the top. order allow,deny ...


0

It's actually possible to generate image style with the trick which image module uses to generate image style preview (see theme_image_style_preview()): $original_path = drupal_get_path('theme', 'mytheme') . '/images/' . $filename; $thumb_file = image_style_path('my_style', $original_path); if (!file_exists($thumb_file)) { $style = image_style_load('...


0

The second argument to views_get_view is $reset: If TRUE, reset this entry in the load cache. So second time around you just need to pass that: $view = views_get_view('my_view'); $view->set_display('default'); ... $view = views_get_view('my_view', TRUE); That will reset the static cache and the data will be fresh.


0

Simply use jQuery instead $ For this case jQuery :contains() Selector need use not drupal_add_js(' $(document).ready(function(){ $("p:contains(is)").css("background-color", "yellow"); }); ', array('type' => 'inline', 'scope' => 'footer', 'defer' => TRUE)); but drupal_add_js(' jQuery(...


0

$ composer create-project drupal-composer/drupal-project:7.x-dev \ example --stability dev --no-interaction This will copy the drupal-project to the example directory, and download Drupal core and some handy packages. This is a good point to cd into the example directory, run git init , and to then create your initial commit for your project.


0

I'd use RecursiveDirectoryIterator for that. $path = '/your/awesome/absolute/path'; $dir = new RecursiveDirectoryIterator($path); $json_files = new RegexIterator($dir, '/\.json$/'); foreach ($json_files as $file) { // Do you stuff here. echo "$file"; }


0

Well. See https://docs.drush.org/en/master/install/ But you are talking about Drupal 7. Please see the compatibility chart below. Drupal 7 requires Drush 8. See https://docs.drush.org/en/master/install/#drupal-compatibility in particular.


Top 50 recent answers are included