texts: How to change the database drupal forms send to

texts: It's super easy using php and SQL but how do you change the default database drupal 6 saves posted data in the forms? To an external database?


texts:
I'm doing a drupal 7 website, I've now started to experience a "EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7820 of C:\xampp----\includes\common.inc)." error whn I try to view a node in full view mode and only if I'm logged in as administrator.

This is happening here:

if (!empty($info['entity keys']['bundle'])) {
// Explicitly fail for malformed entities missing the bundle property.
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
  var_dump($entity);
  throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}

I found some pages about this error but none seems to apply to my case. I put a var_dump just before the instruction throwing the exception and all I get is bool(false). I've checked all the bool fields of the node and they all have #bundle correctly set.

I think the problem might have started after installing the database optimization module. I found some information regardin this error and clearing the form_cache but I didn't understand if this can apply to my case.

I guess these hints are enough to trace the problem for a drupal expert, unfortunately not for me.

Any suggestion? Thanks


texts: Find a particular menu item within the primary links

texts:
Let's say we have a menu inside the primary links, in my case the Misc menu.

As it seems under Misc menu it can be any Content Type (of course and on every other menu)

The question is how can I make it to appear ONLY the Misc menu somewhere in my website without reconstructing it as a separate menu?

I want it to stay in the primary links.

So far I've tried it with the context module, but seems that is not working properly with the sub menus under the Misc menu. It works only for the Misc page.

Even if I do this: menu_set_active_menu_name ('primary-links') it's still working only for the Misc menu, not its childrens.

Creating a block with only the needed menu item and the use of the template_preprocess_block is another approach but not recommended, while I have to refer to the block through the block ID ($bid).


texts: Form states expanded or collapsed not working

texts:
I cannot get this to work. Visible/Invisible works for me but this doesn't. Have I misunderstood anything?

    $form['items']['delivery_address'] = array(
    '#type' => 'fieldset',
    '#title' => '',
    '#collapsed' => true,
    '#collapsible' => true,
    '#states' => array(
        'expanded' => array(
            ':input[name="add_address"]' => array('checked' => false),
            ':input[name="delivery_type_radios"]' => array('value' => 0),
        ),
    ),
);


texts: How do I implement drag and drop node re-ordering in a view?

texts: I am creating a simple content admin view, and I need to implement drag and drop re-ordering (instead of weights in drop down menus). Is that possible, and how?


texts: Save button missing from content type edit form

texts:
Here is what the bottom of my "leaflet" content type edit form (i.e. admin > structure > content types > leaflet > edit) looks like:

Here is what the bottom of my "testimony" content type edit form looks like:

Note that there are no save/delete buttons! Another of my content types has also now picked up this bug. This just happened. I have no idea why. I can't save changes! I tried flushing all caches and it didn't help. I'm an administrator and I have permissions for everything.

Why would this have happened and what can I do? Drupal 7.19.


texts: How to migrate from directory of xml files on same server

texts:
I am completely new to using Migration. I need to migrate data from files that are contained in folders inside a directory that has already been transferred to the destination site. How do I set up the source information in the migration yml file.

For example if the source was at another url I might use something like:

source:
   plugin: url
   data_fetcher_plugin: http
   data_parser_plugin: xml
   urls: private://migration.xml

However so far I have not been able to find an example of how I would manage this for a directory of folders that contain xml files located inside the /sites/default/files directory.

Thank you for any suggestions.


texts: How to disable module warning "User warning: The following module is missing from the file system" only visible on update.php?

texts:
I have a warning when using the update.php. This warning is not visible when using : drush cc all

  User warning: The following module is missing from the file system:
  aaa. For information about how to fix this, see the documentation
  page. in _drupal_trigger_error_with_delayed_logging() (line 1128 of
  C:\www\arlande.nl\includes\bootstrap.inc).

I did run all solutions basis on : https://www.drupal.org/node/2487215

Finally I found out:
There is a record in the system table. If I delete this line using drupal it is oke and the warning is gone.

However when I use  update.php script again the warning is there again and also the record is again available in the system table.

Information in the system table is indicating: The type is a module again but the file reference is not in modules but in profile.

  profiles/aaa/aaa.profile

Big change this is profile of the initial installer but is not there any more and I'm not able to get this anymore.

I scanned all code to see if a hook is used but that 100%  not the case, so the reference should come from somewhere inside the database.

Any suggestion where the update.php file is getting this reference from in the database and/or how to solve this?


texts: How to filter views rows whose nid is less than nid provided by url?

texts:
Drupal 7. In a node/edit form panel I have added a view that returns nodes.
I whish to filter thoses nodes and keep only the nodes whose nid is less than the nid of the node beeing edited.

the url of the node/edit form   is : /node/11541/edit?step=11538

the nid of the node being edited is : 11541

I wish the view to return only the nodes whose nid < 11541

I use Views PHP


texts: Multiple versions of the same menu, based on associated term?

texts:
I am trying to create a site with different portals. Each portal displays content filtered to that person's user tag, i.e. Student, Staff, etc. It's easy to create a view that displays nodes with that user tag (taxonomy term), but I am looking to have a user tag-specific menu. Many items in my menu structure apply to multiple user tags, some to only one or the other. How can I have the portal page display a menu that only contains nodes with the appropriate tag?

I know that if I used actual Drupal roles I could give permissions to the pages, and then when someone is logged in with the appropriate role, they only see the pages that they have permission to see. This is the same idea, but I don't want to require users to log in. Only access the menu through a specific portal.

Hopefully I described that well enough, thanks for any suggestions!


texts: Exposed filter autocomplete has TID with taxonomy term

texts:
I created a view from taxonomy terms of different country names. I added an exposed filter to allow the user to enter the country, but when the user selects the country, it automatically adds the taxonomy ID after the name.

I've tried various things, from hooks to jQuery, I can't seem to figure out how to remove the TID. Please advise.


texts:
I have been using the Apache Solr Search module in Drupal 6 and am looking at the Search API for a Drupal 7 install. I have seen some discussion here but I am looking for any reasons for choosing one or the other.

Is there a reason to choose one over the other? If so, why or why not? I have heard there may be complexity issues and/or performance issues with Search API. Is this true?


texts: Which is the leading facebook module for Drupal 7 a complete site integration?

texts:
There are 3 main FB integration modules for Drupal 7;

FB
FBconnect
FBoauth

There are tons of discussion threads around the net and drupal.org describing the pros and cons of each module. From all these threads, this is what I've gathered. If all you want is FB login capabilities for your users. Then FBoauth is your best bet. FBconnect does a few of the 'other' features pretty well but requires some bug fixes to be stable. FB is great if you want APP integration for your site. But my question is;

If you wanted your site to do;

User Registration
Content Posting to Wall Stream
Comment Stream
Friend Inviting

Which is the best module to be able to have those features built into your drupal site?


texts: Is there a way to add a timestamp to messages print from drupal_set_message()?

texts:
Sometimes when I am editing I may accidentally edit the same page in different tabs, or I might forget  whether I have updated the page earlier or not. I use a Save and Edit button when saving and when I save I want to know when I last saved based on the notice in at the top of the page, where I normally see a message like the following.

There is some sample code for a module that changes the message handling - https://atendesigngroup.com/blog/drupal-7-drupal-8-customize-or-remove-node-creation-message. How could I change it just to add a timestamp to the message?


texts: How to insert a theme table form inside an existing form?

texts:
I would like to put form fields and submits inside a table (generated with theme_table) of an existing form (callback of a hook_menu entry).

The form_id (container) :

  // Part of the existing form having a $form_id,
  // where I want to put form elements into a table :
  ...
  $data = mymodule_get_content_list();

  $form['mymodule_content_list'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $data,
  );

Table builder function :

function mymodule_content_list() {

  ... Running queries to get a $content_list

  $data = array();
  foreach($content_list as $content_data) {
    $operations = array(
      'update' => array(
        '#type' => 'submit',
        '#value' => 'Update',
        '#submit' => array('mymodule_page_edit'),
      ),
    );
    $content = array(
      '#type' => 'textfield',
      '#value' => $content_data->content,
    );
    $data[] = array(
      'content' => drupal_render($content),
      'operations' => drupal_render($operations),
    );
  }

  return $data;

}

With something similar to the above, I currently get the HTML of content textfields and submit buttons in place, but they aren't used as real form elements:

When I click the submit above ('Update'), the submit function used is the first declared within the form container but not the declared array('mymodule_page_edit').
Using a debugger, I found out that textfields declared in the table's rows aren't passed as $form_state['values'] within the (wrong) submit function.

So the question is, how to insert form elements (fields and submits) into a drupal table, inside of an existing form (hook_menu callback) ? Is it possible ?


texts: Single site with multiple user interfaces based on path and role

texts:
I'm currently working on a Drupal project that requires 3 separate interfaces.

Administrative users login to the site and all of the pages associated with their specific role start with a particular base path. Lets say it is /path_A/*. I'd like these users to login to the site using www.example.com/path_A/login and all subsequent requests to any given page would be accessed via www.example.com/path_A/.

The end users would access the site in the same way except the login page and all subsequent requests would begin with www.example.com/path_B. Users of path B should not be able to access any of the administrative functions tied to path_A/ but administrators should be able to navigate to any path_B/ URL and access the site in the same way as the end users.

On top of all of this, there is a public facing set of pages that should be accessed using the domain itself, it is basically a blog and information directory living at the webserver root directory (www.example.com).

Additionally none of the pages belonging to any of these specific URL paths should be available through the others, so a page /path_A/page/3 should not be accessible via /path_B/page/3 or /page/3. Multi site setup for this is not really an option since the a large piece of the database is shared by all three subsections of the site.

My initial idea is that I could use .htaccess rewrites to direct all requests to each of the paths to the drupal index file, register 2 aliases for each of the login pages using the paths module and then use context to change the interface based on the path/role. I am a bit new to drupal and this is my first major project working with it so I'm not sure if this is the best approach to this problem. And yes I realize that this might seem like a waste of time but the client really stressed this functionality.


texts: How do I avoid the text on my site is selectable?

texts:
I am wondering how to avoid the text on a Drupal 6 site is selectable, ideally only for certain node types.

It should help to make life a bit harder for content thieves. Apparently there is a module in Wordpress that does exactly this, but I could not find such thing for Drupal.


texts: I have always been working on drop down menus which nice menus or sucker fish menus was satisfying. I have a new kind of menus to be satisfied.  As show in the image. When destination is hovered its should bring out drop down in that manner.


texts: How to render alt and title texts of image file entities using a theme function

texts:
Out of the box, image file entities have alt and title text fields attached, field_file_image_alt_text and field_file_image_title_text respectively, that provide the rendered image with an HTML alt and title text.

Today I feel like Mysite.com would be a great title for the images on my website, and I could easily programatically populate both text fields with Mysite.com upon upload of the image file. However, what if tommorrow I change my mind and instead of Mysite.com I want the alt and title text to be Welcome to Mysite.com? I would have to edit all file entities and modify both text fields for each.

Is there a way to render the alt and title text through a theming function so that I do not have to actually store the alt and title text within each file entity? I want to be able to modify the alt and title texts of all images by just modifying a single line of code.


texts: Preventing a duplicate node from being created

texts: I'm building a site with a content type that includes a URI. Is there a module that would prevent a node of that content type being created if the URI it includes is already referenced in an existing node? i.e., so that the site can't have two nodes with the same URI field?


texts: Custom module's output is not wrapped in the site theme

texts:
I've put together my first Drupal 7 custom module. I've implemented hook_menu() to get it to path correctly, but I cannot seem to get the output wrapped in the page tpl.

I can visit domain.com/mycustommodule to see the output, but it's just the photos and links that the custom module built, not the site wrapper. How do I get this output into the node area of the page?

Here's my hook_menu if that helps.

function mymodule_menu() {

$items = array();
$items['mymodule/view'] = array(
'title' => 'Mymodule',
'page callback' => 'mymodule_display',
'access callback' => 'user_access',
'access arguments' => array('Access administration menu'),
'weight' => 1,
'type' => MENU_CALLBACK,
);
return $items;
}


texts: Views: Limit amount of a node type by percentage

texts:
I have a view showing nodes of two different types sorted by date.
I want to limit the maximum number of nodes shown of the one type by, say, 25% percent of the total nodes per page.

How would I go about that?


texts: Define a default image when using image as base field in custom entity

texts:
I defined a custom entity type with an image base field. Now I want to have a default image which seems to be quite tricky: when I define a default image on a field api field and export the configs I can see that the file id of the image is set. But when I create a custom entity I cannot know which file id an image might have - except when I just create the image file on the time the entity type is created/ updated.

Is there a proper way to define a default image within the base field definition of a custom entity?


texts: View display plugin "entity reference" not using translation

texts:
UPDATE: This bug was just fixed in Issue
  2174633 and
  Drupal v8.7.9 will no longer have this problem.

For some of my entity reference fields I'm using "Views: Filter by an entity reference views" as reference method. I've configured those views to use the current interface language for rendering (with fallback to default lang).

The interface language selection basically works (in other view blocks, or when previewing in /admin/structure/views), but it does not work when used as source for an entity reference field:

In my admin interface I'm using I've got a paragraph with an ER field using such a view as source. The paragraph always shows the title in default lang
On the frontend I've got a webform select field using the same view as source. The select options are always rendering in default lang.
When using the default reference method I do get translated titles in both use cases.
As stated above, the correct language is used in preview on /admin/structure/views

How can I select the correct language for my view-filtered ER fields?

(Please note that I can not use the interface language as filter criteria, because this would disable the language fallback.)


texts: Is there something equivalent to template_preprocess_search_results()?

texts:
I just realized that template_preprocess_search_results() function has been left out in Drupal 8 for some reasons, although template_preprocess_search_result() (for single results) is still there.

I need to be able to manipulate the search results prior to rendering as I would with template_preprocess_search_results() in Drupal 7.


texts: How do I order a search query by best match?

texts:
I am using the following code.

$query = \Drupal::entityQuery('node');
  $query->condition('status', 1);
  $query->condition('type', 'article');
  for ($i = 0; $i < count($split_keys); $i++){
  $group = $query->orConditionGroup()
  ->condition('title', '%'.$keys.'%' ,'LIKE')
  ->condition('body', '%'.$keys.'%' ,'LIKE')
  ->condition('title', '%'.$split_keys[$i].'%' ,'LIKE')
  ->condition('body', '%'.$split_keys[$i].'%' ,'LIKE');
  }
  $query->range(10,20);
  $query->addExpression('CASE WHEN title like %'.$key.'% THEN 0
       WHEN title like %'.$split_keys[$i].'% THEN 1
       WHEN body like %'.$keys.'% THEN 2
       WHEN body like %'.$split_keys[$i].'% THEN 3
       ELSE 4 END', 'order_col');
  $query->sort('order_col', 'ASC');
  $entity_search = $query->condition($group)->execute();

I am trying to sort by best match, but I get the following error.

  Call to undefined method Drupal\Core\Entity\Query\Sql\Query::addExpression()

How can I fix the code?


texts: Token to show only first term in Page Title module

texts:
I am using Page Title module and patterns to auto create them. One of the tokens for Page Title when creating content is taxonomy term.

Since users can add as many terms in content i would like to limit Page Title to only use first term added by the user.

Is there a way to do this with tokens ?


texts: Creating a node works on local but not on production

texts:
I'm using the same version of Drupal 8 on both local and production. I'm trying to create a node using the Drupal 8 core REST api.

My curl looks like:

curl -i -X POST \
   -H "X-CSRF-Token:mytoken" \
   -H "Content-Type:application/hal+json" \
   -H "Authorization:Basic authstring" \
   -d \
'{"_links":{"type":{"href":"https://www.example.com/rest/type/node/page"}}, "title":[{"value":"My first page"}], "type":[{"target_id":"page"}]}' \
 'https://www.example.com/node?_format=hal_json'

On my Vagrant environment, it works and the node is created on the Drupal 8 site. However, on the production environment I get the error message:

  Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException:
  No route found for "GET /node": Method Not Allowed (Allow: POST) in
  Symfony\Component\HttpKernel\EventListener\RouterListener->onKernelRequest()
  (line 143 of
  /example/vendor/symfony/http-kernel/EventListener/RouterListener.php).

All the settings between local and production are synced using Configuration Management so should be the same.

Any ideas?


texts: How to log all outgoing links generated in a view?

texts:
What is the most lightweight method of tracking all outgoing links generated in a view. By lightweight I mean that I don't want to have to load a module such as statistics that will potentially slow down my site due to it going above and beyond my needs.

Basically I would need to record the data into a database using the following structure:

product_id | uid | timestamp

The product id is associated with each link and is a separate field. The purpose would be to create sets of clicked links for each user, product, etc. This could in turn be used as a dataset for subsequent user/item analysis. I would imagine I would need to use some sort of callback function.

Can anyone provide an example or any hints?


texts:
On the parent term page, I want to get all the nodes belonging to the parent term page and its children term. I need to output the node title, a field I created, and the node summary.

Which tables should I query? Which condition should I use?

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'product')
  ->propertyCondition('status', 1)
  // field_fenlei is the category field name.
  ->fieldCondition('field_fenlei', 'tid', arg(2))
  ->range(0, 10);

$result = $query->execute();

if (isset($result['node'])) {
  $nids = array_keys($result['node']);
  $nodes = entity_load('node', $nids);
  echo $nodes->title;
}


texts: How can I display a block only when a node meets a particular condition?

texts:
I have a block that allows a site visitor to query an external calendar, but it will only work for certain nodes.

How can I set it up so that I can i) indicate whether or not a node has calendar data available for the node and ii) if it has calendar data available, display the block and if it hasn't got calendar data available, the block is not displayed?

Someone suggested to me that I use Workflow to do this, but I've not been able to figure out how Workflow would help me set this up.


texts: D6 Views exposed filter on Search Term field that handles word parts

texts: Is there anyway to have a View with an exposed Search Term field return results for word parts?  I am currently using Drupal search.  I'd like to use a hook inside of a custom module rather then going the Apache SOLR route.  Can this be done?


texts: What is the meaning of the field:delta content type offered in contextual filters in views?

texts: When creating a new contextual filter for a view the list of types includes options such as content:spec (field_spec:delta) where spec is the name of a field I have attached to the content type accepted for the view.  It appears on some, but not all of the fields offered in the list.  I cannot find a reference on this field. What is this (field_name:delta)?


texts: How to change date format in Views Calendar Pager?

texts:
I have multiple displays rendered in a Calendar View (Mo/Day/Upcoming/etc.) and everything's working as it should... except I changed a setting somewhere and applied it to all pages instead of current display and now the heading for the month display uses long format of the first date in the range of context (i.e. Tuesday, October 1 2014, Thursday, November 1, 2014, etc.)

I have "fixed" the issue by hooking theme_date_nav_title() in the theme template.php and setting $params['format'] directly, but this is hacky... Where is this setting in Views?!


texts: How to configure Facet displays that comes with Commerce kickstart

texts: Commerce kickstart comes with some filtering when viewing all the products, I do not have idea how to make my own facet displays, and I cannot find anything in the drupal configuration about facet displays. Can someone explain it to me?, would be great if it is with an example


texts: Change from email id when admin approved user account

texts:
I want to change  FROM Email id, when admin approved an user account.

Currently it is using admin email id. I want to use different email  and my admin email id will remain same

Any Suggestions


texts:
I am trying to create an article node using REST API, but i keep getting 403 error. I have given necessary permission. I am trying it with admin login,

curl --include   --request POST   --user admin:admin   --header 'Content-type: application/hal+json'   --header 'X-CSRF-Token: uQ2CRae94_BUhy3q_JvRmlLhSqm0cCuV7tq7_ioIZk8'   http://drupal8_contrib.local/node?_format=json   --data-binary '{"_links":{"type":{"href":"http://drupal8_contirb/rest/type/node/article"}},"title":[{"value":"Example node title"}],"type":[{"target_id":"article"}]}'

I have enabled all the REST modules and drupal version is 8.1.

Request Header

$request->setHeaders(array(
  'postman-token' => '5add3a97-479d-ee36-7ce4-97a410cc899b',
  'cache-control' => 'no-cache',
  'x-csrf-token' => 'acsr2_Spef5Ah0_TsYRE8p5GUnt3qWcRKEEwrMxodtw',
  'content-type' => 'application/hal+json',
  'authorization' => 'Basic d2VibWFzdGVyOndlYm1hc3Rlcg=='
));

Response Header

 Cache-Control →must-revalidate, no-cache, private
Connection →Keep-Alive
Content-Length →14
Content-Type →application/json
Content-language →en
Date →Tue, 03 May 2016 09:21:25 GMT
Expires →Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive →timeout=5, max=100
Server →Apache/2.4.7 (Ubuntu)
X-Content-Type-Options →nosniff
X-Frame-Options →SAMEORIGIN
X-Generator →Drupal 8 (https://www.drupal.org)
X-Powered-By →PHP/5.5.9-1ubuntu4.16
X-UA-Compatible →IE=edge


texts: Can drupal_http_request be secure (https)?

texts:
I'm using drupal_http_request to parse some user details between servers.

Is it possible to secure drupal_http_request using https or should I fall back to cURL?

If there's a better way, do tell.


texts:
I am trying to add custom actions, events and conditions to work with Rules interface. I began by adding custom actions by creating a custom module. Here's my code till now.

rules_example.info :

name = Rules Example
description = Test module to add new actions, events, and conditions
core = 7.x

rules_example.module :

<?php
/**
 */

rules_example.rules.inc :

<?php

 /**
  * @file
  * Example rules module to create actions, events, and conditions
  */

/**
 * Implement hook_rules_action_info()

 * Declare any meta data about actions for Rules
 */

function rules_example_rules_action_info() {
$actions = array(
    'rules_example_actions_hello_world' => array(
        'label' => t('Print Hello World on the page'),
        'group' => t('Rules Example'),
        ),
    'rules_example_actions_hello_user' => array(
        'label' => t('Print Hello to the logged in user'),
        'group' => t('Rules Example'),
        'parameter' => array(
            'account' => array(
                'type' => 'user',
                'label' => t('User to say hello to'),
                ),
            ),
        ),
    );

return $actions;
}

/**
 * The action function for rules_example_action_hello_world
 */

function rules_example_action_hello_world() {
drupal_set_message(t('Hello World'));
}

/**
 * The action function for rules_example_action_hello_user
 */

function rules_example_action_hello_user($account) {
drupal_set_message(t('Hello @username',
 array('@username' => $account->name)));
}

Well, this is it. I have saved all these files in a folder rules_example in sites/all/modules. When i install the module or rather try to install it i get this error:

ReflectionException: Function rules_example_actions_hello_world() does not exist in ReflectionFunction->__construct() (line 1691 of /opt/lampp/htdocs/sites/all/modules/rules/includes/rules.core.inc)

I am not sure what the error is. I am going to rules.core.inc but am not able to understand what is causing the error. Thanks.


texts: Merge multiple block views to a single jump menu

texts:
I want to implement a jump menu with a list of three different vocabulary terms grouped by each vocabulary name. If I make only a single view all the terms are shown correctly but I would like to be grouped by their vocabulary names. I thought that I could have this result if I could merge three different views with a view for each vocabulary.

Is this possible?


texts:
I installed Commerce Coupon module

I didn't use the coupon percentage module. I created a custom coupon type which has 5 custom field, coupon_code, coupon_number_of_uses, coupon_owner, coupon_percentage and coupon_date. Then I created an instance of it and everything works fine, but in the checkout process page when I enter the coupon code nothing happens.when I check the ajax result with firebug, the response is empty. any idea what's wrong here?


texts: Problem with rendering of taxonomy terms from more than one vocabulary as tags (quickfix needed)

texts:
My theme currently only renders the terms of the last used vocabulary correctly into the designated div, all other terms are incorrectly rendered into the node-content. I already know where to look, I just couldn't figure out how to fix this since I'm not really familiar with PHP and Drupal theming.

This is the method responsible for returning the taxonomy terms used for rendering (and hiding):

function get_terms_D7($content) {
    $result = NULL;
    foreach (array_keys($content) as $name) {
        $$name = & $content[$name];
        $field_type = NULL;
        if (is_array($content[$name])) {
            if (isset($content[$name]['#field_type']))
                $field_type = $content[$name]['#field_type'];
        } else if (is_object($content[$name])) {
            if (isset($content[$name]->field_type))
                $field_type = $content[$name]->field_type;
        }
        if ($field_type == NULL || $field_type != "taxonomy_term_reference") continue;
        $result = $content[$name]; //this seems to be the issue, only the terms of last vocabulary will be returned
    }
    return $result;
}

The results are used for rendering and, before that, hiding (simplified example):

$terms = get_terms_D7($content); // '$content' is the Drupal variable in my node.tpl.php

//rendering
$output = '
' . render($terms) . '
';

//hiding
hide($content[$terms['#field_name']]);

As you can see, it's logical why I'm only getting the terms of the last vocab out of this method. I already tried all kinds of things like $result .= $content[$name] instead of just assigning the last value of the loop. Since the result is an array, I then tried methods like array_push($result, $content[$name]) or array_merge($result, $content[$name]) instead. I also tried to add each single value of the the array:

if ($result == NULL) {
  $result = $content[$name];
} else {
  foreach ($content[$name] as $value) {
    array_push($result, $value);
  }
}

But without a deeper knowledge of Drupal theming and the usage of fields and variabels in the tpl.php-files I'm afraid I'm stuck.

So, I need this method to return the assigned terms of all of the used vocabs, not just the last one. I'd appreciate any help, thanks!


texts: User relationship module - error strict warning: Only variables should be passed by reference

texts:
module name: User Relationships.

module version is: 7.x-1.0-alpha5

whenever i try to add relationship type or edit it give me this error:

Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 103 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).
Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 104 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).
Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 105 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).

the code in user_relationship_implications.module is as follows:

function theme_user_relationship_implications_form_table($variables) {
$form = $variables['form'];
$headers = array(t('Relationship Type'), t('Strict'), t('Reverse'));
$rows = array();

foreach ($form['opts'] as $rtid => $elements) {
if (!is_numeric($rtid)) {
  continue;
}
$rows[$rtid] = array(
  drupal_render(array_shift($elements)),
  drupal_render(array_shift($elements)),
  drupal_render(array_shift($elements)),
);
}
return theme('table', array('header' => $headers, 'rows' => $rows));
}

in the above code line 103-105 is:

drupal_render(array_shift($elements)),
drupal_render(array_shift($elements)),
drupal_render(array_shift($elements)),

Can you please help me solve the error and also bring to my knowledge why does this occur?


texts: Highlight View parent menu item on node page and rebuild breadcrumb

texts:
If you are new to Drupal, as I am, you surely asked yourself once about "How can I highlight parent Views menu item even if I am on a child node? And how can I keep a correct breadcrumb if I use one?"... That's why I wanted to share a little clue in here.

My situation:

I have a content-type named "Testimonial". I created a View for my testimonial's nodes, with a menu item "Témoignages" in a secondary menu on the left of my page (called "Ressources").

First problem: the menu

/!\ This menu displays only on the pages whose menu item is present in the menu. For example, "Marchés publics en Wallonie", "Aides publiques en Wallonie", "Témoignages" (= Testimonials), ...

When I am the the View page, with the list of my testimonial's nodes, the menu item is highlighted automatically by Drupal. Nice.

But when I click on a node and access the full view page, the "Ressources" menu disappears. This behaviour is normal for all other menu item's children pages. But I want to make an exception for the testimonials.

Second problem: the breadcrumb

Breadcrumb on Views page:

Breadcrumb on testimonials node page:

My final question:

How can I keep the menu block in testimonials node pages (only) and make the menu item "Témoignages" highlighted? And how can I keep a correct breadcrumb in the same time?


texts:
the view shows a simple article, i want to show the view in rtl direction if a specific field value is YES for example, if the value is NO, then the view will be displayed as ltr.

I have a hidden field that have two values, Yes or No, based on them i need to change the VIEW. only the view, everything else in the page must stay the same.

How to achieve that please


texts: How to display entity properties using hook_entity_view_alter? Help with syntax

texts:
I'm creating an entity in code using the eck. I've added both properties and fields to my custom entity. That is working great, except I can't figure out how to display certain entity properties when hook_entity_view is being called?

I have this in a custom module -

function mycustommodule_entity_view_alter($build, $type){
  if ($type == 'mycustomentity'){

  }

}

It's suppose to take a render array, but there is no $entity->content and I've tried various things to add a very simple render array #markup => 'somemarketup'; to $build, but I have not been successfully. Given that my property is named something like 'myproperty' and is just a text property (from eck) can someone help me with the syntax for adding it to the entity display using hook_entity_view_alter?


texts: views aggregation - number of results per group

texts:
I have a content type - lets say favorite color - where you can choose blue, green, red ....

One node of favorite color has red
Another node of favorite color has green
Another node of favorite color has again red

and do so on

I would like to show in views3.7 the name of the color and how often it occurs:

red: 10
green: 6
blue: 3

How do I do this? I think its aggregation but I cant display the number of each result...


texts: How to hi-lighten with red border when multi check box fails validation.

texts:
I've been searching around for days but can't find the solution.. I know this is a core bug and have found two solutions on http://drupal.org but both of them don't work for multi check box validation on my site (It works for single check box and multi radio buttons though).

These are what I have found:

Required radios/checkboxes are not validated (D6)

move checkboxes error class to parent div, so that checkboxes can be given a red border like other fields

My problem is that it's not outputting the error classes only for multi check box even after using those methods above.
Any idea how to fix this?


texts:
I am trying to programmatically create a user in Drupal 8 using the following code.

$language = \Drupal::languageManager()->getCurrentLanguage()->getId();

$user = \Drupal\user\Entity\User::create();
$user->setPassword($form_state->getValue('pass'));
$user->enforceIsNew();
$user->setEmail('test@test.com');
$user->setUsername('test_test');
$user->set("init", 'test@test.com');
$user->set("langcode", $language);
$user->set("preferred_langcode", $language);
$user->set("preferred_admin_langcode", $language);
$user->activate();
$user->save();

When I execute it, I get the following exceptions.

  Drupal\Core\Entity\EntityStorageException: Field type is unknown. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 783 of  /home/printhouseheroes/public_html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
  InvalidArgumentException: Field type is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 586 of
  /home/printhouseheroes/public_html/core/lib/Drupal/Core/Entity/ContentEntityBase.php).

How can I avoid getting those exceptions?


texts:
I am facing an error in Drupal 9 Stripe module. After installing the module and setting the private and public keys, I visited the /admin/commerce/orders/84/payments/add page, and selected my newly created 'test stripe payment' as payment gateway. Then, I selected one of the payment methods that I've added from /user/18/payment-methods (Add new payment method). This redirected me to the Add payment page where there is an Amount field and two radio buttons (Authorize only and Authorize and capture) and an Add payment button. When I click on this button, the site crashes with the following error.

Error : Call to a member function getRemoteId() on null dans Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\Stripe->createPaymentIntent() (/home/mywebsite/www/web/modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/Stripe.php line 430)

The line causing the error belongs to this function. Does it mean $payment_method is null? Do you have any idea on what might be causing this error?
/**
  * {@inheritdoc}
  */
public function createPaymentIntent(OrderInterface $order, $capture = TRUE) {
  /** @var \Drupal\commerce_payment\Entity\PaymentMethodInterface $payment_method */
  $payment_method = $order->get('payment_method')->entity;

  // Line 430
  $payment_method_remote_id = $payment_method->getRemoteId();
  $customer_remote_id = $this->getRemoteCustomerId($order->getCustomer());

  $amount = $this->toMinorUnits($order->getTotalPrice());
  $order_id = $order->id();
  $capture_method = $capture ? 'automatic' : 'manual';
  $intent_array = [
    'amount' => $amount,
    'currency' => strtolower($order->getTotalPrice()->getCurrencyCode()),
    'payment_method_types' => ['card'],
    'metadata' => [
      'order_id' => $order_id,
      'store_id' => $order->getStoreId(),
    ],
    'payment_method' => $payment_method_remote_id,
    'capture_method' => $capture_method,
  ];
  if (!empty($customer_remote_id)) {
    $intent_array['customer'] = $customer_remote_id;
  }
  try {
    $intent = \Stripe\PaymentIntent::create($intent_array);
    $order->setData('stripe_intent', $intent->id)->save();
  }
  catch (\Stripe\Exception\ApiErrorException $e) {
    ErrorHelper::handleException($e);
  }
  return $intent;
}


texts: Views Table with Aggregation, total values counted per option

texts:
I'm setting up a view of event registrations. Each registration will be allocated to 1 of 3 workshops at two different times in the day.

I'm looking to output the total number of allocations per workshop so we can try to balance the delegate numbers.

I'm pretty close, but not quite there.

I'm using the Display Format of Table with aggregation options with "Group and Compress" on the Event ID.

I then apply the group function on two data fields:
"Allocated Workshop AM" and "Allocated Workshop PM".

I can get closest to my desired result using the "Tally members" option, however, the results are wrong.

They are showing much lower numbers than are actually allocated.

Any suggestions on how I could achieve this?


texts: Relationships between nodes and display in a special order

texts:
I have two content types: 1) Team member and 2) office

There are about 150 team member nodes that need to be associated with 50 offices. When a team member is added to the site, there should be an auto complete field, where the name of the office, the member is in, can be selected.

After saving, the team member information should show up at the office which she has just been associated with. (Name, title and photo should be displayed - which could be done with Display Suite's view modes.)

In addition, each team member is associated with a specific function (head, partner, principal, consultant). This is done with taxonomy. On the office page, however, the team members associated with that office should be ordered according to the team members' taxonomy function. Those team members with the taxonomy term "head" should be displayed first, those with taxonomy term "partner" second, "principal" third etc.

How can this best be achieved? I have taken Entity Reference and Nodereference modules into consideration. Can this be done with Display Suite only or do I need to create a Views block?


texts: hook_entity_view_alter doesn't seem to be working

texts:
I'm trying to alter a Registration entity (created by the Entity Registration module) and am using hook_entity_view_alter. I can see that my code is being called when the page loads, but it doesn't change the output at all.

Here's my code:

function modulename_entity_view_alter(&$build, $type) {

    if($type == 'registration') {
        $edit_path = url("registration/{$build['#entity']->registration_id}/edit", array('options'=>array('absolute'=>TRUE)));
        $delete_path = url("registration/{$build['#entity']->registration_id}/delete", array('options'=>array('absolute'=>TRUE)));

        $markup = "";
        $markup .= "Edit your registration";
        $markup .= '';

        $markup .= "";
        $markup .= "Cancel your registration";
        $markup .= '';

        $build['links'] = array(
            '#type' => 'markup',
            '#markup' => $markup,
            //'#weight' => 1000,
        );

    }
}

Edit: I've changed to trying to use hook_entity_view but am having the same problem. Trying to add something to $entity->content doesn't result in anything new being output on the page.


texts: Convert vertical (portrait) picture to horizontal (landscape), filling empty space around with blurred background

texts:
How can I do this in Drupal 7?

Note: Original question was here.


texts:
I would like to change the default error message from Drupal core.

The error message is "Please Select the Valid File Format".

My problem is in brief below.

I have created a CCK called 'Assignment'.
There I have given the users an option to upload files.
In such case if the user uploads invalid file format drupal will throw the error message as mentioned above.
I need to change the error message in to "The file upload field cannot upload the speicified filed".

How can I achieve this?

(Should not use string overrides module)

Thanks in advance..


texts: Drupal7 - In Edit View adding a field, no "Configure: field" popup and field not shown in "Fields" section

texts:
In View panel, adding fields not showing up "Configure: field" and the field is not added. i.e. The red-boxed is not shown as below (see step2):

Normal behavior step1:

Normal behavior step2:

The event happened after my

SuSE linux server upgraded from 11 to 12
PHP version upgraded from 5.3.17 to 5.5.14
Apache upgraded from 2.2.12 to 2.4.23

No application nor server-level's error log shown. Any ideas on how can I debug or trace the problem? Many thanks for yours help.


texts:
I am modifying user_pass so that it also has an option to resend a user's activation email.

if($form_id=='user_pass'){
    $form['name']['#title'] = 'Email Address';
    $form['actions']['submit'] = array();
    $form['actions']['submit_reset'] = array(
        '#value' => t('Reset Password'),
        '#type' => 'submit',
        '#attributes' => array('class' => array('btn-primary', 'btn'))

    );

    //resend button
     $form['actions']['submit_resend'] = array (
        '#value' => t('Resend Activation Email'),
        '#type' => 'submit',
        '#submit' => '_mymodule_resend_activation', //gives invalid argument on foreach
        '#attributes' => array('class' => array('btn-primary', 'btn'))
    );
}

This doesn't seem to work bc I get an invalid argument for a foreach when I set the submit property for the resend button. But the reset functionality is exactly as I want it. Is there a way I can use the same validation for both submits and have a custom handler for the second one?


texts: Showing content of subterm under parent term

texts:
I have following taxonomy structure

parent-A
    subterm-1
        sub-subterm-a
        sub-subterm-b
    subterm-2

how can I show contents of both the sub-subterm (a and b) when i select/click subterm-1 ; and contents from subterm-1 (sub-subterm a+b) and from subterm-2 when I select parent-A      using views - block display


texts: How do "Order Types" and "Order Item Types" work?

texts:
I'm using the Commerce framework. I'm trying to understand exactly how "Order Types" and "Order Item Types" work. (I've consulted the docs; they don't really address this question.)
So far, I've deduced that:

The Checkout Flow that Drupal uses is determined by the Order Type that's in play.
Every Order has an Order Type.
Every Order Item has an Order Item Type.
Every Order Item Type belongs to an Order Type.

...but that's as far as I've gotten. I'm trying to understand:

What rules does Drupal use to decide which Order Type it's dealing with? (That is, how does it know which Order Type is in play?)
At what point in the is this decision made? (When the user first adds an item to their cart? When they begin the checkout process? At some other point?)

Thanks!


texts:
Is it possible to prefix the root Drupal folders? Is there an option/way to define a prefix for theses folders?

e.g /includes/ becomes /drupal_includes/

I'm implementing a site that will begin as part Drupal implementation, part static. So to keep the site tidy it would be nice if I could "mark" the Drupal system.

It's not essential so if it's not simple then it wouldn't be worthwhile.


texts:
I am trying to hook into the Print module after to call a custom function after the pdf is generated. I've got this working by simply patching a call back on the wkhtmltopdf.pages.inc:

 if (!empty($pdf)) {
  _callback_for_pdf();
  return $pdf;
}

This is pretty nasty. So ideally I would like to try and extend this contrib module to have a hook for this functionality.

How do I go about adding a hook to something to then use in a custom module?


texts: How to achieve MuchoMenu Multilingual functionality?

texts:
I have used MuchoMenu in my site. Now I'm struck at translation.

There is no option to translate the MuchoMenu, also there is no translation strings available. How do I translate the menu links specified in the muchomenu?


texts: How do I override the vocabulary template but only on a specific content type

texts:
I have a vocabulary called "Sectors" and a content type called "News". Basically the vocab displays which sector the blog article is related to and links to the corresponding CMS page about that sector.

How do I customise the template that shows that vocabulary on my pages of that content type?

Many thanks.


texts: Define custom twig page template for specific pages by page url - page--program.html.twig

texts:
I have multiple pages with different content type. All the pages 1st path component is same. So, I want to define a custom twig page template to these pages by their 1st path component.

Eg. I have pages with the URL like program/one, program/two, program/three and program/ten from the different content type and I want to apply page--program.html.twig template only these specific pages by checking their 1st path component (eg. program/*).

Anyone help me, how to do this?


texts: Custom language switcher block, returning urls problem

texts:
In Drupal 8, i am trying to create a custom language switcher block.
So, I created a custom module, where I created a new class that extends the "LanguageBlock" class of the core language module.
I utilize the build() method, that builds alright my custom block. The problem though, is that the resulting links of my custom block, return a pattern like this in the url:

http://base_url/?language_content_entity=en
http://base_url/?language_content_entity=de
http://base_url/?language_content_entity=es

and the language does not change, whereas the default language switcher block works fine.
This problem occurs even if the build() method is copy/paste from the parent class, and/or even if I just return parent::build(), with no editing whatsoever.
Does anybody have a clue why this is happening, and maybe a possible solution?
Thank you.

PS: The code of the build() method.

public function build() {
    $build = array();
    $route_name = $this->pathMatcher->isFrontPage() ? '<front>' : '<current>';
    $type = $this->getDerivativeId();
    $links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name));

    if (isset($links->links)) {
      $build = array(
        '#theme' => 'links__language_block',
        '#links' => $links->links,
        '#attributes' => array(
          'class' => array(
            "language-switcher-{$links->method_id}",
          ),
        ),
        '#set_active_class' => TRUE,
      );
    }
    return $build;
  }


texts:
I have a custom content entity. For this entity, I want add multiple uploaded files.
After I set this up, I looked at the database and saw:

file_managed => stores all files uploaded by a managed_file field
file_usage => links between your entity and the table file_managed

So for the managed_file field form, I don't need to create a field into my entity content (database), I just add a field into the EntityForm directly:
  $form['image'] = array(
      '#title'=>t('Image du produit'),
      '#type' => 'managed_file',
      '#upload_location' => 'public://produits/',
      //'#default_value' => array(),
      '#description' => t('png jpge jpg'),
      '#upload_validators' => array(
          'file_validate_extensions' => array('png jpg jpeg'),
      ),
      '#multiple'=>true,
  );

And then I can upload multiples files.
Then in my submit :
public function save(array $form, FormStateInterface $form_state) {
    $entity = $this->entity;

      foreach ($form_state->getValue('image') as $image) {
          $file = \Drupal\file\Entity\File::load($image);
          $file->setPermanent();
          $file->save();

      $file_usage = \Drupal::service('file.usage');
      $file_usage->add($file, 'boutique', 'produits_entity',$entity->id());

      }
}

I store image reference into the file_usage table and set it permanent. At this point all is good.
But I need to load all files when user want edit my entity, I can load this from the file_usage table and build my

'#default_value' => array($images)

I want to know if it's a good practice and if Drupal 8 work like that.


texts: How can you identify all nodes that use a certain paragraph type or template?

texts:
In Drupal 7, given a custom paragraph bundle and an associated template file, is there a way to list all the nodes using that bundle? Or, if it's any easier, a way to do the same for a specific module instead of a paragraph type?

A Drupal core module update (https://www.drupal.org/project/link/issues/3095484) broke a bunch of our links across our site, and while a workaround is available, I wanted to test it against all the existing nodes first.


texts:
I am using Drupal Commerce Kickstart and since we are having only one payment method I would like to disable the extra step "Payment" in the checkout process which is reserved for "Off-site payment redirect".

I did not find a way to disable this directly in the UI at Checkout settings (admin/commerce/config/checkout) because this checkout pane seems to be locked.

So I digged in code and found line 309 to 315 in commerce_payment.module (profiles\commerce_kickstart\modules\contrib\commerce\modules\payment\commerce_payment.module).

  $checkout_panes['commerce_payment_redirect'] = array(
'title' => t('Off-site payment redirect'),
'page' => 'payment',
'locked' => TRUE,
'file' => 'includes/commerce_payment.checkout_pane.inc',
'base' => 'commerce_payment_redirect_pane',
 );

If I completely remove these lines the payment step is gone. If I set the locked value to "FALSE" I can disable the pane at Checkout settings.

What is the cause that this step is locked and is it safe to disable this step this way?


texts: How to send dynamic content as an attachment file in email?

texts:
Normally we send files as attachments in the email if they are stored in the file system.
$file->uri = 'sites/default/files/file_name.pdf'; // File path
$file->filename = 'file_name.pdf'; //File name
$file->filemime = 'application/pdf'; //File mime type
$params['attachments'][] = $file;
$mailManager->mail($module, $key, $to, $langcode, $params, NULL, $send);

But I have dynamically generated content.
$content = <?xml version="1.0"?>
<root><element>element value</element></root>

I want to send it as an XML file attachment in the email. How can I do this?


texts:
I am creating listing of content using tableselect form type like as follow.

function partners_list($form,&$form_state){
        $header = array(
            'name'=>array('data' => t('Name'),'field' => 'ept.name'),
            'location'=>array('data' => t('Location'),'field' => 'ept.location'),
        );

        $form['search_ew_partner'] = array(
            '#type' => 'textfield',
            '#prefix' => '

',
            '#suffix' => '
',
            '#default_value'=> $form_state['values']['search_ew_partner'],
            '#attributes' => array(
                'placeholder' => 'Search by name'
            )
        );

        $form['submit'] = array(
            '#type' => 'submit',
            '#value' => t('Search'),

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

',

            '#attributes' => array(
                'class' => array('btn blueBtn')
            )
        );

        if(empty($form_state['input'])){
            $results = partners_list_submit($form,$form_state);
            $results=$results['filter_result'];
        }else{
            $results=$form_state['filter_result'];
        }

        $options = array();
        if(!empty($results)){
            foreach($results as $result){
                $options[$result->id] = array(
                    'name' => array('data' => array('#type' => 'link', '#title' => $result->name, '#href' => "partner/details/".$result->id)),
                    'location' => ucfirst($result->location),
                );
            }
        }

        $form['ew_partners'] = array(
            '#type' => 'tableselect',
            '#header' => $header,
            '#options' => $options,
            '#empty' => t('No partners.'),
            '#attributes' => array(
                'class' => array('table')
            )
        );

        $form['pager'] = array('#markup' => theme('pager'));
        return $form;
    }

    function partners_list_submit(&$form,&$form_state){
        $form_state['rebuild'] = true;
        $header = array(
            'name'=>array('data' => t('Name'),'field' => 'ept.name'),
            'location'=>array('data' => t('Location'),'field' => 'ept.location'),
        );

        $query = db_select('ew_partners', 'ept');
        if(!empty($form_state['values']['search_ew_partner'])){
            $query->condition('ept.name', '%' . $form_state['values']['search_ew_partner'] . '%', 'LIKE');
        }

        $query = $query->extend('PagerDefault')->extend('TableSort');
        $query->fields('ept',array('id','name','location'));
        $query->limit(2)
            ->orderByHeader($header);

        $results = $query->execute();
        $form_state['filter_result']=$results;
        $form_state['no_cache'] = true;
        return $form_state;
    }

Listing and pagination coming properly when there is no filtration on table. After filtration, pagination is not working.
I think due to form_state values are reset when I clicked on next page.
The page count and the result for first page is coming properly.

How can i maintain pagination with filter using tableselect?

Thank you in advance
Any help appreciated.


texts: Illegal choice error in views exposed filter select list

texts:
My question is related to Drupal 7 Views Exposed Filter - How to Select all Taxonomy terms Upon adding new terms? however I have a different problem. I want to filter a view by users of specific roles and for that i have added the user field in views filter and exposed it.

The problem is that if i check "select all" in "options" and leave "Limit list to selected items" unchecked, the select shows "--Any--" as default selection and also includes any users added later but throws "An illegal choice has been detected. Please contact the site administrator" and does not load any views.

On the other hand, if i check "Limit list to selected items" in options it shows no error but then it will only load the selected users in options and not any user added later. The field "check_user" has a field collection relationship. How to solve this? Is this a bug or misconfiguration?

Using views 3.8 and Drupal 7.32

[EDIT]

I managed to remove the error by deselecting the "select all" option and checking all the users, this way the select list filter include the checked users in exposed filter and also any user added later. The select filter also provided "--Any--" option but when I first load the view, the first user in the list is automatically select instead of "--Any--". How to default the select filter to "--Any--"?


texts: How can I send email to user that is not logged in since 30 days?

texts:
I am using Drupal 7, and I want to send email to registered users who have not logged in to the site since 30 days; for example, an email saying:

  Hello user, you are not login since 30 days.

Is there any way?


texts: How to write a drupal cron job to fetch data from a link

texts: How can I write drupal cron job that fetches data from a link and update the database ..? Im new to drupal so unable to understand the working of cron after searching alot. Any help will be appreciated ..


texts:
I am new in Drupal,
and I am creating  a library the library has subject, each subject select from a list that referenced to a taxonomy.

  I want each subject become an item in my menu and when click on it
  show that tag result.


texts: Adding/Editing Node tab links through preprocess method

texts:
When editing/adding/removing tab links to a Node page (View/Edit) is there a quick way doing this with a hook_preprocess method and not via creating a module to alter them? Such as using hook_process_page() and then editing the $title_prefix array since this is where they are stored.

Example: I created a module for editing the contextual links, but what if I wanted to skip creating a module and directly inject my changes in the template.php via  hook().

function mymodule_contextual_links_view_alter(&$element, &$items) {
      $element['#links']['new-links'] = array(
        'title' => 'Add something new',
        'href' => url('/admin/config/add/something/new', array('absolute' => TRUE)),
      );
    }


texts: How to get searched item value in search form?

texts: How do I get the value of searched item value, if I searched for "cat" in a search box then it also displays on a search page?


texts:
Based on articles taxonomy  and branch selection we are differentiating the taxonomies for different branches.

I created one taxonomy per one page
         just like

       section 1
        sub section 1
       section 2
        sub section 2

    In one page  there are many different section is there,

    first you created article i.e. hide test

    select taxonomy as like above
    after select section of the page

    taxonomy will be display only in that section of the page
    Case1:

    We are creation one article
    While creation I selected Taxonomy “section 1 ” and one page section “one”
    This taxonomy is available only "one"  section only.

    Case2:
    We are creation one article
    While creation I am not  selected Taxonomy “section 1” and one page section “two”. I selected the some other category
    Display another category in this two  section.

    Case3:
    We are creatinog one article
    While creation I am selected Taxonomy “section 1 ” and one page section “one”,”two”.
    "hide test" will display in two branches.


texts: Getting JSON format of a node using drupal

texts:
I am having issues receiving JSON data of a node with Drupal 8 Core REST. Here are the steps I have went through several times:

Install latest version of drupal 8
Enable all core web services modules (HAL, HTTP Basic Authentication, RESTful Web Services, Serialization)
Go to permissions page. Find RESTful Web Services permissions and allow delete, get, patch, and post for all users.

I created a path using Views module to show JSON format of my website contents and it works fine:
http://www.example.com/api/v1/order/

but when I use the following URL to Get the JSON format of a node using POSTMAN or DHC client, it returns HTML format of data!:

http://www.example.com/node/1?_format=json


texts: How to process more than one item from queue in each run?

texts:
I have set up a queue using:

  function custom_logger_cron_queue_info()
  {
    $queues['custom_logger'] = array(
      'worker callback' => 'custom_logger_import',
      'time' => 60,
    );
    return $queues;
  }

Which I add items to using:

$item = array('uri' => $uri, 'uid' => $uid, 'fid' => $fid);
$queue = DrupalQueue::get('custom_logger');
$queue->createItem($item);

Which is working great, except that when cron runs every minute for this queue (I am using ultimate_cron module to set this) the custom_logger_import function is only processing one item per run. At present I have the function simply set up as:

function custom_logger_import($item) {
    $uri = $item['uri'];
    $uid = $item['uid'];
    $fid = $item['fid'];
//Do some stuff
}

Is there something I am missing on ensuring that as many items as possible get run? They are only small jobs that complete in less than a couple seconds but at the moment its taking 3-4 minutes to process just 3 items.

UPDATE:

The problem was actually in my function that was being called. I was using non-drupal friendly sql which seemed to prevent the job being done more than once. After updating all the database related stuff to drupal friendly database extraction layer stuff, it all works fine. For the record, here is a good way of checking that everything is running fine with the queues. Comment out your function being called by the queue and add this in replacement:

$file = '/somepath/hello.txt';
$current = file_get_contents($file);
$current .= $item['some variable from your queue item'] . " Hello\n";
file_put_contents($file, $current);

Then, when the queue is processed at cron, it should print out each of your queue items variable followed by hello to a text file.


texts:
I'm using pathauto on a D8 site successfully for pattern type Content using a pattern like this:

[node:content-type]/[node:title]

But I'm not having any luck at all when trying to use it for pattern type Taxonomy term using a pattern like this:

[term:vocabulary]/[term:name]

I just keep getting /taxonomy/term/123 instead of /taxonomyname/taxonomyterm

I have searched and searched and every article I find only covers the tokens for Content, not Taxonomy. I did find one youtube video that covered it in D7 and the pattern was identical to mine, yet his worked but mine doesn't. I've cleared caches and even tried bulk generate to no avail. But Taxonomy (list) pages don't create aliases though, so I'm wondering if that has something to do with it.


texts:
I have installed the module Drush Help to see the module's Drush commands in the module help page. But when I go to see the help page of a module that use in the drush commands drush constants like DRUSH_BOOTSTRAP_DRUPAL_FULL I got a Notice because this constant is only defined in drush, and not for Drupal.

You can see this problem if you install the Drush Help and the Node Revision Delete modules (the Drupal 7 version): Visit admin/help/node_revision_delete and you will see this notice message.

  Notice: Use of undefined constant DRUSH_BOOTSTRAP_DRUPAL_FULL - assumed 'DRUSH_BOOTSTRAP_DRUPAL_FULL' in node_revision_delete_drush_command()

So the problem is that Drupal can't reach the file includes/bootstrap.inc where the constant is defined. I can include the file but the problem is that I need to know where Drush is installed.

How to find where Drush is installed to include a file in my module?


texts: Is there a way to change Views base table dynamically?

texts:
I have a couple of Search API indexes for different server environments (test, qa, uat, prod) with different configurations.

Instead of create 4 views in the admin, I just want to use one, and depending on environment, swap the base table (index). That way I can have one view at one URL.

Is that possible in Drupal 8?


texts: Customizing the form for a field in the content edit form

texts:
I have configured a taxonomy as field of a content type, but I want to replace the checkbox label (work with iphone) with the image field of that taxonomy. (See the screenshot.)

I only know to alter node.pages.inc at row 290 by adding the following code.

$form['product_label'] = array(
    '#type' => 'checkboxes',
    '#title' => 'Checkboxes Title',
    '#title_display' => 'before',
    '#default_value' => array(0,2),
    '#options' => array(
      0 => 'option one',
      1 => 'option two',
      2 => 'option three',
    ),
    '#theme' => 'testmodule_checkboxes',
  );

product_label is the checkbox name. The above code is to override the current checkbox field.

I think this not the best way. Can anyone provide any direction? What module can do it?

Here is the dump of the checkbox field of the form.

array(6) { ["#type"]=> string(9) "container" ["#attributes"]=> array(1) { ["class"]=> array(3) { [0]=> string(34) "field-type-taxonomy-term-reference" [1]=> string(22) "field-name-field-icon1" [2]=> string(28) "field-widget-options-buttons" } } ["#weight"]=> string(1) "2" ["#tree"]=> bool(true) ["#language"]=> string(3) "und" ["und"]=> array(18) { ["#entity"]=> object(stdClass)#91 (12) { ["uid"]=> string(1) "1" ["name"]=> string(5) "admin" ["type"]=> string(7) "product" ["language"]=> string(3) "und" ["title"]=> NULL ["status"]=> int(0) ["promote"]=> int(0) ["sticky"]=> int(0) ["created"]=> int(1344929691) ["revision"]=> bool(false) ["comment"]=> string(1) "1" ["menu"]=> array(12) { ["link_title"]=> string(0) "" ["mlid"]=> int(0) ["plid"]=> int(0) ["menu_name"]=> string(9) "main-menu" ["weight"]=> int(0) ["options"]=> array(0) { } ["module"]=> string(4) "menu" ["expanded"]=> int(0) ["hidden"]=> int(0) ["has_children"]=> int(0) ["customized"]=> int(0) ["parent_depth_limit"]=> int(8) } } ["#entity_type"]=> string(4) "node" ["#bundle"]=> string(7) "product" ["#field_name"]=> string(11) "field_icon1" ["#language"]=> string(3) "und" ["#field_parents"]=> array(0) { } ["#columns"]=> array(1) { [0]=> string(3) "tid" } ["#title"]=> string(4) "icon" ["#description"]=> string(0) "" ["#required"]=> bool(false) ["#delta"]=> int(0) ["#type"]=> string(10) "checkboxes" ["#default_value"]=> array(0) { } ["#options"]=> array(1) { [14]=> string(16) "Work with iphone" } ["#value_key"]=> string(3) "tid" ["#element_validate"]=> array(1) { [0]=> string(29) "options_field_widget_validate" } ["#properties"]=> array(4) { ["filter_xss"]=> bool(true) ["strip_tags"]=> bool(false) ["empty_option"]=> bool(false) ["optgroups"]=> bool(false) } ["#after_build"]=> array(1) { [0]=> string(30) "field_form_element_after_build" } } }

The problem is that I can't find the image (filename) which is a custom field of the taxonomy. I want to replace "work with iphone" with the uploaded image. How can I do this?


texts: How do I theme (add extra markup to) menu links in Drupal 7?

texts:
I have a secondary menu that displays like:

PAGE

...

I would like to change that so it displays a  on the links like:

PAGE

...

According to the Drupal 7 theme_menu_link documentation and this answer on theming Drupal 7 menu links, I should just be able to declare a hook like THEMENAME_menu_link__MENUNAME($variables).

I've declared the following two functions in my template.php, but neither of them is being called:

function MYTEMPLATE_menu_link__system_secondary_menu(array $variables) {die;}
function MYTEMPLATE_menu_link__secondary_menu(array $variables) {die;}

I'm using Framework, and there's a section like:

if (isset($vars['secondary_menu'])) {
    $vars['secondary_menu'] = theme('links__system_secondary_menu', array(
        'links' => $vars['secondary_menu'],
        'attributes' => array(
        'class' => array('secondaryNavigation'),
    )
    ));
}

What's the cleanest / best practice-y way of printing an extra  in the menu links for this menu only?

I can write a function to theme the entire menu at once with function MYTEMPLATE_links__system_secondary_menu(array $variables), but theming the entire menu  just to get a  in each link seems like overkill.


texts: Can't understand how to invoke my own theme() function

texts:
i have made formexample.module, from Drupal 7 Pro Development

function formexample_menu() {
    $items['formexample'] = array(
        'title' => 'View the sample form',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('formexample_nameform'),
        'access callback' => TRUE,
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

function formexample_nameform() {
    $form['name'] = array(
        '#title' => t('Your name'),
        '#type' => 'fieldset',
        '#description' => t('what people call you'),
    );

    $form['name']['user_name'] = array(
        '#title' => t('Your name'),
        '#type' => 'textfield',
        '#description' => t('please enter name'),
    );

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

and a theme function and preprocess function

function formexample_theme() {
    return array(
        'formexmaple_nameform' => array(
            'render element' => 'form',
            'template' => 'formexample-nameform',
        ),
    );
}

function template_preprocess_formexample_nameform(&$variables) {
    $variables['name'] = $variables['form']['name'];
    $variables['submit'] = $variables['form']['submit'];
}

this is template file for this theme() - formexample-nameform.tpl.php

<div id="formexample_nameform">
<?php
    print render($name);
    print render($submit);
?>
</div>

my question is: how and where to invoke this theme('formexample_nameform') , i thought i should insert function template_preprocess_formexample_nameform to my template.php file(with template rename to my theme name) but its not working for me


texts: Protect previous migrated field values on system of record migration

texts:
I have a successful migration of content type A, B and C. In the migration of C, I have entity reference fields that get populated with the correct values coming from migration A and B.

My reference fields is a multi value node entity reference field. To prevent the values being over ridden from my previous migrations, I use the system of record method.

https://www.drupal.org/node/1117454
https://www.drupal.org/node/2550939

The example is very specific to a commerce migration.

// If "updating" a product, protect these fields.
        // We know its updating if the product exists in the database with the sku.
        // Migrate updates by deleting an entire entity and replacing with
        // the new one. We circumvent the removal of the values of these
        // fields by pulling them and overriding the defaults provided
        // in the mapping.
        // You could do the same with a nid id found with a title, or something similar.
        // $row->migrate_map_sourceid1 is usually the entity id you're looking for,
        // our example here uses a commerce_product and loads it with the provided sku
        if ($product = commerce_product_load_by_sku($row->sku)) {
            // Use the metatdata wrapper to pull values
            $product_wrapper = entity_metadata_wrapper('commerce_product', $product);

            // field_stock
            // Some products have a NULL stock, lets keep the zero default if NULL
            if ($product_wrapper->field_stock->value() !== NULL) {
                $row->stock = $product_wrapper->field_stock->value();
            } else { $row->stock = 0; }

            // field_max
            $row->max = $product_wrapper->field_max->value();
        }

I am not sure how I would use my prepare row, current content types, their ids etc to remove the current values, update the new values, and then add the previous ones again? Or am I misunderstanding how this is suppose to work? Thanks in advance!


texts: How to get field structure for a custom content type?

texts:
I have created a custom content type (mytest) via the Drupal 8 UI.

The content type contains a list field which has the following key|values:

gp|GP
device|Device

I have tried the following code to retrieve field, but it not there.

$fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'mytest');

Does any one know how to retrieve a List field structure?


texts: Construct a View-Grid from fields of the same node?

texts:
I understand that naturally it's not possible to grid fields from a single node, when using Views, and we could only display a grid if each field is coming from a different node.

Is there a module that will allow Views, somehow, to make a grid based on fields from the same\single\unique node?

I would surly prefer a way to do it with views-only, but if there is no easy\automatic way to so without installing an external module than so be it.


texts: How do I programmatically get the content title field from a view?


texts:
I was using the "autocomplete term widget (tagging)" as widget type for a term reference field. I found out that the when I set the maximum number of allowed values to more than one (i.e multiple choices), the auto complete does not work after you have added one option.

Do you have any idea on how to work around this?


texts: What is the best way to theme the first row in the view differently?

texts:
I have a view with the first row of it being designed differently from the rest. What is the best way to theme the first row. Should I attach one view (First Row view) with a second view ? If so, how? Or should I theme using the template files and if so How can I know the row I am currently in?

The attached image may better explain what I am talking about:


texts: Get path from router and redirect after autocomplete selection

texts:
I have a form that is inflated inside a box.  In that form I have an autocomplete field.  I want to allow the user, when they select an item from the autocomplete's suggestions they are automatically redirected to the appropriate page.

My current idea is to handle this in JS.  But I don't like this as it makes it very difficult to use Drupal's routing system to route -- instead I have to hardcode things, which is bad.

class AutocompleteSearchForm extends FormBase {

  public function getFormId() {
    return 'search_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['search'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Lookup'),
      '#description' => $this->t('Search.'),
      '#placeholder' => $this->t('Search'),
      '#autocomplete_route_name' => 'block.autocomplete.callback',
      '#autocomplete_route_parameters' => array('name' => 'name'),
      '#attached' => array(
        'library' => array('module/autocomplete'),
      ),
    );
    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state) {
    \Drupal::logger('module')->warning('form submitted for' . $form_state->get('search'));
  }
}

And my JS is:

(function ($) {
    $('#edit-search').on('autocompleteclose', function (event, node) {
        var entity_id = $(this).val();
        alert(entity_id);
    });
}(jQuery));

As you can see, I tried to manage this through the callback, but I don't expose a button and this doesn't submit unless the user hits the "enter" button, which isn't exactly intuitive.

Is JS the best way to handle this?  If it is, is there a good way to get access to Drupal's path/router system from JS?


texts: How to always show Poll results on most recent poll block?

texts:
I want to make a block that shows a poll that shows the results and with a link to vote to that particular poll.
It seems that the default most recent poll shows the results if the user doesn't have the right to vote and the voting options if it has the rights...

How can I control this?


texts: Is it possible to use standard tokens in a views field?

texts:
I am using Drupal 7.38 and Views (7.x-3.11) to show fields. I can't seem to get standard token replacement working for text fields, e.g. [node:created] is not replaced with the relevant value.

This seems to work fine if I set views to show content rather than fields. Am I missing something obvious?


texts: How would we limit the drop down for the Date's Timzone field?

texts:
We are using the Date module that allows for enabling of Timezone during node edit (node/edit). We noticed that the dropdown is really long and we were wondering if there was a way to shorten the list to just say ETC, PST, UTC, GMT, etc.

We tried all the configuration setting, but could not shorten the drop down.

Current scenario:

Desired scenario:

Timezone (as an example)
 - UTC
 - PST/PDT
 - MST/MDT
 - EST/EDT
 - GMT


texts: How to sort on different columns in the same view?

texts:
I'm trying to build a Glossary View in Drupal 8. Let's say I have 3 content types: Person, Article, Event.  I want sort by title ASC for Article and Event, but sort by Last Name for Person.  So that listing would show something like.

Deep Study on Dolphins (article)
John Doe (person)
Jam in the Backyard (event)

And Not

Deep Study
Jam in the Backyard
John Doe

I think I can do this with hook_views_query_alter, but the only examples I've seen are for Drupal 7.

I've got something like this

function mymodule_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
  if ($view->id() == 'glossary_everything') {
     $query->orderby[0]['field'] = "CASE WHEN node_field_data.last_name IS NULL THEN node_field_data.title ELSE node_field_data.last_name END";
  }
}

But I'm getting a "column not found" sql error.  I think it's treating the whole CASE statement as one big field.  Is that because of the ['field'] designation in my array?


texts: Node translation vs. Entity (field) translation

texts:
I would like to know what you guys recommend for a multilanguage site. For example, consider the following case: A page and its content should be available in 3 languages (e.g. German, English, and Spanish); the site uses one profile type, several content types and views, taxonomy, taxonomy-references, node references, user and field references, field collections, menues and so on. All of this informations should be translatable.

As far as I know, there are two ways to obtain this: with Entity Translation and the "node-based" method, or the usual one with the Internationalization modules and l10n.

What way should I choose? In which case and why should I consider a method instead of the other?


texts: Price not updating on custom theme template

texts:
I have a theme with a custom product display template.  I created a product display with different product variations; when different variations are selected, the price doesn't seem to be updated to reflect the product variation chosen.

It seems to be a problem with the theme as it works with standard themes.

I tried different jQuery versions and doesn't seem to be any JavaScript error. I've read somewhere that it could be the the price not being wrapped with the appropriate classes.  If that's the case, how do I fix that?


texts: How to set a taxonomy term programmatically for a node?

texts:
I created taxonomy terms and assigned it to a content type 'Article' using term reference field. I created nodes by programmatically but how to set taxonomy terms for the nodes?

The taxonomy terms are created already. I want to set the taxonomy term for a node programmatically.


texts: How to programmatically custom form field?

texts:
I want to display a form textfield with this HTML output:

      Amount (in dollars)

          <input type="text" class="form-control" name="" id="">

€ / month

I try this in my custom form :

  public function buildForm(array $form, FormStateInterface $form_state) {
    $fields = [
        'field_1',
        'field_2',
        'field_3',
    ];

    foreach ($fields as $field) {

        $form[$field] = array(
            '#type'             => 'textfield',
            '#prefix'           => 'My label',
            '#size'             => 30,
            '#default_value'    => 0,
            '#required'         => TRUE,
            '#suffix'     => '
€ / mois
',
            '#attributes' => array('class' => array('form-control text-right')),
        );
    }

    return $form;
}

And HTML output result look like :


texts:
How does the 404 page you can define in /admin/config/system/site-information work?

I found Drupal\system\Controller\Http4xxController->on404(), but how does that display whatever path I definied in basic site settings?

I'm trying to deliver a 410 when a page is deleted. I hve a database table with deleted paths, an InboundPathProcessorInterface to call a custom controller. Now I want to output the exact same thing as a 404, just with another status code.

Alternativly, how do I get the content of a given system path (i.e. node/123) to output in a Symfony\Component\HttpFoundation\Response?


texts: Going from an installation profile to vanilla Drupal

texts: I currently am using the Acquia Drupal installation profile on a site, and I want to convert it to a vanilla Drupal install.  Other than cross referencing the modules that come with the profile, and making sure you download those from drupal.org and putting them into sites/all/modules, are there anymore steps that would need to be taken besides your regular update instructions?


texts: How to use theme functions in .module files?

texts:
I am trying to override theme_radio and theme_radios directly in MY_MODULE.module file.

For this purpose I declared these functions:

1)

 /**
 * Implements hook_theme().
 */
function MY_MODULE_theme($existing, $type, $theme, $path) {
  return array(
    // Theme for radio group.
    'custom_radios' => array(
      'render element' => array('element' => NULL),
    ),
    // Theme for single radio.
    'custom_radio' => array(
      'arguments' => array('element' => NULL),
    ),
  );
}

2)

function theme_custom_radios($variables) {
  dpm('custom_radios');
  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  $attributes['class'] = 'form-radios';
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']);
  }
  if (isset($element['#attributes']['title'])) {
    $attributes['title'] = $element['#attributes']['title'];
  }
  return '<div' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</div>';
}

3)

function theme_custom_radio($variables) {
  dpm('custom_radio');
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  }
  _form_set_class($element, array('form-radio'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}

Then, to call my custom function I used hook_form_alter this way:

/**
 * Implements hook_form_alter().
 */
function MY_MODULE_form_alter(&$form, &$form_state, $form_id) {
  if(isset($form['nid']['#value'])){
      if($form['nid']['#value']=='472'){
        if($form_id=='uc_product_add_to_cart_form_472'){
            $form['attributes']['8']['#theme'] = 'custom_radios';
        }
      };
    }
}

Apparently the function theme_custom_radios is correctly called, the problem is that my radios buttons are now empty, I mean they are no more there.

Anybody has an idea?

/**** EDIT ****/

Here is the dpm output of my form:

attributes (Array, 7 elements)
    #theme (String, 24 characters ) uc_attribute_add_to_cart
    #id (String, 42 characters ) uc_product_add_to_cart_form-472-attributes
    1 (Array, 7 elements)
    8 (Array, 7 elements)
        #type (String, 6 characters ) radios
        #default_value (NULL)
        #options (Array, 4 elements)
            0 (String, 7 characters ) Color 1
            1 (String, 7 characters ) Color 2
            2 (String, 7 characters ) Color 3
            3 (String, 8 characters ) Color 17
        #ajax (Array, 2 elements)
        #title (String, 4 characters ) yeah
        #description (String, 0 characters )
        #required (String, 1 characters ) 1
    2 (Array, 7 elements)
    #tree (Boolean) TRUE
    #weight (Integer) -1

The options Color 1, Color 2, etc.. is what I need to change.

Actually I have a Drupal error:

Notice: Undefined index: element in theme_custom_radios() (line 85 of /home/www/dev/MY_WEBSITE/sites/all/modules/MY_MODULE/MY_MODULE.module).

Am I supposed to send arguments in MY_MODULE_theme function? I was expecting that arguments would stay exactly the same, I just need to update the html code to add a span with the color as background


texts: Are there certain JavaScript functions that aren't allowed?

texts:
I am trying to use Google Publisher Tags for a site. I have the JavaScript and HTML files that work in a plain HTML document. However, if I use the same JavaScript file in Drupal, it doesn't run.
I can't find anything that would be causing this. I can see the file being attached, I can get some stuff to execute in these files, but not the part that calls Google.
I am just trying to get this test to work.
So I have created a custom block with the HTML and attached the .js file in my theme.
The JavaScript file
   var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function() {
      var gads = document.createElement("script");
      gads.async = true;
      gads.type = "text/javascript";
      var useSSL = "https:" == document.location.protocol;
      gads.src = (useSSL ? "https:" : "http:") + "//www.googletagservices.com/tag/js/gpt.js";
      var node =document.getElementsByTagName("script")[0];
      node.parentNode.insertBefore(gads, node);
     })();

    googletag.cmd.push(function() {
      var adSlot1 = googletag.defineSlot('/6355419/Travel/Europe/France/Paris',[300, 250], "banner1");
      adSlot1.addService(googletag.pubads());
      googletag.enableServices();
    });


texts: Is there anyway to get more control over when CRON runs?

texts:
I've just setup some rules using the Rules Scheduler module. Everything is working as expected, except that when a rule is scheduled for 10:30am, it might not run til 11:00am, because that is when CRON runs.

Furthermore, when I go to the CRON settings page, it only allows me to select the intervals which CRON runs at.

Is there anyway to schedule a CRON task, e.g. everyday at 10:30? If is there anyway to be sure that if I set CRON to run at 1 hour intervals, CRON is running on the hour, and not some random time, based off when someone last pressed the run cron button?

I'm running Drupal 7 on a Windows platform is that makes a difference.


texts:
I'm relatively new to Drupal and I'm working on a page that needs comment functionality for non-authenticated users. I tried some various forms (Webform, EntityForm) but they just seemed like way too much. The comments module has exactly what I need as far as submission and moderation goes.

I tried adding the form to the sidebar of a page but it showed up with a massive rich text editor and kind of broke the layout.

Is it possible to insert a very basic comment form with a simple long-text field and a submit button? If so...how?

Screenshot:


texts: How to pass a custom Form to a Twig template

texts:
my problem is that my drupal 8 form is not getting rendered in twig template.

I created a form with build form method in drupal 8 when i tried it to pass in twig template it is not getting passed.for example my code is

modulenameconfig.php

class modulenameConfigForm extends ConfigFormBase {

  /**

   * {@inheritdoc}

   */

  public function getFormId() {

    return 'modulename';

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

    $form = parent::buildForm($form, $form_state);
    $config = $this->config('modulename.settings');

    $form['first_name'] = array(

      '#type' => 'textfield',

      '#title' => $this->t('First Name'),

      '#default_value' => $config->get('modulename.first_name'),

      '#required' => TRUE,

    );

    $form['last_name'] = array(
      '#type' => 'textfield',
      '#title' => t('Last Name'),
      '#default_value' => $config->get('modulename.last_name'),
      '#required' => TRUE,
    );
    return $form;

  }
 protected function getEditableConfigNames() {

    return [

      'modulename.settings',

    ];

  }
}

modulename.module

<?php

namespace Drupal\modulename\Form;

use Drupal\Core\Form\ConfigFormBase;

use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_menu()
*/

function modulename_theme() {
  return array(
    'modulename_form' => array(
      'render element' => 'form',
      'template' => 'modulename-form',
      'base hook' => 'form'
    ),
  );
}

my twig file in templates folder

modluename-form.html.twig

{%
  set body_classes = [
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    db_offline ? 'db-offline',
  ]
%}

Personal Information

                                    <form method="post">

                                            First Name

                                              {{form.first_name}}

                                            Last Name

                                                <input type="text" class="form-control" name="lname" id="lastname" placeholder="Last Name" required>

any help will be greatly appriciated  help asap


texts: How should the content structure for a Comparison website look like?

texts:
What is the "right way" to build a community-oriented comparison system in Drupal 7? My primary question is do I need to hand-roll the DB code for this or is there a way to do it with existing Drupal techniques? My secondary question is how would you structure this in Drupal?

The entities of my site are as follows.

User classes:

Administrators (me <=1)
Analysts (trusted community moderators <100)
Authenticated Users (untrusted community content creators <2000)
Anonymous site visitors can view all of the reviews (billions of people :)

Products:

product classes. (e.g. Cameras, Laptops, Mobile Phones, etc). There will be >500 product classes. Analysts can edit and manage product classes by adding product feature types, etc.
products (e.g. Nikon D7000, Canon EOS Rebel, etc) are an instance of a product class. Authenticated Users can add/edit products.
product features are the pre-defined set of features of a product class (e.g. Exposure Metering, Exposure Modes, White Balance, Max Shutter Speed, etc). These are administered by Analysts.
product feature types. Each product feature must be of a certain type like a star rating, text, price, number, url, etc.

My initial solution was to create a custom content-type for each product class, then use Drupal fields for the product features. My concern with this approach is that I don't know how to allow semi-trusted Analysts to create and manage their own product classes and product feature types without giving them administrator privileges. Also, I imagine having hundreds of product classes and so it feels weird to have a custom content-type for each * product class*.

I'm happy to do it the php-module way, or the pointy-clicky way. How would you approach this?


texts: Multiple forms in same page from single form builder returning the first form's value in submit

texts:
I have written a single form builder and a form submit handler corresponding to that form.

What I have done is that I have rendered the form multiple times using for loop and then concatenated them into a single variable and then displayed it on a single page.

Each form has separate submit buttons.

But the problem is that whenever I press the submit button of any of the forms I am only getting the form that was built first in the form_state['values'] in the submit handler.

For now, I have made it work by taking the form_state['input'] which seem to have the correct set of values based on the form submit clicked.

I need the corresponding form values in the submit handler. How can I achieve this?

Is this some kind of bug or am I doing it wrong?

$form_markup = '';
  foreach ($ids as $key => $value) {
    $req_form = drupal_get_form('_request_form', $value, $key, $node);
    $form_markup .= render($req_form);
  }

My form and form_submit

function _request_form($form, &$form_state, $value, $key, $node) {
    $form['name'] = array(
      '#type' => 'item',
      '
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => 'Ask',
    );
    return $form;
  }
}

    function _request_form_submit($form, &$form_state) {
      dpm(form_state['values']);
      dpm(form_state['input']);
    }

Any help is much appreciated.
thanks.


texts: How to use Rules to restrict the edit and delete options if a field has value "approved"?

texts:
In my website I have 3 roles: user, tester and admin. When a user submits the content, tester will check and approve it.

As long as the content is not "approved", users can edit and delete their own content. But after the content is "Approved" (indicated via a field with value "approved"), users are not not allowed anymore to edit or delete their content.

How to do this with the Rules module based on roles?


texts:
I have now found two instances where it seems I will finally need to learn how to install and use drush for my new drupal 8 site. I've been avoiding drush the last 5 years working with drupal 7 because I couldn't find a clear tutorial on how to download, install and run (or even how or where to dl, install and run) drush.

For the record - the two use cases I seem to need drush for are:

running a migration command to import the csv I've already prepared with content I exported from a wordpress site. I'm trying to use the migrate Migrate Source CSV and the example listed on github.
running the command entity-updates per the mismatched entity question I posted.

So, I've now plunged back into trying to suss drush out, and I have some questions with my understanding thus far. My knowledge has been limited to logging into my host server to use cpanel (file manager, backups) and using the filezilla ftp client.

According to [this tutorial by digitalocean][4] I need to install LAMP stack and pear. This is the first point of confusion.

Is this still the correct method for drupal 8?
How do I install LAMP on my server - I'm using a Bluehost dedicated server, so it should already have Linux Apache MySQL PHP, correct? Or is this an application of some kind for those components I'm already using on my server to run my sites?
How do I install pear? From the command line I can access through my cpanel?

Then, trying to follow this Toronto Website Developer by Peter Yaworski tutorial it seems I also need composer?

Do I need to install the composer module?
Or do I install the [full composer here][7] - and do I install it to my server via cpanel command line as well?

That's about as far as my spaghetti understanding goes as to how what is needed to actually get drush up and running as a command line I can use. Oh, and finally, when I see videos or examples of people using drush, I assume they're running it from their server unless they have a local drupal install, correct?

Thanks in advance for any clarification - can't help but feel I'm in over my head here.


texts: Gif animation and responsive image styles are not working

texts:
I have a multiple image field and need it to upload images and animated gifs. These images might be resized. When this happens, the animated gif loses its animation.

Has anyone solved this problem in drupal 8?