texts: Why isn't my hook_theme being called or rendering output?

texts:
I am trying to use the hook_theme function to utilize some template files.  I have the following function defined in my theme:

template.php

function my_name_theme($existing, $type, $theme, $path) {
    return array(
        'testy' => array(
            'variables' => array('title' => NULL),
            'template'  => 'testy',
        ),
    );
}

And I have the following template defined:

testy.tpl.php

<?php print $title; ?>

I have a content type called "Page" with a corresponding template:

node--page.tpl.php

<?php
    print 'before theme call';
    $variables = array();
    $variables['title'] = 'my title';
    print theme('testy', $variables);
    print 'after theme call';
?>

When viewing one of my "Page" content types, the rendered page only shows the following, with no title:

before theme callafter theme call

I have cleared all caches.  Why isn't this working?


texts: Workbench Moderation - intermittent save / autosave without new revision

texts:
I'm stuck with a problem while using workbench moderation. while working on a node, my client wants to save / auto save his work but if he hits the default save button then it is creating a revision (which is unwanted, since his work is not finished yet).

how is it possible for admin to save their content while they are still working on it, something like "save as draft", which they can continue later?

is there a way in workbench moderation to have it create a revision only when the moderation state is changed? If not, is there any other module which works with workbench to auto save / save the work without creating a new revision.

I also need the admin to stay on the same edit page when he hits this save button. I tested "save & edit" module, which does what I need but it also creates a new revision, which is not required.

please help!


texts: Image preview thumbnail does not display

texts:
Drupal 7.

When adding a core image field to a content type to display an image, the preview thumbnail does not display on the edit page when uploading an image.

What appears after clicking on the "Upload" button is a placeholder for the image and an image icon. The placeholder then quickly disappears to leave the icon and the name of the file. It looks like the link is broken and the image cannot be found. However, the uploaded image and it's preview (thumbnail image style) are in the right folders. This is confirmed when the edit page is reloaded (browser refresh or a new visit to the page) because the preview image then displays properly on the edit page..

Clicking the Save button displays the image in the content.

However, if I do not click the Upload button and click on the Save button directly instead after selecting an image with the Browse button, the content image is not displayed either unless I click on the browser Refresh (or go to another page and come back.)

A few people have had this issue.

In this Youtube tutorial, the issue is reproduced (the thumbnail does not show up.) The instructor notices it but gives no solution: Drupal Tutorials #9 - Custom Content Types Part 2 Manage Display

Does anyone know what's going on and how to fix this?

Any and all help will be greatly appreciated. :)


texts: How do I make batch callbacks as class methods?

texts:
This is the code I am using.

$serviceClass = \Drupal::service('abcclass.service');
$batch = array(
  'title' => t('Pushing updated.'),
  'init_message' => t('Start Pushing.'),
  'progress_message' => t('Completed @current step of @total.'),
  'error_message' => t('Pushing has encountered an error.'),
  'operations' => array(
    array(array($serviceClass , 'ebook_push_single_pdf'), $node->id()),
  ),
  'finished' => array($serviceClass , 'ebook_push_finished'),
);
batch_set($batch);

But it doesn't work. I checked log file and I get:

  Settings can not be serialized. This probably means you are serializing an object that has an indirect reference to the Settings object. Adjust your code so that is not necessary.

Note that if I implement batch callbacks in same file, it works.

How can I fix the code?


texts: How to get "Show block on specific pages" working?

texts:
I would like to show a certain block only on one specific page. I want to use the Show block on specific pages feature for it. I have tried to set the url of my page like content/hills-restoration-process  as well as the actual node number, like /node/36 but I don't seem to get it to work correctly. What am I doing wrong here? It seems like an easy and straight forward feature...
Thanks for hints and suggestions!


texts: Calendar Prev/Next buttons linking to wrong dates

texts:
In the calendar month display for August with the path calendar/2015-08, the forward and next page buttons offer the user a link to October -- completely jumping over September straight to October.

That is, the Next link in the above picture jumps straight to
calendar/2015-10.

I'm at a loss. I've tried cycling Ajax in the view which did nothing.

I'm running the following modules:

$ drush pml | grep calendar
 Date/Time  Calendar (calendar)               Module  Enabled        7.x-3.5
 FullCalen  FullCalendar (fullcalendar)       Module  Enabled        7.x-2.0
 dar        (fullcalendar_colors)
 dar        (fullcalendar_legend)
 dar        (fullcalendar_options)

And I see the this view is rendered in the ./sites/all/modules/date/date_views/theme/date-views-pager.tpl.php

<?php if (!empty($next_url)) : ?>
 49       <li class="date-next">
 50         <?php print l(($mini ? '' : t('Next', array(), array('context' => 'date_nav')) . ' ') . '&raquo;', $next_url, $next_options); ?>
 51       </li>
 52     <?php endif; ?>


texts: What theme function outputs the administrative overlay in D7?

texts: What theming function generates the output for the admin overlay in d7?


texts:
What I have

A list of taxonomy terms with a name field, a logo field and a category field (category is defined as a list).
A View that should show all logos of the taxonomy term if a certain category matches (e.g. I want to show all Cloth logos if the category is Cloth).

My problem:

I'm trying to use a contextual filter to choose the taxonomy term category and provide a default value from the URL. But the URL contains "cloth" and not "1" so I get no results.

How can I convert the string to the value? Is that even possible?


texts: List Nodes/Content Type Items with same tags as current

texts:
On the node page I'd like to add a linked list of other nodes tagged with the same tag/taxonomy term. How can this be achieved? Via Views?

Any help will be highly appreciated


texts: What are the tables that once were term_node & term_data?

texts:
In Drupal 6 there are the following database tables: term_node and term_data.

What are the equivalent tables for Drupal 8?


texts: How to use views hooks - specifically hook_view_data()?

texts:
I am looking for details on the api to define my own view data, such as what values I can provide for the table I am defining, what values are available for the fields etc.

I have found a tutorial that gives me the basic info, but now I need more specific info.

I have found this page

https://api.drupal.org/api/views/views.api.php/7

but when I click on the link to

hook_views_data

I go to a page with virtually no information with one link which takes me back to the listing page I started at.

Is there somewhere I can find out information about what hook_views_data should define?


texts: for how long is Content considered "new" by the filter criteria "Content: has new content"?

texts:
I'm trying to find out how Drupal uses the "has new content" filter criteria.  I'd like to create a View that only shows the latest content on the site, but not sure what is going to be returned.  24 hours, 7 days, 30 days?

I don't see any way to set the duration, either.


texts: How to remove Quicktabs cookie on certain page?

texts:
I found a useful snippet here to make Quicktabs remember which tab was open if the user leaves the page and then comes back again. My problem is that I want to remove the history (the cookie) after the user has payed a visit to a certain page. In that case I want the default tab to be opened when the user comes back again. In the Quicktabs settings I have set the wanted default tab.

I have a script.js in my theme with this snippet:

  Drupal.behaviors.quicktabsHistory = {
    attach: function(context, settings) {
        var id = $(this).attr('id');
        var tab = $.cookie(id);

        // enable quicktabs memory
        $('.quicktabs-wrapper', context).each(function() {
            if (tab != '') {
              $(this).find('ul.quicktabs-tabs a#' + tab).click();
            }
            $(this).find('ul.quicktabs-tabs a').click(function() {
                $.cookie(id, $(this).attr('id'));
            });
        });

        $('.view-taxonomy-term', context).each(function() {
            if (tab != '') {
              $.removeCookie('id');
            }
        });
    }
};

Everything works fine, except for the part where I want to loose the history. How can I remove the cookie if the user visits the page with the wrapper class ".views-taxonomy-term"?

EDITED: I tried changing the removeCookie row to insteaed force the tab I want to be the default one:

    $('.view-taxonomy-term', context).each(function() {
        if (tab != '') {
          tab = 'quicktabs-tab-instrument_flikar-0';
        }
    });

But that did not do the trick. I have checked though with a breaking point in the script that the tab variable actually is set to the new value, but the previous tab is still activated after return to the page with the tabs. There is something about Drupal.behaviors.quicktabsHistory that I don't understand, obviuosly. :-(


texts: Trigger a module function after a node is saved or updated successfully in the database

texts:
I have used this function hook_node_insert() , but it does not help me because this hook runs before the node is actually saved in the database. I am indexing nodes to a third party application whenever a node is inserted, updated or deleted. The application sends request to the node URL, but using hook_node_insert(). It's giving me an invalid document location error because the node is not actually inserted yet.

Is there any hook invoked after a node is saved or updated in the database?

I followed this approach, without success.

function  my_module_node_insert($node) {
  if (!$node->type == 'article' || !$node->type == 'page') {
    return;
  }
  my_module_do_index($node);
}


texts:
Let's say I have two content types: Page and News.   Both of them have a field called Tags which is taxonomy term.

Let's say I tag a page and a news item with the term 'celebration'.  When a user goes to the page on the front end website, the user should see related news items on the right side bar.  A news item is related to a page if they both have at least one tag in common.

I tried to set up a news item block, but i don't know how to tell it to show only news items that share at least 1 tag in common with the page.


texts:
I am open to doing that with hook_ module code (since i'm doing all my work in a custom module), and I'm open to doing that with Panels, which I'm using.  I don't want to add PHP in the admin interface.

Thanks in advance.


texts: Any way to stop Drupal css from dynamically resizing pages?

texts:
We recently upgraded from Drupal 5.x to 6.22 and one thing noticed right away was that when the browser was taken off full-page the displayed page content would reformat into a very undesirable order.  Previously the page would not resize and users could focus on only a small portion of the screen when in a windowed mode.  This was true for mobile displays as well.
Is there any 'simple' way to prevent this from happening?  I realize this might be a css issue of which I am no expert.  But because this entire site is generated and delivered via Drupal I thought I would ask others.


texts: How to access referenced entities programmatically

texts:
I have an entity (a node) with a term reference field. I'd like to access the referenced term entities programmatically, i.e. the fully loaded term objects.

Note that my question could equally apply to any referenced entity, e.g. node entities, user entities, etc.

Here's what I've got so far:

$node = \Drupal\node\Entity\Node::load($nid);

$term_ids = array();
$items = $node->field_tags->getValue();
foreach ($items as $item) {
  $term_ids[] = $item['target_id'];
}

$terms = \Drupal\taxonomy\Entity\Term::loadMultiple($term_ids);

It works, but I'm not very happy with it:

It lacks abstraction (how am I supposed to know that the id of the referenced entity is in $item['target_id']?)
It's not very generic (it works if the field references terms, but what if it references nodes or users?

Any better solution?


texts:
I am having great difficulty in trying to create my own theme. The errors that persist are:

  Notice: Undefined variable: hide_site_name in include() (line 98 of C:\wamp\www\drupal7\sites\all\themes\ppro8\templates\page.tpl.php).
  Notice: Undefined variable: hide_site_name in include() (line 108 of C:\wamp\www\drupal7\sites\all\themes\ppro8\templates\page.tpl.php).

I copied all files from the bartik theme into /sites/all/themes/myTheme/, and did the following:

I changed bartik.info into myTheme.info, and 'name = bartik' to 'name = myTheme'.
I replaced all occurrences of 'bartik' in templates.php to 'myTheme' (search and replace with notepad++). Up to this stage, the error still shows, so I tried the following as well:

I replaced all occurrences of 'bartik' in all files in the folder 'myTheme'

However, none of the above steps could remove the errors.

Could anyone please shed some light on this issue?


texts:
I am trying to call a custom date field to use in a text pane from a node to use as YYYY-mm-dd in:

yyyy-mm-dd

I have tried to use:

<?php echo date('Y-m-d', strtotime($node->field_custom_date['und'][0]['value']));?>

but this is not working.  I have tied to just print the php but get a result of 1970-01-01 instead of the date in the field.

What am I missing?


texts: Designing different content types with the same fields' name (shared fields)

texts:
For my website I need several content types (at least five), but all that have some fields' name in common as title, subtitle, body, teaser, image and so on.

Shall I use the same field (machine name) for all the content types or is better an its own field for each content type?

For example, if I have the two content types "articles" and "recipes" and create the field "field_subtitle", shall I use this field for both content types or is better to create the two fields "field_articles_subtitle" and "field_recipes_subtitle"?

Are shared fields better or worst in term of performance?


texts: Which hook to use in a custom module for tracking access to one particular page?

texts:
I'm probably not fully awake this morning because it seems so trivial but I cannot figure it out.

I need a hook to track when user access a certain page (path = 'export-csv'). This page is not a node neither a View and neither a form... It is just a "path". And I need a hook that I could use in my custom module's file, not in templates.

I thought of something like hook_preprocess_page or but it doesn't seem to work.

I need a hook called before the page is fully loaded because the page is never truly displayed (it is a page for downloading a file and it just shows the download popup).

If you need precisions about my code or something, just ask. But I don't think that it is necessary.

Thanks in advance of course.

edit: I found a part of solution here but I still have trouble because of the nature of the page. I never truly land on the page and I think the hook is not called before the popup happens.

The callback function of this page looks like this:

function grap_contact_export_csv_page() {
  header("Cache-Control: public");
  header("Content-Type: application/octet-stream");
  header("Cache-Control: no-store, no-cache, must-revalidate");
  header("Cache-Control: post-check=0, pre-check=0");
  header("Content-Disposition: attachment; filename=\"grape-export.csv\";" );
  header("Content-Transfer-Encoding: binary");
  $fp = fopen('export.csv', 'r') or die('Impossible d\'accéder au fichier');
  echo fread($fp, filesize('export.csv'));
  fclose($fp);
  drupal_exit();
}


texts: Will the PHP filter prevent SQL injection attacks?

texts:
I had trouble getting the form API to work though I am considering re doing all my forms with it. I have some custom html/php forms however I directly insert into the DB using pg_query. I am looking into replacing that with pg_query_params to escape. I was wondering whether the php filter module, if I set it up, would prevent users from doing harm via sql injection? Iwould guess not but thought I would check.

Just looking for suggestions.


texts:
If I should allow users to log in using the same username/password, what should I consider when choosing between the following solutions?

Install, and use Bakery Single Sign-On System on the main site, and all the subdomains.
Share the database table containing the user data.


texts:
I have drush 9 installed (current dev release). I can't find the archive-dump command, despite the docs suggesting it should be there.

Executing it produces:

  The Drush command 'archive-dump' could not be found. Use 'drush core-status' to verify that Drupal is found and bootstrapped successfully. Look for 'Drupal bootstrap : Successful' in its output.

I can confirm that drush core-status (or status) states that Drupal is successfully bootstrapped. The problem is present for local and remote environments, and on any machine that it's installed on (I've tried 4 so far, a mix of MacOS and Ubuntu environments).

I've even gone so far as to grep drush's code for mentions of archive and ard (the alias that used to work and also should if the docs are to be believed. There doesn't seem to be anything pertinent in there.

So where's archive-dump gone?? If it's been removed, what's its successor?


texts:
I'm using organic groups 7.x-2.x, as well as admin_views for administering users. I have a field that I'm able to sort users on depending on what department they are in using Views Bulk Operations at admin/people.

My question involves subscribing people in bulk to a specific organic group. Is there a way to achieve this using Views Bulk Operations?


texts: Print module doesn't work with Panelizer module. Why?

texts:
I need to make print pdf module work on the panelizer node. But on page printpdf/node/nid, I see only the node title and panelizer field is not shown.
How to fix it?


texts: Access Denied on file attachment when node state is Draft in Workbench

texts:
I have a file attachment field defined in a content type I have under Workbench moderation. The file field stores the attachment in the private files folder.

PROBLEM:

When I create a node for that content type and view it in Draft mode I get a 403 access denied if I try to download the file attachment with any role other than admin.  If I publish the node I can download the file fine. Revert it back to Draft and I'm back to the 403 access denied.

I've tried enabling “Bypass moderation restrictions” for a role but that does not work around this error.

I really need a solution/workaround for this issue since I have a non-admin role that needs to be able review the node and the file attachment posted by users before they are published. I'm sure this is a fairly common scenario but I haven't been able to find any posts with a similar issue.


texts: How to print out usernames using EntityFieldQuery

texts:
I'm trying to filter users using entityfieldquery (type 'user') by fieldConditions, but I don't know how to print out the usernames on a page. If I use "print_r", it works. But I don't want to print them out on a white page. ^^ If I use $output, I get only one name. For nodes, there is a function "node_view_multiple" to use it like $output = node_view_multiple($nodes);
Is there also a way for entity_type user?

Here is my code:

global $user;
$angemeldeter_user = user_load($user->uid);
$alter = $angemeldeter_user->field_alter['und'][0]['value'];
$alter_faktor = 4;
$alter_untergrenze = $alter - $alter_faktor;
$alter_obergrenze = $alter + $alter_faktor;

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')
->fieldCondition('field_alter', 'value', array($alter_untergrenze, $alter_obergrenze), 'BETWEEN');
$result = $query->execute();

if (isset($result['user'])){
global $user;
$angemeldeter_user = user_load($user->uid);
$users=user_load_multiple(array_keys($result['user']));
dpm($users);

foreach($users as $value) {
  $user_list = (array)$value;
  $users[$user_list['uid']] = $user_list['name'];
  $output = '';
  $output .= $user_list['name'];
  return $output;
  }
  }
  else{
    $hihi = 'no results';
    return $hihi;
  }
}


texts: Assigning OG group title to OG group image title field

texts:
Every member of my site can create groups (OG.) Each group requires a title, an image, and a mission statement. The image Title field is enabled because in some parts of the site, the group images are displayed as thumbnails without the group titles.

However, most users don't bother to fill in the image title field so there is no indication of the group's title or purpose.

The idea here is to have the title of the group show automatically when the mouse cursor hovers above the group image after the group is created.

Any idea on how to accomplish this feast?


texts: Drupal 8: Form fields are not updating when checking triggering element

texts:
I have added a button to the node add form which allows the user to import data from the last node created into this one. Within hook_form_alter, I have:

// Import previous month's data if requested
$trigger = $form_state->getTriggeringElement(); //Check to see if button pressed

if ($trigger['#name'] == 'import_previous') {
  $id = \Drupal::request()->query->get('field_patient'); //grab node id from url
  $previous = st_access_patient_get_previous($id); //grab actual node
  $previous_array = $previous->toArray(); //cast node to array

  // Match up data from previous node to fields in this form, set default value
  foreach ($previous_array as $label => $field) {
    if (substr($label, 0, 5) == 'field' && $form[$label]['#access'] == TRUE) {

      if (array_key_exists('#default_value', $form[$label]['widget'])) {
        if (array_key_exists('target_id', $field[0])) {
          $form[$label]['widget']['#default_value'] =  $field[0]['target_id'];
        } else {
          $form[$label]['widget']['#default_value'] =  $field[0]['value'];
        }
      } else {
        if (array_key_exists('target_id', $field[0])) {
          $form[$label]['widget'][0]['value']['#default_value'] = $field[0]['target_id'];
        } else {
          $form[$label]['widget'][0]['value']['#default_value'] = $field[0]['value'];
        }
      }

    }
  }

}

$form['previous_import'] = [
  '#type' => 'button',
  '#name' => 'import_previous',
  '#value' => t("Import the previous month's values"),
  '#weight' => -9999,
  '#submit' => ['import_previous_submit'],
];

My understanding is that the button will just submit the form, I don't actually need

'#submit' => ['import_previous_submit']

When pressing 'import_previous' button the field values are not updated. If I remove the conditional (which just runs the replacement logic on every form load) then everything works fine. So, I know my logic for the replacement itself is correct. But once I wrap my replacement logic in:

if ($trigger['#name'] == 'import_previous') {}

Then the fields no longer update when the button is pressed. The conditional passes, so I know that is correct. Something else is keeping the form default values from being set. I have tried to add:

  $form_state->setRebuild(TRUE);
  $form_state->setCached(FALSE);

after:

$trigger = $form_state->getTriggeringElement();

and directly before the final closing tag of the conditional. I have also tried to add it to a submit function 'import_previous_submit'. No love with any of that. Any help is greatly appreciated.


texts: Accidentally deactivated flex slideshow on home page

texts: I've accidentally deactivated the flex slider on the home page of the site. The content is still there--I've checked--but it's just an empty block on the home page instead of a large slider. How can I get it back? Thank you!


texts: Search API facets using taxonomy hierarchy causing logic problem

texts:
I have set up search API with facets and a SOLR backend. It all works fine in general, except when I try using with a hierarchical taxonomy.

Each node has a town/city term associated with it. These are represented in the taxonomy as:

-Region 1
--Town1
--Town2
-Region2
--town3

This all displays fine, and works as expected when you click a region:

But when I click a town, instead of showing just the town nodes, it shows all the nodes in the region - i.e. an OR selection as opposed to AND. So this is still showing all the nodes in all the other towns, not just Tavira.

And yes, I do have the operator set to OR on the facet display page, so whilst I'm not entirely surprised at this behaviour, setting it to AND completely changes the way the facet is displayed. Plus I would like OR selections to work within the region.

So, I'm wondering how I can achieve the expected behaviour - I've seen it on various sites so I know it's possible.
Any ideas how I can do this?

Thanks,
Chris


texts: How to set custom user view mode for comments

texts:
How do I control which view mode of a user account appears on different pages?

I have a Compact user view mode with two fields I want to appear in forum posts and comments. I then have a more complete user view mode I would like to have appear on the users home page and eventually i would like a different view mode for article bylines.

I cannot, for the life of me though, figure out how to actually have any of these display.

I want to modify the layout of user.html.twig for the user home pages to have additional headings and information. But then it gets used wherever the user entity appears. Am I suppose to create specific twig templates for every user appearance or is there some more sensible way to control the fields that appear?

I tried accessing specific user entity fields and styling them in templates such as node--forum.html.twig but I can only seem to access the complete user entity with {{ author_picture }} - why is it named that if it is the entire entity? or the user name with {{ author_name }}

How do I do this?


texts: How to translate menus that are made in views?

texts: I'm having hard time translating my menu to other languages, when I try to translate menus that I made with views I confront with "You are not authorized to access this page." Is there any easy way to translate such kind of menus?


texts: How to prevent a node being saved when using the Rules module?

texts:
Is it possible to prevent a node from being saved with Rules? This is what I do now:

Create a rule Before saving content of type ''.

Condition: IF ...

TRUE => Redirect & set message

Create a rule After saving content of type ''.

Calculate & set value

So when a condition is true before saving I want to redirect the user, show a message and DON'T save node.

When it's not true I want to save the node and do the actions in the after saving content of type rule.

The problem is that when the condition is true in the first rule, the redirect and set message is performed. But directly afterwards the node is saved and the actions in the other rule are executed.

How can I make sure that the second rule doesn't get executed? Can I do this without custom code?


texts: How do I display custom tables field value in content-type form?

texts:
I have created custom table where am storing some information.

Now I want to show some data from that table to my particular content type form.

So how to do that?

What i did:

I have created one custom table which contains some history of form submissons. Now, whenever I come on form want to show records from that cusom table, show how to do that?


texts:
I have a content type called Area and another content type called apartment that has a reference to area.

I have an Investment form (using entityform module) in which users select which area; after that, users should be able to see apartments in that area in a select box. (This feature should be implemented wit ajax.)

I want to have some filters on areas and apartments like views module filters (for example apartment which are not sold). How should I implement these features?

and here's my node--invest.tpl.php:

<?php $language = $GLOBALS['language']; if ($language->language == $node->language): ?>

                        <?php echo $custom_content['body'] ?>

                    <?php foreach($custom_content['panels'] as $panel): ?>

<?php echo $panel['title']?>

                                    <?php foreach($panel['steps'] as $step): ?>

<?php echo $step ?>

                                    <?php endforeach; ?>

                    <?php endforeach; ?>

<?php echo $custom_content['form_title'] ?>

<?php echo $custom_content['form_body'] ?>

                    <?php print drupal_render($entityform) ?>

<?php endif; ?>

And if you wonder what is $custom_content, this is the code that generates it.

function get_invest_page_data($node) {
    $invest = [];
    $invest['title'] = $node['title'];
    $invest['body'] = $node['body'][0]['value'];
    $invest['form_title'] = $node['field_form_title'][0]['value'];
    $invest['form_body'] = $node['field_form_body'][0]['value'];
    $invest['panels'] = [];

    if ( ! empty($node['field_step_panel'])) {
        $i = 0;
        foreach ($node['field_step_panel'] as $panel_key) {
            $panel = load_collection($panel_key['value']);
            $panels[$i] = [];
            $invest['panels'][$i]['title'] = $panel->field_invest_panel_title['und'][0]['value'];

            $steps_keys = $panel->field_invest_panel_step;

            $j = 0;
            foreach ($steps_keys['und'] as $step_key) {
                $step = load_collection($step_key['value']);
                $invest['panels'][$i]['steps'][$j] = $step->field_invest_panel_step_body['und'][0]['value'];
                $j++;
            }

            $i++;
        }
    }

    return $invest;
}

This code exists in template.php.
The following line is used in theme_prepreprocess_node().

$node['custom_content'] = get_invest_page_data($node);


texts:
I've set up a module on one site and want to export it to another site. From researching, I understand you can use Features to do this. However there is no documentation detailing this.

Any suggestions about how to do this?


texts: Solr Indexing Error showing "EntityMalformedException: Missing bundle property on entity of type taxonomy_term"

texts:
In Drupal 7.14, when i Index my Whole Site, Solr is showing following error:

AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows.
Path: /batch?id=1938&op=do StatusText: Service unavailable (with message)
ResponseText: EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7539 of /project/path/includes/common.inc).

So when i look into the lines in /includes/common.inc (around lines: 7537):

// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
  throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}

What is that chunk of code (in common.inc) is doing actually please?
How can i overcome that error?


texts: Send mail to email addresses from webform when a content is saved

texts:
I want exactly like this Send notification e-mail after new content was added but the answer is not seems to be question specific. I have a webform where I get email id of the anonymous users and I want to send email to those ids when I save a new content.

I have combined Rules and webform rules for it. I created an

event
-After saving new content

Condition
-Content is of type

Actions
-Fetch webform submissions of node ID n

Loop
-fetched submissions

loop action
-Send mail.

But i am stuck to move forward as I am not able to configure 'TO' field with email fields from fetched submissions.


texts:
I installed CKEditor plugin ver. 1.16. In configuration page for editor appearance I selected "Full":

But when I open "Add content" page I see the different picture:

When I changed the appearance from "Full" to "Advanced", the appearance doesn't change. But when I switched to "Basic" appearance, it worked.

What's the issue here? Why not all the buttons are displayed?


texts: Has the Block Cache Settings from Drupal 8 been back-ported to Drupal 7?

texts:
I noticed in Drupal 8 there are options to cache a block:

I was wondering if these options exist in Drupal 7 with a module? Has the feature been back ported? or was it a contrib module to begin with?


texts: override view Use administration toolbar

texts:
i have a view that using administration toolbar. Problemis theme suggestion is not showing the template names that should override the template. i guess because its using the administration toolbar .. What i am trying to acheive is showing the whole comment body, when the edit link is clicked
 , instead of going to an other page. How can i force drupal to show suggestion view templates. And is there a better idea.


texts: There is a content type called song and it has a file fields. I'm going to add a player on website using jplayer. the problem is, it preloads all of the songs. I mean all of the songs in the page are loaded with the page while I want it to be loaded when the user clicks on the play button. any idea or alternative for jplayer?


texts:
I have few articles that were deleted by accident.

Can I add these again using their nids?


texts:
I've found a nice plugin to bind hotkey combinations like Ctrl+A for submit buttons, but I don't understand how I can apply this to my form submit button.

Can anyone put me on the right direction?


texts:
I was under the impression that modules were only supposed to be enabled/uninstalled in Drupal 8, yet I have a custom module which is disabling itself randomly.  Of course, it's a problem we cannot consistently reproduce, and it is frustratingly difficult to debug, because it doesn't happen on dev servers.

Is there somewhere which documents what can cause a module to become disabled?  I thought this was supposed to be impossible, so I would think it would be only a few things.

The module reports Disabled when running drush pm-list.  It is definitely reporting itself as disabled.

Is there a better way to debug, research why this is happening?


texts: Contextual view -> entity reference target ID

texts:
I have the following situation:

I have 2 content types (session and preformance)

Performance has an entity reference to session

I want to create a view that shows me all performances for the session that is referenced by the performance i am looking at right now.

So this is a contextual view that filters on the nid of the performance, and has a relation to the session that is referenced by the viewed performance.

I cannot get the target_id of the session (from field_session on content type performance) to be passed in as a contextual filter.

I tried to use %node:field_session, but that gives me the label of the session, and not the target_id.

I also tried to change the display of the performance content type->field_session to 'entity id', but no luck.

All suggestions are very welcome.


texts: Newsletter digest based on user selection of taxonomies terms

texts:
I've looked through forums and modules for a few days trying to find this and nothing seemed to quite fit what I'm looking for.  I want to see if this can be done with existing modules before I venture to create my own or hire it out.

A specific content type has a few fields, one of those fields being a taxonomy vocabulary where an author can tag the content with a few terms.

A user can 'subscribe' to those terms on their user profile.

Once a week (or a designated time period), a digest of new content with the terms that a user has subscribed to is sent out via e-mail to the user.  If there is no new content, nothing is sent out for the specific user.

One way I thought of doing it is generate a view based on a users taxonomy subscriptions.  Some how run through each user and e-mail that view.  But, not sure how to even go about starting that.

Thoughts?  Suggestions?


texts: Filter search results per user custom field

texts:
I would like my site to filter search results based on a Node-reference field of the currently-logged-in-user. I want to limit the search results to nodes that have the same Node-reference field. I am just starting, but stuck on which search hook to use.

Questions:
-which search hook should I use?
-How to access node-reference fields of logged in user AND each node from within this hook?


texts: Views: Content grouped by 2nd level taxonomy term

texts:
I want to create a view that accepts parent taxonomy term as contextual filter. And it will show the content grouped by its child taxonomy terms.

For example if the taxonomy has

Top Term1.0
-- Term1.1
-- Term1.2
Top Term2.0
--Term2.1
--Term2.2

If the contextual filter is Top Term1 then content should be grouped by children terms Term1.1 and Term1.2
If the contextual filter is Top Term2 then content should be grouped by children terms Term2.1 and Term2.2

How can I achieve it by using views?


texts: How to put multiple fields in an index operation on a GET HTTP request with services?

texts:
I'm working with the module "services" everything's ok with a get request, note that i've create my own custom resource with CRUD operations, the "retrieve","update" are ok but the problem is with the index operation. With only one field it works and show all records with the default field I declared on resource. Now how to put an array of $fields ?

This is the resource declaration (the "fields" part of the code) :

array(
        'name' => 'fields',
        'optional' => TRUE,
        'type' => 'string',
        'description' => 'The fields to get.',
        'default value' => 'field_title_value',
        'source' => array('param' => 'fields'),
      ),

now here is the function index (callback) :

function _my_module_livre_index($page, $fields, $parameters, $page_size){

$query = db_select('field_data_field_title','t');

services_resource_build_index_query($query, $page, $fields, $parameters, $page_size, 'Livre');
$result = services_resource_execute_index_query($query);

$bien = services_resource_build_index_list($result, 'livre', 'field_title_value');
return array('code'=>'0', 'response'=>$bien);
}

The doc of services said that $fields is an array of fields i want to return, when i make :
$fields = array('field 1','field 2','field 3');
It return an error. If I make a "classic" :

$query = db_select('my table')
->fields('my table', array('field 1','field 2','field 3')

Same error.

Any help please ?

Thank you all.


texts:
I'm working on a Drupal community site and I want to ask about these things:

How do I make a Drupal site more secure?
How do I make my site work as fast as possible when there is a lot of visitors and users on the site, and there is a lot of interaction with the database at the same time? How do I maintain the database consistent in this situation?
How do I configure Drupal to work during high server load? How do I configure my server's hardware to work during high load moments?


texts: How to use EntityFieldQuery::fieldCondition for entity reference field?

texts:
Suppose, we have an entity "song", that has an entity reference field, called "authors":

I added a filter for this field as a group of checkboxes:

After the user submits the form with checkboxes group, it must be used inside WHERE condition for the list of songs. So, I added the following code:

//query to get the list of entities
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'song');

if(!is_null($form_state['input']['field_authors'][LANGUAGE_NONE]))
{
    $query->fieldCondition('field_authors', /* what to put here? */,
            $form_state['input']['field_authors'][LANGUAGE_NONE], 'in');
}

I don't understand, what value to put into column parameter. I tried target_id, but it doesn't work. Here is the description of field_data_field_authors table:

DESCRIBE field_data_field_authors;
+-------------------------+------------------+------+-----+---------+-------+
| Field                   | Type             | Null | Key | Default | Extra |
+-------------------------+------------------+------+-----+---------+-------+
| entity_type             | varchar(128)     | NO   | PRI |         |       |
| bundle                  | varchar(128)     | NO   | MUL |         |       |
| deleted                 | tinyint(4)       | NO   | PRI | 0       |       |
| entity_id               | int(10) unsigned | NO   | PRI | NULL    |       |
| revision_id             | int(10) unsigned | YES  | MUL | NULL    |       |
| language                | varchar(32)      | NO   | PRI |         |       |
| delta                   | int(10) unsigned | NO   | PRI | NULL    |       |
| field_authors_target_id | int(10) unsigned | NO   | MUL | NULL    |       |
+-------------------------+------------------+------+-----+---------+-------+


texts:
In PHP Opcache there is an option opcache.use_cwd. Disabling it improves performance, but in documentation mentioned that this may break existing applications:

  If enabled, OPcache appends the current working directory to the
  script key, thereby eliminating possible collisions between files with
  the same base name. Disabling this directive improves performance, but
  may break existing applications.

I would like know will Drupal break by disabling opcache.use_cwd? I know Drupal has a lot of files with same base name.


texts: How to redirect /user to /user/UID, for logged in users?

texts:
I run a social movement community site, which features links to the '/user' page, which either shows people the login/registration page, or shows them their user account if they're logged in. If people are logged in, how can I make these links to /user redirect to /user/UID ? (E.g. if I'm the one logged in, I'd like to redirect my visits to http://effectivealtruismhub.com/user to http://effectivealtruismhub.com/user/1 - currently it shows me my user page, but just shows http://effectivealtruismhub.com/user in the address bar.)

This is a valuable feature because people benefit from seeing the URL of their user page, as on this community site and others they'll want to share it with people.


texts: Exposed Filter of Child Terms on Parent Page

texts:
I'm looking for a dummy's guide on how to configure the default taxonomy term views so that I can display an exposed filter of child terms on the parent page.

Assuming I have the taxonomy structure below.

Sports

Football
Basketball
Boxing

Entertainment
Politics

I want when I'm on Sports page, there is an exposed filter where I can select either of football, basketball or boxing.

I have followed all tips I could find online but the option to add contextual filter of "Taxonomy Term: Parent term" was not available.


texts: Do a render foreach loop on a regular field?

texts:
I have a regular field with multiple values,
If i do

render( $fields['field1'] )

It prints

Field1_value1
Field1_value2
Field1_value3
etc

Am trying to get it to output like this

[Field1_value1]
[Field1_value2]
[Field1_value3]
etc

To add [ and ] to the output.
I thought of using a foreach loop, but the field array is like such

'#title' => 'xxxx',
'#type' => 'xxxx',
...
'0' => <array>,
'1' => <array>,
'2' => <array>,

How can I get it to loop throught the [0], [1], [2] etc only?

Note: I have no control on how many multiple values the field may have, so I have to loop.

Another solution that worked well for me: Display comma-separated list of taxonomy terms?

You can make use of the power of field.tpl.php.


texts: Is there a module that can "lazy load" content, not just images?

texts: Utilizing the JAIL module I can lazy load images. Is there any module that lets me do this for content as well (i.e. only load portions of the page that are in the current viewport)?


texts: Generate installed modules into a composer.json for existing site: I need to manage via Composer, not via UI

texts:
I have a Drupal 8 site up and running with modules that were manually installed. I want to generate an appropriate composer.json file to manage these using Composer.

The closest I could find to achieve this is an old Drupal 7 module, Composer Generate, mentioned in how to install package via composer? but that only works with Drupal 7 and it isn't any longer developed.

How to move Composer created folder of drupal-8.x.x up one level to html? suggests that third-party modules can/should be handled with Composer, but I would like to not have to manually rewrite the composer.json file to achieve this.

Is there a Drupal 8 / Composer / Drush way to accomplish this, or is manually updating the composer.json the only option?


texts: How do I place the registration form in the front page?

texts:
I am using Drupal 7.

I clicked on Structure > Block > Add Block; I filled in the block title and block description. In the block body, I put in this code.

<?php
  $_GET['q'] = 'user/register';
  print drupal_get_form('user_register');
?>

I set the text format to PHP (PHP wasn't in the drop down options of text formatting so I added PHP to it), and I clicked on save block.

The block is now created but it's just empty. I can't see any sign up form.

Can someone please put me through? I'm new to Drupal.

I just discovered that I had to activate PHP Filter in core modules (administration > modules). So when I activated PHP Filter module, the registration block I created now shows the word "Array", and also some error in the log.

  Notice: Undefined index: user_register in drupal_retrieve_form() (line 764 of C:\xampp\apps\drupal\htdocs\includes\form.inc).
  Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user_register' not found or invalid function name in drupal_retrieve_form() (line 799 of C:\xampp\apps\drupal\htdocs\includes\form.inc).

  Notice: Array to string conversion in eval() (line 3 of C:\xampp\apps\drupal\htdocs\modules\php\php.module(80) : eval()'d code).

However, the "create new account and login" menu is now showing; it is only not showing in the block I created for it. What is showing in the block is "Array"; when I click on either "register" or "log in," it takes me away from the front page (to the register page).


texts: How to discard unsaved changes to a variant?

texts:
While working on a variant for /node/%node I did something that now causes a 'The requested page "/admin/structure/pages/edit/node_view" could not be found.' error and am unable to access any of the variants.

How do I discard all the changes since the last save?


texts: I want to build a "Blog Archive" block with a custom module. How do I do it?


texts: How to resolve "Referenced error: Highcharts not defined" when using Easychart?

texts:
I installed the Easychart module 7.x-3.7 in my Drupal 7.51 site. Using Highcharts 4.2.7 in libraries 7.x-2.3. I extracted highcharts and easychart-master contents into all/libraries/highcharts and all/libraries/easychart folders respectively. Easychart_ex and Chart contenttypes are shown when adding content.

However in my browser console I am getting this error:

  Referenced error: Highcharts not defined.

I tried all the suggestions mentioned in the Notes at the end of the answer to "How to plot a chart from CSV uploaded in a content type?", but none of them helped.

Is there any Easychart latest module I am missing or is it the way it is supposed to work (only with Highcharts 4.2.7) is a question left to Drupal!


texts: Why does this route work with a slash and not a dash?

texts:
I have defined a custom dynamic route that works, but isn't ideal:

/**
* Defines dynamic routes.
*/
class GuideUnitRoutes {

  /**
   * {@inheritdoc}
   */
  public function routes() {
    $route_collection = new RouteCollection();

    $route = new Route(
      "/guide_name/{guide_id}/{child}",
      [
        '_controller' => '\Drupal\guides\Controller\GuidesUnitController::view',
        '_title' => 'Hello',
      ],
      [
        'guide_id' => '\\w+',
        'child' => '\\w+',
        '_permission' => 'access content',
      ]
    );

    $route_collection->add("guide.child", $route);

    $route_collection->setMethods(['GET']);

    return $route_collection;
  }

}

If I define it to be ideal, it stops working:

/**
* Defines dynamic routes.
*/
class GuideUnitRoutes {

  /**
   * {@inheritdoc}
   */
  public function routes() {
    $route_collection = new RouteCollection();

    $route = new Route(
      "/guide_name-{guide_id}/{child}",
      [
        '_controller' => '\Drupal\guides\Controller\GuidesUnitController::view',
        '_title' => 'Hello',
      ],
      [
        'guide_id' => '\\w+',
        'child' => '\\w+',
        '_permission' => 'access content',
      ]
    );

    $route_collection->add("guide.child", $route);

    $route_collection->setMethods(['GET']);

    return $route_collection;
  }

}

The route that works is guide_name/foo/bar while guide_name-foo/bar doesn't work. I would like to know why.

Reading the Symfony docs it looks like this should be a problem. But for some reason Drupal isn't liking this. Is there an undocumented (or maybe a document that I missed) that forces tokens to be delimitated with /. right now if I change the - to a / and reload the same route it works.


texts:
I've created a module to create a new pre-built option list for a webform select list - the kind you can select here:

My code looks like this:

/**
* Implementation of hook_webform_select_options_info().
* See webform/webform_hooks.php for further information on this hook in the Webform API.
*/
function populate_webform_dropdowns_webform_select_options_info() {
  $items = array();
  $items['get_states_provinces'] = array(
    'title' => t('States/Provinces'),
    'options callback' => 'populate_webform_dropdowns_options_get_states'
  );

   $items['get_countries'] = array(
    'title' => t('Countries'),
    'options callback' => 'populate_webform_dropdowns_options_get_countries'
  );

  return $items;
}

/**
* Build an options list for use by webforms.
*/
function populate_webform_dropdowns_options_get_states_provinces() {
  $options = array();
  $query = db_query("SELECT nick, name FROM ismi.list_states ORDER BY name");

  while ($row = db_fetch_array($query)) {
    $options[] = $row['nick'] . "|" . $row['name'];
  }

  return $options;
}

function populate_webform_dropdowns_options_get_countries() {
  $options = array();
  $query = db_query("SELECT country_id, name FROM ismi.country ORDER BY name");

  while ($row = db_fetch_array($query)) {
    $options[] = $row['country_id'] . "|" . $row['name'];
  }

  return $options;
}

The two choices (states/provinces and countries) do show up in the dropdown list of prebuilt options, but when I choose one, it does not fill the options in to the Options field (it does fill in if I use one of the Drupal-provided prebuilt lists) and when I try to save, it tells me the Options field is required. I'm guessing that there's a SQL error (I'm trying to pull these options from a different database), but I don't know how to debug something like this. I've tried using Firebug for Drupal, but because the query isn't being run (I don't think) when the page initially opens, it's not displaying the query in the SQL tab. How can I go about debugging this? I'm perfectly fine with writing to my server's error log, but that requires me to write variables to the log - I want to see any errors that occur.


texts:
I recently found that unlike Drupal 7, D8 has a different form id for addition and edit of nodes. Is there a specific reason for that? Because this makes the hook_form_FORM_ID_alter() less granular as we now have to alter like mymodule_form_node_form_alter() and put the specific node type in there.

Sorry, could not find a discussion on this. Must be something very basic that I missed.

Thanks


texts: How to use the Message module to log site and user activity?

texts:
I am just unable to use the Message module or the Activity module to record the following activities and show them in a view.

User A just got 10 points.
User B just became User A's friend.
User C just joined the site.
User D just logged in.
User E just viewed "Any Blog".
User F just commented on "Any Blog".

The Activity module does not provide hooks for some of this in the CMS UI itself and I am having real difficulties to configure the Message module for these cases.

There is not enough documentation for this, especially the Message module. There is one tutorial at Log Site Activity with Message and Rules but that is for only one of my cases. I haven't been able to figure out the other use cases. I don't get exactly the same options (entity and tokens) as described in the tutorial.

Any help with my use cases?


texts: all my edit button cannot work and got "Invalid form POST data" AJAX error

texts:
I don't know why all my edit button doesn't work since yesterday. In the log report, I got an AJAX HTTP error with 200 HTTP Code and "Invalid form POST data." message. And when I clicked any "edit" button, I received an Ajax error without any response Text:

Here are some buttons I found which don't work any more:

From Feed Import Setting (edit button doesn't work):

From Content type Adding (add existing product button doesn't work):

Does anyone have any idea why I got this???


texts:
So i've run into an issue with a block somehow losing its region placement somewhat randomly.
For background the block is very simple

        $blocks['tx_leftcol_block'] = array(
      'info' => t('Tx leftcol block'),
    );

The content isn't the issue, as even with some static content this block disappears.

On the blocks overview page this is placed on a custom region called tx sidebar (its a sidebar for certain pages). The weird part is other blocks show fine in this sidebar and dont lose placement, but for some reason this block gets disabled randomly, i.e. every couple of login/logouts it hides, or after a certain amount of time.

Any ideas what could be the cause?


texts: How to change non-color-related CSS after the color module has been used?

texts:
I haven't used the color module in years, since I try to avoid it because I know it kind of freezes your CSS changes.

I have a client who has been using color module with a customized version of the Scholarly theme, but does not seem to have the color picker enabled for it.

I'm trying to make some CSS changes for them that have nothing to do with changing colors, but my changes are not reflected on the site. It's pulling in an old version of styles.css. I've cleared the CSS cache and made sure aggregation is turned off on development so I'm pretty sure the color module is the culprit.

How do I clear or regenerate Color module's version of my site CSS?


texts: Is there any easy way to create a keyboard hotkey to flush all caches in a Drupal site?, instead of going to Admin menu Drupal icon and click that time and again? Thx.


texts: I want to add an include_path but don't have access to php.ini

texts: I was thinking I could use the php function set_include_path() to accomplish this, but I'm not sure which file I should include this in. template.php perhaps?


texts: Build a grid with time slots in multiple rooms

texts:
I need to build a grid for one day (Feb. 27) that allows users to reserve time-slots. There are 12 1/2 slots with a limit of 8 bookings for each slot (in 8 different rooms). The users are authenticated...this is not open to the public.

I'm guessing this is possible with Calendar module and Jquery without having to install another module. Any ideas?

Drupal 7


texts: What is the proper way to add third party script snippets to head tag?

texts:
I understand I can hard-code this snippet into html.html.twig but i would prefer a cleaner method. My research is only instructing me how to attach libraries etc, but I can't find any example of injecting code into the header area needed by some third-party services.

I tried the following code, but it doesn't seem to work.

/**
 * Implements hook_page_attachments().
 */
function THEME_page_attachments(&$page) {
  /**
   * Initial JS.
   */
  $javascript_header = "-----js code -----";

  $page['#attached']['html_head'][] = [
    // The data.
    [
      // Add a <script> tag.
      '#tag' => 'script',
      // Add JavaScript to the <script> tag.
      '#value' => \Drupal\Core\Render\Markup::create($javascript_header),
      // Give weight so it appears after meta tags, etc.
      '#weight' => -1,
    ],

    'key'
  ];
}


texts: Add html5 input types using drupal form api

texts:
I want to add HTML5 number type textfield in the form programmatically. I am building the form using hook_form().
I tried adding the code:-

$form['field_price']['#attributes']['type'] = 'number';

But it isnt working.

Is there any other work around for the same?


texts:
I'm having trouble with applying a patch for a Drupal module.
I thought it was as simple as using "git apply thepatch.patch," but when I do this in the main directory that holds the .git directory, I get the following error message:

  Checking patch entity_translation.admin.inc…
  error: entity_translation.admin.inc: No such file or directory

When I do this in the directory where the files are located, nothing happens; no error is shown, but no file is changed.

It's not a problem I have with this particular patch, but I never seem to be able to apply a patch, and I just end up manually editing the files.

I would like to know the solution once and for all.


texts: How to execute custom code at Drupal startup

texts:
What's the correct way to execute code from an existing custom module at Drupal startup? The code checks certain private_tempstore values and sets other values based on what it finds. It should be executed before page processing occurs so that pages can respond to the changed values.

I've read many posts, looked through the list of hooks, tried a few without success, looked at event subscribing, etc. All my searching and trying hasn't found an approach that works correctly for my situation.

Example custom code (not the real code):

$rsc = \Drupal::service('user.private_tempstore')->get('rsc');
$val = $rsc->get('temp_val');

if ($val == 100) {
  $rsc->set('temp_val', 200);
}

What I've tried:

hook_page_build() // in mymodule.module
hook_page_alter() // in mymodule.module
path: '/*' // in mymodule.routing.yml

No error messages, just no results via an error_log() in the custom code to show that it was executed.


texts: How to print views exposed filter among the fields?

texts:
I have a view, having an exposed filter and a few fields. I am using the twig template of the view to show the result for the design purposes. I need the expose filter among the fields.
Eg.
Name: Khan
Expose filter
City: Bolton
in the views-view-fields--names.html.twig There is no variable or token available for the filter while it is available in views-view--names.html.twig. How to print the filter  in views-view-fields--names.html.twig


texts: Is there a module for saving current block setup?

texts: Would be handy to be able to save the current block setup, so after one changes around blocks, it could be reset to a previous state.


texts: Help getting the values from user profile fields from currently logged in user

texts:
As the title says, I am trying to get the values from a custom field I added to the user profile. I am using this code from a previously asked question regarding this.

$user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$value = user->custom_field->value;

This seemed to work for the person that previously asked this question but the problem I am running into is that it is only returning values of an anonymous user regardless of who I am logged in as. For example if I replace custom_field with uid it will return a value of '0'. Any idea where I could be going wrong?


texts:
I'd like to generate a view of Employee names, but I'd like to embed it inside a form as well as add checkboxes next to each Employee name. I tried to use Rewrite the output of this field but my <input/> tag is getting stripped out when being displayed.

How would you recommend I do this?


texts: 7 allow cross-origin framing CORS module

texts:
I am embedding content in my article that are from the same domain. when I am opening my url with HTTP the embedded HTTPS content won't open and when I am opening my url with HTTPS the embedded HTTP content won't open. Same thing happen when i try to open content with localhost. I am getting this error in Firefox and Chrome:

Load denied by X-Frame-Options: http://mywebsite.com/embed/clips/sandy does not permit cross-origin framing.

OR

 Refused to display 'https://mywebsite.com/embed/clips/sandy' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

I installed the CORS module but it does not seems to help. In Domains (/admin/config/services/cors) I added:

*|<mirror>,https://mywebsite.com
*|<mirror>,https://mediamatters.org

without success. Any insight is apreciated.


texts: How to build a simple blog where content could be published securely to user groups?

texts:
I am developing a PHP application and want to host a blog to communicate with my alpha, beta, and (hopefully) other users.  I have some experience with Drupal, so am planning to put it to use.

I installed Acquia Commons.  It was impressive, perhaps too impressive for my needs.  I started out by trying to remove some of the features, and I found that there's not much documentation freely available for it.  (I don't want a paid service - this startup has not made any money).

I am thinking that Drupal Core with Organic Groups added might be sufficient, but I'm not sure since I have not used Organic Groups before.  And of course, there could be other distributions or modules that I don't know about too.

So, the question is, if your Drupal skills were pretty basic, how would you go about building a simple blog where content could be published securely to user groups?

EDIT: Maybe my usage of the word 'groups' is confusing the issue.  Perhaps I could do this simply by creating different roles, such as Alpha User, Beta User, and assigning users to those roles.  In that case, how would I go about restricting access to content based on role?


texts: Show Link to Subscribe/Unsubscribe to Nodes in a View

texts:
I'm creating a view that shows all the nodes of a specific type. I'm looking to also show which of those nodes the current user is subscribed to and provide a link to subscribe or unsubscribe. Is there any way to achieve this using arguments, custom PHP field, etc?

I created an argument that filters the nodes the current user is subscribed to, but it hides all the nodes their not subscribed to, even if "Display All Values" is selected.

I'm using the Notifications module and Views 2.16 on D6.


texts: How to only allow a node to be viewed in its assigned language?

texts:
I have three languages on my site:

/en
/es

If I have a node with ID = 1234 and this node in english, then I can view it as follows:

/en/node/1234

And this will redirect to

/en/my-page

Which is great! The problem is, if I view this ENGLISH page from another language. I.e. If I open this:

/es/node/1234

Then it opens the english page but the link remains at /es/node/1234

I enabled the "Translation Redirect" module, but this doesn't do exactly what I was hoping it would do. In the above case, if you open:

/en/node/1234

And there IS a "ES" version of the page, it will redirect to that page. Which is great, except sometimes I have a page that does not have a translation, and in the case I want that link to redirect to the correct page. In other words, opening this:

/es/node/1234

Must take you to:

/en/node/1234

Which will then automatically take you to:

/en/my-page

Is there a way to enable this in i18n or must I write something custom to do this?


texts: How to get comment cid in hook_comment_insert?

texts:
I've read the answers to How to get the node id the comment is attached to in hook_comment_insert? and found how to extract the nid of the node the comment is associated with.
However, I also need to get the cid of the comment itself from inside hook_comment_insert(). How do I do that?


texts: drupal_render radios missing name attribute

texts:
When rendering form type radios using drupal_get_form, each one of the radio's options can be exclusively selected, as the html name attribute is set to the parent's ('radios') id.

However I'm working on an ajax form module that integrates with mailchimp, and renders these form elements individually in isolation using drupal_render so they can be placed in a template.

My code to render radios is as follows:

$form_child = array (
  '#title' => 'Some Radios',
  '#weight' => '6',
  '#required' => false,
  '#default_value' => '',
  '#type' => 'radios',
  '#options' => array (
    'Option 1' => 'Option 1',
    'Option 2' => 'Option 2',
    'Option 3' => 'Option 3',
  ),
); // This is generated in my module

$form_child = form_process_radios($form_child);

$myhtml = drupal_render($form_child);

And here is what happens on my form:
HTML output

In the browser


texts: Rewrite View Header into first views-row

texts:
I need to rewrite/move the header of one View into the first row of that View.

Current View output:

view header text

output

output

output

output

output

output

Desired Output:

view header text

output

output

output

output

output

output

How can this be accomplished?

The views-row divs are then displayed inline in a responsive flex grid, so that each views-row div has the same height as its neighbor divs on that same row. Each views-row div is 25% width, so they are displayed in 4 columns (4 divs across the page, with subsequent divs wrapping in 4 additional columns below as needed).

I need the header to be part of that flex grid. I tried applying the flex grid markup to the "view-header" div and the "view-content" div, but it does not provide the desired result.

Thanks!


texts:
i have a mark as checkbox field with two options - published and unpublished.
i want articles marked as 'published' to appear on a view page and those marked as 'unpublished' to appear after the published items as an attachment to the view. the unpublished articles will only be visible to the author. How can i go about achieving this? I have tried using the filter but to no avail. i chose the field name and selected 'is one of' then selected publish, but this did not work. Any suggestions?


texts:
Is there a way to lock a field instance?

I want to prevent users from editing or deleting a given instance, but allow the field to be customizable elsewhere by the user.  If I lock the field, it will do the former, but prevent the latter.

According to this Field API documentation, fields can be locked by setting locked = TRUE in the field definition, but there is no corresponding locked key for the instance definition.

I experimented by adding locked = TRUE to my field instance definition, and while that removed the edit and delete links from the bundle types view, I can still edit and delete by visiting the appropriate url.


texts: hook_form_alter - values are not getting saved to db

texts:
In entity, created a form display field using baseFieldDefinitions

$field['blood_type'] = BaseFieldDefinition::create('list_string')
                       ->setLabel('Select the blood type:')
                       ->setSettings(['allowed_values' => array(1 => 'A+ve', 2 => 'o+ve')]);

Now in some other custom module, I alter its state using hook_form_alter

$form['blood_type_fieldset']['report_fieldset'] = array(
          '#type' => 'fieldset',
          '#title' => t('<b>blood report</b>'),
          '#states' => array(
            'visible' => array(
             ':input[name="blood_type"]' => array(
                array('value' => 2),
              ),
            ),
          ),
          '#collapsible' => TRUE,
          '#collapsed' => FALSE,
          '#weight' => 5,
        );
        $form['blood_type_fieldset']['report_fieldset']['report'] = array(
          '#type' => 'radios',
          '#options' => array('report1' => 'Report 1', 'report2' => 'Report 2'),
          '#default_value' => 1,
          '#weight' => 0,
        );

Now as shown, there are 2 radio buttons named A+ve and O+ve. When I select O+ve, my hook_form_alter gets called up and using #form_states, I get fieldset as shown in code.

Now happens what is, When I initially submit my form, only db field coming from original form gets populated. Means, radio button value O+ve get saved to db, and the report radios which I have selected doesn't get saved to db.

And when second time, I click on edit form, and re-entered values report 1 (say), then it gets saved to db.

Is the reason behind it is hook_form_alter()? Why #form_states is not allowed to be saved on first hit of submit button?


texts: How to provide user-defined revisionable css styles?

texts:
I want to provide option for admin to attach CSS styles on specific urls(just like block visibility can be set).

This style is stored in config entity and is revisionable. Since config entities do not support revisions I am storing them in the entity itself under 'revisions' key which is an array keyed by uuid holding 'content' and 'timestamp' values.

User then only creates/edits the entity via UI and types the styles into textarea.

The issue I am facing is how to dynamically attach those stylesheets depending on the paths condition.

I wanted to do it via hook_css_alter but only 'file' and 'external' types are supported so 'inline' is not an option. Then I was thinking about hook_page_top but I think using libraries would be a better idea although I am not sure how to implement this in a proper Drupal8-way.

So far I have created a custom module that provides config entities with the css rules and also on each save it saves the current value as revision within itself under specific array. I am using hook_css_alter to load and attach the active styles. Since the styles don't have only status but also list of paths they are active on(just like blocks with wildcards) I don't think it is possible to attach them as libraries. Also they are just CSS so it should not influence caching in any way(imo).


texts:
In Drupal 8, I have an 'event' content type with a date range that specifies when the event starts and when it ends. In my view, I need to set up a filter with the following behavior: i choose a specific day from a calendar (btw how to create a calendar and make it work like a view filter in D8?!?), and the view only lists events that start <= the specific day AND end >= the specific day.

Thanks in advance.


texts: How to securely authenticate content embeded in another site?

texts:
I need to embed password protected content to a second domain with an iframe. The content itself is a view which will be displayed on a third party site via an iframe and the content is prepared with a custom page and template handing the display. The use case is to present the view on the other site without the users needing to login. From my research, Oauth or Services seem like good candidates, but I don't have much experience with both and using a service to show a single view seems like it might be an over complication. Anyway, I haven't found much in the way of good documentation on the subject so I'm hoping for a good introductory overview of how to implement this. So, what is the best way to securely authenticate the drupal content on another site. I don't want to expose user credentials in the src=url in the frame for security purposes, so I know I need to use another authorisation mechanism. I've looked at the Entity Iframe module, which seems to have some of these features but the module mainly works drupal-to-drupal, and I haven't been able to tangle apart how the module handles the consumer/provider communication.

So, from researching this, I believe that I have to configure oauth and pass the token to the URL in the iframe. What I am unclear about is how to configure oauth access to the page and how to generate the token to be supplied to the iframe.


texts: Any way to link to specific content type without custom field? Exposed contextual filter?

texts:
I want a field that links to a content type, but only one type, and I want the user to choose which type.  I thought an EntityReference view would solve my problem, because that can even take arguments to pass to its contextual filters, but you have to set the argument ahead of time, and I want it to be exposed to the user.

Currently I'm using a reference field to Content, but I want to at least limit the results of the ajax autocomplete to only the content type they've chosen to reference.


texts:
I currently have a form that it is fully loaded from my Mailchimp Account. I configured it for display as a page using mailchimp configuration page (admin/config/services/mailchimp/signup). Then when I was trying to access it with no admin permissions I got Not authorized to access this page message.

Giving Access all Mailchimp Signup Pages permission to anonymous users fix this problem but it specify that have security implications and I think it is a wrong solution.

I searched all the drupal interface and was not able to find it on either side (Content, contact forms, etc...). This element it's only present on signup forms list (admin/config/services/mailchimp/signup) and there isn't any permissions configuration.


texts: Route logged in user to profile on all request to  node

texts:
I'm attempting to make a simple login page on the front page that once you log in it will route you to your profile. This part I got working with Rules, but if the user clicks the home link on the site at any point, when logged in, I want to route the user to the profile, not the front page.

I tried a similar trigger to the one I got routing a user when they log in. This being on page view trigger when role is not anonymous and URL alias is /node route to user/[account:uid]

When logged in I click the home button and it's not getting triggered. It just sends me to the homepage.

How can I do this with Rules?


texts:
Is there any way that I can use a custom PHP code to control the visibility (proper Drupal access) of a node?

Something similar to content access module, but instead of access control by role, I'd like to have access by PHP code so if it returns true, users can access that node, if not, the node will be access denied?


texts: How to place a view under a local task tab?

texts:
For my Drupal 8 project for user view /user/* I have created one custom tab in the local tasks "Manage school":

 $data['tabs'][0]['user.manage_school'] = array(
     '#theme' => 'menu_local_task',
      #link' => array(
       'title' => t('Manage school'),
       'url' => ???,
      ),
     '#weight' => 8,
     '#access' => $uid == \Drupal::currentUser()->id(),
  );

And actually under this tab I would like to insert and display a view (view.related_school_accounts.page_1). How can I do it in the way that the view is shown under the local tasks tab, so that the user can select other tab in case. If I put:

'url' => Url::fromRoute('view.related_school_accounts.page_1')

Then drupal just redirects to the view page, however, the other behaviour is expected. Any help please?


texts: How can I use Rules to send an e-mail to the author of a node linked by an entity reference field?

texts:
I have a content type called Help Wanted.  I have another content type called Reply to Help Wanted.  The reply content type includes an entity reference field that contains a node reference to the original help wanted ad being replied to.

I am trying to use Rules to send an e-mail when a reply is posted to the author of the original Help Wanted post.

However, I don't know what to put in the To field of the Send mail action.  I tried the following:

[node:field_my_entityreference:author:mail]

But this token didn't work.  I also tried several other variations to no effect.  Is it possible to use tokens to get the author's e-mail of a node linked by entity reference?  If not, how do I get the author's e-mail via the entity reference?


texts: Using images in custom module (not through css)

texts:
I am making a flex slider module, and it needs to just load some images statically, the only way I was able to get hold of any of the images was when I used a relative path in a background-image: url(relative-path-to-image) in a css file, but I am not interested in loading it through css.

If I try to access it relative from the template, using <img src="relative-path-to-image"> it won't work of course, because the src tag are being loaded on the client. I have looked a bit at the templating system and I can use a {{ directory }}  variable inside of twig, to maybe get the absolute path to the images right. But I just feel like even if I made that work it would still be a disaster implementation.

So my question is, if you need to add a  tag and give it a src path-to-image, what is your go-to solution to get that image accessible?


texts: Commerce: Setting Custom Form Default Values

texts:
I would like to set custom default values for both the Customer Shipping and Billing forms. I built a custom page/pane that occurs at the beginning of the Commerce Checkout process. This page/pane has 5 fields that pull basic user information before depositing the user at the 'express' checkout form (part 2 in the multi-step form -- or better known as the typical Shipping/Billing forms). My objective is to be able to use the data saved in $form_state['order']->data; in order to pass it into the default_values in certain textfields within the Shipping/Billing forms.

Using hook_form_alter does nothing to modify the Shipping/Billing in either $form_state or $form. There doesn't appear to be a declaration of default_value within the forms. Even if I do declare a value/values, it does not show up on the page. Any ideas?


texts: When should I use collect an end date for a field, instead of using 2 separated date fields?

texts:
I need to make a content type with a Start Date and an End Date. I know that I can handle this in two ways:

Have two separate field
Have one field with a option of "collect an end date".

I wonder when I should choose either of these options. I assume that the second option is for representing an Event in a Calendar. But if I don't need this, is the first option then the best?

EDIT:

If you plan use the "collect an end date" option you need read this:

How to use the Time ago view formatter when you have an end date collected in your date field?

Because you can have problems with the Views module and the Time ago view formatter.


texts: error SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry

texts:
I'm currently migrating my website to D8 and I'm having some issues updating my NEW nodes to match with my live D7 site.
I get a few of these for each content type. I think it's from creating "test page" and the node ID is taken.
I get a few of these warnings:
 [error]  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'e0891884-4da7-45c9-a1b5-808c8f821cfa' for key 'node_field__uuid__value': UPDATE {node} SET vid=:db_update_placeholder_0, type=:db_update_placeholder_1, uuid=:db_update_placeholder_2, langcode=:db_update_placeholder_3
WHERE nid = :db_condition_placeholder_0; Array
(
 [:db_update_placeholder_0] => 61287
 [:db_update_placeholder_1] => festival
 [:db_update_placeholder_2] => e0891884-4da7-45c9-a1b5-808c8f821cfa
 [:db_update_placeholder_3] => und
 [:db_condition_placeholder_0] => 3943
)

I tried drush migrate-import upgrade_d7_node_festival --update , but that didn't work. Is there a way to overwrite my test nodes when migrating? Do I have to go and delete all the table nodes in my DB then rerun the migration?
Thank!


texts: Detailed breakdown of what takes Drupal so long?

texts:
I'm trying to figure out why my Drupal 7 take so long to render. I've installed the "performance log" module, but it was underwhelming, to say the least. It tells me a page took 2785 ms to render, with 51 ms in queries.

Now what? That's 2.7 seconds spent in PHP. Can I break it down further?

The site load is essentially zero.


texts: Product display: no scroll of product list

texts: I have an issue with commerce product display setup page - scroll function for product list disappeared (part where one can choose a product assigned to display) so I am not able to choose products on lower positions. Only first 10 products can be chosen. Any ideas how to reestablish a full product list?


texts: Add to Cal: Parsing content to URL in Outlook add to calendar keeps the + signs used to replace spaces

texts:
Parsing content to URL in Outlook add to calendar keeps the + signs used to replace spaces in the Calendar still when Calendar is opened.
Steps to reproduce
From the front-end:

Click Add to Calendar
Pick "Outlook.com"

It takes you to the tab to add the event to your calendar.
You will see the + signs in place of spaces in the title, description, location fields
I have tried using:
$title = str_replace('+', '%20', $title);

But the above solution didn’t work.
Any help or point to the right direction will be great. Thanks!


texts:
Someone already tried to make the fontawesome plugin (http://ckeditor.com/addon/fontawesome) working with the ckeditor module on Drupal 7 ?

I followed the whole installation (modified the ckeditor.config.js, downloaded the needed plugins as well) but the button still doesn't appear even if the plugin is checked on the appearance configuration.

Do I need to write a hook_ckeditor_plugin in my own module ?

Thanks guys!


texts: Drupal Multi-Site Setup (Different Contet - Shared Nodes)

texts:
I have a complex setup here, and I don't know how to do it in Drupal.

Site1 (Master) - MasterDB and SharedDB
Site2 (Sub-Site) - DB2 and SharedDB
Site3 (Sub-Site) - DB3 and SharedDB
SiteN (Sub-Site) - DB3 and SharedDB

SharedDV currently only has users / sessions for single sign-on

Okay, so I want to be able to create a content type of "Reports" that exists in all the sites. And I when I add a new report, I want it to show up on all sub-sites. However, I want the sub-sites to be able to add there own reports that don't effect other sub-sites or master.

Basically, I want a way to have Master to be able to control the default of for the all the sub-sites, but then allow the sub-sites to add to that if they want.

Another example, lets say I create a content type "Billing" or "Payments"... I want to be able to define that for all the sites, but I don't want any site to be able to see each others payments.

Another way to think of it is, Use Shared DB plus subsite DB.

All the sites are going to be VERY close to the same, just different theme mainly. and there own content. I just don't want to have to make a change 100 times because I change the name of a content-type or add a new field to a content type or setup a new report 100 times that is the same...

Thanks!


texts: Show "create new node" form with "my" and "user I followed" content in a single block

texts:
I have a content type. Let us say "articles". When a user wants to create an article, the user will go to /node/add/article and it will show a form like it shows on stack exchange when go to /questions/ask.

What I want?

I want to create a block which will show the "create new node" form + my articles + articles of the user I am following with follow(user) flag. "My" and "user followed" articles should be shown below the form. The form and articles should always be visible in the block. When user saves a new article, it should show in the list below without page refresh.

The user should not be allowed to select text format. The admin should choose which text format to enable on this particular content type.

Note: When user visits node/add/articles directly, user must not see the articles. User should only see the form to create a new node.

I am sure I have explained it quite well. Let me know in case you have any questions.


texts:
Any module to manage lots of blocks?
Since the block page is so huge to load.
Or any other methods to manage lots of custom user defined content expect node.


texts: How to install drush 8 properly on Debian 8?

texts:
Finding hundreds of articles and documents about how to install drush and none of it explains where exactly and how properly I got a bit lost.

I've got a Debian 8 system with a root user, NGinx and a ssh user.
Now I'd like to go with drush 8 to be ready for Drupal 8 soon.
But I don't feel like installing git on my server - is this common practice? I usually think the fewer software the better?

So - any chance of installing drush without having git?

Next thing that all instructions seem to forget:
As which user do I need to install drush and composer? (I did it now as the ssh user with the result that root can't use drush).

And eventually: Which directory would be correct to have drush installed? /usr/bin/ ? With a symlink? Or directly there?
Does the NGinx user (www-data) need to be able to use drush? (I guess yes for drush pm-update?)

Very lost here - hope someone can shed some light.


texts:
I am using services module with Universally Unique IDentifier to exposed some services.

Everything was working fine. But from 3-4 days back i am facing a issue.

Whenever i am using PUT method to update my comment or node.I am getting following error :

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

        <title>405 Method Not Allowed</title>

Method Not Allowed

The requested method PUT is not allowed for the URL /index.php.

        <address>Apache/2.2.16 (Debian) Server at example.com Port 8091</address>

I never changed anything in my code since 3-4 month.

May be some one help me to fix this issue


texts: How to deal with unverified users in Drupal?

texts:
What do you do with unverified emails in Drupal? I see some have been unverified for several months.

Is it possible to resend the email or to auto delete them?


texts: Entity Validator failing Integer for not being integer

texts:
I have a custom entity with an integer field with the following baseFieldDefinition:

    $fields['permission_level'] = BaseFieldDefinition::create('integer')
    ->setLabel(t("Permission Level"))
    ->setDescription(t("Sets amount of permissions owner has"))
     ->addConstraint('Range', ['min' => 0])
    ->setDefaultValue(0)
    ->setDisplayOptions('form', [
      'type' => 'number'
    ]);

because of the ->addConstraint('Range', ['min' => 0]), drupal throws an error anytime I try to create an entity through either the drupal generate:entity:content generated boilerplate form or json:api post requests.

I have used Xdebug to narrow the issue to the constraint validator range.
Something is passing a FieldListItem object instead of an integer to this constraint validator causing it to fail because its not an integer. The weird thing is that inside the FieldListItem object is the integer I input.

Why is drupal passing a FieldListItem object instead of an Integer?


texts: Drupal embed view in email sent by views

texts:
I've configured a rule to send an email after a commerce order is placed containing products of a particular type. That works fine. The body though is a view token ([views:embed:golf_registration_information:default]) pulling in specific order info (couldn't do this through the rule with the info I wanted to include). However in the email, I'm getting "edit view" links in a few places, which obviously I don't want.

Here's what the link looks like: http://website.com/admin/structure/views/view/golf_registration_information/edit/default?destination=checkout/451/paypal_ec

I can't figure out how they are getting in there. Is there a setting I'm missing in Views? It appears as the first thing in the body, and then within the body above the line items table. Obviously I didn't add anything within the Global Custom Text field that's outputting the fields.

Modules I'm using: D7, Commerce, Commerce Rules Extra, Rules, Mimemail, Views, Token Embed Views


texts:
I have added a content type in Drupal 7 which contains only a file field. Every file needs to contain an array like the following:

'rows' => array(
   array(0,0), //(x,y) values
   array(90,90),
   array(59,70),
   array(65,77),
   array(85,66),
 )

I want from the view module to read the content of the file and send the array to the selected graph type; for example, the user select a file and then a pieChart graph.

how can the content of the file be send to the pieChart library? Is that possible from the Views module? What function have to be added to the view plugin in order to send the content of the file to the selected library?


texts:
Is there a way to get the user's IP address in a twig template? All the twig examples I find say to do it like this:

{% set ipAddr = app.request.server.get("REMOTE_ADDR") %}

But this variable always returns NULL. These examples aren't specific to Drupal so I'm guessing part of the Drupal implementation blocks/omits this.


texts:
I am trying to make field_format visible after two select list fields have a specific values selected. I thought be not using 'or' 'xor' that both are required but its not working. this is doing the same thing as using 'or',

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'page_node_form') {
    $form['field_format']['#states'] = array(
      'visible' => array(
          array(':input[name="field_item_type[und]"]' => array('value' =>     'tv_show')),
          array(':input[name="field_extra[und]"]' => array('value' =>     'bike')),
      ),
    );
  }
}


texts: Is there any need to check the block name when my module just define a block?

texts:
I am reading "Drupal 7 Module Development", and I followed the book's steps to create a block in my module.

/**
   * Implements hook_block_info().
   */
  function first_block_hook_info() {
    $block = array();

    $block['list_modules'] = array(
      'info' => t('A listing of all the enable modules'),
      'cache' => DRUPAL_NO_CACHE
    );

    return $block;
  }
  /**
  * Implements hook_block_view()
  */
  function first_block_view($block_name ='') {
    if ($block_name == 'list_modules') {
      $list = module_list();

      $theme_args = array('items' => $list, 'type' => 'ol');
      $content = theme('item_list', $theme_args);

      $block = array(
        'subject' => t('Enable modules'),
        'content' => $content
      );

      return $block;
    }
  }

first_block_view($block_name = '') is using if ($block_name == 'list_modules') to check which block should be rendered, but I think Drupal will only send  list_modules' to my module.

Is there any need to check the block name in hook_block_view()?


texts: How can i filter taxonomy by another taxonomy term with views (term)?

texts:
I explain my question :
i have a main content -> travel,
Then i have taxonomy term -> country.

On my taxonomy term country, i put a taxonomy term : "tagcountry" (with words like "dangerous", "safe",...)

My question is simple, how can i create a block with related taxonomy "tagcountry"?

For instance, i would like to have in my taxonomy page country "Syria" tagged by "dangerous", a block with the first 10 countries that are tagged "dangerous".
It's quiet easy to achieve this with "content", but i fail with "taxonomy".

Thanks in advance for your answers !

Edit : I already tried with all contextual filters : nothing worked. Except when i provide a manual value like this (but it's not dynamic) :

But when i want to use "taxonomy ID from url" with specified vocabulary ("Load default filter from node page, that's good for related taxonomy blocks"). It doesn't work...


texts: Get select field value inside of a module

texts:
I have a taxonomy reference field field_location_type with terms: Term A, Term B.

Inside of my custom module, I'm setting up a presave function that will set a hidden field value depending on the term selected in field_location_type.

I'm trying to log the current value of the field just to confirm i'm getting the right one, but there are no values displaying, like ...

function general_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
    \Drupal::logger('general')->notice('here: ' . $entity->field_location_type->value);
}

How do i get the value of the select field field_location_type?


texts: Searching entity reference field value with Search API

texts:
I am using Seach API, Solr Search modules in my website for searching.
I've created an index, say 'Blogs index',
I've selected blogs content type to index
Fields - title, body, Author are added to index.

Created the View for the search results.

Issue is when I search the name of the author, I'm getting no relevant results. Result should be the list of blogs written by the searched author.

field Author is an entity reference field referencing the content type 'Blog Author' and is a multi-valued field.
Any help is appreciated.


texts: find Menu Settings of node, given URL alias (or node ID)

texts:
In the Drupal 8 screen for editing a node, we have these two sections:

URL Path Settings > URL alias
Menu Settings (Menu link title, Description, Parent item, Weight)

How, given the URL alias of a node, can we get those Menu Settings, particularly the Menu link title?
This may break down into two separate problems:

finding the node ID from the URL alias
finding the Menu Settings from the node ID

and in fact I would be thrilled at a solution to either one, even as a high-level explanation.
I would go into detail about how I've attempted to answer this question already, and the services & classes that appear to be relevant, but I don't want to post a complicated-looking question.  If data is that easy to put into those basic fields in the UI, it should at least be possible for some module code to get it back out.


texts: Modifying default "Taxonomy term" view to add a filter and change path in Drupal 7

texts:
I am trying to do a seemingly simple thing but unable to come up with anything.

I'll be specific here for what I want to achieve. I want to clone the existing Taxonomy term which has a path of /taxonomy/term/%. After cloning this view, I wanna make the following changes to it:-

Change the name to Document of Taxonomy Term
Add a filter to this view of a field called is_document. It's a checkbox which is when clicked shows that this node of my taxonomy term is a document.
Change path to /taxonomy/term/documents/%, which shows that I am opening all nodes of this term which are marked as document.

Now when I open my site, let's say with the URL www.mysite.com/organisation/company/documents, it doesn't pick the view. The URL www.mysite.com/organisation/company works as it picks the default Drupal View.

Any idea what I can do here?

I hope I was able to explain efficiently.

UPDATE

I used TVI, but it changes all the pages of my taxonomy terms. I don't wanna change my current scenario where normal taxonomy term pages are opened through /taxonomy/term/% (native Drupal view). I just wanna open all taxonomy terms with a document filter when /taxonomy/term/documents/% view is selected.

Thanks.


texts: I have a node (in D8) which is placed in the menu "Main navigation". How do I get the menu item (in code)? In Drupal 7 you could use $node->menu but in 8.x, the object is not populated with menu information. So, how do I retrieve it? I also want to support another type of menus in the future, so something which works with more than the menu_link_content module is appreciated.


texts: How do I pass arguments from URL into panel page block?

texts:
I have created a view with a contextual filter set to a taxonomy term. I am attempting to use the view block in a panels (page manager) page and pass the taxonomy term from the URL into the block. I could do this in Drupal 7 but I can't seem to figure it out in D8.

The page URL will be something like /reports/term1. I would like to pass term1 into the block.

For the panel page I have a URL like /reports/! (I also tried % as the place holder). Though I have seen some recommendations to use a context to pass the term, I have not been able to do so.

I am working with Drupal 8.7.1, Panels 8.x-4.4, Page Manager 8.4-4.0.

Any suggestions on how to accomplish this?


texts:
I want to subscribe an user to a Mailchimp list as soon as their account is activated. I've created a module to use hook_user_presave() and am trying to call mailchimp_subscribe_user() after that.

function mymodule_user_presave(&$edit, $account, $category) {
  if ($account->uid // user is not new
      && $account->status === "0" && $edit['status']==1) { // user is being activated
        $list_id = 1;
        $list = mailchimp_get_list($list_id);
        $mergevars = mailchimp_lists_load_user_mergevars($account, $list);

        watchdog('mymodule_log', 'account->uid '.$account->uid);
        watchdog('mymodule_log', 'list->id '.$list_id);

        mailchimp_subscribe_user($list, $account->mail, $mergevars, FALSE);

        watchdog('mymodule_log', 'got this far!');
  }
}

$account-uid has a valid value and so does $list_id. The problem that does show is up is this

Notice: Trying to get property of non-object in mailchimp_subscribe_user()
            (line 103 of .../sites/all/modules/mailchimp/mailchimp.module).
Notice: Trying to get property of non-object in mailchimp_subscribe_user()
            (line 105 of .../sites/all/modules/mailchimp/mailchimp.module).
Notice: Trying to get property of non-object in mailchimp_subscribe_user()
            (line 116 of .../sites/all/modules/mailchimp/mailchimp.module).

The lines-

$double_optin = $list->settings['doublein']; //line 103

$success = $mcapi->listSubscribe($list->mc_list_id, $email, $merge_vars, 'html', $double_optin, TRUE);  //line 105

mailchimp_cache_clear_user($list->mc_list_id, $email); //line 116

And is there any better way to achieve this?