texts: User edit form on custom page is resetting roles when user belongs to the "Administrator role"

texts:
I'm trying to display the user edit form on a custom page with limited fields. Submitting my form works well, but if I have the Administrator role, roles are reset. I don't understand why this is happening.
This is the routing file custom_user_profile.routing.yml.
my_module.default_controller_view:
  path: '/my_module'
  defaults:
    _controller: '\Drupal\my_module\Controller\DefaultController::view'
    _title: 'Account'
  requirements:
    _user_is_logged_in: 'TRUE'
  options:
    no_cache: 'TRUE'

In the controller DefaultController.php I have

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\user\Entity\User;

class DefaultController extends ControllerBase
{

    public function view()
    {
        $user = User::load(\Drupal::currentUser()->id());

        $html = '';
        $html .= '
Current email is ' . $user->mail->value . '
';

        $data['html'] = [
            '#type' => 'markup',
            '#markup' => $html,
        ];

        $user = User::load(\Drupal::currentUser()->id());
        $formObject = \Drupal::entityTypeManager()
            ->getFormObject('user', 'default')
            ->setEntity($user);

        $form = \Drupal::formBuilder()->getForm($formObject);

        $data['form'] = [
            'form' => $form,
        ];

        return $data;

    }

}

In the my_module.module I have following code.
use Drupal\Core\Form\FormStateInterface;

function my_module_theme($existing, $type, $theme, $path)
{
    $templates = array(
        'my_module_about_form' => [
            'render element' => 'form',
        ],
    );

    return $templates;
}

function my_module_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
    if ($form_id == 'user_form') {
        $form['#theme'] = ['my_module_about_form'];
    }
}

In the template file my-module-about-form.html.twig I have the following lines.
{{ form.timezone }}

{{ form.form_build_id }}
{{ form.form_token }}
{{ form.form_id }}
{{ form.actions.submit }}


texts: Can't submit data when rendering a webform programmatically

texts:
I'm working on a Drupal 8 project, when trying to load a webform programmatically in a controller, the webform is rendered correctly but when data has been submitted no values founded on webform results page (still always empty).

Injecting the form in a paragraph as block and then submit data work perfectly, also submitting data from the webform node page works as it should (We can find data on form results page).

Here is my code:

MyController.php

namespace Drupal\my_module\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\webform\Entity\Webform;

class MyFormPage extends ControllerBase {

  public function content() {
      $webform = Webform::load('my_webform_id');
      $view_builder = \Drupal::service('entity_type.manager')->getViewBuilder('webform');
      $webform        = $view_builder->view($webform);
      return [
        '#theme'   => mycontroller_page',
        '#content' => [
          'title'     => t('I am a page from your controller'),
          'form'      => $webform,
        ],
      ];
  }
}

mycontroller-page.html.twig

{{ content.title }}

    {{ content.form }}

Any idea about this behaviors?
Thanks


texts: Is there any way to capture only the updates from "drush cex"?

texts:
I did a cex to "reset" my config being exported. I then made a bunch of changes to a bundle. Now when I do a new cex I see only the yml files containing my most recent changes. Is there any way to capture JUST these files (into a new folder)?
If I specify a --destination; it dumps my entire config there. Not what I want.


texts:
I use the latest version of Drupal 7 and when I try changing some permissions and click to save, I get the following error:

  Notice : Undefined index: administer partner 6 dans user_role_grant_permissions() (ligne 3111 dans /home/name/www/modules/user/user.module).

  PDOException : SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'module' cannot be null: UPDATE {role_permission} SET module=:db_update_placeholder_0 WHERE ( (rid = :db_condition_placeholder_0) AND (permission = :db_condition_placeholder_1) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => 17 [:db_condition_placeholder_1] => administer partner 6 ) dans user_role_grant_permissions() (ligne 3113 dans /home/name/www/modules/user/user.module).

Administer partner x is a special role I programmatically create when I add a new partner, using the following code.

$partner = entity_create('entity_partner',array(
    'type' => 'entity_partner',
    'id' => '',
    'title' => $partner_submission['title'],
    'admin' => system_name($partner_submission['admin']),
    'category' => $partner_submission['category'],
    'description' => $partner_submission['description'],
    'site' => $partner_submission['site'],
    'facebook' => $partner_submission['facebook'],
    'phone' => $partner_submission['phone'],
    'adresse' => $partner_submission['adresse'],
    'latitude' => $partner_submission['latitude'],
    'longitude' => $partner_submission['longitude'],
    'video' => $partner_submission['video'],
    'horaire' => $partner_submission['horaire'],
    'extradata01' => $partner_submission['extradata01']//machine name
));
field_attach_submit('entity_partner', $partner, $form, $form_state);
entity_save('entity_partner', $partner);

//create role
$new_role = 'admin_' . system_name($partner_submission['title']);
$roles = user_roles();
if (!in_array($new_role, $roles)) {
  $addRole = new stdClass();
  $addRole->name = $new_role;
  user_role_save($addRole);
 $new_user_role = user_role_load_by_name($new_role);

// Add permission to this role.
$rid = intval($new_user_role->rid);
user_role_grant_permissions($rid, array('administer partner '.$partner->id, 'administer one partner'));

// Create partner administrator.
$user = array (
  'name' => system_name($partner_submission['admin']),
  'pass' => system_name($partner_submission['admin_pass']),
  'mail' => system_name($partner_submission['admin_mail']),
  'created' =>time(),
  'login' =>0,
  'access' =>0,
  'status' => 1,
  'language' => 'fr',
  'init' => system_name($partner_submission['admin']),
  'roles' => array (
     $rid => true,
  ),
  'field_partner_destinataire' => array(
    'und' => array(
      0 => array(
        'value' => $partner->id)))
  );
  $account = user_save('', $user);

  // Add uid_admin.
  $partner->uid_admin = $account->uid;
  entity_save('entity_partner', $partner);
}

In my hook permission, I create all of them and it seems to work fine too.

$entities = entity_load('entity_partner');
//one secific perm per partner
foreach($entities as $entity){
    $items['administer partner '.$entity->id] = array(
        'title' => t('Administrer '.$entity->title),
        'restrict access' => TRUE,
    );
}

The code seems to work very fine, as roles are added to the user account and access work properly; the bug occur only when I try to change something on permissions with the admin panel.

I found some similar issues, but they are always old issues already fixed in core.

A workaround could be to manually edit the database, but I really want to avoid this.

This patch fix my problem, for the moment

https://www.drupal.org/node/737816#comment-6978566

But I don't know to make a patch persistent to an update


texts: Enabling AJAX in Views breaks Form API AJAX button (Drupal 8)

texts:
On a product node there is form with a button "add to cart" that is implemented with form API (ajax):

$form['add_to_cart'] = array(
  '#type' => 'button',
  '#value' => $this->t('Add to cart'),
  '#ajax' => array(
    'callback' => 'Drupal\custom_cart\Form\AddToCartForm::addProductToCart',
    'event' => 'click',
    'effect' => 'fade',
    'wrapper' => '#custom-cart',
    'progress' => array(
      'type' => 'throbber',
    ),
  )
);

...

public function addProductToCart(array &$form, FormStateInterface $form_state) {
if ($parent_node_id = $form_state->getStorage()['parent_node_id']) {
  if ($product_node = Node::load($parent_node_id)) {
    $pid = $product_node->get('field_product_bid')->value;
    $price = $product_node->get('field_product_price')->value;
    $renderer = \Drupal::service('renderer');
    $response = new AjaxResponse();
    Cart::addLineItem($pid, $form_state->getValue('amount'), $price);
    $cart = Cart::getThemedCart();
    $elem = ['#markup' =>  $cart];
    $response->addCommand(new ReplaceCommand('.cart-nav', $renderer->render($elem)));
    return $response;
  }
 }
}

This works as expected.

For a product overview page we render out product nodes with a view (node teasers) and the view includes some exposed filters.
If the view is ajax enabled the ajax callback from the "add to cart" button (breaks) and returns a 404 error:

Request URL:http://foobar.lo/views/ajax?_wrapper_format=drupal_ajax
Request Method:POST
Status Code:404 Not Found

Does somebody know how to fix this (core patches anywhere?) or a workaround you know?

Thanks for any advice


texts: What's needed to get Views data export working with a Block view?

texts:
I have been successfully using the Views data export module to export "Page" data to CSV.

However, when attempting to do the same thing from a "Block" view, the path (required by VDE) spec'd for the CSV results in page not found. The Block does not have a specific path associated as it is included in a content page.

Does anything special have to be done to get VDE working with a Block view?


texts: I have removed the title node module element from my listings and replaced it with a text field.  The problem is that the text field still works as a link.  How do I get rid of the link?


texts:
I'm currently working with a client and running some scripts to generate reports (orphaned pages, etc). Right now, I need a way to get all possible registered aliases for a node. Right now, I'm using

$node = node_load($nid, NULL, TRUE);
$nurl = 'node/' . $nid;
$alias = drupal_get_path_alias($nurl);

I'm realizing, though, that the client has more than several pages where multiple aliases lead to the same node. Is there a function to retrieve an array of possible aliases?

Thanks!


texts: How do I render a node queue as custom JSON?

texts:
What would be the most sensible way to render a nodequeue queue in a custom JSON format (using Drupal 6)

We have a nodequeue that is both included in the UI in various places and served in a RSS feed.

I've found that I can use drupal_json() to convert a PHP data structure to JSON so now I'm mostly after what would be the right place for this?

As a hack, I tried to use RSS feed and to have a custom template for the feed. My problem there is that a) it feels pretty hackish and b) in the "general template" available I don't have the content available.

(As background, I'm pretty new with Drupal so the answer here is probably pretty straight-forward)

Where to continue?


texts:
Possible Duplicate:
  How do I update jQuery to the latest version I can download?

In Firefox I get an unresponsive script error from Google hosted jquery but can't echo the problem on other browsers.

I just looked at the source of drupal and it's loading v1.4 of jquery automatically. I applied my own Google Hosted link to jquery v1.8 in html.tpl.php so in  the page is loading 2 versions of jQuery.

I think this could be the reason for the crash. In any case, I still want to remove the redundant script.

How would I go about removing the the automatically added jquery script? I want to print $scripts as some modules have dependents there.


texts:
I have a custom checkout page. I have already included the Swedish taxes of different amounts in my product price. Now the customer wants me to remove the taxes if the buyer is outside the EU. I tried commerce tax remove but couldn't make it happen.
I was thinking if I use the base price instead of the commerce_order_total['und'][0]['amount'] for order order total and to use base price for products on line items?

Will this be correct?

Thank you.


texts: Contextual filter based on base level of taxonomy

texts:
I've been trying to get the following working for a couple of hours:
I have a views block, it displays a single content type.
The content type has a taxonomy field.
The taxonomy items are structured as this:
- option A
- option B
- option C
- - option C1
- - option C2
- - option C3
- option D

I use the values to categorize the content of the nodes. Each node has a single taxonomy value and displays the view block itself.
I want the view to display all nodes of the same taxonomy (this is no problem for A, B and D). But for content tagged as C1, C2 and C3 I want to show all content within the parent taxonomy, "option c".
I have tinkered with depth and parent fields for relations/contextual filters without success... don't really know what to try next and I can't find and decent resources with similar examples that solves my problem. I would prefer to solve it within the views UI if possible.


texts:
We are using the file upload field in a custom drupal form, it was working for one (1) year but now it's not. It is working for administrators but not for anonymous users.

I am using the following code.

$allowed_exts = array('jpg jpeg gif png txt doc xls xlsx pdf ppt pptx pps odt ods odp docx zip rar');

      $form['file1'] = array(
        '#title' => 'Attachments',
        '#description' => t('Allowed Files - jpg jpeg gif png txt doc xls xlsx pdf ppt pptx pps odt ods odp docx zip rar'),
        '#attributes' => array('id' =>'file_attachment'),
        '#type' => 'managed_file',
        '#upload_validators' => array('file_validate_extensions' => $allowed_exts,)
      );


texts: Can't pass php variable to javascript in Drupal 7

texts:
Can somebody help me with this problem.
In the body of a Basic page:

drupal_add_js(array('my_var' => array('orderid' => '123')), 'setting');
drupal_add_js('sites/all/scripts/printout.js');

In printout.js:

alert("Before");
alert(Drupal.settings.my_var.orderid);

Result:
"Before" was alerted then returned to Basic page, no orderid.
What have I done wrong?


texts: How do I send notifications for followers of a group when group content is updated?

texts:
I want to build such functionality that allow the user to follow the other users, and when the followed person is updating the information, the follower can get notified for what they are doing.

I think to build the specified functionality, I can use the Flag module, but for the notification, what kind of modules are good to work with?
I am confused. There are too many modules like notification, or messaging; even the NodeJs module can notify.


texts: What are the ways to allow comments on user profile pages in Drupal 7? There is a profile content module, which unfortunately is not available for Drupal 7.


texts: Set boolean (single on/off checkbox) value while creating a user

texts:
I am creating a user programmatically and there is a boolean field (single on/off checkbox) being used as a terms of use inside the users profile.

How do I set the value of it when creating a user object? I need it to be checked or 1.

$new_user = array(
                'name' => $username,
                'mail' => $email,
                //'pass' => $pass,
                'signature_format' => 'full_html',
                'status' => 1,
                'access' => 0,
                'timezone' => 'America/New_York',
                'init' => $email,
                'field_user_account_terms' => array(
                    'attributes' => array(
                        'checked' => 'checked',
                    ),
                ),
              );

$account = user_save(NULL, $new_user);

i've also tried

                    'field_user_account_terms' => array(
                    'und' => array(
                        0 => array(
                            'value' =>  1,
                        ),
                    ),
                ),

I've also tried setting the default value and a bunch of other syntax. Nothing seems to be working for me.

is this even possible? What is the correct syntax for setting the value of a checkbox, to be saved in a users profile?


texts: Error sending Drush commands to remote host

texts:
I have Drush 5.2 installed on my local dev system and my remote host, which has staging and production sites. I have aliases for all three sites, and am able to use rsync and sql-sync on both systems with no problems.

From what I understand, I'm should also be able to issue commands to the remote system such as

drush @stage vset preprocess_css 0

Whenever I try to do something like this, it fails. For instance, if I run drush -d @stage status, I get:

Bootstrap to phase 0. [0 sec, 3.7 MB]                                [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.93 MB] [bootstrap]
Loaded alias @stage from file /path/to/local/drupal/sites/all/drush/aliases.drushrc.php [0.01 sec, 3.94 MB]                          [notice]
Cache HIT cid: 5.2-commandfiles-0-c87dbef8e3e302e07ccdc024aee7fbbd [0.16 sec, 3.95 MB]                                                                      [debug]
Begin redispatch via invoke process [0.19 sec, 8.77 MB]                                                                                [notice]
Backend invoke: ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug                                                 [command]
--root=/path/to/remote/drupal/ --uri=http://stage.mysite.com --verbose status 2>&1' 2>&1 [0.23 sec, 8.8 MB]
executing ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug --root=/path/to/remote/drupal/      [notice]
--uri=http://stage.mysite.com --verbose status 2>&1' 2>&1 [0.23 sec, 8.8 MB]
Calling proc_open(ssh -o PasswordAuthentication=no user@my.host.com 'drush  --invoke --debug --root=/path/to/remote/drupal/ --uri=http://stage.mysite.com --verbose status 2>&1' 2>&1);
bash: drush: command not found
Invoke process is complete [1.34 sec, 8.79 MB]


texts: Problem translation of terms menu - Drupal 8.5.1 - Distribution VarBase

texts:
how are they?
I have a problem with the menu item translation. when i make click in button translate i have a issue i attach image.

I am using Drupal 8.5.1 and the distribution VarBase 8.x-4.16.

Error: After the click, we see the following error.

El sitio web encontró un error inesperado. Vuelva a intentarlo más tarde.InvalidArgumentException: Field content_translation_source is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of core/lib/Drupal/Core/Entity/ContentEntityBase.php). Drupal\Core\Entity\ContentEntityBase->get('content_translation_source') (Line: 44)
Drupal\content_translation\ContentTranslationMetadataWrapper->getSource() (Line: 120)
Drupal\content_translation\Controller\ContentTranslationController->Drupal\content_translation\Controller{closure}('es')
array_filter(Array, Object) (Line: 122)
Drupal\content_translation\Controller\ContentTranslationController->overview(Object, 'menu_link_content')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I hope favorable answers!!
As always thank you very much


texts:
I am trying to write custom migrations to migrate my Drupal 7 website to Drupal 8. I am currently using Drupal 8.6.7 and Drupal 7.61 for a copy of the production website.

So far I have set up the D8 website with composer (docroot is path/to/web) (https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies )

I have always used Drush for maintenance actions on the D7 site
and I am using Drush 9 for most of the actions including the migrations on the D8 site.

I have installed the most relevant modules in the D8 site so that I can start the migration,
most notably all the D8 equivalents of the modules I used in the text formats/filters as well as migrate_plus, migrate_tools and migrate_upgrade.

The migration files are generated with the Drush command:

drush @dev migrate-upgrade "$LEGACYDB" "$LEGACYURL" --configure-only --migration-prefix=osn_custom_

So far I have successfully migrated the users and their roles so I have some knowledge on how migrations work.

The problem I am currently working on is the migration of a custom content type called 'classified'. This type has a default Drupal 7 body field and a field 'field_image'. So quite ordinary.

When I use the default generated migration file, it looks like everything is migrated, but the text is not visible. After research I found this is caused by the fact that the input format is set to the D7 code (in my case 2 aka 'full html') while there is no filter code in D8 that is called '2'.
(src: https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#d7_to_d8 ).

I decided that I might as well convert 2 to 'basic html' and use the D8 configuration and not migrate the D7 text filters at all.

I created a migration lookup plugin with a static map that converts all D7 codes to the preferred D8 code.
It might work well, but I am running into the problem that I can't get the migration plugin to work with the migration of the 'classified' migration configuration. So I decided to simplify it and set the format to a default value 'basic_html'.

Here is what I tried in the migrate_plus.migration.osn_custom_d7_node_classified.yml
The code snippets below only show the body configuration, because the other field configurations are generated with the drush command and not altered.

body: body

the default. Content is migrated, input format is set to '2'.

According to this: https://www.drupal.org/docs/8/api/migrate-api/migrate-process-plugins/migrate-process-overview#nested

and this: https://medium.com/drupal-stories-an-insiders-view/migrate-api-custom-drupal-to-drupal-migration-3bab05da4686

and this: https://www.phase2technology.com/blog/drupal-8-migrations

it should be done like this:

  'body/format':
    plugin: default_value
    default_value: basic_html

  'body/value': body

However, this results in the following error:

  [error]  InvalidArgumentException: Placeholders must have a trailing
  [] if they are to be expanded with an array of values. in
  /path/to/dev/web/core/lib/Drupal/Core/Database/Connection.php).

  [error]  Placeholders must have a trailing [] if they are to be
  expanded with an array of values.
  (/path/to/dev/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:783)

I have no clue what is wrong and what I should do instead. I also don't know how to debug this to find out what it's expecting.

Can someone please give me some pointers?


texts: Backup and Migrate module - no option to back up files?

texts:
In Drupal's Backup and Migrate module (/admin/config/system/backup_migrate), the only option for "Backup from" is "Default Database". In tutorials, that drop-down seemingly should also have "Public Files Directory".

I'm a new Drupal user - is there something simple I'm missing here?


texts: drupal 7 get title token without anchor tag

texts:
I am using a view with a "content:link" field to display a custom link for each content in my block.

I have job listing in block and want to add a link for each job "Apply". When users click on "Apply" it will redirect to a webform with title of the respective job.

So in my View under the REWRITE RESULTS setting I have selected Rewrite the output of this field and added my custom anchor tag like below:

 Apply Now

It works but it's putting title with anchor tag. So the output URL becomes

 <a href='20?id=Team leader'>Apply Now

Here I want the value of title token, without an anchor tag. Is it possible? Or any other way to do this job?


texts: {{ front_page }} doesn't work in partial

texts:
I have a partial, partials/header.html.twig, I am calling on one of my sub pages with this code.
{% include directory ~ '/partials/header.html.twig' %}

Whenever I use {{ front_page }} inside the partial to link back to the front page, it doesn't work, but it works on everything else. I have been searching for an answer all morning but can't seem to find anything.


texts: Applying a condition/reaction context to all themes

texts:
I use Drupal 7.43 with Context to hide the sidebar regions in certain content-types so that their nodes will have full-width (at least in desktop mode).

This is a good way to hide sidebars programmaitcaly, and not by CSS (which may cause clashes with other CSS rules and maybe also JavaScript).

My problem:

If I change my theme, I need to reapply each condition-reaction I've created to regions in the new theme. For example, I need to pick the existing name of my sidebar region each time anew.

Do you think there's a better approach to auto-hide ANY sidebar region on certain Pages or Nodes?


texts: Set display options for a json string in drupal 8 BaseFieldDefinition:

texts:
I have a field that stores a json string with keys and values in the database. I wish to format this output from my field definition display option to output the json string as a list. Is it possible to achieve this via such an approach?

    $fields['charges'] = BaseFieldDefinition::create('string')
  ->setLabel(t('Charges'))
  ->setDescription(t('The events charges in Ksh.'))
  ->setRevisionable(TRUE)
  ->setSettings([
    'max_length' => 750,
    'text_processing' => 0,
  ])
  ->setDefaultValue('')
  ->setDisplayOptions('view', [
    'label' => 'above',
    'type' => 'string',
    'weight' => -4,
  ])
  ->setDisplayOptions('form', [
    'type' => 'string_textfield',
    'weight' => -4,
  ])
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);


texts:
Our site exists in several languages. I have installed xmlsitemap module and default link looks like sitename/en/sitemap.xml

I need to remove language prefix just for this link. It seems like there's no settings to disable translation for any specific custom link.

May be I can do it programmatically?


texts: How to fix field collection ajax #edit-submit clash with node #edit-submit?

texts:
I have Drupal 7.41, field_collection 7.x-1.0-beta10+1-dev, and field_collection_ajax 7.x-1.x-dev

I am the admin of a site where we have a disease content type, and a part of each disease node is its lab tests. (Some diseases have upwards of 400+ lab tests) I use Field Collection to format the lab tests, and I use Field Collection Ajax to display them in an way that makes them easier to work with when there are many lab tests.

Field Collection Ajax uses ajax to display, edit, and save the individual field collection items. The "Save Item to List" button for Field Collection Ajax appears to be getting mixed up with the node save button. They both have the same id #edit-submit. I don't know for certain, but it appears that on the disease nodes that have 400+ lab tests after you edit a lab test, the next time you try to save another field collection item to the list it acts like you are trying to save the node, and the next time you try to save the node it acts like you are trying to save a field collection item.

Does anyone have any experience with this happening with field_collection_ajax and know how to solve it?


texts:
I have a very small experience with Drupal but I have to add a little form in a block (for a newsletter) in a custom module.

I write this code for the moment :

function block_contact_default() {
  $content = array();
  $content[] = '
My.Site
';
  $items[] = array('class' => 'mail', 'data' => l(t("By mail"), 'node/'.variable_get('webform_contact_default_nid', FALSE)));
  $chat = variable_get('default_chat', "");
  if(!empty($chat)){
    $items[] = array('class' => 'chat', 'data' => l(t("By chat"), variable_get('ot_default_chat', "")));
  }
  $facebook = variable_get('default_facebook', "");
  if(!empty($facebook)) {
      $items[] = array('class' => 'facebook', 'data' => l("Facebook", $facebook));
    }
    $twitter = variable_get('default_twitter', "");
  if(!empty($twitter)) {
    $items[] = array('class' => 'twitter', 'data' => l("Twitter", 'http://twitter.com/'. $twitter));
  }

    $link_newsletter = drupal_get_path_alias('node/'.variable_get('webform_newsletter_default_nid', ''), $language->language);
    if(strstr($path_newsletter, 'node/') !== FALSE){
        $link_newsletter = drupal_get_path_alias('node/'.variable_get('webform_newsletter_default_nid', ''), 'fr');
    }

    $form['#method'] = 'post';
    $form['newsletter_form'] = array(
      '#type' => 'fieldset',
      '#title' => t('Suscribe to Newsletter !'),
      '#tree' => TRUE
    );
    $form['newsletter_form']['newsletter_mail'] = array(
      '#type' => 'textfield',
      '#title' => t('E-mail'),
      '#default_value' => t('E-mail')
    );
    $form['submit'] = array('#type' => 'submit', '#value' => t('OK'));
    $items[] = array('class' => 'newsletter_form', 'data' => $form);

    $content[] = theme('item_list', $items);
    $content[] = $form;

    return array(
      'subject' => t("Contacts"),
      'content' => implode('', $content),
      'classes' => array('block-contact')
    );
}

I'm using Drupal 6.25
But when I go on my page I get only a string "Array", not really what I wanted... I'm sure I don't do this properly. Could you help me ? Thank you with advance.


texts: correct syntax for feeding lat/long to geofield_latlon in migration

texts:
I have a drupal 6 site I wish to migrate to drupal 8.
My configuration includes:
migrate_plus.migration.upgrade_d6_node_complete_club.yml
# ...
class: Drupal\node\Plugin\migrate\D6NodeTranslation
field_plugin_method: null
cck_plugin_method: null
# ...
source:
  plugin: d6_node_complete
  node_type: club
# ...
process:
  # ...
  field_latitude:
    -
      plugin: get
      source: field_latitude
  field_longitude:
    -
      plugin: get
      source: field_longitude
# ...

When I run drush migrate:import, the club content is correctly migrated.
I wish the drupal 8 club content to include a geofield.
Following https://www.drupal.org/node/2866147, I modified the configuration to be:
# ...
process:
  # ...
  field_latitude:
    -
      plugin: get
      source: field_latitude
  field_longitude:
    -
      plugin: get
      source: field_longitude
  field_geofield:
      plugin: geofield_latlon
      source:
        - field_latitude
        - field_longitude
# ...

I manually added (using the web ui) a new field_geofield to the drupal 8 club content-type.
Then I did drush migrate:rollback upgrade_d6_node_complete_club
and drush migrate:import upgrade_d6_node_complete_club.
However, the drupal 8 club new geofield always just has latitude:longitude coordinates of 1:1.

I looked at web/modules/contrib/geofield/src/Plugin/migrate/process/GeofieldLatLon.php and saw:
  public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $value = array_map('floatval', $value);
    list($lat, $lon) = $value;

I added a var_dump($value) at the top. It shows that with the process YAML as above, transform() receives $value like:
array(2) {
  [0]=>
  array(1) {
    [0]=>
    array(2) {
      ["value"]=>
      string(9) "50.854334"
      ["delta"]=>
      string(1) "0"
    }
  }
  [1]=>
  array(1) {
    [0]=>
    array(2) {
      ["value"]=>
      string(9) "-0.553837"
      ["delta"]=>
      string(1) "0"
    }
  }
}

I don't need the geofield_latlon plugin anywhere else for the migration, so I could just prefix transform() with:
$value = array_map(function($k){return $k[0]['value'];}, $value);

Is there a way to adjust just the YAML, without having to write any code, so that geofield_latlon receives its data in the correct format?
I feel that using something like the extract plugin ought to be possible but am having difficulty finding any good description of the semantics of migrate YML config files.


texts: What is the name of the table where view modes are stored?

texts:
We have 10 view modes that we created. When we run drush @env cex sync in our local we are able to export the config files related to these view modes such as core.entity_view_mode.node.related.yml (where related is the view mode).

Is there a database table where these View modes are stored? If so, what is the name of it?

We are not using Display Suite or Panels, just the out of the box View Modes from Core. We do not plan to add those modules.

Goal:

Find out what view modes are being used programmatically.
Delete all view modes that are not being used.

Definition of not being used:

Article content type has 3 custom view modes: listing, minimum, related
Basic Page content type has an Entity reference to Article pages where the Article view mode = listing under Basic Page Default View Mode.
Custom view modes listing and minimum are not being used. However, if we consider all content types (e.g. 10 more content types) then it will be a pain to have to go through one by one.


texts:
I want to replicate the Drupal "Create Poll,Event" links etc of the Drupal groups.
How can I accomplish that with Organic groups?
Thanks


texts: Is it possible to retrieve partial forms?

texts:
Is it possible to retrieve only parts of a form for display, that is, only certain form elements?

I am looking at the stack for building the node form, and so far the functions I've seen work with wholesale forms, in this case the node_form.

  drupal_retrieve_form(): /.../http/includes/form.inc at line 752
  drupal_build_form(): /.../http/includes/form.inc at line 331
  drupal_get_form(): /.../http/includes/form.inc at line 123

I am interested in only retrieving (rendering) the default body field via AJAX only for a preview type of display. So far I've been successfully build and render the whole node form just using the #AJAX FAPI property and other Drupal hooks - but I was wondering if something similar was possible for just one field. Answers that point to Drupal core APIs instead of contrib modules (who may be using their own jQuery magic) are a plus.

I'm just gathering thoughts to see how I write a D7 module for this question.


texts: Secondary submit function for form input button

texts:
I want to have buttons for remove selected field from form.

    $form['questions']['buttons'][$counter] = array(
        '#type' => 'button',
        '#name' =>'button_'.$counter,
        '#value' => t('Remove'),
        '#submit' => array('my_mod_remove_submit'),
    );

Submit function:

function my_mod_remove_submit($form, &$form_state) {
    drupal_set_message('<pre>'.print_r($form_state, 1).'</pre>');
}

But it seems that this function is never invoke.


texts: Does aggregating JS/CSS interfere with my drupal_add_js()?

texts:
I want to use drupal_add_js and drupal_add_css on a per-page basis so I have added a 'scripts' text field to my basic content type and have set the Format Type to PHP.

It works beautifully until I turn js/css aggregation back on; then, none of the files I specified are loaded.  Why?

Because Drupal is still using the previously aggregated files (despite me flushing the cache many times).
Because of some more sinister issue that will prevent me from adding my CSS/JavaScript in this manner.

I see other people doing the same thing here: https://drupal.org/node/290982.


texts: Send email to specific user by using webform

texts:
Send email to specific user :

For this i have added a webform contact to this person using webform.

after filling the information in webform by anonymous user , a mail should be sent to that user whose profile is  he/she seeing.

Note: this functionality should only work for anonymous user and by using webform.

How to achieve this?


texts: Should I create a new Form or use form alter?

texts:
I'm very new to Drupal. I've been handed over a Drupal 7 project. In the project, there's a form to create a new record into database. However it's using hook_form_alter instead of creating from scratch. The form is called as node/add/<something> as a page. Similar to first few steps of this tutorial.

I'm not sure however if this is the correct Drupal way, or should I just rewrite it into a block, as I want to have it shown on .... at least two pages?

Any suggestions?


texts: Contextual links for programmatically embedded views

texts: When embedding a View programmatically, using views_embed_view, what can I do to have the contextual menu (gear icon) appear over its area?


texts:
So i have install views_slideshow_cycle module, and it always shows "cycle" is not a function. after some googling, I found out I have to install jquery_cycle.

In views_slideshow_cycle.libraries.yml file, I found this section:

jquery_cycle:
  remote: http://malsup.github.io/jquery.cycle.all.js
  version: 3.0.3
  license:
    name: MIT
    url: http://jquery.malsup.com/license.html
    gpl-compatible: true
  js:
    /libraries/jquery.cycle/jquery.cycle.all.js: {}
  dependencies:
    - core/jquery

Where is that libraries directory?


texts:
I have a view with 2 fields - one is another view, one is a node field. I do not want to display the parent view header when the inner view result set is empty and the node field does not have a value. "Display even if view has no result" is unchecked on the header settings but does not work because the parent view always has a result regardless of the presence of a value.

I am trying to add a PHP filter that checks for both criteria. I am running into the old issue that the $row object only contains node ids, but the $data object does not seem to work here, either. It only contains two properties, the view and the entity type of the attribute (called field_data_field_electronics_description_node_entity_type in this case).

So, this does not work for my filter code because the entity type is always set, even when the value is empty:

if ($row->view != NULL ||
   $data->field_data_field_electronics_description_node_entity_type != "" )
{
   return FALSE;
}
else return TRUE;

This does not work because field_electronics_description always contains the node id, regardless of the presence of a value:

if ($row->view != NULL || $row->field_electronics_description != "" ) {

I don't see anything else in the $data object in devel that I could use. How can I suppress the parent view display?


texts: How to redirect node on paypal for payment before save in drupal 7?

texts: I need to add payment functionality on specific node type. After registration user can create a node. But node will be shown when user will pay. And after first time payment user got a role .. Means next time he will create node without payment.


texts: How to dynamically consume external RSS feed and display content Drupal 7 with feeds module?

texts: Is it possible to consume an external RSS feed with the feeds module - without turning the content into nodes - and display it in a view? I attempted to do this using the aggregator module as described here: External RSS Feed in View and it looked great at first, but then I discovered this bug where the aggregator does not update. https://www.drupal.org/node/2344795. I am now trying to do the same thing with the feeds module, but I don't see a way to have it not create nodes out of the data. I just want it to be dynamic and not create content nodes on my site. Thanks for the help.


texts: Field API, Field Attach API, Field Instance API, Field CRUD API OR Schema API?

texts:
I'm in my final semester for my degree in Computer Science, and we've been tasked with creating a project management system using Drupal. I thought this was great at first, we easily created a proof of concept using already built modules. And then I attempted to code.

Basic Idea:
We thought about defining our own schema for entities, but the company needs a dynamic way of defining and sharing fields (like the entity / field API already does), so we decided to stick with the built in Entity / Field API.

Entity types would be things like request, project, task, etc...

Fields would be things like select lists, questions for the request form (that could be transferred over to a project once the request was approved), and other text fields needed for the project.

I was thinking that using the field API to start with some of the needed select lists (that the admin can add/update/delete default values to) would work fine - because I defined these with the UI thinking man this is easy. Select lists such as legacy company, products, and other short lists related to telecom. But I cannot programmatically define a select list field with predefined values. How can I do this? I've googled, and searched, and followed this great article, but it does not delve much into select lists, and how to define default values, or any of the $options available for a select list [and neither do the API docs, they do not tell what values should be used, or even the default widget types].

Am I going about this all wrong? Maybe I should just create some good old crud classes and be done with it. The only problem with this is that it would be extremely difficult to make the system as dynamic as they want, or would it?


texts: Should I create fielded content types (with 1000+ tables) OR create custom entities with properties instead of fields (way less tables)?

texts:
I have a case where I have a lot of entities that can be stored with Drupal as node (content types) and fields. I had to end up creating 105 content types, 20 taxonomies and in-numerous fields. And the result is that I have right now 1600+ tables in my database. I'm assuming that is not healthy. Please advise.

The other option that I have now is to create entities. I can use entity api module to create a lot of the above content types as separate entities with all  properties which would mean that one entity information is stored in one table as opposed to 2 fields for each field (i.e. data and revision). The data in these content types need to be imported but I do not need any CRUD interface for them. Will my database calls be better in terms of performance if I make separate entities instead of content types?

My main objective is to be able to present all the information through views. And I believe that if I have entities, I should be able to display the properties through views. Is that true? I have not tried ECK yet, so I am not sure if creating Entities through interface works clean, so some help in that regard will be very much appreciated.


texts:
I want to make a few changes in the HTML output by the guestbook module.  For example, I want to enclose the submitters name in a <div> or a <span> (so I can style it better).

What's the best way to do this?  The only option I can think of is to modify the guestbook.module, but that could cause issues down the track.


texts: How to set the facet block title to the currently applied filter?

texts:
I have a faceted block for the taxonomy reference field.

The faceted block displays the parent terms. When I click on a term in the faceted block then its childs displays in the faceted block. It is fine but the facet block title should be changed to its parent term name.

How will I do this?


texts: Views Slideshow Stops Working Alongside Other Slideshows

texts:
I've made several thumbnail-sized cycle slideshows as block views, which display fields from nodes created via an HTML feed. Each slideshow is basically the same, but they all use a different taxonomy term as a filter on a single content type, and have a different XPath parsing structure.

The slideshows work perfectly on each view's preview page. Each also works separately when its block is displayed on the main page. I've managed to get 6 slideshows at once scrolling normally as blocks on the main page.

However, when I display a 7th slideshow in a block on the main page, only two slideshows work properly, with the rest not progressing via time or clicking on the controls. If I add an 8th slideshow block, 3 of them work, and the other 5 do not.

The 7th and 8th slideshows have slightly different field output, as the feed source is configured differently, but I don't think this is relevant, as the view-generated HTML looks the same.

I can get sporadic results by re-arranging the blocks in the block list, and by displaying them in different block areas. Some permutations allow all the slideshows to function, some only allow a few.

Is there a limit to the number of JQuery slideshows that can be running at once? Or, is there maybe some kind of naming convention that's causing these mixed results with different ordering?

Totally confused, and disappointed. :(


texts: Where do AccessResults for block access get cached?

texts:
AccessResult returned from BlockBase::blockAccess() can have cacheability data added to them.
Where does that end up in the database cache tables?


texts:
I have imported about 2 thousand nodes that include start time.

I have imported and the formating and time looks the way it should.

Now if i try to publish the nodes i get following error -

  Notice: Undefined index: hour in cck_time_field_presave() (line 97 of
  public_html/sites/all/modules/cck_time/cck_time.module).

The time fields gets changed to null time.

But if I open the node and save it - the node is saved with the correct time as it was before.

Im at a loss.

And hoping for some guidance.


texts: Add user points to author for every up vote received to content using Rate module

texts: I saw the post Add user points for every upvote But that was for rewarding the voter, I want to reward the author like Reddit karma. Does anyone know how to do this with Rules? Vote integration for rules is installed of course


texts: Remove Side Menus on certain pages in Drupal 7

texts:
I realize that this question might be the result of a fundamental misunderstanding of how things work.  So I apologize in advance if this is just me being a dope.

I am creating a webpage for a festival.  On each page there is a left side menu bar with about 6 menus in it.  I want that there most of the time, so that is good.

I've now created the ability for users to add events to the festival so others can see what's going on.  I've created a content type called Event, added the fields I want to it and exposed it to registered users.  I then create a table view and calendar view with all the events broken down by date/time with a few filters.

All that is working fine.  The part I'm now struggling with is, I want all the menus on the left to go away, any time I am working with the events. Which means when I'm adding, editing, viewing the content, and when I'm viewing the Event views I want access to the entire width of the site, except for a small menu on the right with Add Event, View Events, View Calendar.

I thought a sub-theme would get me what I want, so I created a subtheme with the menus the way I want it and the page the way I want it.  But I can't for the life of me figure out how to get the content to show in the sub-theme.

Any help would be appreciated.  Please keep in mind I am very new to drupal so as much detail as you can go into would be appreciated.

Thanks,

PJ


texts: How to override configuration from a file?

texts:
I have been playing a lot lately with an import configuration to Drupal 8. And I notice that all documentation show you how to edit value per value instead of overriding the entire config file. You can find more information about this at Configuration override system page.

I notice that DrupalConsole and Drush have the ability of overriding configuration by file.

Using Drush, you can run drush config-import
Using DrupalConsole, you can run drupal config-import

This will override the entire configuration base on the configuration file. How can I achieve this on the code? Hopefully, I will like to edit my configuration when I'm installation my module on hook_install.


texts: Is there any way to make a menu link *not* a link?

texts:
I have a hierarchy of links in my menu, but one of the higher level entries needs to simply be a category, and not link to anything.  It is "Related Sites" and has a bunch of related links under it, but should not itself link to anything.

Drupal doesn't let me save it without a URL, and vomits a bunch of errors if I try using '#'.

How can I achieve this with a minimum of hassle?


texts:
I am using facet search on my site. The search paths for taxonomy term facets are of the pattern "search/term-name", but I would like them to be of the pattern "search/term-tid".

Is this possible? How can I change this?


texts:
I was implemented "simplenews_register" module in my drupal project. so, Whenever user want to register in this site He has to enter his user name,email address,password and at the same time he want to subscribe any existing newsletter  then he check the related newsletter  check box. Then, automatically user will receive one mail regarding to subscribe link . So, he want to subscribe then he will click that link .

Here my requirement is if user has been subscribed any newsletter then automatically he has to receive "Unsubscribe" link . So, for this requirement what I have to do please guide me.


texts:
I want users of a particular role to pay for featured nodes. On my site, the user role "premium member" is able to create nodes of type "products," but they have to pay to make their node (product) featured--for this I have a CCK checkbox field which will be checked on payment.

I am using moneyscript module for subscriptions, but I do not understand how to use it for my requirements.

I am thinking about using a custom module, but I'm also not understanding where to start and what should be the approach.


texts: Breadcrumb per content type per role, bootstrap theme

texts:
I need to display a breadcrumb per content type and per role. What the best way  to do it. I've tried a lot of module and none fit my needs.

I tried overwritting breadcrumb in template.php as follow, and it's not working :

function local_breadcrumb($variables) {
  $output = '';

  global $user;
  /** Breadcrumb for hsrehab_admin **/
  if(in_array('hsrehab_admin', $user->roles)) {
   if ($vars['node']->type == 'patient_sheet') {
     // Build Breadcrumbs
     $breadcrumb = array();
     $breadcrumb[] = l('Dashboard', '');
     $breadcrumb[] = l('Manage Patients', '/admin/manage-patients');
     $breadcrumb[] = l(drupal_get_title(), base_path() . request_uri());
     }
   }

  // Determine if we are to display the breadcrumb.
  $bootstrap_breadcrumb = bootstrap_setting('breadcrumb');
  if (($bootstrap_breadcrumb == 1 || ($bootstrap_breadcrumb == 2 && arg(0) == 'admin')) && !empty($breadcrumb)) {
    $output = theme('item_list', array(
      'attributes' => array(
        'class' => array('breadcrumb container'),
      ),
      'items' => $breadcrumb,
      'type' => 'ol',
    ));
  }
  return $output;
}


texts: I posted a question here, which had one suggestion, but no answer. Does anyone have any advise on how to implement a custom hook in Drupal 8 which will allow other modules to update a table of contents which is created by a parent module? The table of contents will be an unordered list.


texts: Is it mandatory to clear cache for each and every change made?

texts:
It takes more time to clear caches and it also needs to be done more frequently for the each CSS or functionality wise changes.

Are there any alternatives available?


texts:
Ive been trying to setup a view where the distance to users is stated.

There has recently been an update of geofield however I am having trouble with calculating the distances to users (only get a zero)

I have checked whether the users have points, which they do, and tried to create a relationship to the user id without results.

I am a newbee in views so every advice would be beneficial


texts:
I have 4 filters for my nodes. These filters work with taxonomy terms.
So I have 4 taxony lists:

Type (a,b,c)
length (d,e,f,g,h,i,j)

If I select Type (a) then length should only give me the possibilities that actually are possible with the length for example f,g,h. Is this possible?


texts: Hide title in Inline Entity Form with Automatic Nodetitles module?

texts: Is there a way to suppress a node's Title and Status fields when used in the Inline Entity Form module's editing form? I keep having use cases for a very clean and slim "add one or more" subform to create lists of related entities.


texts:
When I try to uninstall the "Commerce license" module, the following error appears :

  drupal module:uninstall commerce_license

[ERROR] SQLSTATE[42S02]: Base table or view not found: 1146 Table
         'www.domaine.com.mg433jdr_commerce_license__license_role' doesn't exist: UPDATE
         {commerce_license__license_role} SET deleted=:db_update_placeholder_0
         WHERE bundle = :db_condition_placeholder_0; Array
         (
             [:db_update_placeholder_0] => 1
             [:db_condition_placeholder_0] => role
         )

I do not know what to do. How to uninstall this module ?

Thank you


texts: Upgrading Drupal 7 version from DEV to PROD

texts:
I've updated from Drupal 7.22 to 7.34 on my Development Machine along with some Module updates. Now I am going to update my Production environment.

Question: Do I have to upload the entire root directory or can I just upload the Sites folder? I'm assuming I have to upload the entire root directory as this is a Drupal 7 version core update.

P.S. Got the database update stuff covered.
P.S.S Would use Drush, but I'm just not comfortable with it yet.

Regards,

John


texts:
I have the strangest thing going on here: I just created a new content type ('jobs'), and a new job (its node ID is 1706), but for some reasons there is no node that node ID in the database; even when I search for type = jobs, I get no result.

What could be the cause why I'm getting no results?


texts:
Currently working on theming with Twig
I created a region called 'Blog Content'
I placed under it a view that i recently created Called 'Blog' with a display Block to display just the 3 last article**

for each field I specified the wrapper around it and the CSS class used by my theme and I have this output:

But i want it to be just like this:

My questions:

How to specify the tag (html) to be used to display my field with specific css class : in my case i want to display the title with
What field should i add to add the date of post


texts: Don't let users buy more than one product of the same type in commerce

texts:
how can I prevent users from buying more than one product of same product type in Drupal commerce?
I need a solution using rules module.

be careful please!!!as I need to limit users on product type (not products) my question is not duplication of any others


texts: How to filter a View by Date Range (start, end)?

texts:
In Drupal 7 with Views an Date module enabled, it was pretty easy to filter a view by Date: The UI just gave you the option to do so.

In Drupal 8, however, the date field and views are part of core, but if you choose a date range field as filter in views it does not offer you date specific options anymore, but shows you only filtering options for text fields:

The date specific options, however, are available for internal date values like ´Content: Changed´

As I would like to show only specific nodes, with a date before or after the actual date, where the date is specified by a custom date range field, this does not suit my needs.

How can I filter a view in Drupal 8 by a date field with date specific operations?


texts: How to determine if loading a form or submitting a form in hook_form_alter?

texts:
I am trying to put a simple message at the top of a node edit form when a user is creating a new node.
I added a \Drupal::messenger()->addMessage() inside a my form_alter hook but this prints when I open the edit form (good!) but also on the view of the node after the node is saved (bad!).

Looking in debugger I can see that the hook is run twice (load and submit); but I don't see any way of determining which version is being run.

The only thing apparent to me is that $form_state->requestMethod is different in both cases; but this is a protected property; so no access to it.

code shouldn't be required for this question, but:

function mymodule_form_alter(&$form, $form_state, $form_id) {
  \Drupal::messenger()->addMessage(t('some msg'), 'warning');
  return;
}


texts:
Is there a way I could display a token (for exmaple user ID) as a default field content to a content type?

Id like to display a node form to users
/node/add/content type

when a user goes to that page the field "name" automatically displays the user id.

name: [user:uid] - something like that

Is it possible, If so, how can I achieve this?

Thanks


texts: What is the correct way to translate variable_get string values entered in admin input fields?

texts:
I'm developing a simple module with and admin page, where admin can fill some textfields with custom strings that will generates a piece of html to be used later.

So for example I have fields like this in admin page:

function MYMODULE_admin_page_arguments() {
  $form = array();

  $form['MYMODULE_link'] = array(
    '#type' => 'textfield',
    '#title' => t('Conditions link path'),
    '#default_value' => variable_get('MYMODULE_link', 'conditions'),
  );
  $form['MYMODULE_link_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Conditions link text'),
    '#default_value' => variable_get('MYMODULE_link_text', 'conditions'),
  );
  $form['MYMODULE_link_target'] = array(
    '#type' => 'textfield',
    '#title' => t('Conditions link target'),
    '#default_value' => variable_get('MYMODULE_link_target', '_blank'),
  );
  $form['MYMODULE_prefix'] = array(
    '#type' => 'textfield',
    '#title' => t('Conditions link prefix text'),
    '#default_value' => variable_get('MYMODULE_prefix', 'I agree to the '),
  );
  $form['MYMODULE_suffix'] = array(
    '#type' => 'textfield',
    '#title' => t('Conditions link suffix text'),
    '#default_value' => variable_get('MYMODULE_suffix', '.'),
  );

  return system_settings_form($form);
}

Then the above values are managed after by my module to compose an output like:

// Create label
$prefix = variable_get('MYMODULE_prefix', 'I agree to the ');
$suffix = variable_get('MYMODULE_suffix', '.');
$path = variable_get('MYMODULE_link', 'conditions');
$text = variable_get('MYMODULE_link_text', 'conditions');
$target = variable_get('MYMODULE_link_target', '_blank');

$label = $prefix . l($text, $path, array('attributes' => array('target' => $target))) . $suffix;

Now I need that all these values are available for string translation, so the first think I thought was to pass all of them through t(), for example:

$label = t($prefix) . l(t($text), $path, array('attributes' => array('target' => $target))) . t($suffix);

but I read here https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/t/7 that I should never pass variables directly to t(), so for e.g t($prefix) is a bad stuff.

So, what is the correct Drupal way to accomplish this?


texts:
I am working on formbuilder for a Drupal 6 project. On of the issues I am facing is that the "markup" component does not use the wysiwyg editor properly.

I found this fix: https://drupal.org/node/1532536#comment-5938202 But apparently it is meant for Drupal 7.

How do I do drupal_add_library('system', 'drupal.textarea'); in Drupal 6?


texts: Using computed fields module to display certain fields?

texts:
I just installed the computed fields module and I'm a little lost as to how to use it. I have 2 fields in my content type: field_shortdesc and field_audio_description.

If field_shortdesc is blank I need to display field_audio_description and vice-versa.

What code do I need to place into the computed code and display code areas?


texts: Other flags are also inserting into flag_friend table

texts:
I have a user flag "shortlist". And I also installed Flag Friend module.
This module creates a default flag named as "friend".

I am creating these two flag links in "user-profile.tpl.php".`

flag_create_link('shortlist', $uid);
flag_create_link('friend', $uid);

If I am flagging shortlist tab the flag data inserting into flag_friend table. How would this happen? I need to insert flag data into the flag_friend table if the flag type is only "friend".


texts: Views Slideshow Using Absolute Path to Images

texts:
We are using views_slideshow to display a 3 image slideshow on our homepage.  The Style is Slideshow, the Row Style is set to Fields.  The Field is: Image attach: Attached images and we are filtering for a specific Node:Type.  The Node Type were filtering for has an attached image which is what the slideshow uses.

The problem we are encountering is that the <img src=""/> references to the image appear to be absolute URLs so that if you view the site over https:// in Internet Explorer, you get the message about referencing unsecure content on a secure page. (since the URL to the image looks like: http://www.foo.com/sites/dailyaccess.com/files/images/Banner1.jpg even though you are viewing the page over https://)

How can we go about correcting this to use a relative URL or display the correct secure/unsecure URL?


texts:
I have a view which lists dishes by category. Category is a tag ("main", "soup", etc). I use grouping fields, and what i wanted is to make a kind of anchor menu for this view. Is it possible to style the grouping fields?
Right now, grouping fields are in h3 headers, just before the relevant views rows.
Is it possible to rewrite them,or alter their structure?


texts: How do I change assigned redirect url to drupal root url?

texts:
Sorry I really don't know how to actually ask this.... But let me explain....
I have my drupal installed in a subdirectory (www.mydomain.com/my-drupal-install). If I type that in the browser url address bar it works fine - drupal loads and I can navigate all links within the domain and the user and admin configuration loads as well. I have set a domain name to that directory in godaddy shared hosting so if I now type (www.my-drupal-install.com) the first page loads but it will not allow me to navigate to any links not even the user or admin login links. I get a 504 error... How can I fix this?


texts: How to migrate user passwords from D6 to D7 site using salt module?

texts:
I need to migrate the user passwords from Drupal 6 site to Drupal 7 Website. I am using the migrate_d2d module for performing the migrations. But the problem I am facing is that the Drupal 6 site uses the salt module which appends an internal string to the users passwords before it is being saved to the database. So migrating the passwords as such doesn't work.

Can any one tell me if there is some way to migrate the user passwords in this case or its not possible??


texts: Editing time for pages in google analytics?

texts:
I've been asked for "development/editing" time for pages analytics to be made available.

Is this possible? If so, how?


texts: I want filter products views by user country ip. Can i use maybe rules for automatic sort, or some module? If this is not possible, as it may be possible to automatically filter on the field by the country?


texts: Editing the navigation menu template in Drupal 8

texts:
I'm getting into Drupal with version 8, and trying to wrap my head around the template system.

I've created a theme with classy as a base theme. I would like to edit the markup for the navigation menu, adding two div's before the <ul>. I've copied the menu.html.twig file over from /core/themes/classy/templates/navigation into my-theme/templates/navigation.

I've added to div's right before the ul but they don't appear on the front-end. Is perhaps my template not being loaded? Or what would be the way to do this?


texts:
I moved a ready drupal 7 site from local to our webserver. It works - but just some time - then php gives the following error:

Fatal error: Cannot redeclare class views_object in /XXX/sites/all/modules/views/includes/base.inc on line 22

OK, I see the class views_object has already been declared. I wanted to fix that by

inserting a code snippet within the error-causing base.inc like this

if(!class_exists(views_object) ) {return;} else {//CODE OF BASE.INC }

This doesn't work propperly.

Blacklisting the error-causing base.inc in the php.ini with

opcache.blacklist_filename = /sites/all/modules/views/includes/base.inc

No result.

Does anyone have an idea how to solve that?

Thank you and best regards

Chris


texts: Error while loading / saving taxonomy term on external DB

texts:
I have 2 different Drupal bootstraps with shared DB, and I'm switching from the "slave" bootstrap with db_set_active('shared') when need to work with the shared DB.

example:

function test_function(){
  db_set_active('shared');
  $term_tid = array_keys(taxonomy_get_term_by_name($term, $vocabulary = 'vocab'));
  if (!$term_tid){
   $term = new stdClass();
   $term->name = $term;
   $term->vid = 1;
   taxonomy_term_save($term);
  }
  db_set_active('default');
}

while using either one of the taxonomy functions, taxonomy_get_term_by_name or taxonomy_term_save giving me this error:

  PHP Fatal error:  Class name must be a valid object or a string in
  /home/user/www/includes/common.inc on line 7618

any help appriciated!


texts: Remove all Div wrapper from comment form

texts:
I want to strip all default Drupal form wrappers and have something like below in comment form output

                    <form>
                        <input type="text" name="name" placeholder="Your name">
                        <input type="email" name="email" placeholder="Email">
                        <input type="text" name="website" placeholder="Website">
                        <textarea name="comment_body" placeholder="Comment"></textarea>
                        <input type="submit" value="Send">
                    </form>

I try

    $form['comment_body']['#theme_wrappers'] = array();
    $form['subject']['#theme_wrappers'] = array();
    $form['author']['mail']['#theme_wrappers'] = array();
    $form['author']['name']['#theme_wrappers'] = array();

But not worked for comment_body field,
I also use Display Suit I want to know how Can implement comment form like I want without any wrapper.


texts: Errors from custom FieldItemList::getConstraints() displayed next to every single property

texts:
Summary

Errors set by constraints on custom field types appear next to every single property by default.

We can use the ::errorElement() method on the widget to place errors that come from the ::getConstraints() method of the field item.

However, errors that come from ::getConstraints() in a custom field item list will not go through ::errorElement(). How can we reasonably place them?

Details

My original problem ist very complicated. I've drastically simplified it to show only what's essential. We start with a very simple custom field type with 2 number properties.

class YearRangeType extends FieldItemBase {
  public static function propertyDefinitions($field_definition) {
    $properties['start'] = DataDefinition::create('integer');
    $properties['end'] = DataDefinition::create('integer');
    return $properties;
  }

  public static function schema($field_definition) {
    $schema = ['columns' => [
      'start' => ['type' => 'int',],
      'end' => ['type' => 'int',],
    ],];
    return $schema;
  }

  public function isEmpty() {
    $start = $this->get('start')->getValue();
    $end = $this->get('end')->getValue();
    return !($start || $end);
  }
}

We define a custom FieldItemList for it that adds a simple validation: checking if at least 2 items are present.

class YearRangeItemList extends FieldItemList {
  public function getConstraints() {
    $constraints = parent::getConstraints();
    $constraints[] = $this->getTypedDataManager()
      ->getValidationConstraintManager()
      ->create('Count', [
        'min' => 2
      ]);
    return $constraints;
  }
}

When I try to save only one item, the field will look like this:

If the errors would result from YearRangeType::getConstraints(), we could use theerrorElement()` method of the widget to place them.

However, the Drupal core class WidgetBase does deliberately not pass errors set by the item list to errorElement(), see these lines in the Drupal core code (version 8.8.1).

How else should we place them?


texts: Resume module not working in Drupal Recruiter

texts:
I'm using the Recruiter distribution of drupal.

I just configured some modules, customize themes, and modules...

After an instance its resume module will not works, it shows Access Denied when accessing the resume pages..

I re-confirm all the permissions in the portal, But there is no change on it.

In everey instance when a confirmation message is displayed on admin panel, the following message also shown:

resume has not been overridden because the menu item does not exist.

Screenshot:

Help me to solve this issue...


texts: Added field to Basic Page Content Type is not displayed in the page

texts:
This question may be a bit silly but I have been struggling with it for a long time and still no solution:

I have added the Star Rating Module to display rating stars in my pages. I have enabled the module and configured the "Basic Page" Content type to have the "rating" field. The point is that I edit a page, assign a rating properly but... when I view the generated page the starts don't show up!

I have tried adding another field, this time a text field, but it doesn't appear on the page either.

Any idea why additional fields added to "Basic Page" aren't displayed in the page?


texts:
There are a lot of ways to build similar content block according to their tags. Is there any way to build similar tags block?

I try to build similar/related tags block.

I want to look at contents and common tags they have. How many times they added to contents together. Something like this:

For example: for first column green is similar for blue. For the third column yellow and blue similar for green.


texts: How can i use main-menu items as a fields in selectbox in drupal 7

texts:
Helllo,
I have a content type called "Lookbook" in that i want to put one field like "Lookbook For" and this field content select box and main-menu items. I have main-menu list but I want only display submenu items of lookbook menu in select box.
Is it possible that menu links display as fields??
Thanxs..


texts: Receive the error PDOException: SQLSTATE[23000] when trying to update some content text

texts:
I get the following error when I try to update a static page's content as an Administrator:

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

In the logs, there is an error for type 'node' and type 'php':

  PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062
  Duplicate entry '3' for key 'PRIMARY': INSERT INTO {pinit} (nid,
  description, image, pincount) VALUES (:db_insert_placeholder_0,
  :db_insert_placeholder_1, :db_insert_placeholder_2,
  :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 3
  [:db_insert_placeholder_1] => [:db_insert_placeholder_2] =>
  /sites/default/files/Steve155.jpg [:db_insert_placeholder_3] =>
  horizontal ) in drupal_write_record() (line 7166 of
  /home/diversif/public_html/includes/common.inc).

I just updated to the latest version of Drupal, and ran the update script on the database. I also created an authenticated user, and confirmed that they are experiencing the same issue.

I'm not modifying anything in the content other than some text. Are there other logs that I can look into to find the source of the problem, or the solution.?


texts:
I have used the code like this

$ch2 = curl_init("http://openexchangerates.org/api/currencies.json");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);

$json2 = curl_exec($ch2);
curl_close($ch2);

$currency = json_decode($json2);

$opts = '';
foreach($currency as $key => $val)
{
$opts .=$key.'=>'.$val.',';
}

return array($opts);

Here I am getting the combo like this everything in a single line

AED=>United Arab Emirates Dirham,AFN=>Afghan Afghani,ALL=>Albanian Lek,...

What can I do for all the currencies listing 1 by 1 ??


texts: Delete old files from server when content is updated

texts:
When a node is updated by replacing a new file upload, old files exist on the server maintaining versions.
I want to delete old files from the server when content is updated.


texts: How to have different displays for the same node type using Display Suite?

texts:
I use display suite module to manage the display of node types. So far so good.

I know that there is a way to have different display for the same node type. Let's say I have 2 nodes of the basic page node type. Then I'd like to set 2 column stacked for the first one and single column for the second node.

But I don't know hot to do it.


texts: Views node count Taxonomy term as a field

texts:
There are a few other posts about this in general but none of them explain how to make this a field so i can keep my other fields such as Title and Image.

I am making a video site, and the taxonomy 'category' has an image attached to each term. Therefore i want the number of nodes tagged with a specific category to show but also have all the other fields i use.

I tried solutions found here: Views and node count for taxonomy terms

The above suggestions seem to ignore my image and title fields i currently have styled

hope this makes sense


texts: How to separate UI language from node's language?

texts:
I have a site that uses 3 languages, namely English, Polish and Russian. And we have content editors with 3 native languages. Now, most of the times Russian guy will want Russian UI and will be editing Russian nodes. But sometimes he will need to correct nodes written in Polish. He will not want his UI to turn to Polish when doing that, of course.

Is there a way to allow users to select their default admin language? Desired effect for nodes is:

http://example.com/node/435 displayed in layout based on node's language (let's say, Polish)
http://example.com/en/node/435 redirected to proper language (here http://example.com/pl/node/435) - that's pretty much easy and was answered in many places.
http://example.com/node/435/edit should be opened in UI based on user's preference set in a profile field, for example, or redirected to proper language edit path like http://example.com/pl/node/435/edit
http://example.com/en/node/435/edit should be redirected to http://example.com/node/435/edit or http://example.com/pl/node/435/edit (consistent with previous point).

If possible, I want this globally, for all admin pages, not only node edits, but of course node edits will be most common = most important to me.


texts: Commerce create order when registering a new account

texts:
I would like to create an order  automatically when a request for a new account is done. So far I have created a rule that triggers on "After saving a new user account". The product, in this case a membership is added to the cart, but I cannot seem how to update the order with the address details of the user ?
I have tried creating a new entity,  Commerce Customer profile, and setting its values but these values are not added to the order? Could it be that the new profile is not "connected" to the order? How should that be done?
Any ideas welcome.

Thanx,

/bo


texts: Organic Groups - How do I set a default role for new group members?

texts:
I have created a custom group role with some custom permissions and I am trying to find a way to allocate this role to group members by default. Ideally I would like every member of every group to be allocated this role, and be able to remove this role from a user if I no longer want the particular user to have my custom permissions.

I believe OG User Roles had this functionality and user roles were put into core organic groups for 7 but I am not sure if this default roles functionality was also implemented?


texts: Exclude Items from Flat Rate Shipping Calculation

texts:
I have several product types:
• T-shirts (FlatRate)
• Pins (FlatRate)
• Poker Chips (No Shipping)
• Gift Card (No Shipping)
• Class Registration (No Shipping)

I charge $10 Flat Rate Shipping for all orders under $75.
All orders over $75 are free.
I do not charge shipping for Poker Chips, GiftCards or Class Registration.

I have everything set up and working EXCEPT I don't want to calculate the price of Poker Chips, Gift Cards or Class Registration in the shipping.

So, if the user orders a t-shirt at $20 and a $100 Gift Card, he should still be charged $10 shipping even though his order total is over $75.

I just can't get the flat rate shipping to not calculate the price of the excluded items in the order.

Help!!


texts: Link menu item to an element ID on the same page

texts:
I want to link my menu items not to a page, but to a specific ID of a div tag on the same page, so if anyone click on it would go to the div section. basically its because I want to make a list of some items in my page.

I appreciate any guidance, thanks.


texts: How to display label and field output inline

texts:
I want to display same line label and fields in drupal 8. But by default it's showing field down and label up.

I'm using suffix and prefix it works.
How can I display it without suffix and prefix?

 $form['doc_date'] = array(
'#type' => 'date',
'#required' => TRUE,
'#date_date_format' => 'd-m-Y',
'#default_value' => (isset($record['doc_date']) && $_GET['num']) ? $d_date:'',
  '#attributes' => array('type'=> 'date', 'min'=> '-180 days', 'max' => date('d-m-Y') ),
  '#prefix' => '

Document Date : *',
'#suffix' => '

',
);


texts: Default values not working in multiple select options

texts:
I have a form with  multiple select options.Other things are working fine. But when I revisit the form I have to select everything again. I have given:

'#default_value' = previously selected array()

But that is not working I guess. Is there any method that the user can add in the selected list without need to select everything again ?
Thank you .


texts:
I just enabled and configureda workflow module. The edit, outline and revisions tabs display in an overlay state whereas the workflow goes out of the overlay and to the site, if that makes sense.

Why is this happening? Where do I change the settings for this so all the tabs behave the same?


texts: I am using webform module to create a form for enrollment. End user will need to add the list of children. Since number of children is unknown for the users, I was trying to add "add child" button to add more children. I used webform add more module but it has known issue. I added a field set component in which I have name, age, ssn fields. Now, I am stuck how to add "add child" button under the fieldset for public to add childs as many as they need. How can I add "add child" button under fieldset component or is there other way I could accomplish that using the webform module?


texts: How to allow OG admins to view private groups?

texts:
The scenario I try to achieve:

Groups that are not public, are hidden for all users that are not member of the group.
Users with the permission "Administer Organic groups permissions (Administer all groups and permissions)" should be able to view it regardless.

The OG setting for "strict node access" is enabled to prevent other users from viewing content that belongs to foreign private groups.

The problem lies with 2.
Even though users with the "Admin OG permissions" permission can access /node/%/edit to modify the group entity, or even view the member list and add users to the group, viewing the group page itself is not possible nor is the group listed in the /groups view.

Is this a configuration issue or rather a bug?


texts: ckeditor underline not allowed on filtered HTML

texts: I have a problem whereby I cant underline text using ckeditor whilst in Filter HTML, it works fine with Full HTML. I can also use Bold and Italic with Filter HTML but not Underline. Is there a configuration setting for this, so a User set up with just permission for Filter HTML can add underline?


texts: Allow users to access only terms that he created

texts:
Terms from user that created nodes are stored in vocabulary tags. When user creates new content i would like to allow him to only choose from list of terms he created instead of whole vocabulary.
Is that possible ?


texts: How to render a region in custom module twig template

texts: I have rendered regions in page.html.twig using {{ page.region_name }}. But it doesn't work for the custom modules template. How can I render a region in custom template?


texts: Customize the display for organic group forum

texts:
I am using Organic groups, and I would like to change the way forum topics are displayed. More precisely, I would like to be able to add a block that shows WebFM attachments.

One way that I've found is to customize the "Node template" page (the one used for the path /node/%node) and create a variant whose selection rule takes "Forum topic" as node type. There I can customize the layout and the content, also adding the WebFM block.

I wonder if there's an easier and more straightforward way of doing this.


texts:
How do I pass the logo on my theme to the image module to create different sizes? I'm using domain access to I can't use

<?php print theme('image_style', array('style_name' => 'thumbnail', 'path' =>'public://new_ctrl_logo_front1_1.jpg')); ?>

as I'm using domain access and using one theme for use on multiple sites. I found this code on another form that works on my theme and need to know if I can pass an image style through it.

<?php
if (theme_get_setting('toggle_logo')) {
$image = array(
'path' => theme_get_setting('logo'),
'alt' => 'my logo',
);
print theme('image', $image);}?>

Thanks for helping,
Gregory S.


texts: How to create heirarchical taxonomy menu/list using VIEWS

texts:
How can I create a view of taxonomy terms for a content type (Story and Page) and display it to a block with parent and child relationship?

What I want is to take a "Taxonomy Term" based on "Content Types".

Example:

Fruits (5)
  - Apple (3)
  - Banana (2)
Vegetables (4)
  - Beans (1)
  - Eggplant (2)
  - Onions (1)

Demo:
http://worldstogethertravel.com

Menu on right sidebar: (Of Cultural Interest)

This menu is created using taxonomy_menu module not VIEWS.


texts:
I'm trying to add the page title to the breadcrumbs for each page, unfortunately my breadcrumbs are not updating with current page title. All sibling pages in the menu show the same breadcrumbs.

For example, all these pages will show the same breadcrumbs:

Home > About Us > Our Team
Home > About Us > Our Mission
Home > About Us > Another Page

Whatever page you visit first, you will get the breadcrumbs for that page on all of the above pages. So if you visit the "Our Team" page first, you will get the "Our Team" breadcrumbs on the "Our Mission" and "Another Page" pages as well. The same happens for 2nd level pages.

So if you visit

Home > About Us

You will get the About Us breadcrumbs on

Home > Services

However, you will not get the Home > About Us> Our Team breadcrumbs on

Home > Services > Service A

I have this code in my .theme file:

function themename_preprocess_breadcrumb(&$variables){
   if(($node = \Drupal::routeMatch()->getParameter('node')) && $variables['breadcrumb']){
       $variables['breadcrumb'][] = array(
                 'text' => $node->getTitle(),
                     'url' => $node->URL()
                   );
   }
}

And this for my breadcrumbs template:

{% if breadcrumb %}

{{ 'Breadcrumb'|t }}

    {% for item in breadcrumb %}

        {% if item.url %}
          {{ item.text }}
        {% else %}
          {{ item.text }}
        {% endif %}

    {% endfor %}

{% endif %}

I'm guessing it's some sort of caching issue, as it seems to happen per-session (different users will get stuck with different breadcrumbs depending on which pages they visit first).

Anyone know why this may be happening?


texts: Menu tree page data not rendering any data if the page does not exist in drupal 7

texts:
I have this code to render the menu. I need to make extensive modifications of the elements, so this is why I extract it in this way (multidomain-multilanguage site, I tried everything and this was the only solution I found):

$a = menu_tree_output( menu_tree_page_data("main-menu") )

It works perfectly and $a is an array full of content. Works for every page, except for 404 not found pages. There it returns an empty array.

Any help would be appreciated. I was thinking of storing the menus for the different languages and domains in the database in a personal table and checking if array is empty, in order to extract the info, but I think that is not a good solution. Thank you!!!


texts: Get Fields of a custom Content Type from Database in Drupal 7

texts:
I'm trying to get custom fields of my custom content-type "slideshow". I've chosen to get the fields from template (.tpl.php) file for some reasons (mainly because I've to write lots of formatting HTMLs and modifying lots of template files did not sound good).

So far, What I've got is individual nodes:

$result = db_query_range('SELECT n.nid
                      FROM {node} n WHERE n.type = :ntype', 0, 10, array(':ntype' => 'slideshow'));
foreach ($result as $record) {
    $node = node_load($record->nid);
    // Got $node! What to do now????
}

The code works & I've got nodes in $node. Now What to do to get individual custom fields & work with the raw data of these fields? Please help.

PS I've tried Get content type with PHP from database but the code does not work... guess it's for older Drupal versions.


texts: How do I create a HTML link from an internal path using the core Link class?

texts:
I miss the deprecated l() a lot. I am trying to construct the Drupal 8 equivalent of:

l(t('mylink'), 'admin/structure/types');

This call generates this HTML:

'mylink'

I want to know how to produce the same HTML (i.e. a string) using the Link class.

Please understand that I am not looking asking how to render the link. I need the string for other purposes than rendering. I fully aware of that usually, one wants to render the link. If that is what you want to do, you should look at the accepted answer to this question: How do I create a link?.

I am trying to generate an HTML link to'admin/structure/types'. But will appreciate an answer that explains how to do this for any valid internal path.

I've looked at a lot of examples, a most of the them end up saying one should use Link::fromTextAndUrl in some construct like this - without explaining how to get $routename from the path.:

Link::fromTextAndUrl(t('mylink'), Url::fromRoute($routeName));

However, by searching (as suggested by Jaypan) I was able to determine that the routename for this path was 'entity.node_type.collection'.  This works as one would expect:

  $url = Url::fromRoute('entity.node_type.collection');
  $url_string = $url->toString();

I.e.: $url_string is now 'admin/structure/types'.

So I proceed to build a link object

$link = Link::fromTextAndUrl(t('mylink'), Url::fromRoute('entity.node_type.collection'));

Now: How to get an HTML string?

No Sssweat suggests:

$url = Url::fromRoute('book.admin');
$link_thingy = Link::fromTextAndUrl(t('mylink'), $url)->toString();

This step just make $link_thingy into an object. Close, but no cigar.

In an updated version of his answer, Jaypan says that treating this object like a string - example:

 print Link::fromTextAndUrl(t('mylink'), Url::fromRoute('user.login'))->toString();

outputs the HTML string.  This works. This means you will have the HTML string when you use it in a context one would use a string.  Therefore, I've accepted Jaypan's answer.

I've also tried out the kiamlaluno's answer, i.e.:

 $link_thingy = $link->toRenderable();

This produces a (huge) render array, not a string.  A render array, however, is a very useful thing (see comments for why this is so), but it is not accepted as answer to this question because the question was: How to get an HTML string?

Environment: Clean install of Drupal 8.8.6 (core + devel). Ubuntu 20.04 LTS.


texts: All other pages are being loaded fine but when I go to permissions page it comes like this. What may be the reason for this ? Please help.


texts: Previewable email templates token replacement

texts:
From my form_alter code, I would like to redirect to email template (Previewable email templates)

$form_state['redirect'] = url('pet/email_template', $options )
The params are set as
$options = array(
      'absolute' => TRUE,
      'query' => array('nid' => '1','uid' => '3')
  );

In the email template, there are tokens [webform:sid] and [webform:data]. How do I replace those data [webform:??] by using the url call to template?
Thank you.


texts: Filter the list of entities referenced by "Entity reference revisions" field

texts:
I have a content type "Slider" which uses an Entity reference revisions field named "Slides" to save reference to various paragraphs that are then displayed on the frontend as a hero slider.
Everything works fine but now we have received a request of filtering out the slides by a show/hide boolean flag in the slide paragraph. Adding a boolean field to each such paragraph is straightforward but how do I filter those paragraphs based on it? I'm assuming a Drupal hook that allows a function to filter out the referenced entities by some arbitrary criterion but I've been unable to find it.
I understand that this question relates to a 3rd party module but it is quite possible that a core Drupal hook could be used in this context.
Any help will be greatly appreciated.
Thanks.


texts: drupal2dupal migration add a default taxonomy term

texts: I want all of my imported data to have a default taxonomy term, since the source doesnt have this taxonomy term .  I have adde the tid of the taxonomy term in the UI as attached, but the content is being imported without this taxonoy term  . What am i doing wrong?


texts: Dropdown whose options are dependent on a choice made in a previous dropdown

texts:
I have two taxonomies (class type and level). I load one in drop-down (class type) and another depended on result of choice (level).

I handle lot of cases (when choice class type load level ) && (if level have data and class type load it when first load) but when I choice empty class type load default data of level :(

function ria_form_alter(&$form, &$form_state, $form_id) {
        $classTypeSelected = false;
        // load class type fron taxonamy
        $classTypes = Utilities::LoadTaxonamy ( 'class_type' );
        $form ['field_level'] ['und'] ['#prefix'] = '
';
        $form ['field_level'] ['und'] ['#suffix'] = '
';
//dpm($form_state ['values'] ['field_class_type'] ['und'] [0] ['tid']);
        if ( isset($form_state ['values'] ['field_class_type'] ['und'] [0] ['tid'] )) {
            $classTypeSelected = $form_state ['values'] ['field_class_type'] ['und'] [0] ['tid'];
        }  else {
            $classTypeSelected = false;
        }

        $form ['field_level'] ['und'] ['#options'] = load_level ( $classTypeSelected );
        $form ['field_level'] ['und'] ['#default_value'] = isset ( $form_state ['field_level'] ['und'] ['#default_value'] [0] ) ? $form_state ['field_level'] ['und'] ['#default_value'] [0] : '';
        $form ['field_class_type'] ['und'] ['#ajax'] = array (
                'callback' => 'ajax_example_dependent_dropdown_callback',
                'wrapper' => 'dropdown-second-replace'
        );

    }

function ajax_example_dependent_dropdown_callback($form, $form_state) {
    return $form ['field_level'] ['und'];
}

function load_level($class_type) {
    $levels = array ();
    if ($class_type && $class_type != '_none') {
        $levels = Utilities::DataFromTaxonamy ( $class_type );
    }
    return $levels;
}


texts: Rules reaction: "After updating an existing user account" reacts on user login

texts: I have a rule that I use to create a group node for user when user gets a new role. A group node was created for the user when she got the new role but unfortunately a group keeps getting created for the user whenever she logs in. Not sure of what is going on. How do I fix this? Thanks!


texts: Cache pages for anonymous users stuck on

texts:
I can't turn off the "Cache pages for anonymous users " cache option.

I uncheck it and then hit save as usual but it stays on. Is there some sort of module conflict causing this or possibly an issue with the database?


texts: programmatically get default value from translated body field per language

texts:
I am trying to get a default value loaded programmatically into every body field when we add translate from english, but it doesn't seems to work using form overwrite fields

I tried using $form[][] = 'value'; but not working

as I also unable to pull the default value that is already set via field_translations.

I used form_alter for the options

can anyone please point me some clue of which method I used for the custom module

thank you!


texts: Create custom path alias when new user is added in drupal 7

texts:
I've created contents using custom form. I don't use content types. I could add, update and delete that content by access test, test/id/edit and test/id/delete.

I've displayed content lists for a user by tests/uid. Now I want to use user name instead of uid. I have to replace space by '-' and also replace all special characters. So my choice is both url alias and path auto.

But I couldn't add custom url pattern into pathauto pattern. There is only available for content types, taxonomy term, user and file path. But I want to custom url pattern for custom content inside the user path.


texts: Content Moderation: Editorial workflow not installed and broken/missing handler on the moderated content view

texts:
I'm having troubles enabling Content Moderation Module (content_moderation) on a Drupal 8.7.8 site.

During installation everything seems fine, drush en content_moderation finishes without errors, workflows module is already enabled before.

After install the editorial workflow is missing, but it's possible to create a new content moderation workflow.

All role permissions are available and the Moderation State widget shows up on nodes of the selected types. But using the widget has no effect, nodes don't get published or unpublished.

The database tables for Content Moderation are created properly (ie. content_moderation_state and three more with similar names).

Also the view moderated_content shows "Broken/missing handler" where the filter criteria "Content revision: Moderation state (exposed)" and "Content revision: Moderation state (<> Published)" are supposed to be.

Clicking the Broken/missing handler fields shows some details for the two broken handlers:

The handler for this item is broken or missing. The following details are available:
id: moderation_state_1
table: node_field_revision
field: moderation_state
relationship: none
group_type: group
admin_label:
operator: not in
group: 1
exposed:
is_grouped:
entity_type: node
plugin_id: moderation_state_filter
Enabling the appropriate module may solve this issue. Otherwise, check to see if there is a module update available.

Second field shows this info:

id: moderation_state
table: node_field_revision
field: moderation_state
relationship: none
group_type: group
admin_label:
operator: in
group: 1
exposed: 1
is_grouped:
entity_type: node
plugin_id: moderation_state_filter

I also can't add any moderation state related fields to the view like "Moderation state". The fields do not show up in the "Add fields" dialog.

I'm having no problems setting up Content Moderation on a vanilla Drupal 8.7.8  it just fails on this existing site (same version).

I already tried reverting the site and reinstalling workflows and content_moderation on different ways, with drush and manually. I uninstalled all custom modules and patches and reinstalled content_moderation.

Are there any modules (except workbench) or settings known to cause problems with Content Moderation?

Any ideas what could be causing the problem or where to start looking?

Thanks a lot!


texts: how to use drush commands for a live site?

texts: I am using drush in my localhost. I am new to drupal and i want to execute some commands in drush for a live site. can anyone know how to use drush for a live site...?


texts: Ubercart - Stay on page when you add product to cart

texts: In Ubercart, each time i add a product to the cart, i'm redirected to the cart page. Then i have to click on the link "continue shopping". Is there an option to stay on the actual page after adding product to page?


texts: How to round the total price, display without decimal?

texts:
I need to count on decimal places (tax, promotion, fee ...), but the total price must be mathematically rounded without decimals.
Example:
2 x product1 CZK 424.00
1 x Product2 CZK 408.00
Subtotal CZK 832.00
Shipping CZK 99.00
Discount CZK -41.60
10% VAT CZK 71.86
21% VAT CZK 17.18
-Total CZK 889.40- remove
Rounded CZK - 0.60 it is not necessary to display
Total CZK 889.00


texts: printing drupal field in comment.tpl.php

texts:
I have disabled user pictures, and created a field in users instead because i feel i have more control of the user pictures, i.e. i can organize them on webhotel with tokens, and choose a certain picture style etc.

Now i want to use the field in the comment.tpl.php of the theme, so i printed following code <?php echo render($content['field_profilbillede']); ?> where the <?php print $picture ?> usually appear .. but nothing happends at all .. what did i do wrong?

Ps. i got the code from another post on stackoverflow.com so yes i have already searched for related posts.

Thanks


texts: How to configure Node Export to mass node export?

texts:
I'm trying out Node Export for mass node export, but it seems that I have to choose every node to export individually.

What if I want to export all nodes of a selected content type? Is there any way I can do this in Node Export, or I should find another module?