texts: Pass Webform Submission Back to Form Template

texts:
I'm trying to use a webform to accept data, do some processing and calculation, and pass it back to the user. For user-friendly purposes I don't want to redirect to a confirmation page, but back to the form page so they can enter the information again. So essentially, I want the form template to submit back to itself, and if it has received a submission, print out the results (for now). I'm having trouble finding a way to do this.

I have an override template (webform-form-9.tpl.php) in my theme folder and it is successfully overriding the default, however I can't find any any way to actually get the values the user just submitted - even printing all available variables doesn't display the submission. I can't even seem to check if the user submitted a form or not. Does the form template not even receive the submission data? That seems extremely peculiar if so, so I can only imagine I'm not just not getting it right.

Any advice here?


texts: Creating nodes from json including image field upload

texts:
I am trying to create a node programmatically from the data(JSON) sent by my front-end template.

<input id="title" name="title" type="text" >
<input id="body" name="body" type="text">
<input type="file" name="pic" id ="pic1" accept="image/*">

^^ This is my front end html

jQuery(document).ready(function(){
jQuery("#save").click(function(){
    //alert("The paragraph was clicked.");
  var postData =  [{
      "content-type" : "article",
      "title": jQuery("#title").val(),
      "body" : jQuery("#body").val(),
      "pic1" : jQuery("#pic1").val(),
  }];
        jQuery.ajax({
            type: "POST",
            dataType: "application/json; charset=utf-8",
            url: "my-module/create-artcle/", //This is the menu hook I created
            data: {'article': postData},
            success:function(data){
            //if(data.status === "success"){
              alert(data);
            //  window.location = "/user";
            //}
          }
    });
  });

});

^^^ This is my json.

This data is sent to the hook_menu I created, which triggers a callback function to create the node. here is the code for that.

function create_article(){
  global $user;

  if(isset($_POST['article'])) {
      $json = $_POST['article'];
      $decodedData = json_decode($json, true);

      $contentType = $decodedData[0]["content-type"];
      $title = $decodedData[0]["title"];
      $body= $decodedData[0]["body"];
      $image1 = $decodedData[0]["pic1"];

       //Create a article
       $node = new stdClass();

       //Set values to fields
       $node->type = $contentType;
       $node->title = $title;
       $node->body[LANGUAGE_NONE][0]['value'] = $body;

       node_object_prepare($node);
       $node->language = LANGUAGE_NONE;
       $node->uid = $user->uid;
       $node->status = 1;

       $node = node_submit($node);
       node_save($node);
  }
}

So far I am getting my code to work except saving the image, because I'm seriously confused in saving an image to my node.
The value that I get from front-end is simply the name of the image.
my question is :
can I save an image to the node I am creating with what I am getting from front-end ? If so I am confused with this reference https://www.drupal.org/node/201594

could any one guide me to extend this code to save my image..
$image1 this variable contains the image name.

Thank you.


texts: I've created a survey using the webform module. I now want to assign a set of users to take the survey. Does anyone have any recommendation on how I should go about doing this.


texts: query API calling db_query result a non-object, but SQL works

texts:
I query my database using the following query API code, but Drupal tells me that the result is a non-object. I can't find any reason to it

in what situation does db_query return anything but?

The error:

  Fatal error: Call to a member function execute() on a non-object

the code:

for ($counter = 1; $counter <= 12; $counter++) {
  $query[$counter] = db_query("SELECT `foo` FROM `{bar}` WHERE DATE(FROM_UNIXTIME(`thing_$counter`)) = CURRENT_DATE");
  $results = $query['$counter']->execute()
    ->fetchAll();
}

The SQL works and produced results when I ran it in PHPmyAdmin.

The answer in this exchange looked tantalizing:

$date = date_create();
$date_to_test_against =  $date->format('U');
 $query[$counter] = db_query("SELECT `foo` FROM `{bar}` WHERE `thing_$counter` = $date_to_test_against");

however that produced the same result, calling execute on a non-object.

I know I don't have enough experience with this API yet. Can someone please point me to what I'm missing?


texts:
I want to add multiple class to my {{item}} twig template. The following code

{% set item = item|merge({'#attributes': { 'class': 'project-label'}}) %}

sets only one class ... how can I assign multiple class ? can i do something like this

{% set item = item|merge({'#attributes': { 'class': 'project-label'}}),
({'#attributes': { 'class': 'project-term{{ loop.index }}'}}`)%}

Please help.

Thanks


texts: Content related to role and user creation time

texts:
I want to show content to the user which belongs to his role, such as taxonomy,
its creation time, or another user custom field. Is there any way to do this in Drupal 8?

To Clarify my Question:
I want to have a relationship between user.creation_time (or another custom date field user.start_time, user.end_time) and content.creation_time (or another custom date field content.start_time, content.end_time). So that i can say user a only sees content which has a start_time that is within his start_time and his end_time.


texts:
I create a custom module that included hook_menu and hook_block_info and ...
i wanna add a tpl to this module . here is my code :

        function hookmenu_menu() {
            $items['hookmenu'] = array(
                'title' => 'Soheil',
                'page callback' => 'hook',
                'type' => MENU_NORMAL_ITEM,
                'page callback' => 'myhook_page',
                'access arguments' =>array('administer content'),
            );
            return $items;
        }

        /*
         * page callback
         */
        function myhook_page(){

            return theme('my_custom_template');
        }

    /*
 * Implement hook_theme().
 */
function custom_example_theme(){
    return array(
        'my_custom_template' => array(

            'template' => 'custom-page',
        ),
    );
}

and i created a custom-page.tpl and wrote hello world .
result : i can see my page but i can't see hello world

thx


texts: Garbage values in From: in the email sent from Webform

texts:
I find some garbage values in the from field of email sent from contact us page in webmail(as in the image From= field below in the top left in which "F" is cut-off by mistake). I've configured correctly as we do in D6.

I've also sent email from my webmail account from the same email account and it's ok.

This site is the latest version( 1 month old only).

Here I'm pasting what is seen in the image in text:

From: =?UTF-8?B?Ij0/VVRGLTg/Qj9RV1J0YVhOemFXOXVJRU52ZFhKelpYTWdTVzVrYVdFaElPQ2s=?=

This snapshot is from Thunderbird email client:

Looks like it is appearing from this(snippet from the email headers ):

........
X-Mailer: Drupal Webform (PHP/5.3.23)
From: =?UTF-8?B?Ij0/VVRGLTg/Qj9RV1J0YVhOemFXOXVJRU52ZFhKelpYTWdTVzVrYVdFaElPQ2s=?=
 =?UTF-8?B?cXVDbGplQ2tzT0NrdGVDbGgrQ2t0aURncEtvPT89CiA9P1VURi04P0I/NEtTKzQ=?=
 =?UTF-8?B?S1NnNEtXTjRLU3Y0S1NWNEtXTjRLU3c0S1N1SU9Da3JlQ2t2dUNrc09Da3BDRGc=?=
 =?UTF-8?B?cEs3Z3BZZmdwSUk9Pz0iIDxjb250YWN0dXNAYWRtaXNzaW9uY291cnNlcy5jb20=?=
 =?UTF-8?B?Pg==?=

I've Googled too but did not find any similar issue anywhere else.

Am I missing anything?


texts: how can I hide ShareThis icons from teasers

texts:
I installed the ShareThis module which works great for me, except I would like to hide the share icons from appearing in teasers. How can I do this?

Thanks


texts:
I would like to insert a JavaScript code in block body but I cannot save it, after 2 or 3 minutes it stop (shows a message The connection has timed out). I want to add statcounter code to a block.

EDIT 1:

I can add JavaScript in local-host but I can't do in server (Linux server, VPS cPanel)


texts: How do I link fields of a 'user content type' to the actual logged in user?

texts:
I'm using the User Content Type module (Drupal 7) in order to store some fields for each user, such as "zip code."

Now, in this node_edit page, I made a variant for a Catalog node, for a specific role. (Let's say "salesman".)

How do I link the actual logged in user with their respective User node, to show and store the "zip code" field in the Catalog node?


texts: How to apply specfic coupon in ubercart while creating an order from backend means admin pages

texts:
I am using ubercart. I am facing two issues while creating an order from backend.

1.) How to add coupon codes on add order admin page ?
i need to add orders manually from backend but not able to apply coupon codes for discounts, there is only a feature to "add a line item" but not for coupon.
I think there should be a textbox to fill coupon code and apply button to apply it.

2.) If coupon is applied to manually created order then tax calculation should be done after coupon price deducted from subtotal.


texts: How can I give Ajax access to currently set fields on my form?

texts:
I'm working on a block form that needs to update certain elements in the form based on what the user selects with certain elements. I've defined the internal class method and it's getting called correctly; however, it can't access the values stored in the form from the $form_state.

For example, when I call $form_state->getValue('filter_field'), it returns an empty value, even though it has been set on the page. I suspect that this may be due to the fact that I'm setting the callback like so: 'callback' => [get_class($this), 'updateWidgetAjax'], and in the final comment in the API, it says to do it like this: 'callback' => '::updateWidgetAjax'. However, when I try this, I get the The specified #ajax callback is empty or not callable. error. I tried following the tutorial on the API page as well as here, yet neither of them worked properly, spouting out the same error as before. I also went through this checklist, but most of the items don't apply.

Additionally, and this is just something annoying but related, if I don't mark updateWidgetAjax as static I get the following message in my log: Deprecated function: call_user_func_array() expects parameter 1 to be a valid callback, non-static method Drupal\global_filter\Plugin\Block\FilterBlock::updateWidgetAjax() should not be called statically, which I suspect will be resolved with fixing the above issue.

In short, how do I get the form values in my Ajax callback?

The element calling the Ajax:

$form['filter_field'] = [
  '#type' => 'select',
  '#name' => 'filter_field',
  '#title' => t('Select field to get the filter value from.'),
  '#options' => self::getAvailableFields(),
  '#empty_option' => t('Select a field'),
  '#ajax' => [
    'callback' => [get_class($this), 'updateWidgetAjax'],
    'event' => 'change',
    'wrapper' => 'default-value-ajax-wrapper',
    //The wrapper is elsewhere on the form
  ]
  '#required' => TRUE,
];

The Ajax callback function:

public function updateWidgetAjax(array &$form, FormStateInterface $form_state) {
  $widget = '';
  $multichoice = FALSE;

  switch ($form_state->getValue('widget_type')) {
    //code that sets $widget
  }
  //Return a render array
  $render = [
    '#type' => $widget,
    '#name' => 'default_value',
    '#title' => t('Default value'),
    '#description' => t('Select the default value for this filter. Leave blank for none.'),
    '#options' => self::getOptions($widget, $form_state->getValue('filter_field')),
    '#required' => TRUE,
  ];
  return $render;
}

EDIT: I forgot to mention that the form is defined with a blockForm, since I'm trying to create new blocks with this. I'm following the Drupal documentation found here. I think this might be a big part of the issue.


texts: How do you allow a role to assign other users roles - but only specific roles?

texts:
I'm creating a "level'ing" role system on my page. At a certain role (Full Member) the user must be able to assign someone with the role level 5 the new role level 6 manually once a dialogue is complete.

How can you do this?


texts: How to create a view that list all child nodes of current page?

texts:
I have a content type "A" that has an entity reference field to content type "B".

I need to create a view that will be embed on "A" node page for listing all "B" nodes referenced to it.

I know I have to use contextual filters for getting the current node id and a relationship, but not sure exactly the recipe.


texts: How to print the value of an array instead of the key?

texts:
I have the code below in a form builder for Drupal 7:

$form['color'] = array(
  '#type' => 'select',
  '#required' => TRUE,
  '#title' => t('Color:'),
  '#options' => array(
    0 => t('Blue'),
    1 => t('Yellow'),
  )
);

I need to print the selected value in hook_mail but I only get the key when I write:

function color_mail($key, &$message, $params) {
  global $user;
  $message['subject'] = 'Selected color is: ' . $params['color']
}

While what would make sense here would be to print the value, not the key. I tried $params['color']['#options']; too but it didn't work.

Any tip on how to make this work? I'm sure it's something simple I don't yet know about.


texts:
I have an entity called announcement, and I have a page (user/%/announcement) where I display a table of three columns (name of entity,an edit entity link and an delete entity link).

function announcements_user($account) {
  $uid = $account->uid;
  $return = '';
  $total = 0;
  $i=0;
  $pid = array();
  $text = array();

  $query = db_select('announcements','a')->extend('PagerDefault');
  $query->fields('a',array('pid','value'));
  $query->condition('uid', $uid);
  $result = $query->execute();

  foreach($result as $row) {
    $pid[] = $row->pid;
    $text[] = $row->value;
    $total++;
  }

  $return .= '

     Announcement
     Edit
     Delete

';

  while ($total) {
    $return .= '
';
    $return .= ''.substr($text[$i],0,10).'......	';
    $return .= 'Edit	';
    $return .= 'Delete	';
    $return .= '
';
    $i++;
    $total--;
  }

  $return .='
';
  $return .='
';
  $return .='Add Announcement';

  return $return;
}

Now my problem is that keeping this format of tabular structure, how do I display my result in a paginated format with 5 announcements per page? I have seen pager.inc for Drupal 7 and howto-print-out-the-pagination-for-entityfieldqueries link, but I just can't figure out how to apply them to my case.


texts: Error Finding Home page for Drupal 7 Site on Ubuntu Linux

texts:
I installed Drupal more or less successfully in /var/www/html on Ubuntu Linux. However when I go to 'localhost' it still just shows the Apache home page. However, if I go anywhere WITHIN my drupal site it works fine. So the home page is the problem. In fact if I click 'home' in the admin toolbar it takes me (again) to the apache home page.

Here's what I set in my 000-default.conf file on Ubuntu:

<VirtualHost *:80>
    . . .
    ServerName  mysite.dev
    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/html

    <Directory /var/www/html>
        AllowOverride All
    </Directory>
    . . .
</VirtualHost>

I tried following the directions here but didn't see any reference to index.htm or .html in my apache2.conf file:

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

Not sure what else to try.

Suggestions?


texts: How do I correct error: Contained fields field is required in Commerce Index Filters

texts:
Commerce Kickstart 2. I noticed that unpublished Products were still visible to users who are not logged in or have editing permissions.

I saw this topic: https://www.drupal.org/node/1899326 which states that one must check the 'Exclude unpublished nodes' box as well as the 'Exclude unpublished products' box in the Filters tab of

/admin/config/search/search_api/index/product_display/workflow

...but when I click 'Save' I get the error:

Contained fields field is required

...five times.

What is causing this? How do I correct?


texts: How to create a view to display event registrants?

texts:
I'm having troubles setting up a View that displays a list of registrants (not registrations!) for a particular event. I don't know how to setup RELATIONSHIPS correctly?

(I have already created a view that displays all registrations for a particular event, but since the user can register more than once for a particular event, I'm getting a list with multiple users enteries (if user registered multiple times) which is not what I want.)

Any suggestions?


texts: Drush command from contrib module not recognized

texts:
I have installed a new module called S3fs using Composer. When I try to execute /root/.composer/vendor/bin/drush drush_s3fs_copy_local, it shows the following error.

  Command "drush_s3fs_copy_local" is not defined

I found out that I could not run any command from third-party modules I installed and enabled.

Please help me.


texts: How do I check a value when creating new content?

texts:
My rule fires after saving new content. The first condition to configure has to be entity is of bundle Src. I don't know how to setup this condition correctly. I chose Entity:node, Type: MY_CONTENT_TYPE, Bundle:Default. Which doesn't work.

What would I have to enter to make this work using the Rules module?


texts: how can i re-direct a user of a particular role, if that user tries to access a page containing certain content type?

texts:
i have set a up a role called subscriber. If a non-subscriber (authenticated or anonymous user) tries to access a page with content type of ‘video class’ i’d like to have them redirected to a page that suggestions they subscribe.  so far, the content access modules i’ve looked at don’t handle page re-directs.

is there a module that would handle that?

the Context module doesn’t seem to handle content types. I could use it to set up a block with a javascript re-direct based on user role that seems kind of flimsy


texts: Using HTML Mail Module, how to link items in the email to individual product page?

texts: Using HTML Mail Module, I allow users to send shopping list (items) email as a notification, but when i send that email, the products in the mail are not linked to individual product page. How can I achieve that? What approach should i take?


texts: When using Drupal Commerce is there any way to add/alter/override the tax on the entire order?

texts:
We are using Drupal Commerce 7.x-1.4 and have a need to calculate the taxes on an order at checkout using an external service. When we make a call to this external service, it takes the Commerce order id as an argument, access the Drupal database, finds the components of the order with the passed id, checks each line item and returns a tax amount for the entire order based on its own set of rules.  Since the tax tables and rules are shared by another system, it's best to tap this service to ensure consistency with other applications when doing calculations.

The problem is that I can see a hook specifically designed to bypass the Commerce tax Rules system (hook_commerce_tax_type_calculate_rates) and allow a user to do their own tax calculations, but that works per line item as the comment in the hook states:

  An implementation might contact a web service and apply the tax to the unit price of the line item based on the returned data.

We are indeed contacting a web service, but not for each line item. Just for the final order as a whole.  So, unfortunately, this is not the answer.

Is there a way to hook in and override the tax calculation on the entire order either by intercepting the call to calculate the tax and overriding the processing (without hacking the Commerce modules) or altering the calculated result and be able to show it on the Tax line in the order summary?  Might there be a hook I'm overlooking or maybe someone has some other suggestion that I might explore?

Thanks.


texts:
I'm trying to migrate users from a non Drupal System into Drupal. I implemented my own CSV import script which basically generates Drupal user entities.

I already managed to teach Drupal how to handle the password hashes from the old system so that on first login of an "old" user, the old hash is getting replaced with a new one.

When creating a user account, Drupal automatically hashes the input for the Password field. I guess this is happening in the post save hook of the user entity.

How can I create user entities which will have my old hash inside of the pass field?


texts: Getting fields' Attributes in node template

texts:
I'm trying to rendering node's fields directly inside a node template.

This is my node template file node--homepage.twig.html:

<div{{ attributes }}>

  {{ title_prefix }} {{ title_suffix }}

  <div{{ content_attributes }}>

    <!-- Render field_1 value here -->
    <div{# field_1's HTML attributes here #}>
      {{ node.field_1.value }}
    </div>

    <!-- Render field_2 value here -->
    <div{# field_2's HTML attributes here #}>
      {{ node.field_2.value }}
    </div>

  </div>

</div>

Is it possible to get HTML attributes for each field inside the node template?


texts: how to upgrade drupal 7 site to universal analytics

texts: what happens if a user upgrades to universal analytics on their google analytics admin page, yet we are still using the drupal 1.4 module, which according to the documentation does not support universal analytics


texts: Drupal 8: Node preview when using Page Manager

texts:
I am using the Page Manager module in D8 to show the full node view pages. Drupal also provides a button to preview the content when creating/editing it. Is there a possibility to actually preview the page using the page manager layout?

Thanks for the answers!

Vasi.


texts: Change Image Alternative text on select box change

texts:
Fields:

Image Field - field_image
Selectbox Field - field_custom_language

Testcase: On selecting a different value from Selectbox, Alternative text of the image field should be changed.
Issue: Alternative text is not changed on ajax call.

    function custom_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
      $form['field_custom_language']['widget']['#ajax'] = [
        'callback' => 'AltChange',
        'event' => 'change',
        'wrapper' => 'custom-image-wrapper',
        'progress' => [
          'type' => 'throbber',
          'message' => t('Loading...'),
        ],
      ];
    }

    function AltChange(&$form, FormStateInterface $form_state) {
      $form['field_image']['widget'][0]['#default_value']['alt'] = $form_state->getValue('field_custom_language');
      $form['field_image']['widget'][0] = ImageWidget::process($form['field_image']['widget'][0], $form_state, $form);
      return $form['field_image'];
    }


texts: Administrator role can't edit html source in tinymce

texts:
I have created and administrator role that has full HTML editing capabilities when creating a node. The issue I am having is that when they click on the button to edit html source button (in tinymce) the resulting dialog doesn't show any source. As user 1, this works with no issues. I thought this was a permission issue of some sort but I can't find where this would be set. This is on a Drupal 6 install. Can anyone tell me what I need to do (and where to go) to fix this?

Thanks.


texts:
I've installed Wysiwyg with CKEditor and set up a profile for the editor. However, the CKEditor toolbar isn't showing up. When I add new content Firebug shows the following script error:

CKEDITOR is not defined

It highlights line 144 of /sites/all/modules/wysiwyg/wysiwyg.js:

CKEDITOR.config.customConfig = '';

I'm really not sure how to solve this problem. Do I need to manually define CKEDITOR.config.customConfig? If so, what should its value be?

I should add that this is a fresh Drupal install (version 7.27) and that I'm using Wysiwyg 7.x-2.2-dev with CKEditor 4.4.0 (standard version). The reason for using the development version of Wysiwyg is that the stable version is unable to detect CKEditor.


texts:
How could I define an image for those images that are not found (404's). In other words, if image which is displaying with image style is not found, provide an another image?

If someone is interested here is my solution:

function themeName_image_style($variables) {
  // Determine the dimensions of the styled image.

  $dimensions = array(
    'width' => $variables['width'],
    'height' => $variables['height'],
);

  image_style_transform_dimensions($variables['style_name'], $dimensions);

  $variables['width'] = $dimensions['width'];
  $variables['height'] = $dimensions['height'];

  // Determine the url for the styled image.
  $variables['path'] = image_style_url($variables['style_name'], $variables['path']);

  // Load default image for 404's
  if(!file_exists($variables['path'])) {
    $variables['path'] = file_create_url('/sites/all/themes/custom/lsa/css/images/404.png');
  }

  return theme('image', $variables);
}


texts: How to programmatically display a select list label instead of the value?

texts:
I created a select list box in the following format

Gender
1|Male
2|Female

I want to display the follwing information in a table but I am getting "1" for male and "2" for female.

Here is my code:

function display_results_submissions(){
$results = db_query("SELECT * FROM {users}");
$header = array( t('Name'), t('Mail'), t('Gender'),);

foreach($results as $result){
        $rows[] = array(

            $result->name,
            $result->mail,
            $result->gender,

            );
    }

    return theme('table', array('header' => $header, 'rows'=>$rows));
}

I want to display Male or Female instead of "1" and "2". How can I do so?


texts: What is the preferred way to delete la arge amount of data from a Drupal site?

texts:
We have a client site that currently has a very, very large data set in Drupal. We are working on generating a 'stripped' copy of the database to be used for testing new code by eliminating the bulk of the site content.

To this end, we need to periodically delete 40 million+ nodes and field collection entities from Drupal to strip down a copy of the production database so it can be used more readily on our staging and local development instances.

This is somewhat beyond what VBO or Bulk Delete (Nodes) or other similar contrib solutions can handle in a reasonable time, not to mention that many of the field collections are not on node objects. I suspect that using node_delete_multiple() and entity_delete_multiple() for millions of items may be a non-starter time-wise, even if batched through either the queue API or the batch API.

Is there any way to 'cheat' by TRUNCATING the field_data_* and field_revision_* tables in MySQL to speed the record deletions?


texts: How can I get the checked attribute into Better Exposed Filters input type radios?

texts:
i'm having a BEF exposed filter representing a taxonomy, they're radios.

It works well, but when i select a radio, it won't get in its HTML tag the property «checked».
I guess the selected value of the radios is stored somehow at $form_state, but this prevents existence of «checked» tag at HTML level. :-(

at jQuery level, i can select and play with the «checked» property, so it's working at javascript level.

the person who does the CSS needs that «checked» property at HTML level ...
is there a way to insert it in the HTML?


texts: How can I add an Zoom in/out event listener to an openlayers map?

texts: I am trying to hide and show certain layers of an open layers map at different zoom levels so that for example only one of all the layers on the map is visible at zoom level 20. I can't seem to find a way to create a behaviour that gets called when the user zooms in or out of the map, any ideas?


texts: How to do a RedirectResponse with a destination query parameter?

texts:
This works:

$redirectURL = '/cart/add/p2';
return new RedirectResponse(base_path().$redirectURL);

The problem is, I want this:

$redirectURL = '/cart/add/p2?destination=somewhere';

The moment I added destination=somewhere, I get this error:

InvalidArgumentException: The internal path component 'http://localhost/XXXX/public_html/XXXX/XXXX' is invalid. Its path component must have a leading slash, e.g. internal:/foo. in Drupal\Core\Url::fromInternalUri() (line 404 of C:\ampps\www\XXXX\public_html\core\lib\Drupal\Core\Url.php).

However, if I do this:

$redirectURL = '/cart/add/p2?SOMETHING_ELSE=somewhere';

Then it works. In other words, it specifically breaks if I add "destination=somewhere".

Why would it be breaking on this and how do I get around it? I.e. How do I redirect to a URL with destination=somewhere in the query string.

FYI: If I can get this to work, I can use "Cart Links" to add stuff to a cart and redirect the user at the same time, making my live a lot easier.


texts: managed_file #progress_indicator never finishes

texts:
I've been beating myself up on this issue all week. This is my first time using file uploads in custom modules so I'm using managed_file.

Here's a snippet of it that's being used:

  $form['family_fid'] = array(
    '#type' => 'managed_file',
    '#title' => t('Family photo'),
    '#description' => t('Upload a family photo, allowed extensions: jpg, jpeg, png, gif'),
    '#upload_location' => 'public://families/',
    '#upload_validators' => array(
      'file_validate_extensions' => array('png gif jpg jpeg'),
    ),
  );

The file upload works fine but the 'throbbing' ajax indicator never finishes and the customer is not happy. Looking around on SO I see that I must:

pecl install uploadprogress

And I have locally. Drupal in /admin/reports/status reports:

Upload progress Enabled (PECL uploadprogress)

No change, even after restarting apache 2.4 on ubuntu. The bad thing is that this project needs to go to Dreamhost shared hosting so I cannot install using PECL. They do point to where I can add "extension = uploadprogrevs" to my .phprc and I have. They have restarted but Drupal on DH does not see it. (FIXED: see edit) Regardless, I have to get some notification to the user that the file upload was successful.

Looking at file_managed_file_submit it describes the function doing a $form_state['rebuild'] at the end, which is ideal. But I don't get that. I don't want to hack a core function so asking around we tried a hook_file_presave($file):

function calendar_admin_file_presave($file) {
  drupal_set_message('File uploaded');
}

But no message at any point, esp. when user clicks "Upload".
We have tried hook_file_insert and it doesn't seem to work.

We have tried adding #process to the form array:

'#process'=>array('file_managed_file_process','_custom_file_process'),

with this functions:

function _custom_file_process(&$element,&$form_state){
if ($form_state['values']['family_fid']['fid']){
  module_invoke_all('file_presave', $file);
}

with no different result.

To further troubleshoot this drupal 7 app I set up a custom content type with a file field. It exhibits this same behavior locally. However, another Drupal 7 app on the same local server, same php 5.4.33 works as expected.

Even if I could get it to work on this app locally, I still will have an issue with Dreamhost shared server. So if I can get a notification to be done when a file is uploaded, I'd be OK. However it seems that Drupal in this app #uploadprogress is not working.

What else can I try to at least get a drupal_set_message inserted? thx, sam

One part of this is to get the PHP extension uploadprogress installed on Dreamhost and that is successful. Either we figure out why the drupal "callback" functions aren't working, or we can determine what could be causing this drupal 7 app to break this AJAX update when other Drupal apps on the same server don't have this issue?


texts: Assigning revision owner when moderating backwards with Workbench

texts:
I have a site that has a complex set of permissions and roles to support a workflow we have defined with Workbench Moderation.  This particular workflow has the "normal" three states:

Draft
Needs Review
Published

The workflow is set up to allow both forward progression through the workflow (eg, Draft to Needs Review) and also backwards (eg, Needs Review to Draft).  The site also uses the basic features in Workbench, and content creators like the My Content, My Drafts, and Needs Review, etc, pages / views that it provides.

OK, here is my problem.  One of the common tasks are editors pushing nodes back to Draft status for original authors to do major work on.  The problem is that if you examine node_save, revisions have their $uid set to the used who did the save (ie, $user->uid).  In this case, it would be the editor.  Therefore, the new draft shows up in the editor's queue and not the original author's (if you examine the view for this page, you can verify this behavior).

I am curious whether others have run into this problem and how they solved it.

Using a hook_node_presave to set the isn't an option, as it fires too soon, and node_save would nuke any changes, anyway.

I suspect that I could do a hook_node_update, eg

function mymodule_node_update ($node)
{
  db_update('node_revision')
    ->fields(array('uid' => $node->uid))
    ->condition('nid', $node->nid)
    ->condition('vid', $node->vid)
    ->execute();
}

but I am worried that there may be side effects that I am not considering.

Are there better options?


texts: How to add CSS classes to a Views-generated block? (NOT to its generated content, the block itself!)

texts:
I don't know why, but Views doesn't add "human-readable" CSS class names (like e.g. the machine name of the view) to the blocks it creates (it only adds its classes to the generated "content" part when adding classes to the "CSS class" part in the view editor (see the screenshots below!)).
It only adds the usual block block-views, and possibly contextual-links-region CSS classes to the block(s), and generates a unique id (not class) like this: block-views-3d8f7966168beeec655c8ead69336789 (because its delta is this generated hash code).
It doesn't make sense to write CSS rules for these classes and ids (like .block-views-3d8f7966168beeec655c8ead69336789 { /* ... */ }), because these classes/ids might change when altering the Views block.

How can I add some custom CSS classes in an implementation of hook_block_view_alter(), if I cannot even identify these blocks because of their generated hash delta?

I do not want to use Block Class, because I feel it's like an overkill for just adding some classes to one or two Views-generated blocks (BTW I checked the module, and I feel SELECT css_class, module, delta FROM {block_class} query in block_class_preprocess_block() like an overkill, because it checks ALL the added classes, even if the block is hidden...).

So I would like to solve it from my own module.

EDIT

An example:

My view with the machine name and the added CSS classes:

The generated block's HTML code in the inspector:


texts: How to prevent ad blockers from restricting sections of my website (non google ads)

texts:
I have a block towards the header, that is full width, and has some basic HTML with Full HTML Text format.

It is getting blocked by my user's ad blocker software. so far it is reported to be blocked with AdBlock and Adguard. I have tested and verified with AdBlock

My content isn't "spamy" at all. In fact it is a coupon code so they are missing out :)

Here's the content

50% OFF entire store. Use code AWESOMESALE50

The CSS class for the block is banner-advert

Could it be the inline CSS?


texts: How to use drupal_get_token() within custom user registration email

texts:
I'm in the process of writing a custom user registration module for Drupal 7. I currently have my own custom form which calls the function user_save within it's submit handler to create the new user account. The account is initially created as "disabled", and will only be activated once the user verified their account via a link in a custom welcome email.

I have generated a token to append to the URL query string (contained in the email generated by hook_mail() using drupal_get_token()):

$myToken = drupal_get_token('email_verify_'.$params->uid);

Unfortunately I'm always getting an Access Denied message when following the registration link within my custom email. I've checked both values storing the UID within the hook_mail and page callback and they're indeed correct.

Is there anything I'm missing here? I considered using user_pass_reset_url() instead, but we capture the user password on registration so we don't want them to have to re-enter their password twice.

Thanks in advance!

EDIT #2: adding more code for Pontus

hook_menu implementation:

//callback to verify user via email link
$items['custom_user/signup/verify/%'] = array(
  'title' => 'Activate your Account',
  'page callback' => 'customer_user_signup_verify_email_page',
  'page arguments' => array(3),
  'file' => 'includes/custom_user_signup.verify.inc',
  'access arguments' => array('access content'),
  'type' => MENU_CALLBACK,
);

Check if valid token within customer_user_signup_verify_email_page() callback function  drupal_valid_token():

if (empty($_GET['tok']) || !drupal_valid_token($_GET['tok'], 'email_verify_' . $user_id)) {
    drupal_access_denied();
}else{
    //enable account now that we know you're a valid user
}

URL printed in email:

http://mysite.com/custom_user/signup/verify/10?tok=Zh2MmBHLnjvd3Dq9KcDxkwJ0lmk_QmMg5QNZomC7Okw


texts: Target field in feeds importer doesnt show product reference fields

texts: Hi I m trying to import a node with content type which has a field of type poduct Reference i am not able to see the fields inside the product variation so how can it be done ? any idea thanks in advance


texts:
In my_module.routing.yml

my_module.detail:
  path: '/module/{id}'
  defaults:
    _controller: '\Drupal\module\Controller\DetailController::view'
  requirements:
    _access: 'TRUE'

In template twig file I'm calling via

Test

Here my Id is not Integer It consists of string like AzT13AAa

So when I access it gives error like

  Symfony\Component\Routing\Exception\InvalidParameterException:
  Parameter "id" for route "my_module.detail" must match "[^/]++" (""
  given) to generate a corresponding URL. in
  Drupal\Core\Routing\UrlGenerator->doGenerate() (line 202 of
  core/lib/Drupal/Core/Routing/UrlGenerator.php).


texts:
I cannot get this to render out. This is what I get with {{ kint(paragraph.field_image.value) }}.

If this makes any difference, the image is uploaded through a media entity browser widget.

How do I render an image from a Twig template?


texts:
We have a live system.

define('DRUPAL_ROOT', getcwd());
define ('DRUPAL_ROOT', getcwd ());

I couldn't log in with the command

define('DRUPAL_ROOT', 'D:/www/webhosting/o3800_7Z55V5Hop2Ff/wwwroot/vts/')

I changed it this way

I entered the site but the page is broken as it appears in the photo

I request help on this subject, thanks.


texts:
How do I get the option text from the submitted value of the radio field in Drupal 8 webform submission? I have written a rule action condition on webform submission where I am storing data in a middle table.

Based on screen I am looking for Option Text from webform field.
Current version: Drupal 8.6.15 & webform 8.x-5.2


texts: How can I modify the result of the core Path listing filter?

texts:
The core Path module defines the page admin/config/search/path which gives a listing of all path aliases.

The menu hook in the module calls the path_admin_overview function in path.admin.inc which makes the query to retrieve a list of URL aliases:

$query->condition('alias', '%' . preg_replace('!\*+!', '%', $keys) . '%', 'LIKE');

What I would like to do is somehow intercept this query and modify the condition in a custom module (to avoid hacking core, of course). To be more precise, I want to make it possible to extend the condition to search the source column as well as the alias column as indicated above.

My first thought was to intercept the Path admin listing form: path_admin_filter_form which I have done using hook_form_alter. I was then hoping that somehow I could override the existing submit handler or attach an second one which would call path_admin_overview, but of course I cannot directly modify that core function.

So it seems like I would have to make my own custom copy of path_admin_overview and modify the code inside, then have that called instead. Of course this doesn't feel right either - since if the Path module changes, the module will fall behind.

Is there some kind of hook or pattern I can employ here to modify the query in path_admin_overview or otherwise achieve the goal indicated in bold in a standalone module?

EDIT: It looks like it could be possible if the query in path_admin_overview was tagged (it isn't currently), see here: https://www.drupal.org/node/310077#hook_query_alter


texts: How to add attribute to element in twig before render?

texts:
I have a template for one of my forms and I want to add css class to the element before I render it but since I am printing the element as a whole I am not sure how to alter the attributes.

I was told on IRC to have a look at the merge method but so far no luck.

{% set submit_attributes = form.submit.attributes %}
{% submit_attributes.addClass('test') %}
{% form.submit.attributes|merge(submit_attributes) %}
{{ form.submit }}

or

{% form.submit.attributes.addClass('test') %}
{{ form.submit }}


texts: How to add a default taxonomy term to all nodes in a migration?

texts:
For a Drupal 7 to Drupal 8 migration, we're taking what was a Quotation content type and migrating it into an Article content type, joining a ton of nodes that are staying as Articles.  To distinguish, I want to add a taxonomy term "Quotation" to the field_categories (which exists on Articles D7 and D8 but not on Quotation).

So i'm "simply" trying to add a value not from a source, but hard-coded.  My source plugin is d7_node (namespace Drupal\node\Plugin\migrate\source\d7).

I'm flailing a bit; tried entity_generate but couldn't figure out how to tell it to use a constant and/or default value rather than looking for something from source.

Even this didn't work, when i tried to test the simplest thing i could think of when already knowing the term ID of an existing term:

  field_categories:
    plugin: iterator
    source: field_categories
    process:
      target_id:
        -
          plugin: default_value
          default_value: 10838

Can one use the default_value plugin or something like it for the 'source:'?

I'm about to stick my non-source value into what comes from the source with a prepare row hook, but it seems there ought to be an easier way.

Note that in this case there is nothing from field_categories in the source to worry about, but i'm also interested in the case of adding a new, hard-coded-into-the-migration term into a field that will have content, in my case field_tags.


texts: Taxonomy term not found using tid from term reference

texts:
The users in my webapplication have a term reference suppliers.

I also have a content type transaction where I have the same term reference. Now I would like to hide the select list and set the default value programmatically. This is what I do now:

$form['field_supplier']['#type'] = 'hidden';
$user_suppliers = array();

foreach($user_selling->field_suppliers['und'] as $supplier)
{
    $user_suppliers[] = $supplier['tid'];
}

$firstsupplier = reset($user_suppliers);

$first_supplier = taxonomy_term_load($firstsupplier);

As you can see I loop through the tid's and save them in array. Afterwards I pick the first one (there's a reason I don't pick the first instead of looping through).

The $firstsupplier variable results 7 so what's not abnormal for a tid. But when I want to load the taxonomy term I get a response false... (he can't find it) .

I recently resetted my taxonomy vocabulary to alphabetical, could that be the reason? (I think not, because I tried it after saving them in a random order)


texts: Node limit - based on cck field of referenced content type

texts:
I have 2 content types:

Organisation (Name, address, tel, places)
Internship (Reference to Organisation , Student, Mentor, ...)

Now for example I have an organisation with 2 places for students. So when this organisation is selected as a refernce in Internship node creation, it must check for the available places. If the pace is available then it needs to save the node else it should give an error message.

I have tried node limit module but it is not a solution.

Thanks.


texts: Hierarchical menu of all Terms of a Vocabulary & Contents of the Terms

texts:
I have Category vocabulary under which there are several terms, i.e Tabs, Smartphones, Cellphones, Umbrellas. There may me one or more contents of custom type under each of these terms (A content could be linked with one term only). I want to generate a menu (automatically, if possible) like this:

Now I've installed Taxonomy Menu module which allows to generate menu with one level hierarchy only (with only terms of a vocabulary, but no contents of the terms).

Is there a pretty solution of my problem? Thanks for caring :)


texts: How can I remove the asterisk for required fields programatically?

texts:
How can I remove the asterisk Drupal inserts for required fields programatically (not hiding with CSS)?

In Drupal 7, there was theme_form_required_marker(), but that's gone from Drupal 8.


texts: How to resolve my error when uploading files?

texts:
In our Drupal site when we try to upload .zip file having 210MB size, we are getting an error saying:

The file NewEdition105.zip could not be saved. An unknown error has occurred.
The file in the Sai Rel File field was unable to be uploaded.

If I try with a 100mb .zip file I am able to upload. My maximum upload file size is 1800MB, upload_max_filesize=1600MB and post_max_size=1600 MB.
Did anybody face a situation like this? Any solution for this?


texts: Can I edit theme CSS without FTP access to the files?

texts: Can I edit Drupal theme CSS files with out the ability to download/upload css files using FTP?


texts: Entering views result to field through rules

texts: When I create a new OG, I would like the user with the least number of OG subscriptions automatically to be added to this group. So I created a views block where I count and least the user with the least number of OG subscriptions. Under actions, there is an option named subscribe user to group. Is there a way for me to use the views result in data selector of this action? Otherwise, how would you tackle this issue.


texts: Change entity reference field widget type based on role?

texts:
EDIT: See the original post below for context. I think I've figured out how to target the field's widget, and to do this based on the admin role, but the module doesn't seem to be recognizing the widget type for some reason. The reason I say this is that when the module is enabled, the targeted field disappears in the node edit form. I figure this means it's getting targeted correctly, but can't define how to display itself. I think this might be because the autocomplete widget is defined by the Entity Reference module itself, and not by Core. Do I have to tell the module where to find this widget type? Or is there another reason that this might be happening?

<?php

//Assign role that will be affected by the module
if(user_access('administer')) {
  function entityreference_widget_field_widget_properties_alter(&$widget, $context) {
    // Change entityreference widget
    $field = $context['field'];
    if ($context['entity_type'] == 'node' && $field['field_name'] == 'field_review_band') {
      $widget['type'] = 'entityreference_autocomplete';
    }
  }
}

ORIGINAL POST: I have an entity reference field that I'm using in a "Review" content type. When users create a "Review", they are given options for this field in a select list based on Bands (another content type) that they have created. If a submitted review needs to be moderated, then an admin must go in and edit the "Review". When the review is edited by an admin, I need the band field to stay the same as it was when originally submitted. However, because of the nature of the how the options for the field are populated, the only options that appear when editing as an admin are "Bands" created by the admin user.

There is a second widget type that can be chosen for the entity reference field, which is autocomplete. Is there a way that I can change the widget type from "select list" to "autocomplete" only when the content is being edited by an administrator? This way, users still have the select list for their bands, and administrators are not limited to only their bands. Otherwise, is there a way to that I can leave this specific field unaltered when editing the content?


texts: Create view of members inherited from OG Subgroups

texts:
I have the following OG Structure:

  Organisation (group)

    Property (subgroup)

      Claim (subgroup content)

I would like to be able to list all the group members of a property, including inherited members. The 'OG Extras group members' view is similar to what I need. It produces a list of users who are members of an Organisation as expected:

However when in a subgroup the view does not show the inherited users:

The users have been inherited correctly by the subgroup as they are shown when you choose the 'group' tab and then click 'people':

Could you please suggest how I can create a view which shows inherited users?


texts: Dynamically populate one select based on another

texts:
I'm new to Drupal and well aware this question has been asked before, but I couldn't find a situation similar to mine, or maybe I didn't understand it.

I have three content types:

Team with fields Team Name.
Game with fields Team 1 and Team 2, an entity reference to the Team content.
Vid content type which has a select box for games (entity reference) which I'm able to populate.

On selection of game, the teams (Team 1 and Team 2) should be populated in the select box of another field say Pass.

One game can have two teams, several teams exist and each team can be involved in different games.

I've tried the hierarchical select module, conditional select, entity reference limit option, creating views and populating the entity reference, and tried Rules as well, but either I couldn't work through it or couldn't find the right setup.

Can someone point me in the right direction to solve this problem?


texts:
I'm a very beginner in drupal and I just want to add a css file to my custom theme.

So I created a upjv.libraries.yml in themes/upjv and I added :

global-styling:
version: '8.4.4'
css:
   theme:
       css/styles-upjv.css: {}

And I have created a styles-upjv.css in themes/upjv/css. On my index page, my file isn't loaded and I don't know if it's because I created the file in a wrong place, if the content of my libraries.yml is correct. Can anyone help me on this little problem please ?


texts: Why would a (working) theme function defined in nodequeue module not be registered in theme registry?

texts:
Trying to overide a  theme function defined in nodequeue  from another custom module:

/**
 * Implements hook_theme().
 */
function nodequeue_theme() {
  return array(
       'nodequeue_arrange_subqueue_form_table' => array(
      'render element' => 'form',
    ),
  );
}

/**
 * Theme the subqueue overview as a sortable list.
 *
 * @ingroup themeable
 */
function theme_nodequeue_arrange_subqueue_form_table($variables) {
  $form = $variables['form'];
  // Build output snipped for clarity...
  $output = 'bunch of code';

 return $output;
}

I was expecting to use theme_registry_alter but upon doing a var_dump of $theme_registry in the alter hook (after cache was flushed), it seems the function is not registered. Did I miss something?


texts: How do I programmatically create a view in a custom module?

texts:
I currently have a custom module that lets you create an entity.  The list page for this has gotten to be really long so I decided to create a view for this to allow filtering.  If this were a new module that I was about to install then I could just throw the .yml file into config/staging, but since it has to be done as an update I cannot just put the .yml file there.

It looks like it needs to be created all in code in an update hook.

Is there an easier way of doing this?


texts: How do I add default values to a database table using hook_install()?

texts:
I am creating a custom module with its own schema of a few tables. These tables need to have some values pre-populated into them for the module to work (default locations, select options, etc).

What's the best practices way to insert default values into these tables during hook_install?

Since drupal_write_record is not available, I can use db_query, but I just want to make sure that I'm not breaking any cardinal rules by doing so.


texts: Creating section with static image and text with dynamic link

texts:
I want to create a section with a static image and text but with a dynamic link and place it in one content type in Drupal 8. What would be the best way to approach this? Every approach seems to have some problem.

If I try using views to make a block and use the default values to populate the static content, the default value of the text field is not shown while default image and dynamic link are displayed.

Another approach I tried is to create a custom block, override its template with static images and text but getting the dynamic links to this block is a problem as I don't know how to access the current node fields in such block.

Is there any way to make the default value of a text field that we create in our content type to be printed through a view? Or in the alternative how would I access the node fields (specifically a link field) in a custom block?

Also, any other approach will be appreciated. I have no experience of working with the .theme file and don't really know the ins and outs of that.


texts:
My theme is adding the following CSS below. How can I remove it? I know that with Drupal 6 you can do stylesheets[all][] = in the .info file but what about Drupal 7? Can hook_css_alter() be used on an external file?

<link type="text/css" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" media="all" />


texts:
I'm using the media module to build an imagebank.
Is there a way to customize the url of a file? Currently is looks like this: file/20 and I would like t to look like this imagebank/image/20.

Any ideas?

thx in advance


texts: Why subscribe/unsubscribe button in the custom entity named group cannot appear?

texts:
I have created a custom render in group_module.js exactly as the example Rendering Entities with the exception of the line items['group/%'] = { instead of items['team/%'] = {. All other content nodes but group nodes (group/%) show ok. Group nodes show no subscribe/unsubscribe button and no menu tabs mentioned below in the groups_menu_module.js. I suppose that this module, groups_menu_module.js, is not loaded somehow.
I have to mention that without the custom rendering of entity group and with 2 LOCAL_TASK_MENU menu tabs, everything works perfect.

groups_menu_module.js

function groups_menu_module_menu() {
  try {
    var items = {};
    items['group/%']={
      title: 'view',
      page_callback: 'drupalgap_get_entity',
      page_arguments: ['groups_menu_module_default_page', 'node', 1]
    };
    items['group/%/provoli'] = {
      title: 'view',
      type: 'MENU_DEFAULT_LOCAL_TASK'
    };
    items['group/%/melh'] = {
      title: 'members',
      type: 'MENU_LOCAL_TASK',
      page_callback: 'groups_menu_module_melh_page',
      page_arguments: [1],
      title_callback: 'groups_menu_module_melh_page_title',
      title_arguments: [1],
      access_callback: 'groups_menu_module_page_access',
      access_arguments: [1],
      options: {
        reloadPage: true
      }
    };
    items['group/%/anarthseis'] = {
      title: 'posts',
      type: 'MENU_LOCAL_TASK',
      page_callback: 'groups_menu_module_anarthseis_page',
      page_arguments: [1],
      access_callback: 'groups_menu_module_page_access',
      access_arguments: [1],
      options: {
        reloadPage: true
      }
    };
    return items;
  }
  catch (error) {
    console.log('groups_menu_module_menu - ' + error);
  }
}

function groups_menu_module_default_page(node) {
  try {
    var content = {};
    content['title'] = { markup: node.title };
    return content;
  }
  catch (error) {
    console.log('groups_menu_module_default_page - ' + error);
  }
}

I have to mention that all functions needed are present in the actual .js file, i just opted them out because i think they are irrelevant.
The pageshow function of the other module is as the example in the above link:

group_module.js

function example_team_pageshow(nid) {
  node_load(nid, {
    success: function(node) {
      var content = node.title; // Add other content here...
      $('#' + example_team_container_id(nid)).html(content).trigger('create');
    }
  });
}

So to conclude the question is how to make the subscribe/unsubscribe button appear in the custom entity render? How to call og_ui_field_formatter_view() from my module to make the button appear?

I don't know if i made my self clear what is needed. If anyone need more information please ask so in the comments below to clarify some points.


texts: Unable to upload files. Though the maximum file size limit is 80 MB, can't upload even 50 kb files

texts:
I copied a site from localhost to AWS server. I can easily upload files in localhost but when I try uploading in the live site it gives me the error

"An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (80 MB) that this server supports."

In php.ini and .htaccess and settings.php I have changed upload_max_filesize to 80MB and post_max_size to 164 MB.

And according to this link, , I also disabled mod_security module in apache.

Here  it says, this could be AJAX/Jquery error.

Is there something else that could be the cause for this error?


texts: How do I set cron using performance page?

texts:
I am not able to set up the performance setting for cron duration, and automatic cache clearing setting in admin performance page.

I am not able to find the exact issue. I am clearing the cache manually everyday currently.

Can anyone provide better solution for this?

I changed the settings, and clicked on the save button of the form,but settings are not saved. This happen with both cron and cache duration settings.


texts: Order item with persistent custom field value

texts:
Goal
With Drupal Commerce, my goal is to have a customizable product with persistent user entered text.
I have added a text field to the order item type and I can see the custom field in the "add to cart" form. When customer enters a value in that field and adds the product to the cart, I can see the value of that field in the cart form view.
I want to have a link to the purchased entity in the cart form view so I checked "Link label to the referenced entity" in the view field configuration.
When I hit that link, I get back to my product page, with the correct variation selected, but the custom text field will be empty.
Question
How can I make this custom text field persistent, that is, "save" its value so that when I click the item link in the cart view, I get back to the product variation with the custom text field already filled in?
Note: I could have multiple products/variations in the cart, each with a different custom text so I need to keep the value on the order item level.
What I have tried
I thought about having that custom text field value as a parameter in the cart form view purchased entity link URL so I tried to rewrite the output of that field/link, but I don't have access to the product entity from that view and I'd need it to compute the new URL... so that won't work.
Any idea?


texts:
In my content type there is a file field; when I upload files, it creates a file path like sites/default/files/uploaded_file.zip.
Is there a way to change this path to something like dl.example.com/uploaded_file.zip? I checked the PathAuto module, but it doesn't seem to have this feature.


texts: ImageCache or different CCK image fields?

texts:
I'm setting up a website with lots of different image presets (probably up to five or six), so basically depending what page and what view my story teasers end up in they will have different dimensions, however, the web publishers need to have as much control as possible over the way the photos are cropped and resized. Is it better to use ImageCache or have different CCK image fields and have the publishers crop the images to their liking in an external image editor such as photoshop and then upload all of the presets to Drupal so the story can automatically display the right preset depending on what page and view displays it?

Also, is it possible to set up different presets for ImageCache depending on which view displays the image? Finally, it doesn't seem to me that imagecache offers cropping functionality per se. Am I correct?


texts: How to mark related entities as dirty in search api module when edited?

texts:
I am using Drupal 7 with the search api. I understand that one of the 'common pitfalls' of the search api is 'Changes in related entities don't lead to re-indexing'. I am bringing in a field called 'Collection Reference' in my search api index as 'type = content' . So when the title of a collection changes the search API doesn't realise it has changed.
I have tried to sort this using the rules module as discussed - https://www.drupal.org/docs/7/modules/search-api/getting-started/common-pitfalls#indirect-changes - but I have not been able to get it working. Has anybody had any luck with this technique? Or another programmatical approach?


texts: Paragraphs: referenced entity error on save

texts:
I recently updated to Drupal 8.6.2 and Paragraphs 8.x-1.3.

I have a content type with a Paragraphs field. When I try to update an existing node I get the following error message:

The referenced entity (user: 21) does not exist.

The existing paragraphs do not reference users directly.
User 21 does not exist.
User 21 is not the node author.
I can only update the node if delete all of the paragraphs, of every type.
There are no pending db updates or entity updates.

My feeling is that something didn't update correctly, but I'm not sure how to check / rerun the updates. (There were a number of updates to be run when I deployed the 8.6.2 update.)

UPDATE: I rolled back to the previous release and DB state, and I still get the error (which no one noticed), so it is not related to the update.

UPDATE 2: Ticket on drupal.org


texts: Taxonomy Menu Associated with a single content type

texts:
I have a single Taxonomy used for all Content Types in the site.  I have one Content Type called "Books" for which I'd like to build a Taxonomy Menu for just this content type.  As I looked through Taxonomy Menu for Drupal 6, I saw a note that indicated it had some association with views.

Is it possible to use a view to let Taxonomy Menu build a view of terms from with the count of "Books" in each?


texts: Organic Groups (7.23) and D7 | drush or cmdline integration?

texts: Just wondering how to manage OG in D7 from command line oder drush. OG seems frequently used so I'm surprised not to see any method to manage OG from shell, e.g. like create, modify Ogroups... As far as I know there were some former OG-DRUSH integrations in D6 but not in D7. Someone pointed out that the 'feature' module might be a solution (as part of the installation?). Anybody there who's willing to share his knowledge or give some information?


texts: How can I upload bulk images as separate nodes in drupal 8?

texts:
I have a folder of images I am trying to bulk upload. As they will be used in galleries that can be filtered by year and location I was hoping to make them individual nodes with year and location fields that the bulk upload would fill in with a preset on each upload batch.

I've played with the media entity module and managed to upload a group of images as a single media entity but I don't really want the files grouped.

Is there a way to do this in D8 yet?
I'm fairly new to D8 so am not too sure of how things work yet.


texts:
We use Profile2 and Node Access but the profiles of users can't be show by everyone (access denied)  since we have installed Node Access. The problem is the same with Content Access.
Do you know how we can see profile of users and use Node Access or Content Access ( we want to limit access on pages of our intranet's ?
Thank you.


texts: I use jQuery to alter the exposed form select options. Got error: "An illegal choice has been detected." How to bypass validation?

texts:
I have a view that has three expose filters (Manufacturer, Type, Model), three options list (term reference to Printer vocabulary) .

Vocabulary: Printer (3 levels)

-- HP
---- xxx
------ xxxx
-- Apple
---- xxxx
------ xxxxxx
-- Dell
---- xxxx
------- xxxxx
-- ...
-- ...
(thousands of terms)

Since Form API AJAX doesn't work on views expose form, I am unable to make the them dependent select for exposed form fields. So I used jQuery to make the exposed form fields "dependent select / cascading select".

Basically, I empty all the options in views_exposed_form_alter() firstly:

$form['manufacturer_id']['#options'] = $form['type_id']['#options'] = $form['model_id']['#options'] = array();

then populate the option lists with my jQuery code accordingly.

However I get "An illegal choice has been detected." on page load, and form submit.
Form submission is prevented due to Drupal form validation mechanism .

It's the form validation detect the options generated by jQuery are not come with the original form data, as I removed the options in form alter. Value of a select box is not present in its defined options .

So I tried to remove form validation in form alter as:

unset($form['#validate']);

still doesn't work, the illegal choice error remains.

============ UPDATED =================

Inspired by @kiamlaluno 's answer below, the only solution I came up is hack/patch the core.
Here is what I done:

Edited /includes/form.inc : (line 2014)

I removed the code:

$element['#needs_validation'] = TRUE;

and added:

// if not these fields, mark for validation as usual.
// so if are these fields, validation will be passed.

if ($element['#name'] != 'manufacturer_id'  &&
    $element['#name'] != 'type_id'          &&
    $element['#name'] != 'model_id' ) {

  $element['#needs_validation'] = TRUE;
}

It works, the exposed form select option bypassed the validation.

But my solution is very ugly which modified the core.

I wonder if there is any other solution without touching the core?
How can I bypass the validation of these exposed form fields?

Thanks!


texts:
I am attempting to create a view that displays Content by it's current Workflow state.

I cannot see how this is possible using the Views module combined with the Workflow module.

Can you advise?


texts: How do I set filters to reset automatically on new search?

texts: I have a search and some filters on a drupal 7 site. If I search a term, for example "stuff", and there are 30 results, I can click a checkbox filter (let's call it FilterA) on the side and narrow my results down. But now if I type "things" in the search bar and submit it, FilterA is still clicked when the results come up. I need for all the filters to be unchecked when I perform a new search. I've gone through I feel every setting in the view and all the search and filter settings and still nothing. Thank you for any help you can provide.


texts:
I'm trying to write a custom message to my log (viewable at /admin/reports/dblog) using the watchdog function.

function create_vector_user_mail($key, &$message, $params) {
   watchdog("VECTOR", "inside user mail", array(), WATCHDOG_INFO);
   /* other stuff */
}

I have the core database logging module enabled, and the log is set to display all messages. But this message isn't getting saved to the log. I've used a standard php error_log just to make sure the create_vector_user_mail function is running, and it is. I copied the watchdog line from another contrib module that does print its messages correctly. What am I doing wrong?


texts: State field in address module not populating with geocoder module

texts:
I added a plain text field to user profiles that expects a zip code. I also have an address field that is hidden on user profiles.
I setup the address field to geocode from the zip code field. It's partly working as it fills out the city and zip code. The state select doesn't seem to get set. I am using the google maps api as my provider.
If it makes a difference, I did not set a "region code for region biasing". I am using the latest version of address (8.x-1.9) and geocoder (8.x-3.17).
Any ideas?
edit I wanted to update that when I output the address field on the user profile page, the state is present. Its just not selected in the form display.


texts: Is there a way to disable the js of the Views Display Tabs module without hacking the module?

texts: I'm using Views Display Tabs module and it works really well. My problem is that I'm using Views exposed filters as a block. When I switch between tabs the filters don't get updated because they are in a  block and the module uses js to switch between tabs, so the page doesn't get refreshed. I would like to know a way to disable the js functionality of the module without hacking it. Ideally the module would have a setting for this.


texts:
We load a specific node in our template.php file via node_load(), in the same way <?php if ($content = render($page['content'])): ?> is used for loading a block.

I have a content type (news), and I want to load this content type items on my template.php file. How can I do it?


texts: On drupal main page menu, number after /node/7/1

texts:
i am starting to learn drupal right now. I downloaded a template and I am trying to figure out where are all the components are stored.

I encountered a problem where on the menu for website,  there are different submenu items under that menu. and one of the items has URL like this: www.example.com/node/7/1, another item URL like this: www.example.com/node/7/2, the list goes on, like www.example.com/node/7/3. When I click on any of those link, it brings me to the same page, however the representation is different.

I am able to find node 7 in the content, however i am not able to find how to configure the number after /node/7. Can somebody tell me what does that number means? Thank you very much and have a great day.


texts: Ajax popop on panels flexible sider not working correctly

texts:
I am trying to create a custom layout using the Panels flexible layout designer. When I try clicking on, for example, Row -> Add region to left, the modal popup pops up, but I get dialog box from my browser saying:

The requested page can not be found.

and then the ajax loading symbol stays like that forever, never loading the content into the layout designer modal box. This is the url its trying to reach:

http://[site-name]/admin/structure/pages/nojs/operation/page-front_page/handlers/page_front_page_panel_context/layout/move

Why am I having this issue? Is this something I should put on the Panels issue page, or is there something I can test to see if its wrong on my side? I don't see any javascript errors in the console, and don't see any issues in the network tab with the ajax call.


texts: What items in the DB do I need to edit when switching from a multisite to a single site?

texts:
I've copied a single site from a live multisite setup to my local (MAMP) server. The content is showing from the site however it is unstyled (and also the home page is showing the 404 page). I assume there's some changes I need to make to the DB to fix this and allow the site to function correctly.

I'm running version 6.22


texts: How to use Drush's concurrent execution capability?

texts:
I am using Drupal multi-sites (single codebase, multiple sites/*). Along with this, I have started using Drush aliases to manage them:

$ cat sites/all/drush/aliases.drushrc.php
<?php
$aliases['localdev'] = array(
  'site-list' => array(
    'site1',
    'site2',
    'site3',
  ),
);
?>

This allows me to easily perform actions on all sites:

$ drush @localdev cc all

>> I've also just discovered that I can just use @sites, and forgo the drushrc file.

Doing this, will execute "cc all" on each of my sites in series (one at a time).

I'd like to take this to the next level and try to run these commands on all sites simulantiously. I've been doing some reading, and am under the impression that Drush does indeed support this. The drush_invoke_process() function takes $backend_options, which can contain (from function documentation):

 *      'invoke-multiple'
 *        If $site_alias_record represents a single site, then 'invoke-multiple'
 *        will cause the _same_ command with the _same_ arguments and options
 *        to be invoked concurrently (e.g. for running concurrent batch processes).
 *      'concurrency'
 *        Limits the number of concurrent processes that will run at the same time.
 *        Defaults to '4'.

What I can't figure out, however, is how do I actually use this from the Drush command line. Is there an option I need to pass to Drush, or do I need to set something in a settings file?

Any info will be much appreciated - my curiosity is piqued!

UPDATE

Based on the answers below, I was able to create a simple test that demonstrates Drush's behaviour, and draw some conclusions:

Drush's default behaviour when executing operations on multiple sites is to use concurrent processes:

$ drush @localdev ev "drupal_set_message(time()); sleep(5);"

Continue?  (y/n): y
site1             >> 1360512943      [status]
site2             >> 1360512943      [status]
site3             >> 1360512943      [status]

This is true even when not using aliases, and is also true when using Drush's built-in @sites alias. These two commands yield identical behaviour as above:

$ drush site1,site2,site3 ev "drupal_set_message(time()); sleep(5);"
$ drush @sites ev "drupal_set_message(time()); sleep(5);"

To change the number of concurrent processes (default is 4), the '--concurrency=N' option can be passed in the drush command. For example, if I want serial execution, I can set the number of concurrent processes to 1:

$ drush @localdev ev "drupal_set_message(time()); sleep(5);" --concurrency=1

Continue?  (y/n): y
site1             >> 1360513387      [status]
site2             >> 1360513393      [status]
site3             >> 1360513399      [status]


texts: Restrict taxonomy terms when users edit content?

texts:
I've implemented my site's structure by creating a taxonomy for "areas" and making a term for each area I want in my site (guest info, newbie, facilities, news, and admin). I've let the main menu show these terms as menu items, so that each item shows the content of the corresponding area. When I add content, I specify which area it's for, and this works quite well.

Now, though, I would like to introduce a content type for users to create (for a "user-to-user" area) and I want to hard-code this content type to a specific taxonomy term.

If I leave out the field for this taxonomy, no term will be assigned. :-/
If I include the field for this taxonomy, the user can choose a term (and put the page in any area). :-/
It doesn't look like term assignment is something that can be done with Actions and Triggers. :-/

Is there perhaps a module that provides control over what terms are available for a given situation (user/role/content type)? I've googled, but all I can find is acces control modules for users and nodes, not taxonomy terms.

Edit: To be clear, I'd like to EITHER programmatically set a particular term of a particular vocabulary every time a user of a particular role saves a node of a particular type (but without me having to do PHP programming); OR allow users of a particular role access to only a subset of a particular vocabulary.

Help! :-)


texts: Problem updating from Drupal Core 8.3.7 to 8.4.0 with composer

texts:
I am having trouble updating from Drupal 8.3.7.

When running composer why-not drupal/core 8.4.0 I get the following results:

drupal/core 8.4.0 requires symfony/class-loader (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/class-loader (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/console (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/console (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/dependency-injection (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/dependency-injection (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/event-dispatcher (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/event-dispatcher (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/http-foundation (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/http-foundation (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/http-kernel (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/http-kernel (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/process (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/process (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/routing (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/routing (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/serializer (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/serializer (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/translation (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/translation (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/validator (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/validator (but v2.8.28 is installed)
drupal/core 8.4.0 requires symfony/yaml (~3.2.8)
andeersg/bouvet-d8-project dev-Stinis does not require symfony/yaml (but v2.8.28 is installed)

Trying to update one of the mentioned packages just results in composer telling me I can't because Drupal 8.3.7 needs a lower version. So I can't update the packages and I can't update Drupal. Am I stuck in a catch22?

Does anybody know what the problem might be? When I run composer update drupal/core --with-dependencies it says that everything is up to date even though it is still at 8.3.7.


texts: How to include jquery from URL in custom module?

texts:
I've got a question about module building and including JS.
I'm working on a D6 custom module, and for JS files I'm including from within my mod
    drupal_add_js(drupal_get_path('module', 'ingsavingsmap') .'/js/effects.js');
works just fine.

The question I have is: I'm trying to include jquery from the jquery site.
I know:
    drupal_add_js(drupal_get_path('module', 'ingsavingsmap') .'http://code.jquery.com/jquery-        latest.js');

is very wrong for a number of reasons, but I don't know how to go about adding JS from a URL.
Also, is it advisable to event be doing it this way? or should I just keep it all within the mod.

Any help or direction to documentation would be appreciate
Thanks!
Steph


texts: Is using Views overkill to display a single image above the footer of all pages on my site?

texts:
I would like to add a banner type image above the footer. I'd like it to be present on every page. Would adding a gallery, and then creating a block using Views be overkill for just a single image?
Should I just include it as a block and then add the image via the ckeditor? Or should I add a content type and field specific for this block/image?


texts:
I'm trying to find how to get the latest version release -number- of Drupal, not actually download it. I appreciate that I can read the contents of the ftp projects page then selectively pick out latest, but I wondered if there was an easier way of doing it.

The reason I'm looking is for an external (non-drupal) page I'm writing that gives current versions of the server's current drupal installations, and whether they're up to date or need to be upgraded - that's why I don't want to actually do a wget of the tarball.


texts: How do I alter a form using an AJAX callback?

texts:
I have this callback function triggered by an onChange() event in another select box.
This code, however, doesn't make the field enabled

public static function changeForm(array &$form, FormStateInterface $form_state) : array {
  $form['field_my_custom_field']['#disabled'] = FALSE;
  return $form;
}

What am I doing wrong?


texts:
The following code is a snippet from the examples for developers project:

    function form_example_tutorial_9_add_name($form, &$form_state) {
        // Everything in $form_state is persistent, so we'll just use
        // $form_state['add_name']

        $form_state['num_names']++;

        // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
        $form_state['rebuild'] = TRUE;
    }

    function form_example_tutorial_9_remove_name($form, &$form_state) {
      if ($form_state['num_names'] > 1) {
        $form_state['num_names']--;
      }

      // Setting $form_state['rebuild'] = TRUE causes the form to be rebuilt again.
      $form_state['rebuild'] = TRUE;
    }

    /**
     * Validate function for form_example_tutorial_9().
     *
     * Adds logic to validate the form to check the validity of the new fields,
     * if they exist.
     */
    function form_example_tutorial_9_validate($form, &$form_state) {

      for ($i = 1; $i <= $form_state['num_names']; $i++) {
        $year_of_birth = $form_state['values']['name'][$i]['year_of_birth'];

        if ($year_of_birth && ($year_of_birth < 1900 || $year_of_birth > 2000)) {
          form_set_error("name][$i][year_of_birth", t('Enter a year between 1900 and 2000.'));
        }
      }
    }

    /**
     * Submit function for form_example_tutorial_9().
     */
    function form_example_tutorial_9_submit($form, &$form_state) {
      $output = t("Form 9 has been submitted.");
      for ($i = 1; $i <= $form_state['num_names']; $i++) {
        $output .= t("@num: @first @last (@date)... ", array('@num' => $i, '@first' => $form_state['values']['name'][$i]['first'],
          '@last' =>  $form_state['values']['name'][$i]['last'], '@date' =>  $form_state['values']['name'][$i]['year_of_birth']));
      }
      drupal_set_message($output);
    }

I've been trying to implement field with an "Add More" button (and "Remove Previous" button if more then one field exists) into theme-settings.php based off of the above code, however I'm not having much luck. Does anyone know how to create this functionality within THEMENAME_form_system_theme_settings_alter? Any help is greatly appreciated. :)


texts: How to redirect the user to an external website with POST data?

texts:
I want to implement an offsite payment method and everything is going well except the fact that I can't find how to redirect the user to the offsite payment gateway after submitting the cart checkout review

When the user submits the checkout review, the orderSubmit function is called. Inside this function I create the array with all the parameters required in the request, but I don't know how to send this request

public function orderSubmit(OrderInterface $order) {
    $fields = array(
      'version' => $this->configuration['version'],
      'TPE' => $this->configuration['tpe'],
      'date' => date('d/m/Y:H:i:s', time()),
      'montant' => round($order->getTotal(), 2).\Drupal::state()->get('uc_currency_code', 'USD'),
      'reference' => $order->id(),
      'texte-libre' => md5(uniqid(rand(), TRUE)),
      'mail' => $order->getEmail(),
      'lgue' => 'FR',
      'societe' => $this->configuration['company'],
      'url_retour' => Url::fromRoute('uc_cmic.cancel', array('absolute' => TRUE)),
      'url_retour_ok' => Url::fromRoute('uc_cmic.success', array('absolute' => TRUE)),
      'url_retour_err' => Url::fromRoute('uc_cmic.return', array('absolute' => TRUE)),
      'MAC' => "",
      'options' => ""
    );
    $fields = uc_cmcic_complete_request($this->configuration['security_key'], $fields); // This function fills the 'MAC' key by using the security key
    $host = UC_CMCIC_URL_CM_TEST;

//TODO send the request and redirect the user to the offsite payment gateway here
  }

What I tried to do and didn't work :

$response = \Drupal::httpClient()->request('POST', $host, [
  'form_params' => $fields,
]);

I tried some other variations of this too (like returning the $response after), which didn't work either

Question : What can I do to redirect the user to the offsite payment gateway while sending POST data in the request ?


texts:
I have a simple block that is used in the footer of a multiple language website. The text in the block changes based on user language so I using the following render attributes, which seems to work well.

$render['#cache'] = [ 'contexts' => ['languages'] ];

This block contains an image that is included with the following:

if( (date('Y') %2) == 1)
  $markup = '';
else
  $markup = '';

One image is used for even numbered years and a second image is used for odd numbered years.

What is the correct way to setup caching base on this image changing once per year?

I have a similar situation with the home page of the website which changes each day.  My current plan is to clear all caching levels for the website early each morning just after mid-night.  This includes the Drupal caches, memcached and AWS Cloudfront. For pages like the home page, which change daily, I will need to keep max-age short to limit caching in the user's browser.

Is there any better way?


texts: UC Orders and Webfrom Submissions in same view

texts:
Does anyone know a method to create a view with both 'UC Orders' and 'Webform Submissions'?
I am using 'UC webfrom pane' to collect some extra info on checkout but am really struggling to add this data to a view with order data.

What would be a possible way to do this? Help is much appreciated.


texts: How can we apply filter in view for a content type by start date-time and end date-time?

texts:
I want to show the latest exam on a tablet based notice board. I am using Drupal 7.

For this I need to show an item from a content type called Exams which has a start date and end date with time. After the time ends I need to show the next item if there any.

We can apply start date and end date filter, but I want to check the time also.

For e.g.

  An exam starts on 28/01/2015 10:00 am and ends on 28/01/2015 11:30 am.
  If I will add another exam starts at 12:30 pm at the same day after the
  first exam I need to show the second one automatically.

How can I accomplish this condition ? Seeking the help from Drupal experts.


texts: Commerce Price: Hide formatted amount if empty

texts:
I have a view with a regular commerce price and a discounted one. When using the Raw amounts everything works fine but when I use the formatted ones the hide if empty, Count the number 0 as empty and Hide rewrite if empty even though they are checked the amount of 0,00€ is shown!

What can I do to hide it?


texts:
Is it possible to render Swagger UI output in Drupal? I'd like something similar to this example in the content area of a page:
http://petstore.swagger.io/

I've tried two "in progress" modules without much luck (mmillford's Swagger module and the tpanagos SwaggerUI module). Both are producing no output (blank pages) when following the included instructions.


texts: How do I test a CKEditor text format field with Behat/Mink?

texts:
I am using an @javascript test in Behat on CircleCI to check my Drupal 8 site.
When I use the standard I fill in "my field" with "value" step, it works for fields with the plain text format, but it fails for fields that use CKEditor.
How can I fill in fields on CKEditor?


texts: Creating a Paragraph type programmatically

texts:
I have a custom module that is installed on a number of sites. In an hook_update_n function I would like to add a completely new Paragraph type (not actual instance of a Paragraph) to every site, using the same configuration.

Adding or updating fields to an existing type is well documented, but I can't find out how to create an actual type (node or paragraph) programmatically.


texts:
I'm trying to get this: http://jsfiddle.net/SgHJ5/
to work in Drupal 7.

For some reason, when I paste it into my front--page.tpl (footer) it doesnt work.

I've also tried including a JS file into my template.php.


texts: Trying to enable clean URLs: The clean URL test failed

texts:
I am trying to follow this document to enable clean urls on a fresh Drupal installation. When I run the test, I get:

The clean URL test failed.

My host provider confirms that mod_rewrite is enabled. I am using a shared server.

In my Drupal installation folder, I see a hidden .htaccess.txt file. Apparently, it has been installed by Drupal itself.

But, I cannot find information in the document mentioned above explaining to solve this issue. What is missing to make Clean URLs work? Thanks.


texts: Is it possible to return form, themes, content in an array for my page callback function?

texts:
For right now I need to return a themed table, a form, & content on one page. In my page callback function how do I properly store and return this variable/array?

I looked at the page below, but the code did not seem to work properly. I can only get the themed table (first in array) to show, but nothing else after it.

Return both a form and content in a menu callback

EDIT:

i tried the code below for my return, but it doesn't work. $header & $rows are both properly declared and holding the right data.

return array(
  'my_content' => array(
    '#type' => 'markup',
    '#markup' => 'Some markup',
  ),
  'my_table' => theme('table', array('header' => $header, 'rows' => $rows)),
);


texts:
Ive put this code before the closing head tag in my html.tpl.php but nothing is happening. Im using the zen theme. Ive tried clearing my cache.

Im I somehow missing a syntax error or is this a Zen/ Drupal qwerk?

<script>
    $(document).ready(function() {
        alert('hi');
    });
</script>

</head>


texts: Advice for reference the same image for several nodes?

texts: I need to show the same image for a several nodes. I have uploaded the image to the server. But, I am not sure how to accomplish or reference this using the image field. Do you have any experience that you can share it? or any other way that I can do this?


texts: Webform adding custom component or modify radio buttons

texts: I need to make a webform that will display the radio buttons like this jsfiddle, where the label is above the radio button. Do I need to make a new webform component to achieve this or can I just modify the default to add the div and change orientation?


texts:
I wanted to add script code to implement "LiveChat" functionality on just three pages of our website. So, I wanted to add one script code given by our LiveChat agency into three webpages of our website.

Script Code

So, I have created three separate html node templates based on their node ID.

Theses three custom node templates are under

/sites/all/themes/mytheme/templates along with (node.tpl.php and html.tpl.php)

(contact page) html--node--28.tpl.php

Url of this page: www.example.com/contact

(admissions page) html--node--1212.tpl.php

Url of this page: www.example.com/admissions

(market page) html--node--378.tpl.php

Url of this page: www.example.com/market

Code used in all custom node templates (html--node--28.tpl.php, html--node--1212.tpl.php, html--node--378.tpl.php) is the same:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"<?php print $rdf_namespaces; ?>>
<head profile="<?php print $grddl_profile; ?>">
  <?php print $head; ?>
  <title><?php print $head_title; ?></title>
  <?php print $styles; ?>

<body<?php print $attributes;?>>
<?php print $scripts; ?>
//Adding script for LiveChat

    <?php print t('Skip to main content'); ?>

  <?php print $page_top; ?>
  <?php print $page; ?>
  <?php print $page_bottom; ?>

But, I am not able to see my script () when I debugged it in view pagesource.

Thanks!


texts: How to create an EMPTY anchor-only link with l()?

texts: I'm trying to use l() to get something like , for ajax-calling purposes.  https://stackoverflow.com/questions/1698453/drupal-creating-anchor-only-link-with-l is very close to the right thing -- use an option in l() like 'fragment' => 'foo' to produce a link like  -- but I'm trying to get a clean '#'.  Is there any way to do this, or should I just put something in as part of the fragment and not worry about it?


texts: How can I change the login URL for administrators?

texts:
Is it possible to change the login URL for administrators, and use it only for them?

If another user comes, and logs in on www.example.com/admin, the system doesn't allow this.
If an administrator uses the normal login URL, the system doesn't allow this.


texts: Alter Entity Reference View Widget available options

texts:
I have 2 content types business, locations, programs and services.

At program level we select all the services associated with that program.

At business level we select the programs the business is associated with.

At the location level based on the programs selected we give the option to sub select the services.

Now the services entity reference is displayed via Entity Reference View Widget. All I want to do is alter or unset certain options based on the choices made at the business level in terms of program selection.

I tried working at the views level to pass it as an argument but was unsuccessful. Then tried the node form alter but the unset option still shows up but without the checkbox.

Tried to alter it using hook_field_widget_form_alter as well but was not successful.

It looks like it implements a preprocess function entityreference_view_widget_preprocess_widget but I am not able to override it.

Looking for pointers if anyone has come across similar problem.


texts: Search API Solr: How to index fulltext fields with and without stemming?

texts:
In short: Is there any way to index the stemmed and non-stemmed version of Fulltext fields in Drupal Search API Solr without resorting to hardcoding field data into copyfield in the schema file?

(and if not, what's the safest, most Drupal / Search API friendly approach to doing this? e.g. using Drupal field machine names in the Solr schema file, maybe?)

Background: A common practice when working with Apache Solr is to use a stemmer like SnowballPorterFilterFactory (stemmers make searches match by the grammatical 'stem' of a word, so for example, searches on "walking" match content with "walked"), then, to copy fulltext fields (e.g. using copyfield), stemming one of the two duplicates and not stemming the other.

This popular approach has two advantages (at the cost of more processing):

Exact matches are indexed more highly than close matches - a search on "walking" matches content with "walking" twice (stemmed and unstemmed) and content with "walked" once (stemmed only)
You're guaranteed to not have any awkward cases where a search on a stemmable term fails to match content that contains that original exact term*.

As I understand it, when Solr is used outside of Drupal, this is usually done by hardcoding <copyfield> declarations into the Solr schema file for each field that is to be stemmed.

(for the sake of this question, imagine a Search API Solr search indexing nodes, processing as fulltext the fields Title, Body, Teaser, and one custom field named Notes)

The problem: With Drupal and the Search API module's Search API Solr, the fields are configured by Drupal dynamically - rather than being hardcoded in the Solr schema.txt file. It's not clear how to make the two approaches play nicely together.

Is there a better, more Drupal-friendly way to index stemmed and unstemmed content than hard-coding the field names into something based on copyfield in the schema.txt file?

If hard-coding is the answer, what names should be used, what care needs to be taken to avoid namespace problems?

Another popular approach with Solr outside of Drupal is to create a composite field of all your fulltext fields, combined, and treat it as a string rather than fulltext - so it bypasses filters and simply mops up and boosts any words that are searched for exactly as they appear in the text. Search API has two features under Workflow that look promising for this, Aggregated fields and  Complete entity view - but (as far as I can tell) both can only index as Fulltext and would therefore be stemmed just like the regular field.

I can't see anything on this specific to Search API Solr. The closest I can see is this issue for D8 core search, but that's rather different. I can't find any information about anything like this for Search API.

**(for example, I find that with stemming, searches on 'unravelling' don't match content containing 'unravelling', but searches on 'unravel' do. It's being stemmed down to 'unravel', but for some reason it's not recognising 'unravelling' as a valid extension of the stem 'unravel'. 'Unpublished' is another example (unpublish matches, unpublished doesn't). I've seen various reports of similar language-specific stemming issues. Keeping an unstemmed copy seems to be the standard approach, but I  can't see any clean way to do this in Drupal)*

Also posted as a support issue on the Search API Solr queue (yes, cross posting like this is okay, actually encouraged to make life easier for maintainers)


texts: Using HOOK_username_alter() to hide the real username

texts:
I'm using a pattern for the username creation using the contrib module: automatic_usernames, this results in the following pattern for my use case: [hotel_name][uid]. Example: Hilton10

Here is the dilemma. This is fine for the business to see, but I do not want them to see their customer's actual username that they just created such as Hilton11 and instead I would like them to see the first name + last name of the customer.

How would I go about this using the following custom fields?

[#field_name] => field_customer_first_name

[#field_name] => field_customer_last_name

function MyCustomModule_username_alter(&$name, $account){
 global $user;
    if(in_array('venue admin', $user->roles)) {
    $name = ? //this is where im stuck
}