texts: In defining a hook_block_info() is it possible to define the region per theme?

texts:
I'm trying to avoid this error and it seems I should be able to define the blocks region on a per theme basis. I've checked the API documentation but it's not covered. Has anyone pulled this off yet?

A for instance would be how do I additionally define the sidebar_first region in Bartik in the following example?

Here is my current _block_info():

  $blocks['find_activities_large'] = array(
  'info' => t('Find Activities Widget (large)'),
  'status' => TRUE,
  'theme' => 'MY_CUSTOM_THEME',
  'region' => 'inner_sidebar',
  'weight' => 0,
  'visibility' => BLOCK_VISIBILITY_LISTED,
  'pages' => '<front>',

);


texts: Nice menus error when implement in zen themes

texts:
I copied the following code:

<div id="navigation">

  <?php if (module_exists('nice_menus')): ?>
  <nav id="main-menu" role="navigation">
    <?php
      print theme('nice_menus_main_menu', array(
        'direction' => 'down',
        'depth' => -1,
      )); ?>

  </nav>
<?php elseif ($main_menu): ?>
  <nav id="main-menu" role="navigation">
    <?php
    print theme('links__system_main_menu', array(
      'links' => $main_menu,
      'attributes' => array(
        'class' => array('links', 'inline', 'clearfix'),
      ),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      ),
    )); ?>
  </nav>

and replaced the default code in page.tpl.php (zen theme),

<?php if ($main_menu): ?>
    <nav id="main-menu" role="navigation">
      <?php
      print theme('links__system_main_menu', array(
        'links' => $main_menu,
        'attributes' => array(
          'class' => array('links', 'inline', 'clearfix'),
        ),
        'heading' => array(
          'text' => t('Main menu'),
          'level' => 'h2',
          'class' => array('element-invisible'),
        ),
      )); ?>
    </nav>
  <?php endif; ?>

The sub-menu is able to drop down but the main menu can't be horizontal; meaning the main menu can't be "inline", because the system didn't run the elseif look I think. So I want to know what the problem is? And what should I do to re-correct the zen theme coding?


texts: Simplenews newsletter unsubscribe page- Access denied

texts:
I am using Simplenews newsletter module on my Drupal-7 website to send newsletters, but when you click on the unsuscribe link, the user gets an access denied page-you need an account to view this page etc.
Where can I make this page visible to all users or/and change what this page says?
 For example, instead of Access denied to show an image or say "Error" or something else.


texts: Creating a responsive menu system for a site with a lot of content

texts:
I am currently creating a website which has a lot of content - text. For this I need a serious menu structure with 5-10 menu items per menu and at least 15 menu-blocks per main menu item.

Further it has to be accessible via mobile.

Till now I have used panels and added menus inside the panels. But mobile isn't to happy about that and the list-names in the menus overlap the content.

How would you go about solving this issue? I trust you experts here! :-)


texts: How can I pass the loop.index from a view template to a node template?

texts:
In a views template (views-view-unformatted.twig.html), I have
{% for row in rows %}
    {% set row_index = loop.index0 %}
    {{ row.content }}
{% endfor %}

where each row is processed in a node--view.twig.html.  How can I pass in row_index to the node--view.twig.html?  This is used simply to create an index.


texts: Rules: after saving new content + after updating existing content both triggered on node create

texts:
I have two rules -

Triggers - after new content is saved
Triggers - after updating existing content

Problem

When I create a new node both rules are getting triggered together.

Probable Cause

I have an image field in my content type. Something that I found - "...Drupal re-saves the node just because it has a file attached to it...". Refer - http://drupal.org/node/1281960#comment-5065932

However, there must be some solution to this. Please any suggestions, workarounds, solutions...anybody?

Thanks.


texts: getting the translated version of current url token

texts:
In D8, with the usual translation modules enabled, I have a custom pop-up to change language on our site. Currently, it contains a link and text, like this:

EN | ES

This would work, except that the link of the translated page is different.

Example. If I'm on the English page, "website.com/contact-us" and change my language to Spanish, the page will load "website.com/es-us/contact-us" ... which does not exist. It's a 404 error

But that is incorrect. The Spanish version is correctly spelled 'contáctenos"
So, I want the Spanish user to go to "website.com/es-us/contactenos.

Is there a way to do this with the tokens? Or another approach? Some way to know to send the user to the Spanish url translation of the page

Thank you!


texts: Can't find the place to add in image caption

texts:
I installed image caption module and enable 'Image caption filter' under Home » Administration » Configuration » Content authoring » Text formats.

But I can't the place to add in the image caption.


texts: How do I test the methods or hooks implemented in .module file using PHPUnit?

texts:
PHPUnit testing in Drupal 8 works for functionality which are written in class files.

How do I test the methods or hooks implemented in a .module file using PHPUnit in Drupal 8?


texts:
I have 2 views. One is used to sort content of type slider using draggableviews. The other one displays an image field of the same slider content type. How can I use the weigh (sort order) of the first view in the second one?

In other words, I want to have one view that lets me sort my slider content, and another one that displays the slider content in the order defined in the first view. Any help would be appreciated. Thank you!


texts: Metatag module version 7.x-1.4 generates Meta tags vertical tab disappears

texts:
When I updated my contributed module Metatag to the last version some problems happened.
Meta tags vertical tab element disappears from new node creation menus. It seems there is some issues with database and new elements.

Anyone knows something about it?

Drupal core version: 7.34


texts:
Using the Rate Module , I'm interested to know if it is possible to "Rate" people.

For example, rate a tradesman; rate a private tutors teaching service; rate any service provider.

I'm already using the Rate module for node rating, but cannot seem to find at this moment the ability for the above, unless it's custom hack or something.

Has anyone used the Rate module for similar, or would anyone like to share a general overview of what's needed to accomplish such a task?


texts: How can I write an if else statement in Twig based on commerce stock quantity?

texts:
Building a D8 Commerce site and trying to hide the price if the product is out of stock.
I can access the stock value with this:
{{ product.variation_field_stock_level.0 }}

I've tried this:
{% if product.variation_field_stock_level.0 > 0 %}
 {{ product.variation_price }}
{% else %}

Sold

{% endif %}

...but it prints the price regardless of whether the stock value is 0 or 1 (or more).
I've also tried:
{% if product.variation_field_stock_level.0 == 0 %}

Sold

{% else %}
  {{ product.variation_price }}
{% endif %}

Regardless of what I try it just will not work.


texts:
I have a view that creates JSON for me. The view has a field that multiple images, title, body and some other data fields on it. The image field can have multiple images. How can I show  all the images? I know multiple field settings would show all the images but then it would loop all the info multiple times (as many times as there images) and I don't want this to happend.

I have also tried "Display all values in the same row" and putting Simple separator as "," but it only shows the first image.

What I want is the JSON would be something like this:

"nodes" : [

{
  "nid" : "124",
  "title" : "This is the node title",
  "field_shot_desc" : "Short description text",
  "Body" : "
Curabitur blandit tempus porttitor. Nulla vitae elit libero, a pharetra augue.
\n",
  "field_images" : "http://www.domain.com/sites/mytheme/files/styles/browser-thumb/public/rest1.jpg","http://www.domain.com/sites/mytheme/files/styles/browser-thumb/public/rest2.jpg",

},

So the images would be separated with , or something so I can manipulate them in JS later.


texts: The clean URL test failed Drupal and Openshift

texts:
I want to clean URL in Drupal but get the test failed, and that what I have done in my httpd.conf :

<Directory "/php/">
 RewriteEngine on
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

I have also enabled the mod_rewrite but got an error! Any idea?


texts: node access not taken in account in views

texts:
using the hook_node_access, i can restrict access to content by role.

If the boolean field_private_only is selected , only the user with the role private can view it, fine.

 my_module_node_access(NodeInterface $node, $op, AccountInterface $account) {

  global $user;
  if ($node->bundle() == 'my_content_type') {
      if ($op == 'view') {
          if ($node->field_private_only->getString()) {
            $user = \Drupal\user\Entity\User::load($account->id());
            if($user->hasRole('private'))
               return \Drupal\Core\Access\AccessResult::allowed();
          }
      }
   }
 return \Drupal\Core\Access\AccessResult::forbidden();
}

When creating a view displaying these contents, the restriction does not occur .

How can i Make it happen in views?

how can i make it happens in search_api index ?


texts: How to set conditional edit permissions on webforms?

texts:
I need to extend a Drupal6 based system. I'm not too familiar with it since I overtook administration from another group. It has a product registration system wich uses webforms and a custom module. The user have to be able to edit the their own submitted webform but only until the status is set to accepted.

I switched on permissions for users to edit their content, and it works fine, but I need to revoke this permission based on a field in the webform. When the field value is set to "new" or "pending" the user must be able to edit the content, but when the business owner sets that field to "accepted", the user shouldn't be able to edit that submission any more.

How can I catch user permissions and only let users edit certain content when I want?


texts: Use custom form submit function inside class

texts:
In my controller I am loading a form and including one custom submit handler. However the submit function is not called. I think that it's either not found or not accessible as it is inside the controller class:

class MyController extends ControllerBase {

  //...

  public function myProfile() {
    $user = User::load($this->currentUser->id());
    $form = $this->entityFormBuilder()->getForm($user);

    $form['actions']['submit']['#submit'][] = '::_custom_submit_form';
  }

  protected function _custom_submit_form(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
    $form_state->setRedirect('<front>');
  }

}

If I use hook_form_alter it works, but I don't want to use a hook as I can directly manipulate the form.


texts: How can I fix the "Deleted and replaced configuration entity" error during configuration import?

texts:
I am currently running into a config import error and it seems like it has something to do with field collections:

Finalizing configuration synchronization.

The import failed due for the following reasons:

Deleted and replaced configuration entity "field_collection.field_collection.field_lives_around"

I just started yesterday with this project and created tons of fields and configurations, no custom code at all for now. Any idea what could go wrong?

The field collection contains an list (text) and an geolocation field (https://www.drupal.org/project/geolocation)


texts: How to create db table while installing a module?

texts:
I want to create a table in Drupal while installing a module (custom module which is crated by me). I tried in the below way, but I could not able to create a table in Drupal db. what am I missing, what else I have to do?

function custom_agent_handler_install() {

if (!db_table_exists('demo_score')) {
  $demo_score_schema = array(
    'description' => 'To store unique number and other details.',
    'fields' => array(
      'score'    => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
      'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => '0'),
    ),
  );

return $demo_score;
}

}


texts:
I inherited someone else's project.

I see he created a module called bcompanies.module.  In that module file I see this:

function bcompanies_menu() {
    $items['company'] = array(
        'title'     => 'Company',
        'page arguments'    => array(1),
        'page callback' => 'company_page',
        'access callback'   => TRUE,
        'type'          => MENU_CALLBACK
    );
    $items['company_page2'] = array(
        'title'     => 'Company',
        'page arguments'    => array(1),
        'page callback' => 'company_page',
        'access callback'   => TRUE,
        'type'          => MENU_CALLBACK
    );

}

function company_page()
{
      return 'hello world';
}

When I go to the url http://site.com/company, I see the text "hello world".  When I go to the url http://site.com/company_page2, I am redirected to http://site.com/welcome .   Does anyone know why the second url keeps redirecting me while the first does not, even though they seems exactly the same in terms of set up?

I did a test and wrote a die() statement in company_page(), that forced it to not redirect.   But that's not that great, because it prevents subsequent drupal hooks from firing.

Additional Notes

I noticed that if I login as an admin user, then there is NO REDIRECT when i go to http://site.com/company_page2 - I see hello world wrapped nicely by the header html template and the footer html template.  The redirect only happens when i login as a regular user going to that page.

So is this a permission/role issue?  But I never set the permission or role or anything...


texts: How to print the url and the filename from image field in views-view-unformatted.tpl.php in Drupal 7?

texts:
I tried using this code, but it does not work.

<?php print $node->field_slider_image['und'][0]['filename']; ?>


texts: Custom migrate with cross database joins issue

texts:
I'm facing an issue when running cross-database joins whilst implementing a custom module using Drupal Migrate.

The set up: I have 2 databases: myshop_migrate - the migrate db and myshop - the Drupal db.  Each database is located on separate AWS instances - so migrate db is not locally available.

I have the following set up in settings.php - I can confirm this works, connection occurs >>

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'my_shop',
      'username' => 'root',
      'password' => '******',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

$databases['migrateserver']['default'] = array (
      'database' => 'myshop_migrate',
      'username' => 'root',
      'password' => '******',
      'host' => '12.34.56.78',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
);

In my custom migrate module, I'm utilising db_set_active('migrateserver'); before running a $query to switch the db prior.

Example 1 - This works:

 db_set_active('migrateserver');
$query = db_select('myshop_migrate.product_commerce', 'p')
             ->fields('p', array('sku', 'ref', 'colorcode', 'size', 'title',
                'product_group', 'user1', 'user2', 'sup_ref', 'price', 'prev_price',
                'vat', 'rem',
             ));
    $query->leftJoin('myshop_migrate.stock_commerce', 's', "s.newref = p.sku");
    $query->fields('s', array('stock'));

    $this->source = new MigrateSourceSQL($query);
    db_set_active();
    $this->destination = new MigrateDestinationEntityAPI('commerce_product', 'product');

Example 2 - This doesn't work

db_set_active('migrateserver');
   $query = db_select('myshop_migrate.stock_commerce', 's')
          ->fields('s', array('ref'));
    $query->addExpression('MAX(s.last_modified)', 'last_modified');

   db_set_active();
    $query->innerJoin('myshop.commerce_product', 'p', "s.newref = p.sku");
    $query->addExpression('COUNT(p.sku)', 'cnt');
    $query->addField('p', 'status');
    $query->having('COUNT(p.sku) = 0');

   db_set_active('migrateserver');
    $query->groupBy('s.ref');

    $this->highwaterField = array(
      'name' => 'last_modified', // Column to be used as highwater mark
      'alias' => 's',           // Table alias containing that column
    );
    // Note that it is important to process rows in the order of the highwater mark
    $query->orderBy('last_modified');
   db_set_active();

Example 2 does not work, I don't know how to solve this. The query doesn't run (like it does it example 1) - the error I receive is as follows:

  MigrateException: Failure to sort migration list - most likely due to circular dependencies involving..

I've looked at a similar issue https://stackoverflow.com/questions/3414295/cross-database-table-joins-in-drupal - but prefixes do not seem to work.


texts:
i often need to change/add new behaviours to existing modules, but i don't really know what is the correct way to do this.

For example i have installed the webform module. What i need to add is this:

on the list of submitted forms i need a button (create user) which creates a new user using some data of the submitted form.

What should i do?

Should i change the module code or is there a way i can inject this behavior by creating a new module?

I'd like the second option more than the first, are there some tutorials on how to do this?


texts: How to show the term name in the URL instead of a term id for faceted searches?

texts:
Using Search API and Facet API, how can you set up exposed facets or indexing so that you can create better URLs instead of something like:

?q=field_myfield_categories:123,456,789

I would rather show:

?q=categories:foo,bar,baz

I am using Drupal 7.54, Search API, Search API Solr, and Facet API.

Note that taxonomy isn't the only thing I would like to rewrite in the URL, so if there is a way to deal with this in Facet API + Search API short of writing everything custom, I would like to know.


texts: Entity registration, register to more event from one form in event detail

texts:
Hi I have created special content type called Event. It is simillar to facebook events. It has description, address where it will be held and date when it will be held. I succesfully added there registration form with Entity registration. So now I can register to one event. But I want to be able to register from one event to more events like this.

In event detail, registration form section, I want to have checkboxes. When I click on these checkboxes and click on register to event, it will register me to every clicked event, and to opened event too. These additional event, I will select in administration, when creating new event.


texts: On Imported content I am getting the error Text format field is required

texts: I imported some content to a content type on a csv which imported fine but when I went to edit and same the content I get the error Text format field is required. Is there any known way to fix this? Thanks


texts: How to set the default value of an exposed filter rather than -Any-?

texts: I have a view with exposed filters in Drupal 7 and I need to set the default value of a filter to current year. I also need to unset/remove the - Any - option from the select list.


texts: mailsystem module does not appear in the selection field for HTML Mail module class

texts:
when I go to the mailsystem module configuration, only two selection fields appear

I do not know why this behavior can be given, there is some option that makes this disappear. I have installed the mailsystem and htmlmail modules

What I see in the site where the selection field is missing

What should be shown (what I need)


texts: How to display batch progression with default theme of my site?

texts:
I just created my first batch using batch API and it seems to work!
The progression bar is properly displayed during the execution and it uses administration theme, Seven for my site, which I guess is the standard behavior.
Is there a way to use the default theme of my site instead?
How do I do that?


texts:
I have 2 user roles in my Drupal 7 site 'A' and 'B' respectively:

Users of role A can create and publish content.

Users of role B can not create content but they can view all published content.

Content in my case is an invitation to some event (ie "Who wants to play football on Friday?")

B users can click the button under each invitation to join event. For this I used Flags and Rules. A users can see who flagged their content.

But A users have to review potential participants profiles and confirm their participation. In user profile I have created button filed with following permissions

But this field is displayed on each B user profile page whatever he flagged content or not. How can I make this field visible to A users only when B user falgs the content?


texts:
When creating a product node for Ubercart, how do I set the product image?

I am using the following code to create a product node.

$node = new stdClass();

$node->name = "Title";
$node->title = $node->name;
$node->body = "Lorem Ipsum";
$node->type = "configurator_product"; //my own product class
$node->created = time();
$node-> changed = $node->created;
$node->promote = 0;
$node->sticky = 0;
$node->format = 2;
$node->status = 1;
$node->language = "en";
$node->default_qty = 1;
$node->sell_price = 55.00;
$node->shippable = 1;

The product node has a field_image_cache field which expects a file (extensions: png, gif, jpg, jpeg). I tried to set this field.

$node->field_image_cache = "Path/to/module/Images/image1.jpeg";
// Results in Fatal error: Cannot unset string offsets in
// path/to/modules/cck/content.module on line 1248

$node->field_image_cache[0]['value'] = "Path/to/module/Images/image1.jpeg";
// No errors, but when viewing the product in store administration there is no image

What is the correct way to set an image for a product?


texts: How to alter checkout panes based on order contents

texts:
I want to remove billing and payment for free orders. Currently, I have the code below.

Am I safe to user global $user in this case? Is there any better way to get the user account & order involved when this hook runs?

I ask because, after installing this hook, I've seen payment and billing panes hidden under admin/commerce/config/checkout, but I didn't hide them there. This seems to be intermittent.

function MODULE_commerce_checkout_pane_info_alter(&$checkout_pane) {

  global $user;
  $order = commerce_cart_order_load($user->uid);
  if (!empty($order)) {

    //get the order wrapper and order total
    $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
    $order_total = $order_wrapper->commerce_order_total->amount->value();

    // hide payment and billing info if the order total is <= 0
    if ((int) $order_total <= 0) {
      $checkout_pane['customer_profile_billing']['enabled'] = FALSE;
      $checkout_pane['commerce_payment']['enabled'] = FALSE;
    }
  }
}


texts:
In the template.php file, we grab the theme settings:

if(theme_get_setting('fix_sidebar')){
...
        variable_set('fixed_navbar',1);
    }

Based on the theme setting(i.e fix_sidbar'), we want to reset another theme setting(i.e fixed_navbar) as you see above. However, it does not appear to be working. It is not showing up theme settings that has:

 $form['style']['fixed_navbar'] = array(
        '#title' => t('Fixed Navbar'),
        '#default_value' => theme_get_setting('fixed_navbar'),
        '#type' => 'checkbox',
    );

How to do the opposite of theme_get_setting API to reset the setting with new value? Thank You


texts:
Here's the scenario:

I have two feeds importers: Members Importer, which does the mapping

SOURCE      TARGET                         TARGET CONFIGURATION
id          GUID (guid)                    Used as unique
id          member_id (field_member_id)    Used as unique
first_name  First Name (field_first_name)
last_name   Last Name (field_last_name)

and Bigs Importer, which does the mapping

SOURCE          TARGET                               TARGET CONFIGURATION
from_member_id  member_id (field_member_id)          Used as unique
to_member_id    Big Brother(s) (Entity reference by
                Feeds GUID) (field_big_brother_s_)

Both have Bundle set to the custom content type Member; note that field_big_brother_s_ is an entity reference to a node which is also of content type Member, which is why I need two separate importers.

Questions:

(For ease of discussions, I've appended a couple example sources to the end of this post.)

Can I guarantee that running Bigs Import on the source below (after running Members Importer on the other source) will add The Doctor to Mr. Rogers's Big Brother(s) field? I've read that GUID is only guaranteed to be unique for a single import, or something like that.
If the answer to 1. is no, is it possible to do the entity reference lookup by the member_id field and eliminate GUID stuff entirely?

Example Sources:

Source for Members Importer:

id,first_name,last_name
1 ,Bob       ,Dylan
2 ,Mister    ,Rogers
3 ,The       ,Doctor

Source for Bigs Importer:

id,from_member_id,to_member_id
1 ,2             ,3
2 ,1             ,3
2 ,1             ,2


texts: Change register button label when certain field is selected

texts:
I use a custom module to change the text of my register form submit button:

<?php
function registration_button_override_form_alter(&$form, &$form_state, $form_id)
{
  //check to see if user is logged in so that this is only displayed to anon users that are registering
     global $user;
     if ($user->uid == 0) {
     if ($form_id == 'user_register_form') {

     // Change register button text.
     $form['actions']['submit']['#value'] = t('Jetzt registrieren');

     }
  }
}
?>

This works fine. Now, I try to adjust this code that the button label text changes if a certain field on the registration form has a certain value selected.

I added this line:

if (isset($row->field_data_field_registrierung_als[0]['value']) == 1)

This doesn't work. When thinking about it the form probably should load again in order to change the text, right? Does somebody know how this could be done?

EDIT:

My HTML:

<select id="edit-field-registrierung-als-und" name="field_registrierung_als[und]" class="form-select required">
<option value="_none">- Wert wählen -</option>
<option value="1">A</option>
<option value="2">B</option>
</select>

<input id="edit-submit--2" name="op" value="Neues Benutzerkonto erstellen" class="form-submit" type="submit">

My jQuery:

(function ($) {
$("#edit-field-registrierung-als").change(function() {
if $( this.value == "2")
$("#edit-submit--2").val("Registrieren");
}
}) (jQuery);


texts: How to format QueryPath Xpath Mappings in Feeds Module

texts:
I have an XML document with the following structure:

<?xml version="1.0" encoding="utf-8"?>
  <ooh>
    <occupation>
      <title type="text">Accountants and Auditors</title>
    </occupation>
    <occupation>
      <title type="text">Another Title</title>
    </occupation>
  </ooh>

What do I enter in the QueryPath XML Parser to set the context to be Occupation and add the title as a new source? I tried //ooh//occupation but I keep getting this error: CSS selector is not well formed.


texts: How to render translated node body in two languages?

texts:
I use entity_translation to translate node body field, so in a fully loaded node object body is an array of 2 languages ('en' and 'ru').

For specific node type I would like to render body in both languages one after another:

  Russian version of node body

  English version of node body

so switching between translations will not be needed.

What hook can I use to achieve this?

In implementation of hook_node_load() body is an array of 2 languages, but in hook_node_view_alter() body already contains only the current language value.

When using node_load() in hook_preprocess_node, it retrieves the node object from cache and its body has only one (current) language value.


texts: Debugging a WSOD in Drupal 7 even with error_reporting on in the index.php file

texts:
I'm coming into a totally abused and hacked up drupal 7 project. The site is currently working on the production server, but I'm trying to migrate it to a new server. I've replicated as much as I can according to its environment, but I still get the WSOD on certain pages. However I am able to reach the admin pages and some of the other pages. I've even enabled the following in the index.php file:

error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);

But I still get the WSOD. I tried to edit the html.tpl.php file to see if it even loads, but it doesn't. What are some next steps one would do to debug something of this state? It's definitely crashing before the theme tpl files are loaded. Would I use a backtrace in this scenario? But where?


texts:
I am building a Drupal 7 boostrap subtheme. I don't want users to be able to add their own fonts and styles to content. I want to force them to use the paragraph and heading tags as defined in my site's CSS.

When users paste in from other sources (eg word) I do not want the styles brought in. Additionally, our site uses Open Sans. This is not appearing in the TinyMCE font list, can this be fixed?

How does one do this with TinyMCE?


texts: '"media_edit_action" plugin does not exist' error when performing update

texts:
I get the following error after a database update. It looks like it completes the update by displaying Completed 8 of 8 but it doesn't run the updates. Any help is appreciated.

  Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "media_edit_action" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 52 of /srv/bindings/ae21023ced6d43099409c0fbbeded25e/code/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

This is what the updates need to run.

System module

  Change plugin IDs of actions.
  Clear caches due to schema changes in core.entity.schema.yml.

Views module

  Update dependencies for moved bulk field plugin.
  Add additional settings to the entity link field and convert node_path usage to entity_link.
  Add placeholder settings to string or numeric filters.
  Fix cache max age for table displays.
  Include views data table provider in views dependencies.


texts: How to lock a node from a certain role after changing state in workflow?

texts:
Workflow module lets you set who can change a certain state to what state. What modules can I use to be able to prevent a certain role from editing a node that is in a specific state?

Ex: if a node has been approved and is in Approved state, it should be final and can't be edited anymore by content authors.


texts: How to send e-mail in users selected languages

texts:
I have created two users and my site supported two languages(English,Spanish).
In every 5 hours CRON will be run,I have wrote a custom module and every CRON run users are getting Emails thats fine.
But here is the problem is Emails are not sended to users prefered languages,it takes admin default language and sended to users.

I have installled multilingual module also.

I want Emails should be in users prefered languages only.

Code:-

function sendmail($from, $to, $firstname, $message, $user,$language) {
  $module = "my_mail_example";
  $key = "mail_example";
  $language = user_preferred_language();
  $send = TRUE;
  $params = array(
    'body' => $message,
    'subject' => 'Hello from Bright Ideas'
  );
  $result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
  $current_messages = $user -> field_reminder_messages_received[LANGUAGE_NONE][0]['value'];
  $updated_messages = $current_messages.'\r\n'.$logmessage;
  $edit = array(
      'field_reminder_messages_received' => array(LANGUAGE_NONE => array(0 => array('value' => $updated_messages, ), ), ),
    );
  user_save($user, $edit);
}


texts: Adding fields via ajax in form does not show in arrays in form_submit

texts:
I have am trying to add fields to a form in drupal via ajax.  I am able to have my fields show up on the form without issue but the problem is seeing values of those fields when the form is submitted.  I have read many tutorials on this tonight and I am very confused why my input fields are not even showing up in $_POST.  Here is an example of what I am trying to do:

function add_product($form, &$form_state) {
    //Several other fields but the main one around this issue is below.
    $form['img_mng'] = array(
        'label' => array(
            '#type'     =>  'markup',
            '#markup'   =>  '
Upload Images
',
        ),
        'file1' => array(
            '#type'     => 'file',
            '#size'     => 22,
        ),
        'addMore'   =>  array(
            '#type' =>  'button',
            '#value'    => t('Add More Images'),
            '#ajax' => array(
                'callback'  =>  'add_img_upload',
                'method'    =>  'append',
                'wrapper'   =>  'kc_img_uploads',
                'keypress'  =>  'true',

            ),
            '#prefix'               =>  '
&nbsp;
',
        ),
    );

    $form['submit'] = array(
        '#type'             => 'submit',
        '#value'            => t('Add Product'),
    );
    return $form;
}

function add_product_validate($form,&$form_state) {
    //Appropriate Validation
    dpm($_POST); //$_POST does not show the fields, not sure how that is even possible since the new fields are added to the form.
    dpm(get_defined_vars()); //None of the variables show the new fields.
}

function add_product_submit($form,&$form_state) {
    // Appropriate database actions....
    dpm($form_state); //No values for new fields.
    dpm($_POST);  //New fields do not even show in the $_POST.
}

function add_img_upload($form,&$form_state) {
    dpm($form_state);  //Does not show the added field below if the button is clicked more than once.
    $num_of_files = 1;
    foreach ( $form['img_mng'] as $key => $value ) {
        if ( preg_match('/^file[0-9]+$/',$key) )
            $num_of_files++;
    }
    $form['img_mng'][sprintf('file%d',$num_of_files)] = array(
        '#type'     => 'file',
        '#size'     => 22,
        '#id'       => sprintf('edit_file%d',$num_of_files),
        '#name'     => sprintf('files[file%d]',$num_of_files),
        '#parents'  => sprintf('file%d',$num_of_files),
        '#array_parents'    => sprintf('file%d',$num_of_files),
    );
    $form_state['values'][sprintf('file%d',$num_of_files)] = '';
    $form_state['file2'] = NULL;
    return $form['img_mng'][sprintf('file%d',$num_of_files)];  //The fields are added to the form every time the button is clicked.  However, the id and name of the elements are only incremented once.  ie file1 becomes file2 but never makes it to file3+.  So I will have one file1 and 1 to many file2's.
}

I originally tried this with managed_file type but I see several people have run into the issue of it returning an empty string.  I was actually able to get it to return the field details but found clicking the upload button on any of the new fields submitted the form?  Any advice on how to correct this issue with managed_file type is highly desired but will settle for file type.  Thanks again.


texts: Discount and coupon 100% off of for only 1 item in shopping cart

texts:
I am using Drupal 7 with the 2.x version of the Coupon and Discount modules.

I am attempting to issue a 100% discount (free item) to my users, but I want to apply it only to 1 item in the cart. This way, 1 item is free but anything else is still full price. I want each user to be able to choose any item they want.

I would like the user to be able to browse the site for 1 item and, at checkout, apply the coupon code so that the item is free. To prevent people getting every item for free and adding many items to the cart, I would like the coupon to only apply to one item in the cart.

Is there a way to give each user the ability to get an item free?


texts:
I have experienced this twice now on a Drupal 8 site.

Pathauto is at its current version and Drupal is 8.2.6.

What is happening is sometimes nodes 'lose' their aliases and revert back to being node/1234 both on the front end, and the admin - even though they have alias records. The page cache maximum for the site is currently set to 1 hour.

Both times I was able to trigger this, these were the actions I was doing just before I noticed the aliases were now back to their paths:

Implement a couple .htaccess rules to redirect an old non-Drupal URL to its new Drupal landing page
Performed a database backup to a backup I had made 15 minutes prior

In both cases it happened. At first I thought maybe I messed up the .htaccess rule, and commented that out and pushed back live. That redirect is handled via event now. But then it happened again, with the database backup.

In both cases, only clearing the cache (either in the admin, or drush cr) fixed the problem. So what is causing it? How can I prevent this from happening again?


texts: Need to identify higher value and lower value stored in the multivalue field

texts:
I have a Multivalued field called temperature in that everyday temperature values are stored. In that i would like to identify the highest and lowest value from that field.I found computed field module will do that but i would like to know how i achieve same in computed field.please anyone guide me do this.

Thanks


texts: attachBehaviors to rate button after ajax load

texts:
I have a view that randomly loads two nodes with rate buttons. Once a rate button is clicked, I have it set to click the "next" pager to load another random view with ajax. However, after the first time ajax loads the new nodes, I get errors and then the rate-button reloads the whole page with a long string in the url.

I'm using drupal_add_js to add the following to the page.

(function($) {
  Drupal.behaviors.myRateButton = {
    attach: function(context, settings) {
      $("a.rate-button").click(function() {
        $('li.pager-next a').click();
      });
    }
  };
  Drupal.attachBehaviors("a.rate-button")
}(jQuery));

The error message is

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /views/ajax?page=1&rate[LONG STRING]
StatusText: error
ResponseText:
ReadyState: 0

Any pointers on what could be going wrong would be greatly appreciated.


texts: _block_load_blocks() returns an empty array. block_list($region), which uses _block_load_blocks() returns nothing as well. Why?


texts: Add Location CCK field and instance programmatically to content type in Drupal 7

texts:
How does one add a Location CCK field and instance programmatically to a content type in a Drupal 7 module install? I am mainly concerned with what params need to be given to the field_create_field and field_create_instance functions, assuming it is created in the same way as core fields? I've put some examples of the params I give to these functions in creating core fields (in case this helps):

An example of the params given to field_create_field:

'field_property_price' => [
    'field_name' => 'field_property_price',
    'label' => $t('Price'),
    'cardinality' => 1,
    'type' => 'text',
    'module' => 'text',
    'length' => '20'
];

An example of the params given to field_create_instance:

'field_property_price' => [
    'field_name' => 'field_property_price',
    'label' => $t('Price'),
    'cardinality' => 1,
    'required' => true,
    'widget' => [
        'weight' => '0',
        'type' => 'text_textfield',
        'module' => 'text',
        'active' => 1,
        'settings' => [
            'size' => '20',
        ],
    ],
],

Thanks for reading.


texts: How to select the user desired crop in the "Manage Display" section of a paragraph type for an image field?

texts:
I'm currently using ImageWidget crop to give some aspect ratios for users to pick when editing content (1:1, 1:2, 2:1, 2:3, 16:9), that is properly set up in the "Manage Form Display" section of the paragraph type I'm using:

That is working properly and showing up as expected in the content editor, however, the crop isn't respected on the front-end because I currently have, in the "Manage Display" section of the paragraph type, "Original Image" selected as a way to present the image.

If I select one of the previously mentioned crops, that is respected in the front-end (i.e.: if I select 16:9, and crop the image to 16:9, that shows up fine).

What should I do to be able to select multiple aspect ratios for the image in the "Manage Display" section so whatever aspect ratio was selected by the user when editing content is used? I'm working on Drupal 8 (mentioning this because some have advised to switch modules, but I'm unable to do so because of both the version and my employer who has been using this for a while now)


texts: handling non-node based items with ubercart

texts:
I'm working on a book repository website very similar to Islandora which is based on  Fedora Commons and Drupal.

Books's information stored in repository outside Drupal. Apache Solr is configured on server and Drupal to search repository and display result in Drupal.

everything works fine, now I want make this books purchasable in Drupal.

As these search results are not nodes and there is not a node per book, I'm looking for a way to adding this non-node based items to cart!

any suggestion may be helpful!

http://www.ubercart.org/forum/support/14856/non_node_based_items


texts:
I'm using the flag module to let users mark their questions as solved, similar to how it works on this site. I therefore want to let users filter posts to show only unsolved questions. Additionally, some posts might not be questions at all. Therefore, they can't have a "solved" flag, but they also should NOT appear in the results when filtering only by unsolved questions. Therefore, I need to join the node table with two others: flag_content and field_data_field_question (this latter table is what tells whether or not a post is a question).

Here's the current code I'm trying:

$query->join('flag_content', 'f', 'f.content_id = n.nid AND f.content_type = "node" AND f.fid = 5');
$query->join('field_data_field_question', 'q', 'q.entity_id = n.nid AND q.field_question_value = 1');
$query->condition('f.fid', 'NULL', 'IS');
$query->condition('q.field_question_value', 'NULL', 'IS NOT');

However, this results in the following error:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''NULL') AND (q.field_question_value IS NOT 'NULL')
LIMIT 21 OFFSET 0' at line 4: SELECT n.nid AS nid
FROM
{node} n
INNER JOIN {field_data_field_category} t ON t.entity_id = n.nid
INNER JOIN {flag_content} f ON f.content_id = n.nid AND f.content_type = "node" AND f.fid = 5
INNER JOIN {field_data_field_question} q ON q.entity_id = n.nid AND q.field_question_value = 1
WHERE (t.field_category_tid = :db_condition_placeholder_0) AND (f.fid IS :db_condition_placeholder_1) AND (q.field_question_value IS NOT :db_condition_placeholder_2)
LIMIT 21 OFFSET 0; Array
( [:db_condition_placeholder_0] => 464 [:db_condition_placeholder_1] => NULL [:db_condition_placeholder_2] => NULL
)
in queryExecuteRender_recentActivity() (line 57 of someFile.php).

Is this not the correct way to pass NULL values into a query?


texts: Need to remove 'drupal' from html attributes

texts:
I've been tasked with removing 'drupal' from front end source code and I've managed to remove most by modifying templates and using theme hooks, but I'm struggling to remove it from a <script> tag on the bottom of the page:

<script type="application/json" data-drupal-selector="drupal-settings-json">

I know that this comes from core/lib/Drupal/Core/Asset/JsCollectionRenderer, but I don't know how to modify it without creating a patch or overriding the class (which I want to avoid).

Is there a preprocess hook I can use to remove it? I have not found one that contains that text.


texts: Different CSS files for different browsers

texts: Ideally, if all of the CSS files used should be defined in the theme's .info file, how would I go about using different CSS files for different browsers?


texts: Error when viewing list of taxonomy terms

texts:
I'm getting an "unexpected error" when I try to view a list of taxonomy terms. I recently updated to 8.7, though I have a feeling the problem has been around since before the update. Here's the error as it appears in watchdog:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AS expression FROM tfr INNER JOIN tr ON tfr. = tr. AND tr. = 0 INNER JOIN (S' at line 1: SELECT tfr.tid AS tid, MAX(tfr.) AS expression FROM {} tfr INNER JOIN {} tr ON tfr. = tr. AND tr. = 0 INNER JOIN (SELECT t.tid AS tid, t.langcode AS langcode, MAX(t.) AS expression FROM {} t WHERE t. = :db_condition_placeholder_0 GROUP BY t.tid, t.langcode) mr ON tfr. = mr. AND tfr.langcode = mr.langcode GROUP BY tfr.tid; Array ( [:db_condition_placeholder_0] => 1 ) in Drupal\taxonomy\TermStorage->getTermIdsWithPendingRevisions() (line 404 of /Applications/MAMP/htdocs/libnews/core/modules/taxonomy/src/TermStorage.php).

And I don't know if this related, but I am also getting an error when I try to update my database via drush:

  Error: Call to a member function getKey() on null in system_update_8702() (line 2278 of /Applications/MAMP/htdocs/libnews/core/modules/system/system.install) #0

This is outside my area of expertise, so I'm pretty stumped.


texts: Adding custom variable to twig's html.html.twig which is not cachable

texts:
In the html.html.twig file of the theme I'm using, I want to add a custom variable called {{ amount }}
like:
Amount of items in cart: {{ amount }}

And I want it to be (in php): count($_SESSION['cart']).

If I add this to my custom module's hook_preprocess(_html) function:

$variables['cart'] = count($_SESSION['cart']);

Then it will work when I clear the cache, and then it will remember the value. So let's say there are 3 items in cart (variable $_SESSION['cart']), then it shows 3. If I then add one more, then next time I refresh the page, it shows 3 again, but it should say 4!!
If I clear the cache, then it says 4! How can I make it "dynamic" without clearing the cache all the time.


texts: Drupal 8's last minor release = Drupal 9?

texts:
I have read about the planned release date of Drupal 9 is scheduled to be on June 3rd, 2020. I read this documentation about how to prepare a Drupal 8 site for Drupal 9:

Prepare a Drupal 8 site for Drupal 9

In the document it says:

"1. Keep Drupal core up to date. Drupal 8's last minor release will become Drupal 9."

Does it mean that when we update the Drupal 8 core to the last minor release of Drupal 8, it will automatically convert our site to use Drupal 9 and we don't have to radically change, migrate or redevelop our sites again in Drupal 9?

In summary, is Drupal 8 core's last minor release = Drupal 9?


texts: Taxonomy filter exposed to user that dynamically only includes terms attached to currently published content

texts:
Background:
a) Taxonomy: I have built as site that allows users to tag content of a particular content type with tags.  The system started with a pre-existing taxonomy before any content was added, but has grown organically as users add content and terms of their own.  What this means, of course, is that at any time, some of the terms in the taxonomy, may not be attached to any currently published content.

b) View with Exposed Tag Filter:  As a means to allow users to find material of interest, I have exposed the Tag Field as a filter for a tabular view of the content.  The Filter is a drop down list.  When a user selects a tag from the list, the view is appropriately filtered to the matching items.

Problem:
As the taxonomy has grown, a good proportion are not, at any time, attached to any content.  Thus, it is frustrating for the user to filter the table with a tag list that includes these terms, as they yield 0 results.

Requested Help:
Therefore, I am looking for a way, that the terms shown in the tag filter are dynamically limited to only those that are attached to currently published content.  It is not clear to me how to do it.  I would greatly appreciate any advice on how this may be accomplished.


texts: how to correctly write drush sql-sycn using drush_invoke_process()

texts:
I need to execute a drush command from a custom module, Im using drush_invoke_process() but I do not know how to write it correctly

How would you write this command for use with drush_invoke_process() ?

drush sql-sync @site1 @site2 --tables-list table1,table2,tableN

How to write the above command in drush_invoke_process() syntax?

Thanks


texts: Drupal 7 displays IP address in internal links instead of URL

texts:
The website I am developing with Drupal 7.17 continues to show the IP address in the links.
I have configured the URL to point toward the site this works  though the internal links display the IP address.

I have modified the $base_url in settings.php but this does not affect it. I have also cleared the caches in my Drupal install as well as Mysql database cache. The hosts file is set to point to the URL but still it's not displaying the the URL in the links.

The website and links work on the local computer development environment.


texts: Changing content type description doesn't work

texts:
I have a new Drupal 8 site (single, non-English language, I have a hunch this plays some part in the problem). After installation, I changed the description of the two prefabricated content types (Article and Page), as well as the name of the Tags vocabulary. The changed descriptions don't appear on the /node/add page, I still have the old descriptions. More than that, looking into the stored entity data reveals strange differences, too. When I dump the node type list in the node.module like this:

function template_preprocess_node_add_list(&$variables) {
  dpm($variables['content']);

This shows the following:

Array
(
    [article] => stdClass Object
        (
            [__CLASS__] => Drupal\node\Entity\NodeType
            [type] => article
            [name] => Article
            [description] => `Original description`
            [help] =>
            [new_revision] =>
            [preview_mode] => 1
            [display_submitted] => 1
            [originalId] => article
            [status] => 1
            [uuid] => c86c5b86-8a8a-4ec8-a56f-f315ee6ce23f

However, when I use the Devel tab to examine the node type in the content type editor, it shows:

stdClass Object
(
    [__CLASS__] => Drupal\node\Entity\NodeType
    [type] => article
    [name] => Article
    [description] => `New description`
    [help] =>
    [new_revision] =>
    [preview_mode] => 1
    [display_submitted] => 1
    [originalId] => article
    [status] => 1
    [uuid] => c86c5b86-8a8a-4ec8-a56f-f315ee6ce23f

They both clearly are supposed to read the same entity from the database, all other data are identical (yes, langcode is the same as well), just not the description.

All cache clearing and rebuilding has already been done, for sure.

Update: it will be the language all right. If I peek into the config table, most config entries (including these) are duplicated. Once without collection, and again with the language specified. I don't think this is correct like this but how can I avoid it or correct it (except for deleting manually from the database)?

Update 2: Not yet an answer although I solved the problem, this seems a Drupal bug to me. The content type description was a red herring, it can happen with any config item. What I did was:

Drupal was installed in English (I happened to start with a preinstalled image but this can happen in any other scenario quite easily).
Another language, XX was added to the site.
Some items were changed in the site, it isn't important what they were, content type, fields, taxonomy, anything that's stored in the config table these days.
English was removed, leaving only language XX.

Step 3 introduces duplicate entries in config where the language is referenced in the collection field. I suppose that if I remove language XX, those will be gone, too. But in Step 4, I removed English, not language XX. Consequently, I was left with duplicate config items, both empty and language=XX in collection.

Yes, it's perfectly clear that without these two extra steps, there wouldn't have been extra items in config. Still, I don't think this is solid enough if it's reproducible like I describe.


texts: Access CCK Fields on Content Type EntityFieldQuery()

texts:
Okay, I've spent two days banging my head against the wall, so I'm finally going out for help...

I have a custom content type "eod_report" with a CCK field called "rfqs_received" which stores an integer.

I need to access the value of "rfqs_received" (previous 5 entries per user), but all I get is a list of the nodes themselves. What I want is an array of the queried field values.

How can I get access to the field values? Any help is MUCH appreciated.

    <?php

global $user;
$uid = $user->uid;

$query = new EntityFieldQuery();
$entities = $query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'eod_report')
  ->propertyCondition('uid', $uid)
  ->propertyCondition('status', 1);

  //->fieldCondition('field_rfqs_received', 'value', '6', '<');

$result = $query->execute();
$nids = array_keys($result['node']);
$nodes = node_load_multiple($nids);
$output = node_view_multiple($nodes);

print render($output);
?>

The answer below solved it. To clarify, this was a portion of an attempt to create a custom action that would calculate the average of field values for the last five pieces of content created by a user. The action occurs when content is saved/updated and saves values to the current user's profile. It's a bit sloppy, I think, but it works. I'm still learning... Here's the full code of the action:

    <?php

global $user;
$uid = $user->uid;

// query the database to get the previous 5 eod_reports
$query = new EntityFieldQuery();
$entities = $query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'eod_report')
  ->propertyCondition('uid', 50)
  ->propertyCondition('status', 1)
  ->propertyOrderBy('created', 'DESC')
  ->range(0,5);

$result = $query->execute();

// Collect the $nids of the nodes returned by the query

$nids = array_keys($result['node']);

// Declare an empty array to store the rfq results
$rfqs = array();
$nodes = node_load_multiple($nids);
foreach ($nodes as $node) {
  // Get the field items
  $items = field_get_items('node', $node, 'field_rfqs_received');

  // loop through items, extract rfq values and store to array.
  foreach ($items as $item) {
    // Add to the output array.
   $rfqs[] = field_view_value('node', $node, 'field_rfqs_received', $item);
  }
}

// Declare an empty array to store the order results
$orders = array();
foreach ($nodes as $node) {
    // Get the field items
    $oitems = field_get_items('node', $node, 'field_orders_received');

    // Loop through items, extract order values and store to array.
    foreach ($oitems as $oitem) {
    $orders[] = field_view_value('node', $node, 'field_orders_received', $oitem);
    }
}

// Prepare the loop to sum the rfq results

$rfqSum = 0;
$i = 0;
// Loop through the results and collect a sum
while ($i < 5) {
    $rfqSum = $rfqSum + render($rfqs[$i]);
    $i = $i + 1;
}

// Prepare the loop to sum the order results

$orderSum = 0;
$x = 0;
// Loop through the order array to collect sum
while ($x < 5) {
    $orderSum = $orderSum + render($orders[$x]);
    $x = $x + 1;
}

// Print the Sums

print "
RFQ Sum: " . $rfqSum . "
";
print "
Order Sum: " . $orderSum . "
";

// Calculate the average

$rfqAvg = $rfqSum/5;
$orderAvg = $orderSum/5;

// Print the average
print "
RFQ Avg: " . $rfqAvg . "
";
print "
Order Avg: " . $orderAvg . "
";

// collect the current user information and store the calculated value in the user->field

$existing = user_load($uid);
$edit = (array) $existing;
$edit['field_rfq_average']['und'][0]['value'] = $rfqAvg;
$edit['field_order_average']['und'][0]['value'] = $orderAvg;
user_save($existing, $edit);

?>


texts: How to show thumbnails gallery images in the footer first section?

texts:
i have installed node gallery module as well media gallery but media gallery is not working for my drupal version now i am using node gallery but its show like below image

but i want like


texts: Print an object value from a twig template?

texts: The below object, named 'profile' is available to me in a twig template. I can dump the variables with {{ dump(profile) }}. How do I print the 'created' timestamp? I've tried every variation of code I can think of.


texts: How to import config and content using config import and hook_update_N

texts:
Background: I have config read-only setup on non-development environments. So all configurations (including enabled modules) are created and exported from development site and imported to different environment.

Problem: I need few new content entity types to be imported and add content of those types in database update (i.e. hook_update_N()).

As per https://www.drupal.org/node/2762235, all database updates should run before configuration import. Since my entity definitions are in configuration,  hook_update_N throws fatal that entity types do not exist. I can run config-import after hook_update_N, but it can cause other problems (as mentioned in above d.o issue).

How to import configuration and content in this case?


texts: How can I add a link to the main menu from a custom module?

texts:
I've seen numerous questions on how to address this, but I've not quite found the answer. I'd like to add an additional link to the main menu. I've attempted this in my_module.links.menu.yml and run drush cr. This doesn't seem to limited impact.

This item will show up under the Tools menu, but not main.

my_module.list:
  title: 'List All Computers'
  description: 'Show all known computers'
  route_name: my_module.listAllComputers
  parent: main

Is there something wrong with the above? Is PHP a better way to add a link to the main menu? If so, where? Do I use a Drupal 8 hook?


texts:
How do I display image title in "Manage Display"?

I have add title in my image.　But it is not showing in article.


texts: how to upload multile user profile pics at a time?

texts:
I have used user reg with picture module for uploading user profile picture on registration page but there is option for uploading only one picture at a time .

I am developing social network website there is requirement of uploading multiple user profile pics.

but how its possible?


texts: File upload with ajax and without upload button

texts: Is there any example how to set up form element with type file to upload it via AJAX and without upload button. I want to be same as stackexchange.


texts: Drupal version control - professional development

texts: I have been assigned to develop a site in Drupal. I will be working on it alone. Is there a need for version control? An if yes which is optimal for drupal? How should I set the development process? (ex:make a testing site locally, then get it live). Thank you in advance.


texts: How to use a view as a search result page with facets?

texts:
I've created a pretty nice view with faceted filters following this guy's tutorial. It's basically a cheap way of doing getting the faceted feature without having to set up Solr.

The problem I have is that I would actually like to pre-query the index with some search terms from the homepage with a search form...basically:

search for a term and get redirected to the view with the facets.
use the facets to further filter my nodes.

How would something like this be possible?

Currently I have configured (in the Search API configurations) one server that uses database search as service class, and one Index hooked to that server, which indexes different fields (Content type and three different taxonomy terms) which are exposed as search facets in the view.

Number 2 is basically covered: I have a view page where all the nodes are listed and can be filtered through the facets... what I want is for the users to get to the front page, enter their search query (could have autocomplete or not, I'll figure later) hit "submit" and find all their search results in a page similar to the one I have with the facets... so they can further narrow their search. Kind of like when you look for something in linkedin.


texts: Composer won't update Drupal Core, can't determine what is stopping it

texts:
I am trying to update Drupal Core 8.6.3 to 8.6.5 (which is the latest Core update at time of writing this).

Using this CLI Composer command:

composer update drupal/core --with-dependencies

completes the whole process without errors.

But after clearing Drupal's cache and checking Status Report, it still shows the previous version (8.6.3).

I'm assuming a dependency may be blocking the Core update.

To test this I ran this CLI Composer command:

composer prohibits

and received this error:

[Symfony\Component\Console\Exception\RuntimeException]
  Not enough arguments (missing: "package").

After searching a few forums I could not find a definite explanation of that error's meaning or how to address it.

UPDATE - As per my answer below, I found a solution which was:

I noticed in a few threads that this inclusion kept being referred to as a potential Core update issue:

webflo/drupal-core-require-dev

So I checked my composer.json require list and it was there, specifying the earlier Core version:

    "require-dev": {
    "webflo/drupal-core-require-dev": "8.6.3"
},

To correct this, I ran this CLI Composer Command:

composer update drupal/core webflo/drupal-core-require-dev --with-dependencies

After clearing cache (drush cr) I checked back on my composer.json and the require had changed to:

    "require-dev": {
    "webflo/drupal-core-require-dev": "^8.6.0"
},

This then triggered a Status Report Warning that 2 Tables required update.
To fix this I ran this CLI Command:

drush updatedb

I then successfully run this CLI Composer command:

composer update drupal/core --with-dependencies

After another cache clear, I checked Drupal's Status Report which showed the update to Core had worked.
I was happy with this so (as I was in maintanenace mode during this time) I then used this CLI command to turn off maintenance mode:

drush sset system.maintenance_mode 0

And all is well and working correctly.


texts: Pulling CiviCRM data into a custom Drupal module based on checksum/hash link

texts:
I have a CiviCRM contribution page that allows an individual to renew a membership on behalf of an organization. When we email them from CiviMail with a checksum link to the page, it will prefill their information in the form automatically and have the membership renewal associate correctly to the organization.

How can I pull the organizational information into a custom Drupal module (e.g. a block that displays in the sidebar, for example)? I would like to have a text block that displays some information about the org and potentially names of people who are related to the org by relationships in CiviCRM. I won't have a problem doing that with Views and/or the CiviCRM API in a custom Drupal module, but I'm not sure how to get the org's ID in this scenario, to know which info to display.


texts: updates page shows an error for a mystery module 'standard 8.6.12'

texts:
on the updates page /admin/reports/updates under Modules there is a module called standard 8.6.12 as and it is highlighted with a warning No available releases found (Warning)

this module does not appear when running $ composer outdated

is there any idea where this module is coming from, if it is in fact needing an update, or if this is just a typo in one of the site's config files somewhere?

this is what I see:

I have recently updated to Drupal 8.6.12 (using $ composer update)


texts: What's the preferred method of creating different page templates

texts:
Basically, I want to give my articles and blog entries a different class on the body so I can style them independently.

I am given to understand that the best way to do this is with creating custom tpl files

I'm working in a custom built theme that is pretty much running just on a page.tpl.php and a stylesheet.

How would I do this easily in Drupal 7? I tried this method for drupal 6 but it didn't seem to work.


texts: Does pre-populated body for content types in Drupal 7 affect performance too?

texts:
From highest rated answer of this post (Drupal 6 case):
Does having too many content types negatively affect site speed and performance?

It is said that:

  Sharing fields among the content types does affect the performance.

But when creating new content type in Drupal 7, the body field will be pre-populated. When many content types created, if not deleted, this field will be shared among all content types.

This is the body field as seen in admin/reports/fields:

The question is, does it affect performance? and what is the best to do for performance? Do I need to delete the pre-populated body?


texts:
When I output the main menu this is the html that gets generated:

Home

Page

page

However I'd like to completely restructure the menu like this:

                    SIGN UP
                    LOGIN
                    <a class="main-nav__button animate grid__item xl--1-5 l--1-5 sp s--tbp t--tbp" href="<?php echo $front_page; ?>">HOME
                    LINK 1
                    LINK 2
                    LINK 3
                    LINK 4

How can I change the html output of the menu as well as the links inside?

Ideally I'd like to output any menus as a  element and be able to pass classes and an id to each one, the same also goes for the links inside.

Also the first two links in the menu are login and signup buttons which only display at certain screen sizes and have completely different classes to the rest of the menu links. Is this also possible to do?

I have tried altering the theme_menu_tree and theme_menu_link functions but am having no luck as I am somewhat of a beginner in PHP and Drupal.


texts: How do you programmatically add a homebox block from one homebox page to another?

texts: I have 2 homebox pages and would like to add a homebox block from homebox PAGE_A to PAGE_B programmatically when the user clicks a button. Ideally, this would clone the box from PAGE_A to PAGE_B.


texts:
I am looking for suggestions on Best Practices for D8 and files / media entities. I originally added this as a answer but kiamlaluno evidently felt that it should be a new question in itself so here goes.

I trying to figure out the best way to handle files and media entities. With the increase of development in the file entity module if appears that things are once again getting way over complicated since files can now be a full blown entity. In my opinion this is going to put a lot of people off as to which way is the most practical way to go.

What I would love to see is a tutorial or a write up on best practices of when to use the file field versus the media field and the pros and cons of each. Drupal 8 by default gives us a Article content type which is a file entity. So should we use this for images or delete it and use media fields.

Does anyone know of a recent tutorial or discussion for review?


texts: How to change menu links items title programitically?

texts:
I have created a menu name My Menu (machine name: my_menu ) with menu item My Nodes and My messages. Now I want alter My nodes and My messages link title. So the menu items should look like Nodes and Messages instead of My nodes and My Messages.

So I don't understand and also didn't find how can I alter the menu link title programmatically. i am trying to use hook_menu_alter(&$items) and hook_menu_link_alter(&$item), but it doesn't give any result.

So can anyone please tell me how can I alter the menu link items title?

Thanks in advance


texts: How to translate inline entity form nodes (or, product variations in kickstart)

texts:
My parent nodes need to be translatable - so i'm slated to use the out-of-the box internationalization module for that. However, one of the fields in this content type is an inline entity field which references another content type. Both the parent and the referenced nodes need to be translatable.

Now, is this a job for entity translate? I've tried with no success - but perhaps i'm not using the right combination. Presently if I set both the parent and child nodes to entity translate types I get an ajax error when I try to add the first child node (regardless of which fields are setup).


texts: Filter on boolean with NULL (unset) value

texts:
Client wants to hide some published content from specific Views displays.

Unpublishing the content is not an option: it needs to remain accessible.

I added a boolean exclude_from_view field to several content types.

I planned to add a boolean filter to exclude content from the necessary displays if this field's value was TRUE, but I was surprised to find that when I did so, Views returned no results at all. Setting the boolean filter to NOT FALSE had the same result.

This is happening because the field has been added to the existing content without a default value, so the field returns NULL, which is neither TRUE nor FALSE. (In PHP, NULL is a "falsy" value, but apparently not to Views.)

A little research reveals that a lot of other people have complained about this problem.

Some of them think that boolean fields not set on entities should be considered FALSE, not NULL.

Others wish that NULL fields could be treated as TRUE.

Still others think that Views UI should offer filtering options for "Treat NULL as FALSE" or "Treat NULL as TRUE." (This is a cool idea but it requires patching core, which I'm not necessarily opposed to if it is the best way forward.)

What should I do?

UPDATE 2019-11-13:

Kudos to @no-sssweat for coming up with a viable workaround, which I upvoted below.

I'm still hoping for a better answer because I'm not satisfied with the user experience of the "checkboxes/radio buttons" field widget.

If I just use one value, it shows up as two radio buttons, for N/A and Yes. Adding a No option doesn't make it much better:

I think the client would really prefer a boolean checkbox, so I'm holding out for an answer that will give me that.


texts: How do I revert all of my DB tables from MyISAM back to InnoDB?

texts:
Possible Duplicate:
  How do I convert a database from MyISAM to InnoDB?

Due to a bug in the Backup and Migrate module http://drupal.org/node/1128620 , all of my DB tables were reverted to MyISAM. How to return them all back to to InnoDB. (Perhaps using phpmyadmin?)

I used to use http://drupal.org/project/dbtuner/ in D6 for this. However there isn't a D7 version.

Also, are there any side effects or possible gotchas for switching this in this way?

Update:

<?php
    // connect your database here first
    //
    $sql = "SHOW tables";
    $rs = mysql_query($sql);

    while($row = mysql_fetch_array($rs))
    {
        $tbl = $row[0];
        $sql = "ALTER TABLE $tbl  ENGINE=INNODB";
         mysql_query($sql);
    }
?>

What do I need to add to the section "connect your database here first" to connect to my Drupal DB?


texts:
I have a site on Drupal 7, where I'm using Views with Multilingual settings.
I have 2 languages, Russian and English.

On the front page, I have created a "Latest News" block with Views.
Each news item has a link to the full article like the following ones:

example.com/en/news/1
example.com/ru/news/1

This block is also shown on some other pages, such "Services - > Service 1"  shown at example.com/en/services/service-1.

The problem is that on my block I use global text to format the output of the latest news; the link is built using the following:

[title]

It works fine on the front page, but when I'm on the Services page, the news link is similar to example.com/en/services/news/1,which is incorrect; Drupal gives me an error about a not existing page.

Is there a way to reference the front page with any tag I can use in the "Global Text" settings?


texts: How do you set a one-off access checker on a route?

texts:
As far as we can tell, the "Simplified custom access checker" section of the handbook is outdated. The entirety of CheckProvider seems to be service oriented and this is the provider which has the $route->setOption('_access_checks', $checks); call. In turn, AccessManager::check has a $checks = $route->getOption('_access_checks') ?: array(); call. There's nothing which would accommodate one-off checkers like the handbook page suggests:

requirements:
  _custom_access: '\Drupal\example\Controller\ExampleController::access'

and based on our debugging, this is indeed not working. What is the current way, if any, to do this?


texts:
I would like to add some custom stylesheets for specific theme.

for example:
Bartik is default and Seven is the Administration theme.

In this case, I want to add some custom styles for only Bartik front-end theme.

How can I customize the following code for the Bartik theme?

<?php
/**
 * Implements hook_init().
 */
function mymodule_init() {
    $path = drupal_get_path('module', 'mymodule');
    drupal_add_css(
        $path . '/custom.css',
        array(
            'group' => CSS_THEME,
            'every_page' => TRUE,
        )
    );
}
?>


texts: How to add Wishlist button field in views in drupal 7?

texts:
I am working on commerce site. In my site I have 3 views & each view have display 3 products. If user can first visit the product then user get the wishlist button but I want to show "add to cart" or "wishlist" or "buy" button with all the products so user can directly purchase, no need to visit.

I already created Relation : "Content: Referenced products" & add Field : "Commerce Product: Add to Cart form". But no button show below product. Please help to solve. Thanks


texts: Return a 404 when a view pane in a page manager page has no result?

texts:
When you have a view page that takes a contextual filter, you can easily set the no result behavior to a 404. But I am trying to do this when I have a view pane, in a page manager page like in the screenshot attached

If the view has no result (contextual fitter does not validate) I would like the page to return a 404.


texts:
I'm trying to find all the absolute URLs in a site (in wysiwyg content, url fields, config) to convert them into relative URLs later via manual administration. All the URLs in question are within the same Drupal site. I've managed to use PHPMyAdmin to find and record readily-accessible entities that contain absolute urls (nodes - /node/NID/edit, menu items - /admin/structure/menu/item/MLID/edit, etc.). However, I'm having a difficult time with Paragraphs.

The id of a paragraph field row is for a specific instance of the paragraph.
Without knowledge of the field hosting the paragraph, the instance could be anywhere.
The paragraph could be nested in another paragraph.

How would one go about solving this issue? How do I find the host node of paragraphs containing an absolute link?


texts: Values from $node object in Views Contexual Filter

texts:
I'd like to create a PHP contexual filter for a view.

This code isn't right, but I want something like this:

global $node;
if ($node->type=="ABC") {
return 5880;
}

if ($node->type=="XYZ") {
return 6200;
}

How do I access the $node object in a PHP contexual filter?

Also, is there a better way to debug/troubleshoot this? I feel like I'm operating in complete darkness.


texts: Customizing the display of properties on a rendered entity

texts:
I have a custom entity with a large amount of properties on it.

We want to format these entity properties to look a certain way, without modifying the underlying data in the table.

What is the most idiomatic (the most Drupal) way of doing it?

We're trying to put an Entity Reference of this custom entity on a node and render only a few fields - with a form of preprocessing or something along those lines so that we can control the ultimate output.

I can get the fields to show with this key => value pair in the entity array in hook_entity_info():

'extra fields controller class' => 'EntityDefaultExtraFieldsController',

But it doesn't seem to give me any control over the output.

Alternatively, I can put all of the properties into $entity->content in hook_entity_view() as such:

foreach ($entity as $field_name => $property) {
  if (in_array($field_name, $properties)) {
    $entity->content[$field_name] = array("#markup" => $property . "<br />");
  }

But this doesn't seem very idiomatic.

This seems like a problem that I can't find a lot of resources on.


texts:
Team,
Is it possible to update individual package of drupal core? I am new to drupal and using drupal 8.9.3.
For example:
Drupal core 8.9.3 has twig 1.38.2. I want to update twig to 1.44.2.
I tried to update Twig to 1.44.2 and composer show --all displays the twig version as 1.44.2. However, composer.lock shows

twig version 1.44.2 as a twig package
twig version 1.38.2 as dependnency package for drupal/core.

Can someone help me how can we update the twig package from 1.38.2 to 1.44.2 without updating drupal/core?


texts: Alternatives to Messaging and Notifications

texts:
I maintain a Drupal 6 site for a team of scuba-divers.
Given the discontinued support for Drupal 6, I am looking at upgrading the site to Drupal 7.

We primarily communicate by e-mail, so we have set up a Messaging+Notifications thing, where users can subscribe to new nodes of a given node-type, with one primary purpose: When a boat-commander arranges a new diving trip (node-type) all interested divers receive a notification mail, so they can sign-in to the trip.
The same functionality goes for clubhouse events and articles in general (secondary).

Mails are formatted so, that they contain a link to the node on the site (obviously), and they also contain a link to unsubscribe to further mails of same kind.

It seems Messaging+Notifications are not (actively) maintained on D7, so I am looking for an alternative.

I have tried a Commons distro, but I just cannot get the grasp of the Messages (log?) and Flags concept. It seems to me that it is build to click-to-follow existing posts, but I want to have the option to always follow posts of a certain kind.

Am I misunderstanding the Messages module, or am I looking at a wrong module?


texts: I am trying to install and work with Drush for my Drupal 6.22 site. However, on the modele's page I can only find the module's tar.gz package for Drupal 7. nor can I find D6 package elsewhere. So appreciate your help.


texts: Search Form block not displaying in Home Page

texts:
I am using drupal 7.9 with the Bartik theme.
I have configured 'Search Form' block in header area.

It is displayed on all pages, but not in the home page.

Then I customized the page.tpl.php file with the following snippet:

if($page['header']['search_form']):
  print render($page['header']['search_form']);
endif;

But this doesn't solve my problem.
Does anybody know how to solve this?


texts: JS/CSS aggregation not creating css folder

texts:
I am creating a Drupal 8 website with a custom theme.
When css and js aggregation checkboxes are checked, js directory is created in sites/default/files/, however css folder does not get created.

Also all js and css is not working.

When I ran this command in terminal ls -l sites/default/ I get the following line for files folder

drwxrwxrwx  7 admin  staff    224 May 10 10:30 files

Would there be any reason the site does not create css folder in sites/default/files?

Thanks in advance.


texts: How do I find out the content type within template.php?

texts:
I'm using THEME_page_alter to give my site a meta description, and is working fine.
However I can't find the variable which defines the content type - I need to use it as an argument to give different pages different descriptions. I tried $node->type

Side question: where on earth can I find answers for such simple tasks like this without having to ask in DA? I did a lot of Googling and looking in the API, and looking at the Globals list... but it seems like the official Drupal documentation doesn't make things easy for you in some respects.

Thanks


texts: How to overwrite a file upload so that the filename is always the same?

texts:
I am trying to implement a file upload form in which files are saved. I had written the following code

<?php

/**
 * @file
 * Contains \Drupal\avenue_product_import\Form\avenue_product_importForm.
 */

namespace Drupal\avenue_product_import\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\file\Entity\File;

class AvenueForm extends FormBase {

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

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

    $form['description'] = [
      '#markup' => '
Use this form to upload a CSV file of Data
',
    ];

    $form['import_csv'] = [
      '#type'              => 'managed_file',
      '#title'             => t('Upload file here'),
      '#upload_location'   => 'public://importcsv/',
      '#default_value'     => '',
      "#upload_validators" => ["file_validate_extensions" => ["csv"]],
      '#states'            => [
        'visible' => [
          ':input[name="File_type"]' => ['value' => t('Upload Your File')],
        ],
      ],
    ];

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

    $form['actions']['submit'] = [
      '#type'        => 'submit',
      '#value'       => $this->t('Upload CSV'),
      '#button_type' => 'primary',
    ];

    return $form;
  }

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

    /* Fetch the array of the file stored temporarily in database */
    $csv_file = $form_state->getValue('import_csv');

    /* Load the object of the file by it's fid */
    $file = File::load($csv_file[0]);

    /* Set the status flag permanent of the file object */
    $file->setPermanent();

    /* Save the file in database */
    $file->save();

    drupal_set_message('File Uploaded Successfully');
  }

}

But here the problem is if the filename in which I am uploading is same. It is getting renamed. But I want to replace old with the new one. How can I achieve this? I had seen file_move() and file_save_upload() function. What changes should I make to replace existing filename with the newly uploaded CSV file?


texts: create a custom field which is allowing multiple values using custom module

texts: I created custom content type and one custom field(text) successfully. But my requirement is, my custom field should allow to add multiple values.


texts: how to save taxonomy terms in a custom user registration form in D7?

texts:
I've got an Implementation of hook_form() on a custom page which I use for user registration.

For example I have this field:

function popover_form($form, &$form_state){

    // some other fields are left out here to simplify my question

    $form['second']['education'] = array(
      '#type' => 'radios',
      '#title' => 'Afgeronde opleiding',
      '#options' => popover_get_tax_term_options('education'),
      '#default_value' => variable_get('education', NULL),
      '#required' => TRUE,
    );
    return $form;
}

Then in form_submit() I'm trying to do this:

function popover_form_submit($form, &$form_state){
  $edit = array(

    // some other fields like username, email etc are also left out here.

    // field_firstname is a simple string and works.
    'field_firstname' => array(LANGUAGE_NONE => array(array('value' => $form_state['values']['first']['field_firstname']))),
    // education doesn't work ( because it is a taxonomy term ? )
    'education' => array(LANGUAGE_NONE => array(array('value' => $form_state['values']['second']['education']))),
  );
  user_save(drupal_anonymous_user(), $edit);
}

so either I need to change my submit handler because taxonomy terms are saved differently or I need to update the standard user edit 'view' ( $sitename/user/1/edit ) so the taxonomy terms become visible? Or I'm doing something else wrong?

EDIT:
I also found out that it is needed to connect taxonomy terms with the user on the admin/config/people/accounts/fields page before you can get this to work.


texts: Flags: get Action after a user flagged a specific number of nodes?

texts:
I would like the users of my site to choose a specific number of nodes. After this they should see, to which taxonomy term these nodes belong to.

I have already found the flag module as well as flag limiter module. I have put the limit to 12 (This is the amount of nodes the user should be able to choose).

Now I would like that the user is redirected to a new page (where he can see the belongig taxonomy terms to his flagged nodes - this I can manage to create with views), after he flagged the 12th node.

Could anyone help me, how to achieve this?

Thanks,
Tabea


texts:
I have a pricing rule to do some items free.
User can purchase only 3 items per month.

Question is how to programmatically get count of free items purchased by user?


texts: Ajax Forms created by Ajax Drupal 7 ERROR JAVASCRIPT

texts:
I read a lot of documentation, specially this post https://www.drupal.org/node/2009252 but doesnt work for me.

This is my code, and the main problem is that i dont get the javascript in function hcat_my_account_create_companion_ajax_callback from the page callback 'my-account/ajax/create-companion' then I cant send my form by ajax.

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

    $items['my-account/ajax/create-companion'] = array(
        'page callback' => 'hcat_my_account_create_companion_ajax_callback',
        'access callback' => TRUE,
     );

    return $items;
}

function hcat_my_account_create_companion_ajax_callback($form, &$form_state) {

    $submission = (object) array();
    $form = render(drupal_get_form('hcat_my_account_acomp_form', null, $submission, true, false));

    $settings = FALSE;
    $javascript = drupal_add_js(NULL, NULL);
    if(isset($javascript['settings'], $javascript['settings']['data'])) {
        $settings = '';
    }

    form_load_include($form_state, 'inc', 'node', 'node.pages');
//I CANT PASS ANY JAVASCRIPT. WILL DISAPPEAR.
    return "
".$form.$settings."
";
}

function hcat_my_account_acomp_form($form, &$form_state, $vars) {

    $form['hola'] = array(
        '#type' => 'textfield',
        '#default_value' => "Vamos",
        '#attributes' => array('class' => array('my-account-input-edit')),
    );
    $form['submit_save'] = array(
          '#type' => 'submit',
          '#value' => 'Vamos que te quda poco',
          '#ajax' => array(
                'callback' => "hcat_my_account_create_attend_form_submit_ajax",
                'wrapper' => "hcat-my-account-acomp-form",
                'method' => 'replace',
                'effect' => 'fade',
              ),
    );

    form_load_include($form_state, 'inc', 'node', 'node.pages');

    return $form;
}

function hcat_my_account_create_attend_form_submit_ajax($form, &$form_state) {
    return "Desde la funcion hcat_my_account_create_attend_form_submit_ajax";
}


texts: Views 3 : Set header/footer/empty text for view via views_embed_view

texts:
I update my views from views 2 and I do the same on embedded code. But actually I can't set footer content as it changes in views 3.

My views 2 code :

$emptyTextVue = $view->display_handler->get_option('empty');
$emptyText = $view->display_handler->set_option('empty','
Pas images.
');

I think I do use the export code like :

$handler->display->display_options['empty']['area']['content'] = 'Pas d\'images à afficher.';

but how ?

EDIT : extract result for var_dump() : ["handler_type"]=> string(5) "empty" ["options"]=> array(11) { ["id"]=> string(4) "area" ["table"]=> string(5) "views" ["field"]=> string(4) "area" ["relationship"]=> string(4) "none" ["group_type"]=> string(5) "group" ["ui_name"]=> string(0) "" ["label"]=> string(13) "Zone de texte" ["empty"]=> int(0) ["content"]=> string(25) "Pas d'images à afficher." ["format"]=> string(1) "2" ["tokenize"]=> int(0) } ["definition"]=> array(4) { ["handler"]=> string(23) "views_handler_area_text" ["group"]=> string(6) "Global" ["title"]=> string(13) "Zone de texte" ["help"]=> string(33) "Provide markup text for the area." } ["is_handler"]=> bool(true) ["localization_keys"]=> array(4) { [0]=> string(7) "default" [1]=> string(5) "empty" [2]=> string(5) "views" [3]=> string(4) "area" } ["table"]=>


texts: How to display result of a View in a specific block?

texts:
I have a View displaying the content of a Custom Content Entity.
The first output I created is a Page display (accessible with a path and an option in a menu).
As expected, this is displayed in the 'Content' region of the default theme (see capture below).
I'd like to output the result in a full width region of the theme, i.e. without the content of 'Sidebar First' (User account menu, Search).
I duplicated the Page Display as a Block Display and placed it. But, of course, it appears on every page of the site :-(
So I created a single basic page (node/xx) and I configured the block to show only in this page. But I had to hide 'User account menu' and 'Search' on this page too.
Is there a more simple way to achieve this?


texts:
I want to place put a block in a view page. Let's say the news page, whose path is http://www.example.com/news.

The view uses pager to list the content.

I want a block to show up only in the very first page of the news page (http://www.example.com/news), excluding from paginated pages, such as news?page=1, news?page=2.

I set the visibility to only list in news, but the block still shows up in news?page=1, news?page=2.

How can I show a block in a view page, excluding its paginated pages?


texts: admin/content/comment/approval -> 410 Gone error (linked from content -> comments -> unapproved comments)

texts:
I have no idea when this happened (I've been trying to fix Mollom + PostgreSQL, to the point where I tried, and removed, some core patches), but when I go to Content / Comments / Unapproved Comments (which leads to admin/content/comment/approval) I get a 410 Gone error.

Was this supposed to be a view? How does one recreate such core views? Is the link the result of some module long since uninstalled?


texts: How do I stop getting the "Google Maps API included multiple times on this page" error?

texts:
I'm pretty new at Drupal 7.

I keep on getting this error You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

I have a custom module which displays a map based on the address provided by the user into a form.

In order to get the map working properly, I had to add the following:

In the .info file

scripts[] = google_map_api.js
scripts[] = gmaps.js

In the .module file

function new_company_init() {
  drupal_add_js('http://maps.google.com/maps/api/js?sensor=true', 'external');
}

If I remove any of the 3 above statments, the map is not working.

I have been searching on the net but could not find any answer.
I do not want to use a module to manage the map.


texts: know if the last cron run automatically or manually?

texts: Is there a way to know if the last cron run automatically or manually from the form "run cron" button?


texts: Taxonomy terms follow/unfollow module (even for anonymous users)

texts:
I want a subscriptions/notifications like module which works for anonymous users too.

Users should be able to subscribe to a taxonomy term, and then be alerted if content is created for that term.

Subscriptions work great but the lack of support for an anonymous user is quite disappointing. I don't get why we can't send a verification mail for any anonyomous user based subscription.

Any Drupal Module which does that?


texts:
I've created a content type: seller and with pathauto module I've set this content type to be seller/[node:title] so every new seller content will be www.example.com/seller/[name_of_the_seller].

I want to add gmap objects in every seller page with only their objects will be visible. (for this detail I'll open a new thread, 'cos I'm not sure how to filter that)

With Views module I've added a page with url:  /seller/%

and in contextual filters I've added Content: Nid.
In When the filter value is NOT in the URL I've selected Provide default value and in the field bellow I've put seller.
That didn't worked, so I've tried with Raw value from URL and checked Use path alias.
That didn't worked too. I've searched couple of other threads, but I didn't find like my problem.

UPDATE

I've solved the problem by creating a block that is displayed seller/*. The two content types has a same taxonomy terms and with contextual filters  Content: Has taxonomy term ID, Provide default value, Taxonomy term ID from URL, I've marked Load default filter from node page, that's good for related taxonomy blocks and Limit terms by vocabulary and I've selected the seller taxonomy.


texts: Trying to use EntityFieldQuery to find all nodes with a node reference field not set

texts:
After some searching the closest code snippet I've found is:

->fieldCondition('field_name_ref', 'nid', 'NULL', '!=');

This will find everything where the node reference is not null. But if I change the != to = it returns nothing. I've tried all the combinations of values I can think of:

Passing in NULL instead of 'NULL'.
Passing in array()
Trying 1, "<"
"", "CONTAINS"
"", "="
0, "="

Plus a few more, just trying all the combinations I can think of.

How can I pull this off?


texts: How can I override theme for the user login page in Drupal 7? By default, that page takes the default theme style.


texts: In panels, does the right region get its argument from the left?

texts:
I plan to have a panel page with two regions:
- on left, a panel of one author
- on right, a view of all the stories written by that author.

I don't yet know how the user arrives at this page (my understanding of panels is still in its infancy).

Does the right panel get its argument from the left panel? Or somewhere else?

If the left panel node has Node ID 62, does the view (right panel) need to be sorted in node ID order (with a contextual filter)?


texts: Get all users with specific roles using EntityFieldQuery

texts:
I thought this was an easy task, yet there does not seem to be a Drupal-method for this. I came as far as knowing I have to use EntityFieldQuery for this - because the API said conditions for user_load_multiple() are deprecated.

So I tried this:

  $query = new EntityFieldQuery;
  $query
    ->entityCondition('entity_type', 'user')
    ->propertyCondition('rid',array(1,2,3);

  $result = $query->execute();

Yet I got this:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'users.rid' in 'where clause': SELECT users.uid AS entity_id,
  :entity_type AS entity_type, NULL AS revision_id, :bundle AS bundle
  FROM {users} users WHERE (users.rid = :db_condition_placeholder_0) ;
  Array ( [:db_condition_placeholder_0] => 3 [:entity_type] => user
  [:bundle] => user ) in EntityFieldQuery->execute()

So my first thought was, that I'd have to join with users_roles-Table and so on, but that will lead to duplicates.

Does anyone have an idea how to do it?


texts: Webservice endpoint with hook_services_resources()

texts:
I've stumbled upon some limitations of the services module. I wanted to create the following endpoints:

public/events/
public/events/categories
public/events/resources
public/blogs/

I wanted to place all the above under a single endpoint with path "public/".
However, in the hook_services_resources the following is invalid:

/**
 * Implements hook_services_resources().
*/
function kw_api_services_resources() {
  $service_resources =
   'event/categories' => array(
      'operations' => array(
        'index' => array(

I ended up using two endpoints public/events and public/blogs. Is there a way to get around this? Meaning to user deeper than 1 level URLs.


texts: Show cached pages with boost for logged in users

texts:
I have a website that is only available to logged in users, I want to increase performance with boost by caching pages for authenticated users would i just edit the code above?

http://drupal.org/node/509694

here it says this code is what prevents boost from caching for logged in users

<?php
  // For authenticated users, set a special cookie to prevent them
  // inadvertently getting served pages from the static page cache.
  if (!empty($user->uid)) {
    boost_set_cookie($user);
  }


texts:
I want to add 3 fields to my articles:

repeatable (boolean)

unlimited values for repeat_date and repeat_comment

I created the fields and with fields dependency I made the it possible that repeat_date and repeat_comment only appear if repeatable is checked. I can also create an unlimited number of values for repeat_date and repeat_comment.
But these 2 fields are independet of another. I could create 2 values of repeat_date entries and 4 values of repeat_comment. Also those fields appear separate when editing articles.
How can I combine those 2 fields and have unlimited values for this combined fields?


texts: Different attribute selection widget in a view

texts:
I have a product display that lists multiple products with various pack sizes.
I added a taxonomy field to a Product for the attribute
e.g.
T shirt 1 pack
T shirt 3 pack

I have set the product display to list the pack sizes as a radio list for selection. Easy enough, in Configure Taxonomy Field I just set the "Enable this field to function as an attribute field on Add to Cart forms." and set the attribute selection widget to Radio buttons.

I would also like to show all the product displays in a view, also easy however, I would like the add to cart form in the view to display the pack sizes as a Select list.

T Shirt > dropdown 1 & 3 pack
Trousers > dropdown 1 & 3 pack

Any suggestions how I can achieve this?