texts: Include third party library in custom module without composer

texts:
I have zero command line access to a remotely hosted drupal site so I'm unable to run composer. My custom module requires the ryanwinchester/hubspot-php package. Is there any way I can manually add this library to my module without having to run composer? I'm willing to do any workaround no matter how dirty or frowned upon the technique is. I am able to run composer locally so I can at least produce a vendor folder with the autoload.php included.

Could I manually include the autoload.php in my module? Is this something I could just require in every class that uses the package?


texts:
I'm running a rather large Drupal 6 site and I need to include additional information in the database, things that run independently of Drupal. Is it best to create a separate database and connect to it from the files I need to access the info from, or is it just safe to add a custom table to the Drupal database and add whatever I want in there?

Thanks!


texts:
In a content type have a field image upload.its image upload type is jpg,png,gif.
When we upload these image type of images an error is coming :

  The selected file Chrysanthemum.jpg could not be uploaded. The file is
  not a known image format.

But its running in local not in server. What is the problem ?
Please help me.
Thanks


texts: Block with entities referenced in a field from current node (of different type)

texts:
I got 2 different types  of content (Place & Event).
When an Event is created you can define Place (one or more) where this Event will happened (Place are referenced in a field in Event).

With View, I can display a block with the Event attached to the current Place. But I can't display in a block the Place of the current Event (on its page).


texts: where is the submit handler for the Drupal Commerce Review page?

texts: I need to know how the drupal Commerce review page is being created and where the submit handler is which precedes that page. I have added a couple of fields which aren't being picked up in the panes, and I want to debug in the handler (or even a review page tpl file). Where can I find this? I have looking though the code and havn't found the answer.


texts: how to give parameters in url for getting json parse for both taxonomy terms AND nodes

texts:
i created 2 nodes in Company CCK under taxonomy A, 2 nodes in Company CCk under taxonomy B. now i want to get a json parse for all the nodes in a taxonomy A.

I tried like this www.mywebsite/api/taxonomy_term?selectNodes&parameters[tid]=1 it gives the value of that taxonomy term but, i wont get nodes under that category . In what way the url  should be framed for attaining values of nodes of a particular category(taxonomy) i.e i would like to filter the nodes of my choice.

so any one help me, Thanks in advance


texts: Adding jQuery libraries using #attached library and drupal_add_js

texts:
version: drupal7.23

I have a web page include 2+ jQuery version libraries, at the page's search box, I use $form['#attached']['library'][] = array('system' => 'ui.autocomplete') to get autocomplete effect, it's works well, besides the page I mentioned at the beginning.

But when I replace #attached into drupal_add_js('/path/to/3party/autocomplete.js'), it's works well for all pages.

I've tried using $.noConflict() but still not working, can someone tell me why ?


texts:
Using Drupal 7:

I have several content types with their own sets of fields, but I also have a set of fields that they must all share in common. That is easy enough through the administrative UI, but I'm writing a module that programmatically will add the fields to all node content types that I specify. Additionally, I do not want the administrator to be able to remove or edit those fields through the administrative UI.

How can I make it so that as an administrator is managing content types that the admin cannot modify or remove these fields that I have specified?

Alternatively, I know that I can create a separate entity and force field existence that way, but then I loose access to a lot of the functionality already built into the node entity, especially the function hook_node_access which is also a requirement for this module.

Anyone have any suggestions or know how to solve this?


texts: Move only jQuery UI Tabs load in footer in Drupal 7

texts: I need jQuery UI Tabs to load after Token renders values. I see the simple method being to move jQuery UI Tabs script to the page footer. Please show me how to do this.


texts: Render page callback output in another region than "content"

texts:
I am implementing hook_menu and I want to render the output of one page callback in a certain region, other than content.

Is there a way of doing this?


texts: How do I add the page number to the page title on drupal default paginated pages?

texts:
It has been recommended by an SEO consultant that for paginated pages the page number is included in the page title to avoid duplicated content. How do I achieve this?

I did this:

    function hook_pager_link($variables){
  $text = $variables['text'];
  $page_new = $variables['page_new'];
  $element = $variables['element'];
  $parameters = $variables['parameters'];
  $attributes = $variables['attributes'];

  $page = isset($_GET['page']) ? $_GET['page'] : '';
  if ($new_page = implode(',', pager_load_array($page_new[$element], $element, explode(',', $page)))) {
    $parameters['page'] = $new_page;
  }

  $query = array();
  if (count($parameters)) {
    $query = drupal_get_query_parameters($parameters, array());
  }
  if ($query_pager = pager_get_query_parameters()) {
    $query = array_merge($query, $query_pager);
  }

  // Set each pager link title
  if (!isset($attributes['title'])) {
    static $titles = NULL;
    if (!isset($titles)) {
      $titles = array(
        t('« first') => t('Go to first page'),
        t('‹ previous') => t('Go to previous page'),
        t('next ›') => t('Go to next page'),
        t('last »') => t('Go to last page'),
      );
    }
    if (isset($titles[$text])) {
      $attributes['title'] = $titles[$text];
    }
    elseif (is_numeric($text)) {
      $attributes['title'] = t('Go to page @number', array('@number' => $text));
    }
  }

  // @todo l() cannot be used here, since it adds an 'active' class based on the
  //   path only (which is always the current path for pager links). Apparently,
  //   none of the pager links is active at any time - but it should still be
  //   possible to use l() here.
  // @see http://drupal.org/node/1410574

  //put the pagination page number into the title tag
  $attributes['href'] = url($_GET['q'], array('query' => $query));
  //add page
  $page = t('page');
  $pattern = '/' . $page . ' \d/';
  $title = drupal_get_title();
  preg_match($pattern, $title, $matches);
  if(!$matches){
    $new_title = $title . ' - ' .  t('page') . ' ' . ($page + 1);
    drupal_set_title($new_title);
    }
  return '<a' . drupal_attributes($attributes) . '>' . check_plain($text) . '</a>';
}


texts: Is is it possible to set an expiry time on the cached version of each node individually in a Drupal 6 website? The expiry time could be based on any factor.


texts: How to get menu title inside menu--main.html.twig file

texts:
I created a suggestion for menu and using menu--main-sidebar.html to render menu.

I want to include menu title (title of block added to specific region from admin side) as first child of menu

I tried to use configuration (configuration.label shows menu title in block--menu-block--main.html.twig file) like below

{{ menus.menu_links(items, attributes, menu_level, menu_name, configuration) }}

That does not work.

So, how to get the menu title inside menu_links in menu--main.html.twig file?


texts:
There is one date field = "Display-date" and my content is displaying as:

2016 | abc

2016 | def

2015 | pqr

2014 | wer

I'm applying a filter in view:

content:display-date

and set its value = 2016 so that only 2016 year content will get visible. (as shown in below screenshot) I chose time zone = UTC.

This is giving me NULL results.

How can I get only 2016 year result to get rendered?


texts:
I have created a report of each students with their paid fee invoices.

Now I would like to delete the invoices only.

Please help me out from this.


texts: how to get tinymce value in javascript?+ Drupal7

texts:
I am using drupal7 form

$form['subject'] = array('#type' => 'textfield',
        '#title' => t('Subject'),
        '#maxlength' => 200,
        '#size' => 100,
        '#required' => TRUE,
);

$form['body'] = array('#type' => 'textarea',
        '#title' => t('Body'),
        '#type' => 'text_format',
        '#base_type' => 'textarea',
        '#format' => 'full_html',
        '#required' => TRUE,

);

we used tinymce editor. Posting form with jquery like this

$.ajax({
            url: '/myevent/preview',
            data: $('#eventform').serialize(),
            type: 'POST',
            success: function(data){
                $('#eventdata').html(data);
            }
        });

At my local its working fine, but on server, I couldn't get value of body textarea.


texts: Calculate distance using Geolocation module

texts:
I'm using the drupal/Geolocation module to assign a location field to a specific content-type.

I have created a View (REST Export display) to return all the content-type entries with all the fields and it's working fine.

I'd like to calculate the distance between a sent lat/lng point and the location of each entry and sort them by distance (and also include it in the resulting JSON).

I'm already applying some changes to the JSON output using the views_post_render hook (and changing the $output variable), but I don't think in that hook I can access a query string (sent via Ajax request).

What would be the best way to pass the user's location from the website frontend to the view? Right now my bet would be sending the query parameter via an Ajax request, adding something like ?location=-17.000,19.000 to the URL.

And where could I access that data (the user's lat/lng location) and calculate the distance to pass it again to the frontend?


texts: would like to replace node contents with pdf under some conditions

texts:
I have been using hook_node_view to set the node contents depending on a bunch of things - this works well except when I need to replace the entire page with a pdf.
The hook function looks something like

function gcc_event_node_view($node, $build_mode = 'full') {
if ($node->type !== 'eventlist') {
    return;
}
if (have replacement html) {
    $node->content['body'][0]['#markup'] = "new stuff";
} else if (use pdf) {
    header('Content-type: application/pdf');
    header('Content-length: ' . filesize($fullPath));
    header('Content-Disposition: filename=' . $this->ShortName() . $file);
    readfile($fullPath);
   // need something here to make the node not render further at all
}

Appreciate all suggestions on the right way to do this.  Should be able to do images with image/jpg as well.


texts: Reducing Number of Fields in Content Type

texts:
Context:

I have a product content type on Drupal 7 with >100 fields, and there are >7000 products, all with several revisions. Our client keeps requesting that we add and remove fields, which is quite painful and takes several tries to successfully complete due to mysql having a conniption.

The go-to strategy has been to increase the RAM on the server, but we are hitting a cost wall and this bothers me as a developer since we are just deferring dealing with the problem.

Comedy Option:

The majority of these fields are specifications which are never related, filtered or displayed outside of the detail view. Could I reasonably create a JSON product_spec field that contains all of these spec fields and write custom modules to display them on the detail/spec screens, allow editing through the API, and allow editing them on the admin interface?

Is there an existing module that does something similar? Would entitycache be a much more practical option?


texts:
I'm building a library and it is possible to add books to website. I need to get uploaded file urls and display them in 'a' tag inside views page (not node). how can I do that?

unfortunately I can't use kpr() to find file properties I guess because it has lot's of outputs and it prevents the page from loading (var_dump does the same thing)

I also tested this function to print the file size but it failed

function MYT-HEME_file_link(&$variables) {
$file = $variables['file'];
print $file->getsize();
}


texts: How to redirect form action to external link after getting form feild value after theming of a external html page

texts:
I have enabled a .tpl.php file in theme in drupal 7 which contain a form field. So my requirement is to redirect the from field action to another external link after getting value from that from field. The form field value i.e  is used in external link redirection.
Please help me how can i redirect the form action with getting value from that single field.


texts:
So it's my first time using entityform module which is awesome to create an order form.

Within my form, I have an "Entity Reference" field which prepoppulating as checkboxes from my "Node: Products".

in my order form now I have my node:title to choose from, what I want is that another field appear IF the user select one.

mainly I want the user to be able to select/check the product name then provide the amount he is ordering with another textfield or something.


texts: How to create a node programatically with drupal_form_submit()?

texts: How to create a node by programatically submitting the existing node add form, and most importantly using it's validation process instead of re-implementing all of the property/field validation logic so we piggyback off of the existing code.


texts: creating custom content comprising both static and dynamic data

texts:
I need to create certain pages in my site, some of them relatively simple layout with mostly static content like Contact Us and About Us which I've created as Content Type Page (node). Similarly other content types have a relatively complex layout and content composed of both static and dynamic data. For example a page with some fancy header images a couple of paragraphs (static) and a list of URLs for contents belonging to a specific category (dynamic). Some of the pages have their own flyout menu (which i use Nice menus) and I create a new menu element and add the block for that specific page which I feel is definitely not the best method to go about this. My site is content heavy and there are many such pages and so its not possible for me to code the URLs in the content body in static manner.

I'm relatively inexperienced with contributed modules like Views and Panels but tried to get some ideas watching webcasts. But it seems that they are very vast topics and I couldn't find what I required from them. Hence request any of the members who've faced similar circumstances to share their experience and provide the methods/implementations or even modules they tried for this.


texts:
I keep getting this error while trying to access content using The Course module.

Call to undefined function ctools_get_plugins()

To my understanding this means the ctools module is not loaded, which is why the Course module cannot access this function. When I run drush cc all on the background and refresh, it works, but only once.
I've no idea what to do about it.


texts: Converting seconds to date with Facet API

texts:
I've inherited a project that deals with Drupal Facet API. I've got everything working fine, except for the display of the date for events.

The filter by date and time >> start date displays the date in seconds, however I would like this to be the date and time, e.g. Saturday 14th September 10:15 am

Here is the code from the event_system.module:

     if (isset($variables['view']) && $variables['view']->name == 'events') {
    $i = $variables['view']->row_index;
    $timestamp = strtotime($variables['view']->result[$i]->field_data_field_date_and_time_field_date_and_time_value);
    $variables['post_date'] = format_date($timestamp, 'medium');
  }

I've tried this:

$variables['post_date'] = format_date($timestamp, 'custom', 'g:i a, d F, Y',0);

and this:

$variables['post_date'] = format_date('l jS F Y', strtotime($timestamp));

I've tried adding different parameters to format_date but with no success. If someone could point me in the right direction that would be great.


texts: DateObject::getTimestamp() returning wrong value

texts:
This is a weird issue I ran into. It seems DateObject::getTimestamp() does not return expected values, while using format('U') returns the proper timestamp.

To see the values passed, here is the code I am using:

  $author_date_timestamp  = $author_reminder_date_obj->format("U");
  $author_date_timestamp1 = $author_reminder_date_obj->getTimestamp();

kpr on these two vars:

$author_date_timestamp = 1345736160  // correct value

$author_date_timestamp = 1345563360  // incorrect value

Here is a var_dump of the author_reminder_date_obj date object:

class DateObject#223 (9) {
  public $granularity =>
  array(7) {
    [0] =>
    string(4) "hour"
    [1] =>
    string(6) "minute"
    [2] =>
    string(6) "second"
    [3] =>
    string(5) "month"
    [4] =>
    string(3) "day"
    [5] =>
    string(4) "year"
    [6] =>
    string(8) "timezone"
  }
  public $errors =>
  array(0) {
  }
  private $serializedTime =>
  NULL
  private $serializedTimezone =>
  NULL
  public $timeOnly =>
  bool(false)
  public $dateOnly =>
  bool(false)
  public $date =>
  string(19) "2012-08-21 11:36:00"
  public $timezone_type =>
  int(3)
  public $timezone =>
  string(16) "America/New_York"
}

Anyone having a clue as to why ->getTimestamp() is not behaving as I expected, I am very curious about this.

Thanks!

UPDATE:

As requested, serialized string of object:

string(151) "O:10:"DateObject":2:{s:26:"\000DateObject\000serializedTime";s:25:"2012-08-23T11:36:00-04:00";s:30:"\000DateObject\000serializedTimezone";s:16:"America/New_York";}"


texts: Unable to find Fast Registration Mode to register and login user automatically using fbconnect button

texts:
I read the README.txt from start to finish.
1. I have enabled the following modules under drupal for facebook.
   1. Facebook API
   2. Facebook Apps
   3. Facebook Connect
   4. FB User Management
2. After That I have added my facebook app using settings page : Add App
3. In FB settings page (admin/build/fb/settings) I have checked the following settings.

   Use Secure URLs:Use HTTPS only when Facebook expects a secure URL. (Recommended.)
  Use FB Cookie
  Store tokens in session
  Use Oauth when initializing javascript.
  Get login status when initializing javascript.
  Use locale learned from facebook, if available.

4. Under user settings (admin/build/fb/fb_user) I have checked the the human friendly name for option:Username Style for Automatically Created Accounts:
5. Now I have logged out and moved the" facebook connect login " block on the front page
6. I can see fb login button above login page
7. I clicked on fb login button and I am redirected to facebook site requesting for login details
8. after logging in through facebook I see my facebook profile picture with following message
NAME , after login or registration your account will be connected.
9.  When I log in using admin (which has different email address then what the fb account has) I get the following warning after successful login "Failed to get Facebook user info for account 10201963083270364: The underlying FQL query made by this API call has encountered the following error: status is not a member of the user table."
10.Also no user is created using fb login button.
11. Also I logout , then use fblogin button it logs me in as admin(I realize that admin account is connected to some other fb account whose email address is different) so How Can I deauthorize the facebook account connected and allow other facebook account to be linked to this account?

Next I try to register using fb by navigating to "registration " provided as shown in the point no . 8

I am redirected to user/register which has my profile picture and profile name.

While trying to register my email id is not mapped but filling the details creates a new user which is default drupal functionality

13,  Now when I again try to login via fb login I get the same message as in the point 8. So , now I again login using the password added using user/register page to see if my facebook account is linked after login

Finally I again logout and try to use the fb login button to login and it connects automatically . So the fb account is linked

The MAIN QUESTION TO ASK-------
How can I enable FAST REGISTRATION MODE in D6 which onclick of fblogin button automatically registers a new user and logs me in to the account?

Does this module provide some settings for fast registration. Please let me know if there are any modules I need to enable or settings I need to set?


texts: How to display a field only if option (x) isn't selected

texts:
In one of my content types, I have a Status field (field_status) which is a List(text) field displaying 3 radio button options set to the following key|label values:

0|In Stock
1|Under Deposit
2|Sold

I have a custom twig template file for this content type and was wondering how I would display the value if the option isn't 0 (In Stock). In Stock is pretty much the default option so when the item is sold/under deposit, I want a "Sold/Under Deposit" banner to appear in the upper corner of the picture of the item.

Also, I have a view displaying a list of these content types so how would I only show this value again if the selection isn't "In Stock". I don't have a custom template for the view as I did it all in the UI so I'm hoping there's a way to do this there as well.

I feel like this should be a simple solution but for some reason I'm having issues with it.

I figured it would be something like the following but this doesn't seem to work:

{% if field_status is not ['0'] %}
  {{ field_status }}
{% endif %}

I'm assuming my syntax is wrong. What would be the proper way of doing this?


texts: Ajax call failing in Workbench email module

texts:
I'm having trouble with ajax in the workbench email module. On two nodes (out of hundreds), the ajax call to get a list of users to notify when the publication status changes will fail. The error is "Invalid form POST data". I added watchdog logging, and actually the entire $_POST is missing when the ajax fires. Does anyone know what would cause that?

I can't reproduce this in our development environment. I copied the database down, and the codebase is the same, but the same node works just fine in dev.

I've turned off boost caching on the live site and deleted the cache, and that did not help (although it's a node edit form, so I didn't think caching should matter).

It's consistently happening to the same two nodes, but I can't see anything different about them than the other nodes that work without issue.

One more thing -- I am using the Ajax Debugger chrome extension, and postData is populated in the request object with all of the form data and sent to the server. So it must be something in the drupal_bootstrap to remove $_POST data, but I'm stumped.


texts:
I need to loop through all the values of a multi field as per example bellow:

for ($i = 1; $i < ???; $i++) {

    $a = $form['field_...']['und'][$i]['#entity']->field_...['und'][0]['value'];

}

of course I could do something like this

foreach ($form['field_additional_sections']['und'] as $key=>$value) {
   if (is_int($key)) {
    ....
   }
}

but I was wondering if there is a nicer option to do this. I should probably mention that I'm implementing hook_FORM_ID_form_alter.

Thank you


texts:
My CKEDITOR icons are missing like this,, but the buttons works fine. Just the icons are not displaying.

Ive check the icons in in the module and it is located in sites/all/modules/ckeditor/ckeditor/skins/moono/icons.png. I checked the actual link if it will display the icons.png, but i found out that there is something in front of the hostname like this

unknownnumbers/hostname/root/sites/all/modules/ckeditor/ckeditor/skins/moono/icons.png,

and if just remove the unknownnumbers and make it into

hostname/root/sites/all/modules/ckeditor/ckeditor/skins/moono/icons.png

i can now see the image, what's the problem? thank you.


texts: Which hook will use for checking taxonomy term page

texts:
I need to run a hook on every taxonomy term page load.

function mymodule_WhichHook(){
   if (arg(0) == 'taxonomy' && arg(2) == 'term' && is_numeric(arg(2)) ) {
    // Store taxonomy details to DB
   }
}

Which Hook can i use for this. Please suggest.


texts: Is it a good idea to load the css files from page.tpl file instead of .info file

texts: I am just curious, because i am trying to get my site working for both IE and chrome, and I want it to load only a specific css file. Conditional stylesheets arent working for me, as I cannot see the change in the browser when I check it's html file.


texts: Adding more Data to a Commerce Feed Upload

texts: Currently I'm working on a Commerce Kickstart 2 storefront, to remake our company website in Drupal, a store front for selling Television Repair parts. I have a little HTML/CSS experience under my belt, but no real experience with Drupal outside of a couple tutorials. While I have figured out how to upload listings from the old website through tutorial videos and the Commerce Feed module, I could use a resource on how to add more information a CSV upload, more than a SKU, Name, Price, Image and a Description. Is it possible to add data to the CSV regarding Manufacturers, Part Number, intended TV Model, Condition of the part, and other useful information that users could sort and search for products with, or would any sorting and tagging have to be done after the objects are uploaded into the system? If there is a common method, where would be a good resource to start with to figure out what I need to do?


texts: Show block in particular nodes having some string in title

texts:
I have a block and I need to show this block only in some situations.
For example if title of node includes "abc", block will be visible else it won't.
From visibility settings of block I use this code snippet:

<?php
$match = FALSE;

$url = request_uri();
if (strpos($url, "myword")) {
  $match = TRUE;
}
?>

I'm sure that "myword" is included in full URL of node.
I tried to debug it by adding "echo $url" but it didn't write this line into page.

How can I solve this?

edit: in last line i forgot to add "return $match;" which returned always false.


texts: How to programmatically create a View on a node that displays SQL Query content?

texts:
How can I programmtically create a View on node(s) that displays the content from a specific query?

For example I would like to display the following:

$args = array(':nid' => $node->nid);
$results = db_query('SELECT USER_ID FROM USER INNER JOIN node ON USER.OFFICE_ID =
  node.title AND node.nid = :nid', $args);

Essentially, I would like to grab the 'nid' from the current node and I would like the View to display all 'users' associated with the current node, as the query would return.

I have been able to achieve this through a custom module. But I have been requested to use Views instead.

EDIT:

I've done what Johnathan Elmore suggested and got the View to display the correct information if I manually enter the 'nid' in the 'Preview with contextual filters:' space. However, if I go to the node itself, it will not display the query content.

For example:

I have nid == 123 with url alias 'office-123', if I enter 123 in 'Preview with contextual filters:', it will display the correct query information. However, if I go to 'mysite/office-123' nothing is displayed.

How can I get this View to display when I go to the node url?


texts: How to avoid timeouts on real long page loads

texts:
I have a few custom modules for our systems administrators where they can select a script and it will remotely execute on a remote server, let's say restart WebSphere.

I would like the results to display, however some of these scripts can take 15 minutes or so to run, I've got a busy spinner running so they know something is running in the back ground, however after 15 minutes or so the page times out, if you reload the page the results display.

I display the results via drupal_set_message() in the "submit" hook.


texts: how to add javascript with #attached and hook_page_alter

texts:
I tried to add js to pages by means of #attached, as it seems to be the recommended way. From what I understand, this involves altering a render array. hook_page_alter seems to me like good candidate.

As per https://www.drupal.org/node/756722 (and answers below), I came with:

function MODULE_page_alter(&$page) {
  $my_path = drupal_get_path('module', 'MODULE' );
  $page ['#attached']['js'][] = array(
    'js' => array(
    'type'=>'file',
    'data' => $my_path . '/module_test.js'),
  );
}

The file does not get attached, though. If I use

drupal_add_js($my_path . '/module_test.js');

it does get attached (it's not a problem of the js file, access persmissions, etc.).

What is wrong?

PS. I asked a related, but apparently wrong-headed question here


texts: Superuser Access denied on admin menu cache clear

texts:
Just took over dev work on this D7 site, so I don't know exactly how everything is set up. When I try to clear the cache via admin menu, I get an access denied message on /admin_menu/flush-cache?token=tokenvalue.

It seems that when I got to clear all caches at /admin/config/development/performance, it silently fails some of the time, and in some times I'll get the success message.

Any suggestions on where to start diagnosing this? I don't see anything in the drupal or server logs relating to this aside from the access denied message.


texts: The condition for the 2 fields sort criteria

texts:
the problem is this.
I have the representation of 2 fields ordered by
1. Discount - open for all users
2. weight
I need to sort was originally on 2 field - weight and if one is already busy 1 field - Discount, then sorting is conducted by him and 2 field-weight was not used, how can I achieve this?

I think possible to accomplish this if 1 field - Discount add independent the default value is not sorted, just outputs the data views, but how do I set the value of 3 in the sort of the same type as the group filters arbitrary value -Any-.
When I do the idea to 1 field value - Discount will not be involved and receive the following 2 field - Weight.
But how do I do this? After all, when you create a sort field has 2 radio buttons - ASC and DESC.


texts:
For all the Drupal sites I run except one, requesting /sites/default/settings.php in the browser results in a blank page, which seems right and proper.

But for one of my sites (on a different host), requesting /sites/default/settings.php actually results in the file's contents being served to the browser.

I have no idea where the trouble might be: is this a Drupal problem? Apache problem? Doesn't seem to be related to file permissions. How can I ensure that a request to settings.php doesn't serve the file?

As a stopgap measure I've added a line in .htaccess that generates a 410 error when settings.php is requested, but I'd really like to know how this is supposed to work...


texts:
Right now, to modify an image, I need to select the image and click on the image icon in the toolbar.

Is there a way in WYSIWYG to double click on an image and open automatically the image manager?


texts:
I notice that all my AHAH forms (in the admin) don't work all of a sudden after I updated Drupal and jquery_update. Now that I am working with building a form with the Form API and want to make it dynamic with AHAH through ahah_helper, it hangs itself.

For example, if I type something into a textfield that is supposed to change on blur, the throbber pops up and I can see that the form is trying to POST the change, but then this error comes up:

  uncaught exception: Syntax error, unrecognized expression: /\x3e\n\x3c/div\x3e\n\x3c/div\x3e"

and it says it's from the jquery.min.js file. I am using 1.5.

I have heard that this can be because of conflicting files in other modules, and I have tried several different patches for those modules; none of them work.

Does anyone have an insight on this? Or should I use AJAX instead?


texts:
I am using D7.

I am attempting to create a redirect in my .htaccess file that will redirect the page if the path doesn't match a pattern.

# only if a particular domain
RewriteCond %{HTTP_HOST} ^mysite\.domain\.org$ [NC]
# only if URI contains "library"
RewriteCond %{REQUEST_URI} !^/Library$ [NC]
# rewrite the URL
RewriteRule ^(.*)$ http://otherdomain.org/$1 [R=301,L]

This works fine for most of the site (e.g. http://mysite.domain.org/blogs is redirected to http://otherdomain.org/blogs

However, http://mysite.domain.org/Library?id=1234 is being redirected but to http://otherdomain.org?id=1234 ("library" in URI is missing but this shouldn't redirect at all)

What am I missing?  Am I running into Drupal URL rewriting rules?


texts: How can I Pass a javascript variable value to PHP in Drupal 7

texts:
I am currently working on a project where i am required to pass Javascript variable value to php, i am able to do it vice-versa but unable to accomplish, this one.
Is there any way to get this done in Drupal 7 ?


texts: Error in simplenews when send the node more than one

texts:
I am using module simplenews and when I send node more than one. Its show me this:-

  This newsletter has been sent.

Why and how can I solve this and don't want to show me again.


texts:
I want to show only warnings and errors but I want to turn-off notices. How can I turn off notices?
In my settings.php, I have this code:
$config['system.logging']['error_level'] = 'verbose';

What value should I put there?


texts: Move uploaded content automatically from one node to another

texts:
Is it possible post images/text on a different page other than the one being uploaded?

I have an insert page where users can add images/text but I want whatever they post to go on another page automatically ('things' page) sorted by the most recent first. I only want to keep the 'insert' page as an 'insert' and without content!


texts: Is it a bug? blog-View read more button reference to home page

texts:
I manually created a blog which is a view page with 3 manually-picked fields:

image
title
body

The body field got a read more link, yet instead of pointing to the specific node listed in the blog, it lists to the home pages.

I didn't track anything that would cause it. Maybe I'm missing something:

Further information:

I also tried to insert the token [node:nid] but no change was seen.


texts: How to create a rule to compare an order total with a custom field in a content type?

texts:
I have multiple restaurants with each another value for minimum order price, this is a custom price field in the content type "Restaurants".

I would need to make a rule where the total order amount is compared to this custom price field. If the total from the order is lower, it should redirect and throw a message.

The problem here is that I don't know what entities to use to get access to the custom price field named "field_leveringsprijs".

The event is on payment selection or checkout completion. The actions would be a page redirect and a message which isn't hard to do. I'm just stuck with the conditions 'Entity has field' and 'Data comparison'.

Any suggestions?


texts: What's the best infrastructure to set permissions to user roles that controls who can see which Nodes and which Views?

texts:
I'm building a bsite that needs pretty stringent permissions. I have already created the (4) user roles for the site, but not sure the best way to handle viewing permissions.

I see that when creating Views it is pretty simple to assign which roles have permission to view, but what about for my content that is straight up page/nodes?


texts:
I have a content type called video with two fields, title and youtube id. Im migrating content to the site using csv files however every time I migrate the youtube id field is always empty.

The field type for the id is Youtube VideoID.

<?php

class VideoMigration extends Migration {
  public function __construct() {
    parent::__construct();
    $this->description = t('Import videos from CSV file.');
    $this->dependencies = array();
    $this->map = new MigrateSQLMap($this->machineName,
      array(
        'nid' => array(
          'type' => 'int',
          'not null' => true,
        ),
      ),
      MigrateDestinationNode::getKeySchema()
    );
    $this->source = new MigrateSourceCSV(drupal_get_path('module', 'deploy_content') . '/import/video/csv/video.csv', $this->csvcolumns(), array('header_rows' => 1));
    $this->destination = new MigrateDestinationNode('video', array('text_format' => 'full_html'));
    $this->addFieldMapping('nid', 'nid');
    $this->addFieldMapping('is_new')
         ->defaultValue(TRUE);
    $this->addFieldMapping('title', 'title');
    $this->addFieldMapping('field_video_embed_code', 'youtube');
  }

  function csvcolumns() {
    $columns[0] = array('nid', 'NID');
    $columns[1] = array('title', 'Title');
    $columns[2] = array('youtube', 'YouTube');
    return $columns;
  }
}

Any ideas why this could be happening?


texts: CKEditor crashes when switching text format for specific content types

texts:
drupal 7.38

wysiwyg 7.x-2.2+63-dev

CKEditor 4.5.1.a513a92

If I create an article, switch text formats, everything is fine.

If I create a basic page, switch text formats, the ckeditor toolbar crashes and none of the buttons are clickable.

The crash also occurs if I create a new content type.

Here is a copy of the console log:

  Uncaught TypeError: Cannot read property 'sas' of undefined
  js_ALIKtebL-PsIulJhUegpZmaxTRnPdAyakIc8kMeoL-4.js:382 Uncaught
  TypeError: Cannot read property 'sas' of
  undefinedDrupal.wysiwyg.plugins.sas.attach @
  js_ALIKtebL-PsIulJhUegpZmaxTRnPdAyakIc8kMeoL-4.js:382(anonymous
  function) @
  js_ALIKtebL-PsIulJhUegpZmaxTRnPdAyakIc8kMeoL-4.js:103CKEDITOR.tools.createClass.proto.setData
  @ ckeditor.js?nstvdm:780(anonymous function) @ ckeditor.js?nstvdm:349j
  @ ckeditor.js?nstvdm:10CKEDITOR.event.CKEDITOR.event.fire @
  ckeditor.js?nstvdm:12CKEDITOR.editor.CKEDITOR.editor.fire @
  ckeditor.js?nstvdm:13CKEDITOR.tools.extend.setData @
  ckeditor.js?nstvdm:251b @ ckeditor.js?nstvdm:775(anonymous function) @
  ckeditor.js?nstvdm:777CKEDITOR.editor.setMode @
  ckeditor.js?nstvdm:328(anonymous function) @ ckeditor.js?nstvdm:323j @
  ckeditor.js?nstvdm:10CKEDITOR.event.CKEDITOR.event.fire @
  ckeditor.js?nstvdm:12CKEDITOR.editor.CKEDITOR.editor.fire @
  ckeditor.js?nstvdm:13CKEDITOR.event.CKEDITOR.event.fireOnce @
  ckeditor.js?nstvdm:12CKEDITOR.editor.CKEDITOR.editor.fireOnce @
  ckeditor.js?nstvdm:13(anonymous function) @
  ckeditor.js?nstvdm:246CKEDITOR.scriptLoader.load.g @
  ckeditor.js?nstvdm:226CKEDITOR.scriptLoader.load @
  ckeditor.js?nstvdm:226(anonymous function) @
  ckeditor.js?nstvdm:245(anonymous function) @
  ckeditor.js?nstvdm:233(anonymous function) @
  ckeditor.js?nstvdm:231CKEDITOR.scriptLoader.load.g @
  ckeditor.js?nstvdm:226CKEDITOR.scriptLoader.load.B @
  ckeditor.js?nstvdm:226CKEDITOR.scriptLoader.load.s @
  ckeditor.js?nstvdm:226(anonymous function) @ ckeditor.js?nstvdm:227


texts: Hide menu backend side for different roles/users

texts:
I'd like to hide some menu on the backend side /admin/structure/menu and make the hidden items to disappear of the navigation menu for a specific user/role.

I managed to hide the list of the menu visible in the page /admin/structure/menu but it's just the list which as been changed, meaning they can access by accessing to the url.

function module_menu_alter(&$items) {
    $items['admin/structure/menu/manage/devel']['page callback'] = 'module_change_devel';
    $items['admin/structure/menu']['page callback'] = 'module_change_menus';
}

function module_change_menus() {

    global $user;
    if(!in_array('administrator', $user->roles)){
        $result = db_query("SELECT * FROM {menu_custom}
            WHERE menu_name='menu-contact-us'
            OR menu_name='menu-1'
            OR menu_name = 'menu-3'
            OR menu_name = 'menu-2'
            ORDER BY title",
            array(),
            array('fetch' => PDO::FETCH_ASSOC));
    }
    else{
       $result = db_query("SELECT * FROM {menu_custom}
           ORDER BY title",
           array(),
           array('fetch' => PDO::FETCH_ASSOC));
    }
    $rows = array();
    $header = array(t('Title'), array('data' => t('Operations'), 'colspan' => '3'));
    foreach ($result as $menu) {
    $row = array(theme('menu_admin_overview', array('title' => $menu['title'], 'name' => $menu['menu_name'], 'description' => $menu['description'])));
    $row[] = array('data' => l(t('list links'), 'admin/structure/menu/manage/' . $menu['menu_name']));
    $row[] = array('data' => l(t('edit menu'), 'admin/structure/menu/manage/' . $menu['menu_name'] . '/edit'));
    $row[] = array('data' => l(t('add link'), 'admin/structure/menu/manage/' . $menu['menu_name'] . '/add'));
    $rows[] = $row;
    }
    return theme('table', array('header' => $header, 'rows' => $rows));

}

function menu_change_devel() {

    global $user;
    if(in_array('administrator', $user->roles) == 1){
        $items['admin/structure/menu/manage/devel']['access arguments'] =  array('aminister users');
        return $items;
    }
}

But the function menu_change_devel which is supposed to give the access to admin/structure/menu/manage/devel for the user having the permission to aminister users doesn't seem to work :(

Any idea ?

Cheers

EDIT :
I found the solution

function MODULE_menu_alter(&$items) {

    //deny the menu if they are not admin (if they don't have the acess right to adsminister users)
    $items['admin/structure/menu/manage/%menu']['access callback'] = array('MODULE_check_menus_access');
    $items['admin/structure/menu/manage/%menu']['access arguments'] = array(4, 'administer menu');
    //edit
    $items['admin/structure/menu/manage/%menu/edit']['access callback'] = array('MODULE_check_menus_access');
    $items['admin/structure/menu/manage/%menu/edit']['access arguments'] = array(4, 'administer menu');
    //add
    $items['admin/structure/menu/manage/%menu/add']['access callback'] = array('MODULE_check_menus_access');
    $items['admin/structure/menu/manage/%menu/add']['access arguments'] = array(4, 'administer menu');
}

function MODULE_check_menus_access($menu, $permission){
    global $user;
    $account = $user;

    if (user_access($permission, $account)) {
        if(array_key_exists ($menu['menu_name'], $menuList)){
            return user_access('can manage '.$menu['menu_name'], $account);
        }
        else{
            return true;
        }
    }
}

/**
 * Implements hook_permission().
 */
function MODULE_permission() {
  return array(
    'can manage navigation' =>  array(
      'title' => t('Can manage navigation menu'),
      'description' => t('Limit access to the navigation menu'),
      ),
    );
}


texts: Kanban-style view : Group nodes in a view into columns based on a field value

texts:
I have a custom node type in Drupal - Order - which has a status field. The status can have three values.

What I would like to do is create a view in which orders are grouped into columns based on their status - essentially a primitive Kanban board - and the columns are ordered in a particular way.

Is this possible and if so, how?


texts:
How should I know which variables and objects can be used directly in the template.php file?This is what a template.php file created by somebody else contains:

function garland_separate_terms($node_taxonomy) {
  if ($node_taxonomy) {
    foreach ($node_taxonomy as $term) {
      $links[$term->vid]['taxonomy_term_'. $term->tid] // …
      // …
    }
    // …
  }
}

Why can he use the $term object directly?


texts:
Currently i am  using drupal six form api. I just wanted to add number field to form but there is no way that i found to add numeric field to form. Is there is any way to do this by using form api drupal6 to add numeric field in drupal 6.

Thanks


texts: How do I display a field that's set to "Hidden" by the content type in the template?

texts:
I have an existing site where a bunch of the fields are set to Hidden in the Display fields for the content type. I don't want to change that because I'm not 100% sure how that will affect other aspects of displaying the page.

When I do a var_export($node, TRUE) I can see the field values are present in the node, they just aren't being rendered in $content.

Can I use hook_nodeapi() to change the field display to "Default" or "Trimmed", etc?


texts: How to create a boxplot/candlestick chart?

texts:
I'm using Drupal 7.54 and I need to create a chart (scatterplot) showing also information like minimum, maximum and mean (e.g. body weight for fishes). Usually, a boxplot is the way to display that kind of data.

Searching through the Comparison of Charting modules, it seems like boxplot or candlestick charts are not supported. Only the Easychart module seems to have the option, but I did not manage to combine Easychart with Views (?) in order to create dynamic charts (I don't need "charts-nodes" created through the Easychart UI).

For the moment, I have created a scatterplot with Charts and then display the 3 basic stats through PHP/MySQL in the header.

I know I could also create Charts add-on (using Views) to combine different charts (scatter for values, columns for basic stats) but I am not really pleased with the final result (see below a very first draft), for the moment (columns hiding the first scatter value, for example).

Is there a way to achieve this?


texts: Send a mail automatically with content/attachment using webform using rules

texts:
In Drupal 7 a want people to fill in a webform with their email/tel/etc..and finally can choose some options.
When the submit the form, I want them to get automaticcaly more information about the chosen options, by sending automaticly a pdf by mail or permission to some content. Rather not with subscribing, also anonymous users.
Is this possible with rules and webform (I also installed webform rules).
When you need more information just let me know.

Thanks very much in advance!!!

Pieter-Jan Derks
Holland


texts:
There are times when I run drush cc css-js and I get the following error:

'css-js' cache is not a valid cache type

Does anyone know why this may happen?

Thanks,


texts: How to use addTranslation() on an entity's multi-value paragraph?

texts:
I'm trying to programmatically update a multivalue paragraph field and add a translation. In the code below field_product_description is the paragraph's field that I'm updating and field_images_descriptions is the node's field that references the paragraph. The code only updates the first iteration ([0]) of the paragraph. How can I also update the other paragraph values?
<?php
                  $lang_node->field_images_descriptions->entity
              ->addTranslation($lang_code, [
                  // field_product_description is a multi-value field
                  // how can I update it's other values
                  'field_product_description' => $desc1,
              ])->save();
    ?>

SOLVED: Working code:
<?php

foreach ($lang_node->field_images_descriptions as $delta => $item) {

          $item->entity->addTranslation($lang_code, [
              'field_product_description' => $desc1[$delta],
          ])->save();
        }

        $lang_node->save();


texts:
What is the file I have to modify in order to get Drupal to output a custom user page.

The default link to the file I need to change is:

http://www.example.com/?q=user/xx

Where xx is the user id.

This page is not dysplaying correctly and I want to fix it, but how do I know which file is Drupal calling?

Is there a reference guide on Drupal 7 default pages and links?


texts: Views > Exposed Filter > How to disable output of options that aren't attached/used by a node

texts:
I have a exposed filter setup to filter content within a view.

The view is displaying a list of house designs. These designs need to be able to be filtered by number of beds, bathrooms etc.

"House Design" content type/node has a field (List (integer)) for bedrooms:

http://theexhale.com/screenshot_1.png

The allowed values for this field are 1,2,3,4,5 (bedrooms)

http://theexhale.com/screenshot_2.png

The issue I'm having is that the exposed filter is outputting all of these fields for sorting the view even though currently only values "2" and "4" are being used by the "House Design" content type.

http://theexhale.com/screenshot_5.png

QUESTION: Can the exposed filter be smart enough to check to see if values of a field/taxonomy vocab are actually being used by the displayed content type/node and then dynamically only display those values in the filter?

I want to do this to remove/lesson the possibility of no results when a user uses the filter.

Thank you :)


texts: How to add a an option to tile background image

texts: Is there a module or modules in Drupal 7.x that can provide members and or admin to have an option to "tile" a background image similar to what you would see on a windows desktop As well as having a color wheel option (to pop up or static on a settings page to change or add different color themes for the member profile page??? Any help would be greatly appreciated...


texts: Adding node with multi value field using Services

texts:
While adding node using REST API, submitting multi-value field is adding only one value to that field.

{
"title":"test",
"type":"article",
"body":{"und":[{"value":"this is main body"}]},
"field_topic":{"und":[{"value":"topic 1"},{"value":"topic 2"}]}
}

the node is created but the field_topic contains only topic 1 and topic 2 is not added.

What is the reason and how to fix that?


texts: How do I set the Views Plugin handler path different from the theme path?

texts:
The file path of the module is set up like this:

addressfield/views/addressfield.views.inc
addressfield/views/addressfield_plugin_row_jmappingfields.inc
addressfield/views/addressfield_plugin_style_jmapping.inc
addressfield/theme/addressfield-jmapping-view.tpl.php
addressfield/theme/addressfield-view-jmappingfields.tpl.php

The problem is I can not figure out how to set the path in the plugin definition for the View. If I set the 'theme path' key to drupal_get_path('module', 'addressfield'). '/views' the handlers will register but the themes can not be found and vis versa.

/**
 * @file
 *  Provide the Addressfield plugin definition.
 */

function addressfield_views_plugins() {
  $path = drupal_get_path('module', 'addressfield') . '/views';
  return array(
    'module' => 'addressfield',
    'style' => array(
      'jmapping' => array(
        'title' => t('jMapping'),
        'help' => t('Display a view jMapping map.'),
        'handler' => 'addressfield_plugin_style_jmapping',
        'theme' => 'addressfield_jmapping_view',
        'theme path' => $path,
        'uses row plugin' => TRUE,
        'uses options' => TRUE,
        'uses grouping' => TRUE,
        'type' => 'normal',
        'parent' => 'default',
      ),
    ),
    'row' => array(
      'jmappingfields' => array(
        'title' => t('jMapping Fields'),
        'help' => t('Choose the fields to display in the jMapping Map.'),
        'handler' => 'addressfield_plugin_row_jmappingfields',
        'theme' => 'addressfield_view_jmappingfields',
        'theme path' => $path,
        'uses fields' => TRUE,
        'uses options' => TRUE,
        'type' => 'normal',
      ),
    ),
  );
}

How do I keep the theme templates for the style plugin and the handlers in separate folders for clarity?

I'm using Views 3 in Drupal 7.


texts: Programatically trigger a click on an AJAX enabled form field (button, select, etc)

texts:
Using jQuery, I need to programmatically click / select Form items (radios, select lists, checkboxes, etc). This field item has an '#ajax' action / callback defined using Form API.

The following code from a similar question works for submit buttons (Programatically trigger a click on an AJAX enabled form submit button):

jQuery('#edit-submit').mousedown()

However, this does not work for radio buttons. I have also tried creating a copy of the element and making my own AJAX call using the following code from another similar question (Use Drupal7 AJAX goodness programmatically):

          base = 'edit-my-radio-button';
          element = '<input type="radio" id="'+base+'" name="cat-selector" value="garfield" class="form-radio ajax-processed">';
          element_settings = Drupal.ajax[base].element_settings;
          myAjax = new Drupal.ajax(base, element, element_settings);
          myAjax.eventResponse(element, 'click');

The AJAX call is made, but the screen does not update as if the user clicked it. How can I programmatically select a radio button or select list using jQuery and cause Drupal to execute the AJAX call?

Please note: I have purposely kept this question as open ended as possible. My hope is that there is a more general way to do this for all form element types and that future answers regarding these can be considered relevant so that we have a single resource for this problem.


texts: Programmatically remove content from a group

texts:
In order to add a node to any group in Drupal 8, I use the following code.

$group->addContent($node, 'group_node:article');

Now, for removing content from a group, I have tried $group->removeContent($node, 'group_node:article'); and $group->removeContent($node); without success. All I obtained is the following error message.

  Error: Call to undefined method Drupal\group\Entity\Group::removeContent() in Drupal\my_valetop_extras\Plugin\WebformHandler\CustomWebformHandler->submitForm()

Finally, I have managed to remove content from a group using this code.

$type = 'group_node:' . $node->getType();
$current_node = $group->getContent($type, ['entity_id' => $node_id]);
$content = array_values($current_node)[0];
$content->delete();

But  believe I can remove a single node from a group with a simple line of code.

How can I achieve it?


texts: Displaying content type as a field in a page

texts:
I am stuck with this architectural design for a client of mine. I am trying to create a testimonial block in 3 different pages, that client can pick any testimonial and I will create simple bootstrap carousel system for that.

So I created a custom content type name testimonial which has 3 fields, body, client name, and client title. This is the point I get stuck, I have no clue what would be the next? I tried to create that block via views slideshow but then client won't be to pick testimonials that they want, it will display all the testimonials.

I wonder if there is a way that I can add this content type as a field at that page? Or am I going to create a custom page(as a module) and create a custom field for this testimonial content type? If I have to do so, is there anyone who encountered this and completed something like this, can direct me to a sample of this?


texts: List module releases that are "Recommended by the project’s maintainer."

texts:
On the project page of a Drupal module there is a list of releases.  The project owner can set for each one whether it is recommended, and the page displays that fact.  For example if there are releases 2.0 and 3.0, it's possible for either one to be recommended or both.
I would like to know which releases are recommended without having to visit the project page of each module one-by-one.  I would be interested in any type of answer: GUI, command line, API, etc.
I have already tried

The GUI (/admin/reports/updates).  It lists releases that are "also available" but does not indicate which are recommended.
composer.  It seems to have no idea of recommended.  With my settings, it appears to pick the newer release except if it is less stable.
drush.  In drush 8, the rl command lists recommended releases but seems to be broken with current Drupal 8.  Newer drush does not have this command.
Code.  The return value of update_get_available() or update_calculate_project_data() don't seem to contain this information.


texts: Migrate plugin migration_lookup : dynamic migration id

texts:
"node_a_migration" is the migration ID of nodes of type "node_a"
"node_b_migration" is the migration ID of nodes of type "node_b"
I'd like to use either "node_a_migration" or "node_b_migration" as a migration_lookup depending on other field value.
The source (not a drupal site, entities of content A and content B can have the same id, because stored in different tables) :
[
  ['entity_type' => 'content_a', 'entity_id' => 123],
  ['entity_type' => 'content_b', 'entity_id' => 123],
]

The migration config :
process:
  pseudo_field_migration_id:
    plugin: static_map
    map:
      content_a: node_a_migration
      content_b: node_b_migration
    source: entity_type
  field_entity_reference:
    plugin: migration_lookup
    migration: '@pseudo_field_migration_id'
    source: entity_id

There is no error when running the migration, but the field_entity_reference is not populated.
It works if I manually replace '@pseudo_field_type_id' by node_a_migration
Any idea how to make it work ?
Thank you!


texts: How do I add the "cancel" button to a managed file

texts:
I made a new component for webform that adds a file upload component. It has a "choose file" button, and an "upload" button. You can also choose to use a progress bar during the upload.

Now I want to include a "cancel" button to interrupt the upload process. How can I do this?


texts: How do I make entity reference lookup faster

texts:
I am trying to look up entity reference id's for each node so I can do stuff with them.

$all_nodes = db_select('node','e')->fields('e',array('nid','type'));
$all_nodes->addField('e','nid');
$all_nodes->condition('type','author');
$data = $all_nodes->execute();
$the_result = $data->fetchAll(\PDO::FETCH_ASSOC);

foreach ($the_result as $node){
     $node_load =  \Drupal\node\Entity\Node::load($node['nid']);
     foreach ($node_load->field_institution_with_date as $item) {
        $the_entity_id = $item->entity->id();
     }
}

Any idea on how to optimize this? it seems that $item->entity->id(); is the bottleneck and it is taking several seconds to iterate through about 1000 nodes.


texts: hook_module_preuninstall doesn't run early enough

texts:
Uninstalling my module threw this error:

[error]  my_module: The My Field field type is used in the following field: my_module.my_field

But, since my module defines both an entity and a field, both of which will be uninstalled when I uninstall this module, it doesn't make sense.  I'm trying to handle this by removing all of the fields programmatically in hook_module_preuninstall, which I have in the .module file because it wasn't working in the .install file.

The problem is, this hook runs after the checks for field dependencies.  It would make more sense if it ran before, in my opinion, but, what can I use to get ahead of these checks?  Anything?  If not, what should I do so that my module realizes it needs to uninstall these things when the module is uninstalled?

Also, shouldn't this hook run earlier?  If not, what is the point of it?


texts: Cron failed with drush: Segmentation fault

texts:
In Drupal 6, whenever I run cron from web interface I get an Internal server error and when I run

drush cron

I just get

Segmentation fault

What can be wrong here and how can I fix it?


texts: How to pass node queue id in views contextual filters

texts:
I a list of node queues and nodes associated with them. Now I have created a block using views. This block should list the nodes in a specific node queue based on the node queue id.

I have used node id in contextual filters, but not sure how to use node queue's id in contextual filter.

Any help would be widely appreciated.


texts: TrustedResponseRedirect failing - how to prevent cache metadata?

texts:
I am getting the following when trying to redirect to an external site from my controller function defined in my routing file:

return new TrustedRedirectResponse($my_ext_url);

  LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\Core\Routing\TrustedRedirectResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 159 of core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php).

This is clearly related to cache metadata - but how do i switch this off for a trusted redirect?

Edit: There is currently no constructor on the controller and therefore no injection going on.
Routing looks like (obv with correct indents :):

tocyn_payment.paypal_checkout:
path: 'test/{order_id}'
defaults:
_controller: 'Drupal\my_module\Controller\MyController::handle'
_title: 'Test Tite'
requirements:
_permission: 'access content'

Thanks in advance

Mathew


texts:
i'd like to dynamically change the option labels of a cck form field in the edit node form.

i allready found ou, that i can't do this in hook_form_alter, since the cck fields aren't in the form object at this time. so i added a after_build function. in this function, i'm trying to set the option labels like this:

function _mymodule_after_build($form, &$form_state) {
   $form['field_product_alternativtitle']['value']['#options'][1] = "foo";
   $form['field_product_alternativtitle']['value']['#options'][2] = "bar";
   $form['field_product_alternativtitle']['value']['#options'][3] = "meh";
   return $form;
}

This, however doesn't change the output of the form in any way.
I guess this is logical, since my function gets calles AFTER the BUILD of the form.

so my question is, how can i achieve my goal?


texts: VBO action on pending node revision (using Revisioning) publishes the revision

texts:
I have a View listing pending node revisions (using Revisioning). I have several actions, like changing the node author, which are executed using Views Bulk Operations. Executing, for example, the "Change author" action should update the author, but keep the revision in pending state. However, the revision gets published, and becomes the new, current revision.

Anyone else run into this issue? I've been digging around both VBO and Revisionings source code, but I cannot find out which one is to "blame". VBO is correctly loading the pending revision, and executing the action on it. Revisioning's node hooks are correctly invoked as well. Auto-publishing is disabled, and Revisioning does not get into that code flow (I put tracer code in there to make sure it doesn't). So this leads me to think VBO or Entity are at fault, but I can't put my finger on it.


texts:
I want to create a website with form, where users can insert the information in the form and then on form submit, information goes into a database table and also goes to the third party API.

Administrators can modify the specific record and add more information, and then publish this record as a web page with a unique URL.

Is it possible in Drupal 8?
How can I achieve that? Is there any specific module I need to use?


texts: In Drupal 7 how can I programmatically create a menu link to a view?

texts: I am trying to programmatically create a menu link to a view. The view already has a menu item but I basically need a shortcut to it in another menu location in a separate module.


texts: Create views field template override for table style

texts:
I have a view named studies that displays title, status. The status field should be "Active" or "Completed". This value is the result of comparing the timestamp of the date field that my content type has with the today timestamp. So I added the date field to my view as well, but choose to have it excluded from display. Then I created a global text field with the label "Status".

Then i tried taking my first steps into theming. What I need is to override the content of the Status field with either "Active" or "Completed" based on my code. I created a template called views-view-field--studies--nothing.tpl based on the suggestions of the Views theme information. The problem is that it doesn't matter what I write inside nothing gets displayed, not even just a simple <?php print $output."Hello World"; ?> (I did rescan the template files and Views sees my template, plus I flushed all caches)

My view right now has table style. I changed the style to unformatted list and voila the Hello World showed up! So am I messing around with the wrong template? Do I need to create a template for the table style of my view? Seems too excessive when I only need to override the content of one field.


texts: Can I have a cache expiration on a single field, and that expiration is respected by storage loading?

texts:
Trying to figure out the best way to go about this.  I have one field added to the User entity and I need somewhat fresh data on it.

Ideally I'd be able to cache this one field for, say, 15 minutes.  If entityTypeManager()->getStorage('user')->load(3) is called after expiration, I need to hit an API and update that data.

Is this possible? How?


texts: How can I inject container to a class with constructor having arguments?

texts:
Fatal error: Declaration of Drupal\migrate_upgrade\MigrateUpgradeDrushRunner::create(Psr\Container\ContainerInterface $container, $options = Array) must be compatible with Drupal\Core\DependencyInjection\ContainerInjectionInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container)

Below is MigrateUpgradeCommands.php file
where I am creating an instance of new MigrateUpgradeDrushRunner() and passing two arguments $options and $this->logger

    class MigrateUpgradeCommands extends DrushCommands {
    /**
       * Logger service.
       *
       * @var \Drupal\Core\Logger\LoggerChannelInterface
       */
      protected $logger;

      /**
       * MigrateUpgradeCommands constructor.
       *
       * @param \Drupal\Core\State\StateInterface $state
       *   State service.
       * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactoryInterface
       *   The logger.factory service.
       */
      public function __construct(StateInterface $state, LoggerChannelFactoryInterface $loggerFactory) {
        $this->state = $state;
        $this->logger = $loggerFactory->get('drush');
      }
/**
   * Perform one or more upgrade processes.
   *
   * @command migrate:upgrade
   *
   * @usage drush migrate-upgrade --legacy-db-url='mysql://root:pass@127.0.0.1/d6'
   *   Upgrade a Drupal 6 database to Drupal 8
   * @usage drush migrate-upgrade --legacy-db-key='drupal_7'
   *   Upgrade Drupal 7 database where the connection to Drupal 7 has already
   * been created in settings.php ($databases['drupal_7'])
   * @usage drush migrate-upgrade --legacy-db-url='mysql://root:pass@127.0.0.1/d7' --configure-only --migration-prefix=d7_custom_ --legacy-root=https://www.example.com
   *   Generate migrations for a custom migration from Drupal 7 to Drupal 8
   *
   * @validate-module-enabled migrate_upgrade
   *
   * @aliases migrate-upgrade, mup
   *
   * @throws \Exception
   *   When an error occurs.
   */
  public function upgrade(array $options = []) {
    $runner = new MigrateUpgradeDrushRunner($options, $this->logger);

    $runner->configure();
    if ($options['configure-only']) {
      $runner->export();
    }
    else {
      $runner->import();
      $this->state->set('migrate_drupal_ui.performed', \Drupal::time()->getRequestTime());
    }
    // Remove the global database state.
    $this->state->delete('migrate.fallback_state_key');
  }

    }

Now file MigrateUpgradeDrushRunner.php

class MigrateUpgradeDrushRunner implements ContainerInjectionInterface {
  /**
   * Logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  public static function create(ContainerInterface $container, $options = []) {
    return new static(
      $container->get('logger.factory'),
      $options
    );
  }

  /**
   * MigrateUpgradeDrushRunner constructor.
   *
   * @param array $options
   *   Drush options parameters.
   * @param \Drupal\Core\Logger\LoggerChannelInterface $logger
   *   Drush logger.
   */
  public function __construct(array $options = [], LoggerChannelInterface $logger) {
    $this->setOptions($options);
    $this->logger = $logger;
  }

}

Basically, how can I inject Container into MigrateUpgradeDrushRunner so that I can fetch logger.factory service and pass it in the construct ?


texts: How to safely render node body on a custom variable?

texts:
I created a custom template for my programmatically created block.

I defined a variable for the template called test

so in my render array I have

'#test' => $node->get('body')->value

Problem is when I print {{ test }} in my twig template, it literally prints the html rather than rendering it. Ex: <p> My node body </p>

I've also have tried:

'#test' => $node

Then on twig {{ test.body.value }}

but same result, the html does not get rendered.

The only way I found to make render is by doing {{ test.body.value|raw }} but raw filter should never be used on user entered data.

How can I make Drupal stop escaping the html safely?


texts: I have a custom form within CTools form wizard that I would like to use Mollom on. Is there an API function I can use to place it in the Form API on that page?


texts: Can I attach a javascript function to a Drupal.behaviors javascript function?

texts:
I want to trigger another function any time Drupal.behaviors.MultiPage (found in field_group/multipage) changes page.

It's part of this code:

Drupal.behaviors.MultiPage = {
  attach: function (context) {
    $('.multipage-panes', context).once('multipage', function () {

      var focusID = $(':hidden.multipage-active-control', this).val();
      var paneWithFocus;

      // Check if there are some wrappers that can be converted to multipages.
      var $panes = $('> div.field-group-multipage', this);
      var $form = $panes.parents('form');
      if ($panes.length == 0) {
        return;
      }

      // Create the next/previous controls.
      var $controls;

      // Transform each div.multipage-pane into a multipage with controls.
      $panes.each(function () {

        $controls = $('

');
        $(this).append($controls);

        // Check if the submit button needs to move to the latest pane.
        if (Drupal.settings.field_group.multipage_move_submit && $('.form-actions').length) {
          $('.form-actions', $form).remove().appendTo($($controls, $panes.last()));
        }

        var multipageControl = new Drupal.multipageControl({
          title: $('> .multipage-pane-title', this).text(),
          wrapper: $(this),
          has_next: $(this).next().length,
          has_previous: $(this).prev().length
        });

        $controls.append(multipageControl.item);
        $(this)
          .addClass('multipage-pane')
          .data('multipageControl', multipageControl);

        if (this.id == focusID) {
          paneWithFocus = $(this);
        }

      });

      if (paneWithFocus === undefined) {
        // If the current URL has a fragment and one of the tabs contains an
        // element that matches the URL fragment, activate that tab.
        var hash = window.location.hash.replace(/[=%;,\/]/g, "");
        if (hash !== '#' && $(hash, this).length) {
          paneWithFocus = $(window.location.hash, this).closest('.multipage-pane');
        }
        else {
          paneWithFocus = $('multipage-open', this).length ? $('multipage-open', this) : $('> .multipage-pane:first', this);
        }
}
      if (paneWithFocus !== undefined) {
        paneWithFocus.data('multipageControl').focus();
      }
    });
  }
};

/**
 * The multipagePane object represents a single div as a page.
 *
 * @param settings
 *   An object with the following keys:
 *   - title: The name of the tab.
 *   - wrapper: The jQuery object of the
 that is the tab pane.
 */
Drupal.multipageControl = function (settings) {
  var self = this;
  var controls = Drupal.theme('multipage', settings);
  $.extend(self, settings, controls);

  this.nextLink.click(function () {
    self.nextPage();
    return false;
  });

  this.previousLink.click(function () {
    self.previousPage();
    return false;
  });

What I want to do is track anytime the user clicks the "Next" or "Previous" buttons - the code that triggers this is at the bottom of the snippet.

Is there a way for me to bind an event handler to this function?


texts: Uncaught Reference Error : JQuery is not Defined at drupal.js

texts:
When clearing the Drupal Cache it automatically enable/ checks the Compressed the cache pages options and breaks many drupal functionality.

when i inspect i found that JQuery is not Defined at drupal.js at line 5 [jQuery.noconflict() ]. i find this error on all the pages of drupal.
and also jquery.js is not loading.

I am not sure what have caused this error.


texts:
I would like to add some products to my cart while I am on checkout process. The cart appears to be empty at the time. I want to make a selection of some add-on products on the checkout process.

I created my own custom checkout pane(it's a form). Also a submit function.

There are "commerce_line_items" in the order object, but then I get an error that says my entity is missing bundle. There is also 'commerce_order_total' that includes the totals? so I can't just edit the object/array?

This is how I create my line item:

$line_item = commerce_product_line_item_new($product, 1, $order->order_id);

This is how I am trying to add it to my order:

$order->commerce_line_items['und'][] = array('line_item_id' => $line_item->line_item_id);


texts:
I've been turning the internet upside down trying to find out how to simply override a contrib module's theme() file. Although I have find many ways that should work, no result pops up and I can't really troubleshoot why.

To be more specific, I want to override the output of the file (/sites/all/modules/contrib/commerce/modules/cart/theme/commerce-cart-block.tpl.php) through theme('commerce_cart_block').

Now, I've tried many things. I have tried something called suggestions trying trying to make a file named block--commerce--commerce_cart_block.tpl.php in my theme directory plus several other varies of names. I've also tried setting new path through custom_checkout_theme_registry_alter's passed array. But now changes are visible, with or without clearing the cache each attempt.

I'm clearly missing something since this should in my eyes be both easy to do and needed to be editable.

So the question in short; How can I with as good practice as possible override the theme file of a contrib module and use it's passed variables?


texts: Only show content in a View if the content has a checked field

texts:
On my content type, I have a boolean field which consists of a single on/off checkbox.

I have created a view, which shows all the nodes of that content type. However, I only want the view to show nodes where the boolean field has been ticked. How can I do this?

I thought in Views I could use "Filter criteria > Content: [Name of Field]."
However, when I select this, the only option available is "Select All". If I select this, I get the following error message:

  No valid values found on filter: Content: Show on Main Navigation.

What am I doing wrong?


texts: Does service module expect Base64 encoding for file uploads through http-post (drupal 7)?

texts:
I have been having trouble getting a file to upload through http-post from my lisp application and I have noticed in all of the curl php examples I have found they have a like this:

$file = array(
  'filesize' => filesize($filename),
  'filename' => basename($filename),
  'file' => base64_encode(file_get_contents($filename)),
  'uid' => $logged_user->user->uid,
);

which includes the call to base64_encode, I am not doing this from my lisp application and I always get a response of 200 but the file is not uploaded.  I am using Services 3.x and a RESt server.

Does Services require that file uploads are base64 encoded?


texts: manually entered redirects are going missing / deleted

texts:
My site is using the redirect 7.x-1.0 patched with no redirect loops and I am seeing some odd behavior.  Some 400 redirects have been manually entered into the site, and about a dozen of those are no longer there.  Six have been repeatedly entered and repeatedly gone missing.  There is nothing obvious about those in relation to the other that would make them rejected or targeted for deletion, and a user is not doing this.  I have added a hook_redirect_delete with a backtrace, but this has not happened in 2 the two days I have been watching sofar.

Any ideas?

Small updates:  My site is set to never delete redirects.  Some of the redirects disappear immediately, and some were working for over a year with no problems.  The 400 redirects in question all start with 'search/' because we want to shortcut certain keywords to certain pages.  One example being 'search/wine' => node/9303


texts: node/123 is not redirecting to its alias

texts:
I have something going on in my site that I didn't notice until now. I am using the Domain Access module to create multiple sites within one Drupal instance, so I'm thinking that may have something to do with it, since it's my only site this is happening to.

If I create a node, Drupal creates the page like normal i.e.: www.mysite.com/node/123. I can then give that URL an alias like "foo" and I can successfully go to that page by going to www.mysite.com/foo and it resolves to the correct page. HOWEVER, if I go to www.mysite.com/node/123 in the address bar, Drupal is not auto redirecting to "www.mysite.com/foo". It just stays at www.mysite.com/node/123 in the address bar. Does anyone know what could be causing this? I do have the redirect module installed. Also, my .htaccess files are in place and are the same as all my other sites that don't have this issue.


texts: Create 2 views exposed filters,one for parent term and one for child term

texts:
I want to create a view with two exposed filters,the first one with a parent term and the second one with a child term.Child term will be populated depending on the parent term that was selected on the first filter.

I want these two filters to exist always,not appearing/dissapearing of exposed filter of child term.

I.e. I don't want to use Simple Hierarchical select or Hierararhical select.
Is there a module for that?I am really impressed that such module doesn't exist in Drupal Or is this possible with some Javascript to disable the effects on Simple hierarchical select?


texts: How do I implement Entity Reference Behaviour Plugins?

texts:
Do Entity Reference behaviour plugins exist for Drupal 8? Please see:
https://www.drupal.org/node/1803064#comment-10717088
Are there any existing examples; documentation or code?

I would like to upgrade entityreference_prepopulate but I am unsure about these behaviour plugins.


texts: Is it possible to attach discussion board to a node?

texts:
I have a content type called "Movies". I would like to create discussion threads  under it similar to discussion threads in imdb.com under a movie. I have tried the advanced forum module and also brain forum module. They don't seem to do that I have in my mind.

Is there a module which does this job? I think I will have to use advanced forum module and use a content type for forum discussion and then use entity reference and entity reference prepopulate to link it to the other content type. Is there a better and cleaner way to do this?


texts: Using hook_theme_registry_alter to only modify specific pages instead of all pages

texts:
I have a custom module which invokes the hook_theme_registry_alter() to modify the presentation of some input fields.

However, I've discovered that the overridden styling is affecting ALL input fields on my entire site.

This is not good!

How to I make it so that my implementation of the hook_theme_registry_alter() is only seen on my module's pages?

Here is my function, and it is applying the theming functions to ALL radio and form elements on our site.

function MY_MODULE_theme_registry_alter(&$theme_registry) {
  if (isset($theme_registry['radio'])) {
    $theme_registry['radios']['function'] = "MY_MODULE_radios";
    $theme_registry['radio']['function'] = "MY_MODULE_radio";
    $theme_registry['form_element']['function'] = "MY_MODULE_element";
  }
}


texts: Hide Price by Role for a Content Type in Drupal 7

texts:
I am trying to achieve the following:
1> Hide Price Field for a Role only on a specific content type.

I am using Drupal Commerce.

Things I tried:
1> Field Permissions for the commerce_price field on a product. But because we using the same field across all product types the settings do not apply  to  just 1 product type.

2> preprocess_node
But could not access the price componenet. As it is a component inside the product reference field.

Could you please help me figure this out. Any help would be really appreciated!!

Links referred:
https://www.drupal.org/node/1496450
Is there a way to hide the price on a product using Drupal Commerce?


texts: What will be the url to show all content type posts?

texts:
OK i have created a content type. But what will be the url that will show the list of all posts in specific content type?
Basically I want to make a link or a menu item that will show all posts in specific content type but off course paginated.


texts: Customize "Access Denied" (403) page for specific content type

texts:
I'm currently setting up a simple LMS in Drupal 8 and would like to customize the Access Denied page as follows:

Anonymous users should be redirected to the Login page, when they hit a 403 error.
Logged in users trying to access a specific content type (a Course),
which they are not allowed to access, should be redirected to a
custom message (telling them to buy the course or something like
that). It would be even better, if they could be shown the teaser of
that node, but that's not a necessity.
In all other cases, I would like to show a general Access Denied page.

Fwiw, there were similiar questions for D6 here and here that also didn't receive any good replies.

Does anybody happen to know a good solution (for D8)?
Any help would be much appreciated.


texts:
I am developing a site where we'll have standard users and somekind of "VIP" users. VIP user can only register by invitation and should record who have invited by who. Besides, I want to have 2 registration forms for each type of user.

I was trying to use referral and registration_invite module but last one doesn't work properly. Referral module and seems useful to me since it store information about who refer who to registration form. But I need VIP registration path to be random (or someway unaccessible to users who have not been invited)


texts: Make an existing field as an autocomplete field in node form

texts: I have created a content type and in this node form i have a cck field 'name'. I want to alter this node form and change attributes of the 'name' field and add     '#autocomplete_path' => "taguser/{$node->vid}/autocomplete", to it. But i am unable to do it. Can you please let me know how to do it.


texts: How do I get the field definition of a paragraphs image field

texts:
I need to get the resolution of the image using getFieldDefinitions(). For normal fields I can get the field definitions with below.

$fieldDefinition = \Drupal::entityManager()->getFieldDefinitions('node', $type);
foreach ($fieldDefinition as $field_name => $field_definition) {
    $settings    = $field_definition->getSettings();
    $resolution  = $settings['min_resolution'];
}

How do I get the field definition of a image field inside of a paragraphs field.


texts: How to complement eMail notifications with a notification bar?

texts:
I am building a Drupal 7 website, and I noticed that you can install a facebook-like chat. This made me wonder if it is possible to implement something related to notifications that works something like Facebook. I simply want the notification "bar" to tell me if a user is posting a comment on my website, or if a new user has signed up. At this moment I just get an email about users trying to sign up.

I looked at the Notifications module for D7, but I am not sure this is what I am looking for. Or maybe I just don't know how to use it.


texts:
In D7 I could place and style a menu with a few lines in a mytheme_preprocess_HOOK function. for example:

$variables['page']['navigation'] = array(
  'section' => array(
    '#type' => 'html_tag',
    '#tag' => 'nav',
    '#attributes' => array(
      'id' => drupal_html_id('navigation'),
      'class' => array(
        'clearfix',
      ),
      'role' => 'navigation',
      'aria-labelledby' => 'main-menu-label',
    ),
    'menu' => array(
      '#theme' => 'links__system_main_menu',
      '#attributes' => array(
        'id' => drupal_html_id('main-menu'),
        'class' => array(
          'links',
          'inline',
          'clearfix',
        ),
      ),
      '#links' => menu_navigation_links('main-menu'),
    ),
  ),
);

As you can see this gave great control over markup and attributes for function and styling. The only way I can find to add a menu in D8 is via a block and to style via a TWIG template.

How can I add the menu in a preprocess?


texts: How can I invoke Drush command inside hook_cron?

texts:
I have module that provides drush integration.

Now I want to create modules with hook_cron where I want to launch drush command.

How can I run Drush command programmatically?


texts: How can I automatically add a comment to a node with rules

texts:
Can someone help me with this?

I have created a view that gives me a table of certain fields. Now I would like to add a "bulk operation" that lets users add an automatic comment to that specific node.

I have tried to ad a rule (component) and this was the result.

I have activated PHP-filter mode and tried with a component with "Execute custom PHP code".

The code in the component

<?php
$comment = new stdClass();
$comment->nid = $node->nid; // nid of a node you want to attach a comment to  (er stond 1)
$comment->cid = 0; // leave it as is
$comment->pid = 0; // parent comment id, 0 if none
$comment->uid = $user->uid; // user's id, who left the comment
//$comment->mail = 'email@example.com'; // user's email
//$comment->name = 'User name'; // If user is authenticated you can omit this field, it will be auto-populated, if the user is anonymous and you want to name him somehow, input his name here
//$comment->thread = '01/'; // OPTIONAL. If you need comments to be threaded you can fill this value. Otherwise omit it.
//$comment->hostname = '127.0.01' // OPTIONAL. You can log poster's ip here
$comment->created = time(); // OPTIONAL. You can set any time you want here. Useful for backdated comments creation.
$comment->is_anonymous = 0; // leave it as is
//$comment->homepage = ''; // you can add homepage URL here
$comment->status = COMMENT_PUBLISHED; // We auto-publish this comment
$comment->language = LANGUAGE_NONE; // The same as for a node
$comment->subject = 'Comment subject';
$comment->comment_body[$comment->language][0]['value'] = 'Afgehaald'; // Everything here is pretty much like with a node
$comment->comment_body[$comment->language][0]['format'] = 'filtered_html';
//$comment->field_custom_field_name[LANGUAGE_NONE][0]['value'] = ‘Some value’; // OPTIONAL. If your comment has a custom field attached it can added as simple as this // preparing a comment for a save
comment_submit($comment); // saving a comment
comment_save($comment);
?>

But when I go to the view and execute the operation, he asks for an identifier. But I want him to directly add the comment.

What I mean with the identifier

Can someone help me with this? Or is there another way?


texts:
In callback of custom  menu  wrote function , in function I want to use node_add ,
I have a field that I want add AJAX to it, but when change the  field nothing happened
where is the problem?
I am using Drupal 7

 module_load_include('inc', 'node', 'node.pages');
    $form = node_add('pre_register');
$form['field_course_display_ref']['und']['#value'][]=$nid;
    $form['field_course_display_ref']['#ajax'] = array(
      'callback' => 'myfunction_ajax_change_course',
      'event' => 'change',
      'wrapper' => 'course-schedules-div',
      'method' => 'replace',
      'effect' => 'fade',
    );
    $form['field_course_schedules']['#prefix'] = '
';
    $form['field_course_schedules']['#suffix'] = '
';

I also try

 module_load_include('inc', 'node', 'node.pages');
    $form = node_add('pre_register');
$form['field_course_display_ref']['und']['#value'][]=$nid;
    $form['field_course_display_ref']['und']['#ajax'] = array(
      'callback' => 'myfunction_ajax_change_course',
      'event' => 'change',
      'wrapper' => 'course-schedules-div',
      'method' => 'replace',
      'effect' => 'fade',
    );
    $form['field_course_schedules']['#prefix'] = '
';
    $form['field_course_schedules']['#suffix'] = '
';

but nothing happened :(

EDITED I have two field, one field_course_schedules (will wrap) and field_course_display_ref The field that I want but changing it ajax will be trigger.

type mistaked in code corrected but not worked again


texts: Cell Phone Validation field using sms message

texts:
I recently want to develop a field for user account.

The Field will provide a cellphone textfield and a validate button!

After finishing the cellphone textfield by the user, The user push the validate button.

Then, the system will send the sms message using ajax.

After sending the validate code message to the user, the system will respond the CODE to the client side. However, the cell phone textfield is invisible right now.

Finally,the user enter the code get from sms message and then push the button.

The system will check the code by ajax and then return the correct/false value to the client side.

After the steps above, the system will hide all the field and show the result of the validation.

My question is how can I do that?


texts: How to get real thumbnails (not onthefly scaled down large originals) in grid from media gallery depending on certain tag using views

texts:
I would like to use Views to display, in a block, real thumbnails of images uploaded using tools based on the Drupal 7 Media Gallery module in a grid of images with a certain tag.

By real thumbnails, I mean either cropped small images of the original or the entire original reduced in size. This kind of thumbnail is efficient at loading. I do not want thumbnails which are simply the browser's on-the-fly scaling down of the original.


texts:
I am using drupal 7 and the ViewsPDF module to generate PDF's from my content. One of my content types has a map that I have done using a geofield. While trying to export the node as a PDF everything gets printed except the map. I've done a bit of asking around before posting this.
Anyone with a solution to this?


texts: Blank spaces opening RSS XML file - How to solve?

texts:
All of the sudden, we are experiencing problems with our RSS feed which comes with the Drupal core 7.x . It is no longer valid due to two spaces before the opening XML tag. The following error is what I get in the feed validator:

  line 1, column 2: XML parsing error: <unknown>:1:2: XML or text declaration not at start of entity

So I am aware of other related posts on Stack Exchange and tried the things mentioned in:

Approach to removing extra space at beginning of RSS file?
xml sitemap module : XML declaration allowed only at the start of the document [closed]
RSS Feed does not validate using Views RSS module

These are the things we did do so far:

Checked all PHP-files on the website for containing blank spaces before the opening tags. There were a few, we fixed them all but no help.
Changed the default theme to another theme, making sure it is not theme related.
When I create a custom RSS feed with Views, the same two blank spaces show up before the XML opening tag.
I checked every page, block and view that has manually written PHP tags everywhere and deleted every space that could cause this.
All modules and Drupal core is updated to the most recent versions.
I checked on the Drupal forum for related issues in XML Sitemap, Metatag, RDF, Schema.org (modules we are using) with no success. I disabled every one of the above mentioned modules one by one, but with no success.
Eventually we exported the complete website, except the sites/default/files/ folder which contains no PHP files anyway, and imported it local. The blank spaces are gone in the local setup.

What makes it a bit difficult too, is that I have no idea when the RSS feed went broken. It can be between a week and a few months, making it difficult to filter out when I updated some contrib modules.

So we are quite desperate in finding this, especially since the problem doesn't exist in a local setup. We have a news website so having a working RSS feed is pretty important.

We must be overlooking something, but have no idea what it can be.


texts: Just wondering if anyone knows why uuid columns created by Drupal 8 in MySQL are of type VARCHAR(128), not CHAR(36)?


texts: Drupal.behaviors get results from function

texts:
I am struggling to understand how this works and I just can not get a grasp of if it. Basically what I am trying to do is get the results from my php function and pass it into ajax to make my page redirect to a certain area.

This is what I have for my php

function paydayform_submit($form, &$form_state){

    $entry = payday_parse($form, $form_state);

    /*if($entry['response'] == "sold"){
        print 'success';
    } else {
        print 'failed';
    }*/

    drupal_add_js(array('payday_form' => array('redirect'=>$entry)), 'settings');

}

And this is where I am completely lost and in the dark at.

(function($){
Drupal.behaviors.payday_form = {
 attach: function (context, settings) {
    $('#edit-submit', context).once('payday_form', function () {
        $(this).click(function(){

            //Response from payday_parse($form, &$form_state)
            final_redirect = Drupal.settings.payday_form.redirect;

                    //this comes back as undefined =/
            console.log(final_redirect);

            //if statement giving from the response above.
            if(final_redirect = 'success'){
                console.log('worked');
            }else{
                console.log('didnt work');
            }
        });
    });
    }
  };
})(jQuery);

Am I using this correctly? What am I doing wrong that it isnt picking up the function?


texts: Site upgrade to D7 using drush stuck on the "Run update.php" step

texts:
I am attempting upgrading my site from D6 to D7 using Drush Site upgrade.

The process gets stuck on the 13th step. This is the last output I get :

    UPGRADE.txt Major Upgrade Step 13

13. Run update.php by visiting http://www.example.com/update.php (replace
    www.example.com with your domain name). This will update the core database
    tables.

    If you are unable to access update.php do the following:

    - Open settings.php with a text editor.

    - Find the line that says: $update_free_access = FALSE;

    - Change it into: $update_free_access = TRUE;

    - Once the upgrade is done, $update_free_access must be reverted to FALSE.

Note that Drush will copy your database and run updatedb on the copy. The
source database remains unchanged.

Drush will automatically do this step now.

Why is this happening and how can I fix it?


texts: Can I run a site on AWS Elastic Beanstalk for PHP?

texts:
I'm looking at AWS Elastic Beanstalk.

Does Drupal 7 run on AWS Elastic Beanstalk for PHP?

Any extra info regarding caching and performance (e.g. comparison with PressFlow, or Memcache) is welcome.


texts: How to add “Quote Request” button on some products?

texts:
I'm using Drupal Commerce and I want a quote button on some product (node) page so that a potential buyer can enter some brief information and click to send a Quote Request for the item that they are viewing.

I have a product type called "Premium products", and I want this Quote Request button instead of price to be on some page.

On clicking the Quote Request button and asking a quote to the seller, the seller may respond to the query and tell the proposal amount for the product which user can accept or reject. Once accepted by user, the product should be added to the user's cart with the purposed price.


texts: Pathauto pattern for a content type depending on a reference field?

texts:
This question is already asked here, but the answer selected does not work for Drupal8.
Description: There is a content-type, which has field, referencing taxonomy term. The term is in "Content class" dictionary. This term is used in views to filter the right content for the view. When a link in the view is clicked, it opens the node. This is OK.
So, it is needed pathauto to generate /Content class term/Content_title_name when this node is opened.
What did not work:  [node:field_content_class:value]/[node:title]. This is not accepted, produces error: Path pattern is using the following invalid tokens: [node:field_content_class:value]
The accepted (by Drupal) pattern:  [node:field_content_class]/[node:title] generates alias, containing only the [node:title] part. The first component is empty.
This is made to not create separate content-types for nodes with the same fields.
EDIT: The accepted answer works on a fresh copy of Drupal with language translation enabled. I continue to investigate the case with my production site.


texts: In Drupal 7 Views how do you set permissions via roles for an attachment display?

texts: I am trying to set roles permissions for my attachment view, but every time i set the roles permissions it affects the master display aswell. I want my attachment display only viewable to admin's of the site. Am i missing something or should is there another alternative to this issue?


texts: How do I get the node ID from the taxonomy term ID?

texts:
In Drupal 7, we are using taxonomy_select_nodes() to get a list of nodes using a taxonomy term.

What is the equivalent in versions after Drupal 7?