texts: Command to start nodejs? Server.js and app.js missing

texts:
The outdated documentation for drupal integration of nodejs using the nodejs module instructs me to start  nodejs with the command node server.js.

But neither server.js or app.js (replacement to server.js) exists

I can see a file called nodejs.js but running node nodejs.js produces this error;

ReferenceError: jQuery is not defined
    at Object.<anonymous> (/data/disk/o1/static/hood-7.43.1/sites/all/modules/nodejs/nodejs.js:132:4)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

What is the command for starting nodejs?


texts: Reordering values in a multi value field

texts:
Is there a module that allows you to reorder the values of a multi value field?  By drag and drop or by weight.

Example:

Field XYZ:
+ Value 1
+ Value 2
+ Value 3
+ Value 4

Reorder to:

Field XYZ:
+ Value 4
+ Value 2
+ Value 3
+ Value 1


texts: how to have block show up on specific pages AND specific content types

texts:
I want to be able to have a particular menu block show up on specific pages, as well as on specific content type pages. My content type pages don't start with /node, so I can't simply say

pagename
/node/*

in the block settings. (I am trying to do this from the UI. If thats not possible, then please tell me what the best way to do this in code is.)


texts: How to override 'H1 page title' and how to group content types?

texts:
I have 2 questions:

Let's say you have a content type named Page and a theme as in this example:

This theme shows the content type name Page (in the picture it shows "About us" as a H1 page title). My question is: How can I change the name that will be shown on the page as a H1 page title, by not creating a bunch of new content types with the appropriate name? So in short: I have a content type named Page, when adding new content it shows Page as a H1 page title. How can I override that so that it says Content , About us etc ...?
Is there a way to group content types? Let's say you created 10 of them (Pizza , Fries , Fish, red wine, white wine, etc ...) and you want to group them so that when you go to "add new content" you don't have to view all 10 of them but only 2 groups (Food, Drinks) that hold the corresponding items?
So when you click Food it shows you the Pizza, Fries, Fish etc ...


texts:
I'm building a form similar to attached image.

Customer enters values for all 3 text fields and click 'Get Online quote'. This will perform a database query (using AJAX) and display a value just below 'Get Online quote' button.

If he's happy with the quote, can ask to get contacted by clicking the second button, 'Contact me for more details'. Therefore second button act as the form submit button which will redirect to a thank you page.

So far I have coded like below.

// online quote button
function fence_quote_form_alter( &$form, &$form_state,$form_id ){
  if ($form_id == 'webform_client_form_4208') {
    $form['actions']['fence_quote']  = array(
    '#type' => 'submit',
    '#value' => t('Get online estimate'),
    '#submit' => array('fence_quote_custom_submit'),
    '#ajax' => array(
      'callback' => 'fence_quote_form_callback',
      'wrapper' => 'fence_quote-submit-button',
    ),
  );
    $form['#validate'][] = 'fence_quote_custom_validate';
  }
}

function fence_quote_custom_validate($form, &$form_state) {
  // your validation code
}

function fence_quote_custom_submit($form, &$form_state) {
  $query = db_select('fence_900', 'f');
  $query->fields('f', array('total_cost'));
        ->condition('meters', 2, '=');
  $result = $query->execute();
}

function fence_quote_form_callback($form, &$form_state) {

}

I'm unclear on what to put under AJAX callback function. Should I
have the database query in it instead of putting inside custom submit
function?
How can I display the database query value below the 'online quote' button on a new text field? I'm unable to print using $form_state['values']['total']


texts: Is there a function for drupal that can identity if a certain page and its children are being viewed?

texts:
So I have nav that looks like this:

  Parent Url</>

       Child Url

       Child Url

I would like to add an "active" class to the Parent URl if a user is on the page with url "some-parent-url" or any of it's parent url?

Ideally something like

<a href="/some-parent-url" <?php if (some_drupal_code_for_this){ echo 'class="active"'; } ?>>Parent Url</>


texts: space character in url is coming up as '%20'

texts:
one of my clients website (built on D7) has the '%20' sign coming up in url as a result of a space. My only way around till now has been to use'-' instead of a space between the product names. But i cannot have a '-' between every products name. Please advise

A 'non html/non - technical / not sure what plugins we have already installed' person

:|


texts: How can I add a filter to an export display?

texts: I have a view "Nearest Dealers" that lists all the near dealers. There are two displays - Page & REST Export. I've added a filter(exposed to visitors) that lets customer search dealers based on current location and distance(eg: 10km radius). Filter works perfectly, but I want to show the same filtered results in REST Export display for the same view. Is it possible to do so because I have no clue how to make this work. Or is there any way to add the same filter for the REST Export display ?


texts: Trouble adding inline Javascript into a page

texts:
I am trying to do work for a client and am having a lot of trouble, so some help would be appreciated!

They have a store, and that 3rd-party called RangeWorks that provides code like the following to embed purchasing and scheduling (business name changed for anonymity):

I have tried pasting that code into the Source of a Drupal page, and then when I View Source, I do get this CDATA comment around it:

Basically, I'm not getting the membership stuff coming through - just the services loading animation jumping around, and nothing loads up.

In my JS console, I do see:

Failed to load resource: the server responded with a status of 404 (Not Found)     rangeworks.us/rgapi/business-name/classes/1

404 - Not Found         main.35041x... .v2.bundle.js:1

Navigated to https://www.business-name.com/classes

GET https://rangeworks.us/rgapi/business-name/classes/1 404 (Not Found)    polyfills.b8ce37e... v2.bundle.js:1

404 - Not Found     main.35041c3... .v2.bundle.js:1

I don't really know if this is an issue on RangeWorks end, or on my end in Drupal. I did contact RangeWorks asking about help with this, but I'm scrambling here and wanted to see if anyone could at least point me in the right direction.

Thank you very much!


texts: Display a message when no results are returned from an exposed filter

texts: How do I add a message, or change the view's behaviour when there is no result returned from a view's exposed filter?


texts:
I'm working on a development site. Up until recently I haven't had any trouble with saving permissions, everything was working fine, until I added the different user roles for the site. After I added them all, I went back, and started to assign the correct permissions to the correct users types. I hit save, and... nothing.

No error message, no message at all. And the save didn't take effect. I'm starting my head over why it suddenly just isn't working when it was working before. Is there a limit the the amount of users types that Drupal allows?


texts: I want to redirect users to a custom page, after they create a node or edit it.


texts: How to grab a user's Fivestar voting value with Rules?

texts:
On my website, users can rate nodes via comments. The Fivestar field is called 'Stars'. I'd like to use the user's voting value in a rule that's activated when a new comment has been saved. (The rule should update a radioactivity field, called 'Popularity', from the node that's commented on.)

When debugging the 'Stars' field in a comment, I'm able to get exactly the value I need via field_stars['und'][0]['rating']. However, I can't find a way to grab it in the Rules UI. I'm always ending up with comment:field-stars: in an action.

I tried adding a condition 'Entity has field: Parameter: Entity: [comment:node], Field: field_stars'. This gave me the option to dig deeper to comment:field-stars:user-rating, but when I'm using it further on in my rule, it always throws an error "The variable or parameter value is empty."

What's going wrong and how can I solve this?

Edit: After reading this question, I tried solving my problem with the following rule.

{ "rules_new_vote" : {
    "LABEL" : "New vote",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "php", "radioactivity", "comment" ],
    "ON" : { "comment_insert--comment_node_article" : { "bundle" : "comment_node_article" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "comment:node" ], "field" : "field_popularity" } }
    ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "integer", "value" : "0" },
          "PROVIDE" : { "variable_added" : { "null" : "null" } }
        }
      },
      { "php_eval" : { "code" : "$rating = \u0026drupal_static(\u0027rating\u0027, $default_value = $comment-\u003Efield_stars[\u0027und\u0027][0][\u0027rating\u0027]);" } },
      { "radioactivity_emit" : {
          "data" : [ "comment:node:field-popularity" ],
          "value" : { "select" : "null", "php" : { "code" : "return $rating;" } }
        }
      }
    ]
  }
}

Unfortunately, it doesn't work properly: when saving a comment, the following error is thrown:

  Notice: Undefined variable: rating in eval() (line 1 of
  C:\wamp\www\mysite\sites\all\modules\rules\modules\php.eval.inc(146)
  : eval()'d code).

How can I solve this?


texts: how do display 404 while the url didn't exits

texts:
I add a view contains three display page,and the page urls are:

questions
questions/my
questions/unanswered

but when I visit the url questions/s12dsdd ,It display the questions page list all questions,how to display a 404 page ? I found none settings in views.

of course we can handle it in code,but not a good one....

other desciptions:

  What he asks (I believe) is how to have 3 displays in one view and with [placeholder], [placeholder/versionone], [placeholder/versiontwo] URLs respectively and get a 404 on [placeholder/somethingrandom]. The second part of the URL does not seem to be an actual argument such as %nid. It's just a literal representation within the URL of what the display is meant to provide. :) @magtak


texts: How do I disable Twig and block cache for a specific module?

texts:
I'm working on a module in Drupal 8 which retrieves time sensitive data from an external REST api. The data is processed and forwarded to a Block. The final data is sent to a Twig template like so:

...

public function build() {
  $build = [];

  $build['ticker_block'] = [
    '#theme' => 'module_theme',
    '#data' => $myService->data(),
  ];

  return $build;
}

This doesn't work on the production environment where cache is enabled and the rendered data shows up as stale. How do I disable cache for my module only, and do I have to do it for both the Twig template and Block plugin?


texts: Related content in a view using entity reference

texts:
I've browsed through (and tested) every solution I could find here to this seemingly simple challenge.

I've got multiple content types (fx. News, Releases, Events, Videos etc.) that are referencing the content type "Artists" using an entity reference-field.

I want to have related content-blocks that shows the related news, releases etc. for the artists references in the node.

I've done this in D7 but it seems the approach have changed a bit since then (?).

What I thought I should do (with content type 'release' as example:

Create a related release-block in views
The a relationship 'Content using field_artist', require this relationship
Add contextual filter, select relationship, select 'content id from URL' as default value

But no results appear when doing this. If I remove the relationship I get 1 result, the node I'm already on...

What am I doing wrong?


texts: Difficulty to list taxonomy terms in a block for specific content type (d7)

texts:
I have made a page using views to list a specific content type.
Then I wanted to make a block to list a taxonomy vocabulary in a sidebar in order to sort the posts according to terms.

The problems I am facing are:

If I select the block to appear for specific content types, the block doesn't show
I am having a multilingual website and the block shows terms in both languages, how do I choose to show the terms in the current users language?
I have also tried the module taxonomy menu but it also lists terms in both languages and doesn't show for specific content types

Any help would be highly appreciated.


texts: What is the correct URI syntax for using Forena to connect to a Postgres database?

texts:
I am trying out Forena Reports and in connecting to a Postgres table I set the the Driver Type to Postgres Database and the URI to postgresql://username:password@127.0.0.1:5432/database.

The problem is when try to connect to the database username and password are correctly sent as the database log produces this message.

 FATAL:  database "database password=password" does not exist

I have created a temporary workaround by creating a user with the same name as the target database, by using the URI and omitting database at the end, as in

postgresql://database:password@127.0.0.1:5432/

What is the correct syntax for this URI postgresql://username:password@127.0.0.1:5432/database which allows a user without the same name as the database?


texts: How does one see the specific structure of some variable?

texts:
I'd normally use dpm($variableName), to drill down to the desired data, but I'm currently working on the webform-mail.tpl.php template file, which doesn't exactly allow that.

Most of the Drupal devs I've met seem to have this magical knowledge of how variable structures work, and I want to figure out how they found these things in the first place.

For example, I see people talk about structures like this: $node->webform['components'][$key]['form_key'] all the time.

How do they find out what's contained inside $node->webform? Is it some functionality in the devel module, or is there an amazing piece of Drupal's documentation that I'm missing somewhere?


texts: Why is my theme's CSS affecting the admin area?

texts: So my conundrum is that my sites front-end theme is affecting the admin area. I thought the concept of having a separate admin theme was to avoid this, but alas this doesn't seem to be the case. I've had a similar problem on a few different sites, any ideas on how to prevent theme css loading when working in the admin area?


texts: What are some alternatives to admin_menu module for Drupal 7?

texts:
Is there an alternative to the admin_menu module for drupal 7? I like the fact that it contains all the site links in the dropdowns, but it seems to conflict with some of the modules I have installed and I have run into issues with this module. I'm not sure why its such a heavy module. I guess it has to transverse the entire admin link structure and rebuild it which causes issues.

What are some good admin_menu alternatives that provide very similar functionality?


texts: what is a reasonable value for max_allowed_packet for Drupal 7 with moderate traffic？

texts:
I need to know some ball park number for this variable for my drupal 7 site. I recently got a "drupal "PDOException: SQLSTATE[08S01]: Communication link failure: 1153" error. I am a newbie to mysql and am using shared hosting. I probably need to ask the administrator to do it for me.

Thanks in advance.


texts: How to hide an empty view block when using a contextual filter and NO file fields?

texts:
I'm trying to figure out how to hide a view block when it has no rows. Though this questions is similar, it's not the same. In my situation I am also using a contextual filter but have no file fields so the answer in that question doesn't apply.

I've tried global: null as a second contextual filter but still the block shows with just the title.

Can anyone help me solve this issue.

Many thanks for any help.


texts: Activate menu item with preprocess_page function

texts:
Hi my international friends!

I work in Drupal 7.38.

If the current page belongs to a specific content type, I want to activate a specific menu item.
By to activate a specific menu item I mean that this menu item has the class active.

I try to do this with preprocess_page() function within template.php. It does not work :(.

Here is the code.

function MY_THEME_preprocess_page(&$vars) {
  if( !empty($vars['node']) ) {
    switch ( $vars['node']->type ) {
      case 'machine_name_my_content_type':
        menu_tree_set_path('machine_name_menu','path_menu_item');
        break;
      default:
        menu_tree_set_path('machine_name_menu','path_menu_item');
    }
  }
}

I have also tried a variation. Instead of putting:

menu_tree_set_path ('machine_name_menu' 'path_menu_item')

I put menu_set_active_item ('path_menu_item')

Nothing works!

Can you help me. Thanks in advance.


texts: public files config in settings.php creates .htaccess file

texts:
I had multisite previously, two sites sharing same codebase like but having their own files system: -

site1 -> sites/site1/files/FILES_HERE
site2 -> sites/site2/files/FILES_HERE

Now I am trying to separate the sites to its own sites and separate codebase to use the normal Drupal structure like: -

site1 -> sites/default/files/FILES_HERE
site2 -> sites/default/files/FILES_HERE

but somehow whenever I clear the cache, it creates folder like: -

site1 -> sites/site1/files

and uses this instead of /sites/default/files

To overcome that I added some config in settings.php file

$conf['file_public_path'] = 'sites/default/files/';
$conf['file_temporary_path'] = '/tmp';

Now, the site1 uses proper file i.e. /sites/default/files but it creates .htaccess files inside sites/default/files/ folder. The .htaccess file contains:

# Turn off all options we don't need.
Options None
Options +FollowSymLinks

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

The images in the website doesn't load properly because of this file. If I delete this file the Images load properly, but while clearing the cache the file is auto generated and again the image doesn't load.

File permission is not an issue here as its 775 universal except for settings.php file.


texts: Site adds "he" to the URLs of all the Hebrew nodes automatically

texts:
All the nodes of my Hebrew site using Drupal 8 have this problem: Their address is similar to www.example.com/he/node/1, instead of what I was used to in Drupal 6+7 that was www.example.com/node/1. The difference is that now the URLs contain /he/ which I have never added.

It happens even when a node (whenever written in Hebrew or English) has its language set to English or Not specified.

What I tried is the following:

At the start all, my nodes were set to Hebrew so I thought it could be the behavior of the new language system of Drupal 8. I thus changed all nodes written for English speaking audience from Hebrew to English; I flushed the cache, but it didn't help: These nodes still had /he/ in their URLs.
I thought the Alternative hreflang module could cause this, so I removed it, but the problem persisted after flushing the cache.


texts: Page title unable to overwrite default title

texts:
admin/config/search/page-title - Global default title is abc

admin/config/search/page-title - Content type BOOK -> title is def

meta tag -> Content -> page title is ghi

meta tag -> Content -> BOOK -> page title is jkl

content type BOOK -> create new node -> page title -> mno

In the website(Content type Book), the title always shows abc.

I want to edit title, may I know how?

Many Thanks.


texts: How to mark calendar days between two dates?

texts:
I added two cck for start date and end date. I want to mark the dates on calendar.

If I select the start date and end date in single field by enabling requires to date option it works fine.

But I have a different date field for end date.How to do it?


texts: Add custom entity search to Drupal core search

texts:
Is it possible to add results for a custom entity search to the results returned by Drupal core node search? At what point in the process would it be possible to add to the core search results?

I've been looking into hook_query_alter, but I'm not sure where you'd add in the adjusted query parameters for a custom entity. The options mainly seem to be related to adjusting the typical node search.

The end goal is to add the results for Page Manager Search to a standard search, but I keep hitting a wall every way I try to go about it.


texts: How to display multiple nodes of a content type on a page displaying a parent node?

texts:
I have a content type called PRODUCT.  Each of these product's has an entity relationship to one or more other PRODUCT items that are similar.  When a user views a PRODUCT, using the themed output for that PRODUCT, I would like to display the other similar PRODUCT's below it.

Initially I used the entity full item display option in the content output and that worked fine, but I really need each node in a  tag of its own and not have the one product group the related product items under it in the output which is what the entity display filter does.

Entity Display Output....

  ...

     ...

     ...

But what I would like is the following.

  ...

  ...

  ...

Where is the best option to create this type of output?


texts: Programmatically disabling webform component - Drupal 7

texts:
According to hook_form_alter doc for webform, I can target the component's properties using $form['submitted']['component_name'], etc. This works fine for altering title, weight, description. The form structure of webform looks something like:

Array
(
  [#tree] => 1
  [component_email] => Array
     (
       [#type] => webform_email
       [#title] => Email
         .
         .
       [#webform_component] => Array
         (
           .
           .
           [extra] => Array
             .
             [disabled] => 0

Simply changing the disabled property to true or 1 doesn't disabled the component. I have also tried the $form['#node']->webform path.


texts: Create a custom block programmatically and specify region and pages on which created block must shown on

texts:
For create block programmatically I use

$block = BlockContent::create([
  'info' => 'block 3',
  'type' => 'basic',
  'langcode' => 'en',
  'body' => [
    'value' => '
Block's body
',
    'format' => 'full_html',
  ],
]);
$block->save();

It works good enough but is it possible also to specify region and then on which pages created block must shown on?


texts: Drupal 8: Node form submit/update - how to redirect to a custom page with an code-based approach different than hook_form_alter()

texts:
I have Drupal 8 installation, with a custom content type.
I would like to redirect to a specific page after node form submission.

What I have tried so far:
Using hook_form_alter() and it works, but that's not the point here.

What I want to achieve:
Delivering the same functionality in a new OOP code based way.

What I have found so far:
https://www.thirdandgrove.com/redirecting-node-pages-drupal-8

This example shows the replacement for the old hook_init().

Update 1:
Rules module can achieve the desired functionality.

Update 2:
Node_save_redirect module can achieve the desired functionality.

Update 3: A possible answer
https://www.foreach.be/blog/how-manipulate-forms-drupal-8
can someone with enough D8 experience actually confirm if that's actually the official way of doing things ?

Regards,
Oleg


texts: How to use the path suffix in the Metatag page title?

texts:
My articles currently have a Metatag page title [node:title]. Sometimes this results in duplicate page titles (articles can have the same title), which isn't desirable from a SEO point of view. Therefore, I would like to add a number after [node:title] when there already exists an article with the same title.

I use the Pathauto module, which adds a suffix to duplicate paths, so this suffix would be perfect. Can I use the path suffix in the Metatag page title? Or is there another possible solution?


texts: Where is the Rules Evaluation Log?  I need to view it but I can't find it.


texts:
I'm new in Drupal 8 and I need to update the user when a node of a specific content type is created or updated.
I did some searching and I find hook_entity_create but this hook Act when creating a new entity


texts:
My department is planning to move its website to a new platform in the next year. We are evaluating several options including Drupal and Liferay.

One of the critical requirements is that we need to publish press releases at 11:00 each day. This time has to be very precise; how precise was not specified, the specification just said at 11:00 exactly but I would interpret this as meaning within 5 seconds or less after 11:00. This precision is needed because some of the statistics we publish are "market-sensitive" and we don't want some people to get them sooner than others (the media receive them ahead of time under embargo, other people get to see them at 11:00 via other channels).

We were told that Drupal would be able to do this, but in the initial test rounds it did not work. Now we are told that Drupal does not have the capacity to do this, or at least not with the specific architecture which the central IT service has set up with the assistance of Acquia. To quote:

  As it stands now, the proposed solutions by Acquia and the central IT department, which
  are based on existing modules, will not be able to publish 'by design'
  a press release at 11:00 'sharp'.

  'By design' means that content in Drupal which is 'published' is
  identified with a simple 'flag' which is set by a 'cron job' that
  checks at regular intervals if the publish date for an item has
  passed.

  This means that in Drupal content can only be published (better:
  flagged as published) after the publish date/time and not on the
  publish date/time.

It is said that this might result in press releases appearing 5-60 seconds after 11:00.

Does this information make sense? I would have assumed that quite a few organisations have this requirement and that it would not pose a problem for Drupal? I would like to think that a clean solution can be found, as Drupal meets all our other requirements.

Notes:

Our present website uses Oracle Portal version 10.1.4. According to our website team, this platform has built-in timed publishing which works fine. That is, pages and portal items (files) are set up with a specific time to become visible, which is quite precise. We have had some cache-related issues, but none with the actual timing of the publishing.
We normally publish only 1 press release per day, occasionally 2. The press releases themselves are PDF files (ca 150 kbytes) with a 1-line title published on the front page of the website. Therefore the operations which have to happen between 11:00:00 and 11:00:05 are something like (a) do something to make the PDF file accessible (b) write new version of front page (c) manipulate cache(s) so that users actually get the new version of the front page.


texts: All available variables returning node ID in views php in drupal 7

texts:
I am trying to define a custom field in D7 view, and I used views_php.
Here few variables are available as field tokens, but while using it inside the code, it doesn't return its original value, but does the node id.

Available variables:

$view: The view object.
$handler: The handler object.
$static: A variable that can be used to store reusable data per row.
$row: Contains the retrieved record from the database (e.g. $data->nid).
$row->nid: Content: Nid
$row->field_twitter_page: Content: Twitter Page
$row->field_facebook_page: Content: Facebook Page
$row->php: Global: PHP
$data: Contains the retrieved record from the database (e.g. $data->nid).
$value: Value of this field.

I need to fetch the value of "$row->field_facebook_page";
so I wrote:

<a href="<?php print $row->field_facebook_page; ?>"Like

When I click on the "Like" link, the given URL is empty. When I print the variable, I get the node ID.

What am I doing wrong?


texts: Use multiple email addresses on contact form

texts:
I'm using the default D7 contact form to have anonymous users enter some information. I've created various categories and based on the category the message should be emailed to a single or multiple email addresses. The email addresses are valid addresses comma separated as described by D7.

This has worked fine for many years but recently emails are refused by Google due to multiple addresses in the From: header. So D7 sends the content of the contact form to both email addresses but also to the email address entered but with the entire list of email addresses in the From: header.

Is there a way to have both? i.e.

copy of the message sent to the user, with a single, preset email address
message sent to a list of email addresses based on the category.

Preferably with the standard contact form or with a separate module.


texts: Drupal Commerce Paypal WPP Programatically Create a Transaction

texts:
I stumbled on a thread over at: https://drupal.org/node/1867768 and I am trying to do a similar integration with a "one page checkout" where the customer selects the product, puts in shipping information and cc information all on one page and I'm capturing that info using drupal's form api submit callback. I can programmatically create the order, add the profile type to the order but I'm getting a little stuck when it comes to the transaction. By the looks of it Ryan had mentioned that each payment gateway has a different way of declaring the transaction. I'm using Paypal Payments pro also know and Website Payments Pro (WPP) and was wondering how to go about creating a WPP transaction programmatically and seeing if anyone had dealt with this before?

Thanks,


texts: How to find the view/page/module that's generating a SQL statement

texts:
I have newrelic performance monitoring with my Pantheon hosting account. It shows "slow SQL" reports but I can't tell which page, view or module is generating a SQL statement.

For example:

  SELECT node.nid AS nid, node.title AS node_title, users_node.name AS
  users_node_name, users_node.uid AS users_node_uid, node.created AS
  node_created, '?' AS field_data_field_photo_node_entity_type FROM node
  node INNER JOIN users users_node ON node.uid = users_node.uid LEFT
  JOIN field_data_field_photo_topic field_data_field_photo_topic ON
  node.nid = field_data_field_photo_topic.entity_id AND
  field_data_field_photo_topic.field_photo_topic_tid =
  :views_join_condition_? WHERE (( (node.status =
  :db_condition_placeholder_?) AND (users_node.uid = :users_uid? )
  )AND(( (node.type IN (:db_condition_placeholder_?)) AND
  (field_data_field_photo_topic.field_photo_topic_tid IS NULL ) )))
  ORDER BY node_created DESC LIMIT ? OFFSET ?

How could I get that info?


texts:
Does anyone have any examples of importing Sales Tax data from Ubercart 2 into Drupal Commerce?

The two systems seem to use -very- different schemas (Ubercart uses separate line items and Commerce attaches tax to the product/line item. I looked at the commerce_migrate_ubercart module and it doesn't even try to handle this.

The problem is that we have historical data where rates have changed over time so it's not accurate to simply recalculate based on current rates.

We could live with simply being able to override the tax on the entire order, but I can't find a hook to override that in the commerce_orders table.

Edit: I could use commerce_tax_rate_apply('state_sales_tax',  $line_item);

     $tax_price = commerce_tax_rate_apply('state_sales_tax',  $line_item);
    // <--- Now what? I don't understand how to apply $tax_price back to the original line item before saving.

     // Save the line item to get its ID.
     commerce_line_item_save($line_item);

Or: After saving the line item, how do I hook into the standard Rules for tax calculation? (Which work fine for new orders.)


texts: Help with debugging and fixing errors with SalesForce Mapping Module

texts:
For Drupal SalesForce Suite I am having the follwoing Errors show up in my log messages

When I select from the Drupal Entity Type , Drupal Entity Bundle, and Salesforce Object I get these errors

Notice: Undefined index: salesforce_record_type_default in salesforce_mapping_form_validate() (line 520 of /x/x/x/x/x/x/web/sites/all/modules/salesforce/modules/salesforce_mapping/includes/salesforce_mapping.admin.inc).

Notice: Undefined index: salesforce_record_types_allowed in salesforce_mapping_form_validate() (line 520 of /x/x/x/x/x/x/web/sites/all/modules/salesforce/modules/salesforce_mapping/includes/salesforce_mapping.admin.inc).

Warning: in_array() expects parameter 2 to be array, null given in salesforce_mapping_form_validate() (line 520 of /x/x/x/x/x/x/web/sites/all/modules/salesforce/modules/salesforce_mapping/includes/salesforce_mapping.admin.inc).

For just SalesForce Object I get this additional error

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2337 of /x/x/x/x/x/x/web/includes/form.inc).

In the UI I am unable to add more then the initial field, when I click the button to add additional mapping and select my field type, the second row of fields disappears and it logs this error in watchdog

Notice: Undefined offset: 1 in salesforce_mapping_form_field_callback() (line 428 of /x/x/x/x/x/x/web/sites/all/modules/salesforce/modules/salesforce_mapping/includes/salesforce_mapping.admin.inc).

Local Environment on XAMPP Mac OS Yosemite/ Drupal 7.34/ SalesForce Module 7.x-3.0-Dev/PHP 5.6

To further update this issue, it will allow me to create a mapping but with only the first row in the mapping table. If I save it and then go back in to edit, when I click "add another field mapping" I get a popup with this error.

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText:
Fatal error:  Call to undefined function salesforce_mapping_form_validate() in /x/x/x/x/x/x/web/includes/form.inc on line 1513


texts: Problems connecting to database in drupal 6

texts:
Whew, ok I am new to Drupal, and I am dealing with a outdated drupal site. Ive been told not to upgrade yet, so for now I am dealing with Drupal 6. I am trying to stage it on our test server, but it won't seem to connect to the database. (It returns a page that says "Site off-line" and "Deprecated: Function ereg() is deprecated in E:\development\ump_2010\includes\file.inc on line 926") Below that, it states that I could not connect to the database:

The mysql error was: Access denied for user 'root'@'localhost' (using password: YES).

I went into the settings.php file and changed $db_url to the correct one, and $db_prefix remains empty. Where is drupal getting 'localhost' and the password from as well?

Thanks,
Austin Slominski


texts: Dependency Injection is added to core, but there's no documentation to tell how developer can alter the default services. For example, I would like to change cache.bootstrap class to APC Caching.


texts: I'm working on migrating a theme from Drupal 6 to 7 but my dev site doesn't have a block used on the old one. I need to export the block from the old one to the dev one, but I can't figure out how. Help please.


texts: What happens to a render array after hook_form_alter() that does not happen after an AJAX callback?

texts:
I have a multi-value field type in a content type. During hook_form_alter(), I add an #ajax property to the field.

Upon execution, the ajax callback loads a node's custom view mode and two form inputs from another content type into the div.

I am using field_default_form() to generate the form elements.

In order for these addons to persist through clicking the 'Add more' button, I use hook_form_alter() to call the same function that is called by the ajax callback, and I add them into the results/wrapper div.

My problem is that the form elements of the #ajax callback results are not rendered correctly. For example, they do not have a name or id for the <input> tag. One of the fields is an autocomplete field and autocomplete functionality does not get applied to the element.

However, the results of the 'add more' button, which calls hook_form_alter(), DOES render these elements correctly.

As far as I can tell, the render arrays are identical during generation. It seems to me like some additional processing happens after hook_form_alter() that does not happen after my #ajax callback.

I have tried adding #theme, #theme_wrapper, #after_build and #rebuild = TRUE keys to the resulting render array elements, but it does not appear to have any effect.

How can I get these elements to render correctly?


texts: Custom form not being validated on submission

texts:
So, I'm trying to implement a Salesforce generated Web-to-Case form on my Drupal site. I have implemented the form correctly so that it updates the Salesforce application cases, but for some reason the form doesn't get validated before submission. I have placed the form in a block with a custom module for portability and versatility. Here is the code for the form. Neither the required fields, nor my attempt to validate the form are enforced before submission. I'm pasting my code below stripped of extraneous fields to for demonstration.

function web_to_case_form($form, &$form_state){
  $form = array(
'#action' => 'https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8',
);
  $form['lastname'] = array(
  '#id' => '00N6A000009vWYv',
  '#name' => '00N6A000009vWYv',
  '#required' => TRUE,
  '#title' => t('Last Name'),
  '#type' => 'textfield',
  '#maxlength' => 30,
  '#size' => 20,
  );

   $form['maidenname'] = array(
  '#id' => '00N6A000009vWYM',
  '#name' => '00N6A000009vWYM',
  '#title' => t('Maiden Name'),
  '#required' => TRUE,
  '#type' => 'textfield',
  '#maxlength' => 30,
  '#size' => 20,
  );

  $form['email'] = array(
  '#id' => 'email',
  '#title' => t('Email'),
  '#name' => 'email',
  '#required' => TRUE,
  '#type' => 'textfield',
  '#maxlength' => 80,
  '#size' => 20,
  );

   $form['phone'] = array(
  '#id' => 'phone',
  '#title' => t('Phone'),
  '#name' => 'phone',
  '#required' => TRUE,
  '#type' => 'textfield',
  '#maxlength' => 80,
  '#size' => 20,
  '#element_validate' => array('element_validate_number '),
   );

  $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Submit'),
   );
return $form;
}

function web_to_case_form_validate($form, &$form_state) {
  $email = $form_state['values']['email'];
  // Verify that the email address is valid.
  if (!valid_email_address($email)) {
    form_set_error('email', t('You must provide a valid email address.'));
  }
}

Is this because the form is being submitted to an external URL? If that's the case, how to I validate a form before submission? Otherwise, not sure what's going on here. I've even tried to add a validate element to one of the form elements, but that doesn't seem to work either.


texts: I enabled certain page view (which is a clone of currently working view), but its page link returns 404 page

texts: The view is enabled, but its page returns 404. in what cases can such problem exist?


texts: How can I make a node reference URL visible only to the person who created the page/article?


texts: How can I update user data whenever a user account is saved in PHP?

texts:
I need to do some processing (calculate a zodiac sign) on some user data after an account is saved.  (When saving a user account, I want to use a custom module to re-compute a field and save the new value.)

I have a function MYMODULE_calculate_zodiac() which returns the term ID of the user's zodiac sign.  I have used dpm() to confirm that the correct value is calculated.

Here is the function in my custom module:

function MYMODULE_user_update(&$edit, $account, $category) {
  global $user;
  $user = user_load($account->uid);

  $zodiac_sign = MYMODULE_calculate_zodiac($account);
  $edit['field_zodiac']['und'][0]['tid'] = $zodiac_sign;

  user_save($account, $edit);
}

However, when I save a user account with this code, my site just hangs and the user is not saved (error: Fatal error: Maximum execution time of 240 seconds exceeded).  What am I doing wrong?


texts:
I'm trying to create a template for a block that I created at Views. So this View (block) has some filters in it, and if I use the default template layout lists my products as it should. My problem is that when I use a custom template, I don't know how to access to those products variables inside that block. I tried to find that variable using get_defined_vars() but was impossible because it display a huge list of vars, and yes, products are there, in an array called 'rendered_content', but I can't figure out the path to that variable in the huge list that is printed.

Please, help this desperate soul.


texts: How to sell credits as products, using commerce module?

texts: The ideas is to allow users to buy credits through Paypal etc. and only using that credits, they can buy 'real' products. I appreciate your hints to set this up.


texts: How Can I restrict a date picker in a date field, to disable a list of specific days from the calendar widget?

texts:
I need to let the user choose a day from a datepicker in a date field, but disabling a list of specific days from the calendar picker, so the user can't select a not available day.

(Just for explain my use case. I am using Date field and Form api. My Disabled days are in a field in several nodes, and I can get the list of disabled days easily from a View listing this date field. If it is needed it can be exported too as json, xml, plain text or any other format, to serve as entry in the calendar picker.)

(After the user choose an available Day, I will have to do the same to let him select an available Time from a time picker.
This will be an appointment for a Photography Session.)


texts: How to create a URL to an unmanaged public file in Drupal 8

texts:
I'm running into a problem creating a URL to an unmanaged file in the "public" file directory (this is for the file_example for Drupal 8).

The following code will throw an exception:

use Drupal\Core\Url;

$stuff = "content for an unmanaged file\n";
$dest = file_unmanaged_save_data($data, "public://unmanaged-mahem.txt");

print "URI: $dest\n";
$url = Url::fromUri($dest);
$our_uri = $url->getUri();
print "Our URL was created, and thinks it corresponds to the URI $our_uri\n";

//but this throws:
$external_link = \Drupal::l(t('External link'), $url);
print "External Link: $external_link\n";

When run, here's what you see (the stack trace is removed):

$ drush @d8 scr unmanaged-mahem.php
URI: public://unmanaged-mahem_1.txt
Our URL was created, and thinks it corresponds to the URI public://unmanaged-mahem.txt
exception 'InvalidArgumentException' with message 'The URI 'public://unmanaged-mahem_1.txt' is invalid. You must use a valid URI scheme. Use base: for a path, e.g., to a Drupal file that needs the base path. Do not use this for internal
paths controlled by Drupal.' in /var/www/drupal/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php:69

I'm not sure if this is a bug or if this is by design, since in general, you'd want to use a managed file for anything in the public files directory that was for public consumption.  But the change record doesn't say anything about this.

Is there a valid way to create a link to an unmanaged file in Drupal 8?


texts:
I have a content type that has a start_date and end_date fields.

I need to make a view with a filter: start_period - end_period

The view should select all nodes where the two periods overlap, for example:

node: 1 jan 2015 - 31 Dec 2015

filter values to select this node could be:
1 oct 2014 - 1 feb 2015
1 oct 2014 - 1 mar 2016
1 apr 2015 - 1 may 2015
1 apr 2015 - 1 mar 2016

Filter values that do not select the node could be:
1 oct 2014 - 1 dec 2014
1 jan 2016 - 1 mar 2016

Is there a module to do that?
thank you in advance


texts: views filter for current user with a relationship

texts:
I know how to create a view that filters nodes that were authored by the current user. What I want to do is filter based on the author of a node that has a relationship with the node.

For example:
My view has a filter to show nodes of type A
type A has a field that is a reference to type B
I want a filter that shows nodes (of type A) where the referenced type B node was authored by the current user.

In D6, I did this by creating a relationship to B, then adding a filter where (B)User=Current (that is, User = current with a relationship to type B). I can't figure out how to do this in D7.

So far I have created a relationship to "Content:Author" which does not allow me to define a relationship to type B. Then I created a filter for "(author) User: Current (Yes)" but this appears to be filtering based on the author if my type A nodes.

I've tried googling, but can't seem to come up with the right keywords.


texts: Using Gulp JS in multiple theme development

texts:
I use Gulp JS in my themes but the issue I'm having is we work on many themes in our drupal site (sometimes up to 40!).

I want to avoid repeating the same "node_modules", "gulpfile.js" and "package.json" files in every single theme. If we want to change 1 of those files, we would have to update each file in every theme across all sites which is going to get too messy.

I would like to have the Gulp files live in sites/all/libraries and have gulp watch my theme that I'm working on.

To anyone experienced with Gulp, any idea's on how this can work?

Edit:

I have moved the 2 gulp files & node_modules folder into /sites/all/libraries/gulp
I have edited gulp.js to point to the theme I'm working on, code is below (I have tried a few different combinations including an absolute path):

gulp.task('less', function() {
  gulp.src('../themes/theme_name/css/style.less')

When I type gulp in the command line in my theme directory I get this error:

Local gulp not found in /var/www/site_name/sites/all/themes/theme_name

If I go into sites/all/libraries/gulp, type gulp in the command line, the gulp process starts, but if I edit a Less file and save it, gulp doesn't compile the css.

Thank You


texts: Showing All Taxonomy Terms count based on a given contextual filter

texts:
I need to create a view that shows All Taxonomy Terms count from a vocabulary based on a contextual filter given.

The contextual filter I'm to be passed are Regions and Regions are taxonomy terms as well so I pass the term name via URL and the contextual filter will then convert the term name to term id and it's working fine and it's already showing the list of Taxonomy Terms and their count (See pic 2).

My problem is that it's only showing terms that's been used, I need to show all terms even terms that hasn't been used or have 0 result on count. I already supplied 'No Result Behaviors' on the fields yet it's still not showing. Can someone help me on this one? Thanks!


texts: drupal_mail sending wrongly encoded special characters in mail subject

texts:
I am using drupal_mail() function to send email. I have PHPMailer module with Mime Mail. It works perfectly, embedding images, sending HTML code, but for some reason, the subject line is pledged with bad characters, all the special chars of other languages do not display, a 'X' character display instead, but in the body of the message, it appears perfectly.

function mymodule_mail($key, &$message, $params) {

    $message['headers']=array(
        'MIME-Version' => '1.0',
        'Content-Type' => 'text/html; charset=UTF-8; ',
        'Content-Transfer-Encoding' => '8bit',
        'Return-Path' => $params["from"],
        'Reply-To' => $params["from"],


texts: path issue with translated (entity_translation) nodes

texts:
I use Drupal 7, entity_translation and pathauto with 2 languages: EN, FR.

I create a new content (of a content type with "entity translation") and I title it "test". Since Generate automatic URL alias is enabled, the URL /test displays the content.

I then translate this to French and submit.

On the sidebar I have a language selector which for FR links to /fr/node/1.

How is it possible to automatically make it link to /fr/test? The only way to solve this is by manually typing test in the alias of the French translated content. Why isn't pathauto working in the translations of the node?


texts:
I have a project where I would use DRUPAL as an internal facing administration system. May even be used as a Client facing solution.  But it would NOT be PUBLIC facing. My reason is that I want to use DRUPAL's roles, Authentication, and forms handling.
The PUBLIC facing/ client end is something different.  These will be Mobile apps on iPHONE and ANDROID.  And there will be a lot of data.
My thought was that the master DB could be maintained in the DRUPAL system as it would be under minimal Authenticated load.  But CRON jobs would fire at random times to take a snap shot of data and post it the couchDB system.
I am choosing couchDB because I am already comfortable with its replication including replication to mobile devices.
My DRUPAL question is, how do a create the JSON file and post it to a couchDB system?

SOme thoughts...
1... Write a module that fires a procedure that will take a snap shot of the db and post it to the couch system.  This could also post static JSON files to an FTP server, that could be synched to mobile devices.  But this can be overwhelming for the hosting computer.  Can I get some sample code or suggestions please.

2... Use DRUPAL services. Write Node.js ( or what ever my taste is )   that will create a JSON file, and post it to the couchDB system.  Or create static files.  I personally like this idea as I can host the Node.js on a separate system.

3... is there another way?


texts:
I started dev on Drupal 8.6.0 and have since updated to 8.6.3. I have also cleared caches, run updates and cron.

I have set up a content revisions view:

FIELDS
Content revision: Revision create time
Content revision: Revision ID
Content revision: ID

FILTER CRITERIA
Content revision: Published (= Yes)

SORT CRITERIA
Content revision: Revision create time (desc)

CONTEXTUAL FILTERS:
Content revision: ID

So I can get all the revisions for 'this' node. The view is a block, so when I place the block on a node, I get the revision id & date showing as expected.

BUT, there seem to be additional revisions in the view then listed in the revisions tab.

For my test node, I have deleted some of the revisions.
The node's revisions tab lists:
revision id:97 - 21 Nov 2018 [the current active revision]
revision id:96 - 16 Nov 2018
revision id:39 - 22 Oct 2018
...

But the view is listing
revision id:97 - 21 Nov 2018
revision id:96 - 16 Nov 2018
revision id:84 - 05 Nov 2018 <- not listed on the node's revisions tab

If I take a look at the DB, I have the following:

table: node
nid:1; vid: 97;
which matches the current node / vid

table: node_field_revision
nid:1; vid: 97; changed: 21 Nov 2018
nid:1; vid: 96; changed: 21 Nov 2018
nid:1; vid: 84; changed: 05 Nov 2018 <- not listed on the node's revisions tab
...

table: node_revision
nid:1; vid: 97; time 21 Nov 2018
nid:1; vid: 96; time 16 Nov 2018
nid:1; vid: 84; time 05 Nov 2018 <- not listed on the node's revisions tab
...

If I go to /node/1/revisions/84/view the revision shows.

How do I either remove these deleted revisions or filter them out of my view?

thank you for your help,

ice70


texts: How to alter textfield auto-submit delay?

texts:
I have a view with exposed filters using AJAX and auto-submit feature.

The problem is it reacts too fast, submitting the request after every key up very fast, so that the view is reloaded before users could finish to type search text...

I would like instead to choose how many millisec it waits before sending request...


texts: I am having multiple reports in google analytic. I have setup the configuration so that i receive the PDF for all the report in one email.My requirement is that i need all the reports in one PDF .Is there any way to configure that in google analytic ??


texts:
Some of my website visitors are stating that they are filling out the webform (ver 7.x-4.2) and we are not getting the email. They have not provided any detail (error messages, etc...) and when I login and review the Results tab I do not see their emails. I've tested the webform and I get the emails. My questions are as follows:

1) Is there anyway to look for webform errors in a log file? Where would I look?
2) If a webform is not successfully sent, it won't show in the Results tab correct? When does the submission get recorded?

Regards,

John


texts: What's the difference between globals $base_root and $base_url

texts: Can't seem to find the difference between these.  D6 is what I need to know, but would love to know how those looks into 7 and even 8.


texts:
I want to display the login form in a popup when a user is not logged in (meaning Anonymous).

I read this tutorial, but when I try nothing happens, so I think maybe it's because I am on Drupal 7? How is jQuery called in Drupal 7?


texts: How to make select option works like a button?

texts:
I have created a contact form by using webform module, in that I have added one component as reset and the type is select options.

My requirement is when I choose this reset option from that dropdown and submitted the form, I want to reset my form. I have no idea how can I achieve this. I tried following but not worked, please help me regarding this.

function test_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == 'webform_client_form_111') {
    $form['submitted']['reset']['#option'] = 'test_reset';
  }
}
function test_reset(&$form, &$form_state){
  $form_state['rebuild'] = FALSE;
}


texts: Panels + Recaptcha : how to add a (re)Captcha in my panels view?

texts:
I've just installed Panels 3.1 on my D7 website.

There is no options to add a Recaptcha form on my Panels view.

Where should I find that ?

Thank you,


texts:
Client wants a blog archive with the posts inside accordions whose toggle is the year. Two example years HTML below.

I have the individual fields exposed as tokens within my view with no problem.  What I can't see how to do is to enable conditional logic so I express the Year toggle structure once per year of posts.

Is this possible with a View?

I went over Blog monthly archive block - list of posts grouped by year then month
I read the 10 year old post at http://chrisshattuck.com/blog/how-create-monthly-archive-block-drupal-blog-views

I have a working view Block but not nesting the way I need it.  It outputs a whole accordion per post (as I knew it would).

2019

{Authored on} - {Linked title}

2018

{Authored on} - {Linked title}


texts: How to create custom page with user images in grid and with pagination, not using views

texts: As I guess I need to override node.tpl.php or page.tpl.php?


texts: How to create field template for displaying taxonomy terms as list in full content page?

texts:
We have a content type displaying taxonomy term input as one of its fields. The goal is to display the one or more terms as an unordered list. That is not an option available in the Manage Display tab, and the default display does not break the entries into separate lines:

Editing the theme's template.php file by changing

$output .= ($variables['element']['#label_display'] == 'inline') ?
'
' : '
';

to

$output .= ($variables['element']['#label_display'] == 'inline') ?
'
' : '
';

we get the desired bulleted list:

– but that is not desired as the default in other content types.

How can this display be customized to be unique to this content type? From some reading it is understood that a custom field tpl.php could do this, but help is needed in understanding how to set that up for this unique situation. Can anyone suggest a path?

--Thanks--


texts: Separate 'free tagging' terms from normal taxonomy terms?

texts:
How to separate 'free tagging' terms from normal taxonomy terms? By default Drupal outputs all terms despite of their vocabulary in one list, which isn’t great at all. On the output we want to get something like this:

vocabulary:tag.


texts: I have a drupal page with the blog module. Every user has his own Blog, reachable by site.name/en/blogs/user.name but on the blog entry i have added an new field where i can list all Authors. I need now a view which reads this information out of this and show all blog entries of this Author in his blog. Because now, there is the entry only on the blog of his owner. thanks (drupal 7)


texts:
I created a custom module that can save nodes.

I want a checkbox that determines whether the node will be saved or not.

This is the node_save program :

     global $user;

// IF (FORM_STATE [VALUE][CHECKBOX] == Checked ! ) {

        $node = new stdClass();
        $node->type = "services";
        node_object_prepare($node);
        $node->language = 'fr'; // Or e.g. 'en' if locale is enabled
        $node->uid = $user->uid;
        $node->status = 1; //(1 or 0): published or not
        $node->promote = 0; //(1 or 0): promoted to front page
        $node->comment = 1; // 0 = comments disabled, 1 = read only, 2 = read/write
        $node->title = $form_state['values']['produit_de_client'];

        $node->field_produit_dc['und'][0]['value'] = $produit;
          $node->field_espace_dediee_categories[LANGUAGE_NONE][0]['tid']=$form_state['values']['espace_dediee'];

        $node->body['und'][0]['value'] =$form_state['values']['text_service'];
        $node->body['und'][0]['format'] ='full_html';

        $aaz= array_filter($form_state['values']['wrapperrr']['id_offre']);
     foreach($aaz as $of)
       {

       $node->field_offre[LANGUAGE_NONE][]['target_id'] = $of;

       }

        $node->field_id_prod['und'][0]['value'] = $produit;
            $file = file_load($form_state['values']['image_dc']);
            $file->status = FILE_STATUS_PERMANENT;

            $uploaded = file_save($file);
            $aaa = file_create_url($file->uri);
        $node->field_produit_dc['und'][0]['value'] = $file->fid;
        $url = $file->uri;

        $node->field_image_serv[LANGUAGE_NONE][0]['fid'] = $file->fid;

        node_object_prepare($node); // Sets some defaults. Invokes hook_prepare() and hook_node_prepare().

        $node = node_submit($node); // Prepare node for saving
        node_save($node);

//ELSE NO NODE WILL BE SAVED


texts: Entity form with pre-populated entity reference from URL

texts:
I have two entities which are in a parent/child relationship. Now I want to add a operations link in the parent's list view so that I can show the child's entity form with the reference to the parent pre-populated.

Ideally, the URL would look something like /admin/myparent/123/mychild/add, where 123 is the ID of the parent entity to which the new child should have a reference. I have the link in place in the operations menu, but I can't figure out how to have my ChildEntityForm load in the parent entity based on the URL parameter. How do I do this in Drupal 8?

I found a couple of questions regarding this here on SO, but they were all about Drupal 7. In addition, the documentation (Using parameters in routes) regarding upcasting url parameters states this:

  Note that this method of providing the entity data to a form is not used for entity forms, such as forms to add/edit/delete entity data.

So is there a solution to this, preferably one that would not require installing a third-party module?


texts: Entity reference or viewfield for Drupal8: How to embedd views output in my node?

texts:
In Drupal 7 it was possible to include into one node (/node/x/edit) the following lines

Label 1
[view:adresses=block_1=argument1]
Label 2
[view:adresses=block_1=argument2]
Label 3
[view:adresses=block_1=argument3]

Result: Output of the view depending on the argument.

I need the same solution in Drupal 8!
How can I realize this?

Maybe entitity reference can solve this but I am able to use entity reference in Drupal 7 but in Drupal 8 this does not work (or I don't know how).

In Drupal 7 there are other modules like "View reference", "Viewfield" ... to solve this in a similar way.

But how can I solve this in Drupal 8?
The output (e.g. block) of a view should be displayed in the content of one specific node.

How can I create a node field with a reference to my adresses view output?
Thank you.


texts: Thanks to kiamlaluno♦ I can load recent nodes using node_load() but how can I load recent nodes from a specific content type?


texts: How can I prevent the theming layer being loaded for JSON requests?

texts:
I can verify that views-exposed-filter.tpl.php is being loaded for basic JSON endpoints that don't re-render any form fields: My autocomplete -  /search_api_autocomplete/search_api_views_flc_biz_search/-/farm - is driven by the View below against Solr, and I'm using project/ajax_facets to POST to
/ajax/ajax_facets/refresh for filtering by other indexed fields.

This breakpoint confirms i'm still loading unnecessary templates during json API calls. I haven't yet dove into the stack trace or scattered more breakpoints to find what is actually loading this, but know that could take many hours to drill down.

For huge performance improvements, how can I avoid all of D7's theming layer when making any requests for JSON?


texts: Documentation of Drupal Content Types and Views

texts:
Drupal 7, Views 3

Ok, I've got a bunch of content types and views, all working happily together, what would be really nice is a way of automatically documenting things, say a printable page of what fields are in a content type or what fields are used in a view. Searching on Google gives lots of info on creating document types but I haven't been able to find anything on actually creating documentation.

Has anyone seen anything like this?


texts:
In Drupal 8, I created a view containing a Custom Text field. I want to alter/change its content for each row I get after running some code. I tried implementing hook_views_pre_render() and template_preprocess_views_view_fields(), but I wasn't able to access this field.

I also would like to learn when this nothing field is added to the view output, and after which hook.


texts: How to add a custom field to views block

texts:
I have a view (block) created. When I modify the view block, I have only the field "block title" in the form. However they are 3 fields (block title, block description et block body) in a block of drupal (which I can create via /structure/block/add).

So my question is how can I add a custom field (like a textfield) to the form of views block?
Is it possible to add it programmatically?

Thanks in advance.


texts: Open Layers Views - Separate Data on Page and Block

texts:
I have a typical OpenLayers Locator proximity search on Drupal 7. I can search a map for my locations and that works great.

I also have a Product content type that is referenced to my locations. What I'd like to do is to display a table of products on my page AND a map of their corresponding locations.

How can I display two separate data sources on a single page?


texts: How can I recalculate field values of a rendered node?

texts: For example on a recipe node, exposing a "yield" field on a rendered node to recalculate ingredient quantity values


texts: Is it possible to use different versions of same language with different prefixes?

texts:
I am building a multi language website. I would like to use 2 instances of same language (maybe with slightly different translations).

So is it somehow possible to use different versions of same language with different prefixes?


texts: Is it possible to replace html outside form with ajax?

texts:
Is it possible to replace a <div> outside form with ajax on select element?

I am having some difficulties, when Drupal generates new content it wraps my HTML with <div> and I don't know why.

This is my form element.

$form['select_element'] = array(
'#type' => 'select',
'#title' => t(''),
'#options' => array(1 => 'Test 1', 2 => 'Test 2'),
'#ajax' => array(
  'callback' => 'ajax_callback',
  ),
);

This is my callback function.

$output = theme('custom_theme_function', array('test_param' => 11,));
$commands[] = ajax_command_replace("#div-id", $output);
return array('#type' => 'ajax', '#commands' => $commands);


texts: Cannot access empty property on entity.inc line 277 when trying to access entity add page

texts:
I created a new entity type with hook_entity_info using this code:

/**
 * Implements hook_entity_info().
 */
function custom_payment_entity_info() {
    return array(
        'custom_payment_period' => array(
            'label' => t('Period'),
            'plural label' => t('Periods'),
            'entity class' => 'Entity',
            'controller class' => 'EntityAPIController',
            'base table' => 'custom_payment_periods',
            'revision table' => 'custom_payment_period_revisions',
            'entity keys' => array(
                'id' => 'pid',
                'revision' => 'pvid',
            ),
            'fieldable' => TRUE,
            'static cache' => FALSE,
            'label callback' => 'entity_class_label',
            'uri callback' => 'entity_class_uri',
            'access callback' => 'custom_payment_access',
            'module' => 'custom_payment',
            'views controller class' => 'EntityDefaultViewsController',
            'admin ui' => array(
                'path' => 'admin/config/custom/custom-payment',
                'file' => '/forms/custom_payment.period.form.inc',
                'controller class' => 'EntityDefaultUIController',
                'menu wildcard' => '%period',
            ),
            'bundles' => array(
                'period' => array(
                    'label' => t('Period'),
                    'admin' => array(
                        'path' => 'admin/config/custom/custom-payment',
                        'access arguments' => array('administrator custom payment periods'),
                    )
                )
            )
        )
    );
}

But when i try to create new entity through the admin add page i get this error:

  Fatal error: Cannot access empty property in
  F:\xampp\htdocs\sfn\sites\all\modules\entity\includes\entity.inc on
  line 277

This is the form function:

function custom_payment_period_form($form, &$form_state, $period = NULL) {
    $form['period'] = array(
        '#type' => 'textfield',
        '#title' => t('Period'),
        '#size' => 5,
        '#required' => TRUE,
        '#element_validate' => array('element_validate_integer_positive'),
        '#default_value' => isset($period->period) ? $period->period : ''
    );
    $form['type'] = array(
        '#type' => 'select',
        '#title' => t('Period Type'),
        '#options' => array(
            1 => t('Day'),
            2 => t('Month'),
            3 => t('Year')
        ),
        '#required' => TRUE,
        '#default_value' => isset($period->type) ? $period->type : ''
    );
    $form['price'] = array(
        '#type' => 'textfield',
        '#title' => t('Price'),
        '#size' => 5,
        '#field_suffix' => t('SYP'),
        '#required' => TRUE,
        '#element_validate' => array('element_validate_integer_positive'),
        '#default_value' => isset($period->price) ? $period->price : ''
    );
    $form['weight'] = array(
        '#type' => 'weight',
        '#title' => t('Position'),
        '#default_value' => isset($period->weight) ? $period->weight : ''
    );
    field_attach_form('period', $period, $form, $form_state);
    $form['actions'] = array(
        '#type' => 'actions',
        'submit' => array(
            '#type' => 'submit',
            '#value' => t('Save')
        )
    );
    return $form;
}

Can you help me fix this?

It's my first time working with entity type creation i followed the entity API documentation and the video entity example found here github.com/Lullabot/entity-api-demos/tree/master/docroot/sites/… i don't know exactly what is messing here.


texts: SQL query to display a particular content type?

texts:
I want to create a view which displays a list of a particular content type. I only have access to the database and I need to figure out the list of content type through view; therefore, I am thinking to write SQL for it. Is it possible to do?

I am using Drupal 6.


texts:
Sorry for repeating this subject. I have studied previous and similar questions but I have been unable to resolve the issue.

I have a module with set to version 7.x-0.1 and I'm trying to execute a simple hook_update_n - but it's not executing.

I read that the hook_update_n naming convent has to be specific so I changed my module version to 7.x-1.0

The code I'm using is as follows:

    function projecty_update_7101() {
    drupal_set_message("Executing Update#7101!");
}

I've tried a variety of number sequences but no joy.

The schema_version for my module in the systems database table is set to 0.

Can someone please tell me what I'm doing wrong?


texts: Cache error on file upload with media, multiform, and plupload

texts:
Checkout the log entries for a site I am working on, I found multiple pairs of the following notice/error:

  Error: Form build-id mismatch detected while attempting to store a
  form in the cache. Notice: Undefined index: #build_id in
  form_set_cache() (line 564 of /dir/includes/form.inc).

I am using media-2.x with plupload and multiform. The above messages are always logged for all files uploaded through plupload at file/add. Any ideas what is going on here and how to fix it? There will be a lot of file uploads on this site, and I really don't want the database filling up with these log entries.

I am getting these messages with Pantheon and with my local environment, so going to assume it is not a server configuration issue, Core and all modules are up to date. Php is 5.4.

Any help would be very much appreciated!


texts: Cannot load module uninstall page - says module does not exist

texts:
I accidentally deleted the Markdown filter module from the file system while it was still enabled. So I installed it again, via the GUI.

Now I cannot load the module uninstall page - it says "The website encountered an unexpected error. Please try again later", and the message in the log says Drupal\Component\Plugin\Exception\PluginNotFoundException: The "markdown" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition()

I have cleared caches, run cron, deleted sites/default/files/php ... all to no avail.

Any ideas?

Edit: I have just tried to enable the module again, and got this message: Unable to install Markdown filter, markdown.settings already exists in active configuration. I looked through the config and cache_config tables and cannot find this setting.


texts: How to see the results of my first module

texts:
I created a module to alter the query executed by a view, but i cannot figure it out how to test it ...  I mean where should i see the results ?
I've created the following files:

my_module.info
my_module.module
my_module.views.inc

in the second file i have:

function my_module_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'my_module'),
    'template path' => drupal_get_path('module', 'my_module'),
  );
}

and in the third one:

function my_module_hook_views_query_alter(&$view, &$query)  {
  var_dump($view);
}

Where should i be able to see the result of var_dump ?


texts: Custom rendering exposed filters in Views

texts:
I'm sorry if this is dumb question, but I'm creating a search page for a content type using Views in Drupal 7.   I am developing multiple exposed filters to achieve this, however, when the filters are rendered, they are done so side by side.  I would like them to stack on top of each other with the "Search" button at the bottom.

Is there something obviously simple I am missing or does anyone know how to do this?


texts:
I am trying to set up username as a main path to the user profiles in Drupal 7; for example, I would like to have mypage.com/someusername as path alias for the profile of the user that uses "someusername" as username.

I am using the Profile 2 module as well. I tried everything, but I cannot achieve this.


texts:
I'm creating a user-upload photo gallery, and I require admin approval on all user uploads. Photos will be a content type with just a few fields (Image, Taxonomy, Tags). I'd like to be able to view a grid of all uploaded photos at a glance, and then check a box next to each one and publish/unpublish all that are selected. Is there a method by which I an do this using Views? If not, is there another method/module that can provide this type of functionality?

Thanks!


texts: In Drupal 7 Views, how can I display a block on every page of a view?

texts:
I am trying to display a SimpleAds block for every page of my view. How can this be accomplished?

Clarification: I would like to display the block once for each page of results. I am using the infinite pager module.


texts:
When running xdebugger in hook_init(), I noticed that the debugger was stopping at same break points more than once.
Why is this so? Will it not affect the page load time?


texts:
I am using Drupal 8. I have installed the Rest module. I need to do polling so I also installed the Poll module. I created two questions with choices in poll and after that I created a view to show polls in that view with Rest Export enabled.

Now there are 3 fields I am showing in my REST export:

Question
Choice
PollID

currently I have two questions and their choices. Here is how its showing in JSON form.

     [{"question":"which is best city",
"choice_target_id":"Delhi, Mumbai, Chennai","id":"1"},
    {"question":"Where do you work?",
"choice_target_id":"Flat, Hotel, Factory, Shop","id":"2"}]

But the thing is when I access the REST URL in my browser window where I am logged in it shows all the field as.

      [
{"question":"which is best city",
    "choice_target_id":"Delhi, Mumbai, Chennai","id":"1"},
    {"question":"Where do you work?",
    "choice_target_id":"Flat, Hotel, Factory, Shop","id":"2"}
]

But when I am not login and when I then call the REST URL from Postman
I get this:

[
    {
        "question": "which is best city",
        "choice_target_id": "",
        "id": "1"
    },
    {
        "question": "Where do you work?",
        "choice_target_id": "",
        "id": "2"
    }
]

choice_target_id is blank. What can be the reason of it?


texts: How can I use the Add Product form as content in the main menu?

texts:
I am using Drupal Commerce to add products to my site.
I would like to use the Add Products form as content in the main menu to make it more user-friendly to edit.
How can I do that?


texts: Migration Source YML File import date string into date and time field of content type

texts:
I have a json file full of data exported from a wordpress site, one field being a string representing a date and time: "03/15/2012 14:46:19".  I would like to import that string into a date and time field of a drupal 8 content type.

I am using a Migration from Source YML file.

fields:
 -
  name: date
  label: 'Date'
  selector: date

Then in process:

process:
  field_press_release_date: date        # is it as easy as this?

Is there a special plug in I'm not seeing listed on:
https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins

I see format date, but couldn't get any format to work.  I have complete control over the format of the date string, I have to do some processing of data from wordpress before drupal so I can do pretty much whatever is needed, if it really is as easy as setting the date_field to the date_string from the fields list, what format does date_string need to be in?

I cannot find a simple example of importing a string into a date and time field, thank you for any assistance!


texts:
I am trying to add a section to the configuration page using hook_menu and add a single entry in the section.

Two modules, the first defines the section on the configuration page.

/**
 * Implementation of hook_menu().
 */
function parent_menu() {
  $items = array();

  // Create local grouping for any custom module that defines a
  // configuration page.
  $items['admin/config/p'] = array(
    'title'            => 'Parent Configuration',
    'description'      => 'Manage configuration for Custom Modules.',
    'position'         => 'right',
    'page callback'    => 'system_admin_menu_block_page',
    'access arguments' => array('administer site configuration'),
    'file'             => 'system.admin.inc',
    'file path'        => drupal_get_path('module', 'system')
  );
  return $items;
}

Second module defines the actual configuration page for one of the custom modules. The idea is that as we add more and more custom modules, we can define a new configuration page inside the parent configuration section.

/**
 * Implementation of hook_menu().
 */
function child_menu() {
  $items = array();

  // settings
  $items['admin/config/p/child'] = array(
    'title'            => 'Child Settings',
    'description'      => 'Administrative settings for Child.',
    'page callback'    => 'drupal_get_form',
    'page arguments'   => array('child_settings'),
    'access arguments' => array('administer child'),
    'file'             => 'child.admin.inc',
  );

  return $items;
}

admin/config/p/child works and I'm able to modify the settings for the module. admin/config/p also works but does not show any sub-links. admin/config does not show the section I've defined.

Please let me know what I am doing wrong here.


texts: How to add an image upload field in a custom Field Type

texts:
I'm defining a new custom Field Type in Drupal 8, let's say MyFieldType, with custom widget and formatter also.

Such Field Type should have these two fields:

text: a simple text value
image: a field where the user that use this Field Type can upload an image, as the built-in image field type.

I created the custom field type with the text field with no problems. Now I'm trying to add the image field also, but I'm stuck and I don't understand how to proceed.

What is the correct way to add an image upload field in a custom Field Type?

What I tried

Below there are the main parts from the custom Field Type. All files are from the folder modules\custom\my_field_type\src\Plugin\Field.

From the file FieldType\MyFieldType.php:

class MyFieldType extends FieldItemBase {

  //

  public static function propertyDefinitions(
    FieldStorageDefinitionInterface $field_definition
  ) {

    $properties['text'] = DataDefinition::create('string')
        ->setLabel(t('Text Value'));

    // $properties['image'] ... go here?
    // ...

    return $properties;
  }

  //

  public static function schema(
    FieldStorageDefinitionInterface $field_definition
  ) {

    $columns = array(

      'text' => array(
        'type' => 'varchar',
        'length' => 255,
      ),

      // What column for the 'image' field?
      // ...

    );

    $schema = array(
      'columns' => $columns,
    );

    return $schema;
  }

}

From the file FieldWidget\MyFieldTypeWidget.php:

class MyFieldTypeWidget extends WidgetBase {

  public function formElement(
    FieldItemListInterface $items,
    $delta,
    Array $element,
    Array &$form,
    FormStateInterface $formState
  ) {

    $element['value'] = [
      '#type' => 'textfield',
      '#title' => t('Value'),
      '#default_value' => isset($items[$delta]->value) ?
          $items[$delta]->value : null,
      '#empty_value' => '',
    ];

    $element['image'] = [
      '#type' => 'file',
      '#title' => t('Image'),

      '#default_value' => isset($items[$delta]->image) ?
        $items[$delta]->image : null,

      '#empty_value' => '',
    ];

    return $element;
  }

}

I can see the file upload field in the edit form (adding a new field with this custom type), but I don't know how to go on and (eventually) how to handle the uploaded image inside the class MyFieldType.


texts: small php script used in drupal module not clear with arrays in php

texts:
Here is a small PHP code which I am not clear with.

/**
* Form for configurable Drupal action to beep multiple times
*/
function beep_multiple_beep_action_form($context) {
$form['beeps'] = array(
'#type' => 'textfield',
'#title' => t('Number of beeps'),
'#description' => t('Enter the number of times to beep when this action executes'),
'#default_value' => isset($context['beeps']) ? $context['beeps'] : '1',
'#required' => TRUE,
);
return $form;
}

In the above user defined function return $form what does it return? How do you access the individual elements of $form['beeps'] what is the significance of writing word beeps in square braces in $form['beeps']

function beep_multiple_beep_action_validate($form, $form_state) {
        $beeps = $form_state['values']['beeps'];
        if (!is_int($beeps)) {
        form_set_error('beeps', t('Please enter a whole number between 0 and 10.'));
        }
        else if ((int) $beeps > 10 ) {
        form_set_error('beeps', t('That would be too annoying. Please choose fewer than 10
        beeps.'));
        } else if ((int) $beeps < 0) {
        form_set_error('beeps', t('That would likely create a black hole! Beeps must be a
        positive integer.'));
        }
}

In above code what is

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

line doing?


texts:
I have 2 server rather than the localhost ex: staging & development.
And I am creating custom fields on the local machine and those fields from
different types [entity reference - user reference - image - ...etc]
so how to migrate creating these fields on the other servers[staging & development] and even [production server] from inside the code, instead of repeating the same process from the Admin of Drupal-7 every time on different server!?


texts: How to fix missing php extensions problems in custom Docker image?

texts:
There are many excellent questions here about automating the initial setup process for Drupal but I haven't seen any pertaining specifically to Drupal containers in Docker.

Here's my setup. I've kept the images/builds as vanilla as possible; the only Dockerfile I have is for composer, inspired by the accepted answer to this question.

docker-compose.yml

version: '2'
services:

  drupal:
    image: drupal
    ports:
      - 8888:80

  mariadb:
    image: mariadb
    environment:
       MYSQL_DATABASE: drupal8
       MYSQL_USER: drupal8
       MYSQL_PASSWORD: drupal8
       MYSQL_ROOT_PASSWORD: drupal8
    restart: always
    depends_on:
      - drupal

  drush:
    image: drush/drush

  composer:
    image: composer
    build: composer_init
    depends_on:
      - drupal
      - drush

Dockerfile for composer:

FROM composer

RUN composer -vvv create-project drupal-composer/drupal-project /var/www/html --stability dev --no-interaction
RUN cd /var/www/html
RUN drush si -y \
  --db-url=mysql://root:drupal8@localhost/drupal8 \
  --site-name=drupal8 \
  --site-mail=drupal8@foo.com \
  --account-mail=drupal8@foo.com \
  --account-name=drupal8 \
  --account-pass=drupal8 >> /dev/null 2>&1

I spun up the build process by issuing docker-compose up -d --build.
Now when the process reached the composer part, it blew up with the following message:

Resolving dependencies through SAT
Dependency resolution completed in 0.001 seconds
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - drupal/core 8.5.x-dev requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - drupal/core 8.5.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - Installation request for drupal/core ~8.5.1 -> satisfiable by drupal/core[8.5.1, 8.5.x-dev].

  To enable extensions, verify that they are enabled in your .ini files:
    -
    - /usr/local/etc/php/conf.d/date_timezone.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
    - /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
    - /usr/local/etc/php/conf.d/memory-limit.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Based on other answers/suggestions here, I added a Dockerfile to my drupal section and added RUN apt-get install php7.0-gd to the Dockerfile, but this now blows up with E: Package 'php7.0-gd' has no installation candidate.

I've ensured that the PHP version for this Docker image is PHP 7.

php --ini gives me:

# php --ini
Configuration File (php.ini) Path: /usr/local/etc/php
Loaded Configuration File:         (none)
Scan for additional .ini files in: /usr/local/etc/php/conf.d
Additional .ini files parsed:      /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-pdo_pgsql.ini,
/usr/local/etc/php/conf.d/docker-php-ext-zip.ini,
/usr/local/etc/php/conf.d/opcache-recommended.ini

How can I resolve this error now?


texts: Feeds importer incremental URL parameter

texts:
I am trying to achieve incremental URL changing to avoid creating thousands of importers. For example if the feed URL contains the param ID=1, i need to loop until ID=1000 and import the provided JSON with the same rules. For example..

https://domain.com/api/v2/bios.json?bio_id=15&with_faces=true
https://domain.com/api/v2/bios.json?bio_id=16&with_faces=true

...and so on...

Is there ANYTHING to allow me do that? Thanks in advance.


texts: How to get selected Value in the listbox by using form api

texts:
I have created a form with fields titled State and City. After selecting the state's appropriate city records, they will be loaded into city listbox. Until now they were working fine, but after clicking the submit button I am not able to store the city's value into variable called $data1. How can I get it to return the city value?

Source code

function form_test_form($form,&$form_submit) {
  $query_state=db_select('state', 's');
  $query_state->fields('s',array('State_code','State_name'));
  $query_state->orderBy('State_name','ASC');
  $state_results = $query_state->execute();
  $options_state = array();

  foreach($state_results as $state_record) {
    $options_state[$state_record->State_code]=t($state_record->State_name);
  }

  $form['state1']= array(
    '#type' => 'select',
    '#title' => t('State'),
    '#options' =>$options_state,
    '#required' => TRUE,
    '#ajax' => array(
      'callback' => '_ajaxfunction',
      'wrapper' => 'divaroundseconddropdown'
    ),
  );

  $form['city_element_wrapper'] = array(
    '#prefix' => '
',
    '#suffix' => '
',
  );
  return $form;
}

Ajax Function

function _ajaxfunction($form, $form_state) {
  $key = !empty($form_state['values']['state1']) ? $form_state['values']['state1'] : 1;

  $query_city=db_select('city', 'c');
  $query_city->fields('c',array('District_Code','District_Name','State_Code'));
  $query_city->condition('State_Code', $key, '=');

  $query_city->orderBy('District_Name','ASC');
  $city_results = $query_city->execute();
  $options_city = array();

  foreach ($city_results as $city_record) {
    // This is correct.
    $options_city[$city_record->District_Code]=t($city_record->District_Name);
  }

  $form['city_element_wrapper']['city']= array(
    '#type' => 'select',
    '#title' => t('District'),
    '#options' => $options_city,
    '#required' => TRUE,);

  return $form['city_element_wrapper'];
}

Now I am trying to store the value of what I have selected in City listbox into $data1 variable but I am not able to store it, Please guide me how to store. It is printing empty value (i.e blank)

function form_test_custom_form_submit($form, $form_state) {
  $data1 = $form_state['values']['city_element_wrapper'];
  print_r($data1); // it is printing empty value
}


texts: debugging an array while creating custom rule

texts:
I am trying debug a custom rule I am creating. In my helper function I am calling an array I want to work with. I want to dpm the contents of the array so that I can see what is available, but it is not working. To check that there wasn't a problem with my array. I set up a new one inside the helper function.

$array = [
      "foo" => "bar",
      "bar" => "foo",
  ];

and then try to dpm the array:

dpm ("array: " . $array);

but all that is shown in the status message is:

array: Array

I have been trying other methods of printing the array like print_r but haven't had any success with these either. How should I be printing my array?


texts: Taxonomy block in views which show the description of the children taxonomy, selected by two exposed filters

texts:
I would like to build a simple block, where my visitors can check our shipping locations.
There are 3 outcome of this form:

Visitor can not find his/her county or city -> we dont deliver there
Visitor finds his/her city and the city field has no description -> we delivery there
Visitor finds his/her city and the city field has description -> we delivery with the desciption's conditions.

I have the following taxonomy tree in Location vocabulary:

County #1

City #1
City #2
...
City #300

County #2
...
County #15

What i did:

I created a new view which shows taxonomy in a block, no pager, only 1 item.
Fields: Taxonomy term: Description
If description has value show that, if empty show "we delivery there"

And this is where I got lost. I would like to have 2 exposed filters, where the visitor can select his/her county and its children cities.

Any help, any suggestions are appriciated, thanks!


texts: Custom entity api admin UI overview table how to add extra columns and operations? Drupal 7

texts:
I've seen this: Custom entity operation links but it's for Drupal 8 and dealing with nodes whereas mine is a non-node type entity.

So how does one go about adding stuff to the row? I want to add custom operations and basically get control of it but I can't see where to start.

I've extended EntityDefaultUIController in the conventional way (like this). When you go the administrative UI we can debug and break in entity.ui.inc and see the following code snippets which seems to be where this gets invoked. But I've got a feeling that there's a quicker and easier way than adding extended versions of the already existing EntityDefaultUIController functions. But what holds the operations & additional column row information?

entity.ui.inc

within overviewTable(...) ...

foreach ($entities as $entity) {
  $rows[] = $this->overviewTableRow($conditions, entity_id($this->entityType, $entity), $entity);
}

... which leads us to the following function (same file)

protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {

and we get use of $additional_cols in the 4th (0th + 3 in array speak) parameter but as you can see it's not passed as a parameter above so how do you go about getting this additional information added into the overviewTable?

    // Add in any passed additional cols.
    foreach ($additional_cols as $col) {
        $row[] = $col;
    }


texts: What is the difference between limit(1) and range(0, 1)?

texts:
In a query I tried using limit(1); I got a WSOD, but when I use range(0,1) I don't get any WSOD.

What is the basic difference between limit(1) and range(0, 1)?


texts: How can trusted host patterns be set dynamically?

texts:
I'm working on a site which uses the Groups module that will allow users to create groups on the site. The site will then allow for users to point custom domain names at the site, with the content for their group being available at that domain.

I've got this set up, except for the trusted host patterns. At the moment I have to manually add the domains to $settings['trusted_host_patterns'] in settings.php. I do not want to have to handle this manually however and would like to set these trusted host patterns dynamically based on domain names stored in a field in the database.

I've been looking at DrupalKernel::initializeSettings(), and I've found that it does not appear any method exists to override the settings:

// Initialize our list of trusted HTTP Host headers to protect against
// header attacks.
$host_patterns = Settings::get('trusted_host_patterns', []);
if (PHP_SAPI !== 'cli' && !empty($host_patterns)) {
  if (static::setupTrustedHosts($request, $host_patterns) === FALSE) {
    throw new BadRequestHttpException('The provided host name is not valid for this server.');
  }
}

So I'm thinking maybe I could use a kernel event, adding trusted host patterns to the settings before the trusted host patterns are called, but I'm starting to think I may be out of luck, due to trusted hosts being set before the database connection is initialized, meaning I won't be able to set trusted host patterns from DB variables.

Does anyone have an ideas of how to get around this?


texts: Alter field collection edit form in hook_menu_alter

texts:
I need to create my own form and validation (when field collection entity is Edited).

function common_menu_alter(&$items) {
    //alter add(insert) - working
    $items['field-collection/field-block-id/add/%/%']['page callback'] = '_common_field_collection_item_add';
    //alter edit - not working
    $items['field-collection/field-block-id/%field_collection_item/edit ']['page arguments'] = '_common_field_collection_item_form'
}

_common_field_collection_item_add() is my own function in my common.module.

I managed to alter the entity on insert, but changing the "edit" part doesn't work. This is the path of my field collection edit: field-collection/field-block-id/%/edit?destination=node/%.
I tried to put this path to $items, but it still doesn't not work.

In hook_form_alter() I did this.

if ($form_id == 'field_collection_item_form' && arg(3) == 'edit') {
       $form['#validate'][] = '_common_field_collection_item_form_validate';
       $form['#submit'][] = '_common_field_collection_item_form_submit';
}


texts: How to compare value of custom field with the Rules module?

texts:
I'm using the Entity has field condition for the After saving new content event, to make sure the rule only fires when the newly created nodes contain the field, which is part of a custom content type.

I want to use the Data comparison condition, but the field doesn't show up in the data selector.

How can I compare the field with a value?


texts: how to apply single page checkout using drupal ubercart

texts:
I am using Drupal6 with ubercart.I want to apply single page checkout instead of multi step checkout. When I checked the ubercart features it provide the one page checkout in features lint but  I am not getting idea how to use this feature.Is there  any module for it?

I have a package functionality in my site.There are three package silver,gold and standard.I want user can choose only one package at a time and user should be not able to add more package in cart if the package is already in cart and if user has already that package?

Please help waiting for the response.

Thanks in advance.


texts: Create two nodes with url aliases on one submission

texts:
I have a content type "News". With URL aliases pattern and token the URL is like this: news/[node:title].

Is it possible to create two nodes on one submission with different URL aliases? Let's say on submitting on the news node, it will create two nodes with two URLs like this: The first one is news/[node:title] and the second will be news2/[node:title].

The whole point is not to create a two different content types, but one and the clone node will have a different URL aliases, so I can filter a new menu block with visible path news2/* and make other logic too.


texts:
I've developed a website and deployed it in a server, I consider this server as a test server. Now, I'm in the final stage of development and I'm looking to move the website content to new server. In that process, I've moved my website contents from test server to the new server, updated the database details in settings.php file, created a database in the new server and imported the .sql file (from the test server). I anticipate all the cloning work is done.

Now, when I look into the new site, the home page appears in the old format - I mean most of the edits that I made have gone. When I click on the menu tabs, the corresponding pages are broken - there is no proper redirection to the pages.

What I've observed was, in the homepage the url was good but when I click on one of the links the url is pointing to something odd like - localhost/new_mywebsite/search. I feel that this is odd. I couldn't trace why it was showing in that way.

Moreover, when i compared the new database with old database(test server) the old one has around 130 tables and the new one has only 90 tables. Even it seems odd for me.

What might the real reason for this odd behaviour? Is it with database or links?


texts: Disable CkEditor to body field of a content type

texts: I enabled the CkEditor module, which is affecting all the text-area fields with summary and input format. How can I exclude the CkEditor for some fields?


texts: How to know what is changing views sql query?

texts: I would like to know what modules are altering the select sql of a view. Is there any way I could know it?. Due to this question I put some days ago, I would like to find why that sql is altered. I have read views core files (core/modules/views/src/Plugin/views/filter/Date.php) but this file isn't adding what I was searching for.


texts: Pre load entity reference fields into a node

texts:
Say I have three content types: Team member, Team and Matchday.

The team content type is made up of entity reference fields, which reference team members.

The Matchday content type should load team members from the Team content type automatically each time a new piece of content is created. Then the content editor should be able to delete people on each Matchday who don't show up, and also add members from other teams who are filling in.

Anyone know how to do this in Drupal 8, even just a general idea to point me in the right direction?


texts: "Jirafe credentials are not set" warning from Commerce

texts:
After install Commerce Kickstart 2.7, there is a warning:

  Jirafe credentials are not set. Get your credentials at Jirafe

What is Jirafe and Jirafe credentials?