texts: Creating custom views query plugin and pull data from CVR

texts:
I created a custom views query plugin following this article:
Building Views Plugins for Drupal 8

In my case, I am pulling data from a CVR registers and not Fitbit.

My Goal:
I want to pull data from CVR Register through this plugin and save it as my information reference. This is a view search. If a user enters CVR number, I want to output all values of my defined fields in the views. When I say defined, these are fields I set in the hook_views_data.

Current status:
I'm already in Step 5(working with remote services and dependency injection section).

Problem:I'm trying to figure out how to build the code that query the CVR api(refer to sample working code below) and shows results in the views.

I'm still learning PHP. I really need help how to integrate this code and use it in views query plugin.

Code below is sample php code to to make entries in the CVR Register.
I made a simple php file to run this code in the terminal which outputs all CVR variables and its values.

function cvrapi($vat, $country)
{

    // Strip all other characters than numbers
    $vat = preg_replace('/[^0-9]/', '', $vat);

    // Check whether VAT-number is invalid
    if( empty($vat) )
    {

        // Print error message
        return('Venligst angiv et CVR-nummer.');

    }else{

        // Start cURL
        $ch = curl_init();

        // Set cURL options
        curl_setopt($ch, CURLOPT_URL, 'http://cvrapi.dk/api?search=' . $vat . '&country=' . $country);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_USERAGENT, 'mit projekt');

        // Parse result
        $result = curl_exec($ch);

        // Close connection when done
        curl_close($ch);

        // Return our decoded result
        return json_decode($result, 1);

    }

}

// Test CVRAPI
print_r( cvrapi('10150817', 'dk') );
print_r( cvrapi('988615625', 'no') )

Found some useful laravel code for more details to understand.
This is a cvrapi.php

use LasseRafn\CvrApi\Models\Business;
use LasseRafn\CvrApi\Utils\Request;

class CvrApi
{
    protected $request;

    public function __construct()
    {
        $this->request = new Request(config( 'cvrapi.endpoint' ));
    }

    /**
     * @param string $query
     * @param string $country
     *
     * @return Business
     */
    public function get($query = '', $country = 'dk')
    {
        $response = $this->request->get($query, $country);

        // todo throw error..

        return new Business($response);
    }
}

And this is the Request.php that is called in the above constructor.

<?php
namespace LasseRafn\CvrApi\Utils;

use GuzzleHttp\Client;
use LasseRafn\CvrApi\Errors\CurlError;

class Request
{
    protected $api_token;
    public    $curl;

    public function __construct( $baseUri = '' )
    {
        $this->curl = new Client( [
            'base_uri' => $baseUri
        ] );
    }

    public function get( $query = '', $country = 'dk' )
    {
        try
        {
            $url      = config( 'cvrapi.endpoint' ) . "?search={$query}&country={$country}";
            $response = $this->curl->get( $url );

            return json_decode( $response->getBody() );
        } catch ( \Exception $exception )
        {
            throw new CurlError( $exception->getMessage(), $exception->getCode() );
        }
    }
}


texts:
I defined the following menu item on my module:

function visita_virtual_menu(){
$items = array();
$items['visita_virtual/marker_selected_handler'] = array(
        'title' => t('Marker Selected Handler'),
        'description' => t('Ajax handler for selected markers'),
        'type' => MENU_CALLBACK,
        'access arguments' => array('access panoramas'),
        'callback' => 'marker_selected_handler');
return $items;

}

And even created an special permission for my module:

function visita_virtual_permission(){
return array('access panoramas' => array(
        'title' => t('Configurar Panoramas'),
        'description' => t('Configurar la visita virtual'),
        )
);

}

Obviously the access panoramas permission appeared on the People Permissions configuration tab on Drupal. I assigned it for anonymous users, logged users, and administrator users (Just for testing purposes).

Now my javascript function does the following:

alert('Callback URL: '+url);

    $.ajax({
        type : "POST",
        url : url,
        data : {
          'marker_latitude' : location.lat,
          'marker_longitude' : location.lng,
        },
        success : function(data){
            alert('Entro a la funcion success');
        },
        error: function(xmlhttp) {
            alert('An error ocurred: '+xmlhttp.status);
        }
    });

The alert('Callback URL: '+url); line shows the following info:

/drupal/visita_virtual/marker_selected_handler

However I'm always getting 403 access forbidden error. Why?? What I'm doing wrong???

I have been debugging the server's code, and the problem seems to be at this piece of code on menu.inc.

function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
// Check if site is offline.
$page_callback_result = _menu_site_is_offline() ? MENU_SITE_OFFLINE : MENU_SITE_ONLINE;

// Allow other modules to change the site status but not the path because that
// would not change the global variable. hook_url_inbound_alter() can be used
// to change the path. Code later will not use the $read_only_path variable.
$read_only_path = !empty($path) ? $path : $_GET['q'];
drupal_alter('menu_site_status', $page_callback_result, $read_only_path);

// Only continue if the site status is not set.
if ($page_callback_result == MENU_SITE_ONLINE) {
if ($router_item = menu_get_item($path)) {
  if ($router_item['access']) {
    if ($router_item['include_file']) {
      require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
    }
    $page_callback_result = call_user_func_array($router_item['page_callback'],   $router_item['page_arguments']);
  }
  else {
    $page_callback_result = MENU_ACCESS_DENIED;
  }

The $path parameter is getting it's default value. NULL, and then the $read_only_path is obtained from the q $_GET value, for this case the $read_only_path has it's value set on: visita_virtual/marker_selected_handler Is that ok?? shouldn't it be /drupal/visita_virtual/marker_selected_handler?

At this point $router_item = menu_get_item($path) I'm getting a $router_item that has an 'access' value of false. So that's the reason I'm receiving 403. Still I'm lost, I don't know what I'm configuring wrong for the menu...


texts: How to add a counter about the total number of nodes visited by a user?

texts:
I have one block that display individual user details.

How can I add a counter which counts the total number of nodes visited by a user?


texts: When adding a new product variation type no catalog options appear

texts:
I have installed the Commerce Kickstart installation profile and I am currently experimenting with it. The main problem I face is when adding a new product variation type and trying to create a new product using it, the vertical TAB where you select the product catalog, instead of this :

I get this :

So far I have tried reindexing and checking the views filters without finding the root cause of this.


texts: Is there a way to group different taxonomy/content type in a single Select List (in a View)?

texts:
I have different content types, each content type has its own taxonomy terms - see screenshot.

International News
|--- Diplomacy
|--- War
-National News
|--- Economy
|--- Politics
-Entertainment
|--- Movies
|--- Theater
-Sports
|--- Football
|--- BasketBall

I built a view that, by default, lists all the content from the different content types/taxonomy terms and i wanted to add a select list that will allow the visitor to filter through content and get the nodes they're interested in (Football for example)

As you can see in the screenshot i have a filtering select lists block with a select list for each Content Type.
Is it possible to have a single select list that groups all the content types and their taxonomy terms ?

If that's not possible. How can i reset the filters each time a filtering occurs.
Right now, if i select Politics for example, the filtering is done and in the results we only get nodes that are tagged with that term which is exactely what it's supposed to do but on the resulting page, the filters do not reset themselves
If i select another taxonomy term, the first term i chose (Politics) stays on so unless there are nodes that are tagged with both terms, no nodes appear in the results page.

Any help is welcome

Thanks


texts: How to add a css file to the admin theme from a front subtheme?

texts:
Is it possible to add a css file to the back office from a front sub-theme?

I would like to avoid having to create an admin sub-theme or a module just for the sake of adding one line of css to modify the existing back office styling.


texts: Export Content Type to a Form Like Structure?

texts:
So, I'm just getting really lazy. I have to make new custom forms for users to input data. The form matches the Content Type exactly(except for somethings being generated server-side). Is there a way to just export a Content Type form into an form function?

If not it seems like something I might have fun developing.

Thanks,
Nate


texts: How to numerate drupal views rows in twig?

texts:
For css purpuses I want to add custom class name to the first item in view.

I need the number in views-view-fields--viewname.html.twig to make some logic expression like

if(view-num == 1) {

} else {

}

or maybe in one of the variables I get in fields {{fields.view_number.content}}


texts:
I am wondering if there is a way to create a Drupal form on the fly with javascript? I know I can create a form, but how could I create all the Drupal hidden fields and other required pieces?

Or if this is even possible?


texts:
I am using the Printer, email and PDF versions module, together with the PHPMailer module to send emails. It works perfectly, but only from the email in admin/config/system/site-information. How could I use hook_mail_alter() or similar hook in order to send from different accounts of the site depending on the situation?

Do I need to install another module, or can it be achieved by using a hook? hook_mail_alter() just have "from" but that is a dummy email address which can be even simulated.


texts: Can I sort a view by a custom date field without the date module?

texts:
I would like to organize products in my site by year of production.
And sort them in a view. With the date(year) as exposed filter, in this format:

Products :
From  year :…
to year:….

Can I do this only by creating a CCK text field with a list of years?
Or should I use the date module instead?

If I have to use this module , How can I change the format in which the date is input. By default, it shows years ,months and days. I want it to show only years.


texts: Add contextual link to panels "custom content" pane?

texts:
I am wondering if there is a way to add a contextual link to a "custom content" pane? For example my "block" panes have the block contextual link that allow for easy edit. But is there a way to do this for regular panes?

I am trying to find a way to make Panel's more accessible to the "non technical user". Having to click Panel Content, then find the gear, then edit that. Is a little too much work that can easily get lost.


texts: Sending notifications to users from other users dependent on certain conditions

texts:
Is there a way to alert users of the content in a node field? I'm trying to get users to be able to mass message other users based on certain taxonomy terms they're selecting as part of their login process.

So essentially the process (as I'm envisioning it, but I'm open to other methods) would work like this:

User1 selects a county as part of their profile creation.

User2 wants to send an alert to all users that are signed up to that county.

They create a node with the content type, "Alert", which consists of the title, the actual alert information (a text field), and a county.

This is then sent to all users (i.e. user1) with that county.

My guess would be to use the notification and messages modules, and have a user subscribe to a given taxonomy term(s). I'm only seeing how to send messages on content update/creation though, not the actual content of the node.

Are there any solutions for this problem (one to many communication between users dependent on certain criteria)


texts: Users and Forum Transfer from a live site to a staging site

texts: How do I transfer just the Forum of a Drupal site to another Drupal site as my staging site is lagging behind the live site, So I need to update it with the live site forum content and then  publish my staging site as the live site afterwards.


texts: What is a good flexible way to send auto system emails to users?

texts: I would like to know a good user friendly, easy to setup and flexible way to send automated emails to users. This will be in response to an event triggered by a user. I guess it does not matter what it is for. Just need a good way to send system emails, which is widely used.


texts: Using Entity API, if given an entity in a function scope, how do you get the entity type?

texts:
This is very similar to this question: How do I get entity_type and entity_id from any entity page?
But I don't know what that asker means by "Entity Page," and in my case, using debug_backtrace (seriously?) doesn't cut it as I'd like this function to actually work from more than 1 scope.

Anyway... I am writing a module that uses numerous Entity Reference fields, and works the same code over several types of entities.  The trouble is that in my function scope I don't know the type of entity.

If I pass an Entity object into a function, I can access its type parameter:

function foo ($entity) {
  // bundle is:
  $entity->type;
}

But how do I get the "Entity Type" from this object?

For example, I have a dateset entity type with several bundles: class and retreat.  When I pass an instance of the class bundle into my function, I can identify that it's a class, and use identifier() to get its ID.  But I want my function foo() to also handle node entity types with bundles content_type_a and content_type_b

Given any instance of one of those bundles, foo() can identify the bundle:

function foo ($entity) {
  $entity->type; // class, retreat, content_type_a or content_type_b
  $entity->indentifier(); // numeric ID
}

But what about getting node vs. dateset?  Doesn't $entity know what type of entity it is?

UPDATE:
Even though I accepted Yury's answer because it provided a realistic workaround, I think the true answer is that you cannot do this in Drupal.  You have to pass around $entity_type anywhere you pass $entity (which really kind of makes the idea of having Entities as objects pretty much worthless... but I think any Drupal developer knows that object oriented concepts in Drupal are just hacked in and not ever truly related to real world object oriented design).  See this Drupal issue: http://drupal.org/node/1042822


texts: Add user to a group after the user makes a comment in that group

texts:
is this possible in Drupal Commons (Drupal 7) using Rules:

If a user makes a comment on a post in a certain group, have a rule which makes the user a member of the group automatically.

Why do I want to do this? Well, the contributors block in Drupal Commons is not showing all those who comment in a group. I found that the reason for this was that the particular user is not yet listed as an active member of the group.

Thank you!


texts: Retrieving jsonp data with callback function

texts:
I need to call a service to retrieve the available values for a select in a form I am creating. Therefore, I need to do this in the .module file and load the options with an array of items that I received from the service.

I retrieve that results but due to it having a callback function, I cannot seem to iterate through the data to retrieve only certain values from the data.

I have the following.

$request = drupal_http_request('http://[local]/TemplateManager/GetRenderingStrategies?Wizard=false&callback=jsonCallback');

I get back this.

jsonCallback([
{
    "HTMLRenderingStrategyId": 1,
    "IsEnabled": true,
    "CreatedDate": "2013-04-19T10:30:36.563",
    "CreatedBy": 1,
    "UpdatedDate": "2013-04-19T10:30:36.563",
    "UpdatedBy": 1,
    "RowGuid": "19223fcf-45c2-452b-aac6-ba357169ff26",
    "Name": "DEFAULT",
    "FormTemplateView": "/Templates/Default/FormTemplate.cshtml",
    "ManagedChoiceTemplateView": null,
    "NoMatchTemplateView": null,
    "ThankYouTemplateView": null,
    "NoThankYouTemplateView": null,
    "CSSPath": "/Templates/Default/css/Base.css",
    "CrossSellTemplateView": null,
    "CrossSellMaxProgramsToDisplay": null
},
{
    "HTMLRenderingStrategyId": 2,
    "IsEnabled": true,
    "CreatedDate": "2013-04-19T10:30:36.563",
    "CreatedBy": 1,
    "UpdatedDate": "2013-04-19T10:30:36.563",
    "UpdatedBy": 1,
    "RowGuid": "2ea1ecb7-0281-4361-87ee-d4cfe12c9b0c",
    "Name": "EMD",
    "FormTemplateView": "/Templates/EMD/FormTemplate.cshtml",
    "ManagedChoiceTemplateView": null,
    "NoMatchTemplateView": null,
    "ThankYouTemplateView": null,
    "NoThankYouTemplateView": null,
    "CSSPath": "/Templates/EMD/css/Base.css",
    "CrossSellTemplateView": null,
    "CrossSellMaxProgramsToDisplay": null
},
{
    "HTMLRenderingStrategyId": 3,
    "IsEnabled": true,
    "CreatedDate": "2013-04-19T10:30:36.563",
    "CreatedBy": 1,
    "UpdatedDate": "2013-04-19T10:30:36.563",
    "UpdatedBy": 1,
    "RowGuid": "e2d7ed2e-7ed7-4d2e-aecb-0a589c7ad338",
    "Name": "ELEARNERS",
    "FormTemplateView": "/Templates/eLearners/FormTemplate.cshtml",
    "ManagedChoiceTemplateView": null,
    "NoMatchTemplateView": null,
    "ThankYouTemplateView": null,
    "NoThankYouTemplateView": null,
    "CSSPath": "/Templates/eLearners/css/Base.css",
    "CrossSellTemplateView": "/Templates/eLearners/CrossSellTemplate.cshtml",
    "CrossSellMaxProgramsToDisplay": 10
}]);

What is my next step to pull out only the "Name" from the result set?

I am at a loss here. I tried looking for the answer and it seems all the jsonp calls are done in javascript/jQuery and that doesn't really suit me.

If you feel I am doing this incorrectly, please let me know. I have never worked with jsonp or json and Drupal for that matter.


texts:
In the node--my-content-type.html.twig, I want to add the French indefinite article to the title, which depends on the first letter of the word to which the article is added.

Banane => de Banane
Orange => d'Orange

So based on the Twig documentation, I'm trying to use one of the following code lines.

{% if label|first|lower == o %}

{% if label|slice(0, 1)|lower == o %}

{% if label[:1]|lower == o %}

None of them work.

How can I get the first character of the node title?


texts:
I added this code in my template.php

function PORTO_SUB_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'rapporto_di_lavoro_node_form') {

    $form['field_livello']['und']['#ajax'] = array(
                                  'callback' => 'my_test_callback',
                                  'wrapper' => 'callback_wrapper',
                                  'progress' => array(
                                    'message' => 'caricamento',
                                    'type' => 'throbber',
                                    ),
                                );        }}

function my_test_callback($form, &$form_state) {
dpm($form_state);
}

When I select an item I can see the throbble, but no dpm() message.
What's wrong?

As I'm still not modifying fields, I don't need to unset or indicate wrapper, aren’t I?


texts: How to adapt #prefix/#suffix for each option in radio form using hook_form_alter()?

texts:
I need to modify the html code of radio buttons generated by Ubercart Attributes. So I want to do it using hook_form_alter().

If I dsm() the $form I need to change using hook_form_alter() I get this

attributes (Array, 7 elements)
#theme (String, 24 characters ) uc_attribute_add_to_cart
#id (String, 42 characters ) uc_product_add_to_cart_form-472-attributes
    #type (String, 6 characters ) radios
    #default_value (NULL)
    #options (Array, 4 elements)
        0 (String, 7 characters ) Color 1
        1 (String, 7 characters ) Color 2
        2 (String, 7 characters ) Color 3
        3 (String, 8 characters ) Color 17
    #ajax (Array, 2 elements)
    #title (String, 4 characters ) yeah
    #description (String, 0 characters )
    #required (String, 1 characters ) 1

I can apply a #prefix/#suffix to div wrapping all radio buttons:

I proceed like that for this result:

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

The problem is that I want to apply this #prefix/#suffix to all options instead, I tried something like that but it doesn't work:

$form['attributes']['8']['#options'][0]['#prefix'] = '
';
$form['attributes']['8']['#options'][0]['#suffix']= '
';

So is it possible to do it this way? Any suggestion?


texts: Verify that salt.txt was located and being used by Drupal?

texts:
In my settings file in Drupal 8, I am specifying a location for hash-salt to a file outside of the docroot.

Example:

$settings['hash_salt'] = file_get_contents('/salt.txt');

I don't see anything in the status report or way to verify that Drupal was able to locate this file on the webserver and it is using it. I tried setting it to a broken path and/or file that doesn't exist, I even removed the line. However I don't see any noticeable change, so, how can you tell that this setting is being respected?


texts:
I've been searching internet for paid or free drupal themes that is best for blogs and does have wide space for html context, not center of screen with a very tight space.

Tight space example:
http://envato.tabvn.com/demo.php?theme=aqua
responsive-blog for drupal

As you can see, they are simply wasting whole html area space and using only middle of it.

In fact, I want something like this:
http://fumalwareanalysis.blogspot.com/p/malware-analysis-tutorials-reverse.html

I'm currently using free Best Responsive. Also it should work properly in mobile devices and ipad, so if browser is mobile device, resize it or fit the page etc.
Any good example theme for drupal?


texts: How do I display the products and nodes of the same author in the current page?

texts:
I wish to display a block with the products of the same author as the current page.

Contextual filters work on node pages, but not on product pages.

In contextual filters, I add "Product: Author" but no options are available for products.

There is no check box for products, as for content "Also look for a node and use the author of the node".

Thank you, but that's not my question.

"User 1" created:

product 1, product 2, product 3.
node 1, node 2, node 3.

"User 2" created:

product 4, product 5, product 6.
node 4, node 5, node 6.

When I visit node 5, I have the products and nodes of the same author in a block in the second sidebar:

product 4, product 5, product 6.
node 4, node 6.

When I visit product 3, nothing is displayed. Because the contextual filter does not find the author in the product page.

Normally it should display the products and nodes of the same author in a block in the second sidebar:

product 1, product 2.
node 1, node 2, node 3.


texts: How do I add conditional shipping cost to an order?

texts:
I am building an e-commerce site. When a shippable item is added to the cart I have to add some fixed shipping cost to the order which I am able to do with flat rate. But I have to
add an option "Residential Delivery Fee" while showing shipping cost on checkout page. If user select this option during checkout then I have to add another shipping cost to the order.

I am unable to figure out that how to add this conditional shipping cost.


texts: Drupal 7 Weform 4 attach file message stays even though correct size file is updated

texts:
I have set a file size limit of 4mb for the file type field.

Current behavior
When a file greater than 4mb is attached (10mb.jpg) and upload button is clicked, there is a message shown that mentions.
"The specified file 10mb.jpg could not be uploaded. The file is 10 MB exceeding the maximum file size of 4 MB..

Now when a file size of less than suggested limit and extensions ( 182kbs - 800px-pizigani_1367_chart_10mb.jpg) is attached and upload button hit, the message still stays and does not go away.

Expected Behavior:
On attaching and hitting the upload button for the file of correct size, the error message should not be displayed.

Let me know if this has been rectified in a later release or is still occurring for others.

Note: If the upload button is not hit and directly the webform is submitted, the functionality does work fine. Thus there seems to be an issue in client side validation.


texts: How to find the entity specific named id?

texts:
How do I map entity type to the entity specific named id, like this:

node => nid
taxonomy_term => tid
comment => cid

so that I can turn code like

 $entity->nid

into something like

$entity->{$label}

and correctly handle non-node entities.


texts: Save my link configuration with drush or else?

texts:
I just modified my database so I can translate 2 link from a block that I made.

The translation won't show up until I go here admin/structure/menu/item/1022/edit and press Save.

I would like to know if it's possible to do this with Drush or something else. Im in a Multisite environnement with more than 100 site, I would like to automate that task.

I tried to make a custom module to try and save my configuration but it doesnt seems to work.
I followed these steps : http://www.jpstacey.info/blog/2014-08-05/programmatically-creating-drupal-menu-link-item


texts: D7 block view to only show child nodes based on taxonomy

texts:
Using Drupal 7

I have a hierarchical taxonomy each node in the site is assigned a taxonomy to identify where it sits in the site structure.

On certain pages (landing pages) I would like to show the children of those pages but not the page itself nor importantly any peer pages

so in the following taxonomy

parent1

child1
child2
child3

parent2

child4
child5
child6

I have two nodes assigned the "parent1" taxonomy and a node assigned to each of the child taxonomies

If I go to one of the nodes assigned the parent1 term I should see in my block view all the nodes assigned to child1-3

Currently using "taxonomy term with depth" I see all the correct children, but I also see the other node assigned to the parent1 term because taxonomy term with depth, returns all children plus the parent nodes.

Hiding the node I am on is easy with exclude, but I cannot see a way of hiding other nodes with the same term as the page I am on.

How can I select only the child nodes, not the child plus parent nodes?


texts: Seperate /user/register fields and admin/people/create

texts:
i extended the add user field by adding a role field as part of the fields that will be displayed when you click  create user in mydomain.com/user/register. With the addition of some rules, this helps me to assign automatic roles to registering users.

I however noticed that when you  add user from the admin menu in People>Add user, this roles fields are added to the already existing fields. This is undesirable because the Add user page already have a section where you can pick the role. This therefore makes the form to have 2 different section where you can pick roles.

I want to hide my custom role field in mydomain.com/admin/people/create but show it in mydomain.com/user/register. Please how do I achieve this


texts: How to convert the drupal-entity tag into an img tag?

texts:
I have a content type with a text field that uses CKEditor, in the editor is possible to add a media entity image, once the image is inserted inside the text the html tag for it is:

Document
\r\n\r\n<drupal-entity alt=\"Luz\" data-embed-button=\"media_browser\" data-entity-embed-display=\"media_image\" data-entity-embed-display-settings=\"{&quot;image_style&quot;:&quot;&quot;,&quot;image_link&quot;:&quot;&quot;}\" data-entity-type=\"media\" data-entity-uuid=\"4076130e-9ccb-43f1-a4d9-dc8176271ffa\" title=\"Luz\"></drupal-entity>\r\n

I have in the site a webservice that need to provide the text field with all the information, but I need to convert the drupal-entity tag into an img tag to provide a tag that can be used from the applications that use the webservice.

I made a search inside the CKEditor configurations and in the media module but I can't find any related to this, how can I convert the drupal-entity tag into an img tag?


texts: views showing only 1 node with specifiec field value

texts:
Displaying problem with views.
I am trying to make a ranking for my track club.

Every result by someone is a node.
I can make a global ranking with views showing all results sorted by running time (lowest time is first item).

Ranking total view looks like.

name    - time  - place
runner1 - 12.00 - city1
runner2 - 12.01 - city1
runner3 - 12.10 - city1
runner1 - 12.15 - city2
runner1 - 12.20 - city1
runner3 - 12.25 - city5
runner4-  12.40 - city1

I need a ranking system with only the best performances. Curently a have used VIEWS AGGREGATOR PLUS (view first item on name) to help me filter some nodes. So my bad 'best results view' looks like:

name    - time  - place
runner1 - 12.00 - city1
runner2 - 12.01 - city1
runner3 - 12.10 - city1
runner1 - 12.15 - city2
runner3 - 12.25 - city5
runner4-  12.40 - city1

I can't seem to only select the node with the best perfomance if there is another node from the same runners result in another city.

My ranking should look like:

 name    - time  - place
 runner1 - 12.00 - city1
 runner2 - 12.01 - city1
 runner3 - 12.10 - city1
 runner4-  12.40 - city1

So my views should :
Select node where 'time' is lowest per 'name'.

How can I do this?


texts: How to create a separate web page menu to be used only on one of my web pages?

texts:
My site has a main menu displayed at the top of each page. But one of my pages is about a Parade we host, and it has a lot of content.

I would like to create a menu just on the Parade web page. Every option I have looked at has edited the main site menu.

But how do I create a separate menu just to be displayed on my specific pages?


texts:
Is it possible to render the add to cart form programatically? Something like:

\Drupal::formBuilder()->getForm('Drupal\commerce_cart\Form\AddToCartForm', $product)


texts: Prices in week to reflect Drupal 6 version

texts: I'm in the process of rebuilding a site - upgrading from Drupal 6 to 7. The old site uses Availability Calendars, utilizing the weekly price display, which is a necessity (administrative and simplicity). However, when using the Drupal 7 version, the weekly price field functionality has been removed. Are there any iterations of the module that can match exactly the same as the Drupal 6 version?


texts: Setting visibility by content type while adding block to region from code

texts:
I created block from code. Now I want to add it to specific region ('sidebar_first') also from code. I'm doing it like this:
function event_block_preprocess_page(&$vars)
{
    if (\Drupal\block\Entity\Block::load('event_block_1') == null){
        $values = array(
            // A unique ID for the block instance.
            'id' => 'event_block_1',
            // The plugin block id as defined in the class.
            'plugin' => 'event_block',
            // The machine name of the theme region.
            'region' => 'sidebar_first',
            'settings' => array(
                'label' => 'Event block',
            ),
            // The machine name of the theme.
            'theme' => 'bartik',
            'visibility' => array()
            ),
            'weight' => 100,
        );
        $block = \Drupal\block\Entity\Block::create($values);
        $block->save();
    }
}

This works, but problem is that block is displayed on every page. What I want is to display that block only on pages in content type "event".
When configuring block from back-end there is "visibility" section and inside it there is a tab allowing setting block to be visible only on specific content types. I want to achieve the same from code. I expect that additional parameters should be passed to "visibility" array and I tried something like:
    'visibility' => array(
        'node_type' => array(
            'event'
        )
    ),

or
        'visibility' => array(
            'content_type' => array(
                'event'
            )
        ),

but nothing of those works. How can I set visibility by content type?


texts:
I am using the Bootstrap module. In the code I can see this:

<?php if (!empty($primary_nav) || !empty($secondary_nav) || !empty($page['navigation'])): ?>
      <div class="navbar-collapse collapse">
            <nav role="navigation">
                <?php if (!empty($primary_nav)): ?>
                    <?php print render($primary_nav); ?>
                <?php endif; ?>
                <?php if (!empty($secondary_nav)): ?>
                    <?php print render($secondary_nav); ?>
                <?php endif; ?>
                <?php if (!empty($page['navigation'])): ?>
                    <?php print render($page['navigation']); ?>
                <?php endif; ?>
            </nav>
        </div>
    <?php endif; ?>

The problem is, I can't get it to print it for any other menu. For example, i created a menu called "web design menu". I am able to make it appear as follows:

print drupal_render(menu_tree_output(menu_tree_all_data('menu-web-design-menu')));

However, this doesn't give it the styling of bootstrap or any of the nice bootstrap benefits. How do I render it so that it renders it the same way the above code does. I.e. with all the correct bootstrap styling and executed javascript etc.


texts: How to conditionally render fields with a different formatter

texts:
I have a content type with two fields one called display which is a simple list and the other is an entityreference field.

I would like to change how the entity reference field is rendered depending on which option is selected in the first field.

I have custom formatters installed and I have created two custom formatters so I need a way of changing the #formatter based on the result in the first field.

I've tried a hook_preprocess_node() and also changing it in a custom tpl file but neither seem to render the field any differently to how it is set in the manage field UI.


texts: Feeds: How to import content from multiple xml files

texts:
I have around 100 xml files. Each xml file contains a single item.

I have created a feeds importer which is working fine for single xml file.

But I don't know if feeds can work with multiple xml files?

Something like loop on the files and import content from each file?

Is it possible with feeds? As I didn't find anything useful.


texts:
I have a bunch of pages that contain only beans. I need these pages to show up when searching (using search_api_solr) for words used in those beans.
The bean fields don't show up in the solr field settings page. Any ideas?
Update: though you can create an index containing both nodes and blocks this will just give me the blocks as results and not the pages they are on. Could this be 'fixed' in views?


texts:
In my view, I have two filters: title (text box), and date (combobox); date has two values: year and month.

When I select the filters parameters in the view, and I click search, the filter values appears in the URL such as in mysite/views-path?title_filter=aaa&date_filter[year][value]=2012&date_filter[month][value]=3.

I used $_GET to get the value of the title filter, and it worked, but I can't get the date values using print $_GET['date_filter[year][value]'];.

Can anyone tell me how to get values like date using $_GET?


texts: What is the difference between Microdata or Schema.org (or can I use both)?

texts:
I am building a community site in Drupal 7.

I am using the SEO checklist, which suggest to use the microdata module.

Other places I read are suggesting to use Schema.org module.

what is difference between them? Can I use both modules?


texts: Change stylesheet for just one page in Drupal 7

texts:
How can I add an additional stylesheet for just one page on a Drupal 7 site?

I want to add an additional stylesheet to a section of content on one page, but want the rest of the elements of the page to use the existing theme stylesheets?

How would I go about this, can I make a call to the additional stylesheet or should I embed the css directly in the page?

Thanks-in-Advance,

John


texts: Logging in I get the error: EntityMalformedException: Missing bundle property

texts:
When I log into my site I get the error: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7721 of /home/sites/mysiteurl.com/includes/common.inc).

In a new tab if I then revisit the site I am now logged in. So the error does not stop the log in process from occurring, but I do need to stop it from happening so that people can log in smoothly.

Googling around the issue I can see people discussing EntityMalformedException with reference to a lot of different problems. It is hard for me to find information on how this problem might relate to logging in as adding 'logging in' to the search still returns lots of pages that have a 'log in' option.

I wish I could tell you the actions i took just before the error started occurring, but I have only just noticed it, and it has been quite a while since I worked on the site.


texts: How to definitely stop inside a Rule and prevent any further actions in the rule from executing?

texts:
I have not seen that the Rules module can do this out of the box, but how can I prevent further execution of subsequent actions in a rule?

For example, I have multiple components in a rule.
The first one has a condition and if that is TRUE, it will execute one action, but the other components following the first one, MUST NOT BE EXECUTED.

So without adding further conditions to the rest of the components in order to prevent execution, I want to jump out of the complete Rule after executing the fist component.

I guess this can be accomplished with php inside the first component?


texts: Countdown timer for schedule unpublish date

texts:
I am using Scheduler module in order to enable unpublish date for a content type.

Now I want to create countdown timer for the nodes that unpublish date is set for them.

I checked jQuery Countdown and Countdown Timer Field modules but it seems they can't help in this issue.

What is your suggestion? Is there any way to create a relation between node unpublish date and countdown_timer modules or I must edit source of themes?

Thanks a lot for your help


texts: Trigger a JS function only if the view has no more results. or is empty?

texts:
Hi this might be a stupid question but i can't seem to work it out.

I'm using 'views ajax get', 'views load more (with waypoints)' and what i'm trying to achieve is to only display the footer when the last page of the view has been loaded and appended to the page. and if the view returns no results (using exposed filters)

I've attempted to use jquery's .ajaxSuccess() but i cant work out how to count the results or even to locate the variable with results. Do i have to search the responseJSON for results

What is the best way to do this? is there some Drupal specific structure i need to know about?

Thank in advance :D


texts:
I'm working on a Drupal project that will live on a locked-down webserver. The internet access on that box is constrained by a domain whitelist so I need to be able to provide a complete list of the domains that are needed for Drupal to update itself and its modules.

We're using Acquia-Drupal so we'll certainly the following to be able to update Drupal itself:

git.acquia.com

I ran a drush update while listening with netstat -t -u -c to try and get a feel for which domains are needed. This raised the following:

*.drupal.org  (obviously)
ec2-174-129-202-133

The latter seems to be an AWS domain.

I realise it may depend on the modules to some extent, but is there a definitive (and unchanging) list of domains that are required to update Drupal's modules?

I'm particularly concerned that if I start getting into AWS domains, they will change down the line, breaking our update path!


texts: How to replace ajax callback of file upload in managed_file?

texts:
I have a text-area with some content inside. I have another form element that is for upload xls file. Now what I want to achieve is, when I click on upload button the xls file content should replace the text-area content.

$form['edit_file'] = array(
        '#type' => 'textarea',
        '#required' => TRUE,
        '#rows' => 20,
        '#default_value' => !empty($raw_xml) ? $raw_xml : '',
//        '#states' => array(
//            'visible' => array(
//                ':input[name ="upload_excel_files_upload_button"]' => array('value' => 'Upload'),
//            ),
//        ),

    );

    $form['upload_excel_files'] = array(
        '#title' => t('Upload Excel File'),
        '#type' => 'managed_file',
        '#description' => t('Please upload only .xlsx files.'),
        '#size' => 50,
//        '#ajax' => array(
//            'callback' => 'replace_existing_xml_callback',
//            'wrapper' => 'replace-existing-xml-div',
//            'method' => 'replace',
//            'effect' => 'fade',
//        ),
    );

How can I replace "edit_file" form item content by uploaded file?? I can't write this logic in form submit handler because on submit, text-area content get saved into database.

Any help will be highly appreciated. Thanks in advance.


texts:
I have a D8 migration from a SQL source to nodes which is working perfectly apart from track_changes is not working, in my YAML I simply have:

source:
  plugin: job
  constants:
    slash: /
  track_changes: true

I discovered track_changes does not work when the map is joinable and applied the patch, but every time I run the migration I get:

[notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) - done with 'job'

Do I need to add anything specific to the source plugin? For now I'm getting round this by updating the whole migration each time, but I would prefer not to. If necessary I will have to use the high_water_property instead.


texts:
I have a view named search-form. In my view there are some fields like age, profession, education, etc. In this view I am using 2 buttons i.e. Submit & Reset. These buttons show from Exposed Form setting of View.

Submit button is working fine but whenever I click on the Reset button. It works like submit button. I have check through firebug. Found this <input type="submit" id="edit-reset" name="op" value="Reset" class="form-submit">. I think in place of 'submit', 'reset' need to set. How can I solve this. Please help. Thanks.


texts: Do path parameters need to be sanitized before using in the controller action method?

texts:
I was surprised to not see anything in the documentation as far as whether or not wildcard routing parameters need to be sanitized before using them in the controller action method.

In Using parameters in routes, there doesn't seem to be any mention about whether or not the Symfony routing takes care of the sensitization or not unless I'm missing something.

This is my test.routing.yml file.

test.test_controller_doTest:
  path: '/test/hello/{name}'
  defaults:
    _controller: '\Drupal\test\Controller\TestController::doTest'
    _title: 'This is the page title - nothing more Yo'
    name: "Rumplestiltskin"
  requirements:
    _permission: 'access content'

It seems that others are having a question about this as well:

  Obviously anything in the path could be altered by a user so you’ll
  want to test for valid values and otherwise ensure that these values
  are safe to use. I can’t tell if the system does any sanitization of
  these values or if this is a straight pass-through of whatever is in
  the url, so I’d probably assume that I need to type hint and sanitize
  these values as necessary for my code to work.

Based on some additional research it looks like they are not sanitized by default. See https://stackoverflow.com/questions/24880067/are-symfony-2-0-route-wildcards-sanitized.
This seems like it's ripe for a code injection attack via something like the following.

$res = eval('return 1 + '. $_GET['crazy']+ ';'); with ?crazy=0;exec("rm+-rf+/")

Can anyone confirm that we do need to sanitize and if so a recommendation for sanitizing string input in a standard way?


texts: Are configurations written and read directly to/from .yaml files or still to the database?

texts:
Background

Drupal 7 and previous versions have attracted criticism for Drupal web site admin configuration being stored in the MySQL database, the criticism being that being in a database means that it cannot be directly managed in git together with the PHP code based development for a Drupal site (custom modules, themes etc.).

Secondly with configuration being in the database along with content, transporting configuration between development, test, staging and live servers as part of development activity is complicated, though Features module (and related) can help.

Reading through:
https://www.drupal.org/documentation/administer/config

...I'm getting the impression that, in Drupal 8, the database is still used to store the config, when for example a site builder creates a new content type, rather than this being written to a .yaml file which is used directly.

So actually it seems that the role of the yaml file(s) is a much more purer (than Features) vehicle for the configuration. Whereas with Features it was PHP code which was harder to read what the configuration was, including if doing diffs between commits where config had been updated resulting in a new version of the Features-based config export. By that I mean not that PHP itself is hard to read, as I'm familiar enough with it, having written custom modules, hooks, themes. What I mean is that to express a configuration in PHP is perhaps not the most legible way to do it. So I can see the rationale of using yaml. The difference is that yaml will be read by a parser to apply a config. The complexity of applying the config is in the parser, which most folks need not concern themselves with most of the time, so the yaml can more cleanly describe the config. whereas in Features, there is no parser / yaml (or other script) separation. The descripton of the config and the means to apply it are necessarily in the same place as PHP code which is executed directly, so it's bound to be a bit harder to read the config, particularly if doing git commit diffs.

So there's the rationale for yaml, a Declarative Programming approach to storing configuration management in Git, contrasted with Features which is an Imperative Programming approach. And next what I need to know is this the case that Drupal 8 does still store config in the database does still and yaml files are the means for transporting config (replacing what Features did in D7 and before)?

(By the way I am a big fan of Drupal and spend most of my time at work, working with it for the sites that my organisation produces and maintained and am also involved in the community. So this question is not a stealth campaign against Drupal in favour of other platforms. It is a genuine question to try to dispel the apparent mystique around Drupal 8 and the new config management system)

Update
@Berdir's answer (accepted) is a great definitive summary as to the state of Drupal 8 regarding configuration management.

I recently discovered that using yaml for config in Drupal 8 is a concept that has been developed for Drupal 7 with the Patterns module, also read a FAQ on it which includes comparing features.

Update

Change default active config from file storage to DB storage Is a definitive answer about making config active from DB storage, which corroborates with @Berdir's answer.


texts: Webform is not submitting after 1st submit?

texts:
I am not able to submit a webform which is configured with honeypot.
I have tried following steps for anonymous user:

Place the webform using the webform block in a page.
Submit the webform. It got worked for 1st time.
When trying to submit from 2nd time onwards it is showing a message "There was a problem with your form submission. Please refresh the page and try again.".
After clearing cache only one submission is happening. From second submission onwards iit is not working.

Following are the module details:
Drupal: 9.1.x
Webform module:6.0.3
Honeypot: 2.0.1
There is no time restriction given in Honeypot module.


texts: Remove specific stylesheets from a given page

texts:
Adding a stylesheet to specific pages is easy: implement hook_preprocess_page(), call drupal_add_css(...) and set $vars['styles'] = drupal_get_css().

But what is the proper way to remove a stylesheet (or in my case, all "media=screen" stylesheets) for a specific page, without interfering with the caching system ? (e.g. not some regex applied to the output)

You can't just do unset($vars['css']['screen']) because $vars['styles'] has already been generated at this point and there exists no drupal_remove_css() function.


texts: Can you print single view fields in a block template file?

texts:
I am new to drupal and I am wondering how to gain more control over a view block. Currently I am embedding my view block in my page by doing :

<?php print views_embed_view('news_overview', $display_id = 'block'); ?>

This works but if I want to style this further I have to go into my view and format it as content and add the html templating there which leaves me with a bit less control than I want.

I made a views-view--block.tpl.php file to try and style my view block a bit more but I am left wondering how to render single view fields here.

I tried doing this to for example render a body field:

<?php foreach($view->result as $object): ?>
    <?php print render($object->_field_data['nid']['entity']->body['und'][0]['value']); ?>
<?php endforeach; ?>

Ofcourse doing this for each field is a hassle and I was wondering if there is an easier way to output view fields inside my views-view--block.tpl.php template.

Cheers.


texts: Identify form control id in Drupal 7 Forms API

texts:
does form controls in Forms API have id's? Below is my sample code:

function myid_user_page_form(){
    $form = array();
    $form['id'] = array(
        '#type' => 'fieldset',
        '#title' => t('ID Information'),
        '#collapsible' => TRUE,
        '#collapsed' => FALSE,
    );
    $form['id']['myphoto_button'] = array(
        '#type' => 'button',
        '#value' => '...',
        '#attributes' => array(
        'onclick' => "myphoto_options();",),
    );
    return $form;
}

Sorry for this very simple beginner's question but how to identify my button's id in the sample above?


texts: AJAX button on table rows to delete rows

texts:
I have a standard form with a table. I can add lines to the table via AJAX.
I also like to delete the lines using AJAX. But I don't know exactly where and how to add the buttons.

Here is my code to build the table inside the standard form building function:

  ...
  $aPersonsTable = array();
  foreach ($aPersons as $key => $value) {
    $row = array($value['dname'],'HERE IS THE PLACE WHERE THE BUTTON SHOULD SHOW UP');
    $aPersonsTable[]=$row;
  }

  $form['persons']['ptable'] = array(
    '#theme' => 'table',
    '#header' => $pheader,
    '#rows' => isset($aPersonsTable)?$aPersonsTable:null,
    '#disabled' => TRUE,
    '#title' => 'Users currently assigned',
    '#empty' => t('No users assigned yet!'),
    '#prefix' => '
',
    '#suffix' => '
',
  );
  ...

I'd like to have the button at 'HERE IS THE PLACE WHERE THE BUTTON SHOULD SHOW UP' :-)

I tried something like:

$row = array($value['dname'],array(
  '#type' => 'submit',
  '#value'=> 'Delete person',
  '#attributes' => array('id'=>$value['id']),
  '#ajax'=> array(
    'callback' => 'delete_person_ajax_callback',
  )
));

Any ideas?
I googled and stackexchanged a lot, but did not find the right solution.
Thx.


texts:
I am building a drupal 8 site and I am keeping my code on git.
I am using a copy of example.gitignore as my .gitignore which exclude vendor folder.
I have been working on my sandbox, at some point I have update drupal core from version 8.1.1 to version 8.1.3 and push it to git.

I have created a new sandbox, pulled code from git and system throw few errors because vendor folder wasn't there so I run composer install. Even then, I still had errors. I run composer update and I had errors again.

What is the right procedure in order to keep drupal 8 on git and at the same time not having problem with vendor folder?

If you download drupal 8 from drupal.org it contains vendor folder, should I keep vendor folder on git?

Thanks in advance.


texts: Get node fields in Rules action programatically

texts:
How to get node field values and include it the Rules Action? If I have a custom content type that has taxonomy terms, and I want to display these terms in Action. Example output is simply logging the terms.

Event: content type is created
Condition: of node type: custom_content
Action: Log the taxonomy terms

Pseudo code:

 public function execute() {
    $term1 = field_taxonomy1_fromCustomContentType
    $term2 = field_taxonomy2_fromCustomContentType
    $this->setProvidedValue('concatenated', $term1 . $term2);
    \Drupal::logger('custom_rules')->notice("Rules Action");
  }


texts:
This is the code I used in Drupal 7.

            <a href="<?php print $base_path ?>" title="<?php print t('Home') ?>">
                <img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" />

This is the code I am using for Drupal 8.

    {{ logopath }}

If I upload the logo, it doesn't display. What should I do now?


texts: Invalidate node cache so hook_node_view() runs on each node view

texts:
My module uses hook_node_view() to add some contents to the node view.

function example_node_view() {
  if ($view_mode == 'full' && $node->bundle() == 'example')

  // Insert file listing content part
    $contents = Class::getContents();
    $build['example'] = $contents;
}

Drupal 8 caches the node view by default and only calls hook_node_view() once after each cache rebuild. For this module to function, hook_node_view() should run every time the node is requested. So, I am looking for ways to invalidate node:nid cache tag.

NB:
- I am not looking for ways to disable the caching for a development.

public function getContents(){
  return [
    "#type" = 'table',
    "#header' = 'header',
     .....
  ];

Solved by adding the CacheDependency to hook_node_view() as indicated by @4k4

$renderer = \Drupal::service('renderer');
$renderer->addCacheableDependency($build, $node->id());


texts: How can I translate "Read More" on Drupal 7

texts:
I have installed the internationalization module, but can't find where to specify a translation for "Read more" and other system strings.
Thanks for any hints


texts: Uploaded image in Block Plugin keeps on getting deleted overnight

texts:
I have a block plugin that allows users to upload an image to be used as a background. Below is what is inside my blockForm function.

    $form = [
        'image' => [
            '#type' => 'managed_file',
            '#title' => 'Image',
            '#upload_location' => 'public://my_style/images',
            '#default_value' => $this->configuration['image'],
        ],
    ];

And my block submit function is as follows.

public function blockSubmit($form, FormStateInterface $form_state) {
    $values = $form_state->getValues();

    foreach ($values as $index => $value) {
        $this->configuration[$index] = $value;
    }
}

Initially this works just fine. The image is uploaded and appears in the background of my block plugin. However overnight it's always deleted. I did see this post Set image as permanent in custom block plugin, temporary URI however I don't see anything different that would cause issues with my code against the one provided in that post. Is there something missing? Or is there anything wrong with how I'm performing the submit function.

I suppose I could try to check if the formstate value is a file and then load the file and then set it to permanent and then save it. But even if that works why would it be necessary in this case but not in others?


texts:
I have a development server set up in my drush aliases as @dev, and a UAT server set up as @uat.  I can successfully execute drush commands locally on both servers, and I can execute remote commands from UAT to the development server (e.g. drush @dev cc all or drush @dev upc or whatever).  However, when from the UAT server I execute

drush sql-sync @uat @dev

it appears to work, but when I first make a change on UAT and then sync and then check the same page on dev is has not changed.   I have tried drush @dev cc all afterward to make sure there is no caching problem, but this doesn't help.

What could I be missing?  Or what could be failing?  How can I troubleshoot this?

UPDATE (corrected): If I log into @dev and execute the same command (in other words, having @dev pull data from @uat rather than having @uat push data to @dev) it works.   But I'd still like to get it working when executed from @uat.


texts:
I'm trying to work with Views PHP but for some reason something is going completely wrong. I have a content field called telephone. In this field is a number "06-12345678" now I want to use Views PHP to remove the "-" so I get the number "0612345678".

What I do is I make a view with the field Telephone and a Global: PHP field underneath it. In this Global: PHP field I add the following code to see if it is working.

<?php print $row->field_telephone; ?>

So when I save this field I get the output: "11" instead of 06-12345678.

When I try <?php print $row->field_title; ?> it does give me the suspected output..? What am I doing wrong? How can I solve this?


texts: Multilingual- can non-English languages be used without a prefix if they are the main language of the site?

texts:
I am trying to set up a multilingual web site, in English and Spanish. The way I want to setup the web site is:

  www.example.com: main page of the site in Spanish

  www.example.com/en:  main page in English

and

  www.example.com/productos/ejemplodeproducto: Spanish product page

  www.example.com/en/products/exampleproduct: English product page

Instead, for the Spanish pages, there is always a prefix as well:

  www.example.com/es/productos/ejemplodeproducto: Spanish product page

Is it possible to not have a language prefix in the URL for the main language? That's how our site worked with Wordpress. We are using Drupal 7.


texts:
There are a couple of attributes in my product. If the product is added to the cart without choosing one or two attributes, the product goes to the cart, but unselected attributes are also showing up.

I want that attributes without values are not shown. How can I do this?
I tried using hook_product_description(), but it doesn't help.

I'm using Ubercart 6.x-2.7, and its Product attributes module.


texts:
I want to create a simple php template for Views in Drupal 7, but I think I'm missing a crucial element to this puzzle, as every time I try to get to the content of Views' output in the template's php code, even if I use the default views-view.tpl.php file as a template for that particular view, I get

  Undefined variable: fields in include() ...

How do I get around this?


texts: How to get the default value of radio button from database?

texts:
I have 5 check-box. For each check-box, 5 radio buttons get generated. These radios value get saved to database. Now what I want is, when I select check-box, and if the selected check-box has some database value already saved in database, that radio button should show saved database value, mean to say, it should be shown selected.
5 check-box are like:
1. A
2. B
3. C
4. D
5. C

All check-box has radio options like:
Male or Female

If(say) I choose "Male" for "A" and submit my form. when I again go to that form and choose "A", "male" radio button should be shown selected.

some code implementation:

foreach ($check-box-options as $key => $value) {

        $form['radio_'.$key] = array(
            '#type' => 'radios',
            '#title' => t('abc'),
            '#options' => $filter_radio_options,
            '#default_value'=> ???,
            '#states' => array(
                'visible' => array(
                    ':input[name="filter_criteria_options['.$key.']"]' => array('checked' => TRUE),
                ),
            ),
        );
}

$check-box-options is an array of check-box A,B,C,D,E. For each check-box, I have radios.

$serialized = unserialize($radio_buttons_database_values);

$serialized contains all selected radio button values. If I replace $check-box-options with $serialized, I got correct radio button selected as default, but if I loop $serialized as nested inside $check-box-options, it is throwing last selected value from database for every check-box. I am not getting the exact problem with my code or approach.

Can anyone please help me understanding the exact problem behind this?


texts: How to resolve the warning on my homepage, after deleting mini panel?

texts:
I deleted a mini panel and then created a new one and on the homepage I keep getting a warning message and I don't understand why.

  Warning: Creating default object from empty value in panels_renderer_ipe->render_pane_content() (line 145 of E:\inetpub\wwwroot\modules\panels\panels_ipe\plugins\display_renderers\panels_renderer_ipe.class.php)

Please can someone explain why this happens? This is quite confusing ...


texts:
I get a message: your configuration has been saved, but when I look at list links it says no links have been added.

I found a similar question and tried the answers to no luck.

I added a new menu Login Menu which worked fine and shows up with the other default menus.
I created a page content to serve as my login page for the site. When I try to add a link to my new Login Menu it says it has been saved, but it does not show up.

My objective is to move the User login block to show only on it's own page. So I need a menu for anonymous users to go to for logging in.


texts: Why is drupal not changing the value when renderd after value change in preprocessor?

texts:
I wrote a preprocessor for one of my views but when i change the title value the value in my view keeps the same! But dpm show the right modified title. Why is that...do i have to save something somewhere?

function mytheme_preprocess_views_view(&$vars) {
    if (isset($vars['view']->name)) {
        $function = 'mytheme_preprocess_views_view__'.$vars['view']->name;
        if (function_exists($function)) {
            $function($vars);
        }
    }

function mytheme_preprocess_views_view__myviewname($vars) {
    //alter here that specific view
    $vars['view']->result[0]->field_field_title[0]['raw']['value']="Newtitle" ;
    dpm( $vars['view']->result[0]->field_field_title[0]['raw']['value']);

}


texts: I can't remove comma after currency in commerce price

texts:
In my project I had to change currency code from USD to IRR (Iranian Rial)

but in Persian language after currency, there is always a "," character in rendered price (in price component or formatted amount).

Anyone knows how can we get rid from this comma.


texts: Where is the result of the query is stored?

texts:
I have created a view page and a block. I need to get the query from the view block. The query preview can be seen.

The following code was found to fetch the query from view

function status_update_views_pre_execute(&$view) {
 if ($view->name == 'project_initiative') {
   $query = (string)$view->build_info['query'];
   echo $query;
 }
}

Where is the result of the query stored? How can I fetch it?

OR

the query is as follows

SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_project_name_node_entity_type FROM  {node} node LEFT JOIN {field_data_field_project_name} field_data_field_project_name ON node.nid = field_data_field_project_name.entity_id AND (field_data_field_project_name.entity_type = 'node' AND field_data_field_project_name.deleted = '0') WHERE (( (field_data_field_project_name.field_project_name_target_id = '55' ) )AND(( (node.status = '1') AND (node.type IN  ('status_update')) ))) ORDER BY node_created DESC LIMIT 10 OFFSET 0

How can I execute it to get the result in drupal custom module?


texts:
In D7, it was easy with the VBO module..
But how to do it with D8? (Preferably using a view to select the nodes to resave)

In many places I saw that a small part of the VBO module is now included in the D8 core but I can't figure out how to use it (assuming a simple save should be feasible)


texts: Under each node there is a 'Add Comment' text. For a particular content type I want to change the text to 'review by adding comment". How do I do this?


texts: How to change the condition operator in the search api query?

texts:
I have a date field facet filter on my search api views page.

When I select a date in the filter, the search api display those results which has that date value selected in the date field.

I want to display those results which has a date value which is greater than or equal to the selected in the date facet filter.

Is it possible? I checked with the search api query alter hook but I can't see any helpful function to alter the condition.


texts: Advaced forum area going off-page in firefox browser?

texts:
I have installed advanced forum and facing the weird issue. When I hover on the configuration button gear the area covered by it shows off-page as in the image(dotted line which automatically shows in drupal modules). I did check on two sites, in case my one site has the css issue. And due to this in my one site the page border of the main-content page sifting all the way to left. You can see the dotted line in the image. For the complete views I have zoom out the browser and you can see the how entire layout gets sifted in the second image.

Edit-2:

I have created the sandbox link with a Username: admin and password: admin. If you hover on the configuration gear of the views forum tab, it shows dotted line, but the left side dotted line has no end (off the page). Why this issue matters because when I create the page-border, page border also gets off-page along with that. This happens with Firefox browser only as described in the Edit-1.

Edit-1:

I did check in all browsers, and this is happening in Firefox browser only. My current browser is 45.0.1 which is the latest one. I did check in chrome and safari also, but there is no issue.


texts: Drupal 7 update.php Notice: Array to string conversion in update_results_page() when running custom module update

texts:
Notice: Array to string conversion in update_results_page() (line 212 of /Users/timdaff/Sites/local-quest-skills-for-life/update.php).

I'm getting the above notice after running update.php on the update function for my module.  It is a simple update to disable some modules I no longer require.  I'm not a PHP guru and it appears to me I have everything correct.

/**
 * Disabling modules. Implements hook_update_N().
 */
function features_controller_update_6009() {
    $return = array();
    $modules = array('views_cache_bully');
    $modules[] = 'gauth';
    $modules[] = 'oauth_common';
    $modules[] = 'oauth2_common';
    module_disable($modules,TRUE);
    $return[] = array('success' => TRUE, 'query' => 'Disabling views_cache_bully, oauth, gauth, gauth_login');
    return $return;
}


texts: How do I access the data of a field using PHP?

texts:
I'm trying to print out different links to an e-mail based on the values selected in the in the multi-select field. I've used devel to make sure that the field is actually storing the values and it is, but it always goes to the default case in my switch. I am trying to access the information from a node.

    print("I am in the php tag");
    $field_lab = field_get_items('node', $node, 'field_lab_s_requested');
    for($i = 0; $i < 4; $i++){
       print("I am in the for loop" + "Count:" + ($i+1));
        $lab = $field_lab['und']['value'][$i];
        switch ($lab) {
            case "127":
                print("link");
                break;
            case "129":
                print("link");
                break;
            case "130":
                print("link");
                break;
            case "132":
                print("link");
                break;
            case "117":
                print("link");
                break;
            case "112":
                print("link");
                break;
            case "113":
                print("link");
                break;
            case "116":
                print("link");
                break;
            case "118":
                print("link");
                break;
            case "121":
                print("link");
                break;
            case "122":
                print("link");
                break;
            case "119":
                print("link");
                break;
            case "123":
                print("link");
                break;
            case "124":
                print("link");
                break;
            case "140":
                print("link");
                break;
            case "143":
                print("link");
                break;
            case "146":
                print("link");
                break;
            case "148":
                print("link");
                break;

            default:
                print("Hit the default case");
                break;
}

}


texts: Drupal paid subscription manager where nodes are removed upon expiration

texts:
I would like to charge my users to post content. For example, 1$ per node/ week that it's visible.

Now I know there are many subscription modules. But how can I manage a subscription system with re-occurring payments, which also automatically interacts with my website and makes changes in real time. For example - how can I have nodes 'expire' after 2 weeks if the user only pays for two weeks.

Are there any combination of modules people would recommend to use to implement such a system?
I was thinking of Ubercart, UC Node Checkout, Node Published, however these are D6 modules and i've been on D7 for a while.


texts: How to theme webform's Custom Composite element?

texts:
Is there any chance I can move specifics sub-element to Custom Composite? Either, I couldn't find any way how to use flexbox inside in a custom composite.

For example, I wish to have;

[First name] [Last name]
[Yes, I am coming or no, coming] [allergies list]

Rather than all in a row:

[First name] [Last name] [Yes, I am coming or no, coming] [allergies list]

Can I also use conditional logic in the custom composite element such as if people click "Yes, I am coming" means allergies list will be visible?


texts:
How I go about implementing editorial workflows within a group of users?
I have user identified with a taxonomy term, for example, a per country or per team-based group.
To simplify configuration and avoid adding more extensions, I went about creating a taxonomy, e.g. "Groups", within that I have the groups, e.g. "Group A" and "Group B" and then each user is related to that group through a field in the user Account Settings.
Team A

John Doe - role: Author - taxonomy: Team A
Jane Doe - role: Reviewer - taxonomy: Team A

Team B

Jake Ryan - role: Author - taxonomy: Team B
Joane Ryan - role: Reviewer - taxonomy: Team B

My objective is that when John Doe creates content, the workflow only emails the Reviewer of that group: Jane Doe.
I do struggle to understand the group module. From what I've heard about it, I guess it would solve all my problems, but I'm having a lot of difficulties finding information (tutorials, documentation) that would allow me to grasp all the concepts this module introduces.


texts: Alternate page for mysql connection error

texts:
I have a drupal 7 site. Recently I changed my mysql password but forgot to update the settings.php file. My website showed Cannot connect to mysql server for 3 days before I noticed and changed the settings.php file. My question is

Is there a way to display a custom HTML page (Like a maintenance page) when there is a mysql connection error ? Is there a module for that purpose ?


texts: Different currency per-product in Ubercart

texts:
Vanilla ubercart configuration allows a single currency for all products, how can I use a different currency per-product. For example, I want to use USD for books and GBP for electronics, both in display and payment processing.

P.S. I don't think it is a duplicate of Multiple currency  displayed in ubercart product page :P


texts: How to use Solr Index to display node in a Google Map

texts:
For several months I am wondering how to achieve this task.

I want to display information from Solr index (preferably Search Api Solr ) directly in a map. The main goal is to have a map where is displayed some nodes, and to have the ability the use facet filters and fulltext filter.

Exactly the same as a typical use of  Search Api Solr (example: http://ygerasimov.com/ajaxified-solr-search-drupal-search-api-views-panels) but using a map instead of a table.

Something like this: http://vps10937.ovh.net/x/map/node, but with Solr features. This page is part of the Location Module and the Gmap Module.

Here is two examples (not drupal) close to what I want to do:

http://www.trulia.com/for_sale/New_York,NY/x_map
http://www.conflicthistory.com/#/period/1495-1500

Thank you


texts: How do I resolve a merge conflict with features?

texts:
This might seem basic, but I am new to Drupal (and, to and extent, git).

I've made some changes to a Feature and downloaded its files to be pushed up to the remote server with git. However, I get the following merge conflict:

<<<<<<< HEAD
  $pane->uuid = '992af322-74c5-4a5c-a261-1e73677d3645';
  $display->content['new-992af322-74c5-4a5c-a261-1e73677d3645'] = $pane;
  $display->panels['content'][2] = 'new-992af322-74c5-4a5c-a261-1e73677d3645';
=======
  $pane->uuid = 'bf806592-c85c-4155-a97c-516f72427e4e';
  $display->content['new-bf806592-c85c-4155-a97c-516f72427e4e'] = $pane;
  $display->panels['content'][2] = 'new-bf806592-c85c-4155-a97c-516f72427e4e';
  $pane = new stdClass();
>>>>>>> refs/heads/my-branch

I would know what to do with a conflict with other code, but this is all very foreign to me and I don't want to break anything.

Would anyone know the best course of action here?


texts: Isn't there a way to have Feeds XML parsers populate the alt text?

texts:
I am building a site and I'm using xml because I feel its more extensible. I have multiple images being imported and I have a special tag  for the captions as well but there is not a direct way that I can reference the caption to the image. Below is an example of my problem.

<?xml version="1.0" encoding="utf-8"?>
<Republikein>
<content>
<category>Verkiesings</category>
<headline>Oorwin, meen ontleders send version </headline>
<author>Dani Booysen</author>
<story>Die finansiële vakbond NBWU het onlangs 'n ondersoek onderneem om vas te stel of versekeringsverteenwoordigers wel werknemers van versekeringsmaatskappye is of nie.
</story>
<image imageid="6985">/var2/www/html/images/Hage-triomfeer-3.jpg</image>
<imagecaption imageid="6985">This is the first captione for  image </imagecaption>
<imagecredit imageid="6985">MARLIZE RAUTENBACH</imagecredit>
<imageid>6985</imageid>
<image imageid="6986">/var2/www/html/images/Rede-het-oorwin-3.jpg</image>
<imagecaption imageid="6986"></imagecaption>
<imagecredit imageid="6986">MARLIZE RAUTENBACH</imagecredit>
<imageid>6986</imageid>
<image imageid="6988">/var2/www/html/images/Bloed-vloei-3.jpg</image>
<imagecaption imageid="6988">Thsi image has a caption too... opk..image#6988 .lol</imagecaption>
<imagecredit imageid="6988">MARLIZE RAUTENBACH</imagecredit>
<imageid>6988</imageid>
<edition>Republikein</edition>
<volume>36</volume>
<volumenumber>1</volumenumber>
<page>12</page>
<publisheddate>1354516920</publisheddate>
<keywords>Afrikaans,Dutch</keywords>
</content>
</Republikein>

As you can see I have my xml with a lot of information. My problem is that the xml xpath parser does not read the attributes as an alternative to use that for alt text for image and nor does the module provide a way to link the captions to the images.

If you have gone this road before your help will be appreciated. Also note that I have tried to use the token module as a replacement pattern for the image caption file, but it take all the caption and bulks them on all the images. So in this case, all images will have 3 captions. This seems easy but I'm importing 4600 nodes and a manual approach is out of the question.


texts: D7 | views filter to show current user nodes or all nodes if admin

texts:
I have a site with multiple roles:
admin
editor1
editor2
editor3
…

I would like to be able to show a node reference drop down menu to only show current users's nodes. So each user can only node-ref to other nodes that they authored.

BUT if the user is an admin, they need to see the entire nodes list.

I thought this could be done with some views filters.
Using user:current as a filter does part of this requirement... but changing that list based on if the current user is as admin role is the part I don't know how to do.

Any ideas?

thx in advance


texts: How to override a single function in a core javascript library?

texts:
Drupal 8's core comments module has a library "node-new-comments-link" with a file "node-new-comments-link.js".

This contains Drupal.behaviors.nodeNewCommentsLink = { ... } which calls another function in the library which in turn calls another function in the library function render(results) { ... }.

This render function controls the text used to show how many new comments a node has:
.text(Drupal.formatPlural(results[nodeID].new_comment_count, '1 new comment', '@count new comments'))

I want to use different text. (I want it just to say 'New' rather than 'x new comments').

I can replace the whole js file or the whole library and that works fine, but it's very heavy handed. It requires me to copy paste lots of complex code I don't need to understand.

Is there a way to override just this one render function?


texts: How to make a select form element with textfields for the array id and key?

texts:
In a custom module which I'm working on, I have a select list which currently has a hard-coded array of key=>value which could change and I would like to expose these options to the user.

I would like to be able to have a select form element which contains one textfield for the user to enter the ID of the option and another for the user to enter the value of the option. I could make a separate form for these options, but I'd like to keep all the configurations on one page since there aren't too many.

Does anyone know how I can make a select form element where the key and value of each option is keyed in by the user?


texts: Display both sort icons on sortable table columns

texts:
I'm using Drupal's theme table function to build a custom table.

All of the columns on my table are sortable. I would like to visually indicate that they are sortable by putting both an ascending and descending sort icon in the column header.

To indicate which sort is active, I would like to show only one icon, corresponding to the current sort (ascending or descending).

Here's what I have:

Here's what I want:

How can I accomplish this?

So far, the closest I've gotten is overriding theme_tablesort_indicator(), but this will only let me override the icon for the active sort. (Docs here)


texts: Data in field_revision with Create new revision unchecked

texts:
The field_data_myfield and field_revision_myfield have the same row entries (D7 fields). All of my content types have the "Create new revision" unchecked. Is this how it's suppose to work? If yes, two questions 1) is this okay for scalability and 2) how do I stop drupal from renaming the files with _0 even when the original is deleted -- I read that this is because revision is on. If it's not suppose to work this way, how do I fix it.

I'm using mysql.

To clarify the end goal, I don't want the entire field deleted, I would like the fields not to track data revisions. Currently if field_body is updated, it also tracks it in field_revision body. Ideally, drupal would only save the update in field_body, and field_revision_body would be left empty. The content type is marked to not track revisions.


texts: Injecting additional content from multiple sources into a block using twig

texts:
I have a module which presents a table of contents from a twig template of examples on to how to use the module. This listing is located at /flot-examples. I would like additional modules to be able to add links to this list. The main module, flot_examples has a block, plugins defined like this:

{% block plugins %}
{% endblock %}

This way, any plugin modules can add
plugin example to the list

If I have only one plugin, I think I could override the route to /flot-examples by the plugin, call {{ parent() }} and inject content into {% block plugins %} However, if I have multiple plugins, they all can't do that.

I also see that there is a way for the parent to identify child scripts as 'appendable':

{% use [child_module].html.twig with appendable as appendableContent %}

This would work, but the parent module would have to be given a list of the child modules. If this is the best way to accomplish this, I imagine I would have to:

1)add an array to the parent module, flot_examples, (where?) so that...

2)the child modules would append their names to (where?) so that ...

3)when this array is passed to the twig template (flot_examples.module and somewhere else?), it can loop over the array (in the twig temple) to generate the {% use .... %} statement.

I guess I can see another strategy would be to move this directory listing out of a twig template, and just use render arrays. Then would the child module use preRender functions to append additional list items to the render array, somehow?

Are any of these on the right track? Which would be "the best" or "the easiest" way?


texts: How to remove title 'Navigation' from Navigation menu in Drupal 7?

texts: How to remove title 'Navigation' from Navigation menu in the left column?


texts:
I have taken a clone of my site, downloaded the files folder and the database to my local system.

I am using Xampp server in my local system and I have kept the site image ‘files’ folder in the sites/default/files directory.

The problem is that in my local system 30% of the images are not displaying in the local site. The images are available in the files/images folder,
but in local site the images are not showing.

I tried all the process and i also updated the base url in my setting.php file but the issue is not yet fixed.

According to my understanding the issue is related to the image path. In site those images we are calling through css is not taking the site base url. For example:

Current path:
http://www.localhost/sites/default/files/images/mobile-block-img-new.png

Correct path: http://www.localhost/repliconwebsite/sites/default/files/images/mobile-block-img-new.png

Please suggest if you get the solution.


texts: How can I center a logo image in an Omega theme?

texts:
I'm using Omega (a subtheme obviously) and am having trouble centering my logo image. I tried adding a .logo-img CSS class to my global.css file but it isn't doing anything. I added the following, but results are weird:

margin-left: auto;
margin-right: auto;
border: 4px solid;

I added the border to see the image field because when I save these settings, the image stays on the left, but the border extends all the way to the right.

So those settings end up in the logo image resulting like this: http://i.imgur.com/1r8Bccc.jpg?1 (sorry I can't post images)

If I comment out the margin lines in the css file, the image stays the same.

I honestly don't know how to fix this. Is there a way to do this within my theme's settings? I can't find anything online or in the documentation.


texts:
I'm wondering if there's a way to customize the create content page (not the content display page), including recordering and repositioning things.

ATM it's "Title" on top, followed by "Body" on the bottom, followed by other fields like "Upload" and "Save".

Is there a way to customise the labels, reorder and repositon this page?

For example: To move "Upload" on top and in the middle, followed by "Title" and "Body" below it while changing the label of Body to "Description", and changing the caption of the "Save" button to "Submit"?

Thank you very much.


texts:
I'm using drupal_unlink() for deleting my files, but don't know why I'm keep on getting this error repetitively?

Warning: unlink() expects parameter 2 to be resource, string given in drupal_unlink() (line 2194 of /includes/file.inc).

<?php
$query = db_select('temp_container_mapping', 'c');
$query->innerJoin('temp_image_holder', 'i', 'i.nid = c.nid');
$query->fields('c', array('cid', 'nid', 'container', 'users_list', 'api_key', 'regions', 'abbreviative'));
$query->fields('i', array('id', 'nid', 'image_path', 'image_style', 'final_image_name_path'));
$query->condition('i.image_style', $param_image_style, '=');
$query->range(0, 10);
$entries = $query->execute()->fetchAll(PDO::FETCH_ASSOC);

if (!empty($entries)) {
  foreach($entries as $value) {

    $container_id = $value['cid'];
    $nid = $value['nid'];
    $id = $value['id'];
    $image_path = $value['image_path'];
    $image_style = $value['image_style'];
    $final_image_name_path = $value['final_image_name_path'];
    $container = $value['container'];
    $users_list = $value['users_list'];
    $api_key = $value['api_key'];
    $regions = $value['regions'];
    $abbreviative = $value['abbreviative'];

    //Establish Connection with server
    $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array('username'=>$users_list, 'apiKey'=>$api_key));

    $service = $client->objectStoreService('cloudFiles', $abbreviative);
    $container = $service->getContainer($container);

    $temp_arr = explode("/", $final_image_name_path);
    $end_element = end($temp_arr);

    try {
      $file = $container->getObject($end_element);
      $fileExists = true;
    } catch (Exception $e) {
      $fileExists = false;
    }

    if ($image_style == "245") {
      $image_style_w = "168";
    } else {
      $image_style_w = $image_style;
    }

    $style = $image_style_w."w_".$image_style."h";
    $display_style[$image_style] = image_style_load($style);
    image_style_create_derivative($display_style[$image_style], $image_path, str_replace("rcf:///", "public:///rackspace/", $final_image_name_path));

    if ($fileExists) {
      //File is ther needs to overwrite
      $file->setContent(fopen('sites/default/files/rackspace/'.$end_element, 'r+'));
      $file->update();
      print 'existing overwrite
';
    } else {
      //New file just to upload
      $container->uploadObject($end_element, fopen('sites/default/files/rackspace/'.$end_element, 'r+'), array());
      print 'new one
';
    }

    drupal_unlink("public:///rackspace/", $final_image_name_path);
  }
}
?>


texts: How to send an email to a node author after selecting a specific value in a selected list field?

texts:
Actually this is my content and I have one select list field in it. If I select a "New litter" and click on save, I have to generate an email to the author. If however I select any other value for that field (and click on save), then there is no need to generate an email.

How can I do this?


texts:
I would like to add helper texts to the different options in the payment methods form, in Drupal Commerce, like this:

/Radio button/ Payment method 1

Helper text option 1...

/Radio button/ Payment method 2

Helper text option 2....

This is what one of the payment method options looks like in code:

/**
* Implements hook_commerce_payment_method_info().
*/
function swish_payments_commerce_payment_method_info() {
  $payment_method = array();

  $payment_method['payment_method_1'] = array(
    'base' => 'payment_method_1',
    'weight' => 20,
    'title' => t('Payed for with mobile pay'),
    'display_title' => t('Pay with mobile pay'),
    'description' => t('Choose this option if.....'),
    'active' => TRUE,
    'offsite' => FALSE,
    'offsite_autoredirect' => FALSE,
  );

  return $payment_method;
}

The content of the description field doesn't show anywhere in the specific payment method (in the Settings pane at the bottom of the page admin/commerce/config/payment-methods/manage/xx).

So how can I add helper texts to the options under each payment method in the form?


texts:
I'm hoping to finally find some solutions here. I'm new to custom module development in Drupal and I'm trying to learn the basics. What I'm trying to do is use hook_node_view_alter, however even at the simplest step (showing a status message) it does not work.

My module (test_module) is installed and enabled on the site. Currently the custom module has only two files: test_module.info.yml and test_module.module

Code from test_module.info.yml file

name: test_module
type: module
description: Test module
core: '8.x'

Code from test_module.module file

<?php
/*
* Implementation of hook_node_view_alter
*/

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\NodeInterface;

function test_content_node_view_alter(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
    drupal_set_message(t('Hello!'));
}

?>

It doesn't show the message when I'm opening a node (/node/1) at my Drupal site. As I understand it, it should show the message for any existing node when it is viewed. I've cleared the cache, nothing's changed.

Update

changed test_content_node_view_alter() to test_module_node_view_alter()
adjusted the code to coding standards
removed the php closing tag

My code in test_module.module looks like this right now:

<?php

/**
 * @file
 * Implementation of hook_node_view_alter();
 */

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\NodeInterface;

function test_module_node_view_alter(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  drupal_set_message(t('Hello!'));
}

I've cleared all cache and now the website gets this error:

  The website encountered an unexpected error. Please try again later.


texts: Single Sign on Windows Authentication popup

texts:
I enabled SSO on my drupal website.
When a user surfs to my website they got a windows authentication popup to fill in their AD credentials (i work with LDAP).

But how do I pass the credentials automaticly without the popup?


texts: node--page.tpl.php not detected in Omega subtheme

texts:
I created a sites/all/themes/mySubtheme/templates/node--page.tpl.php in a Omega subtheme.

I cleared all caches but it is not detected at all.

I even try with sites/all/themes/mySubtheme/templates/node.tpl.php to theme all nodes, just in case that I would have a typo error, but not working.

The base of my subtheme is omega:

base theme = 'omega'

I've also made sure that the tpl.php file exist in:

sites/all/themes/omega/templates/node--page.tpl.php

sites/all/themes/starterkits/omega-html5/templates/node--page.tpl.php

sites/all/themes/starterkits/omega-xhtml/templates/node--page.tpl.php


texts:
i have an enquiry form and submitting the form using jquery/ajax method.

$.ajax({
          url:enquiry.php

I am able to insert records into database table using php mysql_query. When i use db_query in "enquiry.php" page, i am getting errors.

   Call to undefined function db_query()

i want to know how to use db_query to insert records in database table.


texts:
Ultimately, the Empty Front Page module has got it to look exactly like I want it.  However, this causes Google Analytics code to not show up on the front page.

I try adding a new Basic Page content, but it forces me to give it a name which shows up when I publish, also, I think my theme is also adding a button to the bottom of this page as well, and I also get an RSS icon in the lower left corner.

I've installed Empty Page and Front Page modules, but I do not know how to work them, there are no settings associated with those modules and I also can't seem to find anywhere in Drupal where to get this to work the way I want.

I'd also like to stay away from PHP code as when upgrades come in, I don't want to have to have to update that code every time as well.


texts: Safe to add a class attribute to the HTML element via the theme?

texts:
In Drupal 8 is it safe to manually add a class attribute to the HTML element in the theme's html.html.twig file?

<html{{ html_attributes }} class="no-js">

Its working fine for me but I don't know if there are some instances where Drupal would want to add a class as part of html_attributes? If so then presumably my output would be this:

<html class="drupals-class" class="no-js">


texts: Combine two Media fields in Product types and Product variation types

texts:
i'm drupal beginner, i install drupal 8 commerce 2, i create a media field in Product types and create another media field Product variation types also.
when i create new product, i want to give user can upload global images, and also upload different color-type images when user create their own products. At the same time, display those images in one photo gallery.
How can i combine all the upload images show in one photo gallery, at the same time the user change different colors, the photo gallery can only show global images and product's color image? (i'm using Juicebox to display the product image.) Or Any suggestion on other modules can do this. Plz help!!


texts:
I want to add an HTML block inside the node.html.twig file, but only in full content view.

I used the following code but it is not working.

{% if view_mode %}

{% endif %}

I would like to move this code to a Drupal 8 block to avoid editing the template file.

How can I achieve it?


texts:
I'm working on a clothing store and I need to create a page type in which a model wears different pieces of clothes and users can see all the different products and add them separately to cart.

In other words, how could I have multiple products (of different kinds) on the same display, so that users can see the product of each product, choose sizes, etc., and add them to cart separately? (It's not a product bundle that you buy as a whole.) I've tried to create more than one product reference field, and I get multiple product-add-to-cart forms, but I can't have each product's price displayd separately. Is that possible? I can only display the price of the first product with the flag "Render fields from the referenced products when viewing this entity" checked.


texts: Panels layout with sidebar next to 3 pane grid

texts:
I'm using Panels 3.2 on a fresh install of Drupal 7. I want to create a custom layout that I can use and manage via Panels, and the flexible editor is great, but not quite sufficient for the layout I want (as far as I can tell).

Currently I have a simple 3-column layout, but what I want to achieve is this:

I did take a look at Panels Extra Layouts, but I'm not sure if that would cater for this.

EDIT: to clarify, I don't have a problem creating a layout like this with straight up HTML and CSS. I'm just looking for a way of introducing another region above the first two columns of a 3 column layout - something which the flexible layout editor doesn't seem to allow. Sorry for any confusion.


texts:
By default drupal 7 find content page comes with filter by type and status. I wanted to give one more filter, where user can type the few letters from the title they are looking for so that they can find the article/page with ease even when theres 100's of content in the site.

I did something similar using views and exposing title as a filter. But it would be great to add this field and search to the default filters we find in the drupal 7 find content page.


texts: How do I add validation in the node processor before creating a node?

texts:
I'm using Feeds import module, after importing CSV file, if a row doesn't match content type validation the feeds import saves that node with empty space in that field.

Question:
Now i want FeedsNodeProcessor to validate the node, and if there is a empty space it should throw error for that node or should not create node for that row.

Example:
If i have 40 rows in an excel and 39 rows satisfies the conditions of content type and only 1 row doesn't then it has to like this,
39 nodes created.

Updated:
i have added hook_feeds_prevalidate() in my hook_form_alter module.

 function tracker_custom_form_alter(&$form, &$form_state, $form_id) {
   if($form_id == 'orientation_node_form'){
      $form['#validate'][] = 'validate_orientation';
}
}
function validate_orientation($form,&$form_state)
{
....
}
function tracker_custom_feeds_prevalidate($source, &$entity, &$item, $entity_id) {
//      dpm($entity->feeds_item->id); - its not printing anything.
//      dpm($item); - its not printing anything.
  if ($entity->feeds_item->id == 'bulk_upload') {
     if (empty($item['Billing Type'])) {
         $entity->feeds_item->skip = TRUE;
         drupal_set_message('ksdhbf');
   }
 }
}


texts:
I would like to create a custom ruleset component like the one described in  How to automatically generate multiple aliases for one node?

That answer is for Drupal 7, and I am using Drupal 8. When I go to Rules/Components, none of the plugin options that I see in screenshots of Drupal 7 appear to be available (e.g. rule set, condition set, action set). Basically, the Components tab looks nothing like the one found in Drupal 7, so it's unclear to me how to create a ruleset. I'm not a module developer, but when I look through the module folder, I see a folder named Plugins/RulesExpression which contains files that seem to correspond to these component plugin types. Is there something I have to do to enable them to be available in the administration pages?

The documentation for Drupal 8 Rules is basically empty. The only documentation I found is for contributing developers; it doesn't seem there is any updated documentation for administrator users of the module, and I have searched far and wide for any insight on this and found nothing.