texts: Views 3.0 rc1 and node count for taxonomy terms

texts:
Possible Duplicate:
  Views and node count for taxonomy terms

Just watched this topic for the answer Views and node count for taxonomy terms - but i didn't succeed.

As far as i understand - when i use contextual filters it would show only term count not node count in terms.

Could someone explain to me how to do that with relationships?


texts: Display hierarchical entity reference fields inside node

texts:
I have the following content types in Drupal 8 :

User

field: image
other fields

Organization

field: logo
Entity reference to User [one to many]
other fields

Event

Field: Date
Field: Description
Entity reference to Organization [one to many]

The event nodes need to look like this (display the following):

Event Title
Event Date
Event Description
All the organization logos (from the organizations added as a reference entity to the event)
All the user logos that belong to the already referenced organizations

Is there any way to do this with already existing Drupal 8 modules or do I have to write some custom code ?


texts: How do I disable cache in my entityQuery?

texts:
I created a preprocess function in my recipe node page, inside that function I want to get 3 random recipes everytime the user accessess the page.

I have this code:

function sometheme_preprocess_node__recipe__full(&$variables)
{
    $nids = \Drupal::entityQuery('node')
        ->condition('type', 'recipe')
        ->condition('status', 1)
        ->addTag('sort_by_random')
        ->range(0, 3)
        ->execute();

    $variables['random_recipes'] =  \Drupal\node\Entity\Node::loadMultiple($nids);
}

But I notice that the recipes doesn't random because of Drupal cache system.

I don't want to turn off the overall cache system of Drupal for perfomance purposes.

I just want to disable cache programmatically when I get the random recipes.


texts: Drupal node migration (migrate_d2d) with revisions

texts:
I want migrate a Drupal 5 nodes for Drupal 7, use Migrate and Drupal-to-Drupal data migration modules with MigrateDestinationNodeRevision, but migrating only last node revision.

How can I migrate all node revisions?

My test code:

<?php

class FoobarNodeMigration extends DrupalNode5Migration {

  /**
   * constructor
   */
  public function __construct(array $arguments) {
    parent::__construct($arguments);
    $this->destination = new MigrateDestinationNodeRevision($arguments['destination_type']);
    $this->addFieldMapping('nid', 'nid')
      ->description('Reuse the old NIDs');
    $this->addFieldMapping('vid', 'vid')
      ->description('Reuse the old VIDs');
    $this->removeFieldMapping('is_new');
    $this->addFieldMapping('is_new')
      ->defaultvalue(TRUE);
    $this->addFieldMapping('revision')
      ->defaultValue(TRUE);
  }
}


texts: How to alter sort handler to keep existing order intact in views

texts:
I created a views page using foo plugin.When a user visit the page the city and Clinic/Hospital columns by default are being rendered alphabetically (ASC) as in below screenshot.

EDIT: Let's say for example. City is Bangalore and only for Bangalore Clinic/Hospital(C/H) column is alphabetically ordered(say Hospitals A,B,C,D...).Then user clicks on City head,then for Bangalore C/H column is alphabetically disordered(ex B,D,C,H...) but records are still correct to Bangalore city means those clinic/hospitals are located in Bangalore .Same goes for other cities too.What I want is C/H col should be ordered as earlier (alphabetical) City by City but no matter how city is ordered.

When user clicks on City head (which is sortable),the order of Clinic/Hospital goes heywire (no more alphabetical order) like below image:

Problem: How can I make my Clinic/Hospital order intact even after user clicks on City head.

Below is my views configuration:

I am using Drupal 7.41 and views 3.0

Tried so far:

function mymodule_views_query_alter(&$view, &$query) {
   if($view->name == 'list_of_doctors' && $view->current_display == 'page_1' && count($query->orderby) == 1)
    {

        $query->orderby[1] = array(
             'field' => 'field_data_field_clinic_hospital_field_clinic_hospital_value',
             'direction' => 'ASC',
            );
    }
 }

}

But after clicking City head,whole table vanishes.


texts: Create RSS feed for content type = news?

texts:
I created a content type called news items in drupal 7.  How do I tell D7 to create an RSS feed of ONLY news items?

When I go to /rss.xml, it displays all content types, which is too much.  I only need news items.


texts:
Using a deriver, I'm able to produce local tasks for each entity of my custom configuration entity type. So if I have two configuration entity labeled "Foo" and "Bar", I can have similarly labeled tabs on a report page.

However, when adding or removing one of my configuration entity, the local tasks are not updated (ie. the tab for the deleted entity is still visible). This is not a surprise as these things get cached.

I've been able to fix the issues using implementations of hook_ENTITY_TYPE_insert() and hook_ENTITY_TYPE_delete() calling drupal_flush_all_caches(). But clearing all caches in order to only get the tabs on a single page updated seems a bit overkill. I already tried to call both menu_cache_clear_all() and Drupal::cache('discovery')->invalidateAll() without success

The tabs are build using the following code:

MODULE.tasks.yml:

MODULE.settings.webhooks_list:
  deriver: 'Drupal\MODULE\Plugin\Menu\LocalTask\ReportLocalTasks'
  base_route: MODULE.settings.list

src/Plugin/Menu/LocalTasks/ReportLocalTasks.php:

namespace Drupal\MODULE\Plugin\Menu\LocalTask;

use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\MODULE\CustomEntityTypeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class ReportLocalTasks extends DeriverBase implements ContainerDeriverInterface {
  use StringTranslationTrait;

  protected $entityManager;

  /**
   * Constructor.
   *
   * @param $entityManager
   * @param $stringTranslation;
   */
  public function __construct(EntityTypeManagerInterface $entityManager, TranslationInterface $stringTranslation) {
    $this->entityManager = $entityManager;
    $this->stringTranslation = $stringTranslation;
  }

  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static(
      $container->get('entity_type.manager'),
      $container->get('string_translation')
    );
  }

  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];

    /** @var EntityStorageInterface $entityStorage */
    $entityStorage = $this->entityManager->getStorage('custom_type');

    /** @var CustomEntityTypeInterface $connection */
    foreach ($entityStorage->loadMultiple() as $entity) {
      $this->derivatives["MODULE.settings.list.{$entity->id()}"] = [
        'title' => $entity->label(),
        'route_name' => 'MODULE_ecom.settings.list',
        'route_parameters' => [
          'connection' => $entity->id(),
        ],
      ];
    }

    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }

    return $this->derivatives;
  }
}

In order to have up to date tabs when adding or removing custom entity, I'm using the following code. What I'm trying to do is to have something more specific than the call the drupal_flush_all_caches().

MODULE.module

/**
 * Implements hook_ENTITY_TYPE_insert();
 */
function MODULE_CUSTOM_ENTITY_ETYPE_insert(\Drupal\MODULE\CustomEntityTypeInterface $connection) {
  drupal_flush_all_caches();
}

/**
 * Implements hook_ENTITY_TYPE_delete();
 */
function lMODULE_CUSTOM_ENTITY_ETYPE_delete(\Drupal\MODULE\CustomEntityTypeInterface $connection) {
  drupal_flush_all_caches();
}


texts: Migrate module problem with migrating images - D7

texts:
I am attempting to migrate images from a directory into an image field. All of my other fields are migrating correctly. No errors are being thrown, the database values do not appear and the image is not copied into the destination directory.

// Image migration
// basic mapping of destination field and source field
$this->addFieldMapping('field_figurae_image', 'highresfile');
// Directory where source images are located
$this->addFieldMapping('field_figurae_image:source_dir')
     ->defaultValue(drupal_get_path('module', 'migrate') . '/matrixmigrate/matrix_libary');
// Directory that source images will be copied to
$this->addFieldMapping('field_figurae_image:destination_dir')
     ->defaultValue('sites/default/files');

I believe my syntax is at least close to correct here. It is based on the "BeerNodeMigration" example. I had difficulty with Taxonomy migration that had very similar results. It turned out that I had another piece of code that was not formatted correctly. This is the only code I have related to images, is there an additional step that I'm missing?

Thank you for your time.

-Mitchell


texts: Relative URLs for file links when moving between environments

texts:
I'm trying to sync some Drupal 7 basic page nodes that have file fields on between my local development and my production environments. Production is at example.net and development is at localhost:8888/example_dev.

When the content was created on production each node contained links to several files with paths like /system/files/document1.pdf, /system/files/document2.pdf, etc. But those break when I import them to the development site because / resolves to localhost:8888, not localhost:8888/example_dev.

I'm trying to use the base url variable as recommended by this answer, but then the URLs seem to be resolving as /example_dev/node/%3C?php%20echo%20$base_url;%20?%3E/system/files/document1.pdf.

What am I doing wrong?

Update 2020 06 03: Well, what I was doing wrong was not realising that Drupal filters PHP code by default. The fix is to enable the PHP Filter module in core. But there are very good reasons that's not a good idea. Is there a way to make the links transferrable between environments without including PHP in the node body? I tried RewriteBase in .htaccess, but that doesn't seem to work…


texts:
I have a custom content type that has a webform. One of the components is the node title.
Is there a way to use a token to pull the node title instead of typing it?
I've tried setting %title as default but that simply spits back the token at me as text "%title".
Please advice.


texts: What is right way to modify a node field in a multilanguage system (LANGUAGE_NONE or $node->language or ...)

texts:
Let's say we want to modify the body field.

$node->body[LANGUAGE_NONE][0]['value'] = "test";

This will work if the node is language neutral (?)

$node->body[$node->language][0]['value'] = "test";

This will work if the node has the same langauge as the field.

But is this always the case? I found nodes where this is not the case:

(Object) stdClass
...
language (String, 2 characters ) de
...
body (Array, 1 element)
  und (Array, 1 element)
        0 (Array, 5 elements)
            value (String, 4 characters ) test

So if this is a correct node, how can we access the body field value?


texts: What's the best practice for field API prefixes? (To prefix or not to prefix, that is the question)

texts:
I'm implementing a giant list of fields, instances, bundles, et cetera in a custom site specific module.

In progress, I see that the core Tags vocabulary has a field_ machine name prefix, and none of my custom vocabularies have this prefix. I've known that creating fields through the Drupal GUI also prefixes fields with field_.

In my previous experience working with prefixed fields, this has always seemed too verbose.

Is prefixing Field API fields with _field a best practice for a reason I haven't come across yet?


texts: How do I embed a form in a controller response?

texts:
I have a controller that returns a normal renderable page array. I'd like to embed a form in that page, but the form is not appearing in the rendered output. The form is properly added to the renderable array correctly, but it's not in the final HTML for some reason. What's going on here?

Here's my controller (which extends ControllerBase through BlockController):

use Drupal\block\Controller\BlockController;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Render\Element;
use Symfony\Component\DependencyInjection\ContainerInterface;

class LayoutController extends BlockController {

  /**
   * @var \Drupal\Core\Form\FormBuilderInterface
   */
  protected $formBuilder;

  /**
   * {@inheritdoc}
   */
  public function __construct(ThemeHandlerInterface $theme_handler, FormBuilderInterface $form_builder) {
    parent::__construct($theme_handler);
    $this->formBuilder = $form_builder;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('theme_handler'),
      $container->get('form_builder')
    );
  }

  /**
   * Overrides the region demo page, adding placeholder elements for sortable
   * lists of blocks, plus a control panel form.
   *
   * @param string $theme
   *   The theme key.
   *
   * @return array
   *   The renderable page.
   */
  public function layout($theme) {
    $page = parent::demo($theme);

    foreach (Element::children($page) as $region) {
      if (isset($page[$region]['block_description'])) {
        $page[$region]['block_description']['#template'] .= '

';
        $page[$region]['block_description']['#context']['region'] = $region;
      }
    }
    $page['layout_control'] = $this->formBuilder->getForm('Drupal\block_ui\Form\LayoutControlForm');
    $page['#attached']['library'][] = 'block_ui/backbone.collectionView';

    return $page;
  }

}


texts: Anonymous users cannot see listed Commerce products in a View with a relationship to product

texts: Commerce products when listed in a View with a relatioinship to Commerce Products cannot be seen by anonymous users. I am using the Views Reference module in the product display and the View is not showing up when logged out. I cannot seem to find any permissions relating to this setup.


texts: Remove extraneous divs from panels output

texts:
I have a Panels page I am constructing and there are some divs that are interfering with the content in the layout.

At the top of my panels region output, it has:

<div class="block-region-featured-news-top-left" data-region-name="featured_news_top_left">

How can I remove this? I do not see a base twig file for this.


texts: How to accept multiple date formats for date field in webform module (with and without leading zeros)?

texts:
I have webform created with webform module. Inside it I have date field which should accept person's date of birth. When I edit that filed I can set date format at "Date settings" section, "Date format" field.
Problem is that I can set only one format there. I.e. if I set custom format to:
j.n.Y

it will accept days and months only without leading zeros. I can change it of course to accept with leading zeros, but then if someone enters day / month without leading zero it won't pass validation.
Is there a way to set date field somehow so form will accept both options - with and without leading zeros?


texts: Sort an entity query by a term reference field's term weight?

texts:
I've created an entity query to get an array of nodes based on a specific content type,see below:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'article');
$query->propertyCondition('status', 1, '=');
$result = $query->execute();
$nodes = node_load_multiple(array_keys($result['node']));

The node content type article being queried has a Term Reference field (list of tags). Each taxonomy term is sorted via the admin/structure/taxonomy/tags administration screen.

I have the requirement to have the nodes sorted by term weight. For example the nodes that reference the highest weighted taxonomy term will be at the top.

Is there a way to add a relationship to the taxonomy table using EntityQuery, or is there another way to do this?


texts: Hook_views_query_alter: adding condition with entity reference value

texts:
I need to filter a table result based the current user.

I added this condition in my hook_views_query_alter

function my_module_views_query_alter(&$view, &$query) {
  global $user;
  if ($view->name == 'preventivi' && $view->current_display == 'page_3')
  {
    // $view->query->add_where(1, $user->uid, 33, '=');
    $view->query->add_where(1, "field_data_field_installatori_reference.field_installatori_reference_target_id", $user->uid, '!=');

    // dpm($view);
    //dpm($query);
  }
}

but I can't find the correct value of target_id to insert in the condition.
Any suggestion?


texts: How to translate the Automated Logout module administration?

texts:
How to translate language of the Automated Logout module administration?

I was searching for translation of polish language and tired other modules.


texts: How to reset form values when Ajax submits?

texts:
I develop a module which converts submit in the form to Ajax submit (e.g. node/add/article). After every submit, the node is successfully created, but all the values remain saved.

In the Ajax callback, I added a return $form to reload the form after submission, but all fields are empty, not filled with old values.

What shall I do?


texts: Using selected value of Entity Reference as filter for another Entity Reference

texts:
Going to try and put this as simple as i can.

Lets say i have 2 Entity Reference Fields A and B.

A) Gives a list of Countries.

B) What ever country was selected in A should only display list of available State/Province's to that country

Example:
Lets say i have a content type of Countries where i can save the country name in the title, then i also have a content type of state/province's where the state/province name is saved in the title with entity reference field where a county can be selected for that State/Province.

Lastly i have a content type user information, where a user can enter his/her name in the title, a entity reference field country and another entity reference field state/province. When the user select, lets say, USA as a country in the first entity reference field, the second one should only display a list of sates available in the USA.

Can something like this be done where the option of one Entity Reference field can be used as a filter for another entity reference? and if so, how can something like this be achieved? any and all help is much appreciated.


texts:
I have create two view

[1] testimonial_image
[2] testimonial_text

Now i want to display this both view in custom created .tpl file
.i.e

page--alltestimonial.tpl.php

[1] testimonial_image -> display all images of testimonial

[2] testimonial_text -> display all text description of testimonial.

How can i merge in one page?


texts: How may I show the top 4 most recent result and then randomize in Views?

texts:
I currently have a view; I would like to select the top 4 most recent nodes, and then display them in a random order.

I think it would work if they were all posted on the same day.
I have a "sort by date," and then I am using the random seed module to randomize the results.

However, if they occurred on different days, the random does not take effect because it is sorting first by day.

Does anyone have any advice?


texts:
I have configured Vote up/down module for voting. For every vote, content author will be awarded 5 points for up-vote, but i am facing problem for down votes! i can not understand how to minus userpoints for down-votes? Say, if a voter hit down vote then 3 point will be minus from userpoints!Installed Modules:

Vote up/down
Userpoints
Voting API
Voting Rules
Rule module...


texts: Any module for user to custom make a schedule from listed options?

texts:
I'm looking for a module which can do something pretty specific. For a conference that our organization hosts, we have many different sessions during the day. People can pick and choose which one they want to attend.

We would like to create a page which will 1) list all the sessions available and 2) allow people to "favorite" or "pick" from these sessions which will add them to a smaller list, which they can view on a separate page. Ideally this will not require individuals to be logged in, but rely on cookies.

Does anyone know of a module with functions like these? It could really be a view with more robust features, but I can't find an extension of Views which has these features.


texts: 301 redirecting broken links after moving Joomla! to subdomain and giving parent domain to Drupal7?

texts:
I've recently started doing way more Drupal development than Joomla!, and given I use my personal website as a testing platform that changes about once every few years, am trying to migrate it from Joomla! 1.5 to Drupal 7.

To this end, I've moved the entire Joomla! website to http://v3.aendrew.com and in doing so, broken all incoming links, which are now met with a Drupal install that's never heard about any of my prior content -- http://aendrew.com.

Is there any way I can do the following via Drupal 7?

Detect broken incoming request (Drupal 404s)
Check whether the path exists on the Joomla! subdomain.
Issue a 301 redirect pointing to the Joomla! page if so; issue a 404 if not.

Thank you!


texts: How to display only parent terms of hierarchical terms  in Views field

texts:
In the Views UI I set up the Relationship "Taxonomy:Parent term" and then a Field "Taxonomy: Term" with that relationship.
But the problem is that It displays the parent terms of all the vocabularies (I have several vocabularies).
I also tried the Field "Taxnomy:All terms" as it can limit the terms by vocabularies but it can't have the Relationship "Taxonomy:Parent term"

Is there any way to display only the parent terms of one certain vocabulary for hierarchical taxonomy in a view field?


texts: What would cause static image links in html.tpl.php to be dynamically overwritten?

texts:
I have come across something I've never seen before. I'm having trouble understanding the bug, much less clearly explaining it in a question, so bear with me.

I have a theme that is actually a sub theme of Zen.  In my themes folder, I have the folders zen and news_center, which is the name of the theme based on Zen, and gotoniseko, which is also based off zen.

This has worked for over a year with no problem.  Now, we wanted to create a new theme based off news_center. It's exactly the same theme, except css was changed. You can view the differences here:

http://seesapporo.com  <-- original news center theme

http://goniseko.com  <-- new theme based off news_center

This is the same Drupal install, but the Domains module is being used for the multi site capability.

So, again, we wanted to create a new theme for the goniseko.com domain. We did, and we uploaded it. Drupal sees the theme fine, and we enable it.

In the new theme, in addition to the CSS changes, we changed html.tpl.php. We added some custom javascript and two static image links.

Here is the HTML that's included in the html.tpl.php file:

Here is the HTML that was actually rendered in the HTML source:

I know for sure when I edit html.tpl.php I am editing the correct file because if I delete it, the theme breaks. But, if the file is there, no changes I make to the file show up. It's almost like there is a cached version taking precedence, but no amount of clearing cache helps.

Ok, in an attempt to debug the problem I changed the name of the new theme's folder from gotoniseko to gotonisekom - bingo! all of my file changes were recognized. So I thought, ok fine, I'll change the folder name and references of gotoniseko to gotonisekom. I did, and I upload the files.

After uploading Here is the HTML that's included in the html.tpl.php file:

Here is the HTML that was actually rendered in the HTML source:

Now I have to have the theme uploaded twice to the theme directory, exact copies of each other (except the .info file), so they cross reference each other and it works ok. Of course this is a hack.

Something is overwriting the theme directory name in static links to be the directory name of the theme that was installed just before it.  I know that the way to implement the links and JQuery in the html.tpl.php is not the Drupal way to do it, but this is proof of concept before we invest the time into a real module. However, even if I delete the background image functionality, something still overwrites directory names.  What could be causing this to happen?


texts: How do I add content to views slideshow after setting up?

texts: I set up a slideshow according to instructions and it functions beautifully, but when I add more content the slideshow block does not seem to be pulling it.  Is there another way to add additional images to the slideshow?  I have the block/view set to all items, rather than a set number.


texts: How to display a block view on demand triggered by clicking content of another view?

texts:
A Link from a field value (view 1)  to another view (view 2) with contextual filtering works as well, if the second view is a page view.
But what about, if the second view should be a block view, only displaying after clicking on the link in view 1?


texts: Can't make a DISTINCT search in an Apache Solr View

texts: I have a set up Apache Solr on my Drupal 7 site.  I have an apache solr view.  I would like to created distinct results based off an indexed field called 'Part Number'; however, the solr view ui doesn't provide a 'DISTINCT' option.  Does anyone know of a good workaround for this?


texts: How do I get the vocabulary of a term inside an "article" type content type?

texts:
I have a content type tagged with various vocabularies. Each vocabulary has terms which I want to style with particular colours based on the vocabulary. For example, say I have a "Fruits" vocab which has term 'apple' and 'banana' and a "veggies" vocab with 'onion' and 'carrot'. I want to colour the apple and banana tags RED and the onion and carrot tags BLUE *in same node. Say I've a content type "article" which is tagged with apple from the fruits vocab and carrot from the veggies vocab. 'apple' should have a RED background and 'carrot' and BLUE background. Another content node has apple and banana for tags and they should both be RED.

I've found the following code, but it only works when the page I am viewing is the "apple" page - that is, I'm reading the page for the vocab term apple, NOT a content type tagged with apple. It DOESN'T work for tags in other content types and I'm failing miserably to find the right code.

function MYTHEME_preprocess_field__entity_reference(&$variables) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical') {
  // load the term entity and get the data from there
  $term = \Drupal::routeMatch()->getParameter('taxonomy_term');
  $variables['vocab'] = $term->bundle();
  }
}

My theme has custom twig files for field--entity-reference.html.twig

and I'm trying to use the preprocess function above. Nothing I can find anywhere addresses this; what gives?


texts: Custom PHP Unit test trait for a custom module cannot be found

texts:
I have created a new Trait for testing my custom module and placed it in my_module/tests/src/Traits with the namespace Drupal\Test\my_module\Traits, the same as core modules do.
When I try to use this in my PHP Unit kernel test I just get the following error:
Fatal error: Trait 'Drupal\Test\my_module\Traits\CustomTrait' not found

Is there something special that needs to be included to allow custom traits in testing?


texts:
I mistakedly erased a site from a server with ftp last night. Now luckily, I had a backup from not too long ago. I copied all the files from my back up directory back into my site using filezilla (I backed the site up using wget). Now when I go to my site, I gert an error like

  Fatal error: require_once() [function.require]: Failed opening
  required 'includes/ckeditor.user.inc'
  (include_path='.:/usr/local/php5/lib/php') in
  /home/content/q/u/a/quaa7882/html/sites/all/modules/ckeditor/ckeditor.module
  on line 48

This error first appeared on my apps module. So I copied to apps directory out of the sites/all/modules directory but then, the same error appears again for the next module alphabetically so I assume it would appear for every single module. I tried to run update.php but I get a Server error in Chrome, it tells me:

  The website encountered an error while retrieving
  http://quaaoutlodge.com/update.php. It may be down for maintenance or
  configured incorrectly.

I'm wondering what might be going on here and how I can retore the site...?

Thank you!

EDIt1

The files in my backup directory are:

-rw-rw-r-- 1 ron ron 20581 Aug 24  2013 CHANGELOG.txt
-rw-rw-r-- 1 ron ron  2616 Aug 24  2013 ckeditor.api.php
-rw-rw-r-- 1 ron ron  3867 Aug 24  2013 ckeditor.config.js
-rw-rw-r-- 1 ron ron  3395 Aug 24  2013 ckeditor.css
-rw-rw-r-- 1 ron ron   354 Aug 24  2013 ckeditor.info
-rw-rw-r-- 1 ron ron 21467 Aug 24  2013 ckeditor.install
-rw-rw-r-- 1 ron ron 26478 Aug 24  2013 ckeditor.module
-rw-rw-r-- 1 ron ron   519 Aug 24  2013 ckeditor-rtl.css
-rw-rw-r-- 1 ron ron  3749 Aug 24  2013 ckeditor.styles.js
-rw-rw-r-- 1 ron ron 18092 Aug 24  2013 LICENSE.txt
-rw-rw-r-- 1 ron ron 21347 Aug 24  2013 README.txt
-rw-rw-r-- 1 ron ron 10521 Aug 24  2013 TROUBLESHOOTING.txt
-rw-rw-r-- 1 ron ron  1547 Aug 24  2013 UPGRADE.txt

EDIT2

I actually found my ckeditor.user.inc now, it was under sites/all/libraries/includes/ckeditor.user.inc instead and this is also where it is on my ftp. It's got a 175 lines of code and I didn't necessarily want to post the complete file unless required. What should I be looking out for?


texts: Search api solr: The Solr server could not be reached

texts:
I've got a working solr server, however my drupal always fails to connect, what am I doing wrong?

When adding my server and clicking on the solr server url it takes me to my server (so my path is correct), yet I keep getting a message: The Solr server could not be reached.

I am hosting apache solr on a server (not locally).

Host: Server IP address
Port: 8983
Instance: /solr

Can anyone help me out ?


texts: How can I change page title in node with some options?

texts:
how can I change page title drupal 8 in node with some options?
I want change my title on "test" if node have field "field_section" is "dogs".
Just in this page I want showing in "field--node--title.html.twig" 'test'.

I tried
function test_theme_preprocess_field(&$variables, $hook) {
if($variables['field_name']=='title'){
   $variables['items']['changetitle']=true;
      // kint($variables);
   }
}

But I don't know how to search from preprocess field other paramters other fields like my field in node 'field_section'.

I want mix in preproccesing_field 'if field_section have value 'dogs' then showing page_title is 'test'.


texts: Showing 2nd Depth term name and image along with it's associated node's title

texts:
So I have a "Category" vocabulary on my website like this:

Parent Term 1:
  -- First Child Term:
     -- Second Child Term:
        -- Associated Node 1
        -- Associated Node 2
Parent Term 2:
  -- First Child Term:
     -- Second Child Term:
        -- Associated Node 3
        -- Associated Node 4

For Instance consider this:

Electronics:

      - Notebooks
        -- Asus
         --- Node 1
        -- Apple
         --- Node 2, Node 3 ...

What I want is to make a view to Show Popular Categories, The "Second Child Term" "Term Image (field)" along with 4 of it's nodes! so I can have something like this:

- Notebooks
-- Node 1
-- Node 2
-- Node 3
-- Node 4

I almost destroyed my laptop over this and couldn't figure this out, I ask you Views guru's to help out a newbie, Thanks.

Also note that I'll buy you dinner if you can help me <3


texts: The purpose of $page in node.tpl.php and when does it become FALSE?

texts:
I noticed that there is a variable $page in node.tpl.php and it is usually TRUE.
The node title is not displayed while it is TRUE, but in page.tpl.php, the node title has been displayed as a page title. The below is the code snippet from node.tpl.php of Bartik theme.

  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>>
      <a href="<?php print $node_url; ?>"><?php print $title; ?>

  <?php endif; ?>

When the variable is FALSE, the node title in node.tpl.php will be displayed and it seems like duplicate title being displayed. I tried this:

function bartik_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
  }
  dpm($variables);
  $variables['page'] = FALSE;
}

What is the purpose of this variable and when does it become FALSE?.


texts: How to show a description when a select box item has been selected

texts:
On my "node/add" form I have a "topic" taxonomy term field a user has to select. I would like to be able to display a description about a selected text next to the box, see red box in screenshot:

I'm sure there are CSS/javascript hacks out there, just wondering if there is a "Drupal way" for doing this?
Cheers


texts:
I created a view that has a global combined fields filter setup to search through node's title and a set of taxonomy terms. It works fine but only if I include a "Taxonomy term: Name" field.

This field currently causes each node to appear in the results for each term that is assigned to it. I checked Aggregation Settings for that field but only have these options:[]1

I also tried the Views Distinct module which worked but at a great performance cost. Is there either:

a way I can include terms in the global combine fields filter that I haven't thought of or
a way to prevent the duplicate results?

Thanks for your help


texts: Is it bad to add js and css in template_preprocess for a custom block?

texts:
If I load my page where my block is displayed as user 2 (any user besides user 1) my block displays correctly.  If I reload the page my block doesn't display correctly and my js and css that was added via template_preprocess() doesn't show up.

I verified that if I turn off Block caching the problem goes away so it tells me that I shouldn't be adding js and css in the template_preprocess functions and add it via '#attach' but I have a function (video_widget_add_js) that I am adding javascript because I am adding it in multiple places and want to reuse the code.  Anyone have a good suggestion on this?

  <?php

  /**
   * Implements hook_block_view().
   */
  function leadership_block_view($delta = '') {
    $block = array();

    switch($delta) {
      case 'leadership_all_companies':
        $node = menu_get_object();

        $data_card_content = leadership_get_data_card_content($node);

        if (!$data_card_content) {
          $block = array(
            'subject' => '<img class="ld-block-logo" src="' . variable_get('leadership_block_logo') . '" alt="Leadership Logo" />',
            'content' => theme('leadership_allcompanies', array(
                'taxonomies' => leadership_get_taxonomies(FALSE),
                'delta' => $delta,
              )
            ),
          );
        }
        break;

    }

  }

  /**
   * Implements hook_theme().
   */
  function leadership_theme() {
    return array(
      'leadership_allcompanies' =>  array(
        'variables' => array('taxonomies' => NULL, 'delta' => NULL, 'has_data_card' => NULL),
        'template' => 'leadership-allcompanies',
      ),
    );
  }

  /**
   * Preprocess for the all companies block.
   *
   * @param array $vars
   *   An associative array containing:
   *   - taxonomies array
   *     An array that contains taxonomy objects @see taxonomy_get_tree().
   *   - delta string
   *     The block string key.
   *   - has_data_card
   *     This will only be used in the all_companies_and_data_card block. If set
   *     to FALSE then only all data that would appear in the all companies block
   *     will appear. If set to TRUE both will appear.
   */
  function template_preprocess_leadership_allcompanies(&$vars) {
    // Add js and css files.

    $js_extension = (variable_get('smg_global_is_production', false)) ? '.min.js' : '.js';

    $path = drupal_get_path('module', 'leadership');
    $video_widget_path = drupal_get_path('module', 'video_widget');
    drupal_add_css($path . '/css/all_companies_block.css');
    drupal_add_css($path . '/css/datacard.css');
    drupal_add_css($path . '/css/datacard_' . variable_get('smg_global_site') . '.css');
    drupal_add_css($video_widget_path . '/video_widget_includes/css/video_widget.css');
    drupal_add_js($video_widget_path . "/video_widget_includes/angular/app{$js_extension}");
    //drupal_add_js('sites/all/libraries/angularjs/bower_components/angular-animate/angular-animate.min.js');
    drupal_add_js($path . "/angular/js/all_companies_block{$js_extension}", array('every_page' => TRUE, 'preprocess' => TRUE));
    drupal_add_js($path . "/angular/js/datacard{$js_extension}");

    $vars['site_id'] = variable_get('smg_global_site');

    $taxonomies = $vars['taxonomies'];
    if ($taxonomies) {
      if (variable_get('smg_global_site') == 'pw') {
        // Add the parent tids,titles (Ex: Machinery, Materials, Service)
        foreach ($taxonomies as $taxonomy) {
          $categories[$taxonomy->parents[0]]['tids'][] = $taxonomy;
        }
        foreach ($categories as $tid => $category) {
          $categories[$tid]['tid'] = $tid;
          $categories[$tid]['title'] = taxonomy_term_load($tid)->name;
        }
        $vars['taxonomies'] = $categories;
      }

      // Add taxonomy list to Drupal object to be used by Angular.
      drupal_add_js(array('leadership_all_companies_block' => $taxonomies), 'setting');

      // Call the video widget registering function
      video_widget_add_js();
    }
  }


texts: is there a way to hide a "custom field" in edit mode Drupal 8?

texts:
I have a form with 5 custom fields. I would like to hide a couple of fields based on the view mode in the back-end while the user is editing the form.  Right now you can easily hide the field in the front end, but i am looking for way to not confuse the editors and hide the form fields while they are making changes.
Disable fields still show up in the back-end.

My goal is simple: if your view mode has the field disable it should not show up in the back-end and in the front end.

is there a setting or a hook that can allow me to accomplish that.


texts: How to add a sub-theme for mobile version?

texts: I finished my drupal site, and now I should create the mobile version.First I'm using Bootstrap 3.3.5 with a sub-theme, and drupal 7. I'm sorry I don't know how to explain it but I want like, add a another sub-theme  like my existing sub-theme and change on it for mobile with saving all my node and views, thank you.


texts: Privatemsg overwrites page title for custom code. How do I correct it?

texts:
I am using Private message as PHP in a block on the node of a page so that a person can contact the node author without having to leave the page. Here is the code:

$node = menu_get_object();
if ($node->uid != 0) {
module_load_include('pages.inc','privatemsg');
  $recipients = $node->uid;
print "
Contact " . $node->name ." about this post.
";
  $subject = $node->title ." question.";
  print drupal_render(drupal_get_form('privatemsg_new', $recipients, $subject));
}

However, Private message hijacks the title of the entire page, and now every single node  value is 'Write so-and-so' a new message, instead of what the page title should actually be.

Thoughts on how to correct this?

You can check out what's happening here on the test server:

http://g.hokkaido-select.com/classifieds/cars-and-vehicles/motorcycles-and-scooters/2006-150cc-scooter (note, you have to be logged into see the block, but the page title error can still be seen)


texts: Field or Block on view block in Content section of a content type?

texts:
Working on a Drupal 7 site.

For a “view block” (or a series of view blocks) in the content section of a content type(s), when is it better to add a specific view block as field to the content type (and set as default view + hide), vs better to configuring the view block to display via the blocks section (and restricting via content type)?

Dot point:

Add view a field to one or more content types (in content section)
-----Set as default and hide it (same view for all content type)
Or Set view to display in block section (or even context)?
-----Restrict to content type

Pros and cons I can see:

Block displayed via as a field:

View is specific to the content type, no mistaking it
If view is used on one or more content types, the block and can be re-arranged without affecting other content types that might use it.
Block display via blocks (or context) section
Can see at a glance which content types use the view block (if using context, otherwise, its harder)
Can’t have two content types have a different arrangements of the blocks (eg using two view blocks). Unless I’m wrong here?
Pollutes the blocks section of the backend if using many different content types (where are only used 1-2 times)
I can see this makes sense for side bar view or something since it would be used across the majority of the site + it’s not in the content section anyway, not for this though

Can someone advise which direction is better? (and if Drupal 8 way is different?)


texts:
Please help achieve the folowing:
I have a content type "proposal" with a field "prépayment_amount". I want the user who try to flag this node to pay the amount indicated in the field "prepayment_amount" and when the payment is successful, I want to notify this to the user who created this node, if not the flag is cancelled.


texts: Lightest setup to sell only digital content with no physical products?

texts:
I'm looking for recommendations on how to setup Drupal 7 with the fewest modules so I can charge users to Buy Digital Content (Book Pages) on my site.

I will eventually have several books, and users will need to pay for each one to read (view) them. There are no files to be downloaded here, I will actually try to prevent users from copying the content; they should only have access to the Book.

I looked at the recommended Drupal Commerce, but it seems very much like overkill (many unused features like shipping, packing, inventory) for what I want to do. Not sure it can (easily) handle Digital Content.

If there is no simple solution, can this be easily done in Drupal Commerce?


texts: How do I correctly setup caching for my custom API routing?

texts:
I have custom module with some routes which return JSON, for instance terms of a vocabulary.

routing.yml

mymodule.terms:
  path: '/api/terms/{vid}'
  defaults:
    _controller: '\Drupal\mymodule\Controller\MyModuleController::getTerms'
    _title: 'Terms'
  requirements:
    _permission: 'access content'
    vid: '^(foobar|barfoo)$'

Controller:

public function getTerms($vid) {
  $response = $this->jsonifyVocabulary($vid);
  return $response;
}

private function jsonifyVocabulary($vid) {
  $request = \Drupal::request();
  $lang = $request->query->get('lang', 'en');
  $output = [];
  $taxonomyManager = \Drupal::entityManager()->getStorage('taxonomy_term');
  $terms = $taxonomyManager->loadTree($vid, 0, 1, false);
  $response = CacheableJsonResponse::create($output);

  debug(1);

  foreach ($terms as $term) {
    $term = Term::load($term->tid);
    if ($term->hasTranslation($lang) && $lang !== $term->language()) {
      $term = $term->getTranslation($lang);
    }
    $entry = [
      'tid' => (int) $term->id(),
      'label' => $term->getName(),
    ];

    // $response->addCacheableDependency($term);
    $output[$vid][] = $entry;
  }

  $response->setData($output);

  $cacheMeta = (new CacheableMetadata())->addCacheContexts(['url.query_args:lang']);
  $response->addCacheableDependency($cacheMeta);

  return $response;
}

Thanks to this answer I know how to actually add the URL params as a cache context, but the

debug(1);

always gets called, I guess I just somehow have to tell Drupal that this JSON response's cache should relate to that route...

I don't use the core's REST module on purpose since I find it hard to configure to output exactly what I need.


texts: Can You Render Data from Forced Fields in Views While Using format "Show: Content"

texts:
Drupal 8.x

Is it possible to render fields in a view when the display format setting is set to format "Show: Content" ?

For my case, the contrib module I am using has some views integration that provides field data I would like to show, but have found to be difficult to access via preprocess. I also have some programmatically created data I need to show via my template provided by a HOOK_preprocess_HOOK().

I am kind of stuck in the middle. So I am curious if there is a way to render, or maybe get the data of, the forced fields while setting my view to "format: content"?


texts: Hide filter form when filter is limited to one active item

texts:
I have the following facets:

School
Location
Grade

These are indexed from taxonomy fields and 'School' is multi value while 'Location' and 'Grade' are single value fields.

My facets are set to hide not display when empty and limited to one active item at a time.

The 'Location' and 'Grade' forms are hidden when one item is selected, I'll like to hide the 'School' form as well when it is active.

Any ideas, I was thinking of hook_form_alter and then disabling the form when it's active.


texts: Drupal (or perhaps Apache) delivers wrong page

texts:
Made a website in drupal 8, and using webforms to save some webform submissions.

Made a custom url to show the submission data the way I want, for the sake of the example let's say:
/submissiondata/[submission_id]/[submission_token]

anonymous users can see that page, and made sure that the page is not cached- by adding options: no_cache: 'true' in the routing.yml file and also when returning data, returning it like this:

return array('#markup' => $html, '#cache' => ['max-age' => 0,]);

Some extra info:
When showing this info, the user has only 5 min. to see this page, because I compare CREATED to CURRENT_TIME - and deliver some other HTML if more than 5 min. passed.

the apache server is setup with some reverse proxy...

Here is the issue:
Sometimes, a person sees another persons submission data, just by surfing around the website. Like clicking the logo and going to the front page, they don't see the front page, but see submission data of another person!

How the heck is that possible?? It's happens very rarely, but it happens!
It should not be possible! Is this a Drupal issue?


texts:
I'd like to change the output of the search result page.

For example, I've got 3 different content types: foo, bar, etc. I'd like to group my search results by these content types, so that for every content type the first three or so results are shown followed by a link: "View more results for content-type foo" which will lead you to a page where all results of this specific content type are shown.

I've done some researching and couldn't find a module which does something like this. I guess i have to write my own module, but I don't know where to begin. Do you have any tips for me (whick hooks to implement, etc...)


texts:
It's more general question. Just to clarify. I can use preprocess function in my template.php file in a way:

function mytheme_preprocess_node(&$vars) {
  // Do some stuff
}

But is there a way to preprocess node in a module? I've been searching for function hook_preprocess_node() in drupal API, but there's no such function for D7, although it does exists for all other versions of drupal, including 8. May I treat template_preprocess_node() as a function which I can use in my module? For example, if my module has name 'custom' then can I use it this way?

function custom_preprocess_node(&$vars) {
  // Do some stuff
}

How can I override node in custom module?


texts: limit validation button on visible state textfield?

texts:
Suppose I had a selectbox with 2 options. One option enabling the visible state of one field, while the other disables that state and makes a different text field visible.

If I had a button that has limit_validation_errors, how would one go about validating only the field whose state is visible?

Currently my setup looks like the following:

$form['unit'] = array(
  '#type' => 'select',
  '#options' => array(
    0 => '€',
    1 => '%',
  ),
  '#default_value' => 0,
);

$form['price-percentage-field'] = array(
  '#type' => 'textfield',
  '#title' => t('Price'),
  '#description' => t('Set the percentage discount price for this volume set'),
  '#size' => 10,
  '#element_validate' => array('price_percentage_validate'),
  '#states' => array(
    'visible' => array(
      ':input[name="unit"]' => array('value' => 1),
    ),
  ),
);

$form['price-field'] = array(
  '#type' => 'textfield',
  '#title' => t('Price'),
  '#description' => t('Set the price for this volume set'),
  '#size' => 10,
  '#element_validate' => array('price_validate'),
  '#states' => array(
    'visible' => array(
      ':input[name="unit"]' => array('value' => 0),
    ),
  ),
);

$form['add'] = array(
  '#type' => 'submit',
  '#value' => t('Add'),
  '#name' => 'add_row',
  '#limit_validation_errors' => array(
    array('price-field'),
    array('price-percentage-field'),
  ),
  '#submit' => array('add_volume_standard'),
  '#ajax' => array(
    'callback' => 'add_volume_standard_ajax_callback',
    'wrapper' => 'error-placeholder', //<- this here is for my custom error-placeholder that will contain the form_errors nicely in a div using a few ajax_commands and form_states
    'method' => 'append',
    'effect' => 'fade',
  ),
  '#title' => t('Click this button to add a standard volume price'),
);

When using this code, both fields will always be validated. While I want to only validate the visible field. How can I do this?

Also, a validation function is not my preferable approach. I have my reasons.


texts:
Is there any way to db_update() for the following query?

UPDATE field_data_field_TEST as ft
left join node as n on ft.entity_id = n.nid
set n.type='test'
where n.type='foo'

I tried using db_update()->join(); but it didn't work.


texts:
I am building a Rules action that needs to take an array argument, that I would populate using a PHP script on the action UI.

Let's say the action is called TranslateMessage, with arg1 = text, arg2 = array

How to declare arg2 so that it shows up as a text area with PHP input in the Rules UI, and send the array (that I create in the PHP area) as an argument to the action function?


texts:
I'm trying to make an entity reference field a multi-select options select but I can't seem to find out how to make that happen. Any help is appreciated. Below is the code I'm using.

$fields['some_field'] = BaseFieldDefinition::create('entity_reference')
  ->setLabel(t('Some Field'))
  ->setDescription(t('This is a field.'))
  ->setRevisionable(TRUE)
  ->setSetting('target_type', 'other_entity')
  ->setSetting('handler', 'default')
  ->setTranslatable(TRUE)
  ->setDisplayOptions('view', [
    'label' => 'hidden',
    'type' => 'author',
    'weight' => 0,
  ])
  ->setDisplayOptions('form', [
    'type' => 'options_select',
    'weight' => 0,
    'settings' => [
      'options_select' => 'multiple',
      'placeholder' => '',
    ],
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE)
  ->setRequired(FALSE);


texts: How can I check which nodes have the highest value in a certain field?

texts:
My content type 'Article' has an integer field called 'Ranking'. How can I check which nodes have the three highest values after saving a new node or comment? I'd like to use the result in a rule, so I'm looking for some kind of "The node has ranking 1/2/3" condition.

Any ideas how I can achieve this?


texts: How to implement a Dropbox-like functionality for authenticated users to upload files?

texts:
I want to give my users some sort of upload functionality - kind of like a Dropbox. The Dropbox client module seems to have many bugs and the patches aren't fixing them for me.

So basically I am looking for users to be able to JUST upload files.

I don't want them to be able to view files which have been uploaded by others.

Any suggestions about a suitable solution?


texts: Restricting view of nodes on taxonomy aggregation pages?

texts:
I have a taxonomy vocabulary that I use in many different content types.  I want to restrict, programmatically, access rights to specific content types.  As in, a specific role is not able to view particular content types unless they directly authored the item.  This includes any view of a particular node (full, teaser, etc.).  I've implemented hook_node_access as follows:

function progress_reporting_node_access($node, $op, $account) {
  if ($account->uid == 0) {
    return NODE_ACCESS_IGNORE;
  }
  if (_is_tagged($node,$account) && $op == 'update') {
    return NODE_ACCESS_ALLOW;
  }

  $records = _non_viewable_records();
  if (is_object($node) && in_array($node->type,$records)) {
    if ($op == 'view' && $node->uid != $account->uid) {
      drupal_set_message('Sorry, you cannot access this page. Click here to get back home.','error');
      return NODE_ACCESS_DENY;
    }
  }

  return NODE_ACCESS_IGNORE;
}

The only thing that I didn't realize is that this affects a user only when they try to view the full node.  So, when a user navigates to a taxonomy term's aggregation page, all the teasers of all the content that the term is referenced in shows up, regardless of the logic I applied in hook_node_access.

I need to somehow apply the same restrictions to all node views.  In other words, when they navigate to the taxonomy term aggregation page, they don't see teasers that they're not supposed to see.

How can this be done, programmatically, exactly?


texts: How to restrict content access within a site?

texts:
In a community site. I want to restrict users to have some private parts of the site like forum, groups and discussion board with their scope (should not be visible to others).

That is a specific forum should be available to a specific set of users who belongs to a specific group.

Eg: Let's say there are multiple groups of users like cricket players,  football players. I want to restrict the visibility and access to cricket forum only to cricket players and Football forum respectively. And there is a third forum called sports which should be visible to both.

The question can split into two:

How to create a specific set of users?
How can I restrict the specific set of users to the forums, groups, etc...


texts: Allow block display on child nodes but not grandchildren

texts:
In a block configuration, I would like to show the block on
/programs/* but not on programs/* /*

I have seen a number of questions similar to mine.
Block display using wildcard, non-greedy for example.

The recommendation from the above link to use drupal_match_path() makes the most sense to me.  I have implemented the following,

    <?php
if (drupal_match_path(current_path(), "programs/*") && !arg(2)) {
  return TRUE;
}
?>

expecting the block to appear on /projects/name but not on /projects/name/grandchild-node.  The block doesn't appear anywhere. Just to test the system, I tried this:

    <?php
if (drupal_match_path(current_path(), "programs/*") {
  return TRUE;
}
?>

and still the block doesn't show.
I'm certain that I'm doing something wrong that is very basic. Any ideas?


texts: How to use Quicktabs as attachment to Views

texts:
Good day,
I made block with 3 tabs using Quicktabs.
Is it possible to use it like attachment to Views page?

I want use contextual filters in Views and do filtering in tabs also....


texts: The content access permissions need to be rebuilt. Rebuild permissions?

texts:
My Drpal website asks

"The content access permissions need to be rebuilt. Rebuild permissions"

what is this means?

Can I go for Reubuild Permission?

Will it cause any problem for current modules?


texts: If it's possible, how can I go about extracting the database abstraction layer to use in a non-Drupal site?


texts:
I want to use db_update with condition that a specify field is null ,how can I do it?

something like

->condition('used_date',  'isnull','=')

is this correct ,if not,what is the correct condition ?


texts: Listing all terms of a taxonomy in twig template

texts: How can I list all terms of a particular taxonomy in a twig template?


texts:
I am trying to override a field template with my own one. The field is called field_test, so I created a field--field-test--mynodetype.html.twig template file ` in root-theme-directory/templates/, but Drupal doesn't recognize it.

I cleared the cache from the UI, enabled debug mode in settings.yaml, installed the Devel module, and re-generate the theme registry on each request, but nothing seems to help. The field gets always rendered with the default field.html.twig template.

How do I override the field template Drupal uses?


texts: Help needed with hook_node_submit in custom module to save data

texts:
I require some help in my custom module, specifically getting the value of a form element added via ajax in hook_node_submit.

First I'll explain the basic module setup needs:

You have created a content type called 'content'.
You have created a sample taxonomy vocabulary and added some sample terms to it.
In the content type you add a term reference field with the name 'field_terms' for the newly created vocabulary and allow unlimited values (checkboxes).

Now you enable the module and create new content of type 'content'.

Once you select 2 taxonomy terms, a select list appears with the 2 or more selected terms in it, allowing the user to select one of the above selected terms once more (to define a main term from the selected terms - if that makes any sense)

So, in terms of the module I have written this:

1) I use the function hook_form_alter() and apply it to only $form_id == 'content_node_form' (content type = 'content').

2) In hook_form_alter() I apply '#ajax' to each checkbox for the field_term checkboxes and create a blank container where the select list will be placed after the callback.

3) I have written the function _custom_callback() which gets the selected checkbox term_ids and term_names from the field_terms to create the select list options. It then outputs the select list if 2 or more options have been selected

4) Implement hook_node_submit() to grab the data from the $form_state and move it into the node object (this is where the first errors occur)

5) Implement hook_node_load() to load the values when editing the page

6) Impmeneted hook_node_insert(), hook_node_update() and hook_node_delete() to do the db stuff.

But when I submit the form I receive the following errors - due to hook_node_submit:

I am unsure how to call my object in the node. My form is called

$form['container']['main_taxonomy_term']

So I presumed this would be correct:

/**
 * Implements hook_node_submit().
 */
function select_main_taxonomy_term_node_submit($node, $form, &$form_state) {

  $value = $form_state['values'];
  // Move the new data into the node object.
  $node->main_taxonomy_term['tid'] = $value['main_taxonomy_term'];
}

I have looked and tried but I just can not find any clues how to get the data from $form_state and into the node object.

Please find attached the module. maybe someone can help me out as this is driving me insane.

Here is the module:

http://www.megaupload.com/?d=181H4B5F

Many thanks in advance.


texts: Suggested way to setup drupal to handle multiple subsites / subdomains?

texts:
Looking for some examples of folks successfully using Drupal on multiple subdomains. Is there a good way to go about using a single drupal install to manage multiple subsites like so:

Siteone.domain.com
Sitetwo.domain.com
Sitethree.domain.com

Etc….

All of these subsites have separate information, but some of it could be related here and there, so having it available to each subsite would be a benefit... thinking Entities here I suppose. One database and one core to update would be ideal. Any issues with setting it up? Problems with content types or entities?

I've seen:

http://www.aegirproject.org/ However, this is multiple drupal sites as far as I can see...
https://www.drupal.org/project/domain This seems like a near perfect fit. Anyone successfully utilizing this?


texts: How to save the input values in an unfinished node form

texts:
Drupal 6:

Is there a way to save the values in a node form, so that if the user leaves the page before the form is completed, they can access that form at a later time and have the values that they input still in their respective form fields?

Can you use node_api to somehow save the node as "unpublished" once the user gets to a certain point in the form? How would it work if required fields aren't yet filled in at the time of the pre-save?


texts:
I tried to implement an autocomplete in text-field for drupal 8 in my custom module

all I wanted was to fetch and display the likely title I typed via autocomplete
so declared a public function autocomplete within a class  in DefaultController.php
in folder directory -->mymodule/src/Controller/DefaultController.php

<?php

namespace Drupal\mymodule\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;

class DefaultController extends ControllerBase
{
    public function autocomplete($string)
    {
        $matches = array();
        $db = \Drupal::database();
        $result = $db->select('node_field_data', 'n')
        ->fields('n', array('title', 'nid'))
        ->condition('title', '%'.db_like($string).'%', 'LIKE')
        ->addTag('node_access')
        ->execute();

        foreach ($result as $row) {
            $matches[$row->nid] = check_plain($row->title);
        }

        return new JsonResponse($matches);
    }
}

then created an EditForm.php in
folder directory -->mymodule/src/Form/EditForm.php

<?php

namespace Drupal\mymodule\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class EditForm extends FormBase
{
    public function getFormId()
    {
        return 'mymodule_edit_form';
    }

    public function buildForm(array $form, FormStateInterface $form_state)
    {
        $form = array();

  $form['input_fields']['nid'] = array(
    '#type' => 'textfield',
    '#title' => t('Name of the referenced node'),
    '#autocomplete_route_name' => 'mymodule.autocomplete',
    '#description' => t('Node Add/Edit type block'),
    '#default' => ($form_state->isValueEmpty('nid')) ? null : ($form_state->getValue('nid')),
    '#required' => true,
  );

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

        return $form;
    }
}

also created mymodule.routing.yml

  mymodule.autocomplete:
  path: '/mymodule/autocomplete'
  defaults:
    _controller: '\Drupal\mymodule\Controller\DefaultController::autocomplete'
  requirements:
    _permission: 'access content'

still autocomplete functionality not getting implemented ?
Can anybody point me what am i missing ??


texts: How to display current langage on top of the langage list in a content type

texts:
I am using drupal 7.54 and I am a bit in trouble.

I have made a multilingual website based on entity translation.

I created a custom content type that users can create or edit nodes with. And that content type has a language field.

But in that dropdown field, English shows first in both languages. It confuses french users.
So I need to make the current language the first on the list of languages.
As an example I want the list to display like this

Français
Anglais

when viewing the site in French version. And :

English
French

when viewing the site in English.

Hopefully I explained the problem properly, I'll be very happy to know what to do.

I need help please.


texts: Staging process -- how NOT to overwrite user content/data @ DB push to Production site?

texts:
I've finally gotten my Drupal7 Development->Staging->Production file & db syncing all working nicely using a mix of rsync, rsyncd, git &, where it doesn't cause more/unnecessary work for me, drush.

Not the cleanest approach, but all working quite nicely.

Until i realized ...

a DB push from Staging->Production that contains changes I've made & QA'd @ my Staging site (for modules, site config, etc), will overwrite any/all user data/content @ the Production site. Unless, of course, I specifically identify & exclude the tables that contain data/content -- and simply don't inclue them in the push.

My question is -- other than manually checking -- is there a reliable method (a pre-existing static list?  a sql query on table names? something?) to know those tables to exlude?

This

How to migrate from test environment to production environment?
How to migrate from test environment to production environment?

in addition to countless other threads I have found, mentions "Features" and "Deploy", and basically says "it's hard".  If the answer's "in there", I haven't wrapped my head around it yet.

Again, I've got the mechanics working as I want them.  This last step is identifying -- and voiding overwrite of! -- the user content/data at the Production site.


texts: Override the region.tpl.php template for an internal path

texts:
I have a view which I want to output as plain raw data (no html tag, no div, nothing, just the view content as text).
I managed to override html.tpl.php, and page.tpl.php templates, but i still have some default markup...
I get this:

<div class="region region-content">

And don't know how to get rid of it.
I guess the region.tpl.php template is responsible for this, but how could I override it just for that given view (which has an internal path: user-export).

I tried region--user-export.tpl.php but my template is not seen by drupal.
Do I need to use a template suggestion ?

Thanks in advance!

EDIT: I found a solution.
Probably not the cleanest way but it works. I created a "blank" theme, where I overrode region.tpl.php by creating a file named region.tpl.php and stripping all divs and classes from it. I then downloaded the "Page Theme" module and set the template to "blank" for the view url.
And that was it. my view got displayed with no wrappers, no divs, just plain text.


texts:
In my custom content type, I want restricted the length of text entered in a text field. I want to check whether a user entered e.g. thousands of words. For this I tried this one but unable to achieve.

$my_field = field_get_items('node',node_load($nid, NULL, TRUE), 'my_field');
$my_field = substr($my_field,0,100).'...';
print $my_field[0]['value'];

Is there any way to do this in drupal 7 context?


texts: Has anybody figured out how to add videos to a node gallery?

texts: I've just finished building a node gallery image gallery system in drupal that lets my users add lots of photos easily to the site, and create their own galleries. However, I'd like them also be able to add video files. Node gallery says this is not available "out of the box" but possible, but I cant find any instructions on how to do this. I'm hoping someone out there has figured this out.. thanks in advance.


texts: Assign a class to an element dependent on multisite domain?

texts:
I need to have a special class for example for body element which will be showing me on which site from multisite installation I am in.
Here is a solution loading different css files but is there a way to have a simple class?


texts:
Following the amazing work @david-snopek posted:

Blog post - CiviCRM & D8,
David's StackExchange Post.

I spent the better part of last evening trying to get CiviCRM up and running on a Drupal 8.4 BLT project.

After trying a few different approaches, unfortunately I'm now seeing the following error when trying to enable the CiviCRM Core Module

  CiviCRM must be downloaded into the libraries folder.

No matter what I try, I can't seem to get the module to recognize that civicrm is installed.

Other things I've tried:

manually copying the [project_root]/vendor/civicrm-core into [project_root]/docroot/libraries/civicrm-core
Renaming libraries/civicrm-coreto libraries/civicrm
Modifying composer.json to try and install CiviCRM into the libraries folder:
Creating symbolic links to the folder (my least favorite attempt)

Here is the composer.json update for number 3 above:

    "require": {
    "acquia/blt": "^8.3",
    "phpoffice/PHPWord": "dev-zend-version as 0.13.0",
    "civicrm/civicrm-core": "4.7.25"
},

...

"repositories": {
    "phpword": {
        "type": "vcs",
        "url": "https://github.com/dsnopek/PHPWord.git"
    },
    "zetacomponents-mail": {
        "type": "vcs",
        "url": "https://github.com/civicrm/zetacomponents-mail.git"
    },
    "civicrm": {
        "type": "package",
        "package": {
            "name": "civicrm/civicrm-core",
            "version": "4.7.25",
            "type": "drupal-library",
            "source": {
                "url": "https://github.com/civicrm/civicrm-core.git",
                "type": "git",
                "reference": "origin/master"
           }
        }
    }
}

source: https://gist.github.com/mortenson/a5390d99013b5b8c0254081e89bb4d47

I think this has to do with an autoloader issue perhaps seeing that BLT does not use the Drupal composer.json file and the instructions @david-snopek posted were for the traditional Drupal installation method.

I was able to trace the error to modules/custom/civicrm-drupal/civicrm.install:125.

/**
 * Returns the path to where CiviCRM is installed.
 *
 * @return string|void
 *
 * Recommended location for civicrm is in /libraries/civicrm [citation needed].
 * We also allow /modules/civicrm, which seems to work fine.
 */
function _civicrm_find_civicrm() {
  if ($path = drupal_get_path('module', 'civicrm')) {
    if (file_exists($path . '/CRM/Core/ClassLoader.php')) {
      return \Drupal::service('file_system')->realpath($path);
    }
  }

  $path = 'vendor/civicrm/civicrm-core';
  if (file_exists($path . '/CRM/Core/ClassLoader.php')) {
    return \Drupal::service('file_system')->realpath($path);
  }

  return NULL;
}

Notes on my process:

I ran into a couple snags with the Gist David posted.

When running $ composer require 'phpoffice/PHPWord:dev-zend-version as 0.13.0', I noticed that Composer was trying to add the dependency as:

"require": {
    "phpoffice/PHPWord": "dev-zend-version",
    "as 0.13.0"
},

This failed but I was able to get past the issue by manually adding the dependency to the composer.json file as:

    "require": {
        "acquia/blt": "^8.3",
        "phpoffice/PHPWord": "dev-zend-version as 0.13.0",
    },

Unfortunately, I then got stuck on the next step requiring civicrm-core until I read the comment a bit closer. I believe this step is now incorrect as civicrm-core 4.7.25 has been released.

#Require civicrm-core at the requested version.
#TODO: Need to keep using my fork until 4.7.25 is released!
#composer require civicrm/civicrm-core:$CIVICRM_VERSION
composer require "civicrm/civicrm-core:dev-roundearth-$CIVICRM_VERSION as $CIVICRM_VERSION"

I was able to get past that issue by updating the additional repository via:
composer config repositories.civicrm-core vcs https://github.com/civicrm/civicrm-core.git

Reference:
https://www.mydropwizard.com/blog/how-install-civicrm-drupal-8-and-why-choose-it-over-pure-drupal-crm


texts: In which template file is a node title supposed to be?

texts:
I have to add a Title field to each content type to ensure a title appears on the node view.

This makes me wonder: Maybe I'm missing the title variable in my implementation of page.twig.html or something, but I don't see a title variable anywhere in the default page.html.twig.

In which template should my title variable be displaying?
What should the code in the template look like to display the title?


texts: Create a view with a list of webform without any submission by current user

texts:
I am currently stuck trying to build a view wich contains a simple list of webform's name not submitted yet by the current user so that the current user can only see a list of webforms to be filled.
How can this be accomplished?

I experimented a lot of settings but i couldn't get the expected result.
Any help would be much appreciated


texts: How to have a proper alphabetic pager with number support?

texts:
I'm trying to achieve an alphabetic pager with grouping of special characters + numbers.

All pagers available do 0|1|8|9|A|B|C, while I want 0-9|A|B|C or #|A|B|C, # being for special characters and numbers.

To illustrate it better, here is what I'm trying to achieve:

I'm using Drupal 6 and views 6.x-2.12.

I already searched a lot for this, and also tried asking here at http://drupal.org/node/908716, but I did not have success.

I don't mind solving this with "hackish" methods, but I'm not being able to come up with one of those.

Thank you, in advance.


texts: How to display one block among two block in Drupal?

texts:
I have two block (like Block1 and Block2) and I have to display one block among two. Condition is Block1 will be display into the whole site if Block2 is not present there. Block2 will be displayed into specific pages which is controlled dynamically, i.e. when user create content in future they can control the Block2 display. So I need to display Block1 where Block2 is not present.

I am using Durpal 7.

Note: I have tried with default block visibility but this is not worked for me either.


texts: Case difference of Usernames; how to login with Usernames regardless of case in Drupal 7

texts:
Quick question.

On my site, users have entered their username with capitalized case or mixed upper or lower cases during registration. Now when the Login, they forget that write everything lower cased and ofcourse that doesn't work making things difficult for me.

so my humble question is, how do I validate the login regardless of case?

Thanks a lot.


texts: Using the CodeMirror Syntax Highlighting plugin with CKeditor and the WYSIWYG module

texts:
I've installed the latest version of CKeditor and everything works great. However, I wanted to install the CodeMirror Syntax Highlighting Plugin to use it for my editor.

I downloaded the plugin: http://ckeditor.com/addon/codemirror
I extracted the plugin into the plugins directory
I added config.extraPlugins = '[ codemirror ]'; to the config.js file

When I go to the WYSIWYG Profiles section to enable the plugin, it is not there.

Has anyone successfully done this? I've also cleared the cache multiple times.


texts: How to Restrict Content OVerview to certain content types for user roles

texts: I have a user role called Athletics and I have given these users access to add, edit or delete the content type Athletes. However when the content type is created it just creates a node not a URL alias so the Athletics users can not navigate to a page to edit or delete. I tried giving access to the content overview but I think that would confuse my non-technical users. Is there a way to make it so they can ONLY see the content they can edit or delete within the content overview?


texts:
I created a custom form (adding some additional fields) using the Contact module from the core of Drupal 8.

When I submit the form is sent an email containing all values, but it is really bad formatted. The email only contains form's values without any field label and it is unreadable.

How can I customize the template of the email sent on the form's submit?

What I already tried

hook_mail_alter

I found some answer about the same problem for Drupal 7 suggesting to implement a custom hook_mail_alter function (for example: 1, 2).

So I created a custom module with my function:

/**
 * Implements hook_mail_alter().
 */
function mymodule_mail_alter(&$message) {

  // Process only 'contact_page_mail' messages
  if ($message['id'] != 'contact_page_mail') {
    return;
  }

  $params = $message['params'];

  // Body
  $message['body'] = [];
  $message['body'][] = t('Some custom message');

  // I don't know what should I do here?
  // How can I access values of all fields in the form?
  // ...

  return;
}

The function is correctly triggered before the email is sent, but I can't access field's values so I'm not able to build a custom email.

Also I can't get the form's id (only a generic 'contact_page_mail' valid on all contact forms) so I'm not able to handle different contact forms in this function.

Swift Mailer

As suggested in this other similar question, I tried with the Swift Mailer module.

After some effort, I'm able to get it working and now I have a swiftmailer.html.twig template file with this content:

<div>

  {{ body }}

</div>

But as for the hook_mail_alter solution, I don't know how to access form's field values so I can't customize the email format.

Moreover, the Swift Mailer module currently is an alpha version (8.x-1.0-alpha1) and the Mailsystem module (required to get things working) is a beta version. So I would like to avoid to install unstable modules on a production website (anyway this can be the last solution, if no other works).

EDIT

Thanks to @Berdir, now within the hook_mail_alter function I can access field values with:

$contactMessage = $message['params']['contact_message'];

// Value of 'field_my_field_name'
$contactMessage->get('field_my_field_name')->getString();

So I can put them inside the $message['body'].

Quite complicated, but it works.

Is there a way to get field values within the Swift Mailer template? I tried with {{ params.contact_message.field_work_with_us_name }} but it doesn't works.

What happen if I have two or more contact forms? The function hook_mail_alter will be triggered on all of them. Is there a way to have a specific function for each contact form?


texts: Distance / Proximity from cck location field ? not from user or node location?

texts:
I try to get a distance between cck location nodes / users but I didn't succeed at that point because the only avalaible views field to do that is  "EMPLACEMENT : DISTANCE / PROXIMITY" which concerns node location or user location, not cck location field.

How to get that point ?

Regards,
Yoann


texts: How do I redirect users to an external URL?

texts:
I implemented a controller class in Drupal 8, which redirects to an external site.  If I use \Symfony\Component\HttpFoundation\RedirectResponse, I get this error.

  Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it.

Using \Drupal\Core\Routing\TrustedRedirectResponse, I get this error.

  The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early.
  Returned object class: \Drupal\Core\Routing\TrustedRedirectResponse

What should I do?


texts: How do I programmatically generate an entity form?

texts:
I need to programmatically generate the entity form for my custom entity - basically get the same output that happens when you call

\Drupal::formBuilder()->getForm('form namespace')

When I try to do that with my entity form I get the error:

Call to a member function getEntityTypeId() on null in Drupal\Core\Entity\EntityForm->getBaseFormId() (line 77 of core/lib/Drupal/Core/Entity/EntityForm.php).

Really stumped on how to proceed.

Here's an obfuscated version of code I'm using

Entity Definition:

/**
 * Defines the My Entity entity.
 *
 * @ingroup my_module
 *
 * @ContentEntityType(
 *   id = "my_entity",
 *   label = @Translation("My Entity"),
 *   handlers = {
 *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
 *     "list_builder" = "Drupal\my_module\MyEntityListBuilder",
 *     "views_data" = "Drupal\my_module\Entity\MyEntityViewsData",
 *     "translation" = "Drupal\my_module\MyEntityTranslationHandler",
 *
 *     "form" = {
 *       "default" = "Drupal\my_module\Form\MyEntityForm",
 *       "add" = "Drupal\my_module\Form\MyEntityForm",
 *       "edit" = "Drupal\my_module\Form\MyEntityForm",
 *       "delete" = "Drupal\my_module\Form\MyEntityDeleteForm",
 *     },
 *     "access" = "Drupal\my_module\MyEntityAccessControlHandler",
 *     "route_provider" = {
 *       "html" = "Drupal\my_module\MyEntityHtmlRouteProvider",
 *     },
 *   },
 *   base_table = "my_entity",
 *   data_table = "my_entity_field_data",
 *   translatable = TRUE,
 *   admin_permission = "administer as my_entity entities",
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "name",
 *     "uuid" = "uuid",
 *     "uid" = "user_id",
 *     "langcode" = "langcode",
 *     "status" = "status",
 *   },
 *   links = {
 *     "canonical" = "/admin/structure/my_entity/{my_entity}",
 *     "add-form" = "/admin/structure/my_entity/add",
 *     "edit-form" = "/admin/structure/my_entity/{my_entity}/edit",
 *     "delete-form" = "/admin/structure/my_entity/{my_entity}/delete",
 *     "collection" = "/admin/structure/my_entity",
 *   },
 *   field_ui_base_route = "my_entity.settings",
 *   constraints = {
 *     "CustomContraint" = {}
 *   }
 * )
 */
class MyEntity extends ContentEntityBase implements MyEntityInterface {

Form namespace

namespace Drupal\my_module\Form;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for My Entity edit forms.
 *
 * @ingroup my_module
 */
class MyEntityForm extends ContentEntityForm {

Okay, so this is what I've found so far. User oknate's answer partially works; I also had to add a dummy function to my container form class to get around a callback error, which looked like this:

 public function processForm($element, FormStateInterface $form_state, $form)
  {
    return $element;
  }

This is probably not the right way to do this, but it does result in a form object that will render in another form.


texts:
This seems like it should be a simple operation, but I must be completely blind because I can't find anything about it in the API docs at http://www.drupalcontrib.org/api/drupal/contributions!og!og.module/7.

I have a $gid. I need to check if it really is the gid of a valid group, and have access to the group information if it is.

I did find an old post somewhere saying to use og_load(), but that is out of date -- that function does not exist in the current API. Nor can I find a function with similar functionality.

There has to be a simple way to do this; it's hardly an outlier use-case. What am I missing?


texts: How to manage catalog display of images for Commerce 2 product variation

texts:
I have created a custom product type and its variations are created with attribute 'Size'. If I create a new product with its multiple images, then the catalog view shows these multiple images instead of a single image.

Below is the Product type variation 'Manage display' settings.


texts: Weform: Send email to the email field in the node reference field using rules

texts:
I have content type Organiser. and it has an email field Organiser email.

I have created a webform and added a node reference component which is referencing the Organiser content type.

I want to send an email on webform submission to the email address entered in the Organiser email in referenced node.

Is it possible with rules without entering the php code in the rules action?


texts: Add rel="nofollow" to menu displayed by menu_block module

texts:
I am trying to add rel="nofollow" attribute to menu links output by the menu_block module.

My core menu is called Main Menu, which I do not want to modify as it is used for main navigation. However the product level of this menu is output in the footer by Menu Block module, and it is these links I want to add an attribute to.

Thanks.


texts:
I have an install of D7.9 that I can only access the admin tools with firefox. If I use IE, Chrome or Safari, I get "You Are Not Authorized to Access this Page" when I go to www.example.com/user and login.

Funny enough, if I try IE in compatibility mode it works fine, AND, if I try a different computer it works fine.

I've tried clearing all browser data, cookies, etc and it still won't jive..

Any ideas?


texts: Create multiple basic pages with different fields

texts:
I have a question to create a site in Drupal 8.

It is a website with about 60 basic pages, but each of them has different relationships, paragrphs, media.

My question is, how can I assign different fields per page and that the type of content does not grow monstrous? I am trying to reuse fields, but it has been very complicated for me.


texts: Redirect to last page visited on 404 error

texts: Just wondering if there is a simple way to automatically redirect users to the last page they have visited if they receive a 404 error? I am using Drupal 7.


texts: Display menu items of unpublished nodes to users without "Administer Content" permission

texts: I have a content editor who is building out a section. All the nodes are yet unpublished. The problem is unpublished nodes are not displayed in a menu. While this is correct behavior with a user viewing a site, the editing experience is lacking in that way. How can I build a representation of a menu of unpublished items?


texts:
I created a table with operations sorted by date. How to display a second array with the total transaction per month ?

I want to show by example the total in September 2016, the total amount of August 2016 ...

Table should display one line per month with the total amount of transactions.

The same month are not grouped :-(


texts: Why is my migrate source plugin (d7_file) not found for my migration?

texts:
I'm trying to write a migration for files from an old D7 site to a new D8 site, roughly following the instructions at https://www.previousnext.com.au/blog/migrating-drupal-7-file-entities-drupal-8-media-entities.

I have a myproject_migration module which includes the migration in its install folder.

myproject_migration.info.yml:

name: MyProject Migration
description: Migrations for existing MyProject content.
package: myproject
type: module
core: '8.x'
dependencies:
  - file
  - migrate
  - migrate_plus
  - migrate_source_csv
  - migrate_tools

config/install/migrate_plus.migration.furniture_files.yml:

id: files
label: Files from the old D7 site.
migration_group: myproject
dependencies:
  enforced:
    module:
      - myproject_migration
      - file
source:
  plugin: d7_file
  scheme: public
  constants:
    source_base_path: /
process:
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@source_full_path'
      - uri
  filemime: filemime
  status: status
  created: timestamp
  changed: timestamp
  #uid: uid
destination:
  plugin: 'entity:file'

I enable the module; run drush migrate-status and get:

exception 'Drupal\Component\Plugin\Exception\PluginNotFoundException'
...with message 'The "d7_file" plugin does not exist.'
...in /var/www/myproject/docroot/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php:52
Stack trace:
#0 /var/www/myproject/docroot/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryCachedTrait.php(25):
Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition(Array, 'd7_file', true)
#1 /var/www/myproject/docroot/core/modules/migrate/src/Plugin/MigratePluginManager.php(53):
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('d7_file')
#2 /var/www/myproject/docroot/core/modules/migrate/src/Plugin/Migration.php(335):
Drupal\migrate\Plugin\MigratePluginManager->createInstance('d7_file', Array, Object(Drupal\migrate\Plugin\Migration))
#3 /var/www/myproject/docroot/modules/contrib/migrate_tools/migrate_tools.drush.inc(471): Drupal\migrate\Plugin\Migration->getSourcePlugin()
...

I've been importing updates to this config with drush config-import --partial -y --source=modules/custom/myproject_migration/config/install/.

I can see the plugin in core\modules\file\src\Plugin\migrate\source\d7\File.php, with the id "d7_file". Running through the checklist at https://www.drupal.org/docs/8/api/migrate-api/migrate-source-plugins - it implements MigrateSourceInterface; it's annotated with @MigrateSource; it's in in the namespace subdir Plugin\migrate\source under the "file" namespace. So it's definitely there, and everything looks right, it's just not found.


texts: Display content by taxonomy term, including sub-terms

texts:
I'm looking at Drupal for the first time in a long time, with a view to using it in a project we're starting. This seems like a very simple question, but I'm struggling to find the answer.

If we have a taxonomy of website sections and associated sub-sections, like this:

News
    - Europe
    - America
    - etc
Products
    - Widgets
    - Doodahs
    - etc

If we have a menu linking to News it's easy to display content associated explicitly with that term, I'm not seeing how to include content associated with its sub-terms though. Is the conventional way of achieving this through...views?

Thanks,

Toby

Update: It looks like in previous versions of Drupal you could perhaps specify a term depth in your URLs. I guess this is what I'm after, but in Drupal 7


texts:
I have created a view that displays a term description, and links to add a post to that term. As you can see from the Interesting box here it works quite well.

on some tags though the links dont work at all including the edit node link i have on the view. You can see a non working one here.

This happens across all browsers. If i move my block to a position at the bottom of the page it seems to work ok. For the life of me i have no idea whats going on.

Could anyone suggest anything for me?


texts: How to install a local module file with drush?

texts:
I have a local environment I am working on and I want to use drush to install a local file/module I have that was created by a exported feature. The reason I am not doing it with update manager is because its giving me a ftp error and rather than try to solve that, I would rather bypass it completely with drush (and since drush is faster anyway).

So basically I have my main site in www/var/mysite

And i have the exported feature module in my home directory / downloads.

So how do I get drush to upload and enable my local file to my drupal site?


texts: I'm trying to remove the update notifications from the Drupal backend. I tried with Update notifications disable module but it breaks the "module" part of the backend. I can disable the Update manager module but i don't like this solution. Is there any other way to solve this problem?


texts: When I try to modify a view, I get a screen full of odd text

texts:
I have just installed views, and every time I attempt to change a setting (or cancel) I receive a white screen with paragraphs of strange info:

[{"command":"settings","settings":{"basePath":"\/forms\/","pathPrefix":"","ajaxPageState":{"theme":"blogon_responsive_theme","theme_token":"cD6VFX2j18jV0Gu1-xq10ADeBk_yP4V57yKYNYhNnhs"}},"merge":true},{"command":"viewsDismissForm"},{"command":"viewsShowButtons"},{"command":"viewsTriggerPreview"},{"command":"insert","method":"html","selector":"#views-tab-page","data":"\u003Cdiv id=\u0022edit-display-settings-details\u0022\u003E\u003Cdiv id=\u0022edit-display-settings-top\u0022 class=\u0022views-ui-display-tab-actions views-ui-display-tab-bucket clearfix\u0022\u003E\u003Cdiv class=\u0022ctools-no-js ctools-button ctools-dropbutton\u0022\u003E\u003Cdiv class=\u0022ctools-link\u0022\u003E\u003Ca href=\u0022#\u0022 class=\u0022ctools-twisty ctools-

CAn anyone tell me whats wrong and how to fix this?


texts:
Hello I'm using Drupal 6 and I've successfully finished with the site. However, after I uploaded the site to the server, I realised the the header image which is the logo is not showing even though the path is correct in the theme logo path.

Also there is a slide show which was made with Dynamic Display Block module and its images does not show up even though their path is present and correct.

The css style I applied to the three column under the DD Block is also not showing.

This still persists even if I change theme.

Does anyone know what's wrong under the hood?

Thank you


texts:
I want to show teasers of content posted to an OG group.  I want public and private groups, so the user must have view access to that group to see the content. I have a Group (named "Group") and a content type ("Topic") that users can post to the group.

I create a block in views and place it bellow content, then when the group is displayed the block is displayed.  Currently the block will show ALL content, I do not know how to show content for CURRENT GID. The GID is different then the NID (example nid = 3, gid = 1).

I installed Pathauto and gave the rule to group/[node:nid].
I then created a block and want the block to show all Group Content.  I set it only to display on group and group/* This is associated with og_members block & og_nodes block won't display content but unfortunately the individual did not mention his views filter (or contextual filter).
I can get all content to show up in this block, but I do not know how to filter the current nodes group id from the block.


texts: How to keep multiple drupal websites up to date

texts:
I do a lot of web consulting and drupal is my preferred tool of choice. But as I grow, it seems like drupal gets more and more needy. At least once a week, if not more, my inbox gets messages that drupal needs updating, and I have to go and update the dev server, verify nothing broke, and then update the production server, and again verify that nothing broke.

I'm using drush to help me with this, but this is still taking considerable time away from my business, time I could be billing to the customer.

Does anyone have a solution to this? Some way to automate the updates and then a regression test, and if successful, do the same on production?


texts:
I'm stuck with trying to get my head around entities, and as I was following This tutorial, I ran into some troubles with this page callback method:

 $projects = entity_load('project', array(1, 2, 3));

 if (!isset($projects[3])) {
   $entity = entity_create('project', array('id' => 3));
   $entity->name = t('Spring House');
   $entity->description = t('Some more lipsum.');
   $entity->save();
 }

 dpm($projects);

 return 'Some string';

Opening my page, I get

  Fatal error: Call to undefined method stdClass::save() in
  /Applications/XAMPP/xamppfiles/htdocs/expoline/sites/all/modules/demo/demo.module
  on line 52

This leads me to believe that my entity is never created. Any reason why this might be happening?

EDIT:
My hook_entity_info() function

/**
 * Implements hook_entity_info().
 */
function demo_entity_info() {

  $info = array();

  $info['project'] = array(
    'label' => t('Project'),
    'base table' => 'demo_projects',
    'entity keys' => array(
      'id' => 'id',
      'label' => 'name',
    ),
    'entity class' => 'Entity',
    'controller class' => 'ProjectEntityController',
    'module' => 'demo',
  );

  return $info;
}


texts: 'User Account' menu link does not show to anonymous users

texts:
When a user is logged in the User menu shows 'My Account' link and the 'Logout' link. However, when logged out the menu disappears.

How do I make a menu link to the user login page that only shows for anonymous users in the User Menu?

If Trey posted his comment as an answer, I would have checked it. I have disabled the block module since I use context. I created a second sitewide context that is triggered by the anonymous user role and placed the menu block with the link for login page in the user region. It works.

I still would like to see this accomplished in code. I tried to access the variables through preprocess functions but the menu links are already rendered by that time.


texts: I'm currently working on my first Drupal 8 project and while many things are now integrated in the core, others still stump me (for example restoring options to now bare bones CKEditor requires like 4 additional modules). As I relied on Taxonomy Display module to display different taxonomies with different views and this module is not ported to D8 while similar module TVI is still in beta, I am left wondering what's the current standard of handling this use case. I could use template_preprocess_views_view to programatically switch displays depending on vid. Some suggested you can just use contextual filters to do the same, but I don't see how could you switch between different displays using contextual filters. To me it seems that multiple views would run at once, but some would return empty result sets, spamming database with duplicated queries. Is there really no cleaner way to do it?


texts: How can a View be inserted in the .info description of the Backup and Migrate module?

texts:
Using Backup and Migrate (BaM) advanced option description field, I would like to include a view result in the BaM .info file.

The view I've set up uses Module/Theme/Theme Engine (ie system table) with filters.

System Type: Module (exposed filter with options Themes, All)
System Staus: Enabled (exposed filter with options Disabled)
System Module/Theme/Theme engine filename:
    Operator: Starts With (exposed operator for other options)
    Value: sites/all (as default value & exposed for other options)
System Version:

While core provides Module/Theme/Theme Engine filename, I also needed to add "Views System" module to get/parse versions from module.info tables into the view. The result is...

1 == admin_menu 7.x-3.0-rc4
2 == admin_menu_toolbar 7.x-3.0-rc4
3 == backup_migrate 7.x-2.8
4 == ctools 7.x-1.3
5 == views 7.x-3.7 +CSS
6 == views_ui 7.x-3.7
7 == views_system 7.x-3.2

For now, I copy/paste the view result into BaM (advanced) description before. Helps track modules and themes installed during development. Can this be automated or integrated?

Alternately, I see there is this API function called drupal_system_listing which might be an alternate technique.