texts: How can I check that the file is present in database entry and also in files folder?

texts:
I want to write a script where I want to check whether the files are present in files folder of drupal/sites/default/files and is it existing in the database table file_managed.

        $sql=db_query("SELECT * FROM `file_managed` WHERE `filename`LIKE '%.pdf' OR `filename`LIKE '%.doc' OR `filename` LIKE '%.doc' AND `timestamp` < UNIX_TIMESTAMP('2014-01-01')")->fetchAll();

function file_destination($destination, $replace) {

  if (!file_destination($uri, FILE_EXISTS_ERROR)) {
    switch ($replace) {
      case FILE_EXISTS_REPLACE:
        // Do nothing here, we want to overwrite the existing file.
        break;

      case FILE_EXISTS_RENAME:
        $basename = drupal_basename($destination);
        $directory = drupal_dirname($destination);
        $destination = file_create_filename($basename, $directory);
        break;

      case FILE_EXISTS_ERROR:
        // Error reporting handled by calling function.
        return FALSE;
    }
  }
  return $destination;

i am not able to find any way to get the fields delete.


texts: how to make an existing listbox autocomplete

texts:
I have made a content type which has a list box field. now I need to change its widget to autocomplete but as you know list box fields does not have autocomplete widget. now I have added 650 contents of that type and changing the field type would be my last solution because I can't spend time in editing 650 contents!
so is there any way to add an autocomplete widget to the current list box field?


texts: How Do i fix this in D8? there have been more than 5 failed login attempts for this account even flood table is not created in DB?

texts:
I check my DB there is no flood table even found. But getting error There have been more than 5 failed login attempts for this account. It is temporarily blocked

What else could stop me to login?

Thanks


texts: How to correct my Rules Component to perform VBO operations for the Group module?

texts:
I followed the instructions included in the answer to the question "How to implement the mass operations on the Group's members page using Views?". The 2 Rules Components in it (to either block or unblock a member), work fine (and my VBO view shows the mass operations that use those 2 Rules Components).

Now I want to create a similar Rules Component for one of the other typical mass update operations (as used in the context of the Group module).

Below is the Rules Components (in Rules export format) I created for this so far, to "Delete selected members":

{ "rules_remove_a_group_membership" : {
    "LABEL" : "Remove a group membership",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "USES VARIABLES" : { "group_mbrship" : { "label" : "Group membership", "type" : "group_membership" } },
    "DO" : []
  }
}

This Rules Component should implement the equivalent of the Update option "Remove selected members" (as shown on group/gid/member, with gid=group id).

My question:

Something seems wrong in the Rule Component shown above, since I can't get it to do the equivalent of the Update option of the Group module (using VBO, similar to the answer in the question I mentioned above).

So how to correct this Rules Component to perform the equivalent operation using a custom VBO action created using a Rules Component, so that with the addition of this component, my custom VBO page should be equivalent to the default page of the Group module?


texts: I can't login to Drupal as my session cookie was deleted?

texts:
I'm using Drupal 7, and have Pound running in front of Varnish for HTTPS.  I can browse the site via HTTPS, but can't login - each time I do, the server returns a 403 forbidden error.  Any ideas as to what is causing this?  I'm guessing something may need to be changed in settings.php, but not sure.

Output from Firebug:

POST user

Response Headers

Accept-Ranges   bytes
Age 0
Cache-Control   no-cache, must-revalidate, post-check=0, pre-check=0
Connection  keep-alive
Content-Length  0
Content-Type    text/html; charset=UTF-8
Date    Tue, 09 Oct 2012 17:49:08 GMT
Etag    "1349804948"
Expires Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified   Tue, 09 Oct 2012 17:49:08 +0000
Location    https://drupal.domain.com/user/2
Server  Apache
Set-Cookie SESSe15687525d17b8ec181665a71c88775c=EttXyyPvqESdU4RapW7xZkrRagGNHgRH5I9P6x0yRRE; expires=Thu, 01-Nov-2012 21:22:28 GMT; path=/; domain=.drupal.domain.com; httponly SSESSe15687525d17b8ec181665a71c88775c=mAdWa_a_OvcIIoWBuiVbLqFJzwyHiukfd_xBOVz_eaQ; expires=Thu, 01-Nov-2012 21:22:28 GMT; path=/; domain=.drupal.domain.com; secure; HttpOnly
Via 1.1 varnish
X-Drupal-Cache  MISS
X-Varnish   2081364495

Request Headers

Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection  keep-alive
Cookie  has_js=1; __utma=194497400.1529654640.1349804906.1349804906.1349804906.1; __utmb=194497400.3.10.1349804906; __utmc=194497400; __utmz=194497400.1349804906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
DNT 1
Host    drupal.domain.com
Referer https://drupal.domain.com/user
User-Agent  Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1

GET 2

Response Headers

HTTP/1.1 403 Forbidden
Server: Apache
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Tue, 09 Oct 2012 17:49:08 +0000
Cache-Control: public, max-age=300
Etag: "1349804948-1"
Content-Language: en
X-Generator: Drupal 7 (http://drupal.org)
Set-Cookie: SSESSe15687525d17b8ec181665a71c88775c=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.drupal.domain.com; secure; httponly
SESSe15687525d17b8ec181665a71c88775c=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.drupal.domain.com; httponly
Vary: Cookie,Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Content-Length: 8916
Accept-Ranges: bytes
Date: Tue, 09 Oct 2012 17:49:09 GMT
X-Varnish: 2081364496
Age: 0
Via: 1.1 varnish
Connection: keep-alive

Request Headers

GET /user/2 HTTP/1.1
Host: drupal.domain.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Referer: https://drupal.domain.com/user
Cookie: has_js=1; __utma=194497400.1529654640.1349804906.1349804906.1349804906.1; __utmb=194497400.3.10.1349804906; __utmc=194497400; __utmz=194497400.1349804906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); SESSe15687525d17b8ec181665a71c88775c=EttXyyPvqESdU4RapW7xZkrRagGNHgRH5I9P6x0yRRE; SSESSe15687525d17b8ec181665a71c88775c=mAdWa_a_OvcIIoWBuiVbLqFJzwyHiukfd_xBOVz_eaQ


texts: How to provide email notifications to admins for *all* comments?

texts:
My site admins are asking to receive email notifications automatically whenever a comment is posted on any content on the entire site. I already have comment_notify enabled, but that only allows them to get emails for comments posted on their content, or on posts they have subscribed to. They want to get those emails for all content by default.

I have also seen the "Notifications via e-mail comparison" page, but none of the module descriptions say they have this feature.

Am I stuck with having to implement a Rules based solution? Or am I missing something?


texts: AJAX doesn't work in custom form element

texts:
I want to create a custom form element for email that have a textfield and button and when click button send an email but ajax not working inside form elemen class. I test it in form api and it's ok but when move in form element on button click nothing happend
this is my code

<?php
/**
 * Created by IntelliJ IDEA.
 * User: peter
 * Date: 24/12/18
 * Time: 13:59
 */

namespace Drupal\aqr_basic\Element;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;

/**
 * Provides a form element to display a email.
 *
 *
 * @FormElement("aqr_email")
 */
class EmailElement extends FormElement {

  public function getInfo() {
    $class = get_class($this);
    return [
      '#pre_render' => [
        [$class, 'preRenderSelect'],
      ],
    ];
  }

  public static function preRenderSelect($element) {
    dump($element);
    $email = [
      '#type' => 'email',
      '#title' => $element['#emailTitle'],
    ];
    $email = array_merge($email,$element['email']);
    $btnSendCode = [
      '#type' => 'ajax_button',
      '#value' => $element['#btnSendCodeTitle'],
      '#ajax' => [                  //////this ajax not work
        'callback' => '::email',
        'event' => 'click',
      ],
    ];

    $btnSendCode = array_merge($btnSendCode,$element['btnSendCode']);
    $verifyGroup = [
      '#type' => 'fieldgroup',
      '#attributes' => ['class' => ['hidden']],

    ];
    $verifyGroup['emailCode'] = [
      '#type' => 'textfield',
      '#title' => $element['#emailCodeTitle'],
    ];
    $verifyGroup['emailCode'] = array_merge($verifyGroup['emailCode'],$element['verifyGroup']['emailCode']);
    $verifyGroup['btnVerifyCode'] = [
      '#type' => 'ajax_button',
      '#value' => $element['#btnVerifyCodeTitle'],
      '#suffix' => '
' . $element['#description'] . '
',
    ];
    $verifyGroup['btnVerifyCode'] = array_merge($verifyGroup['btnVerifyCode'],$element['verifyGroup']['btnVerifyCode']);

    $element = [
//      '#attached'=>[
//        'library' => ['aqr_basic/state'],
//        'drupalSettings' => [
//          'id' => $element['#id'],
//          'cities' => json_encode($cities),
//        ],
//      ],
      'email' => $email,
      'btnSendCode' => $btnSendCode,
      'verifyGroup' => $verifyGroup,
      '#attributes' => ['id' => ['email-wrapper-id'], 'class' => ['email_verify']],
    ];
    dump($element);
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
    return $input;
  }

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

    dump($form);

    return $form;
  }
}


texts:
I would like to show a "Thank you"-overlay after my contact form is submitted. I already tried this, but this seems to fire one step too early:
function my_theme_form_submit(&$form, &$form_state) {
    $form['isSubmitted'] = true;
}

{% if form.isSubmitted %}

Thank you!

{% endif %}

I could probably rewrite this whole thing into ajax, but a simple solution is much preferred.


texts:
I see that my user is a member of the apache group. I added and confirmed via the following

$ sudo usermod -a -G apache `whoami`  # add my user to apache group
$ sudo chmod -R g+w .                 # permit group members to write
$ groups `whoami`                     # confirm I'm in the apache group

However, when I attempt to run a drush update core or even drush cron

$ drush cc all

unlink(sites/default/files/css/css_71ba7c25a8d3c47c68a8e05608ae525c.css):[warning]
Permission denied file.inc:482

And the CSS cache in this situation looks like

$ ll
total 1536
drwxrwxr-x.  2 apache apache  12288 Nov 26 10:12 .
drwxrwxr-x. 11 apache apache   4096 Nov 24 20:35 ..
-rw-rw-r--   1 apache apache 162269 Nov 26 10:06 css_00d5f4d7c5c92cd4f.css
-rw-rw-r--   1 apache apache 158090 Nov 26 10:02 css_0605989692a2119d305.css
-rw-rw-r--   1 apache apache 162269 Nov 26 10:02 css_0779dcac71ee9aa8e02d9e.css

I would assume that my user account, which has sudo access, should be a group member of apache (or www-data) and that the file tree should permit group write access. Any help or points in the right direction would be much appreciated.


texts: Is it possible to use public:// for inline images (in text) to protect against changes in config?

texts:
There's a similar question here, but it concerns D6 or D7. It seems to me the suggested solution won't work in Drupal 8 for two reasons:

It's very unadvisable to attack the database directly with SQL, you should be using Entity queries and the API
As of D8, inline images become managed files, and are referenced as being attached to the nodes in which they appear - another reason for using the API.

I'm in the middle of writing a Drush command whose purpose is to go through all the inline images migrated from an existing (D6) site, detect them, enter them into the system as managed files, and attach them to their nodes. Looking at the file_managed table in the database, I see that the file URI is always public://something.jpg (for example), so that if you add an inline image via CKEditor then (with the default settings) it will be public://inline-images/mypicture.jpg (for example).

Well that seemed to me very cool, because it protects you from changes in the public files settings (for example, if you're building a site with shared code for multiple domains and the public files folders will change when it goes into production). So I started trying out using a URI in body text something like this:

But this doesn't work: the image doesn't show up and if I try saving it, the "public" gets removed so that it looks like this: .

When I enter an inline image through CKEditor in the normal way, I get something like this:

Is there any way of persuading the inline images to use "public://"? Or should I be looking at the Media Entity module (which I wanted to avoid, because it's overkill for my requirements)


texts: How do I limit the number of results from a search query with hook_query_alter?

texts:
I've followed the Drupal 7 documentation for hook_query_alter() in order to limit the number of total search results when searching for nodes or users to an arbitrary number.

However, with the following code (and the example in the documentation) this function has no effect:

function mymodule_query_alter(QueryAlterableInterface &$query)
{
    $query->range(0, 3);
}

The code is getting executed, because adding a line using the dpm() function works and information is outputted, so the hook is getting executed. However, the $query->range(0, 3) method appears to have no effect.

What am I doing wrong?

EDIT:

I am using the custom_search module for Drupal 7.

I can change the number of results displayed on each page with the following code in hook_query_alter():

$results_per_page = 20;

if ($query instanceof PagerDefault
    && ($tables = $query->getTables())
    && isset($tables['i']['table'])
    && $tables['i']['table'] === 'search_index')
{
    $query->limit($results_per_page);
}

But what I'd like to do is limit the total number of results before being paginated; if there are 234 results, I'd like to limit the number to, say, 100.

I am guessing that this is not working because I'm using the custom_search module.

Thanks.


texts: Password Protect viewing the account page

texts:
I want to make the user re-enter their password to view their account page similar to how some sites make you re-enter it to edit settings, I want to make them enter it to view their account.  Does anyone know if there is a module capable of doing this? I tried the Protected Pages Module with a password for /user and it put me in a redirect loop however it wasn't really what I need anyway.

I could also do it with a hook however I load and save the user object in a number of other places and it can't affect them.


texts: Assign to node all child terms if parent term selected

texts:
I started to develop my first website with drupal. So far so good, I like this system, but I have one problem:
When creating new node, I want to assign all child terms if I select parent term.

Let's say, I have a vocabulary "Plants".
In this vocabulary, there are terms with this kind of hierarchy:

Fruits
--- Apples
------- Green
------- Red
--- Pears
------- Green
------- Red
Berries
--- Wild berries
------- Red
------- Blue

Now, when I create a node, I'm using Simple hierarchical select to select terms of this vocabulary. I'm using Views to display nodes.
Let's say I want to assign term "Apples" to a node. When I go to view the page and use Filter Criteria Content: Has taxonomy terms (with depth) (exposed) and choose "Apples", I can see my node.

That's OK. But I want my node to appear if I select Green or Red (under term Apples in terms tree). In other words, if I assign term "Apples" in node creation page, I want it to assign all of its child terms also to this node. I.e., if I assign Wild berries, I want terms Red and Blue (childs of Wild berries) to be assigned also. Because right now, by assigning term "Apples" and then filtering by "Apples" gives what I want, but if I filter by Fruits->Apples->Green, I get no results.


texts: how to create template suggestion for image like image--NODE-TYPE--VIEW-MODE

texts:
I'm trying to create a suggestion like image--NODE-TYPE--VIEW-MODE, but in mytheme_theme_suggestions_image_alter() $vars i haven't node related info

thanks for help


texts: Manually importing webforms and data with mysql... where is it now?

texts:
I wanted to experiment and see if I could just import all the webforms, webform data, submissions, configurations, etc. from one Drupal 7 site to a new one. The import seems to have gone well but I can't see anything, even after clearing the caches. I even performed a MySQL query on the new site to see if the tables were actually populated.

    mysqldump -u root -p database_name webform webform_component
webform_conditional webform_conditional_actions webform_conditional_rules
webform_emails webform_last_download webform_report webform_roles
webform_submissions webform_submitted_data webform_validation_rule
webform_validation_rule_components content_type_webform> webforms.sql

Then I logged into mysql, chose the correct database and imported it:
source webforms.sql

Did I miss some other crucial table or something else? I have had a lot of success with migrating users and other info over this way even though I'm not sure it's wise and haven't found much in the way of doing data migration for Drupal without modules.


texts:
I want store owners to be able to offer node access to people who purchase their products.

The only problem with this, is when I give the permission "Create and edit NAP" to the developer/store owner role, it gives the permission to ALL nodes.

I've looked for a setting to change this, so that it is only for nodes who have the same author as the current logged in user, and I'm not seeing a way to do this anywhere.

What am I doing wrong? Is there a different module to accomplish this? Should I custom code something?


texts: Handling external authentication with routing.yml

texts:
I am building a new page (general use of "page", not literally referring to the node type) in my Drupal site that should only be accessible to members that have a certain permission. I have defined the routing for this in mymodule.routing.yml as follows:

mymodule.connector:
  path: '/mymodule/connector'
  defaults:
    _controller: \Drupal\mymodule\Controller\MymoduleConnectorController::content
  requirements:
    _permission: 'view mymodule entity'

This so far is working nicely, my accounts with this permission are able to view the content.

I also need /mymodule/connector to be accessible via an ajax request from a web view app that I made, which uses the same login credentials as my Drupal site, so essentially I need external authentication to work. I have tried to accomplish it by adding basic auth to my routing as explained here:

mymodule.connector:
  path: '/mymodule/connector'
  defaults:
    _controller: \Drupal\mymodule\Controller\MymoduleConnectorController::content
  requirements:
    _permission: 'view mymodule entity'
  options:
    _auth: ['basic_auth']

However, when testing with Postman, using Basic Auth with my user credentials, this is a 403 error.

Is something wrong with my routing? I am not sure what else it could be as I am not very experienced with authentication.


texts: How can I programatically change the content of a block and keep Full HTML formatting

texts:
I need to programmatically change the content of a ui configured block. I've partially figured out how to do this, ie:

$ids = \Drupal::entityQuery('block_content')
  ->condition('type', 'custom_block_type')
  ->condition('info', 'Specific block title')
  ->execute();

$my_block = BlockContent::load(array_values($ids)[0]);
$my_block->set('body','
'.$my_processed_string.'
');
$my_block->save();

This does change the content, but when I do this the block loses the Full HTML block format, and the new content in printed out verbatim as html encoded content (ie, the user literally sees '
My altered value
' on the screen). If I go through the ui and change the Text Format field manually to Full HTML, it renders correctly, but that doesn't really accomplish what I need to do.

How can I change the content programatically, without losing the html formatting?


texts: Only allow 1 submission from an email address in webform

texts:
I am taking some users information using webform, which is their name and email address.

I need to only allow one submission per email address, restricting the form by IP or cookie in the webform settings is not sufficient in this case.

Is this possible?


texts: Displaying a block on a content profile page passing the content profile nid into the block

texts:
I have a view block. It takes an argument to filter the content. The argument is the nid of a content profile. I then use a relationship to get the uid of the content profile. This uid means I only returns nodes related to the user of the content profile.

I wish to display this block on the users content profile page. So there would be a block listing nodes from the same user on there content profile. I am displaying the block using context.

What is the best way to get the filtering to occur. I currently am passing an argument which gets the nid of the content profile from the url. I have been told that I can do this by using spaces and contexts and not my custom php. How would you do this>


texts: Do I need to use hook_views_data like a custom table?


texts:
I have a large AD setup which has not been configured in the ideal fashion, the base DN:

dc=davinci,dc=mydomain,dc=local

Now the existing structure of our AD looks something like:

@ 1122 Logan
  Accounting
  Aquarius
    Alejandro
    Mike
    Justin
  Aerospace
  Distribution
  Engineering
@ 2150 Logan
  Uniflyte
@ 1480 Church

Trying to test the authentication of the user Alejandro (old network guy was being funny when he gave me a user name).

Here is my Server Property Dump:

Server Properties:

sid = Davinci
numeric_sid = 1
name = Employees
status = 1
ldap_type = ad
address = davinci
port = 389
tls = 0
followrefs = 0
bind_method = 2
basedn = Array ( [0] => dc=davinci,dc=cadorath,dc=local )
binddn =
user_dn_expression = cn=%username,%basedn
user_attr = samaccountname
account_name_attr =
mail_attr =
mail_template =
picture_attr =
unique_persistent_attr =
unique_persistent_attr_binary = 0
ldap_to_drupal_user =
testing_drupal_username = Alejandro
testing_drupal_user_dn = cn=Alejandro,ou=@ 1122 Logan,dc=davinci,dc=mydomain,dc=local
grp_unused = 0
grp_object_cat =
grp_nested = 0
grp_user_memb_attr_exists = 0
grp_user_memb_attr =
grp_memb_attr =
grp_memb_attr_match_user_attr =
grp_derive_from_dn = 0
grp_derive_from_dn_attr =
grp_test_grp_dn =
grp_test_grp_dn_writeable =
search_pagination = 0
search_page_size = 1000

I enter in my password for non-anonymous search (Windows login password)...

Testing Drupal DN:

  cn=Alejandro,ou=@ 1122 Logan,dc=davinci-1,dc=cadorath,dc=local

Drupal logs report:

LDAP bind failure for user userdn=, pass=XXX.

Where does the userdn get constructed???

I still cannot login to drupal with Windows login details...D7 is running in the same domain as Davinci so I assume I missing something in the syntax of connection string???


texts: Why does legend not appear when the first bar value is zero?

texts:
I have created a chart using Forena reports. I have added the legend by using the property frx:legend_entries="legend" from the frx file.
But when value of the first bar chart is zero or null, legend is not visible.

I am attaching the pictures below.


texts:
I have a custom form that needs to display a default value from a custom user field. The field was created under /admin/config/people/accounts/fields and its machine name is field_r_period_length_sec.

//get user
$userCurrent = \Drupal::currentUser();
$uid = $userCurrent->id();
$r_period = $userCurrent->field_r_period_length_sec;

However, the value doesn't show and I get this error:

  Notice: Undefined property: Drupal\Core\Session\AccountProxy::$field_r_period_length_sec

What am I doing wrong?


texts: How to completely export XML Sitemap configuration settings?

texts:
I have the XML Sitemap installed on a few sites, but due to SEO concerns, I am now tasked to enable the module on all sites that we support. I have an update hook ready, but I'm running into an issue importing the configurations.

When I export the xmlsitemap.settings.yml file, I just get  the following:

minimum_lifetime: 0
xsl: 1
prefetch_aliases: 1
chunk_size: auto
batch_limit: 100
path: xmlsitemap
frontpage_priority: !!float 1
frontpage_changefreq: 86400
lastmod_format: 'Y-m-d\TH:i\Z'
gz: false
clean_url: 0
disable_cron_regeneration: false
i18n_selection_mode: simple

I have rules setup for Media and Content, but as you can see it only picks up Frontpage. The goal is to make all these settings true for all the sites I handle.

I'd appreciate any help. thanks!


texts: Display a Views slideshow only if more than one image

texts:
I have a content type with an image field that allows multiple values. I have a View that displays the images using Views Slideshow.

If there is only one image added to a node, I just want to display it as a static image. If multiple images have been added, I want to display the slideshow View.

I'm using a Panels Page override for this content type, so I can use a visibility rule for the Views slideshow pane (i.e. only display if number of images > 1). But I'm not sure how to check the image field to see if there is more than one image for the current node?

Am using Drupal 7.


texts:
I am doing something wrong and am not able to find what.

I have defined the hook_menu for my module, add and delete are working fine, but edit and view are not. Is like are never being called.

function nutrition_menu()
{
  $items['admin/structure/ingredients'] = array(
    'title' => 'Manage Ingredients.',
    'description' => 'Manage Ingredients.',
    'access arguments' => array('administer ingredients'),
  );

  $items['ingredient/%ingredient'] = array(
    'title callback' => 'ingredient_page_title',
    'title arguments' => array(1),
    'page callback' => 'ingredient_page_view',
    'page arguments' => array(1),
    'access arguments' => array('view ingredients'),
    'type' => MENU_CALLBACK,

  );

  $items['ingredient/%ingredient/view'] = array(
    'title' => 'View',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,

  );

  $items['ingredient/%ingredient/edit'] = array(
    'title' => 'Edit',
    'page callbacks' => 'ingredient_page_edit',
    'page arguments' => array(1),
    'access arguments' => array('update ingredients'),
    'weight' => 2,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,

  );

  $items['ingredient/add'] = array(
    'title' => 'Add new Ingredient:',
    'page callback' => 'ingredient_add',
    'access arguments' => array('create ingredients'),
    'weight' => 1,
    'menu_name' => 'management',
    'file' => 'ingredient.pages.inc',
  );

  $items['ingredient/%ingredient/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('ingredient_delete_confirm',1),
    'access arguments' => array('delete ingredients'),
    'weight' => 1,
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_INLINE,

  );

  return $items;
}

load functions

function ingredient_load( $iid = NULL, $reset = NULL)
{
  $iids = (isset($iid) ? array($iid) : array() );
  $conditions = array();
  $ingredient = ingredient_load_multiple($iids, $conditions, $reset);
  return $ingredient ? reset($ingredient) : FALSE;
}

function ingredient_load_multiple($iids=array(),$conditions=array(),$reset=FALSE)
{
  return entity_load('ingredient', $iids, $conditions, $reset);
}

Callbacks

function ingredient_page_view($ingredient,$view_mode='full')
{
  $ingredient->content = array();

  field_attach_prepare_view('ingredient', array($ingredient->iid=>$ingredient),$view_mode);
  entity_prepare_view('ingredient',array($ingredient->iid=>$ingredient));
  $ingredient->content += field_attach_view('ingredient',$ingredient,$view_mode);

  return $ingredient->content;
}

function ingredient_page_edit($ingredient)
{
  var_dump($ingredient);

  drupal_set_title(t('Edit @name', array('@name' => $ingredient->name)), PASS_THROUGH);

  return drupal_get_form('ingredient_form',$ingredient);
}

Basically what I see is the two tabs ( View, Edit ) with no information bellow, the title isn't changing either.

Any idea?


texts:
I'm running on a restricted machine space/memory where I have to remove all un-needed modules.

Is it considered safe to uninstall core optional unused modules?.

modules like: Book, Forum, etc.


texts: Redirect to mobile page (not theme switching)

texts:
I'm looking for a way to redirect mobile users to a mobile landing page (and I'm not looking for a theme switcher). I have a specific page that I'd like to redirect mobile users to: www.mysite.com/m/

Is there a way to utilize Mobile_Detect.php and specify a single page as the redirect target?


texts:
On the content pages/nodes, there is a block that shows a list of the logged in user's friends. I need to make this list selectable so that the user can mark specific users and share/send the page to them.

Scenario: User1 is logged in and looking at an article. On the article page, a list of all their friends is available but clicking on the friend's name takes to that friends profile. I need to allow user1 to select one or more friends from this list and send them the node link through notification or email.

Is it even possible with block? If so, how? Or any other way of achieving the same?


texts: How to override a Insert module tpl file?

texts:
I'm trying to override a .tpl file from the Insert module in my D7 theme.

I copied the file from sites/all/modules/insert/templates/image-insert-image.tpl.php to sites/all/themes/mytheme/templates/image-insert-image.tpl.php.  I then made an edit to the copy in my theme directory and cleared cache.  I'm not seeing the change reflected when I insert an image using the module.

Just to make sure I had the correct file, I made the same edit to the original the file in the module directory and that worked.  What am I missing?

Thank you.


texts: Convert link from node/nid to Pathauto url?

texts:
Im using Pathauto to make my URLs nice and I may want to change the paths in the future. On some pages Im manually lining to other nodes.

The issue is that if I code the nice URL then the link will be broken if I change the Pathauto settings in the future. If I link to node/(the node id) then the link will always work, but its bad for SEO to not have keywords in the anchor text.

Is there a way to code in the NID so it always works but on the page show the nice URL?


texts:
I'm using Drupal 7 and the Computed Field module.  I have this problem with both the Custom Content Type and Custom Entity Type.

When I add a computed field and go to the Field Settings, I type some PHP code and click the Save field settings button, the page merely reloads with my code deleted and I'm back where I started.

Is this a bug? Or is it maybe not liking my code and deleting it rather than causing a fatal error? But it fails even with simple code like $entity_field[0]['value'] = "test"; that gets deleted too. Is it possibly not allowing me to add a computed field since I have already created contents and entities of those contents and entity types?


texts: How do I create a new admin sub page and how to make it appear in the admin menu?

texts:
Let's say I have to create an extra users management views block for contributors role only, with some different columns, filters and actions available.

How do I create a simple page which is restricted to some roles only and automatically has the backend theming to put my views block in there? (I always put views blocks on pages, it makes editing views easier)

And last, how can I make that page appear in the admin toolbar as sub item of admin/people?

Do I have to write a custom module for that or maybe create a template file? Or is that maybe all in all a wrong approach?


texts: How to enable translation for file entities?

texts:
I need to import files (images) that have a title and description, for multiple languages.

When I go at admin/structure/file-types/manage/image/edit/fields/file.image.field_image_title_text to enable translation for this field, it says To configure translation for this field, enable language support for this type.

When I go at admin/config/regional/content-language?destination=/en/admin/structure/file-types/manage/image/edit/fields/file.image.field_image_title_text and check File in Custom language settings, I see following message : File (Translation is not supported).

How do I enable field translation for file entities?

Thank you!


texts:
Possible stupid question but worth a punt...

My local OS X setup uses Acquia Dev Desktop. I recently changed a remote site's .htaccess file to redirect all no www. URLs to their www. equivalents (done my uncommenting the relevant 2 lines already in Drupal 7 core .htaccess). Pulling this change down to my local setup now means that my local dev version can no longer be navigated to.

Running cron and clearing all caches via Drush doesn't seem to help in any way.

Do I have to use a different .htaccess file for local and remote setups or am I missing something here?


texts: Configuring Fail2ban for the r4032login module

texts:
Recently, I installed fail2ban on my server to help prevent bots from abusing the site.

I have the r4032login module installed and it is writing to the log, but it is using HTTP status 302 for the redirect to the login page.

I'm wondering what would be the easiest way to have fail2ban work alongside the r4032login.

Here is a sample log entry:

ddd.ddd.ddd.ddd - - [12/May/2019:14:46:26 -0400] "GET /node/1/edit HTTP/1.1" 302 4305 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"

https://www.fail2ban.org/wiki/index.php/Main_Page

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


texts:
How do I create an exposed filter for a localized taxonomy term? My vocabulary is set to 'Localize' and I'm able to create a translation for each term in this vocabulary. In my View, however, I can't add a localized taxonomy term to the filter. This is an exposed filter and I'd like the selection items to show up in the user's language.

How do I display localized taxonomy terms in a filter?


texts: Get field value in an entity form validation

texts:
In an entityform "form_alter" function I have $form_state with all the info inside I need.
I could "hard-code" the language, but this is a multi language site...
The information needed is at: $form_state['values']['field_myone']['en'][0]['value']

I'm aware of field_get_items or entity_metadata_wrapper, but I can't get either one to work.

This doesn't give me a wrapper back:

$wrap = entity_metadata_wrapper('entity_form', $form_state);

And this one doesn't work either:

$val = field_get_items('entityform', $form_state, 'field_myone');

Any help out there?

Thanks!


texts: Why does my site still use URLs containing the "q" query parameter?

texts:
I have pathauto, transliteration and automatic node titles enabled.

In the settings, my content path pattern is content/[node:title]. I expect the URLs to be in the format site/content/page-name, whereas what I have is site/?q=content/page-name.

I cannot figure out why. Do you have any idea?


texts: Views Context Filters Hierarchical Cascade / Inheritance

texts:
I have a hierarchal taxonomy but I'm having trouble getting a view of it to do what I want, and while it seems logical to me, I'm not sure it is even possible.

The hierarchy is geographical areas:
Country>State>County>City

I want a view that can take the hierarchy out of the URL (ie USA/Idaho/Adams/Meadows) which I have achieved using three filters, each a reference to the first 3 iterations of the parentage...

The problem is I don't want that requirement for ALL the levels of parentage... I want something like:

if arg1 arg1 == taxo:parent:parent:parent:field
  if arg2 compare arg2 == taxo:parent:parent:field
    if arg3 compare arg3 == taxo:parent:parent:field
      if arg4 compare arg4 == taxo:field
      else compare arg3 == taxo:field
    else compare arg2 == taxo:parent:field
      if arg3 compare arg3 == taxo:field
  else compare arg2 == taxo:field
else compare arg1 == taxo:parent:parent:field
  if arg2 compare arg2 == taxo:parent:field
    if arg3 compare arg3 == taxo:field
  else compare arg2 == taxo:field

So the these result examples would yield the following:

/viewpath/USA/New-Meadows

Would give me every state, county and city in the US called "New Meadows"

/viewpath/Idaho

Would yield every state, county and city in the dataset named "Idaho"

/viewpath/Idaho/New-Meadows

Every state, county and city called "New Meadows" in a country called Idaho
Every county and city called "New Meadows" in a state called Idaho in any country
Every city called "New Meadows" in a county called Idaho in any state in any country

...and I can't figure out how to get that functionality to work in Views, nor can I see anywhere that says if it is possible or not.


texts: How to pass Views contextual filter via URL?

texts:
I want to pass some values to my view via contextual filters in the URL. What GET naImes do I use? There seem to be no clue given, just this "The contextual filter values is provided by the URL".

If I have to construct that URL, how do I find out what GET var names do I need to pass so they are recognized?


texts: Why we go for template files and why we go for theme function?

texts:
Possible Duplicate:
  When should I add a new tpl.php file, and when should I implement a theme function?

To theme a form: There are two ways.

using function theme_themename_form($form)
Assigning to a variable in preprocess and printing it in the template files.

My question is:

Why two ways?
Which way is best for which case ?

That is for which type of cases we should go for function theme and for which cases we should go for template files.
What is all time best way?


texts: Where is the pager data in the Views object

texts: I am trying to alter the number of items per page in a View, programmatically. When I display the Views object returned in hook_views_pre_execute, I see fields for in $view->query for items per page, etc., but despite the view initially having a setting of Display a specified number of items: 6, it appears nowhere in the object, that I can find.


texts:
im using form api and im trying to get to make a group of fields under one type, like for example a phone number, you would have 3 fields 1 being the area code and the other 2 fields being the number

I would think it would be something like this..

$form['phone'] = array(

    '#title' => 'Phone Number',
    '#tree' => TRUE
);

$form['phone']['areacode'] = array(
    '#type' => 'textfield',
    '#maxlength' => 3,
    '#size' => 3,
);

$form['phone']['number1'] = array(
    '#type' => 'textfield',
    '#maxlength' => 3,
    '#size' => 3,
);

    $form['phone']['number2'] = array(
    '#type' => 'textfield',
    '#maxlength' => 4,
    '#size' => 4,
);

or even something with options like this for example

$form['phone'] = array(
    '#type' => 'textfield',
    '#title' => 'Phone Number',
    '#tree' => TRUE,
    '#options' => array(
        array(
        '#value' => t('areacode'),
        '#maxlength' => 3,
        'size' => 3,
        ),
        array(
        '#value' => t('number1'),
        '#maxlength' => 3,
        'size' => 3,
        ),
        array(
        '#value' => t('number2'),
        '#maxlength' => 4,
        'size' => 4,
        ),

    )
);

Either way I want to have multiple textfield values under one form type.

Thanks


texts: Node reference field auto complete in views

texts:
I have content type master program and slave program.

Slave program have node reference field with master program

I created a view for filter and show the slave program list

For node reference field it is showing as dropdown

but I want to display as autocomplete textfield.

I searched view_auto_complete and node_reference_autocomplete modules

I dont know how to implement these

Can any one help me ?


texts: "This theme is missing a 'content' region".?

texts: while creating my custom theme i am getting a error "This theme is missing a 'content' region.".please have a look on screen attached(designed by manoj kumar).any help would be appricated.


texts: drupal_add_js() includes JS with wrong weigth

texts:
A module I am using on my site uses the drupal_add_js() function to include some JavaScript. Although the function is used correctly the JavaScript file is included before the jQuery script which causes an error.

drupal_add_js(drupal_get_path('module', 'rate') . '/rate.js', array('scope' => 'footer', 'group' => JS_THEME));

Even if I add the weight option ('weight' => 500) it keeps be added before the jQuery script.

What am I supposed to do?

I am using newest Drupal 7, Rate API, and Rate widget.


texts: Is it possible to change how entity reference field is displayed?

texts:
I have an entity that I has a taxonomy reference in it.  it currently looks like this

and I want this

Is this one of the options in display options array?  Or is it something different?  How do I change this?

This is my code

$fields['category'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Category'))
      ->setDescription(t('Section this poll is to appear on'))
      ->setSetting('target_type', 'taxonomy_term')
      ->setTranslatable(TRUE)
            ->setDefaultValueCallback('Drupal\poll\Entity\Poll::getMain')
      ->setDisplayOptions('form', array(
        'type' => 'entity_reference_autocomplete',
        'weight' => -10,
        'settings' => array(
          'match_operator' => 'CONTAINS',
          'size' => '60',
          'autocomplete_type' => 'tags',
          'placeholder' => '',
        ),
      ))
      ->setDisplayConfigurable('form', TRUE)
            ->setRequired(FALSE);


texts: form_comment_form_alter modify comment body

texts:
I am using hook_form_comment_form_alter to add values to the textboxes in the commenting form. But in the comment body I can seem to add a default value
and can't seem to find a value that I can change. Does anyone have any ideas?

function mytheme_form_comment_form_alter(&$form, &$form_state, $form_id) {
  dpm(get_defined_vars());
  $form['author']['name']['#title'] = "";
  $form['author']['name']['#default_value'] = "Name";
  $form['author']['name']['#title'] = "";
  $form['author']['mail']['#default_value'] = "Email";
  $form['author']['mail']['#title'] = "";
  $form['author']['homepage']['#default_value'] = "Website";
  $form['author']['homepage']['#title'] = "";
  $form['author']['subject']['#default_value'] = "Subject";
  //$form['comment_body']['need default value']= 'I need to add a value';
}


texts: How do I restrict a user from edit his/her own profile

texts:
I have some custom fields added to the user profile. some of these fields are filled and synced autimatically from an LDAP account and others only admins can fill.
I want to keep these aditional fields on the profile page but don't want to let the user itself modify these.
how can I restrict a user from edit his/her own profile?


texts: How do I import a Drupal site and make changes?

texts:
I wanted to do something similar to whats asked in te below post.

How to import a live Drupal site into Acquia Drupal Dev Desktop?

I have the local version up and running by importing it to  Acquia Drupal Dev Desktop. Now am not able to modify the content.
 Could someone please elaborate the below statement that was part of the accepted answer for the question I referred.
"Then use the Backup and Migrate module again on the local site to synchronize the database. "


texts: Access denied to login to original node id

texts:
Scenario is this:

User sent a link to a website where they must be authenticated to view content.
User clicks link.
They have an account but their session has expired so they get 403 access denied page.
They login.
The ideal outcome is they are redirected to the original link they tried to access.

I can get a login form to show on the 403 page but can't redirect to the node.

Has anyone any experience of this?


texts: UPDATE database field with value from other table

texts:
I'm basically trying to build a query which looks something like:

UPDATE table_a, table_b
SET table_a.value = table_b.value
WHERE table_a.id = table_b.id;

It seems that a query like this is functionally equivalent:

UPDATE table_a
INNER JOIN table_b
  ON table_a.id = table_b.id
SET table_a.value = table_b.value;

The thing is that I can't figure out how the UpdateQuery allows me to attach a second table like that. I tried just adding a ->join('table_b') to my update query object, but I'm told that method is undefined. Argh.

I've ended up cheating by using db_query(), though I'm still curions to know if there's a way to do this properly using the API.


texts: How can I enable/disable programatically added fields from a custom module?

texts:
I'm trying to create a custom module for payment. When installed, the module automatically adds two fields to the 'Article' content type.

I have 'enable/disable checkbox' in the form:

Enable: Should mean that people on my live website can use it

Disable: Should mean that no-one can use it (I don't want to remove the variables or the fields in the article content typ, I just want to hide everything in relation with the module)

Is there any hook or any thing that can do that?  Turn the module off?


texts: What's the best way to include PHP in nodes?

texts:
We're converting some sites over to a Drupal 6 multi site and we have a number of existing pages that make heavy use of PHP.

What's the easiest way to include these scripts, assuming that they may want to live in different menus in different languages, and that we want these pages to also work like other pages on our site (e.g. take advantage of Rules, Views, CCK etc).

Using hook_menu() to create a MENU_CALLBACK seems to mean we couldn't
treat them like other pages (have people edit titles/content, use
Views/Rules etc).
Using hook_nodeapi() to add the PHP only works if it is always at the end (or beginning) of any content.
Using the PHP filter to include a file works, but means editors would need the right to use PHP.

The solution I'm leaning towards is creating a custom filter that replaces a keyword/token with a file/function so editors would add {{FOO_SCRIPT}} to their page and the relevant code would get included.

Is there a better way?


texts:
I tried to change the domain name of the existing site and now when I try to access the domain, it comes up with the drupal install screen.

Initially the domain name was stage.othercompany.com and now I changed the domain name to stage.mycompany.com. I changed the folder mapping in sites.php and cleared all the cache in the Drupal database. I have also restarted the Apache server but still I get only the install screen. Please help with this issue. Is there any other setting that I have to change? I have also changed the $base_url variable in settings.php in the respective multi site folder.

Update:

I checked the file_managed and file_usage table and both are empty.

I tried creating a directory called stage.mycompany.com under stage with all the module, theme,files folder and setting files from stage.othercompany.com folder and it seems to work now. I also tried with a symlink to the folder and that works as well.

My doubt now is that drupal is not honouring the sites.php. Can can one point me in the right direction please.

sites.php

$sites['stage.mycompany.com'] = 'example.com';

and the folders in sites directory are

all, default and example.com

Thanks for your help in advance.


texts: Proper directory permisions for module installation?

texts:
So I'm trying to understand the correct permissions for file directories in order to install a module. I've installed drupal, and I try to install a module, which looks like so:

But When I click install it takes me here:

I then wanted to test if it was permissions preventing it from installing, so I chmod'd everything to 777 in the sites folder just to see, and yes, the module then installed easily and correctly. But of course, 777 on everything is insecure, so I quickly installed drupal again from scratch. So now when I check the permissions they look like this

html/sites$ ls -l
total 16
drwxr-xr-x 5 6226 6226 4096 Jun 17 18:38 all
dr-xr-xr-x 3 6226 6226 4096 Jul 19 20:08 default
-rw-r--r-- 1 6226 6226 2365 Jun 17 18:38 example.sites.php
-rw-r--r-- 1 6226 6226  904 Jun 17 18:38 README.txt

So after an installation the all folder has r-x permissions and the default has r-x as well for group and other. (A side question being, what do I make of the user and group, "6226", "4096","2365", and "904"?)

The "modules" folder, inside "all" folder where they get downloaded is also set to r-x.

html/sites/all$ ls -l
total 12
drwxr-xr-x 2 6226 6226 4096 Jun 17 18:38 libraries
drwxr-xr-x 2 6226 6226 4096 Jun 17 18:38 modules
drwxr-xr-x 2 6226 6226 4096 Jun 17 18:38 themes

I don't know if this seems right to me. Shouldn't it be able to write to the folder to download the module from an external source?

Thanks for all the feedback in advance, I look forward to hearing what people have to say.

Edit, more details:

Linux myhostname 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@myhostname:/var/www/html/sites/all/modules$ ls -la
total 12
drwxr-xr-x 2 www-data 6226 4096 Jun 17 18:38 .
drwxr-xr-x 5     6226 6226 4096 Jun 17 18:38 ..
-rw-r--r-- 1 www-data 6226  952 Jun 17 18:38 README.txt

Okay! So. after reinstalling and repeatedly chowning folders until I made it past that request for FTP details, I finally got it to ATTEMPT to download the file. All I had to do after a fresh install was sudo chown www-data /var/www/html/sites/default. What confuses me is why that would work. Beause before and after chowning, the permissions were dr-xr-xr-x 3 www-data 6226 4096 Jul 20 09:03 default for the default folder. So my understanding is that the owner, group, and others could all all read and execute, so why would changing the owner even matter?
Now when attempting to "Install from a URL" after chowning default, a loading bar appears and says "Completed 100%", and then this screen appears instead of the FTP login request:


texts: Path alias creates redirect loop or redirects to the front page

texts:
When I call our sit "www.example.com/contact-us" I'm getting the following error:

  Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!

If I call the site with "www.example.com/node/5" the contact page is displayed just fine.

When I check the path alias on /admin/config/search/path/edit/6, system path and alias are set correctly.

Another problem exists for another alias, when I call "www.example.com/staff" I'm getting redirected to the landing page "www.example.com". Once again the alias is set correctly.

We're using Drupal 7, and the i18n_redirect and redirect modules.


texts: Can I autopopulate between different users' forms with Rules and Webforms or EntityForms?

texts:
I need to create a form in which some fields auto-populate with the values submitted on other users' forms. Specifically, the manager has to submit a form documenting the progress of projects a, b, and c. However, the manager needs the option to ask another staffer to complete a form for one of the projects. So when the staffer submits the form, their value of textarea field "Project B Status" autopopulates into the field "Project B Status" on the manager's form. The manager can then edit staffer's text if necessary and submit the final report.

I have tried doing this using both WebForms and EntityForms and have tried using Rules to autopopulate. I cannot get it to work right, but before I continue I would like to know if these are the best modules to use or if I am doing something wrong (as I am fairly new to Drupal).

Many of the answers I have seen on this issue involve editing the actual php, which I would prefer not to do at this point (but will if someone can tell me specifically what to do).


texts: update a module in the front page after adding new content into another page

texts:
I want to create a block on the home page which highlights the latest news from the 'news' page. I would like to add new content into the 'news' page frequently. Every time when I add a piece of new article (news), I would like the block to show the image and the title of that new article automatically.

What is the best way to achieve this?

Thanks


texts: Need to find and disable an email that may be coming from a module

texts:
Drupal 7 question: There is an email that goes to users that seems to be produced by a module (on a role change) that is confusing to a specific client's users. They would like me to disable that specific email, but I have not been able to figure out where to do that.

I've gone through the users and roles and configuration for the module. I've done a search on the text in the site files (the snippets of text that do not have field-specific data) and come up empty.

So, generically, I'm wondering about how to disable emails from being sent if there doesn't seem to be a setting to do so in the dashboard. I would be happy to add more information here that is about the module specifically, but it seems that it would be helpful to have some generic pointers of where to look, in case the situation comes up in other modules, as well.


texts: What is the best approach to map Drupal Users to the same user profile that is in SalesForce? Essentially I would want to add the User UID to their corresponding SalesForce User profile. But if there is a better way I would love to know. Thank you.


texts:
In drupal 7 I have a chunk of code that gets the page content by mimicking what drupal does:

$router_item = menu_get_item($href);
if ($router_item['access']) {
  if ($router_item['include_file']) {
    require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
  }
  $page_callback_result = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}

$page_callback_result will then hold the HMTL of the content region of that page.

I'm trying to port this to drupal 8 but I'm stuck. Anyone has a clue how to do this?
I'm close, but I'm struggling on getting the controller:

 $request = Request::create('/' . $href);
 $controller_resolver = \Drupal::getContainer()->get('controller_resolver');
 //$controller = $controller_resolver->getController($request);
 $callable = $controller_resolver->getControllerFromDefinition('\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage');
 $arguments = $controller_resolver->getArguments($request, $callable);
 $page_content = call_user_func_array($callable, $arguments);

The problem is that $controller = $controller_resolver->getController($request); returns FALSE. I'm trying to get the proper controller for a request, for some reason this won't work...


texts:
I have a problem with translating my configuration form in Drupal 8, particularly with rich text fields.

This is my configuration file.

langcode: en
more_info_text: 'More info'
first_link_list:
second_link_list:
third_link_list:

Here is my schema file:

customization.config:
  type: config_object
  label: 'Website config'
  mapping:
    more_info_text:
      type: text
      label: 'More info text'
      translatable: true
    first_link_list:
      type: text_format
      label: 'First link text'
      translatable: true
      class: '\Drupal\Core\TypedData\Plugin\DataType\StringData'
    second_link_list:
      type: text_format
      label: 'Second link text'
      translatable: true
      class: '\Drupal\Core\TypedData\Plugin\DataType\StringData'
    third_link_list:
      type: text_format
      label: 'Third link text'
      translatable: true
      class: '\Drupal\Core\TypedData\Plugin\DataType\StringData'

The form itself works fine, but I cannot get the text format working for translations of the fields; it's always missing.
Any ideas?


texts: How to solve a situation where two or more routes with different controllers point to the same path ?

texts:
For example, we have two routes, which points to the same path.

And each route has its own controller.

For example, I have defined a route with controller, which has a path "node/1", whereas a node with id=1 is already added to the site.

How can we determine, which controller will be started ?

And how can we select and assign forcibly controller to start, which we need ? For example, in my case for path "node/1" we don't want to start the NodeController, but we want to use the controller, defined in our module. Or Vice versa.


texts: mp3 not loading in opera and chrome when in private folder

texts:
I have audio on my site which is rendered through media module. The audio files are in private folder at sites/files/private

In firefox, all is fine. But in opera 31 and chrome 45 the files do not load. In the browser inspector there is error about not being able to load the mp3s which drupal specifies in the audio element as example.com/system/files/file.mp3. Now, the url given to the audio element is of course not the true url, so I know in the background drupal is taking care of the proper rendering. So why would the rendering fail in opera and chrome?

Here is an example.


texts: Do page arguments in hook_menu get sanitized?

texts:
The title pretty much says it all.

If a callback is defined in a hook_menu, such as

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

    $items["mymodule/foo/%"] = array(
        "page callback" => "mymodule_foo",
        "page arguments" => array(2),
        "access arguments" => array("mymodule permission"),
        "type" => MENU_CALLBACK,
    );

    return $items;
}

function mymodule_foo ($parameter)
{
    // do stuff
}

When the callback gets called, has $parameter been sanitized, or is this the responsibility of the module?

I always sanitize in the module, but have never seen this stated either way and haven't found where callbacks get called from core.


texts: Drupal view shows multiple results to a single row

texts:
I am using a view with table format.

I need to show results in a given format. I am unable to find..

Can anybody tell me how to achieve in views..

Thanks


texts:
It seems when I try to save a node with FileField populated with a file that exceeds the PHP limit, Drupal just returns to node/add without any error messages.

This is bypassing the AJAX upload.

Ideally, there should be an error message that tells the user why they are being returned to a blank form.

I tried this on pretty-much fresh install too and I'm still getting this behavior.


texts: User registration silently fails - how to debug?

texts:
On our Drupal 7 site, user registration silently fails.
Drupal doesn't even reach the form's validation functions.

What we checked:

disabling javascript didn't help.
Removing installed modules related to registration such as : logintoboggan, user_registrationpassword didn't help.
Error logs show nothing.
The user module is of course enabled, people are able to login as usual.

Please advise where to put tests to see where execution is stopped.

Thanks in advance

Amnon


texts: How does Drupal find contributed modules and themes?

texts:
I have a development site with a peculiar problem  Although the contributed modules and themes are in their proper place under sites/all/modules (& themes) I am getting an error message that says that my custom theme cannot be found.  Also, the modules list does not include any of the contributed modules.

The error message indicates that it does not find my default theme:

  Notice: Undefined index: CR_Stark in drupal_theme_initialize() (line
  100 of /example.com/includes/theme.inc).
  Notice: Trying to get property of non-object in
  _drupal_theme_initialize() (line 145 of /example.com/includes/theme.inc).

While I would assume that the relative locations of these custom directories is hard coded in Drupal core, the fact that it cannot find the modules when they are in the correct place suggests that there may be a missing variable or setting.  I have checked the sites/default/settings.php file and looked through the variables table in the database, but cannot find a reference that would serve this purpose.  Can anyone point me in the right direction?

EDITS:
per suggestions in comments:

Caches have been cleared frequently without change
Changing to a default theme removes the theme error, but it is replaced with an error I believe is tied to not knowing where the custom modules are.

  Warning: opendir(sites/all/modules): failed to open dir: Permission denied in file_scan_directory() (line 2034 of example.com/includes/file.inc).

Line 2034 is in the core function file_scan_directory () and reads if (is_dir($dir) && $handle = opendir($dir)) {; so it looks like Drupal is searching for a custom module (or theme) directory it cannot find or access. The directory access settings are correct.

The directory settings in the systems table are correct and the contributed modules and theme are all included.

This may not be the solution, but it is one resolution, of a sort.

I recreated the site from scratch with a new core install and copied all of the contents of the sites/all/... directories to the new site.  I then imported the entire database from the affected site into the new one and ran update/php.  This new site is seeing everything fine.  These dev sites are being run on a virtual box running Ubuntu.  It may have had something to do with settings on the directories from the OS, but I could not find it.

If anyone else has had a similar problem and found a source for the problem, please post it here.


texts: how to hidden a taxonomy menu item use hook?

texts:
I have built a web site which has a content type call product and  product taxonomy

product taxonomy has sat a boolin function makes user select to show up for anonymous user or not

If the user selected the taxonomy parent boolin function the taxonomy parent has disappeared form the menu system.

When the user selected the taxonomy boolin function I want to hide the taxonomy parent link

this is my code

function hellosanta_menu_alter(&$items){
    $items['taxonomy/term/82']['access callback'] =  False;
    $items['taxonomy/term/82']['type']=MENU_CALLBACK;
}

I have got nothing for this


texts: I have a View, with its corresponding SQL query. I want a field to be a subquery ( SELECT * FROM TABLE table WHERE ... ) with its corresponding result fields. I don't know if this is allowed, it seems more like a field which is another View in itself, to be called from my View. Is that possible at all?


texts: Query to include if condition in addField

texts:
How can I include an if condition to my drupal 7 query. This is my query.

$query = "SELECT N_en.nid AS en_nid,
  IF(N_lan.translate = 1, 'Outdated', 'New') as lan_translated,
  FROM node N_en
  LEFT JOIN node N_lan ON N_lan.tnid = N_en.nid "

I tried

$query = db_select('node', 'N_en')->extend('PagerDefault');
    $query->addField('N_en', 'nid', 'en_nid');
    $query->addField('N_lan', 'translate', 'lan_translated');
    $query->leftJoin('node', 'N_lan', 'N_en.nid=N_lan.tnid AND N_lan.language=:lang', array(':lang' => $userLan));

How can I give my if condition for N_lan.translate?


texts: How to display custom block without default wrapped html around

texts:
I have custom module with new block. When this block is displayed, the output is wrapped with html tags from block.tpl.php template:

<section id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

I would like to display only content without the wrapped html around. I can accomplish this by overriding the block.tpl.php file in the theme, however. This requires me to go into every possible theme and override the template file every time installing the module. How to avoid that? How to display only content of the custom block from custom module without overriding template file?
Is there some attribute that i can set in the block render array like #theme_wrapper?:

$block['content'] = array(
               '#markup' => '
Hello World!
',
              // '#theme_wrappers' => array('attempt_to_override'),
)

I was thinking the 'theme_wrappers' attribute can be used, but i wasn't able. Thank you for any help


texts: How can I set the energy settings for the Radioactivity module?

texts:
I saw in this screencast (from 4m 20s) that a lot of cool features were available to set the energy settings in Drupal 6. One could for example give specific scores when nodes were viewed or evaluated with Fivestar.

Is this possible in Drupal 7 too? I can't find any documentation about it...


texts: Error - Sharing the Same URL for two different views in exposed filter

texts:
My goal is to prepare glossary based on contents

I have used two views, one is alphabetical search and another one is keyword search filter.

In alphabetical search, I grouped the alphabets and setted in the block and then clicking the letters, It will take to the page which contains the particular content. And here, I have used the URL is local host/glossary.

In Keyword search, Here also used the same URL (localhost/glossary), I setted the search functionality in the block and when searching the content using keywords of contents.

Its not filtering for keyword search, does only for alphabetical search.

I want to filter the both in same URL.

Please help me to sort out this issue.


texts: How to redirect everything to 404 not found?

texts:
I need to block an entire Drupal 7 site from being indexed for a while. So, I think it is best to redirect everything to 404 instead of actually deleting all my files. How can I do that?

PS: using the following code on .htaccess does not seem to work.

RewriteEngine On
RewriteRule ^ - [R=404,L]

-- Update 03/04/2015 --
The server is nginx


texts: Is it possible to automatically add a taxonomy term for a content type?

texts:
How is it possible to automatically add a taxonomy term for a content type?

Is it possible to make the new added terms children of this automatically set term?

I have a content type intended for users, and I would like them to be only able to add terms that are children of a parent term of my wish; in this way, if they choose a term, it will become a child of my default term, but if they don't add a term, then the node will be tagged automatically with my term (the parent term).


texts:
Drupal 7 I have a content type called "Question" with a Answered/Not_answered field for editors.
I want to create a view of all questions which has a header of answered and unanswered questions. Something like this:

Answered questions: 10
Unanswered questions: 2

with links to answered and unanswered questions.

Can anyone please help me to create this view?

Many thanks, Alice


texts: 500 HTTP error on "Manage Display" tab after changing layout with Display Suite! What should I do?

texts:
I changed the layout to "One column" with Display Suite on a given content type's "Manage display" tab, which has many (~30) fields. I'm also using Field group module with multiple groups.
After saving, DS has set some group's parent elements to "Disabled". OK, I changed it, I dragged these to the enabled part, and after saving, I got a 500 HTTP-code when going to "Manage display" tab after a long waiting time!

What should I do? Can I simply uninstall Display Suite module? Will it reset the display to my original settings and field orders?

Thank you for any kind of ideas!

EDIT

Uninstalling the module did NOT solve the problem.... I'm in a real big trouble, because I don't know how to reset the display...
Any ideas?


texts: Ajax drop down list problem with callback

texts:
I need a little help here.
In a custom module, I add a little form where you type your zip code, press a button and a drop down list populates (via ajax) with the stores that are close to that zip code so you can choose one of them. The problem is when you click on that button the callback is made but the zip code field remains empty, seems like I missing something that can bring the zipcode value to that part when the  refreshes.
some ideas?? thank you

    function mymodule_form($form, &$form_state) {

       $form['zip_code'] = array(
        '#type' => 'textfield',
        '#title' => 'zip code',
        '#size' => 5,
        '#maxlength' => 5,
        '#required' => TRUE
      );

      $form['button'] = array(
        '#type' => 'button',
        '#value' => 'find stores',
        "#limit_validation_errors" => array(),
        "#name" => 'mybutton',
        '#ajax' => array(
          'callback' => 'reload',
          'wrapper' => 'stores-div',
          'method' => 'replace',
          'effect' => 'fade'
        )
      );
      $form['select_str'] = array(
        '#prefix' => '
',
        '#suffix' => '
'
      );
      if(isset($form_state['values']['zip_code'])) {
        $arr = find_store($form_state['values']['zip_code']); //here is my main problem, $form_state['values']['zip_code']is always empty even after the callback
      } else {
        $arr[99999] = 'theres none';
      }
      $form['select_str']['stores'] = array(
        '#type' => 'select',
        '#title' => 'stores near you:',
        '#options' => $arr,
        '#required' => TRUE
      );
      $form['submit_button'] = array(
        '#type' => 'submit',
        '#value' => t('Send!'),
      );
      return $form;
    }
    function find_store($zc) {
        $fields = array(
                'zc'=>urlencode($zc),
            );
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,"http://somepage.php");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
        $result=curl_exec ($ch);
        curl_close($ch);
        $arr = array();
        if($result!='none') {
            $explode=explode(',',$result);
            foreach($explode as $value) {
                $stores = explode('|',$value);
                $arr[$stores[0]] = $stores[1];

        }

    } else {
        $arr[99999] ='theres none';
    }
    return $arr;

}
function reload($form, &$form_state) {
  return $form['select_str'];
}


texts: How to display children terms for 3rd or 4th level taxonomy term using views?

texts:
How does one create (in a view) a list of the children (2nd, 3rd or 4th level) of a taxonomy vocabulary? In other words, if I want to display ONLY the 3rd level down of a parent term. Is that possible?
Thanks. :)


texts: When should I use methods, get() and magic offset

texts:
There are three different ways to get an entity value, for example the node content type.

$node->type->value
$node->getType()
$node->get('type')

Which one should I use?


texts: Query for email address already existing

texts: I want to customise registration form action in my drupal8 site.I want to check email address is already existing.I have tried with different queries.But not worked.Can anyone to help me to solve this issue?


texts: Drupal 7: Display Latest Revision's Author on the Admin Content Overview page with Admin Views Module

texts:
Does anyone know the methodology to display the author of the latest content revision, using the Admin Views module on the content overview page (e.g. /admin/content)?

It's easy enough to display the initial author, or the VID of the latest revision, but I'm not sure how to create the relationship to the author of that latest revision and then display it.

Thanks!


texts: entity reference as part of a fieldset of a field_widget_form?

texts:
I want create quite a few graphs and display them on my site.  I am currently using the highcharts api/drupal module, but i'd like to be able to extend this to any js plotting library.  To do this I need to render a graph which takes many fields to set the parameters for the plot.  I need this to be tied to a node so that I can add other non-plot related attributes, such as 'category' to associate to the plot.  I decided that a single field should be be what renders this plot.  To do so I need to create a custom field and custom field formatter.  This can be done easy enough with guides such as

http://evolvingweb.ca/story/poutine-maker-introduction-field-api-drupal-7-part-1

This would allow me to define a field which takes in not just a name but all the associated parameters by simply defining a fieldset which creates multiple fields so that I can use all the various parameters and then render the plot with the custom formatter.

I am also separating the data from the graph.  I have another content type called 'dataset', since many graphs can be derived from various datasets.  The problem is that I would like to reference these datasets from this single field as part of the 'plot' content type.  To do so it needs to be part of field form widget which is created with hook_field_widget_form().  I'm not sure how to do this or if it's even possible.   To clarify what I'm trying to do here is a snippet of my code (derived largely from the above link):

function plot_extender_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $field_name = $instance['field_name'];
  $required = $element['#required'];

  $item = & $items[$delta];

  $element += array(
    '#type' => 'fieldset',
  );

  $element['name'] = array(
    '#title' => t('Dataset Name'),
    '#type' => 'textfield',
    '#required' => $required,
    '#default_value' => isset($item['name']) ? $item['name'] : '',
  );

  $element['type'] = array(
    '#type' => 'select',
    '#title' => t('Type'),
    '#options' => plot_extender_plot_type(),
    '#description' => t('The timer.'),
  );

$element['dataset_reference'] = array(
  '#title' => t('Dataset'),
  '#type' => 'textfield',
  'autocomplete'  // WHAT DO I DO HERE?????
);

);

I can list the different field widgets and field types with field_info_formatter_types() and field_info_widget_types(), but I don't know how I would add an 'entityreference' or 'entityreference_autocomplete' to this block.  Everything I try


texts: How to get the JSON/array value property name for a field instance?

texts:
Given a Drupal\Core\Field\BaseFieldDefinition  how do you get whether the value is stored by target_id, or value or uri or color or ....

it seems getMainPropertyName() is what i'm looking, for but it returns null for the majority of fields. in my case it's only returning target_id or value for for created, status, and entity_id.


texts: How do I wrap two render array elements in a div?

texts:
Given this renderable array:

$output = array(
    'twitter-icon' => array(
      '#type' => 'markup',
      '#markup' => '

'
    ),
    'twitter-link' => array(
      '#type' => 'markup',
      '#markup' => l('follow us on Twitter', 'https://twitter.com/#!/zujava'),
    ),
  );

How do I wrap both of these elements in a single DIV?


texts: array_keys() expects parameter 1 to be array, null given in drupal_schema_fields_sql()?

texts:
i have developed a custom module which will calculate the employee salary . I have created the hook_schema() like this

This is mymodule.install file with two entities

function payroll_schema() {
$schema['payroll'] = array(
  'description' => 'A detail payroll structure for an employee',
  'fields' => array(
    'payroll_id' => array(
      'description' => 'payroll id',//this is my primary key.
      'type' => 'serial',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    'paid_days' => array(
      'description' => 'Working days of an employee',
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
  ...
  ...
  'primary_key' => array('payroll_id'),
);
$schema['payroll_item'] = array(
  'description' => 'Details of payroll items',
  'fields' => array(
    'item_id' => array(
      'description' => 'item_id',
      'type' => 'serial',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    'payroll_items_id' => array(
      'description' => 'Payroll id', //foreign key
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
    ),
    ...
    ...

  ),
  'primary key' => array('item_id'),
  'foreign keys' => array(
    'payroll_items_id' => array(
      'table' => 'payroll',
      'columns' => array('payroll_items_id' => 'payroll_id'),
    ),
   ),
);
}

Here is the mymodule.module file with hook_entity_info()

function payroll_entity_info() {
  $return['payroll'] = array(
    'label' => t('Payroll'),
    'entity class' => 'Payroll',
    'controller class' => 'PayrollController',
    'base table' => 'payroll',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'payroll_id',
      'label' => 'Payroll id',
    ),
    'module' => 'payroll',
    'view modes' => array(
    'full' => array(
       'label' => t('Full content'),
       'custom settings' => FALSE,
       ),
    ),
  );
  $return['payroll_item'] = array(
    'label' => t('Payroll Item'),
    'entity class' => 'PayrollItem',
    'controller class' => 'PayrollItemController',
    'base table' => 'payroll_item',
    'fieldable' => FALSE,
    'entity keys' => array(
      'id' => 'item_id',
      'label' => 'Item id',
    ),
    'module' => 'payroll',
    'view modes' => array(
    'full' => array(
      'label' => t('Full content'),
      'custom settings' => FALSE,
      ),
    ),
  );
  return $return;
}

Here is the entity_load ()

function payroll_load($id) {
  $payrolls = entity_load('payroll', array($id));
  return reset($payrolls);
}

And here is my mymodule.controller.inc

class PayrollController extends DrupalDefaultEntityController {
  public function __construct($payroll) {
  parent::__construct('payroll');
  }
  public function create() {
  $payrolls = new StdClass();
  return $payrolls;
  }
}
class PayrollItemController extends DrupalDefaultEntityController {
  public function __construct($payroll_items) {
  parent::__construct('payroll_item');
  }
  public function create() {
  $payroll_items = new StdClass();
  return $payroll_items;
  }
}

When i am trying to install a module it gives a error as:

  Warning: array_keys() expects parameter 1 to be array, null given in
  drupal_schema_fields_sql()  (line 6969 of
  mylocation/includes/common.inc).

Can you tell me where i may made any mistake ??


texts: How to do user relations, and User editing only their content?

texts:
Doing Drupal 8.6 is hard (I come from Laravel and Wordpress world).

I manage to do by myself OAuth token authentication with Vue, but I stopped on User relations and content-type. I know that where is programmer there is a way, but I just want to see what you do things then choose best option.

How can I, for example, create a friends system? With normal table structure is like this:

+----+--------+-----------+---------+
| id | sender | recipient |  status |
+----+--------+-----------+---------+
| 24 |   11   |    25     | [0,1,2] |
+----+--------+-----------+---------+

Is there built way in Drupal 8.6 to do it or should I get plugin? Or just do content-type Friendships with thse fields?

And when I allow user to create a Portfolio, the right way will be to create Content-Type Portfolio with Gallery field, and just give access to peoples to add nodes? How I can give User access to only edit or delete their own content?


texts: Make drupal core independent from public root

texts:
I would like my drupal core independent of my server public root. It makes things neater and separates your Drupal core from any other software that sits at your public root.

I know how to create the symlink, but I can't seem to remember or find the steps for the rest of it.  I believe it involves the httpd.conf file.  Can anyone help me out?  Thanks

I don't want to do it the messier way that involves the .htaccess file.


texts: Prepopulate Multi-Part Webform fields from client side javascript API

texts:
I am trying to prepopulate fields in a multi-part webform.  I make an api call on the first page and stick the response in a hidden field.
$.ajax({
    type: 'get',
    url:  '/api_helper.php',
    success: function(response) {
        // put the full response in a hidden field
        if ( $('input[name=api_resp]').length > 0 ) {
            $('input[name=api_resp]').val(response);
        }
    }
});

Then on each click to the next button, I wait a half second for the new fields to appear in the DOM and input the values for any matching field :
$('.webform-submission-form .webform-button--next').once().click(function (event) {
    api_resp = JSON.parse($('input[name=api_resp]').val());
    setTimeout(function() {
        var field_value = new Array(
            $('.form-item-address input') : api_resp['address'] ,
            $('.form-item-phone input') : api_resp['phone'] ,
            // more fields, some looping compound fields
        )

        // put values in fields
        for ( var $field in field_value ) {
            $field.val(field_value[field]);
        }
    },500);
});

This works "okay" but has some cumbersome bits I haven't shown related to compound fields.
The question
Is there a better way to do this? Instead of the method above, can I insert the values into the Drupal API when I make the API call?


texts: Using Panelizer, how can I add a new menu item properly

texts:
I want to add a menu item the right way See "Edit IV Block" in the picture below.

That is the wrong way to do it.

The code is here: http://api.drupalecommerce.org/api/panels/panels!plugins!display_renderers!panels_renderer_editor.class.php/function/panels_renderer_editor%3A%3Aget_pane_links/7.x

If you search for  drupal_alter('get_pane_links', $links, $pane, $content_type); you can see that the get_pane_links hook is supposed to fire, but for some reason it does not fire.

My question is, it seems like drupal_alter('get_pane_links') is the correct way to add menu items, but I've tried adding functions in other modules and they don't get called. I modified the code to do

echo 'before';
drupal_alter('get_pane_links', $links, $pane, $content_type);
echo 'after';

And no dice.
What is the correct way to add a menu item or how to I implement this hook?


texts: Can you prevent a module from being disabled?

texts: Is there any way to prevent Admins from disabling a module. Is there anything that can be done via code?


texts:
I have deployed user generated views to a production site using Views (6.x-2.12) bulk export feature; that is, views are saved in the code as mymodule.module and mymodule.views_default.inc, the latter of which contains 12 views in more than 11,000 lines.

Sometimes, one or more views suddenly disappear from the site. Flushing all caches usually fixes it, but it is hard to duplicate the issue and it bothers me that it may happen again in the worst time.

Possible causes that I think of are:

Does the .inc file have too many lines (> 11K)?
I have saved the .inc file with Windows new lines, while the server is Linux.

Could one of these be the cause?
Anyone experienced a similar issue?


texts: How to add another filter to TVI default page view?

texts:
I have the TVI module installed but I wanted to add one more contextual filter
currently: mysite.com/taxonomy/term/[term of tags vocabulary]

what I want: mysite.com/taxonomy/term/[term of tags vocabulary]/[other term of another vocabulary]
How to do this?


texts: Hiding regions for a node page without creating a unique twig file for that node?

texts:
In Drupal 7 I could hide regions as reactions to certain conditions with Context; Here is a pseudocode to explain what I actually did with this module:

  If $node = 1;

  Than programmatically hide $region = sidebar;

In Drupal 8 for some reason, at least in this era, this functionality has been removed from the module. You can no longer hide regions as a reaction to whatever condition.

Hiding regions is still possible with CSS but it should be noted that programmatically hiding regions is better than CSS hiding as it is more swift and sound, as well as more elegant.

What I've tried instead:

Given the fact Context 8 doesn't include that functionality, I tried to use CSS to hide the region in the given node; I knew from Drupal 7 that if you are inside an node and go to the DOM tree, you can see a unique node class that will serve you in such a particular CSS action (hiding a region in a particular node).

In my Drupal 8 site I went to the DOM but didn't quite find such a class (as appears in Drupal 7 sites).

Therefore I tried using what worked for me in Drupal 7 wondering if from any case it just no longer appear in the DOM. I went to my CSS file and added:

.page-node-364 .region-sidebar-first {display: none !important}

It didn't work, nor similar tryings such as:

#node-364 .region-sidebar-first {display: none !important}
.node-364 .region-sidebar-first {display: none !important}
.364 .region-sidebar-first {display: none !important}

And so forth...

Other actions on that node class variations (neglecting region-sidebar-first) also didn't work even with !important declarations on the CSS and what I tried seemed just to be invalid.

I flushed all caches after each try.

Why I'm confused:

What I did saw at DOM and used as a class didn't cause any effect (.364 as mentioned above):

My question:

Due that Context isn't the solution this time, and that seemingly, no usable id or class appears in DOM, I thus ask professional themers here if it is even possible to hide regions for a node in Drupal 8, solely through the CSS, without creating a unique twig file to that particular node.


texts:
How to get values count in db_select
My query is:

$last_item = '2015-07-19';
$query = db_select('field_data_appointment_date','ap');
$query->join('field_data_appointment_slot','aps','aps.entity_id = ap.entity_id');
$query->fields('aps',array('appointment_slot_value '));
$query->condition('ap.appointment_date_value', '%' . db_like($last_item) . '%', 'LIKE');
$result = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
dsm($result);

and my result is:

... (Array, 4 elements)
0 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
1 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
2 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 10.00-11.00
3 (Array, 1 element)
appointment_slot_value (String, 11 characters ) 11.00-12.00

I need result like count of

:10.00-11.00 is 3
:11.00-12:00 is 1

Anyone help me out


texts: Entity 'changed' column doesn't change upon save

texts:
I have a custom entity called "release".
Release has "state" and "building percentage" fields, which values may change during the release process.

In both "setState" and "setPercentage" entity method I explicitly do the following:

$this->setChangedTime(time());
$this->save();

However, during the process, the "changed" column in the database always remains the same value.
Am I missing something? What could be wrong?

UPDATE:
Running the "setState" and "setPercentage" in a test script separated, the database gets updated.

UPDATE2:

I got it. "ChangedItem.php" - line 37, I logged there, and this is where it sets back to the request time value:

   // On an existing entity translation, the changed timestamp will only be
      // set to the request time automatically if at least one other field value
      // of the entity has changed. This detection does not run on new entities
      // and will be turned off if the changed timestamp is set manually before
      // save, for example during migrations or by using
      // \Drupal\content_translation\ContentTranslationMetadataWrapperInterface::setChangedTime().

will be turned off if the changed timestamp is set manually before save

This "promise" of the comment is definitely not working. Any suggestions?


texts: TB Megamenu - How can I reuse a menu with different megamenu configuration?

texts:
I have a Drupal core menu setup for my main menu that has > 50 links setup.  I've also got TB Megamenu configured for that menu to show the menus with pictures, etc.

Now I have a case in which I want to show the same menu content, but configured differently (to shown only standard flyouts with no images) on all pages but the home page.

I haven't been able to find a way to do this without duplicating the main menu link by link (which I obviously don't find sustainable).

Can anyone think of a way I could accomplish this?

(Note that I did try the Context module, which is great, but is not really suited for this purpose).

Thanks.


texts:
I have a website. In which I need to disable some pages for full view. Because I am using them in view. I don't need full view.

Is there is anything in D7 so we can stop full view of Page


texts: Which version of Behat (Guzzle) would be okay to use on a RHEL server with PHP 5.4?

texts:
On a Red Hat Enterprise Linux Server release 7.1 (Maipo) development server using [Behat Drupal Extension][1], a RHEL 7 / PHP 5.4 installation. When I try to run behat from the command line on a dev server, I get the following error:

$ ./vendor/bin/behat

  Feature: First
        Playing with features and exploring

  @api

  Scenario: Run cron                                             # features/first.feature:6
      PHP Fatal error:  Call to undefined function GuzzleHttp\Handler\curl_reset()

  in /var/www/html/sites/default/behat-tests/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
  on line 78

From answers below, it appears the the version of Guzzle bundled with this requires 5.5 or greater.

  guzzlehttp/guzzle               6.1.0   Guzzle is a PHP HTTP client library
  guzzlehttp/promises             1.0.3   Guzzle promises library
  guzzlehttp/psr7                 1.2.0   PSR-7 message implementation

My question: what version of Guzzle should I use in order to be able to run test on a server with PHP 5.4?


texts: How do I display different "No results behavior" based on exposed filter results and total results?

texts:
e.g. A view for job postings has an exposed filter to search by title.

I want to show a "No results behavior" if there aren't any jobs at all "There are no postings at this time. Please check back later."
I also want to show different text if their search returned no results, but there are still postings available. It's just their search didn't match anything. "Sorry, there are no results matching your search criteria."

It appears that I can only do one or the other.


texts: How to set default role as 'Member' in drupal 7?

texts: If I have a role i.e. Member. How to set 'Member' as a default role for the users after they registered yourself ? Please help. Thanks


texts: how to create a grid view with only ONE image from nodes containing multiple images?

texts:
I have Nodes that have an Image field that can have any number of Image Fields. I want to create a Grid View in which I should only a single IMage field (can be the first one or any one actually).

Attached image shows my Views settings that shows multiple images - how do I limit to picking a single image from each node for the grid views display?

(I am in DRUPAL 6)


texts: Use Url Argument in contextual filter for Block View

texts:
I have a View which uses contextual Filter to compare my URL last Argument with Taxonomy term. This Works when my view is Page but doesn't work in block mode. This is my View Below.

Attaching my view and Site Description along this.
My Pdf Category View is placed as a block.

When I Preview by entering the brand name emax in the view, it give me proper results but it doesn't fetch from url(RAW Value from URL). Correct me if i failed to mention anything wrong.


texts: Change menu link before rendered in mmenu module

texts:
I've used Mobile sliding menu module version 7.x-1.0-dev.

We can change menu link using theme_menu_link().

Similarly is any other hook for change menu link in this module?


texts: Deduping Views by forcing Views to add a simple GROUP BY to a query

texts:
In D8, I need a way to "dedupe" a view with a relationship. This involves a "Course" content type, and a "Sessions" entity (actually, a Commerce Product) that points back to the Course.

I've tried to create views that are based off the content type and related to the Session entity, and visa versa.  In both cases, what I really want to do is to get a list of courses searched by both the attributes of the Course (let's say, type of course) and of the session (location).

Since Course :: Session is 1 :: N, we're getting N rows for each Course. This is not what we want. Using the Advanced settings has proved useless so far. Query Setting "Distinct" does not dudupe. The Field Format Setting "Grouping field" does not appear to trigger a GROUP BY in the query.  And using Aggregation creates a monster GROUP BY that appears to pull in just about all the fields in the tables, with no way to remove the useless fields from the GROUP BY.

Here's what I'd like to do: use a simple GROUP BY (say, the title of the Course), and compare the entity ID of the sessions with the minimum entity_id of that group of sessions; if it's not equal, I want to exclude the row either in the WHERE clause or in a HAVING clause if it will work. I'm trying to modify the query via the views hook

function my_module_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  if ($view->id() == 'course_listing') {
    $title_alias = 'alias_to_content_table.title';
    $query->addGroupBy($title_alias);
  }
}

The problem here is that while the code is definitely called, the call to addGroupBy() is ignored when the query is actually rendered out. Views thinks I didn't mean it :-)

What exactly do I need to clobber Views with to get it to add a GROUP BY statement?  If I can get it to do that, I can insert a MIN field into the SELECT statement (see http://tech-tamer.com/drupal-7-using-sql-expressions-in-views-3/ for someone's clever idea of how to do that in D7; it appears to work fine in D8, but will generate a bad query w/o the correct GROUP BY).


texts: How do i remove main menu title once it's in sidebar,

texts:
Why is so dang difficult to style the main menu once you put in the sidebar in Drupal 7?!?

i also want to remove those annoying leaf classes!  first leaf, leaf, last leaf etc.

on the page template file i see the main nav code and where it spits out title, but in the same file,
all the side bar code is in one variable. how do i access that?,

i don't mind  php coding. can someone please advise how to do this?

big thanks in advance


texts: Getting the workflow associated to a node type

texts:
How do i get the workflow entity associated to a certain node bundle? So far my approach has been to use EntityTypeManager to load the workflow config entity storage and trying to load the right workflow using loadByProperties() function,

$workflow = $this->entityTypeManager->getStorage('workflow')->loadByProperties();

except I don't know what properties I should be specifying or If I'm approaching this the right way.


texts: Downside of not rendering a region in twig template?

texts:
Suppose we want to use a different layout/blocks in front page. I know there is a page visibility restriction feature in block configuration, and also  Page Manager and Panelsmodules exist, but what's the downside of this solution?

Define a specific region content-front in theme
Place some blocks in this this region
Render this region only in page--front.html.twig template

The above solution has some advantages: front-page blocks are listed separately from other blocks, no need to configure each block to be in <front> page (preventing a O(n) task), using native UI to arrange the blocks.

Edits:

hooks like hook_block_access or hook_preprocess_block will not be called for a block not being rendered.


texts:
I am trying to solve this issue from last three days. Searched lot regarding this issue but not getting any solution.

I have also visited these links link1 link2 or duplicate questions

This error is occurring at the time of installation, I am installing Drupal7 on linux

I am using PostgreSQL 9.4.8 database, php PHP 5.5.9

The database user has granted all permissions

following are the exceptions

first exception

    Uncaught exception thrown in shutdown function.

    PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;semaphore&quot; does not exist LINE 1: DELETE FROM semaphore ^: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] =&gt; 2108550473576798c2ab0410.91648409 ) in lock_release_all() (line 269 of /var/www/html/rentspeak/includes/lock.inc).

second exception

Uncaught exception thrown in session handler.

PDOException: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation &quot;sessions&quot; does not exist LINE 3: sessions sessions ^: SELECT 1 AS expression FROM {sessions} sessions WHERE ( (sid = :db_condition_placeholder_0) AND (ssid = :db_condition_placeholder_1) ); Array ( [:db_condition_placeholder_0] =&gt; AqE0DsCH1bG6qk3nMspgcEW1J_FUDbF15vNkX5nSdUU [:db_condition_placeholder_1] =&gt; ) in _drupal_session_write() (line 209 of /var/www/html/rentspeak/includes/session.inc).


texts: Rendering nodes of a same content type in different templates

texts: My Client would like to have multiple templates for one content type. How to allow a user in Drupal to select a specific template when creating a node?