texts: How to retrieve form entry for use as default value?

texts:
I'm building a form in a custom module, and I'd like to have that form show as it's default value the value that had been saved to the DB during the previous edit, but I have no idea how to do it.

Here is an example of one of my fields:

$form['savings_ages']['savings_age21'] = array(
'#type' => 'textfield',
'#title' => t('21'),
'#size' => 10,
'#maxlength' => 10,
'#default_value' => $whatgoeshere?,
);

My form is the basis for a calculator, so I've got over 80 fields and only ever expect to have 1 row's worth of information in my table.

I have no idea how to pull that out, so any guidance would be welcome. PLease let me know if I need to provide more detail.

EDIT:
I'm still stuck on this, my normal query works when I test in the sql window of PHPmyadmin:

SELECT `factors_age21` FROM `savingfactors` WHERE 1 limit 1

but I can't seem to convert it to the correct format to work with db_query function and echo it out as the default value of my form field. PLus I'll still have to make this query 44 times (I have 44 columns) so if there is a more efficient way, I'd appreciate it.

Second Edit:
I'm starting to get a partial result, but it's still wrong.

$sql = "SELECT factors_age21 FROM {savingfactors} WHERE factors_age21 LIMIT 1";
$res = db_query($sql);
$item = db_fetch_object($res);

//later
$form['savings_factors']['factors_age21'] = array(
'#type' => 'textfield',
'#title' => t('21'),
'#size' => 10,
'#maxlength' => 10,
'#default_value' => print $item,
);

It IS producing a result, but it's showing me the number "1", when my correct value is "14"
any help is appreciated.

Thanks
Stephanie


texts: RedirectResponse not able to redirect in hook_entity_view drupal 8

texts:
I am trying to redirect users to a page on entity view. I am using RedirectResponse in hook_entity_view. But it is not redirecting to the desired page.

This is how I implemented this.
After fetching my redirect url, I have passed it to RedirectResponse.

return new RedirectResponse($redirect_url);

Thank you


texts:
I have a strange problem. This is my code:

function bd7_services_services_resources() {
  return array(
      'get' => array(
        'index' => array(
          'help' => 'Ritorna le immagini inserite.',
          'callback' => 'bd7_services_get_immagini',
          'access callback' => 'user_access',
          'access arguments' => array('access content'),
          'access arguments append' => FALSE,
        ),

          'actions' => array (
            'immagini' =>
              array(
                'help' => 'Ritorna le immagini inserite.',
                'callback' => 'bd7_services_get_immagini',
                'access callback' => 'user_access',
                'access arguments' => array('access content'),
                'access arguments append' => FALSE,
              ),
          ),
          'operations' => array(
              // Define the index callback for a GET to /cart.
            'immagini2' =>
              array(
                'help' => 'Ritorna le immagini inserite.',
                'callback' => 'bd7_services_get_immagini',
                'access callback' => 'user_access',
                'access arguments' => array('access content'),
                'access arguments append' => FALSE,
              ),
          ),

      )

  );
}

If I call "rest/get" all works.

If I call "rest/get/immagini" I receive "404 Not found : Could not find the controller."

If I call "rest/get/immagini2" I receive "404 Not found : Could not find the controller."

Where is my error ?
"rest" is my "Path to endpoint".

Thanks.


texts: Override html.twig.html within custom module

texts:
According to this Drupal 7 answer, I'm looking for a Drupal 8 solution to simply print the page content within a custom html.twig.html.

namespace Drupal\custom_module\Controller;

use Drupal\Core\Controller\ControllerBase;

class CustomModuleController extends ControllerBase {

  public function content() {

    return [
        '#theme' => 'custommodule_page',
        '#type' => 'page',
    ];
  }
}

This approach seems to be working, but I am not sure how I can remove the core and theme CSS components.


texts: For each row in a view, show a list of entities with entity reference field pointing to that row's content?

texts: For instance, say I have an Author node and multiple Books with entity-reference to that Author. How can I make a view showing each author with a list of their books?


texts: How can I use some Javascript to force a fieldset to stay open

texts:
How can some Javascript or CSS be used to keep a field set open when the page is refreshed?

I am using a module with a form in a fieldset that is automatically closed whenever the page is opened or refreshed. I don't want to touch the module code or write a module to fix it. Is there some Javascript or CSS that can be used to fix it, ie like CSS Injector or Javascript injector?


texts: Disable pre-emptive validation of empty textfield

texts:
On my form I have some fields and I set form['#required_error'] to generate a message on empty fields.
Works OK on select and option fields, but not on textfields.

It seems there is a (kind of ajax) validation before, which gives a pop-up with "fill in this field".

How can I disable pre-emptive validation of empty text fields, so that I can generate my onw messages


texts: Feed Import Products ( Commerce ) and Products Category ( Node Page )

texts:
I need to create a CSV feed importer to import both Commerce products and products category node using single table and I am using Commerce Feed Module... when I create it using two different tables I can easily achieve it using Feeds Tamper Module (using explode plug in)

But when I implement single table structure as mentioned in the image... since the title is not unique it creates multiple nodes for each product... Is there any other table structure to implement this..

But what I actually need is:

Display1- A, SKU1|SKU2|SKU3

Display2- B, SKU4|SKU5|SKU6

Display3- C, SKU7|SKU8|SKU9

Is there no one familiar with this or done this before.. ??  or else I have to refine the question.. ??


texts:
I'm trying to test a method that makes an HTTP request via Guzzle, so I can see if my code that filters that response is working. I have a mock json response in a json file that I want to use to test it. This is simply a saved version of an actual response.

I know you can mock methods e.g. this would override the get method to return a mock Guzzle Response. How do you mock a Guzzle response in Drupal 8?

    $this->mockHttp->expects($this->any())
      ->method('get')
      ->willReturn($mockGuzzleResponseShouldGoHere);

The mock Guzzle response needs to have a mock method getBody so I can do something like this:

$this->mockHttp->expects($this->any())
      ->method('getBody')
      ->willReturn(__DIR__ . 'Mocks/membership-classes.json');

and make sure that getBody returns my mock json file.

Method to test that makes a Http Guzzle request

<?php

/**
   * Call the GetMembershipClasses service.
   *
   * @return \Symfony\Component\HttpFoundation\JsonResponse
   */
  public function getMembershipClasses() {

    try {
      // Load configuration for this module.
      $response = $this->http_client->get(
        $this->getBaseUrl() . '/2014/06/membershipClasses', [
          'headers' => $this->getAnonymousHeaders(),
        ]);

        $response = json_decode($response->getBody());

        // Get to the meat of the response.
        $response = $response->GetMembershipClassesResponseMessage->MembershipClasses->MembershipClass;

        // Validate returned data.
        $filtered = array();
        foreach ($response as $membership_class) {
          $membership_class->MembershipClassCode = $this->removeSpaces($membership_class->MembershipClassCode);
          if ($membership_class->IsActive === TRUE) {
            $filtered[] = $membership_class;
          }
        }
        return new JsonResponse($filtered);
    }
    catch (RequestException $e) {
      return $this->handleError($e);
    }

  }

And the test class

<?php

/**
 * Class RouteControllerAnonymousTest.
 *
 */
class AnonymousWebServicesTest extends UnitTestCase {

  /**
   * Mock of http_client service.
   *
   * @var \GuzzleHttp\Client
   */
  protected $mockHttp;

  /**
   * Mock of state service.
   *
   * @var \Drupal\Core\State\State
   */
  protected $mockState;

  /**
   * Mock of config.factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactory
   */
  protected $mockConfigFactory;

  /**
   * Set up method which is called before any tests are
   * run. Mocks of the services that the class being tested rely on are
   * created.
   *
   * @return void
   */
  protected function setUp() {

    parent::setUp();
    $mockHttp = $this
      ->getMockBuilder('GuzzleHttp\Client')
      ->disableOriginalConstructor()
      ->setMethods(['get', 'getBody'])
      ->getMock();
    $this->mockHttp = $mockHttp;

    $mockState = $this
      ->getMockBuilder('Drupal\Core\State\State')
      ->disableOriginalConstructor()
      ->getMock();
    $this->mockState = $mockState;

    $mockConfigFactory = $this
      ->getMockBuilder('\Drupal\Core\Config\ConfigFactory')
      ->disableOriginalConstructor()
      ->getMock();
    $this->mockConfigFactory = $mockConfigFactory;

  }

  /**
   * Test the getMembershipClasses method.
   */
  public function testGetMembershipClasses() {

    // This needs to mock a Guzzle response from a get request
    $this->mockHttp->expects($this->any())
      ->method('get')
      ->willReturn('The mock guzzle response should go here);

    $this->mockHttp->expects($this->any())
      ->method('getBody')
      ->willReturn(__DIR__ . 'Mocks/membership-classes.json');

    $anonymousWebServices = new AnonymousWebServices(
      $this->mockHttp,
      $this->mockState,
      $this->mockConfigFactory
    );

    $membership_classes = $anonymousWebServices->getMembershipClasses();
    var_dump($membership_classes);
    // Insert some assert statement here

  }

}


texts:
How do I query the database when using PHPunit? This is my current attempt.

 /**
   * Testing to see if table is installed
   */
  public function testTableTest() {
   $connection = $this->getMock('Drupal\Tests\Core\Database\Stub\StubPDO');
    //-- What do I do next to query the database

    $query = $connection->query("SHOW TABLES LIKE {does_my_table_exist}");

    $expected = 'does_my_table_exist';
    $result = $query;
    $this->assertEquals($expected, $result);
  }


texts: Differentiate between same nodes in Drupal Autocomplete Search

texts:
I have implemented Autocomplete Search functionality. Autocomplete suggestion will be available based on characters typed in textbox. When user selects a suggestion then user will be navigated to the page.

Now I want to know that if any website contain same name then how to distinguish between these two.

Example - Website contain 4 Names of Person:- Sandy, Siren, Anita, Sandy.
When user type S in text field then 3 suggestion appear i.e - Sandy,Siren,Sandy.

How to distinguish between two "Sandy" using Drupal default Autocomplete feature.


texts:
My main username is 'bw_admin'. If I visit my login page at localhost:8888/mysite/?q=user I would be able to login but after my login I can't view the account page. Instead I get a HTTP500 internal server error. What I notice it that the underscore of my username is being deleted automatically so I would be getting localhost:8888/mysite/?q=user/bwadmin instead of localhost:8888/mysite/?q=user/bw_admin.

after getting the error if I would just edit the bad URL into the URL of the mainpage of the site I can go on while logged in as admin. But it's important for future user to not have this problem so they won't panic

Here's a list of the modules that I've installed in case this might be a typical problem related to a certain module.

addthis
addtoany
admin_menu
advanced_help
auto_nodetitle
autoload
cck
content_profile
context
ctools
devel
devel_themer
fckeditor
filefield
google_analytics
image
imageapi
imagecache
imagefield
imce
imce_wysiwyg
insert
jquery_ui
jquery_ui_dialog
jquery_update
lightbox2
menu_breadcrumb
module_filter
nice_menus
oauth
panels
pathauto
token
twitter
views
webform
wysiwyg
wysiwyg_imageupload


texts: How can I make a usable backup of the site on CD?

texts:
The client would like to archive off a copy of their drupal 7 site every 6 months or so. By archiving, they are referring to copying the site (in a usable format) onto a cd.

What are some of the options for doing this?


texts:
I'm looking for the .htaccess file that should be in the default installation of Drupal 7.

Normally it is supposed to be there. Does anyone know where it is located?


texts: Anyone any good reference about the variables available in the view template?

texts: Tried to print variables in view template, but the print-out is huge,deep-nested and recursive... crazy thing... Just can't drill down to the rendered_fields array, which seems to be just what I need. Is there any comprehendable reference anywhere?


texts: field collection items are not in panels

texts: Im trying to use Panels to display a Field collection but it looks like it is not in the overlay (see screenshot). How can I display the field collection in my panels?


texts: displaying field from node on page in url in block

texts: I want to put a link in a block which will pull its url from a url field in the node being displayed on the page on which the block is. Meaning, the block will contain a different url for each different node-info page. How can I reference this node in the block?


texts: Change the path for the flexslider slides

texts: I am trying to change the path that the flexslider uses for its slides.  The upload area for the new slides is in one place and the directory that the flexslider displays the slides from is in another.


texts: Change url of nodes in the past - Pathauto; Date module

texts:
I have a content type that includes the date module as a field type. Some of these nodes have the date set in the past and some in the future.

I have been able to have only the nodes that have the date set in the past to appear in a view

What I'd like is for these nodes to have a different url set to the other nodes in the same content type.
For instance Pathauto may assign these nodes a url of

www.example.com/node-1

Once this node's date is in the past I'd like it to automatically appear at something like

www.example.com/past-nodes/node-1

The previous url /node-1 would redirect to the new /past-nodes/node-1 url.

Where www.example.com/past-nodes/ would be the view of past nodes as in the third image.

The breadcrumb trail should also reflect this e.g. home >> past-nodes >> node-1

Thanks,
Tim


texts: Extended default form inside block, possible?

texts:
Ok. So I have a content type, let's say "My favorite places".
So naturally Drupal has a form to create new "favorite place" at node/add/my-favorite-places which appears as a page. I managed to create a customized template for this form my_favorite_places-node-form.tpl.php following this very helpful thread.
How do you theme a content type's create/edit form in Drupal 7?

I'd like to use this form in several pages on my site. So I was thinking to make it into a block. In below mockups, My favorite places = Content Type A.

However......
I had some experiences customizing front page for anonymous users showing login & register form at the same time, which doesn't run properly with a block (messaging issue). An expert mentioned that form rendering calls should never be fired from inside blocks.

So, I was wondering whether this is a good idea. And if so, how should I do that, if possible without installing another contrib module.

Please advise. Thanks.


texts:
I have been trying to implement popup forms that load dynamically, which initially seemed pretty easy. My current method is to echo the form from a menu callback, and insert it where needed with js. The problem I have been having though, is that any ajax controls (or submit) within the form require the ajax behaviour to be rerun on the added form.

On the surface this can be solved by simply running Drupal.attachBehaviors() after inserting the form, however the ajax system utilises the Drupal.settings built by the drupal renderer. As the settings information isn't passed with my form, my only solution is to send both the form and settings as json, and fiddle with the settings to make them match the required format.

Is this the only way to go about it, or is there a much simpler way I am missing?


texts: Embedding content in a panel ctools plugin- any other options

texts: instead of using views, on some occasions, I want to write custom code to display a list of content. I know how to create ctools content type plugins, and in here I could create my EntityFieldQuery to display my content and allow it to be embedded. I was wondering if there are any other options for making my custom code available for embedding in a panel other than creating a ctools content type plugin as mentioned. Ctools content type plugin feel a little  verbose for for the task...


texts: Aegir fails on verify task after import task (Import an existing not aegir site)

texts:
i'm having many problems with importing sites into aegir hosting system:
here is what i do to import a web site into Aegir:

import the directory of the web site into platforms dir
import the DB into the db of Aegir
create a dir in the sites dir calling it with the domain of the site.
cp -r sites/default/* sites/
cp -r sites/all/* sites/
from Aegir fron-end create the platform giving it the path of the root website dir
Aegir verify plaform and detect the site to be imported.
Execute the import task with success(i think here is the problem)
The task import has a success result (but i think is did not work because the scope is a wrong scope, it takes the main scope of aegir).
then the verify task fails, did not create the vhost.d/ , it didn't create drushrc.php file under the sits/.

i think the problem is:
when drush overwrite settings.php and try to store the information of the DB access in the apache environment it fails.
i don't know why...i already made many imports (last one was one week ago), i don't think i changed any thing.

please help me!


texts:
I'm creating the theme with two styles, dark and light. User can choose which style he wants in theme settings. My default theme logo is in the root of the theme.

Now I want to change default logo according to choosen style, so if the user choose dark style and doesn't set logo image, default logo is logo.png form theme root, but if user choose light style and doesn't set logo image, default logo is logo_light.png from theme root.

How can I override default logo according to result from theme_get_setting?


texts: Why is Drupal urlencoding in tpl output?

texts:
In Drupal 7, I have

<?php print $some_content; ?>

in page.tpl.php and when the string $some_content contains a URL (i.e., <a href="some-url?parameters=1|2|3|5"> ... )

the URL gets urlencoded and parameters is shown as:

parameters=1%7C%7C2%7C3%7C5

where | is substituted by %7C. For aesthetic reasons I want Drupal to stop this conversion, but even if I try with urldecode(), it does not work, as it seems to be hard-coded on Drupal core itself.

How can I override this which is just a simple line in pure PHP?


texts:
I want to allow anonymous users to create nodes, and their email address (entered by them into a field) will show on the node view as 'anonymized'.

The idea is that anyone can enter an email address, and the page will show an email address that looks something like "siouent-12393@this-site.com", which automatically forwards to the actual person's email.

Are there any modules for doing this? I have seen something about tokens for the email field, but I think that is not the right direction.

Does this require some deeper server system?


texts: Is there a way to quickly disable caching for all views? (for dev work)

texts:
Is there a variable/other way to quickly disable all views caching when working on a dev server?  I have a lot of views which have different caching settings, and there are times when I am doing testing that I would just like to turn all views caching off, similar to the way that you can turn CSS/JS aggregation off.

I found that the Views module itself has its own cache in the documentation, but this is not the caching for individual views-- and the caching for each individual view is what I want to turn off.


texts: How to define permissions in a Menu Deriver?

texts:
Pre-note: usually my questions aren't as vague as this one. This time though I am pretty lost in the lack of documentation, so I think I don't even completely understand the context of what I'm asking.
I am looking into code that wasn't written by me and it builds a menu using a Deriver (Drupal\Component\Plugin\Derivative\DeriverBase). It's method getDerivativeDefinitions creates a list of links. The actual menu is then loaded in the page using a block.
Now the menu that's being build is a menu of static links. Some of the links require that the user either has certain permissions, or has certain account checkboxes ticket.
Currently these checks are being performed inside the getDerivativeDefinitions method, but that doesn't seem to work because the method is called once during a cache rebuild and then no more.
Adding user as a cache context doesn't seem to change anything.
Example code:
  public function getDerivativeDefinitions($base_plugin_definition)
  {
    $links = [];
    if (!$this->account->isAnonymous() && !$this->account->get('field_something')->isEmpty()) {
      $links['Some link'] = 'https://some-url';
    }
    if (!$this->account->isAnonymous() && $this->account->hasRole('some_role')) {
      $links['Something'] = 'https://some-link';
    }

    $menu = [];
    foreach ($links as $key => $link) {
      $menu['app_links' . $key] = [
          'title'     => $key,
          'menu_name' => 'menu-name',
          'url'       => $link,
          'options'   => ['attributes' => ['target' => '_blank']],
        ] + $base_plugin_definition;
    }

    return $menu;
  }

I would expect the actual link definition to have some kind of access-callback key or something like that, but I can't find that either.
Does anyone know how to fix this?


texts: Change the node edit link for a specific content type

texts:
I want to be able to change the node edit link from node/[nid]/edit to my_custom_module/[nid] for just one content type. Which hook sould I implement?

I need this change to be applied to all the node edit links present on the frontend and backend of the site.

I tried implementing hook_menu_link_alter but this hook does not provide me any node-related data so I can not apply the link changes just to one content type.


texts: field_group: the save button is now in the wrong place

texts: I am using the Field Group module to group my content input fields in my add and edit node pages.  After adding a few groups, I noticed that the Save / Preview buttons moved from the bottom of the page, to a position between my un-grouped content and the groups that I have just created.  How do I move the buttons back to the bottom of the page?


texts: Creating custom settings/variables for site

texts:
I created a custom Form from a module in Drupal 8. Here is the code:

class SocialSettingsForm extends FormBase {

    public function buildForm(array $form, FormStateInterface $form_state){
        $form['facebook'] = [
            '#type' => 'textfield',
            '#title' => $this->t('Facebook Username'),
            '#description' => $this->t('Enter your facebook username.'),
            'required' => FALSE,
        ];

        $form['actions']= [
            '#type' => 'actions',
        ];

        $form['actions']['submit'] = [
            '#type' => 'submit',
            '#value' => $this->t('Submit'),
        ];

        return $form;
    }

        public function getFormId(){
            return 'social_socialsettingsform';
        }

         public function validateForm(array &$form, FormStateInterface $form_state){
            $facebook = $form_state->getValue('facebook');
            if (strlen($facebook) < 5){
                // Set an error for the form element with a key of "title".
                $form_state->setErrorByName('facebook', $this->t('The username must be at least 5 characters long.'));
            }
         }

         public function submitForm(array &$form, FormStateInterface $form_state) {

            $title =$form_state->getValue('facebook');
            drupal_set_message(t('You specified a title of %title', ['%title' => $title]));
         }

    }

The form works fine. But I'm not sure which direction and conventions to follow in order to make use of the user's input.

I would like to make use of the username the user enters, but I'm not sure how to store that input from the form. Ideally I would use these settings in a Twig template or a module.

UPDATE:
I have figured out how to add custom variables to my theme but I'm not sure how to get my form to access them. I was able to add

function mytheme_preprocess_page(&$vars){
    $vars['facebook'] = 'default';
}

But I'm not sure how to get my form to alter this variable.


texts: Views exposed taxonomy filter - show only terms within results

texts:
I have a block display with an exposed 'term' filter using BEF links filter.
I have the need to reduce the terms to display only the ones that show within the blocks results.

For example I have 'term1', 'term2', 'term3' - then if within the results there is only 'term1', 'term2' - I need to remove 'term3' from the list of filter links.

I realize that the filter is built before display so I am having difficulty grasping how the filter can be modified depending on what is in the display.

Any help is much appreciated.


texts: Find matching fields between content types and create new nodes

texts:
I'm working on a project that collects information about a corporate client and then based on the information provided, connects that client with other companies that can help them with a specific need.

I have worked through the first half of the project to collect data conditionally based on the type of industry/operations the company is involved with using rules.  Now i need to use the information collected and filter a view to find matching companies.

Essentially once a client submits their finalized application (a collection of different fields within a handful of content types), behind the scenes I need to figure out a way to filter a view of other companies with matching characteristics, then for each company that matches the filtered view, add a new  node within a separate content type and then entity reference that node back to the finalized application for further input/editing.  Here is a simplified visual:

Most of the fields being filtered are taxonomy references; however, some would be numeric inputs filtered by a less than, greater than, or equal to filter.

Financials Taxonomy: good financials; so so financials; challenged financials

Industry Taxonomy: technology, manufacturing, real estate, etc...

"Client A" node field answers in Clients content type:

good financials (financials taxonomy reference)
focused on technology (industry taxonomy reference)
50 employees (numerical field)

Companies content type contains the following nodes:

Company A: likes only challenged financials; focused on manufacturing; works with companies <100 employees
Company B: likes only good financials; focused on technology; works with companies <500 employees
Company C: likes only challenged financials; focused on manufacturing; works with companies <25 employees
Company D: likes only good or challenged financials; focused on manufacturing; works with companies <100 employees

Once client A selects a field indicating the answers are finalized and the content type Clients is saved, I need to find a way to have the matching companies filtered based on client A's answers, and a new node for a different content type (content type called Partner Details) should be created for each matching company.

That content type would be called Partner Details and would consist of the following fields for each matching company:

entity references the client content type
entity references the matching company to the client
custom blah blah blah entered by rules that indicates why the match makes sense
contact information from the company content type
etc., etc...

So to sum up, client A answers the questions noted above within the client content type, then based on that information, the data within the Companies content type would be filtered - and for this example - two new nodes of Partner Detail content type would be created because nodes in the Companies content type matched the fields that Client A answered in Clients content type. Company B and Company D matched the criteria so they would be entity referenced by the two new Partner Details nodes created. This way, Client A could log in and see their matches and edit the matching partner details and view information about Company B or D based on their entity referenced nodes.

I have an intermediate understanding of views, panels and rules, but can't seem to figure out how i would do this behind the scenes once a user indicates the application is finalized. I also have an understanding of how to use rules to create new nodes and entity reference them. Hoping for a step by step example as detailed as you can provide.  Any help is greatly appreciated. Thanks for bearing with my long winded explanation, hopefully that makes some sense.

(Finally, I had no idea what to title this question so if anyone has a better suggestion, let me know and I'll change it.)


texts: limit amount of upload images (through imagefield module) to only 1 by code/programmatically

texts:
I use image field with possibility to upload unlimited images. BUT under the user registration, I want to limit the possibility to just one image. So that the anonymous user, who wants to become a registered user, can only upload one image. After they become users, then they can upload as many images as they wish.

Does anybody know how to do that?


texts: Is it possible to override configuration with yml files?

texts:
Override configuration guide shows how users can override configuration with global $config variable, for example by using settings.php file (the same method as for D7).

But is it possible to override the configuration in a similar way but with yml file? It's much more convenient to use yml instead of php to override settings.

A real life example: let's say my module offers some configuration but I don't want to expose it via UI. I only want users to be able to change the settings via yml files (there are reasons for that). Obviously they shouldn't change my modules yml config file. Can they create a new yml file, name it accordingly (how?) and put inside sites dir?


texts: Contextual filter on Views Block file not found

texts:
I am trying to use a views block with a contextual filter for taxonomy terms to create an index that can filtered based on terms in the URL.

This works fine with a views page: so if the URL is /my-index then I see all the sub pages. And if the URL is /my-index/apples I see all the sub pages tagged with apples.

Now I when I make a block the same as the page view described, I understand that the block does not have a source for the contextual filter, so I have to provide a filter value. I have tried all the settings, but the problem seems to be that when using a views block and the URL is /my-index/apples I get a file not found error. With /my-index I get the full list as expected.

The filter works in preview mode, and if say I set the Default Value to Fixed Value=apples, is works at URL /my-index (filtered for apples as expected), but when URL is /my-index/apples then again I get file not found error. Then if I change the filter value to 'Display all results for specified field' I get the same result i.e. /my-index shows all and /my-index/apples gets file not found.

It seems to me that when the URL is /my-index/my-term it is not getting to the /my-index page to run the views script in the block. So I cannot connect the page URL to the block because I am not getting to the page at all when I add my-term to the URL.

I have set up a new alias for the page and tried new terms in case there is some sort of clash somewhere but to no avail.

The answers provided at Contextual filter with a block view did not seem to help. I tried every setting in every combination several times.


texts: Composer download Drush 9 - But conflict errors

texts:
I just installed drush 7 and 8 in their own directory under /usr/bin as drush7, drush8 commands. Now I'm trying to do the same for drush9, but I'm getting a conflict error during the composer download of drush 9. How can I resolve this to only download the 9.x version?

The command I used was: composer require drush/drush:9.*

I got this idea of using all the drush versions from:

https://www.lullabot.com/articles/switching-drush-versions


texts:
I see extensive Drupal 7 documentation for the Flags module, but very little for Drupal 8.
I have a Signup flag on a Drupal 8 node (which is an event). I need to suppress the Signup link when a number of signups (flags) have been added to this node.

I'm trying with hook_preprocess_flag() using the following code.

$flag_service = \Drupal::service('flag');
$flag = $flag_service->getFlagById('signup');

What call gets the flag_count of that flag?


texts: How do I show nodes/articles with specific taxonomy on a page?

texts:
Maybe the title is not appropriate, so please dont hesitate to change it or give suggestions for it.

Here's how our Drupal site is done:

A vocabulary called "PAA".
With this vocabulary there are many terms organized like this:

PAA
  |
  \-- MainTerm01
  |   |
  |   \-- SubTerm01
  |   |
  |   \-- SubTerm02
  |   |
  |   ...
  |
  \-- MainTerm02
      |
      \-- SubTerm03
      |
      \-- SubTerm04
      |
      ...

Then we have tons of articles that are associated with only one MainTermXX and only one SubTermXX (whatever XX is).
Here's what we'd like to do: make a page where we can search for a term (either MainTermXX or SubTermXX) and display all articles that are associated with the term.

My question is: is there a way to do this easily (= is this native in Drupal, just configuration) or will I have some work to do about this?


texts: Is there a way to temporarily disable multilanguage selector links when a page doesn't have a translation?

texts:
Currently when a basic page doesn't have a translation and you click on a different language in the multilanguage switcher it shows you the page in the same language. This causes a lot of duplicate content on the website which is bad for SEO.

How can I make sure the multilanguage switcher link to a different language shows up when the article is actually translated and disable the link when it isn't? Is there a way to configure this?


texts: Boost Module: Delete Cache for single node on update

texts:
I use Boost module for Drupal Commerce.
How can i clear the cache for only one cached node after updating that node.
I don´t want to clear the cache for all nodes but only for the one i updating.


texts: Couldn't create range_filter for search index(commerce price)

texts:
I'v a Search Api indexing server, I've added an index for price on it, and I want to create a price range filter on my created view.
I've added the price to the CONTEXTUAL FILTERS on my created view, but when i go to the contextual_range_filter configuration page (admin/config/content/contextual-range-filter), I couldn't see the indexed price field, so I couldn't use the contextual_range_filter.

Note : I need to use Contextual Range Filter module to be able to use the filters with services.

How to make it work by default?


texts: How add a custom page template for an article node

texts:
Hi I want to create an article then define a alias path for it then change template of that page. For example I add an article with title "categories" and no other content like body or image. Then I define "categories" alias for it. Now when I add "page--categories.tpl.php" in my theme template folder nothing happened to page
    http://example.com/categories
and I just see a white page in content region.


texts: drupal 7, how to use variables inside THEME_file_link() function

texts:
I have library website and site managers can upload the book and visitors will be able to download them. I list books in a page view of library content type and I need to have information and properties of the uploaded file (using drupal 7 default file field). this is my function to find the file properties:

function MYTHEME_file_link(&$variables) {
kpr($variables);
}

and this is one of the results

by this code

function MYTHEME_file_link(&$variables)
{
    print $variables['file']->filename;
}

it prints the filename but

I tried this

function MYTHEME_file_link(&$variables)
{
    $name = $variables['file']->filename;
        $variables['name'] = t("$name");
        $variables['name1'] = $name;
        $variables['test1'] = "1111";
        $variables['test2'] = t("2222");
}

and then these codes <?php print $name."  ".$name1; ?> and <?php print $test1."  ".$test2; ?> didn't output the values.

there are two pages, page--library.tpl.php which library__view is embedded inside it and views-view-fields--library__view--page.tpl.php I output variables inside views-view-fields--library__view--page.tpl.php page

why can't I use defined variables inside the file_link() function?


texts:
I have views in a dropdown which hold my content lists, the issue is I cannot add specific content to a specific view.

I have 2 views; Current affairs and Education, I want to add content to a specific view; lets say to the Discussions view but when I add content it is added to both my views here are snips

I decide to add "PK Chishala Bana Mulenga" and "Child Labour, How can we alleviate it?" but I find them in both the Current Affairs view and Education view anyone who knows how I can solve this issue?


texts: How to add a view for a node with an ID?

texts:
I have a simple blog application and would like to add style my nodes with views. More specifically I want to style node/nid path and when I point that in the views configuration, it only works if I type: http://example.com/node/3/3 but if I type http://example.com/node/3 it doesn't work. How can I make the nodes view work with the id being pointed out only once?

If my frontpage is called /content then that would be the path I would point out in the views configuration. In this case, however, I am trying to style an opened node - t.i. where the path is node/id . Everything works fine if I type node/id/id in the adress bar, but not if I type node/id . As the path for that view I have done so: PAGE SETTINGS Path:/node/%


texts:
I have some errors when I try to validate my content, I add a lot a modules at the same time, and I don't know witch module causes this error. I uninstalled some of them without success, Is it some explanation in the following errors for the specialists you are?

Notice : Undefined property: stdClass::$is_new dans node_save() (ligne 1108 dans /var/www/V1/modules/node/node.module).

Notice : Undefined property: stdClass::$is_new dans node_save() (ligne 1134 dans /var/www/V1/modules/node/node.module).

Notice : Undefined property: stdClass::$is_new dans node_save() (ligne 1140 dans /var/www/V1/modules/node/node.module).

PDOException : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'nid' cannot be null: INSERT INTO {location_instance} (nid, vid, uid, genid, lid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => [:db_insert_placeholder_2] => 0 [:db_insert_placeholder_3] => cck:field_endroit: [:db_insert_placeholder_4] => 9 ) dans location_save_locations() (ligne 1132 dans /var/www/V1/modules/location/location.module).


texts: Does DRUPAL_CACHE_PER_PAGE count pager pages (i.e. frontpage?page=3)?

texts: I guess my whole question is pretty much in the title... I'm wondering if blocks that use  DRUPAL_CACHE_PER_PAGE get cached on pager pages (i.e. mysite.com/frontpage?page=3), or if the pager query is disregarded (so the block would only be cached once for frontpage, frontpage?page=2, frontpage?page=3, etc.)?


texts: hook_preprocess_page(): how to tell a views page?

texts:
Im writing a custom module that need to insert some javascript and css files only in a Views page.

Im using hook_preprocess_page, but I can not tell if the current page is from a view:

function mymodule_preprocess_page(&vars)
{
    var_dump($vars); //output: nothings that reference the views!
    if([view page])
    {
        drupal_add_js([...]);
        drupal_add_css([...]);
        // Rebuild scripts
        $scripts = drupal_get_js();
        $vars['scripts'] = $scripts;
        // Same for css
    }
}

I know i could use a template file (page-my_view_page_path.tpl.php), but the js and extra css must be included only if my module is enabled; so I like to keep this things directly inside my module code.

Ideas?


texts: Is it possible to enable the title field for the module views slideshow?

texts:
I'm working with the module views slideshow and was just curious if anyone knew how to enable to title field for the images you upload for it. The alt text field is enabled but not the title field.

And no you don't just go to edit the field.


texts: Resending webform submission doesn't use custom mail template

texts:
I created a custom webform email template named webform-mail-1.tpl.php that is used when a user submits a webform.  The problem is, if someone modifies that submission and wants to resend that submission by email, the email uses the default template instead of the custom one ...

Does anybody have an idea as to why this happens ?  I didn't read anything about needing a separate template for emails that are sent again ...

Thanks !


texts: How to display specific blocks for specific roles alone w.r.t domains and subdomains

texts: I want to display specific blocks for specific roles alone with respect to domains and sub-domains. I know i can give permission for roles in the block to be displayed.How do i differentiate anonymous users with respect to domain and sub-domains in the permission of roles. Help really appreciated.Thanks in advance:)


texts:
I am trying to adapt a Drupal 5 form to a Drupal 7 form, but something is not working. The form is correctly displayed, but when "Submit" button is clicked the information in the form is not correctly send to $_GET. What am I missing??

<?php
 function my_menu($may_cache) {
  $items = array();
    $items['admin/reporting/report_details'] = array(
    'title' => 'Report: User details by stores',
    'access arguments' => array('access content'),
    'page callback' => 'say_report_details',
    'type' => MENU_CALLBACK,);

 return $items;
}

function say_report_details($values = array()) {
  $form = drupal_get_form("report_details_form");
  //$output = theme("report_page", $form, $output);
  return $form;
}

function report_details_form() {
 $form["search"] = array(
 '#type' => 'fieldset',
 '#title' => t('Search params'),
 '#collapsible' => FALSE,
 '#tree' => TRUE,
 );

 for ($i = 1; $i < 32; $i++) {
  $days_opt[$i] = $i;
 }
 for ($i = 1; $i < 13; $i++) {
  $month_opt[$i] = $i;
 }
 for ($i = 2008; $i < date("Y") + 3; $i++) {
  $year_opt[$i] = $i;
 }

 $form["search"]["from_day"] = array(
  '#type' => 'select',
  '#title' => 'Date from',
  '#options' => $days_opt,
  '#default_value' => (($_GET['from_day'] == "") ? date("d") : $_GET['from_day'])
 );
 $form["search"]["from_month"] = array(
  '#type' => 'select',
  '#title' => '&nbsp;',
  '#options' => $month_opt,
  '#default_value' => (($_GET['from_month'] == "") ? date("m") : $_GET['from_month'])
 );
 $form["search"]["from_year"] = array(
  '#type' => 'select',
  '#title' => '&nbsp;',
  '#options' => $year_opt,
  '#default_value' => (($_GET['from_year'] == "") ? date("Y") : $_GET['from_year'])
 );

 $form["search"]["to_day"] = array(
  '#type' => 'select',
  '#title' => 'Date to',
  '#options' => $days_opt,
  '#default_value' => (($_GET['to_day'] == "") ? date("d") : $_GET['to_day'])
 );
 $form["search"]["to_month"] = array(
  '#type' => 'select',
  '#title' => '&nbsp;',
  '#options' => $month_opt,
  '#default_value' => (($_GET['to_month'] == "") ? date("m") : $_GET['to_month'])
 );
 $form["search"]["to_year"] = array(
  '#type' => 'select',
  '#title' => '&nbsp;',
  '#options' => $year_opt,
  '#default_value' => (($_GET['to_year'] == "") ? date("Y") : $_GET['to_year'])
 );

 $result = db_query('SELECT something in the database');

 $strs = array("all" => "All");

 foreach ($result as $store) {
   $strs[$store->tid] = $store->name;
 }

 $form["search"]["store"] = array(
  '#type' => 'select',
  '#title' => 'Stores',
  '#options' => $strs,
  '#default_value' => $_GET['store']
 );

 $form["submit"] = array("#type" => "submit", "#value" => "Show report");

 return $form;
}

function report_details_form_submit($form_id, $form_values) {
  $query = "";
// This next line is the one I am having an issue with right now.$form_values is empty
  foreach ($form_values['search'] as $key => $value) {
     $query .= "&". $key ."=". $value;
  }

 return array('admin/reporting/report_details', $query);
}

The code throws an error at last "foreach" as $form_values is empty for some reason.Thank you!!


texts: Problem with drupal $queue->DrupalQueue::get and $queue->createItem

texts:
I am updating approx 10000 nodes using hook_cron_queue_info and hook_cron(), it execute only for 25 nodes.
Is there any problem?

function my_module_cron_queue_info() {
  $queues['my_module_batch'] = array(
    'worker callback' => '_my_module_process_queue',
    'skip on cron' => FALSE,
  );
  return $queues;
}

function my_module_cron() {
  $contents = lode_update_nodes(); // get node list for updation 10000 nodes.
  $queue = DrupalQueue::get('my_module_batch');
  foreach ($contents as $p_file) {
    $process_data = array(
    // set values for process
    );
    $queue->createItem($process_data);
  }
}

function _my_module_process_queue($arr) {
    // code for updation
    watchdog('update node', 'Custom msg');
}


texts: How do I update same published node for future use?

texts:
I want to create/update nodes in Drupal 7 like Oracle WCS(webCenter sites). In that there are two servers, Managed and Delivery Server. In Managed server content can be created and after getting approved by other users like publisher, it can be published to Delivery server. So, it will be live. At the same time they can update content for future use. (Now this is updated in Managed server.) Whenever they want to make it live, they will just get it approved and publish it again. For author/content creator it seems same content which he is updating and which is live.

Can we achieve this kind of functionality in Drupal 7?  I tried to use the Node clone module, but it creates copy of a node with different node ID. Client just don't want to create a copy of same node for updating. Same node which is live we should update but will publish in future.


texts: How can I render HTML tags in a variable in a twig template?

texts:
I have a variable in my twig template called description.
The variable is a string with an html em tag in it. When I go to the webpage to view the field, the html em tags are stripped out of the string.
I am on a Drupal 8 site and my variable was rendered through
\Drupal::service('renderer')->render() The twig autoescape parameter is set to false.

Using the twig debugger, I can see that my markup object includes the html em tags so I know that the problem is how twig is processing the string.
I've read in other posts to use the |raw tag but this has no effect.
What can I do to make the HTML in my twig variable render properly?

Update: I've included a screenshot of my output from {{ dump(description) }}


texts: Restricting Menu Item visibility for certain nodes

texts: Is there a way of customising what pages a Menu item will be displayed on? For example, I would only like one particular menu item in the sidebar menu to be displayed for one node, but the rest of the menu item links I would like to be the same throughout the site. Is this possible?


texts: Drupal 7 PHP version migration from PHP 5.3 to PHP 5.6

texts:
Our current Drupal 7 site runs on PHP 5.3 environment. But the server provider insisting to upgrade the PHP version to PHP 5.6 as they are about to end the support for PHP 5.3 and PHP 5.5 .

Is there any known issues for an existing Drupal 7 site migration into php 5.6?

Any tools/modules to check the version compatibility of current Drupal 7 in PHP 5.6 ?

Other than this any suggestion or advices prior to the migration ?


texts:
The Overall Plan

I'm creating a staff "portal" area for a non-profit. In the future I want to migrate the current static front-end website to Drupal, so I thought it would make sense to develop this portal area as a custom module into the back-end Drupal administration.

About the custom module

The non-profit provides a Child Sponsorship program, allowing supporters to pay a monthly fee which pays the school fees for children in East Africa. So the idea of the portal will be that it will reduce the administration of staff by holding the sponsorship database online. The database is split into two: children who are sponsored and children on the waiting list.  So I want to produce a module where each child is effectively a node. The node will contain sensitive information such as DOB, Address, School Exam Results etc and so isn't AT ALL for public viewing.

However, that when a child is added to the waiting list, a short bio will feed into the front-end website allowing them to be sponsored. This is one reason for trying to build it into Drupal from the beginning. In the future, it is also planned that when a user goes onto the front-end website, chooses a child to sponsor, they will be made a 'user' in Drupal, and given the ability to view certain information about their child such as a school report.

Questions

Is it conventional use of Drupal to build a module specifically for internal use where primarily the data is not for the public or front-end website? Is it an appropriate use?

To me it makes sense that each child functions as a node of content type 'child', however I'm worried about making them actual nodes.....as I said the data is private, and Drupal currently sets node public at URL node/{nid} What is the best solution moving forward with creating this database within Drupal? Could I make an equivalent 'node' style format?


texts:
I have a site I'm working on where images are inserted into the body of blog nodes and I'm wanting to return these images in a view. I'm using computed field to successfully return the url of the images in the view, but I would like to apply an imagecache style to this before displaying it using

<img src = "[computed_field]">

Does anyone know the best way to do this? I've been searching around and have not been able to successfully do this yet. Thanks!


texts:
I want to be able to show an announcement on the site that requires a confirmation by the user before it disappears.

Something similar to Absolute Messages but I don't want to have all status messages shown that way.


texts: How to use text from a block view as a prefix to a node title

texts:
What I would like to do

In Durpal 7, I am using a block view to display our manufacturers name above our node titles. We added a custom region above content, and that is working fine. However, I would like the manufacturer to be display inline with the node title.

  How I handled it in Drupal 8

In this related question I asked about a Drupal 8 solution.The drupal 8 solution was a little simpler in that we migrated all manufacturer fields into 1 manufacturer field. which made things much easier to code. In my drupal 7 site, the manufacturer fields are separate making it a little messier to handle with code in that there would need to be an instance of the code for every manufacturer/node combo.

  My question

For drupal 7 is it possible to render a block view as an inline prefix to a node title? Placing a block view in this circumstance seems like it would be a much simpler and more front end Drupal approach. Especially since I can have all of the manufacturer fields in the one block view, and they will render according to Taxonomy term ID contextual filter.


texts:
I'm not really a Drupal guru, so any help it'd be awesome.

There's a taxonomy for every state (State Owner), which then allows me select the state when adding a new article.

However, I'm trying to add a National (NAT) to the list. I've added it to the taxonomy term list:

However, NAT won't show up on the State Owner field when adding a new article:

I can see the item on the DB too:

I've flushed the cache, even restarted the server... It just won't show up on the Add Article page (on the State Owner drop down).

Note that if I change the order of the states, it DOES change the order on the drop-down, so it's the correct taxonomy terms.

Any idea?


texts:
Hello I have created a custom form added a # ajax callback on form submit

    $form['hotel_book_form']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Check Availability'),
    '#ajax' => array(
      'callback' => "list_rooms",
      'wrapper' => "replace_hotelbook_div",
      'method' => 'replace',
      'effect' => 'fade',
    ),
  );

and I have added this wrapper as suffix to the form

    $form['hotel_book_form'] = array(
    '#type' => 'fieldset',
    '#title' => t('Book Hotel'),
    '#weight' => 5,
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#prefix' => '

',
  );

but when I click on form's submit button the page gets simply reloaded and the ajax callback function does not fire.


texts: Installation profiles: Something is missing

texts:
I've been working on trying to write an installation profile for Dtupal 8 for almost a week now. I've followed the docs on Drupal.org: https://www.drupal.org/docs/8/creating-distributions/how-to-write-a-drupal-8-installation-profile

I've done this installation at least 5 times. I hit a number of different errors each time.

Error 1

After researching this issue, I'm told that when this error happens, I have to go into my settings.php file and change the profile from standard to my profile name.

Error 2

I hit this issue every single time which really defeats that purpose of a profile. If the module is not in core, it SHOULD download it. It does not though. It throws this message.

Error 3

If I stumble through the installation and fix all of the errors above, I still hit this error when the site tries to work through setting up all of my configs.

I have also downloaded "known" working profiles and they do not work as well.

Having said all of this, the docs on Drupal.org are obviously lacking and missing something. I've asked for help on several post on Drupal.org and I've gotten no help or useful information.

If anyone can point me in the right direction, that would be great. This used to be the way we'd distribute sites to clients with D7 and I've written some fairly large D7 profiles, but I don't understand what the issue is with D8.

With D7, you used to be able to plug in a profile to the /profiles directory, run through the install, and the site would be setup. This feature for D8 seems incomplete or missing some requirements and documentation. Several other developers have commented that they have no been able to get this to work without hacking files and fumbling their way through it.

If I can get a grasp on why this isn't working, and what is missing from the documentation, I'm committed to fixing that issue so that others can use this functionality of D8.


texts: PayPal Payflow Pro not allowing user to buy product

texts:
when I enable (and try to use) PayPal Payments Advanced and Payflow Link sub-module of Paypal module and submit the product form I get this error:

messageEntityMetadataWrapperException: Unknown data property
commerce_customer_address. in EntityStructureWrapper-
>getPropertyInfo() (line 335 of
/site/sites/all/modules/entity/includes/entity.wrapper.inc).

When I remove Payflow Link module I do not get this error.

The problem occurs when I remove the default 'address' field from the Customer Profiles > Billing Information and instead just use my own fields...but I don't want to use that default address field because it contains items I don't want.

Anyone know how I can fix this so i can use Payflow?

It appears to be a problem in the Entity module but only gives me an error when trying to use Payflow Pro to purchase a product.

This is what that line of the entity module file has:

  public function getPropertyInfo($name = NULL) {
    $this->spotInfo();
    if (!isset($name)) {
      return $this->propertyInfo['properties'];
    }
    if (!isset($this->propertyInfo['properties'][$name])) {
      throw new EntityMetadataWrapperException('Unknown data property

' . check_plain($name) . '.');
        }
        return $this->propertyInfo['properties'][$name] + $this-

  info['property defaults'] + $this->propertyInfoDefaults;
        }


texts: How to tell if user selected an autocomplete option in a form?

texts:
I created a form that has an autocomplete field of registered users and it is attached to nodes. In the form validation function I check if the string of the textfield is a valid user but in order to reduce the server load I also need to check if the selected option (current field value) is an option of the autocomplete set of options by Javascript.

I found How can you tell if a suggestion was selected from JQuery UI Autocomplete but it gave me no clue to the solution.

How can I do that?

This is my module code :

function recommend_form($form,$form_state){
    $form = array();
    $form['username'] = array(
            '#type' => 'textfield',
            '#description' => t('Please enter a username using autocomplete widget'),
            '#required' => TRUE,
            '#size' => 20,
            '#autocomplete_path' => 'recommend/autocomplete',
    );
    return $form;
}

function recommend_menu(){
    $items['recommend/autocomplete'] = array(
        'title' => 'Autocomplete for users',
        'page callback' => '_users_autocomplete',
        'access arguments' => array('access content'),
        'type' => MENU_CALLBACK,
    );
    return $items;
}
function _users_autocomplete($string){
    $matches = array();
    $result = db_select('users', 'c')
    ->fields('c', array('name'))
    ->condition('name', '%' . db_like($string) . '%', 'LIKE')
    ->execute();

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

function recommend_node_view($node, $view_mode, $langcode) {
    global $user;
    if($user->uid != 0){
        $form = drupal_get_form("recommend_form");
        $node->content['a_new_field'] = array(
                '#markup' => drupal_render($form),
                '#weight' => 10,
        );
    }
}


texts:
I have content type having fields as follows.

first

second

third

Sum1 (first + second +third) - computed filed

xxxx

yyyy

zzzz

Sum2 (xxxx+yyyy+zzzz) - computed field

Grand Total (sum1 + sum2) - computed field

I could achieve this by using computed field module. When I save node, I could able to find sums and Grand Total.

My problem is client wants to see  sum1 filed in edit/create form and also wants to update sum1/sum2/Grand Total fields on the fly (dynamically).
There are couple of content types having the same requirement.

Before start to write a custom module, I would like to know alternates for this.Any suggestions?


texts: Extracting first few letters from tokens

texts:
I am trying to generate Product SKU through Auto SKU which uses tokens, but with tokens I get full names from fields such as store city, store name, product name, serial field.

[commerce-product:field-stores:field-city]
[commerce-product:field-stores]
[commerce-product:field-stores:id]
[commerce-product:type-name]
[commerce-product:field_serial]

But I only want to extract first 4 letters from city token and from store token. How can i achieve it?


texts: Display single field from argument taxonomy term in Views header area

texts:
I have a view with a taxonomy term ID in the URL which is used to filter the displayed entities in the view.

I want to display the description from the taxonomy term.

I've tried this a million different ways.

I've even gone as far as defining a view mode for the vocabulary which only includes the field - that doesn't work because it insists on displaying the title linked to the term page (which I definitely don't want). I even tried the layout builder but that displayed the title as well.

This is not the same as modifying the page title - which I am doing successfully.

Any ideas what I can do?


texts:
i am working on a development site. i am on hold because of two problems.

i have two content type A and B. i created a view for B content type. i used node reference in content type A  and call the created view so it display view fields rather than only title of nodes.   my problem is that when i start type any title in this field it display the options in autocomplete but it display white spaces, i add css but it is not working

so the main question is css not working in node reference view result
i added a view in the same manner for a field. i want to add radio button on each result of view ,and when we click on radio button it's value copy in another field of content type.

Thanks , plz help me


texts: Newly contributed theme not showing in Project Application issue queue

texts:
I have contributed a theme (Auro) in Drupal.org and assigned for "Needs review" but the project not showing in Project Application issue queue.

Why doesn't my theme appear in the Project Application queue? What did I do wrong?


texts: Drupal 7 :: Configure Master admin under Drupal multi domain website

texts:
I want to configure Master admin under Drupal multi domain website so that admin does not need to switch the login between multiple websites.

For example, if I have 3 websites under single Drupal setup:

www.red.com

www.blue.com

www.green.com

Then I should be able to open red.com admin panel and should have the option to switch from red.com to blue.com admin without logout from red.com admin panel.


texts:
As a block on my homepage I'm trying to output:

Node 1

Node 2

Node 3

Node 4

where each
 represents a node, and the image/text supplied by CCK fields attached to each node.

Currently, I'm using a block view to output nodes 2-4, and an Attachment view to present the first node as outlined here:
http://www.agileapproach.com/blog-entry/the-views2-attachment-display

The problem is my output ends up more like this:

Node 1

Node 2

Node 3

Node 4

I can probably bend that output suit my purpose, but it will involve a lot of templating and configuration. I'd also like to avoid using CSS and/or JavaScript to modify the output, unless that's my only option.

Given this, what's the easiest way to get the output closer to what I need it to be?

Edit: here's some rough php code I'm using in the customfield php code field (based on Jeremy French's suggestion:
 Here's the code I'm using in my PHP Code customfield:

<?php
  ++$static;
  if ($static == 1) {
    $nd=node_load($data->nid);
    $img_path = imagecache_create_path('news_image_thumbnail', $nd->field_image[0]['filepath']);
    print '
Node 1
';
  } else {
    print "Node $static";
  }
?>


texts: How to set default values for "modify entity values" form

texts:
I have a view with nodes and a views bulk operations field. With this vbo field I like to "modify entitity values" of the selected node.

Is it possible:

to automatically check the checkbox for a selected field, so that the field to modify the value is shown by default?
to automatically set a default value in the textfield (which should be shown by default of course)?


texts: Boolean field inside node twig renders ok but does not work in if statement

texts:
I have an node twig and I want to use field of that node inside if of that twig. I managed to get the boolean value via content.field_sample|raw. But it looks like it doesn't work in if statement. For give code:

Value: {{ content.field_sample|raw }}
{% if content.field_sample|raw == '1' %}
    OK
{% else %}
    Error
{% endif %}

I get output:

Value: 1
Error

Sames goes for {% if content.field_sample|raw == 1 %}.

{% if content.field_sample|raw == true %} always returns true, regardless the boolean is on or off (it returns true for both Value: 0 and Value: 1). I guess it's  because it just checks if fields exists.


texts: Modifying user view to display correct gender

texts:
In Drupal 7.21 with ulogin 7.x-1.10 I get following records in the database for male (having sex=2 in the JSON array below) and female (they have sex=1) users:

  5 | 25583 | facebook      | 597287941             | a:7:{s:3:"sex";s:1:"2";s:7:"profile";s:32:"http://www.facebook.com/farber72";s:3:"uid";s:9:"59728
7941";s:10:"first_name";s:9:"Alexander";s:8:"identity";s:32:"http://www.facebook.com/farber72";s:7:"network";s:8:"facebook";s:5:"photo";s:55:"http://gr
aph.facebook.com/597287941/picture?type=square";}

 10 | 25593 | mailru        | 6189724215193505959   | a:8:{s:7:"network";s:6:"mailru";s:8:"identity";s:36:"http://my.mail.ru/mail/masaeva_alla/";s:3:"u
id";s:19:"6189724215193505959";s:10:"first_name";s:27:"\320\220\320\273\320\273\320\260 \320\220\320\275\320\264\321\200\320\265\320\265\320\262\320\27
5\320\260";s:3:"sex";s:1:"1";s:4:"city";s:31:"\320\222\320\265\320\273\320\270\320\272\320\270\320\271 \320\235\320\276\320\262\320\263\320\276\321\200
\320\276\320\264";s:5:"photo";s:48:"http://avt.appsmail.ru/mail/masaeva_alla/_avatar";s:7:"profile";s:36:"http://my.mail.ru/mail/masaeva_alla/";}

And I have this part in my own custom Drupal module:

function pref_user_view($account, $view_mode, $langcode) {
  global $PREFIX;

  $ulogin = @$account->data['ulogin'];
  if (isset($ulogin) && is_array($ulogin) && array_key_exists($ulogin['network'], $PREFIX)) {
          $uid    = $ulogin['uid'];
          $city   = $ulogin['city'];
          $prefix = $PREFIX[$ulogin['network']];
  } else {
          $uid    = $account->uid;
          $city   = $account->field_city['und'][0]['safe_value'];
          $prefix = 'DE';
  }

  $account->content['stats'] =  array(
    '#type'   => 'user_profile_item',
    '#title'  => t('Досье:'),
    '#weight' => 3,
    '#markup' => sprintf('Статистика игр и репутация', $prefix . $uid),
  );
  $account->content['map'] =  array(
    '#type'   => 'user_profile_item',
    '#title'  => t('Карта:'),
    '#weight' => 4,
    '#markup' => sprintf('',
      MAPS_URL, urlencode($city), AVATAR_STYLE),
  );
}

This produces the following user page with wrong gender:

I realise that my question is very chaotic and apologize for the Russian language content here - but I had developed my module over a year ago and don't remember it well.

How could I fix the gender displayed above, do you have any ideas, suggestions?

Please give me a kick start.


texts:
I'm trying to design a form that allows a user to design a custom tshirt. I was thinking of using the fabric.js library to let the user design a custom image and submit it with other custom information filled out in the webform module.

Is there an approach anyone can suggest that would let me take the image designed in the javascript and submit it along with the webform info? I'm pretty sure I can figure out fabric.js by itself but integrating with Drupal might be too advanced? I don't know if it is even possible. Still at a beginner level here with javascript and php.


texts: IIS problem with Drupal - Update manager: Update failed! Directories are locked by php-cgi.exe

texts:
I have some problem when using the "Update manager" on the GUI. Some directories get locked by php-cgi.exe, and thus the replacement of the original directories with the newly downloaded ones (which are fresher) is not successful.
BUT I have to mention that it's not a permission issue, because the modules can get installed via "Install from a URL" on /admin/modules/install, and work without a problem.

Let's take an example:

Available updates page (/admin/reports/updates/update):

Now I check Select (or other) module to be updated (it doesn't matter which module I choose, the results are the same!! so it's just an example).
I hit "Download these updates" button.
OK, the module's updated instance gets downloaded without a problem:
"Updates downloaded successfully":

Now I click on Continue.
Here comes the error. The result:
"Update failed! See the log below for more information.
select_or_other

Error installing / updating
File Transfer failed, reason: Cannot copy D:/Projects/web/drupal-7/tmp/update-extraction-6d8993ac/select_or_other/LICENSE.txt to /Projects/web/drupal-7/htdocs/sites/all/modules/select_or_other/LICENSE.txt."

OK, I'm starting to try to inspect the possible reasons.

Here's what my Drupal directory structure looks like: . I set ../tmp to be the temporary directory (in /admin/config/media/file-system), the Drupal files are in htdocs. This is correct, as I can install modules via the GUI, as I mentioned above.
When I try to enter the htdocs/sites/all/modules/select_or_other directory, I can't, because I get an "Access denied on file ......sites/all/modules/select_or_other!" when opening in Total Commander, and "...sites/all/modules/select_or_other is not accessible. Access is denied" when opening in Windows Explorer:
,
OK, I right click the folder, and open Unlocker via its assistant in the context menu. It says this directory is locked by php-cgi.exe:

I click on "Unlock All", and the folder can now get deleted of itself (as it's not locked anymore by php-cgi.exe), so it simply
I can find the updated select_or_other module's directory in tmp:

so I have to manually move it to sites/all/modules directory.

What can be the possible reasons of the lockup of the directory by php-cgi.exe? (Maybe Windows Cache Extension 1.1 for PHP 5.3 installed via Web Platform Installer? But if yes, why is that for example the deletion of images or similar via the GUI works correctly?)
What can I do to avoid this problem, and let "Update manager" work?


texts:
I have several books with several pages on them.
I want to create a view to display page from a specific book. I'm pretty sure View can dop it but I don't find the way to.

Do you have any idea ?


texts: Content Type "Article" is not showing when trying to add, but it is showing in Structure-> Content Type. Please help me

texts:
I don't know how i lost Article content type when adding a content. It is not visible for me.

Please find the two screen shots attached.


texts:
I'm planning to use drush "make" function for my new D7 projects.

I would like to know if there is a way to detect, in my project, the repertories managed by "svn externals".

I mean, is "drush generate makefile" command, able to launch "svn propget svn:externals" function (by example), and store these properties in the generated .make file.

So it will "svn propset svn:externals" properties on "drush make" function call ?

Is there an option for that ?
Thanks.


texts:
I have a page that shows content to all the users in my database but I have an specific username (exchangeStudents) and I want to show in the same page another view that filters the information for that account.

For example... my main page is:
www.housing.com an when you login you can see www.housing.com/houses but I if you login as exchangeStudent you should be able to only see www.housing.com/exchange-houses

www.housing.com --> all users except exchangeStudent

www.housing.com/exchange-houses --> only for username: exchangeStudent


texts: Page where I can see my user's managed files

texts: Is there a page in Drupal that lists all of the files in file_managed that the logged in user owns?


texts: Get the form to add a term to a vocabulary programmatically

texts:
I am working on Drupal 8.9.6.
I am trying to retrieve the form to add a term to a vocabulary programmatically. I know how to do it for a content type:
    $values = array('type' => $content_type);

    $node = \Drupal::entityTypeManager()
      ->getStorage('node')
      ->create($values);

    $form = \Drupal::entityTypeManager()
      ->getFormObject('node', 'default')
      ->setEntity($node);
    $modal_form =  \Drupal::formBuilder()->getForm($form);

Nevertheless, I am not able to do the same for the form of adding a term to a vocabulary. Any hint would be more than welcome.
Thanks!


texts: Help with db_delete using both LIKE and IN.. I'm trying to delete many rows whilst having a wildcard

texts:
I'm writing a custom cache clearing module for blocks.

At the moment, I can delete cache for one user and their multiple languages.

$uid = 7094;
$module = 'custom_home_panes';
$block = 'custom_home_panes_news_group';
$theme = 'framework';
$table = 'cache_block';

$cid_start = $module . ':' . $block . ':' . $theme . ':';
// Wildcard in middle for language code
$cid_end = ':u.' . $uid;

$delete = db_delete('cache_block')
  ->condition('cid', db_like($cid_start) . '%%' . db_like($cid_end), 'LIKE')
  ->execute();

But I'll need to do this for an array of UIDs and I believe I need to use IN like the snippet below..

->condition('uid', array(1,5,7),'IN')

I thought I could add what I did to an array and got this far.. The LIKE is really confusing me here and I think I'm going about it the wrong way.

foreach ($uids as $uid) {
    $queries[] = db_like($module . ':' . $block . ':' . $theme . ':') . '%%' . db_like(':u.' . $uid), 'LIKE';
}

The end result should be a query that removes records such as the ones below.

custom_home_panes:custom_home_panes_news_group:framework:vi:u.7250
custom_home_panes:custom_home_panes_news_group:framework:en:u.7250
custom_home_panes:custom_home_panes_news_group:framework:vi:u.7253
custom_home_panes:custom_home_panes_news_group:framework:en:u.7253

Any help appreciated.. My SQL skills are abysmal. Thanks!


texts: Leaving first-level tab selected when clicking on a subtab

texts:
I have a menu like the following defined in mymodule.links.menu.yml:

mymodule.page_memos:
  title: 'List of memos'
  description: 'View list of memos'
  route_name: view.document_list.page_1
  route_parameters: { doctype: 'memo'  }
  menu_name: main
  weight: 100

mymodule.page_letters:
  title: 'List of letters'
  description: 'View list of letters'
  route_name: view.document_list.page_1
  route_parameters: { doctype: 'letter'  }
  menu_name: main
  weight: 200

mymodule.page_notes:
  title: 'List of notes'
  description: 'View list of notes'
  route_name: view.document_list.page_1
  route_parameters: { doctype: 'note'  }
  menu_name: main
  weight: 300

and then a list of tasks defined in mymodule.links.task.yml:

mymodule.document_list:
  title: 'List of documents'
  description: "View full list of documents"
  route_name: view.document_list.page_1
  base_route: view.document_list.page_1
  weight: 10

mymodule.create_doc_by_type:
  title: 'New document'
  description: 'Insert new document'
  route_name: mymodule.create_doc_by_type
  base_route: view.document_list.page_1
  weight: 20

Everything work as expected, with three tabs in the main menu and two tabs in the task (they will soon become more). There is only a small visual glitch: when I click on tabs in the main menu, the last one clicked is correctly marked as active; when I click on tabs on the task menu, only the first one is ever marked as active. I am sure this has to be something really minor, but I really don't know how to search for a solution.


texts: How to create a separate theme for webform

texts:
I have a created a webform in drupal, now i want to create webform.tpl.php for this webform.
How to do this?
Any suggestion


texts: How to show a block on a set of subpages except one of them?

texts:
I have a block which is shown on all subpages under "mypagename", using the following bmock visibility settings:

Only the listed pages --> mypagename/*

Except I now need to exclude one page under "mypagename" for showing this block. Is there a way to easily exclude this page using the standard settings of Drupal 7?


texts:
So my problem is i dont know how to make my custom menu item change language in drupal. I know there is a language switcher in drupal, but i want to make a new custom menu in drupal, theme it, and i want the links to trigger changing the language, like the link "french" changes the site to french. How can this custom trigger of events be created in drupal and how do i know which functions to call/variables to change to allow me to achieve this?

I really appreciate any help!


texts:
I'm doing some migration tests since we need to migrate content from Drupal 7 site A to Drupal 7 site B. The only issue I have is the path auto alias, for some reason it just won't migrate. I always seem to get a domain.tld/node/2122.

I already tried checking off the 'DNMG' checkbox and the other one with a path, none of them seem to help.

Can somebody point me in the right direction.

Facts:

Path alias migrates, eg: site.tld/content/hell-world
Path alias and node redirects are in the database:  node/123 goes to site.tld/content/hello-world in the redirect screen
In reality 'node/123' does not redirect to the alias, even though it should be.
tried it with Pathauto, path, Redirect modules disabled, same problem
tried bulk updating alias, same problem.

I really don't know where to look anymore, I'm all doing this via the UI, since it works just fine except the url alias problem.

PS: if you post a code snippet, I need to know where to put it...

Thanks for your time.


texts: How to render element array piece by piece

texts:
I have template form.html.twig Drupal commerce is using it to render cart form. I made override of that template, to be able to change it only for cart form, without affecting other forms. That part works well.

Form template looks like this:

<form class{{ attributes }}>
  {{ children }}
</form>

Where "children" is markup. But (even not documented in template it self) there is also "element" array. So I can print the it instead of children and get the same results:

<form class{{ attributes }}>
  {{ element }}
</form>

This also works well.
Now, I need to print it piece by piece. If I put loop like this:

  {% for single in element %}
    {{ single }}
  {% endfor %}

I get some form elements doubled, so obviously some elements must be excluded. But which ones?

Here is the list of all element keys inside this "element" array:

#action
#prefix
#suffix
#pre_render
#cache
#attached
#substitutions
#form_id
#type
#build_id
#token
#id
#attributes
#method
#theme_wrappers
#defaults_loaded
#tree
#parents
#validate
#submit
#theme
#processed
#required
#title_display
#description_display
#errors
#array_parents
#printed
show_view_elements
output
footer
edit_quantity
remove_button
form_build_id
form_token
form_id
actions
#sorted
#children
#render_children

How can I find out what elements  should I print and what to exclude to get the same result (valid form) as when printing top element:

{{ element }}

Update: purpose of this is to render cart page a bit differently. Now, inside the form element I have first table with purchased items, then, bellow table goes div with sub-total and total prices and then div with "Update" and "Checkout" buttons.
What I want is to display those 3 elements in 2 columns. In left one there should be only table with items and in right prices, buttons and some additional info.

BTW, I'm already displaying another form that way. It's template file looks like this:

<form{{ attributes }}>
  {{ title_prefix }}

  {{ element.pages }}
  {{ element.elements }}
  {{ element.form_build_id }}
  {{ element.form_token }}
  {{ element.form_id }}
  {{ element.footer }}
  {{ element.actions }}
  {{ element.children }}
  {{ element.progress }}

  {{ title_suffix }}

</form>

There I print progress bar bellow the other form elements.
But I have problem achieving the same with cart form.


texts:
How do I link menu to certain section in one page theme?

What is the path should I add if "about" menu link to "about" section?

The single page is combination of different blocks.


texts: Alter a Views query to use "OR" through the user interface

texts:
I have a view with a few different displays, each of them with slightly overridden filters, like this one used in a panel.

How do you add this pseudocode via the UI?

AND (node.type='story' OR node.comment_count >=1)

I found an article (Better WHERE's for your Drupal forums with hook_views_query_alter), but I still don't know what to do.

What does the following code do, and what is "advf_filter"?

if ($view->name == 'YOURVIEW') {
  $view->query->add_where('advf_filter',"(node.type='%s' OR node_comment_statistics.comment_count >= %d)",'forum',1);
  $view->query->set_group_operator('AND');
}


texts: Creating a user reference field based on a similar field on a referenced node

texts:
I have 2 content types (project and issue), you can think of this as an OG style set up, the child nodes reference the parent node via a node reference field called "project" on the issue node type.

The "project" node type has a user reference field called "members".

I'm trying to build a view to create a user reference field on "issue" called "assignee", I would like to limit the users that may be referenced to the users who are in the "members" field of the project node.

So I've created a user view with a reference type and am playing with adding contextual relationships and references, but I am getting no results. I know this is a pretty complex way to use these modules, and typically I would just write a module to achieve this, but I would really like to do this without writing a new module.

Has anyone ever dealt with anything like this?


texts: How to use Blazy in a custom Twig with Responsive Images and WebP

texts:
I have a node twig template and I'm rendering Responsive images like so:
{% set pmpFact1Path = node.field_pmp_fact1_image.entity.uri.value %}

{%
    set pmpFact1ResponsiveImageStyle = {
        '#theme': 'responsive_image',
        '#responsive_image_style_id': 'pmp_facts',
        '#uri': pmpFact1Path,
        '#attributes': { class: 'img-responsive pmp-vtwo-facts-1-img', alt: 'Students' },
    }
%}

{{ pmpFact1ResponsiveImageStyle }}

I have my breakpoints.yml set and my responsive image and image styles are configured through the interface.
I've got the WebP module installed and all of this is working beautifully.
Now I want to lazy load my responsive images.
To that end I've tried several different incarnations of this:
{% set pmpFact1Path = node.field_pmp_fact1_front_image.entity.uri.value %}

{%
    set pmpFact1ResponsiveImageStyle = {
        '#theme': 'blazy',
        '#settings':{
            'lazy': 'blazy',
            '#uri': pmpFact1Path,
            '#responsive_image_style_id': 'pmp_facts'
        },
        '#item_attributes': { class: 'b-lazy img-responsive media media--blazy media--loading media--responsive media--image pmp-vtwo-facts-1-front-img', alt: 'Students' },
        '#uri': pmpFact1Path,
        '#responsive_image_style_id': 'pmp_facts',
        '#attached': {'library': ['blazy/load']}
    }
%}

I'm using blazy 2.2.
I've configured it to work with responsive images via the interface.
I've also set the field format to blazy and applied the responsive image style in the field settings.
I've got the blazy library (blazy.min.js and blazy.js) in my libraries directory well.
The result is I get the blue square place holder flipping endlessly but no image or picture tag srcset markup. i.e.:
<div class="media--blazy media--loading is-b-loading media--image">
 ::before
</div>

From what I've read, this could mean I'm not successfully loading the blazy javascript file.  I've tried requiring it as a dependency in my libraries.yml but that did nothing.
If anybody could offer some advice I'd appreciate it very much.


texts: Config sync directory outside of webroot causes open_basedir restriction warning

texts:
Hello all and thank you for taking the time to help. In following this tutorial and many others like it, I've successfully moved the configuration sync directory outside of my webroot, both locally and on production. I can confirm that it's working using drush cex and drush cim in both locations.

Hopefully Helpful Info

Drupal 8.3.5
On production, I have the config directory set with 775 permissions (and export/import still worked with 755).
in settings.php, I have $config_directories[CONFIG_SYNC_DIRECTORY] = '../config/sync'
since it couldn't be created by Drupal, I created a .htaccess file for this directory on my own.
config is being version controlled, but due to how/where Drupal was installed, I'm having to maintain a separate git repo for this single directory, which doesn't bother me. Drush still seems to work with no complaints.

The Problem

Within the UI, I get the following status report errors:

Warning: is_writable(): open_basedir restriction in effect. File(../config/sync) is not within the allowed path(s): (/home/cathchar/www:/tmp) in config_requirements() (line 24 of core/modules/config/config.install).
Warning: file_exists(): open_basedir restriction in effect. File(../config/sync/.htaccess) is not within the allowed path(s): (/home/cathchar/www:/tmp) in file_save_htaccess() (line 367 of core/includes/file.inc).
Warning: file_exists(): open_basedir restriction in effect. File(../config/sync) is not within the allowed path(s): (/home/cathchar/www:/tmp) in file_save_htaccess() (line 374 of core/includes/file.inc).
Warning: is_dir(): open_basedir restriction in effect. File(../config/sync) is not within the allowed path(s): (/home/cathchar/www:/tmp) in system_requirements() (line 600 of core/modules/system/system.install).
Warning: is_dir(): open_basedir restriction in effect. File(../config/sync) is not within the allowed path(s): (/home/cathchar/www:/tmp) in system_requirements() (line 603 of core/modules/system/system.install).
(and below these) CONFIGURATION DIRECTORY: SYNC - The directory ../config/sync does not exist.

What I do/don't understand

I'm swimming in deeper waters here than I'm used to, but I sincerely want to understand errors like this and be able to get to bottom of issues. From what I understand, Drupal is warning me that my newly created /home/cathchar/config/sync directory is not in a path, namely /home/cathchar/www (the webroot) or the account root /tmp directory, that it can work with/write to. It's also warning me that that it doesn't see this directory as existing.

My question

The directory obviously exists, but what am I missing? PHP should have no problem with seeing outside of and jumping out of the webroot, correct? Do I have to inform Drupal somewhere else about a new path to work in? None of the tutorials/instructions I've read ever mention issues regarding directory access, paths, or open_basedir restrictions. The ones I encountered make it seem like adjusting settings.php and creating the non-webroot directory is really all it takes. I'm a bit stumped.

Any help that anyone could provide would be greatly appreciated!


texts:
I have visited related questions here but i need more specific answer.

I have hooked into the user registration form and i have added a custom submit handler for user registration before the user drupal core registration function.

I want to implement paid registration. I have visited Paypal IPN documentation but they said the require a return url.

Actually i am confused in the whole process. I want to know actual steps to implement payment api of paypal then if the user has paid the drupal core submit function should run otherwise i'll die the script.

Thanks


texts: Can I show an image in place of a Drupal 6 message?

texts: I have a form, that upon completion, goes back to the page it was called from and displays a message of success when everything is done. Is it possible to just display an image on that same page, or do I have to redirect to a new page to show the form submission success image?


texts: TinyIMCE not working: looking for image files

texts:
TinyIMCE is not working: At Hostgator, I cannot access the images that I know are in there (at sites/default/files/field/image and at sites/default/files/pictures). In the text editor, I select the image-add icon (the tree). I select image url icon. The dialog box is limited to showing sites/default/files. It does not allow access to /field/image or /pictures/ The "insert image button at top right is missing (but it exists on my local server.)

I have uninstalled and reinstalled the wysiwyg and imce modules. I have checked permissions. I have made certain the files are in the places noted.


texts: How to show votes in view results by node id?

texts:
I installed the modules "rate (voting widget)" and "voting api". These modules work very well.
I use views to get a list of nodes, and I added the voting results. Now I get a row for each vote, not for each node...

Views rows:

Node 1  --  angry: 1  happy: 1
Node 1  --  angry: 1  happy: 1

Node 2  --  angry: 1  happy: 0

Node 3  --  angry: 0  happy: 1

I want to group the results by node id, but this doesn't seem to work. what would be the easiest solution for this problem?


texts: Save image in any weight and immediately reduce it

texts:
I am building a site using drupal 7. I created a node form for users to write content and upload images (using the core image field).

Is it possible to let users to upload images of 5-10 MB (and more), and immediately reduce the weight of the image to only 1 MB, and only then save it on my Drupal site?

My goal is that user will be able to upload any image size they want, but still save space on my Drupal site.


texts: How to change taxonomy term ID to term name?

texts:
I'm trying to change path of my site which is based on taxonomy tags. Default path of my site in this context is /taxonomy/term/120 (or other number - TID).

In Drupal 7 option to change TID to term:name was easy using Contextual filter and Filter value type set to Term name coverted to Term ID (shown eg here: Views contextual filters taxonomy name).

The big problem I'm struggling with is that there is no Filter value type field (dropdown menu) in Drupal 8. This is picture of my screen:

So I cannot change TID to term name.

Have anyone idea how I can exchange them. Is there another way to change them in Drupal 8?


texts: How do I add HTML to my module's custom admin page?

texts:
I have set up a new page in my admin for my module like so:

/**
 * Implements hook_menu().
 */
function scraper_menu() {
    $items = array();

    $items['admin/scraper'] = array(
        'title' => 'Scraper',
        'description' => 'The main action page in the admin area where we control our scrapers.',
        'page callback' => 'scraper_page',
        'access arguments' => array('administer users'),
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

/**
* Page callback: Scraper page
*
* @see scraper_menu()
*/
function scraper_page() {
    return '
Hello world
';
}

When I navigate to admin/scraper I get the following error:

Fatal error: Unsupported operand types in /######/includes/form.inc on line 1079

So how do I create a custom HTML page in the admin?


texts: Error: Cannot redeclare class becuase of entity self reference

texts:
I've got 2 problems here.

I have an entity that references itself in field definition (see below).

Problem No.1. I've got a fatal error
PHP Fatal error:  Cannot redeclare class Drupal\mymodule\MyEntity when trying to install the module.

Problem No.2 I now get it every time even when I remove the referencing field and do drush cr unless I wrap the class definition in !class_exists().

I swear this is the only file defining the class.

Is there a way to clean this out of wherever drupal has stored it?

And how do I declare this type of self-reference?

<?php

namespace Drupal\mymodule;

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * @ContentEntityType(
 *     id = "myentity",
 *     label = "My Entity",
 *     base_table = "myentity"
 * )
 */
class MyEntity extends ContentEntityBase
{
    public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
    {
        $fields = [];

        // Standard field, used as unique if primary index.
        $fields['id'] = BaseFieldDefinition::create('integer')
            ->setLabel(t('ID'))
            ->setReadOnly(true);

        $fields['myentity_id'] = BaseFieldDefinition::create('entity_reference')
            ->setTargetEntityTypeId('myentity');

        $fields['name'] = BaseFieldDefinition::create('string');

        return $fields;
    }
}


texts: Checkbox value always 0 in custom submit handler

texts:
I have a single checkbox field (not checkboxes) in a custom form, when I try to get the value in a submit handler the value is always 0 whether it's selected or not.
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {

    $form['item_specifics'] = [
      '#type' => 'checkbox',
      '#title' => t('Sync item specifics'),
      '#attributes' => [
        //define static name and id so we can easier select it
        // 'id' => 'select-colour',
        'name' => 'field_item_specifics',
      ]
    ];

    $form['fieldset_item_specifics'] = [
      '#type' => 'fieldset',
      '#title' => $this->t('Item Specifics'),
      '#attributes' => [
        //define static name and id so we can easier select it
        'class' => ['form-wrapper', 'js-form-wrapper'],
      ],
      '#states' => [
        //show this textfield only if the radio 'other' is selected above
        'visible' => [
          //don't mistake :input for the type of field. You'll always use
          //:input here, no matter whether your source is a select, radio or checkbox element.
          ':input[name="field_item_specifics"]' => ['checked' => TRUE],
        ],
      ],
    ];

    $form['submit'] = [
      '#type' => 'submit',
      '#value' => $this->t('Sync'),
    ];

    return $form;
  }

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

    dpm($form_state->getValue('item_specifics'));

  }

}

The output of dpm() is always 0, if I dpm() form state then the values array always has the checkbox value as 0.


texts: How do I import latitude/longitude into geofield?

texts: I have a CSV file with a id column, a latitude and a longitude column, and some other data in each record.  I have created a content type to hold this dataset. Each record will be mapped to a content.  I used Geofield to store the location.  How do I import the CSV file and create these contents?


texts: How may I curtail or minimize the text below CKEditor (while keeping it available for screen readers)?

texts:
In the add/edit form of a node, is there a way to reduce, hide, or minimize the Text Format block information contained inside of <div class="form-item form-type-textarea form-item-body-und-0-value">?

Would it be best to do an accessible hide as mentioned in Drupal 7, two new system classes to improve accessibility by using the classes .element-invisible and .element-invisible.element-focusable? Or should I edit a template file?

I'm using the Autoform Block module and placing this block inside the main page of an Organic Group. The rich text editor is managed by using the CKEditor module.


texts: Problem with database migrating Drupal 8 site from local to web host (multiple databases)

texts:
I'm trying to migrate over a Drupal 8 site developed on my local PC to the web host. Everything is fine with the files transferred over (/site/files, /modules, /themes, etc.), the database has been transferred successfully, but it's not being read by Drupal (the new site is blank but with the CSS working fine). My web host insists that everything is fine with the settings.php and other files and suggested that I look here for solutions.

The only lead I have is that I notice that the local site I created on Bitnami/Xampp has five different databases: "bitnami_drupal8", "information_schema", "mysql", "performance_schema", and "sys".

I've been trying to export and import back in the "bitnami_drupal8" database because that seemed to be the main database. There is only one database on my web server (I'm only allowed two).

Do I need to export/import these five databases and merge them into the one on my web host? If not, are there any other suggestions?

Note too: I've tried the Backup & Migrate module with backups of the entire site, imported that in, and it still didn't show anything. It's like there's some incompatibility between the local and web host databases.

Thanks a lot


texts: Replace the date of a filtering criterion with "Views PHP"?

texts:
I created a "like" flag on the nodes.

I created a comment view.

I want my view to show only comments posted since the flag date.

The solution will be to create a filter criteria with the filter "Comment: Publication date" (Is greater than or equal to) and replace the value with the date of the flag.

The problem is that there are no tokens for the filter criteria.

How to do this with "Views PHP" ?

https://www.drupal.org/project/views_php


texts: Put social Icons next to body field ($content['body'])

texts:
I want to align my social icons vertically next to the body field, in my node.tpl.php file the body is included in the $content with everything else. The social icons sit a few lines above and look like this in my node.tpl.php file:

<div class="main-node-social-share">
  <?php print render($main_node_social_share);?>
</div>

How can i get $main_node_social_share to render right before the $content['body'] field?

// We hide the comments and links now so that we can render them later.
hide($content['comments']);
hide($content['links']);
print render($content);


texts: Painless way to import content from old custom CMS

texts:
I am building a Drupal site (first ever) for a company that wants to move off of an outdated custom built CMS.

They have alot of content and we are pretty much keeping the content layout (fields) the same. And of course they want to have there content in the new Drupal site.

The Drupal database structure is pretty complex and I doubt a few simple insert queries will do the trick. I have written Python scripts to do stuff like this is in the past but not with a DB as complex as what Drupal sets up.

What options do I have for importing the old content into Drupal?