texts:
I'm using Drupal 7. I want to set up a dynamic page, which shows expertises' portfolios. I want to have a basic framework for that page and query data dynamically into the page.

For example, when someone goes to site/expertise?=em, they will find Em's portfolio, but when someone goes to site/expertise?=sarah, they will find Sarah's portfolio. It should be the same page, but just dynamically injected data.

Ideally the administrator will be able to upload xml or excel files and somewhere in the template will query the data from the uploaded database to update the data. Is that even possible, or are there any modules I can use?


texts: Add a MAX aggregation function to a query

texts:
I'm building a query with $query = new db_select('node', 'n') and I'm grouping by a certain field (let's say $query->groupBy('title')), when I'm aggregate another field (such as $query->addField('n', 'MAX(nid)')) it gets sanitized into a field called n.MAXnid (which crashes with a warning when executed)

How can I add a n.MAX(nid) field to my select query?


texts: How can I fix a call to undefined function libraries_load() in GeShi Filter?

texts:
I just installed GeSHi Filter and had to install the Libraries API for it. When I try to go to configuration settings I get this error:

Fatal error: Call to undefined function libraries_load() in /home/username/public_html/drupal/sites/all/modules/geshifilter/geshifilter.module on line 23

For the moment, I uninstalled all the above modules and its back to normal. Does anyone have any idea on how to fix it?


texts:
I'm using GMAP module and its views counterpart.  The issue I'm having is that I'm using a custom text field to display fields wrapped in HTML that I have pulled in from the query.  However, the popup won't size correctly; it ends up being too big. This is my code for Custom Text Field:

  [field_thtr_img_fid]

[title]

  [address_1]

Any help would be greatly appreciated.


texts: sort a view by Most Viewed, Most Favorited, Latest

texts:
I have view which contains all nodes of a content type(article). default sort criteria of view is recent nodes. But i have three links Most Viewed, Most Favorited, Latest.I have to sort this view by clicking on these links .

I am making a node favorite by using flag module .

How can i achieve that .

Please Help.


texts: How to create a hit counter for each published node to find out how often a specific node has been viewed?

texts:
I’m trying to create a hit counter for each published node. I’ve been googling this feature for Drupal 6.x and tried a few hits but with no luck.

I’ve enabled the Statistics module for my site and under admin/reports/settings I’ve enabled the counter but can’t seem to figure out how to put a hit counter on each overview page and node page.

I found a post explaining that I could use a customize query as such SELECT count(*) from accesslog where node = node but when I navigate to my database, the access log is empty (don’t know if it require to some time to enable the page / hit counter).

I want to count every hit and not only unique hits so each time a person access a node it should “just” increment a visitor number and I want to show it within my node-templates (not block) for some specific node content types.

I might miss something but any help or suggestions would really be appreciated.


texts: Get an Error with rendered page content in custom template file

texts:
The code below works, but when I try to add the line  in my MYMODULE-page.tpl.php the content is rendered twice with some errors. For example the $title is printed, but i get an error message that the $title is not set and when I add some test text in the template file i get it also twice. I didn`t find any solution for this.

**** EDIT ****

function MYMODULE_theme() {
  return array(
    'page-MYMODULE' => array (
      'path' => drupal_get_path('module', 'MYMODULE') . '/templates',
      'template' => 'page-MYMODULE',
      'render element' => 'page',
    ),
    'content-MYMODULE' => array (
      'path' => drupal_get_path('module', 'MYMODULE') . '/templates',
      'template' => 'content-MYMODULE',
      'render element' => 'page',
      'variables' => array (
        'title' => NULL,
        'path' => NULL,
      ),
    ),
  );
}

function MYMODULE_preprocess_page(&$variables, $hook) {
  if (arg(0) == 'MYMODULE') {
    $variables['theme_hook_suggestions'][] = 'page-MYMODULE'; //underscores doesn't work for me
  };
}

function MYMODULE_menu() {
  $items = array(
    'MYMODULE' => array(
      'title' => 'Page Title',   // -> page-MYMODULE.tpl.php
      'page callback' => 'MYMODULE_page_main',
      'access callback' => TRUE,
      'type' => MENU_CALLBACK,
    ),
  );
  return $items;
}

function MYMODULE_page_main() {
  $path = drupal_get_path("module", "MYMODULE");
  $page = array();

  $page['MYMODULE'] array(
    '#theme' => 'page-MYMODULE',
    '#path' => '$path',
    '#title' => 'Content Title',  // -> content-MYMODULE.tpl.php
    '#attached' => array (
      'css' => array (
      'type' => 'file',
      'data' => $module_path.'/css/layout.css', //works only if layout.css was disable by hook_css_alter()
      'weight' => 'CSS_THEME',
     ),
  );
  return $page;
}

function MYMODULE_css_alter(&$css){
  if (arg(0) == 'MYMODULE') {
    foreach($css as $key => $val){
      if ($val['group'] == '100') {
        unset($css[$key]);
      };
    };
  }
}

page-MYMODULE.tpl.php

<?php print $title; ?>

<div id="content">
  <?php print render($page['content']); ?>
</div>

content-MYMODULE.tpl.php

<?php print $title; ?>
<?php print $path; ?>


texts: How do I render a node returned by the Drupal search module?

texts:
I'm using Drupal 7 to build a fairly simple directory site. I'm trying to theme my search results page the same as a taxonomy page, but as you may know, the results arrive by a completely different process in those two situations. I've copied the search-result.tpl.php file from the Search module to my own theme, and am trying to take advantage of the $result variable returned by the module. However, it doesn't seem to be as simple as print render($result);

I tried to isolate the relevant node object within $result and perform render() on it, like so:

$content=Array(); $content['#node'] = $result['node'];
print render($content);

But that just throws an error (can't use object as array) or simply returns nothing.

$result['node'] definitely contains the fields I want to echo on the page, so what am I doing wrong?


texts: how to remove all slashes from all path aliases

texts: After I import data to my site, the url aliases  have / at the end, when I visit that Url alias I faced with page not found, I tried to edit one of  them manually and when I removed the slash from end I could see that node correctly, my question is how can I remove all slashes / from all aliases ?


texts:
I'm trying to implement jQuery plugin - Bootstrap Validator in Drupal.

This is the js which I have used.

jQuery(document).ready(function() {
    jQuery('#cta-form').bootstrapValidator({
        container: '#messages',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            FirstName: {
                validators: {
                    notEmpty: {
                        message: 'The full name is required and cannot be empty'
                    }
                }
            },
            email: {
                validators: {
                    notEmpty: {
                        message: 'The email address is required and cannot be empty'
                    },
                    emailAddress: {
                        message: 'The email address is not valid'
                    }
                }
            },
            title: {
                validators: {
                    notEmpty: {
                        message: 'The title is required and cannot be empty'
                    },
                    stringLength: {
                        max: 100,
                        message: 'The title must be less than 100 characters long'
                    }
                }
            },
            content: {
                validators: {
                    notEmpty: {
                        message: 'The content is required and cannot be empty'
                    },
                    stringLength: {
                        max: 500,
                        message: 'The content must be less than 500 characters long'
                    }
                }
            }
        }
    });
});

Is there any module available for user input client side validation or a method to implement this plugin in my drupal form module?


texts:
When user enter http://localhost/node then the user will be able to view all the nodes created in the site till date. In the site there are some content type which are viewable to all users on site and some are restricted to created users and shared users.How to stop users from viewing those nodes which they have not created. It will also be OK for me if user enter http:///node then "Page Not Found" displayed.

Please let me know your views.


texts:
I added new "Markup" field into commerce_product table using custom module. Now I need to create a rule to calculate (sell_price=prod_price*markup), but I can't acccess Markup field throught Rules selectors. Is there a UI , or what hooks should I implement to solve that problem?
Here is complete comm_markup module code:

function comm_markup_schema_alter(&$schema) {
  $schema['commerce_product']['fields']['markup'] = array(
    'type' => 'float',
    'not null' => TRUE,
    'default' => 1,
    'description' => 'Price markup field',
  );
}

function comm_markup_install() {
  $schema = drupal_get_schema('commerce_product');
  db_add_field('commerce_product', 'markup', $schema['fields']['markup']);
}

function comm_markup_entity_property_info_alter(&$info) {
  $properties = &$info['commerce_product']['properties'];
  $properties['markup'] = array(
    'label' => t('Price markup'),
    'type' => 'decimal',
    'description' => 'Gross price multiplier (defines profit amount).',
    'schema field' => 'markup',
    'getter callback' => 'entity_property_verbatim_get',
    'setter callback' => 'entity_property_verbatim_set',
  );
}

function comm_markup_views_data_alter(&$data) {
  $data['commerce_product']['markup'] = array(
    'title' => t('Price markup field'),
    'help' => t('Multiplier. Adds profit to the gross price.'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
}


texts: Conditionally register a user based on fields

texts:
I have a Drupal 8 User registration form that has several text fields to gather information about the user.

I'd like to write a custom hook that examines the values in those fields and then either proceeds with the registration or 'cancels' it, like perhaps redirecting to a static page or displaying some static content.

What are the hooks I need to make this happen?  Do I alter the form?  Or do I hook an entity_presave function?

What do I need to do to cancel the default form processing or default entity presave/save routines?

thanks,


texts: Programmatically created nodes are shown only after re-saving

texts:
I'm creating a lot of nodes programmatically in a custom module. These nodes are showing up on admin/content and in a default view display (unformatted/fields), but not in a calendar view display. Only if I open and resave, those nodes will be shown in the calendar view.

Why is this happening? All nodes are published.


texts: Custom html.tpl.php from module for custom type

texts:
I have built a module that adds a new custom content type.
I need to use my own html.tpl.php for that content type, and the html template sits on my module folder.

I have done somee xperiments, I was able to replace the template of the node content, but it's not enough, and I can't seem to find some examples or explanatory documentation about it.

If my module is called "tomato" and my custom type is called "sauce", and I already have a file called html--sauce.tpl.php on my module folder, how do I tell Drupal to use that template when a "sauce" node is loaded?


texts: How do I change the default '- Any -' option in views exposed filter?

texts:
I have exposed filters in a view as select lists. How can I change the text for the default filter option of "- Any -"? In previous versions it was suggested to use a preprocess function like this:

if($form['#id'] == 'views-exposed-form') {
      foreach ($form['FIELDNAME']['#options'] as $key => &$option) {
        if ($key === 'All') {
          $option = 'All';
        }
      }
    }

But in Drupal 8, instead of a modifiable key/value, it is stuck inside a protected class.

protected string -> string(7) "- Any -"

How can I modify this?

Note: I also tried Better Exposed Filters, but it is unable to rewrite the "- Any -" option.


texts: Is there anyway to get the $form_state inside a hook_block_configure?

texts: Is there any way to get the $form_state inside a hook_block_configure()? I'm trying to do that to make #ajax work on hook_block_configure().


texts:
There are two modules for this: one needs webform 4.x version (I can't update it because this gives me a lot of errors on actual website) and second doesn't work.

I tried to apply html5 attribute multiple to input (file type) by template.php and jQuery, but after sending form attachments links in e-mail track me to strange paths (404 error).

Is any possible way to print in form multifile upload field?


texts:
I want to make the checkbox title as link with target _blank but this doesn't seem working.

$form['approve'] = array(
  '#type' => 'checkbox',
  '#title' => l(t('Approve conditions'), 'node/10'),
  '#required' => TRUE,
);

So the approve conditions should be a link


texts: How to show or hide some content on a node view using Page Manager based on the url destination?

texts:
After certain fields have been set on the edit node form and saved, I don't want the node author to change these anymore and therefore I have created a new variant with a response code "301 permanent redirect" in Page Manager.

My redirect destination is set to %node:url?destination=no-edit-permission
And it does redirect the author to the intended node view (node_view in Page Manager).
But the reason I set this url destination is to be able to inform the user by showing a message at the top of that redirected page that says "You cannot edit this page any longer".
So how do I set such a message based on the destination in the URL?


texts:
My facebook is grabbing the wrong image.

I try to adding this open graph image in my head.

<meta property="og:image" content="<?= $_GET['image'] ?>" />

and

<meta property="og:image" content="<?php echo $image; ?>"/>

but the content image path is not shown.
It became this

<meta property="og:image" content="" />

I want it to be like this.
If the article A have image a_name.jpg, the meta will be <meta property="og:image" content="/images/a_name.jpg"/>

If the article B have image b_name.jpg, the meta will be <meta property="og:image" content="/images/b_name.jpg"/>


texts: Update hooks not being run when module enabled - chicken and egg problem

texts:
I've created a custom module to be used for deploying configuration updates like enabaling modules, reverting features, executing db queries, etc...

The module initially has an empty .module file, a .info file and a .install file with three hook_update_n functions.

When I enable the module, the schema version is set to the last "n" value of the update hooks, but the functions inside those hooks aren't executed.

What's the proper way to enable a "utility" module like this during deployment, and still run the update hooks via update.php?

Should the functions go in a hook_install instead?

Seems like a "who's on first" type problem.

Thank you.


texts: How do I compare a date field with the current time in a twig template?

texts:
I have a date field on a node – set to a custom date format (c which is ISO) in the Manage Display.
I have a twig template checking to see if that date field comes before today, in which is should output Past.
Outputting the fields/comparison values gets me the properly formatted dates I want to compare.
{{ content.field_closing_date.0 }}
{{ 'now'|date('c') }}

which outputs
2021-05-05T16:30:00-07:00
2021-05-14T12:01:53-07:00

My comparison is
{% if 'now'|date('c') > content.field_closing_date.0 %}
Past
{% endif %}

But it's not outputting Past. What gives?
You can see that the todays date does come after the date field.


texts: How to automatically delete all product displays when a product is deleted?

texts:
To automatically delete the product displays when a product is deleted, is a feature of the module Auto Product Display, but I don't need that module.

Preferably using the Rules module, I would like to accomplish the same.
An issue in drupal.org is present, but currently open.

I'm trying to fetch the referencing product displays:

Trigger: After deleting a Commerce Product

Fetch entity by property
Entity is of type: node
The property by which the entity is to be selected: product (the product reference field)
The property value of the entity to be fetched: ?? (The node
ID of the product is not available to select)

How to get the node ID's of all product displays referencing the product?


texts: Why does drupal think there is entity data?

texts:
I am working on customizing the poll module for my D8-rc1 site.  I have sufficiently broken the module and would like to uninstall it and try to reinstall an earlier version of my work.  However when i try to uninstall i get this

exception 'Drupal\Core\Extension\ModuleUninstallValidatorException' with message[error]
'The following reasons prevents the modules from being uninstalled: There is
content for the entity type: Poll' in
/srv/www/dtadev2/core/lib/Drupal/Core/Extension/ModuleInstaller.php:347
Stack trace:
#0
/srv/www/dtadev2/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(95):
Drupal\Core\Extension\ModuleInstaller->uninstall(Array, true)
#1
/home/ubuntu/.composer/vendor/drush/drush/commands/core/drupal/environment.inc(227):
Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall(Array)
#2 /home/ubuntu/.composer/vendor/drush/drush/commands/core/drupal/pm_8.inc(80):
drush_module_uninstall(Array)
#3 /home/ubuntu/.composer/vendor/drush/drush/commands/pm/pm.drush.inc(1190):
_drush_pm_uninstall(Array)
#4 [internal function]: drush_pm_uninstall('poll')
#5 /home/ubuntu/.composer/vendor/drush/drush/includes/command.inc(364):
call_user_func_array('drush_pm_uninst...', Array)
#6 /home/ubuntu/.composer/vendor/drush/drush/includes/command.inc(215):
_drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command('poll')
#8 /home/ubuntu/.composer/vendor/drush/drush/includes/command.inc(183):
call_user_func_array('drush_command', Array)
#9 /home/ubuntu/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62):
drush_dispatch(Array)
#10 /home/ubuntu/.composer/vendor/drush/drush/drush.php(70):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /home/ubuntu/.composer/vendor/drush/drush/drush.php(11): drush_main()
#12 {main}

and all 4 poll tables are totally empty.  when I run an entity query
it returns

array(0) { }

so where else is entity information stored that could be hiding some information to make drupal believe there is content for the entity?


texts: Automatic registration for anonymous node authors

texts: I need anonymous users  to be automatically sent drupal 'welcome' link  when they create nodes (it's required to enter email and to create login when creating nodes). So AFTER the node is created, the user can go on with registration.


texts: How to put two blocks inline in menu bar

texts:
In every theme I tested so far, when a block is added to Menu bar area, each block is always shown stacked in pile, my question is:

  There is a way to to make two or more blocks showing inline in menu bar area?

Please don't say that the question is "too generic", since I tested a plenty of template and they all stack blocks in pile!

Tpl modifications &/or css solutions are both welcome.
No scripting please.


texts: How to give meaningful id names to blocks?

texts: Instead of styling with ids/classes such as block-block-3 which may be deleted and then recreated, how would I go about giving my blocks meaningful names?


texts:
I'm working on a custom module that works with Ajax to create or update entities. But I'm wondering how I can send data via Ajax to be set in the entity fields. So looking at the example below..how to I fetch the my_id variable value 10 inside the mymoduleAjaxCheck function?
Focussing on the most important part of my code I have:
a my_module.routing.yml file:
my_module.ajax_check:
  path: '/js/my_module/ajax/{nid}'
  defaults:
    _controller: '\Drupal\my_module\Controller\MyModuleController::mymoduleAjaxCheck'
  requirements:
    _csrf_token: 'TRUE'

I have a script.js file:
var my_id = 10;
$.ajax({
  type: 'get',
  url: callbackUrl,
  dataType: 'json',
  data: 'my_id=' + count
});

And I have a src/controller/MyModuleController.php file:
/**
* Controller routines for user routes.
*/
class MyModuleController extends ControllerBase {
  /**
  * Saving entity
  */
  public function mymoduleAjaxCheck() {
     // how do I get the ajax data variable my_id here?
  }
}


texts: The same rules, only one being triggered

texts:
I am working on a website and one (maybe more) rule is not being triggered.

The rule that is not working is as follows

Event:
After updating existing content
Condition:
Content is of type...
Actions:
Show a massage on the site...
...
More actions

I tried to reproduce the problem with a following rule

Event:
After updating existing content
Condition:
Content is of type...
Actions:
Show a massage on the site...

But it works.

The rule used to work. The portal is under development. There are many added modules.
The rule weight is the same.

The only difference between the two rules is the name (I tried changing the name) and actions performed.

Any idea what can be wrong?

UPDATE
I tried cloning the faulty rule and the clone does not work.
Below I attach the code of the faulty and working rules.

Works

{ "rules_test_update_rule" : {
    "LABEL" : "test Update Rule",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "node_update" ],
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "test_case" : "test_case" } }
        }
      },
      { "data_is" : { "data" : [ "node:field-workflow-status:tid" ], "value" : "28" } },
      { "NOT data_is_empty" : { "data" : [ "node:field-workflow-reviewers" ] } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Test case got updated", "type" : "warning" } }
    ]
  }
}

Does not work

{ "rules_tc_admin_review_v1" : {
    "LABEL" : "TC: admin review",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "privatemsg_rules", "windbench_workflow", "og" ],
    "ON" : [ "node_update" ],
    "IF" : [
      { "node_is_of_type" : {
          "node" : [ "node" ],
          "type" : { "value" : { "test_case" : "test_case" } }
        }
      },
      { "data_is" : { "data" : [ "node:field-workflow-status:tid" ], "value" : "28" } },
      { "NOT data_is_empty" : { "data" : [ "node:field-workflow-reviewers" ] } }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "User has been notified.", "type" : "warning" } },

........ more in the "DO" section, should be irrelevant.....


texts: How to get taxonomy tree with path auto token?

texts:
I'm using Path auto module to automatically set url of articles.
Last part of url is node title and [node:title] works just fine. But url part before node title should follow taxonomy structure (tree) of tag used for tagging that article (taxonomy name: "structural_category".

So i.e. if article is tagged with tag "Child" and that tag has parent tag called "Parent" then url of my article should be:

/parent/child/node-title

I can get only Child tag with tokens like this: [node:field_structural_category:0], but I don't see the way to get Child's tag parent with token. With "Browse available tokens" I just can't drill any deeper than tag which is used directly for tagging the article.

For Drupal 7 I found that there is a solution with "join" keyword, something like:

[term:taxonomy_name:join:/]/[term:name]

What are the URL Alias pattern replacements for taxonomy parent terms when building up Node paths?

And I know that for Drupal 8 there should be something like:

[term:parent:url:path]/[term:name]

But when I try to save pattern like that I get an error "Path pattern is using the following invalid tokens:..."

When I use "Available tokens" helper tool I don't see this "term" at all?! All I see is:

There's no a word on "join", "parent" or any other similar token.


texts: Dynamic "My Account" text in navigation menu

texts:
How would I go about modifying the "My account" text in the navigation menu, to link the title to a title callback?

My goal is to have "My account" say "My premium account," "My guest account," and so on when an applicable user is logged in. For most menu items, this would be easy to do with hook_menu_alter and a title callback.

But, hook_menu_alter doesn't seem to effect this menu item at all.
Any ideas?


texts: How to automatically highlight syntax of code displayed on page?

texts:
I'm developing a website to publish my codes from different programing languages. I want to highlight syntax of codes with different colors. But, doing it manually is time consuming.
Is there any module or method which could do this automatically? Strictly, it should be done in CSS way.


texts:
I have been currently learning Drupal while trying to duplicate a Drupal application into CakePHP.

I have been looking at the  database tables to know where data is being stored so I can safely migrate any data or study how it is working.

I have researched and have come across questions like:

Where does Drupal store the content of a node's body?
Where does Drupal store NODE data?

So far, I have only seen the title in my Drupal (7) installation.

What I have seen in my node revisions table for a recipe content type, which includes fields like, field_ingredients, field_instructions, field_description, field_preptime, field_cookingtime, just the title of the recipe. This is a sample record on my node_revision table.

nid   |  vid  |  title         |  log   | timestamp  | status | comment | promote  | sticky
-------------------------------------------------------------------------------------------
1     |  1    |  Awesome Sauce |        | 1369998600 | 1      | 2       | 1        | 0

As you can see I can only see the title. Where are the other field contents?


texts: Problem with updating modules (check updates)

texts:
I have Drupal 7.26 with Commons 7.x-3.9. Recentyl manual update of modules is not working. When going to "Modules" - "Update" I'm getting something like:

 Last checked: 4 days 58 min ago (Check manually)

and this is the last time I've been able to check updates (just before Durpal core update).

When I use "Check manually", the page with progress bar appears where progress bar is always "100%" and messages say:

Trying to check available update data ...
Checking available update data ...

After short while it returns to "Update" page with:

 Last checked: 8 hours 5 min ago (Check manually)
There was a problem getting update information. Try again later.

No updates visible, no errors in log.

Any ideas?


texts:
I am trying to change the URL of the node edit link for a specific view.
This is what I have done and it (almost) works:

created a file mymodule/views/mymodule.views.inc with the following code:

/**
 * Implements hook_views_data_alter().
 */
function kd_ari_views_data_alter(&$data) {
  module_load_include('inc', 'mymodule', 'views/views_handler_field_article_link_edit');
  $data['views_entity_node']['edit_node']['field']['handler'] = 'views_handler_field_article_link_edit';
}

created a second file mymodule/views/views_handler_field_article_link_edit.inc with the following code:

class views_handler_field_article_link_edit extends views_handler_field_node_link {

 function render_link($node, $values) {
   if (!node_access('update', $node)) {
     return;
   }
   $this->options['alter']['make_link'] = TRUE;
   $this->options['alter']['path'] = 'admin/mymodule/' . $node->nid;
   $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
   return $text;
 }
}

The problem is that the view displays the edit link only one time after I clear all caches... afterwards the display link is gone. Any tips would be highly appreciated.


texts: Rename or move field data from a custom field to the 'body' field?

texts:
Once upon a time, when I was young and not very bright, I created a content type for a site.

In my ultimate wisdom, I deleted the default body field saying "I'll never need this!" and created a new textarea with a machine name that followed some conventions I was using at that time.

Several years and 60,000+ nodes of that content type later, the site is still running. However, any Views/Panels are a pain in the @ss to build since every other content type I've created since conveniently still has the default 'body' field, but this one (which has most of my content of course), does not.

How can I either A) rename my "my_story_body" field to be the default "body" field for a content type -OR- recreate the default "body" field and copy all the content from the field "my_story_body" into the proper field?

I will be testing the following tonight on a dev version of my database:

drush php-eval '$types = node_type_get_types(); node_add_body_field($types[“my-article-type], $label="Body");'

Hopefully that will recreate the default 'body' type I deleted, leaving me to only have to solve copying data from one field to another.

Running D7.31.

Thanks in advance!


texts:
I made my custom module, and wanted to do some staff in the validation and submission handlers. My Fields are in two field sets:

Member profile, with username and password
Company profile, with company name, URL, location, and logo

I am also using the #states attribute on some fields, but everything works except the validation and submission handlers.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'user_profile_form':
      // Only pre-render works.
      $form['#pre_render'][] = 'mymodule_user_profile_form_pre_render';
      // I try to empty fields with states attribute, but without success. Disabled work OK.
      $form['field_company_url']['und']['0']['value']['#states'] = array(
       'empty' => array(':input[name="field_company_confidential[und]"]' => array('checked' => TRUE)),
       'disabled' => array(':input[name="field_company_confidential[und]"]' => array('checked' => TRUE)),);

      // These don't work as expected.
      $form['#validate'][] = 'mymodule_user_profile_form_validate';
      $form['#submit'][] = 'mymodule_user_profile_form_submit';

      // I also tried this one.
      // $form['actions']['submit']['#submit'][] = 'mymodule_user_profile_form_submit';
  }
}

function mymodule_user_profile_form_submit($form, &$form_state) {
  // I want to download the image from another website and set as logo.
}

function mymodule_user_profile_form_validate($form, &$form_state) {
  //I need to check if checkbox is checked to empty all other fields.
  if ($form_state['values']['field_company_confidential'] == TRUE) {
    $form_state['values']['field_company_url']['und']['0'] = '';
  }

  return $form;
}

When I try to access $form_state['values'], I don't get any value.

What I am doing wrong?


texts: Displaying a form on clicking a file download link?

texts: In D7, is it possible to implement the following scenario: user clicks a file link and is redirected to a generated form that must be filled before actual file download starts. File downloads are made private. I tried to use hook_file_download() for that purpose but it obviously should be used for checking user permissions rather than displaying any forms so I'm kinda lost. How should one handle such situations? I'm looking forward to both general advice and (if possible) actual code snippets.


texts:
If you have caching enabled in Drupal, instead of getting URLs like so:

image.png

You get:

image.png?itok=RANDOMNESS

What function would I need to call to get back the value = "RANDOMNESS"? I ask, because I want to cache other things using the same method Drupal does internally.

Any ideas?


texts: set field value from function after user account edit/registering action

texts:
I need to assign one custom field value from user profile. One field is nickname (this field is filled by user) and I need to generate another field with function.

The function takes nickname and using external library takes this nicknames ID. I need to run one function and save this ID everytime new profile is saved or existing updated.

I can not find good way to do it.

I tried with Rules module setting event after account updated with action evulate value with php, but there i can not load my api library to do the function.

Any information will help me


texts: How do I create an entity using the properties of another entity?

texts:
I am currently working on a custom "quiz" like module in Drupal 7.  The way it works is as follows:  a site administrator creates a bunch of reading assignments, and associated questions that go with those readings (the reading might be a downloadable PDF, or a link to some online content).  I currently have an entity called "reading" which has a title, description, media type field (pdf or link), and a group of question text fields, where the admin can create an arbitrary number of questions.  Thus, a constructed reading entity might look like this:

========= READING ENTITY ===========
Title:       Some Great Paper
Description: This great paper was written by Joe Schmo, and it is great.
Media Type:  PDF
File Field:  /path/to/the/uploaded/file.pdf
Questions:
             What did Joe mean by 'Persistence is necessary?'
             How would you apply these ideas to your life?

Now, I am trying to create the "Assignment" entity.  This is an entity that an instructor would create by picking a reading from the pool of reading entities an administrator has created.  The assigned reading entity would look very similar to the reading entity, however it would have some additional fields.  For example, it would need an indicator that the student has submitted the answers, and a grade field for the instructor.  It would also need fields for instructor notes, and student answers.  Since there needs to be an attached answer and notes field for each of the questions, I also created an "AssignmentQA" entity.

Finally, there is a requirement that if an instructor creates an assignment, and later on an administrator updates the "Reading" entity (Say, changes questions, or the pdf file to be downloaded, etc..) that this change is NOT seen in already created assignments.  Thus, everything would need to be cloned.  I see the Assignment and AssignmentQA entities associated with the above reading as looking like this:

============== ASSIGNMENT ENTITY ===============
Title:       Some Great Paper    <--- cloned from the Reading entity
Description: This great paper... <--- cloned from the Reading entity
Media Type:  PDF                 <--- cloned from the reading entity
File Field:  /path/to...         <--- cloned from the reading entity
Instructor:  User reference to the instructor
Student:     User reference to the student
Status:      [Assigned, Completed, or Graded]
Notes:       General notes from the instructor to the student...
QAs:
             reference field to QA1
             reference field to QA2

============== ASSIGNMENTQA ENTITIES ==============
ID:          QA1
Question:    What did Joe mean by 'Persistence is necessary?' <--- Copied from Reading's Q1
Answer:      The student's answer to this question.
Notes:       Instructor's notes on this particular answer

ID:          QA2
Question:    How would you apply these ideas to your life? <--- Copied from Reading's Q2
Answer:      The student's answer to this question.
Notes:       Instructor's notes on this particular answer.

Of course those IDs for the AssignmentQA entities are pseudo-code used for clarity.

So with all that being said..

Does this sound like a reasonable approach?
Is there a better way to think about this/do this?
If it is reasonable, is there a way to pass a reading entity to the Assignment Entity so that I can properly construct an assignment from the reading data?
And, how do I go about cloning the pdf file field, such that the pdf file can't be deleted from the server if it is updated, but the old version has already been assigned to someone?  (e.g.- I'd like to use the updated PDF for any new assignments created, but keep the old one around for old assignments).


texts: View with Page display won't show menu tab for an alias

texts:
I want to add a few views (members and challenges) to a specific content type called group. I don't want the views to display all on the same page, this is easily done with the block display type. But I want to have menu tabs at the page, this is also easily done (/node/%/members) if you only use one content type. But I'm using multiple content types what than also will have the Members tab.

Basically I'm asking how to manage the visibility of a menu tab.

This is what I tried so far for the view Group Members (User):

Path: /group/%/members
Menu: Tab: Members

nothing showed up..

This is what I tried so far for the view Group specific Challenges (Content):

Path: /node/%/challenges
Menu: Tab: Challenges

It showed up on every node.


texts: Why is Ubercart sending order notification emails in plain text?

texts:
I am using Ubercart 7.x3.1 and I am working with the Checkout rules (E-mail customer checkout notification and E-mail admin checkout notification).

I am using the default templates although these emails are sent in a very hard to read plain text. Am I missing a setting to allow these in HTML? How do I change this?


texts: How to add points using User Points in Drupal 6

texts:
I want users to be able to give points to other users through "User Points"

I think it's the API: http://drupalcontrib.org/api/drupal/contributions!userpoints!userpoints.module/6
http://drupalcontrib.org/api/drupal/contributions!userpoints!userpoints.views.inc/6

I don't want to use views module, I'm looking for a PHP code to place it in template and to give point.

Thanks


texts:
The Cache Router module advertises that it "has an option to utilize the page_fast_cache part of Drupal in order to reduce the amount of resources needed for serving pages to anonymous users."

However, the only Google hits for "drupal page_fast_cache" point back to cacherouter.

What is page_fast_cache?


texts:
I'm using QuickTabs with a couple of views to show some content within tabs. This works fine.

Now, I want my tabs to automatically cycle. Basically, this issue sums up what I want to do.

The thing is, it partially works. I have two tabs, and it cycles to the second tab, but immediately goes back to the first. I have enough time to see it blinking, but that's it.

Here is the slightly modified code (original code does the same, I just find it nicer):

var rotateSpeed = 5000;
setTimeout(function featureRotate() {
  var active_tab = $('ul.quicktabs-style-basic').find('li.active')
  var next_tab = active_tab.next()
  if(next_tab.length){
    next_tab.find('a').trigger('click')
  }
  else {
    /* remove the following line if you don't want it to cycle */
    $('ul.quicktabs-style-basic').find('li.first a').trigger('click')
  }
  setTimeout(featureRotate, rotateSpeed);
}, rotateSpeed);

Debugging it, it looks like the setTimeout function works when it goes through the else statement, but not when it goes through the if one.


texts: Javascript calander to pick contents on a particular date

texts: Is there any module available in drupal which can be used to pick a date and afterwards contents from a particular content type can be displayed ?


texts: $form_state['values'] partial empty, while $form_state['input'] is filled

texts:
I would like extend an existing (altered) form. For this case, I created a new form with the Form API:

function my_new_form($form, &$form_state) {
  ...
}

In the next step, I get the existing form, which one I would like to extend:

function my_new_form($form, &$form_state) {
  $form = drupal_get_form('my_form');
}

Now, I extended the form with fields like this :

function my_new_form($form, &$form_state) {
  $form = drupal_get_form('my_form');

  $form['foo'] = array(
    '#type' => 'textfield',
    '#size' => 30,
    '#title' => t('foo bar'),
  );

  // and so on..

  return $form;
}

In my Template, I display the form:

print drupal_render(drupal_get_form('my_new_form'));

This works correctly, but after submitting the form, the values from the form from which I extend in the $form_state['values'] are empty. But in $form_state['input'] they are existing.

Do you have any idea what I'm doing wrong?


texts:
I am using commerce, which has products as entities. I have each product as a main node (which has title, URL, body, and other basic stuff) then I have a field which references products (price, SKU, product title, image, etc). And then I have a field called recommended products which references products. So a pretty standard commerce setup, nothing overly fancy.

I want to get all of the reference products (so I can show a you may also like product 1, product 2, etc) AND the node which created the product (so I can show a URL to that main product page (thats it, I just want a URL)). And this is where I am running into the issue, I have zero problem getting the product. But I cannot seem tog et the node which created the product.

Is there anyway using views to get the node which created an entity? I have tried everything I can think of.


texts: How to implement "Add another item" for custom forms?

texts:
I am writing a module which is basically a form that creates a relation between two end points.

I want a user to be able to create multiple relations at once. I want to add a button which says "add another item" just like how fields have when you select unlimited in their settings.

Is there a way I can do this to custom forms too ?


texts: Translating variables with context in Twig templates

texts:
In Drupal 8, with English and German enabled, I am trying to translate a variable using a specific context.

When visiting a page in German:

{% trans with {'context': 'Long month name'} %}
    March
{% endtrans %}

  This outputs März which is fine.

{% set month = 'March' %}

{% trans with {'context': 'Long month name'} %}
   {{ month }}
{% endtrans %}

  This outputs March which is not fine.

Why? And how am I supposed to translate variables in a Twig template?

Here is the documentation I have read.

Edit: https://www.drupal.org/node/2357633

This mentions:

  The t filter will run the variable through the Drupal t() function, which will return a translated string. This filter should be used for any interface strings manually placed in the template that will appear for users.

And also:

  The following patterns are unsafe and should not be used because they pass a variable directly to translation. This not only inflates the list of strings for translation but is also a potential vulnerability, particularly if the output can be entered by a user.

{{ var1|t }}
{{ var1|placeholder }}
{% trans %}{{ var1 }}{% endtrans %}


texts: math operators for text fields in views filters

texts: I have a field of type text that contains a number like 10. I want to create a search form with views exposed filters. Since the field is a text, I can't use greater than and less than operators on the field. Is there any way to have such operators for a text field?


texts: How to add custom submit logic to search_block_form?

texts:
I want to alter the input typed into the default search block in a way that when users search for "möp" (with a German umlaut) the search should be broadened to "möp OR moep" automatically.

So I simply tried to append a custom form submit to the search_block_form and simply expand the string by a certain logic. But then I found out that the search_block_form seems to be a little bit special. In core/modules/search/src/Form/SearchBlockForm.php I found the following comment.

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // This form submits to the search page, so processing happens there.
  }

My question now is: Where do I actually add the logic exactly if not in the form submit? I don't find any redirect or controller that would help here. Could you please point me in the right direction? Or maybe, you even have a better idea than appending the logic this way?

I removed the D8 tag as I guess the logic behind this is pretty equal amongst all common Drupal versions.


texts: How to setup custom 404 page that will ignore the path?

texts: I have the pathauto setting up URLs as /Country/Dept/node-name  (i.e. - /US/Training/How-To-Create-Node).  If I enter a non-existent path at the root, it goes to my default 404 page I created.  However, if the path is /Country/Dept/ anything, it just goes to the parent folder.  How can I get it to go to the 404 page, regardless of the path?


texts:
I'm developing an angular application which uses drupal as a backend. When user login to my webapp, they can able to get some data from the drupal backend. Also, I'm maintaining a session for that user in the drupal backend.

I want to get that session values of a user from drupal backend to my angular app. Is there any possibility to do this?


texts: Reviewing and displaying node reviews in Drupal 7

texts:
I have to create a Movie content type that's going to be submitted by the Admin, but where anonymous users will have the possibility of adding a review.

As I'm using D7 (making NodeReview not an option), I was thinking of using the Vote API and fivestar.

My actual question is (and please excuse my n00bness): can I somehow embedded a "Review" content type (that's going to have fivestar, author name and a short text) in the Movie nodes and expose that to anonymous users?

Could someone point me what the Drupal way would be in this case?


texts:
I've found dev seed's article on this issue: http://developmentseed.org/blog/2009/sep/03/5-minute-feature-server/

Is it the same process for Drupal 7?


texts: How do I alter the HTML outputted by an exposed filter?

texts:
I have a view that pulls in content of many different types. I gave the user two exposed filters, using the Better Exposed Filters module. However, the two filters look different. I would like them to look the same.

Specifically, I would like to get rid of the "Start date", "End date", and "E.g., 2017-02-01" labels on the filter on the right hand side.

How do I do this? Is it possible to do it within the view settings? If not, I don't mind writing a custom solution. I imagine there's a relevant hook somewhere, but I do not know which one to use.


texts: I have a webform in my site in that am trying to make toggle for a radio button but the field i require do not have #states .How to add the attribute #states in a webform component using form alter?


texts: context condition for field group multipage

texts:
I have a node form configured with field group multi page, my node form is outputted as a block on the front page. I want to disable(hide) the rest of my front page blocks when the user is on the second step or the third step.
Can i achieve this with context ?


texts: How do I give access provided user has at least one type of access granted?

texts:
I use Drupal 7. My module implements two types of access permissions, named:

access MYMODULE foo
access MYMODULE bar

I want to grant a user access to a particular path (node/%node/MYMODULE) provided the user holds at least one of these access permissions.

The snippet below is how this is currently implemented, and it obviously only grants access based upon the first of these (access MYMODULE foo).

How do I add, and test for, the second permission (access MYMODULE bar)?

/**
 * Callback function to see if a node is acceptable for poll menu items.
 */
function _MYMODULE_menu_access($node, $perm) {
  return user_access($perm);
}

/**
 * Implements hook_menu().
 */
function MYMODULE_menu() {
  $items = array();
  $items['node/%node/MYMODULE'] = array(
    'title' => 'My Module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('MYMODULE_page', 1),
    'access callback' => '_MYMODULE_menu_access',
    'access arguments' => array(1, 'access MYMODULE foo'),
    'file' => 'MYMODULE.nodes.inc',
    'type' => MENU_LOCAL_TASK,
    'weight' => 10,
  );
  return $items;
}


texts: Please explain caching in complex render arrays

texts:
The Scenario

In hook_block_configure(), I'm displaying a configuration form to users that is represented by a fairly complicated render array. The purpose of the form is to allow users to configure an arbitrary number of buttons as part of a button set.

Each button is individually configurable.
As part of each button's configuration, the user can select an icon from a list of icons. This list is mostly static, although users can upload additional icons on a per-site basis.
This module is for use in a Drupal multi-site configuration, where each site can field one or more of these button sets.
Each button configuration also features a preview rendering of the button.
There is a single rendering of the entire button set on the form as well.

The Question

How best to use caching within this render array? Is it possible to separately cache portions of the render array? For instance, could I separately cache each button configuration, as well as the icons and the rendered buttons?

While solutions to this exact situation would be appreciated, I'm actually more interested in insight into the finer points of adding caching to a complex render array. I believe that I've read most of the introductory documentation on caching that is readily available on the Internet, but haven't found much regarding more involved render arrays.

Sources

I found these sources to be very useful in attaining a basic understanding of caching in Drupal:

https://www.lullabot.com/articles/a-beginners-guide-to-caching-data-in-drupal-7
http://omnifik.com/blog/render-arrays-and-cache-drupal-7

Thanks to all for your insights!


texts: How do I debug "unexpected % in php_eval()"?

texts:
While testing with PHP 7 a site, which works fine with PHP 5.5, I get this error on some pages:

  ParseError : syntax error, unexpected '%' in php_eval() (line 7 of ..\modules\php\php.module(80) : eval()'d code).

I have no idea where to search that %. It could be in code, or a token in panels or anything. I already read comments in this similar question, but maybe someone got same bug while testing PHP 7.


texts: Add custom CSS code for a textbox in form

texts:
The following are the code in my module function for textfield in my form:

 $form['price'] = array(
   '#type' => 'textfield',
   '#title' => 'What is Your Price?',
   '#size' => 100,
   '#maxlength' => 10,
   '#required' => TRUE,
  );

Now I want to add css for the textbox like I want to add inline code display:none; only for the textbox. How can  I do that? Please help.


texts: How to use Drupal.displace inside Drupal.behaviors

texts:
I want to scroll down the page at page load time to bring a feature that might be below the fold into the viewport. Script works fine for anonymous, but for authenticated user, Toolbar module overlays the content I just scrolled to.

I've read that the way to resolve this is using Drupal.displace.offsets.top but when I call that from within my behavior Drupal.displace is undefined. I've been using comment-new-indicator.js from comment module as my guide here, and clearly my usecase is a little different because I'm doing this around page load time.

The problem is two fold: Drupal.displace isn't loaded when my script is called AND Toolbar hasn't done its stuff yet. I've cleared caches both in browser and drush numerous times. I've mucked with JS weights in libraries.yml -- nothing works.

One thought was to delay the initial execution with a 500 ms smudge to wait for some eventual viewport adjustment milliseconds later (that may or may not ever happen). So far this isn't really working well either, I don't want to delay the smudge longer for normal users because it becomes too noticeable.

Another thought was to register an event listener for drupalViewportOffsetChange but for some reason that never gets triggered.

mytheme.libraries.yml

custom-scroll-feature:
  js:
    js/custom-scroll-feature.js: { weight: -1 }
  dependencies:
    - core/jquery
    - core/drupal
    - core/drupal.displace

js/custom-scroll-feature.js

(function ($, Drupal) {

  'use strict';

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

      console.log(Drupal.displace);
      // outputs 'undefined'

      console.log(Drupal);
      // outputs
      // {behaviors: {…}, locale: {…}, throwError: ƒ, attachBehaviors: ƒ, detachBehaviors: ƒ, …}
      // no mention of Drupal.displace

      var start = time();
      $(document).on('drupalViewportOffsetChange', function () {
        console.log(Drupal);
        console.log(displace);
        var end = time(),
          elapsed = end - start;
        console.log("elapsed: " + elapsed);
        // The above never gets triggered.
      });

    }
  };

})(jQuery, Drupal);

With JS aggregation off, I've confirmed that jquery.js, drupal.js, and displace.js are all present in the list of requests on chrome network tab and appear before custom-scroll-feature.js is requested.

After I let the page load, and type the following into the javascript console, i get the expected value:

> Drupal.displace.offsets.top
79

To be clear I do not want to make a dependency on Toolbar, because then that would load more javascript for all users but I want to be sure that this script runs after Toolbar may have run, if it existed in the requests.  I would have thought that automagically the weight of js added by themes would be higher than that of core modules, no?


texts: what is the equivalent for category in wordpress in drupal websites?

texts:
to boost the ranking for a specific keyword we should create categories in wordpress. how should I make a category in drupal?
There are only tags. Are tags in drupal the same as categories in wordpress? If so it means that I should implement all the SEO considerations to set up the keywords?
for exp not using a keyword both for meta keyword and tag or assigning two tags to a simple article.


texts: Send email only if a field has a certain value

texts:
I am using webform in Drupal 7 and have a case where I need to send an e-mail only if a certain select field has an option selected. I have installed Rules and Webform rules but am a bit stuck on how to get this going.

In my webform I have the field called type (which is nested in a fieldset called shipping). My 3 options in the field are Ground, Air, Ocean. What I would like to do is send an email (using Rules due to a pdf that is attached to the email) only if the option selected is Ground.

Is this possible with Drupal 7 and rules / webform rules?


texts: How can I tell Drupal to skip a failed DB update instruction?

texts:
when updating from 8.5.x to 8.6.1, an error happened when running one of the database update instructions. More precisely, the error occurs when Drupal is trying to run function taxonomy_update_8502().

This is the error message I get.

  Update #8502
  Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydbname.taxonomy_term_hierarchy' doesn't exist: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {taxonomy_term_hierarchy} taxonomy_term_hierarchy) subquery; Array() in taxonomy_update_8502() (line 37 of /var/www/html/core/modules/taxonomy/taxonomy.install).

I can see why the error is happening. The taxonomy_term_hierarchy table doesn't exist any longer in the database and this database update is trying to remove it. Reading about this issue, I found that Drupal 8.6.x moves data from the old table (taxonomy_term_hierarchy) into the new table (taxonomy_term__parent).

Something must have halted the database update, and Drupal thinks the update function hasn't executed, but I can see on the new taxonomy_term__parent table is there. Perfect! So I still have pending updates I need to run, and now I need taxonomy_update_8502() to get out of my way.

How can I tell Drupal to forget that database update, or just ignore it, or even artificially consider it has ran already? Is there something I can do in that regard, like definitely skipping a database update?


texts: Functional testing without using simpletest

texts:
I have recently joined a Drupal project at work that is approx 50% finished.  Functional testing was never part of the project. The site has about 8 custom modules and they are not going to be used anywhere but with this client. I tried implementing the testing module in D7 but the modules were not created in a way that allows the modules to install cleanly. I tried to get them installable but I don't think there will be enough time to devote.

So, I need a solution that will allow me to test the new features we are building without having to fix the previously built portions.

I looked at Selenium but to my knowledge it requires the feature to be built before the script can be recorded. I'd like to use it Test Driven Development style. I have also been looking at Behat but honestly, I don't get it.

This question is more specific than "what is your favorite functional testing framework?". It is more specifically, "What functional testing framework works well with Drupal and works with our site as it is currently developed?".


texts: Why does the EN version of the Main menu not appear on the EN version of my site?

texts:
I can't see any menu in the EN version of my drupal site with the following settings in my menu :

EN and FR languages installed.
2 Menu's : main menu en (fixed language : en) and main menu fr (fixed language : fr)
I add some menu items in those menu's indeed

When I'm navigating trough FR, all is ok, but when I select EN, nothing appears.

I see in HTML that no menu is shown too (0 div for the menu)...

( I cleared the cache 10 times haha )

Site is available here : http://drupatest.clementhallet.be/en

I'm going crazy about this, any suggestions?


texts: How to limit access to a group page to the group administrator?

texts:
I created a custom module to create a /group/ID/tasks page
https://www.drupal.org/project/group
How to limit access to this page to the group administrator ?
If the current user is administrator of group ID 76, he can access this page :
/group/76/tasks

But if he goes to another group, he must have denied access :
/group/89/tasks

https://git.drupalcode.org/sandbox/zenimagine-3076032
task_notify/task_notify.routing.yml
task_notify.group_page.tasks:
  path: '/group/{group}/tasks'
  defaults:
    _controller: '\Drupal\task_notify\Controller\TaskNotifyGroupController::Tasks'
    _title: 'Liste des tâches'
  requirements:
    _custom_access: '\Drupal\task_notify\Controller\TaskNotifyGroupController::taskAccess'

task_notify/src/Controller/TaskNotifyGroupController.php
<?php

namespace Drupal\task_notify\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFormBuilderInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\group\Entity\GroupContent;
use Drupal\group\Entity\GroupInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class TaskNotifyGroupController extends ControllerBase {

  protected $route_match;

  public static function create(ContainerInterface $container) {
    $instance = parent::create($container);
    $instance->route_match = $container->get('current_route_match');
    return $instance;
  }

  public function Tasks() {
    return [
      '#theme' => 'task_notify_group_template',
    ];
  }

  public function taskAccess(AccountInterface $account) {
    $uid = $this->route_match->getParameter('user');
    return AccessResult::allowedIf($account->id() == $uid)
      ->orIf(AccessResult::allowedIfHasPermission($account, 'administer group settings'));
  }

}

I want group members with Administer group permission in the group to see this page
in :
/admin/group/types/manage/personnel/permissions

I also want the user with Administer group settings permission to see this page.
in :
/admin/people/permissions


texts:
Please help me uninstall MailChimp.

I disabled all MailChimp component modules, then I clicked uninstall. I got no error messages.

I then deleted the MailChimp folder from Sites/All.

Finally I ran phpMyAdmin and searched for MailChimp. I then deleted everything having MailChimp in it, BUT MailChimp still appears (though disabled) when I click modules.

I'm trying to get rid of MailChimp because it does not work and because SimpleNews does not work. I'm think that they are fighting each other.

I'm using Adquia Dev Desktop on my Win 7 computer with Open Outreach distribution.

Thanks!


texts: URL aliases problem when assigning aliases for custom pages

texts:
I have created some content type page around 10 pages after that I started creating custom page like page-node-11.tpl.php. I want to assign node number 11 to my newly created page but when a assign node/11 it will give me error msg

The path node/11 is either invalid or you do not have access to it

How to overcome this error ?


texts: Add CSS class to  element using webform and template file

texts:
I have an existing webform in Drupal 7 which I am trying to theme.
So far I managed to add CSS classes, placeholders, prefix, suffix,.. to form elements (fields) but not to the actual <form>-tag?

I tried this:

$form['#attributes']['class'][] = 'form-horizontal';`

But that didn't change anything to the output.

edit: I have found that putting var_dump($form['#attributes']); displays the array below the form-tag. Does that mean that you cannot alter the root element inside a template file (webform-form-8.tpl.php) and that I should implement the hook in template.php?


texts: Custom module is not showing up for regular user

texts:
This is what Drupal returns if URL defined from the module is accessed:

  Access denied
  You are not authorized to access this page.

THe permissions are all checked for authorized, and anonymous users.

The implementation of hook_menu() is the following.

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

  // This determines the path used to show the form and also makes a menu entry
  // This first path is for the entry form
  $items['qarena'] = array(
    'title' => t('QArena'),
    'page callback' => 'qarena_display_page',
    // drupal_get_form, registers the given form in drupal.
    'access arguments' => array('ask question'),
  );

  return $items;
}


texts: Use Bootswatch.com themes with Drupal Twitter bootstrap

texts:
I would like to know the easiest, simplest and quickest way to use anyone of the bootswatch.com free themes. There are some great themes there, better than I could spend a good 4+ hours trying to do. I'm merely looking to 'experiment' with CSS styles, swatches and the like. Can someone tell us how we can simply 'drag and drop'. I've tried what I thought it would be but it doesn't seem to do what I want it too, I'm not looking to spend hours on this, just to experiment with D7 for a few visual ideas. I have revieed the drupal.org Themeing documentation but that routed a little too long winded at this stage.

I appreciate there are some general paths that need changing in the CSS file and that JS needs to be correctly pointed to. My recent efforts only result in my backend Admin going a little wayout and I presume that simly 'deleting/over writing current CSS files in  the CSS folder isn't exactly the 'quick' way to do things. My long term reason is so I can have a number of preset themes to work with which I prefer and can quickly 'drag and drop' new theme ideas with outspending hours for something which is only for 'eye candy' visuals.

I would rather to it 'hand coding' style rather than a easy 'module' option for those why may suggest in advance.

Thanks in advance.


texts: Change drupal font color based on variables

texts:
I had a content type=score
This "score" content type had "field 1", "field 2" in integer.
Can I customize the font color based on variables.

ex:
when the users fill in <50 then show red color,
When the users fill 50-70 then show orange color,
When the users fill >70 then show green color.

Any contributed modules can do that function?
Thanks


texts: Where are display settings for nodes stored in the DB?

texts: I need to manually update the display settings for my content types. I have a lot of content types and I don't want to have to do it one-by-one using the UI. Where can I show/hide fields for Default and teaser displays for content types directly in the DB?


texts: A non-Views, Panels-compatible slideshow?

texts:
The common way to create some variety of slideshow within Drupal is to use Views Slideshow and then display content that way.

However, what if I just want a simple slideshow that appears in all of one Panel on the front page? Creating a new content type (and the requisite nodes) seems fairly overkill.

To that end — is there a slideshow that is both compatible with Panels and able to be invoked without using Views (or otherwise creating a bunch of nodes)?


texts:
I have set up a Feed Importer than gets a YouTube Atom Feed and processes it into "YouTube Video" content type. This is working great so far but what I want to do now is have the actual YouTube video embedded in my website rather that linking to the youtube website.

I downloaded and installed the Media YouTube module and went to set up a field in the YouTube Video content type to hold the video url. The Multimedia Asset field type is deprecated and I found somewhere that said to use the File field type. So I created the "Video" field as a File field with the Media File Selector widget. Then I set up the mapping in the feed importer. I am using the Feeds: YouTube Parser module to parse the Atom Feed. I set the Source to Video URL and the Target to my new Video field.

When I went to import the feed I got a bunch of errors that look like this

Download of http://www.youtube.com/watch?v=tag:youtube.com,2008:video:xm6Jv3BhdS4 failed with code 404.

I'm not sure where the "tag:youtube.com,2008:video:" part is coming from otherwise the url is correct. Anyone know what my problem is? Is it the way the YouTube Parser is getting the url or something else?

Thanks a lot!


texts: Why does Panels output  for some panes and  for others?

texts:
I'm just wondering what causes Panels Pages (or cTools pages? Never figured out which is which) to output some panel panes in a <section> html tag wrapper, and output the other panel panes in a <div> html tag wrapper?

I would prefer it if they were one or the other, but not both. So I wanted to understand and find out the reason so I could potentially make it consistent.

Theme I use: AdaptiveTheme (Custom Sub-theme with minimal configurations and changes)

Panels "Variant" Layout: AT One Column (Responsive single column panel layout, AdaptiveTheme core)


texts: How to change #weight of fields added to user register page by form_alter()?

texts:
I have created some fields on my user registration page named like -
First Name (machine name - field_first_name),
Last name (machine name - field_last_name) etc..

I want to change their #weight according to me to appear at the place where I like them to be from the form_alter function at my custom module..

For the default name & email I used -

$form['account']['name']['#weight'] = 7;
$form['account']['field_first_name']['#weight'] = 8;

& it worked..

But If I am using for added fields in this way like -

$form['account']['field_first_name']['#weight'] = 6;

It's not working...

Can I get any help in this ?


texts:
I created a view for the front page and also a node--view--frontpage.html.twig to design this view. Is there any opportunity to catch the first node with a if statement to design it differently?

In this case I want to change the order of the first iteration in the node--view--frontpage.html.twig:

{% set createdDate = node.getCreatedTime | date('j.m.Y') %}

  {{ content.field_picture }}

    {{ createdDate }}
    {% if content.typ | render | trim %}
      , {{ content.typ }}
    {% endif %}

    {{ label }}

  {{ content.body }}


texts: What are some php cache related modules for drupal 7?

texts: i just updated my server to php 5.5 and been reading about apc and opcache, and I'm not to sure which one to use or what modules support this feature. What are some modules or modifications to drupal 7 that take full capabilities of these php caching mechanisms? Am i correct that opcache is superseded by opcache for php 5.5?


texts: Drupal 8 url after installation using drush site-install

texts:
I used Composer to download and install Drupal 8.8.1 on Linux and used drush site:install command for setup.

Only the following lines/messages were shown after I entered drush site:install command.

You are about to DROP all tables in your 'drupal8' database. Do you want to continue? (yes/no) [yes]:

>yes

[notice]Starting Drupal installation. This takes a while.
[success] Installation complete. User name and password displayed.

I don't know my site URL. How do I find my site URL? Is there a default site URL?

Thank you


texts: Create validation to input alphanumeric and with specified symbols for field type password in user module

texts:
In the user module for field type password input I want to avoid hazardous characters input so i added #required and '#element_validate. But as i am new to drupal i dont know how to processed and also i am not sure if i am in right direction or not . Please help me

if (!$register) {
  $form['account']['pass'] = array(
  '#type' => 'password_confirm',
  '#size' => 25,
  '#description' => t('To change the current user password, enter the new password in both fields.'),
   //The below two lines are added by naveena.
  '#required' => TRUE,
  '#element_validate' => array('user_pass_element_validate'),

);

function user_pass_element_validate($element, &$form_state, $form) {
  if (!empty($element['#value'])) {
    form_error($element, t(''));
  }
}


texts: Which is the highest version of Solr that is compatible with the "Apache Solr Search" module?

texts:
I have a setup of Drupal 7 with the Apache Solr Search module. I am planning to upgrade the solr server's current installed version(3.6) to a higher version.

The latest version of Solr available in their site is 8.5.1.

Which is the highest version of Solr that is compatible with the module?


texts: The installation directory "/root" is not writable - Error when install Drush

texts:
i want to install drush on my server .

I want to install drush-toolbox project globaly on my linux server box so all users can use it

My server: Cpanel , Litespeed , Cagefs , Cloudlinux (centos 6)

my drupal version 7.5x

I try this article CLick here and after run this command:

curl -sS https://getcomposer.org/installer | php

I get this error :
The installation directory "/root" is not writable

I run this command : chmod 640 /root and chmod 644 /root  but give same error (not writable)

Please help me.Is any guidance for me?


texts: How to override certain function in a module to disable the return value

texts:
Not sure how to explain this clearly but let me try.

/**
 * Implementation of hook_footer()  to insert Javascript at the end of the page
 */
function omniture_footer($main = 0) {

  global $user;

    $header = "\n";
    $header .= "\n";
    $header .= "'."\n";
    $footer .= ''."\n";
    $footer .= ''."\n";

$script  = $header;
$script .= $extra_variables_formatted;
$script .= $footer;

return $script;
}

Now my task is to disable the $script to not show in unpublished articles. Is there any way to do this in template.php preprocess?

Note: The below solved my question. Its 100% working in my end. Thanks

//Remove omniture tags in unpublish node
  if(arg(0) == 'node' && $vars['node']->status == 0) {
    $vars['closure'] = theme('closure');
    $omnitureTags = preg_replace( "/\


texts: I am trying to add header images to my pages. I am currently getting the image in the form of a background using file_url(node.field_custom_image.entity.field_media_image.entity.fileuri) the problem with this is it doesn't get the default image if a image isn't present. How can I get the image url or fall back to the default image?


texts: I want to run a piece of javascript every 24 hours for each specific user? This is to clear HTML5 local storage, how would I run this script every 24 hours for each user when they are logged in?


texts: How to load the immediate parent link in a preprocess function?

texts:
I am using menu block to show a section of the navigation. I have a requirement to show the parent link at the top, but that would not gel with the menu configuration.

Therefore, I should be able to solve this by taking the first link in the list, and loading the parent. Then, I want to add that as a variable, and render it in my twig file above the loop that would output the entire link tree. However, I am coming up short on how to do this effectively.

So far, I have:

function mytheme_preprocess_block__menu_block(&$variables) {
  if ($variables['elements']['#id'] == 'left_navigation' && !empty($variables['elements']['content']['#items'])) {
    $children = $variables['elements']['content']['#items'];
    $top_child = key($children);

    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    $menu_link_parents = $menu_link_manager->getParentIds($top_child);

    // the one we want should be the second one. the first one is the one in the main navigation across the top.
    $parent = end($menu_link_parents);
    $parent = str_replace('menu_link_content:', '' , $parent);
    $menu_content = current(\Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(array('uuid' => $parent)));

    $variables['top_parent'] = [
      'title' => $menu_content->getTitle(),
      'url' => $menu_content->getUrlObject()
    ];
  }
}

I am lost at the point I retrieve the parent. Is there a way to get the UUID instead of the dirty str_replace? Also, how can I take that UUID, and create an object similar to menu items that would be rendered?


texts: Setting up Multisite on windows server with IIS7

texts:
First off I'm not a server person. New windows box spun up, IIS7 was used to install one instance of Drupal 7. Great :)

However I need to have multiple sites running. I've read several tutorials on getting this to work, tried several solutions, and continue to gets errors (from page not found to "this drupal site is already set up"). Does anyone know if there are step by step instructions somewhere on exactly how to set up multisite on a windows box with IIS7?

The "base" drupal install is /inetpub/wwwroot/Drupal/DrupalTest/

Having very little knowledge of Windows servers is probably part of the issue. I really need basic step by step instructions and I have yet to locate any that assume you know essentially zero about windows. I've been taking notes so I can write some out if I eventually figure it out :)

One example I've followed: http://drupal.org/node/554336 : Yielded the "site already setup" when I tried to access the install.php from the second site.

I'm at the point where multisite would be nice, but if I need to use multiple instances of Drupal that's fine, I just need to be able to move forward with the content and be finished messing with the dang server, but I have no idea how to accomplish that as well.


texts: How to make a specific template according number of nodes in a content type?

texts: I have a content type article and I need a specific template for showing articles according the number of nodes.  If I have 2 nodes (content type article) I need to make a template, if I have 3 nodes (content type article) I need to make another template.  How do you suggest to make that?


texts: How to make a page visible only to users with permission to use the administration theme?

texts:
I have created a basic page which I only want to be viewable by people who have access to the administration theme.

I have given the page a path of admin/shipping-help but to my surprise the page is visible to anonymous visitors, nor does the page display in the admin theme.

What am I doing wrong?


texts: Redirecting Views dynamically generated URL's via .htaccess RewriteRule - CSS stylehseets arent loading after change

texts:
I have many dynamically generated pages via views and it seems the easiest way to redirect them is using the .htaccess file via a RewriteRule. I put in the following right above the index.php rewriterule and none of the css files are loading anymore. obviously i have something wrong here, but what?

Doesn't the first rewrite fire only if it detects the buy string in the first part of the url? I dont see how that would interfere with anything.

RewriteRule ^buy(/?.*) http://www.EXAMPLE.com/buy$1 [R=301,L]

RewriteRule ^ index.php [L]


texts: problem with drupal_http_build_query output

texts:
am using drupal_http_build_query and have part of my code as follows:

$or = db_or();
$or->condition('cid',$fField1);
$or->condition('cid',$fField2);
$or->condition('cid',$fField3);
$or->condition('cid',$fField4);
$or->condition('cid',$fField5);
$or->condition('cid',$fField6);
$or->condition('cid',$fField7);
$or->condition('cid',$fField8);

$querydata  = db_select('webform_submitted_data', 'wsd')
  ->fields('wsd',array('data'))
  ->condition('nid', $nodeID, '=')
  ->condition('sid', $sID, '=')
  ->condition($or)
  ->execute()
  ->fetchAll();

$result = array();
$i = 1;
foreach ($querydata as $qvalue) {
    $key = 'mapField'.$i;
    $result[] = array($$key => $qvalue->data);
    $i++;
}

$post_data = drupal_http_build_query($result,'', '&');

When printing the $post_data variable value, am getting something like this:
name=john&1[address]=street1&2[phone]=123456789

Notice the 1[] and 2[] after the &in the printed value. Any fix to remove these so that I get name=john&address=street1&phone=123456789?


texts: What should I set my Content-Security-Policy to?

texts:
I'm using Drupal 8, and I currently use

Header always set Content-Security-Policy "default-src 'self'; nosniff"

However, this causes bugs, such as Google Analytics not working and the textbox mysteriously disappearing from the Edit page. What should I do?


texts: How can I change the title of the search results page?

texts:
I've done much searching on this issue and most, if not all, of the results refer to the html tag in the head. I'm not trying to change the head>title tag in the html, I'm trying to change body content.

Currently, this is being output as "Search Content" like so:

  Search

  Content

I have no idea where either of those pieces of text are stored. They aren't in any template file I have, and if they are set somewhere in drupal, it's hidden to me.


texts: How to use dependency injection to apply a class static method?

texts:
I'm building a custom form (extending ConfigFormBase) and using static method File::load($fid). How to use dependency injection to call this method?
Thank you!


texts: How to add a new permission in "node_list_permissions"?

texts:
Is there a way to  add a new item in node_list_permissions function in node module from a custom module. Let me explain my problem.

I have a module say "audit" which will track node history, I have a new tab say history and user whoever have access to see the node history should be allowed to see the history of that node. Is that possible?


texts: drush cron fails: Drush command terminated abnormally due to an unrecoverable error

texts:
$ drush -v -d cron
Bootstrap to phase 0. [0 sec, 1.65 MB]                               [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0 sec, 1.77 MB]    [bootstrap]
Cache HIT cid: 5.4-commandfiles-0-33f01882e55343a61f1cb10880b0da0f [0.01 sec, 1.78 MB]                                          [debug]
Bootstrap to phase 0. [0.02 sec, 4.16 MB]                                                                                [bootstrap]
Bootstrap to phase 6. [0.02 sec, 4.16 MB]                                                                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.02 sec, 4.17 MB]                                                  [bootstrap]
Initialized Drupal 7.28 root directory at ...htdocs [0.03 sec, 5.78 MB]                                [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.03 sec, 5.78 MB]                                                  [bootstrap]
Initialized Drupal site default at sites/default [0.03 sec, 5.79 MB]                                                           [notice]
Cache HIT cid: 5.4-commandfiles-2-c32acd775c18a90c5b41d0fc9accf5ab [0.03 sec, 5.79 MB]                                          [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.03 sec, 5.79 MB]                                         [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.03 sec, 5.8 MB]                                               [bootstrap]
Successfully connected to the Drupal database. [0.03 sec, 5.8 MB]                                                           [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.04 sec, 6.3 MB]                                                   [bootstrap]
Cache HIT cid: 5.4-commandfiles-5-21916586faf556c236c401ff89ea50f6 [0.18 sec, 33.52 MB]                                         [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [0.18 sec, 34.19 MB]                                                [bootstrap]
Successfully logged into Drupal as Anonymous (uid=0) [0.18 sec, 34.2 MB]                                                    [bootstrap]
Found command: core-cron (commandfile=core) [0.18 sec, 34.2 MB]                                                             [bootstrap]
Drush command terminated abnormally due to an unrecoverable error. [0.2 sec, 34.87 MB]                                      [error]

There's nothing showing up in admin/reports/dblog.

Note that heading to /cron.php?cron_key=... works fine from the web interface. But it fails when curling it from console.
(I also reported an issue at https://github.com/drush-ops/drush/issues/664 but was directed here.)

How can I find out what's wrong?

P.S. related: https://stackoverflow.com/questions/10014142/cron-fails-when-running-through-drush-and-calling-node-load


texts: I have successfully installed sms framework module and configured with envaya gateway. I have support ticket module. I need to allow the users to create ticket (node:support ticket) via sms. Could you please guide me how to accomplished the same.


texts: New site (multisite) setup results in NotFoundHttpExcetion on homepage

texts:
I am trying to setup a new site using the multisite pattern in Drupal 8. The existing site in the repo works great. I am running within Docksal locally (which is a docker orchestrator). I have tried with a fresh copy of repo. I add my new *.site.yml file into drush/sites. I created the appropriate database and settings.php file. Then I am able to load the site setup UI and walk through the entire setup process. That completes and goes to a screen with the following error:
The website encountered an unexpected error. Please try again later.

Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /" in Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest() (line 137 of /var/www/vendor/symfony/http-kernel/EventListener/RouterListener.php).

Drupal\Core\Routing\AccessAwareRouter->matchRequest(Object) (Line: 113)
Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest(Object, 'kernel.request', Object)
call_user_func(Array, Object, 'kernel.request', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request', Object) (Line: 127)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Even when I reload in a different browser it says that. And that is after getting an access control error that was fixed by running drush cr.
Not really sure what to do here. I tried logging into admin, but get the same error but for that route. This is with a fresh vm, fresh clone of the repo even. It just doesn't want to support routing for this site. But the primary site that I am building this from works great locally.


texts: Which alias do I use to run it with another PHP version?

texts:
The Server available for our new Drupal project uses an old PHP CLI Version by default. But I have setup an alias in .bash_profile like so:

alias php7=/path/to/php7

and that is working fine. I would like to use Drush, so I cloned the repository, such that I can use Drush with the PHP version from the alias with php7 ./path/to/drush.

Doing so just prints the content of Drush to the terminal.

How can I setup an alias for PHP 7 that allows me to run Drush with that PHP version?

I have added these lines to the .bash_profile file.

alias php7=/path/to/php7
export DRUSH_PHP=/path/to/php7
alias drush="php7 $HOME/path/to/drush.phar"

When I run drush pm-update drupal, I get the following errors.

  The external command could not be executed due to an application error.
  The command could not be executed successfully
  Returned: PHP Parse error:  syntax error, unexpected '[' in    phar:///path/to/drush.phar/includes/startup.inc on line 63, code: 255)
  pm-updatestatus failed.

Why? How can I fix that?

Running drush pm-updatestatus or drush cr works, and drush status shows no errors.

Is there a bug in a specific version?


texts: Drupal 8 settings.yml file doesn't reflect changes

texts: So I'm trying to define some additional values in my settings.yml file, but none of my changes are reflected in the code. The config object has the same values in it. I've tried drush cr and other measures to clear the cache, but nothing works.


texts: Drush command using chef causing error "Command needs a higher bootstrap level to run"

texts:
Expected process to exit with [0], but received '1'

---- Begin output of /usr/local/drush/drush -y en views ----
STDOUT:
STDERR: Command pm-enable needs a higher bootstrap level to run - you will   [error]
need invoke drush from a more functional Drupal environment to run
this command.
The drush command 'en views' could not be executed.                  [error]
Drush was not able to start (bootstrap) the Drupal database.         [error]
Hint: This error often occurs when Drush is trying to bootstrap a
site that has not been installed or does not have a configured
database.

Please note that database and executing command lines are having full privileges.


texts:
I need to create a rest service that delivers the current data:

getNode(nid)
-> all node fields
   -> if field is entity reference (like file, human readable urls)
       -> include subfields
   -> if field is type of paragraph, include sub fields again in human readable form

It seems that Drupal is not yet ready for Rest without having to create new requests for every peace of content that is referenced with an id.

For example I have a Pinterest wall kind of output. Each item is created by using a paragraph element (sometimes with other references like taxonomy etc)

I want a clean, json list. Structured correctly without missing nested elements like paragraphs, file or taxonomy references. In this moment I just get the id's of the referenced elements.

Do I have to call now 100+ requests to collect all data for this wall?

1) Or should I make one request for collecting the node:

2) Another request to collect all 1st level entity references. Afterwards to store them in an array.

3) Afterwards making request for 2nd level entity references.

This seems horrible to me when it comes to questions about overhead and time.

Of course I have checked out some modules that should help with this issue:

rest_export_nested module
which does not work with paragraphs entity types
rest_views
does seem to output the fields as html instead of json. There is no real solution so far.

So what to do? Another way could be to create a view of paragraphs with target id of [NODE_ID]. But this would work just for 1st level paragraphs. The problem would still exist for nested paragraphs.

Is really the only way to create a custom module that creates it's own rest service?

Is the JSON API maybe another solution I haven't looked at so far?

Any input is appreciated.
Thanks.


texts: Notice: Undefined index: field_brand_image in include() in views field template

texts:
I've got another question about undefined index that I can use help with.

The error message I get is: Notice: Undefined index: field_brand_image in include() on line 15

I'm pretty sure that this is the same lnaguage and "und" portion of the field array issue I had in my other question here: Notice: Undefined index: und in include()

And only displays when the field is empty

Except this time the error is coming from a views template, the line throwing the error looks like:

php print $fields['field_brand_image']->content;

I "think" the answer involves an isset conditional, but I don't know what the syntax should be.
I'm using D7.23 and views 7.x-2.3

I'd appreciate some help.
Thanks.


texts: How to alter data set up to be alterable by drupal_alter()?

texts:
The User Import project has an array named $supported. It also provides the following hook to alter this array:

// hook to add functions to this array.
// Will call all modules implementing hook_field_user_import_supported_alter
drupal_alter('field_user_import_supported', $supported);

Implementing this hook in an altogether different project, e.g.

function mymodule_field_user_import_supported_alter(&$supported) {
  $supported['mymodule'] = array(
    'save' => 'mymodule_user_import_callback',
  );
}

works as one expects.

The User Import project allows users to add support for new fields by implementing the required code in a *.inc-plugin and placing it in a subdirecory named supported.

Rather than adding this to a contributed project I do not own (there is very little chance that my patch will ever be accepted), I want to make use the plugin feature provided by User Import.

I've created file a file named fieldname.inc and inside fieldname.inc , I've implemented hook_user_import_form_field_match(). My implementation of this hook follows the same pattern as the generic implementation of the same hook that comes with the project (it is in a file named field.inc).  What it does is to add the field with the name "fieldname" to the he pulldown-menu constructed by the project that lets the user assign a field from the imported CSV to a specific field in the Drupal database, and calls to custom custom functions to validate and save fields of type filename. This works fine, and  fieldname field type is now supported by User Import on my site.

However, User Import is unaware of this, and when I upload a CSV-file containing fields of type fieldname is says:

  Field fieldname is not supported

I want to get rid of this bogus warning.

To make this warning go away I need to alter the array named $supported to add fieldname to the list of supported fields.

I can do this by hacking the User Support project (i.e. changing this array directly). However, this is not a clean solution. Drupal developers are not supposed to hack code they do not own. So I want to have code inside my plugin that alter the array $supported belonging to User Support.

I've tried to implement hook_field_user_import_supported_alter inside fieldname.inc file as follows:

function fieldname_field_user_import_supported_alter(&$supported) {
  $supported['fieldname'] = array(
    'save' => 'fieldname_user_import_callback',
  );
}

This makes the warning disappear, but the field is now being added to the pulldown menu twice.  The latter is an undesired side-effect of implementing this hook.

So I want to add this add this element to the end of the array named $supported, but without having the field being added twice to the pulldown menu.

So the question is: How can make sure that User Import knows that fieldname is supported without having fieldname added twice to the pulldown menu?


texts: How do I keep data without using sessions

texts:
Is there a way to store data for separate users in Drupal without using sessions. I have previously used Drupal varibales. But it didin't work because the variable gets updated for every user (So whenever I access the variable it shows the last users details). I can't use sessions because I have a horizontally scaled server, so when the server is changed the sessions will be deleted.

Is there a way to do this exactly as the sessions but without sessions? I need to save users data in the browser temporarily.


texts: How to get the Route object from an URI?

texts: If I have a Url object, or even a simple string representation of path such as /node/2, how can I get the full Route object?


texts: New title on old page - search results show old title

texts: I have a page that used to have 2010-2012 in the title, now it has 2014-2017. When I search for that page using HUD or HUD Grant, I want the new title to show. How can I do that?


texts: Can I make interaction between views relations and views arguments?

texts:
I'm running into the problem where I have to join a node and a registration. The nodes are of type 'event' and the registration is available for some, but not all of them.

So basically I have a list of event nodes, and I left join the registrations on them, giving me some extra information where available.

The problem is I want to list only my registrations. So a contextual filter has to be added somewhere. The problem; The default filter applies after the join, filtering also all nodes for which I have not yet registered. But I want to show those.

Therefor I am looking for a custom handler that allows me to add an 'extra' statement to the views join clause. I've looked for it, but started t doubt where such  a thing is actually possible. Had anyone ever tried such a thing?

I suppose I need to make a custom hander, it's not a problem. But can handers 'communicate', or is there something like a hybrid handler of some sort?

Wrong query

SELECT ...
FROM
{node} node
LEFT JOIN {node_registration} node_registration_node ON node.nid = node_registration_node.nid
WHERE (( (node_registration_node.uid = '1' )

Working query, but non contextual

SELECT ...
FROM
{node} node
LEFT JOIN {node_registration} node_registration_node ON node.nid = node_registration_node.nid AND node_registration_node.uid = '1'


texts: Is it possible to use Rules to make an action to entities that refers to other with entity reference

texts:
I have type Article that refers one user with entity reference.

article1 refers to user1
article2 refers to user1

I want a Rule to show a message on user profile with all the articles that refer to this user. Is it possible without coding?


texts:
I am running the following code, retrieving a list of job openings that will expire in 7 days.

$triggerDate = new DateTime();
$triggerDate->add(new DateInterval("P7D"));

$query = new EntityFieldQuery();
$query->entityCondition('entity_type','node')
  ->entityCondition('bundle','job')
  ->propertyCondition('status',1)
  ->fieldCondition('field_expires','value',$triggerDate->format('Y-m-d'),'=');

This is returning 0 jobs, even though I have several that will expire in 7 days.  For example, one of my job nodes, has the following value

[field_expires] => Array
     (
         [und] => Array
             (
                 [0] => Array
                     (
                         [value] => 2013-05-09T00:00:00
                         [timezone] => America/Los_Angeles
                         [timezone_db] => America/Los_Angeles
                         [date_type] => date
                     )

             )

     )

When I leave the filter off altogether, the query succeeds and retrieves all items.  I've tried many variations of the date format including Y-m-d\T00:00:00 and Y-m-d 00:00:00.

The field is of type: Date (ISO format).  What am I doing wrong?


texts: How can I allow admins to choose anything from an Entity Reference field while restricting it for everyone else?

texts:
I'm doing a job listings site. Users with privileges to list jobs have an Entity Reference field connecting them to a Company node. Job nodes have a similar field. So when an employer creates a Job, he should only be able to choose the Company in his own ER field.

This much I can do: I just created an Entity Reference View and limited it with a Referencing Entity Relationship and a Current User filter that uses that Relationship.

However, admins should be able to create Jobs for any Company. This is where I fall down. It seems like there's nothing I can do inside this View, since everything in this View has to do with the nodes being listed; there's no way to conditionally turn off a filter based on the current user.

So now I need other options. I see the obvious workaround: Make the User Company field accept multiple values, and give every single one to every admin user. That will be my last resort. Before I give up and go that route, does anyone have any ideas? Any answer will do, though if yours requires my admin users to grant themselves new permissions every time we create a company, I will probably disregard it. Thanks!