texts: In D7, Where can you go to get a list of Access Arguments to be used with user_access()?

texts:
Where can I find a list of Access Arguments to be used with user_access() ? I went to the permissions page and I'm not sure what I can copy and paste from there to be used as an argument for user_access(). So far I only know two: 'access dashboard' and 'access content'

I want to find out how can we get a list of these arguments.


texts:
I have business logic that interfaces with Drupal entities (in this case, users), and we need to generate reports off these records daily at a preset time. It would be easy for me to generate this data on-demand, but the requirements ask for a daily report.

I'm wondering if its possible in D7 to have the system schedule a specific cron task to run at a preset task over the time cron is expected to run (which right now, is every 3 hours). Another option I am considering is to have a Contrib Drush script that simply runs using the OS'es crontab/launchd. Which one makes the most sense?


texts: How Specify the class name of our columns in Responsive Grid View?

texts:
I'm trying to build a responsive Views grid using views responsive grid module. But added fields in the view is not visible.

I'm confused in adding grid class.Please anybody guide me to set class name, so that fields can be seen in the grid?I have attached screenshot of my settings below.


texts: Is it possible to create a references from text?

texts:
I'll explain problem with an example:

We have:

Text about apples
List of types of apples

Problem:

User inputs text about apples.
User selects text that describes certain type of apple, and then click 'magic button'
'Magic button' creates a small window with input field for type of apple.
User enters type of apple, drupal creates that type of apple in list of types of apples.

Details:

Apples are described in text.
Types of apples will not be a plain text(fieds in content type called 'Apple Types')

Is this even feasible in drupal?

Can you point me in right direction of search? What kind of modules(combination of modules) would help me?


texts: How do prepopulate a Field Type Postal Address with values from a user profile

texts: I'm using address field module (addressfield-7.x-1.2) and I don't know how to prepopulate the address field from users profile2 (profile2-7.x-1.3) addressfield  I managed to prepopulate other single fields using tokens


texts:
I work with:

$mandator = $this->database->select('Mandators', 'm')
     ->fields('m')
     ->condition('idMandators', $mandatorId)
     ->execute()
     ->fetchAll();

to retrieve my data from database. The result is an array with 1 array item. How can I retrieve always only 1 object, without the array? Like e.g. ->fetchOne?


texts: How to define content within a custom region?

texts:
I'm new to Drupal and I'm only learning. I'm required to add a custom region to my site. I understand what I must add in the .info file and set from Structure > Blocks to make it show up. What I don't understand is where do I write the content for my "custom region block"?

Say I've a region I want to call "my_region". What do I do to actually define how the "my_region" is supposed to look like?

I've tried various online reference sites and most of them just show me how to do this -

regions[header] = Header

and this-

        <?php if ($page['header']): ?>
        <?php print render($page['header']); ?>
        <?php endif; ?>

I know all that. What I don't know is how to make regions['my_region'] work.

Any references to tutorials or guides would be deeply appreciated.
Thank you

EDIT:

I've set up a region in the info file as regions['my_region'] = MyRegion.
Now I'm clueless as to where to add the contents that goes in regions['my_region'] or any other custom content that I define?

Example: If I want regions['my_region'] to include a slideshow, where do I actually create the file containing the slideshow that regions['my_region'] refers to?


texts: Content referencing the referenced content

texts:
I've been searching and cannot find a way to achieve this: display content referencing a content that is referenced by the content being displayed.

It may be somewhat confusing but I'll do my best to be clear:

I have two content types: 'Company' and 'Service'
As you can imagine a Company provides many Services, so there is an Entity Reference field in Services that points to the Company providing it.

That's it:  Service content points to Company content in a many to one relation, many services point to one company (the company that provides them)

When I display a Service, I also display the company that provides it through the Entity Reference field.

Now the tricky part is:
When displaying the page for a Service, I'd like to also show (e.g. in a sidebar) the other services provided by the Company that the displayed Service is pointing to.

I'm using Panels and Views on Drupal 7.

Please note: this is not a simple 'related content block', that's what I am using to display the company providing the content or when displaying the Company content


texts:
I am currently developing a Drupal 8 site that will consist of one only central content type with a minimal menu structure. The user is supposed to navigate the site only by using a search/filter form (similar to a search engine) and I would like to disallow all methods for locating content other than using the search form.
The problem is: All content in Drupal is normally accessible by using <site>/node/<somenumber>, which makes it easy to locate all content by simply counting upwards (I think, this process is called node enumeration). I know, I can use the Pathauto module to generate a pattern for URL aliases (say, a random hash). Unfortunately, that won't prevent the original URLs from being accessible: When entered, they will simply be forwarded to the generated aliases.
So, my question is: Is there a way to prevent this node enumeration from being possible? Is it possible to have the node available only under the generated aliases and not forward the original URLs?
All help would be much appreciated.


texts: simple fb connect enter custom user field in field group for new users

texts:
I need a help with an issue that I am facing in the module.

So, on my registration page I have some extra fields like:

Country
Real name (different from username)

Country and real name value is in field group and the name is as following

Name : field_primary_contact[und][0][field_contact_name][und][0][value]
(taxonomy term) Country : field_primary_contact[und][0][field_contact_country][und]

in my hook_simple_fb_connect_registration  I set the following value

example

$drupal_user->field_primary_contact[und][0][field_contact_name][und][0][value] = "fb hook testing";

$drupal_user->field_primary_contact[und][0][field_contact_country][und] = 40;

It doesn't work. Do we need to do anything different for field groups?


texts: What does the method `getLinkTemplate` do in an entity type?

texts:
I am trying to debug the Access by Entity module, and it isn't generating new routes that it should be doing in its RouteSubscriber.

This line here:

if ($access_load = $entity_type->getLinkTemplate('access-entity')) {

It is always FALSE. What is getLinkTemplate method for? I checked the doc page, but didn't come away with a lot of information and I have not seen this used before today (outside core).


texts: Is there any way to alter the response of JSON API module?

texts:
I am using JSON API module to expose data using REST API. I want to alter its response. I am trying to altering it using hook_ENTITY_TYPE_load. If I change any existing property it shows the updated value. But if I try to add custom property it doesn't show the custom property in response. The two hooks I used are below:

function my_custom_entity_type_alter(array &$entity_types) {
  $entity_types['node']->set('flag_count', 10);
}

function my_custom_node_load($nodes) {
  foreach ($nodes as &$node) {
    $node->flag_count = 10;
  }
}

I need to know if there is any possible way to alter the json api response with custom properties?


texts: How to block all users not containing a pattern?

texts: I'm trying to block all users except ones with a specific role, and would love to use something like: drush user:block !roadie.


texts: db_set_active() and node_save() not working as expected

texts:
I'm writing a module to use on a multisite setup that enables nodes to be published to another site on the same installation.

Suppose I have Site A and Site B. I want this module to provide the ability to save a given node from Site A to Site B. Naturally, the way I have the database info set up in settings.php for Site A is as follows:

$databases['default']['default'] = array (
    'database'  => $db_name,
    'username'  => $db_user,
    'password'  => $db_pass,
    'host'      => 'localhost',
    'port'      => '',
    'driver'    => 'mysql',
    'prefix'    => $db_tables,
);

$databases['site_b']['default'] = array (
    'database'  => 'site_b',
    'username'  => $db_user,
    'password'  => $db_pass,
    'host'      => 'localhost',
    'port'      => '',
    'driver'    => 'mysql',
    'prefix'    => '',
);

...thus giving Site A the info it needs to access Site B's database.

When I execute the following code in the module via the hook_node_insert and hook_node_update hooks:

// Switch to Site B database
db_set_active('site_b');

// Save the node on Site B
node_save($node);

...it attempts to save the node on the current database instead, resulting in an SQL error (duplicate node ID). (Also, as a side note, I'm utilising a boolean property on the $node object to prevent the hooks and node_save() from throwing each other into an endless loop.)

I tried using drupal_get_schema(NULL, TRUE); directly after db_set_active('site_b'), but that made no difference. I've also cleared the cache in between every code change and test. No luck.

I don't know what's preventing it from working... maybe my $databases array is structured incorrectly?


texts:
<?php
/**
Provides a block with query and store in database
*/
/**
* Implementation of hook_help().
*/
function demo_help($path,$args)
{
if($path=='admin/help#demo')
{
return t('To use this module, go to block page and turn on the       demo');
}
}

function demo_block_info()
{
$blocks=array();
$blocks['demo_member']=array(
'info'=>t('Demo member'),
'cache'=>DRUPAL_NO_CACHE,
);
return $blocks;
}

/**
* Implements hook_block_view().
*/
function demo_block_view($name)
{
if($name=='demo_member')
{
//$format2 = 'g:i a';
$content=db_query("SELECT entity_id FROM     {field_data_field_category_status}")->fetchField();
            $content.='';
            $block=array(
            'subject'=>t('Member'),
            'content'=>$content,
            );
            return $block;
    }

}
?>

i need to display 3 records by fetching array(.module file)
i am getting single record:
Member
1
i should get below
Member
1
2
3


texts:
I'm having an issue with an undefined index I really could use some help with.

This is the error I get:

Notice: Undefined index: und in include() (line 15)

This is what my line 15 looks like:

  <a href="
      <?php print $node->field_house_coupon_link['und'][0]['url']; ?>
    " style="color:#
      <?php print $node->field_house_coupon_link_hex_code['und'][0]['safe_value']; ?>
    ">
      <?php print $node->field_house_coupon_link['und'][0]['title']; ?>

I know the error is happening because sometime the field is not given a value and allowed to be blank. I'm using Drupal 7.23 and I've tried using the isset method mentioned elsewhere on this site but it's not working and I'm out of ideas

Thanks!


texts: Show a block on a certain URL with wildcard

texts: How do I show a <div> inside page.tpl.php, on every page except for URLs that start with "audio/track"?


texts: How to download files which are stored in the folder

texts:
I need some guidance regarding how to download a file.

Suppose I have a link called "Download." When I click on the particular link a PDF file should be downloaded.

How can I do this?


texts: Building an advanced multicriteria search

texts:
I'm kinda new to Drupal and I would like some advises.

I have a Drupal website, with a few nodes (1000 - 5000) of a particular content type, let's say a "House".

This "House" content type has a few properties (20) like price, location, number of rooms, etc.

In order to allow my end users to find those nodes, I've build an advanced search with the Finder module.

However, this module is no longer maintained and it is not really appropriate to search through many nodes.

  Finder does not work like a typical search module, it does not base
  it's functionality on search indexes, and therefore is not an
  efficient choice for searching body content, though it can technically
  do that. It is more suitable for filtering on short field values.

What are the best options to build an advanced multi criteria search with Drupal 7 ?
Do I need to do it by hand ? What are the modules out there that could help achieving that ?

Is Facet API the way to go ?


texts: Views expose filter with ajax showing validation message after reloading page?

texts:
I added a date filter that showing select list for year and month. I created the block type view. When I select the month and submit the form it makes the red border outside the year. But when I reload the page or go to another page it gives me the error :

Please choose a year.

How to show error message at the time of form submit?

Any Solution???


texts: How to visit a specific node using behat

texts:
I am doing some work that requires customization of a breadcrumb for only one content type. I'm trying to write a behat test to verify it.

My Given is successfully creating the nodes, and I can verify that they are there if I tell behat to look at them in the admin content view:

Scenario:
  Given "partner_accomodation" content:
    |title            | body         | status|
    |Accomodation Foo | Test content | 1     |
  And I am logged in as a user with the "administrator" role
  When I go to "admin/content"
  Then I should see "Accomodation Foo"

What I can't figure out though is how to tell it visit that specific page. I would assume if I have pathauto configured correctly, that I should be able to go something like

When I go to "accomodation-foo"

Is there a way to know the node id or the URL alias of the content it created?


texts: how to enable access to a webform only from a link sent to user

texts:
i'm planning to create a form with the webform module on D7.
i would like to be able to send via e-mail a link to that webform, but only those who receive that link (non-registered users) could access and fill the form. i don't like to expose the form to general public of the website.

i know how to do this with registered users, it would be straight forward with permissions, but don't know how to achieve this with non-registered ones.

what would be the way to do this?


texts:
After migrating a site, I checked /admin/reports/status and verified that cron has not been executed in a long time.

I tried to run cron manually /admin/reports/status/run-cron, but all I got was a blank page.

The file permissions for cron.php are 544
On the dblog page, I see this error
"Cron run exceeded the time limit and was aborted."

Am I missing something else?


texts: Parent term suggestion on entering the child term in term reference field?

texts:
I have a term reference field which has the widget Autocomplete term widget (tagging).
I want the functionality like, when a user type a child term in that autocomplete field, the system should return a suggestion of the parent term that did you mean [parent term].

Suppose A is a parent term and its child term is B. So when a user type B in the field, it should show a suggestion of did you mean A?


texts:
When I create the content (specific to the content, not to the content type), I want to type in an optional ID, that would be set on the html element.

Is there a module for this?


texts: How can I pass updated views result to drupalSettings?

texts:
I've created a custom views style plugin.

I'm trying to pass the views results into a drupalSettings. I'm able to access the dataset like below using the template_preprocess:

$variables['#attached']['drupalSettings']['test']['dataset'] = $items;

However, the results isn't updating with views exposed filter. Though, if I set a drupalSettings based on views results count. It does update. So, I tried to turn off the views caching, but still no luck.

Here's my current code:

function template_preprocess_test(&$variables) {
  $items = &$variables['test']['items'];

  $variables['content']['list'] = [
    '#theme' => 'test_dataset_list',
    '#items' => $items
  ];

  $variables['#attached']['drupalSettings']['test']['dataset'] = $items;
}

Here's how I set the dataset from the custom views style:

function template_preprocess_test_views_style(array &$variables) {
  // Only run the preprocessor if it is a view.
  if (empty($variables['view'])) {
    return;
  }

  $view = $variables['view'];
  $style = $view->style_plugin;
  $options = $style->options;
  $items = [];

  foreach ($variables['rows'] as $k => $row) {
    // @todo should use render arrays instead of actual output
    $item['dataset'] = [];
    $item['dataset']['custom1'] = (isset($row['#custom1']) && !empty($row['#custom1'])) ? $row['#custom1'] : NULL;;
    $item['dataset']['row'] = $row;
    $items[] = $item;
  }

  $content = [
    '#theme' => 'test',
    '#test' => [
      'items' => $items
    ],
  ];

  $variables['content'] = $content;
}


texts: Webpage in different directory off the Root

texts:
I have Drupal (Ver. 6) installed in the Root directory.

I would like to have a page on my website be loaded from another sub-directory off the root. How do I go about doing this and make sure the page uses my theme?

ie.

www.mydomain.com/state/statepage

Thanks-in-Advance,

John


texts: How to get/print value of webform entity reference element in custom entity-print--webform-submission--testing.html.twig file

texts:
I have my webform "Testing" with some field element(field1, field2, etc...) and "person" that is entity reference element(entity automplete) that reference user.
So, I create may custom file entity-print-submission--testing.html.twig file for theming PDF.
With this {{ data.field1 }} {{ data.field2 }} i can render the value for that field, but this {{ data.person }} render the ID of user select in webform.
I want to render field surname that is present in user profile. I have try to use {{ data.person.entity.field_surname }} but return empty value.
In submission display option for person element I set custom and put this token in Item format custom HTML and Item format custom TEXT:
{{ webform_token('[webform_submission:values:person:entity:field_surname]', webform_submission) }}

This work only in submission display. It's not render in my custom entity print twig file.


texts: I have content type with Photos ImageField. I need to create some moderation view to show all photos and "delete" link to delete appropriate photo. How can I programmatically delete value from CCK field (in general not only ImageField but any field type)?


texts: Limit number of nodes able to have custom field selected

texts:
I have a content type named "Story" with a boolean field "Featured".

When users create/edit a story they can check the featured checkbox. Stories that are featured appear in a block throughout the site. The block only shows two stories.

Ideally, if there are two stories featured and a user creates a new story and selects the featured field, it would deselect the featured field for one of the two original stories. Only two stories can be featured at once. Is this possible?

The traditional route is to have the views block show the two most recently created stories that have the featured field selected. From an administrative perspective I want to make it easy for site editors to keep track of what's featured (these users are new to web publishing) so it'd be great if there was a limit on the number of nodes that can be "featured".

Any thoughts are appreciated! Thanks!


texts: Views 3: filter nodes such that an entity reference on the node corresponds to the current user

texts:
I'm creating an approval/review workflow with notifications.
The content type we're reviewing is called a "Scholarship", and the first review is being carried out by an Intern (interns are a role in my permissions schema).
The Scholarship type has an entity reference to a user, of type "intern", which an admin can assign.

I need to create a view for each Intern such that she sees a list of the Scholarships that are assigned to her, in other words all Scholarships where the entity reference field "Intern reviewer" is the same as the logged-in user.

I've got a page display that correctly returns the title of each of my Scholarship nodes. I've created an relationship with the entity that's referenced in the ER field, so as to connect with the assigned intern. I then created a Contextual Filter on the "Intern Reviewer" field, set it to provide a default value, and selected the UID of the current user as that value.

Unfortunately this isn't returning any results. Methinks this may have to do with the fact that what's stored in the ER field is the Intern's username, whereas the contextual filter is using the UID of the logged-in user. Perhaps I need to find a way to provide the current logged-in user's login name as the fixed filter value?  In any case, if anyone has any ideas I'd be grateful to hear them.


texts: How can I install a beta version of a module?

texts:
Now, a good amount of modules do not yet have a stable version, for example, webform. composer require drupal/webform says:

  Could not find package drupal/webform at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

If I try composer require --minimum-stability=beta drupal/webform, I get:

  The "--minimum-stability" option does not exist.

drush dl gives:

  This codebase is assembled with Composer instead of Drush. Use composer update and composer require instead of drush pm-updatecode and drush pm-download.

Note that due to the special versioning of Drupal this is not a generic composer question but a Drupal specific one. Ie. webform today is 8.x-5.0-beta12, how do I install the latest in the 8.x-5.0 series...? Now, composer doesn't understand or use 8.x-5.0 but uses somethting else, but what and how does that work for betas? This needs documentation somewhere because it currently does not exist. I would be the happiest person if this didn't need an answer, but alas, despite having perfectly fine working tools to build sites, with Drupal 8 we need to use composer and most modules are in beta.


texts: Commerce framework: How on earth do I offer recurring license subscriptions?

texts:
I'm new to the Commerce framework. My goal is to sell licenses to users (via the commerce_license module). Purchasing a license should grant the user a particular role for the duration of the license.
I need to offer the license in four different versions, described below. I'm struggling to figure out how to accomplish this:

License is good for one year; does not auto-renew ($99/year)
License is good for one year; auto-renews each year (via the commerce_recurring module) ($89/year)
License is good for one month; does not auto-renew ($9.99/month)
License is good for one month; auto-renews each month ($8.99/month)

Can someone please explain to me how to implement this, in straightforward, step-by-step terms? What product types, product variation types, products, product attributes, order types, order item types, etc. do I need to create – and how should they be configured?
(My main problem is that I really don't understand the relationships between these various objects. I've read the docs. I've watched tutorial videos. I've scrutinized ERDs. I've spent hours experimenting in the Drupal dashboard. I've tried to read the code – but it's too convoluted for me. Maybe I'm dumb, but the Commerce framework is extremely confusing and counterintuitive.)
I would prefer to avoid any custom code – I just need the simplest solution that will satisfy the above requirements.
Any guidance ?


texts: Supplying current URL to "Path override" in Panels with Views pane

texts:
Sorry if this is a known bug but I searched and couldn't find a related issue.

I have a view which has a "Feed" display (xml), and a "Views Pane" display.

On the "Feed" display the supplied path/URL for the display is "feed/xml".

The "Views Pane" display has a contextual filter for "Taxonomy term" and also a pager that has "Expose the Items Per Page" set to on.

Now when the "Views Pane" is included in a Panel, the Contextual Filter value (term id) is supplied from the Panel context (Node being viewed: term field on node). So now when you view the panel page and try to change the Items Per Page exposed form, it tries to submit the form to the "Feed" display's path which is "feed/xml" and that's wrong. Ideally the #action of the exposed form should be submitting to the current URL.

So I went back to the view and edited the "Views Pane" display, opened to "Allowed settings" and set "Path override" to on. And then went to the Panel config, and I put %node:url as the "Path override".

All well and good so far, but now when I view the Panel page and look at the exposed form's #action its the correct url BUT with added extra parameter which is the Contextual Filter's taxonomy term id. For example: if my current page is path/to/my/page then the #action of the form is path/to/my/page/115 where 115 is the ID of the taxonomy term currently supplied to the views pane through the panel context. So submitting the form produces a 404 in this case.

What I've tried so far is:
- Preprocessing the panel pane (theme_preproces_panel_pane) which didn't help a great deal as the view was already rendered as HTML in the content key of the $variables array. At this point I realized preprocessing theme functions won't work.
- So I moved on to Views hooks and tried hook_views_pre_render. dpm-ing the $view from this hook, I can see that $view->override_path (string) is the correct URL (without the extra term id), but the exposed form was also already rendered here in $view->exposed_widgets (string, rendered HTML) with the wrong URL (with extra term id).

So before I go through all Views hooks, and maybe not even come up with a solution, I wanted to ask this question, if anyone knows when exactly this exposed form is being rendered OR how I can stop the Taxonomy Term ID from being attached to %node:url token (Perhaps a simple configuration that I've missed or.. ?).

Edit

So I went through all the Views hooks. Also implemented a hook_form_views_exposed_form_alter. From the order the dpm's are being outputted, it looks like the order of execution is:

hook_views_pre_build
Exposed form gets built (dpm of hook_form_views_exposed_form_alter)
hook_views_post_build
hook_views_pre_execute
hook_views_post_execute

In hook_views_pre_build the path_override is correct. Form is not rendered yet.

In hook_views_exposed_form_alter the form render array is built, and $form['#action'] shows the wrong path with the extra term id.

So I need to somehow get in between these 2 functions and supply the correct #action...


texts: Adding a CDN asset to drupal theme via info file

texts:
Just as the title suggests...I tried using an absolute path:

stylesheets[all][] = 'http://fonts.googleapis.com/css?family=Lato:300,400,700,900'

This doesn't work...how do I add this to a theme?


texts: What is the difference between _form_validate vs form_validate?

texts:
I'm unsure which one you should use for a form_validation.

Seeing that _form_validate() starts with a _ makes it a private function following the Drupal coding standards if I'm not mistaken.

So my guess is that a form validation should be done with hook_validate().

But the question remains: what's the difference between the two and where should they be used?

EDIT:
I misunderstood the hook_validate() which is not the _validate "hook" used in the form API. I'll leave the question unchanged so other users can learn from my mistake.


texts: How to use hook_prepare to modify a field of a node before it is edited

texts:
I want to modify the contents of a field of an Article node just before it comes up for editing. I have read the documentation at http://api.hostdog.gr/api/drupal-8/drupal%21core%21modules%21node%21node.api.php/function/hook_prepare/8, which states that hook_prepare will "Act on a node object about to be shown on the add/edit form." I've read lots of other stuff too.

I've tried lots of ways of naming the function:

MyModule_article_prepare()
MyModule_article_node_prepare()
MyModule_prepare_article()
MyModule_prepare_node_article()
and on and on

But the function is never called. I've tried putting these functions in both the MyModule.module file and in the MyTheme.theme file. I've read countless posts. Nothing has caused my function to be invoked (I output to the error log to tell it got called).

I simply want to look at one field in the node and possibly modify it just before it comes up in the add/edit form for the user to edit it. I feel really dumb; this has got to be dead simple and I'm just not getting it.


texts:
I installed the Smiley module for drupal 7.
Filtered enabled smileys for plan text format.

I want to enable the smile in the comments field where the body of the comments is a plain text.


texts:
In Drupal 8, I have a content type, that has an "entity_reference" field and I wish to access the referenced node's fields in twig template.
the kint() output for the field is:

In this list I can't find the referenced node's field values. How can I (if at all possible) load the node or node fields/values in twig?

Best,

Alari


texts: How do I access a taxonomy term's field(s)?

texts: Specifically, I'm trying to access a field called 'logo' inside of a couple taxonomy terms (Tweet and Wikipedia edit), which is an image. I have a news feed on the front page of my site, and for each feed item that has a term reference to one of these image beside each feed item in the feed. What would be the best way to go about exposing or accessing the logo field from each taxonomy term?


texts: How can I force a view page not to be cached?

texts:
I created a few views which I use as JSON endpoints for a client application. However, they are not refreshed along with the content they serve.

What I have tried with no success:

Setting Caching to none (within the View page).
Disabled Views cache, (in Views' advanced settings).
Running drush cache-rebuild as a cronjob every 12h.

I know I can use a workaround like /api/my-endpoint?time=1234, but this is not an option for me, since I have no access to the consuming client's code anymore. Neither I plan to recreate all these endpoints in custom code.

How can I force a JSON view page not to be cached?


texts: "Add another item" using #ajax in hook_field_widget_form

texts:
I'm trying to create a custom widget for my module which will contain a textfield to hold a question(textfield), Question style (select box), potential answers (typed into textarea).

I'd then like an "add another item" button so the client can add as many questions as they like.

I've got a basic ajax widget working but i'm not sure if I've constructed it correctly because when I want to validate the data in hook_field_validate I don't seem to be able to access each question seperately.

I thought i'd be able to validate each question before the next is added by ajax but this doesn't seem to be working.

Asssuming this code (below) is correct, can you please advise how I can validate each time the "add another item" is clicked.

My hook_field_widget_form looks like this:

    function keep_warm_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  $element['question_wrapper'] = array(
    '#type' => 'fieldset',
    '#title' => t('Questions'),
    // Set up the wrapper so that AJAX will be able to replace the fieldset.
    '#prefix' => '
',
    '#suffix' => '
',
  );

  if (empty($form_state['num_names'])) {
    $form_state['num_names'] = 1;
  }
  for ($i = 0; $i < $form_state['num_names']; $i++) {

    //other form elements
    $element['question_wrapper'][$i]['question'] = array(
      '#type' => 'textfield',
      '#title' => t('Question number '. $form_state['num_names']),

    );

  }

  $element['question_wrapper']['add_question'] = array(
    '#type' => 'submit',
    '#value' => t('Add another question'),
    '#submit' => array('ajax_example_add_more_add_one'),
    // See the examples in ajax_example.module for more details on the
    // properties of #ajax.
    '#ajax' => array(
      'callback' => 'ajax_example_add_more_callback',
      'wrapper' => 'names-fieldset-wrapper',
    ),
  );
  if ($form_state['num_names'] > 1) {
    $element['question_wrapper']['remove_name'] = array(
      '#type' => 'submit',
      '#value' => t('Remove one'),
      '#submit' => array('ajax_example_add_more_remove_one'),
      '#ajax' => array(
        'callback' => 'ajax_example_add_more_callback',
        'wrapper' => 'names-fieldset-wrapper',
      ),
    );
  }

return $element;
}

And my ajax callback

function ajax_example_add_more_callback($form, $form_state) {
  $form_state['num_names']++;
  return $form['field_question'];
}


texts: How to display the number of contents of a node?

texts:
We have a property site that we use to categorize our listings. I would like to know how to make each category show the number of content it has e.g. Sales(45), Lettings(20), etc.

Any help about how to do this? I am new to Drupal.


texts:
How can I lay out blocks or paragraphs using Bootstrap's grid system? I found this seven-year-old answer and am hoping things have evolved since then, and if so would like to know how.

My best stab at cobbling together something at this point is to use Paragraphs for the content and use the Block Class module to assign the desired Bootstrap class to each paragraph type. Is there a more obvious and cleaner solution to the problem in Drupal 8?


texts: Decorating current_route_match service inexplicably causes fatal errors in webforms (and possibly elsewhere)

texts:
When decorating the current_route_match service I'm seeing issues with various webform requests (either fatal errors or ajax responses making no changes) when navigating past page two of a multi-page form and in some other areas. Based on my debugging this may be more of a general form issue than a webform issue as it seems to be caused by the form display missing from the form storage in Drupal\Core\Entity\ContentEntityForm::getEditedFieldNames(). Disabling caching by altering forms mitigates it but does not completely remove it.
It is the act of decorating the service that causes the problem, not any override of functionality. The issue occurs even if the decorated service supplies the exact same class. E.g. the issue will be caused by a module consisting of nothing but an .info.yml file and a services file as follows:
services:
  decorator_test.route_match:
    class: Drupal\Core\Routing\CurrentRouteMatch
    decorates: current_route_match
    decoration_priority: 0
    public: false
    arguments:
      - '@request_stack'

I'm pretty stumped on this. Why would this possibly be happening? Or how could I even go about debugging something like this?


texts: Why is my block not showing up on the Blocks page?

texts:
I don't remember where exactly my return needs to be.  It had worked at one point, but stopped at a random time.  Google'd and didn't find my answer.

function bobby_name_generator_block_view($delta = '') {
  switch ($delta) {
    case 'bobby_name_generator':
      $block['subject'] = t('Generate Bobby Name');
      if(user_access('access content')) {
        $block['content'] = drupal_get_form('bobby_name_generator_form'); // insert bobbyname variable here!
      }
      return $block;
  }
}


texts: Embed view and set filter from CCK field

texts:
I created a view with 3 filters. I embedded the view in my tpl.php file for the content type. My question is, how can I set some filter with the value from a CCK field?

This is the code I use:

$view = views_get_view('view_name');
$view->set_display('default');
$view->filters[2]['value'] = $node->field_name[0]['value'];
if (!empty($view)) {
    print $view->execute_display($display_id , $view_args);
}


texts: Using Date Popup widget with custom format Date field

texts:
I need to save a date in a very specific format: (2013-03-09\T17:01:34.1\Z to be precise).

I also need to allow users to edit this date after it's been saved.

I want to use the Date Popup submodule of Date to allow users to enter dates. However, it doesn't seem to support custom formats. When I enable Date Popup, I see that I lose seconds granularity, and I can no longer use custom formats at all.

Is there a way to use custom formats with Date Popup? If not, is there a recommended way of adding a popup calendar to my date field in a way that will generate dates in my custom format? Does anyone know why the developer of Date made Date Popup incompatible with custom formats?


texts: How to create front page for every language?

texts:
My goal is to have three front page versions per language. Browser language detection is enabled. Front page is correctly rendered with a language according to Accept-Language, but there is no language indicator in URL, example: host.com/it.

Have I missed something in configuration or I have to do this feature (redirect) programmatically (or Rules) ?


texts: How to noindex comment/reply in Drupal 7

texts:
I use Drupal 7, and I am trying to use the "noindex" meta tag to prevent http://example.com/comment/reply/43/738 from being indexed by search engines.

The comment/reply page is being indexed, even though I've used the following role in robots.txt:

Disallow: /comment/reply/

In which template file will I need to incorporate "noindex" meta tag for /comment/reply/ pages?


texts: The username has not been activated or is blocked. using custom login form

texts:
In my module tpl file I'm calling

<?php print drupal_render(drupal_get_form('mymodule_login_form')); ?>

Then in my .module file I have this function:

function mymodule_login_form($form, &$form_state){
  $form = drupal_get_form('user_login');
  return $form;
}

So the user_login form gets called and shows up but when I try to use it ( submit it ) I'm always getting the error message: 'The username has not been activated or is blocked.'

When I change the tpl file to:
<?php print drupal_render(drupal_get_form('user_login')); ?> it works and giving the correct error messages or logs the user in.

The problem with this is that I'm using it in a popup screen and want to display the error messages in the popup screen using ajax. So I need to alter the user_login form. I know how to do that but I'm not getting past the error message 'The username has not been activated or is blocked.'


texts: Alter default value for field settings (allowed_formats)

texts:
Please how can I alter the default field settings whenever a new field is added?

NB I am not asking how to set the default whenever a new entity is added.  This is about changing the pre-populated values on the page "Administration->Structure->Content types->XXX->Manage fields->Add field when a field is added"

NB This question is for D8.  In D7 the answer is to use hook_field_info_alter.

Specifically I am using the module allowed_formats, and I would like every new text_with_summary or text_long field to have defaults of:

Allowed formats = "Basic HTML" only
Form display settings "Hide the help link About text formats." and "Hide text format guidelines." enabled.

The defaults need to work even if the new field is created in code.  In particular it's important to work for the Body field that is created automatically on a new content type.

I'm struggling because looking at the code, the defaults come from the public static function TextWithSummaryItem::defaultFieldSettings and there doesn't seem to be any hook.


texts: Getting Feed Aggregator to ignore certain incoming data

texts:
EDIT: So originally I posted the below, but I've found other issues and I have some more information. I noticed today that sometimes the links are wrong as well but correct when I view the feed. I looked at the XML being sent by the feed we're bringing in and for one thing, the extra timestamp is being sent in a tag called <updated>. I'm not sure why it's being appended to the body text though. Similarly, other tags are being interpreted/appended in such a way as to mess up some other things.

So my new question is: is there any way to have more control over how feed aggregator is arranging this incoming stuff? I want to get rid of that stuff from <updated> and a couple of other tags and tell it to link the header with the appropriate link (right now it doesn't always do that).

Previous Post text:

In Drupal 7 I've got a view to show some news items that another developer set up through aggregator. The fields are Link, Title, Timestamp, and Body (although Link is hidden; long story that doesn't seem to affect this). Everything looks good except there's an extra timestamp at the end of the body text. Here's an example:

  Orange County (CA) Register SEILER: Legislature could ignite rush to smuggle cigarettes

  Wednesday, August 19, 2015 - 11:19

  But higher taxes here would push us in the direction of New York City, meaning more smuggling, more crime and less policing... California already has the nation’s second-lowest rate of tobacco use, after Utah. It should leave higher taxes and other nann 2015-08-19T15:19:16+0000

The '2015-08-19T15:19:16+0000' is what I want to get rid of. I have looked all around but I'm not able to figure out what's causing this. I thought maybe it had something to do with the feed we're using but I looked at the link (http://www.tobacco.org/tagged/new-york.atom) and it doesn't seem to include this.

I'm fairly new to Drupal but I did try to figure this out on my own and I'm at a loss. After extensive Googling I can't even find another example of this happening so I know I'm missing something. Any help is greatly appreciated; thanks.


texts: How can I make required cck date field "not required" by hook_form_alter?

texts:
I could make some requited cck fields "not required"  by hook_form_alter a below but this doesn't work for date field.

for selection type

function hook_form_alter(&$form, &$form_state, $form_id) {
$form['field_smaple_1']['#required'] = 0;
}

or

for text are type

function hook_form_alter(&$form, &$form_state, $form_id) {
$form['field_sample_2']['0']['#required'] = '';
}

How can I do the same thing for date field?


texts: Force a page to be rendered in admin theme

texts:
In drupal 7 we could force a page to open in admin page, there are several way to do that in drupal 7

with hook_admin_paths

function hook_admin_paths() {
  $paths = array(
    'mymodule//add' => TRUE,
    'mymodule//edit' => TRUE,
  );
  return $paths;
}
with Admin theme module
with ThemeKeys module

Now I am looking for equivalent solution in Drupal 8, How can I force drupal to render a specified pages as admin theme?


texts:
For a project I need to register new customers. That customer belongs to a store chain, and that store chain is connected with a store.

I only want to display the store's which are linked to the storechain on the add people page.

What is the best way to fix this? Conditional fields module doesn't work for this :(

Thanks in advance!


texts: How to copy field value into another field by its node ID?

texts:
I have a document that goes through 3 phases.  Each phase is its own content type because each phase brings in new questions and structure built upon the previous phase.

I want the below to happen when a user is adding new content for phase 2 & 3:

User is asked for node ID of previous document in phase 1
Field values from that previous node is retrieved and imported automatically into the new content's fields.

Are there any existing modules that can do this?  Maybe the Rules module?


texts: How to remove form validation in D8 under certain conditions?

texts:
I'm trying to save a node as a draft, but only if we are saving as a draft (Workbench Moderation). Otherwise, validation should be run as normal.

The user must be allowed to save a node in any state, including empty values in required fields.

Should I instead be setting all fields as not required and adding my own validation function?


texts: Making rules refresh page when message after one has time to read the message?

texts:
Issue:
I added a message that should be displayed upon user login using rules. It worked fine only that
 1. The page stuck (showing the message) and you had to refresh and click okay to discarding information upon reload.
 2. The page did refresh but did so immediately so that one did not have more than a split-second to view the message.

Question:
How do you make rules display the system for, say, 5 seconds and then refresh the page? A mixture between the two possible scenarios described above.


texts: How can I merge a content type's fields and settings from dev to staging?

texts:
I have an existing content type on staging. On dev we've added a ton of new fields and display and form setting changes, etc.
It's not practical to go through the config files and find all of the many dozens if not hundreds of interconnected config files related to the content types, its fields and its settings.
So I heard Features is the way to go (even though I thought config sync in D8 was supposed to make Features not needed anymore).
So I've created my Feature. Keeping it simple I just checked the single content type. Saved my feature module and moved it to staging.
When I try to enable to the module I get a screen full of "unable to install" because the configuration already exists errors. Ugg.
So I read that I should remove the configurations. But this removes content and/or associated configurations like vocabularies.
Surely there must be a practical way to merge a content type from dev to staging?


texts: URLs aren't working after site migration

texts:
My problem is two fold:

After migrating my site, many of the URLs aren't working, and producing 404 errors. But the main landing page is working, and so are most/all of the features on the main page.
My configuration for custom 404 error pages are being ignored, and were working before copying the root of the web server files over. This I'm not so worried about.

These are the steps I used to migrate the site:

mysqldump the database from the originating server.
Import the database to the new server, using the same mysql credentials.
Copy the root of the web server files over to the new location.

This is my setup:
CentOS6
nginx
MySQL
php, php-fpm
Drupal 7

The only real difference between the originating server and the target server is that the originating server is centos5.

I am not a drupal expert, but I did some searching and I keep coming across "clean urls". I'm not exactly sure what that is.

Is there a better way to migrate a drupal site, or is there something I did wrong?


texts: Strategy to consolidate multiple fields across content types?

texts:
I've got a handful of content types that all use different fields to hold the same type of data. For instance,

Content Type A --
Field Name: field_type_a_user,
Field type: Entity Reference

Content Type B --
Field Name: field_type_b_user,
Field type: Entity Reference

Content Type C --
Field Name: field_type_c_user,
Field type: Entity Reference

I'm building out a view displaying nodes that might reference any of the three of these content types, and the view needs to display information about the user referenced in the node's user field.

It seems inefficient to be using multiple different fields to be storing the exact same type of data. Is there an efficient way to go about creating a new field, field_user, and moving the data from all of these old fields into the new field? And then update all references throughout the site to use this new field?

Or would it be better to just add all three fields to my new view and call it a day?


texts: List all nodes related to a term which is related to another one

texts:
I searched many times how to list all nodes related to a term which is related to another one, but without success...

Can you help me ?

Actually I want to do something like this:

My page (where a term is defined) <- A term linked to the previous defined one <- The nodes related to this term.

Thank you for the help!


texts:
I'm developing a drupal 7 based website where the user profiles need some modification. Now I need to know how can I re-order tabs in user profile page such as, View, Edit, etc.

i'd like to keep the current tabs, but just reorder them. I'm looking for an easy way to do that.


texts: Drush enable module | not working | Drupal 7 on WAMP with PostgreSQL

texts:
Based on
Drush on windows - Command pm-enable needs a higher bootstrap level to run, i have the following question.

I have the same problem found here https://drupal.org/comment/8533097 except I am using Postgresql and this solution did not work for me.

My Drupal installation is at: C:\SiteData\WebDev\gitproject (aka DrupalRoot). I successfully ran drush status in "[DrupalRoot]\sites\site1.example.com, but when I try to enable a module using drush en ccl and I get the following.

  Command pm-enable needs a higher bootstrap level to run - you will
  need to invoke drush from a more functional Drupal environment to run
  this command. The drush command 'en ccl' could not be executed.
  Drush was not able to start (bootstrap) the Drupal database.

  Hint: This may occur when Drush is trying to:

  bootstrap a site that has not been installed or does not have a  configured database. In this case you can select another site with a
  working database setup by specifying the URI to use with the --uri
  parameter on the command line. See drush topic docs-aliases for
  details.
  connect the database through a socket. The socket file may be wrong or the php-cli  may have no access to it in a jailed shell. See
  http://drupal.org/node/1428638 for details

  Drush was attempting to connect to:

  Drupal version         :  7.26
  Site URI               :  http://site1.example.com
  Database driver        :  pgsql
  Database username      :  user
  Database name          : site1dev
  Default theme          :  garland
  Administration theme   :  garland
  PHP executable         :  php
  PHP configuration      : "C:\Program Files (x86)\Drush\Php\php.ini"
  PHP OS                 :  WINNT
  Drush version          :  6.0
  Drush configuration    :
  Drush alias files      :
  Drupal root            : c:/SiteData/WebDev/gitproject
  Site path              : sites/site1.example.com
  File directory path    : sites/site1.example.com/files

My settings.php file looks like this.

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'site1dev',
      'username' => 'user',
      'password' => 'secretpw',
      'host' => '127.0.0.1',
      'port' => '',
      'driver' => 'pgsql',
      'prefix' => 'dev_',
    ),
  ),
);

if (php_sapi_name() == 'cli') {
  $db_url = 'pgsql://user:secretpw@127.0.0.1/site1dev';
 }
 else {
   $db_url = 'pgsql://user:secretpw@localhost/site1dev';
 }

I have used both the "Drush Command Prompt" and "MINGW32" git command line tool and both work for "drush status" or "drush dl " but not for "drush en "

One last comment.  looking at the settings.php file permissions in MINGW32 they show the unix permissions of -rw-r--r--.. Tried changing this in using chmod but doesn't work on a windows file (not even sure that makes a difference).


texts: How to control resource usage of my website?

texts:
I'm using drupal 6 website and i don't know to check which module or script uses high resource. Below is the graph for my website Resource Usage from my hosting provider. They intimate me to control the usage. Really i don't know how i am going to solve this. And i am in shared hosting.

Any idea ?


texts: HTML tags in a block body are not rendred

texts:
I'm using Drupal 8. I have created a custom installation profile. Inside the profile profileName.install file, I created the following function:

function setupCustomBlocks() {
  $blockContent = BlockContent::create([
        'type' => 'basic',
        'info' => 'Why choose us?',
  ]);
  $blockContent->set('body', '
&nbsp;

Lorem Ipsum is simply dummy text of the printing and typesetting industry.
'
  );
  $blockContent->save();

  $block = Block::create([
        'id' => 'why_choose_us',
        'plugin' => 'block_content:' . $blockContent->uuid(),
        'region' => 'topwidget_first',
        'provider' => 'block_content',
        'weight' => 0,
        'theme' => \Drupal::config('system.theme')->get('default'),
        'visibility' => array(),
        'settings' => [
          'label' => 'Why choose us?',
          'label_display' => TRUE,
        ],
  ]);
  $block->save();
}

The bellow function, allows me to create a custom block when I install the profile. Here is the result:

As you can see, the HTML tags are not rendering. How can fix that?


texts: Some content types don't go through node.html.twig

texts:
I am using Drupal 8 RC1 and run into issue. I upgrade my site from Drupal 8 beta 15 to Drupal 8 RC1.
For Some of my content types page don't get rendered using node.html.twig (node.html.twig not invoked). NO error message and page looks fine.
it actually rendered using blocks and fields.


texts: Can't correctly reference bundle in EntityFieldQuery, field_get_items

texts:
I'm using EntityFieldQuery in an attempt to query for specific field values (dates in an event db) then perform some analysis on them.

I've gotten far enough to correctly query and return specific nodes as a result but am getting stuck on field_get_items - I can't get the actual field values out. It appears I am not passing the necessary parameters of the bundle to the function.

Where am I going wrong?

Drupal throws this error on the last line of code starting w $output
"EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7734 of /home4/xxxxx/public_html/xxxxxx/xxxxxx/includes/common.inc)."

Here's my code:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'event')
  ->propertyCondition('status', 1)
  ->fieldCondition('field_date', 'value', 'NULL', '!=');
$result = $query->execute();

if (isset($result['node'])) {
  $stories = $result['node'];

  // Get all fields attached to a given node type
  $fields = field_info_instances('node', 'event');

  // Get id of body field
  $field_id = $fields['field_date']['field_id'];

   //echo $field_id... testing, works;

  // Attach a field of selected id only to get value for it
echo field_view_field('node', $stories, 'field_date');

  //Get values of our node field
  $output = field_get_items('node', $stories, 'field_date');
}

I get an error on the last step


texts: change block region using template_preprocess_block() not working?

texts:
I'm trying to move a block from the content region to the sidebar region if the page is not the front page. I would think this would be fairly simple. I have the following code:

<?php
    function MYTHEME_preprocess_block(&$variables) {
        if($variables['is_front'] == FALSE) {
            if($variables['block']->bid == 39) {
                $variables['block']->region = 'sidebar';
            }
        }
    }
?>

This doesn't work. I can look at the array dump in Theme Developer and it does say sidebar, but the block isn't actually moved from the content region to the sidebar region when I inspect the rendered HTML.

Any ideas why this isn't working?


texts: Benefit of config entities over regular config entries?

texts:
In Drupal 8 it is possible to store configuration in "config entities".

However, the same can also be achieved with non-entity config entries.

E.g. one example for a config entity schema, from core.entity.schema.yml:

core.entity_view_display.*.*.*:
  type: config_entity
  label: 'Entity display'
  mapping:
    id:
      type: string
      label: 'ID'
    targetEntityType:
      type: string
      label: 'Target entity type'
    bundle:
      type: string
      label: 'Bundle'
    mode:
      type: string
      label: 'View or form mode machine name'
    content:
      type: sequence
      ...
    hidden:
      type: sequence
      ...

The same information could be stored in entries with type: mapping, like so:

core.entity_view_display.*.*.*:
  type: mapping
  label: 'Entity display'
  mapping:
    content:
      type: sequence
      ...
    hidden:
      type: sequence
      ...

In fact, we would not even have to store the 'targetEntityType', 'bundle' and 'mode' as properties, because these are already part of the key (the asterisks in the schema key). We could also omit the 'id', because the key is already a unique identifier, making the id redundant.

Obviously, one would not use entity crud components to deal with those config entries, but call directly the config API, e.g. \Drupal::configFactory->get(..).

Also, one would not inherit from EntityForm, but have custom form classes. But it seems all doable.

Question

So: What would we miss by not using config entities? In which cases would a simple "mapping" be sufficient?

To stick with the example: What can we currently do with 'entity_view_display' entities, that would not be possible if these were just 'mapping' entries?

Background / Use case

My original use case was this one: Custom entries in entity view modes?, which came up when I wanted to port entdispfieldui to Drupal 8.

This question was very specific, so I wanted to ask a more general question about the benefits of config entities.

In this case I decided to use non-entity config entries. One reason was that config entities caused recursion in hook_entity_extra_field_info().

I am going to port more modules to Drupal 8, where the same question will come up, but where I don't have to worry about hook_entity_extra_field_info(). E.g. cfrpreset.


texts: What is the default value for $operator in condition()?

texts:
Looking at the documentation for QueryConditionInterface::condition(), the default value for $operation is reported to be NULL, while Conditional clauses reports the default value is '='.

What is the default value?
Does it change basing on the datatype of $value? For example, when $value is an array, then the default value is 'IN'; when it's a string or an integer, then the default value is '='.


texts: Field Relation Between Content Types and Some Questions

texts:
I have two content types (Movies and Actors), both with picture and name fields.

In Movies I have a field collection with two fields: name and character. This name field is a node reference to Actors content type. I created a view block for the Movies nodes which lists the cast (a list of Actors nodes).

What I want is the actor's pictures. The picture is automatically added to the Movies nodes; I would want the same for my block.


texts: Need webform with list of items, price, and total

texts:
Not sure that webform can do this, BUT my client sells yachts. They want a webform on the site that lists all of the boat options (a check-list) a potential customer might like to have and creates a subtotal at the bottom of the list as the customer checks items on the list.

The way it works: A visitor is interested in buying a boat so they go through the list and check(box) the item/s they want, and as they check the items a subtotal is calculated at the bottom of the list. Then the webform is submitted to the company sales to someone that will contact the potential customer to continue the sales effort.

This should be something like a spreadsheet, but the list cannot be changed (only the checkbox next to each item). The subtotal is affected only by the items on the list that are checked.

This might better be done by something like ubercart, but seems ubercart would be overkill.

Does anyone have ideas how this could be done (or if it cannot) with webforms, OR if there is a better way, please?

cFusch


texts: Access denied trying to edit node that I own

texts:
In an administrator account using the administrator panel i can create and edit content from content type Country. But when they are created from a script, and even if i own them, i can't edit if their origin is said script. I get the message "You are not authorized to access this page."
Already checked permissions (Admin can edit own content and any content) and rebuild them.
How country is created in code:
        $new_country = new stdClass();
        $new_country->type = "country_profile";
        $new_country->title = $country;
        $new_country->language = LANGUAGE;
        global $user;
        $new_country->uid = $user->uid;
        node_object_prepare($new_country);
        $new_country = node_submit($new_country);

        node_save($new_country);
        $new_country->status = NODE_PUBLISHED;
        node_save($new_country);
        $country_wrapper = entity_metadata_wrapper('node', $new_country);


texts: I've added the "rate" module to my project. I've added multiple axes to rate but they display below my node content. How would I be able to style this? I know how to create a custom .tpl file for my content type but the module adds code AFTER my template. How I can fix this?


texts:
I need to schedule a Push Notification, as in the push notifications module, every predefined set of time (e.g. every week). Looked into the Rules module, but could not find a way to program a rule based on time.

Is there a way to do this?


texts: How to use curly braces in schema default value?

texts:
I have a long varchar field that I'm using to save serialised data with drupal_write_record. I'd like to set the default value of the column to "a:0:{}" (which is serialize(array())).

However, when Drupal runs database updates, they are run through the update_sql() function which includes the default value in the query. This means that the '{' and '}' are interpreted as prefixing table names and removed, leaving the actual value of "a:0:" in the database, which is not what I want.

Is there a way to use curly braces in a field spec's "default" value?


texts: Pager should start from last page instead of first one

texts:
I have a block view including pager and shown on front page. when I go to front page I see the pager under block shown in normal way(ie start from first page). But I want that pager start from last page instead of first one.

Result of My View:

Result that I want:

I want that when I visit my view, it's pager should look like this


texts: How to keep in sync git repository and related htdocs directory?

texts:
I use the following set up for my @dev site:

(a) ../git/repository/dev

where I keep version control using git,

and a separate

(b) ../htdocs/dev

that I have an almost exact copy of  git repositor (a) used by the http server

How to make sure git repository (a) is always in sync with http (b) ?

I don't want to version control (b) directly from various reasons.


texts: Unset the "please wait" in drupal commerce

texts:
I've got a product with different taxonomy like "S" "M" "L".
When you change the size in the display product, it shows the ajax div
"Please wait..."
I've tried

function bartik_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
unset($form['attributes']['field_size']['#ajax']['progress']['message']);
}

If I have a look at it with dms($form) I see attributes -> field_size -> #ajax -> callback(commerce_cart_add_to_cart_form_attributes_refresh)

There is not message. How can I get rid of it?

Thanks in advance.


texts: How can I update a node with RESTful Web Services API

texts:
I am able to create nodes no problem using this code but I can't seem to be able to update nodes (PUT) using the RESTful Web Services Module.  I'm pretty much am using the same code as I found on this page.

$crl = curl_init();
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_USERAGENT, 'PHP script');
curl_setopt($crl, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
curl_setopt($crl, CURLOPT_COOKIEFILE, '/tmp/cookie.txt');

// Login.
curl_setopt($crl, CURLOPT_URL,"//" . $site . "/user/login");
curl_setopt($crl, CURLOPT_POST, TRUE);
curl_setopt($crl, CURLOPT_POSTFIELDS, "name=" . $user . "&pass=" . $pass . "&form_id=user_login");
curl_setopt($crl, CURLOPT_COOKIE, session_name() . '=' . session_id());
$ret = new stdClass;
$ret->response = curl_exec($crl);
$ret->error = curl_error($crl);
$ret->info = curl_getinfo($crl);

// Get RESTWS token.
curl_setopt($crl, CURLOPT_HTTPGET, TRUE);
curl_setopt($crl, CURLOPT_URL, 'http://' . $site . '/restws/session/token');
$ret = new stdClass;
$ret->response = curl_exec($crl);
$ret->error = curl_error($crl);
$ret->info = curl_getinfo($crl);
$token = $ret->response;

if ($source_node_id) {
  curl_setopt($crl, CURLOPT_POST, FALSE);
  curl_setopt($crl, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($crl, CURLOPT_URL, 'http://' . $site . '/node/' . $source_node_id);
}
else {
  curl_setopt($crl, CURLOPT_POST, TRUE);
  curl_setopt($crl, CURLOPT_URL, 'http://' . $site . '/node');
}

curl_setopt($crl, CURLOPT_HTTPGET, FALSE);
curl_setopt($crl, CURLOPT_POSTFIELDS, json_encode($node));
curl_setopt($crl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-CSRF-Token: ' . $token));
$ret = new stdClass;
$ret->response = curl_exec($crl);
$ret->error = curl_error($crl);
$ret->info = curl_getinfo($crl);

curl_close($crl);
unset($crl);

return json_decode($ret->response);

Anyone have any suggestion why the node update isn't working?


texts:
I want to print the site name in a custom template (page--front.html.twig)

{{ site_name }} does not work.

If I use {{ page['#title'] }} I only get "Welcome to [site_name]".

I'm looking for a way to only print the site_name. Do anyone know how to achieve this?

Thanks!


texts:
I have Drupal server with a REST API using services and rest_server (that's just background, I don't THINK that applies to this problem at all.) I'd like particular API calls to only report back that the request was received, but then go on to do further work in PHP.

To me, this seems like a thread/fork solution, but I can't seem to find a viable solution using PHP/Drupal. The first (and from the looks of it, easiest) thing I came across was the pcntl_fork() function. But, as it looks like that's not viable:

  It is not possible to use the function 'pcntl_fork' when PHP is used
  as Apache module. You can only use pcntl_fork in CGI mode or from
  command-line.

  Using this function will result in: 'Fatal error: Call to undefined
  function: pcntl_fork()'

(And, indeed, when I try using function_exists() through command line, it's there, but when run in PHP through Drupal it says function is undefined. I'm reading some stuff on how to install it/recompile PHP with it, but would prefer if there were a method that didn't involve changes to the server.)

Other than that, I'm coming across solutions such as creating a queue to run with cron jobs, creating convoluted menu items, or a whole background processes... thing. All I want is for some arbitrary code to be run off on its own. Does anyone have a suggestion that they feel works best with with Drupal?

(Also, I don't know what to tag this as--I tried thread or asynchronous but those don't seem to exist--so feel free to tag.)


texts: Why all dates columns in drupal are type=int and not type=date/timestamp/time?

texts:
I want to make this question short, so as title says "Why all dates in drupal are INT" ?

I've notice that in Schema API there was "datetime" but it was removed in D7.
Also all tables that have time in it (cache_*,semaphore,node etc.) have INT instead of TIMESTAMP.

Before debating "INT vs TIMESTAMP" flame, I would like to remind you that:

DATETIME is obvious what the value represents.
INT is smaller
TIMESTAMP has both advantages.

The thing is that I want to understand what's "philosophy of drupal" for this.


texts:
Is there a Drupal module that can create a content type from an SQL Query or a CSV file?

I am looking for a module which can carry out the process itself, at least based on simple types like strings, dates, floats, and integers, something that can use an SQL table definition to create it.

Another option is one that provides a form similar to the table creation dialogs in database applications like SQLite Manager or Microsoft Access, where you specify the name of the field, the size and the type and  the system goes off to carry out the task.


texts: Drush suddenly stopped working for one site

texts:
I have a bunch of sites on my local machine and have been using Drush (v5.4) happily for a long time to administer them.

All of a sudden, with no changes made to one such site, Drush reports these errors:

  Command pm-disable needs a higher bootstrap level to run - you
  will need invoke drush from a more functional Drupal environment
  to run this command.

  The drush command 'dis addthis' could not be executed.

  Drush was not able to start (bootstrap) the Drupal database.
  Hint: This error often occurs when Drush is trying to bootstrap a
  site that has not been installed or does not have a configured
  database.

Needless to say the site in question is running fine on the local machine with no errors (and is completely installed). Drush works fine for every other site on the machine.

What can cause Drush to suddenly misbehave like this for one particular site?


texts: Restrict Users from creating + editing higher level accounts, but still able to create + edit lower level accounts

texts:
I'm trying to restrict the permissions of a custom user role so that they can create, edit and delete lower level accounts, but not have any access to create or edit Administrator accounts.

I've already tried Administer Users by Role and User Protect, but neither of these provide the functionality I need.

User protect allows me to lock down my Admin account, but a lower level user can still create an administrator account if they want. Administer Users By Role features an permission for 'Create new users', but no permission to restrict the level of user each role can create.

What I need is for a Sub-admin to be able to create and edit sub-admin accounts, but not create or edit Administrator accounts. Is there any way to achieve this?


texts: I'm trying to get all duplicate rows using db_select

texts:
Before I run db_delete, I'm trying to run db_select to test that I am getting all duplicate rows, based on a specific column value.

db_select('node_revision', 'n')
    ->where('n.nid NOT IN SELECT MIN(n.nid)')
    ->groupBy('hash')
    ->execute()
    ->fetchAll();

Basically, delete (select for the test) all rows with the same hash value, except for the first one, is my goal.

I'm basing it on this page:

http://blog.sqlauthority.com/2007/03/01/sql-server-delete-duplicate-records-rows/

But for some reason I get the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM node_revision n WHERE (n.nid NOT IN SELECT MIN(nid)) GROUP BY hash' at line 1: SELECT FROM {node_revision} n WHERE (n.nid NOT IN SELECT MIN(nid)) GROUP BY hash; Array ( ) in include()

What am I doing wrong? Why is ; array ( ) there?


texts: How to add a condition (rule) to skip questions when using the Quiz module?

texts:
I'm using Quiz module and I have a quiz with questions 1 to 10.

I want this:

Question 1: If answer is yes jump to question 2. If answer is no jump to question 7.

How can I achieve this? Do I need to use Rules module?


texts: How to save term with term references programmatically?

texts:
I've got a list of terms which I need to add or update programmatically based on their name.

To check if the term exists I'm using a combination of taxonomy_vocabulary_machine_name_load to get the vid and taxonomy_get_term_by_name to get the term if exists. Otherwise I'm creating the term as stdClass object.

When I save the term normal field (using taxonomy_term_save) in format like $term->field_address[$term->language][]['value'] = 'some address data' everything works just fine, but when it comes to save relations nothing is begin saved.

I'm saving relations as $term->field_realization[$term->language][] = array( 'target_type' => 'taxonomy_term', 'value' => $another_term->tid);.

Where $term->language = 'und'; and $another_term is a term which belongs to right field Vocabulary declared in Administer.

What am I doing wrong?


texts: Where is a UI-configured Views display definition read from?

texts:
General question: In Views 3, on Drupal 7, when a View display in configured using Views UI, what is the location where the configuration is 'read' and applied when...:

...creating a query to generate a page?
...loading its Views UI page (I believe this is the table views_display)?

Background / why asking: I've encountered a very strange problem where (despite repeatedly clearing all caches including Views cache and even disabling Views caching in Views advanced settings), the output a view generates in situ in a panel / block on the page doesn't match the rules shown for it on editting it in Views UI.

Edit: Actually, looks like they are both coming from the same place but the two displays got merged and became non-overridden in a strange way. I'll keep this open as I'd like to know for sure where these are stored in the DB for future reference anyway.

It's a dev environment with no memcache / memcached / boost etc - no additional layers of caching.

There's one existing question where someone finds Views UI somehow 'loses' the override settings for a views display, but it's not related to my case: there's nothing on my general question, the cause doesn't apply in my case, and none of the suggestions there help. There's also a question which includes my general question on drupal.org but none of the replies answer my question.


texts: Change 'Administration theme' not working - still shows current theme for administrative tasks

texts:
I have a custom theme that works fine. I want to use D7's 'Seven' theme for administration. However, despite it being chosen already, Drupal uses my custom theme for administration and editing.

If I change themes to a Drupal default theme like Bartik, then, I can change the administration theme to whatever I want, even my custom theme, and everything works as expected.

This tells me I have something wrong with my theme.  What am I missing? Are there any default drupal theme variables that I need to include to make sure that the overlay theme is indeed Seven (or whatever I choose).  What could be causing my theme to disregard my Administration Theme choice and use my custom theme regardless of the setting?

note: I am trying to give 'overlay' permissions to others and want them to use the Seven theme.  I forgot to mention that this works fine if I am logged in as Admin (user 1) but everyone else gets the custom theme for admin regardless of what I choose.


texts:
I have a widget that allows the user to book and pay on a site. I used:

function capewinefarms_preprocess(&$variables, $hook)

And ended up with something like this:

$variables['book_now_widget'] = '
bla bla bla
';

Which I then output in the template using:

{{ book_now_widget }}

The problem is that instead of seeing:

 bla bla bla

in bold text, i see:

bla bla bla

Because the widget is "self-contained", it needs all the javascript and html and everything to be outputted exactly as is, and not be formatted. It seems twig is somehow doing this.

Any idea as to how to get around this? Or any insight into why this is happening? Or perhaps an even better question might be: how do I do this the most correct way?

I suppose I can do it as a block, but then I would have to attached a JS file, and I can't do this, because it all needs to be self contained as it is also re-used on a mobile app.

Any ideas?


texts: How to alter a field within an unlimited field collection?

texts:
I am trying to set the #access attribute to FALSE on a field that is within an unlimited field collection - so it is hidden from users. I am relatively new to Drupal so I'm not sure how to handle this. I tried to use hook_form_alter and some basic CSS - but I couldn't get either of the solution to work properly because of the unlimited field cardinality.

Here's what worked for one row in the field collection in a custom module:

$form['field_my_field_collection']['und'][0]['field_myfield']['#access'] = FALSE;

How do you alter a specific field in a field collection with unlimited values? Thanks in advance for any help - the Drupal community is awesome.


texts:
How do I display the search term after I have run the search.
Here is my form:
<input data-drupal-selector="edit-search-api-fulltext" id="edit-search-api-fulltext"  placeholder="Keyword" name="search_api_fulltext" value="{{ content.search_api_fulltext }}" class="regular-input" type="text">
<input data-drupal-selector="edit-submit-search" id="edit-submit-search" placeholder="Search" value="Search" class="btn secondary-btn js-form-submit form-submit" type="submit">

The value is not displaying anything, but I can't find an answer to what I should place here.
Before installing Search Api I used {{ content.search_query }} and that displayed the search term after the search was performed using the out-of-the-box Drupal search.


texts: TypeError: $(...).on is not a function $(document).on('click.alert.data-api', dismiss, Alert.prototype.close)

texts:
I have installed a module to use less, so i installed a module less css preprocessor. After enabling this module when i reload my home page i am getting an error and cant able to write any less,

Error Details:

 1."NetworkError: 500 Internal Server Error - http://seat3.nthq-136.com/PPI/Repo/WebSite/sites/default/files/less/5164124a1c0608.63828022/sites/all/themes/ppi/less/style.css?mkzncp" style.css?mkzncp

 2.TypeError: $(...).on is not a function

I have cleared my caches and uninstalled the above module and re installed  for several time but still the error appear .
Where i am doing wrong ?


texts:
I have a custom text field which I use to display some voucher code to users.
I have it in a custom content type named (machine name) : 'add_deal'.

What I want to do is to style the field when the node is displayed and add a link/button next to that field to copy the text in that field.

I created a field--field-type--cotent-type.tpl.php file, but how do I use it, and I dont think its working for me either. Is there any hook function I need to use to make use of that tpl file?

How could I achieve it?


texts: how do I get my module to install a view?

texts:
I have developed a module in a dev environment. I built a view for it using the UI. I've exported the view, but I don't know where to put it so that an installation of the module in a fresh environment will also create the view.

How do I do this properly?

Bonus: how do I have the module uninstall the view on hook_uninstall?


texts:
I want to style my taxonomy tags value. Actually In this Tags accepts comma separated value, so if I am rendering it on page it comes along with the comma.

I want separate values without comma.

How can I do that?


texts: How do I stop losing a fragment of this url when redirected?

texts:
I'm trying to parse callback url, and matching set of params out of a url users are sent to as part of a complex user journey:

Here's the url in question:

https://mysite.org/user/login/idp_sign_up%3FpostbackUrl%3Dhttps%3A//hub.somesite.org.uk%3A443/govuk/register-signin%3FrequestId%3D_ae0b3a45-c878-4033-96f2-2b2428090711

I'm parsing the necessary bits out of this fine, if user is signed in.

My problem occurs when a user isn't signed in, because they're redirected to this url:

https://mysite.org/user/login?destination=/idp_sign_up%3FpostbackUrl%3Dhttps%3A//hub.somesite.org.uk%3A443/register-signin%3FrequestId%3D_ae0b3a45-c878-4033-96f2-2b2428090711

Then they end up at this url, without the crucial %3FrequestId%3D_ae0b3a45-c878-4033-96f2-2b2428090711 fragment:

https://mysite.org/user/login/idp_sign_up%3FpostbackUrl%3Dhttps%3A//hub.somesite.org.uk%3A443/register-signin

How to I ensure I don't lose that fragment if a user isn't logged in?

Is there a relevant hook I can use before the https://mysite.org/user/login?destination process begins?


texts: Is there a safer way to make preprocess changes?

texts: I recently made changes to template and node.tpl files for my theme. Is there a recommended way of implementing preprocess changes as to not hard code them into these files (in case of theme updates) or am I going to have to re-code them after theme udpates?


texts: Programmatically trigger rules action component

texts:
I have some problem in triggering an action component.
I tryed to call it from the module function and from the devel/php page.

This is my component settings

As you can see I have one node argument followed by 4 text arguments.
And i'm trying to call it with this code

$node = node_load( 981 );
$return = rules_invoke_event('rules_send_mail',
    $node,
    'mymail@gmail.com',
    '123',
    'nome',
    'sss' );
print_r( $return );

Nothing is printed on the page.. not an array or a FALSE.
The action simply send and email to client_mail.

Can someone help me to understand why is not working?


texts: How to pass the query string used to access a page in a link in a views content pane?

texts:
On a views content pane that shows a list of taxonomy terms, is there any way to simply rewrite all the term links such that the query string in the URL with which the page was accessed is appended?

I'm using Drupal 7 with Views 3 and Panels 3. I have a views content pane displayed in Panels shows a list of countries.  Clicking a country goes to the country's term page (countries are taxonomy terms), which shows all of the users registered in that country (again via Panels overriding the taxonomy term pages).  These term pages (also made with views and contextual filters) accept query strings for exposed filters such as `?friendship=1'.

What I would like to do is link to the location-based search from other pages on the site and pass values to the term page view via the query string.  However, since I don't know what country the user will want to search, I have to link to the Panel that shows the list of countries.  However, since the views content pane displayed in this panel shows terms by aggregation, the query string is not passed when a user clicks one of the links.


texts: How do I debug/kint Simple XML Sitemap link array?

texts:
I am trying to find how I can debug/kint a variable/array from the Simple XML Sitemap?
I worked through the documentation here: https://www.drupal.org/docs/8/modules/simple-xml-sitemap/api-and-extending-the-module#s-api-hooks to find the hook I need.
My goal is to unset any links that have node/ to remove published, but un-aliased nodes of included content types.
The array key ['path'] looks to be the unaliased URL and the below code removes all links except the home page. I am unsure how I can kint($link) in this function so I can see what other array keys are available to see what else I may use for comparison.
function HOOK_simple_sitemap_links_alter(array &$links, $sitemap_variant) {

  foreach ($links as $key => $link) {
    if (strpos($link['meta']['path'], 'node/') !== FALSE) {
      unset($links[$key]);
    }
  }
}

Is there a way to kint() these sitemap arrays? Or maybe some documentation that shows the structure of these arrays?


texts: How to create a lightweight domain access alternative in Drupal 7

texts:
I have a password protected site mainly used for internal management of projects, but have regularly the need to publish some of its content for clients.

For simplicity sake, I would prefer to keep all content in the same database and site. However, the published content should be viewable from another domain name.

The contrib module 'Domain access' is too heavy for my needs. I'm looking for an alternative that 'simply' allows content to be published to a second domain using something like a setting or toggle per entity.

Experiences in this area are very welcome.


texts: Which Drupal core function might call SELECT * FROM on custom module table?

texts:
I have a Drupal 6 website which is hosted on a shared hosting service and which is used to communicate with a desktop software application. Over the years I extended the user profile with over 70 different profile fields. With over 45.000 users this resulted in a profile_values table containing over 1.200.000 rows and I was getting complaints about slow queries and I've read it might lead to performance issues. Switching host or upgrading Drupal 6 to Drupal 7 is not an option!

Since the profile data is only used when the software communicates with the website, which is done once per application start I did not really have a need for such a large profile table so I created a custom module which stores the profile data per user in a single row as a serialized array. This also has the benefit that I don't need to update my website every time a new profile value is added in the software.

But my MySQL slow query log is filling up again. The query that's logged is SELECT * FROM {my_table}. As I know this table is quite large I was careful not do call such a query myself and therefore I cannot find this query in my module or any of the modules that use my module. I always select a single column and pass a specific parameter to check.

As far as I can see there are only two functions that might have an influence on this. I implement hook_user() for insert and update operations and I call drupal_write_record() when saving the user data. But running through the code I fail to see where such a query might be called.

Can anyone explain where this query might originate from, within the Drupal system, or how I can extend MySQL (5.1) logging to tell me from which script this function might originate? (As it's only supposed to be called from a software application there's no equivalent web page a user can access.)


texts:
I would build a confirmation screen. So I initialized the path in the hook_menu as it should be but for some reason, the argument $node isn't send with the function... What am I doing wrong?

This is my hook_menu:

$items['node/%/revisions/%/offline'] = array(
      'title' => 'Offline,
      'description' => 'Confirm the action "Fiche offline".',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('_mymodule_confirm_offline'),
      'type' => MENU_LOCAL_TASK,
      'weight' => -4,
    );
    return $items;

And this is my function:

function _redactie_omgeving_confirm_offline($form, $form_state, $node) {
    $question = t('Take fiche offline. ');

    return confirm_form($form,
                    $question,
                    'node/7', t('You\'re about to depublish this fiche. <br />Are you sure you want to depublish this fiche?'),
                    t('Yes'), t('Cancel'));
}

But the $node-variable in my function stays empty... What do I have to do to fill in this variable?


texts: How to show user info in DIV based on link click?

texts:
I'm currently trying to make a 'biography' block with Drupal profile pictures and when you click on them more information (user fields that has been filled in by the Drupal user) will dynamically display in a block. To be more specific, this is what I want:

https://css-tricks.com/forums/topic/change-content-in-div-based-on-link-click

I tried to make a Views block displaying the profile pictures. These pictures will function as thumbnails. The things is, I have no idea how it will show more information when you click on them (without going to the profile page). Is there a Views trick, Jquery way or any other method I can try?


texts:
I have a very strange issue with a Drupal 8 install. My production setup is running on NGINX in a subdirectory - something like www.example.com/abc.

The site is running great, but I have seen an error occur that I can't pinpoint. One page that I setup as the frontpage (ie, /abc/index.php) is made with a view that uses the Slick Carousel module to show a carousel of nodes of a certain content type (news).

Here's what's going on:

sometimes the URL on an item of the carousel loses the /abc part of the path, effectively sending users away from the site (ie, /node/123 when it should be /abc/node/123).
this happens when the user who created the node has a certain role (lower than admin). If admins create the node it doesn't happen.
it is only visible/only affects anonymous (not logged) users. If a user is logged in, be it either admin or otherwise (including the role for who this happens), the page shows up the correct URL (ie, /abc/node/123).
it only happens on that page/view. In other pages/views which list the news content type, the same node shows the correct URL for all users, either anonymous and/or logged in.
I (admin) can solve it in at least 2 ways:

unpublish/publish the problematic node;
clearing the cache

the problematic role has no way of solving this using the above methods.

Now, to add difficulty to the whole process, I have no control over the NGINX configuration, although I was told it was setup according to NGINX's Drupal recipe.

Also, in my dev environment this doesn't occur, even though the configuration settings are the same (it's exported every time I deploy to production). The only thing that might be different is the settings.php file.

Obviously, I have no debug facilities in place for the production website, so there isn't much I can do to trace the issue. Also, there are no log messages indicating something might be wrong with this page.

I'm now trying to find a way to replicate the production environment in a VM, but even so, I'm not sure where to start looking for the problem.

Can anyone share any thoughts on this?

EDIT: I have replicated the production environment with Docker containers and I can't replicate the bug.

Meanwhile, I have seen some even weirder things happening: sometimes (again, fixable by clearing cache), the menus also get the wrong URLs - I have a block menu holding a link to the login page that instead of going to www.example.com/abc/user/logingoes to www.example.com/user/login.

I guess clearing the cache forces the URLs to be rebuilt and apparently it gets fixed. But aren't URLs rebuilt anyway when you publish content? Why can this affect the menus as well?


texts: Installation fails with missing "file" -plugin error

texts:
We are creating our own D8 installation profile from previously built site. We exported config and split it to modules, so that our custom modules are defining their own configs.

We've had a lot of issues, basically because we don't know how to debug site installation. XDebug seems to catch nothing. But now I've gotten pretty far, modules do get installed, but the configuration import fails on following error:

[ERROR] The "file" entity type does not exist.

Error gets thrown at Drupal\Component\Plugin\Discovery\DiscoveryTrait.php, but sadly I'm not able to get PHPStorm's debugger to catch that file.

protected function doGetDefinition(array $definitions, $plugin_id, $exception_on_invalid) {
    // Avoid using a ternary that would create a copy of the array.
    if (isset($definitions[$plugin_id])) {
      return $definitions[$plugin_id];
    }
    elseif (!$exception_on_invalid) {
      return NULL;
    }

    throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));
  }

So basically I'd need a way to debug this installation via profile or some way to find out which config file is responsible. I'm finding this unnecessarily difficult, so any help is appreciated.

Cheers,

Janne


texts:
I am looking to add a class to a table that I am creating.

I have the code:

$build['table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
);

I want to add a class to this table.  I don't have any templates for the view of this table, so I don't really want to have to create a tpl.php for it, but I will if I have too.


texts: After the update 8.7.14 to 8.8, the File module causes error when uploading a file

texts:
After updating Drupal 8.7.14 to 8.8, I have a problem with the File module: When I upload a file, I get the This value cannot be zero error message.

The file is however present in the site/default/files folder.
I have already tested changing the permissions, I have no PHP errors in the logs, I checked the /tmp folder, added a private folder, created a new content type with only the file field, but I still have this error.
I also tested thees patches.

https://www.drupal.org/files/issues/2020-08-13/3098718-core.system_update_8804.truncate_path_alias_tables-69.patch
https://www.drupal.org/files/issues/2862702-3.patch

Have you ever had this scenario?


texts: How can I enter a custom maintenance mode message for a non-English D8 site?

texts:
I am playing around with a D8 site (8.0.0-beta6) and having trouble locating where some of the controls have gone. During the initial installation procedure I selected a non-English localization (Turkish). Subsequently putting the site into maintenance mode does indeed show the Turkish localized default maintenance message.

The trouble is I want a custom message. Entering one in the box on the maintenance page (I'm viewing the Administrator site using the same default locale) has no effect on the message displayed. Apparently this message changes the English only because if I add /en to by site URL I get the English maintenance mode page and header, but with my custom Turkish message below it.

Where does one change custom localized maintenance mode messages?


texts: Best practice approach for environment specific keys

texts:
I'm using encrypt/key/real_aes and lockr to create environment specific encryption profiles. Ie, prod data should never be accessible on UAT, dev, local etc.
What I'm wondering about is whether I can easily swap out field encryption profiles on specific environments, or if I can change the key being used by the environment?
Ultimately, I'd just like keys to be available to their environment only. Lockr helps by never displaying the key, but I can still request the prod key from lockr when on local, etc.
I'm not sure I can do these while keeping my site secure so I'm hoping for some best practice solutions to this.
Thanks.


texts:
I've got a custom module form in Drupal 7. The code looks like this:

function form_example_dynamic_form($form, &$form_state) {

$form['tables'] = array(

        '#type' => 'select',
        '#options' => drupal_map_assoc(array("2012", "2013")),
        '#title' => t('Select year:'),

        '#ajax' => array(
            'callback' => 'form_example_dynamic_myajax',
            'wrapper' => 'abcd',
            'effect' => 'fade',
            'method' => 'replace',
            ),

       );

 return $form;
 }

 function form_example_dynamic_myajax($form, $form_state) {
     return $form_state['values']['tables'];
 }

So this simple code should update #abcd tag with the value of the 'tables' select. And the problem is that it works only for the first selection. If I chose 2013 it returns "2013" text in my #abcd tag. But, when I chose 2012, an #abcd tag stays unchanged. It still apperas 2013.

Here is the example: http://kuzaj.yamandi.com/pl/form_example_dynamic

Does anyone has any idea how to solve it?


texts: Change the Mandatory field based on selection in webform

texts:
I have Webform with a radio button type field named as "preferred contact method", for selecting email or phone.

When user select the email I want to set the email field as mandatory or if user select the phone I want to set phone field as mandatory.

How to handle this in Webform Drupal 7.


texts:
I have multiple roles on my website, and I want to assign a certain role to some users when they register to my site.

How can I assign a specific role to new users programmatically when they submit their registration forms?
I have tried modules like logintoboggan, autoassignrole, but they provide a default user role on registration, when I want to assign role to specific users, not to all users signing up on my site.


texts: Multi-site: how to handle some module differences?

texts:
I have a Drupal 7 multi-site installation with some shared modules. Some of these modules declares some forms. And here comes the problem: How to make these forms look different in two different sites? For example: In one site the whole form needs to be on a single page but in another site it needs to be divided in two steps, how can I solve this without change the module code?

I tought in some solutions:

Create a custom module for the site that needs the form to be in two steps.
Break in two steps using javascript and handle the navigation on the client site.
Create a configuration on the shared module (the problem here is that I'd have to create a specific configuration for every possible customization on the form).
Create a template for the form and handle this steps in specific site theme.
Change the module to, instead of creating a form using FAPI, creates a webform node that could be changed for the specific site when the module is installed.

What would be perfect for me is that is someway I could implement a form alter hook in the theme but it isn't possible, right?

What do you think? How you solve this problem?