texts: Changing form field requirement via ajax

texts:
I have a selectbox field, that should change the disabled and required states of another field based on the value selected in the selectbox field. The change must be done via ajax.

In my modules form_alter function I have the following code:

$form['field_type_app_details']['widget']['#ajax'] = array(
  'callback' => 'ajax_type_callback',
  'event' => 'change'
);
if ($form['field_type_app_details']['widget']["#default_value"][0] === 'First') {
  unset($form['field_version']['#disabled']);
  $form['field_version']['widget'][0]['value']['#required'] = true;
} else {
  $form['field_version']['#disabled'] = 'disabled';
  $form['field_version']['widget'][0]['value']['#required'] = false;
}

And the corresponding ajax_type_callback function looks like this:

function ajax_type_callback($form, $form_state) {
  return $form['field_type_app_details'];
}

What I would expect is, that when I change the value in the selectbox, to i.e. "Second", that the required and disabled states of field_version change accordingly.

What actually happens is, that when I change the value in the selectbox, the ajax request fires correctly, but doesn't change anything of field_version. Additionally, not even the changed value of field_version is saved, when the form gets submitted.

Where is the mistake?


texts: How to show 404 page for nodes without translation?

texts:
I'm using entity translation and I need to show 404 page for a node if it hasn't got a translation available for current language.

For example, the  site runs EN, DE, FR, ES languages. Node 100 is translated to EN and DE. If i set current language to FR and visit the node 100, I'll see EN content due to the language fallback. But I would like to show 404 page.

How can I achieve this?


texts: Displaying the data export/feed icon only when there are search results

texts: I've got a data export attached to my view. Although it works what I want it to do... it displays under the search form even when there are no search results... How do I get around this?


texts:
I have drupal 6 with ubercart
When a user clicks on View order history, it takes them to a please register or login page.
Admin can see order history just fine.

I've checked the options for
Allow customers to view order invoices from their order history in Order settings and it's set to true.
I've checked permissions and its set to allow authorized and even anonymous users to view own orders.
Yet they keep getting this strange redirect to register or login.

I'm wondering if anyone has any suggestions where else to check for the problem.
I haven't been able to find the solutions yet.

Thanks!!

UPDATE:
I just noticed what when the Admin account tries to look at another users order history
mysite.com/user/105718/orders
even admin gets please login or register.
I've triple checked permissions and its set for admin to have access to everything and for users to view their own order history. Still not working.


texts: How to exclude non-physical products from shipping calculations?

texts:
I have an show which sells physical products and virtual products like memberships. How can I set up a situation where there is no shipping charge for the virtual products? I know that I could set up free shipping if there are virtual products in the shopping cart,  but I don't want the shipment to be free if the cart has both physical and virtual products.

Would the solution be to set the weight of the virtual products to zero? Or is there another way to implement this?


texts:
I am using the Bluemaster theme on a Drupal 7 site. I want to translate my site and everything is OK, but the title of the block I adde is not translated and still shows as "User menu" even when the language is not English.

How can I change the block title so that it appears in the language set for the site?


texts: How do I redirect to an external URL without caching it?

texts: I can't use a normal RedirectResponse - Drupal prevent's it when it detects I'm redirecting to an external site. Instead I need to use a TrustedRedirectResponse, but this is a cacheable response - which I don't want.


texts: Change site logo for specific content type and page

texts: How to add different logo images for specific content type and page. It want to be dynamic.When user add content, user want to select logo


texts: Advagg only aggregating and compressing some files

texts:
I'm using the Advagg module to reduce the number of http requests for CSS/JS files, but this only seems to work to a limited extent. In particular I'm concerned about why my theme stylesheets/js aren't included in the aggregation. I've played with all the settings including the bundler submodule to no avail.

Here is a list of the non-aggregated files:

/sites/all/modules/contrib/jquery_update/replace/ui/themes/base/minified/jquery.ui.core.min.css
/sites/all/modules/contrib/jquery_update/replace/ui/themes/base/minified/jquery.ui.theme.min.css
/sites/all/modules/contrib/date/date_api/date.css
/sites/all/modules/contrib/date/date_popup/themes/datepicker.1.7.css
/sites/all/modules/contrib/date/date_repeat_field/date_repeat_field.css
/sites/all/modules/contrib/field_hidden/field_hidden.css
/sites/all/modules/contrib/setting_entities/setting_entities_client_ui/css/custom.css
/sites/all/modules/contrib/youtube/css/youtube.css
/sites/all/modules/contrib/views/css/views.css
/sites/all/modules/contrib/ckeditor/css/ckeditor.css
/sites/all/modules/contrib/ctools/css/ctools.css
/sites/all/modules/contrib/ctools/css/modal.css
/sites/all/modules/contrib/ajax_register/css/ajax-register.css
/sites/all/themes/my_theme/css/build/main.css
/sites/all/themes/my_theme/vendor/select2/select2.min.css
/sites/all/themes/my_theme/vendor/fullpage/jquery.fullpage.css

I know this isn't a lot to go on, and will provide further info if needed, but if anyone has some pointers to reducing the number of files it would be appreciated!


texts: JS batch progress bar: possible to force refresh more frequently than every 1500 ms?

texts:
After initiating a js-based batch with batch_set(), and the redirect to batch do URL, the JS refresh interval is every 1500 ms by default. So status message and progress bar are only updated every 1 1/2 seconds. For a specific application I need the refresh to happen more rapidly, let's say, every 500 ms. I couldn't find anything in batch_set() to set the refresh interval.

I believe that D8 core decides in file core/misc/ajax.es6.js that the default refresh interval ought to be 1500 ms, if nothing else specified:

if (this.progress.url) {
  progressBar.startMonitoring(
    this.progress.url,
    this.progress.interval || 1500,
  );

I could be wrong though and this code being only related to Ajax throbbers and such. The form Ajax API seems to have a way to pass #interval but I couldn't find anything for the batch API.

Be that as it may, my question is, how do I set my own custom refresh interval in a batch_set(), or if not there, is there another clean way to override the 1500 ms?

Thanks!


texts: Is there an efficient easy way to test Drupal code while developing it?

texts: While writing code making sure, for example, I'm access the correct array property I keep refreshing the browser.(Or, that I didn't make a semantic mistake like that last sentence but in code) Is there a very simple and quick why to set up tests to do this instead? Simple test module seems like a huge deal and overkill. I love using Grunt watch while working with node.js. Is there an equivalent in Drupal?


texts:
I'm adapting a drupal module to my need. It permit to upload a pdf to insert it into a node add form in an iframe to display the file.
I've need also to insert a link to download the previous uploaded file.

I've read and try thousand of guide and documentation but nothing that work or adapt to my scope.

Is possible to find an easy way to create by code a download link?


texts: Cache-Control: no-cache despite allowing cache for anonymous users

texts:
We have a D7 site I'm trying to cache with Varnish. The assets are caching fine but for some reason every page is served with this header:

Cache-Control:  no-cache, must-revalidate, post-check=0, pre-check=0

The pages are quite heavy to render and end users aren't authenticated, so I'd really like to find a solution. How can I find out if a module is preventing caching? What else could cause this? We have a similar site that plays completely nice with Varnish but I haven't been able to spot the difference yet.

Edit: I checked the site with http://www.isvarnishworking.com/ and it says Varnish is working - "sort of". That is, the age is smaller than one, meaning something is preventing the page from being cached. Below are the full response headers as reported by the service.

Server: Apache
X-Drupal-Cache: MISS
Expires:    Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified:  Mon, 27 Apr 2015 17:11:55 GMT
Cache-Control:  no-cache, must-revalidate, post-check=0, pre-check=0
ETag:   "1430154715"
Content-Language:   en
X-Generator:    Drupal 7 (http://drupal.org)
Content-Type:   text/html; charset=utf-8
Content-Length: 45567
Accept-Ranges:  bytes
Date:   Mon, 27 Apr 2015 17:11:56 GMT
X-Varnish:  1868715414
Age:    0
Via:    1.1 varnish
Connection: keep-alive
X-Varnish-Cache:    MISS


texts:
I want a separate login for my site for Drupal. One to simply access the page, the same functionality that an .htaccess login would provide.

Except I want it to be styled as a separate html page, not as the default module popup htaccess does.

Is there a Drupal module for this or do I need a simple PHP script outside Drupal.


texts:
I'm building a custom module for webform and I want to get only a title for a specific content type.

In phpMyAdmin with sql query I've managed to sort what titles I need. This is the SQL query:

SELECT title FROM `node` WHERE TYPE = 'outlets' AND uid

How can I wrap this into db_query() ?


texts:
For documentation purposes, I'd like to write an article with token in it, for example [toc].

How can I can avoid it is processed as token, and replaced?


texts: How Can I Create a Front Page Based on Blocks?

texts:
I am building a front page that comprises a number of Views-based blocks.  How can I create a front page that has no actual "content" (besides these blocks) without getting a "Page not found error"?

The best I have been able to do is create a Views page and set a filter that will never return a result e.g. nid < 0.  I set the path to the front page and the title to none.  This seems like unnecessary overhead.

Surely, there must be a better way?


texts: How can I programatically change the color of node title in views results?

texts:
I want to change the color of the node titles from a view (fields on table).
My first ides was to alter the title and add a span with inline css.

function views_titles_views_pre_render(&$view) {
if ($view->name == 'documents' && $view->current_display == 'page') {
    $span_open  = '';
    $span_close = '';
    $view->style_plugin->render_fields($view->result);
    foreach ($view->style_plugin->rendered_fields as $index => &$rendered_result) {
      // Add HTML markup icon on rendered title field
      $rendered_result['title'] = $span_open . $rendered_result['title'].$span_close;
    }
  }
}

Although my attempt was a success, I managed to alter the title the css rule did not alter the color of the a tag. I figured out that I should go deeper into the title. As far I can tel the dpm of the views_pre_render does not show more options.

I have experience with drupal site building, but I am not in any way a php developer.

Can someone help me figure this out?

ps: I know there other more easy ways to achieve that but I want to do it with a module.


texts:
function custom_mod_action_info() {
  return array(
    'custom_mod_delete_user_cats' => array(
      'label' => t('Delete a users cats'),
      'type' => 'user',
      'configurable' => FALSE,
      'triggers' => array('any'),
    ),
  );
}

This action is later used as VBO in a View.

I've defined an action like above in a custom module. How can I set some permissions so only users with a specific role can run this action?


texts: How do I create a link to a node to put in new entity?

texts:
So what I'm trying to do seems pretty simple.  And I've found lots of posts similar to it but none have really helped me.

I have a an application content type, when somebody submits it, I'd like to use the rules module to create a post in the forums that has either
a.) a link to the application
b.) the data from the application in the body of the forum post.

I've figured out how to create a forum post each time the application is saved.  Seems to be working ok.  I've also figured out how to set the body to be either a static message, or the contents of ONE of the fields from the application.

What I cant figure out is how to either combine fields from the application to set the forum body to (which i'm guessing is a more complex thing), or to simply have a link to the application be what is put in the body of the forum message, which seems like it should be simple.  I've looked at the rules faq at https://groups.drupal.org/node/15542 but it seems to think that i should have a NID option in the selector which i do not. (yes its set to trigger after save)

My data selector for setting the body field of the forum entity only includes site, node, and entity.  And the Node options are only the individual fields of the application.  It doesnt include any NID or options to link the the node itself.  I choose other options like convert data type i can find UID and URL options, but then I don't know how to use the variable in the set data action.

I'm guessing that it has to do with the type of the body field and its only showing me things of the same type and i have to convert the UID/URL or something, but apparently I'm slow, anyone want to point me in the right direction?

My current rule (in export format):

{ "rules_test_application" : {
"LABEL" : "test application",
"PLUGIN" : "reaction rule",
"ACTIVE" : false,
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_insert--guild_application" : { "bundle" : "guild_application" } },
"IF" : [
  { "node_is_of_type" : {
      "node" : [ "node" ],
      "type" : { "value" : { "guild_application" : "guild_application" } }
    }
  }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "forum",
        "param_title" : "New App: [node:title]",
        "param_author" : [ "site:current-user" ]
      },
      "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
    }
  },
  { "data_set" : { "data" : [ "entity-created:language" ], "value" : "en" } },
  { "data_set" : { "data" : [ "entity-created:taxonomy-forums" ], "value" : "9" } },
  { "data_set" : {
      "data" : [ "entity-created:body" ],
      "value" : { "value" : {
          "value" : "link to application that generated this post",
          "format" : "Plain_text"
        }
      }
    }
  }
]
}
}


texts: Change Ubercart shipping/billing layout & logic?

texts:
I'm selling some tickets for a concert online with Ubercart, and I give people the option of holding the tickets at Will Call, or mailing them out for $1.

The customer's workflow when they're checking out looks a little wonky right now. The first set of address fields is the Shipping Address, then they can click the checkbox to indicate "My billing information is the same as my delivery information." But for a Will Call person, that feels backwards. They shouldn't need to enter a shipping address at all.

Is there a way to put the Billing Information first, and only expose a Shipping Information block when it's needed?

Seems like the same question would pertain to an electronic delivery situation too - but in that case you'd also be generating download links, etc., which I wouldn't need.

Thanks.

(Note - I also posted this question yesterday on ubercart.org's forums, but it looks like traffic there is very slow, I'm wondering whether this is a better place for it.)


texts: Can't restrict permissions on forum topics?

texts:
I have like a bit of an issue with my forum-topic content types : any authentificated user can edit and delete any post in the forums (node or comment of forum-topic type). It's not the case for any other content type where permissions works normal (user can edit/delete their own content, but not any content).

My features are the following:

User's permissions :

  Forum topic: Create new content -> auth user : YES ; admin : YES
  Forum topic: Edit own content -> auth user : YES ; admin : YES
  Forum topic: Edit any content -> auth user : NO ; admin : YES
  Forum topic: Delete own content -> auth user : NO ; admin : YES
  Forum topic: Delete any content -> auth user : NO ; admin : YES
  Bypass content access control -> auth user : YES ; admin : YES

The modules installed in the forums : Advanced forum, Forum Access.

Forum permissions (in admin/structure/forum/)
view this forum - post in this forum - edit posts - delete posts : all checked for auth users and admin.

-> Disabling Forum access only make delete and edit any comment/reply on forum topic disappear. But any auth user can still delete or edit any topic.

-> Disabling "bypass content access control" make forum topic unvisible to auth users.

I hope it is somehow clear... And you can find what's going wrong.

Thanks !


texts: Set permanent status for managed_file in theme settings

texts:
I'm creating some Drupal 8 theme and I need some additional settings for it. So, I have to add some managed_file field in theme settings.

I have theme-settings.php file where I define this field and I want to make this file permanent.

There is what I have in theme-settings.php so far:

<?php

/**
 * @file
 * Provides an additional config form for theme settings.
 */

use Drupal\Core\Form\FormStateInterface;

// Set theme name to use in the key values.
$theme_name = \Drupal::theme()->getActiveTheme()->getName();

/**
 * Implements hook_form_system_theme_settings_alter().
 *
 * Form override for theme settings.
 */
function onion_form_system_theme_settings_alter(array &$form, FormStateInterface $form_state) {
  $form['options_settings'] = [
    '#type' => 'fieldset',
    '#title' => t('Theme Specific Settings'),
  ];

  // Main navigation logo
  $form['options_settings']['menu_logo'] = [
    '#title' => t('Menu Logo'),
    '#type' => 'managed_file',
    '#default_value' => theme_get_setting('menu_logo'),
    '#upload_location' => 'public://',
    '#description' => t('Logo below main navigation. Available extensions (.gif .png .jpg .jpeg)'),
    '#upload_validators' => array(
      'file_validate_extensions' => array('gif png jpg jpeg')
    ),
  ];

  $form['#submit'][] = '_onion_form_system_theme_settings_submit';
}

function _onion_form_system_theme_settings_submit(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {
  $menu_logo_id = $form_state['values']['options_settings']['menu_logo'];
  $menu_logo_file = \Drupal\file\Entity\File::load($menu_logo_id);

  // set status to permanent so that its not deleted
  $menu_logo_file->setPermanent();
  $menu_logo_file->save();
}

But I'm getting this warning:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_onion_form_system_theme_settings_submit' not found or invalid function name in Drupal\Core\Form\FormSubmitter->executeSubmitHandlers() (line 111 of core/lib/Drupal/Core/Form/FormSubmitter.php).

What I'm doing wrong there and what is the best and right way to set file permanent?


texts:
The teaser "more" link is broken for user blog posts that appear on the homepage. The broken link goes to the root page (www.domain.org).

The title links correctly link to the the node.

I'm using Drupal 7.14, Garland, and the feeds_block block to display the blog posts on the homepage.  It looks like the "more" link is created by Views.  It does this even if I have the "more" field turned off!

How can I fix this?


texts: When should I use Backdrop CMS rather than Drupal 8?

texts:
From what I've heard, Backdrop is basically an alternative to Drupal 8.

Is deciding which one to use simply a matter of preference and ideology, or are there specific use cases for each?
If I'm upgrading from 7, how do I decide which way to go?


texts: How to hide paragraph items based on permission

texts:
I am trying to limit access to each item in a paragraph field. My goal is to only let the creator of each item change the specific item. I installed and enabled the Field Permission module and this is almost exactly what I am looking for. I have configure custom permissions for each field in the paragraph. The only problem right now is that each paragraph item is still visible even though none of the fields are showned:

Is there a way to hide or disable a paragraph item for all users except the owner?


texts: "Declaration of  must be compatible with " in Drupal 8.6.10

texts:
Up until Saturday I had a functioning Drupal 8.6.x instance. The I did

composer update

and Drupal 8.6.10 was installed. Since then I get the following in my error logs:

  Declaration of Drupal\Core\Template\TwigTransTokenParser::parse(Twig_Token $token) must be compatible with Twig\TokenParser\TokenParserInterface::parse(Twig\Token $token)

and Drush fails with

  Robo\Robo::configureContainer() must be an instance of Robo\Config\Config, instance of Drush\Config\DrushConfig given

I use PHP 7.2 on Ubuntu 18.04.

I did a clean reinstall of Drupal 8.6.10 and the same things occur. I've tried to replace 8.6.10 with 8.6.9 and even 8.6.0 but I still get these errors. If it were Java, I would suspect that the interface and the class had been compiled with different versions of the compiler. But I don't know PHP well enough to know where to start. These errors seem to me to be in core: all my code is under modules/xxx.

Any hints?

Steve


texts:
I've got a D8 media type that holds information obtained from an external source. The information comes in name value pairs that I wish to save as individual fields, mostly so I can index them easily with solr.  On some files I get new property names that have to be persisted as fields, so I have a presave hook that creates and saves a FieldStorageConfig, and a StorageConfig for my each new field in my  media bundle.  It all works swimmingly.

THe problem is when i try to save a value to that new field in the presave function an error is thrown indicating that the field doesn't exist.  (It does exist, but Drupal doesn't know about it yet).  When I resave the media with the same input file everything goes as planned.

Is there a way to force Drupal to refresh the media's field list?


texts:
In my template (Bootstrap), in the following line:

<section<?php print $content_column_class; ?>>

I need to add a custom class AND keep the dynamic column class.
I tried <section class="myclass <?php print $content_column_class; ?>"> but it give me:

Any idea what to do?


texts: Why are some place holders '@' and others '%'?

texts:
For example:

watchdog('alerts', 'Message for %user was sent.', array('%user' => $user));

and

drupal_set_message(t('options: @options', array('@options' => $form_state['values'])));

Is there any difference?


texts: Best way to get current user purchased products

texts:
I need to get purchased products by the current user (Drupal Commerce).

I use this function to reach there :

function mymodule_user_purchased_products() {
    global $user;
    $query = db_select('commerce_order', 'corder');
    $query->join('commerce_line_item', 'li', 'corder.order_id = li.order_id');
    $query->join('field_data_commerce_product', 'prod', 'li.line_item_id = prod.entity_id');
    $query->condition('corder.uid', $user->uid, '=')
          ->condition('corder.status', 'completed', '=')
          ->fields('prod', array('commerce_product_product_id'));
    $result = $query->execute();
}

But I think I forget certain things, and this solution isn't optimal.

Is it the recommended way?


texts: Where 'target_id' of field_data_field... tables points?

texts:
I'm extracting database information from a Drupal site that I have using SQL queries.
I have seen that, in the field_data_field... tables can be three type of information storage:

field...value: stores the value of the field directly.
field...val_tid: stores the id number of taxonomy_term_data value.
field...val_target_id: stores an integer id.

I'm interested in the third field, my question is: where is this field value pointing?


texts: In which tables and columns data is stored for Story and Page?

texts: I am using Drupal 6.25 with Postgres 8.4. I want to create stories from backend. To which tables and columns should I insert values so that one story is shown on my drupal site?


texts: How to activate some flag field when create a content?

texts:
I have a many flag fields. When Authenticated users bookmark a content, they can enter value in flag fields.

I want to activate some fields of flag field when I create (add) a content.

For example, I have many flag fields of colors. When I create (add) a content, I want to activate some of the flag fields of colors. Because I want users to enter value of some colors, not all of color's field.

When I create first content I want to active 5 fields and when I create second content I want active 3 fiels and etc. I want to active some fields when I creating a content actually I want to have a control on flag fields.

How can I do it?


texts: Send private message - Subject and message filled in

texts:
I'm using the module Privatemsg to give users the possibility to send messages to other users on the website.

What I would like to do is:

A button on the detail page of node with type equal to Proposal, and when a user clicks on it a, they redirect to the page messages/new where the subject and message is already filled in.

Now I just have a static button on the detail page that doesn't do anything. But how can I create the functionality that they redirect and 2 form parameters are already filled in?


texts:
I want to show Login link in the Menu navigation, only for guest User.

clinical_trial.login:
  title: Login
  description: 'Login'
  parent: main
  menu_name: main
  route_name: user.login

This is my Custom Menu links code.

What to add?


texts:
I'm trying to configure Workbench Access.

I follow the guide, so I've two users of the same role that can add node to the "custom" content type, and they can edit own nodes.

Then I've added workbench access and add this two users to all sections.
But if I try to edit, with the user "one" a node owned by the user "two" I obtain an Access denied error.

The system tells me that the node is assigned to "Section one", but also if the user "two" is assigned to the "Section one", he can't edit the node.

Why?
Have I to set standard permissions to node in a particular way?
I haven't set the permission "Custom: edit any content".


texts:
like to alter a template depending on a content type, let's say article and in-depth article if the user is logged in and if a boolean checkbox field is checked or not.

So how to alter these tree conditions programmatically for let's say the video_embed_filed?

I am new to Drupal 8 and Twig.

Thank you for your replies.

Thank you for your replies.


texts: What happens when two files with the same name are uploaded?

texts:
On Monday, I upload dogs.png as my profile picture on my Drupal site.

On Tuesday, I change the image to something else (but keep the name "dogs.png") and upload it as my associate's profile picture.

What will Drupal do to resolve this conflict?


texts:
I have a question regarding a large multisite project. The customer has several pages that share the same user right, the media, some content and the users. But they have different themes and some of them have modules that only this specific sites uses. What's the best way to "port" all of this to a new Drupal 8 project?

I think that I have to use multisite so that the different pages can have their own themes and modules. And I can have modules that all pages share. Am I right with this?

But what do I use to share users, content, taxonomy, media and user rights? And what about the database? Can I have everything in one database or do I have to use different databases?

Any tips?


texts:
Long story short I replaced an outdated site with a Drupal site at its previous url, let's say oldsite.org. But the old site was also accessed from oldsite.org/THIS, I think because it was a subdirectory of a larger site or something. But there are old links around that use oldsite.org/THIS and we want those to go to the homepage of the new site.

What is the proper Drupal way to do this redirect? I have thought of a handful of possible hacks, but I want to do it right.
Maybe a small module to handle the redirect. Or even htaccess somehow?


texts: How to add a "viewed" icon to pages that are visited

texts:
I have a Drupal 7 site where I have a bunch of videos and I could use a little help with understanding the best way to show a small icon next to my video links after a visitor has viewed it. Is there a way to do this if they are anonymous visitors? My site does not have user accounts. Also, each of my videos are on a separate page and have a unique url.

I've looked briefly into the Flag Module, but I'm not sure if this work work as I don't want viewers to click on anything. I only to track their browsing.

Any help in the right direction would be much appreciated!


texts: How do I prevent cached "Maintenance Mode" messages to anonymous users?

texts:
Sometimes pages show up as under Maintenance Mode for anonymous users while working fine for logged in users (the only logged in users are administrators, and I believe I set it so admins always get live pages). The message the anons get is Backup and Migrate maintenance message, even though by now it is running fine.

How do I set it so that maintenance messages are not cached or are cleared out after a backup?


texts:
I'm using hook_form_alter.  I'm having a weird situation where attaching my library works only if I do what I would think is incorrect:

$form['#attached']['library'] = array('somemodule/somelibrary');

But not if I do this:

$form['#attached']['library'][] = array('somemodule/somelibrary');

What could cause a thing like this?  I debugged to see what was happening in the FormBuilder, but it seems like the library is added either way.  It's not removed by any other module or anything.


texts:
I am using webforms in Drupal7, i give the user the option to enter multiple entries for one question. So for example, "how many players", if answer is 1, fieldset 1 opens and has name, address, number in it.

if answer is 2, fieldset 1 and fieldset two appear,
if answer is 3, fielset 1, fieldset 2, and feildset 3.

if the answer is 2 or 3, I get this error:
Conditional errors on page 2:
More than one conditional hides or shows component "One Player".
More than one conditional hides or shows component "Two Player".

so my plan was to create 10 fieldsets and have them display based on the # of players the user inputs.  I understand the error, but don't know of another way to achieve this.  [the one I came up with is just crazy and would mean so many of these inside fields, OMG ]

Any suggestions / guidance, would be appreciated.


texts: How do you automatically perform several back-to-back migrations in a set order?

texts:
I am using the Migrate module to transfer 400,000 items to a new Drupal 7 site.  I had a lot of problems in my first attempt because the database table was too large to import in one go.  To get around this problem, I created several (around 100) smaller migrations which each did a piece of the migration.  This works fine (so far) but the migrations must be done is a specific order.  I would like to set up something that will run each migration, one after the other, in a set order.  The entire process will take several hours, and I would like to set it up and let it run on its own.  How can I do this?

Also, if there is a way create a single migration that can break down one big table query into several smaller queries, I would like to know about it.

Here is a sample of my module activation code (note, the big 400,000 table is not referred to here):

function mig_contacts_enable() {

    for ($i=0; $i<10; $i++) {
        $index = substr((1000+$i), 1);
        Migration::registerMigration('ProspectImport', "prospect_import_$index", array('rank' => $i));
    }

    for ($i=0; $i<1; $i++) {
        $index = substr((1000+$i), 1);
        Migration::registerMigration('CustomerImport', "customer_import_$index", array('rank' => $i));
    }

    for ($i=0; $i<1; $i++) {
        $index = substr((1000+$i), 1);
        Migration::registerMigration('CustomerContactImport', "customer_contact_import_$index", array('rank' => $i));
    }

...


texts: User page tab with node edit, file upload image widget not working

texts:
On every user profile page i have a tab My company its a node edit form of content type Company. Here the code:

/**
 * Implementation of hook_menu().
 */
function feature_directory_section_menu(){
  $items = array();

  $items['user/%user/company'] = array(
    'title' => 'My company',
    'page callback' => 'feature_directory_section_user_company',
    'page arguments' => array(1),
    'access callback' => 'feature_directory_section_access_user_company',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );

  return $items;
}
//callback function
function feature_directory_section_user_company($account) {
  $uid = is_object($account) ? $account->uid : (int) $account;
  module_load_include('inc', 'node', 'node.pages');
  $output = '';
  $nid = db_query("SELECT n.nid FROM {node} n WHERE n.uid = :uid", array(':uid'=> $uid))->fetchField();

  if (is_numeric($nid)) {
    $output = node_page_edit(node_load($nid));
  } else {
    $output = t('You have no company. Please contact the site administrator.');
  }

  return $output;
}

Content type company has alot of fields, when i trying to edit node on user/%user/company page everything works fine, but one thing not working its ajax image upload or i can't delete image of my field(field_company_gallery) - its just a image field and u can upload unlimited count of images.

I get a lot of errors. If i go to node/%nid/edit i can manage images. but on user profile tab i can't.

Some errors are next:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'node_form' not found or invalid function name in drupal_retrieve_form() (line 798 of /home/www/buildit/htdocs/includes/form.inc).
Notice: Undefined index: #node in comment_form_node_form_alter() (line 1194 of /home/www/buildit/htdocs/modules/comment/comment.module).

Notice: Undefined index: field_company_gallery in file_ajax_upload() (line 271 of /home/www/buildit/htdocs/modules/file/file.module).
Notice: Undefined index: #suffix in file_ajax_upload() (line 280 of /home/www/buildit/htdocs/modules/file/file.module).

I guess i need to load all the modules with this function module_load_include or maybe not, i am stuck here.


texts: display nodes of types on a menu item : drupal 7

texts:
I have created some nodes of type books and now I want to display some of them on a menu item. How can I do that without using views?

Mome | Books | Atricles |

node type: (Machine name: books)

For example above is my menu structure. And when a user click books it will show some of the books I have created.


texts: How can i get Page Manager to load a new page.tpl.php file and override the current one?

texts:
I’ve created a new layout (.tpl.php) and is complete with an .info file.  It contains a region I call a super_footer. I want this to load only on certain content types and I’ve been attempting to use Page Manager to do this. I want to load some View Panes that use contextual filters into this super_footer.

Can’t I use Page Manager to do this? and shouldn’t I be able to get this new layout to load via Variants->Layout tab?


texts:
I can't get a form to display a (default?) value after an AJAX call. I am using the following code:

function foo_form ($form, &$form_state, $foo) {

  $form['#prefix'] = '
';
  $form['#suffix'] = '
';

  $form['copy'] = array(
    '#type' => 'submit',
    '#value' => t('Copy foo'),
    '#limit_validation_errors' => array(),
    // #submit is required to use #limit_validation_errors
    '#submit' => array('foo_form_submit'),
    '#ajax' => array(
      'wrapper' => 'foo-form-wrapper',
      'callback' => 'foo_form_callback',
    ),
  );

  $form['description'] = array(
    '#type' => 'textarea',
    '#title' => t('Short description'),
    '#required' => TRUE,
    '#maxlength' => 255,
    '#default_value' => $foo->description,
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );

  return $form;
}

function foo_form_callback($form, $form_state) {
  return $form;
}

function foo_form_submit ($form, &$form_state) {
  if (!isset($form_state['triggering_element']['#ajax'])) {
    $foo = (object)$form_state['values'];

    entity_get_controller('foo')->save($foo);

    $form_state['redirect'] = 'admin/foo';
    return;
  } else {
    form_set_value($form['description'], 'description text', $form_state);
    $form_state['rebuild'] = true;
  }
}

As I understand it, the form should automatically try to display the value if it is set in $form_state. When the callback is executed and the form is built, $form_state['values']['description'] is the value set in foo_form_submit. However, nothing is being displayed.


texts:
I am trying to set the visibility OF A a menu block, so that only certain roles can see it. This seems like a simple task,  but I am having trouble getting it to work. I have using Drupal 7 btw.

To create a menu I go into Structure>>Menus>>Add Menu, and add a link,

This then, tells me that it created a block in the block administration page, which it did. When I selected a Role, which I know I am definetly not in, I am still able to see the Menu(and I should not be able to see it since I am not in that role). Similarly, I am not able to see some new menus that I create at all, even if I don't have any restriction on the roles.

I am not sure why this is why happening, and don't really understand it. Some insight will be greatly appreciated!

UPDATE:  I should also mention that I recently moved my site to a new server. After moving the site, some things went kind of wancky. I don't know if this is related, but my previous site had the In Place Panel Editor in the front page. Now that is gone. I could have controlled the visibility from that(THE PANELS) as well, but it is very difficult to change the settings the settings UI interface is all messed up.


texts: Fetching the revelvant node based upon the tags attched to current node

texts:
I have a requirement to fetch the 5 relevant nodes based upon the taxonomy tags attached to the current node. Relevant nodes has to be fetched based upon the following logic.

  1) If current node has 4 tags, first need to check whether we have 5
  nodes with all matching tags. Then list all nodes.

  2) If we don't have 5 nodes with 4 matching tags , then need to look
  into 3 matching tags. If we got 5 nodes with 4 and 3 matching tags
  list the nodes else again look for 2 matching tags and so on.

I am planing to write a module for this. But unable to find a proper solution for this problem. Any help is greatly appreciated .


texts: Adaptively Displaying Images Inline Drupal 7

texts: For Drupal 7.14 I've been trying to display images inline adaptively to a content type. In my content type I have a long text and summary field and an image field. I'm using the Adaptive Image Styles (ais) module. I upload the image and then insert the image using the insert module. I'm using full HTML without any text editor. But when I insert the code it does not display adaptively.


texts:
I created a nested array.  The array contains two identical sub-arrays.  When I use dsm() to display the array, the first subarray is displayed just fine.  However instead of displaying the second subarray, dsm displays an infinity sign next to the word "(recursion)".

Please note I am using dsm(), not kpr().

Does anyone know why one subarray would be displayed properly, but the second (identical) subarray is not displayed?

Thank you.

UPDATE:
The proposed solution in the referenced "duplicate" does not help me because (a) I am trying to dump my own array (I am not trying to dump a node), and because I am using dsm (not kpr).  Perhaps the answer is "there is nothing I can do about it".  I was hoping, though, that someone would have some general insight into what causes the problem, so that I could figure out a work-around.  I have run into this problem before when dumping nodes, but this is the first time I have run into it when dumping my own internal structures.  That is why I am scratching my head.  What did I do differently this time to "break" dsm()?

FURTHER UPDATE:
When I call dsm() on the subarray in question, it dumps fine.  So that's my current solution:  If some subarray is not getting dumped properly, then I add a dsm() statement to dump the particular subarray.

In addition, I think it would be useful if this was not marked "duplicate", because I believe it is not.  Thank you.


texts: trying to insert a view inside a view using twig tweak module

texts:
I am trying to insert a view inside a view but struggling a bit

I have a view called My Class with all my fields in it, this works fine.

I have a view with a contextual filter called
Students Block, (This is using the reference to the my class content type that populates the My Class view)
machine name       students_block
and a BlockView called  students_block

I've set up a contextual filter and reference to My Class and again this works as expected when used as a block.

Now I am trying to add the students_block in the middle of the My Class view.

I have set up content hidden ID to expose the NID, and then a global custom text field that has as follows

 {{ drupal_view('Students Block', 'students_block', nid) }}

I can't whatever I do get any results, if I remove the nid I do get my original view, and I have tried other blocks as per the examples and that seems to work for me

Can anyone assist please

Thanks


texts: Export Drupal Commerce Checkout Settings

texts:
I'm wondering if there's a way to export Drupal Commerce's checkout pane settings to code?  I've tried commerce_features but it doesn't appear to do it.

For other commerce related things, like payment rules, I've been able to export them using features and using hook_default_default_rules_configuration_alter to make sure only the proper rules are in place.

However for checkout I've not been able to find anything.


texts: How can I stop auto uploading of managed_file elements?

texts:
I am trying to create a field to upload the xml format of site map. But when I add a file to my filed it automatically uploaded and saved in the S3 bucket before I click on the submit button.

The issue is when someone added a xml file to that field and then closes the tab without submitting the form. The xml file is already uploaded to S3 bucket that way.

I need a way to manually upload this. I need to upload the image only after I pressed the submit button in the form. Without uploading the xml file automatically when selecting.

This is my buildForm() function.

public function buildForm(array $form, FormStateInterface $form_state) {

  $form['sitemap'] = [
    '#type'              => 'managed_file',
    '#name'              => 'sitemap',
    '#title'             => t('Upload Site Map (xml)'),
    '#upload_location'   => 's3://private/sitemap',
    '#field_suffix'      => 'XML format supported',
    '#upload_validators' => [
      'file_validate_extensions' => ['xml'],
    ],
    '#required'          => TRUE,
    '#validated'         => TRUE,
  ];

  $form['submit'] = [
    '#type'       => 'submit',
    '#value'      => t('Save configuration'),
    '#attributes' => [],
    '#validated'  => TRUE,
  ];

  return $form;
}


texts: HTML5 web app: How do I create a dynamic manifest file with drupal?

texts:
I hope this is the right place to talk about this...

I'm planning to create an HTML5 web application which basically download new contents, something like the financial times app.
I want to use drupal such as base where I can upload contents and the export it such as json view.
In the web app I would like to create a local database where i will add the contents.
To keep it update I will compare the last content creation date in the app with the last content creation date on drupal, if they are not the same it will download the latest contents and add it into the db.
This is "quite simple", let's move to my problem now...
I've got one image per each content and, to see the images offline, I need to add it to the manifest file every time a new content is added.

How can I get this? Or if you think I should use another method, let me know.

Thanks in advance.


texts: Getting WSOD for non-LDAP User with Domain and LDAP modules enabled

texts:
I am using Domain and LDAP modules on Drupal 7, and upon login as a non-admin non-LDAP user, e.g., "author01", I get a blank screen. Upon viewing source on said blank screen, I can see the HTML for the "Welcome to your new Acquia Drupal website!" page—it is just not rendered in the browser (Safari, Chrome, FF).

When logged in as admin, I can switch to "author01" using the "Switch User" block of the Devel module without issue and the Welcome page appears without issue.

The LDAP module is enabled using "mixed mode authentication," Drupal first and LDAP second; LDAP user are able to login without issue, while Drupal-only users get this blank screen upon login. The Domain module is enabled, and but I haven't added any new domains.

I suspect this issue first started after I installed the domain module and "Rebuilt Permissions." Mixed mode authentication was working fine before that.

I've tried various combinations of enabling/disabling and installing/uninstalling the LDAP and Domain modules, clearing cache, rebuilding permissions, and the only time the "author01" user can login is when LDAP authentication is disabled. I've tried enabling error reporting based on Drupal's WSOD page, but the blank pages continue to appear. Apache access and error logs are fine.

Under reports (admin/reports/dblog), I see these log messages (read it bottom up):

ldap_authentication 04/22/2011 - 11:01  Error: users found with uid=author01 under dc=gwu...
ldap_authentication 04/22/2011 - 11:01  author01 : Success at connecting to devldap
ldap_authentication 04/22/2011 - 11:01  author01 : Trying server devldap where bind_method = 1
ldap_authentication 04/22/2011 - 11:01  author01 : Exisitng Drupal User Account not found. ...
ldap_authentication 04/22/2011 - 11:01  author01 : Drupal User Account found. Continuing on...
ldap_authentication 04/22/2011 - 11:01  author01 : user_load_by_name(author01)

The user "author01" definitely exists in the "user" table, has a role ("Content Author"), and the role has permissions.

So I guess I am stumped here, Do you have any idea on what else I can try to troubleshoot and fix this?


texts: How to ignore the first argument in view contextual filters?

texts:
I am having path aliases of the form

path/val1/val2/data

that are created with pathauto. I want to create a view that will be use a contextual filter and that will read only section 3 of the URL. When I set the view path to:

path/%/%/data

then I need to specify a contextual filter for section 3 (val2) that cannot filter my data properly.

My configuration looks like:

Filter configuration:

So I need the CELEX content filter to match section 3 of the URL. Can I entirely skip %2 and just filter based on %3? Alternatively, can I declare the second section to be a wildcard in the view path?

When I attempt to Provide default value as Bryan Jones suggested, then it seems that default value doesn't work because the context filter actually DOES match the URL section, whereas the default value is provided when the filter value is NOT in the URL

What I see after previewing the view is

Context values:

Query:
(Notice the value that I wanted to be val2)


texts: Features - branch 2.x results in large info files that exceed the 'info' column limit in the 'system' table

texts:
Original thread on DO (will keep it up to date)

Hello. I am currently developing a mid-to-large project. As i've done before, but using the 1.x branch, I use Features to track all structural and functional components of my site in order to be able to transfer them from my local installation, to the staging server, to the production server etc, while also having svn capabilities and tracking.

The current project consists of 45 Content Types with an average of 15 fields each. There are also ~15 vocabularies, ~10 fieldgroups, and a couple of tons of views.

The problem occurs when trying to track all this stuff with Features. It produces a large (initially, just alpha versions of the Content Types) .info file ( > 100K) which results in the following error:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'info' at row 1: UPDATE {system} SET info=:db_update_placeholder_0 WHERE
// yada yada yada serialized array of the .info file

Which is totally natural seeing that the collumn is declared as a BLOB.

My question, is how should one go about to manage such a problem?
1) perform a ALTER TABLE system CHANGE info info LONGBLOB /* or MEDIUMBLOB */ NULL DEFAULT NULL? (Ouch)
2) Use branch 1.x instead which is less verbose in the .info file declarations?
3) Break down the project and track it in multiple features? (I'd avoid this cause it will make reverting those features a hellish job since one would depend on the other and vice versa)
4) ...?

I'd appreciate any input on the matter


texts: is it possible to hack a module by mymodule?

texts:
A few times i had (sadly and not proper) to hack a module, like changing some functions or default images, is it possible to hack a module in a proper way by "mymodule", in order to override simple things like changeing the returns of htlm or css with something like

mymodulefunction_moduleoriginalfunction(%args)

and make sure "mymodule" overrides my code running after original module?


texts: What is the standard or recommended way to store third party passwords in Drupal? Specifically, I want to use oAuth to authenticate a user to Google, and do not want to ask users to type in their passwords each time they access their accounts.


texts: Adding $terms to the byline in node.tpl.php for Drupal 7 and Acquia Prosper & Fusion Framework

texts:
I'm trying to add the taxonomy term for a blog post to node--blog.tpl.php for the Fusion Framework and the Acquia Prosper Theme, but I've run in to some trouble and I'm not sure why it's not working.

The goal is to have the authorship line look like this:

By Blog Author | Posted Thursday March 14, 2013 | Filed under [Category Taxonomy Term name]

Here is the code I've got in there currently:

<?php if ($display_submitted && isset($submitted) && $submitted): ?>

By <?php print $name; ?> | Posted <?php print format_date($node->created, 'custom', 'l F j, Y'); ?> <?php if $terms: ?> | Filed under <?php print $terms; ?><?php endif; ?>

<?php endif; ?>

I've tried several different things, but I can't get anything to work. I'm thinking it should a simple fix, but I've not been able to make it work.

The tpl.php file tells me that $terms should be available to me as a variable, but I've tried everything I can think of to no avail. I'd appreciate any help you can offer!


texts: How to test if current page is an admin page?

texts:
At some point I started using the following code to test if current page is an admin page:

  $route = \Drupal::routeMatch()->getRouteObject();

  $is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);

But I found that this fails on node edit pages in hook_entity_load().

How do we test if we are on an admin page in Drupal 8?  Something like path_is_admin() in Drupal 7?

I found that if I test the same node edit page path from outside hook_entity_load, using the code on this page (https://api.drupal.org/api/drupal/includes%21path.inc/function/path_is_admin/7.x) it works.

use Symfony\Component\HttpFoundation\Request;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;

$path = '/node/75/edit';
$request = Request::create($path);

$route_match = \Drupal::service('router.no_access_checks')->matchRequest($request);
$route = $route_match[RouteObjectInterface::ROUTE_OBJECT];
$is_admin = \Drupal::service('router.admin_context')->isAdminRoute($route);

But if I try to add this code in hook_entity_load using the current path, I get a  fatal loop.

I think where I'm stuck is loading the current route in hook_entity_load.


texts: How to stop animation and turn off the delay time in superfish menu?

texts: I created a superfish menu block and set the animation speed at fast and delay time to 0. Still it taking time to open the child menus. I disabled the animation using this article but still it taking time to open the menu. I want to open the child menu just when user hover on the parent menu.


texts: Show menu even if node it's not in that menu

texts:
Setup I got has two content types, page and article. Pages are normal pages and articles are news. On the site I also have three menus: main, sub and subsub. Main shows first level, sub shows second level items and subsub shows all below items.

Menu:

Front page
News
-Breaking news
About
-History
--Early years
-People in charge
Contact

Now when admin creates a news article it doesn't go to any menu. It's showed on the News page with view. And when user clicks the news it goes to the news article page where the news is showed fully. But now since the news article is not in menu, the submenu disappears. How can I "trink" Drupal to think that user is on sub page of News page -> The sub menu would visible?


texts: How to change (re-order) the deltas programmatically in node_presave

texts:
In a node, I have a multi-value field "field_MV" containing 3 items

I don't think it is important, but field_MV  is of type "Entity reference revisions" and the items are paragraphs of only one type.

Each paragraph (item) have a field "field_quantity" containing a number.

Here is my exemple:

$node->field_MV[0]->field_quantity->value=5 (paragraph at delta 0)
$node->field_MV[1]->field_quantity->value=3 (paragraph at delta 1)
$node->field_MV[2]->field_quantity->value=7 (paragraph at delta 2)

In hook_node_presave, I would like to loop in the paragraphs to change their delta according the the value of field_quantity (descending)

Here is the result I would like to have:

$node->field_MV[0]->field_quantity->value=7 (previously paragraph delta 2)
$node->field_MV[1]->field_quantity->value=5 (previously paragraph delta 0)
$node->field_MV[2]->field_quantity->value=3 (previously paragraph delta 1)

My question is not how to order (I can handle this), but how to change the delta with something like:

$node->field_MV[0]->set("delta",1);
$node->field_MV[0]->save();


texts: Is there an efficient way to dermine whether a node can be viewed by all users?

texts:
I am trying to use the Drupal node access API to determine whether a node is subject to an access restriction. That is: I want to make sure that the node can be viewed by any authenticated user (provided the authenticated user is granted the right to view published content).

The function node_access('view, $node, $account); returns TRUE if the user object $account can access $node, and FALSE otherwise, so I can get the correct result stored in $view_for_all with the following snippet of code:

$accounts = entity_load('user');
$view_for_all = TRUE;
foreach ($accounts as $account) {
  if (!node_access('view', $node, $account)) {
    $view_for_all = FALSE;
    break;
  }
}

However, looping through all accounts will be very slow if there are, say, 50000 users. I am looking for a more efficient way to do this.


texts:
I have a classic view with fields from classic nodes. I have made a custom form that reload the view with parameters :

mypage?nid=168

But to display only the wanted data, my view use CONTEXTUAL FILTERS and need this format :

mypage/168

How can I filter my view from $_GET parameters.


texts: Buying same product simultaneously in drupal commerce

texts:
Case: There is a product in stock with 1 quantity. Now two or more buyers try to buy that product simultaneously.

I want to restrict any one from buying that product on first come first serve basis.

Is there any hook available ?

Please help.


texts:
On a rather busy D6 site, I need to truncate watchdog table very frequently, since it grows at about few Gigabyes per day. On the other hand I can not disable access logs to avoid the table's inflation. Running cron yeilds a lot of errors and does not seem to clean watchdog table. So what is the best way to deal with this problem?

Thanks


texts: Scroll Calendar View so that it Centers (vertically) on page

texts:
I've designed a calendar of events.  It uses a Next and Previous pager.  With the theme I am using, the top of the calendar displays part way down the screen when first viewed.  The user typically scrolls the screen using the mouse to bring the entire calendar into view.  This is problematic if the user needs to page to the next or prior month because he needs to once again use the mouse to position the entire calendar on the screen.

I'm not exactly clear on the best approach to resolve this.  I thought about looking into the theme code but wasn't sure if that's a good place to start.  I thought about trapping the display of each page of the calendar and trying to reposition (scroll) the page programmatically, but, that seemed like unnecessary code.

Can anyone advise me on a proper approach to solve this issue?  Ideally, I'd like the user to not have to scroll each page of the calendar when he uses the Next or Prior button.  It seems like there should be a way to ensure the entire calendar is visible.


texts: Blur text or words in posts for anonymous users

texts: How can selected text, emails etc be blurred and convert into image to completely hide it. Like what quora. com does for guest users. How can this be achieved?


texts: How to show Comment Count in node template?

texts:
How can I show Comment Count in a specific place of the node template?
I want to show Comment Count's of a node (article) in the submitted area instead of in the node links area. I do this already in Drupal 7 with this codes in node.tpl.php:

<?php if (module_exists('comment') && $node->comment) { print t('Comments'). ': ' .$node->comment_count;} ?>

or this code:

<a href="<?php print $node_url;?>#comments"><?php print t('Comments'). ': '. $comment_count; ?>

What is the equivalent code for Drupal 8?


texts: All my blocks are gone. Even the block menu entry is gone

texts: Anyone know what I might have done? I found a few things about hook_block being implemented in template.php causing this, but I don't implement hook_block at all.


texts:
I have a view that shows the Body field of several book pages.  The text format for these pages includes the Markdown filter.

I want to export the body field data as the original markdown without processing it into HTML.  (This is an admin-only view that I want to use to collect the markdown-formatted text from several book pages to make an ebook.)

Is there an option within the Views module to output the "unprocessed" markdown?


texts: How do I load all images and thumbnail for a multivalued image field in node view?

texts:
I have a content type with a multivalued image field. I want to make the image field render with one main image and all the thumbnail. When any of the thumbnail is clicked then it's respective image takes over the main image section. Something like amazon product images.

What I have thought about so far is to create a preprocess function for the field to load all images along with all the thumbnail then, with custom CSS and JS, customize its rendering, is this the right way to go about it? And how do I load all the thumbnails for the image field in node view?


texts: Is there any way to find broken images across an entire site?

texts: A number of images appear to be missing from within body fields of a site. It may have been like this for a while, so it's hard to say why. Folder/file permissions and paths are correct. The site was never moved and oddly, its only happening on some images and not all. Is there any way to detect which ones are missing on an entire site (40,000+ nodes)


texts:
When I try to download registry_autoload via drush dl registry_autoload I get this error:

  No release history was found for the requested project

Is this an issue with the module's .info file, or something I'm doing wrong? How can I get this module using Drush, and if that is impossible can I just download and install the latest release? I don't want to install it if there's an error with the code.


texts:
I'm currently considering using a free theme for my a Website, they use bootstraps Carousel to render a slideshow/banner, and their advice on how to make that slideshow work is to embed HTML in a block an set it to Full HTML. Tutorial here

My question is if there are security risks attached to having a Full HTML block?

Or does Drupal (more specifically 8) inherently protects blocks with code/snippets in?

If so, to which extent should one utilize it, instead of e.g. building a custom block?


texts: How to show picture of the user who triggered the rule for message activity?

texts:
I am using message module to record user activity on the site and displaying it through views. I am using rules module to trigger actions on certain events and show the relevant message.

How I can show picture of the user who triggered the event?

For example: When my question is liked by clive, I receive a message notification that "Clive liked your question". I only see a plain text. How to show the user picture?


texts: Looking to make an opaque image/image caption in a teaser

texts:
I am interesting in making a teaser that just shows an image, which an opaque caption over it it saying blahblahblah READMORE and then a link to the page.

how would i do this?  i'm not even sure where to start.  i am using this with views kwick slider.


texts: What to bear in mind when doing minor update of omega base-theme

texts:
Recently the minor update of Omega-Theme, version 4.3, has been released. Since i have an omega subtheme based on version 4.2, i would like to know, how i can do the update to version 4.3.
Is it sufficient to just update the base-theme or should i do changes in my subtheme too?


texts:
I am using Display Suit module to enhance the apache solr search results page. I use the Teaser view mode, but I don't get the node title in the teaser, because the node Title field is not available in the Content type display setting under teaser settings.

Is there any alternative way to add the node title as part of teaser view?


texts: Having trouble adding a custom js file to my Drupal 7 site

texts:
I added a javascript file to my site in the theme's .info file

scripts[] = js/myjs.js

The js file loads and I can see that it's included in the head when I load the site, however the jQuery javascript doesn't work at all.  I have a simple show/hide when a div on the page is clicked by it's not working.

This works fine when it is not in the Drupal site.

By clicking "Click here to start quiz" it should hide that div and show another.

I have a feeling it is because I do not have the most updated version of jQuery installed (I have 1.4.4 instead of 1.9.1), but I'm not sure how to update it for the theme I'm using.

Any ideas?


texts: How to Allow User to Choose to Pay by Invoice OR Credit Card with Drupal Commerce

texts:
does anyone know if its possible to have a Drupal Commerce checkout form that allows a user to choose whether they want to pay by credit card OR have us send them an invoice so they can pay by check? The form should allow the user to submit the form regardless of which option they choose.

Note: if they choose credit card they would of course have to fill out their credit card information. IF they chose invoice they wouldn't have to pay at this time.


texts:
I have the following 2 files in 2 different directoties in a custom module directory.

modules/custom/calculator

This is my info.yml file (calculator.info.yml)

name: calculator
type: module
description: Calculator
core: 8.x
package: Custom

My css is in  the directory modules/custom/calculator/css and js in the modules/custom/calculator/js directory

My libaries file is this: (calculator.libraries.yml)

base-style:
  version: VERSION
  css:
    component:
      css/wunderpage.css: {}
  js:
    js/wunderpage.js: {}
    js/jquery.matchHeight-min.js: {}

I also have a calculator.module file :

<?php

/**
 * @file
 * Contains calculator.module..
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function calculator_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the calculator module.
    case 'help.page.calculator':
      $output = '';
      $output .= '
' . t('About') . '
';
      $output .= '
' . t('Calculator') . '
';
      return $output;

    default:
  }

  function calculator_preprocess_page(&$variables) {
    $variables['#attached']['library'][] = 'calculator/base-style';
  }
}

Still my css and js etc is not being loaded.

Somebody knows why my libraries are not being loaded?


texts: How to display block using hook_block on specific pages only

texts:
I am creating the block using the following code , but i need to dsiplay this block only in specific pages only . How can i achieve this ?

function mailusers_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0] = array(
      'info' => t('User Management block'),
      'weight' => 0,
      'status' => 1,
      'region' => 'left',
    );

    return $blocks;
  }

  else if ($op == 'save' && $delta == 0) {
    variable_set('test_block_items', $edit['items']);
  }
  else if ($op == 'view') {
    switch ($delta) {
      case 0:
        // Your module will need to define this function to render the block.
        $block = array(
          'subject' => t('User Group Management'),
          'content' => mailuser_block_conent(),
        );
        break;
    }
    return $block;
  }
}

function mailuser_block_conent(){
    //create menu links
     $ret = '<a href="'.$base_url.'/mailusers/adduser">Add User </a>';
     return $ret;
}


texts: db_query - Get all nid in more than one nodetype

texts:
This is a simple query , but i really dont know why its not working. I think the problem is with single quote used!

$type = array('node_type_1', 'node_type_2', 'node_type_3');
$placeholders = db_placeholders($type, 'text');
$query = "SELECT nid FROM {node} WHERE uid = %d AND type IN ($placeholders) AND status = 1 ORDER BY nid DESC";
$result = pager_query($query, 10, 0, NULL, $user->uid, $type);

It tried this also

$result = pager_query($query, 10, 0, NULL, $user->uid, implode(', ',$type);

I am getting error

warning: mysql_real_escape_string() expects parameter 1


texts:
I have few roles in OG groups: Visitor, Reviewer, Member, ...

Visitor and Reviewer are added roles with (at the moment) exactly the same settings. Unfortunately somehow Visitor is inheriting Member's access rights while Reviewer is not.

I checked everything and all looks fine. I tried hacking OG code (I switched off the default role inheritance), checked og_role_permission table and all looks fine. But still whenever I give some rights to the Member role, Visitor user is somehow inheriting them while Reviewer is not.

My website is making use of OG roles everywhere. I have context, rules, custom code depending on it. And while everything works fine, field_access is behaving strange.

Do you guys have any idea how can I go on with debugging this issue? Is there a place in node_access module where I could put some debug code informing me what is going on?

UPDATE

I switched off all the custom code, changed drupal core to older version, made sure that access settings for Visitor OG role are exactly the same as Reviewer's.

I rebuilded cache, rebuilded access rights, changed browsers, went through code in OG and data stored in the db.

Still users with Visitor OG-role inherit rights from Member OG-role, while Reviewer does not. This bug is killing me.


texts: Is it good practice for a module to add fields to a certain content type?

texts:
I have a content type of "album" that is used for displaying reviews of music albums. It has fields like "artist", "genre", "publication_date", etc.

I also have a supporting module that displays relevant albums (that can be purchased elsewhere) for this content type using a 3rd party web service. This module requires a few extra values, like the limit of the relevant albums to be displayed, or a unique id for the artist for the web service.

Is it a good idea to have the module add these extra fields at installation time?


texts: How to show Forms in nodes stored in the node tables

texts:
Mine is shared hosting account with limited CPU usage so I want to minimize CPU and mysql usage.
I'm generating 100,000s of nodes which contain some information. I also want to add a form in those pages. Since these nodes will be stored in node table how can I generate form on the fly? I think using filters but that'll not use Drupal caching hence it'll affect the shared hosting CPU quota due to this performance issue.

I don't want to use _menu to generate those pages on the fly because 1) it will slow down my site 2) It'll be difficult to use Drupal Taxonomy to classify "these" generated pages on the fly. Generating pages from the node table will be faster and also cacheable.

Another way is to insert the Form code in the nodes at the time of generation with the option that it won't contain/verify dynamically generated tokens(eg without #token) but it'll be security risk for my site.

What is the best way to handle this case?


texts: what is the URL I should use to edit a user account?

texts:
I need to edit user account data via services module

I tried endpoint/user, endpoint/user/UID, endpoint/user/UID/edit, endpoint/user/update, endpoint/user/edit

with args like in user_resources.inc

It returns 404user not registered

despite successfully loggedin

$cookie_session = $logged_user->session_name . '=' . $logged_user->sessid;

// User data
$user_data = array();
$user_data['uid'] = $logged_user->user->uid;
$user_data['data']['name'] = 'test4';

$data = json_encode($user_data);

// cURL code
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/html/mob/api-    mob/user/".$user_data['uid']);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_COOKIE, "$cookie_session"); // use the previously saved session
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data), mymodule_get_csrf_header())
);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

what I am missing here or if one could do it via services please provide an example


texts: How can I override the menu toggle on AdaptiveTheme?

texts:
The menu renders:

Menu

which is hidden when in a viewport bigger than tablets. I would like to replace the "Menu" part with a  element with an icon instead, How can I override this?


texts:
I have a birthday field that has the date repeat in drupal. When i try to use feeds to import the dates using CSV, the dates get imported but i can't import the repeat date.

What is the format for the date repeat so i can import the birthday and all the repeat dates


texts: How to make a checkbox field required when a radio button is selected.

texts: I need to show a validation error message when a radio button is clicked but none of the checkbox is checked. The checkbox field is optional in content type. Should be required when radio button is clicked. How can it implement this programaticaly. Not interested to add conditional field  module for a single requirement.


texts: How to hook into field creation (form successfully processed)?

texts:
I need to act after field has been created (new db table).
Actually I need to use data from the first field form:
field-ui-field-storage-add-form
So ideally I need to hook on this form being successfully processed (and its data).
Is there any way of achieving it?
Something like old hook_field_storage_create_field


texts:
I am using STMP module for D7.

When i put test email abc@gmail.com, i have received the email but

When i check show original i am getting received from

Received: from usernem by myhost username with local (Exim 4.85)

Why it is so ?

Also i have enter wrong password and tried to send an email. i recieved the email

Seems SMTP is not working on my site

Below are my settings


texts: Update module issue - version_major in update_calculate_project_update_status()

texts:
I am building a site using Drupal 7.26.

I get this notice all the time:

  Notice: Undefined index: version_major in
  update_calculate_project_update_status() (line 628 of
  /XXX/public_html/modules/update/update.compare.inc).

Does someone knows what is the problem, and how to solve this?

Thanks!


texts: Implement variable in node confirmation popup

texts:
I want to add a confirmation popup for node form.
The message should be changed dynamically.
The code below worked fine in form_alter.
$form['actions']['submit']['#attributes']['onclick'] = 'if(!confirm("Really Save?")){return false;}';

But the popup didn't show up if I include a variable in the code like this:
$text = "Really save?";
$form['actions']['submit']['#attributes']['onclick'] = 'if(!confirm({$text})){return false;}';

Is there any way to change the text dynamically?


texts: Is there a callback for the managed_file form element, called on succesful upload?

texts:
Is there a Javascript/PHP callback for the managed_file form element that is invoked when the file is successfully uploaded? (I mean when the "Upload" button is clicked, not when the form is submitted.)

$form['video'] = array(
    '#title' => t('Video'),
    '#type' => 'managed_file',
    '#default_value' => variable_get('image_example_image_fid', ''),
    '#upload_location' => 'public://temp_managed/',
);

I have tried:

#file_value_callbacks, but this seems to be a preprocess
#process, but it also seems to happen during the page load


texts:
I'm using modules Content Access and Panels.

I need to modify the appearance of a node according to its accessibility by the user.

With Panels, I made 2 variants with selection rules (page "Node template"):

when the node is not accessible
when it is accessible.

But when the user has no access to the node he has a denied access and not the panel.

Do you know how to bypass node access with Panels?


texts: it appears as passwords in Drupal 7 are case sensitive. Is there a way to make them case insensitive?


texts:
I have different fields and showing in different blocks, and want to apply exposed filter to all but my problem is it shows different exposed filters for each different block. I want to make it common for each block.

Below are the steps,

I made 5 blocks to be displayed for each buttons.
Added exposed filter for languages for each block.

Now each block showing its different exposed filter.
But I want the exposed filter should be shown above the buttons and should work for each block display. Attached screenshot for the issue.

I installed Views Global Filter but is gives Session error.


texts: How do I get Drupal to use table prefixes so I can install multiple drupal installations in the same database schema?

texts:
My webhost is pretty limited, and I only have one database user & schema. I would like to install multiple drupal installations on this database schema.

How do I tell each installation to prefix its tablenames with a given string?


texts: How do I update a multi-dimensional commerce product field with Views Bulk Operation?

texts:
I'm converting from an old UPS module to the newer Commerce UPS. The old module used integer fields for height, length, width. The Commerce UPS module demands a multi-dimensional field 'Product_Dimensions'. So I want to update the Product_Dimensions field with the old data.

I created a View with a VBO column and I selected Execute Arbitrary PHP Script as my operation. Here is my code:

$product = commerce_product_load($entity->product_id);
$product->field_package_dimensions = array( "und" => array(0 => array( length=>"91", width=>"22", height=>"11", unit=>"in") ) );
commerce_product_save($product);
// dpm($product->field_package_dimensions);

...the product_dimensions field is being updated BUT each dimension of the array is being assigned a single character '9'. ie. the length, width and height are all '9'. So clearly there is something wrong with my array assignment?

Can someone tell me what I'm doing wrong? I'm sure it's an obvious mistake... or there is a 'proper' procedure for programmatically updating commerce product fields that I'm missing.

TIA.


texts: Because of problems with multi-currency ubecart, I am thinking about creating 2 identical e-shops for 2 countries with different currencies. One important thing worries me - stock levels. Is there any way to synchronize stock levels data between multiple drupal/ubercart installations? Thank you very much.


texts: How to display a block to a specific user?

texts:
I need to display a block just to a specific user.
I don't want to create a role just for a user. that does not make sense!


texts:
I am missing a button to press when replacing a file.

Go to admin/content/file and edit a file.

For example: i am on file 778 at /file/778/edit

If you look at the Replace File field, there is no Replace/Upload button! So, yes, I can only upload an image but not replace the image.


texts: Filter view based on displayed part of an Open Layers map

texts:
I have a page that shows an OpenLayers map which is fed with data coming from an Open Layers data overlay view (user locations; the location is provided via a location cck field in the user account settings). Right underneath the map the overlay data is listed using a clone of the Open Layers data overlay.

Is there a way to filter the displayed entitites in the list based on what part of the map is currently looked at? That is, is there a way to hide entities from the list when I zoom into a different part of the map?

Example: Zoomed to full extend, showing the whole world -> display all entities. Zoomed to the US, showing only California -> display all entities with a Californian location.


texts: How to make a custom translatable string?

texts:
For example, i've a array contains string for each elements

$description[] = $discount->short_description;

foreach ($description as $value) {
$line.= $value."
";
}

the $line will be used in

  $output[$field_name] = array(
    '#theme' => 'field',
    '#title' => $instance['label'],
    '#label_display' => 'hidden',
    '#field_type' => $field['type'],
    '#field_name' => $field_name,
    '#bundle' => $node->type,
    '#object' => $node,
    '#items' => array(1),
    '#entity_type' => 'node',
    '#weight' => $display['weight'],
    0 => array('#markup' => t($line)),
  );

how can i make this $line will appear in admin/config/regional/translate/translate, so i can translate it?


texts: Removing block-system-main div from content

texts:
I'm building a website where I output some of the markup to the front page via hook_page_alter(), and the rest via hook_menu() calling a form. I have a local version running on my laptop that is working fine. The problem is that in the remote install, Drupal is adding the divs:

     //My form markup is in here

//The hook_page_alter markup is in here.

This way, the submit button is always on top of the rest of the content and I would like to be on the bottom. The local install of Drupal doesn't do this for some reason.

Does anyone know how to:

get rid of the two divs (I know I can do it in block.tpl.php with a block--content.tpl.php) but maybe something cleaner would be nice
(or, ideally) how to add the content from hook_page_alter() to the same div as the form is in

In hook_menu() I'm just doing a standard call to drupal_get_form(). Here's the code for hook_page_alter():

function planb_page_alter(&$page) {
  if (drupal_is_front_page()) {
    $q = db_query('SELECT name, mname, number_of_instances FROM {event_type} ORDER BY        number_of_instances DESC');
    foreach($q as $event) {
      $options['name'][] = $event->name;
      $options['mname'][] = $event->mname;
    }
    $tri = array(
      '#theme' => 'frontpage_canvas',
      '#options' => $options,
      '#weight' => -1000,
    );
    return $page['content']['triangle'] = $tri;
  }
}


texts: Change the height of the ckeditor text window

texts: If I try to change the height and style of the ckeditor text window with css then I find there are numerous layers to the css which makes it difficult to style. Is there a width and height setting in the settings which I can modify?


texts: Call to theme_captcha function in captcha module

texts: I put a display at the top of the theme_captcha function in the captcha module for a particular form and it is getting into the function but where does this function get called from ??


texts:
I want to clear the cache of specific node's view. In my database in cache_views_data table I found the cid of my view and the format is like
"views_name:display:hash" but I cannot find this hash where is reffering to.


texts: How to set additional node type options programmatically?

texts:
When creating a node type programatically, some node type options can be set in hook_node_info, including name, base, description, has_title, title_label, has_body, and help. As far as these node options go, using hook_node_info is cleary the canonical way of doing it.

However, some additional node type options cannot be set using this hook, and I have not yet found any canonical documentation that explains how do do this.

The options I look for a method of setting programatically include:

whether commenting by default are open or closed;
whether the node should be published, promoted, sticky and/or have revisions enabled upon creation;
whether it should display author and date information.

The solution I currently use is to set the appropriate database variables in hook_install for the module that creates my_nodetype to the defaults I want, e.g.:

variable_set('comment_my_nodetype', COMMENT_NODE_CLOSED);
variable_set('node_options_my_nodetype', array('status','promote'));
variable_set('node_submitted_my_nodetype', FALSE);

I figured out this solution by reading the source code to discover that these database variables determine behavior at runtime.  I've not found documented anywhere how one should go about setting these additional node type options.

Is there a better way of doing this than the improvised soluton I currently use?


texts: When creating a content type programmatically, is there a way to add tuples (e.g. pairs) of fields?

texts:
In Drupal 7, I'd like to create a Person content type. A person may have multiple profiles - an administrator should be able to select which profile will be considered the primary one. So, that means that I need a tuple consisting of:

A textarea, for the profile text
A checkbox, indicating that this is the primary profile
A textbox, for naming this particular profile

I need functionality to behave like that of any of the lists: I can click "Add another Item", and a set of all three of these fields will appear.

I have a vague idea of how this can be executed, but it involves using the form API to add fields before the form renders each time, as well as the necessary AJAX behavior. This seems a bit overcomplicated, since this would also necessitate creating an additional DB table to hold these tacked-on fields.

Is there a relatively simple way of doing this solely through hook_install()?


texts: How to extract zip files after the upload successfully, I'm using File Field Paths to upload files.


texts:
In Drupal 7, in the views with an argument, is easy to override both title and breadcrumbs.

Now in Drupal 8 I can't find the option.

Did I miss something? or isn't possible? In this case what is the workaround?


texts: I am using Global Redirect which automatically convert /node?page=1 to /?page=1 when click on pagination. everything working fine but i want also remove /node and just want /?page=1 when mouse hover on pagination. you can also refer my site and check its pagination.


texts: Print selected fields from a referenced node

texts:
Using entity reference, i have been able to link a node of type blog to another node of my custom content type, "challenge", by creating a field under blog of type entity reference. Great. Now, when the blog is published, some fields (not all) from the linked custom content type should also be displayed there. For ex, in my custom content type, there are some fields as title,body,image1,image2,sponsor, some flags using the flag module and other fields. I want that only some fields which i mentioned should be displayed on the blog (no flags etc to be displayed). SO what i do is under Manage Display for blog i select Rendered Entity for display. What this does is gets all the fields from the referenced/linked node. However i want some fields not all. Now what i do is write a custom node--blog.tpl.php. I then hide everything from content as:

<?php
   hide($content['title']);
   hide($content['field_blog_pic']);
   hide($content['field_challenge_name']);
   hide($content['field_challenge_pic']);
   hide($content['field_sponsor']);
   hide($content['field_sponsor_logo']);
   hide($content['field_sponsor_description']);
 ?>

Then i tried rendering the fields one by one. It is ok for the field of type blog but the moment i do a print_render($content['field_challenge_name']) then all fields from the referenced node (of my custom content type, challenge) get displayed. How can i just select a few fields for display of the referenced node.

If it helps, here's my node--blog.tpl.php:

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

     <?php
        print $title;
     ?>

     <?php
        print $comment;
     ?>

     <?php
        print $name;
     ?>

    <?php
    /** $user = user_load($user->uid);
      print theme_image_style(
                    array(

                        'path' => $user->picture->uri,
                        'attributes' => array(
                            'class' => 'in-blog-user'
                        )
                    )
                );
    */
    ?>

 <?php
   $user = user_load($uid);
   print theme('user_picture', array('account' =>$user));
 ?>

 <?php
  print $title;
 ?>

<?php
   hide($content['title']);
   hide($content['field_blog_pic']);
   hide($content['field_challenge_name']);
   hide($content['field_challenge_pic']);
   hide($content['field_sponsor']);
   hide($content['field_sponsor_logo']);
   hide($content['field_sponsor_description']);
   hide($content['field_categories']);
?>

 <?php
  print render($content);
 ?>

<?php /*

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

*/?>

All fields get displayed of the referenced node once i do the last few lines

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

    ?>

So after all that blabbering, all i want to ask is how to print some selected fields of a referenced node (here my custom type, "challenge") onto the referencing node (here, blog)...

Regards


texts: How to alter drupal views filter by start date query

texts: I need to display only future events with start and end date greater than or equal to today's date. I am using drupal with oracle. When i am trying in views UI, its giving me an SQL error.


texts:
I am creating a custom front page (using a template page--front.tpl.php).

I've defined a few regions to be used on my front page. In one of these regions I would like to embed a Bootstrap Carousel (that was created with the Bootstrap Carousel module). Can this be done? It appears only blocks can be added. A Carousel appears to be of type content. Perhaps this can be done using Views or a similar module?

The reason for me going this route is for simplicity of updating the carousel. Another maintainer of this website does not have PHP/HTML/CSS skills, so I would like for them to simple update the carousel using the Drupal admin interface, as opposed to updating page--front.tpl.php itself.


texts: Creating a route with a form and some content

texts:
i have created a route with a form:

    amu_404_redirect_import.admin:
      path: '/admin/config/amu_404_redirect_import/upload'
      defaults:
        _form: '\Drupal\amu_404_redirect_import\Form\Amu404RedirectImportForm'
\Amu404RedirectImportController::content'
        _title: '404 redirect Import'
      requirements:
        _permission: 'administrer AMU 404 redirection import'

if now i am creating a controller to display some content to the same page , the form is not displayed anymore

amu_404_redirect_import.admin:
  path: '/admin/config/amu_404_redirect_import/upload'
  defaults:
    _form: '\Drupal\amu_404_redirect_import\Form\Amu404RedirectImportForm'
    _controller: '\Drupal\amu_404_redirect_import\Controller\Amu404RedirectImportController::content'
    _title: '404 redirect Import'
  requirements:
    _permission: 'administrer AMU 404 redirection import'

how could i have both content displayed ?


texts: View with entityreference: make exposed filter autocomplete

texts:
I have two content types A and B. B has an entity reference to A.
When creating a view to list all nodes from type A, I want to use some exposed filters. One filter would be to give all nodes from type A that have a reference to a certain node of type B.
The exposed filter I get is a textfield that needs a nid. I made it autocomplete (via form_alter), but now the value that gets saved is "node title (nid)".

Anyone having the same problem, and knows how to fix it?

EDIT:
I found this patch for entity_reference, but it doesn't seem to work.
http://drupal.org/node/1492260


texts: Migration Issue: New Site won't open -- server doesn't see file that is there

texts:
I am migrating a Drupal site from my localhost to the most current Bitnami Drupal AMI on Amazon:

I uploaded the DB successfully.
I moved the files correctly.
I copied over the modules and libraries.

I got the WSOD, changed the error reporting and now, upon opening the site I get:

    Fatal error: require_once(): Failed opening required
'/opt/bitnami/apps/drupal/htdocs/sites/all/modules/views/includes/view.inc'
(include_path='.:/opt/bitnami/php/lib/php') in
/opt/bitnami/apps/drupal/htdocs/includes/bootstrap.inc on line 3066

But the file is in the proper spot, within the structure outlined by Bitnami:

/home/bitnami/apps/drupal/htdocs/sites/all/modules/views/includes

How do I convince drupal (or php) to use "/home" instead of "/opt"?  I suppose I could just try a symlink but... that seems like such a kludge.  I'd like to do it the "right" way.

Any suggestions?


texts: Creating a Custom Formatter to replace a Link with an Icon / Image

texts:
I would like to replace links in a view I have created with icons. The links are dynamic(varying URLS) but will be be within 5 domains, eg:
www.example.com/page7
www.example.com/page2
www.example2.com/page9
www.example3.com/page77

I would like to provide an Icon for each of the Domains which is applied to the link, so that clicking on the link takes the user to the URL(in a new window) and the text is hidden.
I am aware of CSS image replacement technique but would like to use https://drupal.org/project/custom_formatters to do this. I am also aware of https://drupal.org/project/image_link_formatter .

Using the Custom Links Formatter module would allow me to import/export, save, reuse and share this function.


texts: How can I add custom client-side validation to a Webform field using advanced custom properties?

texts:
The setup:

I have a Drupal 8 form created manually, and I would like to recreate it using Webform module.

So far, I have managed to recreate everything (required fields and submission handler), but there is a last bit missing: the client-side validation that triggers on change.

The initial form have fields defined as follows:

$form['first-name'] = array(
  '#type' => 'textfield',
  '#title' => $this->t('First name'),
  '#required' => true,
  '#required_error' => $this->t('This is a required field. Please enter your first name.'),
  '#ajax' => [
    'callback' => '::validateFnameAjax',
    'effect' => 'fade',
    'event' => 'change',
    'progress' => FALSE,
  ],
);

Calling validation functions like this one:

public function validateFnameAjax(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $errorValidation = '

';
  $successValidation = '

';
  // Assert the name field has been included
  if (!$form_state->getValue('first-name') || empty($form_state->getValue('first-name'))) {
    $message = $this->t('This is a required field. Please enter your first name.');
    $response->addCommand(new InvokeCommand('.staff-register-form .js-form-item-first-name .form-text', 'removeClass', ['is-valid']));
    $response->addCommand(new InvokeCommand('.staff-register-form .js-form-item-first-name .form-text', 'addClass', ['is-invalid']));
    $response->addCommand(new ReplaceCommand('.js-form-item-first-name .form-item-message', $errorValidation));
    $response->addCommand(new HtmlCommand('.js-form-item-first-name .text-danger', $message));
  }
  else {
    $message = $this->t('Your first name is valid.');
    $response->addCommand(new InvokeCommand('.staff-register-form .js-form-item-first-name .form-text', 'removeClass', ['is-invalid']));
    $response->addCommand(new InvokeCommand('.staff-register-form .js-form-item-first-name .form-text', 'addClass', ['is-valid']));
    $response->addCommand(new ReplaceCommand('.js-form-item-first-name .form-item-message', $successValidation));
    $response->addCommand(new HtmlCommand('.js-form-item-first-name .text-success', $message));
  }
  return $response;
}

In the new webform function I have changed lines one and six, but the rest of the code is the same.

New line one:

  public function validateFnameAjax(WebformSubmissionInterface $webform_submission) {

New line 6:

  if (!$webform_submission->getElementData('first_name') || empty($webform_submission->getElementData('first_name'))) {

The challenge:

Implement the same behaviour: trigger the custom validation when the content in the field changes (before submission).

Current status:

I have tried to include the Ajax properties using the Advanced tab of the edit field UI as you can see in the following screenshots:

But I get this error in the log:

  Symfony\Component\HttpKernel\Exception\HttpException: The specified #ajax callback is empty or not callable. in Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse() (line 67 of /var/www/drupalvm/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php).

Does anyone know what am I doing wrong to get this error, and how to make this client side validation work?


texts: Ajax form in preprocess_node never triggers

texts:
In a preprocess_node hook, I try to insert a Drupal node_form form in my page. I do it with this function:

function my_module_get_edit_form($selection) {
  drupal_add_library('system', 'drupal.ajax');
  drupal_add_library('system', 'drupal.form');
  $form = drupal_get_form('selection_node_form', $selection);

  //here some code to disable (#access = FALSE) unwanted fields and options

  $form['actions']['submit'] = array(
    '#type' => 'button',
    '#value' => 'Update',
    '#limit_validation_errors' => array(),
    '#ajax' => array(
      'callback' => 'smll_selection_ajax_callback',
      'wrapper' => 'selection_form'
    ),
  );

  return drupal_render($form);
}

The form is rendered properly but when I click my submit button, it always submits the form and forwards me to the node's page, no ajax call.

I tried adding #ajax array onto a select field in the same form ($form['field_application_type']['und']['#ajax']) but nothing is triggered when I change the select's value. No HTTP request, no Javascript error, nothing.

I tried using drupal_build_form with a manufactured $form_state.

I tried creating my form in an another function and calling it with drupal_build_form.

I tried setting #ajax_processed to TRUE.

The HTML id selection_form exists but, anyway, I never come to the moment the callback function is called.


texts: Multiple results in a view due to taxonomy?

texts:
I have a content type called "Stuff". Which has a taxonomy term called "Area". There are three Areas: A, B and C. I have a view that lists the content. The problem is, I get duplicates based if a node is assigned to multiple terms.

So for example, if I have three nodes, each assigned to ONE taxonomy term, I end up with:

Stuff 1 | A
Stuff 2 | B
Stuff 3 | C

But if I assign a node to multiple terms I end up with:

Stuff 1 | A
Stuff 2 | B
Stuff 3 | C
Stuff 4 | A, B, C
Stuff 4 | A, B, C
Stuff 4 | A, B, C

I've tried:

Going under ADVANCED --> OTHER --> QUERY SETTINGS --> DISTINCT ...

Any ideas what could be causing this?

UPDATE

If I use aggregation, I get:

Stuff 1 | A
Stuff 2 | B
Stuff 3 | C
Stuff 4 | A
Stuff 4 | B
Stuff 4 | C

But I want:

Stuff 1 | A
Stuff 2 | B
Stuff 3 | C
Stuff 4 | A, B, C

What am I missing?


texts: View Database Connector Module not working

texts:
I am using the Views Database Connector module in drupal 8 to display the data from external database.

I have also set the both database setting in setting.php, but still I am unable to see the VDC in view. can anybody please let me know how can I do this.

Thanks.