texts:
I've defined a view with the CCK and Views modules. I have two ways for printing the result:

As node content
As fields content

If I choose node content, I need to choose the view mode, which by default allows to choose between teaser, and rss (among others). How do I create a new custom view mode?

If I choose fields content, I see the following data, under theme information.

Display output: views-view.tpl.php, views-view--frontpage.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--frontpage--page.tpl.php
Style output: views-view-unformatted.tpl.php, views-view-unformatted--frontpage.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--page.tpl.php, views-view-unformatted--frontpage--page.tpl.php
Row style output: views-view-fields.tpl.php, views-view-fields--frontpage.tpl.php, views-view-fields--default.tpl.php, views-view-fields--default.tpl.php, views-view-fields--page.tpl.php, views-view-fields--frontpage--page.tpl.php

How do I create a custom theme for printing the result using the fields method?

Edit1: i create new view mode with Chapabu answer.(create a custom build mode you can use Entity view modes)

now i see this result in front page : Image Link

now, this print default content with default html/css.in act, i need custom content default for my theme. Example : i dont need to print date and author content! i need to print image(Thumbs), Summary and content type. in html/css i need to list content in

Or Any Div or Span ... (custom html/CSS) How To Edit This HTML/CSS?

I Think Fields Method Better For My result. This Is TRUE? If YES, How To?

EDIT2: Example Of my Need Conetnt And CSS/HTML:

I need to design this block(in act example: article promoted front page Or last Article Or Last News ...) for show in vertical news ticker using jquery and css. this jquery plugin need to custom html/css:

Latest News

news item 1

news item 2

news item 3

news item 4

news item 5

news item 6

news item 7

news item 8

now, I need a custom content and html/css design views block for this.


texts:
I'm new to Drupal coming from Wordpress, but I was able to put a site up&running. Theming is easy in WP, but I have not figured that out in D7.

I have a Content Type and the node-content output HTML as below. But I wanted to add custom html in-between section of the node-content:

    ....

    ....

I have searched online but I am not getting the basic instructions how to proceed. Presently I'm using a child theme of Zircon.

Any help?


texts: Our YMCA organization just redesigned a new website as a static site. The old site was in Drupal. The domain and hosting have already been transferred. I have access to the old site through FTP and am trying to find specific pages in order to pick up content. Can anyone tell me where the web pages are in the FTP directory? Thanks!


texts: Theme reply comments differently from node comments (Drupal 7)

texts:
I am using Drupal 7. I have a question/answer website, I want to theme reply comments differently from node comments. How can I apply a different css theme to differentiate node comments from comment replies? I checked the css class and both node comments and comment replies have the same css class. So how do I add different css class to comment replies and theme them differently?

Clarification: My question is just about theming comment replies differently, like removing borders around them or adding background to all comment replies, while node comments (answers) remain same.


texts: How to create content of content type which is a reference to a paragraph?

texts:
I want to add a content to content type (ct1) which has only one field (f1) which is a reference to a paragraph (p1), said paragraph has 4 fields: 3 numeric fields (1, 2, 3) and entity reference (er1) to taxonomy vocabulary, also i am supposed to check if term exists and if term exists then add content, otherwise throw a message and do not add content at all.

I'm Drupal 8 beginner and have no idea where to start with this task. Content creation for non-referenced content types is something I already can do but I do not know how to approach this particular situation. Please link me some guides or post example code.

I do not want to pre-fill paragraphs, it is more like "after-fill" when node is already created and i want to add paragraphs to it. Currently my code looks like this, this is more like pseudo-code, draft:

if (is_file($file) && is_readable($file) && in_array($_FILES['file']['type'], $mimes)) {
            $handle = fopen($file, 'r');

            $node = Node::create(array(
                        'type' => 'your_content_type',
                        'title' => date('l jS \of F Y h:i:s A'),
                        'langcode' => 'en',
                        'uid' => '1',
                        'status' => 1,
                        'field_fields' => array(),
            ));

            while (($data = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {

$termExists = taxonomy_term_load_multiple_by_name($field_taxonomy, 'taxonomy');
                if (isset($termExists)) {
                    $new_csvLine = Paragraph::create($csvLine);
                    $new_csvLine->save();
                    $node->paragraph_field_referenced->appendItem($new_csvLine);
                } else {
                    return print("Taxonomy term $field_taxonomy doesn't exist, import halted.");
                }
            }
            $node->save();

I'm working on csv import module and this is the only thing which left to me to complete. Loaded data I need to add as new node of ct1 and each line from csv needs to be a separate paragraph with 4 fields: 1, 2, 3 and er1. Now I need to somehow store this data in these fields. And yes, I need to do this all programmatically, in code. In other words: one csv import is a new node of ct1, every line of csv is new paragraph p1 and every paragraph has to store data from imported line from csv which is 4 fields.

How should I modify saving paragraphs part to make it work the way I described?

One more time about structure of all this:

content type ct1 -> field: f1, type: Entity reference revisions -> paragraph p1 -> fields: numeric 1, 2, 3; er1 type "Entity reference" (reference to taxonomy).


texts: Menu callback error : Undefined offset: 4 in _menu_translate()

texts:
I have created a menu item with form. Everything is working fine, but I am getting the following error message on the menu page.

  Notice: Undefined offset: 4 in _menu_translate() (line 777 of /home/sysop/old-server/heisenberg/includes/menu.inc).

The code I am using is the following.

/*
 *implements hook_menu
 */
function planet_extension_menu() {
 $items['admin/structure/feeds_admin'] = array(
'title' => 'Planet Extension',
'page callback' => 'main_table',
'access arguments' => array('access administration pages'),
'file' => 'planet_extension.admin.inc',
'type' => MENU_CALLBACK,
);

    $items['admin/structure/feeds_admin/manage/%/delete'] = array(
    'title' => 'Delete',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('delete_feed',4),
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'planet_extension.admin.inc',
    );

    $items['admin/structure/feeds_admin/manage/%/submit'] = array(
    'title' => 'Approve',
    'page callback' => 'submit_feed',
    'page arguments' => array(4),
    'access arguments' => array('access administration pages'),
    'type' => MENU_LOCAL_TASK,
    'file' => 'planet_extension.admin.inc',
    );
    return $items;
}

file : planet_extension.admin.inc

/**
 * Function main_table().
 */

function main_table() {

  $header = array(

    array('data' => t('ID'), 'field' => 'id', 'sort' => 'asc'),

    array('data' => t('Title of Feed'), 'field' => 'title'),

    array('data' => t('Feed URL'), 'field' => 'url'),

    array('data' => t('TYPE'), 'field' => 'category'),

    array('data' => t('Submitted By'), 'field' => 'email'),

    array('data' => t('Operations'), 'colspan' => 2),

  );

  $query = db_select('planet_extension', 'p');

  $query->fields('p', array('id','title','url','category','email'));

  $table_sort = $query->extend('TableSort') // Add table sort extender.

                      ->orderByHeader($header); // Add order by headers.

  $pager = $table_sort->extend('PagerDefault')

                      ->limit(20);

  $result = $pager->execute();

  $rows = array();

  foreach($result as $res){

    $rows[] = array($res->id, $res-> title, $res->url, $res->category, $res->email,(l(t('Approve'), 'admin/structure/feeds_admin/manage/' . $res->id . '/submit')),(l(t('Decline'), 'admin/structure/feeds_admin/manage/' . $res->id . '/delete')));
}
  // If rows are not empty theme and display the rows.

  $output = '';

  if (!empty($rows)) {

    $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'sort-table')));

    $output .= theme('pager');

  }

  else {

    $output .= t("No results found.");

  }

  return $output;

}

/*
 *Delete function
 */
function delete_feed($form,&$form_state,$variable) {
      $form['feed_id'] = array(
      '#type' => 'value',
      '#value' => $variable,
      );
    return confirm_form($form, t('Are you sure you want to delete this feed %variable ?',
    array('%variable' => $variable)), '/admin/structure/feeds_admin', 'Warning!! Would you like to continue with delete?', t('Delete'));
  }

/**
 * Delete given field
 */
function delete_feed_submit($form,&$form_state) {
    $id = $form_state['values']['feed_id'];
    $num_deleted = db_delete('planet_extension')
      ->condition('id', $id)
      ->execute();
    drupal_set_message(t('Feed %id successfully removed.', array('%id' => $id)));
    drupal_goto('/admin/structure/feeds_admin');
  }

/**
 *submit handler
 */
function submit_feed($variable) {
}


texts: How do I migrate while content is still created on production site?

texts:
I've written a bunch of migration script to migrate a site from Drupal 6 to Drupal 8.

On the development server I just ran a sample of each content type migration to test everything was OK while new content was still being created on production server on  a daily basis by redactors.

During the validation time by the project team (which could take several weeks), I'll run migration everyday on a fresh database dump from production server. During that time also, the project team will need to create specific new content (content that is not being migrated) for different purposes, like testing brand new content type or creating specific base pages needed by the new site templates.

Since the migration process keeps the original ID, I need to find a way for new content to be created without taking the node ID  from a node created on the production server. I’ve not been able to find any information about that case (which is quite a common case, I think) in the Drupal migration literature.

My first idea would be to change auto_increment value in relevant tables adding (let’s say) 100.000 to the current value, that way there wouldn’t be any collision between newly created content and the ones created the day before on production server. A brief look to the Drupal 8 database schema gave me the following tables and fields to alter:

file_managed => fid
node => nid
node_revision => vid
url_alias => pid

I am not sure the file managed fid field is kept during migration process; the same is true for the URL alias pid field since the link is made on the source field.

Do you think it would be enough to alter only the node and node_revision tables?

I also noticed a sequences table with a single value field with only one row. As far as I've read about this table, I've not really been able to figure out what it is used for. Maybe some of you can explain me and tell me if it's important regarding my issue.

Do you this is a correct approach? Are there other tables that could need to be altered?


texts:
I am trying to work out how to change the order of a flat list of comments in Drupal 7. It seems that comments are listed in chronological order with the oldest appearing at the top and newer ones appearing further down. Is there some way of reversing this order so that the most recent comments appear at the top and older ones at the bottom?

There is a module called sort_comments but there is no official release version (only dev).  The constraints of the project I am working on does not allow the use of non-production ready modules.

Project constraints also prevent the use of any custom modules.  Only allowed to customize at theme layer (e.g. can create custom theme).


texts: How to modify the D7 user login page html to remove the register and new password options for non-admins?

texts:
So, I'm maintaining a Drupal 7 site for which we recently switched the users over to SSO through a third-party OAuth provider. The implementation isn't fancy, but added a login link to what I assume is the standard login page with a tabs for "registration, login, and password reset."

What I would like to do is remove the menu options altogether for regular users, keeping just the OAuth login link and some additional text to inform users of new registration procedures. For admins, I would like to preserve the regular name and password based login options.

I am aware of the Tab Tamer module, but I'd like a little more granular control. I believe I need to approach this with hook targeting the login block, but I haven't found any examples on how to control what HTML in the block itself.

So, how to do modify the login block's HTML to remove the extra tabs for regular users, but preserve it for admin users?


texts: Unable to override ctools selection plugin class from my module

texts:
I am trying to add a custom ctools selection plugin for entity reference field as explained Here but it is never bing called but it is calling the parent class (EntityReference_SelectionHandler_Generic). Following is my code.

1) Implements hook_ctools_plugin_directory

function mymodule_ctools_plugin_directory($module, $plugin) {

   if ($module == 'entityreference') {
    dsm($plugin);
    return 'plugins/' . $plugin;
  }
 }

Than I created "plugins/selection" folder in my module directory following is the code I have in this file respectively-

1) Base.inc

$plugin = array(
'title' => t('Simple (with optional filter by bundle)'),
'class' => 'myClass',
'weight' => -100,
);

2) myClass.class.php

class myClass extends EntityReference_SelectionHandler_Generic{
public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
watchdog('getInstance', "print something for test ");
return new ExampleSelectionHandler($field, $instance, $entity_type,  $entity);

}
public function buildEntityFieldQuery($match = NULL, $match_operator =CONTAINS'){
}
}

But Myclass is never getting called instate it is calling the
 parent class(I have added a watchdog in that class).


texts: No 'read-more' to specific content type (eg page)

texts:
I've been making a content type page for my Drupal 7 website.
I'd like to see an option to disable the 'read more' and the 'link' to the /node/x in the content type customization.
I just want it to be displayed on the home 'as is'.

Is that possible?


texts: Change label of an exposed filter button in Views

texts: I have an exposed filter, and instead of having the button to activate it have an 'apply' label, I'd like to change it to something else. How can I do that?


texts: How to limit entity reference for new nodes only?

texts:
In an institutional website, there's an archive section listing all events (content type: Event). Each event is coordinated by an event manager (content type: Event Manager). CT Event has an entityreference field to select an Event Manager. The available options are defined by an entityreference view. This process works well so far.

Next, I needed to limit the available managers depending on their status. The status is a simple boolean field in the CT Event Manager defining if that manager is still active or retired. This limitation also works such as new events can't be assigned to retired managers.

However, if I want to edit an (old) event which was managed by a now retired manager, I can't save the node since the reference is not valid anymore.

My question is, how can I restrict the number of available managers for new events but still maintain the relations between old events and retired managers?


texts: Does Drupal have some kind of Structure system?

texts:
I looked all over but no result ...

I wonder if there is a Structure System for Drupal like: Spaces - Sections - Groups - Blocks - etc.

Where to use Spaces and may I have groups in spaces? The documentation is somehow messy, I'm lost. But there seems to be no good guides (like books) for a Drupal beginner.

Edit:

It takes time to find out what I need, where to install, etc.

Drupal 7 with Open Atrium 2 should be used for a Information an collaboration suite for a company. Login and all user-information and its roles comes over LDAP and active directory. So far I haven't got any problems.

But now I would like to build a user page:

I take a layout with two cols.
In the right column I have all the information read from active directory and user information.
In the left column there should be some different things.

But I would be very happy if I could understand how to build a user page with all the logged in user information automatically where user will be redirected after logged in.

I don't know how the hierarchy in Drupal works:

Do I need a space for all user who are logged in in Drupal?
And do I have groups inside a space or can I have groups without a space?

Edit:

So please don't mind if I give you this advice:

Not to explain all this modules and for what they are all for but to give specific projects and go through this from the first plane and road-map over the modules which we need till the building and setup.

So we can see it quit from the other side. Starting from a project going through drupal. And not from Drupal and for what it could be all for.

In my case I should build a company platform for all employees with there personal date from active directory (LDAP) and build up a personal page for each employee with his personal data with Drupal.


texts: Is it possible to trace a Drupal PHP session variable and if so, how?

texts: I'm having an issue with Drupal not caching pages and I think it's being caused by an active PHP session variable being set for anonymous users. I want to know if it's possible to quickly and/or easily find out which module/theme/random piece of code is setting the variable?


texts: Subtheme install settings in config but not showing

texts:
In a brand new site installation, I created a subtheme of the Bootstrap theme. In the subtheme (let's call "mytheme") config/install/mytheme.settings.yml file, I have the following settings.

settings:
  navbar_position: 'fixed-top'
  onelab_footer_type: Fat
  cdn_provider: custom
  cdn_custom_css: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css'
  cdn_custom_css_min: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'
  cdn_custom_js: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js'
  cdn_custom_js_min: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'

I have verified that the database config table shows these settings. However, these settings are not getting applied. I have cleared the cache and that doesn't seem to do anything either. So, if they are correctly in the config table, how do I get Drupal to apply them?


texts: Datatables Module not Sorting all Columns

texts:
I am using the DataTables module (https://www.drupal.org/project/datatables). The sorting option does not work for all columns, and I am not sure why. I'd like the ability to have all columns sortable as this is just in the DOM, shouldn't that be a possibility?

For example:

Columns that do sort: Content Text, Terms, Dates...
Columns that do not sort: View Conditional (if this then that results)

Here is 2 of the table columns html output:

Title

There is a checkbox in the views datatable settings next the "TITLE" column above...

There is not checkbox enabling sorting on the column below (views conditional):

BLM

EDIT:
This might be due to the sType (https://datatables.net/development/sorting)

In the DataTables module, changing line 298 from FALSE to TRUE allows all sorting... I am sure there is a reason not to allow this, but not sure why. Investigating sType more to apply another elseif on string or whatever type is being produced by the views conditional...

Line 298:

if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) {
        $column_options['bSortable'] = TRUE; //changed from FALSE
      }

Line 301:  //checks what sType the data is:

else {
        // Attempt to autodetect the type of field in order to handle sorting
        // correctly.
        if (drupal_strlen($fields[$field]->last_render) != drupal_strlen(strip_tags($fields[$field]->last_render))) {
          $column_options['sType'] = 'html';
        }
        elseif (is_numeric($fields[$field]->last_render)) {
          $column_options['sType'] = 'numeric';
        }
        elseif ($fields[$field] instanceof views_handler_field_date) {
          $column_options['sType'] = 'date';
        }
        $column_options['bSortable'] = TRUE;

STRING is not one of the options in here. Though the documentation says it could be: http://legacy.datatables.net/usage/columns#sType

I attempted to add it like so real quick with no results:

elseif (drupal_strlen($fields[$field]->last_render) != drupal_strlen(strip_tags($fields[$field]->last_render))) {
      $column_options['sType'] = 'string';
    }


texts: Authenticated user can't download audio, even though has permission

texts:
I have an embedded audio player using HTML5 which is displayed on my guitar lessons site. I have a private file system set up. When I am logged in I can play the audio files fine. If I register as a regular user and go to the same page, it shows the embedded audio player, but no audio plays. This is because drupal is not serving the audio via the media module because for some reason drupal thinks the user is not authorized, even though I specifically set up the roles.

Any ideas how to troubleshoot this?

Thanks!


texts: Why doesn't the field table in the Drupal database use entity_id as a primary key?

texts:
I'm working on trying to optimize a View SQL query and I noticed that the query being executed is using a join on a the entity_id field of a field table. I noticed that for some reason unbeknownst to me the entity_id field is not a primary key. The delta field is a primary key.

Can anyone enlighten me as to why this is the case? Can I safely tag entity_id as a primary key without incurring a wrath of unintended consequences? Thank you for your help.


texts:
I have created a form, though I'm having an issue with using the prefix and suffix to place items into rows rather than the list they appear as standard.

For example I have these 3 form elements, how would I go from having them appear as standard on a new line, to on the same line. Normally I would just chuck them into a table and place each one in a different column. I have read that I should possibly use floats?

I have tried  '#prefix' => '
',

'#suffix' => '

' , But this seems to affect the navigation on the left and shuffle it down.

$form['orange'] = array(
    '#type'=>'select',
    '#title' => t('Select Orange'),
    '#options' => $Orange,
    '#multiple' => false,
    '#prefix' => ,
    '#suffix' => ,
    '#attributes'=>array('size'=>0),
    '#required' => TRUE,
);
$form['apple'] = array(
    '#type'=>'select',
    '#title' => t('Select apple'),
    '#options' => $apple,
    '#multiple' => false,
    '#prefix' => ,
    '#suffix' => ,
    '#attributes'=>array('size'=>0),
    '#required' => TRUE,
);
$form['strawberry'] = array(
    '#type'=>'select',
    '#title' => t('Select strawberry'),
    '#options' => $strawberry,
    '#multiple' => false,
    '#prefix' => ,
    '#suffix' => ,
    '#attributes'=>array('size'=>0),
    '#required' => TRUE,

);

I cannot answer for 7 hours but here it is:

The solution was to close the DIV, I had forgotten, which meant the styling was effecting the whole page.

     '#prefix' => '
',
    '#suffix' => '

',
    [Useful link to aligning form elements horizontally][1]


texts:
I have 2 content types which are imported via feeds; One is "user" with a cck field referencing its primary key: user.id

The second is "time_entry", which has a cck field for the fk reference to user id: time_entry.user_id

Now that they are coming into drupal, i am trying to create a view which would have:
time_entry.id, time_entry.user_id, and user.fname, user.lname, which are in the user nodes.

I tried a few different things; I am not too familiar with d7 so entities, bundles, the relations module, etc. are confusing me. I got tangled up trying to even create a php field in views which would get the nid of the user referenced in the time entry table and load that user.node. Any help would be greatly appreciated.


texts:
I am trying to use hook_node_access to change some permissions when viewing a node type.  The problem is that even when I call it in my module, it doesn't work.

function MyModule_node_access($node,$op,$account) {
  die("it works!");
}

I can 100% confirm that other hooks in the same module are working fine.  I have disabled and reenabled the module.  I have cleared all cache.  I can confirm that my test user is not uid = 1, and it does not have the "Bypass content access control" permission.  So why is hook_node_access not working for me?  Does it not work by itself?


texts: Issue in converting a HTML Link to Drupal Link using l() function

texts:
I have created a HTML anchor link. Now i need to convert this link to Drupal's link using l() function. But i am not getting what i want. I am new to this Drupal environment.

HTML Link :

'.START_QTIQUIZ.'

What i have tried is,

l('Start QTI Quiz', '#', array('','onclick' => "loadQtiPlayer('.$targetPath.','.$targetWindowHeight.','.$targetWindowWidth.')"));

This is not working. I am using Drupal 6.14.

Can anyone point out where is the issue?


texts:
I have a client CSV file that has Stores in the first column and Tasks in the cells across the header row. In each Task column, there is either an X, R, or blank (NULL). This is supposed to identify whether the Task is assigned to the Store in the first column, or a "rollover" task, or the task is not assigned to the store. Admittedly, this is a strange CSV format, but I am stuck with it.

The Tasks and Stores are already migrated. I am having a hard time trying to figure out how to tell my migrate class to iterate through the Tasks in the header row, and assign them (or not) to the Store(s) in the first column.

Any directions at this point is extremely appreciated.

See the image attached for reference.


texts: How to add a link to the CSV download to my module page, for a report created with Forena?

texts:
How do I add a link to the CSV download created by the Forena module to my module page?

Do I just copy the link in 'inspect element' and put that in my $output variable that I return on the recommendations page?


texts: how to post an article by jquery using REST service of Drupal?

texts:
i want to create an article by rest services of drupal ?
as given in the documentation on Drupal Post docs link

but it gives an error Reference error : Drupal is not defined

in the following line of code jQuery.get(Drupal.url('rest/session/token'))

here is my code based on docs

function getCsrfToken(callback) {
  jQuery.get(Drupal.url('rest/session/token'))
    .done(function (data) {
      var csrfToken = data;
      callback(csrfToken);
    });
}

function postNode(csrfToken, node) {
  jQuery.ajax({
    url: 'http://localhost/dr/entity/node?_format=hal_json',
    method: 'POST',
    headers: {
      'Content-Type': 'application/hal+json',
      'X-CSRF-Token': csrfToken

    },
    data: JSON.stringify(node),
    success: function (node) {
      console.log(node);
    }
  });
}

var newNode = {
  _links: {
    type: {
      href: 'http://localhost/dr/rest/type/node/article'
    }
  },
  type: {
    target_id: 'article'
  },
  title: {
    value: 'Example node title'
  }
};

getCsrfToken(function (csrfToken) {
  postNode(csrfToken, newNode);
});


texts: Additional custom Omega breakpoint CSS files

texts:
I'm looking to add my own custom wide, normal and narrow CSS files additional to the ones Omega will already look for. I'm aware that by default it'll already search for

YOURSUBTHEME-alpha-default-wide.css

etc

But I was wondering is there anywhere/anything I can set that will allow me to ask it to look for another set of wide, normal and narrow CSS files?

eg: custom-alpha-default-wide.css

And have these automatically be included within the default breakpoint configuration?

I know that I could manually declare all the stylesheets in the .info file, and then copy the media queries into each applicable CSS sheet, however I'm interested to know if it can be done by default


texts:
I'm using jquery mobile and phonegap for a mobile app. I have uploaded an image file and received the fid but the subsequent request to create a node and attach the fid fails. The node is created although the image field is not filled in with the fid. Also the uploaded image in ../sites/default/files doesnot have dimensions(height and width).

Post the image:

var filedata = {
        "file":{
          "file":imageObj['base64s'][0],
          "filename":imageObj['names'][0],
          "filepath":"public://"+imageObj['names'][0],
          "mimeType":"image/"+imageObj['names'][0].split(".")[1],
          "filesize":  imageObj['sizes'][0]

        }
    };

$.ajax({
    url: localStorage.appurl+"/api/file.json",
    type: 'post',
    data: filedata,
    dataType: 'json',
    cache: false,
    headers: {
      'X-CSRF-Token': localStorage.usertoken
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      console.log('error '+errorThrown);
      d.reject(errorThrown);
    },
    success: function (data) {
      d.resolve(data);

    }
  });

Create the node:

$.ajax({
url: localStorage.appurl+"/api/node.json",
type: 'post',
data: "node[title]=new node&node[type]=ftritem&node[field_ftritem_images[und][0][fid]=7895",
dataType: 'json',
heders: {
  'X-CSRF-Token': localStorage.usertoken
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
  console.log('error '+errorThrown);

},
success: function (data) {
console.log("Node created");

}
});

Im getting this error:

Notice: Undefined offset: 0 in image_field_widget_form() (line 358 of /var/www/dt11/modules/image/image.field.inc).

Notice: Undefined offset: 0 in file_field_widget_form() (line 526 of /var/www/dt11/modules/file/file.field.inc).

Has anyone faced this before ? Any suggestions are highly appreaciated.


texts: D7- I am receiving an obscene amount of spam user sign ups - how can I fix this?

texts:
My site is getting a ridiculous amount of spam user sign ups every day. The second I enable 'allow anonymous users to create accounts', 10 spam accounts exist inside of the first 20 seconds of enabling. This seems completely insane. How do I stop this from happening? I'd also prefer not to use the Captcha method, as it does very little from my experience.

So far, I've tried: Honeypot, captcha, ReCaptcha, Antibot, Badbot... And none seem to fix the problem.


texts: How do I alter image field code without hacking core?

texts:
I need to change the style of the title in image field to be a text area rather than a text field. I can achieve this by hacking core in the following way:

image.field.inc line 410

$element['title'] = array(
    '#type' => 'textarea',
    '#title' => t('Title'),
    '#default_value' => isset($item['title']) ? $item['title'] : '',
    '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'),
    '#maxlength' => variable_get('image_title_length', 500),
    '#weight' => -1,
    '#access' => (bool) $item['fid'] && $settings['title_field'],
  );

// Change '#type' => 'textarea'  to '#type' => 'textfield'

I don't though, want to hack core.
How can I create a preprocess function to allow me to do this via my template.php.


texts: Display all values in a facet block even when a value is selected

texts:
I have facet block which looks like:

Categories:
[ ] Category 1
[ ] Category 2
[ ] Category 3
[ ] Category 4

Categories are represented with the ss_category field (single string field). When a category is selected, all the other categories disappear, which makes the block looks like:

Categories:
[X] Category 3

I need all the other categories to remain displayed even when there is an active category, so that the user doesn't have to unclick the active category first then click another one. In other words the block should look like:

Categories:
[ ] Category 1
[ ] Category 2
[X] Category 3
[ ] Category 4

How can I achieve this behavior in Drupal 6?


texts: How do I translate hard coded words in twig file

texts:
Is there a way to translate hard coded words in twig when selecting a language from the language dropdown? I have used the |t ({{ myword|t }}) function but it doesn't seem to be work when selecting another language.

Is there a way to do this?


texts: Custom login page by Overriding user-login.tpl.php

texts:
This is the code for my templates.php.

<?php
    function operationscheck_theme_theme() {
    $items = array();
    $items['user_login'] = array(
   'render element' => 'form',
   'path' => drupal_get_path('theme', 'operationscheck_theme') . '/templates',
   'template' => 'user-login',
    'preprocess functions' => array(
   'operationscheck_theme_preprocess_user_login'
   ),
);
    $items['user_pass'] = array(
   'render element' => 'form',
   'path' => drupal_get_path('theme', 'operationscheck_theme') . '/templates',
   'template' => 'user-pass',
   'preprocess functions' => array(
   'operationscheck_theme_preprocess_user_pass'
  ),
);
 $items['user_register_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'operationscheck_theme') . '/templates',
'template' => 'user-register-form',
'preprocess functions' => array(
'operationscheck_theme_preprocess_user_register_form'
 ),
);
return $items;
}
?>

<?php
   function operationscheck_theme_preprocess_user_login(&$vars) {
      $vars['intro_text'] = t('This is my awesome login form');
    }

   function operationscheck_theme_preprocess_user_login(&$vars) {
     $vars['intro_text'] = t('This is my awesome pass form');
   }

function operationscheck_theme_preprocess_user_register_form(&$vars) {
    $vars['intro_text'] = t('This is my super awesome reg form');
   }

 function operationscheck_theme_theme(&$existing, $type, $theme, $path) {
  $hooks = operationscheck_theme_theme($existing, $type, $theme, $path)
  $hooks['user_login_block'] = array(
 'template' => 'user-login',
 'arguments' => array('form' => NULL)
 );

// @TODO: Needs detailed comments. Patches welcome!
return $hooks;
}

function operationscheck_theme_preprocess_user_login_block(&$variables) {
  $variables['intro_text'] = t('This is my awesome login formX');
  $variables['rendered'] = drupal_render($variables['form']);
}
 ?>

This  is the code for user-login.tpl.php.

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

 <?php print drupal_render_children($form) ?>

But when I am flushing the cache, it is still returning the format of old page.tpl.php rather than the simple user login form page. Every file is in its correct place.

Do I have to write an if condition to redirect to this user-login.tpl.php?


texts: Override webform confirmation and email message if token data is missing

texts:
I have a webform in which I am using tokens to display data in the form submission confirmation and in a sent email.

Some of this data is pulled from a web service, and sometimes no data is returned by the API. This can result in the confirmation and email not being populated with data.

Form submission confirmation:

REPORT COMPLETE
Thank you for your report, which will be forwarded to: .
If you need to contact us about your report, you can do so at:
A confirmation email has been sent to: someone@example.com.

Email:

Thank you for reporting a problem at: Acme Inc.
Your report has been forwarded to .
Please do not reply to this email.

In this event, I'd like to override the confirmation and email message with a different message (that does not rely on data being available).

What is the best way to achieve this? Use hook_form_alter to test for missing values and then override the webform's #confirmation element? And how to override the email message?

Thanks.


texts: How to make the commerce_kickstart distribution fully multilingual?

texts:
I just downloaded and installed the Commerce Kickstart 7.x-2.0-rc1 distribution.

Now I'm in the process of making it fully multilingual. I have no problem with the products.

But I don't know how the make multilingual the Search blocks (Facet) which you can see in the left sidebar in this demo. I already enable the taxonomy_translation module, then I'm able to translate the terms used by the facet. But if I switch languages the facet shows all terms regardless the language the term is in. I also enabled the facetapi_i18n but I see no changes at all.

Any suggestions about how to do this?


texts:
I am using Drupal 8.4.2. I have created my content type and I have an image field in the form fields.

The image upload field is showing on the page but, the upload button is not showing. If I inspect the element, I can see that 'js-hide' class is added for the upload button. I think that is coming from processManagedFile() in core/modules/file/src/Element/ManagedFile.php file.

$element['upload_button'] = [
  '#name' => $parents_prefix . '_upload_button',
  '#type' => 'submit',
  '#value' => t('Upload'),
  '#attributes' => ['class' => ['js-hide']], // Hide class added from here.
  '#validate' => [],
  '#submit' => ['file_managed_file_submit'],
  '#limit_validation_errors' => [$element['#parents']],
  '#ajax' => $ajax_settings,
  '#weight' => -5,
];

It means upload button is hidden in Drupal 8 by default, does it.

If so, after selecting an image, the upload should happen automatically. That is also not happening?

What might be the problem? Is there any setting I need to enable? I would like to have either upload button or the image should be uploaded automatically after selecting an image.

Note

I am having this form for administrator users. Any change must be done in theme, in the specific in the Seven theme.

Update

After selecting an image no ajax request is sent. Do I need to configure ajax upload somewhere in the drupal admin? But after submitting the form, image getting uploaded but showing the alert as "Alternative Text" is mandatory(which was not displayed when uploading the image)


texts: How to add subquery in db_select using orderBy?

texts:
In my project, I want do display users information(fields) by user role. I created a view for users, and I used a subquery for sorting user field by ascending order with the  following query.

SELECT field_level_of_work_value, FROM `field_data_field_level_of_work` ORDER BY FIELD(field_level_of_work_value, '0','1','2','3'), field_level_of_work_value ASC

I don't know how to use this query in hook_view_query_alter(). This is the code I am using.

function user_worklevel_sorting_views_query_alter(&$view, &$query) {
  if ($view->name=="attorney_workload") {
    $sub_query = db_select('node','node');
    $sub_query->addField('field_data_field_level_of_work', 'value','field_level_of_work_value');
    $sub_query->addField('users', 'uid','uid');

    $sub_query->leftJoin('field_data_field_level_of_work', 'field_data_field_level_of_work', 'field_data_field_level_of_work.entity_id=users.uid');
    $sub_query->orderBy('wl.field_level_of_work_value' , '0')
      ->orderBy('wl.field_level_of_work_value' ,'1')
      ->orderBy('wl.field_level_of_work_value' , '2')
      ->orderBy('wl.field_level_of_work_value' ,'3')
      ->orderBy('wl.field_level_of_work_value','ASC');

    $join = new views_join();
    $join->definition = array('table formula' => $sub_query, 'left_field' => 'uid', 'field' => 'uid', 'left_table' => 'node');
    $join->left_table = 'users';// or wathever table you want to join with
    $join->field = 'uid';
    $join->left_field = 'uid';// or wathever column you want to join with
    $join->type = 'LEFT';// if you want another join type play with this value

    // Do the actual join
    $query->table_queue['field_data_field_level_of_work'] = array(
      'alias' => 'field_data_field_level_of_work',// I believe this is optional
      'table' => $sub_query,
      'relationship' => 'node',
      'join' => $join,
    );
  }
}

I don't want to display null values in "Level of work" column and it would be display like my custom orderBy ASC.


texts: Whats the best method for displaying different page layouts for a node based on taxonomy?

texts:
I am building a product site which should use a slightly different page layout for different types of products, depending on what product category they are.

All products are of the same node type. They are categorized based on selected taxonomy terms. The reason I did this instead of creating a different node type for each product category is because some products may exist in multiple categories.

My understanding is that panels relies on the URL structure for determining context. I'm listing all products under ../products/[title] so I dont think that will work. The only way to know the product category is to check the value of a CCK field on that product.

It seems there are many ways to skin a cat in Drupal but I'm unable to figure out what method will allow me to do what Im trying to do.

Any advice/help would be appreciated.


texts: Move fields from additional settings to field_group on node edit forms

texts:
I try to move some settings, for example the comment or menu settings, from the "additional settings" to my own field group created with the Field Group module.

As there is no way to access the fields under additional settings via the gui I thought about moving them via a form_alter hook, but with no success.

Update

Here is the code i used in a custom module to (unsuccessfully) move a field:

function form_tweaks_form_alter(&$form, &$form_state, $form_id) {
  if(isset($form['#node_edit_form']) && $form['#node_edit_form']) {
    // Adding the comment settings to my field group
    $form['#group_children']['comment_settings'] = 'group_sidebar_tab4';

My module's weight is lower then the weight of the field group module and when I use the above code on other fields added to the content type, for example an image field, it works just fine.

Update 2

Just to make sure, I am talking about node forms. I want to move certain elements that resist in the "additional settings" vertical-tab-group to other groups.


texts:
I'm trying to script something up to completely automate synching sites around, and I want to be able to get a value out of the site alias which is an array.

If I do a

root@dev-drupal-www:~# drush sa @www.mysite.org.au
$aliases['www.mysite.org.au'] = array (
  'remote-host' => 'prod-drupalsites',
  'remote-user' => 'root',
  'uri' => 'www.mysite.org.au',
  'root' => '/vhost/www.mysite.org.au',
  'path-aliases' =>
  array (
    '%site' => 'sites/default/',
    '%files' => 'sites/default/files',
    '%dump' => '/tmp/drush_www.mysite.org.au.sql',
  ),
);
root@dev-drupal-www:~# drush sa @www.mysite.org.au --component="path-aliases"
Array
root@dev-drupal-www:~# drush sa @www.mysite.org.au --component="path-aliases:%dump"
The element path-aliases:%dump was not found in the alias record for @www.mysite.org.au.                                                                                [error]
root@dev-drupal-www:~#

How can I extract an item from the path-aliases?

Thanks!


texts: Programmatically rearrange order of entity reference list on node

texts:
My content type has a node reference field that allows users to enter an unlimited amount of nodes in. I need to programmatically change what comes first in this list.

Using the code below I'm able to obtain the data from the field.

$node = \Drupal::entityTypeManager()->getStorage('node')->load($function);
$focus = $node->field_focus_area->getValue();

And it produces:

array(2) {
  [0]=>
  array(1) {
    ["target_id"]=>
    string(2) "31"
  }
  [1]=>
  array(1) {
    ["target_id"]=>
    string(3) "161"
  }
}

In order to rearrange it I tried doing

$newOrder[0] = ['target_id'=> 161];
$newOrder[1] = ['target_id'=> 31];

$focus->field_focus_area->rekey($newOrder);

But it was then when I realized that rekey was a protected function so I could use it. How would I programmatically rearrange the deltas (if that's what you'd call it) of an entity reference field programmatically?


texts: Does Drupal keep timestamps of every time node is updated

texts: I'm wondering whether Drupal keep tracks (keep timestamps) of every time a node is updated (not just the last updated). If it does, how could I access this in the front end?


texts: Check if user_picture value is changed or compare with old value

texts:
I am trying to find if a field value is changed or updated by the user. But there are blockers.

function custom_form_process_user_picture(&$form, FormStateInterface &$form_state) {
  $file_name = "";
  $username = "";
  $fid_0 = NULL;
  $user_picture = $form['user_picture'];
  $uid = $form_state->getValue('uid');
  if ($form_state->hasFileElement() && $form_state->hasValue('user_picture')) {
    $username = $form_state->getValue('field_name')[0]['value'];
    $fid_0 = isset($form_state->getValue('user_picture')[0]['fids'][0]) ? $form_state->getValue('user_picture')[0]['fids'][0] : $fid_0;
    /*
      $changed = $form_state->get('user_picture')->getValue() == $form_state->getValue('user_picture');
      //This is not working as $form_state->get() returns null.
    */
    /*
      $changed = $form_state->get('user_picture')->getValue() == $form['user_picture']['#default_value'];
      //This is not working as $form['user_picture']['#default_value'] is null.
    */
      if($changed) {
        // Proceed to rename the file.
      }
    }

What piece of the code I am doing wrong? Searched drupal and stackoverflow for the changed/updated/dirty field value. Also tried with $form_state->getFormObject()->getEntity() and got no clue if there is old value stored or not.
FormStateInterface seems to have no method to find out altered/modified values.


texts: Print current logged in user without link

texts:
I'd like to print out the name of the user that is currently logged in, but not have it be a link.

Currently I have:

<?php print l($user_name, 'user/' . $user->uid);?>

But this prints out a link to their user profile. Any way to make their name just text and not a link?


texts: Does Multiversion module need content migration if enabled on running site?

texts: I have Drupal 8 setup with lot of content in it. When I enable Multiversion module all the content gets disappeared. Do I have to migrate the content after installing Multiversion? Why does it deletes the content?


texts: Views - offset when displaying all results?

texts: In a view, either set to "display all results" or "specified number of results" and set to 0, I cannot seem to be able to use the "offset". On the other hand, if I set a number of items, say 100, I can use the offset just fine (I want to hide the first item from the result set). Any ideas on what could be causing this?


texts: Programmatically upload a file to a custom file field

texts:
I am trying to update a node and programmatically upload a file.

$nid = 45343;
$node = node_load($nid);

$image_url = 'http://test.com/misc/druplicon.png';
$file = system_retrieve_file($image_url, file_default_scheme().'://products_images/'.basename($image_url), TRUE);

// We save the file to the root of the files directory.
// $file = file_copy($file, 'public://');

$node->field_custom_file[LANGUAGE_NONE][0] = (array)$file;
node_save($node);

Somehow, it's not working at all. Do I need to add more functions to it?


texts: How to extend a module hook from another module?

texts:
I want to be able to clone/replicate a node from one language to another on click of a button using a custom module. Basically we have a view which displays all nodes in the system and under the "operations" column, we have Edit, Delete, Clone.

On click of the Clone button, I want to replicate the node (keeping the same exact data values as is except for the language field) to other languages.

I have installed the node_clone and replicate modules to help me, but I am struggling to see how I can create a custom module that can call the hooks in those contrib modules in such a way that I can save the node in different languages automatically instead of click on the "Translate" tab and manually doing it one by one.

I have tried calling the clone_node_save from the Node clone module from my custom module, but that does not work.

How can I extend a module hook in a custom module?


texts: Character counter for textarea in webform

texts: I am relatively new to drupal. I have webform module and webform validation module installed. I was able to limit the number of characters in webform textarea using webform validation. However, this module does not support character counter for the fields. I have looked at this solution http://drupal.org/node/1459650#comment-5699952 which using maxlength module, but it is very unclear . I am planning to write a module implement hook_webform_component_info_alter(&$components) to add jquery or javascript on to the webform textarea field. Is this a correct way. If so or If not how would i do that?


texts:
I have a multilingual website. The breadcrumbs are also multilingual and that works fine. However, I am somehow not able to get the breadcrumbs of the checkout pages translated too. The checkout pages themselves are translated, but I don't see that in the breadcrumbs. I have tried string overrides, but that didn't work either.

Does anyone have an idea how to solve this?


texts: How to give different permissions for different domains

texts:
I am using the domain access module in Drupal 7.

I want one domain to be accessible by anonymous users and the other domain to be accessible only by authenticated users.

How can I give the "view published content" permission to anonymous users for only one domain.


texts: How to get author_picture URL from a template?

texts:
How to get author_picture URL from a template ? I know that I can use {{ author_picture }} to display the picture; however, all I need is the URL and not the picture. I'm trying to get this URL from the template node--article.html.twig

Here is a similar question but this is different because is base on the field_image. Getting the image URL from a field_image on a node and all I'm trying to get is the author picture.


texts:
hello to the drupal pro,

I have over 50 disable modules listed on my module list page but only one appear under the uninstall tab. (Toolbar module)

I discovered that when i wanted to uninstall a module for the first time

Any idea why?

PS: i'm running my drupal site on the localhost using WAMP server


texts: Change default upload file path (sites/default/files) for a content type

texts:
Drupal default file upload path is sites/default/files.
How this default path change for a particular content type?
Consider an example..
My drupal installation directory is ../drupal then all the files
uploaded in inside location ../drupal/sites/default/files
I have created a content type "test", I would like upload all test content file in the location
../drupal/test


texts: What is the easiest way to export Field settings into a .install file?

texts:
I have a bunch of custom fields on a custom content type. I'm trying to make my module create these fields and remove them on install and uninstall respectively.

There was a previous question and answer on this: https://drupal.stackexchange.com/a/629/2384 However, it is not adequate. The code was not completely presented. The author used node_type_delete() without deleting the content first, and that allegedly leads to trouble later down the line. So I checked the node_example.module as per recommendations on Drupal.org, node_example.install etc. These files provide insight into the structure of the module, but do not discuss all the varieties of fields (like file, taxonomy, etc.,) and how they are to be structured in the .install array.

I have tried to export my content type using Features, and it does produce an array. But the syntax is radically different from what was presented in the example, and I was lost in the arrays and sub-sub arrays.

Is there a simple guide somewhere, that can help me convert my content type into an array specification I can smoothly fit into my hook_install declarations?


texts: How do I redirect access denied to front page?

texts:
I asked this a while back and got nowhere. Sorry for the repost but it needs to be resolved (somehow).

If a visitor types in a URL for which they are not authorized, I do -not- want them to see a 403 page. I just want them to be redirected to the site home page.

I entered...

<front>

...in the 403 field under admin/config/system/site-information but that apparently does nothing. We're using LoginToboggan which (I think) overrides this.

How can I do this?

TIA,


texts: Organic group request membership email issue

texts:
Can anyone recommend how I can get an emailing system working for when users request to join an organic group on my system?

Right now, my users click the "request membership" links and then provides a message and click a join button. But then nothing else happens.

Neighter the user nor the admin get any email confirmation.

Please help.


texts: Is it necessary to cache data generated by menu_tree_all_data and menu_tree_output called in preprocess_page

texts:
In hook_preprocess_page in my template.php I'm using this code:

// Get the entire main menu tree
$main_menu_tree = menu_tree_all_data('main-menu');
// Add the rendered output to the $mobile_menu variable
$mobile_menu = menu_tree_output($main_menu_tree);

To generate the entire menu tree of main menu

Thinking that preprocess_page is executed on every page (please confirm this if it's true) I cached the above code in this way:

$cid = 'ctm_mobile_menu:' . $vars['language']->language;
$mobile_menu = &drupal_static(__FUNCTION__);
if (!isset($mobile_menu)) {
  if ($cache = cache_get($cid)) {
    $mobile_menu = $cache->data;
  }
  else {
    // Get the entire main menu tree
    $main_menu_tree = menu_tree_all_data('main-menu');
    // Add the rendered output to the $mobile_menu variable
    $mobile_menu = menu_tree_output($main_menu_tree);
    cache_set($cid, $mobile_menu, 'cache');
  }
}

But my doubt now is: is caching effectively necessary here? or menu_tree_all_data and menu_tree_output already does caching by itself?

My concern is that I'm caching already cached data and this can generate bad loops.. I don't know please help me


texts:
How can I (either with a module or programmatically) limit the number of values for multiple fields? For example, the user can add only a single value for field A OR field B OR field C.
The total maximum number of values behind all fields can't exceed 1.


texts: Getting Views Rows Data in Custom Module

texts:
I dont know if im over thinking this but im not making much progress with my function. I am trying to get the values from views rows in my modules for example if I was to use $row->field_name inside of a view.tpl file then it would show the output of that row, except I am trying to do it in a module. Ultimately I am trying to render the image style of the 1st image that loads from the view. This is what I have so far.

function custom_module_views_pre_render(&$vars){
    if($vars->name == 'front_page'){
        $vars->result[0]->field_field_image[0]['rendered']['#image_style'] = 'front-page-scroll';
    }
}

Update 1: I've attached a image of what I am trying to do seeing how when I use preview(); execute(); or render(); it makes the function stop working, actually it makes the whole site stop working. If I cant get to the field view result count which counts the the number a current node is then I can say if($views->view_result_counter == 1) then render just that node. The function would look something like this.

function custom_module_views_pre_render(&$vars){
    $views = views_get_current_view('front_page', 'page');
    if($views->name == 'front_page'){
         if($views->views_result_counter == 1){
            $vars->result[0]->field_field_image[0]['rendered']['#image_style'] = 'front-page-scroll';
         }
    }
}

Here is a image of what I am trying to do, Now I currently have the 1st image rendering as I want it to but it keeps rendering the image of each page instead of it rendering one time only.

Now as for my view is there any reason why execute or render wouldnt work? this is what my view looks like.

any suggestions?


texts: Custom line item fields in Create an Order page

texts:
I have successfully added the custom line item fields in the cart through Views and modified the new total using a hook, but how do I do the same thing in Create an Order page (admin/commerce/orders/add)?

The custom line item field was added in
admin/commerce/config/line-items/product/fields
I'm using inline
entity form and I can see the custom field, but the custom field is
not visible in line items table.


texts: What is the best way to add my custom PHP functionality to a Drupal homepage?

texts:
I have a custom PHP application I've written that accesses an API via SOAP, processes some data from the web service, and outputs an HTML table with the results. I'm an experienced WordPress developer and have been able to add my application's functionality into WP sites by creating A custom theme and adding the PHP/HTML code directly into the homepage template.

I now have someone asking me to add this to a Drupal site (v 7.34) - the end goal is to have the HTML table that the application outputs display on the Drupal site's homepage. The site is running the Porto 2.0.3 theme if that makes a difference.

I am pretty new to Drupal and I'd like to know what the best way to accomplish this is. I looked into adding PHP directly into a block, but my application consists of 2 files (an API class and the actual code that produces the output) so I'm not sure that's a good option.

My searching leads me to believe that creating a custom module is the best path (especially since I don't want future updates to the Porto theme to break the functionality) but I'd like to confirm that before I wander down that path. Or is is better/easier to override the homepage template to add my code?

I'd really appreciate some advice from experienced devs - not looking to be spoon fed and perfectly willing to do my own research, but a helping hand from people familiar with this system would be a huge help.


texts:
I am using calender module and going to set up a site. The problem is that the default time on the site can not be set correctly through admin/settings/date-time to reflect the local time.

The values in the drop-down menu turn out to be either half an hour late or early. Also, for the reason of backup synchronisations I can not tweak the server's time.  So I am wondering if there a way to cope with this issue?

Thanks


texts: How to show a random image from unlimited image field using Views?

texts:
There is an content type called "imagenode". This content type contains title, body and one image field (unlimited images can be uploaded/attached).

Now exactly one node from imagenode is created: 20 Images are attached/uploaded.

Question:
How can I create a views block that displays one random image out of these images attached to this one node from type imagenode?

I can create a view with fields and show one image and I can set an offset in order to display onother image. But there seems to be no way to display one random from all attached images.

How can this be solved in Drupal 8?


texts: How can I configure canonical URLs to point back to the original node from its related comment/reply pages?

texts:
I have a Drupal 7 site where comments are turned on. However, all the comment/reply pages are reproducing the content from the main article. In addition, all the canonical urls in the source code point to the address for that comment/reply page.

Here is an example

Node:  http://seesapporo.com/dining/soup-curry-yellow

comment/reply above article: http://seesapporo.com/comment/reply/1315

How can I configure the canonicals for comment/reply pages to point back to their node they originate from?


texts: Is there an option for radio buttons with Facet API + Search API (database)?

texts:
I am using several check box facets.  Some of the facets allow me to use check boxes for multiple values.  There is one facet, however, of taxonomy terms for which I want to only allow a single choice; and per the client's spec, it must be a radio button.

I can't seem to figure out how to do that.  I installed the Facet API Select sandbox module, but that just gives me a drop-down box (and what sucks is when I make a selection, I stay locked on that one and don't get the other choices back).  I installed Facet Bonus pack, but the select option from that keeps giving me a PHP error.

I am using Views on top of Search API database.  It may be that I am missing something conceptually, as I am still getting my arms around Facets.

If there isn't an option for radio buttons, then I will contribute a patch to the Facet API Select sandbox module (if it is feasible).  This is for a paid client, so this is happening.

EDIT:  I need to clarify my biz case of what I'm trying to do.  I have 3 facets with check boxes of multiple items to filter down.  On a fourth facet, I provide a list of filters, but need to allow one item to be selected.  So, my choices look like:

Facet 1:  Type of product
   - phone
   - tablet
   - tv

This would filter down the main product category, i.e., single select option the client wants a radio button for.

Facet 2:  Color
   - red
   - blue
   - green
   - black

Facet 3, Facet 4, etc., would be like Facet 2, where the user can select multiple check boxes for the various sub categories.

These facet categories are taxonomy terms, if that matters.


texts:
I have a custom field/widget that has a format view function that is highly resource intensive.  I currently am caching the result using cache_set()/cache_get() inside the hook_field_formatter_view function for my field.

Is there a better way I could be doing this?  I tried to use drupal_render()'s #cache property and it cached the output but still ran my hook_field_formatter_view function.

Basically, I know how to do full page cache (for anonymous users) but how do you cache a field/node/entity (for everyone)?


texts:
I've been trying to Google my way out of this one but I can't seem to find a solid solution for using wildcards by default for the core search module. Only things I can find are patches which aren't really looking like totally stable. And I want my customer's multi-lingual production site to be as stable as possible.

So, the current situation is as follows:

When I search for foo I will get only foo as result.
When I search for foo* I will be getting foo and foobar as result.

What I want is:

When I search for foo I will get foo and foobar, regardless of language.

Is there any way to elegantly solve this. I'm prepared to solve this with a custom module for example.


texts: including javascript via theme.info doesn't work.

texts:
I'm trying to include a simple javascript into my theme using the theme.info

It works like a charm on my home-setup but when I try to load in on a real page it doesn't include the .js-files (not even an empty <script>-Tag is displayed in the source).

The Code:

...
engine = phptemplate
stylesheets[all][] = css/bjqs.css
stylesheets[all][] = css/style.css
scripts[] = js/bjqs-1.3.js
scripts[] = 'js/jquery-latest.min.js'
features[] = main_menu
regions[slider] = Slider
...

The CSS-Files get included on both projects without any problem.


texts: modify password_reset or request_new_password?

texts:
When building a mobile app, and using services3 and/or my custom module, I have a specific requirement:

I want anonymous users to be able to receive their password, in plaintext, in their email, if they give me their email address and if their account exists. If their account doesnt exist, I want to send a different email. I have trouble finding out where to start.

Services has user/request_new_password, and user/password_reset, but both seem to send out a one-time-link through email. Is there an easy way to modify those handlers ?

Otherwise, what would be a good appraoch in my own module ? Just create an entity_metadata_wrapper around the user, set the pass, call save and send the email ?

PS.
Please dont start a discussion about that workflow, there is a reason for it. If you have additional advice for security without changing the workflow as described, I'm all ears.


texts: How to position Image field in body content

texts:
I have a content type that has title, body, image etc. I am displaying the Title, image with caption and body using Manage Display. But here there is no option to align (Left, Right, Center) the image. How to align the image node wise.

To meet the requirement I found INSERT module. This module is placing the image inside the body content but the caption of the image is missing.

Please help on this issue and let me know if anything is unclear.


texts: Why Isn't #value valid for 'textfield' form types in Drupal 7?

texts:
I can set #default_value but there is no #value for text fields?

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7#textfield

Is there a work around?


texts: How to expose a custom serialized image field in Views in Drupal 7?

texts:
I have added a custom image field to an already existing form which saves the details in DB as a BLOB object (serialized).

I am able to expose the serialized field itself in Views. I am also able to expose each key of the serialized data.

However, exposing the serialized image only shows the fid of the uploaded image.

How I do I expose it as a normal image field with all the image settings like display format, link this page to original content, etc.?

Any help with sample code would be greatly appreciated.


texts: Ajax call returning JSON forces IE8 and 7 to download file instead of reading it

texts:
I have a Drupal 7 site and I'm having this issue, commented here for Drupal 6

The thing is that, when ajax response is set as Content-Type: text/javascript; charset=utf-8 IE 7 and 8 try to download the file. The solution they propose is to change a line in common.inc to declare the response as Content-Type: text/html; charset=utf-8

The solution they propose there means I have to modify Drupal core, I would prefer not to do that as this will be a problem in future Drupal updates.

So, have any of you found this problem? do you know another solution?

PS: When I enter my site, I also find a javascript error in consle saying JQuery is not defined in a lina of drupal.js where it does jQuery.noConflict(); // Allow other JavaScript libraries to use $. I don't think it's related but comment it just in case...

Thank you


texts: Is there any possibility to sort all the messages by subjects? For example, there is a button on the main page "send a message to author". Subject from the sender is defined as "main page". If several users send message with this subject, can i see in my mailbox one subject "main page" and then see the list, who wrote it?


texts: WHERE MySQL clause not working in Drupal 6

texts:
I am writing a Drupal Module and I have encountered a problem. This is my code:

$query3 = db_query("SELECT nid FROM {node} WHERE uid=19");
var_dump(db_result($query3));

It currently returns: bool(false)

Now when I run this query in phpmyadmin it returns the desired nid (47) - no problem.

What am I doing wrong?


texts: How to hook "uc_cart_complete_sale" without broking this ubercart function

texts:
I try to understand the hook system of ubercart but there this something i don't get it at all. My main objective it to add a js code to the page "cart/checkout/complete" to send to an external service the total of an order.

Actually when a new user buy a product, ubercart log the new client automatically, assign him a role so he can download the product. If it's an existing user on the cart/chekout/complete page, we show him a text message on the order complete page telling him to connect to his account to get the product he purchase.

The javascript code the provider give me to add on the "cart/checkout/complete" page is this one:

<script> window.optimizely = window.optimizely || [];     window.optimizely.push(['trackEvent', 'purchases', {'revenue': 100}]);    </script>

In the revenue parameter of this script, I need to put the total order of the purchase.

What I did to get the total order is to hook the "uc_cart_complete_sale".

So in my template file I create this function:

function MY_THEME_NAME_uc_cart_complete_sale($variables) {
  $a0 = arg(0);
  $a1 = arg(1);
  $a2 = arg(2);
  if( $a0 == "cart" && $a1 == "checkout" && $a2 == "complete"){
          $order_json = json_encode($variables[order]->order_total);     $order_json = $order_json * 100;
     // print $order_json;
     drupal_add_js('jQuery(document).ready(function () {window.optimizely = window.optimizely || []; window.optimizely.push([\'trackEvent\', \'purchases\', {\'revenue\': '.$order_json.'}]);});', 'inline');*/

}
     }

I think it's not the best way to do to put this type of function in my template theme file but i don't think of create a custom module only for this type of thing.

When i use this code the script call the external service and notify a sale with the order total.

In part this is working but really it's broking totally the way the client can get his product after.

It's like part of the code of uc_cart_complete_sale are not executed. When i activate this hook code, new client connect to my drupal site as an authenticate user but without the role permission to download the product.

If it's an existing client, i have only the title of the page "Order complete" without any message telling him to connect to his account.

And if he connect with his account he don't have the role permission to get his product.

I dig in the cart.module file to check the uc_cart_complete_sale function in ubercart module but it's like when i hook this function all the $messages variable are emptied and the part of code in charge of assigning a role to client is not executed.

Could you tell me what i'm doing wrong. Maybe i need to do that in an other way but i really don't know how to do that.

Thank you very much for your advices


texts: How can get access to field's data of plugin block in twig template?

texts:
how can I get access to fields data (Variables) of custom plugin block in twig template?
this block has been created by a module (Not a custom block type) and has its own twig template.
in below is shown structure of my module directory:

my_module
  ├ src
  | └ Plugin
  |    └ Block
  |       └ MyBlock.php
  ├ templates
  |  └ block--my-module.html.twig
  ├ my_module.info.yml
  └ my_module.module

MyBlock.php:

<?php

namespace Drupal\my_modules\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * @Block(
 *   id = "my_block",
 *   admin_label = @Translation("My Block"),
 *   category = @Translation("My Block")
 * )
 */
class MyBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
    // Add a form field to the existing block configuration form.

  $form['block_LinkA_url'] = array(
    '#type' => 'url',
    '#title' => t('Link A:'),
    '#size' => 60,
  );
  $form['block_LinkB_url'] = array(
    '#type' => 'url',
    '#title' => t('Link B:'),
    '#size' => 60,
  );
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
    // Save our custom settings when the form is submitted.
    $this->configuration['LinkA_url'] = $form_state->getValue('block_LinkA_url');
    $this->configuration['LinkB_url'] = $form_state->getValue('block_LinkB_url');
  }

}

I'm trying to get access to for eg LinkA_url Variable in block--my-module.html.twig with something like below code:

<div>
    {% block content %}
      {{ content.LinkA_url.value }}
    {% endblock %}
</div>

But whatsoever I try nothing could not be displayed , I would be happy to hear what the problem is.
Thanks for any help.


texts:
I'm using the following method to check whether a variable is set before printing

if (isset($content['field_name'])):
print render($content['field_name']);
endif;

But when the field is empty, unknown is printed.

Is there a Drupal method for checking empty variables?


texts: Problem getting Drupal SESSION value from standalone php page in subdirectory

texts:
Last 2 days I am searching for solution on Internet. I have a module in my drupal site's "sites/all/modules" folder named "coupon".I added a new test.php file in the "coupon" folder which has no relation with drupal. I can't access Drupal's session from this file.Below is my code wrote in test.php which I find on net.It is giving result, but not the right one.

<?php
$path = getcwd();
$pos = strpos($path, 'sites');
$path = substr($path, 0, $pos);
$path = explode('\\', $path);

$length = sizeof($path);
unset($path[$length - 1]);
$path = implode('/', $path);

// Get the base path
define('DRUPAL_ROOT', $path);

//Include the bootstrap file for using the DRUPLA function in our file
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
// Bootstrap Drupal at the phase that you need
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Our custom page now has access to Drupal functions
// such as node_load() and db_query()
$node = node_load(1);
global $user;

var_dump($user);
?>

when I run the test.php file it is giving following result:

object(stdClass)[7]
  public 'uid' => int 0
  public 'hostname' => string '::1' (length=3)
  public 'roles' =>
    array (size=1)
      1 => string 'anonymous user' (length=14)
  public 'cache' => int 0

But I am currently login with username "test" whose uid is '3' and also 'roles' is 'admin'. Please help me to solve this.


texts: Hide a div on webform submission using ajax

texts: I am new to drupal i  am using webform ajax module to submit my webform , its submiting values properly after validating them , but along with this i want to hide a div also on submit . what is the best way to do this


texts: What might cause duplicate user registrations?

texts:
We have a site with about 16,000 registered users. I've just discovered there are over 100 duplicate user registrations.

These users have all the same details (username email etc) and have been created at about the same time and have a uid that is just one more than the original.

We are using Email Registration module 7.x-1.3. I've tried duplicating the problem by hitting the submission button multiple times and be creating an identical submission. However, I always get the validation error.

Any suggestions?

Note: we also use Rules and there is a rule triggered by a "After updating an existing user account" event. The rule runs some simple PHP code that adds the users details to a CSV file.


texts: Get the current range values from a QueryAlterableInterface

texts:
As far as I can see this isn't possible outside of QueryAlterableInterface, because the $this->$range variable is protected, and the range() method can only be used as a setter.

I suppose I could implement my own class that extends QueryAlterableInterface and adds in a method to expose the protected field... but I would have no idea how to get Drupal 7 to use the new class instead of its core one. Not to mention this would be quite over-kill.

Any better ideas?

Context

I am attempting an external (i.e. outside of hacking the Reference module) general code fix for something similar to the following issue:

References module doesn't specify/read a pager limit when field is using a view to generate potential references

I have come across another instance where this is causing my site a problem, but I can't apply the specific fix found in the Q/A above. Mainly because the code takes a different route through the References module. Rather than my field using a view to generate its "potential" reference values — as in the previous Q/A, which makes it quite identifiable — it is instead just a field that relies on a direct query to source its values. This direct query still has the same problem of attempting to list far too many values, to the point of timing out.

My plan is to detect the particular query involved, and see if it has no limit applied, and then set a safe limit — so that the views UI doesn't attempt (and fail) to generate thousands and thousands of checkboxes. I can probably find a way to detect the specific query, but I don't think I can tell if a limit is set or not.

function hook_query_alter(QueryAlterableInterface $query) {
  if ( $query->getMetaData(...) == ...) {
    $query->limit(); /// this does not return the limit value.
    $query->limit; /// triggers an protected access error.
  }
}

A different way to find this question

I realised that with the way I've posed this question, only those who know the underlying cause will be able to find a possible solution. So just as an aid to those who might searching for this specific problem — as it is easy to reproduce if you have a good sized database — here are some key search terms.

Unable to add a filter to a View for a Reference field

When attempting to add a Reference field as a filter for a View, using the Views UI, the Ajax request seems to hang. After max execution time triggers the following error:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/ajax/config-item/related_nodes/default/filter/field_node_related_nid
StatusText: parsererror
ResponseText: Fatal error: Maximum execution time of 60 seconds exceeded in /var/www/drupal/includes/common.inc on line 6642


texts: How to programmatically delete taxonomies when a module is uninstalled?

texts:
Taxonomy vocabularies are in the CMI as of Drupal 8, but I want to also keep the Taxonomy terms in code. I am programmatically creating terms in a custom module.

function taxonomy_vocab_install() {
  foreach (taxonomy_term_info() as $term_info) {
    $term = Term::create(array(
      'parent' => array(),
      'name' => $term_info['name'],
      'description' => [
        'value' => $term_info['description'],
        'format' => 'full_html',
      ],
        'vid' => 'department',
    ));
    $term->save();
  };
};

Now, I want to delete the terms on uninstall, but taxonomy_term_delete is depreciated. Any help on how to programmatically delete the created taxonomy terms in D8 when the module is uninstalled would be greatly appreciated.

function taxonomy_department_uninstall() {
  // ??
};


texts: How to include a view in a specific region defined in a custom layout?

texts:
I defined a set of views that I would like to include in specific regions ordered in a particular way through a custom layout. However, the block menu does not allow me to select these regions. All I can do is to give an order (1, 2, 3, etc.) to these views, which does not solve my problem because I need the views' outcomes to show up in these specific areas of the page.

I've looked up in many places but I couldn't find any answer to that question. Someone could give me a hint?

Thanks a lot!
Igor


texts: Node and Webform - Open, Close, Scheduled and Limit per source entity

texts:
I use Drupal 8 with webform. I have a content type called "Event" which has several fields of simple type and reference type for other content types.

In addition it has a field entity reference that points to a webform named "Team".

In "Event" in creation and edit mode, using the field_permissions-8.x-1.0-rc2 module, I prevent access to authenticated users,
because the default aspect is too complex for users who create content with the "Event" content type.

Among other things, if I do not prevent these settings, there is the possibility of changing the content type, which I would definitely not want.

For this reason I would like to link some simple fields of the "Event" content type to the "Team" webform.

Status (open, closed, scheduled)
Open (date and time)
Closed (date and time)
Max submissions (Total submissions limit per source entity)

Can anyone suggest me how to do it?
Can it be done with Tokens?
Should you use a Hook?
I searched the net but I didn't find anything like that.


texts: Get node based target id from entity reference

texts:
We have an Article content type which has an Entity Reference field called field_document that is linked to the Media bundle type of Document. In mymodule we need to write a hook that will take the current field_document.id (which maps to Document.mid) and return all the Article pages where field_document.target_id = mid.
Goal

Take the current node id and retrieve the Document entity that is linked to by accessing field_document
Using the field_document value, return other Articles that have the same value for field_document
Perform the query in a hook_preprocess_node() hook.

Question

How can we retrieve all the nodes based on the $mid?

When we tried
We were able to return all Articles. However when we add ->condition('field_document.target_id, $mid), we get zero results even though we know there are Articles where the field_document.target_id = $mid.
function mymodule_preprocess_node($variables) {
  $node = $variables['node'];
  $linked_document_id = $node->get('field_document')->first()->getValue()['target_id'];

  $node_storage = \Drupal::entityTypeManager()->getStorage('node');
  $query = $node_storage->getQuery()
    ->condition('type', 'article')
    ->condition('status', 1);

  $and = $query->andConditionGroup();
  $and->condition('field_document', $linked_document_id, '=');
  $query->condition($and);
  $results = $query->execute();

  // returns zero
  ksm($results);
}

We also tried using $and->condition('field_document.target_id', $linked_document_id, '=');, but that did not return any results either.
Additional steps we tried, but with similar issue.
 function mymodule_preprocess_node($variables) {
  $node = $variables['node'];
  $linked_document_id = $node->get('field_document')->first()->getValue()['target_id'];

  $node_storage = \Drupal::entityTypeManager()->getStorage('node');
  $query = $node_storage->getQuery()
    ->condition('type', 'article')
    ->condition('status', 1);
    ->condition('field_document', $linked_document_id, '=');
  $results = $query->execute();

  // returns zero
  ksm($results);
}


texts:
On my edit form I need to fill in the file field, this is my current code:

    $form['file'] = array(
    '#title'        => t('Upload image'),
    '#type'         => 'file',
    '#description'  => t('Images must be one of jpg, bmp, gif or png formats.'),
    '#default_value'        => "$link->icon",
    '#ajax'         => array(
      'wrapper'       => 'box',
      'name'          => 'icon2',
    ),
);

but the file field remains empty, in this way the admin has to reselect the desired image each time he edits the entry. The field returns 'no file chosen'.

Any ideas?

Update I

$form['file'] = array(
    '#title'        => t('Upload image'),
    '#type'         => 'managed_file',
    '#description'  => t('Images must be one of jpg, bmp, gif or png formats.'),
    '#default_value' => variable_get('', $fid),
    '#upload_location' => 'public://',
    '#ajax'         => array(
      'wrapper'       => 'box',
      'name'          => 'icon2',
    ),
);


texts: Include Entity Reference values to term page Solr results

texts:
I would like to index the value/s from EntityReference, to be included in Solr results.

Example, My entityreference field has nodes "Foo" and "Bar" in "Lorem Ipsum" taxonomy term.

I'm using Solr to render my Taxonomy page.

Is there a chance to include "Foo" and "Bar" to my "Lorem Ipsum" Solr results and sorted properly (in order)?

So it is like merging Entity Reference values and Solr results.


texts: Check, anywhere during a session, if a logged in user has previously logged in

texts:
There are a number of properties on the global $user object
https://api.drupal.org/api/drupal/developer%21globals.php/global/user/7

But I can't figure out how to see if a logged in user has ever previously logged in, or if this is his/her first session. When logged in, the $user->access, $user->login, $user->timestamp values all seem to point of the current session.

I can set a cookie and check for that cookie myself. But I suspect I'm just missing something Drupal already has ?


texts:
As given in the code below, I tried enabling select list $form['answer']['answer1'] through AJAX callback, textbox is getting populated with value, where as the dropdownlist is not getting enabled. Any help?

function mymodule_search_block_form($form, &$form_state) {
  $options = array();
  $options['key1'] = t('value1');
  $options['key2'] = t('value2');
  $options['key3'] = t('value3');
  $options['key4'] = t('value4');

  $form['profiles'] = array(
    '#type' => 'select',
    '#title' => 'Profiles',
    '#options' => $options,
    '#ajax' => array(
        'callback' => 'ajax_select_callback',
        'wrapper' => 'profile-wrapper',
        'event' => 'change',
    ),
  );

  $form['answer']['profile_name'] = array(
    '#prefix' => '
',
    '#type' => 'textfield',
    '#title' => 'Profile Name1',
  );
  $form['answer']['profile_name2'] = array(
    '#type' => 'textfield',
    '#title' => 'Profile Name2',
  );
  $form['answer']['answer1'] = array(
    '#type' => 'select',
    '#disabled' => 1,
    '#title' => 'Profiles',
    '#options' => $options,
    '#suffix' => '

',
  );
  return $form;
}

function ajax_select_callback($form, $form_state) {
  $form['answer']['profile_name']['#value'] = 'Profile 1';
  $form['answer']['profile_name2']['#value'] = 'Profile 2';
  $form['answer']['answer1']['#disabled'] = 0;
  return $form['answer'];
}


texts:
I've made a view that contains a filter that the visitor can change.
The problem is that it give the possibilities to filter trough a combobox:

Is equal to
Is not equal to
Contains
Contains any word
Contains all words
Starts with
Does not start with
Ends with
Does not end with
Does not contain
Length is shorter than
Length is longer than
Regular expression

I don't want them! I just want the user to see an input field and click "ok" (something like that). And the search would be "Contains all words".

How to do this?


texts: Views... no format options in Fields->User?

texts:
In any Field using the USER type there are no format options.  I'm making a user_picture view and want to use the image cache option.  But, at the bottom of any Field (pertaining to USER) where Format* usually shows up, it's not there.  Any ideas why?  Thank you.

Also, Format* works for nodes/content types.  So, it's installed and working functionally.


texts: The best way to generate buttons and apply visibility restrictions based on roles

texts:
I want to generate about 40 buttons on the same page, every button should be visible to only a certain group of people based on their Drupal roles.

What the best way to do it ? I thought about creating a bloc for every button but to display them with visibility restriction in the Block layout and restrict every bloc by role..but it's not very efficient and the Block layout page will be full of those blocs.

Does anyone have any suggestions ?

Thank you


texts: How can I pass proper querystring when Search from Drupal using my custom search box?

texts:
I have this search form in my drupal site.

<form id="mysearch" method="get" action="<?php echo $base_url.'/search/node/'; ?>">
   <input type="text" maxlength="150" id="search" name="s" class="input">
   <input type="submit" value="Search" class="button">
</form>

I have problem is that when I am submit the form it will pass the query like that

http://mysite.com/search/node/?s=xyz

Here I would like to change the URL something like this to search in my site.

http://mysite.com/search/node/xyz

Can anyone help me how can i achieve this thing.

I have put this code for URL Change:

$("#adminbarsearch").submit(function(e) {
    $url = $("#adminbarsearch").attr("action") + $( "input:first" ).val();
    e.preventDefault();
    window.location.href = $url;
});

Instead of this Can we change the URL by using the .htaccess


texts:
I want to add a role to the user when they log in for the very first time to their account. Any ideas of how to work this out? Rules maybe?

Thanks,


texts:
I just installed Drupal 7 and made some content and configuration.

After that, I just realized I did not put any table prefix on installation.

My problem is:

Is there anyone here that knows the SQL to add table prefix on Database drupl?

Example

current table: variable
must be: drupal_variable

I want to change all my table and add prefix.


texts: how to add new changes to live site without redoing everything

texts:
I have a site which is running on a huge userbase. The site is about taking online courses and getting certificates.

I am using profile2 which adds some extra fields in user profiles.

Also i am using webforms to create nodes with questions and answers. Users do some webforms exercises, then take the exam(webforms) and get the certificate.

There is only one custom table which is keeping track of user activity and status.

Now i have been working on a dev site and made lot of changes. What will be the best way to transfer these changes to live site. ?

I tried features module and exported content types and views. After enabling the feature some fields in the content types were not changed ( e.g the field type is text on live site, i changed it to a entity reference in dev site + features will not delete fields). ( and same case with views)

Its not easy to track which changes i have made on dev site. How can i import the users from live site (with all their webforms submissions + profile2 updates + whatnot) to the dev site? Or i should go to doing the changes on live site again ?

Thank you.


texts: How do I skip importing a duplicate item?

texts:
I use unique field mapping, but instead of blocking the import on duplicates from CSV, it overwrites the data in Drupal and inserts the new value from the CSV file.

This is the default behavior with unique title field mapping:

"IF the title is duplicate THEN overwrite old item in Drupal with new item from spreadsheet"

But I'm looking for this behaviour:

"IF the title is duplicate THEN skip new item from spreadsheet, and keep old original item in Drupal intact"

I have field tamper, the item field AND the importer field all set to unique. It all works fine, but on duplicate feed imports, instead of preventing import of duplicate items, it overwrites the old field, and inserts the new duplicate...

My goal is for Drupal to PREVENT the duplicate field to be populated at all...the same way if you manually try to input a duplicate entry in manually imputing content, it shows an error and prevents you from submitting the form.

Is this even possible without custom code? Maybe with rules?


texts: How to let an OG administrator contact (via email) all group members?

texts:
I've a request to set up an email form where by a OG administrator can send a message (via email) to all persons subscribed to that group.

I've seen a few modules OG Contact, OG Notify, and Organic Groups Email, but these seem out of date.


texts: How do I add a custom field token to a default value?

texts:
I want to add node-field data into the web from block via tokes as with Webform 7.x-4.1 this should work.

But tokens from custom fields are not available in a webform(block) ?

[node:title] and [node:author] work but [node:field_mycustumfield] or [node:field-mycustumfield] does not work .

Any help appreciated!


texts: prevent ignore empty field in multi value fields

texts:
let suppose I want to create a cast table,
in one field with multi value write down actors and in another write down their roles,
as example

 A has "role A"
 B has "role B"
 C          (no role)
 D gas "role D"

I fill up field actor with 4 value (it is multi value text field),

1)A
2)B
3)C
4)D

then in field roles I write down 3 value, the actor "C" has no role

1)"role A"
2)"role B"
3)
4)"role D"

.

then when I save , I want to show each actor and field in pair, first value of field actor with first value of field role,
but if a actor has not role every thing mixed up

 A has "role A"
 B has "role B"
 C has "role D"
 D

Is there any way to drupal consider a empty field as filled up field and do not ignore it in save specially between filled up field?


texts: HTML escapes appearing in node titles on bespoke content type — substitutions?

texts:
I have a bespoke Content Type pertaining to venues. These are not user-creatable; they are all created from importing a trusted third-party feed, which sanitised the titles before they come to me (so there's no risk of XSS or SQL Injection here). The titles might, however, contain accented characters (é, ô etc), apostrophes (') or ampersands (&); these are coming out as HTML escapes (so &#039; instead of an apostrophe, &amp; instead of an ampersand, etc).

The Content Type Venue has a field title, which is a Node module element, so doesn't allow me to mess with its display settings. In the Node template page, I can use substitutions in the display of this title, but I can't work out how to make it be the raw text version. The title is currently set to display as %node:title and I tried using %node:title:raw and %node:title-raw in case one of those would magically work, but they had no effect.

I saw something that looks like a potential solution at Custom HTML in Drupal Node Titles on zerotodrupal.posterous.com, which attaches to the hooks hook_preprocess_page and hook_preprocess_node, creating a new method like

function hhhdarkelegance_custom_title($node) {
    return check_markup(strip_tags($node->title, '<em><em>'));
}

but, while that blog post looks like it will work well for named HTML tags, I'm not sure it will necessarily deal with HTML entities, which are what my problem is here. I suppose I could do the opposite to the blog-post code and replace out &amp; to & before display, but that feels really kludgy and, frankly, it would be nice to be able to do this just using a substitution, if possible.

Is there some way of achieving this that doesn't involve cutting code? If so, is strip_tags what is causing the HTML escapes? (The function description reads as though it's only causing the removal of HTML tags, which I am fine with either way — they won't occur in my node titles. I am wanting to stop escaping the HTML escapes, however.)

So how can I (on a specific Content Type, without worrying about security concerns) prevent Node titles from rendering HTML escape characters to the usual and just write the damn output to the page?

I did scan through several pages of similar-looking questions before posting and I couldn't find one that addressed this, so my apologies if someone has asked this already; if you point me towards it I'll be suitably embarrassed and try even harder next time. Thanks for your help, everyone!


texts: Use webprofiler to see entire query from view

texts: I am using Drupal 8. I have webprofiler enabled and am trying to see the entire query from a view since the query that shows on the view is not the complete view, its missing some fields. How do I use webprofiler to get this entire query?


texts: As a site builder, how can I learn when modules I use are (going to be) deprecated?

texts:
I have a site that uses a relatively large number of modules (100+).  I do my best to keep up-to-date but recently I have become a little alarmed because I found that Heartbeat and Custom Breadcrumbs, two modules I use on my site, are likely to be deprecated in the near future.

I learned about Heartbeat's deprecation by visiting the module's page by chance when I was checking the documentation.  I learned about Custom Breadcrumbs possibly being deprecated from a comment here on Drupal Answers.

At the time I installed these modules (early last year), they were the most popular in their respective categories.  Heartbeat's maintainer was active and making releases every few weeks.

Now, a year later, they are being deprecated in favor of other modules.  I understand the reason for this, and I'm happy to migrate my site over to the replacement modules (well, maybe not happy, but I'll do it)-- however, I can't do this if I'm not informed that modules are going to be deprecated.  I only found out about these two by chance!

Is there any central resource that keeps track of deprecated modules?  Since I use so many, checking issue queues or even module's pages is not really a feasible option.


texts: How can I output debug info from hook_node_presave()?

texts:
I'm learning about module design for Drupal 7 and I want to see what hook_node_presave is being passed (and working with), how can I output debug info so that I can learn how to manipulate it?

Is there a similar hook that I can use to print out debug info?


texts: how to make $page['content'] stop replacing HTML

texts:
In my page (basic page content type) I have the following code in the body field

Heading

In my custom themes page.tpl.php I have

<?php print render($page['content']); ?>

However the rendered content replaces the h3 with a p and stripes my class for some reason and I need it to render the code that I saved.

header

However, if I use the following then it will print correctly:

<?php print field_get_items('node', $node, 'body')[0]['value']; ?>

If I use that then when I navigate to any of the default pages, mainly the admin login I get an error as $node is not defined. I added a conditional to check that $node was defined to prevent the error. After that the error wasn't displayed but since $node was supposed to contain the content, no content is displayed.

What am I doing wrong here? I just need my page to print out the body without deciding it should edit my code for me and I don't understand why $page['content'] is butchering my code.