texts: Need to save node twice to get wanted result

texts:
I have made 2 custom tokens that I use to determine the URL alias in the Pathauto pattern. They work fine too, but since my custom tokens rely on certain (taxonomy) fields in the node, they always get the "old" field value when the user changes them. The url alias isn't correct until the second time I save the node. Thus I need to "presave" the node immediately when the user changes the field value, so that the new token value is taken into consideration when saving the node... How can I do that?

Since the change is done on the client side I would need to use Ajax to call node_save or hook_node_presave directly when the field value is changed?

Any help is appreciated :-)

EDITED: I have realized that I probably need to write a JS script that uses ajax to call a php function that saves the node when the field is changed. So the question now is if that is wise to do when the user is in the editing mode… ?

Edited again:

I finally worked it out. I skipped the JS solution and opted for using field_attach_presave('node', $node) and field_attach_update('node', $node) in the function hook_node_presave. Doing so permits to save 2 specific fields programmatically just before the node is saved definitely by the user. And Pathauto can use those 2 fields as tokens for my URLs. It works too :-). There are many reasons for this non straight-forward solution, a bit to lengthy to explain here (migration is involved among other tings). But I am happy with this solution. Thanks for the input though!


texts: Is it possible to create 'grouped' fields of related data?

texts:
I have a content type (Recipe) in which my users can add ingredients (terme references). I also have a text field to enter quantity
How is it possible to link this "ingredient" field to the quatity field?

I want to recreate something like this (from Recipe module) :


texts:
I would like to add a field to my node that allows the user to search for a location like a city and pinpoint that location on the map or pick a location on a map but without having to zoom in from viewing the whole world (like the problem I am having using the geofield).
Cheers


texts: In Drupal 7, how i can use the taxonomy-term at the automatic creation of url alias of a content path?


texts:
I use the following code to create a node.

    $datetime = "2016-08-01 12:30:00";
    $values = array(
      'title' => $data['title'],
      'body' => $data['body'],
      'field_client' => $uid,
      'field_appointment_date_time' => $datetime,
      'type' => 'appointment'
   );

  $appointment = Node::create($values);
  $appointment->save();

The problem is that field_appointment_date_time (a Datetime field) is not been saved.

Why does this happen?


texts: How do I create a configuration menu with the selected section name?

texts:
I want to create a menu in the admin section that is in the sitename/admin/config path.

As of now, I am doing this.

Routing file

custom_menu.adminmenu_section:
    path: '/admin/config/custommenu'
    defaults:
        _controller: 'Drupal\custom_menu\Controller\CustomMenuController::content'
        _title: 'Custom Menu Configuration'
    requirements:
        _permission: 'administer site configuration'

custom_menu.admin_menu:
    path: '/admin/config/custommenu/customconf'
    defaults:
        _form: 'Drupal\custom_menu\Form\CustomMenuForm'
        _title: Custom Menu creation
    requirements:
        _permission: 'administer site configuration'

links.menu file

custom_menu.adminmenu_section:
    title: 'Configuration'
    description: 'Custom Menus Configuration section'
    parent: system.admin
    route_name: custom_menu.adminmenu_section

custom_menu.admin_menu:
    title: 'Custom Menus Conf'
    description: 'Custom Menus Configuration section'
    parent: custom_menu.adminmenu_section
    route_name: custom_menu.admin_menu

This code is not creating a section in the admin/config path. But when I used  parent: system.admin_config that time I will get menu in the admin section but the section name will be CONFIGURATION. Because its title given in the system.admin_config route, but I don't want that name.

I want to create a section with separate name. How can I achieve that?


texts: How declare my service via dependency injection in construct?

texts:
i have a class

  Paybox

This class is declare as a service.

In my controller class, i inject this service like this :

public function __construct($payboxService) {
    $this->paybox = $payboxService;
}

public static function create(ContainerInterface $container) {
    return new static(
        $container->get('paybox_services'),
    );
}

This declaration work fine, but i see sometime this in the constructor :

public function __construct(Paybox $payboxService) {
    $this->paybox = $payboxService;
}

public static function create(ContainerInterface $container) {
    return new static(
        $container->get('paybox_services'),
    );
}

They add the Type Paybox before $payboxService.

The 2 method work.

Can someone explain me the difference ? and what is the right way for inject the service ?


texts: I have a specific user role with a profile attached too them. Every user with this role has a corresponding node with the same information that can be found on the user's profile. Now I'm looking for a way to keep the two in sync, so if you change the user's profile, it would update the corresponding node as well. Is there a way to hook in to Profile2's form submit handler, or something similar?


texts:
I am using Drupal 7, and I have strange problem with meta tags. For some content type even if I enter meta title, meta keywords and description, they don't get effective on page.

Where in for some content type it does reflect the meta information.

How can I narrow down the problem? I have no idea how I can make use of meta tag quick module for my problem because meta information is not getting generated.

How can I debug where the problem exists?


texts: How do I remove the underscore a view adds to a rewritten link?

texts:
I am using fields, one has a link, rewriting the link as shown below sending the datetime to webform in the URL. All fields display as they should. When hovering over the link, the URL shows extra space at the end of each field as an underscore as follows. The underscore is not in the datetime field.

  2018-05-14T15:39:15-0400_

As seen above the underscore is added. Webform wont prepopulate the datetime field element with the underscore. When manually writing the value, webform correctly prepopulates my webform.
The link is /appt_testform?apptdatet={{ field_apptdatet }}&body={{ body }}, which becomes /appt_testform?apptdatet=2018-07-15T18%3A00%3A00-0400_&amp;body=Testing%20the%20appt%2C%20test%20and%20recommend. The underscore after 0400 should not be there.

I see an underscore is added to other fields, which accept values where the datetime will not. I am trying to do this without using hook_form_alter().

After testing on 5 servers using different 8.x versions
When importing using feeds module CSV file,
If the content field is date and time..imported using feeds then View linked to webform to prepopulate it will add the underscore as shown in the original question.
If a field is timestamp (unix number in CSV) after importing, the view rewrite results link does not have the underscore added. I don't know why, however, my site works using the timestamp field type. On all the servers.


texts: Conditional Fields with multiple conditions

texts:
I am using Conditional Fields module. I need some guidance when setting dependencies for multiple fields (accepting unlimited values). Here is the situation:

In my entity form I have two fields:

Assignment Status --> This is Select List type with two values DRAFT and FINAL
Upload File -->  This field is required field for accepting documents from student ONLY when Assignment status is FINAL else it is optional field.

Now my question is when I am using this case and creating Dependent and Dependee relation only for one assignment this work fine but when I give an option for accepting unlimited values the Conditional Fields doesn't work.

Because one student is required to submit more than one assignment I used Paragraph Module and also tested this case also  with MultipleFields Module. I am not able to find any answer to my query. Please help me to find this answer.


texts:
We are moving to a Drupal distribution. From all the research we have done, there is no easy path to do Drupal 8 to Drupal 8 migration.

We are looking to copy some content via phpmyadmin.

Data we need to move are:

Taxonomy
Nodes
Comments

Which tables do we need to copy from one database to the new?

We did copy the users successfully.

Now wondering if we can do the content as well.


texts: Store per-user data in field and extract using SQL in Views sort plugin

texts:
TL;DR: This is less a question about how to write a Views sort plugin, and more whether I can serialise key/value pairs and selectively sort by one of them using SQL functions.

I have a content type with a comments field.

There's a corresponding view with an exposed filter where you can select a user from a dropdown.

I wrote a field handler which scans the comments (remember: a comment field only contains settings and stats, comments are their own entities, so you have to load them separately) to see if the selected user has left a comment on each node.

This generates a 'Commented?' column for the view:  Yes / No, no. of comments etc.

Currently, the result isn't stored in the DB, it runs every time.

The challenge is making the column sortable, given the results are different for each user you may select.

I'm assuming the only practical way to do it would be to store the result in the DB (to be updated after comments are created/deleted), so I can use $this->query->addOrderBy() in SortPluginBase.

It would need to be scaleable though - i.e. a single field with all the values, not one field per person.

If I serialised the value (e.g. uid/result key/value pairs) and stored that in a field, it would be easy enough to rewrite my field handler to display the correct result in an unsorted view.

But, for the sorting, is there any SQL I could use to extract the value of the correct key? (This would also need to cope with situations where a new user has been added, but no data is stored for them on the legacy comments, e.g. a default/fallback value if the key is not found).

Or would anyone recommend an entirely different approach? (There is HOOK_views_pre_render(), but looping through results there seems a bit ugly...)


texts: How to Display Hierarchical Vocabulary Terms in URL Pattern Separated with Slashes

texts:
I'm not sure if this is the appropriate place for this question (I'm a self-proclaimed newbie)...I have a vocabulary with the following scheme:

category1
    subcategory1a
    subcategory1b

I'm trying to create a URL pattern for the content path so it has the following URL pattern: category1/subcategory1a/[node:title].  I have Drupal 7.22, Entity API 7.x-1.0-rc3, Token 7.x-1.1, and Pathauto 7.x-1.1 and have been trying different token patterns in the URL aliases
section.  If I set the pattern to be [node:field-VOCABULARYNAME]/[node:title], then the URL alias generated is: category1-subcategory1a/[node:title].
Is there a way to have a "/" appear between the parent term and subterm instead of a dash?

Or is there a way to create the pattern: [node:field-VOCABULARYNAME:0]/[node:field-VOCABULARYNAME:1]/[node:title]?

The tokens related to individual content items ("nodes") listed are:

[node:field-VOCABULARYNAME]
    [node:field-VOCABULARYNAME:1]
    [node:field-VOCABULARYNAME:2]
    [node:field-VOCABULARYNAME:3]

If I set the pattern to [node:field-VOCABULARYNAME]/[node:field-VOCABULARYNAME:1]/[node:title], then the URL alias generated is: category1-subcategory1a/subcategory1a/[node:title].

In my content type, I have the field that's tied to the vocabulary is set up as a Hierarchical Select widget with Term reference as the field type.

I found these StackOverflow and Drupal Answers posts and it seemed most relevant to me, but I do not have the taxonomy term tokens listed.

Thank you for your guidance


texts: Show different fields when adding a content depends on the language

texts:
i have a question about a multilanguage feature which i don't find. I have contenttype with many fields (about 20 fields). Now i want to translate this page in a few languages. My problem is that some fields (the content of the fields) are only visible for a specific language like italian for example.

So the first idea could be to add additional fields to the contenttype for the specific languages. In aspect to the code i would render the specific field depending of what language is selected on the page.

But in relating of adding a content this could be very confusing with many languages.

So my question is: Is it possible to show fields when adding a content depending on what language is selected for the new content. For example when i have a field which should only visible for the italian translation.

Is this a known problem?


texts: Dropdown with Search Box + Views - Without Using Taxonomy

texts:
Okay, so I have been searching Google for weeks on how to do this, and I have kludged some stuff together.

I want to combine a dropdown for year values, and combine it with a search box.

Now, I've figured out that I can create a view, and then pass contextual arguments through the URL. That works perfectly. I can get results for brakes manufactured for cars in 1977 by visiting the URL http://example.com/cars/1977,brakes.

I am trying to configure the interface that will pass the query now. I can do this by passing to a php function outside of Drupal core or related modules. As much as possible, I would like to keep this within the Drupal 7 interface.

My best guess now is using hook_form_alter to alter the url before it is passed. I am also guessing it would have to register a state change and grab the fully built url before passing it. Sorry if I am rambling here.

Has anyone ever built anything like this in D7? I know there was a module in D6 that did something close to this, but it has not been ported to D7. Any help would be much appreciated, with links to either tuts, or code examples.

Gracias.


texts: How to embed "Exposed form in block" into top bar? Using foundation theme

texts: I have a product search view. I use the "exposed form in block" in order to have only the filters show on all pages and the results show on a separate page. I want to put my filters in the top bar. How would I embed the "exposed form in block"? I know how to embed a view but I cant figure how to embed the "exposed form in block." in the top bar (the nav). The biggest reason is because its not a region. So I cannot place the block in it from the structure>blocks. Ive tried moving my header region to be on top of the nav but this create issues also. I was thinking that maybe there is a way to print the "exposed form in block" in the page.tpl.php... is this possible? Or will I have to use a hook in the template.php? Or Can I redefine the nav bar as a region possibly?


texts:
I'm using Drupal 7 and have added checkboxes to a node.

$results = query();

foreach ($results as $result) {
  $name = $result['name'];
  $resultarray[$result['id']] = $name;
}

$form['friends'] = array(
  '#title' => "results",
  '#type' => 'checkboxes',
  '#options' => $resultarray,
);

On my node the checkboxes show.

Now I'm struggling to get the values of selected checkboxes.

function friendmodule_form_submit($form, &$form_state) {

  $friends = $form_state['values']['friends'];

  // do what ever with $friends
}

But nothing displays. I've tried echo $friends, print_r, display them as a Drupal message, but nothing is showing.

What should I do to get the values of selected checkboxes?


texts: Can't migrate my website from localhost to webhost

texts:
I can easily install Drupal 7.37 on my webhosting. But cannot migrate the existing website.
I uploaded all the files. Imported the database. Changed settings.php accordingly. But what I see is only 404 - http://www.hostinger.com.ua/oshibka_404.
The basic link is www.orger.besaba.com. What do I do wrong?


texts: How to redirect request to another page in drupal 6 based on a session variable

texts:
I have installed Drupal 6 and working on custom module.

I want to redirect all user request to a confirmation page when he try to access any other URL.
The flaw is :

User login
If user status is set get confirm set a session variable and re-direct to another page
Confirm or cancel
When ever user try to access any other page show the confirmation page

I have an issue when user do not select any option and type the URL and go to another page. Then I want to check the session variable and redirect the user to confirmation page.

I tried with Drupal hook_init function implementation on my custom module but it gives a redirect loop.
CODE :

function customprints_init() {

    if ( $_SESSION['show_print_size_confirm'] && $_REQUEST['q'] != 'print/confirm/size' ) {
        drupal_goto("print/confirm/size");
    }
}

I can not do the check in template files as there are about 50 template files.

Is there a way to do this properly in a hook function or in a common place.


texts: Link image to another view mode with Media 2 and File Entity

texts:
I'm trying to test Media 2.x and File Entity. I've edited the "Image" File Entity to add taxonomy terms and all and then I'm trying to leverage views to list all images in a grid in a page, and my end goal is to be able to click on a thumbnail and then get a larger image with more details.

I'm finding it complicated (impossible?) to link the images to another display (teaser to full content for instance). It works just fine with regular "Content" views but it seems that when you start with the "Files" view this is not an option.

Do you have any idea what I'm missing? Is there a way (relationship or anything) to be able to get the "Link this image to its content"-like option?


texts: How to add / update a field collection without updating parent node/entity?

texts:
I needed to to add / update field collections to node entities without updating the node entities. I tried two ways listed in https://www.drupal.org/node/1842304 and http://alexrayu.com/blog/saveupdate-field-collection-without-nodesave but none of them seems to be working exactly the way I want.

I tried as follows:

$node = node_load($nid);
$field_collection_item = entity_create('field_collection_item', array('field_name' => 'field_college_rating_data'));
$field_collection_item->setHostEntity('node', $node);
$field_collection_item->field_text1['und'][0]['tid'] = $form_state['input']['field_text1']['und'];
$field_collection_item->field_text2['und'][0]['value'] = $form_state['input']['field_text2']['und'];
$field_collection_item->save();

It added a field collection but it updates the node.

I also tried to alter the field collection form submit and used custom submit handler as follows:

function own_custom_field_collection_submit($form,$form_state) {
  $field_collection_item = field_collection_item_form_submit_build_field_collection($form, $form_state);
  $field_collection_item->save(TRUE);
  drupal_set_message(t('The changes have been saved.'));
  $form_state['redirect'] = $field_collection_item->path();
}

I have copied this code from core field collection module to change the default argument to "TRUE" in the save function. It added the field collection but didn't associated with the parent node.

I need to save the field collection separately since my node entity form is very large with 50 to 60 fields and field collections and I don't want to update it as many times as I add / update any field collections to the node.

Any help?


texts: How to remove white space from a field using Search API module

texts:
I'm using Search API and Search Views to search the Drupal user database.

One of the fields is phone number where users are able to enter free text.

I can include this field in the search, but the search will not pick up part words.

E.g. 6162 5555 - does not display when I search for 25555 because the index sees these terms as separate words.

Is there a way to strip all the site space (and maybe then brackets) from the field before it is indexed by Search API?


texts: Where to look for a forum thread in database?

texts:
In Drupal 6 forum, a user reported that her thread has suddenly disappeared.

I am wondering in which database table should I look for the thread, and what might be the cause?


texts: How to align three blocks on the front page using CSS

texts:
I've got three blocks on my front page and I want them to be centered and aligned.

"About us" block is to be aligned to the left side of the front page what I managed to achieve. The other two blocks are to be aligned to the right side of the front page and one above the other what I managed to achieve as well.

However:

Different browsers show different results which is caused by the reference of the language switcher block I guess. It is moving my right hand side set of blocks up and down. IE is showing the result I would like to achieve (the example: test site).
I would like to be able to reference language switcher block to the content region which is not the case right now and I am not sure how to do it.

Can someone help or guide me into the propriate direction?

Thanks and regards


texts: How to broadcast a message to several Drupal web sites?

texts:
I have several Drupal installations and I want somehow, to send a message that would be displayed in all of them at the same time, in a block for example.
The scenario could be that the server will be down for maintenance, so I want to show a message on the admin section alerting this.

My first thought is trying to use something related with RSS Feeds, but if anyone has experienced the same situation any feedback will be appreciated


texts: Getting empty CookieJar when using cookie authentication with Python

texts:
I have a problem to acquire cookie through cookie authentication for RESTful in Drupal 8.
In the beginning, I enabled the Basic Authentication module, but unfortunately, it does not work with my hosting platform, can't find where to enable it - the whole site becomes a 403 error after the Basic Authentication module was enabled. Would appreciate input on this question also. (Running AWS LightSail Ubuntu 20.04 with Plesk Obsidian hosting platform)
Then I tried to use cookie authentication but seems it doesn't work either. Gettig, as a result, the HTML of unauthenticated /user/login page with response code 200 and empty CookieJar[] in response.
auth = ('user', 'pass') used to bypass additional site restricted area login.
Also, I have a recaptcha_v3 on the login page, but seems it not a problem because I tried with a local network computer where the captcha not enabled and no restricted area, and got the same empty CookieJar.
Here the code:
base_url = 'https://demo.site/drupal-8/'
auth = ('user', 'pass')
verify=True

login_endpoint = base_url + '/user/login'
token_endpoint = base_url + '/rest/session/token'

#Post the new node (a Contact) to the endpoint.
session = requests.Session()

token = str(session.get(token_endpoint, auth=auth, verify=verify).text)
print("Token: " + token)

#Set all required headers
login_headers =  {"Content-Type":"application/x-www-form-urlencoded"}

#Include all fields required by the content type
login_payload =  '''{
        "name": "restuser",
        "pass": "password",
        "form_id": "user_login_form"
    }'''
response = session.post(login_endpoint, data=login_payload, headers=login_headers, auth=auth, verify=verify)
print(response.status_code)
cookies = session.cookies
cookies_params = cookies.items()
print(cookies)

Output:
Token: jEk96ZdvXQIeOs2wukL-s-tkfGRc56PsxsyVBER-g84
200
<RequestsCookieJar[]>


texts: Why are the images missing in newsletter emails created using Simplenews?

texts:
I have created newsletter using the Simplenews module. I have inserted images using the WYSIWYG editor. The mail received is missing those images. There is no indication of images in the newsletter. How to make the images appears in the newsletter email?

mailsystem: SMTP


texts:
I've inherited a site that connected with memcache even though its not necessary and its not installed on the server. Although I've disabled the memcache module,
the settings file has these lines which I cannot delete or the site stops working:

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['cache_default_class'] = 'MemCacheDrupal';

I am getting this log message every two or three minutes:

  Failed to connect to memcache server: 127.0.0.1:11211

Clearing the Drupal cache and restarting Apache do not seem to fix the problem.  How can I fix this?


texts: How to create another Front Page and switch between the two? (in dev process)

texts:
I am working on creating an alternative front page for an existing site. I do not want to disturb the existing front page but I just want to create another page (which I will later point to as front page - once design is complete).

Question: How do I create a page where I can add Blocks and other items? (I did it from Views - but doing so from Views requires me to add fields).

I do not want to add fields from views - want to do it entirely with blocks (even in the main content area)


texts: How to subtract two columns with db_select()?

texts:
I have a db_select query that outputs two columns.  I want to find the difference between these columns, output to another column, and then put a condition on this third column.

Here is a mysql query that I want to convert into db-select:

"SELECT *, `column1value`-`column2value` AS `difference` FROM `mytable` WHERE `difference` > 55"


texts: Why do I get "Type does not correspond to an entity on this site" when POSTing to REST api behind an Apache Reverse proxy?

texts:
I have the REST api configured to allow POSTing new users to /entity/user. On my local machine, it works just fine. Once I push up to my remote host, it stops working.

The key difference is that on my local machine, my site is running in a docker container bound to port 6050, so all rest calls go to localhost:6050.

On my remote host, I have docker configured behind an Apache 2.4 reverse proxy. So the docker container is still bound to 127.0.0.1:6050, but all requests should go to https://sub.example.tld/.

To summarize, posting a new user to http://localhost:6050/entity/user?_format=hal_json, with the appropriate X-CSRF-Token and Content-Type headers set, works. It returns 200.

Posting to https://sub.example.tld/entity/user?_format=hal_json, with the appropriate X-CSRF-Token and Content-Type headers set, does not. It returns 422 Unprocessable Entity.

{"message":"Type https:\/\/sub.example.tld\/rest\/type\/user\/user?_format=hal_json does not correspond to an entity on this site."}

In the recent log messages, I see:

Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException: Type http://sub.example.tld/rest/type/user/user?_format=hal_json does not correspond to an entity on this site. in Drupal\rest\RequestHandler->deserialize() (line 201 of /var/www/html/web/core/modules/rest/src/RequestHandler.php).

I do manually set the user's "_links" array:

"_links": {
        "type": {
          "href": "https://sub.example.tld/rest/type/user/user?_format=hal_json"
        }
      },

I know that authentication isn't the issue. My code is successfully accessing views that require authentication.

Since I think it might be something to do with these settings, I do have the following set:

$settings['trusted_host_patterns'] = ["$sub\.example\.tld$"]
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ["internal network ip","172.18.0.1","127.0.0.1"];

I'm running Drupal 8.7.3.

My docker image is based on php:7.1-apache.

Any ideas what I'm doing wrong?


texts: Associating comments with special pages/module output

texts:
I have what one could consider an "irregularity" in a Drupal module. I have this unique case (mostly due to vendor inconsistencies and ever-changing requirements) where when a user requests a certain item (in this case, something from an inventory database), a hook_menu() call routes them to a callback that polls the inventory API (a REST service), and we pass that REST data to the user through a theme call in Drupal. Attempts to actually display the data directly to the browser are mostly unsuccessful due to CORS issues, and nobody is answering the phone at the vendor.

I've been informed there are some additional requirements that require our newly minted psuedo-content to host a "Comments" section, which if my knowledge of the CMS is clear, only associates with items the system is storing, e.g Entities and Nodes. Before I ask about a definitive solution, I should ask, if there is any way to convince the CMS otherwise, and track a comments record for this faux-content, or if my only option is to save this data as a node (even if its just a single field), and then 301 Redirect to it once saved. Any thoughts? I know this is a rather abstract question with an equally abstract solution, but time constraints make longer-term solutions unobtainable for now.


texts: How to obtain a list of the submodules of a module using Drush?

texts:
I want obtain trough drush a list of the availables submodules that comes inside a module.

So far this is what I have achieved:

drush pmi views_*

I obtain a detailed info for all the modules and themes starting with views in his name. (views_ui, views_bulk_operation, etc)

drush pml views | grep views_

In GNU/Linux systems I obtain a list of availables modules and themes starting with views_ in his name (views_ui, views_bulk_operation, etc)

But I can't obtain only the submodules of a module.

Edit: I'm using Drush 5.10.


texts: Where does a blank theme inherit its templates from?

texts:
I just enabled my theme only containing an MYTHEME.info file. Now I have one query here.

As a output I got broken page. I have checked source of this page. I got some HTML structure.

As per my knowledge, theme renders from html.tpl.php. But my theme doesn't contain this file. So from where did it get its HTML structure?

From any core theme/themes?

I have also disabled all previously enabled themes except for the admin theme.


texts: Split Delivery : Drupal Commerce future : 2 qty in differnt Address : Single Order in Multiple Address

texts:
I want to create split delivery functionality in Drupal 7. I want to split qty in differnt delivery address.ex
Like Product A have 2 qty .I want to deliver 1 qty to my friend house and 1 to  my Address.Please give some suggestion?


texts: Do new routes require a static first portion?

texts:
Using mymodule.routing.yml, I can successfully create a custom route at /foo/{bar}/{baz}, but I cannot use /{bar}/{baz} or /{bar}/foo/{baz} as path for a route; they just return a 404 error.

Why? Is there any way to create a route for /{bar}/{baz} (with strict requirements for bar)?

I've read the entirety of the routing API and I can't seem to find any answers.


texts:
Why aren't nodes indexed when they are saved?

As we all know, node_update_index is invoked by search_cron, which means that the search index is only updated as frequently as cron runs.

I am curious why _node_index_node isn't part of the normal node_save process, eg

if ($node->status == NODE_PUBLISHED) {
  _node_index_node($node);
}

Is there a good reason for this?  Since this function is defined by the node module itself, I don't see how it is a separation of responsibilities thing, nor can I think of a good reason for not doing this.

The related question would be, is is safe to wire up an action to fire when a node is created or updated?


texts: Why don't breadcrumbs appear on views generated pages?

texts: I'm maintaining a site I didn't build and I'm running into an issue with breadcrumbs. Pages generated by views don't seem to conform to the existing bread crumb system. For example I have a members section page, which has a sub page with a list of links. The links created from basic pages show the correct breadcrumb trail (i.e. home->members->subpage1->subpage2), while the views generated pages only show a breadcrumb trail back to home. So what is causing this? How I work the views pages in the breadcrumb system? Does each views page need it's own template?


texts:
I am struggling to work out how to print a node body on a page.

I normally use something like this print $node->field_manufacturer[0]['view']; but I am unsure how to print the body of a node.

How can I achieve it?


texts: Help needed with ajax request from Jquery to callback function

texts:
I create the callback url 'swish_payment/request' in my hook_menu() function:

function swish_payments_menu(){
  $items['swish_payment/request'] = array(
    'type'             => MENU_CALLBACK,
    'page callback'    => '_ajax_payment_request',
    'access callback' => TRUE,
    'file' => 'src/controller/CallbackController.inc',
  );
  return $items;
}

In the file CallbackController.inc, saved in the folder 'src/controller' stated after "file" above I have this:

function _ajax_payment_request() {

  drupal_json_output('It works!');

}

..just to check that the callback works.
And this is how the js looks like in the client ('number' contains a string):

$.ajax({
  data:number,
  dataType: "json",
  type:"POST",
  url : "swish_payment/request",
  cache: false,
  success: function (response) {
    console.log(response);
  }
});

Under the networks tab i Chrome I can see that the url 'swish_payment/request' is found with a 200 code. But the console stays blank.

Can anyone give me a hint on what I am doing wrong?

EDITED: turns out that it worked when I moved the function from the external file into the .module file. Apparently it's a bad idea to split code into several files.


texts:
Is it possible to get Views to return only block data markup and nothing else?

I am trying to get the block data via AJAX and place it exactly where I want it.
I just wonder if I can filter way all the surrounding HTML markup.

I have looked into the Output theme for my View but the markup is only for the data generated rather than for the entire page so I can't edit it there.

I'll appreciate any suggestions.


texts:
i'm trying to make a 'top voted' view of nodes and I want it to appear like this:

title of node; 655 positive, 120 negative votes, total 775.

how do i do the '655 positive, 120 negative votes' part?


texts: drupal site is really slow on VPS server

texts:
I have a drupal 7 website on a VPS server with the following specifications:

Processor Name: Intel(R) Xeon(R) CPU E31270 @ 3.40GHz

Processor Speed (MHz):  3392.294

Total Memory:   3924628 kB

Free Memory:    276096 kB

Total Swap Memory:  4063228 kB

Free Swap Memory:   3894104 kB

Apache 2.2.29:  Running

DirectAdmin 1.47.0: Running

Exim 4.84:  Running

MySQL 5.5.31:   Running

Named 9.8.2rc1: Running

ProFTPd 1.3.5:  Running

sshd:   Running

dovecot 2.2.16: Running

Php 5.3.29: Installed

With one GB of ram, I thought that the slowness of my website might be because of the heaviness of tables. (Number of tables: 381, DB size: 60 MB)
But by searching the net, I found that my DB is not that heavy. I also noticed that in my services, the memory usage of httpd is 650 MB. I think this also might have something to do with slowness of my website.
Can anybody help me with this issue?
Thanks.


texts: Is it possible to add a default URL parameter inside a theme template_XYZ function?

texts: I have a view with a pulldown menu within an exposed form. I want to set that URL parameter to a default value based on the currentLanguage() of the session. Is there a way to edit the URL parameters that a View can see within a custom module or the theme's template_ functions?


texts:
I'm creating a module in Drupal 8 and I need to define a relative path to mymodule to pass it on a JavaScript file like this.

$scope.getPlatformIcon = function (_platform) {
     var modulePath = "/modules/mymodule"
     switch (_platform) {
         case "youtube":
         case "twitter":
         case "instagram":
         case "facebook":
             return modulePath+"/img/"+_platform+".png";
     }
     return false;
};

In Drupal 7 I could use the following.

var modulePath = Drupal.settings.mymodule.basePath;

For the Drupal 8 root directory, I could use the following.

drupalSettings.path.baseUrl

I didn't find how to get the module path.

How can I do it with Drupal 8?


texts:
I'm upgrading a small site currently in Drupal 6 to Drupal 8, it's for a non-profit and doesn't receive all that much traffic. It's a relatively static site, content will be added regularly, but certainly not every day. While the amount of traffic is easily handled even on shared hosting, I'd like to keep the page loading times low. I used Boost for that on Drupal 6, but now with Drupal 8 I want to use the internal page cache.

From what I understand, Drupal 8 should be able to automatically invalidate the cache when nodes are edited. So what I'd like to do is to cache all pages of my site indefinitely until the data behind them actually changed. But the cache dialog on the performance admin page only allows a page cache maximum age of 1 day.

Is there a way to configure a stock Drupal 8 to cache pages forever? The cache should only be invalidated if nodes are edited and the page actually changes content. Ideally I'd like to automatically pre-warm the cache as well.


texts: How to translate strings in (programmatically created) custom module?

texts:
I've (programmatically) created a custom module which includes a block with a string wrapped in the $this->t() function. How or where can I extract this translation file?

In Drupal 7 I would extract a translation file of the custom module, but the POTX module is not ported to Drupal 8 yet.

public function build() {
  return array(
    '#markup' => $this->t('How and where can I translate this string?'),
  );
}


texts:
I have been able to export the commerce_store, commerce_product_variation and commerce_product entities with the default_content module and the drush dce (default-content-export) command, but when importing back, the products and the product variations are not linked together. What am I missing?

Has anybody managed to export products and import as default content in a drupal commerce 2.0 site?


texts:
So using the 'file' module i have added a field to the user table called 'user_files'. What i want to know if how can i programmatically add a file to the user, so that it is displayed on the users profile.

So far i am storing the file information locally and then targetting the database tables directly and inserting the data into them. This has been done correctly, but the file is not dispalying.

I am using file_save_data to store the file in the database. Then manually adding it to 'field_data_field_user_files', 'field_revision_field_user_files' and 'file_usage' tables.

Is there a simpler way to get this to work?


texts: How to convert an HTML website with stylesheets to Drupal 7 nodes?

texts:
I have a question. How can I convert a site with a few stylesheets.css file for the layout into Drupal 7. I'm not so worried about the content of the site, that is not so much. But I would like the layout to be converted to a drupal 7 theme. How can I do that whitout making a hole new theme my shelf. I'm just a beginner with Drupal and want a quick resulte.

Thank you for your help.


texts: What is best coding practices for providing an upgrade path to a new module version?

texts:
I'm getting ready to build a new version of a module of mine. The new version can have an upgrade path from the current version to the new version that will be released, but as you know, new major verions come with database restructuring, entity refactoring, and what not.

Is there a standard practice in the way the upgrade path is provided? For instance, should I build code in the install hook of the new version, and update hook, or some stand alone script?

Suggestions welcomed.


texts: How to repeat events with the calendar module?

texts:
I have installed the calendar module. I create a content type call Events and I added a Date field using the Pop-up Calendar control type. So when I create a event node I'm able to give it a Date. So far so good.

Now I need to have something like "repeat every day", "repeat every month", "repeat every year".

Can I accomplish this with the calendar module? Do I need to install another module?

thanks


texts: How do I force rebuilding/generation of files generated by an imagecache preset?

texts:
I edited the actions on one of my imagecache presets, but it has only generated a few pictures (instead of hundreds) of pictures.

I am using the preset to in a view to show thumbnails that belong to nodes of a specific content type with the help of a module called teaser thumbnail. All the thumbnails on the first page of the view have been generated correctly, but beyond that, none of the thumbnails have been generated.

I am using Drupal 6.25 with public file system on a shared hosting server.

So the main question is how do forcefully rebuild/re-generate the pictures associated with preset?

Edit : I have already used the 'Flush' function on the preset.


texts: How to wrap content around a display suite region?

texts:
I'm using the nifty Display Suite module to create a custom layout for an event page. I'm using the stacked fluid 2 column layout with the Body field on the left and the image and event fields in the left column.

I would like the body (left region) to wrap around the image and date fields (right region). I''ve been unable to figure out to to accomplish this.

http://ctu.robohobo.net/node/17

How  would I make that happen?

Drupal: 7.19
Display Suite: 7.x-2.0


texts: Create an article translation(s) via hook_form_alter?

texts:
I would like to submit an article in English but when I press submit button I would like to create its translation(s) as well. Can I do it with hook_form_alter?

I have this now:

 /**
 * Implements hook_form_alter().
 */

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  drupal_set_message($form_id);

  switch ($form_id) {

    case 'node_article_form':

      $form['actions']['unpublish']['#submit'][] = 'mymodule_node_article_form_submit';
      $form['actions']['publish']['#submit'][] = 'mymodule_node_article_form_submit';
      break;

  }

}

function mymodule_node_article_form_submit($form, FormStateInterface $form_state) {
  drupal_set_message('Running custom submit handler...');
}


texts: Config entity form field with multiple/unlimited cardinality

texts:
I have a config entity form that has a taxonomy field, and it currently works with 1 term

$form['integration'] = array(
  '#type' => 'entity_autocomplete',
  '#title' => 'Integration',
  '#required' => TRUE,
  '#target_type' => 'taxonomy_term',
  '#default_value' => $entity->getIntegration(),
  '#selection_settings' => array(
    'target_bundles' => array(
      'integration',
    ),
  ),
);

That works fine, but I need to be able to select multiple terms, I've tried setting '#cardinality' => -1, but it's only allowing 1 element. I added a taxonomy field with unlimited cardinality to a content type, then set a breakpoint on the form to see how it was being set up for the page rendering. It looks like it creates a container form element, then I assume iterates over an array containing all the terms?

I would have thought there would be a way to set the cardinality of an element by making use of field widgets on the config form page, but I'm not sure that's possible.


texts: How to embed a view (with contextual filters) into a node or another view?

texts:
I'm using the modules below with the Views module to create a views block of all referenced nodes in the entity reference fields.

Entity API
Entity Reference

There is no problem to create a views that lists all the referenced nodes based on this tutorial.
What I want to do is to embed this views into nodes.
I tried both the EVA and Views Field View modules but couldn't be success (no result). The view I want to embed into nodes uses contextual filters and relationships and I think while using this view into a node or another view, the contextual filter doesn't work.

So, how I can embed this view (with contextual filter) into a node or another view?


texts: I'm now getting the following errors on my site and not sure how to proceed

texts:
Started getting the following error on my views admin page after updating to 8.2.0-rc1, have tried searching for related issues with no success as yet. Seeking help from someone better versed in backend drupal than I currently am.

The website encountered an unexpected error. Please try again later.

Drupal\Core\Entity\EntityMalformedException: The "view" entity cannot have a URI as it does not have an ID in Drupal\Core\Entity\Entity->toUrl() (line 179 of core/lib/Drupal/Core/Entity/Entity.php). Drupal\Core\Config\Entity\ConfigEntityBase->toUrl('edit-form', Array) (Line: 171)
Drupal\Core\Entity\Entity->urlInfo('edit-form', Array) (Line: 408)
Drupal\Core\Config\Entity\ConfigEntityBase->urlInfo('edit-form') (Line: 146)
Drupal\Core\Entity\EntityListBuilder->getDefaultOperations(Object) (Line: 33)
Drupal\Core\Config\Entity\ConfigEntityListBuilder->getDefaultOperations(Object) (Line: 155)
Drupal\views_ui\ViewListBuilder->getDefaultOperations(Object) (Line: 122)
Drupal\Core\Entity\EntityListBuilder->getOperations(Object) (Line: 203)
Drupal\Core\Entity\EntityListBuilder->buildOperations(Object) (Line: 185)
Drupal\Core\Entity\EntityListBuilder->buildRow(Object) (Line: 87)
Drupal\views_ui\ViewListBuilder->buildRow(Object) (Line: 223)
Drupal\views_ui\ViewListBuilder->render() (Line: 22)
Drupal\Core\Entity\Controller\EntityListController->listing('view')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}()
call_user_func_array(Object, Array) (Line: 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 649)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Also get a rather large error on the report page that starts with the following - not sure if this info will help or not.

Notice: Undefined index: id in Drupal\Core\Config\Entity\Query\Query->Drupal\Core\Config\Entity\Query{closure}() (line 92 of core/lib/Drupal/Core/Config/Entity/Query/Query.php). Drupal\Core\Config\Entity\Query\Query->Drupal\Core\Config\Entity\Query{closure}(Array, Array)
uasort(Array, Object) (Line: 93)
Drupal\Core\Config\Entity\Query\Query->execute() (Line: 98)

Update: Solved - it was an issue with the group module when trying to update to 8.2.0-beta2 or above. It was since been resolved from within the module and smooth sailing has returned.


texts:
I have an issue with creating a node via the API. I have the correct permissions setup but it seems like a glitch somewhere in the permissions. An admin can create a content but no other role can. [content type]: Can create new content permission is checked.

Error; access denied - /node?_format=hal_json

Config:

Client:

return api({
    method: 'post',
    url: 'node?_format=hal_json',
    data: JSON.stringify(_node),
    headers: {
        'Content-Type': 'application/hal+json',
        'X-CSRF-Token': _xscrf_token,
    },
});


texts: Changing Column width of a table view (Drupal 7 Views 3)

texts:
I have a view with 4 columns.  The first column, which contains a majority of the text is taking about about 80% of the width of the form and forcing the 2nd, 3rd, and 4th rows to wrap.  Problem is those columns have content that should not really be wrapped
for exmaple Tues 3pm - 5pm ends up looking like

Tues

3pm -

5pm

So rather than the columns adjust based on content, I'd like to manually set the width of the first column so that it leaves enough space for the others.  Or if need be manually set all the column widths.

Please understand I am totally lost in drupal and only have a small amount of css/php knowledge so please be as absolutely descriptive as possible.  I've found a bunch of examples in other areas but people have left out huge chunks of the code, or where it's supposed to go etc.  One place kept says "make changes to the css", not sure if it's normal but I have about 25 different css files in my drupal install, I had no idea WHAT css to make the change in.

Thanks in advance for any help!  This is a great community and I'm happy I went with Drupal because of it.


texts: How to disable/turn-off drupal 7 caching permanently, to not to mess with module's operations?

texts:
I am using Drupal 7 for a real time web application so I cannot afford any caching at all. I also could not find any such option in performance section of Admin Panel. Kindly suggest a method with involving the command line.

UPDATED:

Let me explain the problem further.

Yes theme isn't problem for me. I am new to drupal ad still exploring.

What problem I face is I have written a module which takes CSV file from user, parses and calls moodle web-services to perform operations. What happens sometimes is it seems like that data or code in module is not managed properly and it generates useless/meaningless errors. When I do 'Clear All Caches' at Home » Administration » Configuration » Development; everything gets fixed.


texts:
I am trying to make a module that has two parts:

  1) It calls an API when article is set to published. The API returns a
  work id.

  2) The workid must be saved to the articles metadata or something
  similar so that another function uses that id to display specific html
  in that article.

I am done with the first part. Now I want to know how to save workid in the metadata, is there any option for that in drupal? because I have done this kind of work in joomla.


texts: Integrate facebook request dialog inside drupal module!

texts:
I am trying to insert the request dialog inside drupal block, can you please suggest me how to do this?

I mean, do i have to create any js file, etc etc.. because i have no clue on how to do this.

Thanks..


texts: How do I get all the image files and clean them up?

texts:
On my Drupal 8 website I have created multiple media contents and uploaded image file to each content. When I update new image of a media content, the old image file remains unused in the image directory.

How can I query and retrieve all the image files, check if they are used by any media content, if not, delete them from the database and from the image directory?

This is how I have tried. But I did not see any image file that I have uploaded.

$files = \Drupal\file\Entity\File::loadMultiple();

foreach ($files as $file) {
   dump($file);
}


texts:
On my Drupal 7 install, I have content type in which user can upload files to the server, via file upload field. I was sure everything was fine, I forgot about the system (was sure it was working, tested it). But strange enough, after some time I tested it, I could not download files, not by clicking on file link on that content type, nor by pasting url of the file in adress bar.

When I tried to access files, I got HTTP request status: 403 (Forbidden in http headers, while browser shows login page and path in the adress bar was path of that file...

And strange enough, under /admin/config/media/file-system I defined private files path to be files/private, and files were uploaded to that directory. But on the content type page - link to file ignored files/private path and rather had path system/files that I have not defined anywhere!

To test things, I migrated user private files to system/files (actually created that folder and subfolder in drupal root) and defined path of the private files to be also system/files (on /admin/config/media/file-system ).

Got some "progress" -  Apache "Forbidden" page - when acessing private files. There was .htaccess file in the folder, with config

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Deny from all
Options None
Options +FollowSymLinks

And for test,  I renamed that file to bypass "Deny", and voila, I could access my newly uploaded files.
But previously uploaded files still throws mysterious HTTP request status: 403 (Forbidden in  http headers, while browser showed login page and path in the adress bar was path of that file...

I was using Public local files served by the webserver. under /admin/config/media/file-system. I noticed also, when I enter that config, if I am missing .htaccess file in private files dir, a new one is being created.

I have to mention that I implemented Varnish cache and APC in Drupal, but things are not better after clearing the cache.

Could someone please tell me what is happening and how I can set it to work correctly/securely? Thanks!


texts: How can i import plain password that are not encrypted during a user migration?

texts:
I am able to migrate all the datas of users account including the password but it doesn’t work due to encryption and hash in drupal 8.

My password are not MD5. They are not encrypted, in csv file they are like normal plain text.

I’ve seen here :
https://www.drupal.org/docs/8/api/migrate-api/migrate-destination-entityuser

  If the incoming passwords are not plain or are not MD5 hashed you'll
  have to deal with this in your migration

My password are plain so i guess it should work.

Here is what i’ve tried but the password are imported but not encrypted :

destination:
  plugin: 'entity:user'
  plaintext_passwords: true

In the documentation, it is explained how to import MD5 password but not plain password.

What should i use for the configuration ?

EDIT :

I’ve tried this :

pass:
    -
      plugin: callback
      callable: 'Drupal\Core\Password\PhpassHashedPassword::hash'
      source: passwebservice

And

pass:
    -
      plugin: callback
      callable:
        - 'Drupal\Core\Password\PhpassHashedPassword'
        - hash
      source: passwebservice

Error :

  Error: Using $this when not in object context in
  Drupal\Core\Password\PhpassHashedPassword::hash()  [error] (line 215
  of
  Core/Password/PhpassHashedPassword.php)
  0 [internal function]: Drupal\Core\Password\PhpassHashedPassword::hash('9BQmM1')
  1 core/modules/migrate/src/Plugin/migrate/process/Callback.php(54):
  call_user_func('Drupal\Core\Pas...', '9BQmM1')

When i check hash()

public function hash($password) {
    return $this->crypt('sha512', $password, $this->generateSalt());
  }

I can't invoke method this way ($this does not exist in class context) so how can I do ? Is it possible in configuration file ?


texts: Theming the output of multiple image upload widget in node create/edit form

texts:
I need to theme the node create/edit page according to the user's specifications. To do so, I need to output of theme_file_widget_multiple($variables), I suppose. It gives out table format which I need to convert into grid or divs. If there is some other easier hook or function for the same thing, please suggest me.

Can anyone help out?enter image description here


texts: Is it dangerous to call a function that deletes nodes based on criteria while a cron job is running that imports them

texts: I have custom module that performs a dbquery on a button click that deletes nodes that fit a certain criteria. Is it dangerous that I also occasionally run a cron job that imports nodes that fit this criteria? If I ran both at the same time could something break?


texts:
I am using drupal 7 and views. The ajax functionality is not working if I enable bueditor for a textarea. I changed the form element by a custom module like this below:

$form['description']['#type'] = 'text_format';
$form['description']['#format'] = 'full_html';

now problem is that if I remove the type and format, the bueditor is not showing that is good and also the form which I build using drupal views it is working with ajax.

But If i add these 2 lines mentioned above, the bueeditor is appearing but ajax is not working. Submitting to a page instead of ajax.

What is the problem there?

I got some more points. As I checked the ajax is working with the bueditor but not clicking on the submit button, its working when I click on the first element of the bueditor(a input tag for Italic). I think the ajax event is bind with the first element of input button. Really fustrated

Thanks in advance.


texts: Using feeds_ex to import content to drupal using 2 steps API calls

texts:
I am trying to import data to Drupal 8 website using Feeds and Feeds_ex module and here is my scenario:

I need to make a call to the first JSON API and extract the IDs from it, here is a sample of the API

{
"rm": [{
    "mn": "Friday",
    "id": 3003,
    "ra": "JEB  ",
    "md": "2019-11-01 00:00:00.0"
}, {
    "mn": "Saturday",
    "id": 3014,
    "ra": "SHJ  ",
    "md": "2019-11-02 00:00:00.0"
}]

}
Then I want to use the extracted IDs to construct custom URLs to get the actual data that I want to import.

http:/somewebsite/api/index.php?id=1234

I looked to Feeds documentation to create a custom fetcher with no luck.Any advice?


texts: How to automatically upload a file on form submission

texts:
I have created a form with a file attachment field. I have noticed that users will attach a file but sometimes forget to hit the upload button. I would like the form to automatically upload the file when the form submit button is pressed (if a file has been selected to upload).

I have seen a similar answer answer to this at https://drupal.stackexchange.com/a/31453/4471 but that is a slightly different use case then what I am after. I would have thought that submitting a form would automatically upload attached files as default behaviour.

I am working with Drupal 7 by the way.

Thanks.


texts:
I have no idea how to fix this, I don't even understand what the problem is.

Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Taxonomy term

The Term ID field needs to be installed.
The UUID field needs to be installed.
The Language field needs to be installed.
The Vocabulary field needs to be installed.
The Name field needs to be installed.
The Description field needs to be installed.
The Weight field needs to be installed.
The Term Parents field needs to be installed.
The Changed field needs to be installed.
The Default translation field needs to be installed.
The taxonomy_term.field_icon field needs to be installed.
The taxonomy_term.field_link field needs to be installed.
The taxonomy_term.field_meta_tags field needs to be installed.

I tried drush entity-updates but it finishes on error:

Character set 'utf8mb4' is not a compiled character set and is not specified
in the '/usr/share/mysql/charsets/Index.xml' file
PHP Parse error:  syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Component/Serialization/Yaml.php on line 54
Drush command terminated abnormally due to an unrecoverable error.   [error]
Error: syntax error, unexpected 'class' (T_CLASS), expecting
identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in
/var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Component/Serialization/Yaml.php,
line 54

EDITED (after fixing drush install) I get the following for drush entity-updates

-sh-4.1$ drush entity-updates
The following updates are pending:

taxonomy_term entity type :
  The UUID field needs to be installed.
  The Language field needs to be installed.
  The Vocabulary field needs to be installed.
  The Name field needs to be installed.
  The Description field needs to be installed.
  The Weight field needs to be installed.
  The Term Parents field needs to be installed.
  The Changed field needs to be installed.
  The Default translation field needs to be installed.
  The taxonomy_term.field_icon field needs to be installed.
  The taxonomy_term.field_link field needs to be installed.
  The taxonomy_term.field_meta_tags field needs to be installed.
Do you wish to run all pending updates? (y/n): y
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. Cannot add unique key                              [error]
taxonomy_term_field__uuid__value to table taxonomy_term_data: unique key already exists. in
Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1470 of
/var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Failed: Drupal\Core\Entity\EntityStorageException: !message in Drupal\Core\Entity\Sql\SqlContentEntityStorage-&gt;wrapSchemaException() (line    [error]
1470 of /var/www/vhosts/mysite/httpdocs/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Cache rebuild complete.                                                                                [ok]
Finished performing updates.

The bizarre thing is that all these things (field_icon, link, meta_tags..) are installed.

The site has many modules (both custom and from the drupal community) and it works alright. Should I export it all and do a clean install and then import it?

UPDATE

I did not manage to fix this and it was giving very weird problems out of the blue, although the already created content types and nodes worked fine. After 24h+ of non stop working I reset the stype up from a clean install and copied content manually (tried doing the Configuration > Configuration synchronization with single items, but it didn't work very well).

I can report now that the problem is gone. I have no idea what could have caused it or even when.


texts: How to clear the a block cache programmically

texts:
I have a custom block that display some information from a custom configuration form.  I want the block to be cached, however, I want the block cache to be cleared every time I save the form.
I would like to do this in the submitForm function.  How do I go about and do this?


texts: How to tell if a field has renderable content before printing HTML around it?

texts:
I have a half dozen reference fields on a content type that sits at the bottom of a page under a heading of "Related" and some markup structure. I was checking if node.field_name is not empty, ... in twig before entering and printing "Related" and then each individual field, but in cases where the referenced entities are unpublished, this results in just "Related" and nothing else.

How can I figure out ahead of time if the field I am about to render has actual accessible content to show the user? is content.field_name|render|striptags|trim still the only way?

Related

      {% if node.field_topics is not empty  %}
        {{ content.field_topics }}
      {% endif %}

      {% if node.field_programs is not empty  %}
        {{ content.field_programs }}
      {% endif %}

      {% if node.field_working_groups is not empty  %}
        {{ content.field_working_groups }}
      {% endif %}

      {% if node.field_projects is not empty  %}
        {{ content.field_projects }}
      {% endif %}

      {% if node.field_papers is not empty  %}
        {{ content.field_papers }}
      {% endif %}

      {% if node.field_datasets is not empty  %}
        {{ content.field_datasets }}
      {% endif %}

Edit: updating with Hudri suggestion, it still prints the h2 of Related:

{% set display_related = false %}

{% if not (node.field_programs.isEmpty == true) and content.field_programs is defined %}
  {% set display_related = true %}
{% endif %}

{% if display_related %}

...


texts:
This is the template currently being used:

panels-pane.tpl.php

<?php if ($pane_prefix): ?>
  <?php print $pane_prefix; ?>
<?php endif; ?>
<div class="<?php print $classes; ?>" <?php print $id; ?> <?php print $attributes; ?>>
  <?php if ($admin_links): ?>
    <?php print $admin_links; ?>
  <?php endif; ?>

  <?php print render($title_prefix); ?>
  <?php if ($title): ?>
    <<?php print $title_heading; ?><?php print $title_attributes; ?>>
      <?php print $title; ?>
    </<?php print $title_heading; ?>>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($feeds): ?>

      <?php print $feeds; ?>

  <?php endif; ?>

    <?php print render($content); ?>

  <?php if ($links): ?>

      <?php print $links; ?>

  <?php endif; ?>

  <?php if ($more): ?>

      <?php print $more; ?>

  <?php endif; ?>

<?php if ($pane_suffix): ?>
  <?php print $pane_suffix; ?>
<?php endif; ?>

The variable $title_heading is h2. It comes in $content

panels.module

  $vars['title_heading'] = !empty($content->title_heading) ? $content->title_heading : variable_get('override_title_heading', 'h2');

However, I see no way of supplying it, and cannot create it in my Fieldable Pane Panel:

If I try to add a field, it comes with the field_ prefix, and I just need a plain title_heading.

How can I overcome this?


texts:
I'm using the Metatag module to include appropriate Open Graph, etc. tags to delineate site content as it is shared on social media sites. The front page of our site is a Views Page, feature only the most recent piece of content. We would like some of the info from this featured node to be included in the meta tags for the home page of the site.

What I'm wondering is -- How can I include meta tags specific to the first result from a View?

Alternately, can anyone suggest an alternative approach to either featuring the most recent piece of content on the home page that would solve this problem?

Thanks!


texts: How to remove a file from a "Choose file..." dialog?

texts:
Or, how to set things up so users can do that, I guess...

The point: Once you've selected a managed file in a standard Drupal "Choose file..." dialog, there doesn't seem to be a way to remove the file, short of refreshing the page.  For those cases where the file is optional, something like this ought to be there, and I'm actually a little surprised that it's not there already.  I suppose I could throw some jQuery together and hang my own button off the input field, but is there really nothing in core Drupal that will do this (or IS there something, and I'm just missing it or screwing it up somehow)?  Thanks!


texts: Quick editing of taxonomy tags on a node

texts:
I am using Drupal 7 Advanced Forum. I have added a taxonomy field so that posts can be tagged with keywords (like in this forum).

Currently if an editor responds to a customer post, the process for doing so is a bit cumbersome:

edit the customer post to add tags.
once this is done, then reply to the post.

I need to make the process of adding or modifying tags easier.  Perhaps with a button next to the tags so they can be edited in-place.

How can I edit taxonomy fields & reply to posts in the same form?


texts: How can I create a recommended project in the root directory?

texts:
My server consists only one Drupal site and therefore I would like to install it directly under D:\home\site\wwwroot
However this seems impossible as the new command composer create-project drupal/recommended-project:~8.8.0 mysite requires some sort of a folder name like 'mysite'.
All I want is Drupal composer.json stuff to be installed in D:\home\site\wwwroot and 'web' folder to be installed in D:\home\site\wwwroot\web
Is this possible at all?


texts: I'm using an archive view which is in Views by default but just needs to be activated. It works great and is displaying the way I want it to, but I was wondering if there was an easy way for me to expose the view so I can allow users to filter content by month or within a month range (eg. from Janauary 2011 to May 2011)...?


texts:
We installed Webforms and Salesforce suites and we'd like to create new leads in Salesforce based on the webform submissions.

I created a webform with 3 fields.

email:
  '#type': email
  '#title': Email
company:
  '#type': textfield
  '#title': company
last_name:
  '#type': textfield
  '#title': 'last name'

Then I created a mapping with Salesforce linked to webform submissions. In the mapped fields, I think I have to use tokens. So I have the following

[webform_submission:original:values:email] --> linked to Salesforce email field
[webform_submission:original:values:company] --> linked to Salesforce Company field
[webform_submission:original:values:last_name]--> linked to Salesforce Last Name field

When I test my form, I get an error message that says "Drupal push failed".

Any suggestions?
Thanks.


texts:
Need input on Data Entry project using Drupal 7. The requirements are as follows:

A user logs in and enters sale transactions (Name, address, item, price ...) multiple times.
A user can view/modify their own transactions.

Does Drupal 7 offer a solution and how?


texts: Display entityreference field in search-result.tpl

texts:
The entityreference field (field_parent) shows up in node.tpl using print render($content);, but isn't displayed in search-result.tpl. My search-result.tpl looks like this right now:

<li class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>

  <h3 class="title"<?php print $title_attributes; ?>>
    <a href="<?php print $url; ?>"><?php print $title; ?>

  <?php print render($title_suffix); ?>

Imported on <?php print $info_split['date']; ?>.

<a href="<?php print $url; ?>">Comments

<a href="<?php print $result['node']-> field_download[LANGUAGE_NONE][0]['url'] ?>">Download

Lipsum: <?php print $result['node']-> field_lipsum[LANGUAGE_NONE][0]['value'] ?>

I tried using <?php print $result['node']-> field_parent[LANGUAGE_NONE][0]['value'] ?> but it gives me the error "Notice: Undefined index: value in include() (line 25 of ...\search-result.tpl.php)."

<?php print $result['node']-> field_parent[LANGUAGE_NONE][0]['entity'] ?> gives

Recoverable fatal error: Object of class stdClass could not be converted to string in include() (line 25 of ...\search-result.tpl.php).

<?php print $result['node']-> field_parent[LANGUAGE_NONE][0]['entityreference'] ?>

Notice: Undefined index: entityreference in include() (line 25 of ...\search-result.tpl.php).


texts:
Views pager starts with 0 (URL GET argument "page" has value 0 for first page). Is it possible to set the pager, so it will start with 1?

I think it is more user friendly.

(if pager is starting with 0, and if the user click on page "3" there is page=2 in the URL)

thanks for help
Tomas


texts: How do I read the output of the devel module?

texts:
This is not asking where to find the output from devel, as I know where to find it. The question is how to read it and make sense of it. I need to find a field from a field collection, and then reference that field in a computed field; I am totally lost -- that is to say that I know where both the devel output is, and I have a view with a global php field that has print_r($data) in it, both of which show me a bunch of names and php stuff I am unfamiliar with. I am an intermediate novice with php, so please take that into account.

Here is what my dpm($data) looks like, with the field that I desire expanded:


texts: Set height and width of image field being rendered with views PHP

texts:
The context: drupal 7, views, views PHP, rendering some fields with PHP because there's no other way.

$nodo = node_load($row->nid);
$strmn  = '
';
$strmn .= '
';
$image = field_get_items('node', $nodo, 'field_image');
$preout= field_view_value('node', $nodo, 'field_image', $image[0]);
$linko= url('node/'. $nodo->nid);
$strmn .= '' . render($preout) . '';

After a lot of googling I've been able to write this.

It's very probably crude but it works, except I can't find a proper way to set height and width for the image. I don't want to create a style in drupal, it would be no good as it won't be used anywhere else. I also don't want, if at all possible, to rework my code to do something like:

$image = theme('image_style',array(
    'style_name' => 'mail_image_big',
    'path' => $image_obj['uri'],
    'attributes' => array('style' => 'border:1px solid #aaa;')
  )
);

Because my php is sketchy at best and the knowledge of the drupal API is null. Every change costs me a lot of time and energy because, honestly, I lack the basics and I'm not sure of what I'm doing until I do it right.

Finally: how do I set the $display array in field_view_value so that height and width are set the way I want them in my output html? I can't find an example or a list of valid properties I can set in the $settings array to save my life. :)


texts: HTTP request status fails, but update checking works manually

texts:
I have a problem with my Drupal 7 (multi-site) installation on a root-server. The HTTP request status shows "failed" on the status page. However, I am able to check for updates manually when logged in without a problem, so Drupal actually is allowed to access other sites.

I am having problems with automatic update-checks via cron though. Sometimes they work, sometimes they work only partially. This results in an error-report being sent sometimes via email, which is quite annoying since I only want this for security updates.

Does anyone know how to solve this? We do have a root-server, however I'm not the admin and other non-drupal sites run on it too, so I can't just play around with server-settings, I would have to request changes (I can see phpInfo() though, if that helps).

The weird thing is that updates do work manually, and at least partially when checked via cron (I also disabled any external cron-job, so it's only triggered via poor-man's-cron). Could it be a Drupal core problem after all, maybe related to this: https://drupal.org/node/965078?

-- Drupal 7.27, all modules up-to-date


texts: Why drupal need hidden option in comment settings of content types?

texts:
In content type setting in drupal, we have tab comment setting .The comment setting on future content of this type will default to:

Hidden: No comments are allowed, and past comments are hidden.
Closed: No comments are allowed, but any past comments remain visible.
Open: Any future content of this type is open to new comments.

Why do we need HIDDEN option? It  does not make sense in content type setting . If we set this option - in any new nodes that will be created next  - comment will be closed.

This option has sense only in particular material, if it has comments.

Please explain me why this option need in content type settings?

Thanks...


texts: Encode a line break in an HTML email sent by Rules?

texts:
I have a rule that sends out an email when a node gets edited in a certain way. The rule fills the body of the email with the value of a <textarea> field from the node that was updated.

The email is being sent out in HTML format (not plain text) and the <textarea> is set to plain text (not Filtered Text).

When the email gets delivered, the HTML line breaks (
) that I've entered into the <textarea> field are not respected (they get encoded); it just one big mass of text with no line breaks.

What do I have to put in the <textarea> field for line breaks to come out in the HTML email?

I've tried:

\n
\r
\r\n
%0D%0A
&#x3C;br /&#x3E;
%3Cbr+%2F%3E

Any HTML I put in the field gets encoded and not processed as HTML. How do I put in
 and have it stay as HTML?


texts: How to send a message to users who flagged a taxonomy term?

texts:
I want to send a message to users who have flagged, for example, the Toys taxonomy term. But only when a new node is created and contains the taxonomy term of Toys.

Any suggestions?


texts:
I want to integrate BIRT reporting tool with Drupal 6.
Does anyone has an idea on how to do it? BIRT reporting tool basically runs on a Tomcat server.


texts: Disabled AJAX paging with embedded views when used in Views template files

texts:
I am using a View in two different pages: page--front.tpl.php and views-view-grid--inside--page-1.tpl.php which is a custom display of a view.

This is the code that is used in both of these

print views_embed_view("loadcover","block",$nid);

and I also set Use AJAX:Yes in the Views settings. The problem is the View's Ajax paging works in the page--front.tpl.php but it's Ajax paging doesn't work in views-view-grid--inside--page-1.tpl.php, In this page the pager is appeared as a link not ajax. What is the problem?

UPDATE:

I tried

print views_embed_view("loadcover","block",$nid);

in page.tpl.php and it worked with Ajax, Is there any problem with Views template files?

I found Disabled AJAX paging with embedded views when used in page.tpl.php it gave me some clues but still I'm unable to solve the problem.

UPDATE:

This is the complete code, This code is exactly the code that is works in page--front.tpl.php. I moved the print views_embed_view("loadcover","block",$nid); in different places of this code but it didn't work again. I guess the problem might be because of js codes that are not loaded in this page.

<?php
global $base_url;
global $language;
$menu  = new stdClass();
$menu = buildMenuObject($menu);
$bookCounter = 0;
while ($bookCounter < sizeof($view->result)){
    $nid = $view->result[$bookCounter++]->nid;
    if($bookCounter <= 6)
    {
        $top = 222 + (188 * floor($bookCounter/7));
    }
    else
        $top = 252 + (188 * floor($bookCounter/7));
    $node = node_load($nid);
    $wrapper = entity_metadata_wrapper('node',$node);
    $title = $wrapper->title->value();
    $detail = $wrapper->field_detail->value();
    $writer = $wrapper->field_writer->value();
    $edition = $wrapper->field_edition->value();
    $translators = $wrapper->field_translators->value();
    $publisher = $wrapper->field_publisher->value();
    $year = $wrapper->field_year->value();
    $nop = $wrapper->field_nop->value();
    $jelds = $wrapper->field_jeld->value();
    print "
";
        print "";
        print "
";
            print "
";
                print "
";
                    print $title;
                print "
";
                print "
";
                    print $menu->writer." : ". $writer;
                print "
";
                print "
";
                    print $menu->edition." : ". $edition;
                print "
";
                print "
";
                    print $menu->translators." : ". $translators;
                print "
";
                print "
";
                    print $menu->publisher." : ". $publisher;
                print "
";
                print "
";
                    print $detail;
                print "
";
            print "
";
            print "
";
                print "
";
                    print views_embed_view("loadcover","block",$nid);
                print "
";
                print "
";print "
";
            print "
";
        print "
";
    print "
";
}

?>


texts: How to add and render a region in omega 3.x subtheme?

texts:
Can anyone let me know as how to render a region in omega 3.x subtheme ?

I have tried creating a region using this command in .info file as  regions[region name] = region name and used render command in page--front.tpl.php  , ,but regions are not getting rendered !

Can anyone please help me with this issue


texts:
I am running Drupal (latest version 7.22 ) on Apache 2.2 and I have also installed Varnish (module and proxy). In Apache, I have disabled the mod_deflate module.
Reading around the web, it seems that the options on the performance page in Drupal (aggregate css,js) shouldn't compress the css and js files. However, browsing my site and checking the http headers, I see that I am receiving "Content-Encoding: gzip". Looking at the (default) .htaccess, I see that there are some rewrite rules in order to server gziped files to those clients that can read them. So, I guess this is where the "Content-Encoding: gzip" headers come from. Also, when I enable compression of cached pages on the performance settings page in drupal, I find that even the html of the page I am requesting (as anonymous user only) is returned compressed. My questions on the above are:

1) Do the options "Aggregate and compress CSS files." and "Aggregate JavaScript files." actually compress the aggregated files or is it just that .htaccess makes them seem like gziped? Using chrome developer tools, the files seem compressed. Checking them with the developer toolbar addon in firefox, however, (Information -> View document size) they are not reported as compressed (while the html file is always being reported as such, even when I access it as authenticated user!)

2) If they are indeed gziped, where does the compression take place? Can I control the level of compression, etc somehow?

3) I am always receiving X-Drupal-Cache "MISS". I don't care much since I have Varnish installed. Yet, since I am not hitting the cache, how come I am returned a compressed html file (that is not in the cache)?

4) Is there any chance that the Varnish module messes anything up? I am accessing the website with https so as to be sure that Varnish is bypassed, in any case.

5) If I enable mod_deflate, should I leave that part of .htaccess intact? I understand that mod_deflate doesn't allow for precompression, but what if the compression is better?

6) Also, if drupal compresses on its own the css, js and html files, what is the point of enabling mod_deflate for these files?

Here is the relevant part of my .htaccess file for reference:

  <IfModule mod_headers.c>
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]

    <FilesMatch "(\.js\.gz|\.css\.gz)$">
      # Serve correct encoding type.
      Header set Content-Encoding gzip
      # Force proxies to cache gzipped & non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
  </IfModule>


texts: Updating the block region/pages settings for a NEW views block during an implementation of hook_update_N

texts:
I have a feature module which provides a view which has a block component.

To keep things simple, the module I'm writing a hook_update for is 'mymodule' the feature which implements the view is 'myfeature', the view which contains the block is 'myview' and the block is just block_1 of that view.

The block needs to be visible in the region sidebar_second
The block needs to be visible only on pages which match users/*
The following is my hook_update simplified:

function mymodule_update_7001(){
 features_install_modules(array('myfeature'));
 drupal_flush_all_caches();
  //Change block settings
  db_update('block')
  ->fields(array(
      'pages' => "users/*",
      'visibility' => 1,
  ))
  ->condition('module', 'views')
  ->condition('delta', 'myview-block_1')
  ->execute();

  db_update('block')
  ->fields(array(
      'region' => 'sidebar_second',
      'status' => 1,
  ))
  ->condition('module', 'views')
  ->condition('delta', 'myview-block_1')
  ->condition('theme', 'mytheme')
  ->execute();
}

Unfortunately it doesn't work, and this is largely because at the point after running drupal_flush_all_caches(); the block doesn't exist in the table yet.

drupal_flush_all_caches() should run block_flush_caches() which should run _block_rehash() against each theme, expected behaviour is that this would cause the writerecord to occur putting the new views block in the 'blocks' table. (if i ran 9 flush all caches followed by a block flush cache and a rehash this would still not work)

I have experimented with varying combinations of these cache flushes to no avail, i have also tried giving 'mymodule' a higher weight.

Bizaarely using the following drush command directly after the update:

drush php-eval "_block_rehash('mytheme');"

causes the block to exist in the database. I have tried using this exact command in the hook_update_n and that did not work.

any advice would be appreciated.


texts:
I am using Drupal 7 and Views 7.x-3.7 . I am trying to display posts on my site using a SQL query that looks like this:

SELECT DISTINCT node.title AS node_title, node.nid AS nid, node.language AS node_language

FROM

{node} node

ORDER BY node_title ASC

The problem with this query is that if I have multiple posts with the same title,then all are being displayed because the nid, which is the primary key, was added by Drupal. I have been trying to remove the nid by using the hook_views_query_substitutions() method, but I have had no success. The method is getting called, but my query is not being updated.

I call zz_views_api() from my zz.module, and have the following zz.views.inc

function zz_views_query_substitutions($view) {
  // description of  zz_views_query_substitutions().

  return array(
    'node.nid AS nid,' => ' ',
  );
}


texts: Edit page for taxonomy tag terms results

texts:
I have it set up so that when you click a title of a certain part of a page, it directs to another page where anything tagged with that certain tag is included in a list form. However, there are 8 different categories that all fall under this overall category. So, whether you click term A or B or C or whatever, it all links to the same /types/% page, making it impossible for me to customize each one individually (as far as I can tell).

Any tips on how to make each term results page different?


texts: Flushing all caches throws me error - PDOException: SQLSTATE[HY000]: General error: 1030 Got error -1

texts:
i got problem clearing my caches, it throws me an error - PDOException: SQLSTATE[HY000]: General error: 1030 Got error -1 from storage engine: TRUNCATE {cache_field} ; Array ( ) in cache. I use xampp for a local dev server. I've read about this issue here - https://www.drupal.org/node/2229013 , but none of the answers helps me. I use drupal 7.43.

Thanks in advance!


texts:
I have a Drupal site on Amazon server. On the amazon server, I have created an Elasticsearch server. I want to connect my Drupal instance with that server so I can use the search server for performing the search operation on the site.

I added and configured the Elasticsearch connector module which, in order to connect to the search server, needs I create a cluster which would help in connecting both the instances.

While adding a cluster to the Drupal instance, it asks me about the server URL. I am not sure on what I should write as server URL. What should I add in that form field?


texts: How to create a node reference when a link or button is clicked?

texts:
I set up a nodereference from a user to a node. The user can reference multiple nodes but I don't want him to select those in the user profile, which would be the default behavior.

I want to show an "add" button or link on the node page and when the user clicks it I want to create the node reference.

The table schema is pretty straight forward but I would think there is a function available?


texts: How to load node custom fields metadata?

texts:
Possible Duplicate:
  Why node custom fields weren’t saved when adding node programmatically?

This question is related to Why node custom fields weren't saved when adding node programmatically?.

I think that I found why I can't store value in custom fields.

Two Drupal sites A, B. Same server. From site A I want to create node on site B using database access only.

But when I try to get target node type in client sites (A):

db_set_active('gallery');
field_info_instances("node","image")
db_set_active();

I am getting empty array. Inside target site B function returns correct fields definition.

I am looking for function to load node custom fields metadata? I don't want to bootstrap site B from site A.


texts: How to remove submitted & author information on Entityform submission view?

texts:
I'm trying to remove the author/submitted information from an entityform submission view and I don't seem to find the right way to do so.

I'm using Display Suite to manage the view of the email that is being sent to the user with the values of the submission, also in the regular view submission page. The submission is for anonymous users, so it's useless to add the following prepended information:

  Submitted by Anonymous on thu, 06/12/2014 - 14:18

Which obviously doesn't make any sense in the way my form is working.

Does anyone knows how to achieve the removal of this information?

Thanks!


texts:
I want to change the default search help text 'Check if your spelling is correct.
Remove quotes...' that is displayed when there are no results.

What's the best method of practice for this? Should I override the value in a template.php function? If so how do I go about this?


texts: Override remove entities link on module uninstall page

texts:
When a module needs to be uninstalled, Drupal adds links indicating there is content associated with the module which should be deleted first and provides a link Remove module_name entities. This works fine for most modules, however we have a complex module that needs to perform clean up, is there a way to override this link and have it invoke a custom entity deletion method?
In our case the Remove links that are automatically added to the module uninstall page, don't end up cleaning all items, and leave the site in bad state.
Possibly related to this question asked earlier "How to remove custom module provided entity instances by the time the module being uninstalled?"


texts: Change a paragraph link field title at runtime

texts:
We have a site with numerous paragraphs, one of which is a Call-to-action, comprised of a title, summary and a link field (machine name: field_link).

The CTA is used so much that to change the word 'Enquire' to 'Inquire' for when we are on a US translation (en-US in url) would require the paragraph been edited manually for every content page that has a us translation would be a monumental task.

As such I've decide to attempt to simply handle this in the paragraph preprocess hook. The original idea was simply to check if we were in a us translation, then check for the word in the field_linl title and change it if needed, as per my snippet below.

/* Translation modifier:
   * The call to action paragraph is used on almost all pages and translations
   * doesn't work with paragraphs at all. So we need to detect if we are in a US
   * translation and change out the spelling of certain words.
   */
  if($paragraph_type == 'call_to_action'){

    if(is_us_translation()){
      $cta_link = $paragraph->get('field_link');
      $cta_link->list[0]->values['title'] = 'Inquire';
      $paragraph->set('field_link', $cta_link);

      // $paragraph->values['field_link']['x-default'][0]['title'] = 'Inquire';
    }
  }

The commented out line was my other attempt.

My problem though is nothing I have tried seems to manage to change the title of the field. Is there a specific way to change this?


texts:
It seems there is hardly any documentation on page call backs using URLS

This being the case I have 2 questions:

What is a legal callback path?
and what becomes the URL to access that path?

Here is the code on my custom module:

  $menu['tipFeed/arguments/%'] = array(
'page callback' => 'tipfeed_create',
'page arguments' => array(2),
'access arguments' => array('access arguments page'),
'type' => MENU_CALLBACK,
);

Here is the function it refers to:

function tipfeed_create($first){
     return 'cool';
}

My module is called tipFeed.

why is the URL http://www.example.com/tipFeed/arguments/1 saying page not found?

Any help would be great, thank you


texts: How to change OG "subscribe to group" link text?

texts:
I want to customize the link text, don't want to use string overrides module for this small job.

In my template_preprocess_node() function I tried to change the #title element of the render array. But it doesn't change the link. Any ideas?

//change the "subscribe link for tribes
if ($variables['type'] == 'tribe'){
    if (isset($variables['elements']['group_group']['0']['#title'])){
        $variables['elements']['group_group']['0']['#title'] = 'Join this Tribe';
    }
}


texts: view query alter : Subselects/query don't work with out brackets

texts:
I was trying to alter a view query with a subselect that looks like:

$subquery1 = (db_select('users_roles', 'r')
   ->where('r.uid = users_node__users_roles.uid and r.rid=10'));
$subquery1->addExpression('COUNT(r.rid)', 'rid');
$query->add_where(1,'1', $subquery1, '<>');

where $query is the main query.
But when i run the view, the query

  ...AND (1 <> SELECT COUNT(r.rid) AS rid FROM users_roles r WHERE
  (r.uid = users_node__users_roles.uid and r.rid=10))...

if i put brackets for the sub select query it will working fine.
ie;

  ...AND (1 <> (SELECT COUNT(r.rid) AS rid FROM users_roles r WHERE
  (r.uid = users_node__users_roles.uid and r.rid=10)))...

So my question is;
How can i put the subquery inside brackets?
sorry if my question is stupid?

Thanks in advance,
PREM


texts: Exporting a feature to a specific directory using drush

texts: I am creating a new feature using drush. I looked up the component I want to create the feature with. When I run the command drush fe my_feature views_view:my_cool_view, drush wants to put it in sites/all/modules. How do I tell drush to export my feature to sites/all/modules/custom?


texts: Adding AJAX to an existing form element?

texts:
I am trying to Ajaxify a node form element (field_unterbringung). When the user changes the value of an entity reference field (unterbringung) the markup should change from "old markup" to "new markup". But nothing happens. The ajax callback is not even called and drupal_set_message of "ajax callback is not showing up" is not showing up.

function customisations_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == "patientprofile_node_form") {
      $form['field_unterbringung']['und'][0]['value']['#prefix'] = '
';
      $form['field_unterbringung']['und'][0]['value']['#suffix'] = '
';
      $form['field_unterbringung']['und'][0]['value']['#ajax']['callback'] = 'ajax_callback';
      $form['field_unterbringung']['und'][0]['value']['#ajax']['wrapper'] = 'markup_wrapper';
      $form['field_unterbringung']['und'][0]['value']['#ajax']['event'] = 'change';
      $form['field_unterbringung']['und'][0]['value']['#markup'] = "old markup";
      drupal_set_message('
'. print_r($form['field_unterbringung'],TRUE) .'
');
      }
}

corrected callback:

function ajax_callback($form, &$form_state) {
  drupal_set_message("ajax callback firing", 'status');
  watchdog('customisations', 'ajax callback firing');
  return $form['field_unterbringung']['und'][0]['value'];
}

UPDATE:

Turns out that when I add the ajax property without [0]['value'] the Ajax indicator shows up.

$form['field_unterbringung']['und']['#ajax'] = array(
    'callback' => 'customisations_ajax_callback',
    'wrapper' => 'markup_wrapper',
    'method' => 'replace',
  'event' => 'change',
);


texts:
how can we convert the contents of the article into image format using textimage module in drupal 7.

Suppose, we are viewing a article in some textformat (ie default format of drupal) and
if we want to see the contents of article in image format.


texts: How to send e-mail on user account update, but not on password reset?

texts:
I want to send an e-mail after a user profile is updated but not if they are only resetting their password.

I already have the rule working so that when the user profile is updated it sends the e-mail with all the user details, but rules recognises a password reset as an account update. I don't want an e-mail to be sent if it's only a password reset.

Neither of the below rules work as expected, the first one only fires if both fields are changed, if i change the first field but not the second I get this message in the log file "Unable to evaluate condition data_is." if I only modify the second one then I don't get the e-mail.

{ "rules_account_update_2" : {
    "LABEL" : "Account Update 2",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_presave" ],
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "account-unchanged:field-first-name" ],
          "value" : "[account:field-first-name]"
        }
      },
      { "NOT data_is" : {
          "data" : [ "account-unchanged:field-last-name" ],
          "value" : [ "account:field-last-name" ]
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : "",
          "subject" : "",
          "message" : "",
          "from" : "",
          "language" : [ "" ]
        }
      }
    ]
  }
}

The rule with an OR condition, this just never fires no matter what fields I change.

{ "rules_account_update_2" : {
    "LABEL" : "Account Update 2",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_presave" ],
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "account-unchanged:field-first-name" ],
          "value" : "[account:field-first-name]"
        }
      },
      { "OR" : [  ] },
      { "NOT data_is" : {
          "data" : [ "account-unchanged:field-last-name" ],
          "value" : [ "account:field-last-name" ]
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : "",
          "subject" : "",
          "message" : "",
          "from" : "",
          "language" : [ "" ]
        }
      }
    ]
  }
}


texts: How to have all the fields available in a display mode for content type D8

texts:
I'd like to be able to choose the date field or other fields that you can see in form display in 'custom display mode' for content types ?

How can I do that ?

Thank you.


texts: How to retrive menu_get_object() in javascript, jQuery?

texts: I'd like to use the $node object in JavaScript, preferably Drupal's DOM. Is there a recommended way to do this in Drupal?