texts: How do I use exec() to run external software?

texts:
I am trying to use exec() function to run external software. This software is an .exe file.
The code that I created is given below:

$command = 'php sites\all\modules\wkhtmltopdf\bin\wkhtmltoimage.exe http://testing.local:8083 sites\all\modules\nodeImage.png';
$result=exec($command);
echo $result;

wkhtmltoimage.exe is an program to convert webpage to an image and it needs two parameters. The first is a link to a web page, the second is the path where the created image will be saved.

This program giving an error:

  Parse error: syntax error, unexpected '$' in
  C:\Users\123\Sites\drupal-7.26\sites\all\modules\wkhtmltopdf\bin\wkhtmltoimage.exe
  on line 4262

Anyone who is aware of this?


texts: Drupal multilingual monthly archive using views

texts:
I have multilingual website in Drupal 7 and I am trying to implement news and monthly archive by using views. I am facing some problems with the monthly archive (I am cloning the default Archive).

For each language I have created news pages - f.ex. www.mywebsite.com/news (in English) and www.mywebsite.com/da/nyheder (in Danish). I also have created different views ("news", "monthly archive") for each language. The switch between the news including the views "news" works fine. But the switch between the monthly archives does not work in the way that I would like to. For example when I am on the page www.mywebsite.com/news/201301 and switch to Danish I am going to the page www.mywebsite.com/da/news/201301 but I would like to go www.mywebsite.com/da/nyheder/201301.

In every view I am specifying the language (content language and field language) to English or Danish. Any idea how I can solve the path problem?

I have also tried to use one view for news and one view for monthly archive (using current user's language) but then the problem is the title page. I can not translate the title for the different languages (accessibility issue).

Can somebody explane which is the right way for implementation of news monthly archive for multilingual website please.


texts: "Site off-line due to technical problems" (no extra info in message). What causes this?

texts:
What causes the following message on a Drupal 6 site with no other information?

Site off-line
The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.
If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.

I think it means that the database did not respond in time but can someone confirm that?
I can force almost the same message by stopping the db but then it has some extra info under it about not able to connect to the db. That makes me wonder what it means when there is no extra info at all.
It is definitely related to slowness. It happens sometimes when the site is very busy and therefore slow. There is no obvious reason recorded in either the Drupal or Apache logs
Thanks


texts: Should drupal_is_front_page work with ajax and a panelized front page?

texts:
I have a panelized front page which is accessible via base_url/home or base_url/.

If I call the front page normally drupal_is_front_page returns TRUE, but if I use a view with an exposed filter using ajax, drupal_is_front_page returns FALSE. The question is, is this a normal behaviour, or might there be a module or some custom code, which leads to this result?

If I follow the documentation of this function and check

$_GET['q'] == variable_get('site_frontpage', 'node')

this always leads to a TRUE, even if I use an exposed filter with ajax. So maybe drupal_static() delivers a wrong result...

My project is developed now over a few months and I think there had been times where this didn't occur, but I am not 100% sure. And if this is not the normal behaviour, how could I detect the code responsible for this behaviour?


texts: Download development releases of modules with Drush Make

texts:
How do I get a development release of a module in the .make file of my installation profile?

I am writing this now to get the development release of better_exposed_filters.

projects[better_exposed_filters][version] = "3.0-beta3+31-dev"

When I run the .make file I get the following message:

  Could not locate better_exposed_filters version 7.x-3.0-beta3+31-dev, will try to download latest recommended or supported release.


texts:
I'm trying to use Node Hierarchy module together with the Menu Block module to create blocks in different regions of my site.  My problems is that when a child path is active, the parent path doesn't highlight.

An example of what I want is the path http://example.com/exampleparent/childnode1

My main menu is on the left side of the screen, like so:

Home
Example Parent  <-- active parent
About

And the child menu is on the right side of the screen, like so:

Child Node 1 <-- active child
Child Node 2

But when I'm viewing the child node the parent isn't "active" (bold, in my example).

Is there an option I'm missing, or does the Menu Block module not work the way I think it does?


texts: What are dependencies in the context of a user role in Drupal 8?

texts:
In the process of wrapping my head around Drupal 8's configuration system (which is awesome, by the way), I came across this:

YAML file (from core/modules/user/config/install/user.role.authenticated.yml)

id: authenticated
label: 'Authenticated user'
weight: 1
langcode: en
status: true
is_admin: false
dependencies: {  }

Now of course I understand module dependencies, but what might be set here as a dependency for a user role configurable and what would it mean?

Thanks!


texts: How to alert users when new content is added via email and/or text message?

texts:
I have a membership Drupal 7 website and I'd like to automatically alert users via their email address and/or text message to their cell phone when new content is added? I'd also like to give registered users the ability to select/change these communication preferences.

Is there any Drupal way/technique that can provide this functionality?


texts: What is the difference between havingCondition and having?

texts:
Drupal dynamic queries have 2 conditional clauses called having and havingCondition.

The documentation states "The Having clause behaves identically to the WHERE clause, except that it uses methods havingCondition() and having() instead of condition() and where()."

Other than this I can't find any mention of either clauses anywhere (including in the examples module), or any examples of their use.

What is the difference between the 2 functions?


texts: I have installed contact module and SMTP Authentication Support but do not appear in Structure tab

texts:
I have Drupal 7.22 installed, I have installed some modules, but there are two modules that appear correctly installed but I cannot see their configuration in structure.
These modules are Contact and SMTP Authentication Support.

Previously I had some issue with the cache in Configuration tab, and I empty the cache, and it worked, but in the Structure tab even if I do it, I don't solve it.


texts:
After I clicked to create a new content type, I got this message.

  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'bis301.cache' doesn't exist: DELETE FROM {cache} WHERE (cid LIKE :db_condition_placeholder_0 ESCAPE '\') ; Array ( [:db_condition_placeholder_0] => entity_info:% ) in cache_clear_all() (line 168 of C:\xampp\htdocs\bis301\includes\cache.inc).

How can I fix this problem?
Help me please.....


texts: How to access session variables in Twig template?

texts:
In a custom module I specified in the hook_preprocess_page function the following session variable:

if (isset($blockNameState) && $blockNameState == 'open') {
   $tempstore->set($blockNameState, 'close');
}
else {
   $tempstore->set($blockNameState, 'open');
}

Let's assume the above code ran with $blockNameState = 'block1_state' and there is key/value pair 'block1_state/open' in the $tempstore.

How do I access the key/value pair in a Twig template?

Can't run the following PHP command in Twig:

$blockNameState = $tempstore->get($blockNameState);


texts: custom module: drupal_add_js and drupal_add_css do not work after form validation?

texts:
I have created a custom module that changes the layout & adds extra functionality to one of my content type creation and edit forms.

It works beautifully and as expected apart from when I submit the form with, for example, a blank node title or any other required fields.

The page is reloaded as expected with the error message, the form modifications are loaded from the module (field #prefix, #suffix etc..) but the css and the js are not loaded.

Here is the code I have:

/**
* Implementation of HOOK_form_alter()
*/
function mymodule_entry_form_modify_form_alter(&$form, $form_state, $form_id) {

  // 1.ENTRY FORM
  if ($form_id == 'entry_node_form') {

  // here were some form field modifications i removed

/* 1.3 LAYOUT - ADD JAVASCRIPT FILES
 * Add .js files
 */
// add jquery script before calling it
drupal_add_js(drupal_get_path('module', 'mymodule') . '/includes/js/jquery.fixheight.js');
// call the script
drupal_add_js(drupal_get_path('module', 'mymodule') . '/includes/js/mymodule_entry_form_modify.js');

/* 1.4 LAYOUT - ADD CSS FILES
 * Add .css files
 */
drupal_add_css(drupal_get_path('module', 'mymodule') . '/includes/css/mymodule_entry_form_modify.css');

 }
}

Can anyone explain why this happens?


texts: How to check for Grouping field in Views submodule?

texts:
I'm developing on the Views Datasource module to enable grouping by field (not field aggregation). I've now got the output format that I want, but I don't know what variable the Grouping Field setting is stored in. I want to check if a grouping field is selected, and then assign the field's name as an array key if it is.

views-views-json-style-simple.tpl.php:

// TODO Enclose everything in an if statement, conditional
//   on a grouping field being selected

$grouped = array();

foreach ($rows["nodes"] as $nodenum => $nodearray) {
  // TODO Replace "building" with variable representing user-
  //   selected field.
  // Variable names will obviously change too.
  $building = $nodearray["node"]["building"];
  foreach ($nodearray["node"] as $cprop => $cvalue) {
    // TODO Replace "building" with grouping field variable
    if ($cprop != "building") { // Ignore grouped field
      $grouped[$building][$cprop][$nodenum] = $cvalue;
    }
  }
}

$rows = $grouped; // Pass back to existing code

The above code takes the $rows output by views, and reformats the array right before it goes to _views_json_json_encode. The idea is to take the default output of Views Datasource:

{
  "nodes" : [
    {
      "node" : {
        "name" : "Energy Services Performance Contract (ESCO)",
        "geometry" : "48.7366, -122.486",
        "description" : "This project was initiated In order to advance Western’s sustainability goals and reduce our carbon footprint. The project will implement 38 separate facility improvement measures in various academic and auxiliary buildings identified by an energy audit of Western's campus.",
        "building" : "BH"
      }
    },
    {
      "node" : {
        "name" : "Energy Services Performance Contract (ESCO)",
        "geometry" : "48.7378, -122.486",
        "description" : "This project was initiated In order to advance Western’s sustainability goals and reduce our carbon footprint. The project will implement 38 separate facility improvement measures in various academic and auxiliary buildings identified by an energy audit of Western's campus.",
        "building" : "WL"
      }
    },
    {
      "node" : {
        "name" : "Wilson Becoming Skyscraper",
        "geometry" : "48.7378, -122.486",
        "description" : "Wilson will have 708 floors added to it, becoming the tallest building ever.",
        "building" : "WL"
      }
    }
  ]
}

and turn it into

{
  "BH" : {
    "name" : [
      "Energy Services Performance Contract (ESCO)"
    ],
    "geometry" : [
      "48.7366, -122.486"
    ],
    "description" : [
      "This project was initiated In order to advance Western’s sustainability goals and reduce our carbon footprint. The project will implement 38 separate facility improvement measures in various academic and auxiliary buildings identified by an energy audit of Western's campus."
    ]
  },
  "WL" : {
    "name" : {
      "1" : "Energy Services Performance Contract (ESCO)",
      "2" : "Wilson Becoming Skyscraper"
    },
    "geometry" : {
      "1" : "48.7378, -122.486",
      "2" : "48.7378, -122.486"
    },
    "description" : {
      "1" : "This project was initiated In order to advance Western’s sustainability goals and reduce our carbon footprint. The project will implement 38 separate facility improvement measures in various academic and auxiliary buildings identified by an energy audit of Western's campus.",
      "2" : "Wilson will have 708 floors added to it, becoming the tallest building ever.\n"
    }
  }
}


texts: hook form alter with hidden field, throw an error

texts:
I try to alter taxonomy edit form.

This is my hook:

function MYMODULE_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id) {
    // hide the desciption field and relations group field
    $form['description']['#type'] = 'hidden';
    $form['relations']['#type'] = 'hidden';

    // set the default value
    $form['description']['#value'] = ' ';
    $form['relations']['weight']['#value'] = 0;
    $form['relations']['parent']['#value'] = array('value' => '13');

}

But When I submit, It throw me an error:

Warning: Illegal string offset 'value' in taxonomy_form_term_submit_build_taxonomy_term() (line 862 in /Users/tangmonk/MyGit/Drupal/daxuebao/modules/taxonomy/taxonomy.admin.inc).


texts: MigrateSQLMap how to instantiate if table has no primary key

texts:
Guys how do you instantiate this MigrateSQLMap if my destination table has no primary key?

here's my code:

 $table_name = 'taxonomy_index';
    $this->map = new MigrateSQLMap($this->machineName,
      array('id' => array(
              'type' => 'int',
              'unsigned' => TRUE,
              'not null' => TRUE,
             )
           ),
        MigrateDestinationTable::getKeySchema()
      );

im trying to import to the taxonomy_index table in drupal which we know has no primary key.

how to make this possible?


texts: How to show filesize when content type contains more than one file?

texts:
I'm using Drupal 7 and having File 7.14 field installed.I have a content type (named file) containing more than 1 file. I have a view that shows the filesize of all the files of the content of that content type named file.
For doing that I have added  a relationship in Views to "select File Usage: File"
The filesize is nicely shown for content that contains only one 1 file.

However for content containing more than 1 file the filesize is only shown for the first file but not for the 2nd 3th etc.

Here is how my query currently looks like:

SELECT node.title AS node_title, node.nid AS nid, node.language AS node_language,   file_managed_file_usage.filesize AS file_managed_file_usage_filesize, 'node' AS  field_data_field_file_node_entity_type
FROM
{node} node
LEFT JOIN {file_usage} file_usage ON node.nid = file_usage.id AND file_usage.type = 'node'
LEFT JOIN {file_managed} file_managed_file_usage ON file_usage.fid = file_managed_file_usage.fid
WHERE (((node.status = '1') AND (node.type IN  ('file'))))
ORDER BY node_title ASC
LIMIT 50 OFFSET 0

Can anybody explain me how to change the View settings so that the filesizes of the other files are also be visible?


texts: get list of product line item in rule php

texts:
how can I get product id of line items in checkout process with rule,
I know $commerce_order are there in rule, but how can I get list of product id ?


texts: View code stuck in database and does not revert

texts:
hope someone can help.
I'm currently having a problem with view that are not reverting to code.
What I did is creating a module for my view and exported them into code.
I did this to get the structure out of the database and at the same be able to version control.

Using a views_default.inc, I have the following function in it:

function mymodule_views_default_views() {
    $files = file_scan_directory(drupal_get_path('module', 'mymodule') .'/views', '/\.view/');
    foreach ($files as $absolute => $file) {
       require $absolute;
       if (isset($view)) {
          $views[$file->name] = $view;
       }
    }
    return $views;
}

Each view has it's own .view file inside the views sub folder of my module. Files are named usng the view machine names.
Once the module activated, I cleard the cache, view cache. Then reverted the views.

Out of the 46 views, I have 18 of them that don't show "In code" and still say "In database" with no option to revert.
I've been looking around and trying to figure out why, but no luck.

These views are of different type...blocks, pages, reference, etc...

Does anyone know why some views would not revert?
Thanks


texts: Attempting to load content into dialog (modal) via URL

texts:
I have a page that contains both static and dynamic content. On the static portion, I've attached a link that looks like this:

  Profile

Works flawlessly. The link is clicked and a modal(dialog) from Drupal core (powered by jQuery UI) is displayed.

However; in another portion of the page, I've inserted content into the DOM with code that looks like this:

$( ".insert" ).load(data + " .rlp-detail-more", loadComplete).attr("data-research-content", dataResearch);

That code contains EXACTLY the same string of html as above...

However, clicking the link takes me to the content with no overlay/modal/dialog.

And it gets weirder...

If I leave the inserted content open and click on the link further down in the static content, suddenly they both work... e.g., the jquery event hander somehow got attached to the inserted content.

My question is... How can I force an attachment of the event handler.

This question take a pretty good understanding of the jQuery dialog event and Drupal 8 integration of jQuery UI


texts: How to get flag count for any time period

texts: I have View which displays a list of nodes with counters (flags), but the counters for all the time. How to display a list of nodes with counters (flags), for example, over the last week or last month?


texts: How to apply a function to the title of a teaser made with display suite?

texts:
I'm pretty new to functions and PHP (so please forgive my terminology) but here's what I would like to do:

Background

My homepage contains a view displaying various content type teasers. I would like to truncate the title of an article teaser (a custom teaser created with display suite) to 48 characters.

Action taken so far

If I add the following code to my subtheme's template.php file, nothing happens:

function THEMENAME_preprocess_node(&$variables) {
     if ($variables['type'] == 'article' && $variables['view_mode'] == 'teaser') {
     $variables['title'] = truncate_utf8($variables['title'], 48, TRUE, TRUE);
   }
}

However, if I add this other variation of the code (i.e. applying to all teasers, not just article teasers) the titles of some teasers are indeed shortened:

function eunic_global_preprocess_node(&$variables) {
if ($variables['teaser']) {
    $variables['title'] = truncate_utf8($variables['title'], 48, TRUE, TRUE);
   }
}

Conclusion & Question

I think the problem is to do with the fact that some teasers have been created using the Display Suite module while others use more or less the default teaser.

So my question is - how do I 'refer' to the title of a teaser made with display suite in order to apply the truncate_utf8 function? Fingers crossed there's a way to do it...

Thanks
A~


texts: Link field value is missing from views raw result in views_get_view_result($view->name, $display_id = 'some_display');

texts: I have the link field module enabled and It works fine with views. Except when I get the views result in code using view->execute or views_get_view_result I do not see the link field result. Is the link field handlers invoked during the render phase? If so how can I attache the link field views result to the views result.


texts: Mini panel visibility rules based on drupal variable

texts:
I have a site which will have slightly different layout elements displayed throughout its lifecycle. The lifecycle is implemented using simple drupal variable (variable_get/variable_set). Administrator basically changes this variable's value when time comes for the website to pass on from one stage to another. Every stage lasts for few weeks or few months. Based on the value of this variable, I would basically like to show/hide some blocks, using panels and mini panels visibility rules. There are also Rules rules being fired on stage change, but that's whole other story and also taken care of.

Here's the problem - I cannot wrap my head around making Drupal variable available to  panels as context and/or visiblity rule. I searched everywhere and didn't find anything, clicked around panels and some additional modules like crazy, nothing -  maybe I'm using wrong keywords. Did I get stuck in some single line of thining?

Maybe I shouldn't try to stay with variable and there is better, more obvious way to achieve what I need?

Any help/suggestions/hints most appreciated!

Thx,
m


texts: Theme the taxonomy tags list in the node teaser

texts:
In my Drupal site I have node teasers that show taxonomy terms. As it stands they are like:

Tags:

Houses

Tags:

        Houses

I cant locate where the  anchor tag is being generated. I want to be able to change it to a <button> tag instead of anchor.

Any ideas how to do this?


texts: Displaying the node title in different region

texts:
My designer just killed me, I realised he put node titles in a different region of the page layout, just beneath a menu and before left/right sidebars. No going back now.

How can I display titles of things (nodes, views etc) in a different region and hide it from the content region?


texts: I am wondering what is the best way to somehow clone/export/duplicate a single forum thread?


texts:
I can print out user login form with:

print drupal_get_form('user_login');

How can I print out admin login form ?

Edit: Drupal 6


texts: I am creating a Drupal commerce Payment module and planning to sell it through codecanyon. Is there any licencing issues if I proceed with this?


texts: Ajax button strange behaviour when clicked twice

texts:
I have a form where there is a dropdown with names, a button to add the names to a table and a table showing the list of names.

When clicking the button, an AJAX request is fired, the selection is added to a database table, the html table is reloaded and updated.

Everything works fine for the first click. The assigned ajax callback routine is called.

When I like to add the second name, the ajax callback is NOT called, but the standard submit function is called instead.

Here is some sample code - first the elements for the form:

$form['auctionpersons']['add_person'] = array(
  '#type' => 'select',
  '#title' => t('Select person to add'),
  '#options' => $aPersons,
);
$form['auctionpersons']['add_person_btn'] = array(
  '#type' => 'button',
  '#value' => 'Add person',
  '#description' => 'Click button to add person',
  '#ajax' => array(
      'callback' => 'add_auction_person_ajax_callback',
      'effect' => 'fade',
  ),
);
...
$form['auctionpersons']['ptable'] = array(
  '#theme' => 'table',
  '#header' => $pheader,
  '#rows' => isset($aPersonsTable)?$aPersonsTable:null,
  '#disabled' => TRUE,
  '#title' => 'Users currently assigned',
  '#empty' => t('No users assigned yet!'),
  '#prefix' => '
',
  '#suffix' => '
',
);

Now the function for the ajax callback:

function add_auction_person_ajax_callback($form, &$form_state) {
  dpm('172: add_auction_person_ajax_callback');
  dpm($form_state);
  add_person_to_table($form_state['values']['add_person']);
  $aPersonsTable=get_person_table_rows();
  $form['auctionpersons']['ptable']['#rows']=$aPersonsTable;
  $commands = array();
  $commands[] = ajax_command_html('#ptable_wrapper', render($form['auctionpersons']['ptable']));
  return array('#type' => 'ajax', '#commands' => $commands);
}

Can anyone see the problem?


texts: Change page.tpl.php in a shared theme based on domain

texts:
I keep finding snippets like this:

function MYTHEME_preprocess_page(&$vars) {
  $alias_parts = explode('/', drupal_get_path_alias());

  if (count($alias_parts) && $alias_parts[0] == 'mydirectory') {
    $vars['theme_hook_suggestions'][] = 'page__mycustomtemplate';
  }
}

But, what I'm trying to figure out is how to switch to a different page.tpl.php file entirely within the same theme when a domain is different.

So if I had:

http://www.example1.com/stuff AND

http://www.example2.com/stuff

Using domain access module and other rules, the content is slightly different for example1 than example2 but the paths are identical so I can't simply access arg[0].

The ham-fisted way is to dupe the theme, change the name and be on my way but I'm sure I'm not getting something...the actual basic page.tpl.php template has to be modified because of existing content at the same path but different domain.

On example1, there are no side bars for example so those regions are not in the .info file nor rendered but on example2, there are sidebars. However, since I want to apply an existing theme, I just thought I'd restructure the actual page.tpl.php file for example2 so as to keep the majority of css/jquery and custom html implemented into the theme.

Is this more trouble than just duping the theme, rename and make the changes there?


texts:
Let's say I want to make a wiki-styled knowledge base for recipes.

User A submits a recipe for "Lasagna". User B likes this recipe but would like to submit her grandmothers special recipe for others to enjoy, so she clicks "post your version" and then writes "Lasagna - Grandma B's style". The two articles now automatically have a relationship, but behave as independent pieces of content.

User C knows he wants Lasagna, and would like to try a new version of it. This is where I would like all the recipes relating to Lasagna can be listed and sorted on things like points (thumbs up/down), number of comments, visits etc.

If I had complete control over the terms this wouldn't be hard to do with views and taxonomies, but I want this to be community driven and versions of content and their relations to happen organically.

How would you approach this? I've tried References but I couldn't get it to cross reference. Relation seems to be very close, but how would I create the "post your version" (i.e relation) button?


texts: How can I make views show 10 items if there are actually less (and add placeholders)?

texts:
I have a view output that shows user-profiles. Each view is a group on it's own and has a maximum of ten members. How can i show always ten items, if there are currently -let's say- only 7 assigned? So it would show 3 empty slots with maybe a custom text.

I don't find any logic that's out-of-the-box views behaviour for this. Can someone please point me in the right direction?

Thanks!

EDIT: Adam Balsam pointed out the grid format, which has an autofill feature. Unfortunately it's just an empty table row that is created. It's also not useable for responsive layouts... bummer.


texts: Update pagination after hook_apachesolr_process_results()

texts:
Apache Solr Search
Version: 6.x-2.x-dev

I am using hook_apachesolr_process_results() to modify results of search. This returns fewer results than are indicated by displayed filters. Pagination is also configured for original search results, not those modified by hook.

My question is: Is there a way to modify the pagination due to modified results totals without deleting the excluded nodes from the index?

For example, if I execute search A, my pagination is set for a total of 100 results on 10 pages listing 10 results per page.

When the results of this search are modified by hook_apachesolr_process_results(), I now actually have only 15 results. But, my pagination is still set for 100 results.

I want to know how to reset the pagination for a total 15 results.

Thanks for any assistance anyone can provide.


texts: Inserted View in Simplenews excluded from Email but included on website

texts:
Drupal 7.14, Simplenews 7.x-1.0-rc1, Insert View 7.x-2.0, Views 7.x-3.3

I have created a view ("birthdays"), a newsletter and inserted the view [view:birthdays]. The view is inserted and displayed correctly when I display the newsletter on the website. The problem is - the view is not included when I email the newsletter. I am using MailSystem, MimeMail, all set to send HTML, which otherwise works correctly. Ideas?


texts: how to use hook_webform_submission_presave on a site with multiple webforms

texts:
I've got a question on the use of the hook_webform_submission_presave function for D6/webform 6.x-3.4

I've got a multi-lingual D6 site that has one webform for each language, I'm trying to create a new module that will catch the submitted form info and send it to a third party email marketing company (the forms are newsletter signups and the third party is cheetahmail).

My specific question is:
Currently I have 6 webforms on my site, and I need to send info to identify which language the signup has come from.

Do I have to write a hook for each language/form ID?
or is there a way I can set up an admin panel and list the webform IDs that I'd like to hook?

Thanks for the help, please let me know if I need to provide more detail
Steph


texts: Does Drupal modify folder permissions during runtime?

texts:
Does Drupal modify the permissions on folder within the sites folder? Is there an edge case where this is possible outside of install?

I've been seeing an issue where a sites folder whether it be default or blah.com is getting it's write permissions removed after loading the site.

It's not specific to one codebase, it occurs across multiple codebases (no modifications to core) and across multiple versions 6/7.

This is problematic when using git with a specific site folder as git can no longer perform checkouts and merges without the write permissions.


texts:
I see that modules can have dependencies on other modules.

Why is this, and how might I use this in my own custom module development?


texts: Combine fields from many nodes within a custom controller

texts:
I'm going this route as I can't get a view to behave as needed.
In simple terms I have
content type 1 containing custom field 1 with a custom formatter
content type 2 containing custom field 2 with a custom formatter
content type 3 containing custom field 3 with a custom formatter
Each node will display correctly using the formatter if the node is viewed directly so I'm happy with that, however for some of the pages I need to display I need to use all (or partial) content from these content types as a single "entity". What I'm trying to do is generate a response that in effect wrap the output of all 3 sets of fields into a single output that can then be pushed back into Drupal's normal page processing so that other modules can work on the aggregated output before the HTML rendering phase. Additionally, if possible I'd like to be able to use different formatters other than the field default for the fields depending on the use context so a web page used the default formatter, a rest feed used formatter 2, an XML feed used formatter 3
I'm using Drupal 8.9 but will soon be moving to Drupal 9.


texts: How to change the image size within a Drupal view

texts: Does anybody know the best way to change the image size of a field within a view using Drupal 8?


texts:
I want to add the expires_in time to the database when a user authorizes linkedin to store the token. https://www.drupal.org/project/linkedin

I have added token_expires

$sql = array(
    'uid' => $account->uid,
    'token_key' => $oauth['oauth_token'],
    'token_secret' => $oauth['oauth_token_secret'],
    'type' => 'access',
    **'token_expires' => $oauth['oauth_token_expires'],**

and have modified the query, but it does not store the record.

$uid = db_query("SELECT uid FROM {linkedin_token} WHERE token_key = :token_key AND token_secret = :token_secret AND type = :type ", array(':token_key' => $oauth['oauth_token'], ':token_secret' => $oauth['oauth_token_secret'], ':type' => 'access', ':token_expires' => $oauth['oauth_expires_in']))->fetchField();

I would like to store the expiration time to the database that is returned from OAuth


texts:
It's not easy to explain so I made simple example below. I'm making a gallery in Drupal 8.
First I made articles with taxonomy term: animals, forest or people. Some of articles have two or three taxonomy terms. Each article contains 1-5 photos. The main page (gallery) displays a main photo from each article (picture 1). As you can see when you click FOREST gallery shows all articles contain 'forest' taxonomy (picture 2). When someone click on a thumbnail from the forest gallery then a page (picture 3) appears and we can see our tree with 2 more photos (for example colorbox) plus some comments and thumbnails of articles with forest taxonomy above. Picture 4 is easy to understand.  Additionaly when you click on a thumbnail from NEWEST(ALL) gallery the next and previous articles has to include all taxonomy terms or just all photo articles.

I've made a few projects but none of them can do this all same time. Is there a way to make this photo gallery? It looks like a basic gallery but I couldn't find solution or module.

EDIT 2019-11-27: From the beginning: I have articles (with photos) that have taxonomy term.I have views for each taxonomy term. For example, for the "People" category, I have a view that displays the title and thumbnail photo from each article that has "People" taxonomy. If the article has two taxonomy terms, its thumbnail is displayed, for example, in the "People" view and the "Forest" view. And that's ok. I also have a pager for every taxonomy, made by the Entity pager module, which is a block. I would like this pager to be displayed in the article. But now, if I have an article that has two taxonomy term, it displays two pagers. I would like only one to be displayed. If I click on the article shortcut in the "People" view
(and this article has the taxonomy term "People" and "Forest") I would like this article to display the "People" pager only. If I click the same article thumbnail, but in the "Forest" view, I would like only the "Forest" pager to be displayed in this article. Is it even possible to do this?


texts: Changing site:mode throws Twig memory error

texts:
I am trying to toggle the site mode for a new Drupal 8 development site. When I run the command drupal site:mode dev I get the following error:

PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1038876672 bytes) in phar:///usr/local/bin/drupal/vendor/twig/twig/lib/Twig/Extension/Debug.php on line 56

Increasing the memory (even to something huge) doesn't resolve this. Is Twig trying to throw an error, or output loads of data? How can I fix this please?


texts: using hook_user() to capture user actions

texts:
I am trying to create a method to log the actions of users, specifically when they log in and out.  I am using hook_user() method to do this. This is my code.

function mymodule_user($op, &$edit, &$account, $category = NULL) {
     switch ($op) {
        case 'login':
            //log to db
           break;
         case 'logout':
           //log to db
            break;
    }
}

There are two problems with this code, and I can't figure out how to fix them.

When a user password is expired, and they attempt to log in, they are redirected to their profile page to change their password. In this event, $op is never "login" and, as such can never be loaded. Instead, $op = "load" but it is useless to log this as this hook gets called nearly 50 times (storing that much data would be to much). Is there a better way to capture this event?

Second, when a user logs out ($op = 'logout') all the other information about the user is lost: The $account array only has empty values (and I need the user ID). Is there a way to capture the logout event and know the user ID?


texts: I have quite a few content types, and when I set it up I didn't think ahead and created an image field for each content type rather than one image field type.  Is there a way to add a common image field type and mass-convert the content types to use that one field?  Or do I have to manually migrate all of the currently populated fields?


texts:
We created a home page as node/1850 which is specified in /admin/config/system/site-information.  When I look at the generated code, I see:

<link rel="canonical" href="/node/1850" />

This results in Google listing the url of the home page as https://dom.ain/node/1850 which is not what we want.

What is the best way to correct this?  I believe the following is correct.

<link rel="canonical" href="/" />


texts: How to add html to title output of taxonomy terms in Drupal 7?

texts:
I just cant figure it out. How can change the title output of a term?
I have a content type which displays the selected terms. The term is displayed as a link. How can I change this:

    FE-Sub

to something like this:

        FE-Sub

Edit: I tried it out with mymodule_preprocess_field(&$variables) but you may not enter html, it will print "-Element

function proposals_preprocess_field(&$variables) {
    if (isset($variables) && isset($variables['items']['0']['#options']['entity_type']) && $variables['items']['0']['#options']['entity_type'] == 'taxonomy_term') {
        $variables['items']['0']['#title'] = ''.$variables['items']['0']['#title'].'';
    }
}

renders link text:

term title instead of term title

EDIT: here is how i made it work:
in your template.php:

function yourtheme_field__taxonomy_term_reference($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '
' . $variables['label'] . ':
';
  }

  // Render the items.
  $output .= ($variables['element']['#label_display'] == 'inline') ? '
' : '
';

  foreach ($variables['items'] as $delta => $item) {
    // allow html
    $item['#options']['html'] = TRUE;
    // set html
    $item['#title'] = ''.$item['#title'].'';

    $output .= '
' . drupal_render($item) . '
';
  }
  $output .= '
';

  // Render the top-level DIV.
  $output = '
' . $output . '
';

  return $output;
}


texts: Is there a way to log changes to module settings for better long-term administration and debugging?

texts:
We run quite a complicated Drupal 6 site with a lot of custom modules which was already migrated from D5. There are a few site administrators and we have had situations where a change in the settings of one module (usually something conflicting with Boost) has caused a problem with the site that is only detected later. We have no way to quickly tell which settings have been changed recently and what their previous values were.

Is there an additional module that hooks into to all variable_set() calls (for example) and logs the old and new values so that we can have an admin view listing all changes over time and which user made the change? It would be great to have an option to add a note to each item to explain why the change was made?

We try and share notes in our wiki on such changes but I think it would be much better if such data was available from inside Drupal itself.


texts: How to block the user after a few failed logins

texts: modules like login security deny the user IP after afew failed logins. there are softwares that randomly generate new IP for user so it makes such modules useless. sending cookie to the user browser is also unreliable because the user can disable accepting cookie. What is the most reliable solution to block some users?


texts: Is there a way to upload files and directories, and make Drupal keep the structure in the destination folder?


texts: How can I disable single option of checkboxes in drupal 8

texts:
I am using domain access module in Drupal 8. I want to disable one option/site in domain access settings in node edit page . I am trying to disable through hook_node_form_alter. Following is my array in node form alter

Array
(

[widget] => Array
    (
        [#title] => Domain Access
        [#description] => stdClass Object
            (
                [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                [string] => Select the affiliate domain(s) for this content
            )

        [#field_parents] => Array
            (
            )

        [#required] => 1
        [#delta] => 0
        [#weight] => 0
        [#element_validate] => Array
            (
                [0] => Array
                    (
                        [0] => Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsButtonsWidget
                        [1] => validateElement
                    )

            )

        [#key_column] => target_id
        [#type] => checkboxes
        [#default_value] => Array
            (
                [0] => site1
                [1] => site3
            )

        [#options] => Array
            (
                [master] => stdClass Object
                    (
                        [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                        [string] => Master
                    )

                [site1] => stdClass Object
                    (
                        [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                        [string] => Site 1
                    )

                [site2] => stdClass Object
                    (
                        [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                        [string] => Site 2
                    )

                [site3] => stdClass Object
                    (
                        [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                        [string] => Site 3
                    )

                [site4] => stdClass Object
                    (
                        [__CLASS__] => Drupal\Core\Field\FieldFilteredMarkup
                        [string] => Site 4
                    )

            )

)


texts: How to theme separately the node content and the comments

texts:
I have seen here several related questions, none of which clearly provide an answer. I am implementing a theme where I want the node content (with its title, the tabs, etc.) themed completely separately (i.e. in a different div) from the comments. The initial problem is that part of what I consider the node content (the title, the tabs) is rendered in page.tpl.php and part (the node body itself) is rendered in node.tpl.php. The problem is that the comments are an integral part of the variable $content in node.tpl.php.

I found part of the solution:

I found the template comment-wrapper.tpl.php. By reimplementing it in my theme, I can cancel the output of the comments (by blanking out the template).

Now, I would like to use mytheme_preprocess_page() to pull up the comments into a variable $comments so that I can add the comments where I want in page.tpl.php.

The remaining problem is how can I get all the variables originally available within comment-wrapper.tpl.php from mytheme_preprocess_page()?

Or do you know another (better) way to achieve the same thing?

Another way to answer the question: who calls comment-wrapper.tpl.php ?

Maybe an answer to that question would help:
$content: reworded about manipulating this variable


texts:
I have 3 Dropdown Fields which reload "in a row"

$form = array();
 $form['oid'] = array(
'#type' => 'select',
'#title' => t('Operating System'),
'#options' => taas_select_options_os_frontend(),
'#required' => true,
'#ajax' => array(
    'event' => 'change',
    'wrapper' => 'browser-wrapper',
    'callback' => 'taas_ajax_browserlist',
    'method' => 'replace',
  )
);

$form['bid'] = array(
'#type' => 'select',
'#title' => t('Browser'),
'#options' => drupal_map_assoc(array(t('Select OS First'))),
'#required' => true,
  '#prefix' => '
',
  '#suffix' => '
',
  '#ajax' => array(
            'event' => 'change',
            'wrapper' => 'flash-wrapper',
            'callback' => 'taas_ajax_flashlist',
            'method' => 'replace',
        ), );

after Refresh of the BID field the old name and id of the  are gone and so the eventlistner isn't working any more

function taas_ajax_browserlist($form, $form_state){
  $os = isset($form_state['values']['oid']) ? $form_state['values']['oid'] : 'os';

  switch($os){
      case 'os': break;
      default:
          $form['bid'] = array(
          '#type' => 'select',
          '#title' => t('Browser'),
          '#options' => taas_select_options_browser_frontend($os),
          '#required' => true,
          '#prefix' => '
',
          '#suffix' => '
',
        );
  }
  return $form['bid'];
}

And before somebody asks ;) I don't want to use the hierachical-select module if possible

After Ajax reload select field looses its attributes

Before:

    Internet-Browser *
    - Auswahl -Select OS     First

after ajax callback

  Internet-Browser *
 <select class="form-select required"><option value="1">Chrome-16-0-9-12</option><option value="2">FF-3-6</option></select>


texts:
I installed a fresh D8 (Drupal 8.6.15) site on my local dev and I am unable to use drush.

After I installed the site, I also did a composer install. My dev is set up on php 7.1 using AMMPS and drush 8.1.18.

  No such file or directory in
  Drupal\Component\DependencyInjection\PhpArrayContainer->createService()
  (line 79 of
  /Applications/AMPPS/www/commerce/docroot/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php).


texts:
As clearly titled I want to send a form values to js file in Drupal 8.
I've made some researches and all I successfully coded was sending a PHP variable from a Controller to the JS file I'am using.

Here is the code:

library_name.libraries.yml

library_name:
  version: 1.x
  js:
    js/<js_file_name>.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings

controller_name.php (class)

namespace Drupal\module_name\Controller;

use Drupal\Core\Controller\ControllerBase;

class <class_name> extends ControllerBase {

  public function <method>(){

      return array(
        '#attached' => array(
            'library' => array(
            '<module_name>/<library_name>'
            ),
            'drupalSettings' => array(
                '<module_name>' => array(
                  '<library_name' => array(
                      'foo' => 'bar'
                  )
                )
            )
        )
      );

  }

js_file_name.js (under /js folder)

console.log(drupalSettings.<module_name>.<library_name>.foo);

Everything works great!

But how about using a form? I've declared a form extending from FormBase and in the submitForm() overridden method I typed the same array:

return array(
        '#attached' => array(
            'library' => array(
            '<module_name>/<library_name>'
            ),
            'drupalSettings' => array(
                '<module_name>' => array(
                  '<library_name' => array(
                      'foo' => 'bar'
                  )
                )
            )
        )
      );

I know this won't work! But any ideas? I thought about using another library, point to a js file there, and use that js file to get the form values  using the #attached tag like above, and then send those values to the other js file using JSON

If any one can provide me with a better Drupal Standard? that would be great! cause this my first time using Drupal.

EDIT:

I fixed this, using: the module_name.settings.yml file under module_name/config/install folder and also by using the module_name.module file where I've implemented the hook_form_alter() method.

So,

From my module_name.module file, here goes my code:

/**
 * Implements hook_form_alter().
 */

function modulename_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id){

     if($form_id === your_form_id){

        $form['#attached']['library'][] = 'module_name/route_name';
    // that's the route name you've defined in your module_name.libraries.yml file
    // where you've located the js file you're going to use

        $form['#attached']['drupalSettings']
        [module_name][route_name][send_this_variable_to_js] = \Drupal::config(module_name.settings)->get(key);

        return $form;
    }

}

Now in your JS file, you can console.log like this:

console.log(drupalSettings.module_name.route_name.server.send_this_variable_to_js)

Hope this help!


texts: How to default checkboxes to checked while maintaining custom return value

texts:
I'm working on a migration project. I have a form in a custom module that creates a series of checkboxes for URLs to scrape. The form logic looks like this:

foreach ( \Drupal\scrape\Api\Scraper::loadUrls() as $index => $url ) {
  $form['url_' . $index] = [
    '#type' => 'checkbox',
    '#title' => $url . ' &mdash; ' . \Drupal::l('(link)', Url::fromUri($url)),
    '#return_value' => $url,
  ];
}

This code does what I want it to do, but all the checkboxes default to 'unchecked'.

'url_0' => integer0
'url_1' => string(27) "https://myurl1.com"
'url_2' => integer0

I want these checkboxes to default to checked. I couldn't find documentation on how to do it in Drupal 8, so I tried several things, and finally hit upon '#checked' => TRUE, (or any value that evaluates truthily). Now the checkboxes are defaulting to checked.

However, even though I have #return_value specified, the value returned in the form submission is now TRUE (from kint):

'url_0' => boolTRUE
'url_1' => boolTRUE
'url_2' => boolTRUE

Since any truthy value defaults the checkbox to checked, I tried '#value' =>  $url, but then upon submission, the values don't indicate their checked status:

'url_0' => string(86) "https://myurl0.com"
'url_1' => string(27) "https://myurl1.com"
'url_2' => string(29) "https://myurl2.com"

I guess my final option is to have a separate, hidden value for each URL, and map checkbox values to see if the user wants that URL included.

Is there a way I can default my checkboxes to TRUE, while maintaining their #return_value?


texts: Set default value of Search form block to be searched terms

texts:
So I have the Search form block in my template, but after performing a search it doesn't show the query in the form field.

How do I set the default value on search results to be the query?

i.e if I search "cats"..on the search results box, I want "cats" to remain in the search box.

Just like it does on Drupal Answers :)


texts:
I am building my first D8 module, so I probably need a little kick off. My Module should do the following things:

Create a user role
Extend the the profile form for users, who have this particular role.

To start I created /modules/extuser/extuser.info.yml with this content:

   langcode: en
   status: true
   dependencies: {  }
   id: ext_member
   label: ext-member
   is_admin: null
   permissions: {  }

After the module was installed the role appeared in the list, just fine! But what really would like to have, is that this role is locked, so that it cannot be deleted using the UI, just as the "anonymous" is.

First question: How can I lock that role?

The second thing will be: Adding fields to that role. So right here my knowledge about the new internals ends and really would like to know if that can be done with configuration only, or if I have to code. Any hint to show how it could be done would be very fine.


texts: Uncaught TypeError: Only on Drupal edit pages

texts:
I'm using the BigSlide.js sliding menu on my drupal site, which i've built into the theme,  and it works fine on every page, apart from on /edit/ pages. E.g. user/%/edit.
When clicking the target menu button nothing happens - the menu should slide out from the left.

In the chrome console i'm getting:

  Uncaught TypeError: undefined is not a function

As you can see from the image above it's referencing bigSlide.js, I've tried updating jQuery to 1.9 with the Jquery update module as i'm using 1.7 and that didn't help, and i've made sure all my JS files are being loaded on /edit/ pages.

What could be the problem?

Here's the issue spot within bigSlide.js

Any help much appreciated.


texts:
I am trying to create a login link in Drupal 7 that will

keep the destination if set
generate a destination based on the page on which the link was clicked if not set
persist if set on subsequent clicks of the login link
not be generated if not already set AND the currently viewed page is an undesirable destination (such as user/logout)

I have written the following code and put it into to the body of a block only shown to anonymous users, however, as I am new to Drupal's api can someone more knowledgable here check to see if this is OK or can be optimized, and/or what other destinations other than user/* should NOT generate a destination if the destination is not already set:

<a href="/user<?php $curpath = current_path();
if (strpos($curpath, 'user/') === 0 && !isset($_GET['destination'])) {
  print '';
}
else {
  $newdest = drupal_get_destination();
  $newdestimplode = implode('', $newdest);
  print '?destination=' . drupal_get_path_alias($newdestimplode);
} ?>">Login

Alternatively if you know of a setting that puts the login link on pages for anonymous users with the above conditions or a LIGHTWEIGHT module (please don't suggest LoginTobboggan) that does this, let me know here.


texts: Commerce cart form alter to do an availability check

texts: I have some nodes I use as rentable objects, and I want to check availability on the Commerce Cart page (made by Views, the one you see at /cart). I also need to check it a last time before the user is sent off to payment, but as for the views Cart form, what function actually handles the quantity updates? I can see that the edit quantity field has my pre-update value as default_value and the new value as value, but which function actually sets that on submit?


texts: New Relic: "Application Code (in /theme)"

texts:
I have several Drupal sites with which I'm using New Relic to help monitor and debug performance issues.

I've been finding that when viewing the "Web Transactions" section under "Monitoring", that a large percentage of time is spent in "/theme". When I click in to view a trace, then view the Trace details, I often find that the majority of the time is listed in a rows named "Application Code (in /theme)".

The help link beside "Application Code (in /theme)" takes me to New Relic's PHP Custom Metrics Collection page. The documentation is clear enough, but what I don't understand is how to make this useful in Drupal. I'm guessing this is difficult for me because of Drupal's hook system, and (again guessing) that the "Application Code" that New Relic is referring to in this case are calls to theme() functions.

Is there something that I can do to get more useful information out of New Relic? First thing that comes to mind is "killing a kitten" and hacking core's theme() function to insert a New Relic Custom Metric, but I'd prefer not to do that (nor do I know for certain it will help!).


texts: How to exclude a hook function from the hook list?

texts:
For example, there is some module (some_module). The module contains some hook (some_module_some_hook). I need to this hook function didn't execute. For example, I'm not satisfied its code and I want to refactor it, but don't want to use patches.

Is there an opportunity to switch off this hook function (some_module_some_hook) ? For example, I want to switch it off and define in my module a new function implements this hook but having my code.
How to do it in Drupal 7 ?


texts: How can I find why the reason of this error message?

texts:
I get this warning when I edit nodes.

  Notice: Undefined index: id in template_preprocess_fieldset() (line 217 of core/includes/form.inc).

I don't have any field with that machine name, nor did I create any specific template or hook. I don't understand where this can be coming from.

How do I clear that up?


texts: How can I use Views to create a page with 3 Content Types, grouped by type, limited to x number of each type?

texts:
Sorry for the long title.  Essentially what I'm looking for is the best way to create the standard News style list page, in which I might display something like the 3 most recent News Articles, Company Events and Press Releases.

The content would be grouped by content type so would essentially look like this:

News Header
News Item 10
News Item 9
News Item 8

Events Header
Event 10
Event 9
Event 8

Press Releases Header
Press Release 10
Press Release 9
Press Release 8

Seems like a common use case so I'm thinking (hoping) someone has done it before.

I've got it working up to the point of showing only x number of each content type, but can't seem to figure how to limit content without limiting just the overall number of items, not per Content Type.

Thanks a lot.


texts: How can I find what nodes are causing 404 errors?

texts:
I'm watching entries in my Top 'page not found' report page steadily rise.

I am unable to fix the 404 errors because I have several hundreds of nodes, and there is no indication of which node is causing the problem.

Is there a way I can see which nodes are causing the 404 errors?


texts:
Possible Duplicate:
  How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu

I tried the code found in How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu, and I have a problem with it: while it does add the span tags, it also strips out the main menu's unordered list and classes.

How do I add the span tags inside the main menu links while also keeping the unordered list and the list menu classes?


texts: How to use last parameter (term) as a filter in a view

texts:
I'm using Drupal 7 as a document management system and I've got a taxonomy vocabulary called "Document Tags" with the following structure:

Accounting
  Best Practices
  Client 1
  Client 2
HR
  Forms
  Policies
IT
Office Management
   Photos
   Org Charts

I created a block view using Views Tree and set up the tree structure that works well so that the categories are nested and expand properly, and are each linked like so:

mysite.com/docs/accounting
mysite.com/docs/accounting/best-practices
mysite.com/docs/accounting/client-1
mysite.com/docs/hr
mysite.com/docs/hr/forms

My document view uses the contextual filter "Content: Has taxonomy term ID" and then in the filter as shown.  When I click on a first level category (Accounting, HR, IT, Office Management, etc.) it works great but anything underneath only displays the documents tagged with the top level, so it's evidently only using the first parameter in the display.

Is there a way to have the filter always pull the last URL parameter (e.g. "forms" in the URL mysite.com/docs/hr/forms)?

UPDATED - here are screenshots of the two pages and their results:
http://tentenstudios.com/storage/page_1_filter.png
http://tentenstudios.com/storage/page_1_results.png
http://tentenstudios.com/storage/page_2_filter.png
http://tentenstudios.com/storage/page_2_results.png


texts: How do I display links based on user's role and reference?

texts:
I am building an evaluation platform in Drupal using either entity forms or webform. Attendees will evaluate the course, instructor, and location of the lab/site.

"Entities" are:

courses: which is divided to many sections.

courses can be labs or lecture

instructors: can have many courses and lab sites
sections: can belong to only one individual course.
attendees: can belong to many sections. They will evaluate the instructor, course, and lab site.

Process
Attendees will see a link of evaluation form to their respective course section after logging in to their profile page. The form will include course name, instructors name and lab site (if any).

Progress:
I have the webform/form part down. My only issue is automatically assigning users to correct forms.

Blocker
But how do I automatically assign users to correct section (i.e. Attendee will evaluate instructor and lab site, or instructor alone if he/she was not assigned to lab). We're speaking of few hundred sections and attendees... Creating roles for few hundred sections is exhausting and flawed by design. Organic Groups does not seem to serve this purpose.

Should I create several entities of Lab Site, Instructors, Sections? And use entity reference to add individual forms? Attendees only allowed to submit evaluations to the courses they attended. I am not sure how to approach automation and assignment part. Another approach I am thinking is to add the course/section as reference profile field...

Additional Process: attendees list will pre-created before they login...

Any pointers would be helpful... Thanks!


texts: IIS - how to handle file permission problem

texts:
Here is a generic error message, shown several times on each page :

  Warning: file_put_contents(temporary://fil25BC.tmp): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in > file_unmanaged_save_data() (line 1935 of C:\inetpub\www-v2.3\includes\file.inc).

What can I do ?

EDIT
I stopped struggling with that problem by changing my temporary directory on this server
It was C:\Windows\temp (or C:\Windows\temp\drp-tmp)
It is now sites/default/files/drp-tmp
Note : on another server, the first setting is not giving warnings... Well, looks like I do not master that topic !
THANK YOU FOR your answers and attention


texts: Exclude the www- append to only one multisite

texts:
Stock Drupal 7 contains the following in the .htaccess file

  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/... will be redirected to http://www.example.com/...)
  # uncomment the following:
  RewriteCond %{HTTP_HOST} .
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

As per client request, this works just dandy! However, on a multisite installation, one site wants to be excluded from this rule. I tried to get them to remove the auto-www-append, but alas, that failed.

So now I'm in a situation which some multisites (most of them) want the www appended and a small group doesn't want it.

My question: Can I exempt some sites from this rule? Can I throw these exceptions into an apache conf file in /etc/httpd/conf.d/www-exceptions.cnf so that it's not overwritten in a core update?


texts: Attaching Theme Library to Custom Module

texts:
I have a subtheme called bootstrap_subtheme. It has a library called global-styling. I created a custom module called telephone_alter. In telephone_alter.module, I have the following:
function telephone_alter_form_user_form_alter(&$form){
  $form['#attached']['library'][] = 'bootstrap_subtheme/global_styling';
}

it does not load the bootstrap_subtheme library stylesheet. I do dump($form) and get the following:
  "#attached" => array:1 [▼
    "placeholders" => array:1 [▼
      "form_action_p_pvdeGsVG5zNF_XLGPTvYSKCf43t8qZYSwcfZl2uzM" => array:1 [▼
        "#lazy_builder" => array:2 [▶]
      ]
    ]
  ]

seems like the attachment isn't even grabbing it. Yes I am using the right form alter according to the api: hook_form_FORM_ID_alter() and my ID is user_form . It does fire off, if I attach css from within my module's folder, but not my subtheme. Any help would be great! Thank you.
One more note:
my root dir is as follows:
modules
   -telephone_alter
theme:
   contrib:
      -bootstrap
   custom:
      -bootstrap_subtheme

Here is bootstrap_subtheme.libraries.yml:
global-styling:
  js:
    js/popper.min.js: {}
    js/bootstrap.min.js: {}
    js/global.js: {}
  css:
    component:
      css/style.css: {}
  dependencies:
    - core/jquery
    - core/drupal


texts: view access permission, multiple conditions

texts: I'm using views and domain access. I can restrict access to my view by domain or by role but not both in the same time. I'd like to allow access to a custom role OR one of the domains. Any easy way to do this? Thanks


texts: How can we render graphviz diagrams in drupal pages?

texts:
I'd like to be able to allow users to insert Graphviz images in Drupal comments and Wiki pages.

What's involved it doing this?

The benefit is that users could enter something like the following snippet to see a graph.

[code lang=graphviz]
  digraph G {
    a  [label="Hello", shape="square", URL="http://en.wikipedia.org/wiki/graphviz"]
    F1 -> a[label=".63"]
  }
[/code]


texts: What does 'Drupal-friendly' hosting mean?

texts:
I'm new to Drupal and web-hosting generally. My question is what constitutes a totally Drupal-friendly host? I know that the installation is made easier by the host provider letting you have SSH access and the ability to extract compressed files on the server.

What else should I look for in a Drupal-friendly host?


texts: Ajax Submit Forgot Password Form Loaded in Front Page

texts:
Firstly, I altered the Forgot Password Form in my template.php and added the #ajax property:

// Ajaxifying the form

    $form['actions']['submit']['#ajax'] = array(
      'callback' => 'themename_user_pass_form_ajax_callback',
      'wrapper' => 'user-pass',
      'method' => 'replace',
      'effect' => 'fade',
    );

Then I created the ajax callback function:

function themename_user_pass_form_ajax_callback($form, &$form_state){

  module_load_include('inc', 'user', 'user.pages');
  return $form;

}

The form works fine in /user/password page and the ajax works too.

I want the form to appear in the front page, So in my page--front.tpl.php I added the following:

<?php
      module_load_include('inc', 'user', 'user.pages');
      $user_pass = drupal_get_form('user_pass');
      print drupal_render($user_pass);
 ?>

The form appears and when submitting returns with js alert

  An AJAX HTTP error occurred.
  HTTP Result Code: 500
  Debugging information follows.
  Path: /system/ajax
  StatusText: Internal Server Error
  ResponseText:  Memory used at: devel_boot()=3.43 MB, devel_shutdown()=32.2 MB, PHP peak=32.25 MB.

Note: The ResponseText is from devel.

In my php_error log file I found this:

  PHP Fatal error:  Call to undefined function user_pass_validate() in
  /www/drupal/includes/form.inc on line 1464

The user_pass_validate() is not declared maybe module_load_include('inc', 'user', 'user.pages'); is not working with the ajax call?


texts: Where can I configure user and admin email message in Ubercart cart module?

texts:
Where can I configure user and admin email message in Ubercart cart module in Drupal 7?

I want to change the email body of user notification email and admin.


texts:
I have a view with multiple content panes and multiple pages. With the content pane, I have used the feature "Link to view" before to get the title of the pane to link to the page view. When using this before, there has only been one pane and one view, which has worked well.

Now I would like to link multiple panes up to different pages within the same view. When selecting "yes" in "Link to view", it always links to the first page. Is there a way to specify which page I would like to link my panes to?


texts: Modify Commerce Shipping Rate To Integer?

texts:
We're using Commerce Shipping and Commerce UPS to calculate shipping rates. We want to round the calculated rate displayed during checkout up to the nearest dollar.

Just to be clear we want to update the value of each Radio option on the Shipping Options page of checkout; NOT the Commerce Line Items.

I thought it might be possible via Rules but I cannot figure out a starting place. All the Commerce Shipping Rules seem to be about altering the line item; not the calculated value.

I tried the following which does not work. Do the callback functions override what I was trying to do? If so, is there an easy way to STOP the callback from recalculating the shipping after the page loads?

Or is this some obvious mistake?

TIA,

function MYMODULE_form_commerce_checkout_form_shipping_alter(&$form, &$form_state, $form_id) {
 foreach($form['commerce_shipping']['shipping_rates']['#value'] as $values) {
     dpm($values);
     $newval = 100*(commerce_round(COMMERCE_ROUND_HALF_UP, $values->commerce_unit_price['und']['0']['amount']/100)   );
     $values->commerce_unit_price['und']['0']['amount'] = $newval;
     $values->commerce_unit_price['und']['0']['data']['components'][0]['price']['amount'] = $newval;
     }
}


texts:
In page.tpl.php, the logo section is handled as:

<?php if ($logo): ?>
  <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
    <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />

<?php endif; ?>

When user signs in, I want logo to change from logo.png to inner_logo.png

I can track where $logo comes from and add an if statement like <?php if($user->uid <=0) { $logo = "logo.png" } else { ... ?>

But would this be the correct practice? Is there a more practical Drupal way?

edit:

/* Override or insert variable into the pre-process_template*/
function bartik_preprocess_page(&$variables) {
    if (user_is_logged_in()) {
        $variables['logo'] = (drupal_get_path('theme', 'bartik') . '/images/inner_logo.png');
    }
}


texts: How to redirect to a edit node page with RedirectResponse?

texts:
From a hook (not form_alter), I want redirect the user to a node edit page (like mywebsite/node/[nid]/edit)
How can I do that with the RedirectResponse class?

After searches, I found the following code.

new RedirectResponse(\Drupal::url('route.name'));

How can I get/find the route.name for a node edit page?

Update :

According the cilefen's answer =)
From my entity_insert hook :

function article_entity_insert(EntityInterface $entity) {
  if ($entity->bundle() == "article"){
    Url::fromRoute('entity.node.edit_form',['node', $entity->id()]); //But when I create a new node, the "view" page is loaded and not the edit page
    dpm($entity->id()); //show the node id
  }
}

Update 2 :

The command

dpm(Url::fromRoute('entity.node.edit_form',['node', $entity->id()]));

return

Drupal\Core\Url Object
(
    [urlGenerator:protected] =>
    [urlAssembler:protected] =>
    [accessManager:protected] =>
    [routeName:protected] => entity.node.edit_form
    [routeParameters:protected] => Array
        (
            [0] => node
            [1] => 31
        )

    [options:protected] => Array
        (
        )

    [external:protected] =>
    [unrouted:protected] =>
    [uri:protected] =>
    [internalPath:protected] =>
    [_serviceIds:protected] => Array
        (
        )

)

But the command

dpm(Url::fromRoute('entity.node.edit_form',['node', $entity->id()])->toString());

Return this error :

  [Mon Feb 15 01:38:30.081002 2016] [:error] [pid 10219] [client
  192.168.1.48:49246] Uncaught PHP Exception Drupal\Core\Entity\EntityStorageException: "Some mandatory
  parameters are missing ("node") to generate a URL for route
  "entity.node.edit_form"." at
  /var/www/system/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php
  line 757, referer: http://192.168.1.44/system/node/add/article


texts: How do I drush vset a number with decimals?

texts:
drush vset latest_version 6.34a
latest_version was set to "6.34a"

So far so good.

drush vset latest_version 6.34
latest_version was set to 6.

Hmm...

drush vset latest_version '6.34'
latest_version was set to 6.
drush vset latest_version "6.34"
latest_version was set to 6.


texts: Content from the same content type as the current user

texts:
I have users with a "field_org" entity reference (multiple values allowed) to the "Org" content type. I also have a "field_org" (single value) in my "Article" content type.

When looking at a user profile (let's call this user "UserA"), how do I build a view that gets you "articles from your orgs" (i.e. created by other users that also belong to any of UserA's orgs)? And, bonus question: how do I exclude articles created by UserA? (since I have a separate "your articles" view showing in the same page).

I know this is probably a combination of relationships and contextual filters, but I can't figure out exactly how to configure them. Probably something like this:

Contextual filter on node author to prevent "UserA's articles" from showing (set to "exclude" in the options)
Contextual filter on node author, but probably set to one of the relationships below.
Relationship between article nodes and orgs?
Relationship between orgs and users?

Both contextual filters would load the same user ID using "Provide default value".


texts: Apache Solr Search show only currrent user language

texts:
I'm using Apache Solr Search Integration to do the searching on our website, works great except i get results for all the language on the site instead of only the one the user is currently using.

Is there a way to show only nodes that are in the current users language? Either filter it out of the results by a simple check or directly in the query?

I was hoping there would be a hook to alter the results before the pager is created, i got as for as filtering out the other language in hook_apachesolr_search_page_alter() but thats to late, then you get a pager for 3 pages with only one result.

I also tried Apache Solr Multilingual but that doesn't seem the work really well at the moment for 7.x.


texts: How come my view block is not loading using ajax?

texts:
We have a view, myview, that has an exposed filter title (text input). The view has Exposed form in block:Yes and so we load it onto the page under admin/structure/block. The block has a machine name of exposedform_myview_title.

We want to remove it from display and only load the view block on click of an icon. How come my view block is not loading when using ajax?

View Setup:

view_name = 'myview`
when creating view, view page setting -> "create a page" was set to true
view machine name = mypage
view use ajax = Yes
view block (displayed using admin/structure/block) machine name exposedform_myview

Error message

  https://somesite/path/views/ajax?view_name=myview&view_block_id=mypage
  404 (not found)

myjs.js

This will load the view itself and not the exposedform_myview_title block. We want the exposedform_myview_title to be displayed.

(function($) {
  'use strict';

  Drupal.behaviors.iconClick = {
    attach: function(context, setting) {
      $('#someid', context).once().each(function () {
        $(this).on('click', function(clickEvent) {
          // Use Ajax to load form.
          $.ajax({
            url: drupalSettings.path.baseUrl + 'views/ajax',
            type: 'GET', // type: 'POST' not succesfull
            dataType: 'json',
            data: 'view_name=myview&view_display_id=mypage',
            //not successfull --> data: 'view_name=myview&view_block_id=exposedform_myview',
            success: function(response) {
              var output = response[1].data;
              $('.some-element').html(output);
            },
            error: function(data) {
              alert('error');
              console.log(data);
            }
          });
        });
      });
    }
  };

})(jQuery);

page.html.twig

...

my icon goes here

 view block exposed form should go here

...

we also tried to use Drupal.ajax, but that did not load the View into the required

(function($) {
  'use strict';

  Drupal.behaviors.iconClick = {
    attach: function(context, setting) {
      $('#someid', context).once().each(function () {
        $(this).on('click', function(clickEvent) {
          // Use Ajax to load form.
          var ajaxPath = '/views/ajax';
          var view_info = {
            view_name: 'myview',
            view_display_id: 'page'
          };

          var ajax_settings = {
            submit: view_info,
            url: ajaxPath,
            event: 'click'
          };

          Drupal.ajax(ajax_settings);
        });
      });
    }
  };

})(jQuery);


texts: Disabled item in menu in menu_tree_all_data

texts:
I want to fetch all menu item list from specified menu list, I can fetch all of them with menu_tree_all_data, It return all item of menu and when I looked in in result I don't see enabled property
my sample code

  $menuItems=menu_tree_all_data('menu-footer-menu');
  dpm($menuItems);

(after that I put this in foreach statement and print them, but I want exclude disabled menu items)

My question is how can I find out that the menu item is disabled ?


texts: How to alter the search api views exposed form field value?

texts:
I have a search api view. Which has an exposed some exposed filters.

The exposed filters contains postal code, city and latlong field.

The user will enter the city and postal code and then in the code I will get a latlong from that address and will assign to the latlong field.

I have tried the following code but it is not working.

function mymodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-id') {
    array_unshift($form['#submit'], 'mymodule_maps_exposed_form_submit');
  }
}

function mymodule_maps_exposed_form_submit(&$form, &$form_state) {
  $address = $form_state['values']['zipcode'] . ' ' . $form_state['values']['city'];
  $latlong = somefunction($address);
  // Tried all of these options but nothing is working.
  $form_state['values']['latlong'] = $latlong;
  $form_state['input']['latlong'] = $latlong;
  $form_state['view']->exposed_input['latlong'] = $latlong;
  $form_state['view']->display_handler->handlers['filter']['latlong']->validated_exposed_input = $latlong;
  $form_state['view']->display_handler->handlers['filter']['latlong']->value = $latlong;
  // This line adds the value to the form field but the filter doesn't apply.
  $form_state['complete form']['latlong']['#value'] = $latlong;
  $form_state['complete form']['latlong']['#default_value'] = $latlong;
}

Is there any trick I am missing? Can someone guide me? Anyone who can give  a hint?


texts: How to create an entity handler that accepts arguments?

texts:
I've created a module and entity using Drupal Console.  It defines a canonical route like this:

entity.score.canonical:
  path: '/admin/score/{score}'
  defaults:
    # Calls the view controller, defined in the annotation of the score entity
    _entity_view: 'score'
    _title: 'Score'
  requirements:
    _entity_access: 'score.view'
  options:
    _admin_route: TRUE

I want to create a similar route that calls a handler which will render an entity by referencing a field value other than the entity id.

How is that done?


texts: Trouble redirecting users after implementing LDAP

texts:
We had a feature on our site where we redirected users with certain roles to a particular landing page upon logging in. In a custom module, we implemented hook_user_login(\Drupal\user\UserInterface $account) to examine the roles the user had, and redirect them to a particular landing page, depending on the user's roles.

Recently, we installed and configured the ldap module, so that users could log on with their LDAP credentials, and Drupal accounts would be auto-generated. However, we quickly found out that users with particular roles were not getting redirected on their very first login. Users belonging to other groups were correctly redirected upon creation of their Drupal account by means of _hook_user_login(), so it's strange that it only affects particular groups.

What happens is that, the first time you authenticate with LDAP credentials, the LDAP module creates a new Drupal user after successful authentication, then looks at your LDAP groups and assigns your user corresponding Drupal roles, mapped in the module's configuration.

I haven't been able to figure out why the redirection works for some roles but not others. Obviously, those roles are attaching to the account object earlier in the process than others. But where or why this happens, I haven't been able to figure out.

The second time the user logs in, the Drupal account has the roles at that point, and the redirect (running on hook_user_login) happens correctly. I am wanting to say that this works well enough, but my stakeholders want it to work correctly the first time.

My attempt to address the issue was to look at hooks implemented in the LDAP module, and see if any of those give me a user object with all of the assigned roles, from which I can figure out which landing page I should redirect the user to. I couldn't find robust documentation on the hooks, so I implemented each one in a custom module and debugged their arguments to see if any one gave me what I wanted. I found that hook_ldap_user_edit_user_alter($account, $ldap_user, $context) gave me an $account object. However in testing, at the time the hook fires, the account object only has the role anonymous. So, this attempt to use hooks defined in the ldap module seems stymied.

Is there a hook later on in the login/authentication process where I can get a fully fleshed-out user object, with all the roles that the LDAP module is assigning the newly-created user? Or is there another way I can redirect the user?


texts: I have a D6 installation with a very large content type (i.e. a lot of fields) called field_data. I need to migrate the field_data nodes out of D6 and into a new D7 instance. This D7 instance has two content types called field_data and accomplishments. The accomplishments content type has a field that is a node reference to the appropriate node of the field_data type. Essentially I am exporting one content type and need to import each node as two nodes that reference each other. I have looked into the feeds module and don't see a way to do this. What is the best way to do this?


texts:
I have a datetime field on a custom entity defined in baseFieldDefinitions().
This has set a default, which should be now.
But when saving the entity, i get following error:

  Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'date' at row 1: INSERT INTO {sale} (uuid, langcode, user_id, name, status, created, changed, date, price, party) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 3e25c5cb-0092-42dd-914b-4e4b91bdcf19 [:db_insert_placeholder_1] => en [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => Jupiler [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => 1516504047 [:db_insert_placeholder_6] => 1516504047 [:db_insert_placeholder_7] => 2018-01-21 04:07:06 Europe/Brussels [:db_insert_placeholder_8] => 2 [:db_insert_placeholder_9] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->doSaveFieldItems() (line 878 of /var/www/drupalvm/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This is my field definition:

$fields['date'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Sale date'))
  ->setDescription(t('The date that the sale took place.'))
  ->setRequired(true)
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ))
  ->setDisplayOptions('form', array(
    'type' => 'date',
    'weight' => -4,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE)
  ->setDefaultValue(DrupalDateTime::createFromTimestamp(time()));

How are datetime fields supposed to get a default value?
If you look at the error, the value it tries to save is '2018-01-21 04:07:06 Europe/Brussels'.


texts:
I have nginx installed on our server and configured with a previous drupal 7 installation and it works well.

I have installed a new drupal 7 installation and i want to configure it to also work with NGINX already installed on the server. Is there a configuration file i have to update? Please someone point me to the right direction.

This new site is running on the same server but a different cpanel with the previous site.


texts: Finding out if panelizer displays are in use

texts:
Does Drupal keep track of exactly where panelizer display(s) are in use? Basically, I would like to identify all pages across content types that use a particular display.

Is this information stored? Is there a way to get it programmatically or via the UI?


texts: Dynamic data forms and reports from non-Drupal databases

texts:
I have the task of displaying non-Drupal data which is stored in SQL Server within Drupal. I need to display search pages (ad-hoc style) and results based on page and field definitions stored in a SQL Server database. I will also need to display them based on permissions defined in the SQL Server database. This information will be a copy of the users and organic groups from the Drupal system, but will be stored in SQL Server so that they are available to other systems leveraging the same data, so in essence it can be considered a completely separate system.

I need to read the list of permissions (which will be managed down to the field level) and dynamically manage the display of fields, in both search criteria and result sets. For example, if Form1 has 10 fields and 2 of them require you to be an admin to see, there will be the following tables (structure hasn't been decided so there are just samples):

tbl_forms: form_id, form_name
tbl_fields: field_id, form_id, field_name
tbl_users: uid, username, etc
tbl_role_permissions:
 - roleperms_id
 - element_id (id of form or field)
 - element_type (form or field)
 - roles_show (an array of roles that have access to see this form or field)
 - roles_edit (an array of roles that have access to edit this form or field)

With this information, I believe it's possible to create an ad-hoc reporting system with roles level control of who can see individual fields for editing or in the data results of searches. I may need to also add a roles_search field, but I can't think of anything else.

Is there an existing approach to displaying external data dynamically within Drupal? If not, does this type of structure appear granular enough for effective creation of this type of external data management and reporting system?


texts:
I have written two widgets used on a form, now I have to write a plugin to be loaded in a view with editable content. These plugins should not mix: the buttons shown in the first two make no sense on the view, also the contextual menus in CKEditor are supposed to be different. I searched the CKEditor API documentation and searched stackexchange and stackoverflow, but found no hint. Is this possible at all?

EDIT (too long for a comment)

Yes, more or less it is possible: I get close to what I need by defining text format specifici to the fields I need to edit differently; then I can configure the plugins I need on the text format configuration page, and change the text format associated to each field in the field settings page (luckily, the different plugins are associated to different fields). I was bitten by this bug, so I was forced to set a default value for the fields, but that's acceptable. I was forced to associate a button event to a plugin which wouldn't need one in order to be able to associate it to the text formats using the Drupal configuration page, but that's also acceptable, it doesn't show up in the toolbar; at the moment I am trying to understand why this plugin (an autocomplete based on the autotag example, which I'm going to modify to get autocompletion from a web service) is still active on the instance where I didn't associate it to the text format, but that's also a minor problem.


texts: query to fetch all path aliases's content type and title

texts:
I want to know the titles and content types of all the aliases given in table   url_alias . For this, I'm writing query :

$connection = \Drupal::database();
    $query = $connection->select('node_field_data', 'n');
    $query->join('url_alias', 'u', '/node/n.nid = u.source');
    $result = $query->fields('n', ['changed', 'nid','type'])
                    ->fields('u', ['alias'])
              //->condition('n.type',$content_type, '=')
              //->orderBy('n.title', 'ASC')
              ->execute();

    foreach ($result as $rows) {
        $totalRows[] = $rows;

      }

But query is not giving the desired result. What's wrong with the query?


texts: Difference and relationship between View, Page, Panel and Mini Panel?

texts: I'm quite familiar with Views but for others, especially page, panel and mini panel introduced by the module, Panels. Can anyone provide some simple but elegant description between them?


texts: How to send variable to the javascript in Drupal?

texts: What is the easiest way to send a value from PHP to Javascript in Drupal form?


texts:
I had a link:

www.example.com/issues/issue-week-2012–2013/poem1

But it is encoded as:

www.example.com/issues/issue-week-2012%25E2%2580%25932013/poem1

This is an URL alias, the en-dash (between "2012" and "2013") is encoded as %25E2%2580%2593, which shows a 404 error. But when I removed the "25" after each % in the URL manually it works.

Please tell me about the issue?


texts: How to use hook_webform_submission_presave

texts:
In webform 7.x-4.10 I created a module like this:

function webform_presave_webform_submission_presave($node, &$submission) {
  if ($webform->nid == 28) {
    $component_id = 1;
    $submission->data[$component_id]['value'][0] = 'Yes';
  }
}

My webform with nid 28 has only one field, a texfield with a default value to "No".

When the webform is submitted, the value of the field is not change...

What am I doing wrong?


texts: Omega theme responsive grid two break point

texts: I want to make responsive grid with Omega 3 theme. Grids will be 4 columns in large. 2 columns in normal width. 1 column in narrow devices. Is there a way with omega 3 with css classes?


texts: filter view by parent of a taxonomy term

texts:
In drupal 7, how can I filter content of node type by the parent of a taxonomy term, such that if the content has a child of this taxonomy term it will come out if the parent is chosen as the filter ?

I want to be able to add children without having to modify the view each time as to which terms are in the filter, having it rely only on the parent as the filter by term.(can be done using depth level from the parent term)


texts: How to view to user only the node that referenced to him?

texts:
I have a Content Type with a user reference field.

I want that the user can display\access only to the nodes that referenced to him.

Can I do this with Views?

I already tried the modules Node access user reference and Node access node reference with no success because they have a huge bug. When the module is enabled many View becomes inaccessible ( https://www.drupal.org/node/1311460 ).


texts: Form ajax add more button added via another ajax callback not working

texts:
I have a form button which I want to add another field with another button on that form( I am able to do this) but second button is not clickable. Any idea. Following is my code-

This is my form code-

function create_report_form($form, $form_state) {
$form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Report ttitle'),
    '#value' =>'',
);

$form['actions'] = array(
  '#type' => 'actions',
);

$form['actions']['submit'] = array(
  '#type' => 'submit',
  '#value' => t('Save'),
);
$form['conditions'] = array(
  '#tree' => TRUE,
);
$form['conditions']['report_type'] = array(
  '#title' => t('Report type'),
  '#type' => 'select',
  '#prefix'=> '

',
  '#multiple' => false,
  '#options' => get_report_type()
);

 $form['conditions']['submit'] = array(
   '#type' => 'button',
   '#value' => t('Add condition'),
   //'#name' =>   '_add_another_outcome',
   '#ajax' => array(
      'callback' => 'reports_add_conditions',
      'wrapper' => 'report-form',
      'method' => 'replace',
      'effect' => 'fade',
   ),
  );
   return $form;
}

Now, when I click on this button it will call the following function and generate another form element(select list) with another button which will call another ajax function (this is what which is not working).

function reports_add_conditions($form, &$form_state){
$values = $form_state['values'];
$form_state['rebuild'] = TRUE;
$type = $values['conditions']['report_type'];
$form['attributes'] = array(
  '#tree' => TRUE,
);
$form['attributes']['submit'] = array(
    '#type' => 'button',
    '#value' => t('Add attribute condition'),
    '#ajax' => array(
      'callback' => 'reports_add_attribute_conditions',
      'wrapper' => 'report-form',
      'method' => 'replace',
      'effect' => 'fade',
    ),
);
$form['attributes']['attribute'] = array(
    '#type' => 'select',
    '#title' => '',
    '#options' => get_options($type),
    '#size' => 22,
);
  return drupal_render($form);
}

As you can see from the code I am not able to call "reports_add_attribute_conditions" function for the button.

This is my second call back code-

function reports_add_attribute_conditions($form, &$form_state){
$form_state['rebuild'] = TRUE;
$values = $form_state['values'];
$type = $values['conditions']['report_type'];
$form['attribute'] = array(
    '#type' => 'select',
    '#name' => $type,
    '#title' => '',
    '#options' =>  get_options($type),
    '#size' => 22,
);
$form['attributes']['submit'] = array(
    '#type' => 'button',
    '#value' => t('Add attribute condition'),
    '#ajax' => array(
      'callback' => 'reports_add_attribute_conditions',
      'wrapper' => 'report-form',
      'method' => 'replace',
      'effect' => 'fade',
    ),
);

 return drupal_render($form);
}

Any idea is greatly appreciable


texts:
I'm using Drupal 8 and paragraphs together, and I've got an image field attached to an image paragraph. When adding content, if I nest this inside of another paragraph (as a paragraph reference field), the file upload fails. I get the throbber gif, and then "No file chosen." If I use this paragraph type without nesting it, it works fine.

Logs and watchdog show no errors, and all other file related things (logo's, other image and file fields) work properly on their own (verified it's not a permissions or other related issue).


texts:
I'm using Embedded Google Docs Viewer but it's not what I need exactly.
I searched for a while but I could not find my answer.
I need a module that displays the .pdf or .ppt file like in this image.

Can anybody suggest me a module?


texts: Does requiring core/drupal load jQuery in custom script files?

texts:
I am trying to understand a bit more about where and how jQuery is loaded in Drupal 8.

If I write a custom script file that will include some translation strings using Drupal.t(), I need to add core/drupal as a dependency.

I know we have a call for jQuery: core/jquery, but hoping to have a clear understanding.

Drupal core in places uses jQuery, does calling core/drupal include jQuery? When using Drupal.t()?

Is there a difference when doing so inside a custom behaviors wrapper?

The premise is if I write my scripts in vanilla js, will using core/drupal and/or behaviors still call any jQuery?


texts: Programmatically set a $form_state value for user reference

texts:
I'm trying to programmatically create nodes through form submit in Drupal 8 (because I need to validate the submitted values) in this way.

try {
  $node = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->create(array('type' => 'my_bundle_id'));

  $node->set('my_field', 'my_value');

  $node_form_object = \Drupal::entityTypeManager()
    ->getFormObject('node', 'default')
    ->setEntity($node);

  $form_state = new FormState();
  $form_state->setValue('my_field', $node->get('my_field')->getValue());
  $form_state->setValue('op', $this->t('Save'));
  \Drupal::formBuilder()->submitForm($node_form_object, $form_state);
}
catch(Exception $e) {
  Drupal::messenger()->addError($e->getMessage());
}

Before setting any $form_state value, I'm evaluating the field type case (datetime, created and so on) to pass a right value getting it from $node.

Everything works correctly, except in case of a field referencing existing users which is passed to $form_state as follows.

$form_state->setValue('user_ref_field', array (
  0 =>  array (
    'target_id' => '1', // right uid of user
  ),
 )
);

Same happens with fields referencing taxonomy terms unless in default node form mode I don't set client hierarchical select (coming from a third-party module) as widget, while in case of user reference (with any widget type set in node default form) I get a There are no entities matching '1' (my user ID).

What am I doing wrong?


texts: Webform : A partially-completed form was found. Please complete the remaining portions

texts:
Yesterday I have updated webform module from 7.x-4.0-beta3 to 7.x-4.9.

Post to that I am getting this notification message, throughout the site :

  A partially-completed form was found. Please complete the remaining portions

I have also checked some threads :

https://www.drupal.org/node/2483859

https://www.drupal.org/node/2278177

When I check log entries I got this  error :

  Notice: Undefined property: stdClass::$is_draft in webform_client_form()

Which suggest that some alteration leading this issue but unable to get any solution.


texts:
I am creating a custom content type with the following fields:

  Name
  Offices(can be many)
  Address(offices address)

Question is, how can I be able to add address field to each office names?


texts: How to add block to only user/uid and not user/uid/edit

texts:
In my site the www.example/user/uid path contains the view and edit tabs. I want to add some blocks to only the view page and not edit page.

Using "user/* (Only the listed pages)" under the visibility settings of block configuration attaches the block to both pages.

How can I make it appear on only the view page.

Thanks in anticipation.