texts: Display a block based on current select option

texts:
I have a select field that holds two options. When the second option is chosen, I want to display a block.

I know that with form API I should be able to do this. I'm just not sure on where to start. Any help getting me going would be greatly appreciated.

So far I have the code below.

function MODULE_form_user_register_form_alter(&$form, &$form_state, $form_id) {
    $form['account']['type'] = [
      '#title' => 'I am ordering for',
      '#type' => 'select',
      '#options' => [ 'Myself' => 'Myself', 'Someone' => 'Someone else' ],
      '#weight' => -100
      ];
}


texts: Getting distance information on custom data table with Views (Drupal 7)

texts:
I am using Views to display a custom table (locations).  I have everything setup properly but now, I would like to get the distance from the current user to display.

I have first tried to get a custom field in there and do a pre_render to calculate the distance.  It works, but it makes it impossible to sort by distance since the data is modified after the fact.

I tried to figure out a way to add an expression Select to the Views query, but haven't found any ways to do so.  This would most likely be the best solution though.

I then tried to use Location module, but I can't figure out a way to make the Location: (proximity, distance...) fields appear in my fields list. Tried using the location handlers on my lat and long fields, but nothing different happens (ie: location_views_handler_field_latitude).

Anyone knows how to get this working with custom data?

The end goal:  Having the user enter is location, geocode it, then show their distance from the location's custom table (lat, long fields).


texts:
I'd like to ask a question concerning the Views field view module.

I can see in the parent view a list of tokens available to pass as arguments to the child view but I can't see any way to grab those arguments from within the child view.

How can I achieve this?


texts: User authentication handled by a web service

texts:
I seek your help and advice. By default, Drupal manages user authentification using the user module that resides in the "core/modules" and through the main Drupal Database. In my case, the user is authenticated through an external webservice, the process is as follow:
1- The user enters his credentials and click submit
2- the credentials are then sent to the webservice
3- the webservice checks the data(credentials) to the one he has in his database
4- upon validation the webservice sends a token (JWT) otherwise it sends 401 Unauthorized

PS: the admin will have normal login (through Drupal Database)

The question is how can I proceed to elaborate this process of authentification?

Is there some existing modules that could help with this?
should I override the existing user module or create a new module?

Any info will be of great help.


texts: How do I find out the machine name of a view in hook_preprocess_views_view_field?

texts: In Drupal 8, I am trying to use hook_preprocess_views_view_fields to process certain fields of certain views. I know how to test for the field name via $variables['field']->field, but I can't find any similar way to test for the view's machine name. Is there a similar way to do it for the view?


texts:
I am using drush 5.7 and in my command line I can type:

drush dl wysiwyg

Works great but whenever I create a shell command with several downloads, or even just one download, it throws an error "No release history was found for the requested project"

Very confused and bizarre on why this would be happenning?

Test.sh

#!/bin/bash
#WYSIWYG
#http://drupal.org/project/wysiwyg
drush dl wysiwyg


texts: Difference between field_data and field_revision tables?

texts:
I have a lot of custom functions; I just want to make sure I'm doing this right.
If I want the most recent version—the live version—of a node, I go to the field_data_field_xyz table, right?

My understanding is the field_revision_field_xyz keeps all older versions, correct?


texts: Remove js file by template or add condition in info file

texts:
I work on drupal 7, I added all js by info file, work well in whole site. But we want to remove or not load of a specific js in a specific content type page.

I try by template.php of following code

function mytheme_preprocess_page(&$vars) {
  if (isset($vars['node']->type) && !empty($vars['node']->type) && ($vars['node']->type == 'my_content_type')) {
    $js_path = drupal_get_path('theme', 'mytheme') . "/js/xyz.js";
      unset($vars[$js_path]);
  }
}

but load  xyz.js. How to remove of this js file.


texts: The Facebook Autopost module "user hasn't authorized the application"

texts:
I have a problem with the Facebook Autopost module for Drupal 7.28): After publishing a node, I get an authorization error.

  Facebook SDK threw an error: OAuthException: (#200) The user hasn't
  authorized the application to perform this action

I have checked permissions "Publish Actions", "Publish Stream", "Manage Pages" for Administrator role in fbpermissions module.

Also, I have submitted "manage_pages" in my app but cannot submit "publish_actions" because of this:

  It looks like you haven't made any API requests to access content with
  the publish_actions permission in the last 30 days.

Don't know what to do now. Have no idea why it's not working and what Facebook app permissions are missing. Was googling it for an about 2 hours. Checked all found solutions... none of them worked...


texts:
I enabled theme debugging in services.yml file and I added a template file.
Following is what I see in file name suggestions:

x layout--onecol.html.twig
* layout-onecol--taxonomy-term--1.html.twig
* layout-onecol--taxonomy-term-branches-default.html.twig
* layout-onecol--taxonomy-term-branches.html.twig
* layout-onecol--taxonomy-term-default.html.twig
* layout-onecol--taxonomy-term.html.twig
x layout--onecol.html.twig
* layout.html.twig

Here's new file's name:

layout-onecol--taxonomy-term-branches-default.html.twig

The file is not recognized. The page is still rendering from

<!-- BEGIN OUTPUT from 'core/themes/stable/templates/layout/layout--onecol.html.twig' -->

So, I tried adding layout--onecol.html.twig file in my custom theme.
And this file is recognized which means file names with * in suggestions list are not working, but names with x are recognized.

I believe they should work in opposite way.


texts: Private file folder outside document root

texts:
I am setting up a private files folder outside of www. I have set the permissions to allow access to the folder by www-data to read and write but not execute, however, my drupal 8 site is now showing an error:

  PRIVATE FILES DIRECTORY Not fully protected See
  https://www.drupal.org/SA-CORE-2013-003 for information about the
  recommended .htaccess file which should be added to the
  /var/drupal_data directory to help protect against arbitrary code
  execution.

That link is to an advisory and fixes regarding Drupal 6 and 7. There is no mention of of Drupal 8 and it appears reasonably out of date:

  20 Nov 2013

I didn't think apache could even utilise htaccess outside of the www folder in such a way.

Is there some other configuration or permission I need to be changing?

Up until now, for testing, I have had a private folder within the public files directory. I wish to move the private files directory outside the root directory as I am lead to believe it is better for security.

While many guides discuss the best practice of moving this folder outside the root directory few go in to much detail about either why that is beneficial or how that changes the site setup. If there are good recent explanations for this practice I would appreciate being directed to them.


texts: How to use group audience in drupal 7 views filters

texts:
How to use the Group audience field in our drupal 7 views filter. I have to fetch the values for the appropriate groups node. So i want to add the group audience field in the views filter. By default the filter having the fields of Groups audience (group_audience:gid), Groups audience(group_audience:delta) likewise. Please suggest me some ideas how to fetch the values based on the group audience field in the views filter.

Thanks, Sathish


texts: Hook menu in the page--front.tpl with a passed var

texts:
Given the url, for example:

website/all

I wish the hook_menu, to load the existing frontpage, currently using a page--front.tpl.

passing the "all" arg to the page so I know I need to load all records.

One will presume I need to start off with hook_menu......with a page callback, but how will the function load the page?  IS there a function I can call?

Thanks


texts: How to clear values of a custom field when pushing back button in commerce checkout?

texts: In my shop there is a custom pane where the customer can check a checkbox in order to choose "private invoice" (if he checks, the invoice amount will include VAT but will not report it; instead a small discount is given). The Problem: if the customer goes back to the prevoius checkout-page and unchecks the checkbox, this change will not be reflected. How can i make sure, the value is updated propperly?


texts: Is it possible in a TPL to create a link to a View page? Rather than hard code the link I would like it to update if the URL of the view page changes.


texts: My node.title differs from the title field in the database

texts: I have a wierd problem i can't seem to get a solution to. I have a Drupal 7 website with more then 10000 nodes. And i recently discovered that 2000 of them have exactly the same typo in the title. So I did an update on the database fixing the node.title field. But for some reason the title in the Drupal website is not updated. When i save the node in drupal the database get's updated, so the other way around works. I deleted all the cache and those kind of things. Still the same problem. What else can I check?


texts: Remove node_access check from content revisions view

texts:
For the 'content' Views one can simply check tickbox 'Disable access checks' in UI under Advanced => Query, and the View returns all the records regardless of the node_access check.

However, in the 'content revisions' Views this tickbox is not available.

How can I make 'content revisions' Views to bypass the access_check?


texts: get menu link Page Settings from View configuration

texts:
When I have a node on the main menu, I can find its Menu Settings with an entityQuery on the content entity for its menu link, for example:

$system_uri = "entity:node/42";
$query = \Drupal::entityQuery('menu_link_content')
  ->condition('menu_name', 'main')
  ->condition('link.uri', $system_uri);
$result = $query->execute();
$menu_link_id = reset($result);
$menu_link = MenuLinkContent::load($menu_link_id);

... then get the Menu Link Title and Parent Item with these methods from the relevant class:

$menu_link_title = $menu_link->getTitle();
$menu_link_parent = $menu_link->getParentId();

I can't do the same thing with a view.  Even an entityQuery of all menu_link_content entities on the main menu doesn't return views that are on that menu: only nodes and taxonomy term entities.

And I can't see these settings in what I believed would be the corresponding configuration entity for a View, for example:

$view_id = 'frontpage';
$query = \Drupal::entityQuery('view')
  ->condition('id', $view_id);
$result = $query->execute();
$view_id = reset($result);
$view = \Drupal::service('entity.manager')->getStorage('view')->load($view_id);

The resulting Drupal\views\Entity\View object doesn't look like it has any properties or methods to access the configuration data in the Views UI, specifically the Menu Link Title and Parent under Page Settings.  What is the correct way to extract this information?


texts: Can't create table when installing module

texts:
I have a simple 'form_example' module and I want to add a database table when instaling module. I created this form_example.install file:

<?php

function form_example_schema() {
    $schema['form_example_table'] = array(
        'description' => 'Table for form_pokus module',
        'fields' => array(
            'id'        => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
            'name'      => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'gender'    => array('type' => 'varchar','length' => 30,     'not null' => TRUE, 'default' => ''),
            'message'   => array('type' => 'text', 'not null' => TRUE,   'default'  => ''),
            'status'    => array('type' => 'text', 'not null' => FALSE ),
            'created'   => array('type' => 'int',  'not null' => TRUE,   'default'  => 0),
        ),

        'primary key' => array('id'),

    );

    return $schema;
}

I disabled this module, then deleted it from directory, flushed all chaches and then installed and enabled again this module, now with .install file. But new table is not appearing in database. Im using PostgresSQL. What I am missing?


texts: I'm running a largely default Drupal 8.0.0-RC2 site. At /admin/config/development/performance the "Bandwidth Optimization" settings for "Aggregate CSS Files" and "Aggregate Javascript files" are disabled, so I cannot change their state. Extensive though fruitless googling suggests this is unusual, but I'm stumped on where to start. I'm using the Drude environment for my site.


texts: Why does view display incorrectly when logged out?

texts:
I have a view with a page display configured. When I take a look at the page in the browser, while logged in, it displays correctly. When logged out, it's a mess: the fields are out of order, the sort order is wrong, the field settings are wrong...

I've built views with this approach dozens of times before and have never experienced this. In fact, I've even built a similar view-based page in the same site with no issues. Any idea what's happening here?!

I've flushed the caches. No role permission settings have been changed beyond the default.


texts: on a multi-language site 'Entity translation' prefs don't show 'node' option

texts:
I'm working on a multi-language site and would like to pre-define the language per content type (as e.g. described here in the answer) but can't get the vertical tab "nodes" to show up.

The "taxonomies" tab however does show up – so I guess sometings are actually working correctly.

i do have a couple of content types with the publishing setting "Multilingual support = Enabled" – but still none of them shows up in the Entity translation options section. What I would like to achieve is one a one-content-type-per-language setup – therefore I would like to set the default language accordingly on the Entity translation page . What am i missing? Any pointers would be appreciated.

Screenshot from the Entity translation interface:


texts: All taxonomy term paths default to the www.example.com root directory

texts:
After creating a new vocabulary and adding terms to it, clicking on the view tab of the term edit form sends me back to my root directory. And, of course, typing the term path in the url results in a page not found error message. What is going on?
Strangely enough, not too long ago, I created a vocabulary and it still works well (clicking on the view tab takes me to the term page view.) However, older vocabularies no longer work when hey used to.
Does anyone know what is going on?
Any help on this one would be greatly appreciated.
Thanks. :)


texts:
What makes a maintenance mode message display, when a site is not in maintenance mode? In this instance, it appears that it was because a contrib module was throwing a recoverable fatal error. So there was no WSOD/ general crash but because there was an error, the maintenance mode message was being displayed. Is this possible? I suppose it's too localised to really be sure.

This question is for Drupal 6 (it can't connect to the database) is the same true for Drupal 7?

Maintenance mode is not turned on, yet I'm getting a maintenance mode message. What's more it's being displayed as a second HTML page rendered fully marked up, beneath the target page which is also rendered fully marked up: Maintenance page being rendered as an entire page load after the main page load


texts: Flag module: Do not allow users to flag own content

texts:
I am using Flag 7.x-3.0 to enable users to flag file entities. I only want users to be able to flag files that other users have uploaded. However, I am missing the checkbox option "allow users to flag own content" that I remember having been a part of earlier versions of Flag module.

Has this feature been removed?


texts: Override theme function inside module, template_preprocess_field

texts:
I'd like to implement template_preprocess_field in a module for organizational purposes.

How can I do this?

Thanks!

Reference:
https://api.drupal.org/api/drupal/core%21includes%21theme.inc/function/template_preprocess_field/8.2.x


texts: Migrate files attached to comments from D6 to D7

texts:
While migrating from Drupal 6 to Drupal 7 (into a new blank site), I noticed that files attached to comments are not handled by the Migrate module. The D6 site uses a contributed module „Comment Uploads“ that associates files with comments in a table comment_upload:

+------+------+-------+----------------------+------+--------+------------+
| fid  | nid  | cid   | description          | list | weight | legacy_fid |
+------+------+-------+----------------------+------+--------+------------+
| 1002 | 1001 |  1000 | under_149.jpg        |    0 |      0 |          0 |
| 1774 | 1969 |  6855 | ruler.png            |    0 |      0 |          0 |
| 1706 | 1712 |  6009 | 1.png                |    1 |    127 |          0 |
| 1703 | 1712 |  6006 | 2.png                |    1 |    127 |          0 |
| 1704 | 1712 |  6006 | 3.png                |    1 |    127 |          0 |

Nodes, comments and files already migrated successfully to D7 using the migrate_d2d module and its user interface. Node attachments went through fine. Except comments no longer have files attached now. Since files and comments exist, it should be possible to attach the files to their original comments, using the above table.

Q: How would I go about and migrate comment attachments properly?

a) Would it make sense to hack the migration class for D6 comments? The issue is: The comment attachments do not appear as a source field in the Migrate user interface, as they do for nodes. Maybe if this could be achieved, this would be the best solution.

b) Why not grab that above table’s data (some 1000 rows only), iterate over it and call the appropriate D7 API to attach each file (fid) to its original comment (cid)? If so, which API calls should be used and where do I place this code?

Despite doing software development for decades, Drupal’s inner underpinnings are new to me. Any help is highly appreciated.

Edit: I don't want to use the Comment Upload module under D7 anymore.


texts: How to open User registration in a pop up?

texts:
I'm using Fancybox to open user registration page in a pop up window. Here is the code

$('.fan_popup').fancybox({
  type: 'iframe',
  href: '/user/registration',
  width: 800,
  padding: 5,
  height: 600
});

The pop up window is shown but the page gives message like "You are not authorized to access this page.". How to overcome this.


texts: How to add the Organic Group list in the user profile

texts:
Is there a way to add the Organic Group list in the user profile

The OG List appear in the Registration Form but not in the user profile

Not appear in this path
/user/[uid]


texts: Ctools wizard multistep form: Back button should remember entered data

texts:
I am building a multistep form using ctools, basically following this approach. Now I want the following behaviour:

user is at step 1
enters data for step 1
clicks continue and gets to step 2
enters data for step 2
clicks back and gets to step 1
sees the data he entered previously (works already)
clicks continue and gets to step 2
sees the data he entered previously (works not yet)

To show the previously entered data after clicking continue, I simply set $form[$name]['#default_value'] with values from $form_state['values'] (with a detour via ctools object cache). So this works already.

The problem is with clicking back: After clicking back, $form_state['values'] does not contain any entered values. So I don't have the values to populate $form[$name]['#default_value'] and this is my current problem.

So I wonder: How can I send entered values with the back button submit?


texts: Pass PHP variables from my custom block to my custom Twig template

texts:
I created a custom block module my_block. Inside modules/custom/my_block/src/Plugin/Block/MyBlock.php I have this code:

<?php
    namespace Drupal\my_block\Plugin\Block;
    use Drupal\Core\Block\BlockBase;
    /**
     * Provides'My Block' Block.
     *
     * @Block(
     *  id = "my_block",
     *  admin_label = @Translation("MyBlock block"),
     *  category = @Translation("Our Example block"),
     * )
     */

    class MyBlock extends BlockBase {

      /**
       * {@inheritdoc}
       */
       public function build() {
         $build = [];

         for ($day = 1; $day <= 100; $day++) {
           if ($day % 15 == 0) {
               echo $foo . $bar
;
           } elseif ($day % 3 == 0) {
               echo $foo '
';
           } elseif ($day % 5 == 0) {
               echo $bar . '
';
           } else {
               echo $day . '
';
           }
         }

     $block = [
       '#theme' => 'my_template',
       '#cache' => [
         'max-age' => strtotime('01/01/'.(date('Y')+1)) - time(),
       ],
     ];

     $build = $block;

     return $build;
  }

}

I also created a template file modules/custom/my_block/templates/my-template.html.twig and attached it to my custom module.

I have another file modules/custom/my_block/my_block.module:

<?php
/**
 * Implements hook_theme().
 */
 function fizzbuzz_block_theme($existing, $type, $theme, $path) {
   return [
     'my_template' => [
       //'variables' => ['markup' => NULL, 'test_var' => NULL],
       'variables' => [
         'test_var' => '',
       ],
     ],
   ];
 }

How do I output the values from the if/else conditions from modules/custom/my_block/src/Plugin/Block/MyBlock.php, into my custom block and so I am able to render them in my twig file modules/custom/my_block/templates/my-template.html.twig. E.g. Show: {{ result }}

Do I somehow have to parse some variables inside the public function build() function?


texts: Get the user id for triggers when deleting a user

texts:
I have a script that sets up a specific url for a user when they register on a site,

There are no real issues at the moment, but I need to cater for those 'unlikely things to happen that happen 20 times when not prepared for'

Part of this is deleting certain user data when a user deleted (or requests to delete) their account.

I have set up a trigger which at the moment compares the list of uid's with those in the table I wish to delete but this is laborious because every time a user is deleted it has to loop through them all,

What I need is the uid of the user being deleted passed to the trigger so that the trigger than then go directly to the table and delete all user data belonging to uid x.

Is there a method or a way pf programmatically discovering at run time, which uid has been deleted (or being deleted).

The main problem is that the trigger is supposed to be fired after the user is deleted, but it seems to fire beforehand because when I run tests the user data is not removed until the next time, so this is what is happening:

User A is created
User A stores data
User A is deleted
- trigger fired, nothing happens
User B created
User B stores data
User B deleted
- trigger fired User A's data removed, User B's data remains until User C is deleted.

so comparing the user table id's with the id's of the table is useless because until after the user has been deleted their uid is still present in the users table.

Any help or pointers on how to get this uid would help me a GREAT deal :)


texts:
I made a form, with a few fields. In the hook form alter I add some info text depending on the value of a $_GET variable.
Only the hook alter is only called the first time.
I want is to be called every time the form is viewed.

Am I using the wrong hook?


texts:
I'm trying to add a bullet to a string in _preprocess_node() and am running into problems.
I am using Drupal 7.

My code is as such:

if($node->type == 'contact_page'){
    $vars['content']['field_fax']['#title'] = t("F &#8226;");
    $vars['content']['field_phone']['#title'] = t("P &#8226;");
  }

I get the literal string instead of the bullet. I've tried a bunch of things, but nothing seems to work. Am I missing something?


texts:
If I run dpm($form); I get an array containing objets. Now I need to just dpm() the uid of the node object.

How do I do dpm() to isolate an object value?

I tried with dpm($form['#node']['uid']); but not working.

Please look the capture to make my question clear:


texts: Replacing an object of the UserLoginForm class with one of my own class

texts:
Is it possible to replace an object of the UserLoginForm class with one of my own class?

What I want to do is replacing the login form with a custom one which would ask users to enter a code sent to their email address, once they entered the correct user credentials.

The problem is that an object of that class is created from UserController::userPage().

if ($user->id()) {
  $response = new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE)));
}
else {
  $response = drupal_get_form(UserLoginForm::create($this->container), $request);
}

I know I can implement hook_form_alter() to alter the form, but I would like to use a class like UserLogin, and replacing $form_state['build_info']['callback_object'] with the object of my class in hook_form_alter() is probably too late.

Is it possible to use a class for altering the user login form? How?


texts:
How can I process following query structure in drupal 7.

set @num := 0, @termid := 0;

SELECT  * FROM (SELECT tid,nid,created,
           @num:=IF(@termid = tid, @num + 1, 1) AS row_number,
           @termid:=tid AS termid .......


texts: Menu settings missing from all node edit forms

texts:
Apart from what I mention in the title, there are also a couple of other things that give me the impression that they may be related to the same issue:

Can’t add link to any menu from
admin/structure/menu/manage/my-menu/add. What does happen when I try
to add a link to any menu is that it ends up in the Navigation menu
that comes OOTB.
Can’t assign any menu to taxonomy menu. Having taxonomy_menu
enabled, I noticed that when configuring the vocabulary via
admin/structure/taxonomy/gamma/edit  there is no possiblity to assign
any menu as taxonomy menu. The only option in the drop-down list is
=NONE=

There is also A list of modules on which I did this series of events: disabled the module, cleared cache, checked if the problem persisted (which it obviously did), and enabled the module again:

Here is the list:

Big Menu
Jump Menu
Mysite configurator (custom)
Mysite (custom)
Store locator (custom)
roleperm_import (custom)
mforms
mforms example
Menu Block
Menu import
Menu translation
Taxonomy menu _ custom paths
Taxonomy menu
Administration views
Backup and Migrate
Taxonomy translation
Menu translation

Needless to say the core Menu module is enabled.

Went looking on the internet, found this issue (https://drupal.org/node/358844) on drupal.org but this was drupal6 plus the big problem there was that the everything menu related seemed to be missing. The solution there was that menu permission weren’t right, which I have verified on my site that they are ok.


texts:
There is the entity_autocomplete field type which I expect should just work for core entities. I have created my own entity using Drupal console and would like to query those entities with an autocomplete field. I understand that you need some sort of callback to query the correct field and return the response.

I've had a good search but can't find any good examples of how to do this. Is there somewhere in core, contrib module or elsewhere that has a good example?


texts: How one can display the file path once it is successfully uploaded

texts: How one can display the file path in node/add page, once it is successfully uploaded, before saving the node.


texts:
There are several forms in a page and I use recaptcha module for all of them. The problem is, the recaptcha is generated for one of them not all of them.

In Allow multiple instances of reCAPTCHA on the same page the recaptcha-mutltiple_instances-1833822-31.patch patch is offered, and sounds it is working (I am not sure). But the problem is the recaptcha.js file doesn't exist in the recaptha module folder while it asks to update that file as well.

This is the module folder:


texts:
I want to create simple confirmation page. It means that after user change his email then he gets confirmation email with link to page. This link contains token. This link should open page for user with appropriate message (success or fail if token expired). I want to create simple module, But I don't know which hook I should use to create this simple page. I must check this token by sending POST request to REST API before rendering page.

Any advice?


texts: Is it possible to add a flag to a specific role user without using VIEW module?

texts:
I have downloaded profile2 module and I have created a specific role called  artist. I also added some fields so to be shown only for the artist role users' on the registration form.
Then I added a flag and selected flag type as profile2.
Now I selected Artist profile bundle.
Now the problem is that the flag which I just created is being displayed on Artist user's profile view only after we add a value to one of the form fields for that particular Artist user. Is there a way to resolve this without the use of Views?


texts:
I have a custom entity with (among others) a field defined this way:

$fields['datedistribution'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Date distribution'))
  ->setSetting('datetime_type', 'date')
  ->setDefaultValue(array(0 => array(
    'default_date_type' => 'now',
    'default_date' => 'now',
  )))
 ...

I created a View on this custom entity displaying (among others) this 'datedistribution' field.
When I try and to use it as a filter criterion, I don't have condition I expect to have for a date (I'd like to be able to select with this field being greater than today, for example):

So, I search in the direction of hook_views to filter my data before running my View.
So far, no idea of what hook I should use and how to code it.
Could someone help on that?


texts:
I need to put a class/ID on the actual li element as each link in the menu has a color-coded background when active meaning, I can't just style ".active-trail" as that will be the same color for every link.

Creating a menu and using the CSS ID or class puts the ID/class on the a element, not on the
 tag.

I could write something in jQuery, but I thought there might be a way in Drupal.

The output I want would be like the following.

Test links

first

second


texts:
I created a new custom entity using drupal console, I enabled translation and all looks ok in code.

The problem is that I don't know how to translate an entity from the admin interface, I don't see any options to do this. I looked through the generated files and I don't see any translation related functionality there.

Am I missing something? Should I build my own admin interface and logic to manage translations?


texts: feed import on node reference doesn't add language in database

texts:
I got a XML import witch imports new nodes, in this nodes there is a node reference field. When I run the import I get the message "does not match an existing node" when I look at the nodes they got the node reference, but when you edit the field is empty.

If you look in the database I see that language stays on UND when I change this and update the database it works but when the import runs again its ruined again.

Any solution?


texts: myform_validate() and myform_submit() functions not responding

texts:
I have built a form from following examples on tutorials but neither the accompanying _validate() nor _submit() functions are responding when I submit this form. This is my codes:

/**
*implementing foodmenu form
*/
function my_magic_foodmenu_form($form, &$form_state){
    $form = array();
    $form['choice'] = array(
        '#type' => 'select',
        '#title' => t('Choose your meal'),
        '#options' => array(
            'ricestew' => t('Rice with Stew'),
            'ricejollof' => t('Jollof Rice'),
        ),
        '#required' => TRUE,

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

    );

    return $form;
}

/**
*Implement form validation: Foodmenu
*/
function my_magic_foodmenu_form_validate($form, &$form_state){
    krumo($form_state);
}

/**
*Implementing form submition: foodmenu
*/
function my_magic_foodmenu_form_submit($form, &$form_state){
   // krumo($form_state);
}

From the code above, I have implemented the 'choice' field to be '#required'. The _validate() function responds and prints the implemented krumo() when I submit this form without making a choice, so there is nothing wrong with the _validate() code then. Why does it not respond when I just submit the  form after making a choice??

EDIT:

I would really like to know why the default _validate() and _submit() do not work in my code, given that there is nothing apparently wrong with the code. I am not looking for alternatives. I just want to get the defaults above to work. Thanks


texts: How to render a custom entity in a controller?

texts:
I created a custom entity called foo. This entity has a unique name field as well as the standard id key. I would like to build a page where the user can see the entity rendered similarly to how it would be on the admin page, but instead of referencing it by the id, I would like to use the name.

I have the following in my controller:

public function content($name) {
  $output = [];
  //Add a couple things to the $output array
  $output['first thing'] = [/*stuff*/];

  $sql = "SELECT id FROM foo WHERE name=:name";
  $sql_params = [':name' => $name];
  $results = db_query($sql, $sql_params)->fetchAll(PDO::FETCH_ASSOC);
  $render_array = [];
  if (count($results) > 0) {
    $id = $results[0]['id'];

    $entity_type = 'foo';
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity_type);
    $controller = \Drupal::entityManager()->getStorage($entity_type);
    $entity = $controller->load($id);
    $build = $view_builder->view($entity);
    $render_array = render($build);
    $output['entity'] = $render_array;
  }
  return $output;
}

However, I receive an error: User error: "entity" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php).

What do I need to do differently to make my entity render to the page?


texts: How to resend emails that Drupal already sent?

texts: I need to theme emails that happen when a user completes a booking on our site or modifies there booking after this. Is there a way I can resend emails that Drupal has already sent? This would greatly speed things up for me not having to make new or edit existing bookings.


texts: How to split Commerce Order: Shipping Address and/or Billing Address into different lines in Views

texts:
In a Views view that pulls out order information, I'm trying to put the Shipping and Billing addresses, but the addresses seem to be all joined up, and there's no way to split them into different lines. I'm grabbing a field called Commerce Order: Shipping information and Commerce Order: Billing Information

At the moment it looks like:

Name123 StreetSome RoadSome CitySome CountryPOSTCODE

I want it to look like:

Name
123 Street
Some Road
Some City
Some Country
POSTCODE

I'm outputting the result to a CSV export using the Views Data Export module. So I only need it to look readable when I open it with MS Excel.


texts: Enabled Trusted Host Settings in settings.php keep showing up as not enabled

texts:
I just installed Drupal 8.0.1. I have changed the Trusted Host Settings on my website. But in the error report it is still saying that "Trusted Host Settings NOT ENABLED".

The lines are:

$settings['trusted_host_patterns'] = array(
  '^artosphere\.eu$',
  '^www\.artosphere\.eu$',
  '^localhost$',
);

Tried with and without '^localhost$.
I have seen that this question has been asked on other sites. And once here. But I cannot find a solution anywhere.

The site is on a shared host.


texts: hook_taxonomy_term_update(), where does it get invoked in drupal's core code?

texts:
I looked after a module_invoke_all('taxonomy_term_update') in the taxonomy module (and more in the entire Drupal core) but I didn't find anything.

Where does that hook get invoked in the code?


texts: How can I let users register for a certain node type?

texts:
In Drupal 7.15, I use the Webforms module to allow guests to sign up to courses. I therefore created a content type Registration Form.

Courses themselves are individual content nodes, of the type Course.

Now, I'd like the user to be able to select a course to sign up for, and save that in the web form as well. How can I do that?

It seems that the Webform Associate module does exactly that:

  The Webform Associate module is designed to allow attaching webforms to particular node types. The example would be event registration. Event node types might need starting and ending dates, descriptions, etc. With Webform Associate a new webform node is automatically created, and the webform itself is appended to the bottom of the event node.

However it says that "Webform 3.0 Obsoletes this module and is not compatible in any way." Haven't found out how, though.


texts: Ajax callback returns value but wrapper isn't filled

texts:
I'm stuck because whatever I do my wrapper is never filled with my callback, any idea ?

  $form['show_liste_produits'] = array(
   '#type' => 'button',
   //'#attributes' => array('onclick' => 'return (false);'),
   '#value' => t('Lister les produits'),
   '#name'  => 'awesome-button',
   '#ajax' => array(
      'callback' => 'stockerAll',
      'wrapper' => 'listeProduits',
      'method'   => 'replace',
      'effect'   => 'fade',
    ),
  );

  $form['listeProduits'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'id' => array('listeProduits'),
    ),
  );

function stockerAll($form, $form_state){
 return 'test';
}

Thank you in advance !

EDIT:
In fact in the network tab I get this, maybe the selector isn't working ?
Moreover, my empty container isn't displayed after page load actually, maybe is it the source of the problem ?


texts: Webform block: reload page with anchor link

texts:
I have a webform shown in a block that appears at the bottom of my page.

If I select 'no redirect (reload current page)' when the form is submitted you are taken back to the top of the page and the confirmation message is shown above the form, so unless you scroll down it appears as if nothing happened.

If I select 'Custom redirect URL' and enter [current-page:url]#my-form when the form is submitted you do get taken down the page to the form only now the confirmation message is shown at the top of the page, so unless you scroll up you won't see it.

Is there a way to refresh the page, scroll down to my form and show the confirmation above it or do I have to use AJAX for this?


texts:
I am programmatically creating many nodes. Obviously they have to be valid before storing them. Such $node objects have CCK fields mixed with custom fields.

Because the validators only set a form_set_error() and hardly ever return the validation-result, I have to go trough the form-api in order to know if a node is valid, or so it seems.

I call node_validate(), then form_get_errors() (which, in turn calls form_set_error()).

There appear to be several problems with this approach:

form_set_error() sets a message with drupal_set_message(); for stuff like cron (a session-less user), this adds orphaned persistent error-messages to the database (they will never be printed, hence never deleted).
the returning array of errors is created to be used in a multidimensional form array. Especially with CCK-fields, I have to dig quite deep in order to find the actual error.
I just want to store a node, so I am not interested in a user-faced form; using the form API just feels wrong.

Is there a simpler, more elegant method?


texts: Views, Views-Slideshow, and Paging in Drupal 7

texts:
The situation is as follows:  I have a content type Slide, and I want to display the three newest slides in a slideshow.  The slides need to cycle, and the slides also need to be controllable by a pager.  The pager should have three bullets/links/images to be able to jump to a particular slide in the slideshow.  The pager should also have left and right arrows for incrementing and decrementing the the slide in the slideshow.

This technique is used ubiquitously around the web, yet I can't seem to figure out how to set this up correctly using Views and Views Slideshow.  Any pointers from all of you experienced Drupalites out there are welcome.

Cheers, Les.


texts: How do I rename a field name of a table?

texts:
I need to rename one of my fields in a table via a .install file. How can I to do this ?

Let us consider I have a table called "register" and field name called "fname". Now I need to change the field name "fname" to "name". How can I do this using a .install file?

We can add a field for a table using the below syntax :

db_add_field($ret, 'table_name', 'field_name', array('type' => 'varchar',
             'length' => 255, 'not null' => TRUE,));

What is the syntax for doing a field rename?


texts:
I have buttons below a slideshow I have created. I want them to be centered whether there be 1, 2, etc. I'm looking to have a wrapper div surrounding them with a class name of "button-count-x" (x being number of buttons). I've tried using a 'foreach' loop and counting the number of $row's, but that is not working.

Note: I am using the "Views Slideshow" module and am using the view's respective 'views-view.tpl.php' file.

<?php $count = 0; ?>

<?php foreach ($fields as $id => $field): ?>
<?php if (!empty($field->separator)): ?>
<?php $count ++; ?>
<?php print $field->separator; ?>

<?php print $count; ?>

<?php print $field->wrapper_prefix; ?>
<?php print $field->label_html; ?>
<?php print $field->content; ?>
<?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>


texts: Views to display recent content with user pictures

texts: I want to create a view displaying the recent content posted by users along with their respective pictures. I am able to Create the view displaying recent content but how to display the respective user picture who created the content along side the content.


texts: Want to display the validation error message above the webform

texts:
I have a webform created in Drupal 8 using the webform module I have to submit the data to 2 different 3rd party API.

The scenario is I have to submit the data to the 1st API if there is no error response found then submit the data to 2nd API so now I have created a submit handler and attached the handler to the webform. Now the issue is when I got an error response message while submitting the data to 1st API and showing the  message using drupal_set_message() function everything is working fine but the form validation js not loading at this point.

The used code is like the below:

drupal_set_message(t($msg), 'error');
$form_state->setRebuild(true);

can anybody help me with this?


texts:
I am on Drupal 7 and configuring Views. I can easily add a field that displays thew node's content type. But it seems it will bring only the friendly content type name. Is there any way I can pull the content type's system name (like 'content_type_system_name')?

Thank you.


texts:
In the node template, I print an image gallery. I need to add the alt text.

<div class="field--name-field_gallery">
  {{ content.field_gallery }}
  {{ content.field_gallery.alt_field }}
</div>

There are many images, which are printed, but the alt text is not printed.

How can I print it?


texts: Json views not displaying in json format, instead displaying in web view

texts:
I created a json view for a CCK.
I am trying to display the view on my webpage. The data is rendered as a web page. But i need something like exact json response.
Here is the screen shot

Please help to find out the solution.
Thank you


texts:
I have made a view that contains only car manufacturer logos.

What I want is that when a user clicks on a logo they will be taken to a page that will display all cars for this manufacturer (in a view), depending on a link or something.

How to make this or to assign some arguments and where?


texts: How can I render a menu item as a span (or other elements) instead of a ?

texts:
I'm using Drupal 7 with the Bootstrap base theme, and I'd like to create a second and third level of drop-down. I tried using the special_menu_links module but nothing happens. I also tried what suggested on https://www.drupal.org/node/143322, but that doesn't work either.

How can I render a menu item as a span (or other elements) instead of a <a>?


texts: Prevent clicking on view tab when editing a node

texts:
I was wondering anyone knew of a module that would warn people when clicking on the view tab if they have made changes to a node, but didn't save it. For example, I've seen a few times where people would click on the edit tab to edit the node, then when finished, click on the view tab at the top next to it. This doesn't save the page, and they loose everything they just worked on.

Any thoughts on how to warn people to click "save" first before navigating away?


texts: my base_path is empty do I need to set this manually or is something else wrong?

texts:
I've tried putting in these values in my return:

base_path();

global $base_path;
$base_path;

$GLOBALS['base_path'];

They all end up returning nothing, while an appended string shows up just fine:

return '<div>' . base_path() . drupal_get_path('module','bannert') . "banner.html" . '</div>';


texts: Node not being saved when using Rules redirect

texts:
I need help with basic setup of Rules. I have read tuts but could not figure this one out.

I have content type A.
A is saved to system as unpublished. It saves personal information and those cant be changed anymore so users after using it get Access Denied message as they dont have permission to view it.

What i want to do with rules after node is being saved,
1. Redirects to some other internal url (any),
2. Get system message "Node creae successful".

Problem is that node after being saved with Rules module does not get saved at all. Nothing in Content, nothing in database. Without Rules everything works as intended.

Rules setup:
1. Events:
"After saving new content"

Conditions:
"Content is of type" - param: Content node, Content types: A
Actions:
Page redirect - url: blog
Show a message on the site: Parameter: Message: devtest

What happens is that redirect works correctly, message does not appear (no big deal, could create node with some text on it instead of system message).
But node A does not get saved anywhere.


texts:
Is there a way to format a date in Drupal rules? I've got a date timestamp, but obviously that's less than ideal for a client-facing situation.

How do you change a field to a different sort of formatting while in the rules UI?


texts: I have an exported view code.How can I import it in .install file?


texts: Panopoly WYSIWYG exclude buttons configurations

texts:
Can anyone tell me if it's possible to configure the Panopoly wysiwyg to we can have different buttons available to different roles?

At the moment, without have to create a module, I can't find a configuration area which will allow the exclusion of certain buttons for some roles.


texts:
I have a form:

function form_search_products($form, &$form_state) {
  $form = array();

  $form['keyword'] = array(
    '#type' => 'textfield',
    '#description' => 'Enter keywords (ie: Fat free milk)'
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Add item to my shopping list'
  );

  return $form;
}

Simple and its loaded into a block region above product listings via:

function products_block_view($delta = '') {
 $block = array();

  switch ($delta) {
    case 'search_form':
    {
      $block['content'] = drupal_get_form('form_search_products');
      break;
    }
  }
  return $block;
}

I am trying to figure out how to map a submit handler now as there is no menu...

My current menu looks like this:

function products_menu() {
  $items = array();

  $items['products/mycity'] = array(
    'type' => MENU_CALLBACK,

    'title' => 'Enjoy shopping in MyCity',

    'page callback' => 'html_list_products',
    'access arguments' => array('access products')
  );

  $items['products/autocomplete.json/%'] = array(
    'type' => MENU_CALLBACK,

    'page callback' => 'json_list_products',
    'page arguments' => array(2),
    'access arguments' => array('access products')
  );

  return $items;
}

What or how do I add to the menu_hook above so that I can process form submissions done through the above block code???

Alex


texts: I am using drupal 7 built in search  module. In my custom content type, I have multiple products for Industrial,mechanics and sports categories. I need to apply search restriction on some products for my mechanics category. Means If mechanics_product1, mechanics_product2 and mechanics_product3 are mechanics products then I need to apply search restriction on all products for only mechanics_product2. Only authorize user will be only able to search this particular product.


texts: Is it possible to create content and link it to an existing menu item?

texts:
I have a menu tree with links all directing to 'front'.

On creating content I don't want to create a new menu item but want to have an extra option under the Menu settings saying 'Add content to existing menu item'.

What is the best way to achieve this or is there a module available that handles this situation (D7)?


texts: Extract PDF front page and store it as an image field in node

texts:
I'm using Document Library module to manage my files and create listings for them.

I've also noticed the existence of PDFPreview module and I'd like to ask if the following is possible:

I'd like to upload a pdf file in a Document Library Document item and with this file to generate an preview image, stored as a new independent field (lets say the Thumbnail image field) in this content type. As things are now the preview replaces the file field which is something that I need to avoid.


texts: How do you enable translation for a field which was defined by a contrib module?

texts:
I am trying to enable translation for a field which was defined by a different module.

The problem is this field does not list in the UI. When I checked the definition for this field in hook_entity_field_storage_info I can see the setTranslatable(TRUE) is missing. So I added the same in hook_entity_field_storage_info_alter . After this I can see the field listing in the UI for translation, but when I enable the checkbox and submit the value is not saved.

How can I enable translation for this field?


texts:
$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", 1));

with this code i can get title from node with id == 1. But how can i load all node titles with specific content type?

$title = db_result(db_query('SELECT title FROM {node} WHERE type = %s', $content_type));

Please correct my code to get all node titles from specific content type and how to limit them by 20 items for example?


texts: Why is the CSS for my theme not loading while the JS is?

texts:
Theme mytheme is placed under /sites/all/themes/

Content of mytheme.info.yml :

name: My Theme
type: theme
description: Custom theme.
core: 8.x
base theme: classy
version: 8.x-1.0
libraries:
  - mytheme/global-styling
regions:
  logo: 'Logo'
  navigation: 'Navigation'
  page_header: 'Page Header'
  content: Content  # the content region is required
  page_sidebar: 'Page Sidebar'
  contact_first: 'Contact (First column)'
  contact_second: 'Contact (Second column)'
  contact_third: 'Contact (Third column)'
  footer_logo: 'Footer logo'
  footer_first: 'Footer first'
  footer_second: 'Footer second'
  footer_third: 'Footer third'
  footer_copyright: 'Footer Copyright'
regions_hidden:
  - sidebar_first

Content of mytheme.libraries.yml :

global-styling:
  version: 1.x
  css:
    theme:
      assets/plugins/bootstrap/css/bootstrap.min.css: { minified: true }
      assets/plugins/font-awesome/css/font-awesome.min.css: { minified: true }
      assets/css/style.css: {}
      assets/fonts/montserrat/montserrat.css: {}
  js:
    assets/plugins/jquery-1.11.1.min.js: { minified: true }
    assets/plugins/bootstrap/js/bootstrap.min.js: { minified: true }
    assets/plugins/moderniz.js: {}
    assets/js/app.js: {}
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupalSettings

The JS is loading but the CSS isn't. How come?


texts: Is it normal after editing an item in one display for Views to always go back to the first display

texts:
Drupal7 & Views 7.x-3.3 My site installation of Views has several working Views. There is a strange behavior in the GUI and its very annoying. After editing an item, Views always goes back to the first display!?!

For example, the included example view, "Front page (Content)", has two displays, Page & Feed. To recreate this annoyance edit the Front Page View, then:

Select the display Feed;
Edit any item, such as: Display name: / Page /
Make changes, then save;

Page refresh returns to Front Page's View edit page, and in my installation the Feed display is no longer selected. Now the Page display is selected. This happens every time for all Views. After editing an item in one display, the page refreshes back to the first display (at left). This was not the case with Views 2 and Drupal 6. Its the equivalent of changing tabs after saving something.


texts: drupal 7 programatically close comments in custom node type

texts:
I have created a content type programmatically. Also looked at http://drupal.org/node/1169864 but comments are not being close. Although I solve it by variable_set('comment_mynodetype', '1'). Any other help.
My code is below:

$t = get_t();

  $node = array(
    'type' => NODE_NAME,
    'name' => $t('My Node Type'),
    'base' => 'node_content',
    'locked' => TRUE,
    'node-preview' => 0,
    'node-options' => array('status'),
    'comment' => array('status' => 1),
    'description' => $t('A content type.'),
    'title_label' => $t('Title'),
    'custom' => FALSE
  );
  $content_type = node_type_set_defaults($node);
  //add body field using drupal function
  node_add_body_field($content_type, $t('Description'));
  node_type_save($content_type);

Any help ..

[UPDATED]

 $node = array(
        'type' => NODE_NAME,
        'name' => $t('My Node Type'),
        'base' => 'node_content',
        'locked' => TRUE,
        'node-preview' => 0,
        'node-options' => array('status'),
        'description' => $t('A content type.'),
        'title_label' => $t('Title'),
        'custom' => FALSE
      );
   //close comments
   variable_set('comment_mediasite', '1');


texts:
I have installed Devel and XHprof to profile (kind of performance analysis) my website . Configured everything but i am confused with this setting

  XHProf URL: Path to the publically accessible xhprof_html - required to display profiler reports. You will need to set this up
  outside Drupal, for example at http://xhprof.localhost/xhprof_html

my drupal installation is in inside /www/
please help


texts: Override and add a link to a themed table

texts:
Using a custom module, I'm trying to add "Schedule" links to each of the rows of the table on node/%nid/revisions, but can't seem to figure it out.  Do I have to override the entire function node_revision_overview in node/node.pages.inc?

There is another table I would like to this to as well.  So in general, I thought this would be a good excercise to learn Drupal theming.

Any help is appreciated.


texts: Profile 2 different types with single edit form

texts:
I am using the profile2 module to create different types of information for the user.  One of these profile types are filled in on the registration page.

What I am trying to accomplish is combining the registration form profile with another profile so that they can be edited on the same form page.

For example: The fields of Profile-Registration and Profile-Info must all be editable on www.website.com/form/%user/edit.  These fields are rendered with views, and are working perfectly.  It is just the editing I am trying to figure out.  I am not sure how to go about achieving this.


texts: For node, we can change the created date easily, what about user ? Is there any easy way or module that can expose this field for editing instead via database ? I have many old users to be keyed in again manually into drupal, so I need to change this date of creation at the time of creating the user.


texts:
I know that drupal comes along with 2 default stream-wrappers(public and private).
What I want to achieve is to have my images placed in an another server, where they can be accessed by a url similar to http://cdn.mysite.com/image/etc.png.

https://www.drupal.org/project/remote_stream_wrapper allows the use of http, and https as stream wrappers. How am I suppose to use this programmatically?

When a file is loaded "public://" is replaced by the actual public URL, how does this work with the above module? Could you provide any other info on how to tackle this issue?


texts: Add a "Like" button after "Edit" and "Reply" links

texts:
How can I add a Like link using the Flag Module, exactly after the Edit and the Reply links?

I know I must use print flag_create_link('bookmarks', $node->nid);, but I don't know exactly where to place it.


texts:
I need some suggestions, I am not sure which direction to go to do this, but I need to do 4 different landing pages, with 4 different urls, example http://site.com/landingpage?blue=1, http://site.com/landingpage?blue=2.

Now everything is almost the same on the landing pages except for a banner thats going to be on the front and on 2 of the landing pages the layout will be different. I am using panels for the pages. Should I make 4 different panels for them or can panels allow me to change different elements on certain urls? How would I do that using panels? Or would you suggest a different module?

Any suggestions is appreciated,
Thanks


texts: CKEditor: *During* WYSIWYG edit, how to show caption beneath image?

texts:
When editing a body field with image and caption, the caption does not display during editing. Once saved it is visible - when the content is viewed.

Implementation-wise, I've added a caption field to the Image entity via the Entity View Mode config pages - admin/structure/file-types/manage/image/fields

Any thoughts on how to get the caption to show during edit?

CKEditor 4.3 supports captions but there would need to be support for the Drupal side of the implementation.


texts: Where is the maintenance mode value in the database?

texts:
I know the maintenance mode value used to be in the variables table, but in D8 that table is replaced by (or joined with) the config table, but I couldn't find any row with that name.

Where is it located now?


texts: Site index removes "www" from url and files (e.g., '/about') don't work with "www."

texts:
I have a peculiar problem in that people visit any other page other than the homepage with the "www." before the url they will receive an error.

If they visit the index with the "www." it is removed and whatever links they click will work as it doesn't have the "www." in front.

http://www.domain.com/        - will change to http://domain.com and work fine
http://www.domain.com/about   - will return '404 Not Found'
http://domain.com/about       - will work fine

I have Clean URL's installed (but I can't seem to change any settings in it) and I don't remember touching the .htaccess file.

Any help is much appreciated, thanks.


texts: Testing if email was sent in Kernel test

texts:
I am trying to write automated tests for a or that will sent an email on submission.
I can write the test to check for the presence of the entity that is created along side the email, but I also want to have my automated test check that the system is sending an email too.
The examples I can find seem to relate to Laravel and the use of spies to see if a particular class method is called, however I can't find any examples of how to do that in Drupal 8 and in my particular use case I am using the function _user_mail_notify() and not a class method.
Does anyone have an example of testing that emails have seen sent at all?


texts:
I have created the following construction. If a student choose option A with the if construction the following step in the wizard is the internships with medicine domain A, but what if the school create another medicine domain B. With this construction the student will only see the internship domain A and not the medicine domain a AND b. I'm looking for a construction that grows with my Taxonomy (shows medicine domain a and b and if the school create 5 months later a medicine domain c that last one must seen by the student also), so if a student choose medicine than he get all medicine domains (medicine domain a and b and so on) and not just $internship domain a as defined in my if structure. Hope you understand my problem because it is explained in terrible English.

enter code here
case 2:

// Taxonomy list: 'valid type of internship'.

$valueInternship = $_SESSION['gekozenOpleiding'];

//var_dump($valueInternship);

if($valueInternship == 1) { // Stagedomein a
    $internship = 10;
}

if($valueInternship == 2) { // Stagedomein b
    $internship = 11;
}

if($valueInternship == 3) { // Stagedomein c
    $internship = 13;
}

if($valueInternship == 4) { // Stagedomein d
    $internship = 12;
}

if($valueInternship == 5) { // Stagedomein e
    $internship = 14;
}

$dropdown_source_geldig_soort_stage = taxonomy_get_tree($internship);
$dropdown_array_geldig_soort_stage = array();
foreach ($dropdown_source_geldig_soort_stage as $item) {
    $key = $item->tid;
    $value = $item->name;
    $dropdown_array_geldig_soort_stage[$key] = $value;
}
$form['geldig_soort_stage'] = array(
        '#key_type' => 'associative',
        '#multiple_toggle' => '1',
        '#type' => 'checkboxes',
        '#options' => $dropdown_array_geldig_soort_stage,
        '#title' => 'Welk geldig soort stage',
        '#multicolumn' => array('width' => 4,
                '#default_value' => isset($default_value['geldig_soort_stage']) ?
                $default_value['geldig_soort_stage'] : '',
        ),
);
break;


texts: My subtheme css is overriden by the parent theme. How to I reverse this?

texts: I have created a subtheme and for some reason the css I add in there to override the parent theme doesn't work. THe parent theme's css seems to be prioritized over my new stuff. Is there any way of weighting themes or ordering loading of themes?


texts: Select list in entity reference in VIews

texts:
How to create an entity reference exposed filter in drupal 8 in Views?
The only option i have is input of type text


texts: How to reuses page--front.html.twig for multiple pages

texts:
I created a page--front.html.twig which allows me to create a distinctive front page.

How would I go about reusing this page to create a landing page, a page with an identical layout the front page has?


texts: How do I get the number of rows affected from an update query?

texts:
I'm having trouble figuring out how to get the number of affected rows from an update query in Drupal.
I have a form where users can update their profile details. Now, not every user is going to update everything from their profile. They may just update one field or two.
How do I account if there was a change or not and check for the affected rows?
This is the code I am running.
$update_query = $db->update('TABLE NAME')
  ->fields([
    'uid' => $uid,
    'name_of_user' => $name,
    'url' => $url,
    'website' => $website,
    'industry' => $industry,
    'company_size' => $companySize,
    'company_type' => $companyType,
    'headquarters' => $headquarters,
    'founded' => $founded,
    'page_picture' => $upload_picture,
    'tagline' => $tagline,
    'updated_at' => $time,
  ])
  ->condition('uid', $uid);

  $affectedRows = $update_query->execute()->rowCount();
  return new AjaxResponse($affectedRows);

The code doesn't return anything. I even checked the network tab and there's nothing displayed in the response tab. I should be getting back either 0 or 1. Am I missing something?


texts: Creating multiple image crops with each instance of an image upload

texts:
Can anyone tell me if there is a way to define multiple image sizes and create those images sizes each time an original image is uploaded?

I've been using imagecache but unless I'm wrong, it doesn't help when you want to create multiple images of various sizes when an original is uploaded.

Can anyone help?


texts: Sorting orders by name rather than by order number

texts: On my orders page you can search orders by order number only - how do I change this so I can also sort by name, date, ect. When we have customers come in that do not know their order number, we cannot search for their name! The name column on our orders table also does not sort correctly, you can sort by most recent or oldest date, but you cannot sort names alphabetically. Not sure how to change this. Thanks!


texts: Block-Placement in a Feature via Context

texts:
I have got a Feature consisting of a few boxes and a context which puts those boxes in the right regions. That works if I install drupal and my theme and activate the feature.

But it does not work if i install it using drush site-install and my installation profile which contains my theme and my feature. I guess this is because the theme gets activated after the feature and so the feature does not know the regions while activating. What would you recommend to solve this? I could remove my feature as a dependency and activate it manually after my theme in myprofile.install, but is there a "cleaner" approach?


texts: How to access webform elements in webform.html.twig

texts:
I'm trying to figure out a way to access webform elements from webform.html.twig.

I need to style the form; wrapping some elements and adding bunch of styles
all I have in the webform.html.twig is "children" variable which renders the whole form, whereas I need to access every element individually.

I found a link on the web for webform-form.html.twig which might do what I need, however I can't find it in webform template folder

http://cgit.drupalcode.org/webform/tree/templates/webform-form.html.twig?id=1135b65031cd6cd195c2e638300e5ef945a6f652

Any help with this matter is much appreciated.


texts:
I have bad-designed a view, and the result is that I have the following scheme:

Field 1: Category (taxonomy)
Field 2: Node title
Field 3: Image
Field 4: Other data (PHP processed).

The problem is that I need field 1 to appear just once for a group of nodes and not always. As I had to redo all the View, I have made the following process, please tell me if there is a better solution.

Instead of not displaying field 1, grouping by that, etc., as I have some PHP process on it, I do the following:

In views-view-fields.tpl.php I identify the category, and prepend [[BEGIN]]. I identify the last field and append [[END]].

In views-view-unformated.tpl.php I replace [[BEGIN]] and [[END]] with <div> wrappers; depending on the valued inside (preg_match), I make the category title  appear just once at the beginning of the list of products.

Please tell me if that is a valid approach (it works) or it should be more desirable to re-draw the view (hours of changing fields, logic, etc.).

The string replacement outputs an additional <div> which wraps all the complete row of fields. This I had in the view as the field 1 was just another field and did not encapsulate anything. Maybe even if I would set it as grouping field it didn't encapsulate anything. The result I want (and get) is:

<div class="other-class" id="category-119"> divs and HTML stuff from the view  </div>

The only easy and fast way of doing a <div> encapsulation of the row is using those delimiters in the template files.


texts:
Adding some tests to an older Drupal 7 site and a few of the tests check for the presence or lack thereof of custom cache items.

Having this in settings.php seems to interfere with Simpletest using default database cache (this is included to settings.php as a local settings override):

  $conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
  $conf['lock_inc'] = 'sites/all/modules/contrib/memcache/memcache-lock.inc';
  $conf['memcache_stampede_protection'] = TRUE;
  $conf['cache_default_class'] = 'MemCacheDrupal';

  // The 'cache_form' bin must be assigned no non-volatile storage.
  $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

  // Don't bootstrap the database when serving pages from the cache.
  $conf['page_cache_without_database'] = TRUE;
  $conf['page_cache_invoke_hooks'] = FALSE;

  $conf['memcache_servers'] = array('cache:11211' => 'default');

Is there any global flag I can look at at this point to determine whether or not to add these overrides in?

I tried checking the $GLOBALS for a test id and drupal_valid_test_ua but in both cases the memcache information was still used.

If I comment out the memcache settings, I can see the cache tables in simpletest are populated as expected. How can I get around this?

edit: looks like testing specific settings.php is not possible in 7.


texts: Google invisible recaptcha doesn't work with form file fields

texts:
I have a form in my drupal project which has a managed_file field. It worked perfectly until I added invisible recaptcha for the forms. The file is getting uploaded but when I submit the form the windows gets refreshed with all the elements without doing anything.

Form Fields

$form['fileLoad'] = [
    '#type'              => 'managed_file',
    '#name'              => 'fileLoad',
    '#title'             => t(''),
    '#size'              => 20,
    '#description'       => t('Word/Excel/PDF/JPG/PNG formats supported'),
    '#upload_location'   => 's3://forms/contactus',
    '#upload_validators' => [
        'file_validate_extensions' => ['pdf doc docx xlsx jpg png'],
    ],
    '#attributes'        => [
        'id'    => 'fileLoad',
        'class' => ['form-control'],
    ],
    '#required'          => false,
];

$form['submit'] = [
    '#type'       => 'submit',
    '#value'      => t('submit'),
    '#attributes'   => [
        'id'            => 'validateBtn',
        'data-sitekey'  => "##MYSITEKEY##",
        'data-callback' => "onSubmit",
        'class'         => ['g-recaptcha', 'cus-btn-book-now'],
    ],
    '#validated'  => true,
];

Invisible recaptcha script

<script src='https://www.google.com/recaptcha/api.js'></script>
<script>
   function onSubmit(token) {
       document.getElementById('contact_us_form').submit();
   }
</script>

The form works perfectly

With the managed_file field, without invisible recaptcha (works perfectly with recaptcha V2)
Without managed_file field with the invisible recaptcha

I guess the form doesn't work when both the invisible recaptcha and managed_file field present. What would be the solution?


texts: Filter completed events by using end time filter (greater than or equal to 'now')

texts:
I'm almost done with integrating the Fullcalendar module into my website, but I am concerned about the loading time. I have about 200 events, and getting even more which are repeated daily, weekly, monthly. It's impossible to load all these events initially, since it requires tons of queries, and I got a time-out error from Apache. They cannot be cached either.

What I want to do to improve it is initialize the full calendar view in day-view mode, then just fetch the events in the next 7 days, and disable the completed events. Take a look at the date field table, I saw one repeating event will be divided into entities that have their own start and end date for each day, so guess it's possible to filter them out by a view date filter.

I added a view filter as the attached image.  Output query is correct.

The result just remained the same: It displayed the events in the past and in the far future.

I've already tested this filter with an ordinary view and get the expected results. So I'm kind of sure the issue only comes from the module code. For some reasons it doesn't apply the filter. I have been spending several days on examining the code, but didn't have any luck yet. Anyone experienced this or has a better idea to improve the loading time please leave some words. I'd appreciate any time spent on this topic.

You can view my full view at http://citypassguide.com/vietnam-deals.


texts: How can I make special non-Drupal URLs without file extensions?

texts:
As I understand it, Drupal is supposed to check the web root for any URLs it doesn't recognize, to see if it's a non-Drupal file on disk.  Also, Apache is supposed to assume that anything without a file extension is a request for whatever.html, correct?

Here's what I'm trying to achieve: a user requests mysite.com/FOO, Drupal doesn't find any path/alias for FOO, and thus turns it over to Apache.  Apache doesn't see a file extension, and thus looks for a file called FOO.html (which exists) and serves up that file.

If I request mysite.com/FOO.html, the file is returned just fine.  I'm just trying to make it so that people can access FOO.html by simply requesting /FOO, since you can't trust the user to type in the full URL.  (And because it looks nicer in a print ad.)

I'm guessing that there's some .htaccess magic that needs to happen, but I haven't been able to come up with the right trick. I think that Drupal passes to Apache, which doesn't find /FOO, then the .htaccess file punts the request to Drupal's index.php, which returns the Drupal 404 page.


texts:
I am using Layout Builder and I would like to tweak template file a bit.
I can see suggestions here:

But although I added file layout-twocol-section--node-npx-training-teaser2.html.twig in my theme templates folder, Drupal was still picking up the core layout--twocol-section.html.twig
I thought that maybe for some reason it doesn't look to my theme templates folders in this case (it certainly is picking up other custom templates from this folder), but when I placed there layout--twocol-section.html.twig file in my theme templates folders it is being picked up, so only the other suggested templates are not being picked up, I tried also layout-twocol-section--node-teaser2.html.twig, but without luck.
Why is that? Should I point Drupal to these templates somehow? These suggestions are just generic suggestions from Layout Builder, I was able to find them also on my node display:

As you can see the names of the suggested files are a bit different so I tried
layout--twocol-section--node-npx-training-teaser2.html.twig and layout--twocol-section--node-teaser2.html.twig, but no luck.
Caches were cleared multiple times :)


texts: How to update Twig - does it need to be updated?

texts:
Does Twig will be updated automatically? Or does an updated version comes with a new Drupal 8.x release? Or does Drupal just stuck on the current version?
I'm just wondering because Twig will be further developed. Thanks.


texts: How to sort drush status messages in test scripts?

texts:
I'm using drush to run test scripts agains my drupal 7 installation. Simply calling:

$ drush scr path/to/myScript.php

My script is using drupal_set_message() to output status of my test scripts.

My problem is the output is sorted by importance, like that:

Test 1339 failed.                [error]
Test 1338 failed.                [error]
Something strange happened!      [warning]
Test 1337 successful.            [status]
Script starting.                 [notice]
Script finished after 1234ms.    [notice]

Is there any way to sort the output of the messages by the time they get called in my script, it would look much more logical like that:

Script starting.                 [notice]
Test 1337 successful.            [status]
Test 1338 failed.                [error]
Something strange happened!      [warning]
Test 1339 failed.                [error]
Script finished after 1234ms.    [notice]

Is that possible somehow? Is drupal_set_message() the wrong approach? Any suggestions?


texts: Why default template suggestion use double dash instead of single dash?

texts:
block--module--delta.tpl.php
page--front.tpl.php

As above example, what is the reason behind double dash? Why not use single dash like page-front.tpl.php?


texts: Using the Migrate Source CSV plugin to migrate images

texts: I'm currently importing nodes from a Drupal 7 to Drupal 8 site, using this very helpful tutorial: https://www.drupal.org/docs/8/upgrade/using-the-migrate-source-csv-plugin I have found a fairly good way to import fields. My only stumbling block at the moment is images. I'm finding it very hard to find anything about how I would manage importing of images, whether if I give it the path of the old images it can import from there, or if I give it a file name, then put the image somewhere, I have tried both so far and the image field always just ends up blank in the new nodes that are created. I've got my head around using the above links approach so if anyone has a solution that fits with that, that would be great!


texts: How to get the View Object from ViewsBlock?

texts:
I'm loading a variable list of blocks. In some cases these blocks are a views_block type. When I load a views_block, the viewsblockbase provides the protected View object, but does not provide a method to retrieve it.

How would I go about retrieving the full view object from a views_block?

I considered a ViewsBlock::Create() approach however this would be redundant which Im trying to avoid. Likewise, I have the view_id and display_id but would rather not Views::GetView() when the object is already sitting right there in the loaded block.

snippet

<?php

public function buildDashboard() {
  // $block_instance = new DashboardBlockManager;
  $block_instance = \Drupal::service('plugin.manager.block');
  $blocks = $this->getBlocks();
  foreach ($blocks as $region => $region_blocks) {
    foreach ($region_blocks as $index => $block_id) {

      //$block_id example views_block:dashboard_tasks_by_assignee-block_1

      $load_block = $block_instance->createInstance($block_id);

      $title = $load_block->label();
      $build_block = $load_block->build();
      $build_block['#block_title'] = $title;

      //check the plugin type
      $definition = $load_block->getPluginDefinition();

      if ($definition['id'] == 'views_block') {
        //cant do this
          $view = $load_block->view;
      }
}


texts: composer require --dev drupal/devel isn't working

texts:
I followed the instructions on prkos.hr/Install-Drupal-8-Ubuntu-1404-LTS for installing Drupal 8 and tried to install 'devel module' but had the error

composer require --dev drupal/devel
[InvalidArgumentException]
Could not find a matching version of package drupal/devel. Check the
package spelling, your version constraint and that the  package is
available in a stability which matches your minimum-stability
(stable).
require [--dev] [--prefer-source] [--prefer-dist] [--fixed]
[--no-progress] [--no-suggest] [--no-update] [--no-scripts]
[--update-no-dev] [--update-with-dependencies]
[--update-with-all-dependencies] [--ignore-platform-reqs]
[--prefer-stable] [--prefer-lowest] [--sort-packages]
[-o|--optimize-autoloader] [-a|--classmap-authoritative]
[--apcu-autoloader] [--] []...

Also I tried with the same result (from www.drupal.org/project/devel/releases)

composer require --dev drupal/devel 2.x-dev
composer require 'drupal/devel:2.x-dev'
composer require 'drupal/devel:^2.0'
composer require 'drupal/devel:^2.1'

and

composer require drupal/devel:~1.0

Additional info:

Composer version 1.10.8 2020-06-24 21:23:30
access right for folder and all sub-folders drwxrwxrwx (chmod 777 ./ -R)


texts: Can Xdebug be triggered by Drush commands?

texts:
I'm running into an issue with my Features modules and installation profile when installing the site with drush si. There are a number of probably related issues in the Features issue queue, but none with good solutions. The interesting part (mentioned in some of the issues) is that it works fine when installing the site through the browser, but fails when installing with drush si.

I have an idea of what's wrong, but need to confirm it. The only way I can think of confirming it is to step through the code with a debugger (Xdebug is what I have set up). So, is it possible to trigger Xdebug from a command run with Drush? Specifically, can I get Xdebug to kick in when I run drush si?


texts: How can I dynamically get the fields on an image media bundle?

texts:
What’s the correct way to get all of the key/values for a bundle on a media entity?

I am trying to create a media entity programmatically and I need to get all of the fields on the image bundle. I am not sure how to get the image bundle ID either.

In other words, I’d like the module I'm working on to be a bit more generic and reusable as I’ve seen the image bundle have different names depending on the installation.

Here’s what I have so far but the two main problems I see are that the image bundle ID can change and the field names on the bundle can be different.

   $entity = $this->createFile(
      $uri,
      $file[0]['filename'],
      $file[0]['filesize'],
      $this->currentUser
    );
    $entity->setPermanent();
    $entity->save();
    // Save media entity
    $media = [
      'bundle' => 'image',
      'uid' => $this->currentUser->id(),
      'status' => 1,
      'image' => [
        'target_id' => $entity->id(),
        'alt' => t(basename($file[0]['filename'])),
        'title' => t(basename($file[0]['filename'])),
      ],
    ];
    $image = $this->entityTypeManager->getStorage('media')->create($media);
    $image->save();

I'd like to be able to get the image bundle and dynamically figure out whichever field has the target_id and then assign the previously created file entity to that. I do not know how to get the image bundle schema, array signature, in order to traverse the key/values to find the target_id


texts: Modifying only node forms, not forms appearing in blocks?

texts:
I have a contact webform in a block in a sidebar that appears on every page.

I also have some webform nodes.

I want to use hook_form_alter() to modify the forms that are nodes, not those that appear in blocks.

How can I differentiate between the two in code?


texts:
I have a site running Drupal 7, and hosted on GoDaddy.

I use Filezilla FTP client to upload the files, or do any kind of file management on the server.

When I upload a file, the site shows a 500 error. After 25-30 minutes, the site starts working as usual.

This happens every time I upload a file.


texts: Views show fields is set, but only "Content" options are available to select - why?

texts:
Simple question. I thought I knew views, but right now I'm stuck. All I want is a view with the body field of a certain content type.

I have "Fields" selected:

But when I go to add a field, my options are severely limited:

(There is no such thing as a "Content: Body" option to select.)

What happened to the rest of the categories in the Filter dropdown? I'm missing something obvious here...?


texts: How to exclude execution of EntityCache module for a specific page?

texts:
The Entity сache module caches entities very deeply and
this module is incompatible with CacheExclude module.
As well as DRUPAL_NO_CACHE option for blocks does not work for Entity сache module.

How can I forbid this module for specific page (or piece of code)?


texts: D8: Unable to set cache max-age on ResourceResponse

texts:
I'm trying to create a REST API get response. My class extends ResourceBase and this is inside my classes get function.

$response = new ResourceResponse(['time' => time()], 200);

$cache_meta_data = new CacheableMetadata();
$cache_meta_data->setCacheMaxAge(2);
$response->addCacheableDependency($page);
$response->addCacheableDependency($cache_meta_data);

return $response;

This will return the timestamp, but it will be cached forever until I manually clear the Drupal cache. When I curl the interface this is the output for the first hit.

curl 'https://mylocaldrupal.dd:8443/rest/upcoming_matches/1?_format=json' -i -k
HTTP/1.1 200 OK
Date: Sun, 11 Feb 2018 17:03:06 GMT
Server: Apache/2.4.17 (Unix) OpenSSL/1.0.1h mod_fcgid/2.3.9
X-Powered-By: PHP/7.0.14
Cache-Control: must-revalidate, no-cache, private
X-Drupal-Dynamic-Cache: UNCACHEABLE
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
X-Generator: Drupal 8 (https://www.drupal.org)
X-Drupal-Cache: MISS
Transfer-Encoding: chunked
Content-Type: application/json

{"time":1518368586}

And a second hit after a few seconds:

curl 'https://mylocaldrupal.dd:8443/rest/upcoming_matches/1?_format=json' -i -k
HTTP/1.1 200 OK
Date: Sun, 11 Feb 2018 17:04:41 GMT
Server: Apache/2.4.17 (Unix) OpenSSL/1.0.1h mod_fcgid/2.3.9
X-Powered-By: PHP/7.0.14
Cache-Control: must-revalidate, no-cache, private
X-Drupal-Dynamic-Cache: UNCACHEABLE
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Expires: Sun, 19 Nov 1978 05:00:00 GMT
X-Generator: Drupal 8 (https://www.drupal.org)
X-Drupal-Cache: HIT
Transfer-Encoding: chunked
Content-Type: application/json

{"time":1518368586}

Can't really figure it out and the Drupal.org docs doesn't really seem to help me neither. Am I missing something obvious?


texts: How have multiple instances of a Custom Block?

texts:
So I have a custom block that has been created within the module. I have used the drupal API to generate the brand new fields - which works perfectly.

However, I am having an issue regarding multiple instances of the custom block. As I want the blocks to be sandboxed as the custom fields are only related to the block used within the one region.

Now using Multi Block, I can create another instance of that block but the field is exactly the same. What would be the best approach for having one block but whenever its used, its custom fields per block.

case 'live_chat_block' :
    variable_set('text_variable', $edit['text_body']);
break;

Now the idea I had was to add in the "panel page" as variable ID but there might be a better way. Any suggestions would be useful.

Just to expand on what i would like to achieve:

We currently have panel pages implemented and we have built a custom block with custom fields inside that custom block. The requirement is that every block that we drag into one of the panel pages, we would like for them to have unique fields.

Panel Page: 1
Block ID: 123
Custom Field Title: Superman

Panel Page 2:
Block ID: 123
Custom Field Title: Batman

Now as you see, the only thing that changes is the panel pages, the block stay the same and the custom fields need to be unique to that panel page and not the block.

Currently, when changing one block, it impacts on all the other blocks as well.

function livechat_block_configure($delta=''){
  $form = array();

  switch($delta) {
     case 'live_chat_block' :
        // checkbox example:
      $form['text_body'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter in Title here'),
        '#default_value' => variable_get('text_variable', ''),
      );

        break;
  }
  return $form;

}


texts: I added some lines in my .htaccess file, following Is it possible to leverage browser caching?, but Page speed tool still throws "Leverage browser caching error." for only images.


texts: How to create a collapsible Webform form?

texts:
I'd like to make a webform collapsed by default, and have a Sentence/paragraph at top of the page with a checkbox next to it. Upon ticking the checkbox I would like the webform to be displayed.

Similar to Form 2 - Adding Fieldsets on this site: http://dev.sencha.com/deploy/ext-4.0.0/examples/form/dynamic.html

How would I go about doing this?


texts:
I know this has been asked before and I'm trying to use the example at Dynamic select list in the form (dependent dropdown) but I am struggling to get the desired results.

The goal:
Have a form that presents the user with a Platform select field. Once selected take the value from that field pass it to the a SQL statement to render an additional select field with a list of results from the query. Right now the following code displays both select fields when the form renders. I would like only the platform select field to be rendered until the user chooses an option.

I'm a little bit confused about the AJAX function and how you wrap another select item to be marked for replacement when the page is called again so any explanations or pointers would be great.

Per @Clive I've adjusted the code below. However I'm fighting with pulling the selected value into the model lookup query statement. Right now as is the form doesn't even render.

Update 2

I've been cleaning up my code and catching small stupid errors. Which have yielded: 1)AJAX call back working. 2)Hiding the model select field when the platform select hasn't changed.

However I can't seem to make the model field appear when an option is selected in the Platform field. I suspect it's a problem with if (isset($form_state['values']['platform'])) {. Updated full code below. I feel close to completing this just need some guidance.

Full Code

function iosupload_menu() {
$items = array();
$items['ios_upload/form'] = array(
  'title' => t('IOS Upload'),
  'page callback' => 'iosupload_form',
  'access arguments' => array('access content'),
  'description' => t('IOS Upload'),
  'type' => MENU_CALLBACK,
);
return $items;
}

function iosupload_form() {
return drupal_get_form('main_iosupload_form');
}

function main_iosupload_form($form, &$form_state) {
//Define SQL Lookup Query
$sqlplatform = "SELECT vid, name FROM {taxonomy_vocabulary} WHERE vid >= 4";

$result = db_query($sqlplatform);
$options = array();
  foreach ($result as $row) {
    $options[$row->vid] = t($row->name);
  }

$form['platform'] = array(
  '#type' => 'select',
  '#title' => t('Select a Platform'),
  '#options' => array(
    0 => t('- Select -')) + $options,
  '#default_value' =>  0,
  '#required' => TRUE,
  '#ajax' => array(
    'callback' => 'ajax_select_callback',
    'wrapper' => 'replace_model_div',
    'effect' => 'slide',
   ),
);
if (isset($form_state['values']['platform'])) {
 $platform_value = $form_state['values']['platform'];
 $sqlmodel = "SELECT tid, name FROM {taxonomy_term_data} WHERE vid = $platform_value";
 $result = db_query($sqlmodel);
 $options = array();
   foreach ($result as $row) {
     $model_options[$row->vid] = t($row->name);
    }

$form['model_wrapper'] = array(
  '#type' => 'select',
  '#title' => t('Select a Model'),
  '#options' => $model_options,
  '#options' => t('$platform_value'),
  '#prefix' => '
',
  '#suffix' => '
',
);
}
return $form;
}
function ajax_select_callback($form, $form_state) {
  return $form['model_wrapper'];
}


texts:
I'm a bit new to drupal and I have a task, where I have to create a node when cron runs. I set up the node like this in my custom module's cron hook:

$node = new stdClass();
$node->type = 'reports';
$node->language = LANGUAGE_NONE;
$node->uid = 1;
$node->status = 1;
$node->promote = 0;
$node->comment = 0;
$node->sticky = 0;
$node->moderate = 0;
$node->title = 'Daily Report for ' . date('d.m.Y');
$node->field_reporting_cycle[LANGUAGE_NONE][0]['value'] = 1;
$fid = generate_periodic_report(1);
$node->field_period_of_reporting[LANGUAGE_NONE][0]['value'] = date('Y-m-d', strtotime('-1 days'));
$node->field_period_of_reporting[LANGUAGE_NONE][0]['value2'] = date('Y-m-d');
$node->field_reciver[LANGUAGE_NONE][0]['value'] = 2;
$file = file_load($fid);
$file = (array)$file;
$file['display'] = 1;
$node->field_report_file[LANGUAGE_NONE][] = $file;
node_object_prepare($node);
$node = node_submit($node);
node_save($node);

The node doesn't get created. I don't get any error messages in the log. I don't know what I'm doing wrong.


texts: Creating a Testimonials Content Type and making it work as it should

texts:
I have a Testimonials content type which asks for a visitor's name and testimonial. Is it possible to make this form available to Anonymous users so anyone can post a testimonial without having to register?

I don't want people going through the Admin theme so I'm guessing I'll have to create my own form in the standard theme but how do I connect that to the actual Content Type? Posts must also not be published immediately but are set for moderation so I myself can say who gets in and who doesn't. Is this possible?


texts: How to override jquery update preprocess page

texts:
The objective is to exclude certain javascript files from some sections of the website.

I exclude javascript and css files in this way in the template.php file of the theme:

function phptemplate_preprocess_page(&$vars) {
  $scripts = drupal_add_js();
  //PRINT THIS ARRAY AND UNSET THE UNWANTED ARRAY
  // unset($scripts['module']['sites/default/files/js/jquery-min.js']);
  unset($scripts['module']['YOUR_PATH_TO_JS']);
  $vars['scripts'] = drupal_get_js('header', $scripts);
}

However it seems that jquery_update preprocess is executed after template.php, so it overrides my changes:

function jquery_update_preprocess_page(&$variables) {
      ...
      $variables['scripts'] = drupal_get_js('header', $scripts);
}

The code is located in jquery_update.module

How would be the best approach to resolve this?

I would prefer not to hack or disable the jquery_update.module code if possible.

Any alternative ways to exclude javascript files that doesn't involve touching the template.php file would also fix my problem I think.


texts:
I am trying to register and log in users via the Services module 7.0-3.11 on Drupal 7.36.

The endpoints are declared from the following code.

$endpoint = new stdClass();
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'user_service';
$endpoint->server = 'rest_server';
$endpoint->path = 'user_api';
$endpoint->authentication = array(
  'services' => 'services',
);
$endpoint->server_settings = array(
  'formatters' => array(
    'json' => TRUE,
    'bencode' => FALSE,
    'jsonp' => FALSE,
    'php' => FALSE,
    'xml' => FALSE,
  ),
  'parsers' => array(
    'application/json' => TRUE,
    'application/vnd.php.serialized' => FALSE,
    'application/x-www-form-urlencoded' => FALSE,
    'application/xml' => FALSE,
    'multipart/form-data' => FALSE,
    'text/xml' => FALSE,
  ),
);
$endpoint->resources = array(
  'user' => array(
    'operations' => array(
      'retrieve' => array(
        'enabled' => '1',
      ),
      'index' => array(
        'enabled' => '1',
      ),
    ),
    'actions' => array(
      'login' => array(
        'enabled' => '1',
      ),
      'logout' => array(
        'enabled' => '1',
      ),
      'token' => array(
        'enabled' => '1',
      ),
      'request_new_password' => array(
        'enabled' => '1',
      ),
      'register' => array(
        'enabled' => '1',
      ),
    ),
    'targeted_actions' => array(
      'password_reset' => array(
        'enabled' => '1',
      ),
    ),
  ),
);
$endpoint->debug = 1;

I am using basic PHP code for the testing purpose. Please have a look at the GIST.

The problem is that, while I run the test page, I can see it registers a new user and outputs the following.

stdClass Object
(
    [uid] => 14
    [uri] => http://vote-app.dd:8083/user_api/user/14
)

But while I try to log in with the same user (as per the code) it outputs the following error.

  Error
  ["Wrong username or password."]

I need some help on this. Am I missing something?

I also checked https://www.drupal.org/node/1491754 and other Drupal pages for this too.


texts: How can i access MySQL of a local Acquia Dev website using the command line?

texts:
Can we post about Acquia DevDesktop here? i cannot figure out how to log in locally to MySQL using the command line. i posted on their forum and got no response.

Local Acquia DevDesktop sites do not put the DB config info in settings.php. instead it refers to files in an a folder name .acquia which is hidden. on my set up, a typical included looks like this.

Users/myname/.acquia/DevDesktop/DrupalSettings/loc_mywebsite_local.inc

i have managed to open the DB array looks like this.

$databases['default']['default'] = array(
 'driver' => 'mysql',
 'database' => 'mydbname',
 'username' => 'drupaluser',  //this is real default setting for username
 'password' => '',
 'host' => '127.0.0.1',
 'port' => 33067 );

am kind of mystified why there is no DB password?

can any tell me how to access MySQL via the command line. very aggro right now, thanks!


texts: How to create a confirmation page linking to the content just created by a user

texts:
I would like to create a page that that user sees once it has submitted a new piece of content. That page will provide a link to the page that the user has just created, allowing them to share that link through various social networks.

What is the best way to implement something like this? I am not using a webform. The user is allowed to submit an unlimited number of content.

Thanks, Lauren


texts: I'm wondering if anyone has experience switching a Drupal installation away from Panopoly. I have a site built on Panopoly, but I'm finding the upgrade situation stifling. I'd rather have independent control of which modules are installed. So I'm looking to move to a vanilla core installation and do all the modules by hand. Anyone with firsthand experience doing this? I'm just going to give it a whirl and see how it goes, but any tips would be appreciated. Thanks!


texts: How can I capture Watchdog output during a functional test?

texts:
I have a functional test that is failing, and I think that there could be some useful information in the database log, but unfortunately the test suite only runs in containers on GitLab CI so I don't have any way to get to the database log while the environment is running.
Is there any easy way to get a dump of the contents of the watchdog log in a test artifact?