texts:
I've created entities and bundles through Entity Construction Kit UI, and now I'm trying to re-create everything with code, in a module.
I managed to generate entity with Drupal console, added fields, and everything works well.

The problem is when I try to create bundles for an entity, with different fields.
In ECK, I can create an entity, then bundles, and add different fields to each bundle.
However, I can't understand how to do it in the code, and after reading tons of documentation, it feels like bundles are only configuration entities and can't have fields.

So my questions are :

Is there something I don't understand ?
How can I mimic ECK "bundles with fields" in code ? My goal is to create profiles, like the profile module can do for users, but referenced from an other entity, and with specific behavior, so I'd prefer create my own entities.


texts: How to get the nid for a newly created node?

texts:
If I've created a node in an install hook, how can I immediately get a reference to the nid property? It doesn't appear to be set on the entity during save.

use Drupal\node\Entity\Node;

function my_frontpage_install() {
    $node = Node::create(array(
        'type' => 'page',
        'title' => t('Welcome'),
        'body' => array(array(
            'value' => 'Hi there'
        )),
    ));

    $node->save();

    $siteConfig = \Drupal::service('config.factory')->getEditable('system.site');
    $pageConfig = $siteConfig->get('page');
    $pageConfig['front'] = 'node/' . $node->getId(); // this returns null
    $siteConfig->set('page', $pageConfig);
    $siteConfig->save();
}

I've tried variations on the theme of getId, getNid(), get('nid'), getOriginalId(), but if I dump out the node object afer saving, the nid property is clearly not set.


texts: Quick question: horizontal align taxonomy @ node/add?

texts:
When adding a node (node/add/article), all the fields are showing up. With module "field group" i can alter the vertical presentation to an editor. In fact, the editor sees (for example) taxonomy-choices as:
Taxonomy
[] Tag 1
[] Tag 2
[] Tag 3
[] Tag 4
[] Tag 5

[] Option 1
[] Option 2
[] Option 3
[] Option 4
[] Option 5

[]Choise a
[]Choise b
[]Choise c
[]Choise d
[]Choise e

But how can i present it horizontal, like

Taxonomy-choices (here radiobuttons

+-----------+---------------+--------------+| [] Tag 1  | [] Option 1 | []Choise a || [] Tag 2  | [] Option 2 | []Choise b || [] Tag 3  | [] Option 3 | []Choise c || [] Tag 4  | [] Option 4 | []Choise d || [] Tag 5  | [] Option 5 | []Choise e |+-----------+---------------+---------------+


texts: I seem to have a problem when adding html to a block (i'm using ckk editor), if i toggle Source it loses them html id tag. If I save the Block without toggling, it works fine, but when I go back in to edit the block afterwards, it has lost the div id tag. I have attached a pic which shows the problem in 3 steps. I have it set to Full HTML throughout.


texts: How to resolve fatal error 'Cannot redeclare commerce_kickstart_preprocess_html'?

texts:
I have installed an ecommerce website with Commerce Kickstart, not in demo  mode. Everything was OK and I began to add products and then my problem started; when I click on 'products category' I receive this error message:

  Fatal error: Cannot redeclare commerce_kickstart_preprocess_html() (previously declared in /homepages/44/d576739206/htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php:41) in /homepages/44/d576739206/htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php on line 41

This is what that line 41 (as in the error message) looks like.

function commerce_kickstart_preprocess_html(&$variables) {
  drupal_add_css('http://fonts.googleapis.com/css?family=Lobster+Two:400,700', array('type' => 'external'));
}

What could the problem be? How can I solve it?

Update (as in one of the comments): I tried to change as you said it and I have this message:

Fatal error: Cannot redeclare commerce_kickstart_theme_preprocess_html() (previously declared in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php:9) in /homepages/..../htdocs/profiles/commerce_kickstart/themes/commerce_kickstart_theme/template.php on line 41 code

Update 2 : So if I use another theme, the problem is solved.
And there are 2 (minor) differences in the new error message :
Now it is in that line "9" (no longer "41") :

function commerce_kickstart_theme_preprocess_html(&$variables) { // Add conditional stylesheets for IE drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-8.css', array('group' => CSS_THEME, 'weight' => 23, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE)); drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-7.css', array('group' => CSS_THEME, 'weight' => 24, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

Update 3 : Here is template.php :

<?php
/**
 * Preprocess variables for html.tpl.php
 *
 * @see system_elements()
 * @see html.tpl.php
 */
function commerce_kickstart_theme_preprocess_html(&$variables) {
  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-8.css', array('group' => CSS_THEME, 'weight' => 23, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/commerce-kickstart-theme-ie-lte-7.css', array('group' => CSS_THEME, 'weight' => 24, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

  // Add external libraries.
  drupal_add_library('commerce_kickstart_theme', 'selectnav');
}

/**
 * Implements hook_library().
 */
function commerce_kickstart_theme_library() {
  $libraries['selectnav'] = array(
    'title' => 'Selectnav',
    'version' => '',
    'js' => array(
      libraries_get_path('selectnav.js') . '/selectnav.min.js' => array(),
    ),
  );
  return $libraries;
}

/**
 * Override the submitted variable.
 */
function commerce_kickstart_theme_preprocess_node(&$variables) {
  $variables['submitted'] = $variables['date'] . ' - ' . $variables['name'];
  if ($variables['type'] == 'blog_post') {
    $variables['submitted'] = t('By') . ' ' . $variables['name'] . ', ' . $variables['date'];
  }

function commerce_kickstart_theme_preprocess_html(&$variables) {
drupal_add_css('http://fonts.googleapis.com/css?family=Lobster+Two:400,700', array('type' => 'external'));
 }
}


texts: How to create several -lists in one display with Views?

texts:
I display a list of news which have a category. I wish to have over my news list , a list of all categories. Is this possible in one single view , and therefore with one single SQL query ?

What I want :

<ul> Cat1; Cat2; Cat3; .....</ul> //1st list

<ul> //2nd list
Title 1
Cat 1
Body 1

Title 2
Cat 2
Body 2

Title 3
Cat 3
Body 3
</ul>

All of that with one display of a view with Views module.

I get to see the first list. But not the list of categories above. I don't want several block and combine them in a template, wich means several query.

My view :


texts: pathauto with drupal 8 and generated characters

texts: I am using pathauto with drupal 8 but i want to change the way it translates-generates some characters from greek to english. For example the greek character Η is translated as "e" . How can it be done?


texts: Webform multi-page submit handler fires on every page

texts:
I have created a couple of webform submit handlers before, but my new one fires on every page submit rather than when the last page is submitted.

How do I get the webform handler to only fire after the full form is submitted?

Below is what I have at the moment, which fires on each page:

namespace Drupal\the_api\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;

/**
 * Webform submission remote post handler.
 *
 * @WebformHandler(
 *   id = "membership_api_post",
 *   label = @Translation("New Membership to API"),
 *   category = @Translation("External"),
 *   description = @Translation("Posts a new membership through to the API."),
 *   cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 *   results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
 *   submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_REQUIRED,
 * )
 */
class NewMembershipWebformHandler extends WebformHandlerBase {

  /**
   * @param array $form
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   * @param \Drupal\webform\WebformSubmissionInterface $webform_submission
   */
  public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
    parent::submitForm($form, $form_state, $webform_submission);

    kint($form_state);

  }
}


texts: Pathauto does not trigger on node_save when programatically creating nodes

texts:
I am programatically saving nodes. From my reading, it sounds as if Path auto is trigged to autmatically create a URL alias when node_save() is called.  However, this is not happening.

I later read that I needed to set $node->path_set_alias = TRUE. However, this is not working correctly either.

Using 7.12 and the latest versions of pathauto.

Here is my code.

$node = new stdClass();
        //set other defaults
        node_object_prepare($node);

        $node->type = $page_data['content_type'];
        $node->body[LANGUAGE_NONE][0]['value'] = $page_data['description'];
        $node->body[LANGUAGE_NONE][0]['summary'] = text_summary($page_data['description']);
        $node->body[LANGUAGE_NONE][0]['format']  = 'filtered_html';
        $node->title = $page_data['title'];
        $node->field_product_price[LANGUAGE_NONE][0]['value'] = $page_data['price'];
        $node->field_item_location[LANGUAGE_NONE][0]['postal_code'] = $page_data['zipcode'];
        $node->uid = "1";
        $node->status = 1;
        $node->active = 1;
        $node->pathauto_perform_alias = TRUE;

    //the name of my actual field is 'product images'
    $node->field_product_images[LANGUAGE_NONE] = $images;
    unset($images);

    $node->field_baby_clothes_category[LANGUAGE_NONE][0]['tid'] = $page_data['category'];

    if($node = node_submit($node)) { // Prepare node for saving
        node_save($node);
}

Thoughts on how to get this to work correctly? Thanks!


texts: Uppercase module names - what could go wrong, technically?

texts:
This is a technical curiosity question.

Afaik, it is convention that module names in Drupal should be lowercase, with underscores.

Obviously it is generally good to follow conventions.

But does someone know what could go wrong, technically, if module names are upper case or mixed case? E.g. camel case.

I think to remember to have seen at least one case in contrib where a module was CamelCase, but I don't remember which one.


texts: How to check programatically whether a comment is new?

texts:
I'd like to make some changes to a new comment programatically. I'm using the following code:

function MYMODULE_comment_presave($comment) {
    $user = user_load($comment->uid);
    $uid = $user->uid;
    // if ($comment->is_new) {
        $comment->field_image['und'][0]['fid'] = $user->field_image['und'][0]['fid'];
        }
    // }
}

I don't know how I can check whether the comment that's about to be saved is new or edited. $comment->is_new doesn't work.

How can I solve this?


texts: How to create a user after ldap authenticaion?

texts: I am using ldap for Drupal 7.  After successfully authenticating, how do I create a Drupal user.


texts: How to disable edit links/tasks for mobile theme?

texts:
I have a separate sub domain and theme for a mobile version of my site. I would like to disable the edit links/tabs for nodes if viewed from that subdomain/theme, but still allow users from editing in the main theme.

Any help or tips will be appreciated.


texts:
I've a 6.x webform with webform cards enabled. I the form settings, I enabled Track wizard/cards progress in the URL by Page/Card name. This works fine. However, I'm unable to go to specific card by visiting its URL (e.g. ?page=page9) - the webform always redirects me back to the first card and displays its URL.
Is it possible to change this behavior or should I use pages instead of cards for this?


texts: Exporting and importing a view from a custom module

texts:
From my understanding you can export your views and content types to a module so that you can replicate the view and content type on another server. My question is, if I export the view to a module and write the views api in my module, will the view/content type show up under the structure menu, if so would any changes made there be reflected back in the code of the module, or does this require another export and saving the output back into the module code?

Thanks


texts: How to add JS Confirmation popup when clicking an #AJAX button in custom module?

texts:
$form['button4'] = array(
'#value' => 'RESET',
'#type' => 'submit',
'#submit' => array('form_test_form_button4'),
'#ajax' => array(
  'callback' => 'ajax_example_submit_driven_callback1',
    'progress' => array('type' => 'none'),
    'wrapper' => 'deletevalue',
    'event' => 'click',
),

);

This is the RESET button I want to ask Are you sure?.

AJAX submit also working fine. But POPUP Confirmation not working properly.Please anyone guide to me?

If user click the OK button the data will be reset.

JS

$('#edit-button7').on('click', function(){
var r = confirm("Are you sure you want to reset?");
});

If user click the CANCEL button also data was reset.


texts:
I am receiving data from a third party company through XML.
I want to add this to my website as drupal nodes, having some information like title, body, summary, image,...

I am able to make a cron job that reads all the data from the XML & write it to a database.

Now I was wondering:

Can I write this to the database directly without creating any inconsistenties?
What tables do I have to write this to? only the node table and the field_data tables? Or do I also have to add it to field_revision tables etc? Am I forgetting any others?
Is there a module that's doing this? I tried the Feeds & the Migrate modules, but I can't seem to find anything to set up XML or SQL Data import on those. Either of the 2 is fine, whether it goes directly from the XML, or if I have to import it from SQL, cause then I can just add them to a temp table first.

Thank you very much


texts: Alter the generated composer.json on packages.drupal.org for third-party modules

texts:
This question is similar to Support composer_manager AND drupal-composer/drupal-project with contrib module, but I am asking it with a different angle this time. Imo this justifies a separate question, as an answer to this could be generally useful beyond my specific use case.

Technical background

packages.drupal.org re-publishes module packages from drupal.org with auto-generated composer.json.

The main "module package" becomes a composer package with "type": "drupal-module". Each "submodule" (module in a subdirectory) becomes a package with "type": "metapackage".

The composer.json for each submodule is generated from the *.info file. E.g. if the *.info file says dependencies[] = composer_manager, then the composer.json for this metapackage will require drupal/composer_manager. It seems that composer.json in the submodule is ignored.

For the main / root package, perhaps an existing composer.json is not ignored. Not sure about that.

Sometimes the generated composer.json is not exactly what I want.

The functionality on packages.drupal.org is provided by https://www.drupal.org/project/project_composer.
There are database tables that contain information about modules uploaded to drupal.org (via https://www.drupal.org/project/project), and project_composer derives Composer data from this.

Question

Is it possible for a contrib module to alter the composer.json that will be generated for the main module package and for a submodule metapackage?

E.g.:

Prevent a module dependency from the *.info file to be added as a Composer requirement.
Add an additional 3rd party Composer requirement.


texts: Redirect to referring page after form submission

texts:
Trying to figure out how to redirect a user back to referring page after they have completed our feedback form. So a scenario would be if im on page foo/bar and I click on feedback webform link on that page. I then proceed to fill out the webform and then hit submit I will then be directed back to foo/bar page with confirmation message displayed at top of page. Webform module does give me an option to add in a custom confirmation URL and also the ability to add in tokens. However I have had no success with current tokens as none of them redirect me back to referring page.

Would creating a custom token maybe help with resolving this issue or hook_form_alter? Kind of stuck on how best to approach this.


texts: Custom Block Twig: File field how to get direct link to file?

texts:
How can I get the direct URL to a file field in twig? I am able to do this for images, but with a file field, it comes up blank.

WORKS

{% set media_img_url = file_url(content.field_background_image.0['#item'].entity.uri.value) %}

DOESN't WORK

{% set media_file_url = file_url(content.field_cta_file.0['#item'].entity.uri.value) %}


texts: Can I include other template into template?

texts:
I override template in my custom theme na (templates/block--[module]--[delta].tpl.php) and I would like to include other template (from the same directory) into this. Can I do it and how?

Directory structure

sites\all\themes\
   my_name_of_theme\
        templates\
             block--views--front-page-block-1.tpl.php
             example-file-template.tpl.php

block--views--front-page-block-1.tpl.php (concept what I want to do):

<?php
     /* init $path (or maybe it is not needed) */
     include($path . 'example-file-template.tpl.php');
?>


texts:
I have enabled couple of ubercart modules in a drupal 7 site. After enabling it , I am getting error

  Fatal error: Exception thrown without a stack frame in Unknown on line 0

I dont know how to debug this error. I have even tried putting a try/catch block in index.php file of drupal.
but still it doesn't produce any custom message by which I can track the error.

Has any of you guys reproduce the error and how you guys fixed it.

Any pointers on it would be really helpful.


texts: How do you theme a pager in a specific View?

texts: I have a few views, but each view would have a pager that would be themed differently. How do I go about targetting the pagers of each View for theming?


texts: How to Get Custom Field Label Translation

texts:
I'm using Internationalization module and in my custom entity type, I have my custom field. Since this entity is going to be usable for all enabled languages, I have added translation to my custom field's label.

In node.tpl.php file in my custom template, I am calling this field values like this:

$field = field_info_instance('node', 'field_custom', 'custom_entity');

And I render the field's label like this:

echo t($field['label']);

However, even though I've added translation for the label, it remains same string for all languages. I'm surely missing something here, how can I implement this?

Thanks in advance.


texts: Can't see error messages when creating Drupal form in a separate file

texts:
Suppose, I want to use Drupal libraries inside a separate php file to generate a form. I created 3 functions:

function add_form
function add_form_validate
function add_form_submit

And then used drupal_get_form / render to get the HTML code. But when I insert invalid data, I don't see the error message - just the red border of the text input. Here is the minimal example to reproduce the error (file is called test.php and is located inside Drupal directory):

<?php
//including Drupal libraries
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
require_once(DRUPAL_ROOT . DIRECTORY_SEPARATOR . 'includes'.  DIRECTORY_SEPARATOR . 'bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

//form with 1 text field and submit button
function add_form($form, &$form_state)
{
    $form['text'] = array(
        '#type' => 'textfield',
        '#title' => 'Insert text',
        '#required' => true,
        '#attributes' => array('autofocus' => 'autofocus'),
        );

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

    return $form;
}

//text must be 'aaa'
function add_form_validate($form, &$form_state)
{
    if ($form_state['input']['text'] != 'aaa')
    {
        form_set_error('text', t('Text is not aaa!'));
    }
}

function add_form_submit($form, &$form_state)
{
    print "I am inside add_form_submit<br>";
    var_dump($form_state['input']);
    exit;
}
?>
<!DOCTYPE html>
<html>
  <head>
    <title>element</title>
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.base.css">
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.theme.css">
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.messages.css">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
  </head>
  <body>
<?php
//here is the problem: I don't know, how to output the error message
print theme('status_messages');

$content = drupal_get_form('add_form');
$content = render($content);
print $content;
?>
  </body>
</html>


texts: Page--front.tpl.php not working - Tao theme

texts:
This should be really simple, maybe I'm just having a moment. Why is my page--front.tpl.php not rendering my home page? I'm using a tao subtheme.

Here's my tpl.php file.

(There's no other page--front.tpl.php in the tao folder.)

Here's my front page settings:

And here's theme developer telling me that the front page is using page.tpl.php to load:

I've cleared my cache with drush a couple times and restarted my local server. What else am I missing?


texts: Send mail once content approval of custom content types

texts: I am creating one Like job posting custom content type.The permission for only posting the job for recruiter.After Post the job I need the approval for publishing permission from admin. My thought when recruiter post the job i want to send the mail like recruiter post the new job for admin and once admin approved the content. How can i do this


texts: Highlight searched keyword using exposed filter views?

texts:
In a view and I added an exposed filter: Search: Search Terms filter

It works fine, but I'd like to highlight the searched keyword in the results.

How can I do it?


texts: OG group content notification for group administrators

texts:
I'm using Drupal 7.12 with OG 7.x-1.3 and Rules 7.x-2.0.

There is a pre-installed rule that I'm using for group notifications which is "OG group content notification". This sends out an email to all group members when new group content is created. I want to modify this so it only sends out emails to group members who have an "administrator" role for that group.

Does anyone know how I can achieve this?

I did see that it's possible for me to get a list of group managers instead of group members but I don't want just the manager I want all the group administrators.

Many thanks.


texts: How to use conditions on a COUNT Expression?

texts:
I am creating an appointment booking module for my drupal 8 site, which is 99% complete, but I am one or two lines of code away from completing my module. The problem is using a database condition on an Count Expression that has been produced after the database has executed.

This is the code I have so far:

public static function dateavailabilty() {
    $select = db_select('bookingdateandtime', 'e');
    $select->addField('e', 'datecode');
    $select->groupBy("e.datecode");
    $select->addExpression("COUNT(e.datecode)", 'count');
    $select->condition('count', 2, '>');

    $entries = $select->execute()->fetchAll(\PDO::FETCH_ASSOC);

return $entries;}

But the page returns "The website encountered an unexpected error. Please try again later."

The following error report is produce in the Drupal Admin Error Log Messages:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S22]: Column not found: 1054 Champ 'count' inconnu dans where clause: SELECT e.datecode AS datecode, COUNT(e.datecode) AS count FROM {bookingdateandtime} e WHERE (count > :db_condition_placeholder_0) GROUP BY e.datecode; Array ( [:db_condition_placeholder_0] => 2 ) in Drupal\booking\bookingDTdatabase::dateavail() (line 51 of C:\wamp\www\modules\booking\src\bookingDTdatabase.php).

I need to use a condition to only produce results that has a count of more than 2. Obviously, if I cancel out this line "$select->condition('count', 2, '>');", drupal returns everything perfectly. So, using the condition doesn't work on data that has been added after execution.

How do I go about using the correct condition to apply to the Expression?

Many Thanks for reading and helping.


texts: Class Term missing sometimes when used in myTheme.theme

texts:
Using my theme file, I created a theme/template suggestion for taxonomies. I load a term object so I can know its vid. This was working and still works most the time. However, occasionally I get fatal errors. Which is a big deal. Similar to:

  Fatal error: Class 'Term' not found in myTheme.theme on line 4.

I am not sure why the term class isn't found, and only sometimes? Any suggestions on how to prevent this error?

Most of the time rebuilding the cache would fix this but not always.

myTheme.theme

<?php
function myTheme_theme_suggestions_page_alter(&$suggestions, &$vars) {
  if (\Drupal::routeMatch()->getRouteName() == 'entity.taxonomy_term.canonical' && $tid = \Drupal::routeMatch()->getRawParameter('taxonomy_term')) {
    $term = Term::load($tid);
    $suggestions[] = 'page__taxonomy__' . $term->getVocabularyId();
  }
}


texts: Generate match list from two different content type on price basis

texts:
I have two content type A & B in my application. The content type A have some attributes and a price attribute. The content type B have some other attribute and a price attribute.

Now say A have one item as A1 having price value X. And B has one item B1 that has price value Y.

I need to populate items of content A and B based on following price matching algorithm:

 (y- 20 percent of y) < X < (y+ 20 percent of y)

E.g:

content type A :
items price
A1 - 100
A2 - 200
A3 - 300
A4 - 110

content type B :
    items price
    B1 - 80
    B2 - 100
    B3 - 290
    B4 - 310

Final list :
    A1 - B1, B2
    A2 -
    A3 - B3,B4
    A4 - B1,B2

Can any one suggest me how to archive this in drupal 7.


texts:
Hello ive been messing about with drupa for 8 years now and im still YET to get a website to go live :( After about 10 reinstalls of my new website idea i was just about to go live and then i had a wee look in the database and ive noticed a load of tables prefixed dr_

I know some softulicious installs add this db prefix.

My site works well enough but the tables prefixed as per attached are  worry to me. Should they be a worry to me?

Can i fix it easily enough?

Thanks

ps all my other db tables are unprefixed which is the desired effect. All help appreciated as im close to startingmy site again from scratch :(

My electricity is about to get cut off for 12hrs so cant reply till then.


texts:
I am opening my registration form in ctools modal popup. I have applied custom module to get that popup.

Once user submit any form ajax window will be dismiss using  ctools_modal_command_dismiss().As window will be closed, status message will be printed using ajax_command_append('.ctools-use-modal',theme('status_messages').

But the status message get printed twice. I had tried to unset session messages. but it was not working.


texts: How to view all nodes that have the same relation to another node?

texts:
I'm using Relation for drupal 7 with views. There is a content type 'Review', which has a relation('is a review of') to Listings and Events. What I want is two blocks in the right sidebar on the Review pages, one which shows the reviewed item (which I already have working), and another which shows all other reviews of the same item.

I've tried to create a view which does this, using two joined relationships and a contextual filter, but can't make it work the way I want. The contextual filter is on the Nid of the original review, the first relationship is from the review to the reviewed item (relation target), and the second is from the reviewed item to other reviews (relation source). The second relation has a relationship to the first.

So far I can't make it show anything other than the title of the reviewed item, having tried various combinations of parameters.

Can anyone help with this?


texts: Attach a node to a menu link OR attach custom fields to menu links?

texts:
My client would like to add content to the top-level links in the main menu, in order to have "Featured" content that is displayed in the drop-down menu. They must be able to choose which piece of content will be shown, and which menu link it will be associated with. I figure I have two options:

1) Creating a "Featured in Menu" Content Type and adding a drop-down menu of top-level menu links as a field. The problem with this is I am not sure how to output a custom field that will list top-level main menu links. There does not seem to be a module currently that will achieve this, so I guess I would have to do it from scratch.

2) Adding custom fields to the main menu links themselves (image, title, node reference). I tried using the Power Menu module to achieve this, however every version of the module I tried gave SQL errors and broke the Edit Menu page. I'm hesitant to debug and pursue a fix for that module if it could end up being unstable.

I'm not sure which solution would be preferable but either way I'm stuck! I would very much appreciate some help on how to achieve either one of these solutions. (Or if I'm totally over-thinking this and there's a much easier way to achieve this, by all means please let me know.) For the record, I'm using Drupal 7.

Thanks!


texts: Simple-Dialog module not working for non-admin users

texts: actually i am showing a custom form in dialog, it seems correct when admin is logged in but when other user (some other role) logged in, it shows blank screen. On console i found "ReferenceError: jQuery is not defined".


texts: Error on saving a new product with a variable price feature D7 Ubercart and UC Var Price Module

texts:
I've got a site I converted from D6 to D7 about a year ago, and there is a small store built using Ubercart, and the products have a variable price feature on them via the UC Variable Price Module. I'm trying to add a new product to a client's store and we're using the variable_price module. For some reason, I'm now getting this error:

  PDOException: SQLSTATE[HY000]: General error: 1364 Field 'sel_options'
  doesn't have a default value: INSERT INTO {uc_varprice_products}
  (pfid, price_default, price_minimum, price_maximum, add_to_cart_title,
  amount_title) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 18
  [:db_insert_placeholder_1] => 15 [:db_insert_placeholder_2] =>
  [:db_insert_placeholder_3] => [:db_insert_placeholder_4] =>
  [:db_insert_placeholder_5] => ) in drupal_write_record() (line 7166 of
  /var/www/vhosts/mysite.org/web/content/includes/common.inc).

I don't know if it's a permissions error on the server, if it's a bug in the module, or what. in the past the module has worked fine without any trouble, and there are no updates for the var price module. Core is up to date, adn UC is 7.x-3.6.

I've looked, but I cannot find anything on this error anywhere and was hoping that someone here might be able to point me in the right direction. Am I missing something simple, or something broken?


texts: including js through module info file is not working

texts:
mymodule.info:

name = custom
description = custom module

core = 7.x
version 7.x-0.1

scripts[] = custom.js

created the file custom.js in the same folder as custom.module file
I have the $scripts variable in html.tpl.php
cleared all caches

Still cannot see custom.js in page sources. What else it might be?


texts: How to disable specific message displayed by contrib/core?

texts:
I am using the Disable Messages module to disable one of the message which is being displayed to the end user. The message is:

  Anonymous (not verified) has requested to be your Friend. View your
  pending friend requests to approve or decline.

To achieve this I have configured the module and written a regular expression to match a word from the message, But it seems to not be working.

Here is the code:

str.matches("(?i)(^|\\s+)(Anonymous (not verified))(\\s+|[.?!]$)");


texts: Define multiple variables in a custom module using hook_variable_info()

texts:
Im using the Variable module and need to define a variable with the type "multiple" in my custom module. I've been googled whole my day searching for any documentation or just an example and haven't found anything.

There are plenty examples how to set the variable in such type like: string, number, radios, but nothing about the "multiple" type.

My "multiple" variable should look like this:

How can I build this kind of variable using hook_variable_info() ?


texts: Webforms - Is it safe to allow users to upload attachments?

texts:
Is it safe to include a 'File' type field into a webform that allows users (anonymous or authenticated) to upload their files? After reading few articles on the web , it seems it makes a website vulnerable to hacking and malware.

I would like to know better about this so that I can make a decision on this and provide an answer for and against using it.


texts: Commerce - adding a product to a cart programmatically with custom price

texts:
I've got a line item type called 'Donation' which has a Product reference field.

Additionally, I have an instance of a Product type called 'Donation' with the SKU of DONATION_ONEOFF (pid=1), which has a price field set to $0.

What I want to do is decide at form submit time what the value of the line item is before I add it to the cart.

I have a test form, that when submitted, runs the following

function jam_test_donation_form_submit($form, &$form_state) {
    global $user;

    // Load the product with SKU DONATION_ONEOFF
    $product = commerce_product_load(1);

    // Try and set the price of the product before passing it.
    $product->commerce_price['und'][0]['amount'] = 22;

    // Create the line item from the product.
    $line_item = commerce_product_line_item_new($product, 1, 0, array());

    // Add the line item to the cart.
    $line_item_added = commerce_cart_product_add($user->uid, $line_item);
}

I was hoping that the new value (22) would display in the Cart, but it's still at 0 - even though the $line_item and $line_item_added objects show the correct field values of 22 and even a calculated total if I add more.

I assume this could be because the cart is referencing the product node directly rather than using the value it was given at commerce_cart_product_add time - is there something I need to call to update this?

I could create a series of products at fixed amounts but I need the ability to specify an arbitrary amount for donation as well.


texts: how do I change the number of nodes that the admin layout shows?

texts: The drupal 7 admin overlay for nodes seems to show 50 by default. How do I  a raise or change that number? I've googled for this information, but apparently I'm not guessing the right keywords, because I didn't get any relevant results.


texts: Bizarre Behavior with Markdown Filter and Cache Clearing

texts:
We are trying to allow Markdown input on long text fields for certain content types. It is proving difficult. Here is what I have done:

Installed Markdown filter module.
Added a new Text Format in Configuration -> Content Authoring -> Text Formats.
Edited the text fields on our "Lesson Plan" content type so that the user can select "Markdown" text format.

That should be everything I have to do, right?

BUT WAIT -- number 2 above is giving me very strange behavior!

In my "Markdown" text format configuration page, I can't see the Markdown option unless I first clear all the caches while I am on that page.
After I have cleared the cache, the Markdown checkbox shows up, and I can select it.
But after hitting "Save Configuration", the option disappears, and none of my content formats correctly when I try to select the Markdown text format.

Why is this happening? I don't know where to start looking!


texts: Migration: Combine Profile2 and file migration

texts:
I need to migrate profiles from an external database (not drupal) to Drupal 7. The target system uses Profile2 profiles. I already wrote the migration of all the "primitive" fields with the help of this cookbook, but I'm stuck with the profile images. They are only accessible via url (blah.org/blah/[user_id].jpg, so the migration needs to download them, and store them into a Profile2 profile field with type image. I know there is MigrateDestinationFile, but I dont see how to make the file<->image<->Profile2_field connection.

Has anyone done that before?


texts: How to create a Drupal calendar with 2 digits (day date format) instead of 1?

texts:
Does anybody have experience with adding a 0 before the numbers 1 to 9.
After this my calendar numbers should all have 2 digits: 01,02,03,04,05,06,07,08,09,10,11...

I have added a new PHP date format ("d") and that should give 01 instead of 1 (according to the PHP manual).

But I don't know how to implement this in my calendar.


texts: I can connect through this module, but i can't logout. I don't know how, but it doesn't clear the cache or something else. It still remembers my account details and relogin me again everytime.


texts: How to change label pass field on registration form

texts:
I need to change the password field label on the registration form. Name and Email I changed through hook_form_alter and password does not work. Help me!

$form['account']['name']['#title'] = 'Имя пользователя/Login';
$form['account']['mail']['#title'] = 'E-mail адрес/E-mail';


texts:
I use a small script that hides/shows a pane when a certain element is clicked.

(function($) {
Drupal.behaviors.luminary = {
    attach: function (context, settings) {
         $(".toggle-visible").click(function () {
         var targetselector = $($(this).attr('data-target-selector'));
         targetselector.slideToggle("fast");
      });
    }
}
})(jQuery);

It works well, but when an ajax event occurs, the pane will slide visible, and immediately slide invisible again. It goes down, and comes right back up. It only happens after an ajax event. Any ideas?


texts:
I need to output the url for field_slide_media in views-view-unformatted--carousel.html.twig.
I can output the entity ID using:
{{ view.field.field_slide_media.value(view.result[i]) }}

I would like to use it in

I can also output the whole image, but I need to be able to add an img class to it in the twig, so it's too much being output. I need the uri not the whole output.
{{ view.style_plugin.getField(loop.index0, 'field_slide_media') }}

gives me:


texts: Scheduled publishing timings, cron, cache clear

texts:
We have a site where users make extensive use of scheduler to schedule publishing of articles etc.

Site crons are run externally through drush and elysia_cron is installed to give fine-grained control of the actual Drupal cron schedule.

The scheduler_cron task is set to run every 20 minutes and the site's cron is triggered every 10 minutes (though most cron tasks are set to run hourly).

Articles appear to be published at the correct time. But there is often a problem with it not appearing in the specified view/block on the homepage for some time.

We have a Varnish external cache in place which correctly obeys the 30 minutes of the Cache-control: public, max-age=1800 header that Drupal is sending from Development > Performance options.

Even if you ignore Varnish caching for 30 minutes, it can be up to 1-2 hours before the article appears in the block on the front page.

Is there another cron in elysia cron that we need to be running more frequently to force Drupal's front page views/blocks cache to rebuild?
node_cron perhaps?

We don't particularly want to be running system_cron every 20 minutes (which I believe flushes Drupal's internal cache)

EDIT: Does the rebuilding of views/blocks in Drupal's internal cache require system_cron to be running frequently? This article seems to suggest it might https://www.drupal.org/node/2377201, or that an alternate mechanism of just clearing the page cache is required. I'm a bit surprised this isn't already dealt with within the scheduler, also you shouldn't need to expire the whole cache just to update one block on one page.


texts: How to perform an operation every time a node is viewed?

texts: When writing a module, how can I perform an operation every time a node is viewed by a user?


texts: How to add user info along with address info in a single form using 2 content types?

texts:
I have a content type 'Person', one field of which has a entity reference to a content type 'Address'.

I would like an anonymous user to add their information along with their address in a single form using these two content types. What should I use to do that?  Do I have to code it or does a module or a combination of modules help me?

Also similarly, for a logged-in user, I would like them to be able to edit their information which was previously saved. How do I do that?

Notes:

I would like the anonymous users to register and also provide a few more pieces of profile information. Of course, I do limit what else they can do till they get approved by the administrator.
I could capture the address information in the same content type but the reason I am thinking of separate content type is because two people can have the same address and I don't want to have redundant information. It would also provide me a way to figure out people who live in the same household. Also, I don't want to lose the address if someone moves and decides to update their address. It looks like I can add/edit two different nodes in the same page. If not reference, how? Do I have to code for it or there are modules that can do it?
My choice of 'address' as an example was a bad one. My broader question is: Given two tables with one of the fields as a foreign key into the other, in Drupal, how can I create, update, delete corresponding rows in the two tables at the same time. The interface being user friendly UI for end user. Does I have to do this in code, or is there a single module or a set of modules that can be used to accomplish this? I am not looking for a full solution as much as pointers in the right direction.


texts: I have a form using #states which is great, but once a hidden field is made visible I would like the user to be able to hide it again by clicking a close button, rather than deselecting the original checkbox - hopefully by triggering the original states function. Is there a Drupal way to do this?


texts: Installed D7 with Minimal profile and root user do not have any role set to it. How to create a locked role for root?

texts:
Now I can create only simple role which can be easily edited and deleted. I need a role for root user (user ID 1) for some other modules that requires selecting a role.

Now installing minimal profile of Drupal my root user is roleless. Don't know how to call it.

In overall I need something that the root user would be undeletable/uneditable by any other admin who has power to edit users and permissions and roles.


texts: How to pass a literal string into drush config-set

texts:
I'm currently attempting to configure the ClamAV module via drush config-set. When using the executable mode, the module allows us to specify command-line options to run when the ClamAV executable is triggered.

My attempt to do so is:
[root@localhost html]# drush config-set clamav.settings mode_executable.executable_parameters '--max-filesize=4095M --max-scansize=4095M --max-embeddedpe=4095M --max-htmlnormalize=4095M --max-htmlnotags=4095M --max-scriptnormalize=4095M --max-ziptypercg=4095M --pcre-max-filesize
=4095M' --y

Unfortunately, I get the error:
Unknown option: --max-filesize.  Seedrush help config-setfor available options. To suppress this error, add the option --strict=0.

Using sh/bash, how do I write this command as to pass in the executable parameters as the setting (a literal string), not as options to drush config-set, as is currently happening?


texts: Can I have both Language and Country path prefixes?

texts:
On our site, paths are all prefixed by language and country. For example:

http://example.com/en/us/about

In Drupal 7, a previous vendor implemented this by using the Persistent URL module, which rewrites all on-page URLs to include the prefix of your choice. PURL was used to add add the country as a prefix to each path. However, it fails when URL Prefix language negotiation is turned on, requiring a core hack to locale.inc to make both work together to avoid the language negotiation from stomping over our prefix:

@@ -462,7 +462,7@@ -462,7 +462,7 @@ function locale_language_url_rewrite_url(&$path, &$options) {

       case LOCALE_LANGUAGE_NEGOTIATION_URL_PREFIX:
         if (!empty($options['language']->prefix)) {
-          $options['prefix'] = $options['language']->prefix . '/';
+          $options['prefix'] = $options['language']->prefix . '/' . $options['prefix'];
         }
         break;
     }

We are rebuilding the site in Drupal 8, and this is one of the things we need to figure out. Obviously, we'd like to avoid having to reinstate some kind of core hack, but by the same token, we can't change the URL structure due to client requirements.

Is there any way we can pass and preserve both language and country information via path prefixes?


texts:
I have a content-type that has an imagefile and a url; I want the url to wrap around the image. So I'm trying to make a viewtemplate based on the information in Theming information

based on this description

/**
  * This template is used to print a single field in a view. It is not
  * actually used in default Views, as this is registered as a theme
  * function which has better performance. For single overrides, the
  * template is perfectly okay.
  *
  * Variables available:
  * - $view: The view object
  * - $field: The field handler object that can process the input
  * - $row: The raw SQL result that can be used
  * - $output: The processed output that will normally be used.
  *
  * When fetching output from the $row, this construct should be used:
  * $data = $row->{$field->field_alias}
  *
  * The above will guarantee that you'll always get the correct data,
  * regardless of any changes in the aliasing that might happen if
  * the view is modified.
  */

I made views-view-field--my-view--block--field-image.tpl.php to look like this:

$url = $row->{$field->URL}
?>
<a href="<?php echo $url; ?>" target="_blank">
  <?php print $output; ?>
</a>

But I'm getting Cannot access empty property on the $row->{$field->URL} line. Can I only access the image field from within the template for the image field? I was looking at views-view-fields--my-view--block.tpl.php but not sure how to access things from in there


texts: How to get notified when a user is blocked?

texts: Is there a way to get notified when a user is blocked ? like a hook in user module or ? or there are another way ?


texts: Remove the cache for a particular Twig file

texts:
I'm showing the name of the currently logged-in user in header, using \Drupal::currentUser()->getUsername(), but it's showing an already cached  page. I know I can disable the cache for a particular page using \Drupal::service('page_cache_kill_switch')->trigger(), but this won't work with the header.html.twig file.

How can I achieve it without affecting the performance?


texts: Unable to retrieve checkbox values from a template file

texts:
I have created a checkbox option for a field.

Category

One
Two
Three
Four

This is the code I am using.

    {% for key, item in content.field_room_category if key|first != '#' %}
         <li>{{ item }}</li>
    {% endfor %}

In the <li> tag, I get all the checked values, but I also need to check which values have been selected.

For this, I tried {{ item.value }}, {{ item.content }}, and {{ item['#title'] }}. None of them worked.

Is there any way to get all the checkbox items with their values?

I want to achieve something similar to the image above. If the item is checked, I show an icon; if the item is unchecked, another icon will be shown.


texts:
For some reason I cannot save the value of my date_popup field (comment_date) to mysql database.
I need to use default value from existing field (field_due_date6) and store the new value to this field.
So I do the following:

function custom_form_alter(&$form, $form_state, $form_id) {
  $form['comment_date'] = array(
      '#date_format' => 'Y-m-d',
      '#date_year_range' => '0:+1',
      '#type' => 'date_popup',
      '#weight'=>1,
      '#datepicker_options' => array('minDate' => 0),
      '#default_value' => $form['#node']->field_due_date6['und'][0]['value']
    );
}

Then I'm trying to submit it to database:

function custom_support_comment_submit($form, &$form_state) {
  $node = node_load($form_state['values']['nid']);
  $node_wrapper = entity_metadata_wrapper('node', $node);

  if($form_state['values']['comment_date']) {
    $node_wrapper->field_due_date6->set($form_state['values']['comment_date']);
  }
  $node_wrapper->save();
}

But when I click Submit button I got the error -

EntityMetadataWrapperException: Invalid data value given. Be sure it matches the required data type and format. в функции EntityMetadataWrapper->set() (строка 122 в файле Z:\home\dd1\www\sites\all\modules\entity\includes\entity.wrapper.inc).

Could you please specify what I'm doing wrong?


texts: How we can make weekly calendar block with ajax?

texts:
How we can make weekly calendar in drupal 7 module same as attach screenshot?

My R&D

I am using jQuery week calendar (https://github.com/themouette/jquery-week-calendar) .


texts: How can I obscure what I am using to run my site?

texts:
Is there anything I can do to prevent somebody from knowing my site is using Drupal by looking at the source code of the front page? I am referring to people who scan sites using software that detects the software used to run the website to be able to attack it using any known weak point.

If it is not possible to completely hide the fact that the site is using Drupal, is it at least possible to confuse them (e.g., by aliasing the node pages with URLs like http://example.com/servlets/<node-id>.jsp)?


texts: RewriteBase /folder issues on IIS for broken images

texts:
I have a Drupal 7 site hosted under a subdirectory say http://example.com/drupal. I am using IIS and SQLSRV. But all the images could not be loaded on the site as these images pointing to http://example.com/sites/default/files...
I have added $base_url in settings.php but .htaccess could not be recognised by IIS. When I try to import rules from .htaccess, it does not allow RewriteBase /drupal rule as it is not supported by IIS.

Please help me out in this scenario. What could be the equivalent rule of RewriteBase /drupal?


texts: Show all taxonomy terms on taxonomy term page

texts:
Though I saw a lot of posts on views & terms, this is new it seems.

I have a set of 1-level vocabularies. When user is on term page

mysite.com/vocabulary1/term1/

He should see also 'menu' - list of all terms of this vocabulary.

How can it be achieved?

P.S. I think that it's about context filters but I can't figure out how!


texts: How to give class name to no results behavior in views

texts:
I added price column first to view > hide it. I added special price column to view > in no results behavior i added price field token as below:

[field_price]

How to give a css class name to the 'no results behavior text'?

Thanks,

D


texts: How to display custom field label added by CCK in node.tpl file?

texts: I have a new content type called hotel and have added a field called timing. For display in node.tpl.php, I can use field_view_value() but how do I get the value for the label. I know I can use the $content array, but is there a standard Drupal way or function to achieve it?


texts: How to call form function in menu callback in drupal7?

texts:
I have one menu and two functions that want to call on same menu. What I am doing is, in hook_menu page callback i am calling a function and in that function i am calling another function.Means, calling function inside a function in page callback of menu.
Now my PROBLEM IS, my secong function is a form.

$items['component/%/edit'] = array(
    'title' => 'Edit Component item',
    'page callback' => '**component_list_edit**',
    'page arguments' => array(3),
    'access arguments' => array('administer users'),
    'file' => 'popup.inc',
    'type' => MENU_CALLBACK,
  );

My Page callback:

/**
 * ajax popup edit function : ctools implementation
 */
function component_list_edit() {
ctools_include('modal');
  ctools_modal_add_js();
  return _mid_component_make_link('Title').component_type_select_list_form($form, $form_state);
}

It is giving "ARRAY" as an output. no form m getting.
I also tried to return drupal_get_form('component_type_select_list_form');
This is also not working.


texts: How do I filter only the root terms in a vocabulary in a view?

texts:
I have have a vocabulary structured as so:

Root Alpha

Term Alpha 1
Term Alpha 2

Subterm Alpha 1

Root Beta
Root Gamma

Term Gamma 1
Term Gamma 2

How do I filter the view to show only the root terms of the vocabulary?
Currently my view is displaying the root terms as well as the children (Term * *)

Going forward from that I would like to pass the argument 'Root Alpha' (or its tid, or whatever from a context) and then have it filter to only 'Root Alpha's direct children. (Term Alpha *). Filtering to a depth any further than that would be a bonus.

I can get it to work if I put all my terms in one root term so that the vocab becomes:

True Root

Root Alpha

Term Alpha 1
Term Alpha 2

Subterm Alpha 1

Root Beta
Root Gamma

Term Gamma 1
Term Gamma 2

I'm not sure which vocab structure is more correct, writing this made me realise I have some reading to do apart from figuring this out with views.


texts:
Views has a minor bug that causes this particular part of a query to be "AND" when it should be "OR." With this being Drupal 8, figuring out how to alter that value is difficult. For one, it's nested inside a \Drupal\Core\Database\Query\Condition. And the part I need to change is the '#conjuction'.

Does anyone have any advice on how I would target that? Oviously just working with the xdebug path does not work.

$query->where[2]['conditions'][0]['field']->conditions['#conjunction'] = 'OR';


texts:
I have a view created from a node with images.
All images are in one field, image field content:afbeeldingen (images)

I have created my view 1 image is one page. I get the next link and previous below my image but now i want to link add a next link to my image in my view how can I do this?


texts: How can I get Slick Slider to display the images?

texts:
I have a "test" content type with a title, body, and a media entity field that allows for multiple images. I installed Slick Slider 2.2. I mostly followed the steps outlined here: https://www.ostraining.com/blog/drupal/how-to-use-the-slick-module-in-drupal-8/.
I configured the field to use the Slick Media formatter.

When I add a node with the "test" content type and add two images in the image field, the next/prev buttons appear but I can't see the images. See video of slider animation.
I tried this on two different content types and I also tried using layout builder and got the same result.
I don't see any console errors.
I am running:

Drupal: 8.9.3
Slick: 2.2


texts: How to redirect based on matching a node field?

texts:
This question is somewhat similar to How to redirect based on views results? which I think gives me part of the answer I want.  Basically my situation is this:

I am migrating from an old xoops system which had its own set of content ids.  I want to seamlessly make the switch to this new drupal system, meaning the old urls work, but redirect to their new pathauto equivalents.

By way of explanation, say the old url was /view.php?docid=6252 and the new address should be /pubs/capacity_building_climate_change_impact_assessment which has been generated by pathauto.

I can do a redirect at the web server level to get from /view.php?docid=6252' to/pub/6252`.

I have brought over the legacy document id, as a field on the new nodes, and I have a view working where I can visit /pub/6252 and get the right content. Now I want to make sure that the pathauto url is the definitive one url to rule them all for that particular node. How can I redirect to the proper url based on that url segment matching the legacy document id field in a node. It would be nice if it could be done without bringing all of the overhead of a views lookup into it, but if redirecting from that view is the best way, so be it. Hopefully I can aggressively cache that view since that data should almost never change.

I downloaded the Redirect module, hoping that it provided some of that, especially since it claims integration with the views api, but I didn't immediately see anything helpful there, and there doesn't seem to be any documentation for it.


texts: How to display content of a link in a tooltip on hover

texts:
I need to display the content returned from a link in a tooltip on hovering over that link.

I know about the some jquery plugins, which displays inline content, But didn't come across any plugin which satisfy my requirement.

If any one know any tooltip plugin, which loads the content from a link and displays it on hover, please help me.

Thanks in advance for any help,


texts:
I use EnvVars (vhost) to set my MySQL settings so I can have cross-server settings.php file without having to update it 3 different times.

I am wondering if there is a way to get drush to do one of the following.

Read the EnvVars from the VHOST (in which case where so I find the Drush database config gathering stuff).
Override the MySQL settings for pm-update


texts:
solr indexing has suddenly stop working.

Here is all the detail which i got from system admin

while running cron we are getting message during run cron.php through command

PHP Notice:  Undefined index:  REMOTE_ADDR in /var/www/XXXXXXX/includes/bootstrap.inc on line 1670
PHP Fatal error:  Exception thrown without a stack frame in Unknown on line 0

where should i look first and what are the possibility for apache solr indexing to stop suddenly.


texts:
I have three content types A, B and C.

The content type A has two entity reference field (I'm using the Entity and Entity Reference modules for that).

Content Type A

Field 1 (refers to entity type C)
Field 2 (refers to entity type B)

Content Type B

Field 1 (refers to entity type C)

I'm also using the Reference Field Option Limit module to limit the Field X.

  This module allows reference fields of several types to have their
  widgets' available options limited by the values of other fields in
  the current entity.

Everything is OK while creating the nodes manually.

I'm creating the content type C's, then creating the content type B's and referencing these to content type C.
Then, I'm creating the content type A and first select the Field 1 (refers to entity type C) and then the options of Field 2 limited according to value of Field 1 and then I select.

But... while creating the nodes with the Feeds module I couldn't limit the Field 2.

My question: How can I limit the Field 2 according to value of Field 1 while creating the nodes via Feeds module?

Note: What I'm trying to do is detailed in my question "How to create an article -> issue -> magazine hierarchical structure with Entity Reference?".


texts: How do I make drupal check for similar content?

texts:
Im using drupal 7 and Im looking for a solution or a module that when a user goes to submit a piece of content they are presented with a "similar content already submitted" list after they enter a title or more specifically a link.
I want to reduce similar or duplicate nodes on my site. I currently use the link module and I allow users to submit links to my site. Occasionally a user will submit a link that has already been submitted by someone else and I want to help alleviate that. Thanks.


texts: Do any of you have experience with Panels & Floating column? I am creating a template site where I will have side bars on the left and right side. But since this is a template site, sometimes I will not have content in the left and or right and would like floating columns so the content adjust properly.


texts: Devel : what kind of information devel_boot, devel_shutdown and php tweak describes?

texts:
I have a problem on my website about slow query and many 324 errors.
I tried to resolve them but as i'm new in Drupal i have a lot of difficulties to understand some stuff.

(The website site i'm making actually have 102 modules install, 9 differents roles and a lot of permission on fields, node etc. We don't have a dedicated server so it's very slow and not optimize)

So i tried to do my best and i'm actually working with devel to see if i can do something maybe.

I read this about devel_shutdown on drupal.org but as a beginner i'm not really sure to understand the meaning and the purpose of this function.
So i would like to know more about some function used by devel like:

devel_boot
php peak
devel_shutdown

(devel_shudown = memory_allocated per user? and php peak = memory allocated by the server?)

As you see in my picture, i have a devel_shutdown greater than 41mo (sometimes more than 51mo). For people who worked on Drupal since many years do you think it's normal for a drupal site or do i have to be worried about that?

Thanks,


texts: custom field widget - how to add dashes to children, like core

texts:
In Drupal 8, I have a custom compound field module, containing a select type field. It gets values from a taxonomy. I'm trying to figure out how to hook/use the same 'add a dash per depth level' function that core uses on hierarchies in a select field.

I'm snooping around code, but not finding where/how. I hoped I could find it in  the form.inc file, but maybe I just don't know what to look for or how to use it.

EDIT: For reference, here's a pic of what I mean:

If it matters, here's what I've got for for this field, within the module widget:

$plant_parts = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree('plant_part');
$parts = array();
foreach ($plant_parts as $plant_part) {
    $parts[$plant_part->tid] = $plant_part->name;
}

$element['plant_part_described'] = array(
    '#type' => 'select',
    '#empty_option' => 'Select...',
    '#options' => $parts,
    '#title' => t('Plant Part'),
    '#size' => 1,
    '#prefix' => '

',
    '#suffix' => '	',
    '#required' => FALSE,
    '#default_value' => isset($items[$delta]->plant_part_described) ? $items[$delta]->plant_part_described : NULL,
);


texts:
I have a custom view that display several email address.
How I can use these addresses to send it an email with a rule?


texts: Class declaration error when using ResourceBase

texts:
I tried following this guide: https://www.drupal.org/docs/8/api/restful-web-services-api/custom-rest-resources for the REST API.

However, when enabling the module, I get:

  Fatal error: Cannot declare class Drupal\my_module_rest_api\Plugin\rest\resource\MyModuleResource, because the name is already in use in [PATH]\modules\my_module\src\Plugin\rest\resource\MyModuleResource.php on line 0

It seems like it could be a simple class naming error, but I really tried following the guide to a tee. Here is MyModuleResource.php in full:

<?php

namespace Drupal\my_module_rest_api\Plugin\rest\resource;

use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;

/**
 * Provides a REST API Resource
 *
 * @RestResource(
 *   id = "my_module_resource",
 *   label = @Translation("My Module Resource"),
 *   uri_paths = {
 *     "canonical" = "/my_module_rest_api/my_module_resource"
 *   }
 * )
 */
class MyModuleResource extends ResourceBase {

    /**
     * Responds to entity GET requests.
     *
     * @return \Drupal\rest\ResourceResponse
     */
    public function get() {
        $response = ['message' => 'Hello, this is a rest service'];
        return new ResourceResponse($response);
    }
}

Here is the rest.resource.my_module_resource.yml file:

id: my_module_resource
plugin_id: my_module_resource
granularity: method
configuration:
  GET:
    supported_formats:
      - json
    supported_auth:
      - basic_auth


texts:
This is my layout http://www.gorgeoushentai.com/content/saber-marionette-j-2
If you look at the genres section it shows them as a div class and I want it as a < li > . How can I make it a list format? I can't find where it's printing the terms in the templates. This is for drupal 7


texts: How to include PHP code in welcome email?

texts:
I need PHP (for some logic) inside the welcome email, the welcome email structure is defined in admin/config/people/accounts (in the text box)

How can I place PHP code there? I tried to put some PHP but I only get a blank email. Or if I can`t execute PHP code inside the email box what module can I use to do this?


texts: how to open drupal login and signup form on modal form.

texts:
I just want to open login form in modal box as per semantic ui framework http://semantic-ui.com/modules/modal.html. I just want to use this framework. Is this possible with theming or custom module is require for this.

Any help would be appreciated.


texts: How to print a view in node.tpl.php only if it's not empty

texts:
Views can be printed in tpl.php files with this code:

<?php print views_embed_view('myview','block_1'); ?>

However, if that view is empty, the view block code will be printed anyway:

Is it possible to check if the view has any results first and then print it if it does? E. g.:

<?php if ($view_myview,block_1): ?>
<?php print views_embed_view('myview','block_1'); ?>
<?php endif; ?>


texts: Drush installed in local directory but command not found?

texts:
I know that Drush is a huge time saver so I'm trying to get familiar with it but I keep getting

  command not found

error after installation. I've required and removed Drush a couple of times just to make sure I'm doing this correctly.

Here's what I did:

$ cd mydrupal
$ composer require drush/drush

After I run the above command many things install:

  Using version ^9.3 for drush/drush

  ./composer.json has been updated

  Loading composer repositories with package information

  Updating dependencies (including require-dev)

  Package operations: 57 installs, 0 updates, 0 removals

  Installing... (many things download and install (100%))

And I end up with this:

  Writing lock file

  Generating autoload files

    Drupal\Core\Composer\Composer::preAutoloadDump
    Drupal\Core\Composer\Composer::ensureHtaccess

Then I get my command line prompt and I run

$ drush status

and I get this:

  -bash: drush: command not found

Any ideas?


texts: How to set the sizes for image thumbnails

texts:
When I am editing "Image" content type there is an option:

Where can I changes sizes of these previews? And regenerate the corresponding pictures?


texts: Conditional fields not working with hierarchical select module

texts:
Case: I am using the Hierarchical Select module for allowing users to choose taxonomy terms from a particular vocabulary. Based on the chosen terms (deepest level), I want to display a field using the Conditional Fields module.

Currently, the Conditional Fields module is working for simple select widget. But not for Hierarchical Select. Is there any hook or patch available?


texts:
I have 8 articles: Article 1 (Gaming), Article 2 (Local News), Article 3 (World News), Article 4 (World News), Article 5 (Gaming), Article 6, Article 7, Article 8.

In a view I would like to group the articles by: "News," "Gaming," and "Other." Combining the world and local news under one category, and moving anything that doesn't have a category to "Other." I didn't want to create a new vocabulary for just this view. I tried to accomplish this using the group by field, but I can't figure out how I could accomplish this using that method.


texts: Added menu link not showed in menu configuration

texts: I have a very weird problem. If I add a new menu item, I can do it without any error in the menu configuration page, but the item isn't showed in the menu in this page neither in the menu. If I check menu tables in mysql, the items are added. If I try to add another item, I can create a child of the other in the menu structure, but the item isn't showed.


texts: Show table header in views (Bootstrap table)

texts: I need to show header table in a view (bootstrap table) like: title, image, descripton, etc. But i can't find the option. I compare this view to an old one and everything seems normal. Any idea? Thanks!


texts: User registration form validation in drupal 7

texts:
Drupal 7 comes with the built-in user registration form (user/register). I use this form for new users to register. Which is quite obvious. Now the problem is, and I find it hard to believe that it isn't there, I need some validating.

When a new user completes the form and hits submit, the account is being created. Good.

But: when a user completes the form and hits submit, but the email address or username is already in use, the pages just reloads and the user is not being created, which is good, but theres no warning on what he has to change in the form what so ever.

I find it strange that this is not standard.

Could anyone provide me some help? I really have no clue...


texts:
I have couple of polls, I want all of them on one page.
Like this:

Any clue?


texts: How to enable Database search & autocomplete live search?

texts:
Found a great article of how to enable live search on drupal 7 http://www.stevepolitodesign.com/blog/create-live-search-results-search-you-type-drupal

But seems all modules are not yet available for drupal 8. Can anyone show some  light on this please of how a similar thing can be done on drupal 8?


texts:
We are transferring our old data to Drupal 8. Our users' password has been encrypted by MD5 and Drupal 8 hashing system works with SHA algorithm.

Which file should I edit to change the hashing system to the simple MD5?

We are aware of risk, but it has been decided.


texts:
i am using drupal 7

i am trying to add a button within form and successful.  now i want to call a function when someone click on that button

here is my code.

function clicktell_form_alter(&$form, &$form_state, $form_id) {
    //print_r($form);

    if($form_id=='user_register_form') {
        $form['add_button'] = array(
            '#type' => 'button',
            '#value' => 'Verifynow',
            '#ajax'> array (
                'callback' => '_udr_ajax_handler',
                'progress' => FALSE,
            ),
        );

    }
}

function _udr_ajax_handler($form, &$form_state) {
    echo "hello "; exit;
}

But this is not working fine.
Does anybody tell me how to solve this
Thanks


texts: Generating Main content nodes based on SQL data (associated with users)

texts:
This is the first fully fledged website outside of a blog that I've ever configured, so please forgive any glaring errors I make in my logic.

My website is a ranking website: people create a profile for their website with an image, title and description, and users (who have separate 'voter' profiles) vote based on the website they visit. Voter and Websites are distinguished by a field.

All of the other profile details (image, desc ect.) are also stored in fields, and votes are recorded with an SQL table.

My website then displays the image and description of each website, in order of descending number of votes. (a ranking)

This is where I encounter my issue. In order to display these values properly (scrolling through pages) I need to display them as nodes. I have no idea how to generate these nodes.


texts:
Background

I have a Drupal 7 module that is making an AJAX call via jQuery.ajax() to a menu callback that I've defined in my module. The purpose isn't to return markup, but rather just a single string value.

This is all working as it should, but the method by which I'm passing the value back to jQuery seems messy to me.

I'm using:

// $condition is a simple string value.
print($condition);
drupal_exit();

My Question

Is there a cleaner, more standardized way of doing this? This just feels hackish and messy to me.

Thanks, Drupalers!


texts: How to print fields value in views-view.html.twig in drupal 8

texts:
How to print fields value in views-view.html.twig
I have created a views-view.html.twig file for my view slider_3.
The template name is 'views-view--slider_3.html.twig'
The view formatting is done by this template, but I need a field is come at begging position of the view:

<div class="slider-3-main">{{ rows.required_field }}
<div{{ attributes.addClass(classes) }}>
  {{ title_prefix }}
  {% if title %}
    {{ title }}
  {% endif %}
  {{ title_suffix }}

How can be the field will written to display at {{ rows.required_field }}


texts: Workbench moderation allowing a role to unpublish content?

texts:
I'm using Workbench Moderation on a new D7 site build.
All is great in terms of workflow and I think I have the permissions near perfect, but I can't for the life of me seem to grant my 'content approver' roles the ability to unpublish content.

If I log in as a administrator (Drupal default role) I can see the option to 'unpublish' appearing, but I can't spot a particular Workbench / Drupal permission to grant to allow this permission for lower roles.

Anyone have a suggestion?


texts: Field collection translation structure: entity translation vs. node-type translation

texts:
I have a site with field collections and the entity_translation module that saves field collections after the following format:

When I save a new translation via the edit page, Drupal adds a new parent field collection row in field_data_field_parent_fc (en, en-gb, en-au). Each parent field collection points to a different text field (en -> 100, en-gb -> 101, en-au -> 102, etc.)

This is want I want to happen. There should be one row in field_data_field_parent_fc, containing language und, which points to a single text field (100). Then in the text field table, there should be a translation for en, en-gb, and en-au.

What I want is something akin to entity translation as opposed to node translation. Is there a setting for this, within the entity_translation module or otherwise?


texts:
i'm triying to create an custom entity, to store data i'm creating a schema through BaseFieldDefinition (or some near). The problem is that some fiels of type datetime are created in the database with type Varchar(20). The field definition is below:

        $fields['created_at'] = BaseFieldDefinition::create('datetime')
        ->setLabel(t('Fecha de creación'))
        ->setDescription(t('Fecha de creación de la empresa en el sistema'))
        ->setSettings([
            'datetime_type' => 'datetime'
        ])
        ->setDefaultValue(CURRENT_TIMESTAMP);

I'm triying set the default value with and without ", thanks in advance.


texts: How can I add items to the Admin Toolbar?

texts:
In Drupal 8, I want to add a menu item to the Admin Toolbar with a submenu, with different links.

How can I do it?


texts: How to generate a downloadable CSV file from a View table?

texts:
Is there any way to generate a downloadable CSV file from a View table?
If not, how can I generate a CSV file in Drupal 7?


texts: How to generate the function stack trace of the last request made?

texts:
Is there a module that can essentially show you the function stack trace of the last request made?

Say I have a form that I submit.  After the page loads with the result from the request, I would like to see a list of all the functions that were called, start to finish, that resulted in the currently loaded page.


texts:
I want to create a MySQL View in hook_schema() for a module I am developing.

Does anyone know how to do that?


texts: Hook into update/install process callback (Update manager) - providing a custom message after installing a module from URL

texts:
After installing a module from a given URL (on admin/modules/install), I can see the following messages:

So it outputs 3 links in the "Next steps" list, but I would like to hook into the update callback process, extend this list, and provide another link which points to a callback page defined by my own module, where I can enable the module immediately. I don't need help for the latter, only for the way to hook into the process of altering/extending the messages in the result.
After hooking into to the process of generating the output (hooking into the callback process), I will need to know the module's machine name.

This is what the expected result would look like:

OR

OR

What would be the appropriate way to provide custom messages in the update callback?

The "Installation was completed successfully." text is defined by update_authorize_install_batch_finished() in modules/update/update.authorize.inc (and gets into $_SESSION['authorize_results']['page_message'] as an array), and the "Next steps" list is provided by ModuleUpdater::postInstallTasks in modules/system/system.updater.inc.


texts:
I try to construct a field and I wonder how should I implement this process via Field API:

User enter some data to the field. Let's say, the data entered is a node title.
User hits the "Save" button, but what is actually saved in the database is the node ID of the node whose title has been entered by the user.

Something like this happens with the Entity Reference module: I enter the title of the entity (as I 'm getting assistance through autocomplete), but the module saves target_id, not the title I have actually entered.

How can I gain such behavior?


texts:
I am looking for module that would let users of a site save nodes as Favorite, so that these nodes can be found back later via a "My favorite" interface.

Has anyone heard about such a module ?

THanks all in advance


texts: Dragboxes in a page (Dashboard kind of display which is clickable)

texts:
I'm creating a new site and is fairly new to Drupal.
I had some research into sites and liked "http://churchofengland.org/" front page.

They have aligned the front-page with dragboxes.
How can I do similar in Drupal?


texts: How to include phpExcel library in controler?

texts:
I have written composer.json in my module, after running this file, I got all phpExcel dependcies included. Structure formed is like

vendor
--phpoffice
---phpexcel
----classes
----phpexcel.php

I am setting classes to psr-0 level for autoloading but I'm not able to call PhpExcel class in my controller.

Any idea about this?

@edit

I have read below articles, but can't find satisfactory solution for this issue.
I have implemented below described approach, but still can't figure out whats exactly I'm missing.

  install https://www.drupal.org/project/libraries in
  project/modules/contrib folder.

  Install https://www.drupal.org/project/phpexcel

  Installed library from https://github.com/PHPOffice/PHPExcel and place
  it in "libraries" folder at root.

Now when I went to enable my modules it is simply giving me error:

  The website encountered an unexpected error. Please try again later.
  Error: Class 'Drupal\libraries\StreamWrapper\LibraryDefinitionsStream'
  not found in
  Drupal\Core\StreamWrapper\StreamWrapperManager->addStreamWrapper()
  (line 156 of
  core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php).

If I include the phpexcel library using composer, it get included. But the issue is.
 This library has no namespaces. And If I call PhpExcel class in my controller,like

use PhpExcel/PhpExcel;

$spreadsheet = new SpreadsheetReader($file_path);

It gives error class not found.

How can I read excel file using phpExcel library?


texts: How can I add a "Back to Search" link to user profiles?

texts:
I have a view with exposed filters that allows users to search for other users on my site.  The view displays users' profile pictures, and clicking a profile picture takes one to the relevant user's profile (put together using Panels).

I'd like to display a "Back to search results" link on the user profile whenever someone clicks on the link (picture) in the view and visits the profile.  How might I go about doing this?

I'm using D7 with Panels and Views 3.


texts:
I've found about a dozen other people who have experienced this problem, but none of those fixes have helped me.

I have written a module that simply loads a Javascript file into the page. This part of it works fine. However, I cannot access any variables from PHP because the console keeps telling me that Drupal.settings.mymodule is undefined. The top of my js file looks like this:

(function($) {
  Drupal.behaviors.mymodule = {
    attach: function (context, settings) {

      // $(document).ready(blahblahblah...

    }
  }
})(jQuery);

I've also tried ending it with }(jQuery)); as I've seen it suggested both ways.

I have my drupal_add_js function running from hook_form (I've also tried hook_menu) in my .module file, but that doesn't seem to be the problem. Here is where it currently is:

function mymodule_form($form, &$form_state) {
  $form['mymodule_safe_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Safe path'),
    '#default_value' => variable_get('mymodule_safe_path', 'mymodule'),
    '#description' => t('...'),
    '#required' => TRUE,
  );

  $form['mymodule_status'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn on mymoduleification'),
    '#default_value' => variable_get('mymodule_status', 0),
    '#description' => t('...'),
    '#required' => FALSE,
  );

  // Note: I realized mymodule_status is not properly assigning the variable. I was keeping it as an easy-to-read string for debugging purposes.
  drupal_add_js(array('mymodule' => array('mymodule_status' => 'mymodule_status')), array('type' => 'setting'));

  return system_settings_form($form);
}

For some reason it seems that mymodule isn't making its way into Drupal.settings at all. I say this because without even referencing a specific setting, just trying to log Drupal.settings.mymodule to the console results in "Undefined."

Any thoughts as to why this might be happening?


texts: How do I alter a field content before saving the form?

texts:
I have two fields, Transaction type and Amount. I would like to change the value saved by Amount depending on Transaction type.

e.g.

Transaction type == deposit , amount is a positive value.
Transaction type == withdrawal, amount is a negative value.
Transaction type == tax , amount saved is a preset percentage of the value input.


texts: Single document, multiple filetypes for download: how to manage?

texts:
I want to upload/attach several documents to a book node. Each document will be offered in a number of file formats, for example:

Report2010.pdf
Report2010.rtf
Report2010.doc
Agreement11.pdf
Agreement11.rtf
Agreement11.doc

Given this, in order to:

Offer a sensible upload interface (like FileField) that allows an unlimited number of files to be uploaded.
Present these files for download, for example:

Report 2010 - Download as: pdf, rtf, doc
Agreement 11 - Download as: pdf, rtf, doc

Is there a robust way to relate the different file formats for each document to each other? By robust, I mean something that (for example) doesn't rely on the user naming the files in a particular way for it to work.


texts: How to show a image preview of the files in IMCE file browser?

texts:
I'm using the the imce module with the ckeditor module.

When you open the imce file browser to select/upload a image you can see a list of the images you have in your server.

This list shows the name for every image.

Is there a way to make this list to show a image preview of the image (a thumbnail)?

Look my capture:


texts:
I have created the view “my blog entries” which should be displayed on a user’s profile page. In terms of displaying not all but only the currently viewed user’s blog entries I have added the Contextual Filter called Content: Author uid.

In a second step I created a block, which is only present on listed pages: “profile/*”

So now I can go to a user’s profile page (root/profile/3) and the block is enabled, the view is loaded and will load only entries from that very user.

In terms of improving SEO I used URL-Aliases to get something like this: root/profile/the-actual-user-name

For obvious reasons my view won’t work anymore. How to get it work again without the user-ID in the URL?


texts: block->subject set when using one theme, but not when using identical copy of the theme?

texts:
I have a theme (based on zen). I made a copy of the theme, replacing all the references to the theme's name in the files. I switched to the new theme and copied all theme settings in drupal (drupal 6).

As far as I can tell everything looks just the same, except that on some blocks (notably the footer menu) the name ("Footer Menu") appears. From the theme files i see this is because $block->subject suddenly is set.

What's up with this - if the themes are identical and the configuration is the same, why does one have a block->subject set and not the other?


texts: How to import an existing single site into an existing drupal 7 multisite

texts:
What would be the steps to take to add an existing site into an existing multisite that already has several sites in it.
The existing multi site is on acquia cloud and the single site that I want to add to it is on my local computer .

Thanks


texts: How can I send html email notifications with entityforms?

texts: There must be a way to do this, but I'm having trouble turning it up.  Has anyone successfully sent HTML email notifications following an entityform submission?


texts: Trying to get a "Is between" date filter to work... it is returning an offset by + 1 days.

texts:
Please see my website to see what i'm talking about: http://apollo.tbc.iit.edu/~spaceweather/sw_test/?q=download-cases-data#

Ive found some examples and posts on how to do this but even after following them i'm still having issues.

I'm trying to filter the results shown in a table. I want the dates in between the two specified dates a user might put in.

When I select 05/24/2013-05/26/2013 I get an offset of 05/25/2013-05/27/2013 for the results. Can anyone help with this?  I'm storing the date as a Unix time stamp.

Thank you for your help!

(*Note my website has been updated according to the suggestion below by @adem .)


texts: An entity autocomplete widget with opportunity to save its text content

texts:
There is the standard insert or edit node form with an entity_reference field and the EntityReferenceAutocomplete widget.

The client needs to save string values inputed to the widget in case of entity wasn't selected from the autocomplete list. That is, client needs to have possibility to select entity from the autocomplete list or input string value if, for example, entity is absent in the list. And new entity shouldn't be created in this case.

I'm thinking how to create this opportunity the best way. And I'm little bit confused.

Is it possible to perform it with alter hooks only and without creating new field widget ?

Or otherwise is it possible to do it creating a new field widget having inherited it from the class EntityReferenceAutocompleteWidget ?

Or maybe the single solution for it is creating a custom widget based on TextField with including autocomplete function manually ?

Has anyone encountered with a simular task ?


texts: I'm searching for a module to delete product variations revisions?


texts: How to set a value in a reference field programmatically?

texts:
I have installed Drupal Commerce in an existing site and I use a Product reference field to attach items from the web shop to each existing product in the site.
Since there are more than 1 000 items in the site, I would like to avoid doing this manually.

So I thought I could use hook_node_view in a custom module and the rows below to check if the Product reference field is empty. If so I could just fetch the value from the old existing SKU field (field_artikelnummer) and set it to the new Product reference field (field_add_to_cart), in order to create the connection between the existing product node and the product in the Drupal commerce (imported by Feeds).

So I have come up with this:

  if($node->type === "instrument"){
    $node_wrapper = entity_metadata_wrapper('node', $node);
    $referenced_product = !empty($node_wrapper->field_add_to_cart->value()) ?   $node_wrapper->field_field_add_to_cart->value() : NULL;
    dsm($references_product->sku);
    if(empty($references_product->sku)){ // if there is no product reference
      $item_sku = $node_wrapper->field_artikelnummer->raw(); // get the existing old sku value from the existing node
      dsm($item_sku);
          /* and then how do I set $item_sku in the Product reference field? */
      $node_wrapper->save();
    }

EDITED:

Finally I found this solution using commerce_product_load_by_sku():

  if($node->type === "instrument"){
    $node_wrapper = entity_metadata_wrapper('node', $node);
    $referenced_product = !empty($node_wrapper->field_add_to_cart->value()) ?   $node_wrapper->field_field_add_to_cart->value() : NULL;
    dsm($references_product->sku);
    if(empty($references_product->sku)){ // if there is no product reference
      $item_sku = $node_wrapper->field_artikelnummer->raw();
      $ref_new_product = commerce_product_load_by_sku($item_sku);
      $new_product_id = $ref_new_product->product_id;
      $node_wrapper->field_lagg_i_varukorgen->set($new_product_id);
      $node_wrapper->save();
    }

This actually connects the existing nodes to the imported products in drupal commerce. BUT, I need to refresh each page twice in order to get it to work. I tried to add node_save($node) as a last row, but that gave me a bunch of error messages like these:

Warning: array_flip(): Can only flip STRING and INTEGER values! i DrupalDefaultEntityController->load() (rad 175 av C:\wamp\www\includes\entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! i DrupalDefaultEntityController->cacheGet() (rad 388 av C:\wamp\www\includes\entity.inc).


texts: Create a page with database data in a module

texts:
I am new to drupal and in a process of developing a custom module. My module will do a couple of things:

(ADMIN) User will be able to select a zip file and upload it
(ADMIN) The module will than take that file, extract it to files folder
(ADMIN) Upload the content from a certain file to the database table
(ADMIN/front end) Create a link/page/node on the front page in navigation where the data will be displayed with some additional js required

I got first 3 things going but I am struggeling with the last one.

Any pointers in the right direction will be much appreciated.


texts: My theme is set up so that if I add javascript files through the info file they are loaded at the bottom of the page. This is generally what I want however I want to load a few specific javascript files in the head. Is there a 'standard' way of doing this? I would like to use the normal minification and aggregation if possible.


texts: I have a custom field on the user profile, where the user can add site URLs. I would like to have a select option on the new content form with the values of these URLs when a user wants to add content. Any idea what module should I use? Thanks


texts: Accessing html.tpl.php variables from outside

texts:
The Drupal 7 has it's default html.tpl.php looking similar to this:

<!DOCTYPE html>

  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>
  <?php print $scripts; ?>

<body class="<?php print $classes; ?>" <?php print $attributes;?>>

    <?php print t('Skip to main content'); ?>

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

How can I access those variables ($styles, $scripts, etc.) from outside the html.tpl.php? (suppose from page.tpl.php)

Thank you in advance!


texts: Exclude exposed filter for one content type in my view

texts:
I use leaflet map for displaying markers, like that :

My actual view -  filter criteria :

- Content published
AND
- Content - Has taxonomy term AND
- Content - Has taxonomy term AND
AND
Content type = 1 OR
Content type = 2

But now, I want display vectors with a third content type. It works without filters (taxonomy), and add all taxonomy terms to my third content, it's an ugly solution.

Do you have a solution ?

edit : drupal doesn't understand this setup


texts: How can I increase the max lenght of Tab-Title ?


texts: Emails not being sent from Acquia dev desktop2, win7

texts:
I have a Acquia DevDesktop2 set up on my development machine (win7). I'm testing a webform submission and I'm running into an issue where I get messages that the emails are sent, but nothing reaches the inboxes. I have  I'm trying to email them to regular Gmail accounts. The vanilla install on my live site sends the emails without a problem, but I don't want to code on the live codebase.

I've seen that a lot of people have this issue, but there's no good documentation that I've stumbled across on how to set up the xmail server, or how to configure it after the fact. The acquia docs all say it comes cooked in, but I'm not sure why this doesn't work for me. Any references to how to trouble shoot this would be appreciated.

So any advice would be appreciated


texts: How to test for a boolean field in a twig template?

texts:
field_boolean is a boolean field.

{% if content.field_boolean == true %} or {% if content.field_boolean == 1 %} or {% if content.field_boolean == 'true' %} or {% if content.field_boolean == '1' %} don't work.

How do I test if the checkbox is checked?


texts:
I have a view with fields. In fields I have added two rendered node fields with two different view modes teaser and teaser1.

I want to add two pagers to this view. One for the first rendered node with view mode teaser and one is for the 2nd rendered node with view mode teaser1.

I have grouped the 2nd rendered node by a date field in template file.

The first rendered node is simple a list and the pager will add new content.

The 2nd rendered node is grouped by a date field. Content is displaying under each group date. The pager for this view mode will be different.

It will add new group dates along with their content not just only content.

I have looked up for contrib module but didnt find one. I think I have do this custom. But can someone guide me from Where I should start and can give me an idea.


texts: Boost + Expire: Front Page not expiring from cache

texts:
I am using Boost and Cache Expiration. My site generates nodes automatically and adds them via node_save(). I have setup Expire to get triggered on node insert, update and delete and to let the front page and the node page expire (see screenshot).
The problem is now: When the site is under high traffic, the front page does not get expired. When the traffic is low, the expiration works as it should.
I could reproduce this error even locally: While adding a node, I let wget constantly accessing the front page on my local host. As on the production server, the front page did not expire.
My hunch for the reason now is that the following happens within some milliseconds:

When calling node_save(), the new node get only scheduled to be saved but not saved yet.

The cache although, gets flushed immediately.

A new request to the front page is made, it gets delivered and its old version gets cached again.

The scheduled node save operation finally gets written to the database. But it has no effect to the front page, since it is already cached.

Do you think that my hunch is correct? If yes, what should I do? And if no, what could be the reason instead and what should I do?


texts:
entity.query service is very handy when it comes to finding nodes with specific field values. Unfortunately all it returns are entity IDs and revision IDs.

In case in which result set is big it's really inefficient to load whole nodes if only data from specific fields is needed.

In D7 it was possible for example to use field_attach_load() function which (thankfully) has been removed in D8, as detailed in Fields are no longer handled individually and are bound to an entity type. The problem is that Drupal change log references loadFieldItems() and doLoadFieldItems() of FieldableEntityStorageControllerBase class neither of which exists in current release of D8.

What is the Drupal 8 way of loading data for specific node fields only?


texts:
I've created a view that I then turned into a 'Feature.'  I then successfully added this feature to a second site by copying the module files from the first site into the module folder of the second. Only the first-site has the D8 Features Module.

Then on the first site I changed the Title of the View and went through the process of detecting the change and regenerating the Feature:

Edit the view with the new title
Go to the Features Config page where the state of the feature shows "Changed"
Import the code back into the database (i.e. 'revert')
Re-re-edit the view title
Export the view as a feature

Now I want to import the changes of the first-site Feature into second-site Feature.

Uninstall the imported/copied module from second-site
Replace module folder of second site w/ new module from first-site
Re-install the module

I then receive a long error:

  Unable to install My Image Gallery, core.base_field_override.node.my_image.promote, core.entity_form_display.node.my_image.default, core.entity_view_display.node.my_image.default, core.entity_view_display.node.my_image.teaser, field.field.node.my_image.body, field.field.node.my_image.field_my_image_field, field.storage.node.field_my_image_field, node.type.my_image already exist in active configuration.

Obviously there is a problem with either my procedure or my understanding of how to use the 'Feature' feature of Drupal 8, or I have a misconception of what it's supposed to do. Any help would be appreciated.