texts: How to hide View Page Menu if there is no content?

texts:
I'm using the Views module (7.x-3.14) and I have a news view which shows all the articles on a page. I also have its Menu settings set to Normal, thus adding News to my navigation.

This works as expected; however, if there are no articles published, I would like the News link not to be added to my navigation. Essentially I would like a No results behavior for the menu.

Is there a way to accomplish this?

EDIT: I'm using Zurb_Foundation as my base theme which uses a custom function to create the menu that is called in preprocess_page. What I was attempting to do remove News from the menu at this point.

function theme_links__topbar_main_menu(&$variables) {
  // We need to fetch the links ourselves because we need the entire tree.
  $links = menu_tree_output(menu_tree_all_data(variable_get('menu_main_links_source',     'main-menu')));
  foreach ($links as $link){
    if(is_array($link) && array_key_exists('#title', $link)) {
      if($link['#title'] == 'News'){
        $view = views_get_view('news');
        echo count($view->result);
        echo $view->total_rows;
      }
    }
  }
  $output = _zurb_foundation_links($links);
  $variables['attributes']['class'][] = 'right';

  return '<ul' . drupal_attributes($variables['attributes']) . '>' . $output . '</ul>';
}

count($view->results) returns 0 and $view->total_rows returns NULL even though there should be results.


texts: What is the best way to overwrite a node display with a view

texts:
I would like to know what is the best way display a view instead of the content page. This is to have the versatility of views when showing fields instead of the traditional view mode. My current setup is:

Use Panelizar to manage node display
Create a view block with the node id as contextual filters
Add this block to the panelized panel

My question is: is there a better way? Maybe one that does not require an external module?

Thanks


texts: How to print a block in node.tpl.php only for admin?

texts:
What is the simplest code that checks if user is admin and then prints a block to that user in node.tpl.php? I have seen different examples, but they are all either complicated and deal with other problems at the same time or they include editing template.php, which I want to avoid. I have tried with this, but it doesn't work:

<?php if ($is_admin->true): ?>
<?php print views_embed_view('myview','block'); ?>
<?php endif; ?>

Is there such a simple way to achieve this?


texts:
I have been looking searching for a while and couldn't find anything related to Drupal 8. There are Modules like Taxonomy Menu but unfortunately not for Drupal 8 which works accordingly.

Is there already any solution to build-up a menu out of the taxonomy terms for Drupal 8 without an individual development (php etc.)?

Further, I have realized when I create a taxonomy term and create a reference from a content I don't get the overview of contents linked to the term.

Hope my point is clear.


texts: Custom region twig template for region into node twig template

texts:
I did add a custom region to my theme via my .info.yml file :

regions:
  node_col_1: 'Bloc pour colonne 1'

and in my .theme file to make it available for node template:

function starterpf_d8_preprocess_node(&$variables) {
  // Allowed view modes
  $view_mode = $variables['view_mode']; // Retrieve view mode
  $allowed_view_modes = ['full']; // Array of allowed view modes (for performance so as to not execute on unneeded nodes)

  // If view mode is in allowed view modes list, pass to starterpf_d8_add_regions_to_node()
  if(in_array($view_mode, $allowed_view_modes)) {
    // Allowed regions (for performance so as to not execute for unneeded region)
    // Liste des régions utilisées directement dans les node.html.twig
    $allowed_regions = [
      'pole_col1','pole_col2','pole_col3','pole_col4',
      'node_col_1','node_col_2','node_col_3','node_col_4','node_col_5',
      'revue_presse','sortie_action','actuAssociation','projets','intervenants'
      ];
    starterpf_d8_add_regions_to_node($allowed_regions, $variables);
  }
}

/**
* THEME_add_regions_to_node
*/

function starterpf_d8_add_regions_to_node($allowed_regions, &$variables) {
  // Retrieve active theme
  $theme = \Drupal::theme()->getActiveTheme()->getName();

  // Retrieve theme regions
  $available_regions = system_region_list($theme, 'REGIONS_ALL');

  // Validate allowed regions with available regions
  $regions = array_intersect(array_keys($available_regions), $allowed_regions);

  // For each region
  foreach ($regions as $key => $region) {

    // Load region blocks
    $blocks = entity_load_multiple_by_properties('block', array('theme' => $theme, 'region' => $region));

    // Sort ‘em
    uasort($blocks, 'Drupal\block\Entity\Block::sort');

    // Capture viewable blocks and their settings to $build
    $build = array();
    foreach ($blocks as $key => $block) {
      if ($block->access('view')) {
        $build[$key] = entity_view($block, 'block');
      }
    }

    // Add build to region
    $variables[$region] = $build;
  }
}

Then I try to apply a custom template for this region but it seem not to work,and twig doesn't provide suggestions like for block,field,etc..
My file is called : region--node_col_1.html.twig
His content:

{%
  set classes = [
    'region',
    'region-' ~ region|clean_class,
  ]
%}
{% if content %}
  <div{{ attributes.addClass(classes) }}>
    {{ content }}
  </div>
{% endif %}

What do I miss ?
Thanks for help

EDIT: After test, template suggestion work for custom region added to page.html.twig but not for region added to a node.html.twig...folder structure seem not to be the way,most probably a hook in .theme file.

EDIT : someone could help me for the theme_suggestions_block_alter ?


texts: Taxonomy term page $content is empty but shows up later

texts:
I have a taxonomy override page called taxonomy-term--listing-category.tpl.php.

As far as I'm aware I'm supposed to (as per documentation) use <?php render($content); ?> when the part in my template comes to spill all the items (teasers) associated with the taxonomy term.  I'm fine with this.

Except it's empty.

Let me be clear, there are 14 items associated with this term, and they do show up, after my template in the HTML structure, as if I missed it in my template and Drupal is trying to pick up my slack.

Using Xdebug (hooked into my phpstorm) I have discovered that the $content array is 0, it's empty. None of the node items associated with the taxonomy term is available to display IN my template, they simply don't exist in any registered variable.  And as such, shows up AFTER my template.

What gives?


texts:
I use drupal6 and views2. I need to create xml file using views. This can be done easily using any xml export module but I am not able to create deeper nested xml output like:

    <itemslist>
     <items>
      <item>
       <item_nbr></item_nbr>
       <item_pic></item_pic>
      </item>
     </items>
    </itemslist>

Can anybody point me to the right direction?
Thank you.


texts: How to pre-populate multiple "field collection" fields in node form

texts:
I'm building a multistep node add form where you upload a zip of files on page 1, let the module read file names into an array when the uploader presses the "next" button, and then allows the uploader to enter some meta info for each file on page 2. I have set up the field collection "field_files" to hold info for each file.

However, I can't seem to figure out how to generate the field collection form code for page 2. I would like it to be pre-populated with one field collection entry for each file. I've been reading module source code and huge var_dumps all day without getting anywhere. Does anyone know if this is even possible, and if it is, what would be the best way to do it?


texts: Custom Block Class with custom Template, cache issue

texts:
I need add a custom block in my website, this block must show some users values (from customs fields).

I can show all user variables I want but if a user value change for some reason, I must clear all caches for get the news values from the page where is showed my custom block.

I checked the drupal 8 cache API and try find some example, but I don't find how I do for my variables aren't cached. (or cached but refresh when datas user change)

My code is very simple, I have this hook theme (in my .module) :

function main_menu_theme($existing, $type, $theme, $path)
{
  $theme=array();
  $theme['block__main_menu_quick_stat_block'] = array(
    'base hook' => 'block',
    // 'render element' => 'block', // I tried with and without this line..
  );
  return $theme;
}

This is the build method from my Block Class:

class MainMenuQuickStatBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];

    // Get the currect Drupal User
    $user = _getCurrentUser();

//I tried this...
//  $build['main_menu_quick_stat_block'] = array(
//    '#one' => $user->customfieldone->value,
//    '#two' => $user->customfieldtwo->value,
//  );
//  return $build;

//I tried this...
//    return array(
//      'main_menu_quick_stat_block' => array(
//        '#cache' => array('max-age' => 0),
//        '#one' => $user->customfieldone->value,
//        '#two' => $user->customfieldtwo->value,
//      ),
//    );

//Last try..
    return array(
        '#one' => $user->customfieldone->value,
        '#two' => $user->customfieldtwo->value,
        '#cache' => [
          'max-age' => 0,
          // 'contexts' => ['user',], // I tried this
          // 'contexts' => 'user', // I tried this
        ],
    );
  }
}

For my custom template, I copied the default block.html.twig template from the theme directory.
I can show variables "one" and "two" from the webpage thanks to the custom template. But impossible to configure theses variables for they become uncacheable !

I also try with cache tags but no success..

EDIT 1 (after 4k4 detailed answer !)

This is my last try :
From my custom Block Class :

class MainMenuQuickStatBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];
    $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());

    //$user = \Drupal::currentUser(); // If I use this way, I get this error in the "'tags' => $user->getCacheTags()," below : "Error: Call to undefined method Drupal\Core\Session\AccountProxy::getCacheTags() in Drupal\main_menu\Plugin\Block\MainMenuQuickStatBlock->build() (line 52 of modules/custom/main_menu/src/Plugin/Block/MainMenuQuickStatBlock.php)."

    $var1 = $user->field_field1->value; //If a log var1, I get a value here ($var1 = 7 by example)
    $var2 = 42; //its a test

    return [
        '#theme' => 'block__main_menu_quick_stat_block',
        '#test' => 42,
        '#var1' => $var1,
        '#cache' => [
          'contexts' => ['user'],
          'tags' => $user->getCacheTags(),
        ],
    ];
  }
}

From my .module file :

...
function main_menu_theme($existing, $type, $theme, $path)
{
  $theme=array();
  $theme['block__main_menu_quick_stat_block'] = array(
    'variables' => [
      'var1' => NULL,
      'test' => NULL,
    ],
  );

  return $theme;
}

I cleared caches (drush cr)

My custom template block is called when I load the page, but variables 'var1' and 'test' are null. Below, I log variables array with "{{ kint() }}" in my custom template :

I'm going to find drupal guide for know why my vars are null...


texts: Automatically fill the default vocabulary term associated with a content type when editing a node

texts:
What I'm trying to do is to automatically select the default term in the "add content" page based on the user's location in the site.

Example:
User is currently viewing classifieds listed under "Los Angeles", which is in "California", which is in the "Locations" vocabulary.
I want to automatically set the default value of the "Locations" vocabulary shown in the the content form for new classifieds to the term that identifies the area they are viewing.

Is this possible?

NOTE: I'm not referring to GeoIP or locations-based modules. I'm just looking for a way to automatically select the term they are already viewing, and use it for the node being created.


texts: Specify what the Facebook "Like it" button shows on Facebook

texts:
On our website we have a Facebook "Like it" button, which works fine, but if someone "likes" us, Facebook shows an ugly picture.

As we want Facebook to link to the same content on every page, also on pages which are not driven by a node but by a view, this makes Drupal node based meta tags and open graph useless, is it?

How can we tell Facebook what to show about our website?


texts: Is there a "description" field for Rules actions?

texts:
I have several rules that are very complicated and have many steps.  Even though I am the only web developer, I often have to study rules I have written a bit to remember how they work.

Does the Rules module have "description" fields somewhere like Views so developers can make notes to other developers/themselves?  Surely other people must have this same problem...


texts: Administrator notification on user registration

texts:
Administrator is not notified when a user registers on my D7 site, while the registrants do receive a message. On the D6 version of the site it worked. Here's the setup:

Drupal 7.10
User registration is upon admin approval.
Contact users works.

I can't find a flag anywhere to turn on notification to administrator. Google search and search on this site has not turned up a solution. Is this capability in core, how do I turn it on. Do I have to use additional module?

Thanks.


texts: Services 3 - updating a custom field in a user account

texts:
I'm using Postman in Chrome to test my services. I'm sucessfully able to create user accounts using the following:

Headers:

Content-Type /application/x-www-form-urlencoded
X-CSRF-Token 84t_NqiZcxiK42Obcy4aIpT7oxhar4DJvf7hIvRSxJE

x-www-form-urlencoded data

Name = testname1
mail = testmail1@localhost.com
pass = pass

This works, but to update a custom field, nothing seems to work. My field is a text field with the machine name field_test_text, I've tried adding the value

field_test_text[und][0][value] = TEST

But this doesn't work, however the user is still created.


texts: How can I find which modules alter my form?

texts:
Is there a way to debug the list of modules which alters my form (using form_ID).

I can get a list of modules implementing hook_form_alter using module_implements('form_alter') but how can I know which form they are altering?

I need a function which takes my form_id as input and returns the list of modules which alters it.

I want to create a drupal page in which a textbox gets input from developers and returns that modules which alters it.


texts: Show Active terms from vocabulary using taxonomy menu

texts:
What i want: Active terms of vocabulary in main menu.

What i have done so far:

I have used taxonomy_menu module.
Created taxonomy(Category).
Added "Status" field having boolean values (0 = Inactive, 1 = Active).
Added two terms in Category(Cat1 and Cat2).
Cat1 = Active, Cat2 = Inactive.
Configured menu from "Edit vocabulary" section.

Problem: All terms of vocabulary are included in main menu. I want that only those terms whose Status = Active should be displayed in main menu.

Community, please help. Any hint would be helpful.


texts:
I'm looking to create a page on my site that will allow certain users to perform administrative tasks without them needing to have access to the entire administrative back end.

I want to create a page/form that will allow my user to:

Change the default logo (like is on the Appearance page)
Change the site slogan
Put the site into maintenance mode/Change the maintenance mode
text

I have no doubt there is not a module out there with this capability, so I assume I am going to have to make use of the form API, but I was wondering if anyone could give me a point in the right direction.

Kind regards


texts: Setting date-based filter criteria in Views

texts:
All,

I have created a Content Type which includes a field of type Date. I would like to create a Views filter such that only those nodes whose date falls within the current month are selected. Can someone please show me how to accomplish this.

Thank you.

I did some more digging and believe that the best approach is to use PHP Views. I installed the module, wrote my 'challenging' code, but am not getting the expected results.

For debugging purposes, I created the following output field code:

<?php
$field_forumdate = $data->_field_data['nid']['entity']->field_forumdate['und']['0']['value'];
$forumdate=strtotime($field_forumdate);
$currdate=time();
$nc = date('n', $currdate);
$nf = date('n', $forumdate);
$tflag = 'false';
if ($nc == $nf) {
  $tflag = 'true';
}
print 'Current month: ' . $nc . ', Forum month: ' . $nf . ', tflag: ' . $tflag;
?>

I created three Content types, and set the ForumDate fields to dates in October, November, and December. Looking at the preview, I see the following:

Current month: 12, Forum month: 12, tflag: true
Current month: 12, Forum month: 11, tflag: false
Current month: 12, Forum month: 10, tflag: false

Next, I created my filter code - which is identical to the above:

$field_forumdate = $data->_field_data['nid']['entity']->field_forumdate['und']['0']['value'];
$forumdate=strtotime($field_forumdate);
$currdate=time();
$nc = date('n', $currdate);
$nf = date('n', $forumdate);
if ($nc != $nf) {
  return TRUE;
}

The problem is that all three nodes are still being returned, i.e., the filter does not seem to be filtering. Please help!


texts: What causes 'Invalid form POST data' when removing an attached file from a node?

texts:
I have an attached PDF file on a file field. When I click the 'Remove' button, the AJAX throbber appears and then the file remains unremoved. Adding an file to a new node still works.

I checked the error logs; it states "Invalid form POST data."

What is causing this problem?


texts: Drupal 7 - field template - $item - img tag

texts:
In drupal 7 theme, I have the following file:

field--field_photo.tpl.php
     clearfix">

    >:

    >
     $item) : ?>
    ">

Inside render($item) lies an image with img tag
How I may deconstruct this item, so that I write my code with img tag?
The reason is just that I want to add a class to this img tag. thanks

The path to the images are save in public:files format


texts:
I'm continuously getting the error: Drupal\Core\Config\Schema\SchemaIncompleteException: Incomplete or missing schema for mymodule.myentity.myentityname in Drupal\Core\Config\Entity\ConfigEntityBase->toArray() (line 248 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).

Here is how I'd implemented the EntityForm:

class MymoduleForm extends EntityForm {
  public function form(array $form, array &$form_state) {
    $form = parent::form($form, $form_state);
    $entity = $form_state['entity'] = $this->getEntity();
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t('Name'),
      '#default_value' => empty($entity->name) ? '' : $entity->name,
      '#required' => TRUE,
    );
    ...
    ...

    return $form;
  }
  public function validate(array $form, array &$form_state) {
    parent::validate($form, $form_state);
    $entity = $this->getEntity();
    //perform validation
  }
  public function save(array $form, array &$form_state) {
    $entity = $this->getEntity();
    $entity->save();
    print_r($entity);
    //throws error here

    $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
  }

Doing a print_r($entity) shows two Object results: one showing all the values I'd filed up in the form and the other completely emplty.


texts:
I'm using a rate module to voting widgets for nodes and comments.

I needed to put a widget on a specific place in the comments (comment.tpl.php), but I do not get it. Etou to use the following code, but the widget just does not show:

<?php print rate_embed($node, '_1_!', RATE_FULL); ?>


texts: How to make a field purchasable using payment module?

texts:
I have a Drupal site where I want users to buy keys for getting access to member's complete profile. I fetched the data of the custom table of keys using views. I have keyname, key id as views fields. Now I have added another field (global text [buy now]).

Now I want to know how the key id of field can be made purchasable using payments module. How can I do it?


texts: Limit number post per taxonomy term name

texts:
I'm trying to make some limitation in pager and display aritcles per term. I think that i can with Views and  but i would like to do with some simple preprocess or hooks (if it can). Taxonomy display modules do limitation per vocabulary. I don't know where to start.

e.g.
I have one vocabulary (locations) with different terms (lakes, mountains, buildings)
and I have about 20 articles in lakes, but i have 300 in buildings so i want to improve UI.
I want to limit pager 10 per lakes and 50 per builidngs. And terms must stay in same Vocab.

How to do it
thanks


texts: Sidebars and header no longer expressed but blocks are still defined

texts:
I inherited a Drupal 6.28 site using theme Colourise 6.x-2.1.  I do PHP dev but am not very familiar with Drupal.

Today without having modified any files and without having made other updates none of the content displayed by Blocks is being rendered.

I checked in /?q=admin/build/block and all of my blocks have same left sidebar, right sidebar, header, and top content data as before.  Most are just static html.

I am able to rearrange, cut throttle on and off and changes are preserved in admin but the contents are still not rendered at all.

I cleared cache to no effect.

Problem persists across theme changes so I assume it's not the page.tpl.ph file.

For kicks I edited conditionals around sidebars in Colourize theme page.tpl.php and saw the empty divs for them render.

I was able to add and save a new HTML block in admin and move it to sidebars and header and save location but it never rendered.

What should be my next step to debug this?


texts: I can't show the body content with full HTML

texts:
My fresh installed Drupal 8 site can't display articles that use full HTML.

Is that normal?

Using the Full HTML input format, it appears like this.

I have to change the input format to Basic HTML, to make the body appear.

Is my installation complete?

Notes

I also tried pasting a different paragraph from a different website to see what happened, but the body content did not display.
I'm currently using Drupal core 8.1.3. What does missing filter mean? I found this in the information of text format.

  Full HTML: Missing filter. All text is removed.


texts: How to prevent admin role from changing "Updated date" of content

texts:
The updated date of the content is displayed on each node with this code in template file.

<?php print strftime( "%Y-%m-%d", $node->changed) ?>

Now when I save the content with admin role the date displayed is the date I updated (of course). But I only want to display the date updated by the author of the content. So how can I prevent admin role from changing "updated date" and only keep the date updated by the content author?  Or is there a way to display only the updated date by the author of content?


texts: How to get granted and expires fields of commerce license updated?

texts:
I have similar problem as described on Commerce License Billing: How do I charge or refund a prorated amount when the user's plan changes and the billing cycle is prepaid? by @wizonesolutions, but with different goal.

On a Drupal 7 website with the Commerce License Billing module used for subscriptions, the changing subscriptions plan by saving the new product_id on the license entity ($license->product_id) does in fact update the license and the due amount on the next recurring payment order, however, it does not update the granted and expires fields of the license.

So I tried to get those fields' values from the license, make my calculations and save them together with the whole license entity like so:

$bct=$form_state['storage']['target_product']->cl_billing_cycle_type[LANGUAGE_NONE][0]['target_id'];
    if ($bct == '1') { // hourly
      $target_date = strtotime('+1 hour', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    } elseif ($bct == '2') { // daily
      $target_date = strtotime('+1 day', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    } elseif ($bct == '3') { // monthly
      $target_date = strtotime('+1 month', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    } elseif ($bct == '4') { // quarterly
      $target_date = strtotime('+3 months', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    } elseif ($bct == '5') { // biannually
      $target_date = strtotime('+6 months', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    } else { // biannually
      $target_date = strtotime('+1 year', REQUEST_TIME);
      $license[arg(1)]->expires = $target_date;
    }
    $license[arg(1)]->granted = strtotime("now");
    $license[arg(1)]->product_id = $form_state['storage']['selected_plan'];
    entity_save('commerce_license', $license[arg(1)]);
    drupal_set_message('License has been updated.');

And the admin/commerce/licenses page after saving the license entity shows that all the relevant fields - new product_id, granted and expired fields have been in fact updated.

But the problem is that when expire time comes, the granted field reverts back to initial value and the expired field's value is calculated based on the initial granted field.

In other words, guess I have two billing cycles - hourly and daily - and if an initial order is placed with hourly billing cycle, then license with the following fields is created:

Cycle: Hourly
Granted: 15 January 2018 - 17:50
Expires: 15 January 2018 - 18:50

If I update the license with the new product id, granted and expires field then the admin/commerce/licenses shows:

Cycle: Daily
Granted: 15 January 2018 - 17:52
Expires: 16 January 2018 - 17:52

And when 16 January 2018 - 17:52 comes and all the relevant cron tasks are processed then the same page shows:

Cycle: Daily
Granted: 15 January 2018 - 17:52
Expires: 15 January 2018 - 20:48

Meanwhile bunch of extra orders are charged and the new recurring order with Recurring: Open status are created and then only the license admin page showing the granted and expires fields (with values behind from 16 January 2018 - 17:52) constantly changing with every cron execution:

Cycle: Daily
Granted: Active 15 January 2018 - 17:52
Expires: 16 January 2018 - 01:48

So my question is:

If changing the values for the granted and expires fields in license entity does not take effect, where else I should be looking for changing those values?


texts: Import XML with nested elements into field with settings "Number of values" = "Unlimited"

texts:
Noob to Drupal here.  I'm looking to import 100 xml files into an empty D7 database.  Each xml file contains links to other xml and image files.  I have Feeds, Xpath Parser, and Tamper modules installed.

Drupal Content type = Article
Fields (machine name):

unique_xml_id (Text)
body (Long text and summary) -> settings "Number of values" =
"Unlimited"
field_images (Image) settings "Number of values" = "Unlimited"

Here's the xml. Every xml file has a unique id by combining pid and gid.

<testContent pid="5" gid="000007">
  <textContent title="Title 1" ordinal="0">His car</textContent>
  <textContent title="Title 2" ordinal="1">Our car</textContent>
  <textContent title="Title 3" ordinal="2">
    This is my <textLink linkType="int" pid="5" gid="000014">car</textLink> -> link to xml
  </textContent>
  <visualHeader title="Images">
    <visualContent mid="1057" alt="Radiator" type ="thumb"> -> image url, ex: img/1057.jpg
      <visualLink pid="6" gid="001057"</visualLink> -> link to other xml file with parent img
    </visualContent>
    <visualContent mid="1092" alt="Wipers" type="thumb"> -> image url, ex: img/1092.jpg
      <visualLink pid="6" gid="001092"</visualLink> -> link to other xml file with parent img
    </visualContent>
  </visualHeader>
</testContent>

OBJECTIVES:

Map the concatenation of the xml attributes "pid" and "gid" to field "uniquexmlid" and make this check for uniqueness
Map textContent elements to body field values (array?), example:
body[0] = "His car"
body[1] = "Our car"
body[2] = "This is my car" (car is link to other node that does not exist yet in database)
Map "car" link to url of other node (not yet created from xml file) with path alias inside body[2] field

How do I accomplish these?  I'm open to suggestions of other ways of setting up the fields in Drupal.


texts: Validation and Setting value for Multi-value fields

texts:
Consider for a content type, there is a text field with multiple values capability activated.

How can I check its values by $form_state inside the Validate/Submit function?
How can I set its values by $form_state inside the Validate/Submit function?

The single code line for each of them would be enough for me to see, Thanks.

Further discussion:

I need to set/check the MULTI-VALUE fields' values. It's related to the DELTA value and ... but I don't know how clearly I can do it!


texts:
Is it possible to add a the content type comments to a page? When I create a page and look to see what can be added into a panel comments are not available

Thank you!


texts: Read access to user's nodes based for referenced users

texts:
I am trying to figure out how to provide access to nodes of the users, which have referenced users. Please note that users are referenced not from nodes, but the user profiles, so I can not use the Node access user reference module. I also can not use roles-based access modules, because otherwise there would be too many roles to create as users on this website should be able to reference unlimited users. I also can not user organic groups.

So basically users have other users referenced from their profiles. All referenced users should have access to nodes authored by the users who referenced them.


texts: Is it possible for a view to have two outputs

texts:
The reason I need this because I create a view to search through document and need two outputs. One being the document and the other being the files are part of the document group the file is associated with.

*Is this possible with one exposed filter

Thanks for any help with this


texts: Build a link with variables in a views custom text using '%5B' characters

texts:
I use the FillPDF module. Data from a Webform are used to generate a pdf thanks to a url, as explained in the FillPDF documentation.

my_site.com/fillpdf?fid=95&webform[nid]=119&webform[sid]=[submission:sid]&download=1

numbers are those I use, yours can whatever.
I wrote such a url in the confirmation message, so that the user can download its submission results in a file. It works fine.

I would now like to allow an admin to do the same when consulting the submission result tab.
I saw this table was a view. I edited the view so I could display the proper [nid] and [sid] I need within the url.
Then I hid them form display and called them in a Global Text field. I thought I could write my url placing my numbers where i needed them, using '%5B' instead of brackets (which I need for the replacement patterns)

my_site/fillpdf?fid=[field_fillpdf_form_info]&webform%5Bnid%5D=[nid]&webform%5Bsid%5D=[sid]&download=1

Halas! these weird '%5B' and '%5D' are not interpreted. Did anyone come upon this problem already?


texts:
If I have multiple attributes that I want to set to an element in a twig template it can get quite long since each attribute requires setAttribute(attribute name, attribute value).

Based on my IRC conversation (I don't remember who it was), it looks like it is not possible to set multiple attributes at once, like it is possible with CSS classes.

So I would like to know what would be a "pretty" way of setting multiple attributes in a twig template. I presume a loop of some kind.


texts: Using the jQuery Update module throws the "F is undefined" error

texts:
I am using the jQuery validate module (which is mandatory for client side validation module).

If I use that module, my existing functionality is not working well. It is throwing, "F is undefined" while using minified version or, "$.ui is not a function" with the normal version of jQuery.

I understood that version plays the problem here. How do I avoid the error message?


texts:
I have a block in my footer that I currently use to display a copyright message using PHP, like so:

Copyright © <?php echo date("Y"); ?>

I'd like to add the site name to that code snippet, dynamically instead of typing the name. How can I do so?

So the end result would be:

Copyright © <?php echo date("Y"); ?> [[[php code to display site name goes here]]]

Thanks!


texts: How do I wrap the label text of a checkbox with a span tag?

texts:
I have noticed that Drupal 7 generates check-boxes with a markup like this:

<input type="checkbox">
Label text ..

I want to wrap  Label text .. inside a span tag, how to do that via the Drupal 7 API?

The result should be:

<input type="checkbox">
Label text ..


texts: Making a file downloading system with valid input in a custom drupal 8 form

texts:
I am trying to create a custom drupal 8 form, that is going to allow user to enter his/her firstname, lastname and email address, and if the user enters these credentials, will be able to download the file that I will upload to cms. This is how my form looks like right now:

namespace Drupal\whitepaper\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\UrlHelper;

class WhitePaperForm extends FormBase {

/**
 * {@inheritdoc}.
 */
public function getFormId() {
  return 'whitepaper_form';
}

/**
 * {@inheritdoc}.
 */
   public function buildForm(array $form, FormStateInterface $form_state) {
  $form['iam'] = array(
   '#type' => 'select',
   '#title'=>t('I am:'),
   '#options' => array(
    'dentist' => t('Dentist'),
    'broker' => t('Broker'),
    'engineer' => t('Engineer'),
   ),
   '#required' => TRUE,
  );
  $form['fname'] = array(
   '#type' => 'textfield',
   '#title' => $this->t('First Name:'),
   '#required' => TRUE,
  );
  $form['lname'] = array(
   '#type' => 'textfield',
   '#title' => $this->t('Last Name:'),
   '#required' => TRUE,
  );
  $form['email'] = array(
   '#type' => 'email',
   '#title' => $this->t('Your .com email address.'),
   '#required' => TRUE,
  );
  $form['show'] = array(
   '#type' => 'submit',
   '#value' => $this->t('Download Whitepaper'),
  );

  return $form;
}

/**
 * {@inheritdoc}
 */
public function validateForm(array &$form, FormStateInterface $form_state) {

  if (strpos($form_state['values']['email'], '.com') === FALSE ) {
    $this->setFormError('email', $form_state, $this->t('This is not a .com email address.'));
  }
 }

 /**
  * {@inheritdoc}
  */
  public function submitForm(array &$form, FormStateInterface $form_state) {

  drupal_set_message($this->t('Your email address is @email', array('@email' => $form_state['values']['email'])));
 }
}

Can anyone help with a block of code that if the inputs are valid, when the user click download paper button, will be able to download? I got really stuck and i guess my point of view is not helpful to solve this problem.Thank you advanced.


texts: How to migrate File Entities - images and docs into D7 from .csv and attach them to nodes?

texts:
I've got a simple feature which creates a content type with title and fields - subtitle, body, images a documents. The main thing is that I use media module, so I actually attach file entities - image and document to the content type.

Now I'm trying to create a 2nd feature which is going to migrate a demo content in when I switch it on and out when I switch it off. It uses migrate module to import data, and the feature includes a folder with images and .csv file with source data.

I've got it working for title, subtitle, and body, but I don't know how to make it work for files. I built it up on Panopoly distro and used Panopoly App - News Demo as an example code. Unfortunately, News Demo uses a classic image field to import images within the app, and it doesn't seem to work with file entities.

Could anyone share a piece of code for this case, please?

Josef


texts: Webform - how do I change dateformat in mail

texts:
Module: Webform

The short date type is dd/mm/yy, so it appears correctly in the form (day/month/year)
But in the mail it is shown with month first. (month/day/year)

How can I change the date type in the mail?


texts: How do I create a grouped exposed filter on a block?

texts:
I have both a "Galery" content type and a "Galery category" taxonomy. The taxonomy only has two terms, 'Video' and 'Photo' (picture).

When I create a Galery content type, I need to choose the galery category.

I created a view that would display an exposed form, that would allow the user to either pick one of the 2 available categories. A colleague helped me setting up a grouped search and customizing it. Here is how it looks:

However, when testing it, we realized nothing was displayed. Moreover, the <Any> choice does display everything, so I think I've wrongly set something.

If this helps, I'm using "better exposed form" with the "autosubmit" and "use ajax" functions enabled.

What is happening and how should I fix it?

Thank you in advance


texts: drupal_add_js not work in form validation failed

texts:
I add js file with drupal_add_js in hook_form_alter, it is ok and I see it in list of js loaded in page, but when I submit form and form not validate and return to that form (after validation failed) I don't see js files that added to form, why this happened? and how can add my js file in that form after validation failed ?

some part of my code

function mymodle_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'news_node_form') {
    drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodulejsfile.js'); //, array('scope' => 'footer','weight' => 10));
  }
}

code work correctly in add and edit form, but when form submit and validation failed it show validation error but my js file not loaded in page (I checked html source and check firebug script files), but there is not my js file,


texts: How do I find the role id from an og group role name?

texts:
I need to retrieve the rid to assign the 'student' role part of an og group.

I found this post in regards to user roles How do I find the role id from role name?

$rid = array_search('student', user_roles());
og_role_grant('node', $id, $user->uid, $rid);

Is there also a function for og group roles?


texts: drupal 7 default table to store form values

texts:
I am new to drupal and creating a module consist of a form. Now I want to store values in database, please tell me what is the default table in drupal to store form values?
Like in WordPress we have wp_option table to save data.
Is there any default table in drupal or I have to create new one?
What is the exact use of node table?


texts: Variable default_bundle in migration? Field collection to varying paragraph types

texts:
I'm trying to migrate a D7 field collection to D8 paragraphs, but to a different paragraph bundle type depending on the value in one of the field collection's fields.

The logic is as follows: If the field collection's field_type value is "header", the migration should create a header paragraph type. If the field collection's field_type value is "card" it should migrate to a card paragraph type.

I'm trying to set a variable in process, and assign the value of that variable to default_bundle in the destination, but it's not working, the paragraph type is empty for the entities created by this migration:

langcode: en
status: true
dependencies: { }
id: d7_field_collection_list_items
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags:
 - 'Drupal 7'
migration_group: migrate_drupal_7
label: FC
source:
  plugin: d7_field_collection_item
  key: migrate
  field_name: field_list_item
process:
  temp_bundle_type:
    plugin: static_map
    source: field_list_item_type
    map:
      card: card
      header: header
    default_value: card
destination:
  plugin: 'entity_reference_revisions:paragraph'
  default_bundle: '@temp_bundle_type'
migration_dependencies:
  required: { }
  optional: { }

What is the correct way to achieve what I am trying to do? I have tried several other methods without success.


texts:
I'm trying to build a simple module (to learn DI) to return the current user ID, and and apparently I'm missing something in the syntax.

Here's my code and the error it's producing:

use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\HttpFoundation\Response;

 class LSWController {
  /**
   * @var AccountProxy
   */
     protected $currentUser;

     public function __construct(AccountProxyInterface $currentUser) {
         $this->currentUser = $currentUser;
     }

     public function say() {
         return new Response("Hello");
        //return new Response($this->currentUser->id());
     }
 }

and the error

ArgumentCountError: Too few arguments to function Drupal\lsw\Controller\LSWController::__construct(), 0 passed in C:\wamp64\www\testdrupal\core\lib\Drupal\Core\DependencyInjection\ClassResolver.php on line 31 and exactly 1 expected in Drupal\lsw\Controller\LSWController->__construct()

What am I missing?  I'm including the AccountProxyInterface, etc.  How come it's saying that 0 arguments are being passed?


texts: What's the right way to have Drush make automatically add version numbers to my info files?

texts:
Everything I read says Drush should be able to automatically rewrite my info files to add version numbers (and the only switch I see is the switch to disable this, --no-gitinfofile), yet nothing I am doing seems to make this work.

The Drush make command being run is:

drush make --working-copy --no-core -y --contrib-destination=. profile.make

A sample project in the make file would look like this:

; Sample Project
projects[sample_project][type] = "module"
projects[sample_project][download][type] = "git"
projects[sample_project][download][url] = "gitlab@git.example.com:cms/sample_project.git"
projects[sample_project][download][tag] = "7.x-1.5"
projects[sample_project][subdir] = "custom"

Googling around, I found the following options to maybe try, none of which worked:

projects[sample_project][download][version] = "7.x-1.5"
projects[sample_project][download][full_version] = "7.x-1.5"
projects[sample_project][version] = "7.x-1.5"
projects[sample_project][full_version] = "7.x-1.5"

The Drush version is 6.2.0.


texts: Drupal: $_POST and MENU_CALLBACK. How works?

texts:
I've read this and this but nothing is working for me I'd like to create a menu like this

$items['login'] = array(
'page callback' => 'mymodule_login',
'access arguments' => array('access content'),
'access callback' => true,
'type' => MENU_CALLBACK,
);

in order to send a POST to http://www.mysite.com/login.

This is my script in order to generate a POST

<?php

define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$base_url = 'http://www.mysite.com';
$data = array(
  'username' => 'admin',
  'password' => 'password',
);
$data = http_build_query($data, '', '&');
$headers = array();
$options = array(
  'headers' => array(
    'Accept' => 'application/json',
  ),
  'method' => 'POST',
  'data' => $data
);

$response = drupal_http_request($base_url . '/login', $options);
$data = json_decode($response->data);

And this is my callback function

function mymodule_login() {
  header('Content-type: application/json');
  watchdog('mymodule',  print_r($_POST, TRUE));
  $result = array("result" => "ok");
  echo drupal_json_output($result);
}

The body contains a json with username and password. Everything is ok, except for $_POST under function mymodule_login that does not work. $_POST is empty.

What's wrong? Is there another "drupalic" way?


texts:
I recently developed a module where I used the function hook_form_user_profile_form_alter(&$form, &$form_state) to capture user preferences and saved them using function hook_user_presave(&$edit, $account, $category) .
Then I accessed the data using $user->data['field']  in a module . That worked fine .

But now  I want to store the same preferences using another form (not the user profile form).
So is there any other hook to store them ?

I want to give a link to each user to the page(form other than the user profile ) where he can store his preferences .

Thanks in advance.


texts: Rendered entity reference field (list-group) disappears, when user can't access the referenced items. Why?

texts:
I have been trying to find the reason for this problem for a few days now... without any luck. Which is why I would like to ask for help here...

In a nutshell: I'm working on a simple LMS and have defined a content type Course that contains an entity reference field field_lessons, which refers to another content type Lesson. In the template file node--course--full.html.twig I'm using the following code to render a "table of contents" in the sidebar:

...

  {{ content.field_lessons }}

...

In addition I'm using a template file field--node--field-lessons--course.html.twig for rendering the field:

...

  {% for item in items %}
    {% if (item.viewaccess) %}

    {% else %}

    {% endif %}

        {{ item.title }}

      ...
    {% if (item.viewaccess) %}

    {% else %}

    {% endif %}
  {% endfor %}

...

(Note that I deliberately left out a few insignificant details in the code: These are marked with "...".)

So, depending on whether the current user can access a single lesson (I'm using the variable item.viewaccess, which depends on hook_node_access() and is set in hook_preprocess_node()), each lesson is rendered as active or disabled list-group-item. So far, this works perfectly.

Something weird happens, however, as soon as all lessons are locked for the current user: In this case, none of the lessons gets rendered and the whole table of contents (i.e. the whole  block) disappears.

I'm totally stumped at this point. Can anyone offer an idea as to why this happens?
Any help would be much appreciated.


texts: How to run cron more often than every hour?

texts:
I'd like to run cron every 5 minutes, but the UI doesn't offer any increment of time smaller than an hour.  I'm assuming the solution is as simple as

creating a feature module for the setting, and changing the integer to 300 (60 seconds × 5), OR
cracking open the database and changing the value to 300.

Are there any hidden 'gotchas' with either of those approaches (or any reason they'll fail)?  Is there a better way?


texts:
Whenever Drupal encounters an unrecoverable error, it displays an error message.

Is there a way I can provide a template for this page?


texts:
I'm using the Link module to display a field that links to an external site. $snippet places this link (along with other fields) in a paragraph. The fields have no separation and the link doesn't work. I'd like to place $content in search-result.tpl to remedy this but everything I've tried has given me an error.

Someone mentions $result here which may be what I need.

I tried <?php print $result['field_lipsum']; ?> but it gives me Notice: Undefined index: field_lipsum in include() . . .

How can I place $content in search results instead of $snippet?


texts:
I have a very interesting problem.
I have 2 dev machines (both mac, running XAMPP).

In my project I have a submit handler for a custom entity form.

When I try to dpm() (or kpr, or dsm, ...) the contents of $form or $form_state, well, nothing really happens (on one machine!)

On the other machine, the dpm (for the exact same project, in the exact same submit handler, for the exact same variable) works perfectly.

I have copied php.ini settings files, checked the php memory limit, ...

Nothing seems different...

When I try to dpm($form['entities']); then it works on both instances.
This seems to give me the impression that it works when you narrow down the array...

But when I inspect the array ($form) it only contains approx. 40 items or so... (okay there are arrays in arrays and so on).

No errors on in the php log, apache log, ...

Any suggestions would be very welcome!

Many thanks in advance!


texts: Multisite setup on local development environment

texts:
I've been around the block with this one. and I'm back at my front door!

I am trying to setup a multisite configuration on my local dev server, which currently looks like this.
I'm using Xampp in a windows environment so my root is "Xampp\htdocs\"; then any site I'm working on is created under a folder here.

This gives me the follwing Drupal stucture.

  \sites\all\themes\devsite

In my browser, I can go to http://localhost/devsite, and it launches my Drupal site without problems; If I go to http://localhost, I get redirected to XAMPPS installation page.

So now I embark on the multisite config.

First, my hosts file is altered to include these two entries.

127.0.0.1 devsite.com
127.0.0.1 m.devsite.com

Browsing to the following URLs launch my site.

http://devsite.com/devsite
http://m.devsite.com/devsite

I now copy my \devsite\sites\all structure to a \devsite\sites\m.devsite.com folder and setup a \devsite\sites\sites.php file with these entries.

$sites = array(
    'devsite.com' => 'all',
    'm.devsite.com' => 'm.devsite.com',
);

If I browse to either hostname, both load the site configuration which is in All. I can't seem to get it to load anything within m.devsite.com? I've tried copying the settings.php file into each stucture which produces an error message. I've tried renaming All to devsite in folder and sites.php but then I get a blank page when browsing.

Do you have any idea on what is wrong?


texts: I have a question about what would be the best way for a module to accept a posted XML file via a web service.  What I am trying to do is receive the file, read through the contents of the file, and update a setting on my site via the contents of the file. Could some one point me in the right direction?


texts: How to insert line breaks in views global custom text field?

texts: My view renders plaint text output - no HTML allowed. I want to format my fields with \n line breaks. How do I do that?


texts:
I get this Notice:

  Notice: Undefined offset: 1 in
  custom_context_section_condition->_get_url_section() (line 110 of
  modules/custom/custom_context/plugins/custom_context_section_condition.inc).

  **
  * Get section by url
  */
  function _get_url_section() {
    // get the correct URL
    $path = $_GET['q'];
    if (arg(0) == 'node' && is_numeric(arg(1))) {
      $path = drupal_get_path_alias($_GET['q']);
    }
    $path = explode('/', $path);

    // Remove reserved part from path when defined as constant (see custom_context.module)
    if (in_array(arg(0), unserialize(URL_PATH_PART))) {
      array_shift($path);
    }
    // Remove reserved string from path when defined as constant (see custom_context.module)
    else if ($new_path = _custom_context_strpos_replace_arr($_GET['q'], unserialize(URL_PATH_STRING))) {
      $path = explode('/', $new_path);
    }

    // Get section by path
    $value = str_replace('-', ' ', $path[1]);
    $terms = taxonomy_get_term_by_name($value);

    // make sure we are getting the right section under the correct city
    // check if city context exist
    $city = NULL;
    $contexts = context_active_contexts();
    if ($contexts = context_active_contexts()) {
      foreach ($contexts as $key => $context) {
        if ($key == 'city') {
          $city = $context->conditions['custom_city']['city']['term'];
          break;
        }
      }
    }
    else {
      $city_context = new custom_context_city_condition(this, array());
      $cities = $city_context->_get_city($node);
      $city = array_shift($cities);
    }

    // check parent tid here
    foreach ($terms as $key => $term) {
      $parents = taxonomy_get_parents($term->tid);
      $parent = array_shift($parents);
      if ($city->tid != $parent->tid) {
        unset($terms[$key]);
      }
    }
    return $terms;
  }

This part:

if ($city->tid != $parent->tid) {
  unset($terms[$key]);
}

Also says: Notice: Trying to get property of non-object

Any idea whats wrong in my code?


texts: How to prevent page reload when switching between calendar view displays?

texts:
I created a Calendar view, and I put yes on the setting "use Ajax"

This setting works only for next and previous buttons.

I would like to have the page doesn't reload while the user switches between different view displays.

Is it possible to enable the same feature for the tabs Month, Week and Day?


texts: Brightcove Connects breaks site after core upgrade to 8.5.x in Acquia Cloud

texts:
After upgrading core to 8.5.2, and eploying to Acqui Cloud, Brightcove causes a fatal error. Note, the code works as expected in my local DevDesktop environment, and I am unable to recreate the error locally.

Fatal error: Class 'Drupal\brightcove\Entity\BrightcoveCmsEntity' not found in /mnt/www/html/xxx/docroot/modules/contrib/brightcove/src/Entity/BrightcovePlayer.php on line 30

The error is thrown via http and drush commands


texts: Getting nodes based on what the user has in their profile

texts:
I have a term reference field in my user accounts and I have nodes that are also tagged with that same vocabulary.

I have a view set up to display all the nodes, but I want it to display only nodes that have the terms that the users has checked in their account.

Example:

Node: Shirt
Term(s): Blue

Node: Skirt
Term(s): Green, Blue

Node: Dress
Term(s): Red

Node: Shoes
Term(s): Purple

My user has terms: Blue, Red

I would like to see nodes: Shirt, Skirt, Dress


texts: How to change Date format without diving to core?

texts: I want to convert dates to Jalali format. The problem is I have to change some of the core files in /includes and /modules. Is it possible to do this without jumping right into the core?


texts: custom webform time and date elements id's

texts:
Using webform, I have two "Date/time" elements with popup date and timepickers enabled. I have a jQuery script to calculate and display detailed time difference between the values (date and time) entered in the two elements fields and for that I use those elements' id's several times.

My question is:
I like to have custom id's one for each date and time element's field. Drupal/Webform automatically assign long ids like e.g. #edit-leaving-time-time for the time filed and #edit-leaving-time-date for the date field.
That's for the first Date/Time element. And likewise, there's  #edit-returning-time-time for the time filed and #edit-returning-time-date for the second Date/Time element.

The option in "Element custom attributes (YAML)" (accessed from the webform element Advanced tab on editing) to add a new id affects the whole Date/Time element's both date and time while I need to have unique id for each (one for the date and another for the time) to use in my jQuery script.

I see on twig debugging that those elements are controlled by the file \web\core\themes\classy\templates\form\input.html.twig but when I opened it, I only found this line and so I couldn't make any sense to where to go from there.

<input{{ attributes }} />{{ children }}

Although everything is working fine now and my question is more about "cosmetic" thing than functionality, I still love to learn if there's any way to do it without having to write a custom module or so since I still have no experience in that.

Thanks so much for any insightful ideas you may have.


texts: How can I display a message when "add another item" on an Inline Entity Form Multiple field is clicked?

texts:
In Drupal 8 inline entity form is there a "form_alter" or "submit handler" or some type of ajax callback for when a user clicks "add another item"?

What I would like to do is display a message to the user when they click "add another item" on a Inline Entity Form Multiple field.

Struggling to find the right path.


texts: How do I set a custom path for feeds feed items in views?

texts:
Update

I tried doing what Nikhil and the referenced threads said, but I'm still have trouble. I should have been more clear initially on what the problem is. When I go to <new-feed-node-path>/feed-items I'm given a page not found. That is, localhost/shows/<show>/feed-items. The URL in views for that page used to be node/%/feed-items, and I changed it to shows/%/feed-items. The paths of the feed items themselves works fine, ie. localhost/episodes/<episode-title> is working.

In pathauto settings I put:

Pattern for all Feed paths

shows/[node:title]

Pattern for all Feed item paths

episodes/[node:title]

And then in the feeds_defaults_feed_items view I put shows/%/feed-items in place of the default path, node/%/feed-items. I also tried shows/[node:title]/feed-items. I created a new feed each time to test.


texts:
I  have a heavily themed form to integrate, whose structure is shown below. I am just about there for the most part except for the submit.

 <form action="#">
   <fieldset>
     <legend>Authentification</legend>
       Courriel*
       <input type="text" name="email" id="email">
       Mot de passe*
       <input type="password" name="password" id="password" class="last">
       Forgot password?
       <button type="submit" class="clearfix">Login</button>
   </fieldset>
 </form>

I have tried many different combinations, turns out button_type has no effect on core. So I used this hack, hoping it would fix my issue. Alas, it only changes the 'type' attribute (obviously), and not the element itself. The button type can hold other elements, in this case the span is needed to hold a background image, it needs to be in a span to stretch as the text in the button is dynamic.

Does anyone have a clue as to how I can generate the following line of markup using the form API?

<button type="submit" class="clearfix">Login</button>


texts: How can Drupal be made to serve with root-relative paths?

texts:
I'm trying to avoid serving pages that load css and js resources through URLs that specify either http or https.  (I'm trying to find a workaround for the problem described in this question, in case a real solution cannot be found.)

Because Drupal is specifying http:// for the href for all the CSS and JS files, when the server erroneously switches to https, as described in the aforementioned question, the browser seems to be ignoring all these files, and I get an unstyled page.

Instead of

<link type="text/css" rel="stylesheet" href="http://www.example.com/sites/default/files/css/css_pbm0lsQQJ7A7WCCIMgxLho6mI_kBNgznNUWmTWcnfoE.css" media="all" />

(etc.)

I'd like to serve

<link type="text/css" rel="stylesheet" href="/sites/default/files/css/css_pbm0lsQQJ7A7WCCIMgxLho6mI_kBNgznNUWmTWcnfoE.css" media="all" />

or even

<link type="text/css" rel="stylesheet" href="//www.example.com/sites/default/files/css/css_pbm0lsQQJ7A7WCCIMgxLho6mI_kBNgznNUWmTWcnfoE.css" media="all" />

Can I make Drupal serve URLs that don't specify protocol?


texts: In which database table does the number views of a node get stored?

texts:
I'm using Drupal 7. After enabling the Statistics module (part of Drupal core), I see, under each node, how many times it has been read (e.g. "4 reads").

I wonder where this number of views of a node (e.g. "4 reads") gets stored in some table in the Drupal database.


texts: How to get the enabled manage displays per node type?

texts:
I have an admin form and need to check if a node, e.g. article has a specific manage display enabled. How do I get the data?

Found out to get an array of all available displays in general and there is a difference between display views and view modes. May I am just searching with the wrong terms.


texts:
When I put site in maintenance mode and after turn site back all users sessions are not active (is need to log in account), but I put session to work 2 month and it work.

How to prevent users logout when put site in maintenance?


texts:
I am using Display Suite for node creation, but would like to extend this by also using blocks provided by theme to put several fields inside them too (sidebar left and right).

How to accomplish this ?


texts:
I have a view which uses an exposed filter to let the user filter the results via keyword (in other words it behaves like a text search).  The actual field is implemented using views_fields_combine module, but I assume this issues applies to any field which contains text.  The problem I have is that the filter only works correctly if the case of the "search" text matches the content in the field.

For example if the field contains "Cool Capacitors" and the user types "Cool" in the exposed filter then there will be a resulting match.  But it the user types "cool" then the filter will not find any matching results.

I would like to know if there is a method of making the exposed filter ignore the case when making matches.  Strangely enough I have not been able to find any information on this on the internet.  I am wondering if I am try to do something that exposed filters was not designed to do?  Perhaps there is some alternative method I could consider?


texts: Approval required for all comments apart from on the forum

texts:
We need to allow all forum comments to be published automatically, however any comments to articles or any other content type will require approval before being published.

Unfortunately Drupal seems to only have a single permission "post comments without approval" which applies to both the general comments for nodes and also the comments for the forum topic (yes I know they are still nodes)

Is there any easy way round this? I was thinking maybe a rule but it seems a little over the top, surely this must be a common complaint but my searches didnt bring back anything helpful...


texts: How to programmatically submit the file system settings form?

texts:
I am trying to enable private files via features, in code, or with drush but am getting errors.

With drush:

drush vset file_private_path sites/default/files/private

In code:

variable_set('file_private_path','sites/default/files/private');

The problem is that when you set this configuration manually, the file system settings form gets saved and it creates an .htaccess file in that location. When you set it in code, it doesn't create the .htaccess file until you visit the admin/config/media/file-system page, which it returns an error the first time:

Warning: file_put_contents(private:///.htaccess) [function.file-put-contents]: failed to open stream: "DrupalPrivateStreamWrapper::stream_open" call failed in file_create_htaccess() (line 502 of /sandbox/d7/includes/file.inc).

Is there a correct way to be doing this programmatically? Thanks in advance.


texts: How to parse mysql query output as variable into another command in linux via Drush?

texts:
Currently I'm doing a mysql query via the command line using Drush and I want to parse the query output and grab the Node ID #, then put that ID # into a drush php-cli 'node_delete(X)' command. How can I do this? Currently I have the command:

drush sql-query 'select * from node where type="feed_item" AND status=0 limit 1 \G'

then

drush php-eval 'node_delete(X)'

I think I'm suppose to use the command xargs?

From there how can I make this as a loop and delete everything that get's outputted? Yes I know I can just do it via the site, but i want to know how to do it via the command line using only Drush. Eventually I just want to make an interactive bash script where I can just put in the node ID range numbers and it will just delete it at once.


texts: Why aren't the already installed modules recognized?

texts:
I want to migrate my Drupal 7 site to Drupal 9. I test that with my DEV site to see how far I will come, but right at the beginning, when I start the upgrade, I get to the /upgrade/review page.

It tells me that I have to install some modules in Drupal 9 first to get the configuration from my old site. I downloaded and installed and activated some of these 96 missing modules into my new blank Drupal 9 site, but the list doesn't change. It doesn't recognize the modules already installed in Drupal 9.
What am I missing?


texts: Field Reference - context of single node with multiple entries of field

texts:
I've a problem where I have not found an example yet and my attempts to solve this by myself have not been fruitful:

I have two content types where I need to reference the (multiple) entries for a field in the first type in my second type.
Content A has a simple text field that can have an unlimited number of values.
In Content B I want to show a drop down list with entries from Content A of a specific node.

I use the Entity reference module in Content B and have defined an Entity reference view that generates the list of items. This view uses the context filter of the referenced node id, so I really only get the multiple items that are set for the specific nodes.
In the view preview it seems to generate correctly - I get a list of divs with "entry1" "entry2" ... each on a single line.

In my dropdown however, I only see the items "None" and "last entry" ... all others in between are not showing.

I've tried to use Multiple Field Settings set to "Display in same row". This leads to a single entry in the drop down called "entry1, entry2, ..., last entry", which defeats the option of selecting the one I want to set.

Maybe I've gone way too complicated here - so any pointers would be most appreciated.
Maybe it's more complicated than that or just not possible?

Thanks for any input.
Best,
Georg


texts: Implement Gravatar in Drupal 7 using php - how to connect mail addresses to “$email” variable

texts:
Gravatar has a description of its php implementation on the following page:

https://en.gravatar.com/site/implement/images/php/

I'm trying to use this code to implement it in Drupal's user profiles and user pictures.

1st I have created a preprocess function to enable printing e-mail addresses in user-profile.tpl.php

<?php function THEMENAME_preprocess_user_profile(&$variables) {
$account = $variables['elements']['#account'];
foreach (element_children($variables['elements']) as $key) {
$variables['user_profile'][$key] = $variables['elements'][$key];
}
$variables['user_profile']['mail'] = $account->mail;
field_attach_preprocess('user', $account, $variables['elements'], $variables);
}
?>

2nd Added the code to user-profile.tpl.php

print render($user_profile['mail']);

This code works what it's supposed to do - it displays mail address in the user profile. Now I need to use that address to create gravatars in profiles and in user pictures later.

I have somehow tried to connect the tutorial on Gravatar's site and this code, but without success. Here is the code (I have tried at least 20 different combinations):

<?php
$email = "['user_profile']['mail']";
$default = "http://www.somewhere.com/homestar.jpg";
$size = 40;
function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) {
        $url = 'http://www.gravatar.com/avatar/';
        $url .= md5( strtolower( trim( $email ) ) );
        $url .= "?s=$s&d=$d&r=$r";
        if ( $img ) {
            $url = '<img src="' . $url . '"';
            foreach ( $atts as $key => $val )
                $url .= ' ' . $key . '="' . $val . '"';
            $url .= ' />';
        }
        return $url;
    }
?>

As far as I understand, the problem is in this row:

$email = "['user_profile']['mail']";

What am I doing wrong and what is the right expression to put between quotes in this row?

Of course, it would be easier to use Gravatar module, but it seems buggy and unmantained.

Additionally, this php implementation seems to be relatively easy, but I'm probably missing something trivial.


texts: is it possible to have multiple access callback for a menu item

texts:
I am trying to add access callback to already existing access callback for a menu item.

For eg,

path = [node/nid/edit] with access callback 'AC1'.

Now is it possible for us to add another access callback to the existing AC1? I am thinking of hook menu alter but it wont overwrite the AC1.


texts: Unexplained change in module weight in registry table caused site error

texts:
EDIT: August 6, 2015

It turns out that this was actually caused by incomplete data of module_implements cached in the database by Drupal which caused a hook_init to not be called.  We changed the weight but also had cleared the cache and had incorrectly attributed the fix to correcting the weight.

We have a Drupal 7 site with mimemail and htmlmail modules installed. The htmlmail has a weight of 10 since it needs to be loaded after mimemail.

However, recently, the following PHP error started occur in the logs:

  PHP Fatal error: Call to undefined function mailsystem_html_to_text()
  in /path/to/sitefolder/sites/all/modules/htmlmail/htmlmail.mail.inc on
  line 62".

We were able to track it down to the "weight" column in the registry table where the weight for class "HTMLMailSystem" has a weight of 0 when it should have been 10. Manually changing it to back to 10 fixed the issue.

We confirmed that there has been no active development or any core/module updates around the site this error started to occur.

Does anyone know what could have caused the weight to change?

Futher investigation by running the following query revealed no discrepancies in module weight between the registry and system tables on the development site

SELECT r.*,
s.name,
s.weight
FROM `registry` r
LEFT JOIN `system` s ON r.module = s.name
WHERE r.weight != s.weight

However, on the production site, the following entries module entries have a different weight between the two tables so it's possible other modules were affected too by whatever caused this - it just hasn't caused additional errors (such as due to the default load order perhaps being fine for those).

views_plugin_localization_core
views_plugin_localization_none
views_plugin_row_user_view
WebformComponentsTestCase
WebformGeneralTestCase
WebformPermissionsTestCase
WebformSubmissionTestCase
WebformTestCase
webform_exporter
webform_exporter_delimited
webform_exporter_excel
webform_handler_field_form_body
webform_handler_field_is_draft
webform_handler_field_node_link_edit
webform_handler_field_node_link_results
webform_handler_field_submission_link
webform_handler_field_webform_status
webform_handler_filter_is_draft
webform_handler_filter_webform_status


texts: SelectQuery row_number won't work with PDO

texts:
I'm working on a project that needs to query a MySQL database and select the row number (among other columns) for each row. To be more specific, I have the table test and want to get the table result:

test        result
a | b     a | b |counter
1 | 1     1 | 1 |  1
1 | 3     1 | 3 |  2
1 | 5     1 | 5 |  3
2 | 1     2 | 1 |  1
2 | 2     2 | 2 |  2
3 | 1     3 | 1 |  1
3 | 3     3 | 3 |  2

where column counter counts the number of occurences of a with different b

I have found the solution for MySQL in a post, using variables inside the query:

SELECT
  o.a AS a,
  o.b AS b,
  @num := IF(@a = a, @num + 1, 1) AS counter,
  @a := a AS dummy
FROM
(
  SELECT
    t.a AS a,
    t.b AS b
  FROM test t
  ORDER BY a ASC
) o

which gives me the exact result (with the addition of one dummy column).

The problem arises when I try to implement it in Drupal 7 using the following code:

$tq = db_select('test', 't')
  ->fields('t', array('a', 'b'));
// Order rows for correct numbering
$tq->orderBy('a');
$t2q = db_select($tq, 'o')
  ->fields('o', array('a', 'b'));
// Add counter
$t2q->addExpression('@num := IF(@a = a, @num + 1, 1)', 'counter');
// Add dummy column
$t2q->addExpression('@a := a', 'dummy');
// Store results
$r = array();
foreach($t2q->execute() as $row)
  $r[] = (array)$row;
dpm($r, $t2q->__toString());

The prepared query is correct and exactly the same as the above query:

SELECT o.a AS a, o.b AS b, @num := IF(@a = a, @num + 1, 1) AS counter, @a := a AS dummy FROM (SELECT t.a AS a, t.b AS b FROM {test} t ORDER BY a ASC) o

but the result is:

test        result
a | b     a | b |counter
1 | 1     1 | 1 |  1
1 | 3     1 | 3 |  1
1 | 5     1 | 5 |  1
2 | 1     2 | 1 |  1
2 | 2     2 | 2 |  1
3 | 1     3 | 1 |  1
3 | 3     3 | 3 |  1

I have no idea of the internals of PDO and the reason why variables inside SELECT statements won't work.

If I try with db_query feeding it the prepared query (as in the following code) I get the same results.

$tq3 = db_query($t2q->__toString());
while($row = $tq3->fetchAssoc())
  $r[] = $row;
dpm($r);

But if I first call execute on the query I get the correct results (but can not use extend on DatabaseStatementInterface).

$tq3 = db_query($t2q->__toString());
$tq3->execute();
while($row = $tq3->fetchAssoc())
  $r[] = $row;
dpm($r);

Does anyone have any helpfull idea?


texts: Lost Social Connection Icons after uploading custom images

texts:
I created a subtheme for Commerce Kickstart / Omega. As part of the refresh, I want to use the existing "Connect with Us" block, but replace the existing icons with customized images (theme consistent colors).

I uploaded replacement files to sites/all/SUBTHEME/images, using the same file name and type as in the original theme:

icon_facebook.png
icon_twitter.png

Saved / refreshed: Icons disappeared from the block. If I was uploading to the wrong directory, I feel like it would continue to show the original yellow icons, but the icons no longer show at all.

Here's the code from the css file:

  #block-menu-menu-social-connection .content ul.menu li span,
  #block-menu-menu-social-connection .content ul.menu li a {
    color: #eeeeee; }
  #block-menu-menu-social-connection .content ul.menu li a.facebook {
    background: url("../images/icon_facebook.png") 2% 50% no-repeat;
    /* LTR */ }
  #block-menu-menu-social-connection .content ul.menu li a.twitter {
    background: url("../images/icon_twitter.png") 2% 50% no-repeat;
    /* LTR */ }
  #block-menu-menu-social-connection .content ul.menu li a.instagram {
    background: url("../images/icon_instagram.png") 2% 50% no-repeat;
    /* LTR */ }


texts: ManyToMany Relationships Within Configuration Entities

texts:
I come from a symfony/doctrine background where ManyToMany relationships are usually called out in the entity using annotations.  I'm having trouble understanding how this is done in Drupal 8 and haven't found any good documentation.  Lets take this example.

namespace //...
use //...

class MenuExtensionsEntity extends Menu implements MenuExtensionsInterface {

    /** @var MenuExtensionEntity @ORM\..purposely blank */
    protected $parent;

    /** @var MenuExtensionEntity @ORM\..purposely blank */
    protected $children;

    /** @var int; */
    protected $weight;

    public function __construct() {
        $this->children = new ArrayCollection();
     }
    //... all needed getters and setters below.
 }

We'll assume this satisfies the interface.  How is this represented in drupal 8 where children has a ManyToOne and parent has a OneToMany relationship.


texts: CAPTCHA default for Blog post forms does not work in Drupal 7

texts:
I'm trying to get CAPTCHA to be automatically added to my blog post forms so that I don't have to enable it individually on each blog post. I've followed the suggestion on this post, but unfortunately, this doesn't work for me. I've enabled everything that I should, but the CAPTCHA doesn't work for blog posts unless I manually enable them per post. This is not practical. I've used the CAPTCHA module fairly extensively before, so I understand how it works, but it's just not doing what I've told it to do.

Does anyone know what may be keeping my site from enabling CAPTCHA as the default for blog posts?


texts: How can I embed view results right in the content region as if it's part of the content?

texts: I have a node type with some entity reference fields that displays teasers.  I also have a block view that takes a URL component to display related nodes that are not referenced on the node's entity reference field.  What I want is for the view results to display right under the entity reference results display as if they were nodes being referenced on the field.  The site is using display suite so there is a two column display.


texts: how to connect to database for form submission

texts:
I have website and on its home page there is form in which user enter his own label .As user enters label if the user with same label exists in database it through message that "This Label already exists.Use other Label OR Login". If the user is new it will be directed to other site i.e site "example.com".

The problem is I am getting the same message that "This Label is already exist.Use other Label OR Login" even I enter a new label.

Here is the code for this scenario.

function homepage_userlogin_form($form_state){
// drupal_set_title('Add New Person');
$form = array();

$form['name'] = array(
'#title' => '',
'#type' => 'textfield',
'#size' => '30',
'#placeholder' => "enter desired label",
);

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

//$form['#attributes'] = array('id' => 'user-registration001');
return $form;
}

function homepage_userlogin_form_validate($form, &$form_state) {

$name = $form_state['values']['name'];
global $users;
$error=FALSE;

if (empty($name)) {
form_set_error("erorr",t("Please enter your Label."));
$error=TRUE;
}
//if(strlen($name)<6){
// form_set_error("Please Enter atleast 6 character Label.");
// }

if(!$error){

$result = db_select('users', 'u')
->fields('u',array('uid'))
->condition('name', $name,'=')
->execute()->fetchAssoc();

if($result['uid']>0){
form_set_error("erorr1",t("This Label is already exist.Use other Label OR Login"));
}

else{
global $users;
$user->name=$name;

}
}
}

function homepage_userlogin_form_submit($form, &$form_state) {
drupal_goto("http://example.com");

}


texts: How to consume RESTful web services in a custom module?

texts:
I have an API which I would like to consume to do specific actions on my Drupal 7 website after getting data from the user via a webform form. I plan to write my own custom module to do that but don't know how where I should start from.

Is there any hook that could help me add supplementary action after getting data from my webform ? How am I supposed to proceed to consume my web services ? Any code snippet, advice, will be appreciated.


texts: Associate one item of content with one taxonomy term

texts:
I have a view of type 'term' that displays in a grid, all the terms in a vocabulary. I need to display 2 images per term, but this is not possible I believe. (E.g. the taxonomy Image module only allows you to add one image per term).

So I thought maybe a solution to this would be to create another content type with one piece of content per term. And then associated each one with one of the vocabulary terms. And then create relationship in the view to link them. However I cant figure out how to get the view to do this. Is this possible?


texts:
I have this error message, which I know is related to the multiupload_filefield_widget  module. If I disable this module, the message disappear.

  Notice: Undefined index: preview_image_style in image_field_widget_process() (line 381 of /Applications/MAMP/htdocs/my-site.com/modules/image/image.field.inc).

I found this issue]2 which mention this message but isn't fixed yet.

How can I solve this?


texts: How to show thumbnail for image when edit the node Drupal 8

texts:
I need to add thumbnail for field image when I edit node

Field settings and type:
Could you please explain How to do it. Thanks.


texts: Somehow forum's got associated to wrong taxonomy vocabulary. Need help

texts:
I am using Advanced Forum 2.6 and I noticed that some of the views were set to pull the wrong vocabulary instead of the forum vocabulary. I set them all to pull the correct vocabulary but when I go to /forum the page title is still for the incorrect vocabulary and any change I make at admin/structure/forum also affects the terms in the previously connected vocabulary. It seems that the database is confused and I'm not sure how to reset things.

I am also getting a pair of the following errors for every term:

  Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 49 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).

  Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 60 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).

I am mostly a front end guy so I have little experience with messing around in the database directly but not afraid to have a go if that's what it will take to fix it.


texts: How do I get the title of an entity in hook_entity_presave?

texts: I am trying to get the title of an entity and I can do a dsm of the $entity, but when i do a dsm of $entity->values , nothing shows up.


texts: Devel output on hooks called during cron run

texts:
I'm implementing a hook that is called if certain conditions are met during a cron run.

(Specifically hook_bounce_mails_blocked($mails) from the Bounce module)

The hook is triggered, but any output from dpm() functions is never shown. I do see output from var_dump() after cron finishes.

Is this normal behaviour? Is there a way to get devel output shown once cron finishes?


texts:
I have installed S3 File System module, and all image files are served from AWS S3 bucket. The images served from S3 are not compressed. How to compress those images?

Following is the message I get when checking with page speed:

  Compressing
  https://example.s3-us-west-2.amazonaws.com/s3fs-public/test.jpg could
  save 22.4KiB (26% reduction).


texts:
I am trying to create content from a cron job with a custom node type that contains just a title and body; the content type is mycontent (for argument sake).

I am trying to use the Entity API module because apparently it is supposed to be simpler.

Working from examples, I wrote the following code.

$values = array(
    'type' => 'mycontent',
    'uid' => $user->uid
  );
$entity = entity_create('node', $values);
$ewrapper = entity_metadata_wrapper('node', $entity);
$ewrapper->title->set('My Title');

Clearly I am missing something here because I get an exception (EntityMetadataWrapperException: Unknown data property title).

So I changed it to the following.

$values = array(
    'type' => 'mycontent',
    'uid' => $user->uid
  );
$entity = entity_create('mycontent', $values);
$ewrapper = entity_metadata_wrapper('mycontent', $entity);
$ewrapper->title->set('My Title');

Now I get a different error, an obtuse Invalid data value given.

Why cannot I get the Entity API module to work as advertised?

The current user in this case is user 1, not the anonymous user. If I add the content using Drupal standard functions, it works. So I know I am not having a permission issue.

I looked at this example, to write my code, and then proceeded to google a lot.


texts: Wizard for generating a dynamic legal document

texts:
I have been tasked with investigating options for developing a Drupal module that would serve as a Wizard for helping users create a customized legal-agreement template based on a series of interview questions.  Please note, I have had no experience with Drupal before last week, so I need specific answers that do not assume any knowledge on my part.

Essentially, this new tool would ask the user a series of questions on a variety of topics (and follow-up questions based on a decision tree), and when the interview is complete, the tool would produce a text document containing only those (pre-written) paragraphs relevant to the project.  Alternatively, more experienced legal staff could bypass the interview and simply select the paragraphs desired by clicking on items in a list -- much like the way someone with tax experience can bypass the "Guided Tour" in TurboTax to select and manually complete the appropriate IRS forms.  Other requirements:  Our user interface for our interview must be intuitive to the average technophobe, and the user must be able to send the output into a MS-Word document (additional formats are a bonus).  Our office is developing other web-based tools using Drupal 7; we have limited resources available for programming this tool, so simpler solutions are preferred.

Has anyone done anything like this, or know of tools/modules that we could adapt?  What other advice do you have for us?

Thank you all in advance for your advice.


texts: How could I automatically delete accounts with a given criteria?

texts:
My drupal site has a textarea field in the new user application that asks for the new user to explain what their interest is in wanting to join the site.  Some sort of machine bot is sending a dozen or so requests for accounts daily.  Characteristically, this machine bot is putting two random characters into this "interest" field.  Therefore, I know that any account with only 2 characters in this particular field is this computer bot since no answer to this question on the application could be acceptable with only two characters.

I would like to know if there is a way that drupal can delete such accounts with only two characters in this particular field automatically by using a set criteria (e.g. a field containing only two characters).  How could I go about this?  It would be ideal to have Drupal NOT send an email message at all that a new user has signed up when this occurs, but if that is not possible, then can I do something to automatically delete such an application when the length of the field is only two characters?  I am looking for a Drupal method of doing this rather than a cron job method of doing this.

I realize that one could just use a field validation to start with but that won't answer the question: Can Drupal actually use some sort of specific field rule (e.g. a certain field must have more than x number of characters) to delete accounts automatically so they wouldn't have to be deleted manually and constantly by the administrator.


texts:
I'm trying to remove a Workflow instance from a Feature. But every time I uncheck the workflow and recreate the feature, the workflow gets deleted.

Now I know that with Views, Panels and other entities, all you have to do is to edit it, and it will be shown as overwritten (meaning it is using the database instead of code from the feature), and you can then safely remove it from the feature.

If I edit and save the workflow, it gives me a Revert link in the workflow menu. Yet if I then remove it from the feature, the workflow still gets deleted.

I've tried exporting the workflow and re-import it after removing, but then is just added with a new id (WID), which opens another can of worms on my site.

When I edit and save the workflow, I see in the workflow table in the db that the exportable status change from 2 to 3. I don't know what all the allowable statuses are. But this might be something to look into.


texts: Why is there a hash value at the end of this element ID?

texts:
I've created an entityreference to a content type that is just a title and an image, and set the storage settings to unlimited.  Now, when I'm on the edit form and I click the "Add Another Item" button, the ID of the input that appears is: edit-field-photo-1-target-id--nOP2UjZ0zuI

Why is that --nOP2UjZ0zuI at the end, there?  It makes it annoying to select, even though I'll be able to search for an ID that starts with edit-field-photo-X-target-id as a workaround, but what does it do?


texts: How to add secondary exposed form elements using "Better exposed module" in views

texts: I just want to know how to add elements like another exposed filter in this advanced tabs.Currently it is empty.


texts:
How to configure Trusted_Host_Settings for subdomains?

The documentation does not give an example of a subdomain.

For example, I have an Add-On domain that points to website.info, but the subdomain is mainsite.com/website.info


texts: Modifying $view in hook_views_pre_render()

texts:
I'm using Drupal 8.0.5, and need to force a title on a View.

I've tried various Views hooks, but will focus on hook_views_pre_render().

There's a ViewExecutable $view taken as an argument, which is not passed by reference.

I've tried:

function mymodule_views_pre_render(ViewExecutable $view) {
  $view->setTitle('foo');
  // $view->save(); // I've also tried this
}

I've gone through step-debugging to ensure it's getting called, but it seems the setTitle method does not affect the output that renders. I've also set my theme back to Seven to ensure there's not a theme issue involved.

I'm also happy to embed the View using a custom block, but I am running into the same issue there.

How does one modify a ViewExecutable object properly?


texts:
I have two profile type registrations .I am using  Profile2 and Profile2 Registration Path module.

1) student profile

2) parent profile

I have created admission_number field for the student registration. How can I get student admission number while the parent registration OR How do I display the information about his child when he is logged in?

I tried with Views PHP module, But I couldn't able to do it.


texts: hook_form_alter function to make field visible and required?

texts:
I'm trying to build a hook_form_alter function to  make field visible and required.

The form is the checkout form at http://example.com/en/checkout/33

The targeted field are Customer Profile Billing fields that I added at: http://example.com/en/admin/commerce/customer-profiles/types/billing/fields

I tried with:

function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    $form['field_cif_nif_id'] = array(
         // This #states rule says that the "field_cif_nif_id" fieldset should only
         // be shown if the "field_dispongo_de_" form element is set to "CIF/NIF/ID".
        '#states' => array(
           'visible' => array(
               ':input[name="field_dispongo_de_"]' => array('value' => 'CIF/NIF/ID'),
            ),
        ),
  );

 }
}

it simple doesn't work. No errors.

I need to make the 'field_cif_nif_id' visible and required only if 'field_dispongo_de_' has value 'CIF/NIF/ID'

UPDATE:
I forgot to mention that 'field_dispongo_de_' is a 'radio' type field and 'field_cif_nif_id' is a 'input text' type.

UPDATED CODE

It is closer but not working yet.

function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'commerce_checkout_form_checkout') {
    $form['customer_profile_billing']['field_cif_nif_id'] = array(
       '#states' => array(
           'visible' => array(
               ':input[name="field_dispongo_de_"]' => array('value' => 'CIF/NIF/ID'),
            ),
       ),
    );
 }
}


texts: Automagically relating nodes of a single content type

texts:
I have a content type (e.g. Target) which has a title and body. I will have about a 1000 nodes of this content type. I want to be able to create a view that renders not not only the title and body of this type of node, but also associated/related nodes.

I don't want to have to manually associate nodes (based on taxonomy or by adding an entity reference). Instead, I want the view to automatically search for the Title of a given node in the Body field of all other nodes of this type and associate those nodes that contain the given node's Title.

I'm new to Drupal, but believe I've gotten my head around the basics and have several Views configured and working. But I can't seem to find any guidance on achieving the above and not sure how to do that in Drupal/Views, although I know this is achievable in straight SQL.

Any ideas, advice?


texts: How to get $form_id based on $form_state for custom form rule?

texts:
I'm building custom form rule which is having $form_state as rule input parameter, however I would like to use drupal_form_submit() which requires $form_id.

Is it possible to fetch/compute automatically $form_id based on its $form_state to make my rule generic?

Or maybe there is some documentation that explains what $form_state should consist exactly?

My rule is like:

/**
 * Implements hook_rules_action_info().
 */
function rules_forms_rules_action_info() {
  $actions['rules_forms_submit'] = array(
    'label' => t('Submit the form'),
    'group' => 'Rules Forms',
    'parameter' => array(
      'form_state' => array('type' => 'form_state', 'label' => t('Form state')),
    ),
    'base' => 'rules_forms_action_submit',
    'access callback' => 'rules_forms_integration_access',
  );
  return $actions;
}

/**
 * Action: Submit the form.
 */
function rules_forms_action_submit($form_state) {
  // $form_id = ?
  drupal_form_submit($form_id, $form_state);
}

I've checked $form_state and it's a huge (~0,5MB size-like) ArrayObject with the following main keys/properties:

build_info, temporary, programmed, programmed_bypass_access_check, cache, entityform, entityform_form_mode, field, storage, rebuild, rebuild_info, redirect, submitted, executed, method, groups, buttons, input, values, complete form, process_input, invalid_token, triggering_element, submit_handlers, clicked_button


texts: Different page--user.html.twig for different user roles

texts:
I have a few user roles - simple user, editor and contributor.

How to make different profile pages for all of this roles?

Now I can work with:

FILE NAME SUGGESTIONS:
   * page--user--16.html.twig
   * page--user--%.html.twig
   x page--user.html.twig
   * page.html.twig

But I want work with page--user--somerole.html.twig (not (!) user--page--somerole.html.twig)

Thank you for any help.


texts: How can i add a depth class to UL in a menu list?

texts:
I try this code, but i get only the same default depth for all UL tags.

function MYTHEME_preprocess_menu_tree_override(&$variables) {
  $variables['tree_raw'] = $variables['tree'];
}

function MYTHEME_menu_tree($variables) {
  $menu_level = isset($variables['tree_raw']['#depth']) ? $variables['tree_raw']['#depth'] : 1;
  $class = "menu menu-lvl-".$menu_level;
  return '
' . $variables['tree'] . '
';
}


texts:
i am having this query :

   $db = \Drupal::database();

  $exist_query= $db->select('user__roles', 'ur');
  $exist_query->fields('ur', ['entity_id']);
  $exist_query->condition('ur.entity_id','u.uid', '=');
  $exist_query->condition('ur.roles_target_id', $included_user_roles, 'IN');

  $not_exist_query= $db->select('user__roles', 'ur');
  $not_exist_query->fields('ur', ['entity_id']);
  $not_exist_query->condition('ur.entity_id','u.uid', '=');
  $not_exist_query->condition('ur.roles_target_id', $excluded_user_roles, 'IN');

  $query = $db->select('users_field_data', 'u');
  $query->fields('u', ['uid']);
  $query->condition('u.uid', 1, '>');
  if (!empty($param['login_value'])) {
    $query->condition('u.login', $logindate, '<');
    $query->condition('u.login', 0, '!=');
  }
  $query->exists($exist_query);
  $query->notExists($not_exist_query);
  dpq($query);

the problem i am having is here

  $exist_query->condition('ur.entity_id','u.uid', '=');

it generates :

WHERE (ur.entity_id = 'u.uid')

when it should

WHERE (ur.entity_id = u.uid)

How can i solve this ?

The working request i am trying to achieve

SELECT u.uid AS uid
FROM
users_field_data u
WHERE (u.uid > '1') AND (u.login < '1586705658') AND (u.login != '0') AND (EXISTS (SELECT ur.entity_id AS entity_id
FROM
user__roles ur
WHERE (ur.entity_id = u.uid) AND (ur.roles_target_id IN ('admin_site')))) AND (NOT EXISTS (SELECT ur.entity_id AS entity_id
FROM
user__roles ur
WHERE (ur.entity_id = u.uid) AND (ur.roles_target_id IN ('membre_du_site'))))


texts:
I would like to add the possibility to change color in CKEditor, mainly for Webforms. The instructions at https://www.drupal.org/project/colorbutton suggest to download manually the CKEditor colorbutton plugin and then add it to /libraries: would it instead be possibile to modify composer.libraries.json and install the plugin via Composer ?
Thanks a lot


texts: How to use $variables from theme setting in main menu

texts:
I make some field in theme setting and can use them normali in block, page, but when I want to use them in main menu its dont work.

function saka_theme_preprocess_menu__main (&$variables, $hook) {

    $variables['social_url_fb'] = theme_get_setting('social_url_fb','saka_theme');

}

and in menu--main.html.twig I write this..

{% for item in items %}

                     {{ item.title }}

        {% endfor %}


texts: how to display related node titles to taxonomy terms

texts:
I want to display list of taxonomy terms and besides each taxonomy term need to display represented node title as well. For suppose To X taxonomy term a,b,c are taxonomy child terms. I have created a page and selected b term. Now I want to display in the below o/p.

>  X
>        a
>        b -> <node title>
>        c


texts: I just create a new content type and add a couple of nodes but I get 'The requested page could not be found.' message with anonymous users, apparently the nodes of this new content type require admin permissions, I've been searching on user management and enable access content but for this particular content type still need admin permission, any idea?


texts: Email users matching properties based on location, price etc

texts:
I'm building a Drupal 7 site that captures users property preferences (location, price range, bedrooms etc.) in the account creation form. I have a property content type that contains fields that match the ones in the user signup form. I'm trying to figure out a way to email users when a property or properties are submitted to the site that match their preferences.

I've watched the Rules framework series on the nodeone site (great tutorials BTW!) and I'm thinking this may be possible using Rules, VBO and maybe the Relation module? So I'm wondering if anyone could point me in the right direction or let me know if I'm crazy for thinking this is possible at all.

Any help would be greatly appreciated.