texts: Add a class to all the blocks in a region

texts:
I'm theming a Drupal 7 site and I'd like to add a class to all the blocks in a given region using preprocess_block().

I think this should work, but it doesn't seem to:

function MYTHEME_preprocess_block(&$variables) {
        // Other stuff in this function
        $variables['title_attributes_array']['class'][] = 'title';
        $variables['classes_array'][]='clearfix';

        // Now I want to add a 'col-md-4' class to all the blocks in the 'bottom-content' region
        if($variables['block']->region == 'bottom-content') {
                $variables['classes_array'][]='col-md-4';
        }
}

Any ideas why this isn't working?


texts: Drupal fails to run update.php when new services have been introduced and depend in inactive module

texts:
In production environment I have an active module that in a new deployment has changes to the mymodule.services.yml file. This new services file points to services located in an inactive module.

I try to enable them creating a update hook in mymodule.install file and running update.php file without success. update.php triggers an error due to unresolvable dependencies in the active module.

Is there any way to ignore these errors and to continue with the update or is there another way to enable modules in this exact use case?

Thanks


texts:
I wonder if it is possible to add a term reference field with just a subset of the available taxonomy terms. Let me explain. I have a taxonomy vocabulary with a structure like this:

- term 1
  - term 1.1
  - term 1.2
  - term 1.3
- term 2
  - term 2.1
  - term 2.2

Then I will create a specific content type and for that content type I will add a term reference field. Instead of referencing the whole vocabulary, I need to add only the options for, say, branch 2. I need to show options term 2.1 and term 2.2. In Drupal 6, the Node Reference field allows me to pull the options from a View. But this is a term reference field (it pulls the options from a given vocabulary) in Drupal 7.

I just want to avoid creating several different vocabularies, one for each content type, since their subject is more or less the same. In the future, I could take advantage of the fact that I have shared this resource instead of having a series of scattered vocabulary sets.


texts: Fusion Accelerator Skins windows are blank after core upgrade to Drupal 7.1.9

texts: I just upgraded my Drupal core to 7.1.9, and now my Fusion Accelerator settings are not being applied. When I try to edit a skin (for a block), the pop-up window is empty except for the "save" button. Also, the front-end "Edit Skin" link (under the gear icon) is missing. Does anyone know what might cause this kind of issue, and how I can get my settings back so I can reapply those skin settings?


texts: Will disabling the Form Builder UI do anything to my webforms?

texts: I want to disable the form builder UI so that I can select "multiple option" for a select list in the default webforms editor. This feature is missing in form builder. Can I do this or will it clear out all the work I've done building the forms within the form builder UI?


texts: How to display 12 grid for development purpose in bootstrap?

texts:
I am using bootstrap theme and create child theme. i want to display 12 grid for development purpose.

Can any body tell me how to enable this?

Thanks


texts:
I've created a new custom module and I used Facebook SDK to retrieve the latest post from a page.
Here is my .module file:

function social_theme($existing, $type, $theme, $path){
  return array(
    'block__feed_feed' => array(
    'render element' => 'elements',
    'template' => 'block--instagram-feed',
    'base hook' => 'block'
  )
}
function social_preprocess_block(&$variables){
 if ($variables['elements']['#configuration']['id'] === 'facebook-feed'){
   $fb = new \Facebook\Facebook([
     'app_id' => {$app_id},
     'app_secret' => {$app_secret},
     'default_graph_version' => 'v2.10',
     'default_access_token' => {$app_id}.'|'.{$app_secret},
   ]);

   $request = $fb->request('GET', '/'.{$page_id}.'/posts?fields=created_time,reactions,message,comments{comment_count,like_count},likes&limit=4');
   try {
     $response = $fb->getClient()->sendRequest($request);
   } catch(Facebook\Exceptions\FacebookResponseException $e) {
     echo 'Graph returned an error: ' . $e->getMessage();
     exit;
   } catch(Facebook\Exceptions\FacebookSDKException $e) {
     echo 'Facebook SDK returned an error: ' . $e->getMessage();
     exit;
   }
   $posts = $response->getDecodedBody();
   $facebookposts = [];
   for($c=0 ;$c<$posts_no ;$c++){
     if(isset($posts['data'][$c]['reactions'])){
       $likes_count = count($posts['data'][$c]['reactions']['data']);
     }
     else{
       $likes_count = 0;
     }
     if(isset($posts['data'][$c]['comments'])){
       $comments_count = count($posts['data'][$c]['comments']['data']);
     }
     else{
       $comments_count = 0;
     }
     array_push($facebookposts,['post_text'=>$posts['data'][$c]['message'],'likes_count'=>$likes_count,'comments_count'=>$comments_count]);
   }
   $variables['elements']['#cache']['max-age'] = 0;
   $variables['fbposts'] = $facebookposts;
   $variables['likes_comments'] = $likes_comments;
 }
}

and my block plugin code:

public function build() {
  \Drupal::service('page_cache_kill_switch')->trigger();
  return array(
    '#markup' => ' ',
    '#cache' => ['max-age' => 0,],
  );
}

and this is my block template file:

{% for post in fbposts %}

{{post.post_text}}

     {{post.comments_count}}
     {{post.likes_count}}

 {% endfor %}

Now my problem is that the code is working perfectly, but when a new post is added it will not change on the website unless I clear the cache!!!
I tried to give the block '#cache' => ['max-age' => 0,] but it didn't work, I tried \Drupal::service('page_cache_kill_switch')->trigger(); on the hook_preprocess_block but id didn't work too.

What shall I do?


texts:
I am trying to create an examination system with Drupal, and I am not sure how to implement it. I can see many ways to do it, but I am not sure which one is the best way to achieve it.

These are the features am looking at:

Users should have the ability to add questions under different subjects.
Users will take test by answering optional answers (radio buttons).
Users can move back and forward between answers and mark for later reviewing.
In the end the result will be shown.
Users can also choose the number of questions they want, and the difficulty level.

What is the best way to achieve this? This is what I am doing.

I added a content type question.
I added options field for answer option and right-optionfield for the right answer.
I added a drop down field for difficulty level.
I created a taxonomy term list for subject and connected with content type.

From here, what is the best thing to do?
Is creating a view page and giving the limit as per page one a good idea? If so how will I give the options of answer as radio/options, or should I create a custom page from module and take the answers using JSON?
What will be the right and easiest way to achieve this?


texts: How to get product URL or URL alias using product ID?

texts:
I'm using Drupal Commerce and stuck in this problem. I'm creating a custom module that will display a product title and some info.

I want that product to be linked to its node page, and product Object is all I have to my resources. I'm thinking of getting the product URL or alias using product_id but I don't know how. I already searched it but there's nothing clear on the search results I got.

Any suggestions?


texts: Pass additional variable into existing twig template (Book module)

texts:
I use the Drupal 8 Book module for books where each chapter has a different author.

The Book Navigation block uses book-tree.html.twig (core/modules/book/templates) to generate a book tree showing chapter titles. I want to show author names also.

I can subclass and edit book-tree.html.twig, but I don't know how to get the author name passed in so I can use it. How do I go about this? Only the title, the url, and some flags are passed in now.

As an alternative, I can get the id for each chapter node from its url as a string. Can I use this id to load the chapter node from within the twig template? If so, I can get the author name from the node directly.


texts:
Is there any way that Development website can be passed to Production without overriding the nodes on Production. I tried the default backup and migrate modules but it overrides the existing nodes.

What tables I need to exclude ?
Would modifications on content types (changing and text to int) affect what is stored in the nodes table if that is outdated?


texts: How to restrict submit handler when ajax button is clicked in altered form

texts:
I am altering ubercart "uc_product_add_to_cart_form" and adding an ajax button "calculate price":

  $form['price_calculation']['calculate'] = array(
      '#type' => 'button',
      '#value' => t('Prepočítať'),
      '#ajax' => array(
          'callback' => 'activit_calculate_price_ajax',
          'wrapper' => 'price-calculation-value',
          'effect' => 'fade',
          'method' => 'replace'
      ),
  );

This button is just replacing some text info about price based on filled attributes.

Problem is that it also calls submit handler and it adds product to cart.

In case of my own custom submit handler I could verify what button is triggering submit handler, something like if ($form_state['triggering_element']['#value'] == 'calculate') {}. But this is not a custom submit handler. It is default submit handler of altered ubercart form.

Is there any other way to prevent submit handler when ajax button is clicked?

UDATE - I explored ubercart submit handler and commented all the code and added dsm($form_state);

function uc_product_add_to_cart_form_submit($form, &$form_state) {

  dsm($form_state);
  /*
  $form_state['redirect'] =

      uc_cart_add_item(
          $form_state['values']['nid'],
          $form_state['values']['qty'],
          module_invoke_all(
              'uc_add_to_cart_data',
              $form_state['values']
          ),
          NULL,
          variable_get('uc_cart_add_item_msg', TRUE)
      );
  */
}

Weird thing is that $form state shows that triggering element is 'add-to-cart' even if I click only 'calculate price' button.


texts: how do I theme rounded corners in Panels 7.x-3.3

texts:
I looked through older questions & answers and some examples about styling rounded corners and they seemed valid but when I look into the code in Panels 7.x-3.3 I see an entire function that dynamically generates rounded-corners and tells Drupal where to find the image files.

I have new image files for the rounded-corners. How do I over-ride this function without hacking the module itself?

Ex. (This function is in rounded_corners.inc)

/**
 * Generates the dynamic CSS.
 */
function _panels_rounded_corners_css($idstr) {
  $url = panels_get_path('plugins/styles/corners', TRUE);

  $css = <<<EOF

.t-edge, .b-edge, .l-edge, .r-edge, .wrap-corner {
  position: relative;
  /* hasLayout -1 ? For IE only */
  zoom: 1;
}
$idstr .t-edge {
  background: url($url/shadow-t.png) repeat-x 0 top;
  font-size: 1px;
}
$idstr .b-edge {
  background: url($url/shadow-b.png) repeat-x 0 bottom;
  font-size: 1px;
}
$idstr .l-edge {
  background: url($url/shadow-l.png) repeat-y 0 0;
}
$idstr .r-edge {
  background: url($url/shadow-r.png) repeat-y right 0;
}
$idstr .wrap-corner {
  background: #fff !important;
}
$idstr .wrap-corner .t-edge, $idstr .wrap-corner .b-edge {
  height: 11px;
}
$idstr .wrap-corner .l, $idstr .wrap-corner .r {
  position: absolute;
  top: 0;
  height: 11px;
  width: 11px;
  background-image: url($url/corner-bits.png);
}
$idstr .wrap-corner .l {
  left: 0;
}
$idstr .wrap-corner .r {
  right: 0;
  background-position: -11px 0;
}
$idstr .wrap-corner .b-edge .l {
  background-position: 0 -11px;
}
$idstr .wrap-corner .b-edge .r {
  background-position: -11px -11px;
}
$idstr .wrap-corner .r-edge {
  padding: 5px 24px;
}
$idstr div.admin-links {
  margin-top: -14px;
  margin-left: -12px;
}

$idstr .panel-separator {
  background: url($url/shadow-b.png) repeat-x 0 center;
  font-size: 1px;
  height: 30px;
}

$idstr .rounded-corner {
  margin-bottom: 1em;
}

EOF;

  return $css;
}


texts:
I need to run a jQuery file in a twig file in order to bind aqua lift segments.  but jQuery is not loaded yet .  How can I load jQuery at this point without loading it twice?
thanks


texts:
I specifically hope views can solve my issue.

My views will display the list of students in a specific class and in front of each student's name, I will like to have a button to select whether a student is present or not.

Since this page will be accessed daily(monday-friday), it needs to reset to default everyday but the record must be saved in d database so that we can send the total number of days a student is present in school.

I have tried flag but the issue with the approach is that u can either flag or unflag a user which doesn't allow for daily flaggings.

Could you give me any hint as to what next to try? Do I need to write a module for this?


texts:
I have a content type that includes an image field. After the image is uploaded, I add a watermark to this field using the Imagecache Actions module.

I would like to allow users to download the image without watermark. Is it possible?


texts:
If you visit http://balancesocialmedia.com/, under the carousel, there are 4 boxes of content; they are block views with col-md-3 as CSS class.

The new region I created is called content_bottom.

regions[content_bottom] = 'Content Bottom'

I then put this code in the page--front.tpl.php under content region (near the bottom of this snippet).

  <section<?php print $content_column_class; ?>>
  <?php if (!empty($page['highlighted'])): ?>

<?php print render($page['highlighted']); ?>

  <?php endif; ?>
  <?php if (!empty($breadcrumb)): print $breadcrumb; endif;?>

  <?php print render($title_prefix); ?>
  <?php print render($title_suffix); ?>
  <?php print $messages; ?>
  <?php if (!empty($tabs)): ?>
    <?php print render($tabs); ?>
  <?php endif; ?>
  <?php if (!empty($page['help'])): ?>
    <?php print render($page['help']); ?>
  <?php endif; ?>
  <?php if (!empty($action_links)): ?>

<?php print render($action_links); ?>

  <?php endif; ?>
  <?php print render($page['content']); ?>

   <?php if ($page['content_bottom']): ?>

    <?php print render($page['content_bottom']); ?>

<?php endif; ?>

I tried moving the code under the closing section tag, removing the container and row class but the first block view is always renders a bit funny.

Also, I can move the blocks to the content region and shows up as expected. I can't track down what's different between the two regions.

Does anyone see where I'm messing up?


texts: A field that is a multiple of a float field. How?

texts:
Let's say i have a product content type. It has a title, body and price field.

In a view (or in the node page) in addition to these fields I would like to have a multiple of the price field ?

Example :

Title : Red tshirt
Body : Tshirt description
Price : $9,95
Extra field : $99,5 ( Price x 10 )


texts: How do I go to Checkout Page without product in cart?

texts:
I am using Commerce Donate and configured it to show donation form on checkout page. That is what actually I need. Donation form, contact info and payment form on same page.

But we cannot go to the checkout page without having some product in cart.

How can I do that?


texts:
I have a custom module with form and I want to pass the values from form_state into email.
This is my code.

//The form page callback
function mymodule_page($form, &$form_state) {
    $form['name'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter name here'),
    );
    $form['surname'] = array(
        '#type' => 'textfield',
        '#title' => t('Enter surname here'),
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
        '#submit' => array('mymodule_submit'),
    );

    return $form;
}

function mymodule_submit($form, &$form_state) {
    $name = $form_state['values']['name'];
    drupal_mail('mymodule', 'mymodule_mail', 'myemail', language_default(), array($name));
    dpm($form_state);
}

/**
 * Implements hook_mail().
 */
function custom_test_mail($key, &$message, $params) {
    switch($key) {
        case 'mymodule_mail':

        $message['subject'] = t('Hello');
        $message['body'][] = t('This is a body text');

        break;
    }
}

I'm receiving the email with the subject and body, but without the value from $form['name'].

How can I pass the values from form fields?


texts: Views with relationship of taxonomy terms

texts:
A node (Content 1) has two Tax-Terms (Category-Term 1, Category-Term2). The current relationship contains following entry: term from field_category and it's grouped via field_category.

How is it possible via a view to get this result?

Category-Term 1

Content 1

Category-Term 2

Content 1

But the current result is:

Category-Term 1, Category-Term2

Content 1, Content 1

Thanks for help. Best C


texts: What is the difference between normal filter and contextual filter in views?

texts: I am using Drupal 7.34. I have used Views module many time but I don't know difference between normal filter and contextual filter. So can you tell me What is the difference between normal filter and contextual filter in Views?


texts: Using Twig how can I get the summary of the body field to use in a template?

texts:
So I have a textarea with summary and I want to display the summary before the content.
So if I just use {{ content.body }} the text is displayed without the summary.

How can I get the summary ?

{{ content.body.summary }} doesn't seem to do the trick


texts: How do I get at the raw file name of a File entity in a Twig field override?

texts:
This is my first effort at Twig development so please bear with me. I have a vanilla Drupal 8.1 site with a content type that contains just the body and a File type field called field_fichier_svg. This will contain SVG files (surprise!) and I want to override the Twig field rendering so that I can get the raw file name and wrap an "img" HTML tag around it.

I have successfully installed kint, and have overridden the field template with one called field--node--field-fichier-svg--icon.html.twig (the field is used in a content type called "icon") and this works.

I have also succeeded in running kint() and getting the output.

But none of the attempts I have made at getting the value of the field function. In the snippets below you can see the three different attempts I have made.

1) Try to identify the class that handles file entities and use that:

{%
  set classes = [
    'file'
  ]
%}

2 & 3) Loop round "items" and try different things which I have tried to interpret from the kint output (kint does work by the way)

{% for item in items %}

  {{kint(item.content)}}
{% endfor %}

In all cases the "src" attribute is just blank.

To make it a bit more manageable I tried putting

{{dump(item.content|keys)}}

and I get this:

array(5) { [0]=> string(6) "#theme" [1]=> string(5) "#file" [2]=> string(12) "#description" [3]=> string(6) "#cache" [4]=> string(11) "#attributes" }

Then I tried

{{dump(item.content['#file']|keys)}}

and I get this:

array(11) { [0]=> string(3) "fid" [1]=> string(4) "uuid" [2]=> string(8) "langcode" [3]=> string(3) "uid" [4]=> string(8) "filename" [5]=> string(3) "uri" [6]=> string(8) "filemime" [7]=> string(8) "filesize" [8]=> string(6) "status" [9]=> string(7) "created" [10]=> string(7) "changed" }

but if I try

 {{item.content['#file']['filename']}}

I just get nothing


texts: Is it possible to allow duplicate usernames ?

texts:
I'm working on a Community Website and 99% of the time a new user has an unique username. But for my requirement, it is required to allow duplicate usernames.

Is there a way to change drupal default behavior from unique username+email+pass to unique email+pass?


texts: Multiple Value Fields using the Google Chart Tools module

texts:
I have a content type with 3 fields: date, planned, actual. Each field can have unlimited values. I am using the Google Chart Tools module and grouping on date.

What I want is the x-axis to have each date in the field. The y-axis would have the planned and actual data points relative to the date. Example, first date has first planned and actual values and so on.

The problem I am having is that the chart is adding all the values of the field resulting in two horizontal lines between the dates.

All of the fields have 'Display all values in the same row' unchecked.

This seems straight forward, what are the correct settings to accomplish this?  Or is there a better approach?


texts:
I have installed and enabled the simplenews module and I have a newsletter subscribtion block in my website frontpage now.
I would ajaxify the subscribe's button in that block so I googled many websites about that, but I couldn't find any answer about 'How to ajaxify simplenews subscribtion form in drupal 7, any suggestion?


texts: How do I add an ID to the ul tag of a menu?

texts:
I am able to add unique ids to menu links by either adding code to my theme's template file or by using a menu module; however, I would like to add a unique id to the ul tag that encapsulates the menu li links.  The reason that I would like to implement this is to style the menu as a whole instead of the menu's individual links.   My ultimate goal is to take the whole menu and float it to the right in the header-top region of drupal.  I am rather new to Drupal so, perhaps there is another way to achieve this?

I originally attempted custom css styles using the skinr module without success.  The skinr module was able to move the menu's title to the right, but the menu's links were still located at the left of header-top.

My setup consists of Drupal 7

UPDATE
I was able to add a custom CSS class "user-menu" to the user-menu block.  Next I added a custom css to mix-and-match-style.css

css code:

.user-menu ul li {
     padding: 0;
     float: right;
}

The css code seems to float: right the menu, but the links are not ordered properly once floated to the right.  The correct order of the links should be "My account | Log out".  When the list is floated to the right the order changed to: "Log out My account |"

Is that a bug or am I not understanding something?


texts: How do I send a variable value from my form to another page using the POST method?

texts:
In the first page I have the following code:

$form['message1'] = array(
  '#markup' => $this->t('Check Your Details once again !!'),
);

$form['candidate_name'] = array(
  '#type' => 'textfield',
  '#title' => t('Candidate Name:'),
  '#required' => TRUE,
);

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

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

return $form;

function submitForm(array &$form, FormStateInterface $form_state){
  drupal_set_message($this->t('@candidate_name! Wow! Nice choice! Thanks for telling us!', array('@candidate_name' => $form_state->getValue('candidate_name'))));
  $form_state->setRedirect('second_page');
}

In the second page I have the following code:

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

  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Candidate Name:'),
    '#required' => TRUE,
  );

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

  return $form;
}

How can I get the first page candidate name into the second page candidate textfield?


texts: D7 errors given when authenticated user changes password but pwd still changes

texts:
I have a user role for content managers and I don't want to give them the permission to administer users. I do want them to have the ability to change their passwords so they aren't stuck with the temporary one I set them up with.

I have been able to add a link to their own 'edit profile' page on the default user landing page, and the link works and displays the change password form as expected. If they try to change their password, they are then given an access denied error because they are not authorized to view /admin/people, which is where they are sent after a password change.

HOWEVER: THE PASSWORD DOES GET CHANGED

So, it's confusing to the user because they think their password change has failed when it hasn't.

Is it possible to change what page they are directed to after a password change? I would prefer to send them back to their profile or even the homepage. (I would REALLY like to send them right to the content page so they can get to work.)

I would even settle for being able to edit the access denied error to better explain the situation to them.


texts:
I cannot pass variable to js file, from my common.module

  $max_length = 10; //variable_get('title_max_length');
      drupal_add_js(drupal_get_path('theme', 'myTHEME'). '/js/script.js');
      drupal_add_js(array('common' => array('max' => $max_length)), array('type' => 'setting'));

Javascript works fine, but i need to get **$max_length** variable from module. At the moment its not working.
here is js file:

(function($, Drupal) {
/*Character limit for news node*/

    Drupal.behaviors.common = {
        attach: function(context, settings) {
            var length = $('#edit-title').val().length;
           /* ####################################### */
           /* Does not work */
            var char_limit = Drupal.settings.common.max;
           /* ####################################### */
            if (length >= char_limit) {
                $('div.form-item-title label span.form-required').text("characters left limit exceeded for displaying on home page");
            } else {
                $('div.form-item-title label span.form-required').text(char_limit-length-1 + " characters left");
            }

            $('#edit-title:not(.edit-title-processed)', context).keyup(function () {

                $(this).addClass('edit-title-processed');
                var new_length = $('#edit-title').val().length;

                if (new_length >= char_limit) {
                    var chars = char_limit-new_length;
                    $('#edit-title').css('color','red');
                    //$('div.form-item-title label span.form-required').text("characters left limit exceeded for displaying on home page");
                    $('div.form-item-title label span.form-required').text("" + chars-1 + " characters");

                } else {
                    var chars = char_limit-new_length;
                    $('div.form-item-title label span.form-required').text(chars-1 + " characters left");
                    $('#edit-title').css('color', 'black');

                }
            });
        }
    };
})(jQuery, Drupal);


texts: How filter node inside view block by even nid (or odd nid)

texts:
I have a view 2 blocks where I show some images and I'm trying to show the images with an even nid in the 1st block and the images with odd nid in the 2nd block

Do you guys have any idea if it's possible? and how?


texts: Trying to import existing Drupal site to a Linux Mint VM - getting redirected to install.php

texts:
I have Apache/MySQL/PHP installed and working, I've imported the database and called it stove and have updated the settings.php file in sites/default/ to use my database's name, username, and password. The hosts and vhosts are all set up correctly as well, pointing to 127.0.0.1 and the proper directories.

Any ideas on why it keeps trying to re-direct me to the install.php

Here is the snippet of code from settings.php for the database:

/* Database configuration format:
 * @code
 *   $databases['default']['default'] = array(
 *     'driver' => 'mysql',
 *     'database' => 'databasename',
 *     'username' => 'username',
 *     'password' => 'password',
 *     'host' => 'localhost',
 *     'prefix' => '',
 *   );
 *   $databases['default']['default'] = array(
 *     'driver' => 'pgsql',
 *     'database' => 'databasename',
 *     'username' => 'username',
 *     'password' => 'password',
 *     'host' => 'localhost',
 *     'prefix' => '',
 *   );
 *   $databases['default']['default'] = array(
 *     'driver' => 'sqlite',
 *     'database' => '/path/to/databasefilename',
 *   );
 * @endcode
 */
$databases['default']['default'] = array(
    'driver' => 'mysql',
    'database' => 'stove',
    'username' => 'root',
    'password' => '',
    'host' => 'localhost',
    'prefix' => '',
);


texts: How to set page-specific CSS classes on the page callback build array?

texts:
I have a page callback like this:

function example_page() {
  $build = array();

  $build['#attributes'] = array('class' => array('example-class'));

  $build[] = array(
    '#markup' => '
My text here
',
  );

  return $build;
 }

As you can see, I have attempted to add classes to the div that wraps the output of the render array in the same fashion as the form API works. I have also tried setting $build['classes'] or $build['classes_array'], but all of these tree syntaxes are ignored, and the content is simply wrapped in
, which is not very helpful.


texts: Drupal core tries to update to current version

texts:
Many sites on my server are running Drupal 7.23, I usually use Drush to update them without any issue. Eveything works fine with modules and themes but Core keeps installing 7.23 on itself.

The admin/reports/updates page display this :

Drupal Core 7.23
  Recommended version: 7.23
  Security update: 7.24
  Last version: 7.25

It obviously tries to update to the recommended version, which is in this case the current one (7.23).

I use the permissions guidelines given in the script on the bottom of this page. I tried to change the file owner, it is not working. We recently installed Nginx as a reverse proxy on our server but the problem still the same calling directly Apache.

I also have some sites running Drupal 7.24 and no issue when updating to 7.25.

Any clue on the origin of this issue ?


texts: Is it possible to migrate taxonomy terms when having only the term name?

texts:
I'm starting to learn the migration module because i have to do quite a complicate migration from a Drupal 6 site to a Drupal 7 Importing nodes with different field names from Drupal 6 to 7

And i'm wondering if it's possible to migrate taxonomy terms if you have only their name but not the tid (or better, the tid is different between the sites), and if it's possible how? (that is, other than making a query to load the tid from the db, i'd like to know if there's a more "automated" way)


texts: Remove import instance from list using Migrate Tools module

texts:
I'm trying to remove an rss reference of a migration. Once I put the yaml code into the Migrate module in the drupal admin interface, it creates a reference to that yaml code, but there is no one in the UI that I can see the reference. The Migrate Tools module gives me access to drush commands, but none of which could remove a reference.

Does anyone know how to delete a reference to an import?  I can see references through the command line using $ drush ms

I searched but could only find using this, but it doesn't work.

$ drush php

>>> Drupal::configFactory()->getEditable('migrate_plus.migration.my_rss_importer')->delete();

Here is the list of imports from the CLI I am trying to remove.  Just for reference "migrate_plus" mentioned in the code above is another module that compliments the migrate module.

Group: Default (default)      Status  Total  Imported  Unprocessed  Last imported
 berkeley_news_rss_importer_1  Idle    20     20        0            2017-12-09 23:08:36
 berkeley_news_rss_importer_2  Idle    20     20        0            2017-12-09 23:12:34
 berkeley_news_rss_importer_3  Idle    20     20        0            2017-12-09 23:14:03
 berkeley_news_rss_importer_4  Idle    20     20        0            2017-12-09 23:20:04
 berkeley_news_rss_importer_5  Idle    20     20        0            2017-12-09 23:33:17
 berkeley_news_rss_importer_6  Idle    20     20        0            2017-12-09 23:42:26
 berkeley_news_rss_importer_7  Idle    20     0         0            2017-12-10 00:11:17
 berkeley_news_rss_importer_8  Idle    20     20        0            2017-12-11 09:46:45
 berkeley_news_rss_importer_9  Idle    20     0         20


texts:
Is there any module available, with a functionality to show list of users who have visited certain nodes?

I've searched for module like this but haven't found anything like this.


texts:
I have put the following code from adsense in a block with full html filter :

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- newad -->
<ins class="adsbygoogle"
     style="display:inline-block;width:728px;height:90px"
     data-ad-client="ca-pub-4076687304826472"
     data-ad-slot="1906412748"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

But I dont see the proper ads , The message comes with style :"display etc.. and some ads in very unformatted fashion . Is there some other way to put adsense code in drupal 7 ?

thanks for any help in this


texts: Is it possible to style a Views 'group by' field that's excluded from display?

texts:
I'm working on a glossary view. I have created letter headers by rewriting a copy of the term title, limiting it to 1 character, excluding it from display, and using that as the "Group By" field. The field is then shown by Views, but it doesn't contain the <h2> tag that I wrapped around the field in the rewrite rules. The normal term titles are output (by default) with <h3> tags. I would like the letter headers to be larger, but since Views seems to be overriding everything, I can't see how to do accomplish this.  It doesn't even output the class name I attached to the field.

Any ideas?  Your help is appreciated!


texts: The Search API module shows a two-words taxonomy term as two separated words, in its widget

texts:
I am using taxonomy terms to classify my content, and the Search API and Facets modules for searching.

I have some nodes that are tagged with "Asian Cuisine" term; after indexing the content, "Asian Cuisine" is handled as two separated words.

Is there a way to avoid it happens?


texts: Custom plugin modified results in WSOD PluginNotFoundException

texts: I've created a module with a custom Plugin ("group_user"). It all worked great until I modified the code and accidentally introduced an error. This resulted in a WSOD Drupal\Component\Plugin\Exception\PluginNotFoundException</em>: The "group_user" plugin does not exist. I cannot even uninstall the custom module since either drush or the WSOD show the same error. Even undoing the code changes in the code do not work. I've found this bug description which is discussed in the following issue. There does not seem to be a working solution yet. Is there any way I could manually "remove" the plugin or find the "location" it is still loaded?


texts: How to insert user registration data to non-drupal table

texts: I installed drupal 7.34 with oracle database. Now i need to save user registration data to another non-drupal table. User authentication also need to do with these non-drupal database field. Is there any method to generate the per-existing set of users in non-drupal database as drupal users.


texts:
Is there a way to get all the managed files used by a particular entity, i.e. a node or other module item?

Looking in the file_usage table there is an id column and this is what I want to retrieve fid's by.

Seems like something that there would be a function for, but I haven't found it yet...


texts: Ideas on collecting payment before form submission?

texts:
I have a use case in which I wish to collect payments before users are allowed to fill a form; basically the form is an assessment form for which the provider (offering analysis) would like to charge money.
Currently I have the form setup using webforms, but I couldn't find a decent or well established way of collecting payment with webform submission. I already have Ubercart on the site so, if there is a Ubercart to webform bridge, I would definitely like to know about it as well (I couldn't find any). Lastly I am also open for any other approaches.

My use case is the following.
Users pay for the assessment (service) using Paypal, and then they are given a link to submit a form; the submitted data need to go to the provider.
Do you have any ideas on how this could be implemented? I assume it should be a relatively common use case.


texts: How to use entityQuery to find nodes with a specific multi-value field containing one specific value (and no others)?

texts:
I have a node type "group" with an entity reference field "field_things" that can reference zero or more "thing" nodes. I'd like to use entityQuery to find all "groups" that have exactly one value for field_things, and that value is a specific "thing".

I can't tell from the docs how to combine those two requirements.


texts: Basic Authentication for migrate plus - unable to authenticate

texts:
The XML feed I was using recently updated to basic authentication. I updated my YML configuration with the basic authentication plugin as follows, but nothing seems to work, also there are no errors.

YML config

source:
  plugin: mymigration_url_xml
  data_fetcher_plugin: http
  data_parser_plugin: xml
  urls:
    - https://xml-feed-url-for-the-migration
  item_selector: '/title'
  authentication:
    plugin: basic
    username: xyz
    password: pass

All help is appreciated.


texts:
I am developing a site which has around 46 departments and each dept has three Access types. Say Dept Admin, Dept Lead, and Dept Agent.

Site will use taxonomy terms Confidential, Restricted, Private and Public. Rules goes like this..

Dept Admin has access upto Confidential level records, Dept Lead->upto Restricted, Agents upto Private records.
dept records should be accessible by only that dept users and goes its content moderation
I am planning to use taxonomy access control along with Workbench Moderation. But this requires me to set up 46 * 3 (138) roles for my site. I am a bit concerned that it might reach some php memory limit, not sure.

Any advice is appreciated.


texts: How to render author custom fields info on comment and node twig template?

texts:
I am trying to render the author Full Name and other authors customs fields information in comment.html.twig and node.html.twig. But not any of the fields that I made for users such as "First Name", "Last Name", and Auther UID etc. render in comments.

I tried with the following code for comment author

{{ comments.author.field-first_name.entity.value }}
{{ comment.author.user_picture.0.entity.uri.value }}
{{ comments.author.uid.entity.value }}

And, I tryed following code for node author:

{{ node.author.field-first_name.entity.value }}
{{ node.author.user_picture.0.entity.uri.value }}
{{ node.author.uid.entity.value }}

Any ideas, how do I render this info in comment template?


texts:
This is a scenario. I wanted to find the content of the page from a link.

For eg while navigating the website, i clicked a link and the page loads. The page link is like www.example.com/gallery/videos

While checking I found there is a view named Gallery Videos and contains a 4 blocks attached. In the configuration of one block's path setting has been given "gallery/videos". But I did not find the page created for it. How can I easily detect where the content is loading and which view is it?

This seems to be a very basic question , but it seems hard to find when there are lot of contents, views and blocks used in the site.


texts: How to have tpl for parent but not child?

texts:
I want to override the template for just /user/ but not for /user/edit or user/anythingelse. Is there a way to do that?

For example, I made a page--user.tpl.php but it effects all of user's children.


texts: When creating a view based on order products in ubercart, only people with access to all orders can see it

texts:
I've created a view based on order products in ubercart, but only those with admin role, who have permissions to see all orders can see the view.

Now this is problematic, as the view is a most popular products grid, which is meant for anonymous users who visit the webshop.

My question is: can I somehow restrict access to anonymous and authenticated users to see all the orders but at the same time allow them to see that one view, based on order products?

Hope my question was clear, and thanks in advance,

Huba


texts:
I've got a Main Menu and am using Superfish, not sure if this makes any difference.

But in the breadcrumbs the top level of the main menu is being skipped. Eg.

Instead of

Home - A - B

My breadcrumb looks like:

Home - B

B, being the page I am currently on.

What am I doing wrong?


texts: I've logged slow mysql queries on D6 and came up with a large list. So I'm wondering where the queries are located and what is the best strategy to fix them? I also appreciate if you could point me to useful resources about query optimization in Drupal.


texts: Best Approach for View Caching using a Proximity Filter

texts:
I have a view that is time-based cached.

One of the options on the exposed form is a 'near me now', which sorts the results by distance and displays mileage.

The users location is provided by the IPM&V Module, and works fine with the view cache turned off.

The problem is that with cache-view turned on, sorting by near me now continues to display the results based on previous requests.  The view is 'cached' and not using the current users location.

I could simply turn views caching off, but hate losing the extra speed.

Is there a way (a hook or function) that tells views to 'refresh/clear cache' if certain conditions are met? Ie, if user selects 'near me now' do not cache.

I looked at a combination of rules/cache action, but couldn't get it to work on a specific filter input.

Any ideas appreciated.


texts: CKEditor with CKFinder - removing the 'Browse Server' button, but only for certain profiles

texts:
I have a number of CKEditor profiles, some of which use CKFinder to upload images. However, for one profile I want to remove the option to browse the server within the CKFinder dialogue, whilst retaining it for another profile.

Is this possible?

There's a similar question answered here, but it only deals with removing the button globally (as far as I can see):

https://stackoverflow.com/questions/3610041/ckeditor-with-ckfinder-disable-filebrowser-keep-upload-functionality


texts: Create commerce product through web services

texts:
I want to create products using commerce services resource module. At this moment, I can create a product calling the resource .../product with POST, but It seems that It only creates a product variations, because If I navigate to "manage products" option, I can't see the new product but if I call a GET over resource .../product I can see the new one.
Then, I'd tried to create a product using .../node resource, but I always get an error:

"field_product][und][form][commerce_price][und][0][amount": "Price field is required"

I don't know what is the right JSON structure to create a node with its product variations.
Could some one put here an example of the right JSON structure for creating node products?
Thanks.


texts: Customize Filters in a view based on URL in Drupal 7

texts:
I have a view with contextual filter with a URL of /taxonomy/term/%.

So when I visit a URL on my site as www.mysite.com/taxonomy/term, it shows all the nodes which have the selected term.

Now the situation is that I have around 5 filters with this view, what I want is that if I go to a specific term page, I want hide filter based on a term name.

As an example, if I visit URL www.mysite.com/taxonomy/term_1, I want to hide one filter (let's say filter_2) out of five filters.

Is there any way I can do that?

I'll be grateful for your help.

Best.


texts: Leave Month (Date) Field blank (Optional)

texts:
I was wondering if it's possible to have Drupal (7), leave the Month field NULL (empty).

When someone sets a Date, sometimes they don't need to enter a Month along with it. When I try this by Default, Drupal says a Month is needed.

Thanks


texts: Placing Drupal core/modules code outside public_html

texts:
I've been trying to improve my sites security as I build a Drupal 8 update for my page. One thing I've seen recently is keeping your core code outside the web accessible docroot folder. I've also heard about keeping a copy of the code setup on git so you can easily bring down a clean copy if somehow someone changes something.

What is the current best practice for such a thing? On my server I have an account for the page, within which is public_html where anything actually being sent out to the world is kept. Is it possible to have the Drupal code one level down and then have things run from public_html?


texts: Enable a node's menu item when on that node?

texts: I have a node for which there is a menu item. I want this menu item to be disabled except when the user is viewing that node. Can I do this, and if so how?


texts: Views rewrite results texfield to uppercase

texts:
I need to display text field to Uppercase, using Rewrite Results in Views.
For example from the text value "paper Title" to "PAPER TITLE".

How to transform the text to uppercase in Rewrite Results?


texts: Why does deleting a translation on my custom entity delete the entire record?

texts:
I have defined a custom content entity. (You may find the details below.) If I create an entry in the table and a translation for the entry and then delete the translation it removes the entire entry.

/**
 * @ContentEntityType(
 *   id = "my_custom_entity",
 *   label = @Translation("My Custom Entity"),
 *   handlers = {
 *     "storage" = "Drupal\Core\Entity\Sql\SqlContentEntityStorage",
 *     "access" = "Drupal\my_custom_entity\MyCustomEntityAccessControlHandler",
 *     "form" = {
 *       "default" = "Drupal\my_custom_entity\Form\MyCustomEntityForm",
 *       "delete" = "Drupal\my_custom_entity\Form\MyCustomEntityDeleteForm",
 *     },
 *     "list_builder" = "Drupal\my_custom_entity\Entity\Controller\MyCustomEntityListBuilder",
 *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
 *     "views_data" = "Drupal\my_custom_entity\MyCustomEntityViewsData",
 *     "translation" = "Drupal\content_translation\ContentTranslationHandler"
 *   },
 *   translatable = TRUE,
 *   base_table = "my_custom_entity",
 *   data_table = "my_custom_entity_field_data",
 *   fieldable = FALSE,
 *   entity_keys = {
 *     "id" = "id",
 *     "label" = "label",
 *     "langcode" = "langcode"
 *   },
 *   links = {
 *     "canonical" = "/my_custom_entity/{my_custom_entity}",
 *     "edit-form" = "/my_custom_entity/{my_custom_entity}/edit",
 *     "delete-form" = "/my_custom_entity/{my_custom_entity}/delete",
 *     "collection" = "/my_custom_entity/list"
 *   },
 *   list_cache_contexts = {"user"}
 * )
 */

Update: I've made a bit of progress on this. The issue seems to be that the entity provides a delete-form. On account of this core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck::access ends up returning AccessResult::forbidden() on line 85 (Drupal 8.3.7) when looking at the path /my_custom_entity/{my_custom_entity}/translations/delete/{language}. Instead it uses /my_custom_entity/{my_custom_entity}/delete. Now I've got to figure out what I'm supposed to do instead. The User entity does not declare a delete-form, but the Node entity does. My initial attempt at removing the delete-form key on my entity resulted in Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "entity.my_custom_entity.delete_form" does not exist." at /var/www/html/drupal8/core/lib/Drupal/Core/Routing/RouteProvider.php line 190. However, I didn't actually uninstall and reinstall the module. I just visited the Extend page and cleared cache.


texts: I have a Drupal 7 site with a bunch of users. I want to migrate the users to Drupal 8 but not any of the content so I'm writing a crosswalk. Drupal 8 has uuid in the users table. Is there a way I can compute this or can I just set it to NULL? Thanks!


texts:
To create a friend list I'm using views with a "user relationship". It's working fine. Now I want an extra field with the information of who is logged in.

I saw the "filter criteria" to show only the logged in user, but I only want this as a field and maybe in the "sort criteria".  How can I achieve this? I'm a little confused!


texts: How to remove Analysis button from Webform results tab

texts:
I am trying to located the template file or function that outputs the following buttonson the webform results tab

Secondary tabs

Submissions(active tab)
Analysis
Table
Download
Clear

Can anyone advise how I can tweak/remove/hide some of these


texts: How to display field collection fields in tabs on add another item button?

texts:
I have a content type which has a multivalued field collection field.
In this field I have a set of field collection items.
In field collection I have put the fields in horizontal tabs.

But the problem is when I click on add another item button it adds those set fields in a new row not in another horizontal tab.

Is there any module which should add fields in new horizontal tab? Or any custom code hint?


texts:
Is there a way to prevent a webform submission to be saved in the database?

I have added a custom submit handler to my webform but I don't want to save in the DB but send it to an external webservice.

function MY_MODULE_form_alter(&$form, $form_state, $form_id)  {

    if ($form_id == "MY_WEBFORM_ID")  {
        $form['#submit'][] = "_MY_MODULE_webform_handler";
    }

}

function _MY_MODULE_webform_handler($form, &$form_state) {
    // How do I stop data being saved in DB?
}

How do I do that? Thanks!


texts: How to get the URL component values in the Pager Link display when using Custom URL in Views?

texts:
I am trying to add a custom link in the Pager Section in a View that I am buidling in Drupal 8. The link should be dynamic and should be based on the current URL.
Views allow you to add a static URL like /ab/cd/endoftheurl to the Custom link. However the url of the site is xyz.com/EN/anot/ther/url and xyz.com/FR/anot/ther/url. I want to append the first compoment to the url as a placehold so that it becomes /ab/cd/endoftheurl
Is this achievable from configuration? I know using contextual links would allow you to access the URL parameter in the form of {{ arguments.field_organization_target_id }} However I want this done without contextual filter. Is this possible?


texts: Redirect to home page without using deprecated methods

texts:
I am attempting to add some code to a hook_entity_view_alter() function to redirect the user to the homepage under a rare condition with RedirectResponse.

I understand the method to accomplish this is along these lines (taken from here):

$response = new Symfony\Component\HttpFoundation\RedirectResponse($url);
$response->send(); // don't send the response yourself inside controller and form.
return;

My issue is that I am not sure how to format $url. Most articles on the topic, such as this one, suggest using \Drupal::url(), but this is deprecated in favour of Drupal\Core\Url. I would like to avoid using deprecated methods as much as possible, but am stuck at trying to figure out what the Drupal\Core\Url equivalent is to \Drupal::url('<front>'). I am not sure which methods to be using, and nothing I've tried with Url::fromUri() has worked.


texts: Does change of .info file need reinstallation of module to take effect?

texts: Does changing a module's .info file require reinstallation of the respective module to take effect?


texts: Am I able to populate an entity form text field with a value from a URL link on an external site

texts:
I am trying to pass a url variable from an external 3rd party site and have that variable populate an entity form text field that I have on an entity form on my company's website.

Basically we have a "Request for Information" form on our drupal site that people can come to and fill out. We have some 3rd party companies that have links to our form on their websites. We are trying to be able to track which website the person filling out the form came from so we want to add a url variable to the links on their websites so that when a user clicks on the link on their site that it takes the url variable from that link and places it in a hidden field on our drupal entity form.

Is this at all possible?


texts:
Can someone please explain what is the advantage of using Fields API to create fields for an entity rather than just declaring them in hook_schema as values?

It's a bit of work to get all the fields defined, instances, options, allowed and default values, etc. and then you have to deal with getters and setters and finally uninstalling everything is not as simple as db_delete, esp if you have reference fields in use by other entities.


texts:
7 - How do I programmatically create a button, place it in a block, 'weight it' and then make it visible to certain pages?

Code I've tried:

function openid_connect_block_info() {
  $blocks['openid_connect_login'] = array(
      'info' => t('Login Using PixelPin'),
      'cache' => DRUPAL_CACHE_PER_ROLE | DRUPAL_CACHE_PER_PAGE,
      'region' => 'content',
      'pages' => 'user/',
  );

  $blocks['openid_connect_register'] = array(
      'info' => t('Register Using PixelPin'),
      'cache' => DRUPAL_CACHE_PER_ROLE | DRUPAL_CACHE_PER_PAGE,
      'region' => 'content',
      'pages' => '/user/register',
  );
  return $blocks;
}

This code creates the button but doesn't put it under the content block and doesn't make it only visible on the specified pages.


texts:
On Drupal 7 I have a view with filters exposed to the user, which are dropdown lists. I want to use this View as a Block within a page. The only way to get this to work is the tick the "Use AJAX" checkbox in the Advanced section. However this means that the dropdown lists change to autocomplete fields, and I want to keep them as dropdowns. Is there any way to do that?

(Alternatively, is there any way to add the options that appear in the tabs at the bottom of a piece of content to a view page?)


texts: Is there a built-in way to get a language+country locale pair?

texts:
global $language only holds the language code. I wonder if there's any possibility to get a country code as well, at least of that country I set as default country at /admin/config/regional/settings.

Some external services need that locale (en_US, cs_CZ, de_AT) to be loaded in a matching language. Especially in multisites a language+country locale pair would be very handy for loading such services from within one module.

Possible workaround would be to set a new global variable holding a proper locale right?


texts:
I need to apply dynamic css for each node. I have stored the css into the database for each row of the page.

I have generating css like node_57002-en.css here, 57002 is a node-id with language code for each responsive layout.
For eg. If I select width for desktop layout for node-id-57002 then node_57002-en.css generated with below code.

@media only screen and (max-width:991px) {}@media only screen and (max-width:767px){}

I have to find out the better solution becouse, everytime generated  the new css for each node. Below is the code which I used,

$styles = $nodeProcessor->getStyles();
$rowCss = $styles->getDesktop() . "@media only screen and (max-width:991px) {" . $styles->getTablet() . "}" . "@media only screen and (max-width:767px) {" . $styles->getMobile() . "}";
$cssPath = $modulePath . '/resources/css/rows/node_' . $this->_nid . '-' . $this->_langCode . ".css";
$cssPath .= '?' . filemtime($cssPath);

I have some questions on this,

How to get that css from db and how to apply on front-page in
drupal manner.
How to cache the library css and how to clear the cache when css
updated?
If not then what is the alternative option.

I referred Dynamically generated CSS and JS document but it is only for dynamic js. I really appreciate if anybody helps me. Thanks in advance.


texts: how can i access a node variable inside of theme_preprocess_page function?

texts:
I'm trying to access a node variable, the id of a taxonomy term but i have to do it at the page level in theme_prepocess_page function. i did it in preprocess node like this

$libStatus = $vars['field_feature_library_status']['und'][0]['tid'];

in preprocess_page i tried this:

$libStatus = $vars['node']['field_feature_library_status']['und'][0]['tid'];

but i get this error...  Cannot use object of type stdClass as array in….

can someone explain how i can access this node variable in theme_preprocess_page function?


texts: Comment pagers in D7: They appear even when the page has only 1 comment!

texts:
I have this Drupal 7 site (updated from my D6 site).
I have nodetypes wich allows comments.
I have the pager for comments at the very end of the comment lists that shows (as you can imagine) the complete pager:
<< 1 2 3 4 ... >>

The thing is that the max comments allowed per page is 50, and even in nodes that have 1 or 2 comments the complete pager appears!

How can I prevent that from happening?

Thanks!!


texts: I lost permission to access admin/content for user 1

texts:
I uninstalled several contributed modules of my site and suddenly I lost the permission to access admin/content for user 1.

As far as I know this is not related to any contributed module.

When I try to access this page admin/content I get a message "You are not authorized to visit this page.".

How can I trace this? I run cron, clear caches and even run sites/all/modules/registry_rebuild/registry_rebuild.php to rebuild registry.

Is Drupal7 using the Commerce Kickstart distribution (I disabled all commerce modules)

Update1: I just rebuild permission at: admin/reports/status/rebuild but problem persit.

Also there are these error messages:

Notice: Trying to get property of non-object in user_access() (line 808 of /home/temporal-13/www/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 820 of /home/temporal-13/www/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 821 of /home/temporal-13/www/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 827 of /home/temporal-13/www/modules/user/user.module).
Notice: Trying to get property of non-object in user_access() (line 830 of /home/temporal-13/www/modules/user/user.module).


texts: Why isn't libraries-override with absolute paths removing assets?

texts:
I was trying unsuccessfully to override (and eliminate) table.css from the Boostrap Barrio theme. The pertinent lines from bootstrap_barrio.info.yml are:

libraries:
  - bootstrap_barrio/global-styling
libraries-extend:
  ckeditor_stylesheets:
    - css/components/table.css /* Assume this is for the editor, showing just in case */

and from bootstrap_barrio.libraries.yml:

global-styling:
  css:
    component:
      css/components/table.css: {}

The documentation states specifically

  [The path of the most recent override] should be the full path to the file.

In my own sub-theme's .info.yml file, right after the libraries: section, I had tried:

libraries-override:
  bootstrap_barrio/global-styling:
    css:
      component:
        /themes/contrib/bootstrap_barrio/css/components/table.css: false

Changing to a relative path fixed the problem, despite the apparent guidelines in the documentation to use the full path.

libraries-override:
  bootstrap_barrio/global-styling:
    css:
      component:
        css/components/table.css: false

So, why don't the absolute paths seem to be working as documented?


texts: How do I check whether a node is flagged when it is being deleted?

texts:
I'm using the Flags module for some functionality on my site. When a node is deleted, I need to check whether it's flagged or not and take additional action based on that. I've implemented hook_nodeapi() in my module to add my logic when a node is deleted. However, it seems I'm unable to check whether the node is flagged or not... I always get FALSE when I check, even when I know that node was in fact flagged. My code so far is:

// check if this node is flagged for renewal
$flag = flag_get_flag('machine_name_of_my_flag');

if($flag && $flag->is_flagged($node->nid)) {
   // add my custom logic here
}

This code is definitely run when the node is deleted. The $flag is found correctly, but $flag->is_flagged($node->nide) always returns false. I based this code on the documentation for the Flag API. I'm not sure why the is_flagged check is always returning false. Is it something to do with the delete action? When I debug this code in xDebug, I can see all the properties of the node object, but I can't find out if it's flagged or not.


texts: How to display only Duplicate values with a view

texts:
Background

My site is very large already and its only in its infancy. The content title table has 14000+ values in it. To make sure there are no duplicate values in the table I am creating a view that will display all of the institutions with the same title and the same address. At the current time I am just checking title to keep things simple.

Problem

The sizeable amount of data means that to return values is very slow.

Logic and Code

I am creating a view with address, type & title in a table with the requirement that the only institutes that come in have the same name.

My thoughts were that on every row I would take the $row->node_title and put it into a query against every other value in title like

$query= db_query("SELECT node.title
                  FROM node
                  WHERE ((node.status = '1')
                  AND (node.type IN ('institution'))
                  AND (node.title=".$row->node_title."))")->rowCount();

This should return a number, if the number is 1 then i want to exclude it with the following statement

if($query == 1){
  return true
}

Question

This is taking so long to calculate I thought there must be a faster way. I'm not even sure if the result from this is returning correctly because I've been waiting so long, Is there a faster way to get a list of all the duplicate values in a table with drupal?


texts: How to disable links in taxonomy term node fields

texts:
I have a list of rendered taxonomy terms in a node sidebar, rendered as h2 tags, linked to the taxonomy page for that tid.  I don't want that term to link anywhere, so I want to remove the link and just leave a plain rendered h2 tag.

Where is the best place to do this?  It feels like a presentation change, so should I do it in a preprocess function?  It also feels like a functional thing, so should I remove the link within a hook somewhere?

How is the best Drupal-appropriate way to do this?


texts: Drupal 6, Locale Module & Language Fallbacks

texts:
I have a Drupal 6 website, with 4 different locales, but only 2 different languages.

The 4 locales are setup as follows:

en, site.com, (American English)

en-ca, site.ca, (Canadian English)

fr, site.com/fr, (European French)

fr-ca, site.com/fr-ca, (Canadian French)

The language negotiation is set to "Path prefix only".

Content selection mode is set to "Current language and language neutral".

American english is the default locale.

As the language negotiation is set to "Path prefix only" site.ca falls back to American English as expected.

However, all the French content is entered in the European French locale. Leaving the Canadian French site empty, and broken.

Is there a way (in Drupal 6) to either:

a) select multipul languages per node.
b) set a fallback languages.

I see that in Drupal 7 you have the ability to select multipul languages for a single node. There are also many modules available for Drupal 7 to enable language fallbacks.

I tried implementing a quick hack:

function hook_theme_init() {
  global $language;
  if($language->language == 'fr-ca') {
    $language->language = 'fr';
  }
}

This almost works as it starts pulling all the European French content, Node Queue and the language switcher don't seem to like this hack.

Aside from cloning all the the French European content into the French Canadian Locale, is there any way of accomplishing language fallbacks?


texts: Can Date API/Calendar and CCK send an argument to Views with data from a field?

texts:
I have a data/calendar content type using the Date API and Calendar Modules. Each event I add to the calendar uses Advanced Node Reference and returns a list of 5 other events of the same type.

What I want is a list of the next five events following the event node's advertised event date (not the date it was published). If a new event node is added, and it falls within the next five events parameter, then when the page is generated, it is listed, bumping the furthest future event from the list. If a event node is removed, then a new (previously out of range) event node is added to the list. It is a simple sort, and very reasonable requirement using the "advertised" date and not the "published" date. The field data would be the advertised date.

The Node Reference module allows a view to be used to make the selection to populate the node reference. This I have also done. The problem is the list of possible dates/events to be linked are produced by a filter with relative date value from today's date ('>= now'), rather than from the node's content value for event date.

TDW might use an argument to pass the current date value of the date/event being edited to Views. If this exists, where is it? What is it? Some kind of [keyword] to pass in the allowed argument field of the Advanced Node Reference of this Date Content Type?

If this was a PHP template I was hand coding, the value of the current form's 'event date' field would be available from the query used to populate the form. In Drupal I don't know where this is. I'm still a newbie at Devel Module and its variables page was no help.


texts:
Using $base_url to build a link in a computed field, I get this error:

  Notice: Undefined variable: base_url in eval() (line 1 of F:\wamp\www\mysite\sites\all\modules\computed_field\computed_field.module(468) : eval()'d code).

Is it a way to get the site base URL in a computed field?


texts: composer update drupal/drupal does not work : Nothing to install or update

texts:
I’ve installed several Drupal 8 site with composer as it is strongly recommended.

I can update modules like this :

composer require drupal/pathauto:1.1

But I can't update core with

composer update drupal/core --with-dependencies (as seen in documentation)

or (think should be like this in my case) :

composer update drupal/drupal --with-dependencies

I try tu update from 8.4.2 to 8.5.0 in this website.

I’ve read a lot of topics on this, I’ve tried :

remove folder /vendor
remove composer.lock

But it didn’t work.

How can I update my classic Drupal (nothing fancy in it) with composer ? Should I gave up and update with Drush ?

Her is my composer.json

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0+",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/contact_block": "^1.4",
        "drupal/twig_tweak": "^1.9",
        "drupal/contact_ajax": "^1.4@beta",
        "drupal/pathauto": "1.1",
        "drupal/easy_breadcrumb": "^1.6",
        "drupal/redirect": "1.1",
        "drupal/views_slideshow": "^4.6",
        "drupal/bootstrap": "3.11",
        "drush/drush": "dev-master"
    },
    "replace": {
        "drupal/core": "^8.4"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php.",
            "This file specifies the packages.drupal.org repository.",
            "You can read more about this composer repository at:",
            "https://www.drupal.org/node/2718229"
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "core": ["type:drupal-core"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": [
          "Drupal\\Core\\Composer\\Composer::ensureHtaccess"
        ],
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ]
}


texts: Allowing users to create multiple "notebooks" of nodes

texts:
I'm trying to add some functionality to a site that I'm building that would allow users to create multiple "notebooks" that themselves contain links to nodes on the site, and metadata that the user can edit: a little like Evernote, but restricted to one site.

What's the best way to go about building this? I was thinking of using either Entity Reference or Flag, and would be interested on hearing thoughts regarding both of these options, and also any other ways to implement this functionality.


texts:
I've created a custom entity and having trouble providing proper caching.

When you create custom entity, by default it has only one cache tag entity_type:id.

Problem is, I need to display same entity to different users (by role) in a different way.

So I think I need cache tags, such as entity_type:id:user_role? How do I go with this?


texts: 'drush' is appended to each path breaking its commands

texts:
I don't normally use Drush on Windows, but tried it and noticed that it appends drush as a kind of root directory for any action, thus breaking said action.

For example, drush dd gives:

  The command could not be executed successfully (returned: 'Path/To/Composer/vendor/drush/drush/drush' is not recognized as an internal or external command, operable program or batch file. , code: 1)

The correct path is Path/To/Composer/vendor/drush/drush.

When running drush en mymodule, the debug information contains the following.

  [preflight] Alias paths: drupal\site\root/drush/sites,drupal/site/root/drush/sites

drupal/site/root/sites I think makes more sense.

The error is Command pm:enable was not found.

Maybe this is a coincidence and the two are unrelated, but how does one configure Drush directories?

The Drush version is 9.5.2.


texts:
I really like the ability to edit a block in Drupal on whatever page it's on--without having to drill down through menus.  However, a block doesn't seem to be a valid field for a content type.  If something is promoted to the front page, I can edit the item in a similar fashion to a block.

A work-around is to create a page, and put the block on the page.  However this creates additional maintenance.  For instance if the page is deleted, someone has to remember to delete the block too.

Is there any way of creating a field type which would be a block?  Or even better, is there any way in which a text field can be edited on the fly if it's not on the home page?

Any thoughts would be appreciated.


texts: How to read-modify-write a multivalue entity-reference field

texts:
I have some D8 entity code that does read-modify-write on a multivalue entity-reference field. The modification required is to change references to one entity to refer to another, without changing other references.

I get an exception thrown in $entity->set(...) saying that the Value is not an entity. I presume I'm calling the wrong thin somewhere but I don't see what the correct call pattern would be.

What I have at present is, and here $field_values is a EntityReferenceFieldItemList:

  $field = '...';
  $entity = $storage->load(...);

  $field_values = $entity->{$field};
  foreach ($field_values as $k => &$item) {
    $target_id = $item->get('target_id')->getValue();
    if ($target_id === $old_value->id()) {
      $changed = TRUE;
      $item->set('target_id', $new_value);
    }
  }
  if ($changed) {
    var_dump($field_values);
    $entity->set($field, $field_values);
    $entity->save();
  }

where $old_value and $new_value are both EntityInterface objects and $field_values is an EntityReferenceFieldItemList.


texts: Added fields are not displaying while creating the user

texts:
I am new to drupal and I have added few more necessary fields to the user create page [i,e in configuration->people->account setting->manage fields],but the added fields are not displaying while creating the user[i,e admin->people->add user]
but its displaying while editing the created user, I have searched to figure it out from last 1 week but no luck for me. if anyone know the reason for not displaying please help me. I have attached the screen shot too.Thanks in advance.


texts:
I have a simply question, it's possible to delete a node and at the same time delete a menu_links ? For exemple when i will use the button delete of a node of my entity "PROJECT" i want to delete automaticaly a menu_links created before. I found the HOOK_Delete but how to use this function in a particular entity ? Like the HOOK_form_alter we can choose the form_id, there is a HOOK like this ? :

Mymodule_delete($nid) {
    if($entity == "project") {
        delete($nid);
    }
}

Maybe can i change the $form['actions']['delete ??'] in my form alter and use my own function ?

_myfunction_delete_project($nid) {
    $query = "Here get the entity of my $nid";

    if($query == "project") {
        delete($nid);
        delete($my menu links);
    }
}

I hope you understand my request

Thanks


texts:
I have the following call in page.tpl.php.

 theme('links__main_menu',array(...));

How can I override the theme function that is being called from that code?


texts:
I have looked at the source code, briefly, and the problem is that the module is a complex "beast" that relies heavily on the core's API which I am not currently familiar with.

I have a kind of pieced together on how Drupal assembles a completed node object by traversing the various tables (node, node_type, field_config, field_config_instance, etc).

What confuses me is the data abstraction layer. field_config has a storage_type which appears to indicate whether a field is stored in SQL or not.

From what I have read and interpreted, Drupal is flexible enough to have a system which is data store agnostic, so if I had a products content type and capacity out-grew what MySQL was capable of, I could (in theory) switch to MongoDB or similar DBMS which allows better scaling.

So, how would I attach a field to a content type, which let's say was stored in Mongo, but the remaining fields stayed in SQL?
More interesting, how does VIEWS deal with this disconnection in data storage? If I store some fields for a given type in MongoDB and some in SQL how does VIEWS handle the JOINS and filtering capability?


texts: Drupal cannot create sites/default/files even though permissions seemed to be set to standard

texts:
I continue to get an error message regarding file permissions on a sandbox server running RHEL 7

$ drush wd-show
 ID   Date          Type      Severity  Message
 398  15/Jun 20:15  file      error     The directory sites/default/files exists but is not writable and could not
                    system              be made writable.
 397  15/Jun 20:15  file      error     The file permissions could not be set on sites/default/files.
 396  15/Jun 20:14  file      error     The directory sites/default/files exists but is not writable and could not
                    system              be made writable.
 395  15/Jun 20:14  file      error     The file permissions could not be set on sites/default/files.
 394  15/Jun 20:12  file      error     The directory sites/default/files exists but is not writable and could not
                    system              be made writable.
 393  15/Jun 20:12  file      error     The file permissions could not be set on sites/default/files.
 392  15/Jun 20:12  file      error     The directory sites/default/files exists but is not writable and could not
                    system              be made writable.
 391  15/Jun 20:12  file      error     The file permissions could not be set on sites/default/files.
 390  15/Jun 20:11  file      error     The directory /var/www/drupal-private-file-system/tmp exists but is not
                    system              writable and could not be made writable.
 389  15/Jun 20:11  file      error     The file permissions could not be set on
                                        /var/www/drupal-private-file-system/tmp.

I have followed the model from Securing file permissions and ownership. Even though my file permissions are as such:

[dev@sandbox sites]$ ll
total 8
drwxr-x---. 6 dev apache   61 Jun  8 14:38 all
drwxr-x---. 4 dev apache   55 Jun 15 15:08 default
-rw-r-----. 1 dev apache 2365 May  6 23:13 example.sites.php
-rw-r-----. 1 dev apache  904 May  6 23:13 README.txt

and

[dev@sandbox default]$ ll
total 24
drwxr-x---. 3 dev apache    37 Jun 10 13:35 behat-tests
drwxrwx---. 3 dev apache    35 Jun  5 15:21 files
-rw-r-----. 1 dev apache 24103 Jun  8 10:30 settings.php

The folder structure looks like the following...

[dev@sandbox sites]$ tree -d -L 2
.
├── all
│   ├── libraries
│   ├── modules
│   ├── tests
│   └── themes
└── default
    ├── behat-tests
    └── files

My question: Where did I go wrong? Is there something you see here that I don't?


texts: How to work around check for `sites/default/files` during Drupal installation, if you're not planning on using it?

texts:
I'm working with a server where I don't have shell access and I've dropped the database in an attempt to reinstall Drupal (having run into issues with a failed deployment). When I try to step through the Drupal install process on the server, during the "Verify requirements" step, I get this error:

FILE SYSTEM: Writable (public download method) - The directory sites/default/files does not exist. An automated attempt to create this directory failed, possibly due to a permissions problem. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see INSTALL.txt or the online handbook.

We're using the S3FS module, so we don't really need the sites/default/files directory, once the site is up and running. I've run into this issue before in other environments where I do have shell access and I was able to create the directory from the command line and continue the installation process. At first, I thought I'd add an (almost) empty directory to the site's repository and redeploy; however, we have a cleanup script that deletes all .gitignore files prior to deploying. I could presumably add a DoNotDelete.txt file or something, but is there a "cleaner" way to work past the error message?


texts: Really really need help debugging this dpm(). It's an error from trying to create a new Message | Fixed by reinstalling Reply module

texts:
The Message module was working fine but I noticed one of the messages wasn't getting created by Rules. I suspect it's due to locale being enabled recently and creating with the UI gives this error.

For message types where I haven't created a different language, it seems to work fine.

2 errors in log:

Warning: array_flip(): Can only flip STRING and INTEGER values! in EntityAPIController->load() (line 219 of /usr/share/nginx/html/sites/all/modules/entity/includes/entity.controller.inc).

.

EntityMalformedException: Missing bundle property on entity of type message. in entity_extract_ids() (line 7930 of /usr/share/nginx/html/includes/common.inc).

The relevant lines in common.inc are:

// Explicitly fail for malformed entities missing the bundle property.
    if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
        dpm($info);// My dpm
      throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
    }

You can see where I added dpm(). $entity is empty but $info gives the below screenshot.

Any pointers for someone who just isn't used to debugging things like this? I've deleted every message in on the site with VBO but the error persists.

After two and half years of dev, this site was supposed to go into a proper beta next week in a friend's business but the entire UI relies on the Message module. :/

And here is a dpm of the ids for the flipping error.

Any help appreciated. I didn't expect it to all fall apart this weekend.

Edit: Closed as it is indeed a duplicate. I don't have the skills to deal with it so will just rewrite to use node functionality instead.

Edit 2: Calmed my head today and looked at things that weren't my own code. Turns out it was the Reply module which I use on Message. Reinstalling it gets rid of the errors. I don't know why it happened. It's been a part of Message for like a year during development.


texts: Adding translations to installation profile upon installation

texts:
Creating an installation profile for a french site.

I have hit a brick wall trying to have the profile install fr language translations.
I have tried adding this to my profile as this comment http://drupal.org/node/1297438#comment-6308144

// Add french language.
locale_add_language('fr', 'French', 'Français', LANGUAGE_LTR, '', '', true, true);
drupal_set_message(t('The language %language has been add and is now the default language.', array('%language' => 'french')));

Code above generates a fatal error:

[drush] Fatal error: Call to undefined function locale_add_language() in /home/stef/jmt-www/build/www/profiles/jmt_profile/jmt_profile.profile on line 19

I have the fr.po file in profile/jmt_profile/translations but have no clear way of getting the fr.po loaded. Has anyone dealt with installing secondary languages without going through ui?


texts: Create an image slideshow with multiple image fields per node

texts:
I'd like to create an image slideshow using views slideshow. I see a few ways of doing it, like this one create-an-easy-jquery-slideshow-in-drupal-7, but they all require a single image per node.

I would like to have a content type that accepts multiple images and still retains similar functionality. So there is a list of thumbnails at the bottom, as a pager, and a single image above that is activated by hovering the thumbnails below.

I'm sure there is a way to do this. possibly with a few more modules? I'd love to know.

EDIT: This is drupal 7


texts: how i can display the file path in imce?

texts:
i want display the file location path in the imce :
i opened the imce-file-list.tpl.php and i found that :

<tr id="<?php print $raw = rawurlencode($file['name']); ?>">
    <?php print $raw; ?>
    <td class="size" id="<?php print $file['size']; ?>"><?php print format_size($file['size']); ?>
    <?php print $file['width']; ?>
    <?php print $file['height']; ?>
    <td class="date" id="<?php print $file['date']; ?>"><?php print format_date($file['date'], 'short'); ?>

i want print $file[path] but it not working


texts: PHP code to add a link to the configured default home page

texts:
The default home page of a site can be configured in Home » Administration » Configuration » System » Site information.

I have a node instance (with PHP code text format) and I need to insert a link to the default home page of my site, knowing that it can be reconfigured later. In other words, I can't put a static link, I need to fetch info from Drupal (if possible).

How can I create such a link with a PHP code snippet? Is this possible?

Solution

I got away with:

<?php
    $ttmp = variable_get('site_frontpage', url());
    echo 'Home';
?>


texts: Mimemail + SMTP + Mail System: inline images make body empty

texts:
I'm trying to send HTML mails on a Drupal 7 install.
For this, I use Mail System, SMTP authentication and Mime mail modules.
I used settings as Alternative approach on this page http://drupal.org/node/1200142

The mail content is built within custom modules I'm writing (not by rules or simplenews, I mean).
I tweaked default Mail mime template to my needs, within a separate, light drupal theme.

My mails are sent (and received) without error when they contain only HTML and styles.
There are no error also when I had images with absolute url: Mime mail is leaving them as such.

I need to embed a few small images within my mails and when I try to do so, accordingly to what's written in Mime Mail README, I get a "Message body empty" at the top of my page when my code tried to send the mail.

I placed dpm($message) along the Mime mail code to locate where the body content is left empty.
I finally reached the
class MimeMailSystem implements MailSystemInterface
located in mimemail/includes/mimemail.mail.inc

Body content was still there.

Then the class MimeMailSystem__SmtpMailSystem implements MailSystemInterface
in default/files/mailsystem/MimeMailSystem__SmtpMailSystem.mail.inc

Again, my content was still there, along with inline BASE64 encoded images.
So the content disappears somewhere after that (in Mail System ?)

As I pointed it out here, switching Site-wide default MailSystemInterface class in Mail System settings from
MimeMailSystem__SmtpMailSystem
to
MimeMailSystem
allows the mail to be sent with its images, but the mail is no more sent through SMTP.

I'm pretty sure this is not due to a bug within one of the 3 modules, but I can't figure what I'm doing wrong.

The only thing I doubt from here is how I build the mail content :

I build some variable HTML content
I store it in $message['body'][] in my module's hook_mail implementation
then I print $body in my mimemail-message.tpl.php within static HTML part of the mail

The images I try to embed are in public files. I tried to link them :

with relative paths like sites/default/files/<filename>
with relative paths like public://<filename>

with no success.

Does anyone has a magical one character solution for something I missed ? ;)

Regards,


texts: How do I exclude admin strings from interface translation?

texts:
I want to translate my Drupal 8 site to another language.

I have several translatable strings in my custom theme and modules specified via either the t method or {% trans %}.

To translate these I have activated interface translation. I can now find my strings by going to admin/config/regional/translate.

The problem is this page lists all strings including all strings defined by core. For this project I don't want to translate the admin interface, we specifically want it to stay in the default language (English). This means 90% of the strings listed should not be translated.

I know that I can set the admin interface to stay in a certain language by checking a box on the user account settings page, but this only works when on an admin page. When visiting a node in a translated language, the admin toolbar will still be translated if there are translated strings. If this problem could be solved it would probably be the best solution to just have that box checked.

But for now it seems like my only other option is to only translate the strings I want translated and none of the admin strings. To do this I feel like I have to be able to filter the list of strings on the interface translation page somehow. But there is no way to filter out strings based on which theme or module they are defined in. Or is there?

I have seen that there is a context parameter you can pass to the t method or {% trans %}. Maybe if I add a key like "translate" or something here, I could filter out strings with this context and only translate them. The thing is it feels like using the context parameter in the wrong way and it does not seem to be any way to filter by context either.

Does anyone have a good solution for this?


texts: Override core permissions used for visualizing a page

texts: Is there is a way (without using any external module) to override the core drupal 7 pages access permissions , for example and by default you will not be able to access /admin/structure/taxonomy/tags page without having (Administer vocabularies and terms) permission , but I want the users to be able to access it if they have for example (Edit terms in Tags) permission


texts: Migration of multi-value pictures to user fields

texts:
I need to migrate from a WordPress site to a Drupal 7 site where users could upload their own images (like multiple user pictures). I have a CSV file with the User's ID and a serialized array containing the filenames of uploaded pictures (no, really).

Users have a multi-value image field 'field_user_pictures'.

After deserializing the array, drupal complains with the error "ltrim() expects parameter 1 to be string, array given". (Presumably because MigrateDestinationFile doesn't handle arrays very well.) Then I tried with just using the first image of the array, and that actually works. What doesn't work, however, is to get drupal to link this sole image to the 'field_user_pictures' user field.

I have been trying to get to something like this:

 class PictureMigration extends Migration
 {
    public function __construct ($arguments)
        {
        parent::__construct($arguments);

        $source = 'user_pictures.csv';

        $columns = array(
            1 => array('source_userid', ''),
            3 => array('source_serialized', ''),
        );

        $source_key = array('source_userid' => array('type' => 'int', 'not null' => TRUE),);

        $this->source = new MigrateSourceCSV($source, $columns);
        $this->destination = new MigrateDestinationFile('image', 'MigrateFileUri');
        $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationFile::getKeySchema());

        $this->addFieldMapping('source_dir')->defaultValue($this->remote_dir);
        $this->addFieldMapping('destination_dir')->defaultValue('public://');
        $this->addFieldMapping('value', 'source_serialized');
      }

  public function prepareRow($row) {
     // snipped
     $row->source_serialized = $this->deserializePhotos($row->source_serialized); // returns array of filenames
    }
}

public class UserMigration extends Migration {
  public class __construct ($arguments) {
    // snipped...
      $this->addFieldMapping('field_user_pictures')->sourceMigration('PictureMigration');
  }
}

The first problem is that MigrateDestinationFile doesn't seem to like multi-value values; the second problem is that even when I only use the first filename of the array, it still doesn't get linked to the 'field_user_pictures' field...

See also: Migration: Combine Profile2 and file migration -- almost exactly the same issue, but with no valid answer as well.


texts: How does core handle the different time zones?

texts:
Here is my situation, I have a website where the content author(i.e who has his preferred time zone as PST in US) had created the node of one content type which had an event in New York(i.e a different time zone EST in US). So he adds the content in that node and set the time for the event according to his time zone(i.e PST) as 12 PM.
Then a customer comes onto site to check for the event on the UI in his place(New York) and sees the event is at 12 PM EST(i.e JS takes the preferred time zone of the OS where the user has set) and when he goes to the event he figures out the event was 3 hours later the time which he saw in the website.
Is there a way that Drupal can handle the events in different time zones to be shown to the anonymous users in their respective time zones?


texts: How to return drupal's articles image upload

texts:
I am new in drupal

when I click on content>add content
I don't have the browse button to uploading image for article, maybe I removed accidentally from structure>content type or other...

How can I see that browse button again?


texts: Access taxonomy fields on page.html.twig

texts:
I have added a header image field to most of my entities of my website so that the header image can be overwritten if needed. On any node, my code in my page.html.twig file works perfectly:

{% if node.field_header_image.entity.uri.value %}

{% else %}

{% endif %}

However, I've added a field_header_image field to my taxonomy terms and can't seem to find a way to get the code I need to print on my page.html.twig file.

On my taxonomy page template file, if I print the following code:
{{ file_url(elements['#taxonomy_term'].field_header_image.entity.uri.value) }} I get what I need but this doesn't work in page.html.twig file.

Any suggestions on how I can access this? Or is there another way for me to overwrite the header image on my taxonomy terms?

EDIT: Is there a way to do this through a preprocess?


texts: media 2.x: customize media browser view with single fields - how to submit media item?

texts:
I want to use 7.x-2.x-dev as it uses a view as media browser. I added several fields (license, tags etc.) and want to show some of them in the media browser.

In the view, I thought of using an unformatted list instead of the "media browser" style plugin; but of course, now the items either
- cannot be selected for submission (if I disable their links) or
- are linked to their content

How can I mimic the normal beaviour (clicking on a media item just selects it for inserting)?

Thanks in advance to everyone,
sol


texts: How to embed "add node" form in a page and retain content-creation permissions?

texts:
Question about adding "add node form" to page happened few times, for example:

https://stackoverflow.com/questions/5344754/drupal-7-how-to-display-node-add-sometype-form-on-another-page

Embed a "node add" form in a page

render form in page--node--add--contenttype.tpl.php

How do I embed a node creation form inside a view

And it is also mentioned here: Embed a node form with default values in drupal 7

Everyone gives this piece of code:

module_load_include('inc', 'node', 'node.pages');
$node_form = node_add('node_type');

So I used it that way:

function MYMODULE_menu() {
    $items['content/add'] = array(
        'title' => 'Add: Content',
        'page callback' => 'MYMODULE_content_add_callback',
        'access arguments' => array('access content'),
        'weight' => 2,
    );
    return $items;
}

function MYMODULE_content_add_callback() {
    module_load_include('inc', 'node', 'node.pages');
    $form = node_add('MY_CONTENT_TYPE');
    return $form;
}

The intention was to show form to everyone, but not everyone should be able to create content by it. It should only encourage registering for gaining proper permissions. What I discovered after initial testing is that form added to page that way, is completely ignoring permissions. Even if anonymous user have no permission to create that kind of content - he can send this form, and content will be created. Maybe it is following only page access arguments or I don't know.

I'm writing this firstly to warn everyone who embed a form that way with the same intention, and secondly to ask, how can we embed form so it can be visible for everyone, but would still follow all Drupal permissions.

I know that I can add custom validation function, and it works, but I would like it to be following Drupal core permissions for content creation.


texts: Exporting results with Views Data Export not working as intended

texts:
I have a view-based search (drupal 7, newest version of Views) with several exposed filters. By default it shows all results and users have to use the filters to narrow down their search.

I've added 'Views Data Export' module to allow users to download search results via CSV export, if they wish. However it's not working as intended.

I created the export view and attached it to the search view fine. I made sure pager in the export view was set to 'display all items' (otherwise it only shows around 10 results).

I set batched export to yes. I also set each filter to 'remember last selection'.

However, no matter which filters are selected, the data export still shows every record in the database on export.

Anyone know how to fix this? Ideally the export would just show the records displayed on the screen after using the various filters.


texts: Drupal Upgrade module: SQL table prefixes and upgrading from Drupal 7 to Drupal 8

texts:
When I ought to do an upgrade to my site from Drupal 7 to Drupal 8, and I go to localhost/site/upgrade in my D8 site, I am being asked about table prefixes in my site's SQL DB... Indeed, all the tables in my DB include prefixes, but I didn't understand from the explanation at Drupal upgrade module's description if it is a must to bring them into this advanced options field in the module.

Maybe a Drupal dev could shed some light here about this...


texts:
I am getting the following errors from Googlebot; I am getting about 5 of them per minute, and I want to find out what is causing them.

  Type php
  Date Friday, February 3, 2012 - 08:16
  User Anonymous (not verified)
  Location http://www.*/biblio?f%5Bkeyword%5D=70&f%5Bag%5D=C&s=...
  Notice: Trying to get property of non-object in eval() (line 3 of /home/sltruweb/public_html/modules/php/php.module(74) : eval()'d code).
  Severity notice
  Hostname 66.249.71.165