texts: Drupal 8.2.5 no internal pages on fresh install

texts:
Just installed Drupal 8 on a Ubuntu 16.04 server.   Everything looked great until the final install and then there was no stylesheets on the site and all of the links give an

The requested URL /admin was not found on this server.

Apache/2.4.18 (Ubuntu) Server  ###########.net Port 80

error.  This error persists for all linked pages.

I installed it previously on the server with the same issue, except before it had the Bartik theme.   I realized I had built the database on it incorrectly and it was faster to reimage the server then go in and delete everything and put things back proper, plus I figured that way it would be fresh.

Thanks in advance for the help,
Joey


texts: Overriding a view with views_pre_render. How to be more specific?

texts:
I have a view which has a page display and a block display. I'm trying to write some custom code that takes one of the fields from the block and uses it to amend the title of the page. So far, here's my code:

function custommodule_views_pre_render(&$view) {
  if ($view->name == 'topic_page') {
    $title = $view->result[0]->node_title;
    drupal_set_title($title);
  }

I managed to pinpoint the field I need by looking through the returned views result array. The problem is that there are multiple results arrays returned - one for each display, so there's two $view->result[0] in this view. The code above only happens to work for me because the one for the block is returned after the one for the page.

So in the interests of making sure the code doesn't break should another display be added to the view, and therefore having that display's result[0]->node_title become the one that overrides the page title, how do I increase the accuracy here? How do I pinpoint my block display?

(I realise there are plenty of contrib modules that can do this for me, but I'd really like to do this with custom code as something of a learning exercise.)


texts: How to delete a variable during uninstall?

texts:
I've never run into this problem before, but the variable I set in my module won't delete during uninstall. What am I doing wrong?

I set the variable in my module like this:

variable_set('marigold_nutrients', $nutrients);

All is good. The variable saves just fine and I'm able to use it as normal with variable_get.

Here is how I try to delete it:

In my module's .install file, I implement hook_uninstall...

/**
 * Implements hook_uninstall().
 */
function marigold_nutrition_uninstall() {
  variable_del('marigold_nutrients');
}

Using the UI, I remove the module then uninstall it. The database table the module creates deletes just fine, and it looks as though it's uninstalled. However, when I look at the variable table in Sequel Pro, the 'marigold_nutrients' variable is still there. I've run cron, cleared the cache... not sure what to do.

MORE INFO:
- Using the debugger, I see that when I uninstall the module, it steps into the uninstall function just fine, so I'm pretty sure that function is working.


texts:
I am a newbie in Drupal. I recently upgraded a site from D6 to D7. The site used simplenews module. So i got the D7 equivalent and installed it. After enabling the module i find the following issues -

1) The newsletter page does not display the subscription area any more. Earlier the newsletter page asked the user to fill in the name and email and subscribe/unsubscribe radio boxes and a save button. When i am logged in as admin i only get the username and a unsubscribe button.

2) When i compare the simplenews folder then i find out that the earlier version has a simplenews_action folder which I dont have in my D7 version.

3) The site previously also used the simplenews_realname module which helped to retrieve names and emails of individuals if an export option was tried. What should i do for this since I could not find a simplenews_realname version for D7.

4) I opened EDIT for the newsletter page to find out the following for the simplenews code.

so i changed it to this -

<?php $block = module_invoke('simplenews','block_view',27); print render($block['content']); ?>

But this also didn't solve the purpose. How can i fix this simplenews problem. Any sort of help is deeply appreciated.


texts: What is the relationship between hook menu() and menu_link_save()?

texts:
I am trying to create a menu using code in D7 (see my related question) and have found that these two Drupal API functions have different arrays for the $item variable. My intent is to create a three level menu hierarchy but with all of the associated paths being the same format /name/%/something so that I can use views to refine the content.  In hook menu, the parents are defined using the Path name (eg. parent/child/something).  In menu_save_link, the hierarchy appears to be established using the pid array value in $item. Hook_menu is called when my custom module is read by drupal and the menu links are established.  What I am wondering is if menu_link_save, could be used to do the same thing but with the same path style for all links, rather than a parent-child pattern?

I have been trying to trace the logic between the two functions in the API, but have not found the link between them.  My thinking is that menu_link_saveis used by hook_menu after some preprocessing and that I might be able to define a uniform paths and establish the hierarchy through the pid.  Failing that, is there another way to alter the paths and preserve the hierarchy?


texts: An illegal choice has been detected. Please contact the site administrator.in dynamic select list dependent dropdown

texts:
using hook_form_alter and custom form elements below

$form['get-quotes-shipping']['country'] = array(
      '#type' => 'select',
      '#options' => array('_none' => '- None -') + country_get_list(),
      '#multiple' => FALSE,
      '#weight' => 3,
      '#title'=>t('Country'),
      '#default_value' => (isset($_SESSION['selected_country'])) ? $_SESSION['selected_country'] : '_none',
      '#ajax' => array(
          'event' => 'change',
            'wrapper' => 'squadron-wrapper',
            'callback' => '_get_state_field',
            'method' => 'replace',
       ),
    );

    $form['get-quotes-shipping2']['actions']['get_quotes'] = array(
      '#type' =>'submit',
      '#value' => 'Get Quotes',
       '#submit' => array('custom_changes_get_quotes_submit'),
      '#validate' => array('custom_changes_get_quotes_validate'),
      '#weight' => 1,
    );

  $squadron_options = array();
   if (isset($_SESSION['selected_country'])) {
       module_load_include('inc', 'location');
       $states = location_get_provinces($_SESSION['selected_country']);
       $squadron_options =  $states;
   }
   $form['get-quotes-shipping0']['states']['#type'] = 'select';
     $form['get-quotes-shipping0']['states']['#title'] = t('State/Province');

   $form['get-quotes-shipping0']['states']['#prefix'] = '
';
   $form['get-quotes-shipping0']['states']['#suffix'] = '
';
    $form['get-quotes-shipping0']['states']['#options'] = array('_none' => '- None -') + $squadron_options;
    if (isset($squadron_options[0])) {
      $form['get-quotes-shipping0']['states']['#default_value'] =  $squadron_options[0];
    }

Callback function as given below.

function _get_state_field(&$form,&$form_state) {
  module_load_include('inc', 'location');
  if ($form_state['values']['country'] == '_none') {
    unset($form['get-quotes-shipping0']['states']['#options']);
    $form['get-quotes-shipping0']['states']['#default_value'] = '_none';
     return $form['get-quotes-shipping0']['states'];

  }
  else {
      $states = location_get_provinces($form_state['values']['country']);
 $form['get-quotes-shipping0']['states']['#options'] = $states;
     return $form['get-quotes-shipping0']['states'];

  }

}

When I select Country and then state at first it gives proper values
but when I select country again it gives
An illegal choice has been detected

What is the issue with the above code?
can anyone point out?


texts: I want to upload image(.tif extension) to drupal website, but as per current we can upload only jpg/jpeg/png/gif only.


texts: When switching themes in blocks, theme stays the same

texts:
I'm trying to add a block to a specific theme (garland), but no matter what theme I switch to, I'm always shown the admin theme.

If I only have a single theme (garland) enabled, I can access the blocks I need, but there has to be a reason for this.

Edit: Discovered that this is being caused by the module "RealName" I have no idea where to look for the culprit though. Any suggestions?

Edit2: Found this explanation, but no real fix. Suggestions?


texts: Allow non-members of an OG to post group content

texts: I'm building a website with the use of Organic Groups module. I need to allow all registered users (not only group members) to have permission to post nodes of a certain content type to any group. However I failed to achieve this behaviour as well as finding helpful info online. Can anyone please advise me on how to make this? Are any additional modules needed?


texts: How can I best display code examples on my site?

texts:
I'm doing some PHP code examples for a class in a fancy Drupal site.

I have a "Code" content type.
I have a "field_php" that gets processed on the actual node.
I have a view that uses "node/%/code" to display the code formatted via Geshi:

View PHP Body: Link back to node/1
View PHP footer: PHP code to pull geshi formatted "field_php"

<?php
  include_once('sites/all/libraries/geshi/geshi.php');

  $page = $view->args[0];
  $node = menu_get_item("node/$page");

  $source = $node['page_arguments'][0]->field_php['und'][0]['value'];
  $language = 'php';
  $geshi = new GeSHi($source, $language);

  echo $geshi->parse_code();
?>

LASTLY I have a node--code.tpl.php edited to include a "View Code" link at the top of each "code" page. The include_once/echo at the top is the following:

<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  <?php
    include_once('sites/wernercd.php/public/~functions.php');
    echo "Code For You!";
  ?>
  <?php if (!$label_hidden) : ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;

  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <div class="field-item even"<?php print $item_attributes[0]; ?>><?php print render($items[0]); ?>

http://mysite.com/node/1

http://mysite.com/node/1/code

I don't know why, but I feel like I'm doing it wrong. It works like I want it, but I just feel like its the "wrong" way to go about doing it.

What would the "recommended" way of getting this desired output be? How could I change this to catch issues unforseen by my naivete?


texts: Core jQuery not working in Bootstrap theme

texts:
I am using Bootstrap 3 subtheme and Drupal 8. For some reason when I add the dependency core/jquery it does not work. What am I doing wrong?

mysubtheme:
  css:
    theme:
      css/slippry.css: {}
    header: true
    js:
      js/slippry.js: {}
  dependencies:
      - core/jquery

The only way I can get jquery to load is when I put the jquery.min.js URL into my page.html.twig file.


texts:
I'm trying to add more fields to my content types.
I have a content type called Cars, and another called Airplanes; I want they belong to a category called "Transportation".

If I want to get a list of all transportation content types, it will return Cars and Airplanes.


texts: I am trying to edit the content of panel to insert a block view I created into a region. When I click on add content and click on the views category, my view is not listed. I flushed the cache and it still doesn't show in the list. I checked the other categories to make sure that it was not showing up. Am I missing a setting somewhere?


texts: How to actually set a maxlength for textarea field in contact form

texts:
I need to limit the textarea message of the core module contact form to a certain number of characters.

Here are the facts

The Form API does not allow one to set a maxlength on textarea field types [while plain HTML does]
The Maxlength module , doesn't allow you to actually set a maximum length. It gets its max length from the field's max length, defined on each content type's manage field section
Creating a new form element type using hook_element_info, still doesn't gurantee I can add the #maxlength to the textarea. Besides if I succeed I need to alter again the contact form module to overrride actual message textarea field with mine.

So I can I alter it plain and straightforward?

What is the best idea to alter all textarea fields in the website?


texts: How to display menu block but deny adding a new instance?

texts:
I have a menu which has a block provided by the system automatically.
This menu has links that come from a module which defines the menu(config).
This menu block can be seen(ie. the block is visible) but it shouldn't be possible to attach another instance of this menu nor put links into it via UI. I do not want the admin so see this menu block in the list of available blocks on the block library page.

So far I have been able to tweak things so that some specific menus are not available for user to put links into or even see them in the menu listing(I have custom list builder for this + some form alterations in place). But when it comes to blocks the issue is that on some places Drupal checks plugin definitions(which are cached so I cannot distinguish if the user is on the "manage blocks" page or somewhere else or if the user has specific permissions and such) and in other places it uses the block entities.

So my question is how can I hide a block from the block library but keep the block displayed when attached to a region? If I remove the plugin definition the bloc kwon' be displayed since the plugin will be non existing. This works in other cases that I have but not int this one.

I think this relates to https://www.drupal.org/node/1975064 but I need to fix this ASAP.


texts: Is the X-csrf-token only available for authenticated users?

texts:
I am working on a rest api end point. I am noticing that some end points work without X-csrf-token header. Digging into the core revealed the following
  // This check only applies if
    // 1. the user was successfully authenticated and
    // 2. the request comes with a session cookie.
    if ($account->isAuthenticated()
      && $this->sessionConfiguration->hasSession($request)
    ) {
      if (!$request->headers->has('X-CSRF-Token')) {
        return AccessResult::forbidden()->setReason('X-CSRF-Token request header is missing')->setCacheMaxAge(0);
      }

This means that the X-csrf-token header is only checked for authenticated users. Are anonymous users not required to have this header? This really seems counter-intuitive to  me as I feel that authenticated users already have a session cookie and its the anonymous users that need some kind of validation.
How do we add token validation for anonmyous users?


texts: Field weight in display mode is not respected on custom entity

texts:
I have a custom entity type with a set of base fields and I can create/view/update/delete entities. However When I create & enabled a custom view mode to the entity type and set to display subset of fields (using Manage display) in a page using below code:
$view_builder = $this->entityTypeManager->getViewBuilder('my_entity');
$build['top_summary'] = $view_builder->view($entity, 'summary');

The fields get rendered, but not in the order they are in the view mode. They are in the order of the IDs of the fields alphabetically. So if the entity has these fields in this order:

First name
Last name
Email

They get displayed as

Email
First name
Last name

I can hide fields using the hidden section, but can't change the visible fields' order.
Updating the fields' order in core.entity_view_display.[ENTITY_TYPE].[BUNDLE].[VIEW MODE] does not help as the fields are sorted alphabetically on config import/export


texts: Entity Registration: Override built-in registration list with custom view

texts:
I'm trying to override existing registration list (in Registration tab) with my custom built view, however if I set my View's path to "node/%/registrations", the tab "Manage registrations" is gone from entity tab.

What should I do?


texts: Strange sorting in one facet of Apache Solr Search results

texts:
We're using the Apache Solr Search module to allow users to filter search results; for example, if a user searches for Pepsi, they get all results, but along the left of our screen they get facets allowing them to filter by Post Date, Article Type, Trend, etc. (Ignore the HTML under Trends/Seasonal; we have the Themer module turned on.)

We haven't done anything custom to this search that I know of, but there's something strange: all the facets EXCEPT post date sort descending by number of results. Filter by post date actually sorts by post date. We want that one to also filter by number of results. (It's not visible in the screenshot, but 2010, for example, has over 500 posts so we'd definitely like that one to be at the top.)

Is sorting a module setting somewhere? (There are blocks for each filter-by facet, but sort order is not one of the config settings.) I tried looking around in the code, and I found the spot in our search results page template where the entire left filter bar is printed out, but cannot for the life of me find (even with a full-site grep) where the variable it's printing is actually being set.


texts: Translating custom database table fields

texts:
How can I translate the fields for my custom database table which uses the following schema?

member_id: int
name: varchar(60)
i_prefer: varchar(50)

I need to translate the string that is displayed for the 'i_prefer' field. I know how I should represent this in template page (<?php print t($query->i_prefer); ?>), but the translated string will not appear until I provide the translation. I checked in 'Regional and language > Translate interface'; I can not see my text.

How can I do this?


texts: How do get a body.onload event executed?

texts:
Background:

(*) I'm a JavaScript dilettante -- I just dabble when I need to.

(*) I have a piece of javascript that I've tested with a dummy page that I loaded by just calling it from a <body onload="..."/>.  It does what I want there.   (See https://github.com/cwestin/bobt/blob/master/site/style/article.html , and the sibling file http://github.com/cwestin/bobt/blob/master/site/style/bobt.js).

(*) I want to add this onload behavior to my Drupal site.

I followed the instructions on how to create a Drupal 7 module from here:  http://drupal.org/node/361112.

However, this seems to be aimed at PHP development of block modules that generate content.  All I have is the JS file, which will act on some div classes I put in my content's unfiltered HTML markup.

I also found instructions on managing JavaScript here: http://drupal.org/node/756722.

And, a search on this site found these instructions for including JS:  Best way for including javascript/jQuery OnLoad in EVERY page on my site .  However, that didn't really seem to answer the question it posed -- that I could tell.

However, having created a module by following these incomplete instructions as best I can, it doesn't look like my JS is getting triggered.  A View Source shows that my .js file is being included in the pages, but the transformation it does isn't happening (it did work in my dummy test page).  It's possible I'm not translating into jQuery correctly; I've never used that before, and the syntax is clearly not just plain old JS.

Here's the module:  https://github.com/cwestin/bobt/tree/master/site/style/sectiontoc .  As you can see, in the spooky function($) thingy, I add the required attach() to try to add my behavior to $(document).ready at the bottom.  But as I said, it's not getting triggered.

Could anyone please tell me what I'm missing, or what I'm doing wrong here?  Thanks in advance for any help.


texts: Field:REWRITE , Contextual filters Views 3

texts:
i am pretty new to drupal 7 , and i have managed to create a view (conferences_details) with a contextual filter Content:Nid, the link to the view is now conference_details/%
How then do i include node id to the title field in the page that links to the respective
conference_details/% view page.?
I have tried to REWRITE output field:Title as link using:
conference_details/%nid
conference_details/%Nid
conference_details/[%nid]
conference_details/[Nid]
conference_details/[nid]
with no luck. Can you please help. on how to do this . what i m trying to do


texts: how theme/template connected/related to each other

texts:
for example, I have:

module id: module_id (file: module_id.info.yml)
FieldType ID: FieldTypeID (file: /src/plugin/Field/FieldType/FieldType.php)
FieldWidget: FieldDefaultWidget (file: /src/plugin/Field/FieldWidget/FieldDefaultWidget.php)
FieldFormatter: FieldDefaultFormatter (file: /src/plugin/Field/FieldWidget/FieldDefaultFormatter.php)

and inside my field formatter:

public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = [];
    foreach ($items as $delta => $item) {
      $elements[$delta] = [
        '#theme' => 'my_field',
        '#type' => 'markup',
        // etc...
      ];
    }

    return $elements;
  }

I have file: my_field.module

with function:

function my_field_theme() {
  return array(
    'location_field' => array(
      'variables' => array(
        'x' => NULL,
        'y' => NULL,
        'z' => NULL,
      ),
      'template' => 'my_field',
    ),
  );
}

and I have template file: /templates/my_field.html.twig

as simple as:

name

content

with that, seems like i can't see my template, which i don't have any idea why?

how is theme or template name relate with the filename (or ID or anything)? - how are they connected each other?

what is the rule for that?

Thank you,

AnD


texts: Get the custom fields created for User entity in Drupal8

texts:
I was trying to get the custom fields created for User entity in Drupal8:

Drupal::service('entity_field.manager')->getFieldStorageDefinitions('user') is returning all the fields

Drupal::service('entity_field.manager')->getFieldDefinitions('user', '') is returning only the default fields

Was doing a diff of the 2 arrays, but I was wondering if there is a proper way to achieve this?


texts:
I am using quick tabs, but I want to display 2 blocks under each tab, been told I should use attachments but I don't get.

How can I achieve this?

So each tab displays 2 blocks when clicked like in the sketch.


texts: Can I invoke a template for print media?

texts:
I have a node type that is usually viewed as a web page but the client requires that occasionally it is also printed out in hard copy.

There is quite a lot I can do with css and media queries for print media but I would ideally like greater control over the content through the page templates.

As far as I can tell, there are no special theme suggestions for print and that theme functions, hooks, and templates are not aware of the target medium, be it screen or print.

This is a Drupal 8 project and whereas there were some Drupal 7 modules for print that might have been worth investigating, there doesn't seem to be anything right now for D8.

I any case, getting control over the content in a twig template would be quite sufficient if only I could tell that it was being rendered for print rather than screen.


texts: How to clear varnish cache using drush? I'm on acquia cloud dev account

texts: im working in an acquia cloud environment and currently im clearing the varnish cache via the web interface. is there a drush command to clear varnish cache while using an acquia environment.


texts:
I've been trying to create and update users and their pictures through REST calls using the services module. So far, I've got creating and updating users to work, but creating files to set their profile pictures still doesn't work.

I try to do a POST request to my API endpoint (http://www.domain.com/api/api_name/file), with the following data:

    $data = array(
        'file' => base64_encode($file),
        'filename' => $filename,
        'filepath' => 'public://' . $filename
    );

I POST this using CURL, with the exact same settings (apart from the API endpoint) as I'm using to create a user, which is working. However, I'm getting a HTML 500 as a response, with no response contents otherwise. The following error is logged in the Drupal error log:

Notice: Undefined property: stdClass::$fid in file_entity_access() (regel 1661 van /home/enschede/domains/aegee-enschede.nl/public_html/sites/all/modules/file_entity/file_entity.module).

The function that it errors on, file_entity_access, says that its $file parameter will either be an object, or a string with the file type (e.g. "image") if it is a create action. Apparently, it receives an object, so the create action is not executed properly on the server.

However, at this point I'm stuck. I can't find where these calls are coming from on the server, and I can't find anything I should change in the POST request. The fields I'm posting are the same as a tutorial I've followed. I'm posting the following fields to create a user, with the exact same CURL options otherwise:

    $initialData = array(
        'name' => 'test.user',
        'mail' => 'bogus_email@provider.com',
        'pass' => 'waytoolongboguspassword',
        'status' => 1
    );


texts: how to render a template inside a template?

texts:
I have entity Car which has a node reference of another entity: Review

Car has a custom .tpl file node--car.tpl.php and reviews have there own .tpl files "node--reviews.tpl.php"

when i try to render the reviews of the Car inside the node--car.tpl.php the reviews does not render using their own .tpl files,

i am using render() drupal function

can someone explain me why?

EDIT:

Heres the code which fetches the reviews:

function mymodule_get_reviews( $nid, $full = false ) {
    $field = 'field_car_reference';
    $sql_query = 'SELECT DISTINCT entity_id AS reference FROM {field_data_' . $field . '} WHERE ' . $field . '_nid IS NOT NULL
        AND ' . $field . '_nid = ' . $nid;

        $queryObj = db_query( $sql_query );

        $type = 'review';
        $nodes = node_load_multiple($queryObj->fetchCol('reference'));

    $reviews = array();

        if( !empty( $nodes ) )
        {
            foreach( $nodes as $nid => $node_review )
            {
                    if( $node_review->workbench_moderation['current']->state == 'published' ) {
                        $node_review = node_show( $node_review );
                        $reviews[] = $node_review;
                    }
            }
        }
    return $reviews;
}

the function is called as:

$reviews = mymodule_get_reviews( $node->nid );
if( !empty( $reviews ) ) {
  echo render( $reviews );
}


texts: How to get hal_json format as Drupal output?

texts:
I installed Drupal 8 and these modules on my host:

HAL
HTTP Basic Authentication
RESTful Web Services
REST UI
Serialization

These are all core modules except REST UI.

According to Drupal tutorials (https://www.youtube.com/watch?v=4xCndQQVJsg and https://www.youtube.com/watch?v=DnZo5lMICKc) when I enter this URL, Drupal would show JSON format of node 1:

www.example.com/node/1?format=hal_json

But it shows the normal (HTML) view of node 1.

What should I do to get JSON or hal+json format as output?


texts: I want to know the module through which any user can add his own tags for the content on the pages

texts:
I want to know the module from D7 which i can use to add tags for the any content.
Suppose i have one page Guide for beginners
then on this page there is word "Guide"
So at the bottom of the page there should be Add tag option in which i can add the tag for the word "Guide".
once i tagged it should display at the bottom in my tags.
So this facility should be for any user.
Please let me know the module if any available or the method for implementing this.

Thanks in advance.


texts:
I'm working on a new site with drupal 7+profile2+search api+apachesolr. Actually it's a dating site. I've developed an advanced search page (view(from search index)+exposed filters), and I'd like to filter online users too. (about on-off checkbox or radio) In addition I'd like to use it as facet as well.

I need some help because I don't really know how to start the process.

Thanks in advance


texts: How do I allow users to determine which other users can edit their content?

texts:
I'd like to let users specify which other users may edit their content. Basically a user would be able to create a piece of content, which they are then allowed to edit but no other users can edit (accept "admins"). This is all standard Drupal stuff so far and very easy. But now I'd like to let the user give permissions to other specific users to edit the content they created. So, the "creator" can now assign "editors", letting other users edit the content the original user created.

In case this isn't quite clear yet, here is a use case...

A site sells subscriptions which allow privileged users to create a Project on the site (Project in the sense of a software development project). The user who purchased the subscription can now create nodes of various content types that make up the content of the Project. But since no one likes to work alone, they can invite others to their Project. The invited users can edit any content created by the user who purchased the subscription.

So... how do I allow a user to specify certain other users which can edit his/her content and give those selected users edit permissions on all nodes created by the original user?


texts: creating a custom entity which stores multiple bundles as per user input?

texts:
I want to create an custom entity(Lets say payroll entity) which has the following fields
1. Basic salary
2. Earnings
3. Deductions

It is possible by Entities

But now I would like to add some new feature

Basic salary(field)
Earnings(Bundle) contains (bun1, bun2, bun3 fields)
Deduction(Bundle ded1,ded2 and ded3 fields )

If a user wants to set his employee's Earnings and other details he can manual sets it .For an example if a user needs to set his/her employee's salary like daily allowance, travel allowance, bonus etc)  he/she can do it from their own choice . And there should not be any restrictions for the no. of fields to add either bundles or fields . A user add custom bundles as well as custom fields.


texts: How to create a single View with 2 different, optional contextual filters?

texts:
I need to check whether there is already a registered user having the same user email or username. Right now I have two Views (one with passing the username and one with passing the user email as contextual filter). When there is no user with the username, the second view is called.

There is the "allow multiple values" setting for the contextual filter, but this allows me to pass 2 emails, but not an email or a username for instance.

Is there a way to create one View where the user enters a value (name or email) as filter?

SOLUTION:

As suggested by Marco that works well:


texts: point a subdomain to a page without using domain module

texts:
I want to add a subdomain to my site (mysite.local) so it is, x.mysite.local and I want that to land on a custom page, i.e. a node, a view. I do not want to use the domain module because it has way more stuff that I need. Is there an easy way to do that in a custom module?

I tried doing something like this in settings.php but that does not seem to work:

// Get the subdomain:
$sub = explode('.',  $_SERVER['HTTP_HOST'])[0];
if ($sub == 'test') {
  $config['system.site']['page']['front'] = "node/12664";
}


texts: Changing to date field based on from date using javascript

texts:
I have a form written using Drupal's FAPI (Drupal v7.15). The form includes two date fields - a from date and a to date. I've installed the Date module and both fields are both set-up to use the 'date_popup' widget.

Now I want to make the to date automatically change when the from date is updated by the user. Eg if the user sets the from date to 1st Nov 2012, I want the to date to automatically change to match the from date. Ideally I would also like the date picker to disable all options earlier than this date. This is the same behaviour you see on many travel sites, such as expedia.com.

I can't find a good example of how to add the Javascript to do this. I can only see AJAX examples, and it seems unnecessary to make a round trip to the server to do this - the browser has all the info it needs to do so client side.


texts: Performance and javascript issue in a drupal 7 website

texts:
I have a drupal 7 website. Currently its performance is not good and takes much time to render the web pages. For performance, I checked out in YSlow and came up with some results like move all js files at bottom, compress them and images too etc.

As far as I know its drupal structure to render js first at the head and then it loads the body content. So, Is there any way to move all js files at bottom of the web page in drupal???

I tried to aggregate javascript and css files with the admin panel in drupal but that is breaking some features of the website, say for example, some jquery and ajax codes are not working. Please suggest something for these problems as how can I approach for it.


texts: Create bundles programmatically using ECK (Entity Construction Kit)

texts:
The ECK module allows users to create custom entities.

When using this modules UI it is possible to create an entity type, and then attach multiple bundles to the entity.

It is also possible to create new entity types via code. This page shows an example which is as follows:

$entity_type =  new EntityType();
$entity_type->name = "eck_employee";
$entity_type->label = "Employee";
// Following line is taken from the eck_example.install file
$entity_type->addProperty('name', 'Name', 'text');
$entity_type->save();

This doesn't however show how to create and attach bundles.

Is it possible to attach bundles to entities when creating them via code (using ECK)?


texts: Conflict with modules uLogin and Profile 2

texts:
I use registration on my site for 3 types of roles by module Profile 2. Now i need use registration from social networks and i using uLogin but after registration from social user isn't has role.
What could be the reason?


texts: Directly changing a theme causes a "Functional environment bootstrapping" error

texts:
I bought a premium theme, installed it, and the site crashed with a WSOD, so I figured changing the theme back to Bartik would probably solve it. Thus, after reading the very fresh Drush 8 documentation I ran the command (also tried other variations that didn't work):

drush config-set system.theme default bartik

Yet, when I did that I got the same error I had before I moved the Dev environment from Windows10 to Ubuntu, that very same error "the demon who haunted me" that says (paraphrase): "Please use a more functional environment for bootstrapping Drush"... I mean, even Ubuntu isn't? Come on...

System details: Ubuntu desktop 15.10, apache 2.4.12, php 5.6.11, mysql 5.6.27... full session:


texts:
I have a form with multiple select elements with an #ajax callback on change. The ajax is working but the problem is that I can't figure out how to find which select has triggered the ajax. All ajax callbacks point to the same function.

Any ideas on how to find which select was changed?

Thanks.


texts: Getting a custom block image field URL in the block Twig template

texts:
I have a custom block containing a text field and an image field. I would like to render the block so that the image's URL can be defined as a data attribute of the block's wrapper div so that it can be used by a javascript function to create a parallax background effect behind the text field.

If I make a template file block.parallax.html.twig, I am able to render the image HTML.

{{ content.field_parallax_image.0 }}

However If I try to get the actual image URL, nothing is returned

{{ content.field_parallax_image.0['#url'] }}

If I dump the #item keys

{{ dump(content.field_parallax_image.0['#item']|keys) }}

I am able to get target_id, alt, title, width and height values, but I can't find the URL defined anywhere.

I have also tried to see if I could find anything useful in the block preprocess function but the field_parallax_image #url field in the variables is also empty

function mytheme_preprocess_block(&$variables) {
    if( isset($variables['content']['body']['#bundle']) && $variables['content']['body']['#bundle'] == 'parallax'){
        $variables['img_url'] = $variables['elements']['content']['field_parallax_image'][0]['#url'];
    }
}

Is there a way I can get this URL?


texts:
Is variable_set just creating a session variable or can I retrieve this variable from a cron job?

I can load the page over and over, but I always get this output.  It seems as though the data is not pulled from the variables table, but set only manually each page load.

$default_vals = get_defaults_variable_get();
clean_dump($default_vals);

save_defaults_variable_set();

$default_vals = get_defaults_variable_get();
clean_dump($default_vals);
clean_dump($_GET);

function get_defaults_variable_get(){
    $content[sort_direction] = variable_get('inventory_sort_direction');
    $content[threshold] = variable_get('inventory_threshold');
    $content[hide_zero_inventory] = variable_get('inventory_hide_zero_inventory');
    $content[email] = variable_get('inventory_email');
    return $content;
}

function save_defaults_variable_set(){
    //echo 'save defaults';
    variable_set('inventory_sort_direction', $_GET[sort_direction]);
    variable_set('inventory_threshold', $_GET[threshold]);
    variable_set('inventory_hide_zero_inventory', $_GET[hide_zero_inventory]);
    variable_set('inventory_email', $_GET[email]);

}

output

array
  'sort_direction' => null
  'threshold' => null
  'hide_zero_inventory' => null
  'email' => null
array
  'sort_direction' => string 'DESC' (length=4)
  'threshold' => string '5' (length=1)
  'hide_zero_inventory' => string 'true' (length=4)
  'email' => string 'e@sltwtr.com,bsaltzman@gmail.com' (length=39)
array
  'threshold' => string '5' (length=1)
  'sort_direction' => string 'DESC' (length=4)
  'hide_zero_inventory' => string 'true' (length=4)
  'email' => string 'e@sltwtr.com,bsaltzman@gmail.com' (length=39)
  'save_to_email' => string 'true' (length=4)
  'q' => string '' (length=0)


texts: How to recalculate the current User Points?

texts:
I manually deleted a couple of User Point transactions in my database's table userpoints_txn. This results in inaccurate current User Points in the table userpoints_total. Clearing caches or running cron doesn't resolve this problem.

Is there a way to recalculate the current total User Points for all users?


texts: How to display specific exposed filters of a view in a block

texts:
I have a set of exposed filters in one of my views. I want display a few of them as normal exposed filters and the rest exposed filters in a block in the head region of the view. Is there a way by which I can split the exposed filters & specify the filters to be displayed in the block?

Thanks


texts: How to find out whether or not a page is cached?

texts:
I have some serious problems with the performance of my Drupal website and I think that the problem may caused by the fact, that the pages are not cached. How can I find out whether or not a page was cached and if not, how can I find out why the page is not cached?

I am using varnish for my page.


texts: Can views pages be indexed and be searchable by apachesolr?

texts:
By default drupal will only send nodes to apachesolr, is there a way to send views pages to solr, so that they may show in the search index?

I know this question seems a little out there, just looking to see what clever minds within Drupal think about what can be done here.


texts: Views alter changes next row instead of current one

texts:
I have a view that is showing event content types. Users can apply for these events. I am using a hook to alter the 'view applicants' so I can show how many applications already excist.

The following code works and shows the values but is somehow skipping the first row and printing all the values one row later.

function frontview_general_preprocess_views_view_field(&$vars) {

  $view = $vars['view'];

  if(isset($vars['view']) && ($vars['view']->id() == 'evenementen') && ($vars['view']->current_display == 'accreditaties_overzicht')) {

    if($vars['field']->options['id'] ==='nothing_1') {

      // Getting the values
      $accreditaties = $vars['row']->_entity->get('field_accreditaties');
      $accreditaties = $accreditaties->getValue('list');
      $amount = count($accreditaties);

      $vars['field']->options['alter']['text'] = 'View Applicants ('. $amount .')';
    }

  }
}

This is my current output, the first row still shows the normal values without the hook but the first row values are printed on the second row, second row on third row, ...

This is the output that I need

I'm not sure why it's doing that, when I dd() my code it looks fine.

Thanks in advance!

*Drupal 8


texts: Module development - Layout of dynamic content

texts:
I am creating a drupal module that receives content from a Web Based XML API. The module takes some search parameters from a  user and embeds these into a XML command. I am at the point where I am receiving back a response and am able to process the returned data and display it on the page using a simple return statement. At the moment I am simply returning a html table that is created in the module.

What I would like to do is make content available to other Drupal modules such as Views or Display Suite. But as this data is not coming from the database but being created on the fly I am not sure where to start. Any help would be much appreciated.

Thanks
Simon


texts: How to trace menu links not linked to a node in views

texts:
I am using drupal 7.18 + views 7.x-3.5 + menu node views 7.x.1

I managed to make blocks of the children of the active menu item, using views and menu node views based on the menu node id contextual filter. (similar functionality with menu block module but more flexible).

Now i created some menu links that are linked directly to pdf files, so there is no node available.
Views can identify such menu links (not linked to a node)?

I just want to have a dynamic list of pdfs, using views accordion module.
Any suggestions on how to do that are appreciated!


texts: How can I add a new value for a multi-value field programmatically?

texts:
If there is a unlimited user text field named "user_log_field", How can I add a new value for it?

I'm planning to log the IP and location for each user every time they login. Is using an unlimited user text field a good idea for this purpose?


texts: Re-import nodes daily using feeds and hook_cron

texts:
My requirement is to import nodes daily night after deleting all the contents in that node type.

I enabled the cron settings in feeds module as 1 day and tried to write hook_cron() to delete all nodes.

function my_module_cron() {
  $results = db_select('node', 'n')
              ->fields('n', array('nid'))
              ->condition('type', 'ars', '=')
              ->execute()
              ->fetchCol();
  if (!empty($results)) {
    node_delete_multiple($results);
  }
}

But the doesn't seems to be deleted. I think this might be because of the user access problem.

I also want to know will the delete occurs before re-importing. How to order the cron jobs or shall I run the import via code after deleting the nodes.


texts: How to map uid in users table data to the entityid in feild table to retrieve data of the users in drupal7

texts:
I would like to retrieve data related to users with the uid in users table.

But the uid is not mapped in the feild_data tables which has entity_id and entity_type.

How are these two ids mapped in drupal database 7


texts: Drupal 7 views: Get NID in views using contextual filters

texts:
Does anybody know how to get the nid from a node using contextual filters or filter criteria in views

WITHOUT using "Get id from url"? I was thinking about using PHP or getting it from a node-field.

My view is a block of comments that is to be placed together with a node. The comments needs to belong to the node and linked by node ID. In this case the "Get ID from url" wont work since the node itself is listed in another view.

It is a view-block (containing comments) inside of a node that is listed in a view.


texts: Have Leaflet marker popup open on page load

texts: Has anyone used Leaflet to display a single location, while making the "popup" open when the map is loaded?  This is really easy to do in Leaflet, but the module's JS is a little hard to decipher.  Any help would be appreciated.


texts:
I would like to ask about my logic problem with site. I want to make a searchlist of distributors. Client selects manufacturer, and all distributors who are providing goods from certain manufacturer will be displayed. I have two content types: 1. Distributor, 2. Manufacturer. Im assigning x manufacturers to one distributor (multiple entity references). And the problem is here. I want to have for every distributor link to their shop where they offer the goods from selected manufacturer. How it can be done if one distributor can have x manufacters? I tried to search some module which dynamically adds text field for every nodereference which is set to multiple values, but didnt find anything. If I use multifield I cannot acces is aterwards with entity reference filter.

Just to be clear this is how it should look like.

Distributor1

Manufacturer-1
Manufacturer-x
Manufacturer-y

Distributor2

Manufacturer-1
Manufacturer-x
Manufacturer-y

Distributor3

Manufacturer-x
Manufacturer-y
Manufacturer-z

Distributor4

Manufacturer-1
Manufacturer-x
Manufacturer-y

Distributor5

Manufacturer-x
Manufacturer-y
Manufacturer-z

Distributor6

Manufacturer-1
Manufacturer-x
Manufacturer-y


texts:
I am implementing the following in a module:

function foo_module_menu() {

    $items['taxonomy/term/%'] = array(
    'page callback' => 'subproducts_populate_taxo',
   'page arguments' => array(1),
    'access callback' => 'user_access',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);

    return $items;
};

This hook doesn't seem to work, i assumed it was because of the taxonomy module having prevalence on this menu item, so i gave my module a -1 weight.

Now strange thing, it work but only after clear cache once after applying the weight change. If i reflush cache the Taxonomy module take prevalence again even though i didn't rechange the weight..

Any ideas ?


texts: Order of search results for exact match content

texts:
I am using Search API module with Search API DB module to use drupal database for search indexing.

Issue is when I do a phrase search as following "test content" I get results having "test"(let's say nid:1) or "content"(nid:2) or "test content"(nid:3) in them but the content having exact match which is "test content" which is node 3 shows down in the search results.

I do not have any fields for sorting in my search view.

My question is why I am not getting search results on phrase match on top of those who have partial matches?


texts: Stop overriding for the development snapshot module

texts:
I have a development snapshot for a module (ABC-8.x-1.x-dev). I added 4 Patches. Now the developer does commit updates to the module.
By running composer update, I will loose all my patches.
When I remove the module name from composer.json, the module gets deleted. I have read that I should remove the composer.json file within the module.
Is there some kind of sub-version that defines the commit or so, for example "drupal/abc": "~1.0-dev-FD1512" or "drupal/abc": "~1.0-dev-221"?


texts: writing form action path programmatically

texts:
Here is a custom user login form by Overriding the template. But can't understand how to print the destination/action path on the form. here is my code:

  block--user--login.tpl.php

<form accept-charset="UTF-8" id="user-login-form" method="post" action="/node?destination=node">

  Username *
  <input type="text" class="form-text required" maxlength="60" size="15" value=""     name="name" id="edit-name">

  Password *
  <input type="password" class="form-text required" maxlength="60" size="15" name="pass" id="edit-pass">

  <input type="submit" class="form-submit" value="Log in" name="op" id="edit-submit">

Create new account

Request new password

<input type="hidden" value="<?php print $elements['form_build_id']['#value']; ?> "     name="form_build_id">
    <input type="hidden" value="user_login_block" name="form_id">

</form>

Here we are using a default path like action="/node?destination=node" its really a bad idea..So i want to print the action path programmatically.. Any idea?
This maybe an idea: <?php print $elements['actions']['#the_path']; ?>


texts:
I made a custom log in, register and forget password templates, to hide the theme region and wrote a css code.
the issue here when open the page using colorbox module the regions appear for few second before they hide by css code, what i need to disable the theme region in those custom pages.
any advices?
Thanks.


texts: Load node by value of a field and update value for another field

texts:
I'm trying to load a node by a value in a custom field (field_one) to change the value of another custom field (field_two) on that node.

I am using the following code to load the node:

$nodes = \Drupal::entityTypeManager()
      ->getStorage('node')
      ->loadByProperties(['field_one' => $fieldValue]);

I am then trying to update the value of "field_two" using the following code:

if ($node = reset($nodes)) {

    $node->set('field_two', 'New value');
    $node->save();
}

The above results in the error "InvalidArgumentException: Field field_two is unknown... "

It works if I try to set the value of the title ( $node->set('title', 'New value') ) but I can't get it to work for custom fields?


texts: One of my menu items I have, I want to make it so that only the child links are clickable, and the parent is not. Is there a way to make the parent a sort of "Dummy Link" just to set a hierarchy for a menu?


texts: How can I create a hook into an external module

texts:
I want to be able to alter a function inside another module like a hook, but I'm not sure if that's what it's called. I want to alter a function inside another module from my module without changing the external modules code.

This is in version 7.x.

Thanks
Frank N.


texts:
I have an EntityForm referenced on a node and I need to show submissions on a view where :

Node Author can view all submissions
Submitter view his own Submission (for edition purpose)

How can I do so?


texts: D7 Rules - User Profile Field in Send Email Action

texts:
I'm using D7 with Rules 7.x-2.7. I am trying to create a Rule that will email and BCC all users of a particular role when a node of a certain content type is created. I've added the event: After saving new content of type..., and the action: Send mail to all users of a role. What I'm now trying to do is pull in the user profile data to populate the email body. Something like:

Hi [user-field-firstname],

A new announcement has been released. Please log in to your profile and browse to http://examplesite.com/user/[user-id]/announcements.

regards

I've been unsuccessful thus far. I've tried to add another action of Fetch entity by Id, but could find any decent selectors in the data selector. Any advice for me, please?


texts: How does Feed import get a list of the CSV fields to map to content type fields?

texts:
I am using Feed import to load a CSV file exported from an SQL database into Drupal and I am stuck at the stage where  I need to map the CSV field names to the Drupal content type field names.

I think there as to be some stage in the process where in some form or dialog I can input a list of the CSV field headers and proceed to a form which enables me to match the CSV headers to the field names of the content type, but I can't find such a page in the list of pages I have to follow.

I am sure I have followed the Feed Importer creation process properly. Am I missing something, or this capability not included in the Feeds CSV importing system??


texts: How do I correctly cache a themed menu output?

texts:
In mytheme_preprocess_menu(), I am altering the main menu:

function mytheme_preprocess_menu(&$variables, $hook) {
  $node = \Drupal::routeMatch()->getParameter('node');
  if ('menu__main' == $hook) {
    if ($node) {
      _mytheme_menu_replace_with_project_items($node, $variables['items']);
    }
  }
}

In _mytheme_menu_replace_with_project_items(), I check whether the current node is a project node, and show that node's submenu instead.

When I visit the node the menu gets displayed, but when I add another node with another project reference, the menu of the former node gets displayed.

How can I correctly cache that?

I tried with the following code, but it didn't work.

$variables['#cache']['tags'][] = 'node:' . $node->id();
$variables['#cache']['contexts'][] = 'route.name';
$variables['#cache']['contexts'][] = 'theme';


texts:
Is this possible to  use drush in  dedicated host that only I can access cpanel?
If yes how can I do it?


texts:
I have installed Kickstart Commerce 2. With the demo store, the social media buttons (facebook like, g+, and tweet buttons) are shown at the bottom right of the product page directly below the add to cart button, as shown in this kickstart demo store link, http://demo.commerceguys.com/ck/drinks/drupal-commerce-wake-you).

When I create a new product of a content type that was pre-created by the demo store, these social media icons show up the same way. But now that I have created my own content type for other products I choose to add to my store, this does not display. I thought it was a block, but no blocks seen to have this information.

How do I display social media buttons on new content pages on my Drupal Commerce site?

Thank you to anyone they can offer some direction in this please.


texts: Create a filterable, sortable admin view that produces front end block

texts:
The goal is to produce a single block to go on the homepage with 5 linked terms from a single taxonomy vocabulary. These terms would be selected and then ordered in an admin interface by a content administrator. The taxonomy vocabulary itself my have 30-50 terms.

I thought I could create an admin view with an exposed form to select the terms and then apply draggable views to the results, but I am having trouble combining the exposed form and draggable views. I am also having trouble turning the results into a block.

Happy to ad more info if this is vague, but all of the views I have set up have been so wrong I did not want to waste anyones time by posting them here.

Would views / exposed filters / draggable views be the right way to go about this or is there a better way? I'd rather not install something huge like panels to make this happen.


texts: Youtube embed won't work without other character or whitespace

texts: I am not able to embed Youtube video in embed field or in normal body area, when the content is only the video embed code. But if I add any character or a whitespace it works. I am not able to explain to the client why it is like that not explain a logical reason for the same.


texts: I have some prior experience in PHP programming but I had used Smarty as my template engine, and found it easy to use. I read that Drupal is making use of PHPTemplate as template engine. So, I just wanted to know how to implement Smarty template engine in Drupal?


texts: How can I create a new field with a line break in it?

texts:
I created a few fields which always stick together with no free space at all.
Then I created a new field between them which I named linebrake, chose the "long text and summary" (which is the only type where I can add html-code) and wrote
 (

 doesn't work) and now I have like 3 line breaks at once.

Is there any way to get only 1 line break?

Thanks in advance


texts: How to add code that will run on visiting a URL, in addition to another module that also has code that will run on same URL, & control execution order

texts:
I'd like to make a custom module that runs code when a URL is visited and then allows an existing module with code that also runs on same URL.
So in the case of the existing module that runs on the URL, it is not affected by my module. That existing module still runs as it would in any case.
I would like my module to run first before the other module.
I'm already familiar with making a custom module and with routine, for example here: [How do I run PHP code when visiting a specific URL?]]1
And I've seen this other answer: Override specific routing from a core module But this seems to replace the routing of another module and I don't want to do that as said, I want my module to also run on the same URL as another module and be able to control my module running before the other. Thank you.
One thought I have so far: is the execution order of modules controlled by their order in core.execution.yml config file?
Background:
I want to run code on a callback method at the end of a 3rd-party login authentication. I believe that the callback might be a GET or POST and I'd like my code to read the values of the GET (param) or POST (form submission values) and just pass the URL call back and these intact to the original module, so it processes them as it wants as if my module hadn't looked at them in the first place.
I want my module to look at the data in the callback as GET or POST to decide what role to give the user that's been created and what Drupal Group for it to make to belong to, as a result of the data from the 3rd party authentication.


texts: How to override "Create @bundlename" text?

texts:
I'm using String Overrides module to override some strings on my site. I could override some strings like

"Performance" to "Clear"   (admin/config/development/performance)

"Content" to "List of Nodes" (admin/content)

But it doesn't override "Create @bundlename" strings like

"Create Article" to "New Article".

When I navigate to /node/add/article it's still showing Create Article as title of the 'Node add form'.

I've cleared cache, but still not working.

Any suggestions?


texts: Creating multiple destinations from one source

texts:
I'm writing a Drupal 8 migration from a non-Drupal site where I need to migrate news articles that have inline images in them, sometimes more than 10. I've figured I'll do this in two steps:

A migration for creating file entities for each image present in the source node body.
A migration that creates news article entities, and for each image encountered, look up the file entity that was created in the 1st migration and use the File Usage API to indicate the file is used in this node.

My problem is the first migration. The Migration API wants to map a single source to a single destination. I need to be able to map a single source to MULTIPLE destinations, since I will be creating as many as 10 file entities from this single source row.

Does anyone know if this is possible, and if so, are there any examples in core or contrib migrating like this?

If I can't find a way to do it this way, I'll instead just migrate everything in the same single migration, and create the file entities on the fly. I'll just have to write a custom rollback implementation to remove them as well.


texts:
does anyone know how to disable a javascript loaded by drupal?

<script src="/profiles/ncr/themes/contrib/bootstrap/js/bootstrap.js?ny8c02"></script>

I tried the following in the template.php file but no luck.

function bootstrap_ncr_js_alter(&$javascript) {
    $path = drupal_get_path('module', 'js_theme');
    unset($js[$path . '/bootstrap.js']);
}


texts: How do I add an expression into a query?

texts:
When I use the code below, I get the following error:

  Call to a member function addExpression() on a non-object

 $query = db_select('node', 'n')
    ->fields('n', array('nid'))
    ->execute()
    ->fetchAssoc();
  $query->addExpression('MAX(nid)', 'max_nid');

What is wrong with that code?


texts: How to change a field type from Integer to Decimal?

texts:
I have a content type with an integer content field. The field needs to contain float data. What's the easiest way to change the field type from integer to decimal? (There are thousands of existing nodes I will have to convert).

I've found a solution in this comment and this comment. Is it the best?


texts:
What is the correct syntax to test if a file has been uploaded in a webform in a twig email template?

For a text area, {% if webform_token('[webform_submission:values:question_text_area:value]', webform_submission) %} works fine but to test if a file has been uploaded, {% if webform_token('[webform_submission:values:join_a_file:value]', webform_submission) %} does not work.

Also, when there's a file uploaded, I want to display in the email only the title of the file ... {{ webform_token('[webform_submission:values:join_a_file:delta:format:value]', webform_submission) }} works but it outputs a link to that file. Is it possible to just have the text of the file name?

Thanks!


texts:
I've installed the multiselect module, to add this option in a custom form.

The problem is that when I see the options, it shows this:

Does anybody know if there is a way to solve this?

This is the code of the form.

  $form['municipios'] = array(
 '#type' => 'multiselect',
 '#title' => t('Municipios'),
 '#options' => $options2,
 '#required' => TRUE,
  );

($options2 is an array with all the option)

Thank you.


texts: What is the best way to theme page--front with twitter bootstrap?

texts:
I am trying to create a user dashboard by design a flat menu for page--front.tpl.php, and the twitter 3.0 bootstrap. My current site is using Omega's OHM responsive theme as default, so my question is, how do I apply twitter bootstrap to just a SINGLE tpl file?

There's a part 2 if its related, copying page.tpl.php and calling it page--front.tpl.php isn't being recognized (I do this within ohms templates/system dir, and cleared cache). I've read through Drupal.se, and googled it and tried the variety of things - but I guess I don't understand how drupal recognizes page--front. Do I assign a piece of content as home page then it gets applied? If so, that's the page I need specifically themed with bootstrap only.


texts: Views Filter to display field only if it matches a certain value

texts: how do I display a field in views ONLY if the value matches a certain specified value?


texts: IE7 IE8 layout broken if advanced aggregation is enabled

texts:
When I install & enable Advanced CSS/JS Aggregation, my site layout breaks in IE7 and IE8.

How could that happen? Is there CSS3 in the compiled/compressed CSS? What should I do?


texts:
I am trying to create a solution programmatically where I can give access to edit a particular block to a user.

I know using hook_entity_access() I can grant permission to the user to access the block, But the block doesn't show the "edit" icon which I need to help the user to navigate to the edit page.


texts: What is "Keyword relevance" in Search setting in Drupal 7

texts: Can anyone please explain me what is the "Keyword relevance" in search setting and what is does.? i followed many websites but i could not understand this.


texts: What does "attach to content type" option in Feeds importer do?

texts:
I am struggling to find a clear explanation of what the "attach to content type" field in the basic settings of a Feeds importer actually does. The closest explanation I can find is from here:

"Feeds importers" can be used attached to a content type or on
standalone forms. If attached to a content type, an import (or
aggregation) is created by creating a node. This is e. g. useful when
you would like your users to contribute feeds or when you need to
track many feeds of data of the same kind.Alternatively, a Feeds
importer can be used on a standalone form. This is useful for one-off
imports like importing nodes.

I don't understand what this explanation means. Would be grateful if someone could explain what setting this "attach to content type" option actually does.


texts:
I have a view that is showing a single image, and I need the image to link to a specific URL, but when I try using Rewrite Results on the field it will still show the image but doesn't add the link.

I have tried both "Rewrite the output of this field" putting in [field_file] and "Output this field as a link" putting http://example.com in the field and neither of those ways worked.

How can I rewrite the field to have the link on the image?


texts: Modules i18n: How to set the default language home page url without alias

texts:
I have a standard Drupal 7 installation with the i18n module and 3 languages defined.

one basic page "node/1" created with the URL alias "home"
in the Configuration > System > Site Information the default front page is "home"
created other 2 languages (pt-br and it)
created the translation of the basic page "node/1" to pt-br and it (are created "node/2" and "node/3" pages)
the 3 pages "node/1, 2 and 3" have the same alias "home"

If I go to mysite/en, I see the defined front page in english and all the site is in english: it's ok!

The problems:

If I go to mysite/pt-br/home, I see the site in portuguese and the "node/1" in porguguese: it's ok!
If I go to mysite/pt-br, I see the site in portuguese but the "node/1" content in english and not the "node/2" (portuguese version of the basic page): wrong!
the same thing to the italian version.

What is wrong? How to set the correct language node for front page in the default language url (mysite/pt-br and mysite/it)?

Note: In the Detection and Selection tab is the original items with the default order (URL, Session, User, Browser and Default) and I have been enabled all (in the Configure page of URL the selected option is the Path Prefix).


texts: setErrorByName() not highlighting multi-select fields

texts:
I have the following HTML code, generated by drupal

<div class="multiselect-selected">
<select multiple="multiple" name="field_test_ins[]" data-drupal-selector="edit-field-test-ins" aria-describedby="edit-field-test-ins--description" id="edit-field-test-ins" size="12" class="multiselect-selected form-multiselect">
</div>

In custom test_validate(), I tried below approaches for multi-select field highlighting in validation function.

function test_validate(&$form, &$form_state) {

//Tried below ways:

//Case 1:
    $form_state->setErrorByName('field_test_ins', t("ERROR_MESSAGE-1"));

//Case 1:
    $form_state->setErrorByName('field_test_ins][', t("ERROR_MESSAGE-1"));

//Case 3:
    $form_state->setErrorByName('field_test_ins]', t("ERROR_MESSAGE-1"));

}

When I submit the form, the error message appears at the top of the form, but the multi-select field is not highlighted.

I tried all the above approaches, but no luck.

Can anybody suggest how to highlight this multi-select field?


texts:
Using latest Drupal 7.
Cannot figure out why CK editor is not showing.
Granted all permissions to my administrative user, cannot edit configuration because links don't work, no dropdowns.
What am I missing?


texts: How can I show a list of terms from a specific vocabulary that are not assigned to the current node

texts:
I need to create a view of terms from a specific vocabulary for a specific node, where the view will contain only those terms that are not assigned to that node.

I've tried various methods within Views without luck. The closest I got was to use aggregation so I could identify terms with a zero node count. I had hoped that by using the NID as a contextual filter then the view would only count based on the current node. That's not how it worked out.

Any thoughts?

Thanks

David


texts: I'm getting swamped by spam users.  Can I use rules to automatically delete users that 1) don't have content/comments, 2) have never activated in a few weeks, and 3) have only activated the same day they created their account, but haven't posted content/comments?


texts: $_SESSION vars created outside of Drupal lost when navigating to a Drupal served page

texts:
I'm building a Facebook iframe app in Drupal.

I'm using an initial simple PHP script (non-Drupal driven) to handle the Facebook open auth side of things - this script is getting the Facebook user's name, id, profile pic etc.
This script stores those values to session vars. Then it redirects the user to a page served by Drupal.

My understanding looking at the D7 session.inc is that pre-existing session vars should be maintained when Drupal session start is called. But if I print_r() the $_SESSION array, it is empty.

So essentially a plain PHP script saying:

session_start();
$_SESSION['name'] = 'bob';

sets the session correctly.
But when then adding a redirect (header()) to a Drupal served page I can no longer get that name variable and the session is empty.

Any suggestions/tips?

Thanks,
Steve


texts: IMCE stops uploading image in the middle of uploading

texts:
I have a very strange case. I am using IMCE 6.x-2.2. and when my editors try to upload a new image, it stops uploading in the middle of the process and gives message: "A file with the specified name already exists.".
now when i check on the server, i found that it has uploaded part of the image only (image cropped).
this happens always on google chrome and sometimes on Firefox!!
any idea is highly appreciated


texts:
I've got a website filled with events. Some events have a start date, others don't. I sort my events by date on the frontpage so the event closest into the future shows up first.

But their are some events with no dates. These kind of events take more than one day/week/month/... so it doesn't make sense to add a (single) date.

How can I make a list, by using views, where the dates with a date show up on top and those without close the list by showing up at the end of the page.

Any suggestions on filters or work-arounds where I can specify this kind of sorting criteria?


texts: Make quiz link look like a button or apply css style

texts:
I have rendered the quiz entity teaser display into a content type and would like to know how to apply a css class to the "download certificate" and "take quiz" links.

Usually this would be done by editing the content type display, and in this case, the teaser for the quiz. The only options I am given is to show or hide the link.

Furthermore, I can't find the settings for the "download certificate" link, which doesn't show up in the display settings at all. They are called buttons but do not look like buttons.

What I've tried:

looking for the settings where I can apply CSS to these buttons.
used Chrome browser inspection tool to see that there is a style class already being applied to a href, called quiz-start-link; I tried creating some custom css for both a.quiz-start-link and just .quiz-start-link to no avail.

Would I just need to figure out how to harness quiz-start-link or can I edit this to apply my own?


texts:
I am using following code to replace current-user:email token.

 $pattern = '[current-user:mail]';
 $output = $token_service->replace($pattern, array('current-user' => $account), array(
            'clear' => TRUE,
            'callback' => xyz_function($pattern_array),
          ));

In the callback function i am doing

foreach ($replacements as $token => $value) {
  $replacements[$token] = _cleanstring($value);
}

I guess i am passing wrong array('current-user' => $account) argument. Where am i doing wrong?


texts: Update title field in hook_ENTITY_TYPE_insert()

texts:
I use hook_ENTITY_TYPE_presave() and hook_ENTITY_TYPE_insert() in order to update the node with a title using its ID.

function <module_name>_node_presave($node) {
  // ...
  if ($node->isNew() && $node->getType() == '<custom_content_type>') {
    $node->title = 'New entity ' . $node->id()->value;
  }
}

function <module_name>_node_insert($node) {
  if ($node->getType() == '<custom_content_type>') {
    $node->title = 'Submission #' . $node->id();
    // more code...
    $node->save();

  }
}

The first setting of title in hook_ENTITY_TYPE_presave() is only done because no entity can be saved without title. However, it seems like the setting of the title in hook_ENTITY_TYPE_insert() does not change anything.

I have already tried calling node->save(); in hook_ENTITY_TYPE_insert() but it gives me an exception stating that I try to store an entity using an already existing primary key. The exception message is

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

  Drupal\Core\Entity\EntityStorageException: SQLSTATE[23000]: Integrity
  constraint violation: 1062 Duplicate entry '48' for key 'PRIMARY':
  INSERT INTO {node_revision} (nid, vid, langcode, revision_timestamp,
  revision_uid, revision_log) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3, :db_insert_placeholder_4,
  :db_insert_placeholder_5); Array ( [:db_insert_placeholder_0] => 45
  [:db_insert_placeholder_1] => 48 [:db_insert_placeholder_2] => en
  [:db_insert_placeholder_3] => 1485011236 [:db_insert_placeholder_4] =>
  11 [:db_insert_placeholder_5] => ) in
  Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 770 of
  core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

Can I change the title of the new entity (using the id)? Should I use another hook?


texts: How to add the User:Picture field on the account registration form?

texts:
I saw the User:Picture field after setting the User:uid contextual filter for a Views block. Now I am wondering how to show this field on the account registration form? I looked at config/people/accounts/fields but nothing there.

Any help is appreciated.


texts: Get node's view mode within template_preprocess_page

texts:
We have to get the current node's view_mode from within the mymodule_preprocess_page(&$variables) hook. When we tried the following we could not get the view_mode after performing some validation to make sure we have a node object.

In the Basic page, we have a Related Articles section that is an entity reference to the Article content type. This returns multiple nodes depending upon the page and we want to ensure the template_preprocess_node() hook is ran only once.

How can we get the current node's view_mode from within the template_preprocess_page(&$variables) hook?

Here is what we tried to do

function mymodule_preprocess_page(&$variables) {
  $node = $variables['node'];
  if(isset($node) && is_object($node) {
    // Tried printing variables but cannot find `view_mode`
    ksm($node);
  }
}


texts: Stay with 7.19 or hack 7.22 (to avoid the "itok" issue)

texts:
First things first, I don't need a DDoS prevention mechanism in Drupal since that is my server's job.

In all my Drupal installs, I usually hide the identity of Drupal for security reasons. Image style token (itok) is also a Drupal identifier. I tried a hack to remove itok in 7.22, and found out itok is not a small implementation, which may need more work to get benefit from the community after hack.

I'm just wondering if there is a better way.


texts: How to get image URL of the product image field in Drupal Commerce

texts:
I'm stil pretty new to Drupal Commerce and I've run into a small issue with something that has worked for me in the past. I'm working on a custom Product Display node template and I'm wanting to get just the URL of the image in the image field. Right now I'm rendering the image with:

<?php print render($content['product:field_image']); ?>

In the past I have generated just the image field URL with the following code:

<?php echo file_create_url($node->field_image['und'][0]['uri']); ?>

However, modifying that to call product:field_image results in a total page error. Does anyone know the proper syntax to generate just the URL of the product image field?


texts: How to create a view block only visible to the Referenced Content Type's Author?

texts:
I have 2 custom content types: Item for sale, and Bid (offer). The latter has a node reference URL to a node of the first content type.

I created a view (block) which shows the people with their offers.

I need to edit this view in such a way that is will be only visible to the person who created the Item for sale (author of the first content type may only see this block).

How can I achieve this? I cant seem to find a way with contextual filters.


texts:
I only want to have certain content types indexed, for the default Drupal 7 search. And I would like to do this without installing any other modules.

I would like to do this by hooking into the query (using hook_query_alter) that grabs all the nodes from the search_dataset. This query is found in the node_update_index function (node.module):

$result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit, array(), array('target' => 'slave'));

The problem is I never get the ability to alter this query in the hook, my code is as following:

function mymodule_query_alter(&$query) {
  var_dump((string)$query);
}

At some point it should print the db_query_range query. I've also tried printing my debugging to a file so I could catch those queries running ajax time.

Any ideas on what I might be doing wrong?


texts: Php Access User Data from external script

texts:
Currently my Drupal installation is at www.example.com/wiki/

I was wondering if it is possible in Drupal 8.2.4 to access the current user uid from an external php script.

The script is located at www.example.com/someScript.php

I've tried this before

include_once('./includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

global $user;

if ($user->uid) {
    print "Logged in";
} else {
   print "Logged out";
}


texts:
Hi Every one I am trying to create new field collection item programmatically but code is not working. I want to create a number of field collection items but no Luck. My code is following.

use Drupal\Core\Field\FieldItemListInterface;
use Drupal\field_collection\Entity\FieldCollectionItem;

function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if($form_id == 'my_form'){

for($i = 0; $i < 2; $i++) {

$new_experience_item = FieldCollectionItem::create(['field_name' => 'field_collection_name']);

      }

    }

}

My first Question-> Can we run this code in the hook_form_alter?  If yes, Then why my code is not working perfectly?


texts: How to use presave hook to save a field value as node title?

texts:
I have a custom date field in a node type 'day'.
When the node is saved (or edited then saved), I would like to get the field_date value (not the published date) and save it into the title field.

I would like to know how, perhaps using a module to:

hook_presave

GET FIELD VALUE
SET TITLE AS FIELD VALUE
SAVE NODE


texts:
I want to notify users immediately when a node they’ve subscribed to is commented on, but then not send them any more notifications (from any other node either) until they’ve visited the site.  This is because I want users to immediately know when a discussion has a reply, but not have their inbox filled up with unnecessary emails. As far as I know no module can do this.

Im more of a themer than developer but it occurred to me that maybe this could be done with the Rules module. It would work this this:

1) When a node is commented on, send an email to the user if the user doesn't have role of ‘no’, and then add a role of ‘no’ to user.

2) When the user logs in, wait until they log out or are timed out, and then remove the role of ‘no’.

My reason for waiting until the user logs out before removing the role is I don't want them to get emails of comments while they are on the site. These may be emails from a discussion they are replying to several times while still logged in.

One issue could be if a user closes down their browser or leaves it open without refreshing it, but doesn't log out. Then Rules won't send them an email until they are timed out but they won't be aware or any comments made before this. Is there a solution to this?

Does anyone know how other forum software deal with this situation of wanting to have immediate notifications but not send loads of pointless emails to users?


texts:
Let's say I have the following in example.links.task.yml from a contributed module:

    example.view:
    title: 'View'
    base_route: 'entity.example.canonical'
    route_name: 'entity.example.canonical'

    example.edit_form:
    title: 'Edit'
    base_route: 'entity.example.canonical'
    route_name: 'entity.example.edit_form'

    ... more routes with the same base_route

Now I'd like to add a custom access restriction for all these local tasks. I tried to set a restriction to the base_route, thinking that all other routes with this particular base_route would have the restriction too, but it only works for entity.example.canonical. I tried the following way:

class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if (($route = $collection->get('entity.example.canonical'))) {
      $route->setRequirement('_role', 'administrator');
    }
  }

}

I could explicitly name all different routes, but I thought there might be a way to only use the base_route - not knowing if this would work though. Any ideas?


texts:
One of the security principles is sanitize string and variables passed from client to server; SQL injection is one of the way to hack a website. in plain PHP there are some functions to prevent SQL injection:

mysql_real_escape_string()
stripslashes()

What is Drupal 8 strategy to prevent SQL injection? How can I clean up client data post in my Controller to protect my site from SQL injection?


texts: Divide menu tree parents and children links into columns

texts:
I have the following menu tree for my main navigation:

Parent 1 (= level 0)

SubParent 1 (= level 1)

SubChild 1.1 (= level 1)
SubChild 1.2 (= level 1)
SubChild 1.3 (= level 1)

SubSubParent 1 (= level 2)

SubSubChild 1.1 (= level 2)
SubSubChild 1.2 (= level 2)
SubSubChild 1.3 (= level 2)

SubParent 2 (= level 1)

SubChild 2.1 (= level 1)
SubChild 2.2 (= level 1)
SubChild 2.3 (= level 1)

SubParent 3 (= level 1)

SubChild 3.1 (= level 1)
SubChild 3.2 (= level 1)
SubChild 3.3 (= level 1)

Parent 2 (= level 0)

etc.

I am building a custom Bootstrap 4 theme.

I need to build a custom Mega menu dropdown (just theming and styling is my approach), that goes and fit well together with Bootstrap Navbar, dropdown-toggle and so on.

So if you hover or click on e.g. Parent 1 link you see the following Mega menu dropdown. I want to achieve the following example (see screenshot):

In menu--main.html.twig I made the following macro:

{# Custom macro for dropdown menu in Megamenu  #}
{% macro submenu_megamenu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}

      {% for item in items %}

          {{ link(item.title, item.url, { 'class':['list-group-item']}) }}

      {% endfor %}

  {% endif %}
{% endmacro %}

Then my menu_link macro:

{% macro menu_links(items, attributes, menu_level) %}
  {% import _self as menus %}
  {% if items %}
    {% if menu_level == 0 %}

        {% for item in items %}
          {%
            set classes_list_item = [
            'nav-item',
            item.is_expanded ? 'dropdown',
            'navigation'
          ]
          %}
          {%
            set classes_link = [
            'nav-item',
            'nav-link',
            item.is_expanded ? 'dropdown-toggle',
            item.is_collapsed ? 'dropdown-toggle',
            item.in_active_trail ? 'active',
          ]
          %}

            {% if item.below %}
              {{ link(item.title, item.url, { 'class': classes_link, 'data-toggle' : 'dropdown' }) }}
              {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
            {% else %}
              {{ link(item.title, item.url, { 'class': classes_link }) }}
            {% endif %}

        {% endfor %}

      {% elseif menu_level == 1 %}

              {% for item in items %}
                {%
                  set classes_link = [
                  'dropdown-item',
                  item.is_expanded ? 'dropdown-toggle',
                  item.is_collapsed ? 'dropdown-toggle',
                  item.in_active_trail ? 'active',
                ]
                %}

                  {{ link(item.title, item.url, { 'class': classes_link }) }}
                  {% if item.below %}
                    {{ menus.submenu_megamenu_links(item.below, attributes, menu_level + 1) }}
                  {% endif %}

              {% endfor %}

          {% else %}
           ???
    {% endif %}
  {% endif %}
{% endmacro %}

Ok I am getting close. It's adding now different CSS classes and HTML markup to level 0 and level 1 links. The level 1 parents (and it's Childs) are divided into (4) columns. And it's expanding the childs.

But how do I render SubSubParent 1 (= level 2) and it's childs into the same column as it's parent (like on the example screenshot in the first column)?


texts: pecl uploadprogress installed, but I don't see it anywhere

texts:
I've successfully installed the PECL uploadprogress extension and restarted my server. Here's an exerpt from phpinfo():

However, when I add a piece of content and I choose to upload a photo or a video or a generic file, all I see is the normal ajax spinner but I don't see any kind of upload progress UI that I see on the drupal site (Install PECL uploadprogress), which looks like this:

What am I missing?


texts: How do I deal with loading too many objects?

texts:
I'm totaling Ubercart orders grouped by credit card type (VISA, MC, etc). Given the order id, I can
 1. load the order object using uc_order_load($order['order_id'], TRUE)
 2. and use $order_obj->payment_details['cc_type'] to get the card type.
However, my query is resulting in a long list of order_ids, so I'd be loading a lot of order objects.

My page hangs when my query returns more than around 10 order ids, showing only

  Service Unavailable

  The service is temporarily unavailable. Please try again later.

Which goes away when I comment out the object loading.

So I'm guessing I have too many order objects loaded. I tried using the reset argument to uc_order_load, but saw no effect. I've seen this before with custom objects. So how do I manage this load of objects, please?

(Drupal 6)


texts:
I have different registration pages for different user roles in drupal, for some users i would like them to be able to create an OG group when there accounts is created.

I have a field in the registration form for group name which i would like to be used in creating the new group.

Im sure this is something you can do with rules but i cant seem to find any good tutorials on seeting it up any help appreciated


texts: 404 errors for pages other than homepage when uploaded to web-server

texts:
I and new to php and I got started with drupal and this is my demo site http://sugandha.net63.net/ Yea and it works but when I try to click on any link it throws 404error message. What might be the problem? It works fine in localhost.

My setting is as follows :

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'a2256974_drupal',
      'username' => 'username',
      'password' => 'pwd',
      'host' => 'mysql1.000webhost.com',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

This is my database setting and

 # $base_url = 'http://www.example.com';  // NO trailing slash!


texts:
Problem

I'm trying to pull data from the entity objects on a views page that is rendered using Search API. I'm trying to pull the data from hook_views_post_render.

Views appears to sometimes load the entire entity in the path:

$view->result[x]->_entity_properties['entity object']

However it doesn't always. Sometimes the objects are just missing and I can't pull data from them. (They appear on flushing the cache and then disappear a couple normal browser refreshes after.)

Does anyone know why this happens? I was wondering if they were cached, but they don't appear in $cache or $view i.e.:

hook_views_post_render ($view, $output, $cache)


texts: Cron run exceeded the time limit and was aborted + How to change max_exec_time if not access on php.ini

texts:
I am running a script which Fetches the data from other site like Articles of a user and other things also. I run my script in hook_cron. Cron gives me this error after a while of script running.

Cron run exceeded the time limit and was aborted.

Also I don't have access to change php.ini and setting.php. How can I change max_exec_time value.


texts: Search API + Apache SOLR - No highlighted excerpts returned for stemmed terms

texts:
I have a Drupal 7 site using the Search API and Search API Apache SOLR modules to provide search functionality to site visitors.

I'm running Apache SOLR 4.10.2 within my development Vagrant VM environment, and search results are returned for both stemmed and unstemmed terms which is great:

Example search term: "car"

Apache SOLR returns nodes with fields containing the text "car" and "cars"

The problem is, when Apache Solr returns nodes containing the stemmed term "cars", no highlighted excerpts are returned. However results containing the exact term "car"  are returned with a hightlighted excerpt as expected.

After extensive searching I found this blog post which contains instructions on how to enable stemming for highlighted excerpts, but no luck.

Here is the excerpt of my schema.xml config file as per the instructions in the blog post:

<!--  Setup simple analysis for spell checking -->

 <fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100">
   <analyzer>
     <tokenizer class="solr.StandardTokenizerFactory" />
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
     <filter class="solr.LengthFilterFactory" min="4" max="20" />
     <filter class="solr.LowerCaseFilterFactory" />
     <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
     <filter class="solr.PorterStemFilterFactory"/>
   </analyzer>
 </fieldType>

I have restarted my VM and cleared and reindexed all the nodes, but still no dice.

Has anyone else had this issue before?

Thanks in advance!


texts:
I would like to keep info on the user that last edited a node. From a little search I found that you can easily obtain that info from the node_revisions table. But what if you don't want to enable revisions? Is there any other way to get the uid of the user?

I thought of manually adding a field to my content type that will be set to the current's user username. So every time a user hits save that field will store his info. But then I would have to add field permissions to make sure the users don't see or edit this field.

I was hoping for a more out-of-the-box solution. Probably there isn't any otherwise google would have given me the answer. All ideas appreciated.
Thank you


texts: Creating new content type (programmatically) with CCK fields as default

texts:
Possible Duplicate:
  Module development - integrating custom content types

Is there any way to programmatically create a new content type with few CCK default fields?
I don't want to add those fields after I created the content type, but I want them to be delivered with my module instead
Luca


texts: Exclude fields from a node-add form (but keep them on the node-edit form) by excluding (to save load time) not hiding? Drupal 7

texts:
The site I am building is for a parts database and parts are related to each other - eg a circuit board can have a bunch of screws and relays that are sub parts and the board itself can be a sub-part of a module.

When you are registering a circuit board (node-add) you don't need to associate it with parent parts or sub parts. But you may want to do that when you edit it (node-edit).

The parts are associated by entity reference fields and the entity select views take a bit of time to load. I want to save that load time for the node-add by excluding those fields from the node-add form completely (not just hiding them) but I want them to load as normal for the node-edit form.

Thanks very much and have a great Friday!


texts: How do I get a hold of the session object in my form handler?

texts:
I have build a form in D8 and on submit I want to save the form values into a session, so that I can access them 3, 4,.... page requests later.
In D7 I just used

$_SESSION['key'] = $value

I have a feeling, in D8 and symfony, this is (very) bad practice. How should I solve this?
At the moment I'm using the following chunk of code, but I don't know if this is the correct way:

$session = new Session();
$session->set('name', 'value');

$name = $session->get('name');


texts: Add Object in json file generate by services module drupal

texts:
I need some help about this problem. I need to add object that encompasses the hash of my json file.

I use services module in drupal 6 for generate xml and json file from my nodes.
So, when i view my nodes in json i have this:

[
{
"nid": "7",
"vid": "7",
"type": "page",
"language": "",
"title": "Bievenido", ..... } ]

But i need that this json file look like this:

[
{
"<whatever>": {
    "nid": "7",
    "vid": "7",
    "type": "page",
    "language": "",
    "title": "Bievenido", .....  } ]

How to change this json file generated by services module?


texts: programmaticaly extract the shipping service name

texts:
Through following code in a custom sub module for commerce_cybersource_sawm I am able to pass shipping information to merchant like name, address, country

$shipping_address = $order_wrapper->commerce_customer_shipping->commerce_customer_address->value();
 if (!empty($shipping_address['first_name'])) {
    $form['ship_to_forename'] = array(
    '#type' => 'hidden',
    '#value' => $shipping_address['first_name'],
  );
}

I want to know how can we extract the shipping service name. Since I have Free Shipping and Standard Shipping which I want to pass to the merchant.


texts: JQuery accordion works in admin but not for anonymous

texts:
D7.18
I have a similar problem to another question but the solution did not work for me.
I have added my jquery accordion file  (accordion.js) to the subtheme.info file and a file called  accordion.js to the subtheme folder.
The accordion.js code is

(function($) {
Drupal.behaviors.accordion = {
attach: function (context, settings) {
   //code starts
  $("#accordion").accordion({
  autoHeight: false
  }
  );
   //code ends
  }
 };
 })(jQuery);

The accordion effect works correctly when logged in as admin but does not when logged out.
Firebug shows  for the anonymous user but none of the other classes that are shown when logged in as admin.
I am using the Omega Theme.
I am completely stuck as to how to resolve this


texts: Add custom param data-cmp-src in drupal_add_js

texts:
I added js files in the header of my drupal 7 site by using drupal_add_js as the example below:
drupal_add_js(drupal_get_path('theme', 'ims') .'/js/qc2.js', array('group' => JS_THEME, 'scope' => 'header', 'weight' => 1));
drupal_add_js('//cdn.yyy.com/tech/omg.js', array('type' => 'external', 'group' => JS_THEME, 'async' => TRUE, 'scope' => 'header', 'weight' => 2));

The following code is producing an src="..." tag and I would like to convert it to data-cmp-src or add a custom param data-cmp-src  along with src tag.
Any ideas?


texts: Mysql query that performs sums between different tables

texts:
I am struggling to make a query in a custom service function in Drupal 7, which should make 3 sums. In each table (3), there are 2 records saved with the following values:

field_data_field_monto_15pts with field [field_monto_15pts_value] data: 5 and 6
field_data_field_monto_14pts with field [field_monto_14pts_value] data: 3 and 4
field_data_field_monto_13pts with field [field_monto_13pts_value] data: 1 and 2

The service function that performs the query and returns data in the JSON format is the following.

$cantidad = db_query('
  SELECT SUM(field_monto_15pts_value) AS 15pts,
         SUM(field_monto_14pts_value) AS 14pts,
         SUM(field_monto_13pts_value) AS 13pts
  FROM {field_data_field_monto_15pts},  {field_data_field_monto_14pts},  {field_data_field_monto_13pts}')
  ->fetchAssoc();

return $cantidad;

What I expect from the function is the following values.

{
  "15pts": "11",
   "14pts": "7",
   "13pts": "3"
}

What the function returns is this.

{
   "15pts": "44",
   "14pts": "28",
   "13pts": "12"
}

What is wrong in the code I am using?


texts: increase users to display in who is new block

texts:
I need to display more than 10 users in who is new block, i see the dropdown list has at max 10.

So, how can I increase it?


texts: Different node parent menu for per language

texts: My struggle with Drupal 8 continues as I moved onto i18n settings. I've enabled and configured content translation and now I'm facing issue of menu displaying untranslated pages. Popular suggestions to remedy this is either using Menu manipulator module to filter out untranslated nodes from menu or using different menu per language. I'd like to do the latter, but I can't seem to find an option to select different parent menu for different translations. If I change parent menu selection in English version of a node it will change in other languages as well upon saving. This is curious, as there's no "all languages" next to parent menu label that would suggest that this setting is synched between languages. Or am I supposed to add links to other languages manually by editing menu items?


texts: How to insert the title of the page as a class in page title block?

texts:
I am new to Drupal 8 theming and I've been long time trying the following:

I want to add classes to page-title in the template, page-title.html.twig. Two new classes:

1.- 'page_title'

2.- The real title of the page

The code I'm using is,:

{{ title_prefix }}

{%
set classes = [
'page-title',
title|clean_class
]
%}

{% if title %}

{{ title }}

{% endif %}

{{ title_suffix }}

it renders:

FORMACIÓN: CURSOS Y  TALLERES

The string 'page-title' is working well but the variable title provoke an error:

  Notice: Array to string conversion in
  Drupal\Component\Utility\Html::getClass() (line 72 of
  core\lib\Drupal\Component\Utility\Html.php).

And print the class, array.

Any help?


texts: How to create Taxonomy Term using Services?

texts:
I've a vocabulary called Tags. I need to create Taxonomy terms under this vocabulary using REST service.

So What is the JSON format to create taxonomy term. Similarly what is the JSON format to update taxonomy term?