texts: 1 Better exposed Filters for 2 views blocks

texts:
I would like to make a page with 2 Views blocks. The views show the same content type, but in a different format.

Block A contains an OpenLayers map.

Block B contains a listing result.

I want to filter both Views based on taxonomy, but with one exposed filter block.

I've made one Better Exposed Filter for block A, but I don't know how to control both blocks with one exposed filter.

Can anyone help?


texts: There is Drupal super user with uid = 1. I was trying to find out what is so special about this account and what activities will require this account. Is it necessary to have access to this account for Drupal page administration. I would like to know a list of thing that will require super user access. I would also like to know what is so special about this account. As far as I know there can be only one super user in Drupal.


texts: Set site URI for drush uli without 'default'

texts:
Versions discussed: Drupal 8.6.13, Drush 9.6.1.

This is somewhat similar to How to have an environment specific drush.yml? except that the other thread is now four or five months out-of-date and Drush 9.6.1 doesn't seem to respect the drush.yml anymore.

I'm just trying to set my Site URI.

As detailed in that thread, I've tried web/sites/default/drush.yml as well as many other locations for the drush.yml, done a drush cc drush, and yet drush status still reveals an incorrect Site URI of http://default, showing that it is not respecting the uri: line in any of my drush.yml files.

To complicate matters, I'm using DDEV, so following up on some suggestions that I've gotten from the Drupal Slack that we should really be using an environment variable (namely DRUSH_OPTIONS_URI) have proven tricky, as I'm not exactly sure where that goes inside of the DDEV environment.

Inside the DDEV container, if I do export DRUSH_OPTIONS_URI=http://my.ddev.local/ then everything works great, but once I quit the container or try to do things from outside it, such as ddev exec drush uli, things are back to the incorrect Site URI.

How can I persist this environment variable across restarts of DDEV/Docker?


texts:
I've problem when render form using ajax.
In my case link which should replece by form after clicking. But when I use form I have "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience." and nothing change. And if I callback sting all ok.

Someone know solution to render form?

function MYMODULE_ajax_response($type = 'ajax') {
    if ($type == 'ajax') {
        $form = drupal_get_form('MYMODULE_my_form');
        $commands = array();
        $commands[] = ajax_command_replace('#my-div'.$product_id, render($form));
        debug($commands);
        $page = array('#type' => 'ajax', '#commands' => $commands);
        ajax_deliver($page);
    }
    else {
        $output = t("This is some content delivered via a page load.");
        return $output;
    }
}


texts: How do I add grouping, programmatically?

texts:
I've added a custom field to a view and want to display results as a grid grouped by this field. How do I set that "Grouping field Nr.1" option in my code? I tried the hook_views_pre_build() using the $view->addHandler but m not able to make it work. I guess the issue lies in the $option array and the $type parameter for addHandler method. Here is my code.

function utility_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view->id() == 'frontpage' && $display_id == 'page_1') {
    $options = array(
      'style' => array(
        'options' => array(
          'grouping' => array(
            'field_category',
          ),
        ),
      ),
    );
    $view->addHandler("page_1", "grouping", "node__field_category", "field_category", $options);
  }
}

Update
When I use $view->addHandler("page_1", "field", "node__field_category", "field_category", $options); I get the a catgeory field added to each of the view items.

Can anyone help me on this?


texts: Remove disabled menu links from menu settings

texts:
I have a multilingual site, and when adding content theres an option to add a menu link. Both languages show up in the drop down selection, my goal is to hide/remove the links that are "disabled" (NOT in the current language).

So only the current language links should be visible in the dropdown.


texts:
I have one controller like as below .

<?php
namespace Drupal\users\Controller;

use Drupal\Core\Controller\ControllerBase;

class UsersController extends ControllerBase {

  public function getList() {
    $time = time();
    $data = array();
    $response = $data = $result = null;

      // add all the data in one multiple dim. array
      $data['title'] = 'Example to consume REST API of User List';
      $data['users'] = $result->list;
      $data['form_data'] = $result->form_data;

      // display the content in the middle section of the page
      $build = array(
        '#theme' => 'users_list', // assign the theme [users-list.html.twig]
        '#title' => 'Example to consume REST API',
        '#pagehtml' => 'API URL : api/users/list ',
        '#data' => $data
      );
    }

    return $build;
  }
}

this above function is called and render the HTML in the middle of the page in HTML format where page URL is call as per defined in routing file (http://siteurl.com/user-list).
I want to use this HTML output in ajax request which will call the same function through ajax instead of page url.

<?php
namespace Drupal\ajax\Controller;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;

class AjaxController extends ControllerBase {

  public function call_ajax(){

      //  my target is like as below
       $op = Drupal\Core\Controller\UsersController()->getList();
       return $op;
  }
}

Q) Is there any way to get the output of getList() in HTML format in ajax callback?


texts:
Using the example on [this][1] page, I have the following jQuery code:

(function ($) {
  Drupal.behaviors.gsdOmega4ExampleBehavior = {
    attach: function (context, settings) {
      var jcarousel = $('.home-jcarousel');
      console.log('executed');
      jcarousel.on('jcarousel:create jcarousel:reload', function() {
        console.log('never executed');
      })
      console.log('executed');
  };
})(jQuery);

The 'jcarousel' object is being referenced correctly.  I don't understand why jcarousel.on() is not being executed


texts: How do I get raw urls with contextual filters to work with views in Drupal 7, when i'm using panels, and panels everywhere?

texts:
I've scoured the site for solutions, and I have no idea what's going on. I have drupal 7 running off a local installation (mamp), and my site is structured with Panels and Panels Everywhere. I have a view that is in the sidebar, and I want it to pull up anything tagged with the name of the page. (for example walldamp/drupal/architecture would pull up architecture, or walldamp/drupal/acoustics would pull up all nodes tagged with acoustics).

The preview works just fine when I type in a tag, but it just won't work with the sites. If anyone could help, I'd really appreciate it.

I'll post a picture as soon as I get more reputation, but currently my settings are as follows for the contextual filter.

Configure contextual filter: Content: Has taxonomy term ID
Provide Default Value
Raw Value form URL
Path Component: 3
Exception Value: All
Specify Validation Criteria
Validator: Taxonomy Term
Filter Value Type: Term Name converted to Term ID
Transform dashes in url to spaces in term name filter values
Action to take if filter value does not validate: Display a summary.

It's just displaying the summary in my sidebar, no actual blog posts or images like in the preview. Any help would be appreciated.


texts: Allow timestamp published/updated dates for certains fields?

texts:
Is there a module to enable or disable the created and updated dates to certain fields?

The goal is to have a timestamp of the date of creation/modification date of a field (of type text) has multiple values.


texts: How to solve mind-mapping hierarchy in form of a form?

texts:
Any suggestions on how to solve the following problem?
Okay, I am creating a site in which there is a form. This form has several categories, and in each category, you are creating items. These items depend on each other: there's "Category one", which is kind of a 'root category'. You create how many items you want in this category. Then, in "Category two", you can create how many branches you want from the category item before "Category one", and so forth in the next categories. The set-up is kinda like a mindmap.
This is hard to explain in words only, so here is an illustration in hopes for better understanding:

Hope you understand my concept. The question is: How can i solve this in Drupal? I know there are mind-mapping solutions to this, but unless these are very customizable, it might not be ideal. The thing is that I want to break the "add new" process into individual modules. That way I can create a wizard which guides the user into adding new activities, product and consequences. Also: is this do-able from any known wizard plugins or scripts? (I am using Open Atrium)


texts: Can I add a link to the node reference when using the autocomplete widget?

texts:
I love the autocomplete widget for the References module in Drupal 7, but I find it odd that it doesn't include either a link to the referenced node (view or edit)?

Is there some way in hook_form_alter that I can add this somehow?

I can do this:

$form['field_lessons']['und'][0]['#suffix'] = 'Edit';

And the autocomplete field has an edit link underneath of it, but this doesn't work:

foreach($form['field_lessons']['und'] AS $lesson) {
  $lesson['#suffix'] = 'Edit';
}

And also loops 10+ times even though I only have 1 node reference currently :s

I don't necessarily like it but I can do it in Javascript like this and the Drag & Drop still works:

$('#edit-field-lessons .form-item').each(function(i) {
  var lesson_nid = $(this).find('input[type="text"]').val();
  lesson_nid = lesson_nid.substring(lesson_nid.indexOf('[nid:')+5, lesson_nid.indexOf(']'));

  $(this).append('View');
  $(this).append('Edit');
});


texts:
I'm trying to add a GMap to my contact page, I don't have the need for Location / GMap modules. I'm following the tutorial here but following it I have to add everything to the head in my html.tpl file:

<script>
  function initialize() {
    var map_canvas = document.getElementById('map_canvas');
    var map_options = {
      center: new google.maps.LatLng(44.5403, -78.5463),
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(map_canvas, map_options)
  }
  google.maps.event.addDomListener(window, 'load', initialize);
</script>

Where else can I place this script? I've tried to add it in a separate JS file and call it through my info file but it doesn't work that way.


texts: How to prepopulate a field from parent form to Inline Entity Form

texts:
I have 2 content types - Employee and Project.

Both forms have Inline Entity Forms with references to content of each other

when user creates an Employee node, he can add projects he took part in, and also when user creates a Project node, he can add a list of employees, who worked on this project.

But I would like to prepopulate parent node title in IEF, how can I do this?

For example, when I create a Project content type node, I add some employees, when I save Project node, these employees are mentioned on this project's node, but in the employees node there's no link to this Project.

I would like to prepopulate project title field in employees IEF project when saving Project node and vice versa.
It sounds a little bit like recursion, and  I'm not sure that my explanation is clear but I tried my best.
I'm using Drupal 8.


texts: Translated page does not show new paragraphs(components) that are added to the original language node (Drupal 8 core translation module)

texts: I've translated pages with Drupal's translation module. The issue that I'm having is that if you add new paragraphs(components) to the original language node, the translated page does not inherit those new paragraphs. Is that feature available? Thanks!


texts:
What is the correct way of using hook_menu_later.

I did this in my module to redirect (see also redirect in hook_init makes body text disappear):

function MYMODULE_menu_alter(&$items) {
  $items['node/%node']['page callback'] = 'citykidz_node_page_view';
}

function MYMODULE_node_page_view($node) {
  if ($node->type == 'event') {
    if ($items = field_get_items('node', $node, 'field_event_date')) {
      $date = date_create($items[0]['value']);
      drupal_goto('news/events/day/' . date_format($date, 'Y-m-d'));
    }
  }
  else {
    return node_page_view($node);
  }
}

And this got me wondering: what if other modules are also overriding hook_menu_alter and setting their own page callbacks on 'node/%node'? Or even on access or whatever. This is the standard Drupal way of doing things, but surely it will lead to problems (that can be hard to detect). I see there is a module Chain Menu Access API that addresses this. Has anyone had success using this module? And has this issue been addressed in Drupal 8?


texts:
I am developing a module, that when installed, should place an HTML element in a drupal block.
That block, will be inside a region. I would like the region to be added to the theme on module installation. Any workarounds?


texts:
Clicking on Whislist, it adds product to wishlist, and hides the wishlist button and replace it with text 'Already in wishlist' which I need to style and position, so to do that I at least need it to be in a div.

Is there a template?


texts: How to Create a single page within a module and set page variables?

texts:
I create a page within my custom module with the following code:

function mymodule_menu(){
    $items['product-detail'] = array(
        'title' => t('Product detail'),
        'page callback' => '_mymodule_product_detail',
        'variables' => array('var1' => "Hello World Attempt #1"),
        'type' => MENU_CALLBACK,
        'access callback' => TRUE,
     );

 function _mymodule_product_detail(){
      // global $var1 = "Hello Workd Attempt #3";

     return array('variables' => array("var1" => "Hello World Attempt #2") , '#markup' => '
This is some markup content displayed correctly in the page
');
 } // function

It renders the template, sets the title and display the markup (content of the page). However, I would like to fill some variables defined in the page.tpl.php and I don't know how to send these parameters, I tried with the variables key in the code but nothing is written. I want to display the message "Hello World Attempt #?" in the place in page.tpl.php where I have the code <?php if(isset($var1)) print $var1; ?>

I have been able to reach my goal with the following code, but using GLOBAL, which is not adequate:

function mymodule_preprocess_page(&$variables) {
   global $var1;
if(isset($var1) && $var1 != "") $variables["var1"] = $var1;

}

The global $var1 is set to $var1 = "HELLO WORLD Attempt #3" in the _mymodule_product_detail() function above (lines commented).


texts: Same tax for all territories and tax-free products

texts:
We're selling registrations to a congress through Drupal Commerce 2 and have been informed by the government of the country where the conference takes place that we have to charge their local tax to all attendees. Our attendees come from all over the world.

Is there a way to configure the Commerce 2 tax module to have it charge the same tax rate to all orders, regardless of where the customer is, other than creating a custom tax type and adding all territories one by one?

We also sell other products and do not want this local tax applied to those products. How would we go about configuring those products so they are not included in the tax calculation?


texts:
Hello Advanced Forum Module Experts!

I have installed the plugin and started styling on it and I also took a look on the views were they have listed a couple of views. I looked them up but I don't seem to find the view that display the discusion forums like General Discussion.

The url is /forum/view but I dont seem to find it on views

Where can I find it?

Thanks


texts:
I have always separated my field names by entity. e.g.

field_paragraph_h2 or field_content_h2,

but when you look at config, fields are designated by their entity type as well.

field.field.paragraph.paragraph_type.field_paragraph_h2 or field.field.node.content_type.field_content_h2

Am I safe using just field_h2 for both entity type field names, or are there instances with Drupal where this may be problematic?

e.g.

field.field.paragraph.paragraph_type.field_h2 or field.field.node.content_type.field_h2


texts: Can you customize the User Edit page without editing the theme?

texts:
Is there a way to customize what appears on the user profile edit page without editing the theme? I'd much rather use blocks or hooks to accomplish this task.

Is this possible?


texts: Is it possible to display a Mailchimp campaign (the newsletter, not a link) from my Drupal 7 website?

texts:
I've tried using views, but when I choose the rendered entity display of the MailChimp campaign field, the result is empty even though I've created 3 campaigns from within my Drupal site.  I don't think views is the answer anyhow as creating a campaign from a Drupal site still requires logging in to MailChimp to send. So I need to be able to display newsletters created in MailChimp.

I've resorted to displaying the archive of the latest newsletter in an iframe.  Besides being unattractive, it requires my client perform extra steps which is counterproductive. Not to mention, it is not responsive.


texts: How do I make several displays of one image field in a node?

texts:
I'm trying to implement a JS image gallery to my project. I've created three image styles:

thumbnails 135x105
gallery 690x430
full 1600x900 (responsive)

Thumbnails are used as a pager for the gallery. By clicking the zoom button, the full image should be loaded and opened in a modal.

The question is, how to use all three image styles with one image field and display them in one node?

On Drupal 7 I've used Gallery Formatter module, but on Drupal 8 it's not working properly.

The task seems to be quite trivial, but i didn't find any answer. May be there is some module or i can set image style to the field in twig template? Thanks in advance!


texts:
Backup and Migrate is great as a backup system and thus allows some sort of versioning. This enables  me to roll back easily when developing and testing small sites which I tend to develop in a live environment.Migrating a dev version to a live site is also quite easy this way.

Backup and Migrate does not work for SQLLite, however. I assume the best would be to put the site in maintenance mode, and copy the .ht.sqlite as a backup ... restoring should then be the same in reverse.

Am I on the right track?


texts: Using AJAX in Drupal 7 to change a form action

texts:
I would like to update the Drupal save_edit module to add an auto-save feature. This would look similar to the Stack Exchange auto-save (draft saved). So far I've gotten the save portion working (saving the new node) but when I save again, it creates another node (this is not a surprise since I've not told it to do anything else).

I'm looking for how to tell the form that the node has already been saved and what the node id is.

I think I need to update the form action to point to /node/$nid/edit this way when the user clicks on the normal submit button, the node will be published (if set to).

Obviously I'm not wanting to refresh the page after these saves, that would be too easy ;-)


texts: How to change the Drupal Commerce Stock formatter?

texts:
Drupal Commerce Stock displays the correct number of stock. For example:

Product Name, Price: $ 1.00, Stock: 20.

I would like to change the stock levels to 1, 2, 3, 4 and 4+. So if the stock level is 5 or more, the displayed stock will be 4+. What's the best way to do this?


texts: '#ajax' is not working with drupal_render(drupal_get_form())

texts:
I've a html form in a page. And also I've added another form at end of the form. My code should look like something below:

$customer_details = array('name' => 'Guru');
$form['#suffix'] = '

' . drupal_render(drupal_get_form('test_customer_info_form', $customer_details)) . '

';

Now I've  two form in a page.
My customer info form have below code:

function test_customer_info_form($form, &$form_state, $details) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Name',
    '#default_value' => $details['name'],
  );
  $form['submit-customer'] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
    '#attributes' => array('id' => 'customer_submit', 'class' => array('btn-primary')),
    '#ajax' => array(
      'callback' => 'customer_custom_form_submit',
      'wrapper'  => 'customers-box',
    ),
  );
  return  $form;
}

function customer_custom_form_submit($form, &$form_state) {
  print_r($form_state['values']);exit;
}

Now '#ajax' is not triggered while submitting form. But form submit handler is working fine. I can get form state values by test_customer_info_form_submit(). I want to get form values by '#ajax'. Is any suggestions?

Answer:
 The problem is my side. Because i've added 'id' using '#attributes' in form submit button. My id override the '#ajax' callback button id. Thats is the problem. Now i've removed 'id' from submit button. Now it is working fine.

Note: if you use '#ajax' callback for your form, make sure don't set 'id' attribute for submit button


texts: How do I programatically get access to the file uploaded to a webform after a submission?

texts:
I am using business rules custom action to access the submission data on entity insert.
I am able to get the file id and ultimately the realpath.
the real path is sites/default/files/private/webform/[webform_name]/_sid_/[file_name].
When I try to attach this file it is as if it were not there and ultimately gets moved into sites/default/files/private/webform/[webform_name]/[webform_submission_id]/[file_name].
I have tried to use the above path but it as if the file had not been written yet.
After the action has been completed I can attach the file with no problem.

The issue I am having is how can I get this illusive file and attach it to an email pragmatically.

here is the snipet of code that will generate the "/_sid_/" path

$file_id = $event['entity']->getData()[$file_field];
$file = \Drupal\file\Entity\File::load($file_id);
$realpath = \Drupal::service('file_system')->realpath($file->getFileUri());

Thank you for your responses and help on this.


texts: How to send notification emails in a journal style "Newsletter"?

texts:
I am working on replace an existing, custom built website with a Drupal 7 site. In the existing website I've coded a more or less smart email-notification system which I like to re-build for the Drupal version (if possible).

The website allows members to create/edit/cancel events, participate/decline events, comment  events etc. If any of these action happened they where logged for email-notification. The user then could set an interval how often the so called "Action-Log" should be emailed to the user. eg. once an hour, every four hours, one a day or once a week. This is extremely handy to a) stay in touch with the event and b) to not fill the members inboxes.

Advanced feature (phase 2): Further more the website had some logic to reduce the notification if or example a member already declined an event he will not get any notifications about that event. Think this will get really tricky to do in a generic way.

Any hints about how to do this with Drupal 7?

I already had a look to the following modules:

Triggers / Actions (sonding email but not "cached/delayed").
EntityRegistration (used for event registration).
Notifications (is alpha on D7 and called "quick port").

PS: I was told this feature is normally called "digest".


texts: How do I set "Add to Cart form" css globally using Commerce Kickstart as basis?

texts:
My goal is to borrow the Add to Cart form style from Commerce Kickstart on a site where:

Panels: Node Templates controls the Product Displays
Subtheme of Commerce Kickstart sets the CSS / template

Questions:

How do I find the CSS controlling the standard Commerce Kickstart Add to Cart form?
How do I use that CSS to control all "Add to Cart" widgets on the site?
Do I need to call out each Product Display type? Or is there a way to call it globally?
Related question: Why is the parent theme CSS being called? (There seems to be two levels of the Commerce Kickstart theme. One in .../themes/contrib and one in .../themes/commerce_kickstart_theme What's the difference? Are there two to share between the admin theme and site theme?

I am new to css, so am using "Inspect Element" to figure out how styles are applying to a given item. However, I can't figure out how to repurpose the css from Commerce Kickstart to apply to all "Add to Cart" widgets that are sprinkled throughout the site and control on a product-type basis through several Panels: Node Templates.

**These css callouts seem to be coming from the Kickstart theme, instead of the subtheme. I have enabled the subtheme and see changes I am making in the subtheme work, so I'm lost on why it is calling from the parent theme.
.../profiles/commerce_kickstart/themes/contrib/omega_kickstart/css/omega-kickstart-alpha-default-normal.css

From Inspect Element, I see that Commerce Kickstart shows:

For the attribute label:

.node-product-type .field-name-field-product form.commerce-add-to-cart label {
    float: left;
}

For the attribute drop-down:

element.style {
    width: 44.7778px;
    margin-right: 17px;
    text-align: right;
}


texts: How can I allow the user to choose their language upon registration?

texts:
There is a solution for showing the site language selection field on the user/register form in Drupal 6 here:
https://stackoverflow.com/questions/5556895/how-to-add-language-switcher-in-user-register-form-in-drupal-6

However, I'm personally not able to convert this to Drupal 7.  Is there another way to do this?

EDIT: When multiple languages are enabled via locale, the "Language Settings" with the list of user languages is shown on /admin/people/create.  This is what I want-- except I want this to be shown on /user/register, where it is not (at least by enabling locale alone) shown by itself.


texts:
OK, so this is a bit tricky, let's see if you can follow my problem:
(just let me know which part you don't understand 1,2,3...) I am using Drupal 7

1) I have 2 content types: Workers and Documents

2) In the content type Documents I have the entity reference field of all the workers. (Eg. I want to add a document/node that refers to a specificic worker John)

3) In the content type Documents there is a list field the user can select two options: red or green (it's a field where the user can say the document is OK to use)

4) Everytime I add a Document, I have to select red or green in that field.

5) Right now, I am displaying a view with all the nodes/documents from the content type Documents refering to the title and List field (red or green). Something like this:

Document 1 ------------------ red

6) On another page, I am displaying a view with a list of all workers (Content type Workers) and here comes the tricky part:

I want to add a field in this view displaying red or green based on this condition: IF (all the Documents from the entity reference "specific worker" have "green" on the field): display green.
IF (one of the Documents has the field "red"): display red

It will diplay something like:

John --------------- green

How can I achieve this with views? Do  I need to write code? Thank you.


texts: How to create a rule to email all users who bookmarked the author of new content?

texts:
I have the Rules and Flag modules installed. I want other users to be notified of flagged user new content.

I made 2 rules:

To add the author of content to bookmarks of user:

To send an e-mail notification when bookmarked (flagged) user created new article:

But it sends an e-mail only to the user who created the article.

What am I doing wrong?


texts: Using the DB API to test against a trimmed value?

texts:
I want to use the DB API (Drupal 7) to do a query like:

select my_field from table where trim(my_field) <> ''

where my_field is a text field.  My goal is to not get any values in the result that are made up of one or more spaces. (This is a greatly simplified example query, but you get the idea.) Is there any way to get that call to trim() in there? The only thing I could imagine trying was:

$query->condition('trim(my_field)', '', '<>');

which doesn't work at all.  Any thoughts?  Thanks!


texts: Problem with drush and site alias (Drupal 8.8.6 / Drush 10.3.1)

texts:
I've installed two drupal sites on a share hosting (OVH), in two folders :

dev.www
www

I've installed drush 10.3.1 and create two alias, but when I try use alias (drush @dev status), I have the follow error :
[warning] Drush command terminated abnormally.

I don't know if my drush configuration or aliases are good or bad. Here is my configuration in .drush/sites/the-choices.site.yml:
'@the-choice.dev':
  remote-host: ...
  user: ...
  root: /home/thechoc/dev.www
  uri: 'http://dev.the-choice.org'
  ssh:
    options: '-o PasswordAuthentication=no -i /home/thechoc/dev.www/insecure_private_key'
'@the-choice.prod':
  host: ...
  user: ...
  root: /home/thechoc/www
  uri: 'https://the-choice.org'
  ssh:
    options: '-o PasswordAuthentication=no -i /home/thechoc/www/insecure_private_key'

If someone can help me. Thank in advance.


texts: How to add alphabetized pager using glossary view?

texts: I have a member's directory that lists the last name, first name of all the users on the site, as well as other custom field values about the members.  I created a view, added contextual filter for the user's last name (Provide fixed value = "A", character limit =1), and enabled glossary mode. According to my google search results, I should automagically get an alphabetized pager.  This is not happening.  I made sure to save my new view.  Anyone have any other ideas?  What I want is an alphabetized pager that allows the user to choose the first letter of the person's last name, and display the info.


texts: Is there a way to show different Amazon affiliate link based on visitor locations?

texts:
I'm trying to get an Amazon affiliate link set up that directs the visitor to their local store, rather than being fixed to one particular store. I know I could set up individual links for each country and let the user choose the right one, but ideally I only want to show the one Amazon link.

Essentially what I'm looking for is a Drupal version of this Amazon Affiliate Link Localizer Wordpress plugin, or a combination of modules/tweaks that will let me do the same thing.


texts: Panels default content when creating a new page

texts:
When I'm creating a new panel page within the Panels module I want the new page to automatically load up with the content and layout and settings of my default site template.

For example, I want the site name, logo, main menu and a few other things to show on every single page without manually adding it every time I create a new page.

Should I not be creating a new Panel page for each section of my site?


texts: Programmatically setting a webform submission to draft in presave

texts:
I am trying from within a hook_webform_submission_presave() programmatically set a webform submission to draft.  We are creating an event registration system with webforms and some events require approval.  The thought is if an event requires approval we would set submissions to draft and admins could then "approve" them by making them no longer drafts.

Maybe there is a better way to handle this functionality and i'm open to ideas though I am not sure why this cleaned up hook below doesn't set submissions to draft mode.

function lebow_events_webform_submission_presave(WebformSubmissionInterface $webform_submission) {
  $current_data = $webform_submission->getData();
  $current_data['in_draft'] = TRUE;
  $webform_submission->setData($current_data);
}


texts: I am unable to get 'file' #type to appear in my form

texts:
I am building a custom module where the user needs to upload an image.  Here is the code for my form:

function floor_map_form($form, &$form_state) {
        $form['file'] = array(
            '#type '        => 'file',
            '#title'        => t('Choose a file'),
        );
        $form['center'] = array(
            '#type'     => 'textfield',
            '#title'        => t('Center'),
            );
        $form['country'] = array(
            '#type'     => 'textfield',
            '#title'        => t('Country'),
            );
        $form['region'] = array(
            '#type'     => 'textfield',
            '#title'        => t('Region'),
            );
        $form['submit'] = array(
            '#type'     => 'submit',
            '#value'    => t('Submit'),
            );

        return $form;
    }

The only thing that shows in the browser are the text fields and submit button, the file upload field is nowhere in the page or html for the page.


texts:
This is from the node_example from the Examples module on Drupal.org, I cut most part of them off now this should be an edited version of node_example.install: http://newstartpoint.com/public/node_example.install.txt

Now this is what I managed to get by myself: This http://newstartpoint.com/public/tudou_update.install.txt. This above one works but the one I programmed doesn't. Can anyone give me some ideas? They seem pretty much identical.

Thanks!


texts: General template (node.tpl.php) being used instead of specific template (node-article.tpl.php)

texts:
I'm creating my sub-theme based on Zen's starterkit. I copied node.tpl.php from zen to my theme and started making some customizations. Then I realized that I really only wanted those customizations to happen to the Article content type, so I renamed my subtheme's node.tpl.php to node-article.tpl.php but when I do it doesn't get used when I'm viewing my front page which has a list of articles. If I rename it back to node.tpl.php then it immediately gets used again. Back to node-article.tpl.php and I get nothing.

What am I doing wrong?


texts: FAPI initial checked state for #type => radio

texts:
Drupal FAPI reference doesn't have a working example for #type=>radio.  How can I indicate that I want the element to be rendered in a checked state?

$form['my_radio_button'] = array(
  '#type' => 'radio',
  '#default_value' => TRUE,
  '#title' => t('Checked by default.'),
);

I've tried #default_value TRUE, 1, and different combinations of #value, but nothing seems to work.  Thanks!


texts: Can one user be assigned different permissions in different sections with Workbench Access?

texts:
We are testing the Workbench and Workbench Access modules. We have many different sections on our site which are each managed by a specific department. These sections are established using a Vocabulary and this vocabulary is what we have configured to establish access through Workbench Access.

We have two main roles (aside from administrator) Author and Publisher. In essence, the author has less power and the Publisher has more.

Is it possible for User X to have Publisher permission on a node in one section and Author permissions on a node in a different section?

I have tried the following:

Assigning User X to the Publisher and Author roles.
Assign all Authors to Section 1 in the Roles Configuration of Access.
Assign User X to Section 1a (See example taxonomy below) in the Editors Configuration of Access.

The reason we want this configuration is so that, moving forward to Workbench Moderation, a user can have access to move a node in Section 2 to publication (since they're in charge of it) and also be able to make edits for review on typos or inaccuracies for any Section N they might notice needs it.

Example Taxonomy:

Section 1

Section 1a
Section 1b

Section 2

Section 2a
Section 2b


texts: Composer update still shows an older version of a module

texts:
Updating dependencies according to these instructions offers an older version of the module. Composer.json file has the package required as "drupal/h5p": "^1.0@RC", and it used to update just fine. It seems to be stuck with version rc14 and unable to recognise any changes. It seems like a problem with packages.drupal.org being unable to update the package info.

The instructions on creating an issue about it here seem to be outdated as that is for a Drupal version 7 project.

Any ideas how could that be resolved? A newer version has been released in the meantime and the package manager is still showing the rc14 one.


texts:
Currently I'm working on a custom module (my_module) that has some 'submodules' (my_module_sub). I would like to alter any of the my_module_sub_keyword_admin form using hook_form_BASE_FORM_ID_alter to avoid switch statements.

To achieve this I have added the following:

my_module.module

/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function my_module_form_my_module_sub_keyword_admin_foo_alter(&$form, &$form_state, $form_id) {
  // Alter any form where BASE_FORM_ID = my_module_sub_keyword_admin_foo
}

my_module_sub_keyword.admin.inc

(According to the hook_form_BASE_FORM_ID_alter documentation the base form ID is stored under $form_state['build_info']['base_form_id']. so I set it here)

/**
* Admin form.
*/
function my_module_sub_keyword_admin($form, &$form_state) {
  $form_state['build_info']['base_form_id'] = 'my_module_sub_keyword_foo';
}

and it works.

My question is simple: Is it correct way to set the BASE_FORM_ID like the examples above or is there a better/safer solution?


texts: How To Upload Image From Media Library Programmatically?

texts:
I enabled latest version of media module to upload images in wysiwyg. It is working fine. There is no problem. I want to upload images programmatically from media library.
  Below is my code.

function test_form_upload_form_alter(&$form, $form_state) {
 $form['settings']['apply_now_image'] = array(
  '#type' => 'media',
  '#title' => 'Image for apply now',
 );
 $form['#submit'][] = 'test_upload_form_submit';
}

function test_upload_form_submit(&$form, $form_state) {
    global $user;
    if (!empty($form_state['values']['apply_now_image'])) {
    $file = file_load($form_state['values']['apply_now_image']);
    // Change status to permanent.
    $file->status = FILE_STATUS_PERMANENT;
    // Save.
    file_save($file);
    file_usage_add($file, 'user', 'user', $user->uid);
    $apply_now_image_path = file_create_url($file->uri);
    variable_set('rgit_apply_now_image', $apply_now_image_path);
    variable_set('rgit_apply_now_image1', $file->fid);
  }
}

But it didn't give correct answer. This is only work if the '#type' is managed_file'. It didn't work if the '#type' is media. Is any solutions there to upload images from media library.


texts: How to change the position of a block in a particular page?

texts:
I have a Drupal's default User Login block in Side bar first region at the last position. Reference page: http://indiansnakes.org/snakes

The proposed home page has been redesigned and the User Login block has to be displayed in the Footer Fourth region. Reference Page: http://indiansnakes.org/homepage

So, the User Login block should appear in footer fourth only for this new homepage but for the rest of the pages in websites it has to continue to stay in the Side bar first region. In normal scenarios if it was a custom block, then I can create a clone of the same block and change the visibility per page / set of pages. But User Login block is system defined and it does not allow me to clone or duplicate it.

I tried searching if someone has already addressed this issue but it seems like not. Looking forward for thoughts.

Edit:
Nearest I could find is this: Change block location on page by page basis?. But the solution there was to create multiple blocks from same view, unfortunately User Login is not based out of views for me.


texts:
Form function:

$form['upload_photo'] = array(
        '#type' => 'file',
        '#title' => t('Upload Your Photo'),
        '#title_display' => 'before',
        '#states' => array(
            'visible' => array(
                ':input[name="testimonial_type"]' => array('value' => 'Text'),
            ),
        ),
        '#prefix' => '
',
        '#suffix' => '
',
    );

Submit function:

$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_text_testimonial_info'));
$file_d = $form_state['values']['upload_photo'];
                $file = file_load($file_d);
                $file->status = FILE_STATUS_PERMANENT;
                file_save($file);
                file_usage_add($file, 'user', 'TYPE', $file->fid);
                $file_info = image_get_info($file->uri);
                $file_arr = array(
                'fid' => $file->fid,
                );
                $field_collection_item->field_client_image[LANGUAGE_NONE][0] = $file_arr;
                $field_collection_item->setHostEntity('user', $user);
                $field_collection_item->save();

After submit I am getting below error:

Notice: Undefined property: stdClass::$uri in file_save() (line 614 of /public_html/includes/file.inc).
Notice: Undefined property: stdClass::$filename in views_data_export_file_presave() (line 278 of /public_html/sites/all/modules/contrib/views_data_export/views_data_export.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'uri': INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1535026403 ) in drupal_write_record() (line 7386 of /public_html/includes/common.inc).

Kindly help me to solve it out


texts:
Basically, I want the name of a node to be replaced with the value of a certain field. So if I have a field type called field_new_name, I want the title field to be changed to that field's value.

I found this link http://dropbucket.org/node/823 but I don't quite understand what it's doing. Is this what I want?

If so, as I run this script, is there a way to build to keep track of changes? Because some nodes reference others via hrefs so I'd wanna go back and change those references as well.


texts: How to create widget element with unlimited values?

texts:
I have a widget for a field as shown below:

I would like to make the text field ('script_paths') an unlimited value so that the user can add as many as they like. Is there a way to do this? Maybe there is a property I add in my code below:

function mango_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  $field_name = $instance['field_name'];
  $required = $element['#required'];
  $item =& $items[$delta];
  $element += array(
    '#type' => 'fieldset',
  );

  $element['enabled'] = array(
    '#title' => t('Enabled'),
    '#type' => 'checkbox',
    '#default_value' => isset($item['enabled']) ? $item['enbled'] : '',
  );

  $element['script_paths'] = array(
    '#title' => t('Script Paths'),
    '#type' => 'textfield',
    '#default_value' => isset($item['script_paths']) ? $item['script_paths'] : '',
  );

  return $element;
}


texts: How to verify only the email address on user registration?

texts:
I have a registration form. On the registration form the user can enter his username, email address and password and confirm password.

When the user registered, he/she should receive an email to verify his/her email address before login to the system.

Before email verification he/she should not be allowed to login to the system.

Also he/she should set his/her password on registration, no on email verification.

Is it possible?

I am using the logintoboggan with the Rules module. Through Rules, I set the status of a user to block upon registration. Then through rules with the event When the user account is validated (this event is provided by the logintoboggan rules integration module), I am activating the user.

But the problem is the loggintoboggan module automatically login the user upon email validation, which display an error message that the user is currently not active or blocked although the user has been actived. Because the rule event is triggered after validation of the email address.

Is there any way to prevent loggintoboggan module from automatically login the user upon email validation?


texts: Comments and Testimonials on Profile 2 Profiles

texts:
Is there a way of enabling either comments or a guestbook/testimonial functionality on Profile 2 Profiles?

I've read discussions on here about implementing on User Account Pages but not for the Profile 2 Profiles module.

Any ideas?


texts: Restricting view to content associated with user profile

texts:
On my site some users have the permission to see others' profile.

I'm looking to show a view in a block containing a food content type. It will be displayed on the profile page of the users (user/*). The block will contain content associated with that user (somehow I need to tell that when I am creating the content).

For example: Content "rice" belongs to user1; content "potatoes" belong to user2.

When I enter the user1's profile I see "rice"; when I enter user2 profile I see "potatos". It's the same block with the information changing according to the user profile I am seeing.


texts: How do I get the property of a node object?

texts:
I am trying to get the moderation_state property from a node object in Drupal8 (see attached image); however, I cannot work out how to do this.  In Drupal7 it was pretty straight forward $node->moderation_state.

How can I get this value in Drupal8 where $node is an instance of Drupal\node\Entity\Node?

I have tried:
$node->moderation_state
$node->moderation_state->value


texts: Pre-select facet with content from user field

texts:
I have a City field in the user profile and I would like to pre-select the faceted search results with the content of that field.

Latest Commerce kickstart installation, customized.
The field City exists both for the product and user, linked to the same taxonomy dictionary

So, I would like to have the city pre-selected to the user's city whenever the /product page is loaded, or a search is executed.
I tried Rules, but found nothing usable.

Thanks in advance!


texts:
I installed Drupal 8 distribution in Acquia Drupal. I am trying to install the Panels module after downloading the archive file from drupal.org.

I am not able to select the Panels module to install it.
Is there any other additional module to install, apart from the Layout Discovery module?


texts: Content profile bug - cannot edit user profile page

texts:
If the administrator user creates a profile node for a user, then that user cannot edit his own profile. How can I solve this problem? I have looked on the Content Profile module's issues, and found similar problems but no solutions for that.

In my case, that user created his profile node by himself, but I changed his username through phpmyadmin; now, his profile node results created by the admin user, not himself.

Problem solved! that profile node had php input format and that user whom i edited profile hadn't access for php input format filter.


texts:
Hey guys I tried to render a field on to the page template and it works fine on all pages except login/registration/profile pages.

Here's the code:

    <h3>
     <?php print render(field_view_field('node', $node, 'field_introduction', array('label'=>'hidden'))); ?>
    </h3>

Here's the error:


texts: simplexml_load_file() alternatives in drupal to fetch API data

texts:
Hello I just really want to know how can I fetch data from a API Link and store the data in database? In custom PHP I used simplexml_load_file() to fetch the data from API. I created the following page in custom PHP .
example.com.
I want to do the same functionalities in my drupal site.
Should I copy the same code from the above site in my drupal module. Will it work? I dont want to use external module like
aggregator
 or feeds
This may be a basic question for some user but for me it is very crucial to understand this.


texts: Drupal services multiple entity reference field

texts:
I am building a rest api with services. I have a user that has a entity reference field where they can add multiple nodes at once.

My question is, when returned from the rest api it only provides me the target ids. Is it possible to allow it to return all field values target id, name, date etc.

It would be nice to only have to make 1 call and not a call for each target id. instead of 1 call it could be potentially hundreds.

I was able to do something similar from a node with this code, but need it from the user:

function services_erf_services_resources_alter(&$resources) {
  $resources['node']['operations']['retrieve']['callback'] = 'services_erf_node_resource_retrieve';
}

function services_erf_node_resource_retrieve($nid) {
  $node = node_load($nid);
  if ($node) {
    $uri = entity_uri('node', $node);
    $node->path = url($uri['path'], array('absolute' => TRUE));
    // Unset uri as it has complete entity and this
    // cause never ending recursion in rendering.
    unset($node->uri);
  }

  $node = services_field_permissions_clean('view', 'node', $node);
 if ($node->field_specialty) {
   $wrapper = entity_metadata_wrapper('node', $node);
   $node->specialites = $wrapper->field_specialty->value();
 }

  return $node;
}


texts:
Say I have this type of code to build a custom block in Drupal 8.

 public function build() {

  //code that does a Guzzle call to retrieve data setting $links to contain that data

  $build['article_links'] = array(
    '#theme' => 'them_stuff',
    '#article_links' => $links,
    '#cache' => array('max-age' => 600),

  );

  return $build;
  }

Currently I don't have the '#cache' => array('max-age' => 600), and so every time to page loads the Guzzle call is run.  If I add '#cache' => array('max-age' => 600), does that mean that the Guzzle call won't be run until the cache is invalidated?


texts: How can I give option tags of a select tag ids or classes in Drupal 7?

texts: I was able to add classes to option tags in a select statement in Drupal 6 using a very convoluted method. I was hoping that there would be a better way in Drupal 7. Does anyone know how to add classes to option tags in select tags?


texts:
I am using a custom image field in one of my content types, which I am accessing using the following code.

if ($content['field_heading']) {
  print render($content['field_heading']);
}

Everything is fine, except that in administrative area I am seeing this error message:

  Notice: Undefined index: field_heading in include() (line 4 of tridz7\sites\all\themes\tridz\node.tpl.php).

What could be the reason? Is there any workaround?


texts: How to pass required arguments to a custom content type with services?

texts:
I am trying to create a Room Reservations Reservation through a Service using the Node Creation resource, but looking at the Room Reservations module code, the module does not allow the creation of nodes, or the passing of the form data for that matters, unless specific parameters are passed as arguments in the URL.

So far I have tried using the node create resource with the following data formatted as JSON, to no success

{"title":"fulano de tal","type":"room_reservations_reservation","reservation_block_title":{"und":[{"value":"0"}]},"reservation_date":{"und":[{"value":{"year":"2016","month":"6","day":"1","hour":"10","minute":"0","second":"0"},"timezone":"America/Bogota","timezone_db":"America/Bogota"}]},"reservation_length":{"und":[{"value":"60"}]},"reservation_repeat_type":{"und":[{"value":"1"}]},"reservation_repeat_until":{"und":[{"value":{"year":"2016","month":"6","day":"1","hour":"10","minute":"0","second":"0"},"timezone":"America/Bogota","timezone_db":"America/Bogota"}]},"reservation_room":{"und":[{"value":"163"}]},"reservation_time":{"und":[{"value":"1000"}]},"reservation_series_id":"","field_codigo_reservation":{"und":[{"value":"654535184561"}]},"field_email_registro":{"und":[{"email":"dshaooner@unisabana.edu.co"}]}}

The response is the whole webpage and no node is created.

i think the solution here is to pass the required arguments so that Room Reservations creates the node, would something like the following work?

example.com/endpoint/node.json/add/room-reservations-reservation/6/1/1200/160

Along with the rest of the data in the JSON POST request.


texts: Suggestion for "Convert line breaks into HTML" and text editor for corporate website

texts:
Previously when developing my own community website in Drupal 6, I've never know what people like when dealing with text editor. So I simply go with Ckeditor and untick Convert line breaks into HTML in the Text format options.

But now developing corporate website in Drupal 7. Ckeditor is in early stage (lack of visibility option) and I cannot use wysiwyg module because it has many conflict.

One good choice is use Bueditor. It looks clean and perfect but i must tick Convert line breaks into HTML in the Text format options to make it works for paragraphs.

So, should I:

use wysiwyg editor and untick Convert line breaks into HTML ?
or use Bueditor and tick Convert line breaks into HTML ?


texts: Commerce field with no value, but printed

texts:
My commerce product type has a text field, which is printed even if it has no value.
Every commerce field is printed within a <div classes_here></div>. Is there any way to avoid this issue??

thanks


texts: Setup existing drupal 6 site on local server

texts:
so far I've worked with Drupal 7 sites and have no experience importing Drupal 6 site to local server, so maybe you could help. I have 2 folders and .sql database file.

First folder is named 'files' which has sub-folder 'design' which consist all files stored in site (css, images, js, models etc.).
Second folder is named 'sites' which has two sub-folders - 'themes', 'models' and settings.php file.

I'm using Acquia Dev Desktop 2. So far I've created new site and database importing .sql dump file. And have plain text entering the site. Where should I override these two folders and should I rename them? My project is called 'project.dd', should 'design' folder be called as project name?


texts:
I have revisions active for a content type, called e.g. "procedures".

When a node of this type is revised, a new vid is assigned, which is a number independent of the number of revisions made on THAT node.

Given the nature of the node, I need to show/store in the node the revision number in a more meaningful way, for example version=1 for the original node, version=2 for the first revision and so on.
[edit]: I need to store this information in the database, so that it can be queried whenever it's needed. Also, it needs not to change when a old revision is deleted.

How can obtain such result in a easy, clean way?


texts: How to find url alias that is not matching pattern

texts:
I find the "fun" problems.
I have a site that is using token paths for content.  Not all the paths are correct.  This is a symptom of a deeper problem that I am still looking for, but it is causing its own trouble in the mean time.  The url pattern should be [field_category]/[title] and I have constructed a mysql query to identify ones that do not follow this pattern.

SELECT r.redirect, r.source, a.alias, s.field_category_value FROM redirect r
LEFT JOIN url_alias a ON r.redirect = a.source
LEFT JOIN node n ON r.redirect LIKE CONCAT( 'node/', n.nid)
LEFT JOIN field_data_field_category s ON s.entity_id = n.nid
WHERE a.alias NOT LIKE CONCAT(LOWER(LEFT(s.field_category_value, 2)), '%');

Examples of field_category_value are Aquariums & Zoos and RV Site.  I did not want to bother with converting the space after RV to a dash so I am using LEFT(x, 2) to trim it there.

Currently, this query is returning 14 results from the 8000 listings, so not a high ratio but still something that should never happen.  Especially when I just manually deleted the 300 that were discovered as wrong last week, and then used the bulk alias updater to replace them.  These incorrect urls are being indexed by solr, compounding my problem.  I am not even sure what I am asking.  The biggest question is why is this happening, but I dont expect anyone out there to know that.

If you have a programmatic way to find these, I can hook_cron something to repair them until the actual cause is found.

Modules installed:

Path (path)
Pathologic (pathologic)
Pathauto (pathauto)
Global Redirect (globalredirect)
Redirect (redirect) with PATCH


texts: How to add results count in exposed filter?

texts:
I have a view with some better exposed filter and I'd like to add the count of items for each filter like this (but without using facets) :

Term 1 (7) - Term 2 (5) - Term 3 (8) ...

I saw this solution but, I'd prefer using the query directly from my view or better using the view itself.

The problem is that inside a hook_form_alter(), every function related to this view (like views_get_view_result()) crashes Apache.

function mymodule_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-my-view-page') {
    $v = views_get_view_result('my_view', 'page');
    dpm($v);
  }
}

Any better idea for accomplishing this ?


texts: How do I display a content author's userpoints next to the author's name on posts?

texts:
I have set up the User Points module and want to show authors' points next to their name.

What is the simplest way to do this?


texts: How to filter nodes by the number of taxonomy term tagged with using exposed view filter

texts:
I have a node view and the nodes listed are tagged with some terms of Vocabulary A,B,C.
And I need an exposed filter that filters the nodes by the total number of the terms of Vocabulary A and B. I can't find filter like Taxonomy: Term - delta
How can I do this?


texts: Render main menu in page.tpl.php, with override from template.php

texts:
In Drupal 7, I'm trying to add a <span> tag inside the <a> tag of an item in the Main Menu, but it only works for the 'Navigation' menu which is a block, however, I am trying render it within page.tpl.php

I've been searching this up for a while now and can't seem to get it to work.
I was attempting to follow the information from How do I insert a <span> </span> tag inside the <a> </a> tag on my main menu

Here's a snippet from page.tpl.php

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

and from template.php

function THEMENAME_menu_link(array $variables) {
  $element = $variables['element'];
  $sub_menu = '';

//$element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];

$get_title= $element['#title'];
$element['#title']='<span>' . $get_title .' </span>';

$element['#localized_options'] += array(
    'attributes' => array(),
    'html' => TRUE,
  );

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}


texts: Drupal commerce payment callback endpoint

texts: Currently I'm work for a payment gateway plugin, the payment gateway will returning data by using the post method to my Drupal site once the payment transaction occur. I would like to know is that any endpoint and what are the hook is able to handle this process.


texts:
I am trying to print out the $view object using devel and dsm.

My function in function.php is

function my_theme_views_pre_render(&$view) {

  if ($view->name == 'my-view') {
     dsm('$view');
  }
}

But I just get this message below, there is nothing inside the message, the html is

  ×

Status message

$view


texts: How to theme output of node_view_multiple()?

texts:
If I want to theme the output of node_view_multiple() I can just set the #theme element of the renderable array generated by the node_view_multiple() function.

But, what if I'm not the one that called the node_view_multiple()? Is there a tpl file for that?

A good example would be a taxonomy term page. The taxonomy-term.tpl.php allows to theme only the term itself, not the actual list of nodes. So how can I theme that list of nodes?

Note that I don't want to theme individual nodes (that's not the scope of the question). I want to theme the list of nodes.


texts:
I have a view that contains images, I need to slightly alter the alt tag for each image by amending some text from the url onto the end. I seem to have pretty much figured it out yet when I check the view it has not altered anything.

Here is the code in my custom module, I have tried using a HOOK_views_post_execute and HOOK_views_pre_render, but still isn't changing the alt tags in the view

function image_alt_tag_alter_views_pre_render(&$view) {

  if ($view->name == "we_print_for_menu") {
    $path == arg(0) . "/" . arg(1);
    $alias = drupal_get_path_alias($path);

    // loops through index in array to change each alt tag
    // I have echo'd out from this loop and it is changing successfully
    // It just won't render in the view
      for ($i = 0; $i < count($view->result); ++$i) {
    $view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] == $view->result[$i]->_field_data['nid']['entity']->field_image_front_menu['und'][0]['alt'] . $alias;
  }
    // not sure if I need this
    return $view;

}


texts: Wrap a single html tag around each block that's generated from a single view

texts:
I'm sure this isn't difficult, but I can't seem to figure it out.  I have about 10 block displays generated from one view that needs a single html wrap (Setting the css property in the view itself is not what I'm looking for).  Devel themer module is suggesting block--views.tpl.php, however that obviously affects all blocks generated by views.  I assume a preprocess function would be best. The function below works, but I need to target a specific view.

Thanks in advance.

  function mytheme_preprocess_block(&$variables) {
    if ($variables['block']->module == 'views') {
      $variables['classes_array'][] = drupal_html_class('semester-container');
    }
  }


texts: How to extend the user registration in Drupal 7

texts:
I want to run a set of php code(not drupal code) after the user submits the registration form.

user enter details
submit the form drupal
writes form data to db
execute custom code
comes back to default registration tanakyou page of drupal

For this how will i extend the default user module of drupal without touching the core user module codes.

can i define a custom module and execute its resources


texts: How to pass variables to OpenModalDialogCommand

texts:
Drupal 8.
Clicking the upload button on Form1 should open UploadForm in a modal dialog.

/**
 * Callback to display a modal.
 */
public function ajaxSubmit(&$form, FormStateInterface $form_state) {
  $op = $form_state->getTriggeringElement()['#return_value'];
  switch ($op) {
    case 'upload':
      $modal = new OpenModalDialogCommand(
        t('Upload file(s)'),
          render(\Drupal::formBuilder()->getForm('UploadForm',
            $this->nid, $this->foo, $this->bar))));
      break;

    // ... other cases.
  }

  $response = new AjaxResponse();
  $response->setAttachments($form['#attached']);
  $response->addCommand($modal);
  return $response;
}

I'm not able to pass the variables to UploadForm. $this-> properties don't appear in UploadForm.

\Drupal::formBuilder()->getForm('UploadForm', $this->nid, $this->foo, $this->bar));

The form also fails if I replace the variables by local variables

$nid, $foo, $bar

But it works when I replace them by

'28', 'foo', 'bar'

The non-ajax version of the form uses a redirect to a form route (my_module.uploadform) and works OK.
Is there a way to pass the parameters to UploadForm?


texts: How to dynamically create option definitions in a views style plugin?

texts:
When creating my own Views 3 Style Plugin in Drupal 7, how can I create an option for each field that is loaded into the view?

I have tried looping through the views field handler (that works in the options_form function) but it seems I'm forced to hard code option definitions in the option_definition function.

//Get out Field Handler
$handlers = $this->get_view_field_handler();

//Set Some Options we - for some reason - can't set in the option definition
//because the "handler" object cannot be identified.
foreach($handlers as $i => $handler){

   $this->options[$handler->field . '-color'] = array('default' => "#666");

}

Is there some other way I can access the fields used in a view and dynamically create an option for each?


texts: Getting Image URL in Views with field_views_field

texts:
I have an content type called Image that has two fields:  Title and Image

I have a Views block created so that it displays the images I want based on my criteria.

What I need is to have the raw image URL available.

Example:

/sites/default/files/background1.jpg

I found this article Rendering Drupal 7 fields (the right way) and quite frankly, I am at a loss.

From the Drupal API:

field_view_field($entity_type, $entity, $field_name, $display = array(), $langcode = NULL)

I know I have to code the views-view-fields--my_custom_view.tpl.php, but everything I do results in an error.

What needs to go in this file so that I can simply get the URL from the image that I am looking for?

Also  point in the right direction to a tutorial would be great.  Everything I have found assumes you are an expert in Drupal and at this point, everything feels circular.


texts: content types vs. paragraphes types + taxonomy

texts:
I have quite a complex content structure and found the paragraphs module (in combination with taxonomies) can be very powerful for creating complex compound fields and dynamically reusing existing content types.

Example: 1 content type "equipment" tagged with a term from a taxonomy "mobility devices" (terms: car, aircraft, bike...) and with different fields of paragraphs types representing the different attributes for each of the devices. This way I'd only use the car_paragraphs_field if the equipment is tagged as a car and leave the other paragraphs fields blank. This in contrast of having multiple different content types "car", "bike"...

I'm wondering whether this a reasonable approach in terms of later displaying data in views, storing data to the DB, internal Drupal complexity/load when having let's say 100 different paragraphs types and only using 1 for each new content (i.e. leaving many paragraphs types fields blank), instead of having one separate content type for each.


texts: How to prevent the login block to be shown twice?

texts:
When I open my web without being logged in, the login block appears twice. Once in sidebar and once in header (at least I hope it is header section), as shown in this screenshot:

However, in structure/blocks I have it set in sidebar only.
Any idea how to fix this, so that the login block is only shown once?
Theme is ANDROMEDA: https://www.drupal.org/project/andromeda


texts: Drush site aliases empty within project folder but showing out of the project

texts:
I've got a project that was built using drupal composer project and have a number of drush alias files that site in ~/.drush/sites.

Using a globally installed drush, it appears to pick up the site aliases correctly although didn't appear to recognise the drush config file in ~/.drush/drush.yml.

Conversely, when in the project folder where a vendor/drush folder exists, running drush st shows the drush config files are recognised, as it shows:

Drush configs: /Users/me/.drush/drush.yml
               /Users/me/sites/www/client/vendor/drush/drush/drush.yml

However nothing in Drush site alias files and running drush sa shows {}.

I have checked ~/.drush/drush.yml and in drush: paths: alias-path: it lists

- '${env.home}/.drush/sites'
- /etc/drush/sites

So am a little perplexed by this!


texts: displaying updated time in aggregator block

texts:
I'm trying to add a line showing the last updated time for my RSS aggregator feed block (essentially the checked timestamp field from the aggregator_feed in a formatted manner).

I'm not able to find a preprocess function that lets me get this value.. the closest i got was implementing

function mm_theme2_aggregator_block_item($item, $feed = 0) {

  if($item->fid) {
    $fetch_modified_time = "SELECT `checked` FROM {aggregator_feed} WHERE `fid` = %d";
     $feed_last_modified_time = db_result(db_query($fetch_modified_time, $item->fid));
    }
    $last_modified = 'Last Modified time is ' . date('D M d h:i:s T Y', $feed_last_modified_time);
  $output .= 'link) .'" target="_blank">'. check_plain($item->title) ."\n";
  return $output;
}

where i'm not sure how to pass on this value to my $block or to $variables. Also this method iterates for each feed item and it'd be unwise to get the same value executed multiple times.

I'm pretty certain there's a drupal based way to get what i desire and am missing something.

Any help/support on this would be really helpful.

Thanks in advance


texts: Views block link defaults to target="_blank" using rewrite output

texts:
My client is using d6 and views 3.  They want to be able to display a box containing a random static image with an internal link to display in the same browser tab or an external link that would display in a new tab.  I created a content type with a field to upload an image, a text field to include a url, and (for simplicity's sake) a text field to include the target (either _self or _blank).  Then I built a views block to display each image using the 'rewrite the output of this field' option on the image field.  The text for the rewrite looks something like this:

[field_image].

The problem I'm having is even when field_target_value has target="_self" in it, views or something is ignoring it and the a tag is always showing up in firebug with target="_blank".  Another weird thing is that when I display the page source, the target doesn't appear at all.  When you click on the image, it does in fact bring the page up in a different tab as expected.

I've looked in the views code and did not see anything in there that seems to be the cause.  There is some custom code and theming on the site but I have not been able to find anything in there either.

Anyone have any clues why or thoughts on the strategy I am trying to use ??


texts: How do I create a number field that displays the number with a specific number of characters using leading zeros?

texts: In Drupal 7, I would like to create a serial number for one of my content type displays. I could use a serial field or integer field that will auto increment the integer with module code or with rules. I would like this serial number to have a specific number of digits with leading zeros, four for instance.


texts: Custom javascript file not working in mobile browsers

texts:
I have added a custom jQuery file to my theme with the theme.libraries.yml. In my laptop and fullscreen browsers the added javascript is working without any issues. But it seems the javascript does not have any effect in mobile browsers(I'm testing with ipad and iphone browsers in both safari and chrome). My custom_theme_libraries.yml is as following

global-scripts:
  js:
  js/jqueryfile1.js: {}
dependencies:
- core/jquery

And my jqueryfile1.js is as following

(function ($){
Drupal.behaviors.myModuleBehavior = {
    attach: function(context, settings) {
        $(document).ready(function(){

            //code goes here

            });
        });
    }
};
})(jQuery);

Is there any additional configurations to be considered to get the code works in mobile browser also?


texts:
I need to send data in the URL to the receiving server so that two fields from a survey form is put in the Completed URL string. It looks like it should be possible to use tokens for this, but I can't seem to figure out the correct syntax to use.

I need to send the response to a URL on the form

https://server.tld/sub/value1/value2

where value1 and value2 are fetched from form fields and the rest is static.

According to https://www.drupal.org/project/webform/issues/3021818 this should be possible, if I only could find the correct syntax to use to add the tokens.

Background
The user gets a link to the survey form in a text message. After filling in the form, the Remote Post handler functionality in Webform should post the results to an external server that expects the survey ID and user alias as parts of the URL (for reasons unknown to me, but apparently expensive and difficult to change) for the purposes of knowing when the user has filled in the survey so as to avoid sending out a reminder.

What I have tried
I have tried formatting the Completed URL string in various ways; like for example

http://example.com/%value[my_fieldset][a_value_in_the_form]

and

http://example.com/%value

but I just get a URL invalid error response when I try to save the setting.


texts:
Here's what I have:

An Image node type that includes an image file field and a node reference list that lists nodes of type "gallery"
A Gallery node type that lists taxonomy terms and stuff
A View that displays all Images associated with a given Gallery
Users with role Photographer who will be adding pictures to those galleries for which they have permissions
Users with role Admin who will be able to edit Image and Gallery nodes and administer Taxonomies.

Here's what I need:

A user-friendly bulk upload interface, preferably point-and-click-and-drag, that will allow Photographers to upload, say 100 photos at a time into their own directory
Bulk creation of Image nodes, one for each image that's uploaded
Bulk assignment a value to the "Gallery" reference field (both upon bulk node creation and also for already-created nodes)

Here's my question about it:

How can I offer user-friendly bulk upload options for Drupal 7?
... which would also support bulk node creation?
... and which would also bulk populate field values?

Suggestions of (stable!) modules are welcome, as are coding solutions.


texts: How do you do a redirect after a batch job?

texts:
I'm working on setting up a batch process in Drupal 8 that will gather a bunch of remote information for a collection of entities, cache it, and create a list of the results on its own page. The batch process is kicked off from a form using batch_set().

The batch job runs fine, but I'm not sure how to do the redirect at the end. Since Drupal 8 uses RedirectResponse objects or $this->redirect('user.page'); in a controller and the callback for a batch job doesn't have a return type, I'm not sure what to use to trigger the redirect.

I've tried using the url_options value of the batch job definition but that's not working.

$batch = [
  'title'    => $this->t('job running'),
  'init_message' => $this->t('starting job'),
  'operations'  => $ops,
  'finished' => '\Drupal\my_module\MyClass::finished',
  'url_options' => [
    'query' => [
      'destination' => '/job/results',
    ],
  ],
];


texts: Views contextual filter base path URL relative to current path

texts:
How can I get the summary base URL to start with the node that the view is currently on?

Below is my current configuration

If I am understanding correctly, 'node/%' in the base path for the summary is telling it to use the argument from my organic group contextual filter.

I need to use the Node ID of the current Node that the view is applied to but keep the rest of the functionality the same.

Let me know what other information I need to supply.


texts: How to set the user must login as member before purchase?

texts:
How do I set the user must login as member before purchase?

I'm using Drupal version 7, with Drupal Commerce.


texts:
I am able to display file with url: For example

echo ''.$path_parts['basename'].'';

How can I make this file downloadable? In case of pdf files, it is not downloading and opening in new tab as i have added target.


texts: Is there any elegant way of excluding form element from the `values` array of the `FormState`?

texts: I know that the values array can be cleaned up in the validation or submit callback, but can we somehow mark the element itself to be not put in the values array of the FormState?


texts: How can I prevent or limit CRON during SimpleTest?

texts:
I have a CRON job that tops up a huge cache table. Normally, it only updates a few records. But the first time it runs in a new installation, it has to load the entire table with thousands of requests to an external API. This gives SimpleTest a big overhead for any minor test in the module.

How can I skip or limit CRON when SimpleTest creates a new installation?


texts: Savings values to file form field on form submission - theme-settings.php

texts:
I'm trying to build a custom file upload field in my theme-settings.php file, but I can't seem to get the uploaded file to persist after the form is submitted. Setting the default value as it is set below causes an error 500 and the theme settings page won't load at all. With it commented out, I'm able to upload a file I see the uploaded files in my files directory but it doesn't show up in the form as a currently set value - am I missing something here?

Current code below.

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Theme\ThemeSettings;
use Drupal\system\Form\ThemeSettingsForm;
use Drupal\Core\Form;

function strata_form_system_theme_settings_alter(array &$form, Drupal\Core\Form\FormStateInterface $form_state) {

    $form['strata_settings']['hero'] = array(
        '#title' => t('Hero Image'),
        '#type' => 'managed_file',
        '#description' => t('A hero image for the homepage'),
        //'#default_value' => theme_get_setting('hero'),
        '#required' => FALSE,
        '#upload_validators' => array(
            'file_validate_extensions' => array("png jpg jpeg gif"),
        ),
    );
}


texts:
I am using Drush 9 and Drupal 8. When I execute drush site:install I find that it also modifies the permission of the web/site/default directory to r-xr-x--x, which troubles me delete that directory later. I want that directory to be 740 in my case. So two methods came to my mind. One is to run a custom shell script as post drush si or to override the default dush si command. I tried to go through some blogs but I couldn't understand them. Please explain stepwise.

How can I invoke a custom shell script to drush site:install which will be run just after that command is executed.

How can I override the default site:install command?

Note: I am using Drupal composer project. So I have a drush folder outside the webroot but I don't know if I can edit some files in that directory and write my custom commands.


texts: I've got a view with a few exposed filters. Is there a way to change the submit speed of the ajax request? So that rather than submitting the request after every key press, it waits until no keypress has been registered for say 500ms before submitting the request? I'm having problems, especially on mobile, where you might type "ar" in the exposed filter, but end up seeing the results for "a", with the filter set back to "a".


texts: Drush make and SVN: Leaving behind the .svn folders

texts:
Maybe I am missing a parameter, but when I use the below code in my make file, the ".svn" folder is removed. I would like that folder to remain. How can I do this?

projects[module_name][type] = "module"
projects[module_name][download][type] = "svn"
projects[module_name][download][url] = svn+ssh://company.com/home/svn/drupal7modules/module_name


texts:
Iam using Omega 4 and Drupal 7 and Iam wondering how to apply layouts just to certain parts to the website.
My website almost stays the same, header and footer never changes, just the content area.
I created a subtheme and applied a layout to it using panels or context, just to try both.

So whenever I create a new layout for instance for the basic article node, I need to setup the entire page structure within that tpl file again, how do I avoid such things?

I took a look in the omega theme folder under template, and there they just put the specific thing they want to change in the files, and dont rebuild the entire page strcuture.


texts: What is standard approach to module development?

texts:
I'm using module to create content types and views I need.

I prepare the content type in admin, then use export to export the configuration (i.e. views.view.my_view_name.yml, etc).
Then I copy relevant pieces of configuration to the mymodule/config/install directory.
I installed the module and it added the content type.

Now I had to update the content type's field display.

So I changed it in admin and exported.
Copied the updated file to my module.

Now I need to let Drupal know that my module is changed and to "reload" it.

Clearing cache did not help.
Calling /update.php said "nothing to update".
Only thing that actually worked is disable/re-enable the the module. But in that process it breaks all the nodes that used the content type in the module (because for some time the content type was unavailable and therefore it "downgraded" it to normal node).

What is a standard way to develop modules? Removing the module after every change seems ridiculous.


texts: How do I include jQuery scripts at the bottom of the  tag?

texts:
I want to include a JavaScript file at the bottom of the <body> tag, and I only want to  include it for a specific node type, but my node.tpl.php file's content is only wrapped by <article> tag; there is no ` tag in this file. If I do this in the root template.tpl.php file, it will effect all pages, which is not what I want.

Can I do this via theme preprocess functions?


texts: How to load node object in node preview page?

texts:
In drupal 8, how do you load the node object in hook_preprocess_page() when on the node preview page?

I had a bug come up where this standard way of loading the current node object was failing on the preview page:

$node = \Drupal::routeMatch()->getParameter('node');


texts: How to integrate CAPTCHA in a search form with Views

texts:
I have created a search page with the Views module, which includes a few exposed filter criteria. The form will be available to guest users, so I would like to include a CAPTCHA in the form.

The CAPTCHA module has been installed and works just fine in the user registration, but I cannot figure out how to integrate it inside the search page.

PS: I am using Drupal 7.10.


texts:
I created a feature module in site-1.

Then I instaled the feature module in site-2. This features creates a new content type and enable a module. Then I got the new content type and the module enabled.

So far so good.

Now I disabled and uninstall de feature module(drush). I expected the content type to be deleted and the module to be disabled, I mean the content type and the module that the feature created.

But they are still there...

How do I disable a feature and remove all the things that the feature created?

UPDATE: Steps I did to disable the feature:

1) drush dis myFeatureModule

2) drush pm-uninstall myFeatureModule

3) in admin/structure/features the feature myFeatureModuleis disabled

4) The delete button for the content type (created by this feature) in admin/structure/types is missing...


texts:
I am writing my first Drupal module and am having a little bit of a hard time wrapping my head around when I should use nodes vs storing data directly in the database. Is there any documentation I can read on this subject or does anyone have any advice on this?

I've actually already written most of the module entirely using direct database access and my own tables. I am planning on open sourcing it but I want to make sure I'm following common Drupal development standards and I think this is the most glaring error I made. So now I am trying to figure out how much I need to move from my own tables into nodes.

What started me down this path of looking a nodes is that I need to implement permissions. The module has a bunch of projects and I need to be able to control which users have access to each individual project and all the data related to it. It's not obvious to me how to do that using nodes so I was considering doing this as yet another table in the database.


texts: Help! Can't Login - Accidently set Omega content zone to not display in content section

texts: mysite.com/user/login can't display the login form because I accidently set my content zone to not display. Is there a way to reverse this programmatically?


texts: Site broken after upgrading with Pathauto < 8.x-1.6

texts:
I recently upgraded to Drupal 8.8. Unfortunately I missed the memo on needing to upgrade Pathauto first and now my site is broken. Most pages give the message "The website encountered an unexpected error. Please try again later."

I can get to /user and log in with an admin account, and I can get to /update.php which tells me "The Pathauto module is not compatible with the current version of Drupal core. Update the Pathauto module to 8.x-1.6 or later." and does not give me the option to continue to database updates.

I can't get to many other pages, and notably can't get to /admin/modules where I would normally upgrade a specific out of date module like Pathauto.

Do I have any other options besides wipe my site and restore from a backup? Even if I can figure out how to upgrade Pathauto at this point, I'm not clear if that's likely to fix the issue.

Thanks.


texts: Regenerating images after new image style

texts:
I created a new image style. When I inspect my code, the image style has been applied but it doesn't find the image. The image and the new folder in sites/default/files/styles hasn't been created?

Whats wrong, how do I generate my new image(s)?


texts: How To Get Views Argument as a Like / Contains Instead of Equals

texts:
I have a view that I need to filter using the logic Field_a Contains url_argument_1. Or in SQL Field_a LIKE '%url_argument_1%'. The problem I am having is only filters let me use the "Contains" operator and only Arguments let me access url_argument_1. How can I combine them?

Just for clarity url_argument_1 is Argument #1 that is passed into the view from the URL. Also, if at all possible I want to avoid writing a custom module. I prefer to do this via the views interface.


texts: limit exposed filter to top X taxonomy terms in drupal 7

texts:
basically I have an exposed filter that lets users use the filter to search the website.

Only the terms available are sometimes 20+ items so I want to limit the available exposed terms and show only the top X terms with the most related nodes and create a 'more' button to show the rest.

Is there already a module or something for this?


texts: Views: Highlight today's post based on previously referenced node

texts:
I have a weekly recipe list view, I manually create the list at the first day of the week.

for instance I assign Node 1 for Reference field labeled with Monday, Node 2 for Tuesday and so on using reference field in my Weekly content-type.

Next I made a page views of Weekly nodes and show the last node which contains that 7 referenced nodes previously mentioned.

What I want to do is to somehow determine today's date and change display mode of today's node along with Views Sort, like that if today is Sunday, the node referenced in Sunday field becomes highlighted and shows on top of the list.

Is there anyway to manage this using views, display suite or any other way?


texts: How to configure list page/detail page view?

texts:
I have created a new content type and show a list of all content of this type (list page). I have used the page URL article.

The detail page should be a child of article f.e. article/1. I configured the second view with path article/%.

How can I configure the detail view correctly and change the link in the list?


texts:
ON Drupal 7

I am trying to figure out how to lock an answer in a Drupal Webform answers the questions. (once the person filling out the webform) It is a quiz to enter into a contest. Only one question with 2 options.If they answer right they are entered into a contest, if not than they are not entered.

For example when filling out the webform: If there is a question that says- Do you like blue? the options are Yes or No. I want to have it so that once if the person selected No, than they cannot go back and answer Yes.

No turning back once answered...

Is that possible?


texts:
I have a view that lists the (ubercart) orders of a user. I created a view for that with a filter applied: "User: current". This works perfectly this way, I use this view in my profile page template like this:

$view = views_get_view('user_orders_custom');
$result = $view->execute_display('default', array($account->uid));

My problem is that when admin is inspecting the profile page of a user, this lists the orders of the admin, not the user being watched. Of course the passed $account->uid is not used by the applied views filter User:current.

I don't know how to make my view filter on the passed uid. I tried creating a relationship, arguments but the filter thing is not clear to me.


texts: What would be the best practice for theming the maintenance mode page in Drupal 7?


texts:
I have a block that I want to display on /group/*. That is working, but it is also displaying the block on /group/*/editwhich is pretty annoying and unwanted.

Is there a way to restrict that?


texts:
I accidantly deleted the user picture field while development. Now the app is production and a new feature should provide user pictures.

How do I get back the user picture field?


texts: Is it possible to make a nested Search API query?

texts:
I need to make a query in the following form:

SELECT * FROM {index}
...
AND (
  (field1 = value AND field2 = value) OR
  (field1 = other_value AND field2 = other_value)
)
...

But it doesn’t seem to be possible with the existing createFilter and condition methods, as there is no way to pass another filter to a condition for example. Am I missing something, or is this (basic functionality?) really not there?


texts: Is it possible to render an Adsense Block as a custom field block in Drupal?

texts: I'm trying to add an adsense banner inside my content and Drupal's Adsense regular module doesn't do that. It can only add Adsense in one of my regions but none within articles. Would that be possible using Display Suite?


texts: Creating a view by comparing two fields of two different content types using the same taxonomy

texts:
I'm trying to create a view to desplay contents based on shared taxonomy terms.

More concretely, I have two content types:

Offers (with field "Category")
Needs (with field "Category")

This contents share the same vocabulary "Category". Indeed, the "Category" fields of the content types "Offers" and "Needs" are refered to the same vacabulary (taxonomy) with terms:

electronic
chemistry
mathematics
science

Each user can define their offers and needs through 2 differents forms.

To put it simply, let's take the case of 3 users who created their offers and needs using this forms. Here is a table of a concrete example:

==> Case 1: current user (logged in user) = user 1

Imagine that I am user 1 (current user). The view page will have to desplay to me a list of the contents "Needs" of other users (user 2, user 3) and that have the peculiarity of having a "Category" field equivalent to the "Category" field of my contents "Offers".

In other words:

1) My content "Offers" are "Offer 1" and "Offer 2" with fields category ("electronic","science")

2) The contents "Needs" of other users are "Need 2", "Need 3","Need 4","Need 5" and "Need 6"

3) Comparing fields category between my contents "Offers" and contents "Needs" of other users:

Field Category of "Need 2" = chemistry. The value of this field is different from the values ("electronic","science"), that are the values category of my offers ==> The view will not display the content "Need 2"
Field Category of "Need 3" = electronic. The value of this field is equivalent to the value category of my Offer 1 ==> The view will display the content "Need 3"
Field Category of "Need 4" = mathematics. The value of this field is different from the values ("electronic","science"), that are the values category of my offers ==> The view will not display the content "Need 4"
Field Category of "Need 5" = science. The value of this field is equivalent to the value category of my Offer 2 ==> The view will display the content "Need 5"
Field Category of "Need 6" = electronic. The value of this field is equivalent to the value category of my Offer 1 ==> The view will display the content "Need 6"

4) It means that the view page should display this list of Needs:

Need 3 (electronic)
Need 5 (science)
Need 6 (electronic)

In other words, Offer 1 and Offer 2 (that are my Offers) match with Need 3, Need 5 and Need 6 (that are needs of the other users covered by my Offers). And this because they have the same categories "electronic" and "science"

==> Case 2: current user = user 2

Using the same logic, if the current user is user 2, the view page is going to desplay this list of Needs:

Need 5

==> Case 3: current user = user 3

And for the user 3, this list of Needs:

Need 1
Need 2
Need 4

Question : How can I create this view with view UI ? Any other suggestion is welcome.


texts: Hide tab created by views if user has a specific role

texts:
I have a views page with a menu tab in user profile, I want to hide it for some user roles.
I tried with hook_menu_alter

function hide_tabs_menu_alter(&$items) {
    global $user;
    if (in_array('gerant', array_values($user->roles))) {
        $items['user/%user/infos']['type'] = MENU_CALLBACK;
    }
}

This doesn't hide the tab, but it works for other tabs -created by
other modules- like user/%user/contact.
I wanted this user still be able to see this tab in other users
profile.

To add more information

There are two roles (gerant and etudiant). The permission should be View own info page which should be assigned to etudiant. gerant should not have it, but it should still be allowed to see user/%user/infos in etudiant's profiles.


texts: $page parameter doesn't appear to contain all the information used to render a page

texts:
I'm using hook_menu to build a series (100+) of pages where the code uses a basic page "master template" and replaces strings in the "master template" node with elements of the URL that reaches the Drupal menu page callback routine.

Once the appropriate strings are replaced, the page callback routine uses node_view() to create the render array, and returns it for further processing and transmission to the client.

The "master template" page is at URL mysite/whatever-string. The problem is that Drupal sticks whatever-string into the page the client receives, and it looks like this:

        ....

I'm using dd($var, 'description') to look at data structures and elements as a debugging tool.  From the callback routine, dumping the unprocessed and processed "master template" node and the render array returned by node_view() and searching for whatever-string returns no results. The string isn't there.  Thinking that perhaps the render array produced by node_view() didn't have all of the elements that the page contained, I implemented hook_page_alter($page) to see if the render array that it gets as a parameter might contain the string.  It doesn't.  Is there some other hook that's available to a module which will have everything that goes into rendering the page ?

As a last resort, I'm sure I can work around this by writing theme/template code to wander through the html (or DOM) and make the changes needed.  I've done this a lot before, but I think it's cleaner (and marginally more efficient) to do it all when the page is generated, rather than looking at all the nodes that get rendered to see if it's a generated one, and make the changes to the HTML directly.


texts: Programmatically / by Rules, remove reference of a deleted user from contents created by that user.

texts:
A user [content_editor] got deleted and the content created by this user is referring to anonymous user.  While an administrator is editing that content, administrator is receiving user doesn't exist. The error goes off when we re-assign the content to administrator or an existing user. As the user has created paragraphs, nodes etc how do we track contents created and referred by the user as user id is already deleted?

How can we remove these references and save the content without error message.

I thought we can use Rules API to create a simple rule which will force save any entity if an admin is saving the content, then save the content. But the rules API is providing me only nodes and not entities which means paragraphs will still refer to old deleted user. How can I overcome this. Is there a programmatic solution to this problem?


texts: How to use the value of a field in a filter criterion?

texts:
I created a comment view.

The parent content can be flagged and I want to display the comments posted since the date of the flag.

I added a hidden field "Date of creation of the flag".

I added a filter criterion (is greater than or equal to) "Date the comment was posted".

How to use the value of the flag in the filter criterion "Date of publication of the comment" ? there is no token and I have not found a module that can do that.


texts: How to hide certain taxonomy views from user?

texts:
I have one general taxonomy view wich has this alias mask /taxonomy/term/%.

What I need is to hide views for certain taxonomy terms like 'canada' from display while it'll remain showing the other ones the same way it was before.


texts: Cannot access subdirectory of private file system

texts: Why can I download a file from site.com/system/files/ but not site.com/system/files/protected/? Ownership is the same, permissions are 777, but I get a page not found. This is confusing to me.