texts:
I have added a library to the libraries folder. I have the Libraries API module installed and I wrote this code:

function my_module_libraries_info() {
  $libraries['google-api-php-client'] = array(
    'name' => 'Google Api PHP Client',
    'path' => 'src/Google',
    'vendor_url' => 'https://github.com/google/google-api-php-client',
    'download_url'=> 'https://github.com/google/google-api-php-client',
    'files' => array(
      'php' => array(
        'Client.php',
        'Service.php',
      ),
    ),
  );
  return $libraries;
}

and the code to call it

$library =libraries_load('google-api-php-client');
dpm($library);

This dpm did give me a library array, so it looked like it was ok. But then I tried

$client = new Google_Client();

and I got an error:

PHP Fatal error:  require(): Failed opening required 'http://[site-name-here]/sites/all/libraries/google-api-php-client/src/Google/Client.php'

When I tried this

 global $base_root;
  require $base_root . '/'. libraries_get_path('google-api-php-client') . '/src/Google/Client.php';

I got the same error message. I checked and saw tat the files were still there. What is going wrong?


texts:
I am learning to improve Drupal's performance and I discovered Google's PageSpeed Insights tool. It urges me to use browser caching and presents me a list of all my images at mytheme/images and default/files. To be honest, I am not too sure about what this means. I assumed that Drupal's default caching could handle this, but apparently that is not the case, since caching is already enabled at Performance (both minimal lifetime and expiration time are set to 1 hour).

How can I cache all those images as well? Should I install some extra modules like Varnish or Boost to solve this? As a beginner, I can't really wrap my head around all these performance modules and what they do.


texts: Contextual filter does not work with page with wildcard path

texts:
I'm stuck on something. I have a view with a path with a wildcard "/the-register/%". I would like to use the contextual filter, to filter on taxonomy term id or name. But when i add a contextual filter "Taxonomyterm-ID" with a fixed value 1, it's showing up nice in the preview, but when i go to the page it self it does'n show anything?

I'm using drupal 8.7.8. It also occures in drupal 8.7.6.

steps to reproduce:

create a "view" with a page set it on a content with taxonomy field
set the path to "/the-register/%"
create a "Relationship" "Taxonomy term" with "Vocabularies" on the Taxonomy name and enable "Require this relationship"
create a "Contextual filter" on "Taxonomy term: Term ID", set "Relationship" on the previous created relation and "Provide default value" on "Fixed" and in the "Fixed value" "1" (the taxonomy term id)
save the view
press "Update preview"

Now you see some results in the preview, but if you go to "/the-register/asdfsdfs" nothing is shown


texts: How to create a homepage exposed views search box drupal 7

texts:
I'm sure this is really easy to do, but I've spent the best part of 2 hours trying to get Views to accomodate and I'm stuck.

Simply, I would like to create a single search function using Views in Drupal 7 which can go on a homepage to search for both "subject" and "town/ZIP" (ie "English Teachers" available in "Detroit". then the user hits the GO button. This will search the node fields and return a list which (ala a general google search engine style). I'm ambitious in moving forward with D7, but it's painfully slow at the moment).

OK, I'm new to D7 but not IT, but the lack of helpful books or tutorials is making self-learning takes 'years' and not 'months' (I'm upskilling during this downturn and I need to get back into employment like now not next year!).

Can anyone point me to a decent 'How to' tutorial for the above, or suggest the real easy way option in Views? I'd rather use Views and not have any .tpl


texts:
I am tring to load a full profile2.
I a trying the following code
<?php
$uid = user_load($node->uid);
$profile2_p = profile2_load_by_user($uid, 'profile2_profile');
print render($profile2_p);
?>

I get an error saying object can't be used as array.
If I print_r $profile2_p then I get an array relating to the correct profile2 entity. How can I render this entity?
Thanks


texts: Allow role to edit node with same taxonomy term

texts:
I would like to allow a user to edit some node that have the same taxonomy term.

I created a taxonomy for enterprise and I referenced it in a field of user profile. I used this taxonomy in a content type too.

I wonder if it's possible to allow users to edit only nodes with the same taxonomy term, as in this example:

Users :

Alex - enterprise : AAA
Paul - enterprise : PPP

Nodes :

1 - enterprise : AAA
2 - enterprise : AAA
3 - enterprise : PPP

In this example:

Alex can edit node 1 and 2 only, and see all.
Paul can edit node 3 only, see all.

I tested taxonomy access control but I have to create a role for each enterprise to edit node with same term enterprise. But I have more than 100 enterprises.


texts: Programatically create node + panel configuration?

texts: Is there a way to programmatically create a panel node with a certain layout?


texts: Hook the language switcher and change the URLs it redirects to in Drupal 7

texts:
I have a multilanguage site in Drupal 7.

The language negotiation is based on URL. I have got translated content, so when I visit www.example.com/this-is-a-news in English, I can change to Spanish using the language switcher and go to www.example.com/esta-es-una-noticia, which is the URL of the translated node. However, I have some URLs which are dynamic, i.e., they are built in-the-fly, for example: www.example.com/this-is-a-news/on-the-fly-parameter...

As the part of the URL /on-the-fly-parameter is completely dynamic and can change, and because the translation is a non-Drupal table in the database which is updated independently, I want to hook the language switcher and add the translations of all of these URLs dynamically. How can I achieve this?


texts: How does Drupal 7's SQL call for 'node' and retrieve an image?

texts:
I have the following query shown in one of my views:

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created,
node.sticky AS node_sticky,
'node' AS field_data_field_featured_image_node_entity_type,
'node' AS field_data_body_node_entity_type,
'node' AS field_data_field_premium_content_node_entity_type,
'node' AS field_data_field_article_type_node_entity_type,
'node' AS field_data_field_video_upload_node_entity_type
    FROM
    {node} node
    INNER JOIN {field_data_field_sports_type} field_data_field_sports_type ON node.nid = field_data_field_sports_type.entity_id AND (field_data_field_sports_type.entity_type = 'node' AND field_data_field_sports_type.deleted = '0')
    WHERE (( (node.status = '1') AND (node.type IN  ('article')) AND (field_data_field_sports_type.field_sports_type_tid = '1884') ))
    ORDER BY node_sticky DESC, node_created DESC
    LIMIT 8 OFFSET 1

What does the 'node' in this query return, for instance when I'm calling:

...'node' AS field_data_field_featured_image_node_entity_type,

It seems to me that this should just return the string "node" but in the preview it's actually showing the image. When I do the SQL query in the console it's just returning the string 'node'. I'm confused because I don't see any JOIN statements on things like the field_featured_image table in this query, which I would have expected if the query actually was pulling the image.

How is the image getting shown via this query?


texts: How To resolve Broken/Missing Handler with Independent views query backend flag links patch?

texts:
So, I'm trying to do something that should be relatively simple, show a catalog of products based on a search index to provide a faceted search with some flag links.

I have a view based on a search index of product displays with a required relationship to
Indexed Commerce Product: A bridge to node referenced by field_product_sku in order to pull the images into the view. My Flag is set to my custom product type (posters), and I can confirm it works.

The closest I've come was using patch #1Independent backend query flag links mentioned here. This works in so far as I now have access to Commerce Product: Flag Link for Entities, and Content: Flag Link for Entities, both of which give me a broken/missing handler message.

So: 1) How do I fix this? 2) is there a better way to get my Flag links into the Search view?


texts:
I have a drupal site on remote server.
The site is working properly right now.

I just check and the views folder is empty!!

I looked into the ftp, and also on the remote server it looks like the views folder is empty.
The site works perfect currently with many views, but it looks like the views folder under public_html/sites/all/modules/views is empty.

When I checked the permission it say "0711". and it says that owner can read edit and everything..

How that can be that I see empty folder?


texts: Why didn't we got rid of primary entity keys in favour of UUIDs?

texts:
I just remembered, while working with custom entities, that Drupal 8 was supposed to bring UUID support and replace the old "entity id" keys but then I've also noticed that the old fashioned entity id key is required by tye EntityType annotation and interestingly the UUID key is just optional.

Is this so that urls/entites are easier to remember by their "nid"?

And most importantly: should we use UUIDs or entity ids in logic and/or database operations?

Is this the final approach or we'll see entity id disappear in beta/rc/stable release?

Personally I don't see any good reason to keep using the typical serial keys when we have UUIDs now.


texts:
I have a multilingual Drupal 7 site with following languages enabled:

Dutch (default)
French

Now when I enable my sitewide contact form, and navigate to it using Dutch (http://www.mywebsite.com/nl/contact) it is in Dutch (as it should be).

However, when I navigate to what is supposed to be the French version (using http://www.mywebsite.com/fr/contact), it shows me the English contact form ...

I have downloaded & imported the French .po file for the contact form to no avail , the contact form stays in English.

Does anyone know a solution to this problem?


texts: Module for Importing and exporting Vcards

texts:
Is there drupal module to support importing vcard details to the site and publish the details of the content?

Thank you


texts: How to add template suggestions for form elements of a certain form ID?

texts:
I'm looking to edit some Twig templates for certain form elements, but I need template suggestions only for certain form IDs. How do I go about that?
I currently have the following functions in my .theme file:
function exmaple_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_register_form') {
    // Something here to alter suggestions of form elements only for the form with the ID 'user_register_form'
  }
}

function example_theme_suggestions_form_element_alter(array &$suggestions, array $variables, $hook) {
  if (isset($variables['element']['#id'])) {
    $suggestions[] = $hook . '__' . str_replace('-','_', $variables['element']['#id']);
    // This works but returns global form element suggestions
    // For example 'form-element--edit-mail.html.twig' which affects all email edit form elements
    // I need suggestions like 'form-element--user-register-form--edit-mail.html.twig'
  }
}


texts:
I'm using D7.

If you set a field <Hidden> on 'Manage display', and, unless you display it by views or something, you cannot see it anywhere on the site, right?

They say...

  Format
  The format column contains the options to show the field value
  in different formats. Hidden is the global value which is present in
  all the format option list, if you choose hidden then it will hide the
  whole field from showing on the content page.

  https://www.drupal.org/docs/7/nodes-content-types-and-fields/specify-how-fields-are-displayed

I understand it hides a field from View mode. But, you can also hide it if you don't try to do by using those modules, which are designed to output fields, like Views, right? Or, is there still any possibility that users can see the hidden field even if those modules are not used?

I'm sorry if this is a very basic question. But, I wanted to make sure what 'hidden' field means.

Thank you.


texts:
I am trying to modify an existing views join.

Let's say I am trying to remove the 'langcode' condition.

What I have so far:

function mymodule_views_query_alter(Drupal\views\ViewExecutable $view, Drupal\views\Plugin\views\query\Sql $query) {
    $joindata = $query->getJoinData("node__field_joined_whatever", "node_field_data");

//$joindata contains the join I need, so far so good

    foreach($joindata->extra as $ix=>$val) {
      if (isset($val['field']) && $val['field'] == 'langcode') {
        unset($joindata->extra[$ix]);
      }
    }
//here I have modified join object, but there is nothing like '$query->setJoinData()'
...
}

Does anybody know how to put my modified join back to the query?


texts:
I have a content type with a lot of different fields. Now this content can have (but not always) variations, which have the same fields, but different content.

I don't know how it would be best to organize this on the admin side. I could use child nodes, but if I have children, I'll have an empty parent. Basically what I need is to have multiple sets of the same fields for a content item.

I don't know if this is understandable, you might think of the as product variations or subproducts, here's an example:

Macbook (this only has title + description)
 -- Macbook Air (title + one set of characteristics)
 -- Macbook Pro (title + 2nd set of characteristics)
Mac Mini (title, description, characteristics)
iMac (title, description, characteristics)


texts: How to set which entities a workflow for Content Moderation applies to?

texts:
On Drupal 8.3, I enabled the Content Moderation and Workflow modules.

This provides an example Editorial Workflow by default.

The Content Moderation documentation states:

  Once your moderation workflows are established, you can apply the
  workflows to different entity types. Out of the box Content Moderation
  can be added to Block Content and Content (Node) entities. The
  "select" button will allow you to select which types should use this
  workflow.

However, there is no "select" link on the workflow edit page.  The screenshot on the documentation page shows This workflow applies to, but out of the box that information is not displayed.

Where can I select which types of entities a workflow applies to?


texts: Pulling capacity and slots left from entity registration

texts:
I'd like to pull the values for capacity and the slots left from a registration created by the entity registration module. This sets up registration entities which are attached to (I believe this is how it works - my familiarity with the entity system is only so-so at this point, but I'm actively learning) nodes.

I'm creating a view for the event nodes, I would like to display these fields - how would I go about doing that? Would I create a relationship of some sort in the view?

What's the standard method to pull another, related entity's content into a node entity?


texts: How do I add a minipanel to a panel page?

texts:
In D7 I've created a new minipanel and would like to add it to a panel page.

However, when I go to add it I cannot find it. It's not under the category I've set it in and it's not under the Mini Panels category. I've tried clearing cache, rebuilding the registry and have ensured the minipanel has a unique machine name.

How can I add it?


texts:
I want to switch theme on the basis of URLs and roles. I have used hook_custom_theme() but it's working only on the frontend.

Is there a way to switch theme basing on the URL for every page?


texts: Entity Query using conditions that ignore special characters

texts:
I have an entity query where I search the body for user provided text.
I'm performing the query like so

$searchterm = 'test';
    $query = \Drupal::entityQuery('node')
            ->condition('status', NODE_PUBLISHED)
            ->condition('body', $searchterm, 'CONTAINS');

This gives me the results I need, but what if I run into a situation where the body contains the text 'test-1' but I want searches for 'test1' to bring up that result.

Is there anyway that I can write a query that ignores all special characters in the field I'm searching?


texts:
I cannot make the module translation strings to be considered, unistalling and installing the module again.

Is the indicated .po relative path correct?

in my module blockForm function i have :

  $form['retrieval_method'] = array(
    '#type' => 'fieldset',
    '#title' => $this->t('Retrieval Method'),
  );

my .info.yml

name: 'amu hal'
type: module
description: display publications from HAL
core: 8.x
version: 8.x-3.0
package: AMU
project: 'amu_hal'
interface translation project: amu_hal
interface translation server pattern: modules/amu_hal/translations/%language.po

and in

  /sites/mysite/modules/amu_hal/translations/fr.po :

msgid "Retrieval Method"

msgstr "Méthode d'extraction"

i have activated the core interface traduction module and the

  /fr/admin/reports/translations

tells me Missing translations for 11 projects:

amu hal (8.x-3.0). File not found at modules/amu_hal/translations/fr.po


texts: Is there a way to pass many arguments and not have an ugly url?

texts:
I'm writing a module that displays graphs based on a selection of arguments (an array with items to display, a daterange and some other stuff). This results in a long and ugly url.

Is there a way to get the arguments to the page with the graphs without putting everything in the url for that page? I'm looking for something that can keep temporary variables with a short reference that I can pass in the url, but haven't been able to find anything.

I'm using Drupal 7.


texts: What is the basic concept behind revisons in term of performance?

texts:
On a Drupal 8 project, I am planning to allow revisions to be created for one "content type" which consist of around 40 different fields !

Can someone explain the concept behind on how Drupal save the revisions ?

My main concern is that the "Content type" in question will have in one year around "one million +" nodes with at least "3 revisions" for each node.

Could this affect the performance of the website ?

Revisions are treated as separated nodes as well ?

Update:

Any node of this content type will live on the website for a period of 1 year and then will be deleted for good !


texts: Move XML once they're processed in Feeds

texts:
Currently, I'm using Feeds & Feeds XPath Parser for importing XMLs into my Drupal 7.x site. As per the requirement, it's working perfectly fine expect the moving feature.

What I need to do is to move the XML files once they are processed, is there any hook or something which can be helpful for me on this? Suggestions are welcome.


texts: Views3 - Is there are feature in Views3 that allows for authenticated users to change the fields in a view?

texts:
I'm using Drupal 7 to display a particular content type as a table view. This particular content type has the possibility of 15 columns, but I want to give users the option of displaying fields that are interesting to them. Does Views3 allow for users to select which fields he or she is interested in and save that to the profile?

Drupal 6 has a module based on Views - Control field display, which seems to have this feature.


texts:
I have setup Apache Solr version 5.5 and it runs fine when I test through my browser at http://localhost:8983/solr/ but when I try to connect Drupal to this it throws the error:

I am getting some 404's in my logs also:

I don't know what is going wrong here, My Solr set up is fine so I just can't figure out why it doesn't connect to the Apache Solr Server.


texts:
I will present the problem as an example: If I want to use the twitter API: https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline

In the link above, under "Example Request", it shows the GET  command also the response.

Two questions:

In Drupal - How do I make this GET call from my module file? (do I need Services module?)
How to parse and use the output (i.e. save it into variables and show in my form elements/page) that I receive from the GET  command?

Any links/resources or just simply pointing me in the right direction will be very helpful.


texts: simple numeric token string 2 max 3 digits

texts: I need to generate numeric string and append it at the end of node url. Tried using some token random number options but the result is 10 digit number which is not neccessary for my purpose. Is there any other option? Node NID is not possible to use. Thank you


texts: How to create charts based on content types items?

texts:
I want to create a chart according to each content type created per month or week.

How can I do it? Is there any suggestion to use some module?


texts: Is it possible to turn on/off two layers at once with the openlayers_plus module?

texts: Using the BlockSwitcher module that comes with the openlayers_plus module, is it possible to create a button that turns on/off two layers at once?


texts:
I try to override this function in my template.php in Drupal 7; I copied the function found on template_preprocess_comment().

The first line contains function themename_preprocess_comment($variables).

It contains the following code, which doesn't work.

$variables['submitted'] = t('!username on !datetime', array('!username' => $variables['author'], '!datetime' => $variables['created']));

I clear the cache, I override theme_textarea($variables) and it works.


texts:
I want to render node/7 on /mymodule/info. I don't want to use path to cover it. What callback function shall I use?

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

  $items['mymodule/info'] = array(
    'title' => t('My module'),
    'description' => t('My module description'),
    'page callback' => ?????????,
    'type' => MENU_CALLBACK,
   );

  return $items;
}


texts: Duplicates when creating view with entity reference

texts:
I have a content type called Conference and there are various sections of data attached to each conference such as guest speakers, agenda, and local amenities. These sections of data are entity bundles. These attach to the content type with an entity reference field on the bundle, so each bundle has a list of conferences in a select list and you attach the bundle to conference by selecting it in this list.

The problem has come when creating a view to display the conference content type with it's corresponding entity bundle information, I am getting a views-row for every bundle, so the basic information from the content type is being duplicated 8-9 times and the bundle data is showing once, and each bundle shows on a views-row where all other bundle info is missing apart from its own.

I have tried to turn on DISTINCT in query settings but not working and if I turn on aggregation I get this error

SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near the keyword 'AS'.

My View uses a contextual filter for nid and an entity reference relationship to pull the values through.

Any help is welcome, thanks as I am completely stuck with this. Maybe there is a work around, or maybe I need to set up my views differently?


texts: In Drupal 7, What are some methods to prevent or detect botnets hammering your site?

texts: In drupal 7, what are some methods to stop botnets hammering your site? I have captcha protecting my registration page, but this doesn't stop them from bootstrapping my site when they land on the page. If enough load can be put on that page, it would lag my server. What are some tricks or modules that can prevent this scenario?


texts: CSS/jQuery not showing in Drupal 7 when upgraded from 6

texts:
I have just recently upgraded a large site from Drupal 6 to Drupal 7. When I load up the site it doesn't load any theme at all. Even when I check the admin panel under appearance it  shows the enabled themes, but nothing shows up at all, style wise. When I view the source, it isn't pulling in any CSS or jQuery files at all. Does anyone know how I would go about fixing this?

Also, I am receiving this error 'The specified file temporary://fileoR4rjt could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.'

I thought it may have something to do with the tmp folder/file-system but I can't seem to get anything to work.

Any help would be great. Cheers.


texts: Wysiwyg, ckeditor disappers when click "Add another item" button

texts:
I use Field collection modules to group image + textarea for multiple field group inputs.
When I click "Add another item" button, ckeditor bar disappeared from the textarea.

I think there would be some errors occured on Ajax request for an iframe tag appeared at the bottom of the script.

This thing only happened when field collection group contains both image and textarea.
Field collection with only textarea are fine.

The modules I use:
wysiwyg 7.x-2.1
ckEditor 3.6.4.7575
IMCE 7.x-1.5
File Field Sources 7.x-1.4
field collection 7.x-1.0-beta4


texts: How to translate the search block title?

texts:
In Drupal 8.1.1 I am able to translate customs block and basic blocks (block type).

The search block seems not to be translatable. But I need to translate the title of the standard search block. I can not find a way to do it. Words like "Search" are translated in all languages but the search block title gets not translated.


texts: Menu alter for a particular content type

texts:
I am trying to add a custom access callback for the node edit page for a particular content type.

I am using alterRoutes function to change the access callback but I am unable to get the node type in this function.

Am I missing something obvious?


texts:
Login with CURL:

curl --header "Content-Type: application/json" \
--request POST \
--data '{"name":"admin", "pass":"admin"}'
http://d8.local/drupal-8.5.6/user/login?_format=json

Then the result:

{"current_user":{"uid":"1","roles":["authenticated","administrator"],"name":"admin"},"csrf_token":"LUa3_xAXC8CgDkCoDoKonAmJ8hYFF6gZTak_LpaHFco","logout_token":"90jJUh08H437-F5fU25eq7rS2b8FS22eVVy_Fcsk2TA"}

Look good. But when I tried to check login status:

curl --header "Content-Type: application/json" \
--header "X-CSRF-Token: LUa3_xAXC8CgDkCoDoKonAmJ8hYFF6gZTak_LpaHFco" \
--request GET \
http://d8.local/drupal-8.5.6/user/login_status?_format=json

The results is: 0. So it failed.

Same result when I did with Vue resource.

Note: Postman seems to work, but it's working like real browser without CSRF token need.

Any idea?

Thank you.


texts: Use Drupal as a 'cloud system' frontend, what is your opinion?

texts:
I'm working on a small project where I need implement some kind of cloud architecture.

I'd like to deploy multiple Drupal installs among multiple servers; one would act as a domain controller and other as nodes. It should be simple to scale; adding nodes to the cluster would be as simple as cloning a node install and changing it's parameters (such as IP address and name). The new node will then announce itself to the controller which would update its nodes-list records.

I also like to be able to manage users in a centralized way; I would add users to the controller and assign them one or many nodes; once created it would sync to the target node(s) (e.g. create the user in the unix list as well as in drupal install on the target node).

Finally, once logged in the controller, the user would be able to do various operations such as:

download/upload files to nodes (on which he's granted to)
execute predefined shell commands such as starting/stopping services (probably as a module that would do all that stuff)

I hear that Drupal 7 has now some interesting file management modules in core; can they help in my case? Also, what would be the best communication protocol for accessing the different nodes from the controller?

Is it possible to have a kind of RPC call to a module (on target node) from the controller and get the result back ?

Any thoughts or starting points?


texts: How do I delete all book page nodes, book outline, and uninstall book module

texts:
I would like to remove a book, its contents, its outline, and uninstall the book module itself.
I deleted all the "Book page" content type nodes. I then deleted the one book listed under:
admin/structure/book
However, when I try and uninstall the module using Drush I get the message:
"To uninstall Book, delete all content that is part of a book"
I'm assuming this is the outline data on non "Book page" nodes that I missed, but there's nothing there in the Admin UI to tell me which ones they are. The UI says "No books available."
There is a module that addresses the issue of deleting book pages and their outlines in this answer here in Drupal 7.
Is there a way to easily find and delete that book content and uninstall the module in Drupal 8?


texts:
Few months ago I installed reCaptcha module to use with webform. It worked perfectly: I can't submit form if I didn't provide correct captcha code. It worked even if I disable JavaScript. Problem is that I still get a lot of SPAM submissions from this webform. How this can be possible?
Drupal version: 6.27.
Webform version: 3.18.


texts: Importing Published status from xml using Xpath parser

texts:
I have an xml page that I want to import. Although I'm able to successfully import the Title and Body, Im unable to import the published status and promoted-to-front-page settings for the page.
Here is what my xml code looks like:

<nodes>
<node>
<Title>This is the Title
</Title>
<Body>
This is the Body
</Body>
<Order>1</Order>
<Path>
/clips/this-is-the-path
</Path>
<Post-date>Tuesday, February 17, 2015 - 09:33</Post-date>
<Promoted-to-front-page>No</Promoted-to-front-page>
<Published>Yes</Published>
</node>
</nodes>

Here are what my Xpath settings look like:

Could anyone suggest what I'm doing wrong here?


texts: Rewrite the field label text on node dispaly

texts:
I created a content type.
In the content type I have field called ingredients. Machine name is "field_ingredients".

When a user see the output of the node (not in form and not in views), the label is:
"ingredients:".
I want the remove the ":" or even change the label to something else.

How can I do that?

I tried the "preprocess_node" function, but it didn't succeed.


texts: Date popup form field doesn't show the default value correctly

texts:
I am creating a custom form with "date_popup" form fields.
The only issue I have is that the default_value for the date popup form field shows only the first digit of the year, not the whole date.

Can anyone help with this?


texts:
I'm using a theme called Nexus.

Now in the login page, /?q=user, it looks somewhat like this:

All I want to do is change the order of the tabs, where "Log in" is in front, number one, then Request new password, then lastly Create new account.

Aka:
[Log in][Request new password][Create new account]

I've tried looking in the theme's folder, including page.tpl.php, and in the user module files to see if I could find where it was defined/rendered but I couldn't find anything.
This also did not seem to be what I wanted.

Sorry for being such a noob.


texts: How to track user view of nodes presented in a view?

texts:
Situation: I have a simple video player set up using views with a pager. Views loads a set of related nodes, each with an embedded video. By using a pager, the user can advance to the next or previous video in the list.

Problem: I'd like to track whether a logged in user has viewed a video or not, then use this information to help a user see what they have left to watch in another view (a view that simply lists the nodes with embedded videos). So, I need to be able to list viewed/not viewed nodes with views at the user level.

I realize there is complexity around tracking whether a user has really watched a video or not, so ideally the logic that decides whether a user has watched a video or not (custom code, a rule, etc) can be extended/updated later. For now, simply tracking that the user viewed the node is fine.

Related question: since the user is viewing nodes thru the views-based player, and not by clicking node links, where is the best place to execute custom code to mark a node as viewed? I think it could be done with hook_views_pre_render, but I'm not sure that's the right place.

Any thoughts on a simple lightweight approach for Drupal 7? I thought of trying the Flag module (with a user-level flag), using either Rules or custom code to flag a video as "watched", but I haven't tried it yet. There is also a module called path rules that can trigger a rule based on paths: https://drupal.org/project/pathrules

Are there other modules I should consider that already do some of this?


texts:
I'm currently working with Drupal 8's Guzzle HTTP Client.

What I need is the request headers, response headers and the response data (raw html).

Response headers and response data is not the problem:

$client = \Drupal::httpClient();
$response = $client->get('https://www.drupal.org');
$responseHeaders = $response->getHeaders(); //Response Headers array
$body = $response->getBody()->getContents(); // Raw HTML

But what's the way to get the request headers?

I can find a way in documentation of GuzzleHttp version 4 (https://guzzle.readthedocs.org/en/guzzle4/http-messages.html) but nothing like this in version 6 (which is being used by Drupal 8).


texts: How can I create a new user—with Profile 2 fields—programmatically?

texts:
I am writing a module where I need to create a new user and save his profile fields using Profile 2.

This is the code I'm using, but it's not working:

$edit = array(
  'name' => $submission->data[1]['value'][0],
  'pass' => user_password(),
  'mail' => $email,
  'init' => $email,
  'status' => 1,
  'roles' => $role_id,
  'profile_first_name' => $submission->data[1]['value'][0],
  'profile_surname' => 'ag',
  'profile_email' => $email,
  'access' => REQUEST_TIME,
);

$new_user = user_save(drupal_anonymous_user(), $edit/*,'customer_profile'*/);

What am I doing wrong?


texts: Skip updating certain themes/modules on composer update

texts:
My setup is composer driven.

I have overridden some module with patches and customised a contributed theme (boostrap_sass).

Now I want to avoid overbidding these modules and theme when I perform composer update in console, so as to skip updating those modules and themes and perform update on only the modules, themes and core that I want to update via composer.


texts: Public and Private file system path is the same

texts:
My company inherited a Drupal 7 site that may not have been properly set up. For example I recently noticed that under Configuration, File System, the "Public file system path" and the "Private file system path" have the same path:

sites/default/files

I'm just wondering what the repercussions might be if I suddenly changed the private files to

sites/default/files/private

Is it too late for this, since there might be sensitive private files already there that can't just be moved because they're registered in the database? I haven't looked too closely at the files yet.

Thanks


texts: No Nice Menu navigation when logged in as admin

texts:
I just installed the Nice Menu module for drop-down support on in my theme. It looks all good when visiting the site anonymously, but when I'm logged in as admin the block "Header" doesn't display my menu. I've tried to find the problem under /admin/structure/block but couldn't, any hints?
I was able to get a comparison of both pages, side by side
EDIT1
left being the page in admin mode (no visible nice menu), right being the page in "normal" anonymus (nice menu visible) mode

The block seems to be visible on both sides... so why would it only display on one? :o


texts:
How can I change the access callback for a page view (Views module)? I tried hook_menu_alter but realized that views uses the same hook to add the menu items defined by it - as a result of which, I am unable to have access to them.

Any way out?


texts: How can I list the nodes for which a Boolean value is FALSE or NULL?

texts:
On Drupal 9 I have a content type (Article), which has a not required Boolean field, Need Further Review.
Its values are TRUE, FALSE, and NULL, where the latter is used when the node doesn't have yet a value for the field.
There is a view for that content type, with an exposed filter for that field. The filter options are Any, True, and False.
How can I list the nodes for which the field value is FALSE or NULL?


texts: Allow downloading files from private filesystem when paths to files are built without Drupal

texts:
I have set up files under private filesystem (large tree of dirs and files).
Drupal does not know anything about those files, because they are not added by file upload field, but links are manually defined as strings (in special field in content type), and put in place with ftp.

Also, path to those files are not completely contained within string, but constructed in field--field_myfiled.tpl.php (some taxonomy magic adds parts of the path, so in actual string i have only filename).

Now, adding just system/files/ before link constructed in field--field_myfiled.tpl.php returns privilege errors, so I guess i need to tell Drupal somehow to allow downloading these files. I am not sure - could I use hook_file_download in this case, and how I could implement this or simmilar function or approach to give access to those files ?

EDIT: My latest findings are that it seems that hook_file_download is triggered whenever you try to access a valid link to a file in private filesystem. No need for anything except hook_file_download here!


texts: Views doesn't split content into seprates list items

texts:
I need to produce a list of images with views 3 but these group items in only one li element...like this:

How can I force it to put items in is proper li element ?

thanks

EDIT: after tips from @LaurenG , this is the right obtained HTML Markup :)
Views 3 under D6 is a bit different of D7 but I found how to setup the display as I would.

now,I need to work on the JS code to run the slideshow.


texts: Migrate into paragraphs without parent import

texts:
If I have a data source with some values, can I process those into a paragraph attached to a node in Drupal 8 without having to run a prior migration to create the paragraphs first (and then relying on a migration_lookup)?

Would I need some kind of process plugin (like Import Json data into node uses) or can this be done out of the box with simple generic sub-process/mapping config in the YML?


texts: How to allow special character in username?

texts: Is there any way to allow the special character in username like "#" and "~"?


texts: I want to hide hybridauth tab in user page. I have used  $items['user/%user/hybridauth']['access callback'] = FALSE; in hook_menu_alter() which gives the result, but hides for all user. In my case I Want hybridauth tab to hide for all user except admin.


texts: How to change a field type from free-form text to a taxonomy term and keep its existing data?

texts:
I need to change one of the fields of a type of a node from a free-form text to be a taxonomy term, but the data already has about 250,000 records.

How can I change this field type without losing the existing data?


texts: Correct way to add custom column to user table?

texts:
I'm looking to add a column called 'updated' directly to the users table.

The Field API and Joins are not an option for me in this case due to external constraints.

How can I safely modify the user_schema to add the 'updated' column in a custom module and safely clean it up when the module is removed?

Here is the layout of the 'updated' column based on the Schema API:

  $field = array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'description' => 'Timestamp for last time user was updated.',
  );

Currently my attempts using hook_install are not working as I believe they should.


texts: How can I programatically enable a block by default for a theme?

texts:
I have set up my site to allow users to set a different theme for each node, which works fine. Some of my themes make use of blocks, so I created a custom blocks module added them programatically, which works fine. The problem comes when I need to enable them. When a user creates a new node, all of the themes are available but none of the blocks are enabled. I have to go in and enable each block manually for each theme on each node. Is there any way to basically programatically say "when this theme is enabled, enable this block in this region" so I don't have to manually enable each block?

Please note that I am using Drupal 6 and upgrading is not gonna happen any time within the next couple of months.


texts: How to add a view as a filter criteria to an other

texts:
I've got a View of nodes with a taxonomy term as an exposed filter (category of the node). Thus, the search result is a list of nodes of a specific category. In addition, I've got a second View (in a block) that currently displays all the the nodes of the same Content Type.

What I want to achieve here is (when I use my first view to browse a category) to display the node results of the first view to the second view (instead of displaying all the nodes).

Is it possible to add a view as a filter criteria on an other view?

I would appreciate some ideas =)


texts:
I've created a small helper where I can set and access my session variable (thanks to the drupal 8 session).
Can't figure out why, my session is working well with my dev (no cache) but on my prod my session is not persisted, need to refresh drupal cache to see my session variable...
  public static function getSessionIRA()
  {
    return self::getModuleStore()->get('session_ira');
  }

  public static function setSessionIRA($session_ira)
  {
    return self::getModuleStore()->set('session_ira', $session_ira);
  }

  /**
   * @return mixed
   */
  private static function getModuleStore()
  {
    return \Drupal::request()->getSession();

    return self::$module_store = \Drupal::service('user.private_tempstore')->get('mymodule_services');
  }

UPDATE:
I had to add my development settings on my production website, but I believe that it's not recommanded... How can I avoid this ?
See my config below on my prod environment
parameters:
  http.response.debug_cacheability_headers: true
  twig.config:
    debug: false
    auto_reload: true

services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory


texts: Trigger Emails/Handlers on Webform submissions update

texts:
Is there a way to trigger the Emails/Handlers, When webform submission has been updated. I'm using webform_mailchimp as a handler. When I'm submitting a new record, handler is working fine and  I can receive the data into my Mailchimp account. I have a function to update the submission via code. But it doesn't trigger, when I update the same record.  Following is my code to update the webform submission:

$webform = Webform::load('my_form');
$is_open = WebformSubmissionForm::isOpen($webform);
$sid = 2;

if ($is_open === TRUE) {
    // Load submission
    $webform_submission = WebformSubmission::load($sid);

    // Modify submission values
    $webform_submission->setElementData('preferred_date', $form_state->getValue('preferredDate'));
    $webform_submission->setElementData('preferred_time', $form_state->getValue('preferredTime'));

    // Validate submission.
    $errors = WebformSubmissionForm::validateWebformSubmission($webform_submission);

    // Check there are no validation errors.
    if (!empty($errors)) {
        drupal_set_message(t('Failed! Please contact the administrator.'), 'error');
    }
    else {
        // Submit values and get submission ID.
        $webform_submission = WebformSubmissionForm::submitWebformSubmission($webform_submission);
        drupal_set_message(t("Success! ".$webform_submission->id()), 'status');
    }
}

Is there a way to trigger the handler through code(programmatically)?
Is there a default configuration in the CMS?

Thanks guys,


texts: How to do file downloading in a controller function?

texts:
I asked the question about downloading of files upon submitting a form.

Now I want to clarify how to do it in the case of controller function.
That is, some controller is called and its function is being executed.

In the form submit function file downloading starts upon executing the $form_state->setResponse($response);

How to start it in the controller function ?

I tried to use $response->send(); but it sends a file with wrong data and another size.


texts:
I have a content type with some fields. My client want that the empty fields must to be visible, obviously only the label. Like

Status: New
Owner:
Read: 714

I write these "fields" in my node--XYZ.tpl.php file  via

<? echo render($content['field_all_status']); ?>

But there are not "emtpy fields"

How I can set Drupal to display all fields, empty too?


texts: Getting the content type in Template.php

texts:
I am trying to get the content type to conditionally add JavaScript code/files to the template.

The code in template.php is the following one:

echo $node->type;

The same line in "node.tpl.php" is returning the content type. How do I get it to work
in template.php?


texts: Drupal 7 db_insert() execute() error when table contains unique keys

texts:
I have a database (mysql) table that contains a unique key in barcode column.

What I intend is this:

I have a form that has a barcode field.
When user submits the form and the barcode entered already exists in the database table, I should just give an error message.
Currently, it gives me PDOException: ... Duplicate entry and the page contents does not load.

This is how I did the insert:

$insert = db_insert('mymodule_mytable')->fields($fieldarray)->execute();

At that line, Drupal 7 returns PDO error so I cannot execute the lines after it. Thus, I cannot also check the return value in $insert.

Is there workaround to avoid the PDO error? I need to do something like:

if($insert === FALSE) {
  drupal_set_message(t('Error'), 'error');
}


texts: How to add metatag module data to the Search API indexes

texts:
I am in the process of building a new site that will have some content in the form of videos and PDFs. To make those more searchable I added the metatag module. We are also using the Search API to hook into Solr and do our search operations.

I have found the hooks I need to insert, update, and delete metatag info from the metatag fields. That part is fairly straight forward.

However, I am stuck on the part where I tell the Search API about the fields so that they can be indexed. I think I will be able to figure out how to push the data to the index with the hooks. I just don't know how to tell the Search API that the fields are there and that they contain strings.

I was looking, originally, at the hook_search_api_item_type_info(). However, after reading the description in the API documentation (in the code) I realize that it is only for new entity types. These metatag fields are mainly attached to nodes. And the documentation specifically says that it should not be used for existing entity types (i.e. nodes) because this hook simply tells about the data controller classes.

Should I use hook_search_api_alter_callback_info() to do this? That seems like a good candidate, but I am just not quite following how this works in the SearchAPI.

How do I tell the Search API that the metatag fields exist and I want to be able to index them?

This is in Drupal 7.


texts: How do I create a View of different entity types?

texts:
I haven't used Views much before but it feels like I should be so I'm getting stuck in...

I think I'm missing something obvious here but how would I go about creating a view that 'mixes' several different entity types?

I have a custom field type attached to nodes, users, and also to user profiles provided by the Profile2 module. The field contains lat/long data (I know OpenLayers etc. provide this functionality, the field type was built as an exercise).

How can I create a view that contains all of the different entities that have this lat/long field associated with them? I'm basically after a simple table with 'Entity Title', 'Lat' and 'Long' as columns.

All of the different entity types are separated when I create a view (Content, Users & Profile) and I can't find a way to group them together so to speak.

Is this possible with Views or is not quite there yet with regard to entities?


texts: How to remove link of username in comment submission form

texts: How can I remove the username link which is displayed in the comment submission form?


texts: error message: You are not connected to the facebook account that this application is registered to

texts:
I have configured the fbconnect.  I put the ID and secret, I have installed the library.  When I active the block doesn't show nothing.  It's a white block.

When I am going to "App Settings" in the configuration of module appears the next message:

"You are not connected to the facebook account that this application is registered to"

What's happening?

Thanks for your help.


texts: In Drupal 7 Commerce, where do you send an order completion confirmation email to administrators or store owners?

texts: I just noticed that I wasnt getting any confirmation emails when there is a order completion. Where do I set this up so I can get an email notifying me of a completed order for Drupal 7 commerce?


texts:
I have been searching everywhere for an answer to this. I created a views slide show, in Drupal 7, then found out it wasn't working with my responsive theme, so I followed a guide on how to install and use flexslide show modular. Everything worked great, in the preview it shows how it should look but once saved and viewed on website it is showing the nav arrows at the bottom together, not on side of slide show.

I have cleared cache, tried to edit using a css file, tried to move block to another region, tried to adjust size of images through styles, choose both styles and flex style in image format everything I have tried nothing works.

I can change the effects of the arrows, but I can not move them to where they should be. I have searched everywhere, but can not find anything on this problem or how to move them. I have included 2 screen shots of the preview in views and live site. Also, the address of the site i'm working on.

If someone could point me in right direction why this is happening would be great. Thanks!

prntscr.com/dhmdn4 screen shot in views
prntscr.com/dhmde7 screen show of live site

I know that the views shows arrows cropped or missing the top and my pager buttons not center, I can fix that with .css file I created to override my theme I am working on. I just can't figure out why the nav arrows are showing like that.


texts:
I'm setting up multiple drush folders to run for older versions of Drupal. I run composer require "drush/drush:dev-master" and I get this error:

  [InvalidArgumentException]
  Package drush/drush at version dev-master has a PHP requirement
  incompatible with your PHP version (5.5.38)

at command line, php -v yields: 7.1.0

How do I find and fix this issue?


texts: Any way to do custom action from clicking an #autocomplete_path option

texts: I'm attempting to hack the search_autocomplete module. I inject my own suggestions in the matches portion in order to grab results from external sources. I would like to make it so that when I click one of these external suggestions, instead of filling in the search box, it re-directs the user to this external source. Is it possible to do this?


texts:
I have two Drupal 8 sites: One has been created with Composer, and the other one has been created with drupal site:new.

On the latter, the UUID module appears in the list of modules. I installed it, and added a UUID field to a custom entity.
In the first site, the module doesn't appear in the list of the installable modules.

How can I install the UUID module also in the second site?


texts:
I've tried to define a new breadcrumb override, but I'm still getting the site default.

I've created a custom module, foo_breadcrumb:

   - modules/custom/foo_breadcrumb
     - foo_breadcrumb.info.yml
     - foo_breadcrumb.services.yml
     - src/
         - BreadcrumbBuild.php

Here's the foo_breadcrumb.services.yml:

services:
    foo_breadcrumb.breadcrumb:
        class: Drupal\foo_breadcrumb\BreadcrumbBuild
        tags:
            - { name: breadcrumb_builder, priority: 100 }

Inside src/BreadcrumbBuild.php, I have:

<?php

namespace Drupal\foo_breadcrumb;

use Drupal\Core\Breadcrumb\BreadcrumbBuilderBase;

class BreadcrumbBuild implements BreadcrumbManager {
    /**
     * {@inheritdoc}
     */
    public function applies(array $attributes) {
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function build(array $attributes) {
        $breadcrumb[] = $this->l($this->t('Test'), NULL);
        $breadcrumb[] = $this->l($this->t('Test2'), 'test');
        return $breadcrumb;
    }
}
?>

I started working off the only writeup I could find on Drupal 8 breadcrumbs, but the thing is it appears to be using an older version of the PSR-4 autoloading that is no longer in place (for the record I'm on 8.0.0-dev-beta3), and so I went by how all the other modules work in the codebase.

Now I'm fairly certain this correct to get the module to load; however I'm not sure if

class BreadcrumbBuild extends BreadcrumbBuilderBase

is correct. The problem is that the old tutorial I linked to mentions extending from BreadcrumbBuilderBase, but the more current docs don't seem to mention it and I wonder if it's out of date - and how I should do this.

Likewise, I don't really understand what the services.yml file is doing in this regard, there's no documentation anywhere for this.


texts: How can I pass an empty case subject from Webform CiviCRM integration to CiviCRM?

texts:
I am using Drupal 7 and CiviCRM 4.4.2. I have created a form with Webform CiviCRM integration that creates a new case. However, the case subject should be generated in CiviCRM, based on a standard pattern. The code replaces {contactName}-{caseType}-{caseId} with the values in the civicrm_post hook.
How do I set the default value of the case subject in the Webform whilst not showing the field on the webform?


texts: How to apply an image style to an image field within a node template

texts: I have a view where I can't use fields (the reason is complicated but I have to list the content as full content). I'm trying to figure out how to use differnt image styles from withing the node template. For instance, I have two image styles one that is 120 x 120 and one that is 360 x 360. I want to make the node template behave so that the first row displays the 360 x 360 and the subsequent rows display 120 x 120, but I can't figure out how to apply the image style to the field within the node template.


texts:
I have a taxonomy terms display that list a taxonomy_list, this taxonomy_list has parents and childs:

Parent
 child
Parent
 child
 child

Is there a contextual filter in views that i can use to pass the parent id and it would return the childs under this parent.


texts: Theme video-embed-iframe.html.twig by content type

texts:
I am using Drupal 8 and trying to theme video-embed-iframe.html.twig by content type. with the current naming suggestions this is not possible.

I am using Media with video embed field containing in a field called video

This is what I did so far. in the fields template named above in the templates folder of my theme

{% if logged_in %}

{% else %}

Eine brilliante Überschrift

 Credit author of the background image

{% endif %}

I have no clue how to access the field by content type to separate the code deepening if you have a content type eg page and article
Any Ideas?

Is there a way to populate a global var like logged in containing the mashine name of the content type without needing a custom module. I other words is there a way to populate a var like

contenttype=anycotenttypehere in the mytheme.theme file by writing a function? to be able to display the video depending on with contetnt type has been used and if the user is logged in or not


texts: Print from drupal to a printer over the internet

texts: Hope someone can shed some light on this. I've been asked to develop an ecommerce site in which once the order goes through a receipt will be sent some order details over the internet to a printer without the need of a computer in the middle. This is for a takeway restaurant so I do not know what kind of printer I could use either. Has someone faced a similar problem and could point me in the right direction?


texts: How do I get computed column using db_select?

texts:
I require sum(points)? Any help on what to add in the sample code given below?

$query = db_select('digitaliq_question_points','n')
  ->fields('n',array('points'))
  ->condition("node_id", $node->nid, '=')
  ->condition('n.fld_group', $fields, 'IN');

$points = $query->execute()->fetchAll();


texts: Uninstall or delete modules when upgrading 6 to 7?

texts:
Sorry to ask such a basic question, but I can't find an answer (and I'm an amateur).

I have a website that was written for me in Drupal 6. I want to upgrade it to Drupal 7.

There are quite a few contributed modules, and I realise I need to disable these before upgrading the core. Can I then simply delete the unused modules via FTP, or do I have to use uninstall within Drupal?


texts:
Could anyone please point out where I might be doing something wrong? I can't seem to capture the form values to manipulate them when this form is submitted.

   function admin_score_table_block_view($delta = '') {
      //The $delta parameter tells us which block is being requested.
        switch ($delta) {
            case 'admin_score_table':

                $block['subject'] = t('Admin Editable Score Table');
                $block['content'] = '';
                global $user;

            $form = drupal_get_form('admin_scores');

            $block['content'] = $form;

        break;
    }
    return $block;
}

function admin_scores($form) {
  if ($node = menu_get_object()) {
        $node = node_load($nid = $node->nid);

        $programmetmp = $node->field_sportevent_cd;
        $programme = $programmetmp['und'][0];
    }

    $form['#tree'] = 1;

    $result = db_query("SELECT cdt.entity_id AS nid FROM field_data_field_team_corpdec AS cdt WHERE cdt.field_team_corpdec_nid = " . $programme['nid']);
    foreach($result as $row){
        $team = node_load($row->nid);

        $form[$team->nid]['nid'] = array(
            '#type' => 'hidden',
            '#value' => $team->nid,
        );
        $form[$team->nid]['team'] = array(
            '#type' => 'textfield',
            '#value' => $team->title,
            '#title' => 'Team',
            '#attributes' => array('class' => 'field-team'),
            '#name' => 'team[' . $team->nid . ']'
        );
        $form[$team->nid]['score'] = array(
            '#type' => 'textfield',
            '#value' => '',
            '#title' => 'Score',
            '#attributes' => array('class' => 'field-score'),
            '#name' => 'score[' . $team->nid . ']'
        );
    }

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

    return $form;
}

function admin_scores_form_submit($form, &$form_state){
    var_dump($form_id);

}


texts: How can I customize the message after register?

texts:
How can I change, or customize, the message shown to the user after registration in Drupal 7?

  Further instructions have been sent to your e-mail address.

I tried the following code, but it didn't work for me.

function mymodule_message_alter(&$messages) {
  switch($messages->messages['status'][0]) {
    case 'Further instructions have been sent to your e-mail address.':
      $messages->messages['status'][0] = t('Your reset password instructions have been sent to your e-mail address. Please check your email and follow the instructions</p>');
    break;
  }

  // Disabling / Suppress all messages on a page and only display one Message
  if(arg(0) =='your-custom-page') {
    if($messages->messages['error']) {
      unset($messages->messages['error']);
      $messages->messages['error'][0] = t('This is my custom message to replace 10 system messages :) ');
    }
  }
  return $messages;
}


texts: Remove label Search terms from Views exposed form

texts:
On this site in the sidebar i have a views_exposed_form to search. I need this search functionality to show my search results for restricted pages.

How do i remove the label 'Search Terms'. Is it possible within
template.php with a hook?
How do i add a placeholder to the input field?


texts: How to get user data/authenticate with bearer token - Simple OAuth - Decoupled

texts:
I am working on a single page application using NUXT and Drupal 8 as headless CMS. for user authentication token I am using Simple OAuth Drupal 8 module. Everything is working fine. I am getting the access token when I send request to this API https://website.com/oauth/token as you can see below.

What I want now is to authenticate the user using this token. How will I get the user detail every time I refresh the page using this response? Is there any API where we send the access token with the bearer .

Excuse me Please if I am using the wrong terms I am new to Decoupled.

But as you know setting up JWT for authentication. we send two requests. 1 request to get the token and another request to get the user using that token as mention in this tutorial.

I don't know if I made my point clear. I am totally lost here.

Thanks


texts: Migrate callbacks() with addFieldMapping for destination_dir

texts:
i want to switch the destination_dir in a custom file migration class derived from DrupalFile6Migration. The DrupalFile6Migration class is provided by the migrate_d2d module.

For this purpose i think it's necessary to use callbacks for field mappings like it's described here:
https://www.drupal.org/node/1133448

I use successful a callback with the field mapping for destination_file in the file migration:

class FileMigration extends DrupalFile6Migration {
  public function __construct(array $arguments) {
    parent::__construct($arguments);
    $this->addFieldMapping('destination_file', 'filepath')
      ->callbacks(array($this, 'myPath'));
  ...
  protected function myPath($uri) {
    // do stuff
  }
...

But when i try do do this with the destination_dir i can't get success.
XDebug shows, that myDestination() is never called:

  this->addFieldMapping('destination_dir')
    ->callbacks('myDestination');
  ...
  protected function myDestination() {
    if(...) {
       return 'private://';
    }
    else {
      return 'public://';
    }
  }

But i can change the destination_dir with defaultValue, e.g.:

  this->addFieldMapping('destination_dir')
    ->defaultValue('private://');

Any suggestions, knowings if callbacks() in combination with destination_dir is perhaps not possible?


texts: Views Grouped by *each* value of a content field (multivalue).

texts:
I am pretty new to drupal, so some terms I describe may not be accurate. Anyways, I know how to group things in views using single values (i.e. Group faculty members by their departments: engineering, biology, medicine, social science, etc).

I want to create a view that groups items by a field which accepts multiple value (i.e. research areas). Suppose we have the Research Areas A, B, C, and D. Then, I want to group it such that each faculty member is displayed under each value of the multi-value field. Let's also suppose there are Faculty Members John, Josh, Jack, Jasmine, and their respective research areas are as follow (Note: omitted departments):

John { research area: A, B }
Josh { research area: B, D }
Jack { research area: A, D }
Jasmine { research area: B, C }
Joyanne { research area: A, B }

Then, the view should display as follows (desired output):

Research Area A:
 John  Jack  Joyanne
Research Area B:
 John  Josh  Jasmine  Joyanne
Research Area C:
 Jasmine
Research Area D:
 Josh  Jack

---------------------------------------------------------------
I have been using fields inside each faculty member to represent the research areas they fall under (check boxes for different research areas they focus on). And I have some how grouped them using the Research Area field; however, they are grouping as such:

Research Area A, B:
 John  Joyanne

Research Area B, D:
 Josh

Research Area A, D:
 Jack

Research Area B, C:
 Jasmine

I have also used Taxonomy Vocabularies, but to no avail.

Help SVP. Thanks for your time in advance.


texts:
I am trying to create a configuration page for my module that lists a set of php scripts that admins can use to trigger off different scripts. To do this, the configuration page is a form that has a table element where is row is a script that contains a button.
class ScriptsForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'scripts_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    // Create Form Table
    $form['table'] = [
      '#type' => 'table',
      '#header' => [
        'Title',
        'Description',
        'Path',
        'Status',
      ],
    ];

    // Retrieve scripts
    $scripts_config_file = file_get_contents(drupal_get_path('module', 'my_module') . '/my_module.scripts.yml');
    $script_config = Yaml::parse($scripts_config_file);

    // Create Table Rows and add to table
    $rows = [];
    foreach($script_config as $script) {
      $rows[] = [
        'title' => $script['title'],
        'description' => $script['description'],
        'path' => $script['path'],
        'operations' => [
          'data' => [
            '#type' => 'button',
            '#value' => 'Run',
          ],
        ],
      ];
    }
    $form['table']['#rows'] = $rows;

    return $form;
  }

  /**
   * Run Script
   */
  public function runScript() {
    \Drupal::logger('my_module')->notice('
' . print_r('Run Script', TRUE) . '
');
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  }

}

I don't care to actually submit the form, therefore I don't need to validate the form or anything. I only want the row button to trigger off the runScript method. However, everything I've tried, the button only runs the validate method.
I've tried these configurations on the button:
'validate' => ['::resendCode']
'submit' => FALSE,
'#limit_validation_errors' = []

'validate' => ['::resendCode']
'submit' => ['']

'validate' => ['']
'submit' => ['::resendCode']

How can I get these buttons to run runScript but not run validateForm or submitForm?


texts: Fire custom submit handler in form embedded in node edit form

texts:
I have a form that is being inserted inside of a node edit form and the inserted form is given a custom submit handler. The inserted form's submit button is defined as follows:
    $form['decision_select']['update'] = [
      '#type' => 'submit',
      '#value' => $this->t('Select Segment Set'),
      '#submit' => [[$this, 'updateSegmentSet']],
      '#limit_validation_errors' => [],
      '#ajax' => [
        'callback' => [$this, 'updateSegmentSetAjax'],
        'wrapper' => $wrapper_id,
      ],
    ];

However, when I click 'Select Segment Set' the entire node form is submitted to the backend (I've verified this by printing the request/route objects sent to the backend). Is there any way to press that submit button and have only the inserted form sent to the backend along with this custom submit handler? The idea is to have this inserted form filled with values given to it via ajax before the node form is ever submitted to save the node.


texts: Remove superfluous divs from views fields output?

texts: I've set the Wrapper HTML Element option to none, and removed any wrapper divs in the templates presented in Theme Information, but my image fields are still getting wrapped in plain divs.


texts:
I created a content type call Block. I want to use Views to display this Block content type per node. It means when I create a Block node, Views will create a block for me. So far I don't see any setting in Views allow me to do this. If it is possible I prefer using Views to do it instead of install another module like Nodeblock(nothing against it, just don't want to install another module when existing one can do it).

My original question is a bit confusing. To clear it up:

Is it possible for user to create a block by using a node? For example, user create a new node call 'My day' will automatically create a new block call 'My day'.
Is it possible to accomplish it by using Views module?


texts:
Anyone know how to render a path defined in a view in the core overlay.

hook_admin_paths_alter() does not work in that instance. I can only think that it has to do with the execution pipeline.

overlay_paths module also does not work.


texts: After logging off, user is able to see the workbench page by pressing back button of the browser

texts: I am using workbench module to show the entry made by some particular user with some role when user is logged in he redirect to my workbench page and  as the user log out it redirect to home page and after pressing back button it redirects to my workbench page


texts: D7 - Ckeditor buttons get messed up when moving a site from one server to other

texts:
I just moved a D7 site from one server to another and the Ckeditor buttons get messed up. Look my capture. How can I fix this?

I use the Adminimal Theme but it is not the problem. If I switch to Bartik the problem persist.

I already cleared caches and run Cron several times.


texts: How Do You Make a 'Rules Link' Work in a Custom Content Pane?

texts:
I'm struggling to get a Rules Link set in a Custom Content Pane to trigger a Rules Link and work. I've done many tests and using the URL path provided by the Rules Link Edit page, (ie domain/content/post-new-content) all I get is a 404 despite my many trials and viewing/reading of info docs online.

Put simply, I want a link set on a Custom Content Pane to show a link which the user clicks, this will then trigger a Rules set to check: a) the user has valid auth/role; B) and then redirect to a Post page; if not authorised then redirect to a 'Subscription' page. Through my testing, a 'standard' link to an Add Content page works fine, so I presume it is something within the Rules/Rules Link  framework I working within the D7.2x

Can someone please provide some generalism how this (assumed simple flow) should work. HELP!


texts: Migrate nodes from D7 to custom entity defined in D8

texts:
I have defined custom entity using Drupal console. the entity have extra columns defined to store field data from D7 nodes migrated instead of having entity fields.

I am using Migrate tools and Migrate plus modules and created migration group defined as below:

id: phases
label: Phases nodes migration
migration_group: phases
deriver: Drupal\taxonomy\Plugin\migrate\D7NodeDeriver

source:
  plugin: d7_node
  node_type: phase

destination:
  plugin: entity:phase_entity

process:
  id: nid
  type:
plugin: default_value
default_value: phase
langcode: language
name: title
user_id: uid
changed: changed
created: created

migration_dependencies: { }

The migration group listed under admin/structure/migrate But no import action execute.

I have tried to import with basic fields only but nothing happens.

I searched a lot but no results even examples, I did created destination plugin to save the entity but I don't know how to.

Do I have write some code? where to write it or where docs for that part?

Does Drupal migration not work for custom entities at all so I have to look for another solution?

Any help will be appreciated, Thanks in advance.


texts: How to export a Field's Allowed Value List in a feature?

texts:
I've made a drop-down list type Field and have exported it as part of a Feature. However, whilst every other facet of the Field (Name, Help text, etc)  is successfully exported the actual Allowed Values is not.

Does anyone know how I would include this in my Feature?


texts: Prepopulate new Taxonomy Term's Parent via the URL

texts:
I currently have a views page made up of taxonomy terms. Each term has a link next to it that redirects to the Add Term page. The add term page should auto-populate the parent of the corresponding term.

The Prepopulate module should make something like this possible and it works with all other fields, but not with the Parent select field for some reason.

I am using the following query parameter=?edit[parent][]=24 in the URL (where 24 is the value).

Any help getting this to work with Prepopulate, or using another method would be extremely helpful. Thanks in advance for any assistance.


texts: PHP contextual filter code in drupal 7 'no query was run'

texts:
I am using the contextual filter code in views to filter more options for the view, using this snippet:

$uid= $GLOBALS['user']->uid;

$result = db_query('SELECT users_node__field_data_field_agencyname.field_agencyname_nid as agencyid
FROM {field_data_field_agencyname} users_node__field_data_field_agencyname
WHERE users_node__field_data_field_agencyname.entity_id=:uid AND users_node__field_data_field_agencyname.deleted=0 AND users_node__field_data_field_agencyname.entity_type=:user',array(':uid'=>$uid,':user'=>'user'));

return $result->agencyid;

but no query is run shows up on the sql pane ?

How come?


texts: How do I calculate the resource requirements for using Solr?

texts: I want to use Apache Solr for faceted navigation of my D6 site(s), but I'm unsure of the resource requirements for it. How do I check if my VPS can cope with implementing it?


texts:
We are sending newsletters via the Simplenews module in Drupal 7. All server configurations are good and it seems our IP was blocked for reputation reasons by Barracuda.

How does one send newsletters without this happening? All users opted in and should not trigger any spam filters? Is there an ideal number of emails to send via cron to avoid this?

How can we stay within the recommendations of the CAN-SPAM Act?

Is there an ideal way to setup the newsletter simplenews module in Drupal or the way the newsletter is coded to avoid problems?

Thanx.


texts: Different CSS file when in development mode

texts: Using Gulp I create two css files. One style.css and one style.min.css. Is it possible to load the style.css when developing (locally) and the style.min.css when in production (remote)?


texts:
i have custom software and wanna write an api for drupal (custom software -> drupal). The thing is the custom software will call api calls to index.php (you cant change that). So how can i write something like an index.php for my module, like (http://drupal.install/myhookmenulink/index.php) so the software can reach that link and send infos to my module. anyone know ?

greetings


texts:
I’m utilizing accordions in a large install and I cannot save nodes.

When the save button is clicked it creates a required paragraph that is hidden in an accordion. When you delete the created paragraph it still will not allow the node to save.

This is happening in multiple sites with various versions.

An AJAX 403 sometimes gets thrown, but usually it fails silently.

I have attempted the following to remedy the issue:
Making the paragraphs not required
Pulling the paragraphs out of the accordions
Making any nested fields within the paragraphs not required

The only path that seems to work is to recreate the node from scratch entirely, but now my data set is too large to do that.

Field Group Version: 8.x-3.0-rc1
Paragraphs Version: 8.x-1.11 & 8.x-1.12
Drupal Version: 8.8.6

I've also posted this on drupal.org - thanks for any assistance!


texts:
This is the RSS I want to import. I want to write mapping to fetch the <img> tag within the <description> tag. When I import I get this.

 xpathparser:3 :
   <description>&lt;img
   src="http://www.moneycontrol.com/news_image_files/2013/a/acquisitions_yahoo_tumblr.jpg"
   alt="Tumblr had $16.6 mn in cash when Yahoo acquired it" title="Tumblr had $16.6 mn in
   cash when Yahoo acquired it" border="0" width="75" height="75" align=" left"
   hspace="5"/&gt; The deal for Tumblr was the largest since Yahoo Chief Executive Marissa
   Mayer took the role in July with a focus on reversing a long decline in Yahoo's
   business and web traffic. The deal also made Tumblr founder and CEO David Karp, 27, a
   multimillionaire.</description>

What should be the xpath to get the <img> source?

I've tried Feeds Tamper to convert &lt; to < and &gt; to >and the following xpaths, but nothing works.

   //img/@src
   description[1]
   description/img
   description/img/@src

I am using Drupal 7.


texts: How to change background color in my Tao subtheme

texts:
We have a custom sub theme built on Tao and I tried adding

body {
  color:#fff;
  background:#333;
  }

to the style.css file, but to no avail. In Chrome dev tools I started inspecting elements and changing their backgrounds individually, but I cannot figure out how to change the background color for all divs, form elements, blocks, etc without some super complicated CSS.

I'm trying to avoid doing this, if possible:

#main-content {
  background: #333;
}

#page {
  background: #333;
}

#page-title {
  background: #333;
}

#branding {
  background: #666;
}

div.limiter {
  background: transparent;
}

div.region {
  background: #333;
}

span.fieldset-title {
  background: #333;
}

div.tabs {
  background: #333;
}

fieldset.collapsible {
  background: #333;
}

.collapsed .fieldset-legend a {
  background: #333;
  color: #fff;
}

Further, when implementing this code, I cannot get some divs to change color, for instance <div id="page-title">


texts: Add theme settings field to theme-settings.php in d8 is not working for me

texts:
I followed the documentation on drupal.org to add a field to the theme-settings.php but there must be a mistake in code.

I have a filed called advertisement and a theme called tv so I tried to copy and paste the code and altered the names where to alter theme the files I created in particular are as follows:

/themes/tv/templates/system/thme-settings.php

#}
function tv_form_system_theme_settings_alter(&$form,
\Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {
  // Work-around for a core bug affecting admin themes. See issue
 #943212.
  if (isset($form_id)) {
    return;

$form['tv_advertisement'] = array(
    '#type'          => 'textfield',
    '#title'         => t('Widget'),
    '#default_value' => theme_get_setting('tv_advertisement'),
    '#description'   => t("Place this text in the widget spot on your
 site."),
  );
}
$tv_advertisement = theme_get_setting('tv_advertisement');

in /themes/tv/config/install/tv.settings.yml I put this:

tv_advertisement: blue bikeshed

My /themes/tv/tv.theme file contains:

<?php
/**
 * @file
 * Theme functions
 */

// Include all files from the includes directory.
$includes_path = dirname(__FILE__) . '/includes/*.inc';
foreach (glob($includes_path) as $filename) {
  require_once dirname(__FILE__) . '/includes/' . basename($filename);
}

 function tv_preprocess_node(&$variables) {
 $variables['tv_advertisement'] =
 theme_get_setting('tv_advertisement');
 }

The last thing I did was

drush cr

to clear the cache

When I go to the themes settings page there are only the default fieds displayed but the new one does not show up

If anyone has a clue what I am doing wrong and is able to enlighten me I would be very pleased.

Thank you


texts: Access webform by checking predefined codes

texts: If I set up a webform with one component "authrization code", which is predefined by my side. People can access the form only when they get the authorized unique code from me. Is there any way to realize this? I tried a module "webform invitation", but have the same problem as described "any code is accepted"(my system is D8.64,php7.0). If I add a text field for code validation, I don't know where to predefine those codes and how to check. Another question is how can I produce those unique codes and transfer them to QR codes so that people can scan them to automatically fill in the form? Appreciate for any help in advance!


texts: Difference between hook_form_alter and hook_field_attach_form

texts:
I was attempting to add default values to the addressfield field type (on the Drupal Commerce billing pane), and originally tried doing this in hook_form_alter and it did not work. I then found the module commerce_extra_address_populate which used hook_field_attach_form, and it worked.

When would you use hook_form_alter and when hook_field_attach_form when trying to modify a form, and why didn't hook_form_alter work in my scenario?

I populated an array of fields

$fields = array(
  "name_block" => array(
    "rank" => $rank->name,
    "first_name" => $user_fields->field_first_name['und'][0]['value'],
    "middle_name" => $user_fields->field_mcaf_middle_initial['und'][0]['value'],
    "last_name" => $user_fields->field_last_name['und'][0]['value'],
    "suffix" => $suffix->name,
    "credentials"=> $credentials->name,
  ),
  "organisation_block" => array(
    "organisation_name" = >$user_fields->field_mcaf_profile_organization['und'][0]['value'],
  ),
);

and then looped through it to set the form values

foreach($fields as $gkey => $group) {
  foreach ($group as $fkey => $value) {
    //dpm($fkey." - ".$value);
    if (!isset($form['commerce_customer_address'][$langcode][0]['#address'][$fkey])) {
      //dpm("hete");
      $form['commerce_customer_address'][$langcode][0]['#address'][$fkey] = $value;
      //$element[$gkey][$fkey]['#default_value'] = $value;
    }
  }
}


texts: How to set nodes to be excluded from a block view based in the url of current node?

texts:
I have a view block listing nodes. Let's say I have the following nodes (it's urls)

node/first-node
node/second-node
node/third-node
node/fourth-node

Then I have the view block listing this 4 nodes. This block is shown in the First sidebar in all pages.

What I need: when the block is shown at the page node/fourth-node, I need to arbitrarily exclude from the view block from the following nodes.

   node/second-node
   node/third-node

I need to do this in a way so that then after I can do the same thing with other nodes.

I thought of adding a field to the node called: "Exclude from view block at:" to be filled with the paths (one per line) where the node will not be listed in the view block (similar to blocks settings). Then I will need to modify the view.

Is this a correct approach? If so, what do I have to do in the view?


texts:
The path '/profiles' exists as a physical folder in the root of a Drupal install, which means adding a URL alias for a piece of content to '/profiles' will not work - a 403 error is the result.

Lucky 'ol me, for a particular project I have an SEO partner telling me that using that particular path is an absolute, categorical must; not having this would be proof that the Myan's doomsday prediction is in fact accurate, we'll all die slowly, etc., etc.

So I'm going to go ahead and throw this slightly ridiculous question out to the masses to see if anyone's found a creative way to solve this problem before...

How can I use '/profiles' (and '/profiles/*', etc.) as URL aliases, while maintaining a fully functional, update-able Drupal instance?

Importantly, we're using the Global Redirect module, with the 'De-slash' and 'Non-clean to clean' options enabled (and they need to stay that way).


texts:
How to transfer the submitted data too when redirecting a form through $form_data['#redirect']?

Like :

hook_menu declares : page-1, page-2

page-1 having a form that when submitted triggers page_1_form_submit() (in which I does the redirection)

but I'd like that once redirected to page-2, page_2_page() (registered as render function in hook_menu) can access the previously submitted data!

:)


texts: when cron is running, apache PID peaks, and blocking the server response. is it possible to limit the cron CPU usage and leave some headroom for HTTP requests?


texts: Pass field on node/x/edit to a view, using global field / php?

texts:
I just want to pass a field from a node being edited- to a view- that I am using to provide a select list for another field on that same node, that is an an entity reference.

And I think I could maybe do that by using a global field on the view, with php- to get the field I want, from the node being edited- into the view?


texts: How to show Wordpress blog posts in Drupal's Search Api?

texts:
We have a blog site on Wordpress that we want displayed in our search without having to create Drupal nodes for each blog post. We using the following below and were interested in seeing how we can do this as the Wordpress Migrate and Migrate has not provided a way to do this.

All we want to do is display the blog post on our search (which using Apache Solr Search Index) in such a way that we pull the blog post title, description and a direct link to the post.


texts: Import a PDF from within a page (Feeds / Mailhandler)

texts:
I am using Mailhandler to import quite a bit of content. The one piece I'm not able to get is a pdf.

The email body contains five links. The last link goes to a page that has an iframe with a source of the pdf I want. Example:

<iframe src="/files/20394.pdf">

However, the link in the email does not seem to have "20394" anywhere in it, so I can't even generate the link to the pdf myself.

At the end, then, I would have the importer import that link as a file.

Is there any other way to grab that pdf?


texts: How to re-create vanilla field configuration strings programmatically for any field?

texts:
After a D7 update and migration of fields, most of our problems with converted fields result from invalid or incompatible field settings. Field settings are stored in the
field_config_instance.data column in the database as serialized php objects.

How can I, for any given field instance, generate a fresh field configuration string, as if the field was just created in D7, while leaving the already stored field data intact?

My manual approach seems to work but is very cumbersome:

create a new content type
add an existing field to the new content type, generating new settings string
search the new and old field in the database
using sql: replacing the string in the data column of the old field (with the same name) with the new data content.

There must be a way to automate this a bit.


texts: Default Field Value based on another referenced field

texts:
I am now learning drupal 8 and I am struggling about 2 weeks to find an answer to this. I am trying to give to a reference field of the comment a default dynamic value. This value is the same with the referenced field of the article that the comment belongs. There are 2 ways to do this:

1) The easiest and cleaner way is to create a view that will show the specific article's field value that the current comment belongs. Easy but the issue is that although the view has only one result, that result cannot be set as default value. The user has to choose it or type in the autocomplete box in order for the value to appear. Is there any way to make that field been automatically completed and make it hidden? I would like the user not to be aware of that field

2) Here is another solution more difficult to me. https://www.drupal.org/node/1797100#comment-11792569 I should create a text widget for my field. I tried this but it is not working. The field has been created from the dashboard. I would like to keep things as cleaner as possible and not to create the field from the beggining with code. I believe that the text base,text widget and text formatter have already been created by core and that's why my text widget is not working. Should I in this case override (alter) the text widget and not create a new one and if yes how could I do that? https://api.drupal.org/api/drupal/core!modules!field!field.api.php/function/hook_field_widget_form_alter/8.2.x

function hook_field_widget_form_alter(&$element, \Drupal\Core\Form\FormStateInterface $form_state, $context) {
  // Add a css class to widget form elements for all fields of type mytype.
  $field_definition = $context['items']->getFieldDefinition();
  if ($field_definition->getType() == 'mytype') {
    // Be sure not to overwrite existing attributes.
    $element['#attributes']['class'][] = 'myclass';
  }
}

where should I place the above function?

If you have an answer to 1) or 2) please leave a comment, I am totally desperate as this is very basic for the functionality of my website and I cannot find a solution...

Thank you


texts: How can I style fields in custom content type

texts:
I am using Drupal 8 and I've made a custom content type, and I've figure it out, that I can "style" this content type with page--mycontenttype.html.twig and with adding this code in mytheme.theme:

function mythemename_theme_suggestions_page_alter(array &$suggestions, array $variables) {

  if ($node = \Drupal::routeMatch()->getParameter('node')) {
    $content_type = $node->bundle();
    $suggestions[] = 'page__'.$content_type;
  }
}

But with this I can only style page of custom content type, and not the fields of it. I try with this but it's not working:

{{ node.field_body.value }}
{{ node.field_title.value }}


texts: How to list Content A nodes on Content B's page using Entity Reference fields and Views (with Paragraph field Bundles attached)

texts:
I have Content A (Music Albums) with entity reference fields referencing Content B (Musician).

I want to display a view on Content B (Musician) page that displays every Album (Content A) they are 'tagged' on. Basically using entity reference fields in place of taxonomy (per StackExchange suggestion).

Content A (Album) has a View displaying various info such as album image, album name, record label etc... and an Entity Reference field  referencing Content B (Musician). When clicked it takes me to the node page of that Musician.

On the Musician's (Content B) page I want to have a View displaying all Albums (Content A) they appear on (tagged via entity reference field).

Finally, Getting the entity reference fields attached to a Paragraph Bundle to relate to Content B (Musician)


texts: I could not access a page as administrator user

texts:
I just had a problem where a page created with a custom module caused an access denied error even when logged in as administrator user.

function cmis_play_menu() {
  $items['cmis_play'] = array(
    'title' => 'cmis_play',
    'page callback' => 'cmis_play_page',
  );

  return $items;
}

function cmis_play_page() {
  return 'boot';
}

I checked the following.

The administrator user has all the privileges
Cookies are disabled in settings.php
The database username and password are correct

I tried the following (without success):

Drush CC all
Truncating the session table
Accessing the page as a guest and as non administrator (but authenticated) user

I solved the problem by adding the following line:

$items['cmis_play'] = array(
  'access arguments' => array('administer news feeds'),
);

Why did I need to do this?
How do I configure Drupal so that expressly setting access permissions for a page is not needed?


texts: What's the best files and directories permission for shared hosting

texts:
i'm using a shared hosting for my Drupal Website and I'm having some security troubles especially with folders and files permissions.
So after some researches in the official documentation and some group discussions and even in StackOverFlow answers , I made my configuration like this:

Any Drupal php file: 444
Drupal folders: 555
SITES folder: 755
SITES/DEFAULT folder: 505
SITES/ALL folder: 705
SITES/ALL files:604
settings.php : 404
SITES/DEFAULT/FILES folder: 775

Is there anything to correct or to adjsut for more security?


texts: checkboxes on submit not showing correct values. Shows 0 always

texts:
I am working with a form which contains list of checkboxes based on country. checkboxes are rendered correctly. But on submit, I don't get checkboxes' correct values. It always gets submitted as NOT CHECKED. My code is as below:

    foreach($fields as $id=>$title) {
          $form['test'.$code]['fields-'.$code] = array(
              '#type' => 'checkboxes',
              '#options' => drupal_map_assoc(array_keys($fields)),
              '#title' => t('Title'),
              '#attributes' => array('name' => 'field-'.$code.'-'.$id),
          );
        }

    function config_submit($form, &$form_state) {
      var_dump($form_state['values']);
      exit;
    }

outputs :

array (size=13)
  'fields-dk' =>
    array (size=7)
      'title' => int 0
      'reason' => int 0
      'doc-reference' => int 0
      'description' => int 0
      'upload-claim-file' => int 0
      'product-detail' => int 0
      'barcode-num' => int 0

Why is it returning always as 0? What am I missing?


texts: Check if there is already a valid one-time-password -reset link

texts:
I am using drupal 7.
I have this functionality that when a user clicks the reset password he gets a one time link on which if he/she clicks then they gets to some page where they can change their password.

But this functionality is somewhat need to be modified.
Suppose if they don't click on one link sent to them and then again request forget password, i want to send the same on-time-password-reset link to them and not generate new one untill 24 hours or if they clicks whichever happens first.

So do we have any function which can tell us if there is already existing one-time-password-reset link in database or not and if yes how can we reuse that instead of creating new one.

Also if they clicks on the one-time-forget-password link then they should land on password reset page (it is working as expected), but they should not be able to click any other navigation icon and if they does then message should tell them that they need to reset their password first.


texts: Using entity_lookup inside an entity_generate migration process plugins

texts:
I'm trying to use an entity_lookup process plugin inside an entity_generate process plugin. The YML looks like this

field_validation:
    plugin: entity_generate
    access_check: false
    entity_type: node
    source: validation_name
    value_key: title
    bundle: validation
    ignore_case: true
    values:
      title: validation_name
      body: validation_description
      field_validation_type:
        plugin: entity_lookup
          access_check: false
          ignore_case: true
          source: validation_type

The error I'm getting is

  Uncaught PHP Exception
  Drupal\Core\Config\UnsupportedDataTypeConfigException: "Invalid
  data type in config xxxxxx, found in xxxxxx : A colon cannot be used
  in an unquoted mapping value at line 282 (near "  source:
  validation_type")." at xxxxxx line 117, referer: xxxxxx

Because I'm relatively new in using the Migrate/Migrate Plus modules, I'm not sure if the error is triggered because I'm doing something wrong with the syntax or just because I can't use entity_lookup inside an entity_generate. So, the question is: can I do something like this, or I'm forced to use a separate migration instead of entity_generate and the call it with migration_lookup?

[later edit, just for context]

my field definition:

-
 name: validation_type
 label: 'Validation Type'
 selector: $.Description.Validation[*].Type #item_selector is set to $.Schema[*]

the relevant part of the source JSON:

{
  "Schema": [
    {
      "Description": {
        "Validation": [
          {
            "Type": "CUSTOM_TYPE",
            "Description": "lorem ipsum"
          }
        ]
      }
    }
  ]
}


texts: How to get plain link with views-data-export module in CSV?

texts:
I have a view with field that provides a simple link to the content.

Problem: When I export the data into a csv file there is only the word link instead of a link.

How can I get there the content URL instead of the word link?


texts: Cannot Send an Email Using SMTP module in Drupal 7

texts:
I'm using SMTP module to send an email in Drupal 7. I have tested to send an email through configuration and it works. Unfortunately, when I'm trying to send an email after submitting a form (in my apps). It says successful, but no email has been sent to my mail.

I setup the module based on this article: http://www.symphonythemes.com/drupal-blog/configure-drupal-smtp-gmail

Here's the settings:

host: host.mycompany.com
port: 25
secure: no
authentication: no
from: info@company.com
from name: Info Company
testing to: myname@company.com

Here is the code:

$mail = new PHPMailer();

$mail->IsSMTP();                                      // set mailer to use

$mail->From = "info@company.com";
$mail->FromName = "Info Company";
$mail->AddAddress("myname@company.com", "My Name");

$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = "Here is the subject";
$mail->Body    = "This is the HTML message body <b>in bold!</b>";

if(!$mail->Send()) {
   echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
   echo "Message has been sent";
}

if(!$mail->Send()) always return true, but no email has been sent.
The email and host are in one domain, so I don't think there is any permission problem?


texts: How to declare core requirements in composer.json?

texts:
If a module depends on a particular minor release of Drupal (eg 8.4.*), the best practice is to declare this in info.yml: This blocks installation of the module if core is too old.

However, this just blocks installation, and doesn't help at all with falling back to a compatible version. We can make this much easier by also declaring the compatibility in composer.json.

Requiring drupal/core in the composer.json of a module seems like a major change, though. For one thing, it means that your local dev environment pulls in core as well as all its dependencies (about 40 packages), and not their default locked versions either, but the latest supported ones (same effect as running composer update in a core checkout). For another, it will cause problems for all environments that use composer for contrib only.

I think "conflict": {"drupal/core": "<8.4"} might be a low-impact solution here.

Is there an accepted best practice for this already?