texts: Parent and subordinary weights and relations like in menu and taxonomy system module

texts: It seems that there is no module in the contribution repository which simulates the behaviour like this of terms in given vocabulary or menu items in a given menu from system modules in Drupal 7. (?) Wouldn't it be an interesting use-case to achieve something like entity trees simultaniously this way, like a task and sub task management, with a given weight and relation to each other to build parent and subordinary relations between them? I know about many reference and relation modules and asked already some specific questions about them and their limits here but I can't find an entry point where I could start to contribute on this special scenario. I can easely drag and drop taxonomy terms or menu items and give them an "order" and sub "order" in their hierarchy already from core and the system "knows" about this order. Not only of one level, also for more levels. It is not visually only. So I can build paths based on that relations. It seems that this is not possible to make with entities and any reference or relation modules out there ? Am I right or is my question asked the wrong way around?


texts: Does the 'field table' always hold the current value? Or is it only in newest revision?

texts:
As I understand it, the current value for every field can be found in corresponding data table (e. g. field_data_body) and the history of its changes in corresponding revision table (field_revision_body) with the value of newest revision being the same as the value in data table.

Is that, however, really true or do I have to (to get the current value) look into the newest revision (which id can be obtained from 'entity type' table (e. g. node table)). If that's the case then does the data table hold the first value or what?

In other words, when dealing with content in Drupal 7 directly (accessing database and not using Drupal functions (load_entity, etc.)) is it safe to work only with 'data' tables and not caring about 'revision' ones?

//I'm almost sure the way I understand is right and everything seems to verify it, I'd still like to be totally sure.


texts:
I'm under MacOSX and I'm struggling for hours trying to figure out how to make drush run from a bash script.
So let's say I create a named build, then I make it executable.
now I begin the script like this:

#!/bin/bash
drush cc drush

In the terminal if I make ./build, it brings me result like : Drush: command not found
So how can I make it work?

Thank you for your answers!


texts: How to create a Views relationship using the Address Field module?

texts:
I am trying to create a view to filter content types assigned to a specific country (set using Address Field module), determined by the current node's title.

My address field is not being listed under relationships in views.

How am I able to set contextual filters by a nodes country? Is this currently possible, or am I just missing something?


texts:
I have installed latest Drupal 8.1.1 also Devel module installed there is no any option for Display query log on devel setting page while it's present on D7 Devel module.
I have created a view with relationship now I want to display SQL Query of that view at the front end.

How do I print the SQL query of a view in front end?


texts:
I am using Drupal-6 . i am using ubbercart module here. In Content type Product I have a field named Actual Amount.

Now i want to get total of Actual Amount by Datawise only .

Can Anybody tell me how to do this ?

Thanks


texts: Enroll user on course module error due to permissions

texts:
I want that a role called "Profesor" can enroll users on a course created using the course module, using the course-enrollments/search-add view but I'm getting the following error:

Type: views bulk operation
User: profesor1
Message: Skipped Enroll user on user alumno2 due to insufficient permissions.

Here is my permissions configuration:

Administrator can enroll users, any help?

EDIT:

The course permissions are configured as follows:


texts: How to implement a pop up form in hook_page_build

texts: I'm trying to create a serial validator that pops up when the user goes to download a file. I already have a disclaimer in the hook_page_build() but I would like to expand upon this and then ask them to put in the serial number of the product before they are allowed download.


texts: How to get these content types to appear in my view based on role?

texts:
I have two content types known as Generic Credit and Generic Expense. There are only three roles (Secretary, Admin, and Developer) that can create and view this type of content for administrative purposes. Additionally, these are important for a view that acts as a budget, which gathers several types of financially-related nodes. All of these content types are used for calculating a budget for teams (comprised of a coach and several students). This budget view can be viewed by the students and coaches, and it filters correctly, showing the appropriate budget for a team.

That is, unless it's pulling a Generic Credit or Generic Expense. When a student or coach without the three creating roles views the budget, these two content types don't appear. However, when a coach with the Admin or Secretary roles uses the view, they are able to see the Generic Credit/Expenses.

So far, I've tried using Node View Permissions, but that didn't have any affect on the views. I've also tried allowing students and coaches to create and edit the content types, but that has proved futile.

Am I missing something here with the permissions? What settings might I need to check?


texts:
I have made the block and want it to be clickable(entire block) and we can provide the path to it?

Note: There is other question with same heading but it does not provide the answer and it is in context of views.


texts: Programmatically create a Custom Content type on saving a form

texts:
We have explored it and found - how to create a content type by adding the YML files in the config/install directory of a custom module. The new content type will be created when we enable the module.

But we have a use case where we need to generate content types on saving a form.
For eg: We have a custom form with a field called "Content-Type Name". On submitting the form, we need to create a new content type with that name.

We are not able to find any proper documentation for this in Drupal 8.


texts: How do I add code to browse for a file in a Drupal Form?

texts: I am trying to add items to a form (in code) similar to the add image item in the Drupal Add Content form that has the Browse and Upload buttons.  In Firefox, the Browse button invokes a Pop-up window to search files on the user's computer and returns the selected file & path to the associated text box. I would like to review the code in Drupal to understand and duplicate the action. Thus far I cannot locate the code in core modules (its big in there and a file search does not find the word "Browse"!).  Does anyone know where the add content form is, or a reference site that explains it, or how to code it?


texts: How can I make a node like template for a vocabulary?

texts:
I have a taxonomy where I want to theme the term pages.

I only want to theme the terms pages in this taxonomy.

No matter what I do I can't see to get it to show a template file that I can then further customise.

I have a node page at /name
then I have the terms of the taxonomy using the path pattern /name/term_name

Can anyone help me figure this out, it seems strangely difficult. To the point where I am begining to wonder if some module might be derailing me.

From what I understand I should be about to make a template named something "taxonomy-term--myTaxonomy_name.tpl.php" but I can't seem to dislodge the default term view. Even with many cache clearings.


texts:
i have created a content type in which i have a field with a select list. I create views for each option i have on the select list and am not sure how to go about it.

Example - Select list options - car, bicycle, motorcycle

View displaying all cars
view displaying all bicycles
view displaying all motorcycles

i Have tried using taxonomy but i keep getting ajax errors hence why i created a cck select list.

Thank you in advance.


texts: user_authenticate() function not working

texts:
I'm working with Drupal 7, the function **user_authenticate()** working fine with the default User module, but I have implemented a custom "user login" module, and I use this same function in that module, but somehow it is not working at all in this new module.

When we are using this function in default module, it's retrieving all the records based on the user parameters, but in my case it's retrieving nothing.

This is the code that I have put in my custom module file.

if (module_exists('user')) {
     $username = $form_state['values']['name'];
     $pass = trim($form_state['values']['pass']);
     $userRecord = user_authenticate($username, $pass);

     print_r($userRecord); // its resulting me BLANK!!
     exit;

   }

Can anybody help me out please? What would the problem be?


texts: How can I overwrite meta tags on the Drupal blog homepage? I'm using a "Blog" module ( which creates a blog homepage with the URL www.mysite.org/blog ) and a "Metateg" module for generating and overwriting title, description and keywords meta tags. The problem is that I can't find a way to overwrite the default generated meta tags for the blog home page since Metatag module doesn't provide this functionality. Is there any other way to do it?


texts:
I'm trying to override the Drupal Login form. I have been able to unset and modify pieces of it, but the last thing I am struggling with is the name attribute on the submit button. Currently, the button looks like this:

 <button class="btn btn-default form-submit" id="edit-submit" name="op" value="Log in" type="submit">Log in</button>

I am trying to get rid of the name attribute, but I don't see it listed as a array element when I dpm($form). How do I alter this

EDIT:
I almost figured it out. I found that the below can be used to alter the name attribute, but I cant remove it, even if I set it equal to NULL. When set to null, it defaults to 'op':

$form['actions']['submit']['#attributes']['name'] = 'submit';


texts: Commerce + Views: Distinct on Referenced Product not working

texts: I have a Product Display node view which ignores distinct on the query. The goal is to avoid displaying multiple product displays which refer to same Product SKU. I created a relation with the Referenced Product but this did not change anything.


texts: How do I take out the caching and bandwidth optimizations sections out of the performance window for a user?

texts: How do I take out caching and bandwidth optimizations sections out of the performance window for a user?


texts:
I have to deal with order with high quantities by product.

Tax (VAT) is calculated by rule for unit price, rounded, then multiplied by quantity. With high quantity this kind of rounding cause problem.

How to deal with that?


texts:
I'm building a form and setting values via

$form = \Drupal::formBuilder()->getForm('My\Module', ['key1' => 'x']);

where I set the passed key1 as the default values for the associated fields : in My\Module\buildForm, you would find

public function buildForm(array $form, FormStateInterface $form_state, $presets = array()) {

    $form['key1'] = [
      '#type' => 'textfield',
      '#default_value' => isset($presets['key1']) ? $presets['key1'] : $query->get('key1')
    ];

    return $form;
}

This takes place in a controller not directly related to the form and I'd like to retrieve all values set, either as defaults or as parameters of the page, something like ['key1' => 'x'] if no parameter is passed to the page or ['key1' => 'v1'] if the page is called with ?key1=v1

How can I get all the values on my form array (besides filtering on the field names)?


texts: Changing exposed filter doesn't rebuild SQL query

texts:
I created 5 fields for filters. 3 of them are exposed to site visitor. Problem is that if I even change this exposed filter values while editing View it doesn't rebuild SQL query.
Views version: 7.x-3.3
exposed_filter_problems
Other 2 exposed to visitors filter have the same settings but different names.


texts: Restricting view access to a line Item field based on role

texts:
I have an order page that displays a set of line items.

However, my client wants me to remove the "Responsible Vendor" from display for authenticated users, but it should be displayed for administrators and store manager users.
I have tried the following, but I could not get the desired results.

Hide using Field Permission as described in https://stackoverflow.com/a/9187147/260665

Implementing hook_field_widget_form_alter() following https://stackoverflow.com/q/8009716/260665

I am using the following code.
function bricks_field_widget_form_alter(&$element, &$form_state, $context) {
  if ($context['field']['field_name'] == 'field_responsible_vendor') {
    // Users without the "administer nodes" permission should not see the
    // Responsible Vendor section
    if (!user_access('administer nodes')) {
      unset($element['#options']['field_responsible_vendor']);
    }
  }
}

This hook is never invoked for the field_responsible_vendor field  which represents the Responsible vendor entity reference field.
Now, I tried to dig deep and see why this hook was never invoked for the field in which I am interested. I placed breakpoints in /includes/module.inc with some test code in it.
    // Raj:
    $gotIt = NULL;
    if (is_array($context1)) {
      if ($context1['field'] == 'field_responsible_vendor') {
        $gotIt = $context1['field']['field_name'];
      }
      if (is_array($context1['field'])) {
        if ($context1['field']['field_name'] == 'field_responsible_vendor') {
          $gotIt = $context1['field']['field_name'];
        }
      }
    }

I tried it with $context2 too. The nearest I could get was the following.

I could never get to the field_responsible_vendor field to unset it based on the user roles.
Is there anything I am missing? How can I achieve what I am looking for?
As per @Darvanen's answer, I was able to remove the Responsible vendor value using this code.
function bricks_views_pre_render(&$view) {
  foreach ($view->result as $lineItem) {
    if (!user_access('administer nodes')) {
      unset($lineItem->field_field_responsible_vendor);
    }
  }
}

I have the following 2 problems.

This hook is invoked for all views, I would rather like to restrict either the invocation to this page / view alone, or provide a condition to check if it is the page where this code should be executed in order to make sure that performance is not impacted.

The column header is appearing though none of the line items will contain the value for it. I suppose I need to use another hook in order to address this?


texts: domain access display content to ANONYMOUS USER

texts:
I have create basic page that only displays on domain one and not the others which I want. The issue is that the page will only display when the user is log in and I want ANONYMOUS USER to see the content

Under the permissions the View published content has the  ANONYMOUS USER ticked
but I can't seem to find a way or why the content is not displaying until an authenticated user is logged in


texts: Outputting recent comments in a different part of the node

texts:
I have created a custom node, and at the bottom of this node I would like to show the latest three comments made on that node. I have added the code below to my template.php, and then loop through the array to get the data in my node:

if ((arg(0) == 'node') && is_numeric(arg(1)))
{
    $result = db_query_range('SELECT c.cid, c.nid, c.subject, c.name
    FROM {comment} c WHERE c.nid = :cid ORDER BY c.cid DESC', 0, 3, array(':cid' => arg(1)));

    $i = 0;
    foreach ($result as $record) {
        $variables['NewComments']['NewSubject'][$i] = $record -> subject;
        $variables['NewComments']['NewName'][$i] = $record -> name;
        $i++;
    }
}

else {
    $variables['errorCheck'] = t('nope fail');
}

However, I am having trouble outputting this into the node.tpl. Is there an easy way to do this, or should I try something else to tackle this issue?

Thanks


texts:
I know it is possible to override node pages using page manager, then use panels to make new layout by selecting a variant type, and  creating a new variant.

Is it possible not to use the Panels mdoule? I would like to use the Context module, and the default theme regions.


texts: How to show block on pages with URLs containing a question mark ( 'searchquery' )?

texts:
For example I end up with url's like

example.com/viewname?f=[0]field_name=%3A21

I want to make a block visible on pages like the above but not when only the view is displayed.

Only the view will looks like this: example.com/viewname

So my thought was to set the block visibility setting to be only visible on:

example.com/viewname*

That didn't work ( block did not show up ) so i tried:

example.com/viewname?* , example.com/viewname?f* and example.com/viewname/*

No success.

EDIT:

There are some options:

1) Creating a block in custom module could be a solution.

1a Setting visibility to 'none' by unsetting the block content and title ( which I have chosen to use for now )

1b Enabling the PHP filter module and adding a block setting visibility restrictions like so:

/**
  * Implements hook_block_info().
  */
function mymod_block_info(){
  $blocks['mymod_job_agent'] = array(
    'info' => t('block description'), //The name that will appear in the block list.
    'cache' => DRUPAL_CACHE_PER_ROLE, //Default
    'region' => 'sidebar_first', // assign block region
    'status' => 1, // enable the block
    'visibility' => BLOCK_VISIBILITY_PHP, // set visibility to use the result of pages
    'pages' => '<?php return TRUE; ?>',
  );
  return $blocks;
}

Drawback: since hook_block_info is called upon module install only you cant change your code without reinstalling the module. And putting php code in de pages just doesn't feel right.
So I think we can cross option 1b.

2) Another solution would be to use the Block Conditional Visibility by URI Query Parameters module but I couldn't figure out how to use this for this use case.

Reading the comments this is something that should be done in the theme layer...

Hope this helps anyone searching for a similar question. feel free to edit update my question/answer to improve it!


texts:
I'm trying to run this library ParticleJS which requires me to download a Json.

I added this file into theme/libraries.yml this way:

global-js:
  js:
    assets/js/particles.min.js : {}
    assets/js/particles.json : {}

But that gives me this error:

  Refused to execute script from
  'https://www.example.com/themes/nexus/assets/js/particles.json?pem8cm'
  because its MIME type ('application/json') is not executable, and
  strict MIME type checking is enabled.

So I'm added:

<script src="themes/nexus/assets/js/particles.json"></script>

And it is giving me the same error.

Can someone help me with this problem, please? How should I include any other file into twig templates? Thank you


texts: Ajax callback not working with 'language_select' in drupal 8 forms

texts:
I'm trying to implement an ajax callback whenever language gets changed. Following code I have used:

public function buildForm(array $form, FormStateInterface $form_state) {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$langcode = $from_database->lid;
$form['langcode'] = array(
           '#title' => $this->t('Language'),
           '#type' => 'language_select',
           '#default_value' => !empty($langcode) ? $langcode : $language,
           '#languages' => Language::STATE_ALL,
           '#ajax' => array(
        'callback' => ::ajax_example_autocheckboxes_callback',
        'wrapper' => 'checkboxes-div',

       ) ,
       );

$form['checkboxes_fieldset'] = array(
  '#title' => t("Generated Checkboxes"),
  // The prefix/suffix provide the div that we're replacing, named by
  // #ajax['wrapper'] above.
  '#prefix' => '
',
  '#suffix' => '
',
  '#type' => 'fieldset',
  '#description' => t('This is where we get automatically generated    checkboxes'),
 );
}

function ajax_example_autocheckboxes_callback($form, $form_state) {
  return $form['checkboxes_fieldset'];
}

But ajax callback is not working. Suggest a way to implement ajax on language select.


texts: Can the following be done with Organic Groups?

texts:
I have a menu tab called "College" and what I'm trying to do is, when one user logs in he will be able to see information about the college regarding him.

So I have 2 colleges called CIT and UCC and I want users going to CIT to be able just to view the CIT page when they click on "college" from the menu and users going to UCC to be able to view just the UCC page when they click on college. I want students to be able to just view the information and one user to be able to edit it.

I've been searching how to do it for a while and was wondering if this is something I can do with organic groups or is this a completely different thing?

Any HELP be greatly appreciated!!!!


texts: How do I automatically load a bunch of JS/CSS from sites/all/libraries without hook_library?

texts:
My question is simple.

Is there a straightforward method to load a library e.g. ibeginshare (it contains 2 css, an images folder and 1 js) which I copied in sites/all/libraries to use it in my module?

I have created a module that implements hook_block_info and hook_block_view and I want to load this library in its hook_init.

Is it mandatory to use hook_library and define there everysingle file then call it via drupal_add_library? I am confused. What if I have dozens of js/css files ? What if I don't want necessarly to share the library with other modules?

NOTE
I managed to load the file like this:

METHOD 1

function MYMODULE_init() {
  drupal_add_js('sites/all/libraries/ibeginshare/share.js');
}

I would like a more elegant way so I tried:

METHOD 2

function MYMODULE_init() {
  drupal_add_library('MYMODULE', 'ibeginshare');

}

/**
 * Implements hook_library().
 * @return string
 */
function MYMODULE_library() {
  $libraries['ibeginshare'] = array(
    'title' => 'ibeginshare',
    'website' => '',
    'version' => '1.2',
    'js' => array(
      'sites/all/libraries/ibeginshare/share.js' => array(),
    ),
    'css' => array(
      'sites/all/libraries/ibeginshare/share.css' => array(),
    ),
     'css' => array(
      'sites/all/libraries/ibeginshare/share-print.css' => array(),
    ),
  );

  return $libraries;
}

this loads all libraries but the plugin doesn't initialize. I wonder why.
I think will work if I add a weight property in the hook_library but anything I tried didn't work.


texts: Updating the PHP version of an existing site?

texts:
I am asking this as a total ignorant in differences between PHP versions: Is it possible to update the PHP version of an existing Drupal site that is installed on a local server on Ubuntu?

I mean, let's assume my Apache is in the last version possible, as well as my mySQL, and PHPmyadmin, and I want to update from PHP 5.x.x to 7.x.x. Is this possible? Is it done by an internal Drupal module or an external tool?


texts: Accessing a block types content programatically

texts: I have created a block type in the drupal 8 UI (structure/block/block-content/types ) that has two fields that are just strings. I then created 4 pieces of content using that block_type. How do I access the content created by the block type in hook_preprocessor_html programmatically?


texts:
I'm building a site using Drupal 7 and have a question regarding navigation and roles. My site requires that a lot of content be accessible only to members. I'm wondering how I can show a secondary navigation element on the site once a user logs in? Obviously this would be tied to an authenticated user role.

Any assistance is greatly appreciated!


texts: Where is the group of a fields group stored in datababase (to get it programatically)?

texts:
I have installed the Field group module, which, as the name implies, groups fields together. Once you have ordered the fields of content type, is there any way to programmatically get the group of the fields that are grouped together?

I have search in database (columns field_config, field_config_instance) and there is not any column to save that information. Where is that information (the group of field) stored in database?

Thanks in advance.


texts: save cart for anonymous user after registration

texts:
I know drupal commerce let anonymous user create cart and in billing or shipping step create a user according  billing or shipping information,But I want implement another policy,user can add product to his/her cart,then when he/she want checkout I want redirect him/her to registration form I provided then after he/she fill information(registration) then he/she can keep on shipping.
I have idea I save cart information in temp variables,after he/she create user add that cart information to him/her,But I don't sure this is the only and best way,anybody has idea about how can I achieve this task?


texts: Error when clearing cache: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cache_views' doesn't exist

texts:
today I have almost successfully moved my Drupal website from localhost to a shared hosting account. Everything seems to work fine for now, except for 1 thing: anytime I want to clear Drupal's cache I get this error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'prevcer_drupal.cache_views' doesn't exist: TRUNCATE {cache_views} ; Array ( ) in cache_clear_all() (line 165 of /home/prevcer/public_html/drupal-7.26/includes/cache.inc).

The problem happens because I didn't import 'cache_views' table as it was giving me errors. The weird thing is I can import it now, but it breaks my site completely with these bunch of errors:

Additional uncaught exception thrown while handling exception.

This error goes away as soon as I delete 'cache_views' table again, but the original problem stays.

I've tried multiple solutions (created blank 'cache_views' table, created same 'cache_views' table as 'cache', tried importing whole database again and again) but nothing helped.

Comments appreciated!


texts: How to eMail webforms to 2 alternating email adresses?

texts:
I got a Drupal 7 site with a working webform in it. Now I got 2 email addresses to send the mails to, we want to send them like so:

Send 1st email to emailadress A.
Send 2th email to emailadress B.
Send 3th email to emailadress A again.
Send 4th email to emailadress B again
... and so on.

Can someone help me how to do this or push me in the right direction?

I was thinking about something with the Rules module.


texts: How to show a field in views only when a checkbox is ticked?

texts: I want the user to be able to choose whether to show a description or not for each node in the view. Adding the filter only works on the entire object, I just want to show/hide one field. How can I achieve this?


texts: Taxonomy term view with number of items for parent and child terms

texts:
For my shop, I need a taxonomy tree view with 2 levels, the number of items should be shown in brackets for every parent and child term.
My problem: it works for the child terms, but not for their parents.

This should my view look like:

parent-term-1 (15)
- term-1.1 (7)
- term-1.2 (8)

parent-term-2 (15)
- term-2.1 (6)
- term-2.2 (9)

But it looks like this:

parent-term-1 (0)
- term-1.1 (7)
- term-1.2 (8)

parent-term-2 (0)
- term-2.1 (6)
- term-2.2 (9)

My view
Vocabulary Name = Category

Relationships
Taxonomy Term: Parent term (Identifier = Parent)
Taxonomy Term: Content with term (Identifier = node)

Use aggregation: Yes

Fields
Taxonomy Term: Term ID (Exclude from display)
(Parent) Taxonomy Term: Term ID (Exclude from display)
Taxonomy Term: Name
(node) COUNT (Content: Nid)

Filter criteria
Taxonomy vocabulary: Machine Name=(Category)

Format
Format: Tree (Main field: 1st Term ID, Parent Field: 2nd Term ID)
Field Settings: 3rd + 4th field inline

Any ideas?


texts:
I'm managing Drupal 7 and Drupal 8 sites, so I'm running Drush 8 as that's the only version that can manage both. The Drupal 8 sites are installed using Composer and my local setup runs on MAMP 5.5.1.
It works fine for the Drupal 7 sites, and rsync works for the Drupal 8 sites as well. However, sql-sync fails. When I run drush sql-sync @local.dup @prod.dup, I get the following messages.

  Warning: require(/Users/username/path/to/local/vendor/bin/drush.php): failed to open stream: No such file or directory in /Users/username/path/to/localvendor/bin/drush on line 4
  Fatal error: require(): Failed opening required '/Users/username/path/to/local/vendor/bin/drush.php' (include_path='.:') in /Users/username/path/to/local/vendor/bin/drush on line 4
  The command could not be executed successfully (returned:                                                                                [error] Warning: require(/Users/username/path/to/local/vendor/bin/drush.php): failed to open stream: No such file or directory in /Users/username/path/to/local/vendor/bin/drush on line 4
  Fatal error: require(): Failed opening required '/Users/username/path/to/local/vendor/bin/drush.php' (include_path='.:') in  /Users/username/path/to/local/vendor/bin/drush on line 4, code: 255)
  The Drush sql-dump command did not report the path to the dump file produced. Try upgrading the version of Drush you are using on the source machine.

I get similar errors when checking drush @local status and drush @remote status as well as when I try to use the Drush 9 included in each site ( cd path/to/docroot > vendor/bin/drush @self @remote).

I've tried removing all Drush instances and installing only the same version that my host (cloudways) uses on the remote server (Drush 8.0.5) with no luck. I've installed Drush using CGR as instructed on Install (alternatives).
I've also checked my alias' file in the global Drush folder multiple times and can't find any issues.

What can I do from here to debug and resolve the issue?


texts: How do I display the raw value of a CCK field securely?

texts:
I have a CCK field that I can print out by doing:

print $node->field_cck[0]['value'];

Are there any security concerns with doing this?


texts: How to hide selected term values in Views?

texts:
I have a content type with a taxonomy field called Price. Authors create content based on this content type. While doing so they select from a Price list (two options). Either they can select 'Costs Money' or 'Free'.

In Views, I want to show the value (a rendered image) if it's set to "costs money" and NOT display the field if it's set to "free".

Is there an easy way to accomplish this in Views?

I'm using Views 3 and Drupal 7.


texts: How can I specify which submit action is the default?

texts:
I have a custom form, with two different submit actions. Here's my code (edited for brevity):
class EditSlideshow extends FormBase
{

    public function buildForm(array $form, FormStateInterface $form_state)
    {

        $form['actions']['delete'] = [
            '#type' => 'submit',
            '#value' => t('Delete Slideshow'),
            '#submit' => ['::submitDelete'],
            '#validate' => ['::validateDelete'],
            '#attributes' => ['class' => ['btn', 'btn-blue']],
        ];

        $form['actions']['submit'] = [
            '#type' => 'submit',
            '#value' => t('Save Changes'),
            '#submit' => ['::submitForm'],
            '#validate' => ['::validateForm'],
            '#attributes' => ['class' => ['btn', 'btn-blue']],
        ];

    }

}

This mostly works: if I submit the form by clicking on the "Save Changes" button, then validateForm() and submitForm() get called; and if I submit the form by clicking on the "Delete Slideshow" button, then validateDelete() and submitDelete() get called.
But if I submit the form via some other means – for example, by pressing the Enter key while the cursor is inside a text field – then the first action gets called (in this case, the delete action).
That isn't what I want – the submit action should be the default, not delete.
Is there some way that I can tell Drupal to treat submit as the default action instead?
A few things come to mind:

I could register the submit action before the delete action, so that it becomes the first (and therefore the default). I'd rather not do this, though – I want the "Save Changes" button to appear after the "Delete Slideshow" button.

To get around that, I could use CSS to rearrange the buttons. This seems kind of hackish, though.

Instead of implementing "Delete Slideshow" as an action, I could render it as <input type="button"> inside a #markup item, and add some custom JavaScript to detect and handle clicks on this button. However, this means that I'd no longer be able to use FormBase's built-in submit handling to process this "action" – I guess I would need to create my own separate route, controller, etc. (The details are somewhat beyond my understanding of Drupal.)

Any suggestions? (Bonus points if you can show me how to add a confirmation popup to the delete action.) Thanks!


texts: Add ajax on hook_field_widget_paragraphs_form_alter

texts:
I'm working with paragraph and I try to change a paragraph with AJAX.
My content type have a content field which contains "section" paragraphs which can contain various paragraph types which themselves can contain various paragraphs types.
To do certain modification on paragraphs, I use hook_field_widget_paragraphs_form_alter. It's work well but I meet a problem when I try to use #ajax because I don't know how to retrieve which paragraph has been modified in the ajax callback because I receive the entire form from the content and no information on which part has been modified. Here my code:
function mymodule_field_widget_paragraphs_form_alter(&$element, &$form_state, $context) {
  switch ($element['#paragraph_type']) {
    case 'block_special':
      $element['subform']['field_type']['widget']['#ajax'] = [
          'wrapper' => 'type-bs-wrapper',
          'callback' => '_type_paragraph_callback',
        ];

        $element['subform']['field_content']['widget']['#attributes'] = ['id' => 'type-bs-wrapper'];

        $values_paragraph = $form_state->getValues();
        if(!empty($values_paragraph)) {
          foreach ($element['#field_parents'] as $field) {
            $values_paragraph = $values_paragraph[$field];
          }

          $type = $values_paragraph['subform']['field_type'];
        }

        if (!empty($type) && $type === 'exception') {
          unset($element['subform']['field_content']['widget']['add_more']['add_more_button_paragraph_type1']);
          unset($element['subform']['field_content']['widget']['add_more']['add_more_button_paragraph_type2']);
        }
  }
}

function _type_paragraph_callback(array $form, FormStateInterface $form_state) {

  return $form; // <- How can I know what I should return?
}

I don't know which paragraph have been return. I don't know if I can pass the argument $element['#parent'] from the function hook_field_widget_paragraphs_form_alter (but how in this case) or if I should do a recursive research between default value of all paragraphs of my form between form_values (which will be laborious).


texts: Is it possible to use an image in my themes directory as the default image of an image field?

texts:
This question addresses how to add an image using a URL rather than a direct upload using the filefield sources module.  However, that module does not allow the "Default image" to be set.

For my image field, I want users to only be able to upload files (just the way Drupal comes by default).  However, I want the default image to be stored in my themes directory if possible in order to ease deployment across multiple sites.  Is there a way to set the default image to an image on the server rather than having to upload it?

I'm using Drupal 7.


texts:
In D7 Commerce module, I've created a product_display content type.
With this content type, it is possible to create nodes from product entities that come from my store.
In these nodes, the images are shown but I can't figure out how to link them to a large image when hovered or clicked on.

I guess this has to be done through a basic D7 configuration.


texts:
I'm using Google Webmaster Tools to manage my site SEO; even with 600 articles my total indexed pages is zero.

When I use "Fetch as Google" I get the following.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

    <title>302 Found</title>

Found

The document has moved here.

My site is made with Drupal 7, and the Boost module.

Is that caused by a wrong configuration? If so, how can I fix it?


texts: and  tags in a text field of format Full HTML are not rendered in a field based view

texts:
In latest Drupal 8, I've got a text field of format Full HTML that contains <form> and <input> tags (It's a MailChimp subscribe snippet). As long as I am editing the text in CKEditor in the backend, the form is displayed correctly. But as soon as I view tha page in the frontend, both tags are stipped out. I checked my text format/CKEditor settings to see if tags are stripped out there, but "Limit Allowed HTML Tags" is unchecked.
Does someone know what's happening here?

Edit: after checking out more, I realized that the text field is rendered inside a view (field based). When rendered as a node, the markup is perfectly rendered, just when rendered as a view, then the tags are stripped. I edited the question title to refelct this information.
Any suggestions how to render the tags inside a view?

Edit 2: the text field is rewritten in views (added some wrapper tags).


texts: Changing upload_max_filesize inb Drupal 7

texts: Is there any way to change php's upload_max_filesize setting from settings.php in Drupal 7? This used to work for me in Druapl 6 but no longer seems to. I don't like the idea of doing it in .htaccess, because that's a core file that will get overwritten on an upgrade.


texts: Creating separate list of a custom content type for every user

texts:
I have a custom content type named Movie.

Every user must have 2 lists of movies :-

1) Seen Movies

2) Unseen Movies

For this purpose a ADD button (or 2 buttons - 1. add to seen, and 2. add to unseen) should appear on every movie page , by which a user can add the corresponding movie to his seen list or unseen list.

How can i do this??

I am using Drupal 7.

I am new to drupal, so what should be my approach to solve this problem ?? Please help :-)

THANX IN ADVANCE


texts: Views exposed filter, filter on multiple fields with dropdown and one textbox

texts:
I'm working on a views integration where the table and its fields are exposed to views. I want to give users the ability to filter on results of this view based on 1 of 3 fields.

I want each of the three fields in a drop down, and one text field where the user can input search terms.

Then once submitted, views will filter on the specific field and terms entered.

Is this possible? I found this discussion which has no resolution: https://drupal.org/node/732458

I'm thinking I may need to just create exposed filters for each of the three fields, and then alter the form a bit to get it how I need it.

To clarify further:

I want to expose three filters, each one searches a field by the text a user entered. I can do this in Views no problem, and it produces three distinct text fields for each of the three filters. Instead, I want the user to have just one text field, and a drop down to select which one they want to search on.


texts: Auto Increment value for field collection

texts:
I have a field collection group to which I am importing values using Field Collection Feeds Importer. This requires a unique identifier field within the field collection. This has posed an issue where the user has to keep track of these identifier fields. One way to avoid this is having an auto increment field so that when a new row is added it automatically auto increments this field without any user interaction. This would also help maintain the correct sequence at all times and avoid any user editing accidental mistakes.

This is how it is right now

Any ideas or existing functionality to use this.

Thanks.


texts:
I have a site set up with Solr search. Drupal says 100% of the site is indexed, and the Search appears to work for most content types and their fields. However, the search does not seem to be searching all fields of the "Publications" Content Type.

For example, the second item in the list of publications (Title = "Bibliography of dry valleys...") has the following text in the "Bibliographic Citation" field:

  Mead, Kay L. Bibliography of dry valleys publications produced under
  the aegis of the New Zealand Antarctic Research Program 1959-1976 1977

However, when I search "Mead" in the Solr search I get "no results found". The same with "overseas", which appears in the abstract of the publication.

Yet, if I search "aegis" which appears in the title, the publication is returned.

How can I get Solr to index the other fields?


texts:
I am having a problem with getting Entity Reference to behave with a multilingual Drupal 7 installation using field translation (Entity Translation).

I have a node called 'Features' which has a bunch of dummy content entered in the default English and also in French. I have another node called 'Products' with an Entity Reference field in it for selecting the features.

So far so good, on the English form I see what I expect; I can select some of the references and save out.

When I create a French translation though, I see the following form:

I don't see any of the entities when creating or editing a French translation. Now, this in itself isn't a problem (for me) because the same selections should be made across all translations, but when I go ahead and save the French version, it will deselect all of the references in the English version of the node too.

Might I be missing something obvious with this? Is this expected behavior?


texts:
My code is working if I am trying to just modify a single form element.
What do I need to change to checkboxes(multiple elements).

My code is:

function custom_filter_form_alter(&$form, $form_state, $form_id)
{
    if (isset($form['#parameters'][1]['view'])) {
        $view = $form['#parameters'][1]['view'];
    }
    switch ($form_id) {
        case 'views_exposed_form':
            if ($view->name == 'uc_products') {
                custom_filter_range_to_select('sell_price', array(
                         '0,50' => 'Under $50',
                         '50,100' => '$50-$100',
                         '100,150' => '$100-$150',
                         '150,200' => '$150-$200',
                         '200,1000' => 'Over $150',
                ), $form, $form_state);
            }
            break;
    }
}

function custom_filter_range_to_select($field, $value, &$form, &$form_state, $optional = TRUE)
{
    $form[$field]['#type'] = 'checkboxes';
    if ($optional) {
        $value = array_merge(array('All' => 'Any Price'), $value);
    }
    $form[$field]['#options'] = $value;
    unset($form[$field]['min']);
    unset($form[$field]['max']);

    $f = (array)$form_state['input'][$field];
    $array1 = array_pop($f);
    $array1 = array_pop($f);
    $f ? $form[$field]['#value'] = $f : true;
    $form[$field]['#element_validate'] = array('custom_filter_range_validate');
}

function custom_filter_range_validate($element, &$form_state)
{
    $array = (array)$element['#post'][$element['#name']];
    $array1 = array_pop($array);
    $array1 = array_pop($array);
    foreach ($array as $key => $value) {
        if ($value == 'All') {
            $min = $max = '';
        }
        else {
            list($min, $max) = explode(',', $value);
        }
        $form_state['input'][$element['#name']] = array(
            'min' => $min,
            'max' => $max,
        );
        $form_state['values'][$element['#name']] = array(
            'min' => $min,
            'max' => $max,
        );
    }
}


texts:
I developed multi site using Drupal 7.

example.com
site1.example.com
site2.example.com

All subdomains are using the same codebase in /sites/site1 and /sites/site2.

Is it possible to host SITE1 in a different hosting server with the same codebase?


texts: Only allow specific roles to upload specific extension files

texts:
How do I restrict users with specific roles to upload files with specific extensions on node edit pages. On my site I have two specific roles editor and animator.
Conditions are:

Editors can only upload .docx .doc .pdf files while Animators can upload .mp4 .mp3 .jpg files.

I added a validate function with hook_form_alter() and the validate does work but the user has to save the entire form before validation spits out an error about the wrong file extension. I want to get the file extension as soon as the user has finished uploading their file and display the error message before submitting the form but after uploading the file.


texts: Each slideshow image with specific button

texts:
I've got a Drupal website, to which I added a slideshow.
Each slideshow has to contain some text and a button.

The problem is, I don't know how to add a different link/URL to every single slideshow image.

Does anyone know how to solve this problem?

PS. I would not prefer adding a button programmatically. However, I'm familiar with Javascript/jQuery, in case there is no other solution


texts: How can I link a gallery made with views to another gallery made in views?

texts:
I am trying to do a gallery with a page of preview of the pics, I got how to do it with views and tags for the full size pictures and with image styles; I got the preview gallery (btw for this one I am using Nodequeues).
Now I don't know how to link the galleries from the previews to the full size ones, I did try with the output linking in the override section of the view, I tried creating a new field with the URL and nothing, it always links to content/node but not to /photos/node

Btw this is the website http://www.nellens.com/home/

Thank you.


texts:
The main Profile can be printed in a basic PHP page using:

print(drupal_render(drupal_get_form('user_register_form')));
print(drupal_render(drupal_get_form('user_login_block')));

but how can I specify a Profile 2 profile to be printed instead?


texts: How to send an email notification reminder based on a user's date of entry field?

texts:
The authenticated users on my Drupal website have "Entry date" in their profile (= date when they registered). I want to send out notifications to me (the admin) when a user has been registered on my website since more than 5, 10 or 15 years. So each time a user surpasses for example 5 years of registration time, I get an email notification 1 month in advance.

How can I achieve this?


texts:
I have included in my theme a new javascript library(Easy-Responsive-Tabs-to-Accordion) which converts horizontal tabs to accordion.
So I have included in my .info theme
scripts[] = js/Easy-Responsive-Tabs-to-Accordion/js/easyResponsiveTabs.js

Then,according to the instructions,I have to call the javascript function $('#demoTab').easyResponsiveTabs();

My question is:Where to add this javascript function?
thanks


texts: Multi Axes Voting using Fiverstar, Views, Reference

texts:
I have tried several different tutorials on how to accomplish this. Most were for drupal 6, but there were few for drupal 7 but none seem to make sense to the modules being used currently that are in dev or stable. The Node Review module seems to be the closest thing to what I need but that requires some hacking to make it work for my particular use. I have several other modules that I've experimented with. Rate 7.x-1.3 Seemed to have potential.

How would I be able to make a system like the following use these modules?;

Node Reference   7.x-2.0+8-dev
Fivestar 7.x-2.0-alpha1+22-dev
Views    7.x-3.3

What I am looking for a content-type: Business. These will have several businesses that people can rate based on different criteria. Multi Axes Rating on separate page or tab. The Review can be a separate content type. Not required thou.


texts: Commerce line items without reference to product

texts:
With Drupal Commerce, when visitor adds a product to his cart, system creates commerce line item instance. The order consists of line items, and these line items have references to particular products. It is possible to omit products and create only line items?

I am generating orders dynamically with my custom code, and I do not need to have products in my database. As I can see, the only missing information in line item is price. It is set for commerce product. Thatswhy I create product entities for now.

But it is possible to set price directly in line items? Then I do not need to create and load products. Line items would be representing the buyed items itself.

For now, I am creating custom line items without products as follows:

<?php
global $user;
$order_id = commerce_cart_order_id($user->uid);
$order = commerce_order_load($order_id);
$line_item = commerce_line_item_new('custom_line_item', $order_id);
$line_item->commerce_price = array();
$line_item->line_item_label = 'Custom..';
$line_item->commerce_unit_price[LANGUAGE_NONE][0]['currency_code'] = 'EUR';
$line_item->commerce_unit_price[LANGUAGE_NONE][0]['amount'] = 100;
//entity_save('commerce_line_item', $line_item);  dpm($line_item, 'item');
commerce_line_item_save($line_item);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Add it to the order's line item reference value.
$order_wrapper->commerce_line_items[] = $line_item;

?>

The problem is, this item is not showing in cart or checkout, and the price is not including in total.
It is possible to add "product" to the cart as line item without referencing to commerce product?


texts:
Suppose we have numerous entities of types Alpha and Bravo. Alpha entities could easily be taxonomy terms and Bravo – content nodes. Bravo entities can reference multiple
Alpha entities each; whereas, Alpha entities (taxonomy terms) are completely agnostic of any other entities.

The exercise is to aggregate all Alpha entities that are referenced together (by the Bravo entities) with a given Alpha entity.

Example: Alpha entity type is a taxonomy vocabulary containing Artists. Bravo is a Project content type. Sometimes Artists collaborate on Projects; therefore, some Projects have multiple Artists. An example of the aggregation in question would be to list all Artists that a given Artist has collaborated with (has been referenced in the same Project with).

I am building the information architecture for my first Drupal project, in which metadata and it's inter connectivity is important. I have achieved this aggregation using Views, but Views seems impractical for my uses. In many cases I want to list just Taxonomy term names like this:

  Nirvana has collaborated with: Biggie Smalls, Lil' Wayne, Lil' Jon.

(Of course, I wouldn't want my Taxonomy system to make jokes)

What aggregation solutions are there? Do you have tips? Have you done something like this?

Why I'm looking for an alternative to Views:

The reason I find Views impractical for this use: my impression is that it's geared more towards heavier listing, like catalogs and is hard to squeeze into "lighter" roles (like the one in my example). If I am fooling myself, do correct me.


texts:
I have the module Google Store Locator. It works perfectly. The data are fed via GeoJSON views module.

I have used Feeds module to feed all the data.

The problem is that the coordinates of the stores are geocoded, and if, for some reason, the system does not find the correct address, they will be empty.

I have the coordinates in a database, but don't know how to feed into the system with this configuration. I even try to hard-insert the data into the table field_data_gsl_geofield but for some reason it does not work.

Any suggestion?


texts:
a lot of blogs have a feature to show the "incoming search terms" - it's great for SEO.
I looked up and down drupal.org but couldn't find a module.

Any recommendations on how to tackle this (I'm new to D7 and haven't built a module yet).


texts: How to get the $node->nid inside a views template where i'm printing cck fields? $node variable is availabli only in node.tpl.php.


texts: How to speed up Drupal 7 calls to _theme_process_registry?

texts:
Using xhprof php profiler I can see there is much more then 100000 calls to function_exists
each time user accesses a Drupal 7.8 page, mostly from _theme_process_registry.

What to do to limit the number of or cache these calls ?


texts: Which module to use for tracking pages browsed by users?

texts:
My requirement are:

most viewed pages
most 404
most 403
most referring pages
most visitors

In addition provides charts and HTML table view for those data.

Could someone give me any advice?


texts: Display another page's content without changing url for drupal 8

texts:
I want to display another page's content without changing url for drupal 8 .
In drupal 7 I used menu_execute_active_handler() , but drupal 8 this function is not available.
I got a solution from drupal forum , but properly not working for me.
https://www.drupal.org/project/drupal/issues/1591618

Please any one provide me example code for this.


texts: MailChimp Error: API Key cannot be blank

texts:
I'm trying to install the mailchimp addon but are stuck on getting the error message above.

So far:

I've installed/enabled the module with version 7.x-4.0
Loaded the PHP Library to /sites/all/libraries/mailchimp
Added the API Key to /admin/config/services/mailchimp
Enabled the MailChimp Signup module

The error occurs after enabling the signup module and freezes the whole website with a blank screen even though error messages are being fully displayed. When I uninstall the signup module via drush and check the admin page for the service my API key is still set.

Any pointers what I'm doing wrong?


texts: Module is shown as installed but I can't access its settings

texts:
I have Drupal 7 installed and I am trying to install Webform module. Firstly the page shows " The website has faced some unexpected error" and then after re-accessing the Modules page, it shows the Module to be enabled and links to it's settings as well.

But when I go to Create Content, I don't see any Webform option.

This is the error generated in the Reports / Log.

  DatabaseSchemaObjectExistsException: Table webform already exists. in DatabaseSchema->createTable() (line 657 of /home/evosysgr/public_html/includes/database/schema.inc).

Kindly suggest what is to be done.


texts: Post the same menu as two different blocks?

texts:
I have a menu called main-menu.  I want to post it twice as a block: one block with a main-menu in the header, and one block with a main-menu in the footer.  But Drupal 7 will not allow it.  Drupal 7 only allows me to post the block once...either in the header or in the footer.

Is there another way?  If not, I will use Javascript to clone the entire main-menu html node and append to footer node.


texts: Disable a Module after Fatal Error without Server/DB access?

texts: I'm working on a Drupal 7 site and recently triggered a fatal error via installation of incompatible modules. Is it possible to disable a module when site is giving fatal error on each page? Specifically without direct access to files or database?


texts: How do I POST a new node using the Services module and uuid?

texts:
I tried several ways to POST a new node to a Drupal site, but I have failed.

I have installed and configured the Services 3 module (D7) with UUID, and created a service end point at services.

I am able to login and i have access token

I am posting my node json

{"type":"article","title":"Test1","language":"und"}

on

localhost/drupal/services/node

But its showing " 404 Not found : Could not find the controller."


texts: How do I check if the current password that the user gives in the password reset form matches with the hashed password?

texts:
I'm trying to reset a user password programmatically in Drupal 8 without the email link. For this the first step would be to check if the password(which is plain) that the user enters in the password reset form is matching with the hashed password of the respective user. And then save the new password.

Each time I hash the password, its giving a different value, this is because its salted. How shall I compare the password which the user enters in the form with the hashed password from the table.

This is the code that I have in my controller for checking the current password :

<?php
/**
* @file
* contains \Drupal\customer_profile\Controller\ProfileUpdateController
*/

 namespace Drupal\customer_profile\Controller;

 use Drupal\Core\Controller\ControllerBase;

 use Symfony\Component\HttpFoundation\JsonResponse;
 use Drupal\Core\Password\PhpassHashedPassword;
 use Drupal\Core\Password\PasswordInterface;

 class ProfileUpdateController extends ControllerBase {

   $user =\Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
   $ret = \Drupal\Core\Password\PasswordInterface::check('secret', $user);
   //$user->setPassword('secret');
   //$pass = $user->save();

   $response->password = $ret;
   return new JsonResponse($response);
  }
 }

After using \Drupal\Core\Password\PasswordInterface::check() method, for comparing the plain text password with the hash password, I get this fatal error :

Fatal error: Non-static method Drupal\Core\Password\PasswordInterface::check() cannot be called statically, assuming $this from incompatible context in C:\xampp\htdocs\ijarah\modules\custom\customer_profile\src\Controller\ProfileUpdateController.php on line 725

In Drupal 7 we have user_check_password to check the password with string and user_hash_password for hashing.
How can I approach the same in Drupal 8.

Please help.


texts:
My 'gatsby develop' command fails as image files (coming from Drupal 8) are returning a 404 error - I don't understand why (this is new)
== Details: ==
JSON:API (which Gatsby uses to build the site), uses this URL:
https://dev-tuckel.pantheonsite.io/jsonapi/file/file
it provides this image URL:
https://dev-tuckel.pantheonsite.io/sites/default/files/2020-08/mckenzie%20falls.jpg
Which returns a 404. There are at least 3 other images that are returning a 404 error - this is strange.
== Investigation: ==
In: content> Files:
the file is 165.17 KB, which is strange, as I ussually upload higher quality images.
it also says it has 1 "use count", however the "entity" field is empty (again, not usual)
I cleared the Admin > Performance cache (thinking it's may a thumbnail / cache file error).
The site is hosted in the free dev tier of pantheon.
Prior: I was not working on Drupal at the time of failure, I was working on Gatsby code.
If you have any ideas, it would really help because I'm stumped.


texts: Empty field value showing in webform email content

texts:
I have a file attach field in my webform. When i have submit my webform without this field,in my email content showing like "ATTACHED FILE: [webform_submission:values:attach_file]".
I have checked "Exclude empty elements" in my email handler.This is working for all other fields in my form except this "File attach" field.How can i solve this issue?


texts:
When i upload a file, be it a avatar picture or image, the file loads however does not display.

I have checked the permissions on my hosting environment and it seems that everye uploaded file gets a 664 permission and apache as owner.

How can i give the uploaded files the proper permission automatically?


texts: I am using simplenews module for sending newsletter and simplenews scheduler for scheduling it. I want to differentiate scheduled nodes and non-scheduled nodes. How can I achieve it.


texts: Sending a JavaScript variable to a PHP function

texts:
I am trying to send a value in JavaScript variable to Drupal. I am calling an external js file in hook_nodeapi(). I want to send a value from this external js file to Drupal, and want to use this value in Drupal in hook_block.
For example

hook_nodeapi() {
  // call(external.js)
}
external.js
var sendData =10;

hook_block
{
  case view:
  // need to access sendData value
}

I tried this using cookies, but I think that is not the best way.
How can this be done?


texts: How to display an entity property 'type' with form api 'type' for display in a form and then setting with the submitted value?

texts:
Is there is process/ function that maps data types that you can use in entities (specifically custom entities using the Entity API) to form #type options? This is to dynamically add a field to a form from the entity and then once I've got the value from the submit handler, use the wrappers to set the property on a entity of the same entity type. Or am I taking the wrong approach here?

I am trying to get an entity property type and am currently using...

$property_info = entity_get_all_property_info('MY ENTITY TYPE');

Which generates $property_info['field_postcode'] which has this value...

field_postcode      Array [10]
    label               Post Code
    type                text
    description         Field "field_postcode".
    getter callback     entity_metadata_field_property_get
    setter callback     entity_metadata_field_property_set
    access callback     entity_metadata_field_access_callback
    query callback      entity_metadata_field_query
    translatable        false
    field               true
    required            true

There I can see that it's got a 'type' of text which seems to translate well to a textfield in the Form API. But what about something like "file" in the Form API?

I wonder if I'm missing a piece of the puzzle here.


texts: Add VBO checkbox to send Bulk emails in Admin

texts:
We are using Enterprise Event module in Drupal 7.  I checked the Views and module files but not able to locate the file as from where Manage Registration Page is formed. Please guide me how I can add VBO checkbox to send Bulk emails in Admin > Content > Event > Edit > Manage Registration Tab.

I am using enterprise event module in which people register for upcoming events. Registration module is used for registration. Admin can view registrants for  specific event.  I need to add a checkbox so that admin can send bulk emails to those registrants.

Please help still hoping for some solution.


texts:
Trying to theme user pictures, in the following statement:

 print '';

How do I replace the "width="32px" by the "thumbnail" image style?

Thanks. :)


texts:
I have a taxonomy called Species, and another taxonomy called Protected Areas.

Inside of the Protected Areas I have a multifield widget (Taxonomy reference pointing to Species), where user can select different Species present on the Area.

Users are able to manipulate also the Species taxonomy, when adding a new Species they are able to choose in which Protected Area is this specie present. Then, when users do it, I would like to automatically update the user selected Protected Area taxonomy (for this Species), adding on the multifield widget the recently added Species value.

Even shorter: how to communicate new/changed values between taxonomies.

Some chances to avoid writing my own module? thanks


texts: Loop Paragraph types with all values in field--field-page-detail-paragraph.html.twig

texts:
I have two paragraph types called First Type & Second Type and added Image & Text fields on it separately. I have created the basic page & added the two above paragraphs(First Type & Second Type) with multiple values.

Its showing only one value of each paragraph, but I have multiple values. So mainly its not rendering/iterate the values properly.

Here is my field--field-page-detail-paragraph.html.twig file

   {% set first = {} %}
    {% set second = {} %}

{% for key, item in items %} // looking for the bundle items to display

        {% set bundle = item.content['#paragraph'].type.target_id %}

        {% if bundle == "first_type" %}
            {% set first = item.content %}

        {% elseif bundle == "second_type" %}
            {% set second = item.content %}

        {% endif %}

{% endfor %}

                    {{ first }}

                    {{ second }}

paragraph--first-type.html.twig file

            {{ content.field_message }}
            {{ content.field_image }}

paragraph--second-type.html.twig file

            {{ content.field_test }}
            {{ content.field_link }}

Can anyone let me know what's issue & how to display all values.


texts: Customizing search results page to use template.php and search-results.tpl.php

texts:
I'm using Drupal 7, the basic Drupal search tool. I like what it returns as far as the actual node pages. However, I want to customize the main search results page that shows a list of results after a user enters a term to search by.

Right now it shows a list with a linked title to the node (fine), and then a 'summary' (if you can call it that) that's sort of a jumbled mess of the URL, part of the description field, and some other fields. I just want the description to show up there. I'd also like to add the date field and the associated image for the node in the search results. So I've discovered that I need to customize template.php mytheme_preprocess_search_results function and also search-results.tpl.php (results NOT result).

But I can't figure out how to parse out individual items from what the database is returning so I can make sure to only print those out in the tpl file. I did a var_dump on $search_results and see it returns a big 'ol chunk of HTML and database data...but how do I return just individual fields from the database and print those out?

Right now it just does a print $search_results.

I tried print $title and print $url but drupal complains it doesn't recognize those vars. So what are the vars and how can I use them to display what I want?

I'm also noticing it's showing the author and date for each node in the search results (although I hid this information in the content type)...so I'd also like to hide that information in the search results.

I've found a bunch of stuff online that led me to those two files I referenced, for changing the search results...but nothing that specifically addressed how to grab and use individual fields from the database. I also don't want to use a module, I want to do this with template.php and the tpl.php files if possible.

Thanks for your help in advance!


texts:
I want to prevent validation check on the field_abc ?
How can I prevent validation for a field_abc

  function test_mail_menu() {
         $items['test-mail-1'] = array(
            'page callback' => 'drupal_get_form',
            'page arguments' => array('test_mail1_form'),
            'type' => MENU_CALLBACK,
            'access arguments' => array('access content'),
          );

    return $items;
    }
    function test_mail1_form ($form,$form_state) {
      $form = array();
      $form['field_abc'] = array(
        '#type' => 'textfield',
        '#title' => t('ABC'),
        '#validated' => TRUE,
     );

      $form['submit-button'] = array(
        '#type' => 'button',
        '#title' => t('sub'),
      );

      $form['#submit'][] = 'test_mail1_submit';
      $form['#validate'][] = 'test_mail1_validate';
      return $form;
    }

    function test_mail1_submit($form,&$form_submit) {

    }

    function test_mail1_validate($form, &$form_state) {

      if (!(is_numeric($form_state['input']['field_abc']))) {

        form_set_error('field_abc','ERROR');

      }
    }


texts:
when

hook_block_info()
hook_block_configure()
hook_block_save()
hook_block_view()

are get called? is it possible to call these hooks manually in a module?


texts:
I am trying to build a custom module that uses a theme page to display a list of items withing a table. Each item has a unique ID. and I would like to have links within this table so that my users can preform actions using the uid. The link works and takes you to the form but it doesn't carry over the uid.

Here is the code from my theme file.

<?php

/**
 * @file
 * definition of uc-bitcoin-account-outgoing-escrows.tpl.php.
 */
$user = user_load($variables['uid']);

global $base_url;

$transactions = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE from_account='$user->uid'");

$header = array(t('Escrow ID'), t('Amount'), t('Payment'), t('Allocated to'), t('Release'), t('Dispiute'), t('Date'));

$rows = array();

foreach ($transactions as $transaction) {
  $rows[] = array(
      $transaction->escrow_id, $transaction->amount, $transaction->status , $transaction->to_user, 'escrow_id . '">Release Payment', 'escrow_id . '">Dispute Payment', date('d/m/Y   g:i:s A', $transaction->created)
  );
}

print t('
Outgoing Escrows
');

print theme('table', array('header' => $header, 'rows' => $rows));
?>

When the user clicks on the Release Payment link it will take them to the form I created but it has a few errors. And Doesn't work. Here is the code for that function.

function uc_escrow_release_payment($form, &$form_state, $escrow_id) {

  $form['#$escrow_id'] = $escrow_id;

  $transaction = db_query("SELECT * FROM {uc_btc_escrow_payment} WHERE escrow_id= :escrow_id", array(':escrow_id' => $escrow_id))->fetchAssoc();

  $user = user_load($transaction['reference']);
  $to_user = $transaction->to_user;
  return confirm_form($form, check_plain('Release Escrow Payment?'), 'user/orders', check_plain('Are you sure you want to release this payment and send the funds to ' . $to_user . '?'), check_plain('Yes'));
}

The errors I am getting are because the information isn't getting passed from one page to the other.

Notice: Undefined index: reference in uc_escrow_release_payment()
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()
Notice: Trying to get property of non-object in uc_escrow_release_payment()

I think I am missing something small. Thank you for the help.


texts: How to tell Stringsoverrides module to replace text only in specific module? Are there any alternatives to this module?


texts: I have a node type (actually entityform type) with a term reference field. The terms has a description field (a long text with a HTML markup). I need to display the description of a selected term on a node edit form. Is it possible to show a description immediately after user selects new term from a list?


texts:
I have a content type with several fields; one field defines a postal address. If new content is created and the user has logged in, this field should be automatically filled with the address defined in the user profile. If a guest is creating new content, he will have to fill in the address by himself.

How I can achieve this? Are there any modules?


texts: How can I restrict various roles with limit in creating nodes of a particular content type?


texts: Custom REST POST resource to accept JSON

texts:
I am trying to build simple search autocomplete POST endpoint, that accepts JSON and outputs JSON, but I am having problems getting Drupal 8 to just accept plain JSON.

Currently I am getting a 404 error for that endpoint, even though it is enabled in REST UI and I have permission. If I add serialization_class with value Drupal\node\Entity\Node to the class comment, I get 415 error, because it expects a node. Okay, great. How do I actually make it accept JSON? Do I really need to make an Entity type just for my autocomplete search?

Here is the code I have in mymodule/src/Plugin/rest/resource/SearchAutocompleteResource.php.

namespace Drupal\MyModule\Plugin\rest\resource;

use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Drupal\node\Entity\Node;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * Provides a resource for search autocomplete.
 *
 * @RestResource(
 *   id = "mymodule:searchautocomplete",
 *   label = @Translation("MyModule: Search Autocomplete"),
 *   uri_paths = {
 *     "canonical" = "/api/v1/search-autocomplete",
 *     "https://www.drupal.org/link-relations/create" = "/api/v1/search-autocomplete"
 *   }
 * )
 */
class SearchAutocompleteResource extends ResourceBase {

  public function post($search = null) {

    return new ResourceResponse(array(
      'example' => 'return value'
    ));

  }

}


texts: How to show warning and list of related content

texts: I'm working with Drupal and I wanted to show users that the included URL in post has already been submitted when they click preview


texts:
I want to create a page that render a template (.tpl) file with this:

hook_menu

    $items['news'] = array(
    'title callback' => 'check_plain',
    'title arguments' => array('News'),
    'page callback' => 'theme',
    'page arguments' => array('news', array()),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
);

hook theme

$items['news'] = array(
    'template' => 'templates/news',
);

All works well if i go to www.mydomain/news

But if i go to www.mydomain/news/aaaaa (that is a non existing page) i will see again the template page and not a 404 error page, why?

Is this a normal d7 behaviors and i need to fix this in a callback function?
...or i need to check into other code/modules that cause this bug ?


texts:
I need to create a block with a search box in header in order to allow users to search for a the specific content type that is shown in that block, but I don't know how to do this.

I've attached one photo to show what I need.


texts:
I want to add a static page to drupal.
To be specific, for example,

  ....

    Hi there
    Link

No sidebars. No Drupal anything. Just a nice page some words.
I would like to have the base tag in the header
(e.g., <base href="http://example.org/'>) set for me.


texts: Get node values from array with Drupal API?

texts:
With Drupal API I found you can get the values of a node with noad_load like so:

$thisnode = node_load($nid = $child2, $vid = NULL, $reset = FALSE);

Now it is easy to echo the title in this way

$thisnode->title;

But the array begins to get quite complex when I try and get data from the custom image_thumbnail field because it is array within array. See the full printed array for one node:

stdClass Object ( [vid] => 4 [uid] => 1 [title] => Who we are [log] => [status] => 1 [comment] => 0 [promote] => 0 [sticky] => 0 [nid] => 4 [type] => level_2 [language] => und [created] => 1345561152 [changed] => 1346982536 [tnid] => 0 [translate] => 0 [revision_timestamp] => 1346982536 [revision_uid] => 1 [body] => Array ( [und] => Array ( [0] => Array ( [value] => blah blah blah [summary] => [format] => plain_text [safe_value] =>

blah blah blah
 [safe_summary] => ) ) ) [field_parent2] => Array ( [und] => Array ( [0] => Array ( [target_id] => 2 ) ) ) [field_level2_thumbnail_image] => Array ( [und] => Array ( [0] => Array ( [fid] => 4 [alt] => this is a photo [title] => this is a photo [width] => 308 [height] => 198 [uid] => 1 [filename] => article-image.png [uri] => public://article-image.png [filemime] => image/png [filesize] => 105660 [status] => 1 [timestamp] => 1346982536 [rdf_mapping] => Array ( ) ) ) ) [rdf_mapping] => Array ( [rdftype] => Array ( [0] => sioc:Item [1] => foaf:Document ) [title] => Array ( [predicates] => Array ( [0] => dc:title ) ) [created] => Array ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => Array ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => Array ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => Array ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => Array ( [predicates] => Array ( [0] => foaf:name ) ) [comment_count] => Array ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => Array ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) ) [name] => slawrence10 [picture] => 0 [data] => b:0; )

What's the best way to extract for example alt from *field_level2_thumbnail_image*?

I can do it like so:

$thisnode->field_level2_thumbnail_image['und'][0]['alt'];

But is this stable? Will 'und' always be 0? Am I missing something here?


texts: how can contrib modules be enabled in install files without including the files?

texts:
I'm trying to make a quick simple install profile that I can use to get Drupal set up whenever I need a development environment.

There are contrib modules I want to enable as part of this, but I don't want to include them in the profile. I want to assume that they are already there in sites/all/modules (the reason for this is I will usually be creating a new install in a multisite).

I've set dependencies in the profile .info file, but the contrib modules do not get enabled by the install process.


texts: Loop through child elements in Twig like Element::children()

texts:
When dealing with a renderable array in PHP, I can use Element::children() to access the elements that are not # properties but subordinated renderable elements (form items inside a fieldset, items inside a field widget, etc). For instance, this snippet from file.module:

<?php
if ($element['#multiple']) {
  foreach (Element::children($element) as $name) {
    // ...
  }
}
?>

How can I do the same in a Twig template? If I do {% for child in element %}, it will include also #type, #cache etc.


texts: drush perm-grant gives "The drush command 'perm-grant' could not be found"

texts:
I am using drush -u 15 perm-grant --roles="site administrator" but the command returns:

  The drush command 'perm-grant' could not be found.

any ideas about that? according this documentation the drush perm-grant is an available command. or maybe is some limitation of the user used to run drush?

the drush version is 5.4

thanks.


texts:
I want to import a view during the installation of Drupal.

Does anybody have an idea on how to do this?


texts: Search and display node by scanning a barcode image

texts:
I am developing a new tracking system for my fashion store to have a good relationship with my returning back customers using drupal 7.
THE SCENARIO:
1) When a customer come into my store and buy some products, he/she will be given a plastic card with a barcode on it, and ask him to present this card to the cashier every time he/she visits our store.
2) When the customer will come back later and present his/her card, the cashier will scan their plastic card using a barcode scanner device attached to the computer where the drupal website is always loaded in the browser.
3) Upon scanning of the plastic card, the website will perform a quick search based on the barcode input data and return two possible actions:
First Action:(If the card was not found on the system)
Information message: This card in not registered into the system.
Second Action: (If the card was found on the system)
Display a page contain information related to the scanned card like first name, last name, last purchased items, phone number....
MY WAY OF APPROACH:
1) I created one content type VIP Customer and added to it the below fields:
Barcode field (using the barcode module)
First Name
Last Name
Phone Number
Last purchased items
....
2) Create a webform with one text field to scan the barcode . (Using webform or entityform module)
3) In order to not let the cutomers wait for the cashier to prepare the plastic card and printed out and...
All plastic cards will have to be prepared earlier and in order to do that i decided:

Create around 500 nodes of type VIP customer where the field barcode is the only field which is filled by some data.

The data filled inside each barcode field is a arbitrary mix of text and numbers just to create a barcode image for each node.

Take all of the barcode images and give them to a library in order to print the barcode images on plastic cards.

Now, I have around 500 plastic cards with barcodes printed on them and each related to a node on my drupal website and ready to be used directly.

4) When a customer will come, the cashier will take a new plastic card and scan it using a scanner reader and here the magic will happen:

The cashier will open the webform and scan the barcode on the plastic card.

The barcode scanner will input the code behind the barcode image into the text field.

Automatically when this text field is filled up with some data, a quick search will take place and find the only node which related to the scanned barcode image.

The node will be displayed to the cashier and here the cashier can edit the node to add information about the customer.

When finish, the cashier will save the node and give the card to the customer.

5) When the customer will come back later, the cashier will take the card from the customer and scan it.

The node should automatically open on the screen and the cashier can read all the information related to that customer.

PROBLEMS:

How to transfer the code from the barcode image to the text field on the webform upon scanning ?

and what is the best approach for performing the search among all nodes and pull out/display only the node related to the card being scanned.

If the above is possible with drupal I prefer to use the drupal core and contributed modules without any written custom codes.
(I am good with drupal but not good in php coding)
Thank you for your time and support.


texts:
I am trying to make a link on node by returning this array(The array is being formed in the function by the name buildLinks() ):

     $links[$key] = array(

    'title' => $definition['title'],

    'href' => $this->urlGenerator->generateFromRoute('module.show_format.' . $entity->getEntityTypeId(), array('module_format' => $key, 'entity' => $entity->id())),
  );

but on the page the link title is appearing but the link's href value gets lost(I mean title is appearing but it is not appearing as link).What am I doing wrong?

Update: The above array is being returned over here:

    return array(
    '#theme' => 'links__entity__module',
    '#links' => $this->linkBuilder->buildLinks($this->request->attributes->get($entity_type)),
  );

So is there is a possiblity that I am doing something wrong over here?


texts: Import documentation to Drupal site from CI pipeline

texts:
We have a Drupal 8 site for various product documentation.
Documentation for APIs is generated from Markdown files, and we currently do not have a good way to get that content into Drupal. We create "fake" pages in Drupal that use Javascript to fetch HTML from an external site (Azure Storage containers). This documentation is updated for each release, and we'd like users to pick which version they want to see documentation for.
The generated documentation (mainly HTML and images) is created in continuous integration pipelines. Now we upload that to Azure Storage. But is it possible to upload it to Drupal instead?
I've looked at Drush and https://www.drupal.org/project/migrate_git. But I cannot find any tutorial / example that shows how to use that for our scenario. However, I've found tutorials on migrating a complete site from staging to production, or migrate from Drupal X to Drupal Y.
How can I import content to Drupal?


texts: How do I make link act like a view or a view look like a link?

texts:
Good morning!

I want to create a link that displays a node, the most recently created for example. What is the best way to do that in Drupal?

I have a menu link that does what I want with:
moneymap/Pro/EURUSD/Day?sort_by=field_map_id_value&sort_order=DESC
but I don't know how that works or how to make that work in an HTML link.

I've made a few views but still a beginner? How should I proceed?

Thanks!


texts: Session gets lost when a user closes their browser

texts: When user login, I am creating cookie till a certain date. When the browser tab is closed while the user is logged in, the session remains. But when we quit the browser, the session is lost and user has to login again even if the cookie exists. What is causing this?


texts: Alter a custom block depending on custom block type

texts:
I need to alter all the blocks of custom type 'my_custom_block_type' that get displayed on my site.
In order to achieve this, i added a custom prerender in which  i filter on the block bundle :

function my_module_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  $build['#pre_render'][] = '_custom_block_custom_prerender';
}

function _custom_block_custom_prerender(array $build) {
  if ($build['content']['#block_content']) {
    $block_bundle = $build['content']['#block_content']->bundle();

    if ($build['content']['#block_content']->bundle() === 'my_custom_block_type') {
      // do your thing here
    }
  }
  return $build;
}

I think it's not the most elegant way to do this.

I tried to enhance this, but i did not manage, after several attempts, to retrieve the block type directly inside a hook_block_view_alter or a hook_block_build_alter ...

function hook_block_view_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  // things
}
function hook_block_build_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  // stuff
}

Is there a way to easily get the custom block type inside those two hooks ?


texts: How to add a pager at both the top and bottom of a View

texts:
How can I do this for Drupal 8?

I have searched for a solution but I didn't find anything yet, I hope some one here can help me.

I have this "pager.html.twig" (from the clasy theme) template in the path of my own theme, the path is "mytheme/templates/navigation/pager.html.twig" and this is rendered automatly by drupal in the views where the pager is requiered, but I have a requierement in my job that I have to place the pagination at the top and the bottom from my view.

Example:

<[1|2|3|4|5|6|7|8|9|10]> (this is the pager that I want to place on top)

content of my view
content of my view
content of my view
content of my view
content of my view
content of my view
content of my view
content of my view

<[1|2|3|4|5|6|7|8|9|10]> (this is the drupal rendered pager automatly)

Thanks in advace for the help.


texts: How to disable max length validation on an entity form?

texts:
How do I disable the #maxlength validation on a field I've added to the user entity form?

Let me explain: I want my field to be 10 characters long in the database, so I've set a max length of 10 at the field UI. However, at the form level I want it to have a formatting mask that makes it be 14 characters long.

Even though I could disable its #maxlength property via hook_form_alter and get to enter more than 10 characters, the validation for such property is still up when I submit the form.

Since I don't want to remove the mask via JS by the time the form gets submitted, my intention was to to bypass form validation only for the max length property of this field (or even for the whole field) and then at a presave hook I'd remove the mask and store only the original 10 characters to the database.

Hope I've made it clear.

Thank you.


texts: Can I use entityreference module with my custom entity to display it?

texts:
I've attached a new entityreference field to users that referenced my custom entity type, say it's called my_entity. When I dpm() the user or view the tokens, I can see my custom entity properties (id, name, etc) but when I view the user I do not see the field label or the entity label.

I threw a dpm($items) into hook_field_formatter_view() inside entityreference.module and
discovered that there are 0 items available to be displayed, but they are available in many other places! (as described above)

In hook_entity_info():

<?php
return array('my_entity' => array(
  'label' => t('My Entity'),
  'controller class' => 'MyEntityController',
  'base table' => 'my_entity',
  'uri callback' => 'my_entity_uri',
  'load hook' => 'my_entity_load',
  'fieldable' => FALSE,
  'label callback' => 'my_entity_label',
  'entity keys' => array(
    'id' => 'id',
    'label' => 'name',
  ),
);
?>

I tried just setting the entity keys['label'] to the schema field, which is supposed to be adequate to set the label, but I also tried 'label callback' and even setting up the bundle info, which is not necessary for my entity.

I've also tried adding the property into hook_entity_property_info() in the hope that it would be "made aware" to other modules, but no luck:

<?php
return array('my_entity' => array(
  'properties' => array(
    'name' => array(
      'label' => 'Name',
      'type' => 'text',
      'schema field' => 'name',
    ),
  ),
);
?>

Any ideas?


texts: Drupal commerce WPS , if user not go back to the site after paypal payment?

texts:
this is the problem.
The payment used in my site is WPS (With Paypal Business account) so user switch from my site to Paypal site to pay order in cart.

BUT

If User close paypal site after paypal message "Payment complete" and NOT go back in site, the status order stay on "Checkout: Complete". Drupal Commerce has no way of knowing that payment is complete so not send order email and decrease stock.

Is there a way to get around this problem?

I work with drupal commerce kickstart 2 (+ stock module)

Ty for your reply :)


texts:
i spent tons of hours to solve a problem without success, so i'm here now.

If you visit my website example.com everything looks nice (y)

But when you click on a navigation point the url will change to http://example.com/subpath/nodetitle

How i'm able to get a url like this:
http://example.com/noteditle

I tried with RewriteBase / and uncomment the $base_url without any success.

Please help me, thanks!


texts:
is there any way to add node ID (if it exists) to template variables using

my_theme_preprocess_page(&vars) function?

It looks like theme theme isn't using my_theme_preprocess_node(&$vars, $hook) so I assume that node object isnt available in vars for my_theme_preprocess_page(&vars).

It's not my website so I don't really know the structure.


texts: Commerce Hook Function To Checkout Button

texts:
I am a Drupal Commerce novice. I have a basic cart system working fine, but I now need to get into some custom code. I don't think I can use Rules because the code is a bit too complicated.

I have a Shopping Cart page with a Checkout button. I want to hook into that Checkout button.

I need to add a php function (which I already have) which will execute when that button is clicked but -before- the checkout page is rendered.

And I need this to do so without disabling the default actions that the Checkout button performs.

SO: How do I hook into this button without disabling the default behaviour?

Due to my noobness--I'd appreciate as complete an example as possible. I'm not lazy, just can't take for granted that I'll catch everything I need to if the answer is 'shorthand'.

TIA,

---JC


texts: How to use an user profile custom field using Rules?

texts:
Working with Drupal 8.4.5 and Rules 8.x-3.0-alpha3 and Typed Data 8.x-1.0-alpha1

With Drupal 7 Rules, we may use an user custom field for data comparison (address or vocabulary for example). And it was easy to create the condition Entity has field with a select list to choose the right field (cf screenshot) :

Now, in Drupal 8 Rules, the procedure has changed and I did not manage to reproduce this simple condition Entity has field since the Field select list has disappeared and custom fields are hidden in the Data selector suggestions (cf screenshot)

So my question is : how to use my custom field in a Rule (simple data comparison, for example)? What is the new way to write user:field_custom?

Surprisingly, the help text within Entity has field condition says : ...To make entity fields appear in the data selector, you may have to use the condition 'entity has field'...

It seems like an infinite loop to me?

Furthermore, "More useful tips about data selection is available in the online documentation" and there we have documentation about Drupal 7 Rules.

Ultimately, I need to create a Rule in Drupal 8 to automatically give an user role when a new account is saved, depending on a custom field value.

The question below is quite similar.

How to custom field has a value with the Rules module?

EDIT : I found an alternative for my specific need with the module Auto User Role (still in dev version). It seems to work nicely (only when saving a new user, not after editing an user, so the custom field is required at creation)


texts:
I'm trying to setup memcache on my drupal 7 site. I have a memcache server setup and working and I've used setsebool -P httpd_can_network_memcache 1 to allow apache to communicate with it. I've also confirmed that port 11211 tcp is open in ip tables.

I've installed the memecache drupal extension, the PECL extension in PHP and when I run phpinfo(); I see that memcache is loaded.

In settings.php on my drupal web server I have the following:

/**************************************************
 * MEMCACHE
 **************************************************/
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_servers'] = array(
        'memcacheserver.ourdomain.local:11211' => 'cluster'
);

$conf['memcache_bins'] = array(
        'bin1' => 'cluster'
);

$conf['memcache_key_prefix'] = 'sdrupal';

However when I go to the status reports page I see the following:

Memcache integration    Memcache integration is not currently loaded.
Check README.txt and ensure that memcache.inc is configured correctly in settings.php

I've read through the readme.txt file repeatedly and of course you can see I have memcache.inc specified above.

I thought perhaps I had a conflict with the varnish module, or the apc module as those also set cache_backends - but its an array so I think thats ok. I also commented them out and I'm still seeing the error above.

I also confirmed that sites/all/modules/memcache/memcache.inc exists.

Why isn't drupal loading/finding memcache.inc?

Thanks
Brad


texts: Commerce: Diffrent text to add to cart button in product list and in product page

texts:
i try to modify the add to cart button text in commerce so i can have diffrent text in product list and diffrent text in product page.

Is it possible to do this with form_alter?

I tried to use something like node type but no success.

function custom_addtocart_form_alter(&$form, &$form_state, $form_id) {

    if ((substr($form_id, 0, 30) == 'commerce_cart_add_to_cart_form') && $node->type == 'product_display') {
    $form['submit']['#value'] = t('Buy');
    }
}

Thanks


texts: Select(dropdown) options visible text removed but values remain

texts:
I am having a really weird problem that I have been unable to solve except with a javascript workaround/hack that repopulates the values...

screenshot of problem: http://imgur.com/7W0B4jf

The exact problem is that many of the select drop-downs on a site, both front-end and backend have the visible values removed. This happened when I migrated the site from dev to live, but I have been unable to track down the cause, I am grasping in the dark a bit for what might cause a weird problem like this. Something I notice from comparing the missing values and the ones that aren't missing is that the missing ones seem to be only numeric and the ones that are unaffected are non-numeric, in fact all non-numeric selects seem to be unaffected and all numeric ones to be affected.

The places I have noticed the problem are:

Front end:

ubercart checkout page: credit card year

Backend

Ubercart authorize.net payment settings page: duplicate window
admin/store/orders/***/payments: date entry: day and year (but not month)
admin/store/orders/***/packages/new: qty field
admin/store/products/attributes/*/edit: list position
admin/store/products/attributes/*/options/1/edit: list position
admin/store/reports/coupon:  date entry: day and year (but not month)
admin/store/settings/store: number of decimal places
admin/store/settings/cart: duration
admin/store/settings/coupon: line-item weight (but not coupon activation/expiration time, which is semi-numeric: 00:00)
admin/store/settings/orders/workflow: list position
admin/store/settings/quotes: list position
admin/structure/types/manage/article: edit: comments per page
admin/structure/menu/item/***/edit: weight

Things I have tried to fix the problem:

disable almost any and all modules, each one at a time. This is difficult because eventually the more you disable the more broken the site becomes, so I have tried both methods: disabling a single one and re-enabling it when it doesn't fix it and disabling a single one at a time, but not re-enabling it before disabling the next...
re-install the same modules through devel

I am using Drupal 7.23. Link to site: http://cafemam.b.fgqa.net/cart/checkout

also using drupal to firebug (in chrome) and inspecting the form building shows me:

 [cc_exp_year] => array (
                     [#type] => [select]
                     [#title] => [Expiration year]
                     [#options] => array (
                         [2013] => []
                         [2014] => []
                         [2015] => []
                         [2016] => []
                         [2017] => []
                         [2018] => []
                         [2019] => []
                         [2020] => []
                         [2021] => []
                         [2022] => []
                         [2023] => []
                         [2024] => []
                         [2025] => []
                         [2026] => []
                         [2027] => []
                         [2028] => []
                         [2029] => []
                         [2030] => []
                         [2031] => []
                         [2032] => []
                         [2033] => []
                     )

any other broken selects I inspect the data for are similarly empty.


texts: Send e-mail after entityform submission using field from referncing node

texts:
I have a content type called contact page and several entity forms. The content type contact page has two fields on it one entityreference field that is used to reference an entityform and the other a text field used to store an e-mail address.

If the user selects an entity form then when the contact page is rendered so is the referenced entityform. When a user submits and entityform I would like to send an email to the email address supplied on the contact page.

I've been looking at rules but I am struggling to find out where I can load fields from the referencing entity so that I can use the email address on the contact page once an entityform is submitted.