texts: Custom node access control not working with access filter?

texts:
In some of mine content types I have checkbox field "Content protect". If checked that node should be visible only to registered user. If not checked - visible to everyone:

function hook_node_access($node, $op, $account) {

  // If $node is a string, the node has not yet been created. We don't care
  // about that case.
  if (is_string($node)) {
    return new AccessResultNeutral();
  }
  if ($node->hasField('field_content_protect')) {
    $protected = ($node->field_content_protect->value == 1) ? TRUE : FALSE;
    $userId = $account->id();
    if ($protected && $userId == 0) {
      return new AccessResultForbidden();
    }
  }
  return new AccessResultNeutral();
}

And this works well when I try to access node directly. If it's protected anonymous users can't access it.

Now, I have a view that lists some of those nodes. I want to apply same logic and to exclude protected nodes for anonymous users. So in my view I added filter:

Content access: Access

But it's not working as expected. For authenticated users content is there, but for anonymous users simply whole block content is missing?!? Nodes that don't have this "Content protect" field checked are also not listed?!? Why is that? This filter has no options/settings.

I do have other option, to duplicate view display, check directly the field and display first or second block view depending on user, but this solution with Content access filter looks more elegant.


texts: Views - Rewrite Content:Link field based on content type

texts:
I'm using Content:Link as a field in a view to make a link button in a list of content. How can I rewrite the results based on content type?

For instance, if the content type is an Article, it would say "Read More" but if it's a Product Display, it would say "Buy Now".

Thanks!
:)


texts: Best APC settings to reduce page execution time

texts:
I have Drupal 7, apc with php-fpm and apache behind varnish and512 MB RAM.

I measure page execution time with devel module.

Database query time is low (62ms) compared to page execution time which is 854 ms.
That means there is problem with PHP and APC settings.

My current settings are just

apc.shm_size = 64
apc.stat=1

How I can improve?

What are the best settings for Drupal given the above configuration?

Thanks


texts: CKEditor table td style not showing in frontend

texts:
I use CKEditor (WISYWYG editor) to edit text and HTML for my Drupal project. I want to edit an HTML table and try to horizontally align text in a table cell  to the right.

My steps:

select the text in the table cell
right+click > Cell > Cell properties > Horizontal Alignment: Right.

When I am logged-in and I inspect the HTML I see My text	. But as soon as I am logged-out the HTML is stripped and I see only My text	 (style="text-align: right;" disappeared).

I certainly need to align my text to the right in some HTML table cells.

Update:

I use Filtered HTML
In admin/config/content/formats/filtered_html, I added the following settings (see screenshot):


texts:
I have two sites running from separate installations. I would like to move them to a multisite configuration. I am currently developing in a localhost environment.

I am starting by moving the first site into a multisite config within its own installation. I have given it its own unique folder in the sites directory, set up the sites.php file and given the site its own settings.php in its directory. When I navigate to the location specified in the sites.php configuration I get a not found error, and when I go to the drupal install directory, Drupal would like to do a fresh install.

Do I need to set up a .conf file in the sites-enabled folder of apache2?

Any help is greatly appreciated.


texts:
I've got custom content-type with several groups and fields.

I want to change default display of that content-type. In which file can I find appropriate code?


texts: How to restrict access to private files to members of an organic group?

texts:
I have an organic group with a file field that stores its files in a private directory (sites/default/files/private/).
These files are visible only to members of that group. But, as is commonly known, if someone guesses the Drupal path even if he is not a member of that group or not even logged in, he can access that file by using the correct file link directly.

How can I restrict file access to group members?


texts:
I am just looking to do a bulk save on a bunch of taxonomy terms - need to trigger an update on a geofield - but there is no Save option in the bulk operations for Taxonomy Terms (as there is for Nodes).
When I try to update a field on the terms with Modify Entity Value, I get an AJAX error...
Ditto when I try to do a taxonomy_term_save($object) with Execute Arbitrary PHP Script.
Any ideas?

Thanks!

Simon.


texts: How to Create Membership Groups for Products?

texts: I'm exploring if the latest release of Drupal Commerce (using Commerce Kickstart 7x-2.38) will work for my Apparel eCommerce requirements. We need membership to groups (which will be corporate accounts or schools) that will present authenticated users a selection of apparel products using corporate or school logos and of course special pricing. I've looked into both Organic Groups and Membership Entities and neither seem to be the best solution. Any ideas?


texts: Line breaks are stripped by ckeditor after saving a node programmatically

texts:
I'm setting a value to a long text using this code :

$node->language = $language->language; // Or e.g. 'en' if locale is enabled
$node->field_job_description[$field_langcode][0]['value'] = $description;
$node->field_job_description[$field_langcode][0]['format']  = 'filtered_html';
$node->field_job_description[$field_langcode][0]['save_value']  = $description;

When viewing the node the line breaks are showing, when I edit this node using ckeditor all link breaks are automatically removed


texts: How to properly inject mutable config to the controller?

texts:
Apparently by default ControllerBase::config() returns \Drupal\Core\Config\ImmutableConfig object. How can I instantiate the controller class to make it use \Drupal\Core\Config\Config instead (which is mutable)?

I know I can do this inside the controller:

$config = \Drupal::service('config.factory')->getEditable('loremipsum');

However this is not the nicest solution. Besides, is there any reason for using ImmutableConfig by default?


texts: How do I render content "as is" from custom controller

texts:
I've created a custom controller that pulls content from another node (the body). That content is defined in the node as Raw HTML.

  public function page(Request $request): array {

    $nid = $request->attributes->get('_nid');
    $node_storage = $this->entityTypeManager()->getStorage('node');
    $node = $node_storage->load($nid);
    $content = $node->get('field_content')->value;

    // Load Entity using passed NID from key.
    $build = $content;
    // Return new Response($build);
    $render_array['snippet'] = [
      '#theme' => 'webpart_snippet',
      '#content' => $build,
      '#prefix' => '
',
      '#suffix' => '
',
    ];
    return $render_array;

  }

I would like to render that content as if it were a native Symfony response. (e.g., correctly parse and HTML tags AND scripts)

In the node that I'm pulling in, I have, for example

This is text

and that is exactly what is showing on the page

It should be

This is text

I have defined a custom theme as well as twig template

/**
 * Implements hook_theme().
 * Declare a new theme
 */
function custom_webpart_snippet_theme() {
  return [
    'webpart_snippet' => [
      'variables' => [
        'content' => '',
      ],
    ],
  ];
}


texts: How to make autocomplete search by an entity field instead of by name?

texts:
Let's say we have 3 custom entities:

When creating a new operator, I need to autocomplete the license:

By default we can use the autocomplete to find by name. So, we need to type the name to display the related results.

But here I'd like to autocomplete by authority name instead (since a license has no name).

Is it possible? If so, how to do it?


texts: I have created a page view, and I want to put in a block. I am not looking for a block view.


texts: Change to a directory and get current directory using FTPFileTransfer

texts:
1) Suppose I am in directory "/home/stream". Which class should I use in FTPFileTransfer to get the directory "/home/stream".

suppose in php to get the current directory we use "ftp_pwd"

How to know the current directory using FTPFileTransfer.

2)  In PHP we use "ftp_chdir" to change to a directory.

Suppose if my current directory is "/home/stream" , how to change to directory "/home/stream/public_html" using FTPFileTransfer.


texts: How to change rendering of div order in a field?

texts:
It appears that the module label help is not compatible with Date fields. It allows you to enter text, but it does not display.

I found out that in the div with class description should be above div id edit-field-geboortedatum-und-0-value instead of below

How to achieve this? Should I change a weight key in something?


texts: How to avoid calling performRequiredValidation() for custom element

texts:
I'm trying to integrate Selectize plugin  within Drupal 8 Form API.
The important thing that I want to create 'optgroup' options.

I've used Selectize module and created a custom FieldWidget Field plugin.
Almost everything works, but I got some troubles with validation of my element.
Every time my form element submitted I receive an validation error:

  "An illegal choice has been detected. Please contact the site
  administrator."

I've found the function, which sends me that error - performRequiredValidation().
I've found lines, so I can hack the core and add a case for my widget. But it's not a case for me.

if ($elements['#type'] == 'select') {
  $options = OptGroup::flattenOptions($elements['#options']);
}
else {
  $options = $elements['#options'];
}

So the only way I see - I have to avoid this validation somehow.
Plase help. Any suggestions would be appreciated.

Here is a simplified code of my widget:

namespace Drupal\my_fields\Plugin\Field\FieldWidget;

use Drupal;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget;

/**
 * Plugin implementation of the 'my_selectize_widget' widget.
 *
 * @FieldWidget(
 *   id = "my_selectize_widget",
 *   label = @Translation("My Selectize Widget"),
 *   module = "my_fields",
 *   field_types = {
 *     "entity_reference"
 *   },
 *   multiple_values = TRUE
 * )
 */
class MySelectizeWidget extends OptionsSelectWidget {

  /**
   * {@inheritdoc}
   */
  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $element = parent::formElement($items, $delta, $element, $form, $form_state);

    // Get our types.
    $grouped_types = _getTypesGrouped();

    // Override select form element.
    $element['#settings'] = [
      'plugins' => ['optgroup_columns'],
    ];
    $element['#type'] = 'selectize';
    $element['#options'] = $grouped_types;

    return $element;
  }

  /**
   * Get types grouped (options).
   */
  protected function _getTypesGrouped() {
    /**
     * // For example:
     * return [
     *   '1' => $this->t('One'),
     *   '2' => [
     *     '2.1' => $this->t('Two point one'),
     *     '2.2' => $this->t('Two point two'),
     *   ],
     *   '3' => $this->t('Three'),
     * ];
     */
  }

}


texts: How to add a time picker in datetime form elements

texts:
I have made a module that display a form. One of the form elements is a datetime field.

$form['FirstDate'] = array(
      '#type' => 'datetime',
      '#title' => t('First date-time'),
      '#id' => 'inputFechaMd',
      '#required' => TRUE,
      '#default_value' => '',
      '#prefix' => '

',
      '#suffix' => '
',
      '#attributes' => array('style' => array('margin-bottom: 1em;'))
    );

When the form is displayed It has two fields, one for date and one for time. The date field has a date picker, but the time field hasn't a time picker. I would like to add a time picker for this fields, but I don't know how to do it. Also, I would like to hide seconds and request only hour and minutes.


texts:
I have this managed_file form in a Drupal customized module, with this form a user can upload an image and saved it under sites/defaults/files.

 $form['Background_image'] = array(
'#type' => 'managed_file',
'#title' => t('Image'),
'#progress_message' => t('Please wait...'),
 '#progress_indicator' => 'bar',
'#description' => t('Click "Browse..." to select an image to upload.'),
'#required' => TRUE,
 ///'#upload_validators' => array('file_validate_extensions' => array('jpeg jpg png gif')),
'#upload_location' => 'public://backgroundimage/'
'#default_value' => $this->options['Background image'],
);

how to add a function to get the uploaded file? I tried this but it didnt work.

$image = file_load($form_state['values']['Background_image']);


texts: Views Bulk Operations Modify entity values on one form

texts:
I am trying to use VBO to update order status on entities.
When using "Modify entity values" it shows 'Modify entity values' on vbo dropdown and then it redirects to a page with dropdown with all the options.

How to make it all on one form so I could check rows and then select (eg.) an order status option?

Is there any module or do I have to go programmatically through this journey?

Thanks


texts: How to put a date token at the start of Backup and Migrate file name pattems?

texts:
Because Backup and Migrate sorts files by age, when you untar or copy some files to a destination, they will be more or less the same date and it may be hard to tell which ones are the latest etc. This makes it necessary to create a file pattern with the backup date at the start and make sorting by file name easier.

PS. Getting the date of the files restored from the archive correctly can be accomplished by some of the tar options.


texts:
I am trying to get a list of seasonal items that dynamically display items based on the current month. It also includes items from the prior month and future month.

I have created a content type for this type of item, with an integer checkbox list. The values are 1|January, 2|February, 3|March, etc. When creating/editing a seasonal item. I check the checkboxes for the month(s) that the item is used.

I have created a view for current items, but have yet to find a way to dynamically set the filter for the item month. At the beginning of each month, I have to remember to go into the view, and uncheck the checkbox from (now) two months ago, and check the checkbox for the future month to maintain that three-month spread.

How can I make this filter dynamically create a three-month list based on the current month?


texts:
I have a hierarchical user structure, so every user has a entity reference field that points to another user - his/her supervisor.

The thing is that I need to give every user the permission to modify/delete the users that are under him/her in the hierarchy but to no one else.

It is a bit more complicated due to the fact that the hierarchy can be quite high, so a user has to be able to modify even users that points to someone (as to their supervisor) who points to him.

I've Googled for quite a few minutes but didn't find any solution whatsoever. I also need to implement it with my module so programmatic approach would be proffered to another module.


texts: How can you remove another modules events?

texts:
So, I have an event subscriber for Drupal commerce that listens for "commerce_order.place.post_transition" and will send a bespoke order email (due to not being able to change some of the things like subject title in the commerce module).

Commerce also has an event subscriber listening to "commerce_order.place.post_transition" which will send an order receipt email. I need to unsubscribe this event to prevent sending duplicate emails but searching through google and comments sections of articles has lead me to a dead end.

Any ideas?


texts: Drush make: "Found makefile: myfile.make. Aborting"

texts:
I have a custom drush make file and custom drupal installation file for a new site. Both work fine on my local VM, and the local VM's of the three other developers who have tried it. However, when I try to run it on our test server, it chokes:

sudo drush -y make stub.make
Make new site in the current directory? (y/n): y
Beginning to build stub.make.                                       [ok]
drupal-7.37 downloaded.                                             [ok]
drupal patched with 1093420-22.patch.                               [ok]
drupal patched with comment-node-type-delete-1565892-3.patch.       [ok]
Generated PATCHES.txt file for drupal                               [ok]
MYPROFILE cloned from git://github.com/MYPROFILE.                   [ok]
Checked out branch development.                                     [ok]
Found makefile: MYPROFILE.make                                      [ok]
Aborting.

The first time this error occurred, my investigation uncovered a permissions issue. However, that is fixed, and I'm still getting the error.

The MYPROFILE.make begins with:

api = 2
core = 7.37

And continues with a bunch of

project[MODULE_NAME][subdir] = contrib

As well as

projects[CUSTOM_MODULE][type] = module
projects[CUSTOM_MODULE][download][type] = git
projects[CUSTOM_MODULE][download][url] = git://github.com/CUSTOM_MODULE
projects[CUSTOM_MODULE][download][branch] = development
projects[CUSTOM_MODULE][download[branch][working-copy] = TRUE

projects[CUSTOM_THEME][type] = theme
projects[CUSTOM_THEME][download][type] = git
projects[CUSTOM_THEME][download][url] = git://github.com/CUSTOM_THEME
projects[CUSTOM_THEME][download][branch] = development
projects[CUSTOM_THEME][download][working-copy] = TRUE

Everything works fine on the Vagrant for Drupal Development box downloadable from Drupal.org, and also on a custom Vagrant box another of the developers set up that integrates better with components beyond the website. But on the dev server, it chokes without giving a reason why. Googling for drush make found makefile aborted didn't turn up anything.

Is there some sort of diagnostic tool that I can use to get a more helpful message than 'Aborting'?

Forgot to add:

Before posting this, I tried running drush make directly on the MYPROFILE.make:

sudo drush -y make profiles/MYPROFILE/MYPROFILE.make
Make new site in the current directory? (y/n): y
Beginning to build profiles/MYPROFILE/MYPROFILE.make.              [ok]
No core project specified.                                           [error]

But as you can see from my excerpt of the make file above, it does specify a core. And again, it works on two different VMs. -- Since MYPROFILE.make was designed to be called by stub.make, the above error is the expected reaction when running it alone.


texts:
I'm not sure if this is possible, but I want to create a panel with a header image.

The way I'm planning to do this is to add a new Page element within panels called "Banner" (in this menu http://puu.sh/jfBbm/8c09cfe2fe.png).

Is it possible to have it so then when a user clicks the "Add Panel -> Page Elements -> Banner -> Chose image?" or is it not possible to have a variable image with this way?


texts: How to display additional fields in user profile?

texts:
I have added three fields to user profile (field_firstname, field_lastname, field_user_gender) and I want to display them on user profile page. Default render($user_profile) displays values of those fields continuously, for instance: JohnMalkovichMale

How I can do this right? And how I can get names of fields?


texts: Statistics per node only visible to node author

texts:
I want a simple block (or it could be attached to the content, I don't really care) displaying how many hits a node has had, visible on the node itself, and only visible to the user who created the node (and admins obviously).

Any easy way to do this?


texts: How to save node form data in form_values using drupal_execute

texts:
I want to save $form_values in the session table in the submit handler when a node type (eg page) is saved.

How can I reuse this $form_values to create this node again using drupal_execute after some time (say tomorrow)?

I've tried creating it but it isn't working out:

function abcdonations_entry() {
  if (isset($_SESSION['form_id'])) {
    $fs = $_SESSION['form_id'];
    $form_id = $fs['values']['form_id'];
    module_load_include('inc', 'node', 'node.pages');
    $node = array('type' => 'person');
    drupal_execute($form_id, $fs,(object)$node);
    print "Written successfully";
  }
}

Then I save it in this function:

function anu_general_form_person_node_form_submit(&$form, &$form_state) {
  $_SESSION['form_id'] = $form_state;
}


texts:
i'm trying to insert data to a different data base that i created. I've read a lot in the forum, the support documents and other pages but i haven been able to figure it out the problem, can someone give me a hand? point me to a right direction?

first i modified the settings.php like this:

<?php
/** ORIGINAL DATA BASE CONNECTION
$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'dbname',
      'username' => 'dbuser',
      'password' => 'dbpsw',
      'host' => 'dbhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);
*/

/** DOUBLE DATA BASE CONNECTION  */
$databases = array();
$databases['default']['default'] = array(
   'database' => 'dbname',
      'username' => 'dbuser',
      'password' => 'dbpsw',
      'host' => 'dbhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
);
$databases['civilproconstru']['default'] = array(
   'database' => 'name',
      'username' => 'username',
      'password' => 'password',
      'host' => 'datahost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
);
?>

And then in the module i'm creating i'm using this code: (i'm pasting the full module code, the insert is at the end, just in case the error is in the back)

<?php
/** START CONFIG MODULE
 * Implements hook_permission().
 */
function project_creator_permission() {
  return array(
    'access project_creator content' => array(
      'title' => t('Access content for the project_creator module'),
    )
  );
}

 /**
 * Agrega a lista de estructura hook_block_info().
 */
function project_creator_block_info() {
  $blocks['project_creator'] = array(
    // The name that will appear in the block list.
    'info' => t('Project Creator'),
    // Default setting.
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );
  return $blocks;
}

/**
 * Agrega menu en toolbar para "role" contratante hook_menu().
 */
function project_creator_menu() {
  $items['admin/crear_proyecto'] = array(
    'title' => 'Crear Proyecto',
    'description' => 'Crear Proyecto',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('project_creator_insert'),
    'access callback' => 'project_creator_access',
  );

  return $items;
}

function project_creator_access() {
 global $user;
 if (in_array('contratante', array_values($user->roles))){
     return TRUE;
 }
}
 /**
 * END CONFIG MODULE.
 */

/** START PROJECT CREATOR FORM */

function project_creator_insert($form, &$form_state){

    $form['p_name'] = array(
    '#type' => 'textfield',
    '#title' => 'p_name',
    '#size' => 15
    );

    $form['save'] = array(
    '#type' => 'submit',
    '#value' => 'save',
    '#submit' => array('project_creator_insert')
    );
    return $form;

db_set_active('civilproconstru'); /* OPEN DATA BASE*/
db_insert('project_info')
->fields(array(
'p_name' => $form_state['values']['p_name'],
))->execute();
drupal_set_message("succesfully saved");
db_set_active(); /*CLOSE DATA BASE*/

}
?>

At the end, it shows me the form but when i click save button it seems to be inserting the data but when i check the database it still empty. It doesnt give me any kind of errors on execution.
Thank u for the help...


texts: How to print login form with destination url on a page using code in drupal 7  ?


texts: How to get a referencedEntity field value in current node language

texts:
I am trying to get some node's content inside a block.

I managed to get the fields i wanted, but they are always returned in my site default language instead of the current translations (ex. /node/1 and /fr/node/1 returns the same english content instead of the translation)

It works fine for simple fields, but can't get it to work for referencedEntities :

I am inside a Block build() function :

$node = \Drupal::routeMatch()->getParameter('node');

// Simple text field : Correct value depending on language
$correctValue = $node->field_test_text->getValue();

// Paragraphs/referencedEntities
$paras = $node->get('field_paragraphes')->referencedEntities();
foreach ($paras as $para) {
   // Not translated, always in default language ?
   $badValue = $para->get('field_test_in_para')->getValue();
}

Thanks a lot.


texts: Trusted Host Patterns Settings Not working with IP

texts:
So I am trying to get this drupal(drupal845.localhost) site accessible by my VM. But the Trusted Host Settings are not working.

Here are the settings in my settings.php

$settings['trusted_host_patterns'] = array(
   '^drupal845\.localhost$'
   '^.+\.drupal845\.localhost$'
   '^192\.*\.*\.*\.drupal845\.localhost$',
);

I have another drupal(drupal.localhost) site on the same machine and the trusted host patterns work. This is what I have in my settings.php for trusted host patterns:

$settings['trusted_host_patterns'] = array(
   '^drupal\.localhost$'
   '^.+\.drupal\.localhost$'
   '^192\.*\.*\.*\.drupal\.localhost$',
);

Why does it work on the drupal.localhost but not on drupal845.localhost

Also to note is I have .localhost masked to 127.0.0.1. I have to specify the port because windows is using 80 so my WSL(Ubuntu) Apache server I set to use 8080.
They both work without the ip specification as well.


texts: How do add a condition to check if created node is language source (in a multilingual site)?

texts:
I need to fire a rule action when a node is created and this node is the original source in a multilingual site. This means that this node is not the translation of other node.

How do add a condition to check if the created node the original source in a multilingual site?


texts: Drush Make for a custom module hosted at github

texts:
I am trying to fetch a custom module versioned at github.com via drush make, but I get

Could not retrieve version information for custom_migration
Non-existent project type  on project techarena_migration

My drush make file section for the custom module is the following:

projects[custom_migration][subdir] = "custom"
projects[custom_migration][type] = "module"
projects[custom_migration][download][type] = "git"
projects[custom_migration][download][url]="git@github.com:qed42/custom_migration.git"

I also tried giving the branch parameter, but no change

projects[custom_migration][download][branch] = "master"

This is a private repository, could it be that?

Update: I am so sorry, I was using the wrong makefile. Sorry to have wasted your time. I am not sure if I should close the question?

P.S git:// doesn't work with private repo on github, git@github.com does!!


texts: How to show registration page in another language, maintaining its natural behaviour?

texts:
I need to show my registration page in another language, keeping this separate from his natural behaviour. In particular this page must be showed in English on the page of the site it owns to, but i need to show it in Italian on another site into an iframe. Now, common sense tells me i need a page

 www.example.com/user

and a

 www.example.com/it/user

and i tried to achieve this by "admin/config/regional/language/configure" and the option "Determine the language from the URL (Path prefix or domain)." and all works fine, but, for some reason, as i activate this option, ALL my site pages get a "/en/" in their url, breaking a lot of things into the site (that is extremely complex). There's a way to achieve this behaviour for the registration page only? (be able to call a page www.example.com/it/user to show registration in italian and having www.example.com/user and all other pages in the site work without any changes?)


texts: Next link on node page based on its taxonomy term

texts:
So here is what I'd like to achieve:

I'd like to put a Next link to every content of a type, that links to the next content with the same taxonomy term.

So for examle if I have A, B and C products with the term 'clothing' on them, I need a link A product that points to B, one link on B that points to C and so on.

How is this possible to do?


texts:
I haven't been able to access drupal.org for the past few days. When using Chrome I get: 'This webpage is not available'.  I have no problems with accessing any other site.

Oddly enough when I use a proxy I have no problem. I've cleared my cache in both IE and chrome but still no luck. I don't believe my IP address has been blacklisted so beyond that I don't know. This is true when I try on my phone too so perhaps it is IP address related?


texts:
Recently I developed a cg related image gallery with drupal, here: http://cgart.ir/en.

top rated images displayed in quicktabs and provided by views. I need a refresh button instead pager. currently I theme next link as refresh button and hide previous link.

how can I add refresh button in views?


texts: Would enabling 'Use Ajax' for view content harm our SEO?

texts:
Background:

We currently use a View to allow users to browse/search among the several hundred guidance pages on our website.

The current UX of the View is not ideal - using the exposed filters causes the whole page to reload, meaning that users have to:

a). Wait for full page reload
b). Scroll back down to the results grid

Question:

I was wondering if anyone had any experience using the 'Use Ajax' setting on a View - specifically in terms of any effect on their SEO?

All our guidance pages are listed on our sitemap, and most are linked to from other pages, but this View is the main, most trafficked area pointing towards them.

How likely is it that the switch would mean that search engines aren't able to/are less able to find/index them?


texts:
I'm using webforms to get some data from users. These results are later used in another php script, and this relies on looping through the data:

for ($i = 1; $i <= count($data); $i++)
    {
        $answers[] = $data[$i]["value"][0];
    }

However, by adding and deleting questions in the webform, the indices look something like this now:

1
2
3
5
8
12

And this gives an error because I use count() to get the number of entries. (count() = 6, but max() = 12). My first idea is to find a way to automatically reset the indices after adding or removing questions. So my indices look like this:

1
2
3
4
5
6

But I honestly have no idea how to go about this. Any ideas?


texts:
I think this is an easy problem, but cannot solve it.
I need to pass arguments from my module to a View3; suppose that i want to pass a part of the node title and need to get all the nodes that start with that value. I cannot expose filters because i have a particular layout that am not able to desing using exposed filters, so i need to pass arguments programmatically.
I thought to use Contextual filters but i have not found a way to specify the "Starts with" directive ... What can i do to pass argument?


texts: cout rows of a view for new content and comments

texts:
I have made a view getting the new content added and new comments

But i need to get its count and so i usedthe following code

$view = views_get_view('new_activity');

$view->set_arguments(array(arg(2)));

$view->execute();

return l(count($view->result), 'new-activity/' . arg(2));

but i see untrue number related to the view page

how to fix it espicially using history_timestamp attribute of each row

the main problem is that the views gets , data and hide the viewed rows
and only shows the unviewed rows which gives me wrong count

please help or advice with a better scenario

thanks in advance


texts: Are there any benefits/caveats with using Entity Reference over Term Reference?

texts:
Pretty simple question really, but is there any benefit to using a core term reference field over an Entity Reference field?

Obviously tagging is not really an option with Entity Reference, but I've used the Inline Entity Form for creating new terms from a node page and it works fine (I prefer it over tagging if my terms have fields).

tl;dr

Apart from tagging are there any benefits/caveats with using Entity Reference over Term Reference for referencing taxonomy terms?


texts:
I have a user who is uploading a number of files with the same file name. It is important to them that the files are never renamed. However, the files are getting _1, _2, etc on the end.

Is there a way I can ask Drupal to make a new directory for duplicate file names so that a rename is not necessary?


texts: Why does my rule have no effect on a VBO list of unpublished nodes but does work for published nodes?

texts:
I set up a rule that is supposed to delete some unpublished nodes. I created a view with VBO for the rule to work with. The rule is triggered by cron, leads a list of nodes provided by the view with VBO. The rule loops through the listed item and has delete content as action.

The problem is that the rule has no effect on unpublished nodes, even though I found out that the rule and view as they're set up can delete published nodes. Could someone give me a pointer here, why the rule works on published nodes but not unpublished nodes?


texts: How to flag node when "event date" has passed and send notice to authors of flagged nodes?

texts:
I have a "delivery date" field in my content type that users choose when creating a node. When this date passes I want the notice to be sent to the nodeauthor.

As far as I see, I need to flag the node with expired date with Flag module. I know that it's possible to set exiry date when node is created. In my case I need to compare the user set "delivery date" and current date.

Can I do it with the Rules module?


texts:
I have a strange problem on the intro of my site with jQuery animation. I load content with views/drupal, en set display to none. Then I want to fade in and out each row.

All works great in all browsers, but not in IE... Anybody has an idea why?

jQuery('.view-intro').find('.views-row-1')
    .css('display','block')
    .animate({opacity: 1.00}, time_short, 'swing')
    .animate({opacity: 1.00}, time_long, 'linear')
    .animate({opacity: 0.00}, time_short, 'swing', function(){

        jQuery('.view-intro').find('.views-row-1').css('display','none')

        jQuery('.view-intro').find('.views-row-2')
        .css('display','block')
        .animate({opacity: 1.00}, time_short, 'swing')
        .animate({opacity: 1.00}, time_long, 'linear')
        .animate({opacity: 0.00}, time_short, 'swing', function(){

            jQuery('.view-intro').find('.views-row-2').css('display','none')

            jQuery('.view-intro').find('.views-row-3')
            .css('display','block')
            .animate({opacity: 1.00}, time_short, 'swing')
            .animate({opacity: 1.00}, time_long, 'linear')
            .animate({opacity: 0.00}, time_short, 'swing', function(){

                jQuery('.view-intro').find('.views-row-3').css('display','none')

                jQuery('.view-intro').css('display', 'none')
                jQuery('.view-collections').animate({opacity: 1, paddingLeft: 0}, time_short, 'swing')

            })
        })
    })


texts:
On my drupal 6 site I have the following fieldset in one of my forms ($cur_div_wrapper_name is a variable I have set to be "share_opp_with_rep_div"):

$form['add_rep_share_fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Share with Rep'),
    '#prefix' => '
',
    '#suffix' => '
',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
);

As you can see, the fieldset is collapsible and has a state of collapsed by default.

Inside of this fieldset I have two selects.  One of these selects ("share_with_rep") changes it's values when the other select ("share_with_rep_region") is changed.  I utilize ahah and the ahah_helper module to make this work.

$form['add_rep_share_fieldset']['share_with_rep_region'] = array(
    '#type' => 'select',
    '#title' => t('Region'),
    '#options' => $regions_lov,
    '#default_value' => $default_share_opp_region,
    '#ahah' => array(
        'event' => 'change',
        'path' => ahah_helper_path(array('add_rep_share_fieldset')),
        'wrapper' => $cur_div_wrapper_name,
    ),
);

$regions_lov is a variable containing an array of options for this select.

$form['add_rep_share_fieldset']['share_with_rep'] = array(
    '#type' => 'select',
    '#title' => t('Sales Rep'),
    '#options' => $rep_user_lov,
    '#default_value' => $default_share_opp_rep,
);

$rep_user_lov is a variable containing an array of options for this select.

The user has to un-collapse the fieldset in order to see the two selects.  When I change the "share_with_rep_region" select the other select ("share_with_rep") changes automatically.  This works fine.

My problem is that the fieldset does not keep it's un-collapsed state after changing the "share_with_rep_region" select, and the user has to click on the fieldset again to un-collapse it and choose a value for "share_with_rep".

Does anyone know if it's possible to pull the collapsed state of the fieldset and remember it so the user does not have to click it again to view the contents after changing the "share_with_rep_region" select?

Thank you!


texts: How do I migrate from a site using a core version to another one using the same version?

texts:
I like to change the web-hosting provider. I want to remove un-necassary and useless stuff (e.g. modules, content types that aren't used from the site).

I have no idea how to do this. Is there a module for migrating only stuff which is in use? The migration modules I found only consider migration from previous versions to Drupal 8, not from Drupal 8 to Drupal 8.


texts: How to put a custom login menu in a page?

texts:
I'm totally new to Drupal and I'm using v.6.xx.

I've managed to remove the "login" menu via Admin panel.

Now I'd like to create a custom "page" (= no menu) with a customized login form, and once authentified, show a menu with some options and the "disconnect" option.

What is the best way to achieve this?

Thank you very much


texts:
I have to make a lot of different new content types. It will save me some time if the defaults (promote to frontpage etc) are set to my preferences. How can I do this?

I hope you get my question


texts:
I have a dev and prod versions of my D7 site. On dev I developed some functionality based on User Points module and plan to roll out it on prod. But it requires some initial number of user points for every user.

What is the best way to add user points to existing users: SQL query, Rules etc?


texts: How do I avoid behaviors are invoked after an AJAX call?

texts:
I have a search result page, with the first set of data being fetched during the page load, and we add a Load More button. Clicking on this button fires an AJAX call, using the ajax_links_api module. After the AJAX call is completed, we append more search results to the current set.
I have a behavior where I read the URL parameter; if it exists, I open a Colorbox.

If the colorbox opens on page load, we close it, and then click on Load More (which fires AJAX); then the Colorbox JavaScript is fired again, and we see the popup in action again.

I don't want to fire the Colorbox JavaScript after AJAX is completed/fired.

I tried jQuery Once, but it didn't work.

How can I achieve this? Can I detect when an AJAX call happens?

The following is the code I am using.

Drupal.behaviors.openColorbox = {
  attach: function (context, settings) {
    if ($('body', context).hasClass('page-search-site')) {
      var nid = url('?node');
      if (nid != undefined) {
        if (nid.trim()) {
          $('div.search-result')
            .find('.node-' + nid)
            .once('colorbox-clicked')
            .click();
        }
      }
    }
  }
};


texts: How to set a menu link to user/edit in Drupalgap?

texts:
I do not need the profile view tab and would like to link from a menu directly to user/%/edit/. In settings.js below I tried different paths, none of which worked.

// User Menu Authenticated
drupalgap.settings.menus['user_menu_authenticated'] = {
 options: menu_popup_get_default_options(),
 links: [
{
  title: 'My Account',
  path: 'user',
  path: 'user/%/edit', //not working
  path: 'user/edit', // not working
  options: {
    attributes: {
      'data-icon': 'user',
      'class': 'ui-btn ui-btn-icon-right'
    }
  }
},

Is there a (simple) way to set such a direct link?


texts: How can I override the string programmatically in forum topic list?

texts:
I am using the Forum module in Drupal 7. I want to change "Topic" with "foo", for example, in the General discussion forum page.

Where did I search for this

I did check the template in the forum module file and for this page it is forum-topic-list.tpl.php. There I found that, it is printed by following code,

<?php print $header; ?>

And in the description, the following statement has been provided.

  Available variables:

  $header: The table header. This is pre-generated with click-sorting information. If you need to change this, see template_preprocess_forum_topic_list().

Hence, there is nothing called "Topic" which I can just change as this header coming from the $header.

Now, I did check template_preprocess_forum_topic_list() but it does not have provision to Change "Topic" string.
Lastly, I did check the forum.module where I found the following function starting at line 914.

 function forum_get_topics($tid, $sortby, $forum_per_page) {
   global $user, $forum_topic_list_header;

   $forum_topic_list_header = array(
     NULL,
     array('data' => t('Topic'), 'field' => 'f.title'),
     array('data' => t('Replies'), 'field' => 'f.comment_count'),
     array('data' => t('Last reply'), 'field' => 'f.last_comment_timestamp'),
  );

Now, in the above function you can see t('Topic'). I could simply replace it with t('foo'), but I think this is not the right way.

Any suggestion, how can I override this? Thanks.


texts: Compare form input with user password in drupal 7

texts:
I'm trying to compare the user password from different databases so users of other drupal sites can also login.
I'm switching from the main database to other databases and then trying to compare the passwoord input field to the stored hash value.

I did not found a answer on this site maybe because my situation is a bit different.

I did found this question and tried user_check_password() and user_hash_password()
 returns nothing and user_hash_password returns a new hash every time I run it so I don't think I can use that to compare that to the stored value in the database.


texts: Media/file repository - asset autocomplete widget?

texts:
Does anyone know of a module which would install an autocomplete widget for file and image fields on admin-side?

The purpose of it would be to allow admin/editor to re-use a reference to an already uploaded file by typing its name. The widget would then auto-complete the path/reference based on the actual contents of directory where the asset is supposed to be uploaded. Otherwise, the file would have to be uploaded repeatedly.

Or, to rephrase the question: how do you folks solve such a media repository issue?


texts: We are going to have a "staging" server where all edits will be made. We are going to push to the cloud production server with Drush sync. I know there is a way to exclude tables, but is there a way to only push nodes and field data from published nodes/revisions?


texts:
I have a series of letters, each with a recipient and sender address stored with Addressfield, with spatial data added Geocoder into lat/long and stored in a Geofield. I'm using IPGV&M, Views, and Leaflet to render these points - 1 letter to each row, with 2 points (sender / recipient). This is working fine.

I'd now like to add a linestring between those two points, but am at a loss for how to do that. Can Geofield store linestrings? Can I automatically generate a linestring and store that in a Geofield field based on the geo POINT values of the sender / recipient Geofields?


texts: How to hide associated nodes with taxonomy term

texts:
I've created taxonomy-term--example.tpl to theme all terms within this vocabulary. I got one problem: beside the term fields, the page shows all the associated nodes (the nodes that has a term reference to my currently displayed term).

How to prevent the nodes from showing up on my page ?


texts:
I am creating a user programatically.

I have following files

$fields = array(

    'name' => $name,
    'mail' => $mail,
    'pass' => $password,
    'status' => 1,
    'init' => $mail,
    'field_first_name' =>array('und'=>array(0=>array('value'=>$first_name))),
    'field_last_name' => array('und'=>array(0=>array('value'=>$last_name))),
    'field_company_name'=>array('und'=>array(0=>array('value'=>$company_name))),
    'field_company_number'=>array('und'=>array(0=>array('value'=>$company_number))),
    'field_mobile_number'=>array('und'=>array(0=>array('value'=>$mobile_number))),
    'field_secondary_number'=>array('und'=>array(0=>array('value'=>$secondary_number))),
    'field_mobile_or_landline'=>array('und'=>array(0=>array('value'=>$landlinemobile))),
    'field_promo_emails_notifications'=>array('und'=>array(0=>array('value'=>$email_notification))),

);

Now i am using user_save(NULL,$fields);

Which is working fine. Now field_first_name, and some other fields are required which i have set under account mangefields. How to check validations of these fields. Does anybody tell me

Thanks


texts:
I understand how locks work, thanks to this post.  Very straightforward:

function mymodule_long_operation() {
  if (lock_acquire('mymodule_long_operation')) {
    // Do the long operation here.
    // ...
    lock_release('mymodule_long_operation');
  }
}

My problem is that my function can get "stuck" if lock_release is never hit. So how can I get my function to work again if something goes wrong here:

function mymodule_long_operation() {
  if (lock_acquire('mymodule_long_operation')) {
    // SOMETHING GOES WRONG HERE!
    lock_release('mymodule_long_operation');
  }
}

Yes, I can put the whole function around a try/catch and release the lock in the catch. But as a developer, I often add "die()" in my code when working. So I can easily trigger this function into an unexecutable state.

Is there some way to make the lock expire after a while? Or to make the lock expire as part of some gauranteed garbage collection function?

Any ideas would be highly appreciated! Thanks!

** UPDATE **

Nevermind me adding die() in my code. What if the function times out? Then it wont reach the release. I'm sure there are more cases to validate this as a problem.


texts: How to put multiple entity fields inline as sub fields?

texts:
Not sure how to explain this so will add an image.

I want a field to have 2 values, one is the type of data, the other is how many, needs to be on the same line.

For example for a website, I need the client to be able to select the photo type, and then how many of them.

I'm using entity form, but a solution for webform also might work, although I prefer entity forms.


texts: How to use managed_file to upload many files

texts:
I'm looking for a way to upload many files by means of the managed_file form API element. I would like it be like while uploading for node where is 'add new item' button.
How to do it?


texts: Matching User Taxonomy Selections to Related Content

texts:
In Drupal 7, I am using the “Profile 2” module to collect information about users.  I am using Profile 2 instead of the core profile functionality because I would like separate pages for users to answer questions.

Basically, users just select taxonomy terms as answers to questions.  For example, there might be a question like “what kinds of skills do you want?” and the user could select “fixing cars” (the taxonomy term and the vocabulary “Skills”.

I would then like to have a view on the user account page that shows recent pieces of content tagged with the term they selected (say, the content type could be called “Jobs”, with a tag within it for “fixing cars”).

Ideally, I would like this view to show all of the related tags a piece of content has to a user, but for now, I just want to figure out this basic functionality.  Can anyone help?


texts: Adding custom Text changes the horizontal alignment in Content type

texts:
I have a content type. For two fields I am using horizontal tab item . those two fields Section_grid_image and section_grid_image_path are displayed one after another so I have used hook_form_alter and added custom CSS.

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

//Load CSS
$form['#attached']['css'][drupal_get_path('module', 'displayor') . '/form.css'] = array();

if ($form['#id'] == 'section-node-form'){ //contenttype-node-form

   $form['field_section_grid_image']['#prefix'] = '
';
   $form['field_section_grid_image']['#suffix'] = '
';
   //where field_test is your file upload field

   $form['field_section_grid_image_path']['#prefix'] = '
 OR';
   $form['field_section_grid_image_path']['#suffix'] = '
';
   //where field_test is your file upload field
 }
}

CSS

#leftcolumn{
width: 400px;
float: left;
}

#rightcolumn{
 width: 600px;
 margin-left: 200px;
}

#innercolumn{
 width: 500px;
}

My alignment is getting like this:

I want the fields and OR to be displayed in a line.

How to do this.

EDIT: Got the answer.Below CSS did the trick.

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

//Load CSS
$form['#attached']['css'][drupal_get_path('module', 'displayor') . '/form.css'] = array();

if ($form['#id'] == 'section-node-form'){ //contenttype-node-form

   $form['field_section_grid_image']['#prefix'] = '
';
   $form['field_section_grid_image']['#suffix'] = '
';
   //where field_test is your file upload field

   $form['field_section_grid_image_path']['#prefix'] = '
(OR)';
   $form['field_section_grid_image_path']['#suffix'] = '
';
   //where field_test is your file upload field
 }
}

CSS

#leftcolumn,
#rightcolumn,
#orseperator
 {
   float: left;
   margin-right: 77px;
   padding: 10px;
 }
 .or
  { left: 382px;
   margin-right: 25px;
   margin-top: 1px;
   position: absolute;
   top: 76px;
  }


texts: How to pick the most expensive shipping rate

texts:
I have a Drupal 7 site with Drupal Commerce e-shop. For most of the products I charge a flat rate, in 3 tiers, some products cost € 5 to ship, some € 6 and some € 25, implemented as three flat rate shipping services.

I have set up rules to apply the correct shipping rate. These rules check for the presence of applicable products and - if found:

Delete all shipping line items from an order
Apply shipping rate to an order

I've set the weight of the rules so they are evaluated cheap-to-expensive. I figured the expensive shipping would then replace the cheap shipping.

I get both though. My check-out form shows:

-- Article listing --
Subtotal    € 20
Shipping    € 6
Shipping    € 25
Order total € 51

Instead I just want to charge € 25 for shipping.
Is the current behavior the expected behavior? Is my current approach wrong and misguided?


texts: why THEME_preprocess_menu_block_wrapper is never called

texts:
function mytheme_preprocess_menu_block_wrapper(&$variables, $hook) {
  $zebra = 0;
  foreach (element_children($variables['content']) as $mlid){
    $variables['content'][$mlid]['#attributes']['class'][] = ($zebra % 2) ? 'even' : 'odd';
    $zebra++;
  }
}

Taken from http://drupal.org/node/1503938

I can flush every cache in drupal 7 and it won't work, putting die statements in the code of the function proves this so what's the deal, other template theme functions I've added work just fine.


texts: How to submit form on selecting image in file select widget?

texts:
I am using Drupal Form API to upload profile image for user.
I found two file upload widgets in FORM API:

'#type' => 'managed_file' &
'#type' => 'file'

managed_file requires first selecting the file, then uploading the file and then submitting the form to change the image

file requires first selecting the file and then submitting the form to change the image

What I want to do is just when you select the image file and click ok in the file browser, the form should get submitted and image should be changed.

Is it possible using FORM API?
If not please recommend an alternative solution.


texts: Add fieldset with add more button using ajax

texts:
I have one fieldset like,

Education Qualification:
1. School, 2. College, 3. Course, 4. Year (these are the fields which will be in this fieldset)

Now I want to do "Add more" button under this fieldset then it will add same another fieldset as per user's requirement. If anyone have an idea so let me know on this. I can use Webform or Content Type also. Which will be suited for this type of form.?


texts: Get Thumbnail Image URL for Video in Views

texts:
I've got a Video field and the Video Thumbnail is uploaded by the user.

I've got a View which is generating JSON (with the views_datasource extension). I want to include the image url to the Video Thumbnail has one of the fields in my JSON. I've set the formatter on this field to be "Video Thumbnail":

However, the value shown in my JSON output is the url to the original video and not to the Thumbnail image.

So, I tried enabling Rewriting on that field in the Views configuration. I used the [field_video-thumbnail] token to try to get the URL of the Thumbnail image...

but what I get in my JSON is the fid of the Image and not the URL of the image.

  "node" : {
    "title" : "Test 6",
    "body" : "
test
\n",
    "field_image" : null,
    "path" : "/blog/test-6",
    "created" : "Monday, November, 2012",
    "field_video" : "38"
  }

How can I get the Image Thumbnail URL?


texts: The path admin/content/files is missing in Drupal 8.5

texts: I have installed Drupal 8.5 and today I realised that the tab admin/content/files is missing. Thanks to my backups I realized that this tab link is already missing since the 14th of March. Prior to the disappearance on the link I did not install any module. How can I solve this issue?


texts: How to use an image with Responsive Image style as a background?

texts:
We have a need to use the Responsive Image module. The key is that we want to be able to use the image (field_image) field with Responsive Image styles as a background and put the node's title on top of them.

How can we achieve this?

We have tried the following but this only fetches the original photo in a twig template. In other words, when i use Chrome Dev tools to see if it fetched the other images as part of the Responsive Image style settings, it does not fetch them.

 {# title goes here #}

Sample image:

Currently we are using the out of the box Responsive Image twig template

{% if output_image_tag %}
  {{ img_element }}
{% else %}
  <picture>
    {% if sources %}
      {#
      Internet Explorer 9 doesn't recognise source elements that are wrapped in
      picture tags. See http://scottjehl.github.io/picturefill/#ie9
      #}

      {% for source_attributes in sources %}
        <source{{ source_attributes }}/>
      {% endfor %}

    {% endif %}
    {# The controlling image, with the fallback image in srcset. #}
    {{ img_element }}
  </picture>
{% endif %}


texts: Translation of select field allowed values

texts:
I have a field that has just one option to choose. It's:

Online|This product will be delivered online

I'm struggeling to make it translatable, but with no luck. I've checked everywhere and I stucked. So, in database there is core locales_source table that holds english phrases. There is a source and context of this phrase:

lid: 39
location: field:field_product_delivery:#allowed_values:Online
textgroup: field
source: This product will be delivered online
context: field_product_delivery:#allowed_values:Online
version: 1

There is also locales_target table that contains translations and there is:

lid: 39
translation: Este producto se ofrece online
language: es
plid: 0
plural: 0
i18n_status: 1

Still, the value is displayed in English on Spanish node view page.
How to force it to use correct translation, not the english phrase. By the way, my default language set in Drupal is Spanish.


texts: How to set Form API link href to # hashtag

texts:
In Form API when creating a link, the output a-anchor will have a prefix of "en/" in front of whatever I set as the href value and if href is set to "#" it will be output with the language prefix and # is escaped and becomes a code something like "en/%23"

this is the code:

$element['add_address'] = array(
            '#type' => 'link',
            '#title' => t('Add new address'),
            '#href' => '#',
        );

I need that link to not have a href destination value, as it's supposed to react to javascript only. I know I could do a preventDefault() or any of the same resulting bypasses with JS, but I'm curious how to make a empty anchor with the form API.

Thanks,

Alari


texts: Migrating data from Drupal 6 to 7 with a twist

texts:
I am working on an update of a site from Drupal 6 to 7. The site will have a complete redesign and - since the structure is somewhat chaotic - I don't want to migrate the complete data.

On the current site, articles are stored in 6 different content types which are different only by name, but have the same fields. I want to migrate them to the standard "article" type and only add a tag which will indicate which section they belong.

On the current site, images were uploaded to the server and then just linked from the teaser. I want them stored in an image field on the new site, and I need to modify the teaser too before inserting to the new site.

Can I do this on database level with a php script or should I do this in Drupal? In that case - how do I communicate between the old and the new version?

Or is there a module for this? What I need is:

Move all articles (6 content types) to new site (about 500 articles), all in the article content type and set a tag based on the original 6 content types
Catch images in teasers, make them drupal managed files and attach them to the correspondig node
Delete the image tags from the teasers (they will be displayed from the image field)
Retain paths and tags for the nodes as we have a lot of indexed pages

Is this possible or shuld I choose another path?

EDIT: Ok, I can insert nodes in the new system by code and add taxonomy terms as required, but I still trying to figure out how to add images and the way of communication between the two systems.

EDIT Thanks everyone for the ideas. I solved the problem by writing a custom module that communicated with the D6 install and pulled the nodes I needed.


texts: Dropdown is not working in Better Exposed filter

texts:
I am created the location taxonomy and i used the better exposed filter to expose the form but the dropdown in location from better exposed filter is not working,, so please suggest me that how to do this in drupal7.

If i will select Bangalore then mg road within Bangalore will display, otherwise every cities are displayed like dropdown.


texts:
I'm encountering the bug described at "Login form error message is redundant and does not make sense". In short, if a user enters invalid credentials once, an inline error message appears on the user login page. When the user enters valid credentials and successfully logs in, the user sees an error message at the top of the screen (e.g., "1 error has been found: username"), but that is no longer correct.
According to this blog post one can disable inline form errors for a particular form by adding $form['#disable_inline_form_errors'] = TRUE; to the form definition, and I have seen that code snippet elsewhere, too. But I can't find any instructions for implementing it. Does anyone have an example?


texts: How do I override a panel pane admin title?

texts: I am trying to provide an overview to my site's admins of what each panel pane is exactly doing by trying to provide extra information in views panes, as I have panel pages with many regions and panes. For instance, rather than saying 'View: {View name} : {Display name} it would be a lot more helpful if I could label each of those differently, by adding custom text, views arguments dynamically, etc. I have tried a number of hooks like hook_panels_pane_prerender, but they only affect the front end, not the panel page on admin. How could I achieve this?


texts: Re-writing SQL statement in Drupal dynamic queries

texts:
I have the following SQL query, which I need to re-write using Drupal's dynamic query language. I'm new to Drupal development, could you please give me an example for the following SQL?

SELECT
    node.title,
    GROUP_CONCAT(field_data_field_location.field_location_value)
FROM
    node
    INNER JOIN field_data_field_location
        ON node.nid = field_data_field_location.entity_id
    INNER JOIN
        (SELECT DISTINCT
            entity_id
         FROM
            field_data_field_location
         WHERE
            field_location_value IN ('Berlin', 'Stuttgart')) AS IDS
        ON node.nid = IDS.entity_id
GROUP BY
    node.nid

What I currently have is the following:

$query = db_select('node', 'n');
$query->addField('n', 'title', 'title');
$query->groupBy('n.nid');

$subquery = db_select('field_data_field_location', 'loc');
$subquery->distinct();
$subquery->fields('loc.entity_id', array('eid'));
$subquery->condition('loc.field_location_value', $locations, 'IN');

$query->join('field_data_field_location', 'l', 'n.nid = l.entity_id');
$query->addExpression('GROUP_CONCAT(l.field_location_value)', 'locations');
$query->addJoin('INNER', $subquery, 'IDS', 'n.nid = IDS.entity_id');

$result = $query->execute();

return $result->fetchAll();

If I execute the code, I just get nothing back from Drupal. I think the problem is the subquery. Do you have any idea how I can solve that?


texts: How do add row striping CSS classes in Views?

texts:
I'm sure that on older versions of Drupal (6 or 7?) Views that showed as tables automatically had odd/even striping background colours.
Is there a UI option for this in D8/9?
I've done it in code like this:
/**
 * Implements hook_preprocess_HOOK(): views_view_table.
 */
function mymodule_preprocess_views_view_table(&$variables) {
  // Add zebra striping classes to the view rows.
  foreach ($variables['rows'] as $index => &$row) {
    $row['attributes']->addClass($index % 2 ? 'even' : 'odd');
  }
}

and it turns out that Bartik theme has 'even' and 'odd' CSS that work fine.
But is there a simpler way?


texts: Clearing a Date Field value in the Edit Node form

texts:
I have a content type with a date field (field_acquisition_date) and I'm using the Popup Calendar widget in the form UI. If a user...

puts a value into that field and save the node
then edits the node again
clears out the value
and saves the node a second time

the original value is still in that date field. How can the user set that field value to empty/NULL while using the edit form?


texts:
I need to programmatically save field data (during node save I want to take the title & path alias and store it in a link field called field_alternative_titles_title).

Which functions can I use here? Do I use field_attach_insert or hook_field_storage_pre_insert to save the link field?


texts:
I'm using the Simplenews module for creating newsletter and I would like to know if it's possible to aggregate different newsletter content into only one for the same subscriber.
For example, one person subscribes to 3 different newsletters on the same website and receives only one newsletter containing the 3 content of those three newsletters.


texts: all internal links won't work in a local-wamp site even after .HTaccess and mod_rewrite setup

texts:
I've imported a Drupal 7.41 existing site to my local machine on a wamp server. I've already imported it's .HTaccess (uncustomized), and have enabled mod_rewrite in WAMP and restarted all services.

Yet, anytime I click on one of the internal links at the local site, I get, is some, 404 error, and in some WSOD.

When I tried to log in via localhost:8095/yoyo I got this error after filling the details and clicking on the log in button, I've seen the following error, but I don't know should I do with it exactly? (Adding some kind of a class manually?) Updating the theme maybe?


texts: Commerce Kickstart 2 Collection - Displaying too much information

texts: I'm having an issue, for some reason, the collection page is displaying the product detail, included with the add to cart. Where would I adjust this setting? I was comparing with another product variation, and can't seem to fix this issue.


texts:
Let's say we navigate to http://example.org/ch/de/node/1 (with pathauto enabled /ch/de/hallo-welt)

Now I want to specify somewhere the country Switzerland (ch) and set the available languages to de (for German), fr (for French), it (for Italian), rm (for Rhaeto-Romanic)

So when I navigate to that link above, there should be a language switcher that shows me all translations for that country.

But now I have other countries specified. For example Canada (ca) with the languages en and fr but en should not be visible on node/1
And of course now I have a node at /ca/en/hello-world with a translation in fr. Now the other languages should not be visible on that node.

How can I do that with modules?


texts: How do I access a value from a form element which has a name attribute?

texts:
I have a form with a select field which has a name attribute.

$form['select_c'] = [
  "#type" => 'select',
  "#options" => [1,2,3],
  "#attributes" => ['name' => 'select_name'],
];

I am using that attribute to conditionally display some other form elements, but when I look at the content of form_state->getValues(), the select_c field is always empty.

However, when I comment out the #attributes line, I can see the right values for select_c with $form_state->getValues().

What should I change in my code?


texts:
I have a single PDF form with fields specified to several webforms.  I can successfully generate a PDF for each form individually.  using the url http://mydomain.dd:8083/fillpdf?fid=58&webform[nid]=19 and http://mydomain.dd:8083/fillpdf?fid=58&webform[nid]=33.

How do I combine the two NIDs into one FID=58?

Thanks for your help.


texts: Using Drush to update Drupal 6 core on multisite installation

texts:
I'm running multiple sites on a single Drupal 6 installation. I'd like to use drush to update Drupal core to the latest version without having to unlock update.php via settings for each site and then going to update.php for each of the different urls (there are over 10 sites).

Is there a drush command to update drupal core and run update.php for all sites at once?


texts: I would like to be able make a selection of nodes. The chosen nodes could be displayed in a block or similar. Much like a cart. Then I want to be able to save the selection and get a link for it that I can send and view. Could be either for 7 or 8.


texts:
I've been attempting to get a file to upload using REST services and have been having a heck of a time getting it to work. All attempts come back as 403 (Forbidden).

Here's the code:

export const postImage = async file => {
  const url = "http://XXXXXX.com/entity/file?_format=json";

  const reader = new FileReader();

  reader.readAsDataURL(file);

  reader.onload = async e => {
    const body = {
      filename: [{ value: file.name }],
      filemime: [{ value: file.type }],
      filesize: [{ value: file.size }],
      type: [{ target_id: "image" }],
      data: [{ value: Base64.encode(e.target.result) }]
    };

const requestObject = {
  body: JSON.stringify(body),
  method: "POST",
  mode: "cors",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json",
    Authorization: "Basic XXXXXXXXX",
    "X-CSRF-Token": "XXXXXXXX"
  }
};

const response = await fetch(url, requestObject);

const data = await response.json();

return data

I have been able to properly POST with content just fine using the same authentication. Setup for File in REST is just like with Content (JSON, basic auth). The account I'm posting from has full admin privileges. Any help would be greatly appreciated.


texts: Commerce/Rules - Multiply the price by a custom field value

texts:
In my Drupal Commerce store, I have a field called Commission.

The Commission is input as a percentage (i.e. its not a fixed global value).

I need the final price to be updated so it incorporates the commission. I then need VAT to be added to the commission (but not the original price). The user should be able to see the full price (with commission and commission-VAT) before they add a product to cart.

I thought Rules would be perfect for this situation, especially as it has an action called "Multiply the unit price by some amount". However, this action doesn't seem to accept values from custom fields, even if you bring them into scope in the conditions area of the Rule.

I have watched Randy Fey's excellent tutorials on the Rules and Commercial modules, and I have tried to adapt them to my use case. However, I can't get it to work.

Could some one give me some pointers. Thanks!


texts: What's the proper way to add a field at a given place in a form?

texts:
I'd like to add a checkbox right before the 	 tag of each column of a table.
According to this answer, we should preferably use #prefix and #suffix over #weight.
So, here is my hook_form_alter():
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_admin_permissions') {
    $form['select_all'] = array(
      '#type' => 'checkbox',
      '#title' => t('Select all the column'),
      '#prefix' => '',
      '#suffix' => '	',
    );
  }
}

But my checkbox is at the bottom of the page.
Since I didn't understand why we use an additional latitude array in the linked example, I also tried with an additional array:
function my_module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_admin_permissions') {
    $form['table_header']['select_all'] = array(
      '#type' => 'checkbox',
      '#title' => t('Select all the column'),
      '#prefix' => '',
      '#suffix' => '	',
    );
    $form['table_header']['select_all'] = $form['select_all'];
    unset($form['select_all']);
  }
}

In that case my checkbox does not appear at all.
It seems another strategy could be using array_search and array_merge like suggested here, but I couldn't make it work.
To provide more info about the form I want to override, I put a break-point at the second line of my_module_form_alter():

In my case, this is what I'd like to do:


texts: Drupal log in block and side bars and content is disable and can not log in to my drupal site locally my site is based on omega theme and content regeion is also disabled and also log in block is disabled and mysite/user does not show any input box for user name and password.. what shoult i do? plz i stuck in this problem. it's very serious.


texts:
I'm using the Drupal-7 system caching and i recently installed the Boost module to improve my site performence;
I'm wondering if there's no conflict between the two system caching because i didn't feel any increasing of my site rapidity .
Thank you very much


texts: How can I remove or overwrite the YAML validation from a Webform Entity?

texts:
I am currently building a module that parses raw HTML into a webform using YAML, however I am running into an issue where the name='SomeName' on form elements is causing an error in the YAML keys.

The form relies on the name attribute in order to accurately map the data so I need it to be case insensitive.  I can force a save programmatically with

$webform = new \Drupal\webform\Entity\Webform::create(
// stuff here
);

$webform->save();

However when someone attempts to edit the form in the UI and saves, there is an error preventing save that comes from docroot/modules/contrib/webform/src/WebformEntityElementsValidator.php

This error prevents saving due to casing errors.

The element key contact_Name on line 1 must contain only lowercase letters, numbers, and underscores.

I have tried

function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $forms_array = ['webform_ui_element_form', 'webform_source_form'];
  if (in_array($form_id, $forms_array)) {
    $form['actions']['submit']['#limit_validation_errors'] = [];
    $form['actions']['submit']['#_validate_form'] = FALSE;
  }

}

However it seems that for some reason this prevents saving a new element.

Any help is appreciated.


texts: How to deal with PHP Fatal error: Cannot unset string offsets in field.default.inc when implementing custom widget?

texts:
I have a custom auto-complete widget that I use to create a custom field that is used to create a custom content type in a custom module.

I have hook_field_widget_info

function MODULE_field_widget_info()
{
    return array(
        "MODULE_taxonomy_autocomplete" => array(
            "label"         => t("MODULE Autocomplete term widget (tagging)"),
            "field types"   => array("taxonomy_term_reference"),
            "settings"      => array(
                "size"              => 60,
                "autocomplete_path" => "taxonomy/autocomplete",
            ),
            "behaviors"     => array(
                "multiple values"   => FIELD_CARDINALITY_UNLIMITED,
            ),
        ),
    );
}

I have hook_field_widget_form

function MODULE_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element)
{
    $tags = array();
    foreach ($items as $item)
    {
        $tags[$item["tid"]] = isset($item["taxonomy_term"]) ? $item["taxonomy_term"] : taxonomy_term_load($item["tid"]);
    }

    $element += array(
        "#type"                 => "textfield",
        "#default_value"        => taxonomy_implode_tags($tags),
        "#autocomplete_path"    => $instance["widget"]["settings"]["autocomplete_path"] . "/" . $field["field_name"],
        "#size"                 => $instance["widget"]["settings"]["size"],
        "#maxlength"            => 1024,
    );

    return $element;
}

I have hook_field_widget_error

function MODULE_field_widget_error($element, $error, $form, &$form_state)
{
    form_error($element, $error["message"]);
}

Here I am creating the field of the content type

field_create_field(
    array(
        "field_name"    => "field_MODULE_tags",
        "type"          => "taxonomy_term_reference",
        "bundles"       => array(
            "node" => array(
                "CONTENT_TYPE",
            ),
        ),
        "cardinality"   => "-1",
        "settings"      => array(
            "allowed_values" => array(
                array(
                    "vocabulary" => "TAXONOMY_LIST",
                    "parent"     => 0,
                ),
            ),
        ),
    )
);

field_create_instance(
    array(
        "field_name"    => "field_MODULE_tags",
        "entity_type"   => "node",
        "label"         => "Tags",
        "description"   => "",
        "bundle"        => "CONTENT_TYPE",
        "widget"        => array(
            "weight"    => 1,
            "type"      => "MODULE_taxonomy_autocomplete",
            "settings"  => array(
                "size"              => 60,
                "autocomplete_path" => "taxonomy/autocomplete",
            ),
        ),
    )
);

All of this appears to work fine, the content type shows the correct field, the auto complete works great, but when I try to save a new node of the custom type, I get the following error:

PHP Fatal error:  Cannot unset string offsets in /modules/field/field.default.inc on line 41

If I look at field.default.inc file I see

function field_default_extract_form_values($entity_type, $entity, $field, $instance, $langcode, &$items, $form, &$form_state) {
  $path = array_merge($form['#parents'], array($field['field_name'], $langcode));
  $key_exists = NULL;
  $values = drupal_array_get_nested_value($form_state['values'], $path, $key_exists);
  if ($key_exists) {
    // Remove the 'value' of the 'add more' button.
    unset($values['add_more']);
    $items = $values;
  }
}

where line 41 is unset($values['add_more']);

If I output $values, I get a string where unset is expecting an array.

How can I make my value an array?

I've tried using hook_form_alter to add a custom submit function so I can manipulate the value but the custom submit never gets fired (which is weird).


texts:
I am writing a Ruby script to ingest content into Drupal 7. This is on my local machine. I'm using the Services module and its rest service to GET and POST. I could log in and grab the csrf token and the cookie information but I get a 403 error when I try to post a new node. I checked my local apache access and error logs. There were no errors listed and the access log only reports the status. This is my code so far:

require "rest-client"
require "json"

node = create_node(node_hsh)
node_json = JSON.generate(node)
response = RestClient.post('localhost/drupal/restfulapi/node', node_json,
:content_type => :json,
:accept => :json,
:headers => {:cookie => cookie, 'x-csrf-token' => csrf_token}
)

I'm not sure where else to look? I would really appreciate any pointers. Thanks.


texts: How to include a user defined select list in a custom form

texts:
I have a written a custom module that defines a block with a form in it.

Is it possible to allow the form to pull in a list of values that is defined by the user in drupal's cms?

If so how do I go about including that in the modules code?


texts: How can locally deleted fields also be deleted on production?

texts:
We are using D8's Configuration Management for our site. When we delete fields in our local development environment the corresponding content type and field yml files are updated to reflect the change. However when we deploy these changes to our production environment, the field is not deleted. It is simply moved to the hidden (Disabled) spot for the content type under manage fields.

As a result we have to manually go in and delete the field in production. How can we delete the fields on production when new configuration files are deployed?

Deployment process:

In our local environment, make the changes by deleting the fields
Export config into the config/sync folder and commit into git
Deploy branch with latest updates to config/sync folder to Cloud environment such as production
run drush config-import and select the vcs option (to import from git)
navigate to the content type and verify changes
observe that the field is hidden, not deleted.


texts: What is the best practice or easiest way to import product types from their content type derivatives?

texts:
I'm new to Drupal Commerce, and I want sell clothing articles. For the clothing articles, I created a view with a content type including fields like name, price, article-number, etc.

Now I want to create a shop with product types. Can I just import the content types into the product types or do I have to add new product types and then create all the articles over again? What is the best way to add products to my shop?


texts: Remove "Comments" title section from node template

texts:
in my node.tpl.php i have this line:

<?php echo render($content['comments']); ?>

It works, but before comments I have a <div> with the text "Comments". I think that it is the section titles. I don't want it. Is there a possibility to remove it before "render" or I need to hide it via css ?

M.


texts: Inject SQL_CALC_FOUND_ROWS into db_select()?

texts:
I've recently learned that SQL_CALC_FOUND_ROWS can give the number of rows in a table from almost any SELECT statement. It's raw SQL syntax is SELECT SQL_CALC_FOUND_ROWS field1, field2, ... FROM ...

Is there an existing way I can that inject that syntax into db_select()?

I want to use this for creating a pager, so I'm already selecting some rows in the first place. It would be handy to get a count out of the query I'm already running. Doing a separate count query would be extra work in my case.


texts: How to display content in views with large 4-layer taxonomy term tree filter?

texts:
To describe my problem more accurately I'll give a simple example of my situation:
I have a categorized content. There are 10 different categories like clothes, cars, lamps etc. Each of them have more child terms(clothes:white,red,black) Each of those has more childs(white: size1, size2 etc). If i put everything under one vocabulary, the term Filter in views gives a very long list of every single term in that vocabulary. That's kind of crappy.

A thing like this would probably solve my problems: http://drupal.org/project/hierarchical_select

However, it's still not available for views. So how do i go about this?

I saw sites with same category trees using just top layer of vocabulary for views filter, and other terms putting as menus above whole content view. For example if Clothes is selected in filter, you see all the relevant content plus menu of White, Red and Black and so on. Maybe it's not exactly the way they do it but i'm trying to figure out what's the best way to solve this.


texts: I know this is a very basic question. Is flush and clear cache the same in Drupal 7? How will I flush cache in DRupal 7? It seems like the only available option for me is clear cache. But I saw a video tutorial which uses flush cache in Drupal 7. What will I do to avail this option?


texts: Saving a field of type 'text_format' as a theme settings variable

texts:
I try to add a text area with wysiwyg editor in the theme setting.

If i use '#type' => 'textfield', it works :

If I use '#type' => 'text_format', the text is saved but i don’t see it as default value :

If I revert back to '#type' => 'textfield', i can see this :

I guess it is related to the text_format form which is stored as an array ?

How can I use text_format in theme settings ?

Full code in mytheme.theme

function MYTHEME_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface &$form_state, $form_id = NULL) {

  $form['mytheme_texte_presentation'] = array(
    '#type'          => 'text_format',
    '#title'         => t('Test theme settings'),
    '#default_value' => theme_get_setting('mytheme_texte_presentation'),
    '#description'   => t("lorem ipsum"),
  );
}


texts: Require Confirmation when navigating to a new page

texts:
Not sure if I've phrased this perfectly. Many websites have functionality such that if you're typing in a text window on a page and then go to navigate away from that page (close the tab, hit back, etc) it will give you a confirmation box/window to let you know your information won't be saved.

Is there a way to add something like this to drupal? I've lost several posts by accidentally closing the wrong tab.


texts: How to avoid redirection to front page in photo gallery using Views

texts:
I'm using Drupal 6 Fivestar, voting API,voting api_autoremove modules for voting system.There is a Photo gallery in my site where the users can vote for their desired picture.I brought the pictures through views and which is also using the pager(currently it has 1 to 5 pages).

If an user votes for an image in third page(for example i'm saying third page, it may be any inner page that is not the first page),it saves the vote and it is redirected to the first page.But i wanna make the user to stay in the same page ie the third page in this case(in whichever the page they are being voted).

I searched for a very long time but didn't find out any solutions.Could anyone help me to solve this problem?

Thanks in advance.


texts: How to add content inbetween node fields on node creation?

texts:
I have a node called survey. Inbetween fields I want arbitrary text. The text is not associated with a field. I tried adding a "group", but could not find a way to add html. Then I looked at adding some kind of plain text field, but also no luck.

I'm sure I've done this using groups in the past, but I just can't seem to find out where to do it. Any ideas?

And just to be clear:
 - I have a node called survey
 - It has fields on it like "name" and "email" address
 - Inbetween name and email, I want, for example, to show an image and some text. I want to be able to enter the html to do this, but not sure how to add it?

In code, I would just add a type "#markup", but how do you do this via the interface?


texts: menu_tree_all_data returning empty arrays for custom menus

texts:
I have tried to get the menu tree for two different custom menus using menu_tree_all_data, but they have returned empty arrays, while using it to get 'navigation' menu works.

Does anyone have any idea about what might be going on?


texts: show a form in a popup when a button is pressed

texts:
I am creating  a registration form it has multiple stages. I am able to redirect to another page with the help of a link.
How can i get the form as a popup with a button.

 $form['adding_disease']=array(
   '#markup'=> ''.t('disease_list').'',
 );

Here this snippet is written in a form with many other fields.
this link is in the middle of the form.


texts:
I have solr search setup on my drupal8 website.  I have a view setup that has two pages in it. I have the search box via an exposed form placed as a block in my header region.

What I want to do is to create a new search form that has different text in the submit button and submits the form to a different page than the search form in the header.

Is there a way through the view or display modes to expose a new template so that I can customize the button and action on the form?

More Details

I was able to create a new solr search form by duplicated the "page" in the solr search view.  I modified the name and machine name and modified the input-submit.html.twig template to remove the ID from the submit button.  I did that because I have a search form in the header region of my website and then adding another form to the page in a Layout Builder with the same id was causing a conflict and chrome was yelling about it. ID's have to be unique after all.

Layout Builder won't let me save the layout though. I had to revert back to the default and then rebuild my page layout in layout builder.  I have to add all of the blocks and then I get to save the layout once.  I can the form into the page now, but I won't be able to make any changes to the page in the future.

Well, I suppose i can remove the search form, save the layout, go back in and make my changes and then add the search form back to the layout builder.  That is not ideal.

Any trick to fix that issue?

Possible Solution, but not ideal

I added the view page block into the Block Layout and restricted to only the page I needed it on.  That should work for now, but I would prefer to be able to see all of the content blocks in the Layout Builder.


texts: Users have access to add Commerce Products into the Store and publish it. How to display to user only allowed firms in the product addition form?

texts:
My webshop has lot of users with role Seller. They can add SKU and publish goods. Product display content type has field "Firm" that is taxonomy term reference.

Now every Seller can see all the firms (all the terms) when he add a product and he can check anyone. This is very uncomfortable because Seller work with only a few firms and he want to see only his firms to check one of it.

I want to display only user referenced firms in this field when user add a product.

How do I do this?

I've added to user profile field "Seller Firms" that is the term reference to the Firms. Using module Field Permissions I've made this field accessible to edit only by administrator.
I've checked for each user his firms that he can have access to publish goods of these firms (seller will can to check only those firms that I've checked in profile)
So how to alter product addition form to show only user allowed firms? I have few product displays machine names: product, product_with_attributes

I think this will be hook_alter_form or Rule that will limit the selection to only a few firms that are allowed.

I've made the first part this way:
1. I add Entity Reference field "Seller" to taxonomy Firms that link to users profiles.
2. I'd fill this field for all terms with users that must have access
3. I start to write my module that will display only user referenced terms in node add form. I do not know how to write this. The field name in node Product Display: field_firm. Field Entity Reference in terms: field_seller. Help me to finish my module:

function user_referenced_taxonomy_terms_form_node_form_alter(&$form, &$form_state, $form_id) {
  //$form ['field_firm']
}


texts: Some files are deleted from the files table after CRON execution

texts:
I am using hook_form_alter() to add a file upload field to the taxonomy term form.
The form itself and the submit are working well. From the submit callback i save the uploaded file using file_save_upload(). This also works well, the is saved in sites/default/files and in the files database. I have noticed that when Drupal CRON is executed the files i saved are deleted, but the other files (from CCK for example) remains in the table. Files are also deleted from the sites/default/files directory.

Here is my code :

/**
 * Implementation of hook_form_alter()
 */
function community_form_alter($form, $form_state, $form_id) {
  switch($form_id) {
    case 'taxonomy_form_term':
      // get the current image if any
      $image = variable_get('community_term_image_'.$form['tid']['#value'], '');
      // load file
      if($image) $image = field_file_load($image);
      $form['identification']['image_preview'] = array(
        '#type' => 'markup',
        '#value' => $image ? theme_imagecache('community-section-title', $image['filepath']) : '',
      );
      $form['identification']['image'] = array(
        '#title' => t('Category image'),
        '#type' => 'file',
      );
      $form['#attributes'] = array('enctype' => "multipart/form-data");
      $form['#submit'][] = 'community_term_form_image_submit';
    break;
  }
}

function community_term_form_image_submit($form, &$form_state) {
  $dir = variable_get('file_directory_path', 'files');
  $save = file_save_upload('image', array(), $dir);
  if($save->fid) {
    // If the term currently contains a picture, we remove it prior to saving
    // the new one
    $current_image = variable_get('community_term_image_'.$form_state['values']['tid'], '');
    if($current_image) {
      $current_image = field_file_load($current_image);
      db_query('DELETE FROM {files} WHERE fid = %d', $current_image['fid']);
      file_delete($current_image['filepath']);
    }
    variable_set('community_term_image_'.$form_state['values']['tid'], $save->fid);
  }
}


texts: Real world experience in scaling and tuning performance

texts:
The website I'm working is allegedly going to have a massive hit rate soon after launch. The client is talking about the possibility  of around 2500 hits per second over a day or so.

Ignoring the fact that this hit rate is probably wild client optimism and apart from getting the largest servers possible, what is the best way that Drupal should be configured to support a large hit rate.

I've read Scaling the drupal.org Infrastructure, Drupal performance blog, Best Practices for Scaling Drupal and many other pages, but what I'm looking for is real experience of doing this, what works, what doesn't, and what to expect.


texts: Cannot access the site after changing admin password

texts:
I have drupal 7 site hosted on bluehost.

After I changed the admin password, I got an error. I then tried to access the site, and I was able to do that, but it was very slow.

Now, I can't access the site as an administrator. It becomes even more weird: If I delete all history and cookies from the server, I can access the site; I can also login as an authenticated user.

When I try to log in as administrator, I get a white page or a "500 internal server" error. (It depends on the browser; I tried Chrome, FF and IE.) After I do that, I cannot access the site even as guest or authenticated user; only when I delete all the history and cookies, I can access the site as guest or authenticated user.

How can I fix this?

This is the error log the bluehost Representative gave me:

  [15-Apr-2014 14:48:49 Europe/Helsinki] PHP Fatal error:  Call to undefined function intel_path_filter_type_to_arg() in /public_html/includes/menu.inc on line 814

Is it possiable this module has something to do with the issue? https://drupal.org/project/intel

I think I disable the google analytic api module. Maybe the problem is related to one of the Drupal SEO modules?

I am really not sure, and cannot connect my site..

Yesterday the site worked great!
Restoring the site to yesterdays backup did not help - this is the weirdest thing!


texts: How to alter account activation mail Depending on roles

texts:
In account settings ,Account Activation mail settings is general i think so.

I want the account activation mail to be altered. I want to check roles, according to that display the mail messages .

how will i do that?


texts:
I'm trying to set up a batch process and from the examples I see:

$context['results']['processed']++;
$context['message']

Is there a list of these, 'buckets' somewhere?


texts: Different front page for anonymous users

texts:
I am looking to create a custom front page for users that are visiting the site. This is a landing page in a way, which will encourage users to register and has different CSS. Once a user is logged in or registered then they can see the normal website. Trying to do this without any modules.

What I have done so far is change the .htaccess file so it loads the index.html first.

Like so:

DirectoryIndex index.html index.php index.htm

The problem with this method is that users who login in still see the index.html page if they click on any link that points to the Home page. Instead I would like them to see the index.php or the normal Drupal site.

If it possible to do this with preprocess page hook? What code should be used?

I am only trying to present a different front page to the visitor when they hit domain.com. All the other pages such as domain.com/about-us and others should display properly regardless of the user role. In other words, I am NOT trying to hide the whole site for visitors.


texts: How to call function after submit button clicked

texts:
$nid = db_insert('tennis_vana')
  ->fields(array(   'firstname' => $first,   'lastname' => $last   ))
  ->execute();

unset($form);
$form_state['rebuild'] = TRUE;

drupal_set_message("you data has been saved");

$details=project_list1();

this is not working. My requirement is, I want to call and display information from after submit.


texts: How to programmatically check in module if multisite is used?

texts: Is it possible to easily check with code if a site is running as multisite instance?


texts: Linux Drush install error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56

texts:
I tried installing Drush with both methods listed in the drush.org documentation. I think they might be conflicting with each other if that's possible.

When I run composer global require drush/drush all the components appear to install correctly. However when I change to a Drupal site (Using XAMPP, /opt/lampp/htdocs/sitefolder) and run drush status I get the following error:

  PHP Fatal error:  Undefined class constant 'MYSQL_ATTR_SSL_CA' in
  phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56
  Drush command terminated abnormally due to an unrecoverable error.
  [error] Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
  phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56

I do have the following line in my ~/.bashrc:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Unfortunately I don't know how to troubleshoot from here, as there doesn't seem to be an easy way to uninstall Drush via the main method (http://docs.drush.org/en/master/install/), which didn't seem to work for me. composer global remove drush/drush does appear to run successfully.

Thanks in advance.


texts: Contextual filter by taxonomy term not using language

texts:
We have a site with 3 different languages and each language is detected by sub-domain. One of the taxonomies we use is representing types of products and have terms in all 3 languages inside:

CategoryQ (se)
   CategoryW (se)

CategoryE (no)
   CategoryR (no)

CategoryT (da)
   CategoryY (da)

I faced with problem regarding contextual filters and taxonomy terms. I have view with contextual filter accepting term name and displaying nodes related to this term:

Content: Has taxonomy term ID (with depth)

Also added validation and "Filter value type" set to "Term name converted to Term ID".

All worked fine until we discovered that we have couple of terms that have same names in all languages (we are not translating terms, all terms are added separately for each language - BL requirement):

CategoryG (se)
   CategoryY (se)

CategoryG (no)
   CategoryX (no)

CategoryG (da)
   CategoryZ (da)

Processing contextual filter Drupal takes first term tid he found in database (with lowest tid) and use that constructing view's query. In our case Drupal takes SE term instead of NO. So basically there is no language control in contextual filter at all. Is it possible to somehow add this control with hooks or some modules maybe?


texts:
I have the code that create entity named "Victory" in entity type, my problem is how to prevent user creates the entity with the same name again.

function commerce_services_store_create($data, $flatten_fields) {
  $storeName = $data['store_name'];
  $status = 1;

  $entityType = "fruit_store";       //entity type name Fruit Store
  $entity = entity_create($entityType, array('type' => "store")); //bundle store
  $entityWrapper= entity_metadata_wrapper($entityType,$entity);  // create entity named "Victory"
  $entityWrapper->title->set($storeName);
  $entityWrapper->save();

  $store_id = $entityWrapper->id-> value();
  if($store_id != null){
    $reply= (array('status' => $status,'result' =>"Your store name ". $storeName. " Store id is ". $store_id));
  }else{
    $status = 0;
    $result = "Can't create store.";
    $reply = $reply= array('status' => $status,'result' => $result);
  }

  return $reply;

}