texts:
Using Drupal 7 and Views 3 I am trying to setup a block to show related content based on taxonomy terms.I have read numerous articles and threads on how to do this but none seem to work, this might be due to using a view and custom path rather than displaying the node directly.I have done the following.

Created nodes and added Taxonomy terms to each.
Created a view for each node, the views have a custom path.
Created a block view, added contextual filter on "Has Taxonomy Term ID". I have set default value "Taxonomy term ID from URL" and clicked the LOad Default from node page checkbox.
Added the block to sidebar.

My URL are of the format www/example.com/name , there is only 1 argument, I am struggling to understand how the filter can pick up the term from that URL and would like to know if there is a simple way around this. The problem seems to either lie with my URL or that I'm displaying the  node through a view, I would have thought these were both common scenarios that wouldnt require any coding, any help on how to workaround this would be much appreciated. I am leaning towards using mini panels but having spent some hours with them would rather just use views if possible.
Thanks

EDIT
I think this is very likely view/path related, going to the content page directly displays the block with the related content, its on the View pages with their own paths this is not working. My views are simply Page views with normal filters on the content type and on a taxonomy term (which is different to the term on the contextual filter).


texts: Encoded strings in hook_menu wildcard case menu item to lose access

texts:
I'm trying to create a menu link within the admin area that includes a urlencoded() copy of the current URL as a tail to the link URL, so that the code invoked can redirect back to the current page when it's done its job.

However, as soon as the string returned by my _to_arg() callback contains a URLencoded string (Or specifically any string containing a % character), Drupal drops access rights to that menu, and the link is hidden.

Sample code below:

/**
 * Implements hook_menu().
 */
function admin_bar_menu() {

  $items['admin/bar/%test'] = array(
    'title' => 'Admin Bar Test',
    'page callback' => '_admin_bar_redirector',
    'page arguments' => array(2),
    'access callback' => 'user_access',
    'type' => MENU_NORMAL_ITEM,
    'weight' => 15,
  );

  return $items;
}

function test_to_arg ( $arg, $map, $index ) {

  // 1. Link is shown, but is of the form /admin/bar/admin/appearance,
  // so the desired string (admin/appearance) can't be retrieved
    // return $_GET['q'];

  // 2. Link is hidden
  // return urlencode($_GET['q']);

  // 3. Link is hidden
  // return 'foo%bar';

}

function _admin_bar_redirector($destination) {
    drupal_goto($destination);
}

I'm pretty sure this is being caused by the following code in menu.inc (Line 911 - d7.14):

// Skip links containing untranslated arguments.

if (strpos($item['href'], '%') !== FALSE) {
  $item['access'] = FALSE;
  return FALSE;
}

Can anyone suggest a potential avenue for a fix to the code in menu.inc - or is there a better way to achieve what I'm trying to do?


texts: Change page title from Views preprocess function

texts:
I want to be able to change the main page title based on some value that I get in a views preprocess function.

The View is displayed as a page.

function MYTHEME_preprocess_views_view(&$variables) {

  // Can I set the page title from here?
}

The title I am trying to override is the title printed by the /templates/content/page-title.html.twig below:

{#
/**
 * @file
 * Theme override for page titles.
 *
 * Available variables:
 * - title_attributes: HTML attributes for the page title element.
 * - title_prefix: Additional output populated by modules, intended to be
 *   displayed in front of the main title tag that appears in the template.
 * - title: The page title, for use in the actual content.
 * - title_suffix: Additional output populated by modules, intended to be
 *   displayed after the main title tag that appears in the template.
 */
#}
{{ title_prefix }}
{% if title %}
  <h1{{ title_attributes }}>{{ title }}</h1>
{% endif %}
{{ title_suffix }}


texts: Insert multiple checkbox value from webform into table

texts:
I created:

a webform named Test Number checkboxes
checkboxes named Number with values one, two and
three using Form Builder
a table named checkbox_check

Aim: When the webform is submitted, the values selected are placed in a string and saved into the table. Example: If "one" and "two" are selected from the checkboxes, they will be saved like "one,two" in the table when the webform is submitted.
The table name is checkbox_check with field Number (Vachar 11)
EDITED: I just added these codes within the function webform_webform_submission_insert($node, $submission) from the webform.module file in my drupal project:
$accessnode=$node->nid;
if($accessnode==11)// the **Test Number checkboxes** webform containing the checkboxes
{
    $lastestSub=db_query("SELECT MAX(sid) FROM {webform_submitted_data}")->fetchField(); //retrieving the highest number of sid which is the lastest submission
    $selectedData=db_query("SELECT data FROM {webform_submitted_data} WHERE nid = :nid AND cid =:cid AND sid= :sid",array(':nid'=>$accessnode, ':cid' => 1, 'sid'=>$lastestSub))->fetchAll();

    $text='';// This will be used to concatenate the different values into a string and placed in the table afterwards
    foreach($selectedData as $valD)
    {
            $text=$text.$valD.",";
    }
        db_insert('checkbox_check')
        ->fields(array(

        'Number' => $text,
        ))
        ->execute();

}

When I submitted the webform, I got this error message:

Can you guys help me with this?


texts: Pass custom variable to an entity reference templete

texts:
i have the following problem in Drupal 8.

In custom content type there is a field, which is a multiple entity reference to the same content type. The field is set to use custom view mode, where only title and body fields are displayed. Kind of sub-pages structure. Also the content type has a boolean field, which determines whether the body field of sub pages (entity reference) should be displayed or not.
So in my theme_preprocess_field() hook i can get the boolean value, but i don't know how to pass it to the entity references, so in my node--mypage--grid-item.html.twig i could check for that flag and determine should be content.body be rendered or not.

Thank for any hints.


texts:
Just before the title field I have added a "Content: Edit link" in several of my views to make it easy to edit nodes. In the Rewrite section for this item I have added this to change the edit symbol:

<img src="/sites/all/themes/mysite/images/application_edit.png" alt="Edit symbol" height="16" width="16">

Now I have discovered that the Edit link redirects to the wrong node. The link looks like this:

www.mysite.com/node/25305/edit?destination=node/24207

How can I make it direct the user to the right node? Should I enable Output this field as a link and add the node ID manually? I am not quite sure how to do that using the replacement patterns.


texts: Why isn't my feature overridden after I change a rule in it?

texts:
I've exported a feature that contains a rule —

// my_feature.info
features[rules_config][] = rules_my_rule

// my_feature.rules_defaults.inc
$items['rules_my_rule'] = entity_import('rules_config', '{ "rules_my_rule" : {
   ...
  }');

When I modify the rule with Rules UI, I'd expect the feature to be marked as overridden, but it's not. I've tried disabling a rule and editing a rule's conditions. Neither change affects the feature's status (Default).

I've tried clearing all caches (drush cc all) and reinstalling the feature (drush dre my_feature).

Am I missing some step needed to make features detect changes to rules?

Edit: If I update the feature (even though it doesn't say "overridden"), the changes to get written to my_feature.rules_defaults.inc. But reverting the feature  (even with drush fr --force) has no effect.


texts:
I have created an entity. I have exposed it to views using hook_views_data().
I can create a view for my data however when I try and add a field for Bulk Operation there is not a field listed for my entity type.

How do I expose my entity to VBO?


texts: Access one Field from another field via field.tpl.php

texts:
In Drupal 7, I have two fields field_cta_button and field_cta_text.

I am using field--field-cta-button.tpl.php to modify the outputs of the field.

I need the field_cta_button to change depending on the values of field_cta_text.

How can I access field_cta_text from field--field-cta-button.tpl.php?

If possible, I would like to do it without installing any extra modules.

Steps I have tired:

1) Node Load

I have used the following code from this page:

 <?php
$node = node_load($nid);
$field = field_get_items('node', $node, 'field_cta_text');
$output = field_view_value('node', $node, 'field_ctac_text', $field[$delta]);
?>

However, it just outputs this error message:
Notice: Undefined variable: nid in include() (line 60 of /[SITE NAME]/sites/all/themes/legendary/[MY THEME]/field--field-call-to-action.tpl.php).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7562 of /[SITE NAME]/includes/common.inc).

2) Entity Field Query
I thought I might be able to use EntityFieldQuery(), but I'm not sure how to get it to load the current node.


texts: moving of a database [drupal-commons 6x25]: Which tables can be emptied safely?

texts:
I am running Drupal Commons 6.x25  (released February 2012); I have installed it yesterday locally on a lamp, on OpenSuse 12.1. Now I want to move it to the web server, but I have noticed that the fresh database—without any special module, beside the ones that are shipped with commons—is extremely large (16 Mbit).

Sometimes, the moving of a database can be too hard since the database is a way too large. Which Drupal tables are safe to manually clear using PhpMyAdmin?

What about all the "cache_" prefixed tables be emptied without causing problems?

Background: well - sometimes i have some troubles in meging the 16 db at once... but i continue to try to move a drupal-commons in a single step without any emptiying. BTW to which extend we can lower the db-size of 16 mb - 10 or 5 mb probably.


texts:
I have a custom content type which has a url alias pattern of [node:type]/[node:title].

How can I validate the node form in order to prevent the url alias from becoming [node:type]/[node:title]-0 in case the same title is used somewhere else.

Basically, I would like to prevent the node from saving, and display an error message if the url alias will end up having a "-0" at the end.


texts: How to create a menu from content type fields found on a node?

texts:
I have a content type with 4 text areas I would like to make into 4 separate "pages" by creating a menu dynamically based on fields.

Is this possible? Reason I'd like to do this is to create a single content type a person creates with the necessary fields and then has a menu created dynamically from these fields if they contain data.

The only other option I can think of is creating multiple content types and then combining them.


texts:
I read everywhere that it is possible with Views 3 to display search results in a custom view by adding a contextual filter "search: term" to the view and pointing the view's path to "search/node/%". There even used to be a module that added this contextual filter to earlier Views versions: https://drupal.org/project/views_handler_argument_search

Also, see #9 here: https://drupal.org/node/266683

However, I don't have any "search" contextual filters or relations in my view. Was this feature removed again?

Edit: I don't want to search the view once I'm in the view (exposed filters would be the answer in this case). I want to use a view to display the search results of the search form that would be present anywhere on my website. Also, I want to use the indexing feature of Search module instead of using exposed filters. Unfortunately, Apache Solr is not an option.


texts:
I have inherited a Drupal site and I'm trying to debug some issues. I am fairly new to Drupal.

I have copied the site to a different server to use as a test environment.
The site seems to be working fine except that when I try to output a pre-existing 'report' as PDF, but I got the the following error

  TCPDF ERROR: Unable to create output file:
  /home2/freelond/public_html/sites/all/pdf/historic_report/agilityweb-2013-09-18-1246.pdf

The location referred to is the original server and not the new one (hence the error)
I cant see where to set the path for the output file.

The site settings have all been changed (as far as I am aware) in Configuration and I can see any setting specific to this module for this (but may not be seeing wood for the trees!)

I have also cleared caches.

Can anyone suggest anything here?


texts: unable to set dateboosting in apachesolr with D6

texts:
I'm using Drupal 6.22 with apache solr module for search functionality, specifically using 6.x-1.6 version of solr. I had a date field for my node added to the solr indexing named as ds_myDate in ISO-8601 format (Y-M-DTH:i:sZ) and used it for sorting the search results which worked fine.

Recently I decided to replace the sort with a search boost functionality so that most relevant search results are boosted based on the ds_myDate field. In my custom module's hook_apachesolr_modify_query adding the following code (based on understanding from http://wiki.apache.org/solr/FunctionQuery#Date_Boosting)

$params['bf'][] = "recip(ms(NOW/HOUR,ds_myDate),3.16e-11,1,1)";

to effect the boosting threw 400 error stating Can't use ms() function on non-numeric legacy date field ds_myDate. Hence I tried using an alternative of adding the same in the queryfield instead of boostfield in the same hook as

$params['qf'][] = "recip(ms(NOW/HOUR,ds_myDate),3.16e-11,1,1)";

which got added but did not show any impact on the search results.

As I have very little or no access to the Solr server or its logs I logged the solr query in the search function and in both cases the field was added to the query. In the former case of using boost field (throwing 400 error) the solr search url would return a path like

...qf=tags_inline^5.0&bf=recip(ms(NOW/HOUR,ds_myDate),3.16e-11,1,1)
&bf=recip(rord(created),4,3403,3403)^200.0&fq=...

and in the latter method of using as queryfield would return

...qf=tags_inline^5.0&bf=recip(ms(NOW/HOUR,ds_myDate),3.16e-11,1,1)
    &bf=recip(rord(created),4,3403,3403)^200.0&fq=...

Would be great to know what I'm doing wrong here or how this implementation in Drupal could be done properly since 7 has a hook like hook_apachesolr_query_alter where the date boosting could be done.


texts: How to render fields from User profile using user reference?

texts:
I have content type Team in which user reference is used.
Now I need to get the user profile fields based on the user reference in the content type.

Example - In team content type i am adding 1 user using user reference field and based on that user reference selection i need to pull out gender of that selected user and load in a gender drop-down.

Is there any module for this or any custom coding required?


texts: How do I automatically generate image styles?

texts:
How do I automatically generate different image styles in Drupal 8, for existing images?

For example, I have about 10K images in field_image field. I would like to generate thumbnails using my thumbnail image style for those images.


texts: How do I include JavaScript on a single page in a way that is amenable to scale

texts:
I've read through a bunch of material about using JS in Drupal 8 theming and module development, but did not come away with an understanding of the most straightforward way to routinely add things likes GSAP animations and interactive D3 charts to individual nodes.

Each piece of custom JS will only ever be needed on one page. Over time the site may grow to include 10s or even 100s of such pages.

From reading the module development documentation, creating a custom module and adding each JS file to the myModule.libraries.yml with logic to load each on only one page based on id would work, but before I start down that path I thought I'd ask if there is some other way to do this.


texts: I am trying to run upgrade status module to find out the errors of incompatible modules. but i am unable to click the scan selected button. i cant select the button in admin side. Is there any other way to check the modules


texts: Can I use taxonomy term id from URL as Contextual Filter to get entities of custom entity type (not node)?

texts:
As in question.

I have a View with Profile2 entity. Entity has taxonomy term reference field. I'd to filter entities by term. I tried, but no luck

Can I do it with Contextual Filter or I must use exposed filter form (Filter Criteria)?

Path is council/%

The display is a page.


texts: How do I pass a specific argument from a rules event to a condition?

texts:
I am setting up a default rule for my custom Drupal 7 module, as follows:

$rule->event('commerce_cart_product_add')
->condition(
  'mymodule_condition_1',
  array('something' => 'something_else'))
->action(
  'drupal_message',
  array(
    'message' => t('Example message'),
  ),
));

I have written a function, mymodule_condition_1, which returns TRUE or FALSE based on what product is being added to the cart. I need to be able to get the product from the rules event, and pass this to the condition. I have looked through all the documentation and example code but I can't seem to see a way to do this.

In the above example, 'something' and 'something_else' need to be specific values, but I can't see what I can refer to in order to find out what they should be.


texts: Facet pages bring site down because of bots

texts:
We have a search page that uses facets and recently our website has been going up and down.  When looking at the logs I noticed that bots (Bing, Ahrefs, etc..) are hitting these facetted pages a lot.  Since the facetted pages are not cached I think it is causing this issue.

I did add Search-specific caching but that did not help.

I have seen these related issues with caching and facets:

facets will disappear, when you enable caching for a views page
Facet blocks not displayed with cached Search API View
Facet blocks disappear when Views caching is enabled

Has anyone else ran into an issue like this?  For now I blocked all bots from accessing the facetted urls (so they will still be able to see the main search page).


texts: How do I add a variable to $node from a module?

texts:
I would like to perform a lookup on $node->uid from a module, fetch a field from the user profile and then attach that field to $node for use in template files.

I can do this within a theme preprocess method, but my understanding is that adding data (and performing queries) the "Drupal Way" means doing it in a module.

I guess I'm asking what hook I want to target. (Please note that this module did not implement the content type I want to alter.)


texts: Is it feasible to migrate by only migrating content?

texts:
I am preparing to do a Drupal 7 to Drupal 8 migration. This is not a pure like for like migration. Whilst many of the content types are similar there will be some differences between the Drupal 7 and Drupal 8 content types and paragraphs (i.e. site architecture improvements).
I would have thought that the easiest way to do the migration would be to completely rebuild the site in Drupal 8 and configure and customise it the way I want and then just migrate the content (e.g. users, taxonomy, nodes, etc.); however, according to the Drupal documentation one should not configure the site. From the Drupal "Preparing a site for upgrade to Drupal 8" page

Do not configure the Drupal 8 site
Keep in mind that the upgrade process will overwrite configuration on the Drupal 8 site, so do not do any configuration of the Drupal 8 site until after the upgrade process is complete. This means you do not have to create all the content types and fields manually before running this upgrade. The Migrate module will create them as a part of the migration process. In fact, it is a common best practice to install Drupal 8 using the Minimal install profile, because the Standard profile introduces its own configuration that you might not want to use.

Couldn't I just build and configure the Drupal 8 site just the way I like it and then just migrate the content being sure to customise the migration in order to adjust for any architectural changes? This idea of migrating all content and configuration and then making content changes afterwards doesn't make sense to me.


texts: Search api autocomplete with commerce kickstart

texts:
i am using search api with commerce kickstart i have created a view and used it as an exposed form on the homepage, I have used the search api autocomplete module but its not working because the server is not supported. So I have made a custom module to do the autocomplete feature for my search filter block. This is the code

<?php

function ajaxforms_menu() {
$items['ajaxforms/autocomplete'] = array(
'page callback' => 'ajaxforms_products',
'access arguments' => array('access ajax autocomplete'),
'type' => MENU_CALLBACK
);
return $items;
}

function ajaxforms_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'views_exposed_form-display_products-page') {
$form['#submit'][] = 'ajaxforms_submit_funtion';
}
}
function ajaxforms_submit_function(&$form, &$form_state) {
$search_str = $form_state['values']['views-exposed-form-display-products-page'];
$form_state['rebuild'] = TRUE;
drupal_goto('path_to_your_search_view', array('query' => array('search_api_view_fulltext' => $search_str)));
}

function ajaxforms_products($string) {
$matches = array();

// DB table which holds products
$query = db_select('commerce_product', 'p');

// Select rows that match the string
$return = $query
->fields('p', array('title'))
->condition('p.title', '%' . db_like($string) . '%', 'LIKE')
->range(0, 10)
->execute();

// add matches to $matches
foreach ($return as $row) {
$matches[$row->title] = check_plain($row->title);
}

drupal_json_output($matches);
}

But its not working I dont know where I am wrong on this. Anyone have any idea on how to solve this ? I want the autocomplete in the block of the exposed filter search which I am using as a block


texts:
I have a custom block type with two different fields.
What I am trying to accomplish is, to hide the first field if the second is not empty.

That seems like something that could be done in template_preprocess, but where would I put it and what would be my template?

thanks!


texts: How to change field value from a Views block?

texts:
I have a content type named "Tasks" and it has a boolean field simple on/off checkbox. It controls tasks for done or not done.

I have a views block to list all task assigned to me.
I want to control this checkbox field from this block like this:

When I click the checkbox beside Task 1 it's value should change. How can I do that?


texts:
According to db_insert manual page this function is deprecated and it is better to use Drupal 8 database connection to perform insert.

  Deprecated

  as of Drupal 8.0.x, will be removed in Drupal 9.0.0. Instead, get a
  database connection injected into your service from the container and
  call insert() on it. For example, $injected_database->insert($table,
  $options);

Now how can I get a database connection and call insert() method?


texts: Error "not valid choice" when dropdown populated using ajax

texts:
I've searched the other similar answer but still no luck.
I have content type Station with field Province and City.
Form alter:
function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id === 'node_station_form') {
//    kint($form);
    $form['field_province']['widget']['#ajax'] = [
      'event' => 'change',
      'callback' => 'mymodule_callback_example',
      'wrapper' => 'edit-field-city-wrapper',
      'method' => 'replace',
    ];

    $form['field_city']['#attributes']['id'] = 'edit-field-city-wrapper';

    $options = ['_none' => '- None -'];

    $user_input = $form_state->getUserInput();
    $province = $user_input["field_province"] ?? NULL;

    if ($province) {
      if ($province === 'province_a') {
        $cities = [
          'province-a-city-1' => 'Province A City 1',
          'province-a-city-2' => 'Province A City 2',
          'province-a-city-3' => 'Province A City 3',
        ];
      }
      else {
        $cities = [
          'province-b-city-1' => 'Province B City 1',
          'province-b-city-2' => 'Province B City 2',
          'province-b-city-3' => 'Province B City 3',
        ];
      }
      $options += $cities;
    }

    $form['field_city']['widget']['#options'] = $options;
  }
}

function mymodule_callback_example($form, FormStateInterface $form_state) {
  return $form['field_city'];
}

The dropdown City successfully populate based on Province, but when I click submit form, there are error "The value you selected is not a valid choice"

What did I miss?
Update
Solved by following this link. It add allowed_values_function to the field storage.
Added to field storage
allowed_values_function: 'mymodule_allowed_values_function'

and
default_value_callback: 'mymodule_default_value_callback'

to field field.field.node.station.field_city.yml.
The callback function:
function mymodule_allowed_values_function(FieldStorageConfig $definition, ContentEntityInterface $entity = NULL, $cacheable) {
  $empty = ['_none' => t('- None -')];
  $cities = [];
  if (!$entity->get('field_province')->isEmpty()) {
    $province = $entity->get('field_province')->value;
    if ($province === 'province_a') {
      $cities = [
        'province-a-city-1' => 'Province A City 1',
        'province-a-city-2' => 'Province A City 2',
        'province-a-city-3' => 'Province A City 3',
      ];
    }
    else {
      $cities = [
        'province-b-city-1' => 'Province B City 1',
        'province-b-city-2' => 'Province B City 2',
        'province-b-city-3' => 'Province B City 3',
      ];
    }
  }
  return $empty + $cities;
}

function mymodule_default_value_callback(ContentEntityInterface $entity, FieldDefinitionInterface $definition) {
  return [
    ['value' => '_none'],
  ];
}


texts:
$query = \Drupal::entityQuery('node');

$group = $query->orConditionGroup()
 ->condition('field_ref1_user.entity:user.uid', $user->id())
 ->condition('field_ref2_user.entity:user.uid', $user->id());

$ids = $query
 ->condition('status', 1)
 ->condition('type', 'mynodetype')
 ->condition($group)
 ->execute();

The first condition in $group met 3 nodes and the second condition met 1 additional node (different from 3 nodes of condition 1) so since it is OR condition I expect to get 4 node IDs but I receive only 3 node IDs that met the first $group condition.

If I switch the conditions within the $group, I get 1 node ID, that met the first condition. It's seems that the second condition in the group is ignored.

What is wrong with my code?
Is there a way to see the query that actually executed?

Edit
I have activated WebProfiler to see the actual query.

WHERE (node_field_data.status = '1') AND (node_field_data.type = 'mynodetype') AND ((users_field_data.uid = '11') or (users_field_data.uid = '11'))

These are 2 different user reference fields but for both of them the query checks users_field_data.uid = '11'


texts:
I have been trying to create dynamic routes by using RouteSubscriberBase class.

I know we can create dynamic routes by using slug parameter in the URL. Similar to this method ( https://befused.com/drupal/dynamic-route ).

But I want is dynamic Routes not URLs.Similar to this method ( https://www.previousnext.com.au/blog/dynamic-routes-drupal-8-routesubscriber )

Here is the code I have written so far but I cant get whats missing in the code.

When I try to access http://example.com/custom-module/dynamic-routes/ it is available but when I try to access http://example.com/custom-module/dynamic-routes/tents I am getting Page not found Error.

I have Cleared cache before accessing the new URL.

DynamicRoutesAlter.php

<?php

namespace Drupal\custom_module\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

/**
 * DynamicRoutesAlter Class.
 */
class DynamicRoutesAlter extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  public function alterRoutes(RouteCollection $collection) {

   $products = ['cooking_gear' => 'Cooking Gear', 'tents' => 'Tents' , 'sleeping_bags' => 'Sleeping Bags','rope' => 'Rope', 'safety' => 'Safety','packs' => 'Packs'];

    foreach ($products as $key => $value) {

      $url = preg_replace('/_/', '-', $key);

      $route = new Route(
        // The url path to match.
        '/custom-module/dynamic-routes/' . $url,
        // The defaults (see the custom_module.dynamic_routes for structure)
        [
          '_title' => $value,
          '_controller' => '\Drupal\custom_module\Controller\DynamicRoutesController::productType',
          'type' => $key, //Not sure what type does ? Is it required? I have seen it as the syntax in the book Mastering Drupal 8 By Chaz Chumley, William Hurley
        ],
        // The requirements.
        [
          '_permission' => 'create ' . $value,
        ]
      );

      // Add our route to the collection with a unique key.
      $collection->add('custom_module.dynamic_routes'. $key, $route);

    }
  }

}

custom_module.services.yml

services:
  custom_module.dynamic_routes:
    class: Drupal\custom_module\Routing\DynamicRoutesAlter
    tags:
      - { name: event_subscriber }

custom_module.routing.yml

custom_module.dynamic_routes:
  path: '/custom-module/dynamic-routes'
  defaults:
    _title: 'Dynamic Routes'
    _controller: '\Drupal\custom_module\Controller\DynamicRoutesController::productType'
  requirements:
    _permission: 'access content'

DynamicRoutesController.php

  /**
   * {@inheritdoc}
   */
  public function productType() {

    $build['results'] = [
      '#markup' => $this->t('Controller to get Products List.'),
    ];

    return $build;
  }


texts: Count how many times a node is referenced

texts:
I have a content type: classroom
I have another content type: lesson
Lesson nodes have an entity reference field (field_classroom) that reference classrooms.
I want to create a view that outputs a table like this:

Classroom
Number of lessons

Leicester Square
5

Piccadilly Circus
8

London Bridge
0

So, there are five lesson nodes that reference the "Leicester Square" classroom (all the classrooms are named after places in London), 8 that reference the classroom named Piccadilly Circus, and 0 lesson nodes referencing London Bridge.
Is there a way to achieve this in views?
I'm playing around with relationships and aggregation but I can't get it to work.


texts:
I inserted this with a new created Text format

test

E-mail

but drupal outputs this when i save the content

Test

E-mail

I want that the div mail is inside the anchor thumbnail but drupal strips out the anchor automaticly out of the anchour thumbnail.

Can anybody tell me how i can fix that?


texts: Code running in one theme but not the other

texts: I am using the Mobile Theme module to switch between my themes, in my primary theme's page-front template I have some PHP code including a select statement, it queries tables created by a contributed module. The code works fine in my primary theme but in the mobile theme, the PHP returns nothing. What could cause this change from one Theme's page-front to another? None of this code relies on template.php, but I copied that over in case.


texts: Migrating Drupal 7 to Drupal 8 - Source Plugin Error

texts:
I am trying to migrate a Drupal 7 site to Drupal 8, however, I keep getting this error;

Resolve all issues below to continue the upgrade.
The d6_library_transaction plugin must define the source_module property.

Not sure where to define this. I have looked in the Library module folder and the Migrate module folder.

Any help is appreciated.


texts: How to render a text with linebreak saved from a textarea form?

texts:
Unfortunately I haven't found anything on the web with this specific problem.

I have a field (text, formatted, long) and a form with a textarea element that should save the entered text to this field.

Now I want to render it in my twig template. I access the value like this in my controller:

'text' => $node->field_text->value

And I render it in twig normally:

<p>{{ text }}</p>

But whenever I entered a new line by pressing enter in the textarea, it doesn't render the new line. The same thing in the CKEditor when I edit the node and look at the content, there's no new line.

I'm sure that there's a linebreak though, because when I dpm() this value, it prints that.

I tried putting the value in a '#markup' => $text render array, but it was the same. How can I render this new line?


texts: Show a summary calculated from webform submitted values on the submission preview page only (not on form) and re-use in e-mail handler

texts:
We need to display a computed summary of submitted information on both the submission preview page and in e-mails that are sent out.
I'd expect this is a common usecase and wanted to check if i'm missing something obvious before cobbling something together (and documenting that and leading others astray!)— like figuring out if computed twig elements can be excluded from the original form, and if the same computed twig elements can be pulled into the email handler easily.
Thanks for any assistance!
(Edited body and title: clarified that this need is for the submission preview page, not the Webform 'confirmation' page)


texts: How to show a notification at a speicific page based on visitor's country?

texts:
I need to notify (only notify) users ordering through my Drupal Commerce based website that we don't serve their country, if they are not from a specific country. How can I achieve this on the checkout page only?

I know smart IP module can help me determine the country per IP, how can I implement the notification at the checkout page, before user proceed with his order.


texts: Can't access global user object after drupal_bootstrap

texts:
I have a stand-alone php script with the following lines at the beginning:

define('DRUPAL_ROOT', '../../../../../');

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

And this is giving me access to all of Drupal's functions just fine, however, when I try to access the global user object, it's as if the user is not logged in (IE the user object says the user is anonymous and has a UID of 0), even though I know they are because when I browse the site normally, the user is logged in.

Why does it not pick up the user's session in my script?


texts: Validation when having 2 webform in same page?

texts:
On Drupal 6, I have 2 different webforms which I have available as 'blocks'. Then I create a 'page panel' and added the 2 blocks. Everything works just fine but I have 2 problems.

One comes when sending any of the forms and the validation shows up. Both 'name' inputs are red marked.
When the form is correctly sent I'm redirected to the succes page but when I hit the 'back' button it takes me to the webform node instead of the 'page panel'.


texts:
Where in the Panels "add content" list can I find the "add to cart" button?

So far I can only add it via node / node content =

but this prints node title + body text + add to cart as opposed to just add to cart - here is the node content panel with a cyan border:

How can I add just the "add to cart" button without the other stuff?

Thanks...


texts: How do I export Entityform submissions to CSV?

texts:
I see that it is possible to bulk download Entityform submissions to a CSV file.

How do I do it? I don't see a "Download as CSV" button anywhere.


texts: How to use the Rules module to attribute a new user role after a product was bought?

texts:
I use these modules: Drupal Commerce, Rules, Node option premium.

My question: with Rules, how attribute a new user role, when the product was bought, and when this product is a premium content ? So that, when a user bought the product, that user can have access to full content.


texts:
I'm attempting to build custom template for specific content type.
So, I created node--my-content-type.tpl.php and tried to write some text: it works!
Ok, now I want to render my fields. I have $content['field_title'], field_author, field_cast (is a field collection) etc.

I need values of these fields, so I tried to assign some variables:
$title = $content['field_title']['value'] etc, but it doesn't seem to work.
I can only call render function to render these fields, but I want to format page in custom mode.

How can I get field info in order to use correct values?
Thanks!


texts:
With the new EU cookie compliance law coming into force Friday (26/05/12), does anyone have any suitable advice for those of us who not only develop in Drupal and other frameworks? I myself have a degree in Business (and use to teach Business at FE level and had numerous limited companies), the ICO website is not helpful for those who developing, but those who have 'netpreneur' aspirations, may have second thoughts now the full weight of the ICO is behind the EU law. Personally, I would be quite happy to see the cookies option removed from all visitors on my future portal developments.

Would anyone care to shed some light on this in how we can ensure end users perceptions of 'privacy' theft are reduced to the lowest possible point. I don't believe the answer is merely to 'seek professional advice' as some Drupal developers simply cannot when starting out, even though I would argue that that should always be the case from a organsizational legal standpoint.

What would be the simplest answer to ensure compliance across Drupal?


texts:
I'm struggling with Drupal, OAuth and a (Cordova) mobile app I'm developing. I've made a custom module and it exposes data to the Services module. What I want to do now is get that data into my mobile app.

I've set up my endpoint, but I need authentication of course.

I've read the tutorials on 3-legged and 2-legged authentication, but from what I've read, I (think I) want the Client-flow. This is the flow where the user enters his/her username and password in the app.

Can anyone get me started on this flow? Is it even possible with Services and OAuth?

Tell me if you need any more info. I'm a developer, but mainly in the .NET space. I've managed with Drupal modules so far, but I find OAuth quite complicated.


texts: {% if page.left_sidebar %} region showing on nodes but not view

texts:
I have a template page--about.html.twig that is being extended by page--recreation.html.twig everything else is the same and when I look in inspector it everything is correct the only this is my left sidebar region is not printing in the extended theme. The theme is being used by a view /recreation

then I have

  {% if page.left_sidebar %}
        {% block left_sidebar %}
          <aside class="col-sm-3 left-aside" role="complementary">
            {{ page.left_sidebar }}
          </aside>
        {% endblock %}
      {% endif %}

maybe it won' display because it is a view /recreation and I am using a page template but that is the template it is suggesting for me it is suggesting the same template name for my content type called 'recreation' and view called 'recreation' it prints on the node but not the view.


texts: Loading taxonomy terms in a tree in Drupal 8

texts:
I have multiple level of vocabulary, I want to display all level in the hierarchy same as taxonomy display. My taxonomy is like.

All
   Drinks
      Alcohol Drinks
         Beer
         Vodka
      Alcohol Free Drinks
         Coca Cola
         Pepsi
   Fruits
      Fruits For Losing Weight
         Watermelon
         Blackberrie
      Fruits For Dogs
         Strawberry
         Orange

now I am trying to load this using code.

$vid = 'food';
    $terms =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1, FALSE);
    foreach ($terms as $term) {
        $term_data_1[$term->tid] = $term->name;
            $terms_2 =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, $term->tid, 1, FALSE);
            foreach ($terms_2 as $term_2) {
                $term_data_2[$term_2->tid] = $term_2->name;
                    $terms_3 =\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, $term_2->tid, 1, FALSE);
                    foreach ($terms_3 as $term_3) {
                        $term_data_3[$term_3->tid] = $term_3->name;
                    }

            }
            $term_data_1[$term_2->tid] = $term_data_2;
            $term_data_1[$term_3->tid] = $term_data_3;
    }

    kint($term_data_1);

and this code giving result like

Need help to get term in hierarchy.


texts:
I  create a views with REST export display, result are serialized with Json,

In my formBuild method  I want to parse JSON and Convert it to array and use it in select option

    $host = \Drupal::request()->getHost();
    $response = \Drupal::httpClient()
        ->get($host.'/get/slider' );

    $json_string = $response->getBody()->getContents();
    kint($json_string);

I see Symfony serialize class and find Deserialize method with this example

 $person = $serializer->deserialize($data, 'Acme\Person', 'xml');

According to this,I guess maybe I should something like

     $results = $serializer->deserialize($json_string, '???', 'josn');

but what I should write in second param(???)?
I try

    $serialize = new Serializer\Serializer();
    $json_string = $response->getBody()->getContents();
  $entity = $serialize->deserialize($json_string, '\Drupal\node\Entity\Node::class', 'json')  ;

but face me with error Symfony\Component\Serializer\Exception\UnexpectedValueException: Deserialization for the format json is not supported in Symfony\Component\Serializer\Serializer->deserialize().

And if you have better solution  tell me
How Can I deserilized views REST results?

update
Also,I tried

    $json_string = $response->getBody()->getContents();
    $serializer = \Drupal::service('serializer');
    $deserialized = $serializer->deserialize($json_string, \Drupal\node\Entity\Node::class, 'json');

but Symfony\Component\Serializer\Exception\UnexpectedValueException: A string must be provided as a bundle value. in Drupal\serialization\Normalizer\EntityNormalizer->denormalize()


texts: Where DHTML Menu link's title is getting printed

texts:
I would like to replace the title attribute of DHTML menu's link with a javascript tool tip. But i could not find the place where the link attributes are printed. ie. where  test  is mentioned.

Kindly help me.


texts:
I was using menu_get_object() to load node information in Drupal 6.

if ($node = menu_get_object()) {
    // Get the nid
    $nid = $node->nid;
  }

Since menu_get_object() is deprecated in Drupal 8, I was using the following code.

if ($node_id = \Drupal::request()->attributes->get('node')) { #menu_get_object()
    //load all the information of the node
    $node = node_load($node_id);
  }
  echo '<pre>';print_r($node);exit();echo '</pre>'; //its okay
  echo $node->type->value; //not working

This is not getting the node values, but printing the node information's in array. How do I resolve this ?

UPDATE

I am getting all other values like $node->title->value and $node->nid->value, but not $node->type->value.


texts: How to get Drush to be able to query the DB?

texts:
I am getting the following error trying to run Drush on Win10, WSL2, and DDev. I can run other Drush commands, but not all of them.
How do I fix it?
Command self-update was not found. Drush was unable to query the database.
As a result, many commands are unavailable.
Re-run your command with --debug to see relevant log messages.

Below is the output when I run the command with the debug flag...
username@DESKTOP-4JKF77A:~/workspace/drupal8Dev$ drush self-update --debug
[preflight] Config paths: /home/username/workspace/drupal8Dev/vendor/drush/drush/drush.yml
[preflight] Alias paths: /home/username/workspace/drupal8Dev/web/drush/sites,/home/username/workspace/drupal8Dev/drush/sites
[preflight] Commandfile search paths: /home/username/workspace/drupal8Dev/vendor/drush/drush/src
[debug] Bootstrap further to find self-update [0.03 sec, 7.94 MB]
[debug] Trying to bootstrap as far as we can [0.03 sec, 7.94 MB]
[debug] Drush bootstrap phase: bootstrapDrupalRoot() [0.03 sec, 7.94 MB]
[debug] Change working directory to /home/username/workspace/drupal8Dev/web [0.03 sec, 7.94 MB]
[debug] Initialized Drupal 8.9.7 root directory at /home/username/workspace/drupal8Dev/web [0.03 sec, 8.14 MB]
[debug] Drush bootstrap phase: bootstrapDrupalSite() [0.03 sec, 8.43 MB]
[debug] Initialized Drupal site default at sites/default [0.04 sec, 8.67 MB]
[debug] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.04 sec, 8.66 MB]
[debug] Add service modifier [0.04 sec, 8.79 MB]
[debug] Unable to connect to database. More information may be available by running `drush status`.
This may occur when Drush is trying to bootstrap a site that has not been installed or does not have a configured database.
In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line.
See `drush topic docs-aliases` for details. [0.04 sec, 8.84 MB]
[debug] Bootstrap phase bootstrapDrupalDatabase() failed to validate; continuing at bootstrapDrupalConfiguration() [0.04 sec, 8.84 MB]
[debug] Done with bootstrap max in Application::bootstrapAndFind(): trying to find self-update again. [0.04 sec, 8.84 MB]

In Application.php line 239:

[Symfony\Component\Console\Exception\CommandNotFoundException]
Command self-update was not found. Drush was unable to query the database. As a result, many commands are
unavailable. Re-run your command with --debug to see relevant log messages.

Exception trace:
at /home/username/workspace/drupal8Dev/vendor/drush/drush/src/Application.php:239
Drush\Application->bootstrapAndFind() at /home/username/workspace/drupal8Dev/vendor/drush/drush/src/Application.php:192
Drush\Application->find() at /home/username/workspace/drupal8Dev/vendor/symfony/console/Application.php:236
Symfony\Component\Console\Application->doRun() at /home/username/workspace/drupal8Dev/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /home/username/workspace/drupal8Dev/vendor/drush/drush/src/Runtime/Runtime.php:118
Drush\Runtime\Runtime->doRun() at /home/username/workspace/drupal8Dev/vendor/drush/drush/src/Runtime/Runtime.php:49
Drush\Runtime\Runtime->run() at /home/username/workspace/drupal8Dev/vendor/drush/drush/drush.php:72
require() at /home/username/workspace/drupal8Dev/vendor/drush/drush/drush:4


texts: What is basic difference between themes and modules in drupal?

texts: Is there any difference between modules and themes if so then what are the basic difference in between them? If there is no difference then what is the concept behind having separate folder for both of them?


texts: Where to a place a custom php file in the directory

texts:
I have a hard coded form that i need to send to a php page that i have built. With drupal i am a bit confused on where i would place this php page so it doesnt cause any problems.

I was thinking here but i wanted to check first.
/httpdocs/newsite/PHP-HERE
(Same directory as index.php)

Where would i place this php page?


texts: In Drupal 8, I am using the Config Pages module to set up a configuration page for a custom module. How can I add all the existing content types into a dropdown list?


texts: Replacing display page with views in template.php

texts:
since yesterday I can not solve the problem with function preprocess_views_view:
In the views named 'Calendar' I have a few display page(page_classic, page_mobile) and I would like to change preprocess_views_view function in mobile version of the site, which replace default display page(page_classic) with page_mobile. Below function, does not work:(

function mobiletheme_preprocess_views_view(&$vars){
    dpm($vars);
    $view = views_get_view('calendar');
    if($view->name=='calendar'){
        $display_id = 'page_mobile';
        $view->current_display = $display_id;
    }
}

Any ideas?


texts: Access list of view modes available for nodes

texts:
In my code, I need to get a list of all the view modes defined for nodes.

In Drupal 7, it was available via entity_get_info(). What is the equivalent method for producing a list of available view modes in Drupal 8?


texts: I need my view to default the exposed filter depending on the ?tid= variable that i put in the url .  It was working before, but now it no longer does.  Is there a setting in the view that makes that tid variable work?


texts:
I'm theming with Boostrap right now in Drupal 8 and created a footer menu with a bunch of links. The menu is displaying collapsed right now, but I want it to be uncollapsed and display like a default navbar.

While bootstrap displays as collapsed


texts: Pulling Values from $order in Commerce Cart

texts:
I am trying to pull the value of a selected item in a field list located in the order entity.  Later this is used to determine what panes should be shown in the checkout workflow.  I should note that the list is located in a checkout pane itself and therefore must be pulled from either $order->data or entity_metadata_wrapper.  I am having problems getting the test code to work on one pane, specifically with getting the selected value from the list.

    global $user;

// $checkout_panes actually holds ALL the panes...
foreach($checkout_panes as $pane_name => &$pane_data) {

    // load current order
    $order = commerce_cart_order_load($user->uid);

    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    $make = $order->field_make['und']['0']['value'];

    if($make == 'value2'){

      // ...we only need to override one of them
      if($pane_name == 'commerce_fieldgroup_pane__534' && $pane_data['enabled']) {

            // the pane is enabled by default, so we need to disable it
            $pane_data['enabled'] = 0;

      }
   }
}


texts: Change language name based on the domain i'm on

texts:
I'm looking for a solution which can alter/change a language name based on the domain I'm on.

Here I can configure one name, which is used everywhere, but can't be configured for each domain:
/admin/config/regional/language

I got a site with multiple domains. Every domain has a set of languages: en, nl and fr etc.

Each domain has different labels for those languages. For example:
domain 1: en: English
domain 2: en: International

Any suggestions?

Altering every form, every view output, just feels wrong.


texts:
I have hard time setting up a DraggableViews (DV) view to re-order content. The DV actually does save the weights - they appear correct in the draggable table, but on the user side (when viewed on the site page) the weights are all zero (not retrieved?).

The site is bi-lingual and the content is tagged with a vocabulary. The purpose of the DV is to set the order within a term. In the header there's an exposed filter to allow the admin set the correct sequence within a term.

To my eyes, the query run to generate visitor's view is correct, but I'm not an expert.

Please refer to the attached mockup image to get an idea what's going on.

I have the latest version of DV + Views 3.5.

Has anyone been through this? Does this have a known workaround? Is this module limitation or is it the view set up incorrectly?

Edit:

User-facing View:

SELECT draggableviews_structure.parent AS draggableviews_structure_parent, node.title AS node_title, node.nid AS nid, node.language AS node_language, draggableviews_structure.weight AS draggableviews_structure_weight
FROM
{node} node
LEFT JOIN {draggableviews_structure} draggableviews_structure ON node.nid = draggableviews_structure.entity_id AND draggableviews_structure.view_name = 'project_reorder' AND draggableviews_structure.view_display = 'page' AND draggableviews_structure.args = '[]'
WHERE (( (node.status = '1') AND (node.type IN  ('project')) AND (node.language IN  ('en')) ))
ORDER BY draggableviews_structure_weight ASC

Sorting UI View

SELECT draggableviews_structure.parent AS draggableviews_structure_parent, node.title AS node_title, node.nid AS nid, node.language AS node_language, draggableviews_structure.weight AS draggableviews_structure_weight
FROM
{node} node
INNER JOIN {field_data_field_genre} field_data_field_genre ON node.nid = field_data_field_genre.entity_id AND (field_data_field_genre.entity_type = 'node' AND field_data_field_genre.deleted = '0')
LEFT JOIN {draggableviews_structure} draggableviews_structure ON node.nid = draggableviews_structure.entity_id AND draggableviews_structure.view_name = 'project_reorder' AND draggableviews_structure.view_display = 'page' AND draggableviews_structure.args = '{\"field_genre_tid_i18n\":\"1\",\"language\":\"en\"}'
WHERE (( (node.status = '1') AND (node.type IN  ('project')) AND (node.language IN  ('en')) AND (field_data_field_genre.field_genre_tid = '1') ))
ORDER BY draggableviews_structure_weight ASC

Note that the sorting view makes use of arguments (derived from exposed filter), while the user-facing one does not. I would think this might case the problem.


texts:
I'm just starting out with Drupal, and I have no idea what I'm doing.

I already have the postal code which I can convert to latitude and longitude using the Google Geocoding API.

My problem is how to create the fields that will store the latitude and longitude and how to insert those values in the database so that I can use them in a search view which uses the Search API Solr search module.

All I need is for someone to point me out to what I need to do, maybe some tutorials or resources that will enlighten me so that I know what I'm doing. Please help, thanks!


texts:
I have defined few tokens that are grouped in few separate groups similar to [node:content-type:name] scheme. For example I'd like to have a token like [master:sub_group_1:tokan_A]. So This is how hook_token_info() looks like:

function MY_MODULE_token_info() {
  $tokens = array();
  $types = array();

  $types['master'] = array(
    'name' => 'Master group',
    'description' => 'This is the master group',
  );

  $types['sub_group_1'] = array(
    'name' => 'Sub group 1',
    'description' => 'This is the first sub group',
    // this tells this group that it's parent is 'master' group.
    'needs-data' => 'master',
  );

  $tokens['sub_group_1']['token_A'] = array(
    'name' => 'Token A',
    'description' => 'This token prints letter A',
  );

  return array(
    'types' => $types,
    'tokens' => $tokens,
  );
}

I'll skip MY_MODULE_tokens() as it's irrelevant here, but token_replace() works perfectly. It replaces [master:sub_group_1:token_A] correctly. But the problem is that token module does not list my custom tokens in available tokens section and when I try to use [master:sub_group_1:token_A] in forms that get validated by token module, I get The %element-title is using the following invalid tokens error message.

What is the correct method to define custom tokens and group them to avoid conflicts with tokens defined by other modules?


texts: How to fetch HTML created via a Forena report and store it as a node?

texts:
I'd like to automatically (Rules) copy some HTML into a node . The HTML comes from a Forena report (already as an HTML document), created by the Forena module. In the Rules module I couldn't find anything exactly fitting.

It might be possible to develop a small module that fetches the Forena report (using some of the available Forena hooks) and create a node from it.

But is this the easiest way to go? It feels a bit like a detour, maybe I'm just overlooking some module or feature which can do that task?


texts: How to manage custom module for development but repository module for production?

texts:
There is a module that I frequently post patches for and use the latest development version. I have created a composer.json that includes:

"repositories": [
  {
    "type": "path",
    "url": "web/modules/custom/*"
  },
... and later ...
"require": {
  "drupal/THEMODULE": "*",
....

The git repository for THEMODULE resides at web/modules/custom/THEMODULE. Locally I manage the repository there, pushing, pulling, and creating patches. Then for production, I push to the production server and a git post-receive hook copies the code to the same directory on the server.

But now I want to stop using git to push to production and instead use composer to specify a particular version/release/commit and use cweagan/composer-patches to specify the patches I want for production.

I have committed both composer.json and composer.lock to git so that I can push the specifications I want for production and then just run 'composer install' (rather than composer update) on the server. This re-creates the environment I'm using in development. I would like to avoid running 'composer update' on the server for fear it will create regression that I haven't tested in dev or staging.

I know that you can use "require-dev" to ADD additional resources, but what I really want is to keep my custom modules repository (for my custom module) but for production to NOT use the custom modules repo, but rather the packages.drupal.org repo. And for local dev, I want the opposite: use the local modules/custom repo and not packages.drupal.org

What are other people doing for modules that you keep in git locally but want deployed from official repos for production?


texts: What are possible alternatives for Admin:Hover, which suffers a major security issue?

texts:
As mentioned on its project page, module Admin:hover adds administrative links to nodes and blocks for users with proper permissions to easily edit content.

But it suffers a major security issue, as detailed in SA-CONTRIB-2012-006.

Does anyone know of any alternatives?


texts:
I hope that you could help me out with this. After much time ive finally managed to work out how to takeover the space that my breadcrumb was taking up. With this bit of space i thought about adding a banner in there or a welcome message. I dont want my site to look 'tatty' so the banner idea was soon forgotten. A welcome message would be nice but it will be going through all my site and im sure that folks will get a bit sick of it.

I was hoping to add a View of random quotes in there. You can see the 'spot' i mean on my frontpage here-
http://onlinebanter.com/

As i type this though i'm a wondering if i could make that spot a block region? Then i could have a welcome message on the frontpage and then use it as a region to add helpfull advice for differant sections of my site. also i could add a random quote view for within nodes etc.

Could anyone offer me advice on either adding a view to a page.tpl or creating a block region in the wee spot ive found?

All help appreciated.

thanks


texts: Taxonomy terms won't arrange themselves by ID but will work alphabetically instead

texts: I added a large number of taxonomy terms in the order I want. Their term IDs reflect they are added in the correct order. However, everywhere they are displayed alphabetically. Particularly, inside a hierarchical select widget they are displayed alphabetically - when I see their IDs (856, 847, 843 - not a correct numeric order but correct alphabetic A, B, C) they check out fine so they were added properly. How can I control this?


texts: Permission to control revisions without giving full content access in D6

texts:
I want users belonging to my 'editor' role to be able to create/revert etc revisions. To do this, as far as I can tell, I have to check the 'administer nodes' option in admin/user/permissions

However this seems to give editors the ability to create any content type (seems to override the specific content type permissions). I want editors to be able to create only certain content type (under node/add).

Is there a way to enable the node revision setting but restrict the content types that can be created?

Drupal 6.


texts: Drupal 7 special chars not working in db_select

texts:
I have implemented custom search to get some values from node.

When I'm using special chars like "/, ?, !", no result is being displayed.

Example value : "24/7" or "site?" or "test!", etc...

$search_text = '24/7';
$query->condition(db_or()
->condition('n.title', '%' . db_like($search_text) . '%', 'LIKE')
->condition('fld.body_value', '%' . db_like($search_text) . '%', 'LIKE'));

I'm running my site in Drupal 7. PHP version is 5.5.9. Using Mysql DB. OS windows.

Note:
Query is correct. Its giving proper result for other than special chars.

Edit:
$query->arguments(); is returning below image.

I was running LIKE command in phpmyadmin. Please find that screen shot below.

So what is the modification do we need to do at PDO to support this issue?


texts:
I am seeking to build a website which contains quite a lot of information. All this information will be structured in a specific way. As such I am looking for a way to represent this data/articles/nodes visually.

The purpose is to be able to add new articles to an already existing visual structure by simply adding a node and classifying it/linking to existing articles that are already structured/adding taxonomy terms etc.

The visual structure will as such have a changing shape/size. A map of the information presented on the site if you will.

A way to navigate the wealth of information visually.

Does something like this already exist or is there a way to create such a module/program for the site - potentially as a separate site that presents the drupal site?

Thanks,


texts: how to load 2 services (or more) through dependency injection

texts:
if i have 1 service, i can load my service through dependency injection like:

class MyForm extends FormBase {

  protected $coreService;

  /**
   * Class constructor.
   */
  public function __construct($coreService) {
    $this->coreService = $coreService;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static( $container->get('arm_core.core_service') );
  }

but now let say i have 2 services, how i load the service through dependency injection rather than globally?

class MyForm extends FormBase {

  protected $coreService
  protected $mainService;

  //then...?

Thank you


texts:
I have a field loading hidden in an attachment view and I need to hook into that attachment to alter the output of the field.

It involves PHP and I'd rather hook into template.php rather than download some PHP module to store PHP code in my database.

I've tried hooking into theme_views_pre_render but I can't find my attachment, I can only modify the $view->attachment_before output.

That, plus I can't actually obtain the field values in this hook?

So how can I hook into a field value in an attachment?


texts: How to print the timestamp of date in a Views fields?

texts:
I am using the Views Data Export module to show feeds as XML.
I need to show the created date and updated date in timestamp .

How can I implement it?


texts: Drupal 7 Rules - Grant access to node - pick username from node field

texts:
I have in D7 Content access and Rules -modules. I have content type which Content access settings are limited to only admin.

In that content type I have User Reference field.

I need to have rule which picks username from that User Reference field and grants content view access to the user, so user can view that node.

So after rule has applied user from node User Reference field has view access to that content - ohter users can't see that node.

I have tryed multiple rules settings but have not got it right yet so help would be appreciated. Thanks!


texts: how to change a theme through themekey on the contact page in drupal 7

texts:
I made a site in drupal 7 and used themekey (i'm using "nid" for all the pages) to have on every page a different backgrounds, this works perfect. But on the contact page i'm not able to find the way to do this, what are the settings in themekey to set a different background in the contact page.

Thx
Fred


texts: Services Views not exposing thumbnail image url

texts:
I am trying to create a view which will be exposed as a service via Services Views module. I have only defined Default display for this view and added the following field to the list of Fields -

Node: Nid Nid
Node: Type Type
Node: Title Title
Profile: Author Info: Full Name Author Name
Node: Post date Post date
Node: Teaser Teaser
Node: Promoted to front page Promoted to front page
Node: Last edited by Last edited by
Node: Updated date Updated date
Content: Thumbnail URL to file

All the fields are appearing nicely when I request it (using this url: http://localhost/app/rest/views/articlelist?args[0]=1), but the last field, which is the url to thumbnail file isn't appearing there.

A sample response from the above url is as follows -

<item>
<nid>22</nid>
<type>Article</type>
<title>UK soldier killed in Afghanistan</title>
<author_name>Demo Journalist</author_name>
<post_date>Jul 1 2012 - 4:08pm</post_date>
<teaser>
<p>&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t&nbsp;ret rre tre tretre trtretre tre t re t</p>
</teaser>
<promoted_to_front_page>Yes</promoted_to_front_page>
<last_edited_by>admin</last_edited_by>
<updated_date>Jan 2 2013 - 3:56pm</updated_date>
</item>

What do I need to do to display the related thumbnail url?

Edit

Here is the query that is being executed (obtained from preview) -

SELECT node.nid AS nid, node.language AS node_language, node.type AS node_type,
       node.title AS node_title,
       profile_values_profile_full_name.value AS profile_values_profile_full_name_value,
       profile_values_profile_full_name.uid AS profile_values_profile_full_name_uid,
       node.created AS node_created, node.promote AS node_promote,
       node.changed AS node_changed,
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_fid AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_fid,
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_list AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_list,
       files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_data AS files_node_data_field_thumbnail_image_node_data_field_thumbnail_image_field_thumbnail_image_data,
       node_data_field_analysis_box.field_analysis_box_value AS node_data_field_analysis_box_field_analysis_box_value,
       node.vid AS node_vid
FROM node node  LEFT JOIN content_type_article node_data_field_thumbnail_image
ON node.vid = node_data_field_thumbnail_image.vid
LEFT JOIN files files_node_data_field_thumbnail_image
ON node_data_field_thumbnail_image.field_thumbnail_image_fid = files_node_data_field_thumbnail_image.fid
INNER JOIN term_node term_node
ON node.vid = term_node.vid
INNER JOIN users users
ON node.uid = users.uid
LEFT JOIN profile_values profile_values_profile_full_name
ON users.uid = profile_values_profile_full_name.uid AND
    profile_values_profile_full_name.fid = '1'
LEFT JOIN content_type_article files_node_data_field_thumbnail_image_node_data_field_thumbnail_image
ON files_node_data_field_thumbnail_image.fid = files_node_data_field_thumbnail_image_node_data_field_thumbnail_image.field_thumbnail_image_fid
LEFT JOIN content_type_article node_data_field_analysis_box
ON node.vid = node_data_field_analysis_box.vid
WHERE (node.status <> 0) AND (term_node.tid IN (1, 2))
ORDER BY node_changed DESC, node_created DESC


texts: Remove uploaded files before the 6 hours cron?

texts:
I have a custom Content Entity in wich definition there is a 'file' field.
The file widget works fine.
The 'Browse' button allows to select a file and uploads it to the proper server directory and the 'file_managed' and 'file_usage' tables are updated accordingly.
If I delete the entity, 'file_usage' record is deleted and in 'file_managed' table, the record has its status field set to '0'.
What I understood is that cron job removes all files in the directory with status = '0' after 6 hours.
My question is: how to have the file removed just after the submission of the delete form?


texts: Getting my paths/breadcrumb right with views

texts:
Is it possible to get SEO friendly URLs when using a view? I have a site I am building that has a homepage which leads to two main views ("Homme" and "Femme"). I need the URL and breadcrumb to read "Home >> Homme >> name-of-the-article." Then, on the article page, I need "Homme" to be a link. Pretty straight forward and what you would expect in a site, right? I did download and install the Pathauto module, but I can't seem to get it working. I have a custom content type called "Men's blog post" and I set the path to be: "homme/[node:title]";  something similar is for "Femme."

This is not working. Do you have any idea?


texts: Why did all my themes disappear when I upgraded to PHP 7?

texts:
Today I had to do some support on a Drupal 6 website and when I tried to refresh a CSS file, all the themes disappeared. When going to the theme page, nothing in the list at all. Not even the core themes.

This is a Drupal 6.x website and I am running it on my current development system which runs PHP 7.x among other things.

Why would my theme disappear like that?

Note: I tried clearly all the cache tables and click on the "Clear all Caches" and the caching is turned off in the Performance screen (so that way I know it's not that creating problems.)


texts:
Content types that are created recently are not showing up. They are displayed in content type list but not in "Add content" list and navigation menu. I tried few solutions like:

I checked in the database node_type table if the fields type and orig_type are same; they are same.
I configured the navigation block to access all content types, though it is not necessary.
I tried to do add the link directly in navigation menu, but the link is not getting added to the menu.
I cleared the cache several times and run the cron tasks too.
Its is not even permissions, I have given them already.
Can anyone help? I am stuck and I cannot start everything from scratch.


texts: Link to small .php script on drupal page gives 404

texts:
I am new to drupal and have a page set up with a bunch of links. When clicked, the links are supposed to open up a php file (player.php, located in the root directory) in a new window. However, all I get is a 404 error. When I try to navigate to the page directly, I also get a 404 error (www.mywebsite.com/player.php).

If anyone has any suggestions on how to fix this, it would be a great help!


texts: Table view: "Hide Empty Column" checkbox doesn't seem to work

texts:
I've created a view, formatted as a table.

I'm trying to hide empty columns – so, in the table settings, I've checked the "Hide Empty Column" checkbox for most of the table columns.

However, this doesn't seem to have any effect – these columns are still included in the rendered table, with empty <td>s.

I expect this checkbox to hide the column entirely when all data cells contain an empty value. Am I understanding this correctly?

This certainly seems to be how it worked in Drupal 7. (I'm converting an existing D7 site to D8 – and this is how the table columns were hidden on the D7 site.)

Is there anything I should check which might be preventing this from working as expected?

Thanks.


texts: How to remove front tag from landing page and logged in home page?

texts:
I have a D7 website on the production environment. On the landing page and logged in page i see the page head title "Front | XXXXXXXXXX". Basically xxxxxx is portal name. I would like to remove the Front keyword from the title and show only XXXXXXXXX.

I tried with several options like
- handling in the template.php with in goodnex_preprocess_page()
- handing via module with hook_init().

Please suggest how to fix it.


texts: URL aliases and Entity Translation (menu name replacement pattern)

texts:
I am using entity translation (Field translation) for my nodes, and set the menu name on each 'page'.
The menu itself is arrange to basically have a duplicate tree in the same menu each with a different language, for example:

main-menu
-item 1 english
--sub item 1 english <node/23>
-item 1 german
--sub item 1 german <node/23>

Now when i want to make URL aliases based on the menu it does not translate.

[node:menu-link:parents:join-path]/[node:menu-link]

Keeps the URL as english. i assume this is because of "node".

What replacement patterns could i use to make the URL aliases compatible with my entity translation?


texts:
Some of my articles are protected - allowed only if user is logged in. In case anonymous is trying to open them page "Access denied. You are not authorized to access this page." is displayed, which is ok - that works well.
Now, I want instead of showing them that page to redirect then to login page. I created event subscriber which looks like:
class RedirectAnonymousSubscriber implements EventSubscriberInterface {

  public function checkAuthStatus(GetResponseEvent $event) {

    global $base_url;

    if (
      \Drupal::currentUser()->isAnonymous() &&
      \Drupal::routeMatch()->getRouteName() == 'system.403') {

      $response = new RedirectResponse($base_url . '/user/login', 301);
      $event->setResponse($response);
      $event->stopPropagation();
      return;
    }
  }

  public static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array('checkAuthStatus');
    return $events;
  }
}

When debugging I saw that this "Access denied" page has "system.403" route name so I'm checking if user is anonymous and also that page is displayed. In that case I'm doing redirection to login page. However I end up in unlimited redirection loop with this code?!
I just don't see what the problem is here?


texts: hook_url_outbound_alter only for links in node body

texts: I'm building a site with drafts/revisions as a major component. For now I'm using hook_url_outbound_alter to check if "/draft" is at the end of the current URL, and if so to append "/draft" to all paths. The problem is that it's also altering the Menu URLs. Is there any way that I can explicitly target links in the node body using hook_url_outbound_alter?


texts: Performance: Efficient use of EntityFieldQuery (with node_load OR node_load_multiple) to update thousands of nodes with/without conditions

texts:
I have script that queries a system called Symplectic for publications of over 30 users (each authored over 300 publications). Most of the publications are authored jointly by more than one user. I have done the following using a combination of Entity API and other methods:

Programmatically creating publication nodes (with fields i.e. integer, text, lists, taxonomy terms, entity reference, etc).

I would like to avoid the following scenario:

Creating duplicate nodes of type publication

Every time I create a publication, I would like to check whether the publication already exist or not (most probably yes because, the users have authored so many publications together). I can achieve this when I am creating all publications at the same time :

I will lookup a structure the stores publication specific properties (i.e. Symplectic object id, doi, publication source id, last-modified-timestamp where source being pubmed, scopus, etc.). If not exist then create publications and update the structure, else reference the user to the already existing publication.

The actual use I am Concerned about is, Updating thousands of publications at a later date after they are created. I have the following options, which one do you think is most efficient:

Use EntityFieldQuery to query for all nodes of type publications (over 2500 nodes) at once, and store the properties useful for comparison in a structure. Use the structure to decide whether publication exist in Drupal, if no then create it, if yes then check for last-modified-date.
Use EntityFieldQuery with condition fields to check if a publication already exist in the Drupal system, if yes then check if update is avaiable, if no then create it. This method would require, N number of quries (2500 publication nodes would result in 2500 calls).
During initial create operation (when no publication node exists), create a structure and store the few publication fields that are expected to be unique (not timestamp) across all publications (i.e. symplectic object id, doi, publication source id, last-modified-timestamp), serialize the structure and store it in the file system. During update phase, load the structure from file system, unserialize it and use it to check whether a publication node already exist in the drupal system, if no then create it and update this structure, if yes then check whether update is required.

My worries in regards to above available options:

Loading over 3000 publication nodes (of course, EntityFieldQuery would retrun all nids, then I will have to use either node_load_multiple or node_load) - Is this efficient? Would I not face memory problems?
2500+ EntityFieldQuery does not seem to be the right choice due to query time. (Attaching conditions might increase the query time i.e. if symplectic id field of publication equals X)
This is my idea, I don't know if it makes sense.

I have Drupal 7 on CentOS 6.5, and a publication content type has the following number of fields:
boolean - 2
text - 20
Double field - 3
Taxonomy - 1
List 2,
title, body, etc.

What do you recommend based on your experience? I did have a look at Biblio module, it is not the way to go forward for our requirements.
I also know that $conditions parameter of node_load_multiple is deprecated in D7.

Sorry for long description, I tried to be as descriptive as possible.


texts: Drupal 7 Form API not returning all values into $form_state

texts:
I have a form with multiple similar fields like so:

<?php

example_form($form, &$form_state) {

   for($i = 0; $i < 10; $i++){
       $form[$i]['name'] = array(
           '#title' => t('Name'),
           '#type'  => 'textfield',
       );
   }

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

   return $form;
}

This outputs ten fields and a submit button. However, inside hook_form_submit and viewing the values from dpm($form_state['values']), there is only one instance of name.

I can easily fix this problem by uniquely naming the field $form[$i]["name-{$i}"] but this solution does not seem pragmatic. What is the work around for not individually naming each field uniquely? Why is the not naming the container qualify as unique?


texts:
I have installed this module and I assume that this works not only in the regular content type but also in the group module. I was expecting that after enabling the module there is an option to map my group type fields in the manage fields section but none even in the edit setting of the group type.

See RDF Mappings in the Basic Page content type:

Notice this from the module:

  Features

  RDF UI Map Content Types to Schema.org Types. Map Fields to Schema.org
  properties.

Does the group module supports schema integration? If yes, is there any documentation provided?


texts: Pass argument when overriding controller in RouteSubscriber

texts:
I am having the issue of overriding the default taxonomy controller /taxonomy/term/{tid}.

I have created my own controller which takes {tid} as a parameter and I want to use it instead, so I overrode the default taxonomy controller in the RouteSubscriber like this:

    <?php

namespace Drupal\my_module\EventSubscriber;

use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\Routing\RouteCollection;

class RouteSubscriber extends RouteSubscriberBase {

  protected function alterRoutes(RouteCollection $collection) {
    foreach ($collection->all() as $route) {
      if ($route = $collection->get('entity.taxonomy_term.canonical')) {
        $route->setDefault('_controller', '\Drupal\my_module\Controller\PagerController::handleDefaultPage');
      }
    }
  }

  public static function getSubscribedEvents() {
    $events = parent::getSubscribedEvents();
    $events[RoutingEvents::ALTER] = array('onAlterRoutes', -250);
    return $events;
  }

}

My sample page controller is this:

<?php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Class PagerController.
 */
class PagerController extends ControllerBase {

  /**
   * Handlepage.
   *
   * @return string
   *   Return Hello string.
   */
  public function handleDefaultPage($tid) {
    return [
      '#type' => 'markup',
      '#markup' => 'term: ' . $tid,
    ];
  }
}

And its routing is this:

my_module.pager_controller_handleDefaultPage:
  path: '/taxonomy/term/{tid}'
  defaults:
    _controller: '\Drupal\my_module\Controller\PagerController::handleDefaultPage'
    _title: 'Taxonomy Pager'
  requirements:
    _permission: 'access content'
    _entity_access: 'taxonomy_term.view'
    taxonomy_term: \d+

But then, when I open the taxonomy page, I get this error which means, that I need to pass the $tid param somehow.

RuntimeException: Controller "Drupal\my_module\Controller\PagerController::handleDefaultPage()" requires that you provide a value for the "$tid" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one. in Symfony\Component\HttpKernel\Controller\ArgumentResolver->getArguments() (line 78 of /var/www/html/vendor/symfony/http-kernel/Controller/ArgumentResolver.php).

How to resolve it?


texts: can we add ahah element into form using ahah?

texts:
I am using ahah for drupal 6.
Now there is scenario in which I need to add ahah field into a form.

There is one form and in that form, there is one ahah field on submit button.

Now when user clicks on that ahah button, I want to add another ahah field with textbox and button. The button which we add through ahah should have ahah for adding more content.

is it possible to add ahah submit button using ahah submit button ?


texts:
I'm trying to deploy a development Drupal instance to a test environment, but something is going wrong with Rules.
I copied the entire site's filesystem, dumped the database with mysqldump, imported the dump file to the test database server, and edited the test instance's settings.php.
I can log into the new test site, but the site fails if I try to rebuild caches. Permanently.
If I go to Admin->Configuration->Workflow-Rules, the page is broken. I see the following warnings and errors:
Notice: unserialize(): Error at offset 6574 of 7668 bytes in unserialize() (line 261 of [site location]/sites/all/modules/entity/includes/entity.controller.inc).

Notice: unserialize(): Error at offset 6574 of 7668 bytes in unserialize() (line 261 of [site location]/sites/all/modules/entity/includes/entity.controller.inc). =>

Warning: Creating default object from empty value in attachLoad() (line 57 of [site location]/sites/all/modules/rules/includes/rules.core.inc).

Warning: Creating default object from empty value in attachLoad() (line 57 of [site location]/sites/all/modules/rules/includes/rules.core.inc). =>

Error: Call to undefined method stdClass::buildContent() in RulesUIController->overviewTableRow() (line 260 of [site location]/sites/all/modules/rules/ui/ui.controller.inc).

I also disabled the rules on the dev site before dumping the database. Same situation.
And now the site is unusable. Am I missing something that needs to be done to deploy a site with rules? Is there some way to repair a broken rules system?


texts: Adding of social media links( Facebook, Google Plus)

texts:
In my site I've already added Facebook Like, Google Plus and Addthis modules.

Facebook like shows up only in the bottom of the article and it won't display if we're in the home page where no node is shown in full view.

Google Plus also won't show for home page in teaser mode

Addthis shows up in the bottom.

So I've gone ahead and copy pasted this code in the "content top" position in Acquia theme from Addthis.com account:

So this will make the buttons display on all url's. I just want to know if I'm doing the right way. When I added this same code to another site using Acquia theme in the same position then this code caused the buttons to show in staircase way. So I removed this code.

My main concern is that this code should not break layout in any browser/version.


texts: Auto Increment on users table is not functioning

texts:
I need to Create a new user programmatically. So, I have used user_save method, as shown here:

$usersave = array(
'name' => 'abc',
'pass' => 'abc',
'mail' => 'abc@gmail.com',
'status' => 1,
'roles' => array(
  DRUPAL_AUTHENTICATED_RID => 'authenticated user',
      5 => 'customer'
),
);

$save = user_save($usersave);

But it throws this error message:

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY': INSERT INTO {users} (name, pass, mail, status) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => abc [:db_insert_placeholder_1] => abc [:db_insert_placeholder_2] => abc@gmail.com [:db_insert_placeholder_3] => 1 ) in drupal_write_record() (line 7383 of /home/vijay/public_html/vssb/public/includes/common.inc).

What's the issue?


texts: Adding line items to cart in Ubercart 3 and Drupal 7

texts:
Is there a simple way to add line items to a user's cart in Ubercart 3 ?

I've been searching for a solution all day. I basically need to add additional service cost for certain items that may appear in a user's cart. I've defined this additional cost as a line item.

I know its possible to add line items to an order, however from what I understand cart contents become an order only after passing through checkout. But if I want this line item to appear on the cart page (where you have a list of items in the cart and the total cost etc) I can't use this method.

Currently I'm resorting to customising the cart table, which is a pain. Then later I plan to add the line item to the order.

There must be a better way to do this. Does anyone know how I can achieve this?

(Also, I've been having problems getting hook_uc_order to work, is there a problem with this in D7?)

If somebody could point me in the right direction that would be really helpful. Thanks in advance.


texts: Building a reusable carousel paragraph item

texts:
I'm using the Paragraphs Module to create Paragraphs Items for easy page/content creation. I'm trying to create a paragraph item which displays a carousel (slideshow).

The idea:
The user wants to display images in a carousel, selects the slider paragraph, uploads his images (or reuse uploaded images with the Media module). Done.

The solution (which doesn't work):
Needed modules: paragraphs, views, views_bootstrap, viewfield

Create a paragraph with two fields: one image field and a viewfield
Creating a block view, which displays the image of the paragraph

The problem is that it shows all uploaded images. If node 1 has 2 images and node 2 has 3 images, both nodes display 5 images. I added a contextual filter to the view (Paragraphs item: Paragraphs item ID) and provided a default filter value: "Content ID from URL". But it still doesn't work – a couple of nodes show up correctly, other ones doesn't.

It seems to me that the contextual filter uses the node id as paragraph id, but node id != paragraph id.
Can somebody reproduce this behaviour and have an idea how to solve this? I think I need a contextual filter for the node, but can't define it.


texts: How do you render a Node's Last Saved date in a Region Footer (ie, inside a Block on every page)?

texts:
I'm new to Drupal (8) and have no PHP experience, but I've managed to get this interesting CMS doing just about everything I need by playing with Twigs.

I cannot for the life of me figure out how to get a Page's "Last Saved" date to render in the footer block though.

In the Node twig I can add this, and it works perfectly:

{{ node.changed.value|date("d/m/Y H:i") }}

But in the region--footer.html.twig (which is an included block at the base of every page on the site, and where I wish to render this information) all I get back, from every combination I try, is the current date/time of when the page loads in the browser. Actually, i think it is the current server time.

Obviously there's something I just don't get about how Drupal works!

Can anyone offer a newbie some help in language I might understand?

Cheers,
mrEdge


texts:
I'm trying to render a weight element but it doesn't works I just have as output an empty string. But when I try to render a checkbox I get the correct output.

For the weight element:

$weight = array(
  '#type' => 'weight',
  '#title' => t('Weight'),
  '#default_value' => 1,
  '#delta' => 10,
);

// For Drupal 7.
dpm(drupal_render($weight));
// For Drupal 8.
kint(\Drupal::service('renderer')->render($weight));

Output: An empty string.

For the checkbox element.

$check = array(
  '#type' => 'checkbox',
  '#title' => t('Dry run'),
  '#description' => t('Test run without deleting revisions but seeing the output results.'),
);
// For Drupal 7.
dpm(drupal_render($check));
// For Drupal 8.
kint(\Drupal::service('renderer')->render($check));

Output:

 <input type="checkbox" value="1" class="form-checkbox" />  Dry run

Test run without deleting revisions but seeing the output results.

So, I think that the drupal_render() function and renderer service are working fine because the checkbox is rendered, but the weight element not, I'm missing something here?


texts: Views Calendar Pager Skips a Month Forward

texts:
In our calendar constructed by Views, the pager (also constructed by Views) skips a month when you hit next. However, the "previous" pager button only goes back one month. So it goes forward two months and back one...

Has anyone else experienced this? I've tried messing with the pager settings, but to no avail. This calendar was added to the site before my time, so I don't really know what to look for, but if you need more info, let me know and I'll try to find it!


texts: Module library dependancies is not working

texts:
I have a module that is loading a custom library. In that library I'm trying to set jquery and drupalSettings as dependancies, but they are not being loaded. Here is my library and code:

in questionnaire.libraries.yml:

google_map:
  version: 1.1
  css:
    theme:
      css/google_map.css: {}
  js:
    js/google_map.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/drupalSettings

in the QuestionnaireController:

$element['#attached']['library'][] = 'questionnaire/google_map';

I get this error when loading the page:

Uncaught TypeError: $ is not a function

I know the library is being loaded, because it is picking up on the javascript and css I have made. I'm assuming the dependencies are not being loaded, since that error means jquery is not being loaded. Any specific reason why I can't load dependancies from the core?


texts: Is running DRUSH on a Windows 7 64 bit machine in a WAMP dev environment worth it? I've heard there are some speed and performance issues with this set up? Will I lose any functionality with this set up?


texts: Reassign $view_mode using entity field passed to hook_entity_view_mode_alter()

texts:
I'm using baseFieldDefinitions to create my custom entity form.
With gracious help here, I've been able to successfully generate a radio button on the form which lets the user select what view mode to use for the display.

Goal:
Get the selected value from the radio button on the form and use it to reset the view mode for the display.

Problem:
Other than my general confusion, I believe I have a cache issue when invoking the hook to alter the view mode.  I'd like to think I was finally able to overcome the array value to single value assignment problems.

I added this code into MY-MODULE.module:

/**  * Implements hook_entity_view_mode_alter().  */
function nfl_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
    // Change the view mode to the value selected via radio button on the form.

    if ($entity->getEntityTypeId() == 'nfl_fact'  ) {  /*<-- restrict to custom entity */

        $change_to_view_mode = $entity->change_view->value;  /*<-- get the lowercase value -- not Initial Cap Label  */

        drupal_set_message(sprintf('
 change_to_view_mode %s
', print_r($change_to_view_mode, TRUE)));
        drupal_set_message(sprintf('
 view_mode before %s
', print_r($view_mode, TRUE)));

        //  $view_mode = $change_to_view_mode;  /*<--- reassign view mode here -didn't work*/
        $entity->view_mode[LANGUAGE_NONE][0]['value'] = $val[0]->change_to_view_mode;  /* <-- reassign */
        $entity->save();

        drupal_set_message(sprintf('
 view_mode after reassignment %s
', print_r($view_mode, TRUE)));
    }
}

I added some drupal_set_message entries to reassure myself that I was getting the variable values changed.

 change_to_view_mode standard

 view_mode before full

 view_mode after reassignment standard

Cache cleared.

When I click on my link from the viewlist builder, I don't get the display.  I get White Screen of Death with the error in the PHP log:

(first few lines)

[29-Sep-2018 02:15:53 UTC] TypeError: Argument 1 passed to Drupal\Core\Form\OptGroup::flattenOptions() must be of the type array, null given,
    called in C:\wamp\www\drupal8\web\core\modules\options\src\Plugin\Field\FieldFormatter\OptionsDefaultFormatter.php on line 40
    in C:\wamp\www\drupal8\web\core\lib\Drupal\Core\Form\OptGroup.php on line 23
#0 C:\wamp\www\drupal8\web\core\modules\options\src\Plugin\Field\FieldFormatter\OptionsDefaultFormatter.php(40): Drupal\Core\Form\OptGroup::flattenOptions(NULL)
#1 C:\wamp\www\drupal8\web\core\lib\Drupal\Core\Field\FormatterBase.php(80): Drupal\options\Plugin\Field\FieldFormatter\OptionsDefaultFormatter->v

I'm confused.
Also am open to guidance on how to better format this question if it looks too goofy ;)


texts:
I had a fully working Drupal site and had some problems with uploading files on a specific page.  So I started looking closely at the code and noticed some oddities (basically a lot of random characters).  I removed the code and everything seemed to be fine.  The code had to do with the images on the page.  Then all of a sudden I started receiving a "page cannot be displayed" error, and was not able to view the site anymore.

I had someone else look at the server and they were able to connect just fine.  To be on the safe side, they rebuilt the page.  I tried again, and still couldn't see the website.

I then tried to attempt the connection through another network I manage via VPN.  Coming at it from the other network, the page loads.  I've tried Firefox, Chrome, Safari, all with the same result.  I tried clearing the cache, reset settings, delete and reinstall.  I've restarted my router.  I'm out of ideas.  This has been super frustrating.  Thanks for any help.

Update:  I talked to the person hosting this and they mentioned they run something called Liquid Web.  I guess it bans your IP if it thinks you're doing something bad.  All I did was modify a page it banned me.


texts:
I have a view with a field Title that needs to be filtered before being sent:

Users fill a tracking number and press Enter
This number is actually related to a node id
If a user enter "123 123" or "#123123" it will not work because of the space and/or the # symbol

My first guess as a non-expert in Drupal (and coming from other CMS and PHP Framework) would be to add a filter to this input with a regex on it to get rid of all characters that are not 1-9. However, I tried to accomplish such a thing in creating a Filter Critera but it does not seem to be the solution.

Do you have any recommendation to do such a thing?

Thanks


texts:
I am developing a moule which has one page asking for email frequency; when the user selects and save it, I save it in the user table, but it doesn't work. It works only when I hard code the user ID.

global $user;
$uuid = $user->uid;

function emailf_form_submit($form, &$form_state) {
  $bb = $form_state['values']['emailf'];
  $query = db_update('users')
    ->fields(array('email_f' => $bb))
    ->condition('uid', $uuid, '=')
    ->execute();

  drupal_set_message('Email frequency successfully changed');
}


texts:
I'm trying to get the parent menu item of node I am currently on:
$node_id = // some id
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$menu_link = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node_id));
$parent = $menu_link->getParent();

but for some reason it always fails with this error:
Error: Call to a member function getParent() on array

When I inspect $menu_link I can clearly see it is there:

Also the method of getParent() seems to be correct: Docs
Would appreciate any help!


texts: How to create a organic-group-alias/content-type subpage?

texts:
I've created a page via views that show a list of all the nodes of a specific content type in a specific group.

/node/groupid/post lists all the nodes of type post in groupid.

But what I really need, is to be able to use the groups path alias. So:

/group-name-here/post should work for /node/groupid/post.

How can I do that?

site specs

Drupal 7.41

Views 3.11

OG 2.7

Pathauto 1.3


texts: Drupal Commerce hide cart to non authenticated users

texts:
I have a drupal 7 commerce install. I have made the views only accessible to authenticated users, but when I am not authenticated, and type in "mysite.com/cart" I still can see the cart (even though it has nothing in it).

I am using the content access module to prevent non authenticated users from viewing my produces, but I don't want anyone who is not logged in, to even know the website doubles as a store. How do I hide the cart page?