texts: How to build render array with node title linked to node for a list of nodes

texts:
I have a paragraph type to output a list of content. The editor can set different options, one of them is to show the list as teasers or just node titles linked to node. The corresponding part in code looks like:

    if ($teaser_display) {
      $value = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, 'teaser');
    }
    else {
      $value = \Drupal::entityTypeManager()->getViewBuilder('node')->viewField($node->get('title'), ['link' => true, 'type' => 'entity_reference_label']);
    }

Is there a way to build the render array for titel field linked to the node without creating a dedicated view mode and without rendering the markup directly? I thought it should somehow work to use the method viewField() as $display_options can either be a view mode or an array with display options.


texts: Display form errors on each field instead of at the top of the page using form_set_error

texts:
I use form_set_error to set the error text after validation fields (email, phone, etc.). The validation error messages are show at the top of the page. This also happens with errors for required fields that are not explicitly set with form_set_error.

How can I make them appear under their relevant fields.

Note: I'm not using the Webforms module, but rather the Forms API. I'm on Drupal 7.


texts:
I am really stuck at this pont can anybody help me out

if i am in the domain.com/computers/all/brand/acer
i want to create a contextual filter block with urls like say

computers/com1/brand/acer
computers/com2/brand/acer
computers/com3/brand/acer
computers/com4/brand/acer

com vocabulary contains these com1, com2, com3, com4 items
acer has to be dynamically taken from url

I have tried a lot but ended up with
computers/com1/brand/all
computers/com2/brand/all

or i ended up with

computers/all/brand/acer/com1
computers/all/brand/acer/com1

can anybody guide me


texts: how to not display a sum with value 0 with views aggergation plus module

texts: I'm using views aggregation plus module, doing group and compress from taxonomy fields and haveing a columns sum action, how can i hide sums with zero value? views conditional module do not have any effect,  also i tryed all 'no results behaviour' settings. Code or hooks are welcome, any help will be very appreciated.


texts:
I filled out the Database name, Database username, password, and port number within the Drupal set up. I selected continue, then the page loads for a long time. Next, I was leaded to another page saying, Drupal already installed. Next, I clicked on View your existing site, displaying the log in for the admin. Drupal literally skipped the admin set up, resulting in not allowing me to log in as admin. Anyone is familiar with this error? Is this even an error, or the norm for Drupal (since I seen other users experiencing this errors, but no answers)?

Drupal explain the the error is the following

  The website encountered an unexpected error. Please try again later.
  Drupal\Core\Config\UnmetDependenciesException: Configuration objects
  (automated_cron.settings, block.block.bartik_account_menu,
  block.block.bartik_branding, block.block.bartik_breadcrumbs,
  block.block.bartik_content..

If anyone that knows this, feel free to provide some input.


texts: Hook to get details of taxonomy term page

texts:
I wrote a module to store taxonomy page details to DB. My requirement is to store tid, term name, vid and UNIX timestamp to DB table on every load of taxonomy term page. Here is my code:

function reporting_api_taxonomy_term_load($terms) {
  $tid = $terms[arg(2)]->tid;
  $vid = $terms[arg(2)]->vid;
  $term = taxonomy_term_load($tid);
  $name = $term->name;
  db_insert('reporting_api')
    ->fields(array(
      'tid' => $tid,
      'name' => $name,
      'vid' => $vid,
      'timestamp' => REQUEST_TIME,
    ))
    ->execute();
}

But it creates unwanted rows with timestamp only. Can any one help to fix this. Is hook_taxonomy_term_load is the correct hook.


texts:
I am new to drupal, I am using drupal 8, I have develop a custom form by extending FormBase controller and i am trying to render it using a custom controller like below.

$form = $this->formBuilder->getForm('Drupal\xyz\Forms\XyzActionsForm',$parameter);

return [
  '#form'=>$form
]

This works fine form me. But now i also want custom html below this form so try below code

$form = $this->formBuilder->getForm('Drupal\xyz\Forms\XyzActionsForm',$parameter);

$form = render(form);

$form .= '<div>custom html </div>';

return [
  '#markup'=>$form
]

But this didn't work for me, Can anyone let me know how to achieve this.


texts:
I want to use the Views module to obtain the number of comments associated to a node, and show it as "1 comment," "5 comments."
How do I do this?


texts: Deleting users who have created content can lead to access bypass?

texts:
The statement below appears in several places on the Internet about Drupal security. Is it the case that someone once wrote this and people repeat it in the their '10 Drupal security tips' posts without checking - or is there some truth to it?

  Disable user accounts and keep their contents. Deleting users who have
  created content can lead to access bypass.

Thanks.


texts:
I'm using Drupal 6.

I have a custom view that needs to be filtered by an argument passed by the user.

The argument is a simple date, and I need my query to be filtered like the following:

WHERE created >= %argument&

Where %argument% is the user argument passed within the URL.

The thing is, I manage to filter it, but only as equals, like this:

WHERE created = %argument&

Is there any way I can make it filter as greater or equal to?


texts: Google Maps Module custom markers and routeplanner

texts:
On my Drupal site, I have a nice Google maps module with custom markers.

The only thing I want to add is a route planner that makes use of my custom
Markers.

Any suggestions?


texts: Which table are field instance widget settings stored? Is it ok to update these everytime a node is saved?

texts:
I wanted to utilise the Minimum/Maximum values of Integer field instance settings. I'd like to know where these are stored in the database, and whether it's feasible to use hook_node_save or presave to update these min/max fields. The site will use feeds to mass import nodes, and I was wondering if it'll be ok to update these values everytime the feed import is run?

Also is there an easy way to grab these min/max values on node view?


texts: Can I manualy add modules in Drupal 7 just by pasting them in the modules folder?

texts:
I am unable to install modules in Drupal 7. I'm working on localhost so I don't have FTP, but it seems that they made it impossible to install them otherwise.

In Drupal 6 I would of just paste a module, refresh and there it was. Here I have to specify the FTP.


texts:
I wrote into my settings.php file (into default.settings.php file too):

$conf['theme_debug'] = TRUE;
$settings['theme_debug'] = TRUE;
$settings['theme_auto_reload'] = TRUE;

(These files have 777 permission.)

I have the "Theme developer" module.

I cleared all cache.

But the suggestions doesn't appear.

What else should I do?

(I have Drupal 7.)


texts:
I'm sure this should be simple and I'm missing something because I'm tired on a Friday afternoon.

I have a Content Type (which I didn't design!) with fields "Start Date" and "Start Month". I want to show items in the View if EITHER "Start Date" OR "Start Month" are non-empty. However it seems that multiple Filter Criteria in the View are AND-ed ?

Any help much appreciated.

Thanks,

MB


texts: Constructor in a custom entity isn't prior to baseFieldDefinitions

texts:
I have a custom entity with a constructor that calls a custom method (generateCharacteristics()) to generate random values for certain fields of my entity :

    public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) {

    parent::__construct($values, $entity_type, $bundle = FALSE, $translations = array());

    $values += $this->generateCharacteristics();

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

        $method = 'set'.ucfirst($key);

        // For two-words attributes
        if( strstr($method, '_') ) {
            $method = explode('_', $method);
            $method[1] = ucfirst($method[1]);
            $method = implode('', $method);
        }

        if (method_exists($this, $method))
        {
          $this->$method($value);
        }
    }

}

When I log what occurs in this __construct method when I create a new entity, all works fine, attributes are well setted, but in my database I have NULL or default values (the ones I declared in baseFieldDefinitions()). That's a shame because I think that baseFieldDefinitions() is put in cache (not good for random values) and that my method using constructor is cleaner.

Maybe my error is to think that $values array is the array we send during the call of Entity::create() method because this $values array seems always empty before I add my own array to $values... Nevertheless I set my attributes correctly in the constructor. The use of a postCreate() method should be more appropriate ?

thanks !


texts: Calendar - Adding relationship to contextual date filter

texts:
I would like to create an Calendar view of some interships for a certain student. But when I change the Contextual (Date) filter to use an relationship no results are shown in the calendar.
When I construct a similar view page in a list instead of an calendar view mode, with identical filters, the results get returned.

Below an image of my attempt to get the relationship in a contextual date filter.


texts: Hide an entire View Block when query returns no data

texts:
I have a view block and - because of the filters being applied - it may show data or may not. If the view's query returns no results, I need to hide the entire block - the .block - not just the .view or .view-content. I've seen several other questions and pages that offer solutions but all either don't hide the entire .block or just flat out don't work.

The solution that appears to be most discussed uses the Global: Null contextual filter, but that always hides the entire block regardless of any other condition. In fact, it doesn't even run the query when this filter is active. I need the block to be hidden if and only if the query returns no results.

I have the default, barebones Drupal 7 installed with only Bartik, CTools and Views so I am sure there aren't any other conflicts coming in from the theme or other modules.


texts: Views exposed filter redirects to wrong url

texts:
After submitting the filter settings, on a page (panel in ctools Page manager module) with view content pane, the filter path (in URL) instead of being applied to the current page (with view), it is added to the root domain (home page).

Please give a tip what might be wrong with settings?


texts:
I have two tables on a page that the row positions need synchronized when a row is drug. One table is the master table and is the only place that the actual dragging can take place.

Basically, what needs to happen is when the user drags a row in the master table, the changes in position need to be duplicated to the child table.
I've been poking around with the onDrop custom handler function, but I am about at my wits end.
I'm not willing to hack tabledrag.js, as my custom module will be deployed on a system that I don't manage.

I'm sure someone else has faced this same issue. Are there any suggestion for a solution?


texts: Get current URL arguments inside ajax callback?

texts:
I have created custom module called 'mymodule'.

In this URL localhost/es/mymodule/name/1/2/3, I have this field:

$form['name'] = array(
  '#title' => t('Enter name'),
  ...
  '#ajax' => array(
    'event' => 'blur',
    'callback' => 'mymodule_ajax_callback',
    'wrapper' => 'my-wrapper',
    'method' => 'replace',
  ),
  ...
);

My ajax callback is successfully called:

function mymodule_ajax_callback($form, &$form_state) {
  ...
  return ...
}

However, inside 'mymodule_ajax_callback', I need to get the current URL arguments of the page such that arg(1) = 'name', arg(2) = 1, arg(3) = 2, and so on.

By nature, Drupal uses the URL system/ajax so calling arg(N) does not work as I need it to be.

How to get the current URL arguments using arg() inside the ajax callback?

EDIT 1:

I thought of using $_SESSION[...] = arg(1); $_SESSION[...] = arg(2); ... on my form and calling the session variables on my ajax callback. But I am looking for a better way without using session but only using drupal methods if available.


texts: How do I add a  over a paragraph's field, depending on another field of this paragraph?

texts:
I have a paragraph (from the paragraphs module) which has two fields :

field_title (text)
field_title_level (list text)

The field_title_level can have either h2, h3, or h4 as a value.
What I would like to do is to surround the title text with a h2/h3/h4 div.
I tried using templates (paragraph, or field). With the field one, I managed to add a div over the title, but I didn't manage to access the field_title_level in order to add the correct div. And using the paragraph template, I didn't manage to add any div over the title.
Any clue?


texts: D6 Is it possible to set node reference field and use this value in another field on the same node/add form?

texts:
I have two node reference fields in a Content Type.
Driver
Manager

Each driver belongs to a certain organisational unit. Every organisational unit has a set of managers. I need the organisational unit to retrieve the right selection of managers in the node reference field Manager.

Now I need to select the driver, save the node and edit the node again. Then I can select the manager from the right set of managers (based on the organisational unit token I supply in the node reference field).

Is there any other way I can do this without implementing a 2-step form?


texts: No sub theme folder inside bootstrap theme folder

texts: I just installed Bootstrap 3 theme in Drupal 7, but the subtheme folder is missing. I am new to Drupal and am following online tutorials but no result. All instructions direct me to a sub theme folder in themes>bootstrap> bootstrap-subtheme, but there is no such folder. I removed the theme and reinstalled but still no folder.


texts:
I have a quite simple query :
(find all nodes, fetch 3 fields from the node table and join the results with some tax.terms)

$query = db_select ( 'node', 'n' );
  $query->fields ( 'n', array(
      'nid',
      'title',
      'type' ));
  $query->fields('b',array('body_value'));
  $query->fields('ttd',array('name'));

  $query->leftJoin ( 'field_data_body', 'b', 'b.entity_id = n.nid');
  $query->leftjoin ( 'taxonomy_index', 'ti', 'ti.nid = n.nid');
  $query->leftjoin ( 'taxonomy_term_data', 'ttd', 'ttd.tid = ti.tid AND ttd.vid = "5"');

  /* $query->condition('ttd',5); */

  $result = $query->execute ()->fetchAll ();

Now the problem is that i want a single object returned form the query for each node.
Like this :

stdClass Object
(
    [nid] => 557
    [title] => Lorem ipsum
    [type] => content_type
    [body_value] => lorem ispum
    [name] => taxonomy_term_value
)

But what i get is multiple objects because of the taxonomy index table (where a node can have anywhere from 12 term id's to none at all) but i only need 1 that corresponds to the condition stated above in the query (vid = 5, from the tax.term data table) if that node has a link to the tax.term, if the node does not have link it should return nothing,null,empty string...

So my results are as follows :

stdClass Object
(
    [nid] => 155
    [title] => lorem ipsum
    [type] => content_type
    [body_value] => lorem ispum
    [name] =>
)
stdClass Object
(
    [nid] => 3411
    [title] => lorem ipsum
    [type] => content_type
    [body_value] => lorem ispum
    [name] => value1
)
stdClass Object
(
    [nid] => 161
    [title] => lorem ipsum
    [type] => content_type
    [body_value] => lorem ispum
    [name] => value4
)
stdClass Object
(
    [nid] => 561
    [title] => lorem ipsum
    [type] => content_type
    [body_value] => lorem ispum
    [name] => value16
)


texts: URL alias for each country, URL should display Description

texts:
<?php
        $dbresult = db_query("SELECT country_name,description FROM {countries} WHERE status='1' order by country_name ASC");
        $theanswer[] = $row->country_name;

        ?>

Countries

<form id="live-search" action="" class="styled" method="post">
                <fieldset>
                <input type="text" class="form-control" id="filter" value="" placeholder="Search By Country" />

                </fieldset>
            </form>

            <?php foreach($dbresult as $row){ ?>

<?php echo $row->country_name; ?>

            <?php } ?>

        $dbresult = db_query("SELECT country_name,description FROM {countries} WHERE status='1' order by country_name ASC");
        $theanswer[] = $row->country_name;

    ?>

Countries

<form id="live-search" action="" class="styled" method="post">
            <fieldset>
            <input type="text" class="form-control" id="filter" value="" placeholder="Search By Country" />

            </fieldset>
        </form>

        <?php foreach($dbresult as $row){ ?>

<?php echo $row->country_name; ?>

        <?php } ?>

I am using drupal 7 , I have created custom modules for adding countries and edit/delete/status like this.. enter image description here

The attached image having my database table..

Now i am able to display all countries list ....and filtering live search as well..

Now i want link each country description as one page content...like dynamic pages based on country select link redirect to country description page...Table image


texts: Showing the Quiz Score for the current user of current quiz attempt?

texts:
I am trying to create a block using Views which shows the current users score for the current attempt of the quiz being completed by the user. The idea here the student can see their overall score while working through the questions; and as they get each question right their score updates from question to question.

I have been playing around with the contextual filters and relationships but I cannot seem to work out how to filter it down to only show the current user's score of the current quiz attempt. Any suggestions on this?


texts: How do I create a custom JSON API endpoint?

texts: I would like to create a custom JSON API endpoint to preview nodes in draft status.  The URL will be something like "jsonapi/node/page/preview".  If a page node has a draft in progress, it should be displayed instead of the published version.  If there is no draft, then the published version should be displayed.  I am new to Drupal 8, so I do not know where to start.  Could someone point me to an example, or let me know which classes I need to extend?  Thanks in advance!


texts: How to get the Published or Archived revision of a node

texts:
I'm trying to compare some field values from the edit form of a node to the published/archived field values. However I'm running to an issue where when im trying to load the Node object using
Drupal::entityTypeManager()->getStorage('node')->load($nid)
It's returning the last saved draft revision. How do i get the Node object of the published/archived revision?

P.S. Content Moderation is turned on, and content type is assigned to a workflow.


texts:
Is it possible to upload an image to Drupal which is accessible by all nodes programmatically?

What I want to do is upload an image to display as a banner (CSS background) for nodes that have a specific radio button selected.

My idea is to have the user upload the image to one place then in my template.php file detect which radio button has been selected & from that pull that image in as a CSS background.

Is this even possible?


texts:
Suppose I build a webform with only a date picker and a submit button.
After I pick a date and click on the submit button, it takes me to a page
with a list of movie title, the date the movie released and the time interval in days (between the date I picked and the date the movie released).

For example, I picked 11/23/1995 and clicked submit; the result page will show a list.

Titanic 11/1/1997 709 days
Fight Club 10/15/1999 1421 days
The Shawshank Redemption 09/23/1994 426 days

I want to display the time since the release in a view.


texts: Given a node object how can I detect if it's first term (or term in a chosen vocabulary) contains a taxonomy image?

texts: Using php code and a node object, how can I detect whether or not the node's first term (or term in a chosen vocabulary) has a taxonomy image? Any help appreciated.


texts:
I need to create a web form that functions as a skills checklist. The user will select a 'specialty' from a drop down and based upon that selection, a list (with as many as 50 radio selections) will be presented to the user. I'm trying to figure out the best way to do this in terms of performance and maintainability.

1) I can write the skills list as a huge single form and then use jQuery to to show and hide the elements based upon the drop down selection. However, this may lead to very long page load times since there may be upwards of 1000 fields in the form.

2) I could gather the 'specialty' information at an earlier time, then load it at run time and based upon that, run another query for all the fields I will need from the database and build the form in a foreach loop. This means that there will be upwards of 30 queries in the form and an extremely complex submit handler to insert all of the entered data into the database.

Any thoughts on the best way to accomplish this? This is part of a large web application with many different sections and performance and maintainability is a huge consideration.

Thanks


texts:
I am trying to setup a Feed Import from CSV.  There is an images field in the content type which can have unlimited values.  These images are in a folder and named in the following format:

[identifier_from_csv]_01_large.jpg
[identifier_from_csv]_02_large.jpg
[identifier_from_csv]_03_large.jpg

Each project has a variable number of images.  I would like to be able to read from the file system and import as many images it has located there.  I've tried to research into this and from what I can see the Feeds Tamper module I would still have to know how many images there are and have them all listed in a field.

How can I setup an import that would automatically read in as many images as there are located in the file import directory?  I'm assuming there is a hook I could use and loop through there checking the file system, I'm not sure where/how to implement that.


texts: Views Search Terms not working correctly for taxonomy terms with multiple words

texts:
I'm having a bit of an odd issue. I have a Search Terms filter set up on a view and it's not working quite correctly for taxonomy terms in the view.  For example, if one of the Terms is 'International Harvester' and it returns the correct results if I enter International or Harvester or "International Harvester", but if I put in International Harvester without quotes then no results are returned. Any ideas?

using Drupal 7.41, Views 7.x-3.7


texts: How do I model content (types) from a database-centric point of view?

texts:
How can I model content from a "database-centric" point of view?

For example to show Appartments in a District in a City, as in this example:

Table Cities:
CityID (int) primary key
City (string)

Table District:
DistrictID primary key
CityID foreign key
District (string)

Table Appartment:
AppartmentID primary
DistrictID foreign
AppartmentName
NrOfRooms
.....etc....

How would I create content types (?) to do this?


texts: Check if viewing teaser in hook_node_access

texts:
Is there a simple way that I can forcibly allow everybody to view all teasers no matter what, overriding any other permissions set by Content Access, etc.

I was thinking something like this:

function mymodule_node_access($node, $op, $account) {
  if( $op == 'view' && ... viewing teaser ) {
    return NODE_ACCESS_ALLOW;
  }
  return NODE_ACCESS_IGNORE;
}

and then I would set the module weight really high. But I'm not sure how to check if viewing teaser. I would also need Views to respect the access I'm granting.


texts:
I am working with a fluid 100% theme with Panels 6.x-3.9.

I have created a custom layout in Panels; it is based on threecol_25_50_25_stacked (First column is 25%, center is 50%, and last is 25%), and I created it for a 20/50/30 layout.

In the original threecol_25_50_25_stacked CSS file, the code is:

.panel-3col-stacked .panel-col-first {
  float: left;
  width: 25%;
}

.panel-3col-stacked .panel-col .inside {
  margin: 0 .5em 1em .5em;
}

.panel-3col-stacked .panel-col {
  float: left;
  width: 50%;
}

.panel-3col-stacked .panel-col .inside {
  margin: 0 .5em 1em .5em;
}

.panel-3col-stacked .panel-col-last {
  float: left;
  width: 25%;
}

.panel-3col-stacked .panel-col-last .inside {
  margin: 0 0 1em .5em;
}

In my CSS for the custom layout, I changed the widths to 20%, 50%, 30%, respectively.
When I resize the browser window, and dragging it smaller, the first column gets overlapped with the center column.  With all padding and margins unchanged, it should not do this, should it?
The original layout 25/50/25 does not do this.  What am I missing?

Here is a breakdown of what I have tested:

Garland
Original 25/50/25 Stacked: overlaps
Custom 20/50/30 Stacked: overlaps
Acquia Propser Fluid (Fusion sub-theme)
Original 25/50/25 Stacked: does not overlap
Custom 20/50/30 Stacked: overlaps
Fusion Core Fluid
Original 25/50/25 Stacked: does not overlap
Custom 20/50/30 Stacked: overlaps
Zen Core Fluid
Original 25/50/25 Stacked: does not overlap
Custom 20/50/30 Stacked: overlaps
CTI Flex (Zen Sub-theme) Fluid
Original 25/50/25 Stacked: does not overlap
Custom 20/50/30 Stacked: overlaps


texts:
I have a React native front end with D7 backend. I am populating a content type that has a multi-value Date field. I am successfully creating the content-type with all other fields except the Date field. The format I am sending via POST looks like :
"field__delivery_dates": {
        "und": [
           {
                "value": "2020-07-23"

            },
            {
                "value": "2020-08-05"

            },
            {
                "value": "2020-08-07"

            }
        ]
    }

The problem is when I sent the multiple date field values it's getting submitting but the values are not reflected in drupal.
Anyone, please help me to find out a solution for sending a multi-field date field to drupal 7


texts: Remove white spaces from inline form-inputs

texts:
If there is a form generated by drupal form api in template file, is there a way how to remove whitespaces between .form-input html elements?

My template looks like this:

            <form action="" method="post" id="activit-grant-filter-form" accept-charset="UTF-8">

<?php echo render($form['organisation_type']); ?><?php echo render($form['locality']); ?><?php echo render($form['support_type']); ?><?php echo render($form['thematic_objective']); ?>

                    <?php echo render($form['submit']); ?>
                    <?php echo drupal_render_children($form); ?>

            </form>

As you can see I'm using comments between form elements, but they're still keeping whitespaces in between.


texts: Why my Migration don't reckognize my plugin in drupal 9

texts:
I'm new in drupal and I try to migrate the article of an old blog with sql database to my drupal 9 project.
I follow
the instruction give by the drupal API migration docs, so i connect the 2 database in the settings.php. Then i generate a module with drush
call article_migration the file  migrate_plus.migration.article.yml :
#Migration metadata
id: article
label: migrate list of articles
migration_group: article_migration

#Source plugin, id defined in the @MigrateSource annotation
#in the src/Plugin/migrate/source/Article.php file.
source:
  plugin: article

#Destination plugin
destination:
  plugin: entity:node

#Process plugin
process:
  # Node type (bundle)
  type:
    plugin: default_value
    default_value: article

  # One-to-one field mapping using the default "get" process plugin.
  title: title
  body/value: content

  #Nothing needed here, it is a single table without any other relation.
  migration_dependencies: {}

plugin source article.php follow the norme :

/**
 * @file
 * Contains Drupal\article_migration\Plugin\migrate\source\Article
 */

 namespace Drupal\article_migration\Plugin\migrate\source;

 use Drupal\migrate\Plugin\migrate\source\SqlBase;

 /**
  * Source plugin for Articles
  *
  *@MigrateSource(
  * id = "news"
  *)
  */
  class Article extends SqlBase {
    /**
     * {@inheritDoc}
     */
    public function query(){
      $query =  $this->select('news', 'n')
        ->fields('n', array(
          'id',
          'title',
          'content',
        ));
        return $query;
    }

    /**
     * {@inheritDoc}
     */
    public function fields(){
      $fields = array(
        'id' => $this->t('Autoincrement ID'),
        'title' => $this->t('Article name'),
        'content' => $this->t('HTML content'),
      );
      return $fields;
    }

    /**
     * {@inheritDoc}
     */
    public function getIDs(){
      return [
        'id' => [
          'type' => 'integer',
          'alias' => 'n',
        ],
      ];
    }
  }

and yet when i try to execute the migration  i have that message error that i don't understand saying that my plugin article doesn't exist  :
The "article" plugin does not exist. Valid plugin IDs for Drupal\migrate\Plugin\MigrateSourcePluginManager are: news, d7_block_translation, d6_block_translation, block, d7_block_custom_translation, d7_block_custom, d6_box, d6_box_tra
  nslation, d7_color, d7_comment_entity_translation, d7_comment, d6_comment, contact_category, contact_settings, d7_view_mode, d7_field_instance_per_view_mode, d7_field_instance_per_form_display, d7_field_option_translation, d7_field,

if someone can put lead me to the right direction or tell me what i'am missing


texts: How do I know from which page the users are coming?

texts:
I'm looking for a way to determine where the users are coming from to build the breadcrumb for a page.

Is there something I can do with hook_breadcrumb_alter(&$active_trail, $item), or should I use the Flag module or any activity tracker module?


texts: How do I programmatically use the S3FS module?

texts:
I've included S3FS module in Drupal 7. I'm able to store files by using S3FS as a field of a node.

Now, I need to store a file on S3 bucket when a cron job is executed. How can I programmatically use the module?


texts: How to remove unnecessary information inside comments for support tickets

texts:
I've installed Support module. And setup comments for it. Everything works fine, but comment contains a lot of unnecessary information:

I looked into comment section of Support ticket content type. But there is nothing I can do about it there:


texts: how do I get the depth of a MenuLinkContent?

texts:
I'm using the sitemap module and i need to get the menu link depth in my preprocess function (template_sitemap_menu_link). I'm trying to do that by accessing the MenuLinkContent object with

    $menu_link_obj = $variables['element']['#original_link'];

There is a getParent() method I can access to check if this is a level zero item, but no way to check for depth. I could always loop trough getParent() until I get NULL and count the number of iterations, but that seems like a bad practise to me. Is there an alternative?


texts:
In my node--content_type.html.twig template file, I can output both the label AND value of a field by using:

{{ content.field_title }}

I can also render just the label of a field with:

{{ content.field_title['#title'] }}

So far, so good.

However, how can I output only the VALUE of a field using the content array? I've tried:

{{ content.field_title['#value'] }}

And:

{{ content.field_title.value }}

To no avail.

Thank you for any help.


texts: How do you access custom user information added from: Configuration » People » Account settings

texts:
I'm looking to create a script that pulls some of this information, but I need to know how to call it. For example one of the 'machine names' for one field is field_first_name how could I call this?

At the moment I'm using:

<?php
global $user;
print $user->name;
?>

Below is what I'm looking for, pulling the custom information instead of the username.

<?php
global $user;
print $user->feild_first_name;
?>


texts: Can I turn cache off for the development deployment?

texts: On development platform caching can be a pain. Can I turn it off? Will it affect any of the modules that require it?


texts:
I'm using the Views and Entity reference modules in Drupal 7. I'm trying to do the following:
Make a view to list nodes of type A (teasers)
Expose filters to filter this list

I have other nodes (type B) that reference A nodes. I would like to add an exposed filter in the form of "Has referring nodes" (of type B implicitly).

My problem is that the only way I am able to do it is by using operators like "greater than" and I don't find a "has" operator. I can implement it as "greater than 0" and it works but it looks really ugly because the user has a text field to put the 0. I would like to have a checkbox that toggles on/off a filter that works like "greater than a fixed value" or an actual "has" filter.

I think the question it is Views related but Ive mentioned the Entity relation just in case its important for the problem.

Thanks for your help.

PD: I have just thought that a "is referred" filter will also work, so thats a third possible solution I'm looking for.


texts: Per instance settings on blocks with context?

texts:
Blocks normally have a single global configuration.

What options are there to provide "per instance" settings on blocks, so that I can vary them depending on where they are displayed, when they are handled with Context?


texts: We have around 150 nodes of type "X". We want to show only 20 nodes out of that for all the users ( including anonymous ) except users having role "Y". For users with role "Y" will be able to see all the 150 nodes. How can I achieve this?.


texts: Monitoring field changes in custom content type

texts:
I have custom content type with "price" field.

I would like to log the information about when the price has been changed (by administrator). All I need is date and old/new value of that field (for each entity of my custom content type).

But how to monitor such changes? Can I use any hook for it?


texts: How do I interact with $title, $breadcrumbs, and $action_links within a process or preprocess function?

texts:
I'm using a Bootstrap subtheme, with a custom page.tpl.php override.  Within the template file, I see there are variables for $title, $breadcrumbs, and $action_links.

If I wanted to access these inside of a preprocess or process function, let's say to modify the title based on whether or not there is content in a given region, how would I do that?

They don't seem to be passed along in $variables like the rest of the page content.  $variables['title'] is not present.  Would I use API functions such as drupal_set_title()?


texts:
I want to move a term from one vocabulary to another.  In drupal 7 one can use taxonomy manager to do this but drupal 8 branch has not implemented MOVE yet and the module has not received any update in some time.

Taxonomy merge that is suggested in this thread has not even been ported in drupal 8 yet.

Thus the only way that is left to do such a task is programmatically.

How do you update programmatically the vocabulary or a term?


texts: How to change the draggable icon of new theme

texts:
I am using draggable table in my new theme. Every thing is working properly but

I want to show this icon like in Bartik theme for every draggable rows:-

Currently it is showing as

How to change this?


texts:
I am trying to customize the Bartik theme.
How can I customize left sidebar? I want to add some more links, and remove the search fields.


texts:
Can I use the Panels module to layout a custom form?

I've created a custom form and I'm loading it in a menu callback using a function like this:

function _MODULE_menu_callback_function() {
  return drupal_get_form('_my_custom_form');
}

My ultimate goal is to use the Panels UI to rearrange the form fields into different panes so that I can easily mix in other elements.

I tried to use Page Manager: Existing Pages to accomplish this, but it simply brings the form in as a whole.  I cannot break the fields apart into different panes using this module.

Is this possible with Panels?


texts: hook_module_implements_alter() to put hook implementations into separate files - bad practice?

texts:
In a number of modules I wrote, I use hook_module_implements_alter() to split up the *.module file, and to move hook implementations into separate files.

The main reason is that I passionately hate long files. (and yes, this does make me unhappy about a lot of the files in Drupal 7 and contrib)

Examples:

nestedbox_core_module_implements_alter()
xautoload_module_implements_alter()

I know there are a few things to consider:

It might not work for all hooks. E.g. boot or install, or hooks that are not called via module_implements().
It is important to include the respective file from within the hook_module_implements_alter() implementation, due to the way that module_implements() works.

Now I heard from a long-time and well-known Drupal developer that this practice is problematic. https://drupal.org/node/2230319 (topic starter, and comments #5 and #11).

Before I start moving functions around, I would like to hear from others whether and why this is bad, both technically and aesthetically.

EDIT:
I guess this could be split in two questions:

Is it good or bad to split up your *.module file, so that hook implementations live elsewhere?
Is hook_module_implements_alter() reliable enough, or should I rather use include_once __DIR__ . '/MYMODULE.filename.inc' directly in the *.module file? What could possibly go wrong by using hook_module_implements_alter() for this?


texts:
How do I know which Drupal 8 modules are supported by Drupal 8 versions?

For example is Page Manager 8.x-1.0-alpha8 module supported in every Drupal 8 version? And if not how do I know which Drupal 8 version supports some module?

Which version of Drupal 8 supports Paragraphs 8.x-1.0-alpha2 module?


texts: How to implement hook_webform_validation_validators()

texts:
While doing validation in a Drupal 6 site, I found it uses the webform module. I just want to apply validation on a specific component.
I googled, but I didn't get any link that would help me with adding a validation hook in a webform.

Can anyone help me with the code to implement for hook_webform_validation_validators()?


texts: Creating programatically a node that has a programtically created image field that should stay empty

texts:
I'm dealing building several modules that should cope with automatic creation of content synchronized with external sources.
The whole process is automatized, e.g. everything had been created programatically.
My content type has and image field attached to it.
When appempting to create a node without defining what this image field should contain (and it should stay empty), I fall with exception:

    PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048
    Column 'fid' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count)
    VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4);
    Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => node [:db_insert_placeholder_3] => 264 [:db_insert_placeholder_4] => 1 )
    in file_usage_add() (line 657 of /usr/local/drupal7/includes/file.inc).

When on hook_node_presave I'm adding an image to this field all works correctly, but I would like to leave this field empty, that may affect the rest of development process.

If I create the node type programatically but add the image field manually -- all works ok. I tried it, then printed the definition of this field using function field_info_field() and copied some values of there into my code, but it didn't help.

Here is my image field definition:

...

'field_member_photo' => array(
'label' => t('Member Photo'),
'field_name' => 'field_member_photo',
'type' => 'image',
'module' => 'image',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'widget' => 'image_image',
'entity_types' => array('node'),
'settings' => array('uri_scheme' => 'public', 'default_image' => 0,),
),

...

Would appreciate any thought about how to solve this problem.


texts:
I have a drop down in my article content type which lets the user select which teaser template to use for that article.

I'm trying to change the template in themename_preprocess_node(), since this is where I know what template is assigned to that specific article.

My problem is that I am struggling to specify which twig template to render.

How can I achieve what I am trying to do?


texts: Only admin can see bulk operations in view

texts:
I have a view that includes bulk operations that involve flagging (Flag module) or unflagging nodes.  I originally created this in Drupal 6 for another site and have been using it for several years.  I recently re-created this in Drupal 7 whereby four different bulk operations can be carried out in a view on a specific type of node.  This works flawlessly for administrative users.  Authenticated users, however, cannot see the four "operations" buttons in the view I've created.

I've checked permissions everywhere, even "loosening" them to see if they were too tight.  For example, I granted "Edit any node" permission to authenticated users, even though they shouldn't need that for the flag action.  I've checked the view permissions, etc.

The operation calls a simple flag or unflag action and I'm unable to find any other permission(s) that might be impacting this.  I'm hoping someone's going to jog my memory with something simple I've missed.

Edited to add:  I have a similar view on the same site that allows users (through VBO) to send an email to multiple users.  They're able to see the button for this functionality just fine.  Again, leading me to believe this is a permissions issue.


texts: How to get drupal module path in javascript?

texts: I'm trying to use this: var path = Drupal.settings.mymodule.basePath;but I'm getting this error: Uncaught TypeError: Cannot read property 'basePath' of undefined.


texts:
I am using the custom module to create a block wich contains a form. I added this form in a node of a custom content type. When I click to submit, I want to open a view wich contains another form and I will create it in the same module.

this is my code

function my_module_block_info() {
$blocks['visit'] = array(
    'info' => t('Visit'),
    'cache' => DRUPAL_CACHE_GLOBAL
);
return $blocks;
}
function my_module_block_view($delta = '') {
$block = array();
if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
    $nid = arg(1);
}
switch ($delta) {
    case 'visit':
        $block['content'] = drupal_get_form('visit_project', $nid);
        break;
}
return $block;
}
function visit_project($form, &$form_state, $nid) {
$form['id'] = array(
    '#type' => 'hidden',
    '#value' => $nid,
);
$form['actions'] = array('#type' => 'actions');
$form['actions'] = array(
    '#type' => 'submit',
    '#value' => t('Visit'),
    '#attributes' => array('class' => array('general_button')),
    '#submit' => array('_visit_project_details')
);
return $form;
}
function my_module_menu() {
$items['my-page'] = array(
    'title' => 'Title of my page',
    'page callback' => 'project_details',
    'access callback' => TRUE,
);
return $items;
}
function _visit_project_details($form_state)
{
   $form_state['redirect'] = 'my-page';
}
function project_details() {
    return '
ok in details of '.$_POST['id'].'
';
}

Can you help to go to my-page after submit form and still reading the $_POST?

Thank you


texts: Domain access domain menu show default values

texts:
The problem:
We have a main site with 70 subsites. On these subsites are users who have access to the menu settings. When they add a menu item they need to check the box near their own subsite.
If they forget this the menu item will be shown on all the other domains. Sometimes resulting in multiple menu items with the same title.

The proposed solution:
Alter the menu_edit_item form so that the $form['domain_menu_access']['manage']['domain_menu_access_show']['#default_value'] is set to the domains the current user has access to.

My question:
How do I set the default value for these checkboxes?
Here is my code:

// Alter the edit menu item form

if($form_id == 'menu_edit_item'){
    $domains = array();
    if($user->uid > 1){
      $form['domain_menu_access']['manage']['#collapsed'] = false;
      foreach($user->domain_user as $domain){

    $form['domain_menu_access']['manage']['domain_menu_access_show']['#default_value'] = array((string)'d'.$domain);
  }
}

I have tried several variations with the $domain. (array($domain), array($domain => $domain), etc)


texts: Facet API, exclude option, and a field with multiple values

texts:
Im getting headaches concerning this one ...

Ive got a field, say a text field nammed "MyField", which can have multiple values.

Ive created a feed that imports the data for this filed.

After the import, my content looks like that :

Content A
Myfield :
- Element 1
- Element 2

Contnent B
Myfield :
- Element 1

Content C
Myfield :
- Element 2
- Element 3

Now im trying to create a facet with an exclude option.
What I would like is when I choose an element, all content, having at least the choosen element as a value of the Myfield field, should be hidden.

So if I check "Element 1", I want the content A and B to be hidden.
And if I check "Element 3", only the content C would be hidden.

The fact is that this is not the way it works ...

If I check "Element 1", only the content B will be hidden, because Content A has another value "Element 2" for this field, so it is not retrieved during the query.

I found something ...

The file "sites/all/modules/contrib/search_api/contrib/search_api_facetapi/plugins/facetapi/query_type_term.inc" contains the "addFacetFilter" function. This is where the exclude cases are processed.

If the Exclude settings is checked, this function changes the query condition to "<>" (instead of "=")

This is the query that is generated concerning an exclude facet :

SELECT COUNT(*) AS expression FROM (SELECT DISTINCT t.item_id AS item_id, :score AS score, 1 AS expression FROM search_api_db_default_node_index t LEFT OUTER JOIN search_api_db_default_node_index_field_produit_organisation_pa t_2 ON t.item_id = t_2.item_id LEFT OUTER JOIN search_api_db_default_node_index_field_derniere_liste_allergen t_3 ON t.item_id = t_3.item_id WHERE (( (t.created >= :db_condition_placeholder_0) )AND (t_2.value = :db_condition_placeholder_1) AND( (t_3.value <> :db_condition_placeholder_2) )))

Retrieved results are wrong.

AND( (t_3.value <> :db_condition_placeholder_2) is the default part added to handle the excluding setting.

Ive managed to modify the SQL Query so that the retrieved results are the good ones :

SELECT DISTINCT t.item_id AS item_id FROM search_api_db_default_node_index t LEFT OUTER JOIN search_api_db_default_node_index_field_produit_organisation_pa t_2 ON t.item_id=t_2.item_id LEFT OUTER JOIN search_api_db_default_node_index_field_derniere_liste_allergen t_3 ON t.item_id = t_3.item_id WHERE (( (t.created >= :db_condition_placeholder_0) )AND t_2.value = :db_condition_placeholder_1) AND NOT EXISTS (select t_4.item_id FROM search_api_db_default_node_index_field_derniere_liste_allergen t_4 WHERE t_4.value = :db_condition_placeholder_3 AND t_4.item_id=t_3.item_id))

Ive replaced the excluding condition with :

AND NOT EXISTS (select t_4.item_id FROM search_api_db_default_node_index_field_derniere_liste_allergen t_4 WHERE t_4.value = 'moutarde' AND t_4.item_id=t_3.item_id)

Now it returns only items that have no occurrence of the selected term in its values

Now I need to know how I can manage to get these correct results with views ... any idea ?


texts: resizing the dimensions of the an image field

texts:
I need to re-size all the thumbnails of my article images to fit the dimensions of the redesign.

Is there a easy way to do this?


texts: drupal 7 error: table blocked_ips not found

texts:
I have a running Drupal 7 site and wanted to restore it locally on development computer. But on localhost I keep receiving white screen in Firefox or Internal Server Error code 500 on Chrome.

Debugging shows that Drupal is running line 1895 of bootstrap.inc, which says:

$denied = (bool)db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();

And just after this line it jumps to error handler, complaining about missing blocked_ips table. The blocked_ips table is not there on either site, the production site had no problem with it.

How to deal with this?


texts: Drupal 7 - How to get Twitter module to post on Node update

texts:
I'm using the Twitter module and have configured all how I wanted. At the moment when I create a post, a Twit is automatically created and submitted to Twitter. All working as expected.

The problem I'm having whenever I update the post, the update doesn't get posted to Twitter.

In the settings (pic attached), I'm trying to tick the box "Post to Twitter on node update" but every time I his "Save" the tick box get "unticked" and the setting doesn't seem to save.

Does anyone know why is this happening? Is it a bug in the module?

Thanks


texts: Clean URLs work*, but not when I submit forms?

texts:
I have a local dev site configured (Ubuntu 14.04.1 LTS), and I copied a production website to play with there. Everything appears to work great. Clean URLs seem to work and I can navigate the site. It's all wonderful... until I try to login.

When I login at /user, submitting the form returns me to the login as if nothing happened. I was able to login by visiting /?q=user .

After that, if I attempt to clear the cache under performance settings, I get a similar result where the performance page loads as if nothing happened (clearing cache manually via mysql doesn't help). If I disable clean URLs altogether, all is well.

I tried replacing the .htaccess file with Drupal's default to prevent special config issues (no effect). I didn't see anything set as $base_url in settings.php (I'll try setting that to see what happens next).

Any thoughts on why a site with clean URLs enabled seems fine until POST data is involved? Thanks for the feedback in advance!


texts:
I am new to Drupal 7, so I hope I am using the word entity in the right context.

I am using the profile2 module to collect additional information when yours signup. Of course, the users are required to provide an email address and they can also upload a photo of themselves.

My issue is how to use the same view to return a users user information (email, username, photo) and all the profile2 collected information.


texts: How to upload files in sites/all folder in a hosted website?

texts:
I want to edit some php files present in sites/all/themes/danland/ and add some css and js files in same location. I have checked by modifying in the localhost to see the affect and finally want these changes to appear on the hosted website.

How can do that? I currently have the site login user details of aws.amazon.com, ssh access to the remote system from where I copied the zipped website files from to work on localhost.

I have already tried to scp my required files in the desired file location on the remote system but those php files do not get hosted even after copying. Also, I also do not want to migrate the complete site at once since my changes are minor and I do not want to take the risk of the hosted website gone wrong.

Please help me as I am new to drupal 6.


texts: How to change the 'Name' label on term add/edit pages programmatically?

texts:
In Drupal 7 this was pretty easy. But now when I try to change the term name label on the term add/edit form all I find are protected methods.

/**
 * Implements hook_form_alter().
 */
function MYMODULE_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  if ($form_id == 'taxonomy_MYVOCABULARY_form') {
    ksm($form['name']);
    // ?????
  }
}

This is no translation issue.


texts: Ajax in textfield adding extra div in markup

texts:
I have created a form using a custom module. I am working on ajax functionality and updating markup when user enter text in textfield of the form.

Creating form in module

/**
 * Implements hook_form().
 */

  $form['name'] = array(
    '#type' => 'textfield',
    '#description' => 'Enter your name',
    '#title' => 'Name',
    '#size' => 50,
    '#ajax' => array(
        'callback' => 'custom_print_ajax_name_callback',
        'wrapper' => 'custom-print-name',
        'method' => 'replace',
  ),
  );

  $form['name_msg'] = array(
    '#type' => 'item',
    '#markup' => (!empty($form_state['input']['name']) ? $form_state['input']['name'] : ''),
    '#prefix' => '
',
    '#suffix' => '
',

  );

Ajax submit callback:

/**
 * Ajax callback
 */
function custom_print_ajax_name_callback($form, &$form_state) {

  return $form['name_msg'];
}

Everything is working correctly except that when I checked HTML of the page, an extra div is added in HTML of markup after updating ajax as shown in below image.

I do not have any idea why is this extra div rendering with markup.

Thanks in advance.


texts: Drupal 7.12 - how do I enable a WYSIWYG editor within the Wysiwyg templates area when creating a new Wysiwyg template?

texts:
I've enabled the Wysiwyg and Wysiwyg API template plugin modules within a Drupal 7.12 installation.

I've subsequently installed CKEditor 3.6.2.7275 and configured the Wysiwyg profiles for Filtered HTML, and Full HTML to use CKEditor leaving the setting for Plain text set to 'no editor'.

What I want to do is make it so an administrator can use CKEditor when creating new Wysiwyg templates.

I want an admin to be able to use full or filtered HTML via CKEditor.

Can anyone help me to enable a WYSIWYG editor within the WYSIWYG templates area when creating a new WYSIWYG template?


texts:
I created an entity in a module, using code. I generated skeletons with drupal console generate:entity:content (without bundles), and then added a datetime field to my TestFieldEntityItem.php, in baseFieldDefinitions().

$fields['test_date_incode'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Test date'))
  ->setDescription(t('Test.'))
  ->setRevisionable(TRUE)
  ->setSettings([
    'datetime_type' => 'date'
  ])
  ->setDefaultValue('')
  ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'datetime_default',
    'settings' => [
      'format_type' => 'medium',
    ],
    'weight' => 14,
  ])
  ->setDisplayOptions('form', [
    'type' => 'datetime',
    'weight' => 14,
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

I can add data to my entity, without problem, but if I want to add another field (a simple text field) through the UI, I get this error:

  Un problème est survenu à la création du champ test_text : The "datetime" plugin does not exist.

(In English, the error message is A problem occurred creating field test_text: The "datetime" plugin does not exist.)

The field is created, but I don't like this error. It seems my code to create the datetime field is not the right one.
I use the Calendar module, if this could have any incidence.


texts: How to modify a term reference autocomplete field

texts: I am using a term reference field but the widget type is autocomplete term widget. This term consist of many levels as parents and child. In the form I need to display only the child terms(only the lowest level in my case 3rd level) in this field. How can I do this. Please anyone help me on this. Thanks


texts: Display all content in a group, even to non-members

texts:
I've setup a few Organic Groups. I've created a view to show all of the content (full content) related to the current Group ID in a block. I placed the block onto the group's node page.

The view works fine for members of the group (displays full content). However, I would like to show this same content to non-members of the group as well. Currently, non-members see only titles of the node content related to the group and a link "Request Group Membership". I'd like to continue to display that link, but would like to show the full content of the nodes related to the group, just as members of the group can see. My view is there, but only the titles of the nodes (not linked) display in a list.


texts: When using &drupal_static to cache variables how do I store an empty return result of null or false?

texts:
I'm making an expensive soap call and would like to cache it even if it is empty through the duration of the script and page load. It's entirely possible that in the third party database the object is empty and null. I don't want to make five soap calls if the object is empty. I feel like using PHP empty() and isset() this way is hackish. It works but there is a lot of funky logic involved. Is there a better way?

I need the drupal_static so if the $third_party_info_object is change anywhere else all the caches can get cleaned.

function my_module_get_information($user) {

  third_party_soap_initialize();

  $third_party_info = &drupal_static(__FUNCTION__);

  if (!isset($third_party_info) && is_null($third_party_info)) {
    // work some magic here
    $account_object = new thirdPartyAccounObject();
    $account_object->setThirdParyAccountId($user->uid);

    $third_party_info_object = new ThirdPartyInfo();
    $response = $third_party_info_object->getByAccount($account_object, false);

    $returnCode = {get the $returnCode here}

    if ($returnCode == 200) {
      $third_party_info = $response->getThirdPartyInfo();
    }
  }

  if (!isset($third_party_info)) {
    $third_party_info = false;
  }

  return $third_party_info;
}


texts: node_load_multiple does not respect node access grants

texts:
I used $nodes = node_load_multiple(NULL, array("title" => "Foo Bar")); to fetch nodes by titles. But after going through Drupal security standards, node_load_multiple is not the right way to load all nodes.

node_load_multiple() will load ALL nodes regardless of access, so that must not be used here.

Solution suggestion is:

  Use an entity query instead. "When adding a node listing to your
  module, be sure to use an entity query, which will add a tag of
  "node_access". This will allow modules dealing with node access to
  ensure only nodes to which the user has access are retrieved"

But I'm not sure how to apply above statement programmaticly?

Is below query the right way that solves security issues?

\Drupal\node\Entity\Node::loadMultiple(NULL, array("title" => "Foo Bar"));

If not, please suggest an appropriate alternate of loading nodes by title that respects node access grants.


texts: How to add Add Search Index view mode in eck entity type?

texts:
I am using ECk module in one of my content for displaying content in managed way .
The problem which i am facing the content in eck fields not creating search index when we are searching its content by input any string in search block nothing is searching regarding that field.

I have properly indexed all the node in admin/config/search/pages

Actually when i am enabling search index view mode in any content type then its content is searchable otherwise not.
There is no option to add search index view mode in Eck entity type like node content type.

I want to programatically add search index view mode in ECK field.

I want to do something like below code

$entity_type="eck"; //The entity for which you want to create the view mode
$view_mode="search index"; //The name of the new view mode
$settings=Array();
$settings["id"]=$entity_type.".".$view_mode;
$settings["targetEntityType"]=$entity_type;
$evm=Drupal\Core\Entity\Entity\EntityViewMode::create($settings);
$evm->save();


texts: Where to look in D7 if virtual tabs in cck edit form do not appear?

texts:
I'm having some problem with my D7 installation - I've migrated from D6 on this. Thing is, when I create content of a CCK type, some of the vertical tabs on the bottom of the form are not available for some types, but not for all.

I cannot find the settings where and how to change this behavior. I'm missing the 'menu settings', 'revision information', 'authoring information' and 'comment settings'. Didn't find an option in the cck settings or variables.

Since the system does not report any error on this, it's hard to find in what database table the settings are hiding and what goes wrong.


texts: How to host and play videos in a drupal site?

texts: Just that, I need to host and play videos in a drupal site. I mean not using vimeo, youtube...


texts: Splash screen for product category doesn't show

texts:
The version is Drupal 7. It is a B2B inquiry store and I just started at the company whom asked me to fix the splash screen function on their store.

The menu on the site looks like this:

-Main cat 1
   - sub cat 1
   - sub cat 2
   - sub cat 3
   - sub cat 4
-Main cat 2
   - sub cat 1
   - sub cat 2
   - sub cat 3
   - sub cat 4

and they would like to show some information and some picture when you click on the main category.

When I click on Edit for the Main Cat page, I can set some pictures and some text I would like to have displayed, but when I look at the page after I save, I still only get to see products.

This is how the settings look like:

And this is the result:

My question would be if anybody has any idea of what may cause the problem? Maybe somewhere I am supposed to uncheck a box or something?


texts: How can I fetch the complete main navigation menu via JSON:API?

texts:
How can I fetch the complete main navigation menu via jsonapi?

I've tried:

curl --header 'Accept: application/vnd.api+json' https://cms.example.com/jsonapi/menu/menu/

and

 curl --header 'Accept: application/vnd.api+json' https://cms.example.com/jsonapi/menu/menu/232fc942-51f3-4478-8535-e5dc482a166e

where 232fc942-51f3-4478-8535-e5dc482a166e is the id of the main-navigation menu BUT only the first level nodes are returned:

{
  "data": {
    "type": "menu--menu",
    "id": "232fc942-51f3-4478-8535-e5dc482a166e",
    "attributes": {
      "label": "Main navigation"
    },
    "links": {
      "self": {
    "href": "https://cms.garanteasy.com/jsonapi/menu/menu/232fc942-51f3-4478-8535-e5dc482a166e"
      }
    }
  },
  "jsonapi": {
    "version": "1.0",
    "meta": {
      "links": {
    "self": {
      "href": "http://jsonapi.org/format/1.0/"
    }
      }
    }
  },
  "links": {
    "self": {
      "href": "https://cms.garanteasy.com/jsonapi/menu/menu/232fc942-51f3-4478-8535-e5dc482a166e"
    }
  }
}


texts: File attachments should be private if node is unpublished

texts: If a content editor uploads a file to an unpublished node. An anonymous user should not be able to go to the file by the url pathing UNTIL the node is published. Any help on how to restrict file attachment access to anonymous users on unpublished nodes would be appreciated.


texts: How to add custom functionality on per-date base to nodes that use date fields for an event ticket system?

texts:
For an event ticket system I have created a node type with multiple date fields including start- and end-dates.

-EVENT1-
Date A
Date B - Date F
Date G

- Event2 -
Date B
Date C
Date E - Date G

Now I need to add a boolean field to every date that is inserted into an event node to possible mark it as 'sold out event day'. How is this possible when I want to use the start-/end-date option? I don't want to create a nodetype 'date' and then reference its nodes to an event-node...
Thnx!


texts: What is the significance of dumping the tablespaces?

texts:
While recently running drush sql-dump on a server where there were never any error messages, I have started to get:

mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

It still produces a file I can import locally and I don't seem to be having any problems. But I am still curious: What is the significance of dumping the tablespaces when it comes to the average Drupal sysadmin?
Environment

Drush: Drush Commandline Tool 10.3.2
Drupal: 8.9.13
DB: Server version: 5.7.31-34-log Percona Server (GPL), Release '34', Revision '2e68637'
Acquia Cloud hosted


texts:
Sync Drupal commerce order information between several drupal instances.

Here is my use case.

A business has a Drupal commerce website.
It also has several internal commerce sites.

Each of these has to have the ability to work independently of each other for certain periods of time.
At a later date there will be a mobile app doing the same thing.
So any sales information or orders need to be synced at later points throughout the day.

What is the recommended way to do that securely and also avoid and order related conflicts such as order number customer name changes etc?

I realize this is a fairly broad question but Im not looking for a specific answer,  Any general information or recommendations would be great.


texts:
Please, I need help.

I have a site design that has a totally different home page than the rest of the pages. The interior pages might present problems too, I don't know...everything in Drupal seems like a mighty struggle that takes days or weeks to understand.

At any rate, i'm using a zen sub-theme. I created all my blocks from scratch in the admin interface and then styled them in _custom.scss (imported to styles.scss) such that they all had styles to set them up exactly as I intended...It took awhile but I finally made it look like I wanted it to look.

Then I thought I should try using zen grids to do the layout since it was included in zen package and thought I would be able to utilize all the benefits of that system by doing so. So I re-did the entire home page by editing the responsive.scss in /layouts folder specifically for my home page layout with the blocks all over the place. But now I realize this won't work because I need to have a different layout on the other pages...possibly many different layouts...so maybe zen grids won't work for me, but I don't know that for a fact...I just don't know.

So I looked into creating a template.php function to call a different css file for the home page but after reading a bunch of articles on this site and other sites I couldn't get that to work either. I tried calling a different stylesheet if it's the front page from my .info file but couldn't get that to work either...maybe I don't know how to call the 'home page' correctly.

Does anyone have any tips for moving forward with what should be a fairly simple design using the zen sub-theme and about 6-7 other sites pages (including one custom module which is almost done and some views pages)?


texts: #block-system-main with no content interrupting my layout

texts:
I have a drupal page with three blocks beeing rendered and floated besides each other in a content area. In the middle of these, Drupal renders out a block called #block-system-main with an empty content div. It breaks my floats, and I have no idea where this div is coming from or how to remove it.

Any ideas as to what could cause this and how I can remove it?


texts:
i have a Problem extending a BookNavigationBlock Plugin. When I extend BlockBase it works, but when trying to extend BookNavigationBlock, it fails when placing the block, without any error messages. What am I missing here? (The Code is inside modules/ifg_book_navigation/src/Plugin/Block/IfgBookNavigationBlock.php)

namespace Drupal\ifg_book_navigation\Plugin\Block;

use Drupal\book\Plugin\Block;
/**
 * Provides a fully expanded 'Book navigation' block.
 *
 * @Block(
 *   id = "ifg_book_navigation",
 *   admin_label = @Translation("Expanded Book navigation"),
 *   category = @Translation("Menus")
 * )
 */
class IfgBookNavigationBlock extends BookNavigationBlock {

  /**
   * {@inheritdoc}
   */
  public function build() {
    return array(
      '#markup' => $this->t('Hello, World!'),
    );
  }
}

Thanx!

UPDATE:
I could trace the Problem to the Plugin Factory.
In the getPluginClass method of DefaultFactory it is checked if the class exists:

if (!class_exists($class)) {
  throw new PluginException(sprintf('Plugin (%s) instance class "%s" does not exist.', $plugin_id, $class));
}

The value of $class is Drupal\ifg_book_navigation\Plugin\Block\IfgBookNavigationBlock which seems to be correct. However class_exists() itself seems to fail, not even returning false. This could have something to do with autoloading, as by default class_exists() tries this by default ...

UPDATE: It seems like the behaviour is the same for other existing blocks, just tested UserLoginBlock


texts: Configuration values in Kernel Test are null

texts:
I'm trying to write a kernel test for a service in my custom module.
This service depends on certain configuration values that are installed by default when the module is enabled. Values are stored in /config/install/mymodule.settings.yml
If I try to get these configuration values in my test setUp() function, I get the correct value.
However, when the test is running, the same value is null when called from inside the service.
Any idea why?


texts: Is it safe to delete all revisions of a deleted node?

texts:
I'm trying to import nodes from a Drupal 7 database to a brand new Drupal 8 one using the Feeds module.

I'v imported stuff and then deleted it (because I'm testing at the moment the best way to do it). I keep deleting nodes, but I've noticed that the revision tables are full of stuff.

Currently there is no node in the site, but the revision tables are occupying 50MB already.

Is it safe to empty all those tables?


texts: How to conditionally hide a space in a rules action if the first token is empty?

texts:
I am using the tokens module to print personalized email notifications. Sometimes a webform component is not filled out and the email notification leaves an empty space before the token. I am using the Rules module to send a mail.

E.g.

[data:title-value-raw] [data:name-value-raw]

Default output

Mr. Example

Expected result

Example

Actual result

 Example

How can I hide the space if the first token is empty?

Drupal rule to send message.

{ "rules_mail_confirmation" : {
"LABEL" : "Mail Confirmation",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "webform_rules" ],
"ON" : { "webform_rules_submit" : [] },
"IF" : [
  { "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "contact" : "contact" } } } },
  { "node_is_webform" : { "node" : [ "node" ] } }
],
"DO" : [
  { "mail" : {
      "to" : "[data:email-value]",
      "subject" : "Confirmation",
      "message" : "[data:title-value-raw] [data:name-value-raw],\r\n\r\n",
      "from" : "[site:mail]"
    }
  }
]

}
}


texts: Rate module stops working and admin menu disappears on frontpage - fixed by flushing cache

texts:
At random times, the Rate widget in a view on my frontpage stops working, and the votes are no longer recorded. The users are also able to click the vote widget on their own content when this happens, even though it's not allowed. That vote is not recorded either, but the widget turns into a link, and it shouldn't. The admin menu also disappears.

And all this only happens on the front page. It's easily fixed by flushing the cache, but that's not very efficient :)

How can I fix this issue from happening again?


texts: How do I set a block title to the title of a referenced node?

texts:
In Views 3, I have a block that is showing content from a particular Node ID. I'd like to have the title of that block set dynamically to what the referenced page's title is. I know this would be accomplished using Contextual Filters and that my display's title would be an argument, like %1 but I'm uncertain what the Contextual Filter settings should be. I'd rather not use PHP code if avoidable simply because I don't have the 'PHP Filter' module enabled on most sites I create.

Which settings should I use to make a block title the same as the title of a referenced node?


texts: How to give access to inactive user profile?

texts:
I guess the title is obvious. I have built a Drupal 7 website showing a view of the previous Users (inactive profiles).

As an admin, I can access these profiles but I need anonymous users to have that permission too (view "previous" or "old" members profiles).

Is there any module to add that kind of permission?

Thanks and sorry for my English ;)


texts: Pagination for Multi value Entity Reference fields

texts:
I have added an Entity Reference type (Taxonomy Term) to the User Entity.  It is a multi-value field so that any number of taxonomy terms can have the reference.

Now I am using the following code to get the referenced entities for the current user.
/** @var \Drupal\user\Entity\User $user */
$user = $this->userStorage->load($this->currentUser->id());

/** @var /Drupal\Core\Field\EntityReferenceFieldItemList $myMagazineReferenceItemList */
$myMagazineReferenceItemList = $user->get('field_my_magazines');

/** @var \Drupal\taxonomy\Entity\Term $myMagazine */
foreach ($myMagazineReferenceItemList->referencedEntities() as $key => $myMagazine) {
    // Create an array of taxonomy terms
}

I am able to get all the entity-reference-list in $myMagazineReferenceItemList. But can I use pagination for this? I am using the code in a REST endpoint, so I would like to make the result paginated. Is there any right-approach for this?
Should I explicitly need to use delta explicitly and build pagination?


texts:
I have been given a broken site and a database that was formerly running Drupal commerce via Commerce kickstart. The site was hacked when Drupalgeddon happened, and I can't get the code to update (lots of missing component errors).

So I think we need to start over from scratch here, and I would like to know what the SQL query might be to get all of the product data out of the database? Is this something that can be done directly in SQL?


texts:
Let's say I set a variable in settings.php:
$conf['var'] = foo;

In my module or theme code, I can access this with either:
variable_get('var'); or $GLOBALS['conf']['var'];

Which is the preferred method and why?


texts: Can anyone recommend a good Drupal module for managing/displaying videos

texts:
I would like to put together a video gallery on my website and am wondering if there are any existing Drupal modules to manage that. I'm using Drupal 6 and most likely the videos will be hosted on YouTube.

Ideally, I would like to arrange them in topical albums in which each video could be annotated with a description of the videos.

Thanks.


texts: how can I change all price view in drupal commerce

texts:
I want to change default drupal view of price in all of my field,
as a example I want to remove '00' and add my custom postfix to it,

I found hook_commerce_price_field_formatter_prepare_view but when I implement it in my module it not called,really I am not sure this hook is suitable and ca  achieve my need??

I just want the all price fields changes to my desire only  in front-end view (only in view, because my payment method is according to main currency)


texts:
who use a form in a node?
for example
I want to create a content type that show in this, my product , description , ....
and bottom on this node have a form to get comment and price recommended of user.

I test Webform but not in use for me!

who to create this content type?


texts: Move File Field storage from public:// to another stream wrapper (like s3://)

texts:
I've been looking around for this a bit, and it seems like it would be relatively easy in Drupal 7, since D7 supports stream wrappers, and Fields are part of core... but I can't find any documentation.

I have a file field with a few thousand files attached to nodes, and it's using public:// right now.

I also have the AmazonS3 module installed, and some other file fields are already set to use the s3:// stream wrapper.

I now want to migrate the file field using public:// to s3://, and I want all the files already uploaded to the site's files folder to switch to s3. I can manually copy over the files to a bucket on S3, but what exactly would I need to do in Drupal/the database to get the files to be loaded over s3 instead of public?

I thought about just writing a custom query to update all rows in the file_managed table with public://custom/path to change to s3://custom/path, but (a) there are some older files that were migrated with different paths than custom/path, and (b) I'm not sure if this is the right way to get Drupal to use S3.

[Edit: Just noticed the file_move() function in the API—would I be able to move files using this (after switching the field storage in the Field UI) instead of having to manually copy files and update the database?].


texts: Registration email showing default mail message as well new custom message

texts:
How to stop default mail , i want to override default mail with my custom body message?
Here is my code :
function mag_api_mail_alter(&$message) {
  // only alter register forms
  if (!empty($message['id']) && $message['id'] == 'user_register_no_approval_required') {

  // make it a bit neater to access fields

    $nids = \Drupal::entityQuery('node')->condition('type','email_template')->execute();
    $nodes =  \Drupal\node\Entity\Node::loadMultiple($nids);
    $data_fields = array();
    foreach ($nodes as $new_data){
        $data_fields[] = $new_data->get('body')->getValue();
    }
    $contact_message = $message['params']['account'];
    $first_name = $contact_message->field_first_name->value;
    $username_email = $contact_message->get('name')->value;
    $pass = 'test';
    $app_url = 'abcd.com';

    /*custom field added through configuration*/

    $to_replace_keys = array("[user_name]","[user_email]","[user_password]","[app_url]");
    $replace_keys =array($first_name,$username_email,$pass,$app_url);
    $success_email_msg = str_replace($to_replace_keys, $replace_keys,$data_fields[0][0]['value']);
    // Assigning new message to mail body.
    $message['body'][] = $success_email_msg;

   }
}

Its is working but i am not able to find out why is this showing default mail message as well new body message.
I just want to show my custom body message.


texts: Imported views from other site that didn't have any Master display in the UI. How to remove Master display from Views UI?

texts:
I wanted to reuse some View I built on older site which is using EVA module and contextual filters and so on. So I just re-imported it to my new site and now from nowhere there's that Master display showing up (while on older site its not shown) when editing view and the view cannot be saved because it gives me error:

'Display "Master" uses fields but there are none defined for it or all are excluded.'

The problem is that I don't need that master display at all. How is that it popped up from nowhere?


texts: Drush, post receive hooks and git branches/tags

texts:
I am stuck with a nagging issue in our deployment systems

drush version 5.7
git version 1.7.7
Drupal 7.x

We currently have a bare git repository (consisting of drush makefiles) on the production server that fires off a post-receive hook to recursively build our Drupal multisite structure with drush make when it receives new data via a push from our local machines.

Everything works very swimmingly until a project in the makefiles contains either a git tag or branch in the definition. Then, the post-receive hook triggered build fails with :

    git://github.com/[account]/[repo].git.
    DOWNLOAD_ERROR: Unable to check out tag 7.x-1.01. -- build forced  [warning]

Even more interesting : if I run the build on the production server locally or via a remote SSH command, the build succeeds. The problem only arises if it is run from a post-receive hook from a remote git push.

Verbose output offers no more information.

I can only assume that the post-receive hook system in git does not store/carry over an environment variable that is required for a drush to perform a two-step git operation on the single project. Is this a known issue?

I recognize this hurdle can be avoided by defining the project in the makefile as a 'get' download and providing the github download URL (instead of using the git functionality). Being pedantic, however, I'd like to narrow down where the problem is, and report it as a bug if appropriate.

I can repeat this on a fresh install.

But has anyone run into this? Solutions would be welcomed with elation.


texts: links__system_main_menu in drupal not gettign called

texts:
I created a theme and the theme name is abc. I am trying to override the default menu in drupal. I have the following filed in the theme folder (folder name is abc).

abc.info file and page.tpl and template.php file.

Inside the template.php I wrote the following

function abc_links__system_main_menu($variables) {
print_r($variables);die();
}

but this function never gets called. I already assigned the main menu to the header region through drupal admin. Drupal version is 7.

I have another function

function abc_menu_tree__main_menu($variables) {print_r($variables);die();
}

this function gets called without any issues.

Any help please


texts: custom node template involving the use of quick tabs in drupal 7?

texts:
I have products that I want to display divided up into quick tabs. Originally I was thinking of using multiple views to do this, but then I realized that there has to be a way to do it using a node--product.tpl.php. the way they are divided up are as follows:

One quick tab that has a basic image, title, and a little paragraph about the product.
The second tab should have features of the product.
The third should be a description of the product. the fourth should be files (images, and videos, and audio files, etc).
And the last one is a tab for technicians of the product.

I want it so that I only have to use one CCK to do this, and it would be the content it's self, instead of multiple views put togeather in quick tabs. here is the kind of thing that I am looking for:

1. Product Tab:

2. Features Tab

is this possible to do in a node--product.tpl.php?


texts:
I need to specify the type of script in my theme.info
I add the script in my theme.info like this scripts[] = js/file.js
In the head it look like this

<script type="text/javascript" src="..."></script>

but i need to change the type to

type="application/ld+json"

Can someone help me please


texts: How to properly configure jQuery for Views Slideshow/Flexslider displays in blocks

texts:
I've been playing with a slider/slide implementation for my site. But don't know how to configure jQuery properly.  My research suggests that this is an issue with the implementation of a jQuery version, but there's conflicting information on how to resolve the problem in the various documentation. I'm aware of both jquery_update and jquery_plugin modules. My current setup have manually loaded libraries for jquery.cycle and Flexslider per their individual documentations. Earlier posts suggest this was a jQuery version conflict.

The issue I have is that the slideshow only cycles in the preview on the page view of the slider. It doesn't cycle in the block view, and it doesn't cycle when it's placed on my page. This the case with both Flexslider and with Views Slideshow. I have the correct modules and libraries, I just don't understand why it works in preview and not when placed on the page.

This post addresses a similar issue Flexslider view preview working but not on actual page, but doesn't really elaborate on how the jquery update conflicts, or how to solve the problem. This post was was flagged as a duplicate so I am trying to articulate what I think I need help with here.

I have searched the documentation on Views Slideshow and Flexslider, and I haven't found an obvious solution to the problem, or a definitive way to address the problem. What seems to be the case is that this is a jQuery versioning issue, where for some reason the javascript isn't initialized from the block itself, but only a page view. I don't know enough about the behavior of javascript in Drupal to understand exactly why one will make the js call, and the other won't?


texts:
I have a module that will provide a dropdown when creating a new block. Selecting either none, option 1 or option 2 will add a corresponding class to that block. That class will be targeted by a small (>4kb) jquery file. The file needs to be able to access every page since blocks can be put anywhere on the site.

I have seen multiple methods of adding JS files to websites, including editing the theme .info file. What is the best way to accomplish what I am trying to do? If the info file is the best way to go, is there a way to programmatically add the JS file to the info file?


texts: Change mailsystem used on webforms on a per email basis

texts:
I'm using the mailsystem module to send webform notification emails using mandrill.

However, for some of our webforms we need to use mandrill for the notification email sent to the users, but send the admin notifications without mandrill, using normal text based emails.

From what I can tell you can only change the mailsystem on a per module or per-key basis, and it seems like all webform emails use the same key -- "submission".

Is there any way to achieve what I want here?

Thanks,


texts: How to set related products view contextual filter to get its value from current product category id

texts:
I have build a Related Products view that supposed to show latest products which in the same category of the current product being viewed.

so I set a contextual filter for the category_id field, but couldn't find anyway to get the commerce product category id.

Drupal 8 / Commerce 2


texts:
I have an installation which I am trying to upgrade from Drupal 6 without much success. I have decided to manually port the database over.

I realized that in a fresh installation of Drupal 7, node has entity ID = 1 whereas in another installation, node has entity ID = 2.

Where is the table storing this data located?


texts:
I have defined a new content type, that just has a body field, which I define in my install file:

$type = array(
        'type' => 'status_update',
        'name' => t('Status Update'),
        'module' => 'socmed',
        'base' => 'node_content',
        'description' => t('A Facebook-like status update.'),
        'has_title' => FALSE,
        'custom' => TRUE
        );

    // Turn off comments.
    variable_set('comment_status_update', 0);

    // Fill in remaining defaults, add a body field and save the node type.
    $type = node_type_set_defaults($type);
    node_add_body_field($type);
    node_type_save($type);

I would now like to

a) Create a new text format.

b) Assign that text format to be the default for this content type's body.

c) Set permissions on the text format for normal authenticated users, so that this text format is the only option.

I want to package this up as a module, so I would like to do so programatically, but I'm not sure how to go about it. Any pointers on any of these steps? Thanks!


texts: Custom content for several Spanish speaking countries

texts:
I am on Drupal 7.

I need a website that will have different versions for each country in Latin America, where many countries speak Spanish. I was considering using one language per country, but as far as I am concerned, Drupal has only one Spanish version. At least, it doesn`t have one Spanish for Costa Rica, another to Honduras, Panama, El Salvador, Colombia and so forth. So I was considering creating one flavor of Spanish per country in Drupal (I would create new custom languages like "es-country code") and loading all the Spanish vocabulary again and again into these alternative custom languages. Do you think this approach works? I would like to take advantage from the fact that when using localization (i18n) you can set one single structure/navigation for the website accross the languages. The content across different countries will usually be the same, but sometimes it will be different. Working with i18n I can duplicate content accross the countries and change the small details wherever I need.

So my question isn`t technical, but broader. Do you think this approach is good? Which strategy/approach would you use if you needed to content customization per country where some of these countries speak the same language? Thank you


texts:
I want to know what's the limit of drupal?:

Maximum number of nodes .
Maximum number of content type .
Maximum of files 's size .

And That without interruption of service .
I am using Apache + mysql +redhat  .
Thank you very much


texts: Further optimizing CSS delivery with AdvAgg?

texts:
It seems to me that my main Drupal UI based task to leverage my site's optimization is further optimizing it's CSS delivery...

Given the following facts, It's wired for me that Google's PSI advices me to do so:

Aggregation is on for CSS.
AdvAgg is installed and (as can seen from the picture) Both CSS minification & compression are on.
If it relates in any way in this case --- HTML is minified (if CSS served via HTML it would be served better, I guess).

Besides that, the site is very light in graphic details (both images and CSS).

I've tried to do the following AdvAgg conf's, but when I ran PSI again the advice still appeared:

Putting more css bundles per page (5 instead of 4) while I admit I am not familiar with the term at all.
compressing the (small amount) of inline CSS via YUI method.
Enable preprocess on all CSS and Checking all checkboxes at "Optimize CSS rendering", at the Modifications tab (via Modifications sub-module).

Further details:

Full PSI score results

It seem I don't have much options left... Would appreciate your help, Ben.


texts:
Users must be logged in to see anything on my site; so it's important the user login block is always shown to anonymous users.

When users log out, they are normally redirected to the front page. A user has reported an issue where this doesn't happen; the user is kept at /user/logout, where the blocks are not shown.

If I manually navigate to that address, the redirection to the front page doesn't always happen to me, and I can also see that no blocks are shown.


texts: drupal 7: hook intercept url file requests located within the "Public File System Path"

texts:
For Drupal 7 when going to: admin/config/media/file-system you can set up both a Public and Private File System Path.

Is it possible for files that are within the "Public File System Path" that when they are directly accessed via url that a hook could intercept that file request and decide based on the users role whether to allow or send them to a goto like (drupal_goto('user', array('query' => array('destination' => $pre_alias)));)

I know that the hook_file_download can intercept file requests for private files but if possible I don't want to have to spend this extra time setting up a private area.


texts:
I installed the Menu block module, and it seems to work fine.

I need to change one of the menu HTML output; instead of the following HTML tags:

Home

Our Rides

I want to have:

Home|Our Rides

I tried implementing a hook, but it doesn't work.

function bsrentals_menu_item_link__menu_block($variables) {
      print 123;exit;
}


texts: How to add custom line item total to order total amount?

texts:
I am using commerce_discount module to create a custom line item. Then inside my code I am creating a line item of type commerce_discount. I populate it and save it to order. It is saved but the line item total amount is not added to order total amount. The code is given below.

$line_item_new = commerce_line_item_new('commerce_discount', $order->order_id);

        $line_item_new->line_item_label = 'Discount';
        $line_item_new->quantity = 1;
        $line_item_new->commerce_unit_price['amount'] = $total_discount;
        $line_item_new->commerce_unit_price['currency'] = commerce_default_currency();
        $line_item_new->commerce_total['und'][0]['amount'] = -$amount;

        $order->commerce_line_items[] = $line_item_new;
        commerce_order_save($order);


texts: Display block content in current language

texts:
I have multilingual Drupal 8 site.

I want to display views block in home page.

It should display block contents in current site language.

Example:

I have content type called "Book". Which has translated content in EN & NL.
Created views block for "Book" content type.
Placed this block in Home page.
Enabled language switcher block in Home page.

When I visit my home page mysite.com & mysite.com/nl above views block shows always English contents.

When I visit site in NL language, I want to display this block in NL language.


texts: D7: Race condition(?) when deleting a node with lots of associated nodes?

texts:
I've got a situation where I have a content type -- let's call it "book" -- which has a number of related nodes attached to it -- let's call them "chapters".  A user's home page shows snippets of each of the "books" that he's created on the site.

Now, comes the time when the user wants to delete one of these books.  As noted, each book has all those chapter nodes attached to it, so, when the book is deleted, the chapter nodes need to go away, too.  (It's actually worse than this -- in the real case, there is a LOT of stuff associated with a book, and it ALL has to be deleted.  But this will do for now.)

So I have something like:

 function book_node_delete($node) {
     try() {
           // stuff
           node_delete_multiple(get_chapter_nids_of_book($node);
           // other stuff
     }
     catch (Exception $e) {
           ....
     }
 }

(The try/catch is there because, in the real situation, there's a LOT of DB stuff going on, and I'm trying to make sure that I always have a consistent database.)

Once the book is deleted, the user gets sent back to his home page, where he is meant to see the snippets of his remaining books.  But what I'm finding is that, when there are a lot of chapters and other stuff, Drupal sends the user back to the home page BEFORE all the deletion is done and the book node is completely deleted.  He therefore gets a home page with a listing of the just-deleted book.  This is wrong, of course, and leads to a 404 when the deletion actually finishes and the link in the snippet fails to resolve.

I've set up a bunch of watchdog statements tracking the deletion process, and this is definitely what's going on.  Is there any way around it? Thanks!


texts: How can I load all Media of a certain type?

texts:
I am trying to load all media items of a certain type but I can't find how to.

Is there a way to set a filtering type on something like

$media = Media::loadMultiple();

Or do you have to load all media and then filter manually?


texts: Description metatag from first row of the view

texts:
Okay. Current version of metatag_views does not support views data in it's tokens. The idea is to make custom handler based on Custom text, where theme() method will have the rendered text. If I put the result in drupal_static variable, I can get it in hook_page_attachments.
But if the view is cached, hook_page_attachments does not gave a value.

Is there a way to save the data generated in the field handler and get it when the view is displayed? Or is there a way to get cached view with some hook and get the value from its results?

Handler code. Copy and paste from «Custom text»:

/**
 * A handler to provide a field that is completely custom by the administrator.
 *
 * @ingroup views_field_handlers
 *
 * @ViewsField("description_field")
 */
class DescriptionField extends FieldPluginBase {
.......
/**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {
    // Return the text, so the code never thinks the value is empty.
    $ret = ViewsRenderPipelineMarkup::create(Xss::filterAdmin($this->options['alter']['text']));
    // $ret has rendered value. I need to store it somewhere.
    $description = &drupal_static('bd_metatag_description');
    $description = $ret;
    return $ret;
  }
.........
}

And then hook:

function HOOK_page_attachments(array &$page) {
  $d = &drupal_static('bd_metatag_description');
  // When the view is not cached everything is okay. But is there a way to get cached view data?
    $description = [
      '#tag' => 'meta',
      '#attributes' => [
        'name' => 'description',
        'content' => $d,
      ],
    ];
    $page['#attached']['html_head'][] = [$description, 'description'];

}


texts: Unsubscribe users from Simplenews from a specific Newsletter category

texts:
I send newsletters from my Drupal-7 website using Simplenews module. I have a general category, that has all my site users and it is the category I use the most.
Although, some of the newsletters are sent to a smaller target group (women-only, men-only etc).
My problem is that when users click on the unsubscribe link from a newsletter that is not from my general category, then they unsubscribe from this category only and not the general.
What I want to achieve, is that when a user is unsubscribed from any newsletter category, to automatically unsubscribe him from the general category also.


texts: Send newsletter with list of users with specific field value

texts: Is there a module to send a newsletter with a list of users with the same interests?


texts: Query condition on entity reference field count

texts:
I need to query an article with more than 1 tag (a field entity reference) in drupal entity query.

I tried this :

$query = Drupal::entityQuery('node')
                ->condition('type', 'article')
                ->condition('field_tags', 1, '>');
dd($query->execute());

But I got more than expected the articles id's and I don't why.

What is the good query to do that ?


texts: How do I add a class to the HTML "body" tag programmatically?

texts:
I would like to add a custom CSS class to  the <body> tag. I am using Drupal 7/Corolla.

How can I do it programmatically from my custom module?


texts: Show block on term page if term has no children

texts: Is there a way (probably with PHP block viability settings) to only show a view on term pages and only if the term has no child terms?