texts: Change views exposed filter value only on page reload

texts:
Is there a clean way to alter a View exposed filter field, but only on page reload and not each time you submit the exposed filters form ?

Example

I have a View with exposed filters. When a user is loading this View, I want to change the value of an exposed filter field, depending on a cookie value.

I've managed to make it work with the hook_form_views_exposed_form_alter function.

function HOOK_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
    if ($form['#id'] == 'views-exposed-form-MY-VIEW') {
        $cookies = \Drupal::request()->cookies->all();
        if (isset($cookies['MY_COOKIE'])) {
            $form['MY_FIELD']['#value'] = $cookies['MY_COOKIE'];
        }
    }
}

Problem is : if the user manually change the exposed filter and submit the form, the value is getting back to the first one because the hook_form_alter is getting called again.

Here is a video : https://imgur.com/EmVha6e

Poor solution

I've found a solution, but it doesn't looks like a good one. I've found out that when the hook_form_alter is getting called by a submit, there is a new entry ('a' => '') in the UserInput array that you can find by calling $form_state->getUserInput().

First load :

[
    'MY_FIELD' => 'All',
    '...' => '...'
]

After submit :

[
    'MY_FIELD' => 'New value',
    'a' => '',
    '...' => '...'
]

So now I can use the following to change the field value only on the page load :

if (isset($cookies['MY_COOKIE']) && !array_key_exists('a', $form_state->getUserInput())) {
    $form['MY_FIELD']['#value'] = $cookies['MY_COOKIE'];
}

But I'm not even sure it is fully functional, is there a better way to do it ?

Clean solution

Thank's to @NoSssweat, here's a cleaner solution :

function MODULE_views_pre_build(ViewExecutable $view) {
    $request = \Drupal::request();
    $is_ajax = $request->isXmlHttpRequest();
    if (!$is_ajax) {
        $cookies = \Drupal::request()->cookies->all();
        if (isset($cookies['MY_COOKIE'])) {
            $view->setExposedInput(['MY_FIELD' => [$cookies['MY_COOKIE'] => $cookies['MY_COOKIE']]]);
        }
    }
}


texts:
I have a content type, 'A'.
Now I need a form with the user registration form fields plus the 'A' creation form fields.
So when the user (annonymous) submits this form, a user and a node of type 'A' with the filled information would be created.

I have this for now:

function my_module_menu() {
  $items['create_node_and_user'] = array(
    'page callback' => 'user_and_node_creation_form',
    'type' => MENU_CALLBACK,
    'access callback' => TRUE,
  );

  return $items;
}

function user_and_node_creation_form() {
  module_load_include('inc', 'node', 'node.pages');
  $output = array();
  $output['user'] = drupal_get_form('user_register_form');
  $output['node_type_a'] = node_add('node_type_a');

  return $output;
}

The form is displayed fine, but How can I add a submit handler to manage the node creation after register the user?


texts: How to Lazyload any src object in node body

texts:
Currently using Blazy on Drupal 8. What I am trying to do is figure out how to lazyload any image, iframe, mp4 found in the body.

I think I have found a good solution as seen here:
https://www.drupal.org/project/blazy/issues/2912992

But how do I implement it. I am stuck at step 4.


texts:
I super love Krumo/Devel. However, I'm sure I'm missing something obvious, because when I use dsm() and I get my array or object all expandable and awesome, sometimes I have a hard time knowing which array or object it is. At the top, it just says ... (Object) stdClass.

Is there somewhere that it includes the name of the object/array you're exploring? What about on the devel tab of a node?


texts:
I know how to setup a multi-page webforms (basically add page breaks' between each page).  I also know how to use the conditionals to skip certain questions based on the values or state of previous questions.

However, I would like to do this dynamically.  So instead of using conditionals to change the workflow, I would like to use my own logic (code) to decide what the next question should be.  The reason is I have a webforms with 42 questions (pages) and the actual workflow can change significantly.

All I am really asking is how do I tell webforms what the next question is that should be shown.

I guess it is similar to this question (How to jump to a specific page in a multipage Webform) but the solution quoted (Webform steps Module) does not solve my problem.


texts: Using views arguments to highlight/alter corresponding entries instead of filtering

texts:
So, I am making a tree based tab style menu for a section of my site.

There are 3 content types with node references going up the tree. They are ordered: Section < Product < Package.

If I am on a package I want to display 3 tiers of tab at the top of the page, filtered by the section/product the package is in and with the section+product+package that the package is a child of highlighted.

eg: If I am looking at "SECTION1 PRODUCT2 PACKAGE3" it should display the tabs like this:

SECTION1 section2 section3

section1product1 SECTION1PRODUCT2 section1product3

section1product2package1 section1product2package2 SECTION1PRODUCT2PACKAGE3

with the capitalisation representing something akin to the "active"class in css

My URL aliases are formatted: example.com/[sectionname]/[productname]/[packagename]

Edit: Many paths have failed me thus far... Any generic advice welcome...


texts:
I have 2 views with contextual filter, they work well stand alone.

Now I want to include those two views into a panel (called eg. trypane/ ) and pass to it the contextual filter for the views it includes (eg. 19)

So I create a new content, panel, and i've added those two views.
But when i call the panel (trypane/19) simply it doesn't work.

The infos for the views included are:

Using display Master.
1 items displayed.
Without pager.
Sending arguments.
Using arguments: %2

and a similar description for the second.

What's wrong with my setup?


texts:
I want to auto add flat rate shipping cost to any order and display it in the shopping cart summary.

I am using Commerce Shipping and Commerce Flat Rate modules. I can't know how to implement it using rules.

I found this post but it didn't help me.

what I need is to automatically add $10 on every order for shipping, I will disable the Shipping Service Panel.


texts: How to prevent User Roles from getting reapplied?

texts:
For whatever reason when I remove a role from a user's profile, at url site/user/user-id/edit it just comes back a few days later. I tried to check users_role table but I do not have that table.

.

We do import every employee every night, based off Active Directory, but I do not touch their roles in the import.

I imagine the best way of solving this is finding the table that has every user's roles, then just removing that entry from the particular user.


texts:
Is there a way to allow a user who is not a developer to enter the text and slideshow images for a Lead Generator page without going through all of the Drupal screens? I need to allow our marketing department to create Lead Gen pages, which they do frequently. Every page uses the same theme and settings. The only thing that changes is the content (images and text).

Basically, I need a simplified UI where the user can enter the variable content, but other settings (like page visibility and slideshow settings) use our defaults.

Can I either create a new data entry screen(s) or filter/restrict/reorganize the existing screen(s) for this?


texts: What is the naming convention for theme region template files?

texts:
I want a custom template for every theme region, but I'm not sure of the naming convention.
For example, with the following information the .info file, would region--header.tpl.php be a correct template name for the Header region?

regions[header] = 'Header'
regions[sidebar_first] = 'Sidebar First'
regions[content] = 'Content'
regions[footer] = 'Footer'


texts:
What would be the smartest way to approach filtering content by the groups that it is posted in?

I will almost certainly need custom code to do this (I think a Handler, but I need someone to point me in the right direction), especially because I want to be able to filter by content posted in "All" groups, posted in a set of groups (i.e. a user's "core groups," determined by a taxonomy term reference on all users and groups -- if they are equal, that group is a user's "Core Group"), and also by each individual group that the user belongs to (but I don't want groups that the user isn't a member of showing up in the filter).

The docs for Views aren't very good, and I just know that there's an elegant, Drupal way to do this, and I need someone to point me in the correct direction (i.e what hooks, etc.)

Thanks in advance for help!


texts: How to exclude the user table using the drush sql-sync command

texts: How do I exclude Drupal's user table from drush's sql-sync command?


texts: How do I display the last person that edited content instead of the original author?

texts:
On the page /admin/content, there is a column for Author. We have a lot of people editing our content, so the original author isn't all that important. I want to change it to show the last person that edited the content, which I believe is stored in the revision of that content. How can I modify the view to show that? Alternatively, is there a hook I can implement in a custom module to do this?

I've checked out a couple other questions like this one and this one, but they weren't much help.


texts: How do I change the description of a view?

texts:
I have some existing views for which I have written a developer guide description. Now I duplicated the views for some other task, Duplication is successful but I didn't find any possibilities to change the description of the view. I check advanced section of the view but not successful.
The only way is to create a new view but it will take a lot of time and I already have it done in the existing views a few changes are required. But the description is different from the existing one.


texts: Error after updating to latest core version

texts:
After Drupalcon last week I felt comfortable using composer, and I was ready to update our site from 8.4.6 to 8.5.1. I have done just that (luckily in a dev environment) and now the front page of the site loads fine (as well as the user/login page), but any other page I try to navigate too just throws up an error

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

  InvalidArgumentException: Field is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
  Drupal\Core\Entity\ContentEntityBase->get() (Line: 49)
  Drupal\Core\Entity\EditorialContentEntityBase->isPublished() (Line: 188)
  content_moderation_entity_access(Object, "view", Object)
  call_user_func_array("content_moderation_entity_access", Array) (Line: 402)
  Drupal\Core\Extension\ModuleHandler->invokeAll("entity_access", Array) (Line: 96)
  Drupal\Core\Entity\EntityAccessControlHandler->;access(Object, "view", Object, 1) (Line: 702)
  Drupal\Core\Entity\ContentEntityBase->access("view", Object, 1) (Line: 177)
  Drupal\block_content\Plugin\Block\BlockContentBlock->blockAccess(Object) (Line: 118)
  Drupal\block\BlockAccessControlHandler->checkAccess(Object, "view", Object) (Line: 105)
  Drupal\Core\Block\BlockBase->access(Object, 1) (Line: 119)
  Drupal\Core\Entity\EntityAccessControlHandler->access(Object, "view", Object, 1) (Line: 362)
  Drupal\Core\Entity\Entity->access("view", NULL, 1) (Line: 56)
  Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
  Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
  Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
  Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
  Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, "kernel.view", Object)
  call user_func(Array, Object, "kernel.view", Object) (Line: 111)
  Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch("kernel.view", Object) (Line: 156)
  Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
  Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
  Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
  Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 184)
  Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)
  Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)
  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)

Now I have no idea what that means, anyone out there experienced anything like this before?


texts: views_embed_view use to append new HTML from view

texts:
Using drupal 7, I have a view that created an aggregated table like this:

Animals  44

Plants 25

I want that when user clicks on 'Plants', on the same view, without refreshing, the list of the 25 plants (coming from another view) comes out, appending the HTML to the Plants div.

I think that views_embed_view might be the solution. I am on the right track? how do I specify on which DIV the generated view should be appended to?

thanks


texts: What does the votingapi_set_votes function in the votingapi module actually do?

texts:
I am trying to use the Voting API module to add a vote through a menu item. Meaning that when someone visits a menu item [the/menu/item] a vote is added to the database.

There is already the Voting API functions that does that. I don't understand what the votingapi_set_votes function in the Voting API module does.

I have read the website documentation however I don't understand what it does and how can I use it. And couldn't find an example of usage either.

I have tried the follwing to add a vote:

  $items['the/menu/path/1'] = array
  (
  'title' => 'Some title',
  'page callback' => 'my_page',
  'access callback' => TRUE
);

return $items;
}

function my_page(){

  $votes = array();
  $votes[] = array(
    'content_type' => 'news',
    'content_id' => 1025,
    'value_type' => 'points',
    'value' => '1',
  );

  $criteria = array(
    'content_type' => 'news',
    'content_id' => 1025,
    'function' => 'sum',
    'value_type' => 'points',
  );

  if (TRUE) {
    if (module_exists('votingapi')) {
      // die("test");
      votingapi_set_votes($votes);
      die();
      $result = (votingapi_select_results($criteria));
      print 'result is: '.$result[0][value];
      $result = '';
    }
  }
  return "true";
}

But it gives me an SQL error like so:

  PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column
  'content_type' in 'where clause': SELECT votingapi_vote.* FROM
  {votingapi_vote} votingapi_vote WHERE (content_type =
  :db_condition_placeholder_0) AND (content_id =
  :db_condition_placeholder_1) AND (value_type =
  :db_condition_placeholder_2) AND (uid = :db_condition_placeholder_3) ;
  Array ( [:db_condition_placeholder_0] => news
  [:db_condition_placeholder_1] => 1025 [:db_condition_placeholder_2] =>
  points [:db_condition_placeholder_3] => 130 ) in
  votingapi_votingapi_storage_select_votes() (line 225 of
  C:\Users\tarek.ismail\public\egyptinnovate\sites\all\modules\contrib\votingapi\votingapi.module).


texts:
I have a D7 site where users are linked to other users (by References). User profiles are extended using the Profile 2 module and by so, containing some additional fields (phone, email,...).

I want to create a landing page where logged in users can see the info of the connected profile. So a logged in user should see the name, phone and email of the linked account.

I've been trying around for a while, but not able to close this issue.
It's not a matter of permissions, since the direct URL (/profile-representative/16) is accessible by the logged in user. On that page, he can see all the info. It's that info (phone, email,...) I want to get into Views.
But for some reason, it cannot be done by using relationships. At least not by me.

Is there anyone with experience concerning this matter?


texts: How can I make a link from user account page to its content profile node?

texts:
I could make a link from content profile to its user page by this method.

But how can I do the other way round from user account page to content profile?


texts:
We are getting emails from google about the latest version of Double-click for Publishers' (dpf) API.

Currently our site appears to still be using a deprecated version (v201508) and need to update to v201608 by November 30.
https://developers.google.com/doubleclick-publishers/docs/deprecation

Is this dfp api change is going to affect the dfp module?


texts:
I added an if statement around the content render php in my page.tpl.php file. Only problem is I made a mistake and accidentally prevented it from rendering content on any page. I cleared the cache and logged out to test it, and realising my mistake I corrected the template file. But now I can't log back in to clear the cache again as my site won't render content and thus won't render the login box.

Can someone give me a way in Drupal 7 to either log in without the login in box (like a way to render the login box separately to the content) or a way to clear the cache?


texts: Cannot install and activate contrib themes in Drupal 8

texts:
On my XAMPP D8-beta15, I cannot seem to use any of the contributed theme modules. What I did was to

download and unpack it in the theme/contrib folder
go to /admin/appearance
click on "install and set as default"

Regardless of which theme I install, when I go back to the main site, I get a plain HTML view with no style sheets in <head> and no HTML title.

Same result if I install the themes in folder sites/all/themes. There are neither error messages nor log messages.

What am I missing? Could this be a server issue?


texts: How can i change comment form in drupal 6?

texts:
I just want to change comment form completely not in css in html/php like change title name comments to mycomment and post your comment to create a comment etc...

and i also want this only for particular page like i want for contact us page comments to Your Details and for about us page write your suggestion.

plz help me..


texts: How to get parent paragraph from a child block preprocess

texts:
Searched all over the place but cannot find anything similar. Here's the issue...
The setup:

'Page' content type
'Block Content' paragraph type

The 'Page' content type has a field for referencing the 'Block Content' paragraph, called "Components" (set to unlimited). Now we can use paragraphs within our page. Simple.
The 'Block Content' paragraph type has a field for referencing blocks (using the module Block Field). It also has two other fields for title and subtitle. These fields need to be displayed on the referenced block template for this paragraph instance. This is the issue.
I have included some images to show the setup.
I am trying to use theme_preprocess_block to inject these fields (title and subtitle) into the correct block using $vars['plugin_id'] from the block preprocess but the issue is that the block does not know its paragraph parent. And if I don't know the parent, I can't retrieve these fields that I need to inject into the block.
This answer suggests using the following to get the parent:
$parent   = $variables['elements']['#node']->_referringItem->getEntity();

But in my case I could not find anything equivalent in my block preprocess function.
Update 1:
I tried (from within theme_preprocess_block):
dpm($vars['elements']['content']['#block_content']->_referringItem->getEntity());

This give the following error:
Error: Call to a member function getEntity() on null in limit_preprocess_block__banner_block()

Update 2:
I just dumped the $vars from the preprocess function and noticed that there seems to be the paragraph id in there. But I don't know how to access it from the $vars variable. Is it possible? (see dump image below)

IMAGE 1:

IMAGE 2:

IMAGE 3:

IMAGE 4:

IMAGE 5:


texts:
I am using CKeditor and I would like to be able to export my configuration with Features.

I find that I am able to put all my CKeditor profiles into a Features module. All the settings are stored in the Features module, but the Profiles don't save the settings of which text format the profile is applied to.

This means that when I enable the features module on a new site, I have to reassign the profiles to the text formats.

How can I overcome this?

I have tried using the dev version of CK editor and strong arm as well.

Note: I am talking about the standalone Drupal CKeditor module and not the one that requires the WYSIWYG module to be installed. I am using this module because it is compatible with the Drupal Edit project.


texts: cron error Fatal error: Call to undefined function filter_xss()

texts:
I am running a remote command on my server to execute cron.php and I get this error : Fatal error: Fatal error: Call to undefined function filter_xss() in /home/k1004/html/www_dem
o/oan/srcs/includes/common.inc on line 655
Does anyone have an idea about where it comes from??


texts:
I've truncated registry table, because of the other problems, but now I have problem rebuilding the registry table based on the files listed in the database.

I'm calling registry_update(), _registry_update() or registry_rebuild() to do it:

drush eval "registry_rebuild();"

But then I've the following error which appears:

  Fatal error: Class 'SelectQueryExtender' not found in includes/pager.inc on line 15

By default (on system module install) registry table is empty, so how Drupal fills that table with the proper default data?


texts: Drupal site not loading any CSS/JS/Images

texts:
I've been trying to migrate my site from my local to GoDaddy server. I've done it so many times before and it's worked fine but this time I can't quite figure out what's wrong.

My steps on migrating the site:

Clear cache
Export DB
Create DB on server and import local DB
Upload Files (tar zip)
Change settings file

As I say, that's worked for me this whole time but now the site and content loads up fine but no styles, no images, no js. If I inspect the page it seems all of those files have a 403 forbidden error.

I noticed that even the Drupal menu and other Drupal CMS styles aren't loading up either so maybe that could be important in finding a solution?


texts: How do I rename the uploaded files for my module?


texts: save views->execute result as a static variable

texts:
Does it make sense (performancewise) to store view->execute() as a static variable in order to avoid running same view multiple times?
And then call view->render() wherewer I want to print the view? Does it make any sense? Or are there better options? Thank you


texts: How can I change the published state of a node before it is saved with hook_entity_presave()?

texts: I tried adding this in entity_presave $entity->setPublished(0);  but the node still gets saved as published.  How can I make it be set to draft?


texts: Manually removing an orphaned entity type

texts:
I have been handed an older Drupal 8 site and asked to update it to run with composer. I didn't do it in the cleanest possible way but it is working. I have run into trouble updating it.
I am most of the way there. Have rebuilt it and it is now managed with composer. However, In trying to run the final DB updates I am stuck with the following error blocking update:
[notice] Update started: system_post_update_entity_reference_autocomplete_match_limit
[error]  The "support_ticket" entity type does not exist.
[error]  Update failed: system_post_update_entity_reference_autocomplete_match_limit
[error]  Update aborted by: system_post_update_entity_reference_autocomplete_match_limit
[error]  Finished performing updates.

The "support_ticket" module was on the old site and in the DB but not enabled. I have tried adding and removing it and the "support" module that is its parent but the above error remains.
Is there a way for me to manually stop the system updating that entity type? Or inserting a placeholder? Or some other solution that lets me update the site.
MORE INFORMATION
The module Support and it's sub-module support ticket don't even appeat to be current drupal 8 projects. The last contribution to their d8-port github page is from 2015.
After some messing around I realise the sub-module support_ticket does not only fail to uninstall but it can't be re-installed either. If you try to re-install it you get the following error:
Unable to install Support ticket, comment.type.support_ticket_update,
core.entity_form_display.comment.support_ticket_update.default,
core.entity_form_display.support_ticket.ticket.default,
core.entity_view_display.comment.support_ticket_update.default,
core.entity_view_display.support_ticket.ticket.default,
field.field.comment.support_ticket_update.comment_body,
field.field.comment.support_ticket_update.field_revision_changes,
field.field.comment.support_ticket_update.field_revision_reference,
field.field.support_ticket.ticket.body,
field.field.support_ticket.ticket.field_assigned_to,
field.field.support_ticket.ticket.field_priority,
field.field.support_ticket.ticket.field_related,
field.field.support_ticket.ticket.field_state,
field.field.support_ticket.ticket.field_ticket_update,
field.field.support_ticket.ticket.field_watchers,
field.storage.comment.field_revision_changes,
field.storage.comment.field_revision_reference,
field.storage.support_ticket.body,
field.storage.support_ticket.field_assigned_to,
field.storage.support_ticket.field_priority,
field.storage.support_ticket.field_related,
field.storage.support_ticket.field_state,
field.storage.support_ticket.field_ticket_update,
field.storage.support_ticket.field_watchers,
filter.format.support_ticket_diff, support_ticket.settings,
support_ticket.type.ticket, system.action.support_ticket_delete_action,
system.action.support_ticket_lock_action,
system.action.support_ticket_publish_action,
system.action.support_ticket_save_action,
system.action.support_ticket_unlock_action,
system.action.support_ticket_unpublish_action,
views.view.support_ticket_overview, views.view.users_support_tickets
already exist in active configuration.

I am guessing at this point I would need to manually delete entries from the DB?


texts: Different taxonomy term title for menu and term page

texts:
Need help with one problem, I want to use different term title, 1-st for menu and breadcrumbs, 2-nd for term page

For example in menu and breadcrumbs: "doors"
In term page: "glasses doors"

I thought create special field for alternative title and add to page.tpl but I don't know how I can do it.

Can anybody help?


texts:
I created a book with the module provided by Drupal 8, but I am unable to organize the pages of the book correctly in a view.
I want to organize the book in this way.

In the left block, pages and sub-pages are correctly organized, but in the content (it's a view), pages and subpages don't match my ranking.

How do I classify the pages in the book configuration?
This is the  configuration page for the view.


texts: how to Views call images of each node? I saw that is not in SQL of the view

texts: I have a View that shows the first image of each node (so, a common View). I saw the SQL of this view, and I saw that the image is not called inside this SQL, so, what's the way that Views call images of each node?


texts: How can I assign multiple files to the same field in a migration lookup?

texts:
In a first migration step, I import files.
Therefore, I read a csv file, containing filenames and attributes about the files.
Files can share the same attribute like so:
file,attribute,...
ex1.pdf,666,...
ex2.pdf,666,...
ex3.pdf,667,...

This works perfectly fine.
I have my custom file entity bundle that has fields for all of these attributes.
A migration configuration assigns all these things correctly.
Now, I have a different entity bundle.
This bundle has a field reference that is configured for multiple values.
I have an additional migration for this one.
This migration also knows attribute from migration number one.
In a first try, I did something like the following in my second migration:
field_files:
  plugin: migration_lookup
  migration: <file_migration_from_first_step>
  source: kundennummer

The result was, that only one file was assigned.
I found this issue and tried patch 65 there and added the allow_multiple: true to my migration.
As a result, nothing gets assigned anymore to my field_files.
With a little debugging for just migrating data for attribute == 666, I saw, that the result of the transform function without the patch (or better: with the patch, but without the allow_multiple configuration) was just a single id (1 in my case) that corresponds to the first file (ex1.pdf).
With the patch activated, I saw a different result that looks like this:
Array
(
    [0] => Array
        (
            [fid] => 1
        )

    [1] => Array
        (
            [fid] => 2
        )
)

with 1 and 2 being the correct file ids of ex1.pdf and ex2.pdf.
So, I think, here is something quite broken on a larger scale, but at least my problem could be solved, if someone could tell me, how to assign the migration_lookup result from above to the field_files, such that my entity with attribute 666 links to the files ex1.pdf and ex2.pdf via one field_files.
I saw a few things, using sub_process approaches in similar scenarios, but I was not able to translate them to my problem.


texts: How to make field label as node reference link?

texts:
If I have field label as Links and type is a node reference link to Page Title. And its displayed like this:

Links: Page Title

How to make the label is the link to the node without showing Page Title like this:

Links


texts: Overiding homepage template problem. "page__front.tpl.php" won't be loaded

texts:
I am trying to overriding the homepage by creating a template file named "page__front.tpl.php"; I placed it under the theme folder where page.tpl.php lives.

After refreshing the site, the homepage still loads "page.tpl.php" instead of "page__front.tpl.php."
The cache and the theme registry are cleared.


texts: How to execute a flag after uncollapsing/clicking a (block) item?

texts:
I have this code working as a dropdown menu block that shows user's notifications, with a notification count item to its right:

<?php
global $user;

//We get the user's "notifications" field value and if it's greater than 0 show the counter
$user_fields = user_load($user->uid);
 if ($user_fields->field_notifications['und']['0']['value'] > 0) {
 $customfield = $user_fields->field_notifications['und']['0']['value'];}
 else
 {$customfield = '';}
 $text = 'Activity '.'
'.$customfield.'
';

 //here we print the block menu content (message's activity)
 $block = module_invoke('views','block_view','user_activity-block_1');
 $blocko= render($block);
 $output = '
'.$blocko.'
';
 $options = array('handle' => $text, 'content' => $output, 'collapsed' => TRUE);
 echo theme('ctools_collapsible',$options);
?>

Then I have a flag that sets the user's notifications field value to "0":

<?php print flag_create_link('unmark_notifications', $user->uid); ?>

The thing is that you have to click it separately to remove the notifications counter, but what I need is when I uncollapse the menu to execute the unmark_notifications flag too.

How can this be done?


texts:
The content region throughout the site seems to have disappeared.  I believe this might be a result of some mishandling of the default settings in Omega.

As a result the login prompt is gone from /user and I'm currently logged out without a way to log back in and fix it.

Any idea how I can login to the site without going to /user or how I would go about editing Omega/delta so that I can bring back the content region without logging in?  This site is still local/on my development server.  So I can still access the files.

Attached is a screenshot of what I'm looking at for those who are confused.


texts: Show node body fields for entity reference checkboxes widget?

texts: I need to show the body field of the nodes next to their checkboxes in an entity reference field widget (default is just their node titles). Is there a way to do that without writing a new widget?


texts: Different prices in Shopping cart form and Shopping cart summary views in Commerce price table

texts:
I have a problem with price table module that I hope you can support me on this issue. As I have some products with different prices depending on item's quantity according to the commerce price table module, everything is ok except "Shopping cart summary view" that only show base price and don't show calculated prices according to quantities. Also I have found rule "Override price with price table" in admin>configuration>rules that it seems it doesn't any effect on "Shopping cart summary view" !! . If possible pls help me on this topic and thanks in advanced for your perfect module.

For ease of reference, pls find attached file that show the price difference in "Shopping cart form" with "Shopping cart summary".


texts: Using CDN for jQuery and jQuery-ui with Drupal 6

texts:
For my Drupal 6 site, I'd like to get the latest jQuery and jQuery-ui scripts from the Google CDN.  Although this seems like something that many people would want to do, it seems that it is not so easy.

The project Advanced CSS/JS Aggregation (advagg) seems promising, but after installing it and trying to use the Google CDN in the standard way, e.g., adding

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>

to the head of a Drupal page, those files are not available.

Any ideas for how to do this?

EDIT:

I used drupal_set_html_head() to add the above lines to the HEAD of the Drupal page where I want to use jQuery and jQueryUI.  I verified that this was working by viewing the page source.


texts: How to change form field description output/markup?

texts:
I'm using Physics theme and I can't figure out how to change form fields description output/rendering.

At the moment is it rendered as

Lorem

while it should be

Lorem

This specific form is a Views exposed filter form but I don't really see that it would differ much from "other forms".

The base theme, Bootstrap, has it's own function for description and it is supposed to render it correctly. However, I don't where this change happens from regarding tag and classes.


texts: Running Drupal in a Windows environment (IIS, SQL Server)?

texts:
We are in the process of evaluating Drupal to replace our in-house .NET CMS. We run an IIS 7.5 web farm with a SQL Server 2008R2 on the back end. To make matters worse, we use sql server merge-replication between our primary and secondary collocation facility. Rebuilding the entire web farm structure would be cumbersome.

Can anyone provide thoughts/feedback/experiences on using Drupal with IIS/SQL server? Bonus points if you know it works sql server merge-replication.


texts: How to get links of translated node edit page in the secondary tabs

texts:
In D7, if a node is translated, let say in French and if you are in the entity.node.edit_form page then you could find 2 secondary tabs: [French] and [English] pointing to the edit_form of each language.

To achieve this in D8, I looked at the derivatives, but they are loaded once during cache clear and can't evaluate the current entity.

Following the 4k4 comment I have tried to subclass LocalTaskDefault
But I am stuck with the following problems:

1-How can I create a route for a defined language (eg: a route to edit a french node)

2-In .links.task.yml: should I create as many tabs as there are languages (I don't think so)

Here is my .links.task.ymlfile

translated_node_tabs:
  class: Drupal\mymodule\Plugin\Menu\TranslatedNodeTab
  title: 'Translated nodes'
  base_route: entity.node.edit_form
  route_name:  entity.node.edit_form

And here is the very beginning of what I have understood from the 4k4 advice

class TranslatedNodeTab extends LocalTaskDefault {
  /**
   * {@inheritdoc}
   */
  public function getCacheContexts() {
    return [
        'route'
    ];
  }
  /**
   * {@inheritdoc}
   */
  public function getRouteParameters(RouteMatchInterface $route_match) {
    $current_node = $route_match->getParameter('node');
    if ($current_node instanceof NodeInterface) {
      $nid = $current_node->id();
      return [
          'node' => $nid
      ];
    }
    return [];
  }
}


texts:
I'm using Drupal 7 and Clean theme. And i have got a map. That's javascript codes. I created map field in my content type and want import this javascript in node.

How can i do?


texts: How to create a webform submission table with values from the form itself?

texts:
I find the current webform submission table completely inadequate when forms are submitted by anonymous users - you can't tell one from another other than by its submission date which not helpful in many instances. I would like to create a new webform submission table that can display specific fields from the submission itself to help identify who the submission is from. Ideally if I could accomplish this with views that would be great, but I am not adverse to creating a module if need be. Has anyone done this before and what would be the best approach?

Thanks.


texts: How to calculate margins based on JSON and ONIX (XML) input and calculate points based on them?

texts:
In a Drupal Commerce distribution based on Drupal 7 we sell books. First I want to calculate a margin price based on several given data. The JSON is imported or can be manually added. The ONIX (in fact XML) data is already imported in an earlier stage. In the ONIX data the tags Price, Weight and Publisher are available as variable. When an order is placed I need a rule that combines these data, makes a calculation and present the result after ordercompletion in the dashboard of the admin as a view.

After this I want to calculate how many points the buyer gets based on the order price per item in the order in relation with the previously calculated margin. The point that is earned is an equivalent to a maximum percentage of the price of a book AND cannot be more then the maximum % of the calculated margin.

Is there any way or technique in Drupal to do this?


texts: How to show People menu in Admin for role restricted user?

texts:
Created role "tech support" for help desk to address user account issues.

Granted this role the following privs:

Administration
  Access administration menu

User
  Administer permissions
  Administer users
  View user profiles
  Change own username
  Cancel own user account
  Select method for cancelling own account

The Administration menu does not display for the user - I see the home icon and nothing else.  I did enable clear cache just to see something will display and it does.

Yet if I go to /admin/people, the user with this role can perform the actions I desire.  My issue is simply displaying the People menu item.

Any thoughts/pointers?  This is a production environment, I need to be able to do this without adding new modules to the system.


texts: Is there any performance issues in using Omega theme with Context, Delta and Panels modules?

texts:
Is there any performance issues in using Omega theme with Context/Delta modules and Panels module too? (I mean the context standalone menu, not the one inside panels)

Is there any known issue? I´ve read about some issues with Omega and panels in the past, but now they work just fine.
And I need context for my homepage, to create a slighty different layout than the rest of the site.


texts:
I am using D7, views 3, apache solr views modules. I have created a view with 2 contextual filters for apache solr. I want to view the solr query built using my contextual filters. But the view preview is displaying the text "No query was run".

Is there any way to view the solr query at preview page?


texts: Redirecting to a page based on the sub-domain

texts:
How can I redirect visitors to a specific page based on the sub-domain? For example:

www.site.com goes to frontpage
checklist.site.com goes to checklist.site.com/checklist

My server is set to work with a wildcard (*.site.com). All sub-domains point to the same Drupal site.

I found Redirect based on query string about redirecting in Drupal 8, but I am not able to achieve what I want following what reported there.


texts: "Notice: unserialize() [function.unserialize]: Error at offset 10301 of 11637 bytes on views_db_object->load_row()"

texts:
I use the E-Commerce Kickstart distribution. Almost always I get some error, every time I update and save any view.

Please could anybody tell me what is causing this error, or give me some suggestions?


texts: "Administer Taxonomy" is needed to make a user select a term

texts: I need a user to select a term from a given vocabulary but the field is only available to a normal user if I enable "Administer Taxonomy" for them. Is there a way around this? Shouldn't I be using taxonomy for this?


texts: views Filter field equal to the value of another field

texts: Is there a way or a module to filter a vie by a field against the value of another field. For example uI'd is equal to the  value of another field that's given.


texts: Grouping the nodes based on the taxonomy terms

texts:
A specific taxonomy page should display its description as well as the grouped teasers of the pages with the other taxonomy terms.
For example: An article (Article1) is having 2 taxonomy terms : Accounting, Finance. Another article (Article2) has 2 taxonomy terms: Accounting, Money.

My output when I see the Accounting term page (Example: http://www.myexample.com/group/accounting), the page output will contain the Accounting term description and the grouping of the remaining Taxonomy terms that the articles are linked to.

Finance

Article 1
Article x

Money

Article 2
Article y

I need a little customization here by grouping the articles with the remaining Taxonomy terms. I tried Views with Taxonomy Display and Taxonomy Views Integrator. But, couldn't organize the output.

Is there a way to alter the output of the 3 different taxonomy terms using Views?


texts: How to create sub-directory based multi-site?

texts:
I want to create subdirectory based multisite, for this I roamed full day in internet but nowhere I found how can do the symlink in a proper manner. I will divide my requirement below:

Site name I have is: capacad(accesible by url: localhost:81/capacad/)

I want multisite url should be: localhost:81/capacad/subsite

So to achieve this I created a folder named subsite in C:\xampp\htdocs\capacad\sites\subsite.

Later this step I have to do symlink. So how can I achieve that.

I tried this command: C:\>mklink /d C:\xampp\htdocs\capacad\sites\subsite C:\xampp\htdocs\capacad

This is creating multiple loops inside the subsite folder.

I am not getting the what path names where to link. Can anybody please explain me elaborately how can I achieve this in windows.

Thanks for any suggestions.

I followed some below links:

link1

link2

link3


texts: How to disable PHP files from being run in the sites/default/files directory?

texts: By default does drupal 7's sites/default/files directory disables running of PHP files?


texts:
I want to have multiple roles in my site :
FirstOne is Admin :
 Admin is not super admin (user 1) but Admin can define permission for other users .
Permission is controlled by Super Admin .
i want to show some of the permission options in the admin/people/permissions not all of them for this role.

Any idea ?

Thanks in Advance


texts: having multiple instances of blocks with different settings in D7

texts:
I have activated Multiblock module, create an instance of one custom block.
The admin/structure/block/instances say my new block instance is not 'multiblock enabled'

The doc say
https://www.drupal.org/node/353565

  To get around this, you can make a block "multiblock enabled". To do
  this, you have to first add an $op to your hook_block called
  'mb_enabled'. It should always return the string 'mb_enabled'.

I don't quite get how to do that and I have tried that with no effect

/**
 * Implementation of hook_block().
 * @param string $op one of "list", "view", "save" and "configure"
 * @param integer $delta code to identify the block
 * @param array $edit only for "save" operation
 */
function amu_hal_block($op = 'list', $delta = 0, $edit = array()) {

    // set up an empty array which will contain the block contents
    $block = array();

    switch ($op) {
        case "list":
            // Generate listing of blocks from this module, for the admin/block page
            $block[0]["info"] = t('On This Date');
            break;

        case "view":
            break;

        case "save":
            break;

        case "configure":
            break;

            case 'mb_enabled':
                return 'mb_enabled';
                break;
    }

    return $block;
}

Is hook_block present in D7 at all?


texts: Views: List of recent months containing nodes

texts:
Using Drupal 7, views 7.x-3.0-beta3. I am trying to make a display containing a list of links which direct users to an archive page containing posts of that month (eg. all news messages posted in march 2011).

Tried to solve this with a contextual filter 'Created year + month',
which, when no parameter is given, gives a summary list of links like 'march 2011, december 2010' linking to the URL 'news/201103', 'news/201012'.

Is there a way to change the formatting of that URL to 'news/YYYY/MM' ?


texts:
I wan to migrate taxonomy terms from a D7 install to another.
The taxonomy terms have fields added to them and also translations.
Drupal Migration module would be the only option?


texts: How can I limit filter to child terms of selected parent in Views?

texts:
I have a View that I am using to allow users to search for nodes on my site, all nodes have a category and a subcategory. I have two filters in the View, call these Parent Term filter & Child Term filter.

Example vocabulary:

-Categories
--Category A
---Item 1
---Item 2
---Item 3
--Category B
---Item 1
---Item 2
---Item 3

I want to implement the following functionality:

User selects Category A from list in Parent Term filter.
Child Term filter list populates with only Category A child terms.
User selects Category B from list in Parent Term filter.
Child Term filter list populates with only Category B child terms.

I've looked into Views Dependent modules, but none seem to do this properly. I'd prefer to have something in code (AJAX?) that does this much more efficiently.

At the moment I have the two filters manually limited to parent terms and child terms. However this means the child term filter shows all children irrespective of parent term selected.


texts:
I am new to Drupal. After reading about it and watching some tutorials, I tried to install Drupal 7 on my localhost to see it for myself. But now it is installed, I see no admin toolbar on top of the page. On the place where the toolbar should be I get the following code: $S$DWqdyauf.rdiK9FyIjcO5oZuwyz2HaRQiTO2Ot/5o4YIN8fxcH3u

In the middle of the page it does say 'add more content', so I guess I do have an admin account.

I tried to change the rights via PHPadmin, but sometimes I ended up having no access to the page at all anymore. When I refresh the page I get a different code. It happens in both Chrome and Explore.

What can I do to see a toolbar?

Thank you for your time. Mariska.


texts: Error message "responsive-utilities.less" not found

texts:
I did set-up the sub-theme with less for the Bootstrap theme.
Following is the file structure,

Installed less using(Instruction followed from here),

$ npm install -g less

Then ran a following code to activate less,

$ lessc styles.less styles.css

Then following error shown,

Error message:

FileError: '../bootstrap/less/responsive-utilities.less' wasn't found.

Complete message as below.

FileError: '../bootstrap/less/responsive-utilities.less' wasn't found. Tried - /Applications/MAMP/htdocs/drupal7114/sites/all/themes/lsubtheme/bootstrap/less/responsive-utilities.less,/Applications/MAMP/htdocs/drupal7114/sites/all/themes/lsubtheme/bootstrap/less/responsive-utilities.less,../bootstrap/less/responsive-utilities.less in /Applications/MAMP/htdocs/drupal7114/sites/all/themes/lsubtheme/less/bootstrap.less on line 61, column 1:
60 @import "../bootstrap/less/utilities.less";
61 @import "../bootstrap/less/responsive-utilities.less";
62

What could be the reason for this error? Any idea? Thanks


texts: Drupal Commerce: how to add "Middle name" field to the "Address" pane?

texts:
Currently for "Address" pane (field named "commerce_customer_address") available two options:

1) Name (First name, Last name)
2) Name (single line)

In my country middle name is very important. How to add this as separated field from custom module?

To Rayan: By the way, does it make sense to include this option in the Commerce core?


texts:
Let's say I have a simplest "unformated list" view.

I see that "views-view-unformatted.tpl.php" is outputting $rows in a loop.

When I open my view page on a browser, I see that the following codes are generated by $row.

test1

What template can I edit to remove anchor part?


texts:
I am building a module for Drupal 8 which needs to use hook_node_view(). I tried the following code

<?php

/**
 * @file
 * Demonstrates the possibilities of forms in Drupal 8.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Node;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_form_alter()
 */
function demo_form_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  drupal_set_message(t('Found a form with ID %form_id', array('%form_id' => $form_id)));
}

/**
 * Implements hook_node_view()
 */
function demo_form_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
   drupal_set_message(t('its working'));
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Only alters the Search form 'search_block_form'.
 */
function demo_form_form_search_block_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $form['hello'] = array(
    '#markup' => t('Go ahead, try me ...') . '<br />',
    '#weight' => -1,
  );
}

I can't see any message from demo_form_node_view(). If the hook was correct, it should have shown the message. I am new to Drupal and I can't figure out why it is not working.


texts:
I need help in setting up bootstrap 3 theme with Drupal 6.

With a lot of research I found that we have BootStrap module that supports D7 . Can anyone tell me how I can use Bootstrap in Drupal 6?


texts: Drupal commerce checkout page is not redirecting

texts:
I am working on e-commerce website and using Drupal commerce module. I have created several products and allow authenticated user to view checkout page. Everything was working fine and order was created in site.

Now, I have implemented shipping functionality using Commerce UPS module. I have also installed commerce physical module and created weight and dimension field with content type and update each product with weight and dimension field.

I have also configured commerce ups module in admin with correct username, password and access key.

Now, the problem is that when I am adding address in checkout page and submitting the form, its not redirecting to next step (shipping service).

I have checked in google and drupal.org and issue queue of module but did not find any solution.

I have no idea that I am facing this issue due to some wrong configuration of module or this is issue with shipping or commerce ups module.

Thanks in advance.

Edit:

After perform R&D, I found that $form_state contains $form_state['rebuild'] => TRUE in commerce_checkout_form_validate() function, but I am not getting any error in form.

Please suggest, if you have any solution.


texts:
I have a simple jquery slider for the homepage of a website, which works in my static HTML/CSS layouts.

I want to incorporate this front-end mark-up into a block module that will allow an admin to add/edit/remove slides. Is there a good module that already does this that I could hack with to get this functionality. Or even better does anyone know a good tutorial (doesn't have to be for a slider), that shows developing a module where you can add/edit multiple items specific to that block module (separate to the main content); in my case it would be adding/editing slide items to the slider.


texts: How to get the $form_state in hook form submit?

texts:
I need to create a node when a comment is submitted in nodes. There are two content types image and memory and I need to get node ID of the node that a user is inserting comment in it.

Here is my code

function THEME_form_submit(&$form_state, $form_id){
    if($form_id == "comment_node_memory_form" || $form_id == "comment_node_image_form"){
        kpr($form_state);
        //Insert new node
    }
}

Clearly this code won't display the $form_state but I need to some how get the node ID and the ID of the user who inserting the comment. I guess these information are in $form_state but I really have no idea how to get them.

Thanks


texts: After calling drupal_flush_all_caches, menu items with access callback TRUE are giving access denied error

texts:
I was building a custom module that affected the front page and I found myself having to go clear the caches for it to take effect. So as part of the code, I put in drupal_flush_all_caches().

After I ran the page, my website had all sorts of issues. It seems like any menu item with 'access callback' => TRUE, is getting access denied errors for any user. These items were working fine before the cache clearing.

Current versions (yes I know I need to upgrade)

Drupal: 6.38
PHP version: 5.6.38
Server: Red Hat Enterprise Linux Server 7.5 x86_64

PHP ini values:

session.cookie_httponly Off
session.use_only_cookies    On
session.cookie_secure   Off
session.hash_function   0
session.cookie_domain   .example.com

Things I have done:

Checked users table for uid of 0 - exists with status of 1, has role of anonymous user, has permission of access content
Repaired database tables
Clear browser cache
Clear drupal cache (/devel/cache/clear)
Rebuild menu (/devel/menu/reset)
Clear db sessions table

Please let me know if you need additional information. Thank you.


texts: Content Type vs. Taxonomy | Example TV Series

texts:
As this is my first post here I don't know if I do everything right. Please forgive me.

So, my plan is to build a website with many categories and these than contain posts. To explain the stuff in the easiest way I decided to use Series and Episodes.

Serie A:

Episode 1
Episode 2
Episode 3

Serie B:

Episode 1

For my use I also want to be able to decide what exactly an episode is. For example is it an normal one or just a 20 minute special and should be displayed like this:

Serie A:

Author:
Year:
(more stuff here)
Episodes: (Headline)

E1 (Link to this Episode)
E2 (Link to this Episode)

Special Episodes: (Headline)

E1 (Link again)
E2 (Link again)

The problem here is that I don't know if I should create this with Content Types or Taxonomy.

A) So one Content Type for Serie and another one for Episodes. Both with the needed fields. But the problem is here I don't know how to join/connect them properly.

B) Creating a Taxonomy called "Series" and adding all Series into it. Than a Content Type "Episodes" with setting a Tag to connect the Episode to the right Series. The problem I could get here is for example when adding something like genre. A Taxonomy would get a list of Genres like Action, Comedy and so on.

Another point would be accessibility. It should be possible to search for Series include/exclude genres and also searching for fields like year, episode-count of a series.

At last is it possible to create Custom Types where for example a javascript is loaded in the background that parses text from a input text area?

I hope you understand my goal with this example and can tell me the proper way. Thanks for everything.


texts:
I realize the title of the post probably made everyone roll their eyes...but bear with me...please.

I need some very advanced user management where some users can be assigned as the admin of a group that can add users to that group, make sub groups and assign admins to it to add users...all the users need to have permissions to add edit and view some info that will be part of a large module I am creating...but unique to each user/subuser.

I think Organic groups, but I don't need, or want the content management/viewing aspects, just strictly user management and permissions, but permissions being restricted only to allowed permissions within my specific module...not system wide permissions...

I am looking for a slimmer solution than Organic groups, if possible.

Thoughts? Thanks for any input.


texts: Add lightbox to product list in Ubercart

texts: I'm trying to enable lightbox2 for product listings in Ubercart for Drupal 6. This is simple via views, but I think the product list is being generated by uc_catalog module. How can I add classes to the product thumbnails or enable lightbox2 for them? Are tpl.php files available to customize output? Thanks for any help.


texts:
I am looking to create a QUESTIONS view for all terms in a taxonomy vocabulary. Let's say I have a taxonomy that has terms apple, orange, banana. We use pathauto to go to domain.com/apple which shows one content type.

But what I am trying to do is create a sub page for each term with the path:
domain.com/apple/questions

I have already set the view and added a contextual filter but for some reason, its is not working.

The path that I have for the view is (/taxonomy/term/%/questions)

Is this correct? Am I approaching this the right way? If you have a better suggestion please let me know.


texts: Duplicated results using fields from relation File Usage: file

texts:
I have a content type with a field image and a field file. I made a simple view to get all items of that content. I included in my view a relation ¨File Usage: File¨ to get some data like file size, upload date and uri of file field and for using VBO to download all files.

Now Im getting duplicate results, all data (file size, upload date, vbo) for image field and the same for file field when I just want to get the information for the file field, the image is just a thumbnail. Any ideas of how to get real results over duplicates?


texts: Database not writing while statement returns TRUE

texts:
public function verify() {
    $uid = \Drupal::currentUser()->id();
    $user = \Drupal\user\Entity\User::load($uid);
    $username = $user->get('name')->value;
    $update = 1;
    $verify = 0;

    $mysql = new addressverify_MySql();
    $datestamp = $mysql -> pushVerificationDate($username, $update, $verify);

    if ($datestamp === TRUE) {
        return 'success';
    }
    // All else fails, no record
    return FALSE;
 } }

class addressverify_MySql {

public /*void*/ function pushVerificationDate(/*string*/ $username, /*bool*/ $verify, /*bool*/ $update) {

    $insert = \Drupal::database()->insert('du_addressverify_verification')
     ->fields([
        'username' => $username,
        'datestamp' => now(),
        'verified' => $verify,
        'updated' => $update,
     ])
     ->execute();

    if (is_numeric($insert))
    {
        return TRUE;
    }
    else{
        return FALSE;
    }

As written, this code returns true, however, does not write to the database.   If I comment out the if statement in pushVerificationDate(), it returns false but writes to the database.   I'm at a loss for how to proceed with this to return true AND write to the database. I have a feeling it's something silly that I'm missing, but can't seem to find it.  Any input would be helpful!


texts: How do I push module update in a cached production environment?

texts:
I don't manage to update Flag module in remote server, while it worked like a charm on local environment. The stage site is cached with Zend opcache, Apcu, Varnish and Redis. I suspected Opcache was faultier but no way to get it work.

The steps I did (local dev) :

drush up flag -y
drush cc all. Tested flag features, OK.
Commited & pushed files to stage on a flag branch

The steps then on remote server :

git checkout flag
Reset Opcache various times (thanks to this great Opcache GUI)
Saved database
Ran update.php, which returned

flag module
7300 - Rebuild the class registry due to classes moving files.
7301 - Rename {flag_content} table to {flagging} and {flags} table to {flag}.
7302 - Rename database columns on the {flag} table.
7303 - Rename database columns on the {flagging} table.
7304 - Rename database columns on the {flag_counts} table.
7305 - Convert flag roles to permissions.
7306 - Convert flag view modes settings.

Ran Apply pending updates, which retunred An unrecoverable error has occurred, Ajax error, http status 200, followed by 4 notices. These notices are known, but caused no update crash on local site.
if I go to the "error page", I'm sent back to Review updates page.

If I try to visit dblog, I have this fatal php error : Class 'flag_flag' not found in profiles/commons/modules/contrib/flag/flag.module on line 1948. But if I check the remote files, I can find that class in profiles/commons/modules/contrib/flag/includes/flag/flag_flag.inc .

I invalidated that file namely in Opcache and invalidate full Opcache. I also checked in varnish.vcl that update.php is in the list of bypassed URL.

Then after a while, Varnish finds backend server is not responding and boom : Error 503 Backend fetch failed, ending restarting php5-fpm...

To be honest, I understand about nothing anymore, "eating my hat" or "banging my head" or how would you say that ? Help really welcome !


texts: While migrating D6 to D7, should sites folder be replaced?

texts:
I am trying to migrate Drupal 6.29 to 7.22. Part of migration I have deleted all files & directories except sites in D6 site. Now I downloaded Drupal 7.22. D7 version also has sites folder, so do I need to replace sites folder or not?
In documentation I read like while copying the sites folder which files need automatically will be replaced, when I am copying sites it is asking for replace or not. Totally confused, can anyone help on this, it would be greatly appreciated!


texts:
I think this may be related to using "tokens" when developing a module, but I am seeing this:

'og:updated_time' => array('value' => '[node:changed:custom:c]'),

The question I have is about:  [node:changed:custom:c]

What is this? What is it even called?

In my particular case, I am adjusting a module to retrieve a new value from a custom field.

'og:image' => array('value' => '[node:field_social_image]')

I have successfully used this for other custom fields, using the exact same syntax, but this one does not work.


texts: Facebook Share the older version of the article

texts:
I using facebook share to share my article to facebook.

Sometimes I edit my article title and image.

While I share it to facebook, the article title and image is still shows the older version of the article.

Anyway to fix this problem?


texts: In Views, do filter criteria override context filters for the same field?

texts:
And can I do something about it?

I have a view that filters by date and exposes that filter to the user. I would like to be able to pass it in via the URL as well.

The accepted answer to this question seems to indicate that this is not possible. True or not?

I could not find any docs on that question. Are there any?


texts: Menu unserialized warning when using autocomplete in a custom module

texts:
I am working on creating a form with Autocomplete feature for the text field. This is the code I have so far..

    /**
     * Implementation of hook_menu()
     */
    function suggest_feature_menu() {
      $item['suggest_feature/autocomplete'] = array(
        'page callback' => '_suggest_feature_autocomplete',
        'access arguments' => user_access('access example autocomplete'),
        'type' => MENU_CALLBACK
        );

        return $item;
      }

    /**
     * Implementation of autocomplete
     */

 function suggest_feature_autocomplete($string){

    $query = db_select('node', 'n')
    ->fields('n', array('nid', 'title'))
    ->condition('status', 1) //Published.
    ->condition('type', array('e_hood', 'oranization'))
    ->condition('n.title','%'.db_like($string) . '%', 'LIKE')
    ->orderBy('created', 'DESC') //Most recent first.
    ->range(0,10)
    ->execute();

    $items = array();

    foreach ($query as $node){
       $items[$node->nid] = check_plain($node->title);
    }

    return drupal_json_output($items);

  }

    /**
     * Implementation of hook_form()
     */

    function suggest_feature_form($form_state) {
     $form = array();

       $form['test_item'] = array(
        '#type' => 'textfield',
        '#autocomplete_path' => 'suggest_feature/autocomplete'
        );

      return $form;
    }

all my functionality works but i get a warning which says

  Warning: Invalid argument supplied for foreach() in menu_unserialize()
  (line 393 of C:\xampp\htdocs\drupal7\includes\menu.inc).

Please let me know how to solve this. Is this an issue with my code ? Also I use superfish menu's in my drupal. Is this related ?


texts: Dialog form submit button fails to trigger submitForm()

texts:
I load this form into a dialog using:
$content = \Drupal::formBuilder()->getForm('Drupal\web_core\Form\MyForm');
$response = new AjaxResponse();
$response->addCommand(new OpenDialogCommand($title,$content));

And the form is properly rendered inside the dialog. Problem is that when I click the submit button my submitForm() isn't called. None of the tasks inside the function are performed. Even a dpm() shows nothing. And the redirect after submit doesn't work either.
Here's The actual form
class MyForm extends FormBase {
...
public function buildForm(...) {
...
$form['action']['submit'] = [
  '#type => 'submit',
  '#value => t('Select'),
];

public function submitForm(array &$form, FormStateInterface $form_state) {
  dpm('Inside form' );
  \Drupal::entityTypeManager()->getStorage('my_app')->load(1)->delete();

$form_state->setRedirectUrl($url);
}
}
}

None of the things inside the submitForm() runs. This form submits normally when outside a dialog. Pls What could be wrong here?


texts: How to make a custom page.tpl.php file for a views page?

texts:
I have made two pages, one for my sites Terms of Service and a second for a secondary add content page. I made both in views with a custom text field. I would like to have a custom page.tpl.php file for these pages so they can better match my theme. How would I do this? Also, If anyone has a better way for me to make a TOS page, I would appreciate the insight. I will be making  a page describing my privacy policy as well as few other things and I want to make sure Im doing this in the most efficient way.
Thanks.


texts: Is there a performance hit to using persistant variables?

texts:
While working on some old custom code I noticed that variable_set() was being used in a manner that always made new key pair values and never made a call to variable_del. These values would be read once under a certain condition and never read again.

Are persistant variables something that get cleared on clear cache or are they always building up?

if they are building up does this affect the size or speed of page load?

example:

variable_set('key_name_' . $increment, $value);


texts: Issues with Composer at module dependencies

texts:
The Currency module requires Composer dependencies. I am trying to install it with the following command:

composer.phar require drupal/currency

It returns the following error.

  [InvalidArgumentException]
  Could not find package drupal/currency at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

What am I doing wrong?

Furthermore, if I specify the version of currency with composer.phar require drupal/currency:8.x-3.1, I get this error:

  [UnexpectedValueException]
  Could not parse version constraint 8.x-3.1: Invalid version string "8.x-3.1"

Anything is going wrong and I don't know what. The file composer.json and composer.phar are both in root directory of the Drupal installation.


texts:
<?php

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_alter()
 */
function mymodule_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'search_form') {

     $form['#attached']['library'][] = 'mymodule/mylibrary';

  }

}

Doing a dpm($form) on the search form, I see it has the my attached library, so what gives?

Solution:

The above code works fine, turns out it was my js code, I had copied over from another js file and it had an if statement that somehow I missed (it was 4 am). Credit @Alexei Rayu


texts: Migrating into custom node type with multi value field

texts:
I'm doing a migration into D8, and I'm migrating into a custom video player field with multiple values. Here's the schema for the field as defined in its plugin:

  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    return array(
      'columns' => array(
        'vid' => array(
          'type' => 'int',
          'size' => 'normal',
          'not null' => TRUE,
          'default' => 0,
        ),
        'video' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'video_hd' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'video_sm' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'thumbnail' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'poster' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
        'show_ads' => array(
          'type' => 'int',
          'size' => 'tiny',
          'not null' => TRUE,
          'default' => '1',
        ),
        'raw_file' => array(
          'type' => 'varchar',
          'length' => 256,
          'not null' => FALSE,
        ),
      ),
    );
  }

I have a custom source plugin that gathers all of the information needed for these columns into appropriately named items. My question is, how do I get those pieces of data into the destination field. Can I do it in the .yml file configuration, as can be done with the body field?

  'body/format':
    plugin: migration
    migration: d6_filter_format
    source: format
  'body/value': node_body
  'body/summary': teaser

Or do I need to have a custom destination plugin that takes these pieces of data and puts them into the correct places in the node? I'm seeing a lot of blogs and documentation on source and process plugins, but not much on destination plugins, so I'm not sure.

Thanks.


texts: Using Drupal Bootstrap, I want the 'title' of my parent menu item to be a glyphicon and to drop to the search bar!

texts:
I am having 2 issues with Drupal Bootstrap, I have no idea how to set a leaf specifically in the menu to not only be a glyph of a search icon, but also how to add the search block to the dropdown.

I am going to probably stop using the main-menu and just add a few regions for it!


texts: Assign license to specified user B when successful checkout by user A

texts:
I want users on my site to be able to buy a file download for other users and anonymous users. I have added line item fields to the checkout form so the current user can specify the email address of the recipient of the purchased file.

How do I grant license to the file paid for to the recipient based on the supplied email address? I tried to use rules, but I did not see any rules action that could issue license to the recipient user or email.


texts: How to preserve form values for user who navigates out of form and back?

texts:
I have a form that works, essentially, as a search / filter:

 foreach($search_properties as $property) {
    $form['properties'][$property->idProperty] = array(
      '#title' => $property->Label,
      '#ajax' => array(
        'callback' => 'mymodule_filter_ajax',
        'wrapper' => 'category-filter-result',
        'method' => 'replace',
        'effect' => 'fade',
      )
    );
    switch ($property->PropertyType) {

Options are generated by taking only actually used values from possible ones:

  '#options' => array_intersect_key($possible_choices, $used_values),
  '#default_value' => array_keys($used_values),

Nothing interesting here, really, just set of fields that, on change, reloads a list of links using AJAX. Never submitted, never saved.

Problem is - when user clicks on a link, and then clicks browser's "back", all fields have their defaults selected again.

I'm under impression that it was not the case with Views exposed filters. I think I remember these filters was able to keep values when user went back to them. So it is possible.

What is the Drupal way to keep user-selected values in the simple scenario of a link click, and then browser's "back" button?


texts: Redirect node/id to node/path-auto-alias

texts:
Using Drupal 8

I need to set various links between my content types and so far I'm setting the link using their path-auto-generated-alias, but that's terrible practice because if I change the pattern one day I will have to change every single existance of the out of date url alias.

I've seen plenty of answers for Drupal 7 with module Global Redirect but it states that it's deprecated for Drupal 8 and to use Redirect instead. I installed the module and I'm presented with this:

I have no idea what's amitted in there, tokens? If someone could direct me to a documentation where I can learn to use the module I'd really appreciate it since I'm at a loss.

The reason why I'm in that part is because I have the following Global Settings and it's not redirecting /node/id to expected Path Auto URL alias.


texts: Can I control which database Drupal uses for certain data?

texts:
It is of course possible in a custom modules to use two different databases (and I mean different databases not different RDBMSs!), but is there a way to use two different databases, and then force Drupal to keep certain data in one and other data in the other?

For instance, keep nodes (and closely related tables) in one, and all site configuration in another.  (Perhaps, while sorting it out, it might be useful to have a third as the default.  That way everything that's not sorted into either the content or the configuration database would remain in the default until you decided where it best fit.)

How can this be done, without major hacking of Drupal's core?


texts: How can I get a GMap Marker field to be a target in my Feeds importer?

texts:
I have site that needs to import a CSV of hundreds of locations to be displayed on a GMap. I have set up an importer in the Feeds module that successfully imports a CSV containing Title, address, longitude and latitude. The properties all appear on my GMap view correctly.

Now, I would also like to assign different colored markers for various location types that I am importing. I have my content type properly set up with a GMap Marker Field (if I manually assign a Marker to each node they appear with the correct markers on my map view). However, on my Feed importer Mapping page, the GMap Marker field is not appearing as a target option in the dropdown list.

How can I get the GMap Marker field to appear as a target option in the feeds importer?


texts: Rule to check specific field of content every week

texts:
I have a content type called change_note, and within that I have a field called action, action_owner, a field called action_date, and one called action status. What I am trying to do, is get the site to check if the action status = pending, and if true send an email to the person listed in action owner.

I can work out how to do this if it is based on someone saving the content (using the rules module in drupal 7) but I can't see how you do it based on just a specific schedule. I've looked at the schedule module also, but am struggling to see how to do it in that.


texts: view's query "was not run" while getting results

texts:
I'm working with drupal 7 and views module (7.x-3.11 version) and I'm getting a strange problem.

In the Views admin, when I run the query, I get a message no query was run while I actually get expected results. Moreover, if I add a filter criteria and run the query, the results are affected by this new criteria while I still get no query run message.

Secondly, I have created a custom module to use views_query_alter to modify view's queries. It never comes into the function on this particular view while it does for other views.

So, to summary, I have a no query was run message and nothing is passing by the hook_views_query_alter but query is run somewhere because I get some results and it is sensitive to filter criteria changes.

I really need to find this query and to override but I just can't find it.

Do you have any idea of what's going on here?


texts: Taxonomy term: "The requested page "xx" could not be found."

texts:
In a taxonomy vocabulary, I have terms such as: groups/arts (parent level.)

The URL alias of the term is set as groups/arts (Organic Groups.)

But when I want to access the page www.example.com/groups/arts, I get a "The requested page "/groups/arts" could not be found" error message. This is true regardless of pathauto being enabled or not.

If instead of writing the url I click on the view tab of the taxonomy term edit page (which should bring me to the page) I am sent instead to the root directory (www.example.com)

This issue started after I began using the default view provided for taxonomy. I used the view for for a different vocabulary that works well (the terms have their own pages that show.) However, if I disable the view then I get the same no page found result.

Is it possible that the taxonomy view messed up? Or can one not use it twice on the same site for different vocabularies?

Any pointer on those issues greatly appreciated. Thanks. :)

Any idea on how to fix this? Is it a .htaccess file issue? If I knew where to start looking that would already be a big help. Thank you. :)


texts:
I'm implementing a site where users pay for submissions and reviewers get paid. Drupal Commerce with Commerce Credits allows me to buy credits using Paypal and to pay on site with credits for submitting content.

Reviewers receive credits for performing the review, when they reach a certain amount I want them to offer the possibility to withdraw credits through Paypal.

I had a look at modules like Commerce Funds (broken) and Commerce-Marketplace (withdrawal not implemented yet) and Paypal Adaptive Payments (not public anymore), did I miss anything?

Is there anything I can do to automatize this process with rules? I could transfer credits to a withdrawal user account and manually make the transaction with Paypal. Any hints how to automatize this process and trigger a Paypal payment to users credit card?


texts: Is inheritance between content types possible?

texts:
I just read Should I use a seperate content type?, and it's got me thinking.

Say I had a site with twenty-five content types, with some of the content types sharing enough of the features of some of the other content types to make some kind of "inheritance" worthwhile: I'm thinking in terms of object-oriented PHP here. Is content type inheritance possible in Drupal 6? Is it possible in Drupal 7? Or 8? Could a module be written to make it possible?


texts: How to reduce options for units of measurement to just miles and km for proximity search

texts:
Using geofield with Views and exposed filters to the user to search for things on the map within a certain radius of a particular location.

I only require miles and kilometres as units of measurement, not: Yards, Feet, Nautical Miles. Any way to omit these?

They are defined in the module geofield's file, geofield.elements.inc code:

/**
 * Returns options for radius of the Earth.
 */

function geofield_radius_options() {
  return array(
    GEOFIELD_KILOMETERS => t('Kilometers'),
    GEOFIELD_METERS => t('Meters'),
    GEOFIELD_MILES => t('Miles'),
    GEOFIELD_YARDS => t('Yards'),
    GEOFIELD_FEET => t('Feet'),
    GEOFIELD_NAUTICAL_MILES => t('Nautical Miles'),
  );
}

But I don't want to hack this and remove them.

The approach I am expecting to use would be to implement hook_form_alter in my own module and remove the options from there.

But is there a better way?


texts: Webform Tokens lets me access form meta-info but not user-submitted values (with Fill PDF)

texts:
I'm attempting to use the Fill PDF module to populate an editable pdf. The data source is a Drupal Webform submission. I'm specifying those values to Fill PDF using tokens from the Webform Tokens module.  I have also tried this using Webform's tokens made available to Fill PDF via the Webform Rules module, which does not work at all (no PDF is generated).

With the Webform Tokens module I have partial success: I can get a PDF to fill in with non-user-submitted values from the webform (such as the submission ID and the webform component label) but user-submitted values always end up blank. For example:

I enter the following into the Value field of the PDF-Field key in /admin/structure/fillpdf/[form ID]/edit/[pdfkeyname]:

The SID of this submission is [webform:meta-sid].
The value of the form component titled [webform:meta-label-textmetest]
is [webform:val-textmetest].`

For the submission in question the value of the textmetest field is "glasstest."

I go back to /fillpdf?fid=53&webform[nid]=4&webform[sid]=10 and it now reads

The SID of this submission is 10.
The value of the form component titled textmetest
is  .

Thus, the [webform:meta-sid] and [webform:meta-label-textmetest] tokens are being replaced, but not the token [webform:val-textmetest].

I have confirmed that the webform's ID is indeed 4, the SID is 10, the value of textmetest for SID 10 is glasstest, and the form ID for the pdf is 53.

I know that it is trying to access a specific submission, because if I use a nonexistent SID in the URL (e.g., /fillpdf?fid=53&webform[nid]=4&webform[sid]=99) the field reads: The SID of this submission is . The value of the form component titled  is  . , i.e. the SID and title don't populate for a nonexistent submission. However, I can't get at the values for any specific submission.

If I try Webform Rules enabled instead, instead using the tokens [webform:sid], [webform:textmetest-value], and [webform:textmetest-title], which are the corresponding tokens that Webform Rules exposes to Fill PDF, it does not even generate a PDF; I get a 500 internal server error.

Does anyone have any suggestions, either for how to make this work or for another way to get at webform values?


texts: Prevent Drupal from Caching API Responses

texts:
I am not sure this is even supposed to happen, but it looks like Drupal is caching REST API responses. I have created a module that makes certain data available through the REST API, and changing the value in the DB requires clearing the cache for it to be reflected immediately in the API response.

Is there a way to prevent Drupal from doing this? The idea behind my API responses is that they are supposed to return real-time data. Currently I'm talking about the user.data service (users_data table), but an answer for any arbitrary data would be appreciated.

A specific random example of what retrieving the data looks like:

$user_data = \Drupal::service('user.data')->get('my_module', $id);

It looks like the cache I want to avoid is stored in cache_dynamic_page_cache.

EDIT: The simplest API response in this case (in the get() method) is:

return new ResourceResponse($user_data);


texts: Which is the most performant way of overriding views field output

texts:
This question sureley can only be answered by people with some drupal experience.
As I have quite different and complex views, which I need to control totally, I need to come to a design decision. Which way has the highest performance putting out view content?

Define the fields in the Views UI, don't output them and use them in custom text? Like described here: http://highrockmedia.com/blog/rewriting-drupal-views-output-custom-theming-css
Provide a views-view-field--field-machine-name-of-field.tpl, get the $row['_field_data']['nid']['entity']->{'field_machine_name'} and iterate over its contents?
Another or better way of which I'm not aware off?

Example, of how a result could look like:

  Dell UltraSharp 30" LCD Monitor

    87
    out of 100
    based on 24 user ratings

    $1250
    to $1495
    from 8 sellers
  Sellers:

     Save A Lot Monitors - $1250

    Jon Doe's Gadgets - $1350


texts: Adding a 'Add New Listing' (Create Content) Link on Local Tasks Menu

texts:
I am working on making user pages for a certain type of user who can add/edit/delete content on my Drupal site. I've figured out how to use Views to create a 'Manage Listings' tab which appears on the user's profile, now I need to make another Local Task tab (or any kind of link) that allows the user to add new content.

I tried just adding a header to the view using basic markup text that contains:

Add New Listing

But because the link is displayed from the 'users/admin/' page, the link ends up bringing them to 'users/admin/node/add/' which doesn't exists (obviously). How can I create a create content link without messing up the path?

I would provide a screenshot, but my reputation isn't high enough to do so. Thanks.


texts:
There are 50+ categories on my site,i want each category to achieve this effect:One row ,4 products.

I do not clone views one by one.
Anyone can help me? THX

Note:I use drupal 7.


texts:
How can I add create a multi-part email in D7?  I need to add custom part to an email.

I am trying to use hook_mail_alter to append a new content type.  The content type is Content-Type: text/calendar.  I can't figure out where to add it in the $message array.

I have tried mimemail but it seems to disregard my SMTP settings.


texts:
I want to create multiple nodes from one page where I input one or two values into each entity, where each of the entities has a reference.

Example:
If I had three kids, I would measure their height each week, entity types "kid" and "height". Height references to kid and instead of click add "height" three times and select which kid then input height, I would like to have a page with the names (or ID) of the kids, then one input field for each, so that when I save, three entities of height are created with the values specified.


texts:
I have a paragraph that has a field of type paragraph reference to sub-paragraphs.

Within my template, I need to access these sub-paragraphs and render the entity element. I have a loop that loops through a list of Drupal\paragraphs\Entity\Paragraph elements.

I need to render the paragraph markup.
Is there a function?

I tried item|render and item.view(), but neither of them worked.


texts: After 10 webforms have been added. How could we creat a HTML report to list all items inside drupal ?


texts: Explain field's language opposed to node language

texts:
I'm having a hard time understanding how it supposed to work.

For example I have a node where I set up the language to English. the langcode is en. If I want to read values from a field from this node I will have to do something like:

$node->field_custom[LANGUAGE_NONE][0]["value"]

and not

$node->field_custom[$node->language][0]["value"]

What is the point of having LANGUAGE_NONE for all fields if on all nodes this is the same, no matter what language the node has. Thanks.


texts: How to embed image field url in API response?

texts:
I have a content type that has a title, body, link, and image field.
Then in my php file I have the following:
$articles = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'expand_your_world', 'status' => 1]);

When I check the articles variable in a JSON response, I only see the title, body, and link.
I then concluded that probably the reason why the image is not included, is because it is a reference field.
My get method looks like this:
$articles = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'expand_your_world', 'status' => 1]);

$main_content = [];

foreach($articles as $article) {
    $fields = [
        'title' => $article->title[0]->value,
        'body' => $article->body[0]->value,
        'field_expand_link' => $article->field_expand_link[0]->uri,
        'field_expand_icon' => '',
    ];

    array_push($main_content, $fields);

}

$response = [
    'content' => $articles,

];

How do I embed the image URL in the response?


texts: Webform Error Occurs During Configuration Import

texts:
Currently we are having some trouble handling webform module configuration on our various environments.

When running a configuration import drupal config:import --directory=$SYNC_DIR on our dev environments with a fresh database from production we receive the following error:

[ERROR] An error occurred while trying to write the config file: "Entities exist of type Webform submission and Webform Borough Newsletter. These entities need to be deleted before importing."

This particular web form (Borough Newsletter) has not been exported as config from production and has no associated yaml file, additionally it has some submissions in the database.  When we remove all submissions of this particular webform the import completes, but removes any webforms not stored as config (no surprise there).  We also tried to use the Config Ignore to prevent webforms from importing configuration, but we still got the above error.  I have three main questions:

Our webforms are created on production by non-developers.  Is the proper workflow to start exporting webform config from prod and bring it to our dev environments top down?
What exactly was the cause of the error we got during import (mentioned above)?
How come we still get an import error when we explicitly attempted to block any webform config from being imported? Was it due to a dependency on webforms from some other configuration item?

Webform Module Version: 8.x-5.3

Drupal Core Version: 8.6.17

Thank you in advance!


texts: What is the proper permission settings to create a moderated, private organic group (in commons 3)?

texts:
I'm trying to create a private group in Drupal Commons. It is my assumption that one follows open, public groups.

However, I've marked a few groups as private using the default roles and permissions. I anticipated seeing a Register option for that group.

I guess I'm trying to create a moderated group where the user is approved by the group owner. How does this happen?

I'm also seeing that Commons Groups may be interfering with the group permissions by graying out the Member subscribe only with the approval option (drupal ticket link).

In the group field settings, I have the following fields attached to groups and content types.

The group settings for one example group I wish to make private are the following.

However, while masquerading as authenticated user, I still see the Follow button. I would expect to see a Register for this group option.


texts: Is there a way to bulk upload into the Media module? What I'm trying to do is get a huge batch of images into the media Library browser. It seems like you have to first establish the image as an entity in the D7, so most of these bulk methods using something like rsync of scp wont work.


texts: Why in node.tpl.php $content is different from $node?

texts:
I'm creating a custom template file for a specific content type.
I'm printing most of values with

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

As some of them didn't show up and they are not empty I tried

dpm($content);

Indeed they aren't in the array printed, but if try

$node = node_load($node->nid, NULL, TRUE);
dpm($node->field_blabla['und'][0]['value']);

I can see the value!

What's the problem? Why are they missing?

Thanks


texts:
I am trying to create a list of shops using views as a html list and also as shop icons in a ipgeoloc map. Both these views will need to use post code taxonomy as its exposed filter field, I am having issue in getting the views attachments working. For me at a time only geolocation map is working or the html list is working. I am unable to get both of them working at the same time, I have attached the view correctly and have picked inherit filters for attachments

Like to get some guidance how this can be done, thanks in advance

Cheers
Vignesh


texts: Comment styling dependent on author's user roles

texts: I want to style comments differently depending of the author's user roles. How can i add a specific class attribute in the comment template if the author of the comment has a certain role?


texts:
So I have a custom module function that checks a cart order for a certain product type

global $user;
$order = commerce_cart_order_load($user->uid);
$wrapper = entity_metadata_wrapper('commerce_order', $order);

foreach ($wrapper->commerce_line_items as $delta => $line_item_wrapper) {
  $type = $line_item_wrapper->commerce_product->value()->type;
  if($type=='X'){
    //go mental
  }
}

This is used within checkout to display certain list items for "checkout progress" depending on whether a product type is in the cart (i.e show the gift aid stage if there is a donation).

The issue with this is it seems that when the order is no longer within the cart, for example when we hit the payment stage, and further go on to checkout complete. So the function commerce_cart_order_load($user->uid); no longer works. How would I achieve this same functionality checking the order for product of type 'X' when the order status is updated post-shopping-cart?

I think I can use $order = commerce_order_load(); but somehow I need to get the $order_id?


texts: Why does my Quiz rule stop working after adding an extra user profile condition?

texts:
I have a Drupal 7 site, that uses Rules and Quiz.
I have a rule that adds a role after the user takes a specific quiz, which
work fine. Here are the details of it:

Event

After updating existing content
Conditions

Content is of type

Parameter: Contenido: [node], Content types: Cuestionario

Data comparison

Parameter: Data to compare: [node:nid], Data value: 1985
Actions

Add user role

Parameter: Usuario: [site:current-user], Roles: nivel2

Now I want a similar rule but add the new role only if a specific profile field in the user's profile, has specific content. The field is a selection of certain terms of a certain taxonomy.

So, I've cloned the above (working) rule, and added to it a condition. So that this new rule looks like so:

Event

After updating existing content
Conditions

Data comparison

Parameter: Data to compare: [site:current-user:profile-profile:field-ubicacion, Data value: Provincia de Chaco

Content is of type

Parameter: Contenido: [node], Content types: Cuestionario

Data comparison

Parameter: Data to compare: [node:nid], Data value: 1985
Actions

Add user role

Parameter: Usuario: [site:current-user], Roles: nivel2

Now in this case, this new rule won't work. I.e the role is not added.

Why could this be?


texts:
I want to add some fields (programmatically from my module) to the content_type "Article".

Is that possible ?


texts: How to define alias dependent Drush extensions?

texts:
I have a stage and an anonymized instance of a project both managed under the same user (www-data). The anonymized instance is taken from production instance and has a drush extension that can have a different version than the stage instance.

With one instance per user I can simply symlink the extension to the ~/.drush folder, but how would I do that with two different versions of the same extensions? Is there a way to define alias dependent extensions in Drush? If Drush does not support this, what would be a good OS work around?


texts: How to get the url from a link field in preprocess function

texts:
I have a content type event.
It has a link field field_event_location_link
Both the link text and url are optional

By default Drupal uses the url as the title if there is no title typed in.

I want to show 'Location' if the title is not filled in.

How can I use a preprocess function to see if there is a title, and if not, use my string.

I tried ...

function my_module_preprocess_field(&$variables) {
  if ($variables['field_name'] == 'field_event_location_link') {
    if ($variables['items'][0]['content']['#title'] == '') {
     $variables['items'][0]['content']['#title'] = 'Location';
    }
  }
}

But it doesn't work and I think it's because by the time I get to that point, Drupal has already used the uri for the #title.

Question:
Can I catch it before that?
Or can I get a variable for the URL and use that variable in the '' above? Should I be checking if something is empty...?


texts:
Is it possible to Delete the user and keep its content as created by the one who deleted the user.

Suppose, abc is a user as content creator/editor only and have created 2 contents.

abc got fired as editor and his boss xyz wants to delete his user account.

xyz not only wants to delete abc but while deleting abc transfer all the content created by abc to his name, so that it'd be like created by xyz.

Drupal has only 4 options while deleting user account which doesn't satisfy this need.

If it is possible then how? please elaborate how to achieve that....


texts: Can't add a new field of type entity reference!

texts:
Other field types can be added, but only a field of type "Entity Reference" can't be added.

I am getting a status message "Die Einstellungen wurden gespeichert."(Configuration has been saved), but it should redirect me to the manage field of the content type in which I am adding the content type.

Can someone please help me with this?