texts: I'm fairly new to Drupal and have this task to create an about us page. Now every customer has two certain co-workers assigned to him. This information is stored in the database. I want to show the two co-workers depending on the customer that is signed in. Someone said that I need to create a custom content type, but i couldn't find anything about it online. What would be the best approach to this problem?


texts: View with multiple value fields: suppress display of repeated column values

texts:
My content type has two fields: field_title and field_related. The field_related is of type Entity Reference and its cardinality is set to unlimited.

The view should display the title, updated date and all related titles, in tabular form, like this:

Title          Updated      Related
=====================================
Chapter 1      2014-01-01   Note A
                            Note B
                            Note C
Chapter 2      2014-02-02   Note A
                            Note B

Currently, it is displaying this:

Title          Updated      Related
=====================================
Chapter 1      2014-01-01   Note A
Chapter 1      2014-01-01   Note B
Chapter 1      2014-01-01   Note C
Chapter 2      2014-02-02   Note A
Chapter 2      2014-01-01   Note B

I tried grouping, but it divided the whole table into separate tables.

I see no point here in using aggregation here (maybe I am wrong..)

What is the solution to this?


texts: check other commerce pane validation error

texts:
I am work on commerce pane, in hook_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order)  I call a function to do something in pane sumbit,

something like

function hook_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {

  do_update_something($user);
}

but when I am not fill another pane like address , my function called,
How can I prevent submit when there is error (validation in another panes) in other panes?


texts:
I added a custom field to a taxonomy term via 'Manage Fields' (see screenshot here: https://cl.ly/022v2B2H2c1m). How can I display this new field in the Frontend? In my template.php I have this:

$cats = taxonomy_get_tree(7);
$categories = array();
if (!empty($cats)) {
  foreach ($cats as $cat) {
    $parent = $cat->parents[0];
    $item = array(
      'tid' => $cat->tid,
      'name' => $cat->name,
      'description' => $cat->description,
      'image' => $cat->field_images,
      'children' => array(),
    );

  }
}

When I do a var_dump($item), the image field shows 'NULL', although I added an image.

Anybody with a solution?

Best wishes


texts: Is there a module that can display items in database?

texts:
after a few rounds of research, seems like Drupal is the way to go to manage data, but I'm fairly new to this...

I want to build a website that displays entries in the form of a table from a database.

For example,
1. User type in words of interest in the search bar
2. Data will be retrieved and displayed, which they can use for comparison (ie between data 1 and data 2)

One very similar example is like,
http://www.eigenfactor.org/

Your help is greatly appreciated


texts: Drupal commerce show taxonomy image in product variation

texts:
I'm trying to change the view of the product variation.
Let's say I'm selling t-shirt in different color so I create the taxonomy with the color and a small image of the color.
I create the term reference in product and enable the "Attribute field settings".
Now when i display a product i should be able so see the image of the taxonomy to choose the color but it shows me just the title in a select list or radio button. How can I override it?

Thanks in advance.


texts: hook_form_FORMID_alter select list default value

texts:
I created a custom module to override some fields in an exposed form created by views. One of the filters is the between filter on a number field. The between filter produces min and max fields for every field in the form. What I want to do is replace the min and max text fields with lists of integers that the user can select from. Where I am stuck at is the default value of the lists. I keep getting the following message:
"An illegal choice has been detected. Please contact the site administrator."
Below is a snippet from my module file:

$sale_price_min_options=array(
  'All'=>t('-Any'),
  10000=>'10000',
  20000=>'20000',
  30000=>'30000',
  40000=>'40000',
  50000=>'50000',
  60000=>'60000',
  70000=>'70000'
);

$form['field_sale_price_value']['min']=array(
          '#type' => 'select',
          '#options' => $sale_price_min_options,
          '#default_value' => "",
      );
      $form['field_sale_price_value']['max']=array(
                '#type' => 'select',
                '#options' => $sale_price_min_options,
                '#default_value' => 70000,
            );

Please let me know where did I go wrong. Many thanks in advance


texts: Node Acess User Reference and Organic Groups permissions

texts:
I am using Organic Groups to give group-specific content to users.

The groups' permissions do not allow simple group members to edit group content.

By using the Node Acess User Reference module I wanted to grant permission to specific group members to edit specific nodes on an ad-hoc basis.

The devel information that I get is that allthough that rule works, it is being overriden by OG's permissions thus still not allowing the user to edit the node.


texts: Changing a block title per theme or page

texts:
I have a search view, and I use the exposed form as a block to put the search box on every page.  In the block configuration I hide the exposed form block title so that I'll just get the search form with no title.

That works fine, but now on the Admin dashboard, I want to include the same search box.  The dashboard shows the block title, which is what I want, except the view title is 'Exposed form: publication_search-page' which is gross.

If I try to go into the block configuration and change the block title to Publication Search, I override the  that is in there now, and the title starts showing up everywhere.

How can I change the block title in the dashboard (or when I'm using the adminimal theme or whatever the admin theme is set to if that is easier) without messing up the configuration to hide it on all the other pages?


texts: Search all content fields with "find content" module instead of title

texts:
I want to search all fields instead of the title only.

Right now I'm using the "find content" module. Tried to find another one which is similar but am not able to find.


texts: Should Views result URL's be blocked in robots.txt?

texts:
I've a View of Jobs search depending on several exposed filters and I find plenty of url's like these in Google's index in the Google Webmaster Tools:

http://www.example.com/views/advanced-search?field_city_tid=&sort_by=field_last_date_of_application_value&sort_order=DESC&&&order=type&sort=desc

I see no point in indexing those URL's. Should I do block it in the robots.txt or make the result page "noindex" using Metatag module?


texts: What would make all content of a certain type return a 404 on the node page?

texts:
When trying to view/edit nodes of Content Type X, drupal returns a 404 - Not Found. All other content on the site (content of other node types) seems unaffected.

To eliminate other issues with clean URLs, path or path auto, I'm using the q param to access the nodes (example.com?q=node/123, example.com?q=node/123/edit), so it's not something silly like that (not likely anyway since all of the other site content renders fine at the expected URLS).

To be clear, drupal seems completely unaware of these nodes. Filtering by this content type on the admin/content/node page returns "No posts available". However, I happen to have a Views Bulk Operation view that modifies a CCK field for these nodes and that page does show all of them with the proper titles and everything. Trying to modify that CCK field with the VBO has no effect though (the field is not updated).

What I was doing before this happened:
I recently installed a new theme. Unfortunately, I can't confirm or deny that this started happening as a direct result of the theme. I would expect any error caused by this to result in 500 errors anyway. Or possibly 403 errors because I do use drupal_access_denied() in some custom modules - but not drupal_not_found().

What I have looked into while troubleshooting:

The node table looks fine. The rows referring to these nodes remain and appear unchanged.
All of the CCK tables (content_type_x, content_node_field, content_field_abc, etc) look fine.
The menu_router table rows for node/%, and node/%/edit are fine (but like I said, this is just one content type and I would think that something wrong with those rows would break all content types). (All of these database checks seem unlikely anyway since I haven't touched the DB directly or modified much of anything recently.)
I have rebuilt the permissions on site content (/admin/content/node-settings/rebuild).
The watchdog table records the 404, but nothing else.
The Status Report page is all green.

I realize that this is a pretty esoteric question, but I'm hoping something in the above rings a bell with someone.

This site is (still) running on Drupal 6.


texts: How do I find the hooks used by this module?

texts: How can I find out what hooks are available in the Entity Clone module? I want to modify the entity after it is cloned to change its author and workflow state.


texts: Get referenced node fields in twig where reference is on remote node only

texts:
I have a reference field with reference on node 2 to node 1.

On node 1 I want to find those nodes node 2 with reference to node 1.

How can I access those in twig?


texts: Display the flag link only for the node author

texts:
I'm trying to display the flag link only for the node author, and I'm using the following code:

global $user;
if ($node->uid == $user->uid) {
  //print your flag
}

The link doesn't appear.

Do you have any idea on what is causing this?


texts: HTML tags are counted in for the length of a teaser, instead of words?

texts: How to limit teaser length by words rather than characters?


texts: How do I make a clickable dropdown menu?  I'm making a dropdown menu that allows the user to click the item they want.  I would like then like that page appear automatically, or at least allow the person to click on the item and taken to the new page.


texts: Is there a way to let every user can choose (e.g. on registration) whether their field is private or public?

texts: I have an address field for every user on my website. Now, not everyone is happy with having his address visible to other users. I'm currently using field_permissions to control the visibility of the single fields. Is it possible to let the user decide which visibility he chooses (without code)?


texts: Configure a block view via block settings

texts:
I'm developing a website for a comprehensive but not professional user. He has the permissions to configure blocks (in order to tweak minor things like ordering or so).
Now I have a block view and I want to allow him to configure the number of displayed items for that block without giving him the permissions for view configuration in general.

Is there a way to put certain aspects of a block view configuration onto the configure block page or a similarly consistent way to achieve that?

(working on drupal 7 with views 3.10, btw.)


texts: Unable to save variable(s) from a custom form

texts:
I want to create a custom form with a few textfields and then use variable_set to save those textfields as variables.

I am not able to save the variable with the code below.

Question: I do not see the drupal message on hitting submit and when I go to the 'variables' table, I do not see the variable 'id_event'. I have tried clearing all caches several times.

Code below is from *.module file of my custom module "mymodule"

    function mymodule_menu() {

     $items['example_form'] = array(
         'title'        =>  'Progress Numbers',
         'description'  =>  'Form to enter variables that will be shown on Progress Update Block on Front Page',
         'page callback'    => 'drupal_get_form',
         'page arguments'   => array('example_form_form1'),
         'access arguments' => array('access administration menu'),

     );

     return $items;
 }

The callback function:

 function example_form_form1($form, &$form_state) {
  $form['id_event'] = array(
    '#type' => 'textfield',
    '#title' => t('Id Event'),
    '#required' => TRUE,
    '#default_value' => variable_get('id_event', 7),
  );

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

Submit Function

function example_form_form1_submit(&$form, &$form_state) {
  variable_set('id_event', $form_state['values']['id_event']);
  drupal_set_message($id_event);
}


texts:
How can I theme the div with a class of item-list that appears around a views pager? All I need to do is add an additional class to this div when it surrounds a pager.

I can find lots of documentation on theming the content of the pager, but none on how to theme them this div.


texts: Basic filter that can be expanded to include additional filtering criteria

texts: I have several filter criteria for examining different classes based on location,meeting time, etc. All the different filter options take up a lot of space and can look overwhelming to a new visitor. Is there a way to just have a few filter criteria initially visible with an option for the visitor to expand the filter criteria?


texts: Content disappeared for authenticated users

texts:
Suddenly, I have encountered a weird problem. I see my site flawlessly as admin and unauthenticated users. But all the timestamp-based content (Like blocks-forum thread etc.) disappear when I log in as a (non-admin) user.

I have checked server's time and truncated session table and flushed all cache but the problem persists. Really appreciate your hints.


texts: Placing block inside a node (positioning block between specific elements in node's content)

texts:
Basically I created a webform and enabled it as a block, now I want to put that block inside a specific node. I can do that by placing it in a 'content' region and defining the specific node BUT it displays at the end of the content. Now how can I move it between specific elements inside the content?

The node is using a page-type....tpl.php which is used by 5 other nodes as well so I cannot change the code.

To visualize it looks like:

[ content ]

-description text-

-list of videos-

[ end of content ]

and I need to put my webform between the text and the video list. Is there a way?


texts:
I've tried a few different methods to change the options listed in the "font" drop-down in CKEditor, to no avail.

First off, I went to Config > CKEditor > Profiles > edit each profile > Advanced Options > Custom JavaScript configuration and followed the instructions below, putting something like

config.font_names = "Helvetica Neue;Helvetica;Arial;sans-serif;"

but nothing changed. I went into the config.js file located at sites\all\modules\ckeditor\ckeditor\ and added the following lines inside the function call:

config.font_names = "Helvetica/Helvetica Neue, Hevletica, Arial, sans-serif;"

but nothing changed. I then tried removing the prior line in Drupal's Configuration menu but that also didn't help. I've cleared my browser's cache and Drupal's cache, no luck. I've tried Firefox & Chrome, no luck.

Am I missing something or is this a bug? As a last resort, I could go directly into ckeditor\ckeditor_source\plugins\font\plugin.js and change the font_names listed there but the documentation I've read indicates my methods above should work, so I'm trying to avoid that.


texts: Impossible to edit nodes, log to in etcetera after enabling Boost and editing .htaccess

texts:
After installing and enabling Boost in my Drupal 7 site (locally on WAMP and I also tried it on a remote test site) it's not possible to send any forms, e.g. not possible to edit and save nodes, not possible to login etcetera.

The actual Boost caching works though. When I remove the generated htaccess rules from my .htaccess file, everything works as normal again (except that the Boost caching stops to work of course).

My guess is that it's something in the generated htaccess rules that my site does not approve of.

Here is how the added rows look like:

  ### BOOST START ###

  # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support)
  RewriteRule .* - [E=boostpath:normal]

#  # Apache 2.4 bug workaround
#  # Enables Search from home page https://drupal.org/node/2078595#comment-8724321
#  RewriteCond %{REQUEST_METHOD} ^(POST)$
#  RewriteCond %{REQUEST_URI} /
#  RewriteRule .* / [S=3]

  # Caching for anonymous users
  # Skip boost IF not get request OR uri has wrong dir OR cookie is set OR request came from this server OR https request
  RewriteCond %{REQUEST_METHOD} !^(GET|HEAD)$ [OR]
  RewriteCond %{REQUEST_URI} (^/(admin|cache|misc|modules|sites|system|openid|themes|node/add|comment/reply))|(/(edit|user|user/(login|password|register))$) [OR]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_COOKIE} DRUPAL_UID [OR]
  RewriteCond %{ENV:REDIRECT_STATUS} 200
  RewriteRule .* - [S=2]

#  # Apache 2.4 bug workaround
#  # Enables caching of index/ home page
#  RewriteCond %{REQUEST_URI} ^/index\.php$
#  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html -s
#  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}/\_%{QUERY_STRING}\.html [L,T=text/html]

  # NORMAL
  RewriteCond %{DOCUMENT_ROOT}/cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html -s
  RewriteRule .* cache/%{ENV:boostpath}/%{HTTP_HOST}%{REQUEST_URI}_%{QUERY_STRING}\.html [L,T=text/html]

  ### BOOST END ###

Anyone who can help?


texts: How could I do a FULL OUTER JOIN in drupal?

texts:
How can I do this code in Drupal? I cannot find how this code is writing in Drupal.

SELECT column_name(s)
FROM table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name;


texts:
I my apache I have mod_expires enabled. My htaccess contains:

<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On
  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

Problem: If I make html change, it is not visible even after flushing all caches in drupal.
Question: Is it possible to setup html expiring to say 1 hour and other things like css/scripts/images to say 1 day?
Thank you.


texts:
I've installed the Tabs module, but I don't know how to use it.

Can anyone help me, please?


texts: How can I add a pager to the top of a forum?

texts:
I am using the standard forum module that comes with Drupal 8. The problem is, when I view a forum node, it shows the pager the bottom. I want the pager to also appear at the top.

The closest I've been able to come is editing the "comment--comment_forum.html.twig" template. If I put random text at the top of this template, then I can see the text appearing at the right spot I want. But if I put this:

{{ pager }}

Then nothing shows. So the comment--comment_forum.html.twig template doesn't know what "pager" is.

Does anyone know where the correct place is to add a pager to the top of forum posts?


texts:
How can I create products in Drupal8 eCommerce, which are from different vendors, but I'm handling it trough a single store ?
(Vendors should be invisible to the end customer).

I want in addition to keep track internally (for my own accounting purposes) which item from which vendor was sold, so I can reimburse the specific vendor.
Is there a way to put/attach "out-of-bound" info to products and eventually orders ?

I'm still in research phase, experimenting with Drupal. Is such thing possible ?


texts: Customizing main_menu so that it shows nested elements with styling in Drupal 7

texts:
I have the following menu structure which i like to implement in Drupal 7 :

Home

About

About Us

Team

So far i have the base elements displaying correctly using :

<?php
print theme('links__system_main_menu',
array('links' => $main_menu, 'attributes' => array('id' => 'dropdown-menu',
'class' => array('fixed'))));
?>

Problems :

It doesn't display nested elements
I can only control the styling of the first level but in my code i have to apply a subclass of 'sub-menu' according to my theme.

Can someone point me to a starting point ? Thanks


texts:
How do I convert the query below properly to 7x?

$query = db_query('SELECT latitude, longitude FROM {zipcodes} WHERE city = UPPER("%s") LIMIT 1', $search_term);

$query = db_query('SELECT latitude, longitude FROM {zipcodes} WHERE zip = "%s" LIMIT 1', $search_term);

The Coder module advised that I change it to db_query_range so I tried the code below.

$query = db_query_range('SELECT z.latitude, z.longitude FROM {zipcodes} z WHERE z.city = UPPER(:city)', 0, 1, array(':city' => $search_term);

$query = db_query_range('SELECT z.latitude, z.longitude FROM {zipcodes} z WHERE z.zip = :zip', 0, 1, array(':zip' => $search_term);


texts:
I need to add some tables to the database in a new module version. I created a hook_update function:

function bundles_update_7000()
{
    ...
}

But for some reason my module is missing in the updates list in the admin interface. When I run:

drush pm-update bundles

it writes: "No code updates available."

What could be the issue?


texts: Adding an active menu trail to the main ul, in the html.tpl.php?

texts:
Is there an easy way to get the active menu trail in this nav ul? I don't really understand PHP yet, I'm still learning. I personally would have setup the menu in Drupal, not in the html.tpl.php.

  <? foreach($full_menu_items as $menu_item) : ?>
  <? if($menu_item['#original_link']['has_children'] == '1') : $belowMenu = $menu_item['#below'] ?>

  <li class="<? { echo "";  } ?>">

<? echo $menu_item['#original_link']['link_title'] ?>

       <? foreach($belowMenu as $sub_menu_item) : ?>
       <? if($sub_menu_item['#original_link']['link_path']): ?>

<a href="<? echo $sub_menu_item['#original_link']['link_path']; ?>"><? echo $sub_menu_item['#original_link']['link_title']; ?>

       <? endif; ?>
       <? endforeach; ?>

        <? else: ?>
   <? if($menu_item['#original_link']['link_path']): ?>

<a href="<? echo $menu_item['#original_link']['link_path']; ?>"><? echo $menu_item['#original_link']['link_title']; ?>

   <? endif; ?>

   <? endif; ?>
   <? endforeach; ?>


texts: Images of some content types disappeared

texts:
I have something strange going on on one of my drupal installation.

It seem's that for two content types all the images got unlinked from the existing entities. I can still see in the table file_managed that the images are still in database and linked to the entity and the files are also on disk. But when I edit an entity of those two content types the images do not show up. I can only upload a new one.

Has somebody ever experienced this kind of issue? What could I check to see what caused this strange behavior? Beside me 3 other content editors have access to the drupal admin panel. What could they have done so that the pictures of all entities for two content types disappeared overnight?

EDIT I just noticed other fields are als gone. All the data is still in database but does not show up in either edit form/node view.


texts: How to theme the $item in views-view-grid.tpl.php

texts:
I'm just beginning to learn theming Drupal 7, and have encountered something I can't seem to find any info on (and my experiments have no effect).

In tao/rubik theme, and in many others there is the  views-view-grid.tpl.php template which arranges the resulting items from a view in a grid design.

Now, at the very end, after splitting into rows and columns there is a print $item which is the section that prints the actual node content/teaser in the grid square. I'm assuming the content is a node, since this is what I set the view block to display, also I set it to display the full content of that single node.

However, no matter what I do, I can't seem to modify the template of this node... how should the template be called? should it be placed somewhere special?

What am I missing?


texts: How to insert an image into a drupal form

texts:
Is it possible in drupal7 to insert a photo in drupal form? I have a start interface that contains two buttons leading to two athors interfaces and I would like to insert a photo above the two buttons. I have tryed the next but it didnt work

function my_module_start_form($form, &$form_state) {
  $image_options = array(
    'path' => 'path/to/img.jpg',
    'alt' => 'Test alt',
    'title' => 'Test title',
    'width' => '50%',
    'height' => '50%',
    'attributes' => array('class' => 'some-img', 'id' => 'my-img'),
  );

  $image = theme('image', $image_options);

  $form['start']['image'] = array(
    '#markup' => $image,
  );

  $form['start']['next'] = array(
    '#type' => 'submit',
    '#value' => t('Create charts')
  );

  $form['start']['examples'] = array(
    '#type' => 'submit',
    '#value' => t('See charts examples')
  );

  return $form;
}


texts: Is there a way to tell a browser to not cache a particular custom page?

texts:
A custom module I'm building has a page callback that creates and Inbox listing. When a user clicks an item in the inbox, another page callback displays the message, and it updates the database to record that it's been read.

The problem is that when the user presses Back, they get back to their local cache of the inbox which suggests it has not been read. If they reload, it's OK.

Is there a way (in hook_menu?) to flag that a page should not be cached/expires immediately?


texts: Get a single date value from a date field on a node with entity_metadata_wrapper()

texts:
I want to retrieve a date value from a date field attached to a node with entity_metadata_wrapper.

So far:

$node_wrapper->field_tournament_date->value();

Provides an array. Not many other methods work. So, I have to do:

$date = $node_wrapper->field_tournament_date->value();
$start_date = format_date($date['value'], 'short');

Is there a cleaner way of getting the value of a date field without breaking it up like that?


texts: How do I fix my Commerce Feeds import process post updating my modules and core?

texts:
I have just upgraded to core 7.15 and updated all my modules at the same time.
When I now try and run the an import using commerce feeds I receive the error below.

    An AJAX HTTP error occurred.
    HTTP Result Code: 200 Debugging information follows.
    Path: /batch?id=892&op=do
    StatusText: OK
    ResponseText: Fatal error:
Call to undefined function commerce_product_validate_sku() in /home/mmlcofdk/public_html/sites/all/modules/commerce_feeds/plugins/FeedsCommerceProductProcessor.inc on line 216

I would really appreciate some advice on how I could go about debugging this...


texts:
I have enabled several languages on my site and the following modules has been installed: Locale & Content translation.
I have created a simple page in English and have added several translations for this node.
Now when I view node on separate page it's displaying in language which is selected in language switcher block.
But if I view node on front-page (/node) or on taxonomy page (taxonomy/term/%) all translations of this node has been shown.
Is it possible to disable displaying other translations for all pages?


texts: Disabling the site cache brakes the page output

texts:
I have just finished my development and uploaded a website to a hosting. But unfortunately I've got another weird problem..

If I disable the site cache another template is used for rendering a view node.
I cannot catch the error. The problem is that in case I disable all caches, this problem appears. But when I try to debug the problem it disappears))
So I am not able to find what is wrong with it ?
Sometimes it appears after commenting these lines

#$settings['cache']['bins']['render'] = 'cache.backend.null';
#$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

Sometimes it appears after disabling Twig Debug

The problem that it swaps view node templates between two views. For exampl I have a view for rendering teasers, and another view is for rendering a node preview. So it swaps them. I really cannot understand what is going on and what is the problem.

Please suggest what can cause such weird behavior ?

Thanks

NOTE 1

The same problem occurs locally when I disable caches.

NOTE 2

I've found the weird part of debug output

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_unformatted__latest_works' -->
<!-- FILE NAME SUGGESTIONS:
   x views-view-unformatted--latest-works.html.twig
   x views-view-unformatted--latest-works.html.twig
   * views-view-unformatted.html.twig
-->

The same template is suggested twice

NOTE 3

I've noticed another weird behavior

#$settings['cache']['bins']['render'] = 'cache.backend.null';
#$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

Comment these lines the view on the main page doesn't work, outputs nodes with template from another page.
Go to menu, Devel -> Clear Cache.
Now view on the main page works correctly, but on the other page output nodes using template from the main page.

And these behavior repeats

FINALLY

The problem is caused by the render cache I guess. To get this error I have to do following steps :

Consider there are two pages the front and the category page.
If current page is displayed incorrectly, then stay on this page open admin panel, clear the site cache, refresh the page - everything is rendered correctly.
Go to the category page, now it rendered incorrectly and nodes that are also present on the front page rendered incorrectly using the front page template.
If I clear cache again and refresh the category page it will work, but the front page will be rendered using the view template from the category page.

I hope I've described the problem clearly.
It seems that the problem is similar to that one https://www.drupal.org/node/2359955


texts: How can i access only the text of a comment?

texts:
In the comment.tpl.php there is

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

and this converts to this html

THE COMMENT

What can i do if only want text "THE COMMENT" printed and not all this html?
I know $content is an array but can't find a way to dig into it's elements.


texts: Creating a block with installation profile

texts:
To create a block I am currently using this code:

$default_theme = variable_get('theme_default', getDefaultTheme());
$blocks = array(
  array(
    'module' => 'user',
    'delta' => 'login',
    'theme' => $default_theme,
    'status' => 1,
    'weight' => 0,
    'region' => 'sidebar_first',
    'pages' => '',
    'cache' => -1,
    ),
);

// Save blocks
$query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'pages', 'cache'));
foreach ($blocks as $block) {
  $query->values($block);
}
$query->execute();

My question is what do the 'module' and 'delta' field exactly do? What can I fill in there if I made a custom block? And how do I define on which pages this block should be visible, should I add a page name or id?


texts:
Hi i have a complex form like this:

I want to present it as a content type, i don't have any clue how to do it.
i've tried making collections of collection fields and setting its format as table
but it's not what i want. any idea or help i'd be grateful.


texts: Notice: Undefined property: stdClass::$field imce drupal

texts:
I'm in trouble so maybe someone can figure it out: I'm trying to have singular folder for every user in imce (drupal7) and I want that the folder is a code that I can insert with a field in user profile. (like 78M4589)

well, this code generate the folder in the right place:

return 'users/'.$user->field_code['und'][0]['value'];

but in imce on the page i have this notice:

  Notice: Undefined property: stdClass::$field_code in eval() (linea 1 di () : eval()'d code).

I really can't figure it out.


texts: How to create arguments in path with regular page node instead of module, yet pass them to a module

texts:
I know how to create a URL with hook_menu() in a module, but is it possible outside a module?
Here's what I'm needing/asking:
My front-end guy wants to create a page as a node using a Content Type via the Content menu. The URL for this content type needs to be something like www.somesite.com/some-page/arg1/arg2. Can this be done without a module defining the route with hook_menu() in a module?
If so, in my module that needs to do the work, it needs to collect these args and use them to insert data into the DB.
Is it possible for him to create a path with arguments that I can get? If so, what would be the best way to get these args to my module that is going to work on the backend.
I could do this all day with hook_menu() in module, but the front-end guy seems adamant that he can create a node and get the args from it's path. I don't understand how he can do that.
Thanks in advance.
Cy


texts: Get node in custom token to be used in Pathauto url alias pattern

texts:
I'm attempting to use a custom made token for url alias patterns. I've been able to custom tokens using node information just fine. But it just occurred to me that I don't know how I could possibly use it with url alias patterns.

function mymodule_plugins_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata){
  $token_service = \Drupal::token();
  $replacements = array();
  if($type == 'mymodule_tokens') {
    foreach($tokens as $name => $original){
      switch($name){
        case 'current_nid':
        $node = \Drupal::routeMatch()->getParameter('node');
        $title = (!empty($node)) ? $node->id() : 'This is a test';
        $replacements[$original] = $title;
        break;
      }
    }
  }
  return $replacements;
}

It works fine if I'm using it on a node page. But what if I want to use it in a url alias pattern in the pathauto module?

$node = \Drupal::routeMatch()->getParameter('node');

I know here it gets the node based on the current page it's on. But if it's used in a url alias pattern it's not on any page at the time of url alias construction.
I have a feeling this is possible since there are already tokens like [node:title] that work.  Also is there any weird thing I can do like this?

[mymodule_tokens:current_nid[node:nid]]

Where I pass a token within a token? And if I can how would I access that extra parameter within my custom token. (p.s. I understand that my example is just getting the current_nid and that there are already tokens for it. I'm just using that as an example)

Is there anyway I can get the node from my custom token to be used in a url alias pattern?


texts: CiviCRM on Drupal: Array to string conversion error in BAO setting.php in Display preferences

texts:
I'm receiving this error after a fresh install of civicrm-4.4.17 on
drupal-7.38.

While attempting to go through the configuration checklist I also noticed that the items were not turning green after I completed them.

What might be causing these errors?


texts: How do I get the timezone form reference on a date field?

texts:
In Drupal 7 I have a date field in a content type that has the Time zone handling option set to "Date's time zone".  Setting this option will render a drop down list of time zones in your date field.

I am trying to replace the list of core time zones with a smaller list for just the United States.  I found this post which works perfectly for overriding the timezone drop down list on the user profile page.  However, I have not been able to figure out how to get a reference to the timezone select list on a date field.

The timezone reference on the user profile field is:

 $form['timezone']['timezone']['#options']

If you print the $form variable to the screen you can clearly see the time zones in the above reference.

What I can't figure out is where the timezone options are in the form variable for a date field.  I would expect them to be in somewhere in

 $form['field_event_dates']['und'][0]

I do see a default value for the timezone at

 $form['field_event_dates']['und'][0]['#default_value']['timezone']

but I can't find "options" in there.

Any ideas where the "options" for the time zone are set in the form variable?


texts: Minimizing cache clearing during development

texts:
I'm suffering from very long (several second) load times when developing locally with Drupal 8 when developing/debugging twig templates or in general having ALL caching disabled.  Rebuilding cache makes my admin pages needlessly require a rebuild for example.  When I'm not actually working on them I'd like them to remain cached.

I'd like to be more specific in my cache clearing so that I can clear only the parts I'm actively working on - ex a view or block - instead of constantly invalidating the entire site cache which is rather expensive.

I've found that cache tags may work, but I can't find documentation or the location where I might find a listing of available cache tags or really much else on clearing specific caches.  So if tags are effective, where can I find all registered cache tags on my site?

Is there more information I'm missing on how targeted caching is implemented in Drupal 8?  Are there alternatives to tags that might work better?

Edit:  I should mention my environment, in case there is an alternative solution.

I'm running Drupal using docker, with Nginx/PHP-FPM and MySQL containers , on Docker for Mac which has known issues with file mounts so I'm only mounting my custom modules as volumes into any containers.  I profiled the difference between mounting everything and am now spending negligible time doing file operations whereas previously it was very expensive.

Now it appears that my bottleneck is calling the Database many times per pageload, I imagine this is because I'm rebuilding the entire cache meaning I'm adding/removing it from the DB over and over.  I may try memcached or redis and see if that helps.

My ideal solution here is to just invalidate portions of the cache I actually want to invalidate instead of the entire thing though.  Cached pages are ofc incredibly fast in this environment.  My staging environment which is using native Docker does not have the FS issues but still suffers when caches are turned entirely off.


texts:
My website is currently accessible via 2 address

www.mydomain.com
and
mydomain.com

What is the best way to manage redirects. I would like

mydomain/blah to redirect to www.mydomain.com/blah


texts:
I have a view that shows related products by means of a contextual filter (PHP). If the returned nid values from the contextual filter is for example "20697, 20735, 20768, 20903, 20695, 21863" I want the nodes to be rendered in that order.

But they don't, I have tried all kinds of settings with no luck. The order given is in fact the delta of a certain field, but when I try to use the delta version of that field as a sort criteria, it is simply ignored, even if I add a relationship under "Advanced".

Anyone who recognizes this behaviour?

EDITED:
This is my contextual PHP filter. It fetches all the nid's entered in a certain node reference field as I explained above. And I want them to show in that same order, so that the admin user can sort the order by dragging the rows in the Node reference field:

$node = menu_get_object();
$value = null;
if(empty($node->field_lagg_till_givargrupp['und'][0]['nid'])){
    $node->field_lagg_till_givargrupp['und'][0]['nid'] = NULL;
    $value = FALSE;
         return $value;
} else {
        $limit = count($node->field_lagg_till_givargrupp['und']);
        for($i = 0; $limit > $i; ++$i){
            $group_nid = $node->field_lagg_till_givargrupp['und'][$i]['nid'];
            $group_node = node_load($group_nid);
            $limit2 = count($group_node->field_koppla_givare['und']);
            for($x = 0; $limit2 > $x; ++$x){
                $value .= $group_node->field_koppla_givare['und'][$x]['nid'].",";
            }
        }
        return rtrim($value, ",");
}

EDITED: this is the SQL query (I have added a few nids as an example);

SELECT node.nid AS nid, field_data_field_koppla_givare.delta AS field_data_field_koppla_givare_delta, field_data_field_koppla_givare.field_koppla_givare_nid AS field_data_field_koppla_givare_field_koppla_givare_nid, 'node' AS field_data_field_givargrupper_node_entity_type, 'node' AS field_data_field_huvudbild_givare_node_entity_type, 'node' AS field_data_field_tumnagel_givare_node_entity_type, 'node' AS field_data_field_underrubrik_givare_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_artikelnr_produkt_node_entity_type, 'node' AS field_data_field_pris_givare_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_koppla_givare} field_data_field_koppla_givare ON node.nid = field_data_field_koppla_givare.entity_id AND (field_data_field_koppla_givare.entity_type = 'node' AND field_data_field_koppla_givare.deleted = '0')
WHERE (( (node.nid IN('20697', '20735', '20768', '20903', '20695') ) )AND(( (node.status = '1') )))
ORDER BY field_data_field_koppla_givare_field_koppla_givare_nid ASC

And this is the simple query without the delta field and without the order by criteria trying to sort in hook_views_pre_render() instead (see this question about that Sorting logic with anonymous function does not work):

SELECT node.nid AS nid, 'node' AS field_data_field_givargrupper_node_entity_type, 'node' AS field_data_field_huvudbild_givare_node_entity_type, 'node' AS field_data_field_tumnagel_givare_node_entity_type, 'node' AS field_data_field_underrubrik_givare_node_entity_type, 'node' AS field_data_body_node_entity_type, 'node' AS field_data_field_artikelnr_produkt_node_entity_type, 'node' AS field_data_field_pris_givare_node_entity_type
FROM
{node} node
WHERE (( (node.nid IN('20697', '20735', '20768', '20903', '20695') ) )AND(( (node.status = '1') )))

As you can see I am really stuck in all ways about this ...


texts: Updating a module via backend or manually didn't work. No drush available. What else can I try?

texts:
I have to administrate a site I didn't build. An older version (7.x-3.0-beta4) of http://drupal.org/project/context (7.x-3.0-beta6) gives me security alerts and suggests to update immeditaley(!).

The automated update process works fine until it comes to the point where the database should is updated. I just says: No pending updates. Back in the modules overview it still is the old version (7.x-3.0-beta4) and message prompts again: update immediately.

So I tried updating manually. Deleted the context module folder in sites/all/module. And uploaded the freshly unpacked new version (7.x-3.0-beta6). Then I ran updated.php and: same again. Drupal still says old version and tells me to update immediately.

Then I tried to uninstall the complete module through the 'uninstall module' dialogue, though I don't know if uninstalling it completely is a good idea (Is it? Or will data get lost?). But even that didn't work. I deactivated all the three parts of that module (context, context ui, context layouts), then went to the uninstall site but there I wasn't given the chance to check the main part (context).

Even when deleting the whole module folder, the module still appears in every list and the alert message still prompts me to update.

So, what can I do to force the database to update and finally recognize the new files? Or what else would be a point I maybe missed to try?


texts: Include content of a block in a view template

texts:
I'm trying to create a Twig view that renders:

Intro block
View content
outro block (yes, made up word for the opposite of intro)

The reason I'm putting these three things in one view is that I have a repeating background pattern; if each item is rendered alone, the background does not display smoothly across/through each element.

I've been trying to put this line - {% include 'block--intro.html.twig' %}, based upon block.html.twig - into the appropriate place of the view twig file, but when the page containing this view is rendered the {{ contents }} of the block is empty.

How should I be trying to do this?

I am using Drupal 8.2.4. The base theme is Bootstrap; we are using a subtheme of that.


texts: how to set the options value of facet field fixed as pretty path alias

texts:
I am working with facetapi & facetapi_pretty_paths for my product search.
I already created the widget ,it is showing facet in drop down list .
Now i have the problem ,that when i search any thing the first search is working fine ,but after that the widget field value is not set as of path alias .
I followed this module .

In the facet_select.module

/**
 * Widget that renders facets as dropdowns.
 */
class FacetapiSelectDropdowns extends FacetapiWidgetLinks {

  /**
   * Renders the links.
   */
  public function execute() {
    static $count = 0;
    $count++;

    $element = &$this->build[$this->facet['field alias']];
    print_r(&$this);exit;
    if(count($element) > 1){
      $options['choose'] = t('- choose -');
    }
    foreach ($element as $value => $item) {

       //here i want pretty path alias value  $options[?]

       $options[$item['#path']] = $item['#markup'];
    }
    if (end($options) !== '(-)') {
      if (!isset($form_state)) {
        $form_state = array();
      }
      $element = facetapi_selectbox_facet_form($form_state, $options, $count);
    }
  }
}

Is i am doing it wrong ?

Any help is most welcome .
Thank you.

EDIT:
here is the widget function

function facetapi_selectbox_facet_form($form_state, $options, $count = 0) {
  drupal_add_js(drupal_get_path('module', 'facetapi_selectbox') .'/js/facetapi_select.js');

  $name = 'facetapi_selectbox_facet_form_' . $count;
  $form['facets'] = array(
    '#type' => 'select',
    '#id' => $name,
    '#default_value' => '',
    '#options' => $options,
    //'#attributes' => array('onchange' => "top.location.href=document.getElementById('$name').options[document.getElementById('$name').selectedIndex].value"),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}


texts: Display order of entity reference fields

texts:
I have an entity reference field which references and displays multiple nodes on a Drupal 7 install.
I am trying to get them to display in date order (the date is a field on the referenced nodes).  The problem I have is that if a referenced node date is changed, or a new one created, the display order doesn't change.

I use a entity reference view to order the nodes on their date fields, which works when you manually edit the master node and then save it.  This then updates the order.  However this not a very practical solution.

I have tried creating a module which when referenced nodes are modified or created, it programatically loads and saves the master node using node_load and node_save.

However this doesn't trigger the referenced nodes to update their display order.

Does anyone know anything else I can try?


texts: hook_menu() and collapsable menu items with wildcard

texts:
I've defined a few routes with hook_menu(), and added these routes to a menu with nesting. This works fine for all static routes, but for any route with a wildcard the 'active-trail' does (understandably) not apply to the menu, and the parent menu item is collapsed. How can I enforce that the parent menu item is open and has 'active-trail' class?

This is the hook_menu() implementation I am using.

function my_module_menu() {
  $items['parent'] = array(
    'title' => t("Parent"),
    'page callback' => 'my_module_parent',
    'access callback' => 'user_is_logged_in',
  );
  $items['parent/child'] = array(
    'title' => t("Child"),
    'page callback' => 'my_module_child',
    'access callback' => 'user_is_logged_in',
  );
  $items['parent/child/%'] = array(
    'title' => t("Child Item"),
    'page callback' => 'my_module_child_item',
    'access callback' => 'user_is_logged_in',
    'page arguments' => array(2)
  );

  return $items;
}

My menu (a custom menu) looks like the following.

Home

Item 1
Item 2
Parent

Child

So if I go to 'parent/child/123' I want the 'parent' and 'child' menu items to be active and not collapsed.

I've tried the Menu Trail by Path module, but it seems to have no effect.


texts: Profile Completion e-mail to user in Drupal

texts:
Hi in drupal(6) how to send reminder e-mail to the user whoever did not complete the profile information?

Is there any module available to do this? i think we can do using rules/trigger. but not exactly. I need similar to that what cron job do in php. Help me out.


texts: Why Manage_fields and Manage_display tab are not shown in content type?

texts:
Suddenly My dev site is not showing

  Manage_fields and Manage_displays

in all content types. I am using contributed module admin_menu. I clear all cache but it happens same. This is multilingual site. I can't understand why it occurs? Can anyone solve this problem? I have enabled field_ui modules.


texts: How to access block fields programmatically?

texts:
I display a block of type Assignment on the top of a page when I'm creating a node of type Submission.  I need to access the fields of the Assignment block programmatically with my custom module.

Are there any built in Drupal functions that will allow me to do so?

I'm currently using hook_form_alter() but that does not give me access to the block elements.


texts: Modifying Field Values for a Custom Content Type?

texts:
I have a custom content type that has a field whose values need to be modified. The field in question is a select list and I need to add a new value to the list and re-order the list to satisfy the requirements of the project. The existing list looks like this:

1_Value A|Value A
2_Value B|Value B
3_Value C|Value C

The new list needs to look like this:

1_Value A|Value A
2_Value D|Value D
3_Value B|Value B
4_Value C|Value C

I realize because this field/content type already contains data, that this field cannot be edited. That being said, I suppose my question is two-fold:

How can I easily edit this field? What is the best way to export the data, make my modification and re-import?
Will re-ordering the values have any impact on the existing data associated with this content type?


texts: How do I automatically add a user to a group when a user role is added to the account?

texts:
What I would like is that when a Drupal user has a User Role added to their user, then this also adds them to a specific Drupal Group.
When I talk about User Role, I mean the standard User Roles defined on the Drupal web admin page at this address admin/people/roles . I'm also aware that Group itself can defined Group roles, but that's not what I mean here.
Is this already possible in Drupal Group module?
I also look for add-on companion/extension modules on this page: Community Contributions | Group but could not see anything there for this.
Can it be done in Rules in Drupal 8? I had a look but could not see a particular Rule available.
I'm also looking at my own programmatic implementation - by asking these two questions:

How do I 'subscribe' to user event creation, so I can run my own
code when a user is created?

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

... but if I can avoid reinventing the wheel if such functionality exists then I would like to - hence my asking the question here. Thank you.


texts: Theme Node Add Form for content type created in custom module

texts:
I have built a module in D9 that creates a content type.
Now I am trying to theme the node/add form.
my_module.module
<?php
/**
 * Implements hook_theme().
 */
function my_module_theme() {
  return [
    'html__node__add__content_type' => [
      'template' => 'html--node--add--content-type',
      'base hook' => 'node'
    ],
  ];
}

My html--node--add--content-type.html.twig is recognised and the form renders, BUT all the styling of the site's theme is stripped out.
Within html--node--add--content-type.html.twig, this works to render the form:
{{ page }}

but this:
{{ form }}

results in a blank page.
I need to be able to target specific fields, without losing the site's theme css.
Any help appreciated.
Thanks.


texts: custom search in drupal for custom content type page

texts:
I am trying to implement following functionality in drupal:

From the admin interface add, edit, list multiple stores for a company. The store record would be: Store name, address, image and zip code. This will be like how its done in simple lists - a list of stores shows up with edit and delete links and a link to add a new store, thats all.
Provide a search box in the homepage (separate from the standard site search) which will allow users to enter a zip code and view the image, title and address of stores in that zip code ( No need for proximity search or anything)

What I have done so far:

For adding store information:
created a new content type called 'Store Locator'' and added custom fields for required data. I unchecked promote to front page, so the added records do not show up in the homepage. This works pretty much how I want so that is fine.

The main challenge is to give a search facility for the stores. I created a view called store locator with rule set to show only 'Store Locator' content types. Added 'Table' as the format for display, and added the fields I want to see in the table. This view was created as a 'Page'

Now when I got to the view's URL, I can see a list of stores in the defined table format. My problem is that I need to add a search box in the front page where the user can enter a zip code and it will show this same view page, but with only matching records. Basically the custom search result page should be in the same table format and not like how the results gets displayed when a standard site search is done. I am at a loss on how to add a new search box in the home page, and how to link it to the view page with filtered results..

I am not looking for a complete answer to this problem, just some pointers on what area I should be looking at..I am pretty new to drupal and its pretty daunting to figure out which way I should explore more. I installed/uninstalled a lot of modules to see if they can do it, but they did not really help. Any pointers on which direction to explore would be highly appreciated!


texts: Can menus be auto-generated from discovered content?

texts:
I am considering Drupal to host technical manuals. Aspects:

the manuals change frequently
I would bulk update the pages via curl, ftp, or some other method to be determined (point being: there will be zero hand editing in the Drupal interface). This upload would happen once a month.
the manuals have nested Tables of Content that I want a taxonomy based menu to follow. These TOC change frequently.
I could embed metadata (a tag maybe?) in the pages to support menu building

Example content, before and after update:

BEFORE an update I may have this TOC and node structure

Chapter 1
    Section A
    Section B
Chapter 2
    Section A
    Section B
    Section C

AFTER an update I may have this TOC and node structure

Chapter 1
    Section A
    Section B
    Section C
Chapter 2
    Section A
        Subsection I
        Subsection II
    Section B

Of course, menus need to change to reflect the new content I just uploaded.

The part I have not figured out:

(assume I have Drupal Core 7.38, and any stable and active modules you might suggest):

  Question After I bulk create or bulk update content---can the corresponding menus be generated auto-magically by reading the new content I just uploaded? Or does it have to be hand-entered?

I hope my Q made sense. I hope Drupal can discover/build menus without custom PHP.

Any suggestions on Drupal configuration or publishing workflow are welcome.


texts: How can I use Javascript (Google Analytics) in my "Rewrite Results" in Views?

texts:
I'm trying to track downloads as events in Google Analytics for file fields.  The links are displayed in Views using "Rewrite results."

I tried the following:

Windows

But the onclick part gets stripped out by Views.  I know the Full HTML filter does this by default, but how do I get around it?


texts:
I found a similar issue but it will not help me since I have not changed permissions.

I am running drush cc all and getting this error...

I have logged out and back in and nothing. I have not changed permissions and I have the admin rights to the account. Any ideas on what to do?


texts: How do I fetch a vote given on a node and programmatically apply this vote to the author of the node?

texts:
I am using the voting api, fivestar and rules modules to try to fetch the vote a user gave to a node (article) and apply that same vote/value to a fivestar field of the author of that node. How can I accomplish this?

{ "rules_cast_a_vote_when_the_author_casts_a_vote_on_their_article" : {
"LABEL" : "Cast a vote when the author casts a vote on their article",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "cast", "fivestar", "vote" ],
"REQUIRES" : [ "rules", "rules_conditional", "voting_rules" ],
"ON" : { "voting_rules_insert_node" : [] },
"IF" : [
  { "entity_is_of_bundle" : {
      "entity" : [ "node" ],
      "type" : "node",
      "bundle" : { "value" : { "article" : "article" } }
    }
  },
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_my_fivestar_rating" } },
  { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_the_editor" } }
],
"DO" : [
  { "entity_fetch" : {
      "USING" : { "type" : "user", "id" : [ "node:field-the-editor:uid" ] },
      "PROVIDE" : { "entity_fetched" : { "editor_uid_fetched" : "Fetched editor uid" } }
    }
  },
  { "CONDITIONAL" : [
      {
        "IF" : { "entity_has_field" : {
            "entity" : [ "editor-uid-fetched" ],
            "field" : "field_my_fivestar_rating"
          }
        },
        "DO" : [
          { "drupal_message" : { "message" : "When conditional is TRUE: [editor-uid-fetched:name]\u0027s ID has been fetched and is: [editor-uid-fetched:uid]" } },
          { "data_set" : {
              "data" : [ "editor-uid-fetched:field-my-fivestar-rating" ],
              "value" : [ "node:field-my-fivestar-rating" ]
            }
          }
        ]
      }
    ]
  },
  { "drupal_message" : { "message" : "vote:value [vote:value]\u003Cbr\u003E\r\nnode author fetched ID: [node-author-fetched:uid]\u003Cbr\u003E\r\nnode author fetched name: [node-author-fetched:name]\u003Cbr\u003E\r\neditor rating now: [editor-uid-fetched:field_cr_rating]\u003Cbr\u003E\r\neditor rating value now: [editor-uid-fetched:field_cr_rating:value]\u003Cbr\u003E\r\neditor rating now (hyphens): [editor-uid-fetched:field-cr-rating]\u003Cbr\u003E\r\neditor rating value now (hyphens): [editor-uid-fetched:field-cr-rating:value]\u003Cbr\u003E\r\n\r\n" } }
]

}
}


texts:
This answer  from 2 years ago (to which I am not allowed to comment) to the question "How send argument to Services Module (Views+Contextual filters)" contains something about passing contextual filter value to the service module. It is about this URL:

http://test.url/endpoint/path?uid=123

My question here: what exactly is that "path"?
Is that machine name of the view?


texts: Form API: Form field not being translated

texts:
I'm implementing a gender field in a custom registration form.

The gender field also exists as a user field, so I'd like to call the label and allowed values from the existing instance. I've written it as a conditional override just in case...:

$form['gender'] = array(
    '#title' => t('Gender'),
    '#type' => 'radios',
    '#options' => array('female' => t('Female'), 'male' => t('Male')),
    '#required' => TRUE,
);
if($field = field_info_field('field_gender')) {
    $form['gender']['#options'] = $field['settings']['allowed_values'];
    $info = field_info_instance('user', 'field_gender', 'user');
    $form['gender']['#title'] = t($info['label']);
}

Everything's working great, except for the multilingual part: despite having translated the field instance at the admin account settings using i18n, the extracted options and title of the existing field are not being translated upon changing the front-end language. They DO get translated however when visiting the user account page in a different language.

It seems my custom form doesn't send its strings through i18n...?

Can anyone point me out the pitfall please?

Thanks

UPDATE

I used

$func = function($val) { return t($val); };
$form['gender']['#options'] = array_map($func, $field['settings']['allowed_values']);

as suggested by Shameem to translate the options.  But now it seems t() is fetching translations from the Locale module repository. How to direct t() to fetch it from i18n?


texts: Filter condition like "from now to now+1 year" on a date field in Views

texts:
I have a custom entity with (among others) a field defined this way:

$fields['datedistribution'] = BaseFieldDefinition::create('datetime')
  ->setLabel(t('Date distribution'))
  ->setSetting('datetime_type', 'date')
  ->setDefaultValue(array(0 => array(
    'default_date_type' => 'now',
    'default_date' => 'now',
  )))
  ->setDisplayOptions('view', array(
    'label' => 'above',
    'weight' => 2,
  ))
  ->setDisplayOptions('form', array(
    'weight' => 2,
  ))
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);

The values of this field are stored in the database in YYYY-MM-DD format.
I designed a View on this custom entity displaying (among others) this 'datedistribution' field and I use it as a filter criterion.
I would like to a filter condition like "from now to now+1 year".
The available operators being

how can I do that?


texts: How would I create and render, but not save, an entire menu tree programmatically?

texts:
I'm trying to pull a number of links from several services, and combine them into a renderable menu tree:
Source one: pull links A, B and C
Source two: pull links D and E
Source three: pull links F, G, and H
Desired end result: a menu tree object that I can render using core and contrib menu theming functions, structured like:

Parent 1

Link A
Link B
Link C

Parent 2

Link D
Link E

Parent 3

Link F
Link G
Link H

It seems like this is simple enough to do with a menu that's been saved to the database, but as the contents of the links from each of these sources may change at any time, I'm looking to build the menu on the fly. I can create menu items out of the data, but I'm having trouble creating and populating a tree with them. All the documentation and posts I've been able to find seem to assume you're loading a tree from a pre-existing menu. I think what I need to do is create a new, empty tree, and add the links to it. Is there a way to do this?


texts: How do I create inline border style in views table for views data export word output?

texts: I am using views data export module to generate word output. I am able to get word document but views table out is coming without border. How to put border in word output ?


texts: Where does the menu trail get added into the $data parameter in pathauto_tokens()?

texts:
I have seen this post: where does $data come from in hook_tokens?, but that did not help me answer my question, maybe it could've but there's no way for me to interact with that post.

I am working in Drupal 8.5, using pathauto 8.x-1.1.

I am looking at pathauto.tokens.inc, here is the code for pathauto's hook_tokens():

function pathauto_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
  $replacements = array();

  if ($type == 'array' && !empty($data['array'])) {
    $array = $data['array'];

    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'join-path':
          $values = array();
          foreach (token_element_children($array) as $key) {
            $value = is_array($array[$key]) ? render($array[$key]) : (string) $array[$key];
            $value = \Drupal::service('pathauto.alias_cleaner')->cleanString($value, $options);
            $values[] = $value;
          }
          $replacements[$original] = implode('/', $values);
          break;
      }
    }
  }

  return $replacements;
}

I can't seem to find how the menu trail makes it into the $data parameter. I can see the menu trail in $data when I set a breakpoint at array = data['array'].

My ultimate goal is to figure out why pages with a menu_position rule associated with them are not getting the joined-path history in their url alias.


texts: How can I create a new content type based on an attached format

texts:
I'm creating an intranet company portal website and the HR department requests I create a new Content Type/View for employee records. They sent me a document based on the format they would like. I was hoping to get some input on the easiest way of creating this content type/View

I uploaded the format to the following snapshot:

My questions are as follows

How can I format the Expiration Date field to align to the right of it's specific corresponding field
When adding new content with the HR content type, is it possible for the user to click "Add new Incident/Disciplinary/Recognition field"? For example, start with one field for each but if the employee has earned more rewards etc they can add a new field?

Thank you for your help


texts: How do I count the number of products in cart programmatically?

texts:
I have created the custom block, here I want to count the number of products which is presented in the cart and tried with commerce_cart_order_load function to get the user selected products.

Is there any other methods to count the number of product in cart ?

Please help me how to achieve this !


texts: How can I get a count of users with a certain role?

texts:
I have a rather complicated profile completion process on my site.  As users create their profiles, they are awarded more roles.

For my own information, I'd like to be able to quickly check the number of users with role ABC.  I'd also like to be able to quickly know how many users have role ABC and role XYZ, as well as how many users have role ABC and role EFG.

Is there a quick way to do this in Views or some other module?  I don't want to see a list of all users; I just want to know how many have a given role (or combination of roles).


texts:
I'm new to Drupal. I'm trying to make a work calendar.

I need to make weekly events in the calendar. And that's working real well but now I want to exclude dates from an event.

Is there a way to select more than one date at time?


texts: Show Taxonomy Name not TID in Views Query String

texts:
I'm using Views exposed filters (dropdown) based on Term Reference (taxonomy Fields.)

It works but the query string it generates uses the Term ID (TID) instead of using the more readable and clean term name.

How do I change the query string to use the term name instead of TID? For example:

Current: http://test.com/test?gender=1

Desired: http://test.com/test?gender=female


texts: How to translation webform mailchimp compenent checkbox label

texts:
How to  translate webform mailchimp compenent  checkbox label.

I tried translate interface, edit.po file but not translated.


texts: How to translate my drupal site in other language.

texts:
My drupal site is in default English language and I have added Spanish and German languages using Internationalization and Locale Modules. When I switch to other language using Language Switcher block placed in header of my site, It translated Drupal Interface like admin menu and other core displays, but does not translate nodes or module pages which I have added. I have used t() function to display page contents or titles and its not translating them using t function.

The code for the page which I have added is as:

function MY_MODULE_menu() {
     $items['fee/per'] = array(
    'title callback' => 'attendance_og_get_title',
    'title arguments' => array('calendar'),
    'description' => t('Shows attendance percentage recorded per day for a group in a calendar.'),
    'page callback' => 'attendance_og_calendar_page',
    'file' => 'fee_management.pages.inc'
  );

    return $items;
}

function attendance_og_get_title($c) {
    return t('!entity_type Attendance Report (Aggregated)',  array('!entity_type' => ucfirst('Some Name ' . $c)));
}

File fee_managemen.pages.inc.

 function attendance_og_calendar_page($entity_type, $etid) {
       return array(
        '#prefix' => '
' .
        t('This view shows the percentage attendance recorded per attendance day in this group. An attendance day is a calendar day in which attendance was taken.') . '
',
        '#markup' => '
' . t('Loading.. I am loading here') . '

',
      );
}

Please help me to get this working.


texts: Drupal Behaviors uncaught reference error

texts:
I'm using Drupal 8.

What I'm trying to do is:

Access the active node
From the node get the value of field_test and assign it to a variable
Pass the variable to the drupalSettings function and subsequently to a custom module 'mycustommodule' that triggers an alert

In my content type, I created a field_test field, which is the field I reference in my code. The block is placed on a page of this content type.

This is the JavaScript code I am using.

mycustomblock.libraries.yml

custom:
  version: 1.x
  js:
    js/custom.js: {}
  dependencies:
    - core/jquery
    - core/drupalSettings

custom.js

(function ($, Drupal, drupalSettings) {
  Drupal.behaviors.mycustomblock = {
    attach: function (context, settings) {
      var testMe = drupalSettings.mycustomblock.test;
      alert(testMe);

  }
};
})(jQuery, Drupal, drupalSettings);

The error I get from the JavaScript console is this.

The error message is referring to this line.

Why is the instance of Drupal in the closing parenthesis throwing this error?


texts:
Is it possible to make a template based on node content?
For instance, is it possible to page--[node-type]--%.tpl.php or block--[content-type].tpl.php or page--[content-type]--%.  I tried node--[content-type].tpl.php but to no avail.  When I use the theme developer module, it shows me that my content is being created as a 'block.tpl.php' template.

What I want to do is theme the content of node name 'vehicle'. I want to put custom headings, styles and classes for divs in, and display suite is not giving me these options.  Any other suggestions would be awesome.

Thanks


texts: Alter existing dynamic route to a different route with a User Parameter

texts:
In the Open Social distro when you click on an author link it takes you to /user/[uid]/stream. This path is a path to a view. The social_user.routing.yml file includes:
  path: '/user/{user}/home'
  defaults:
    _entity_view: 'user.stream'
  requirements:
    _user_is_logged_in: 'TRUE'
    _custom_access: '\Drupal\social_user\Controller\SocialUserController::accessUsersPages'

In Open Social, the path 'user/{user}/home' redirects to 'user/{user}/stream' and I would like to change it so that it redirects to '/user/{user}/activity'. This path uses a custom view I have made.
In my custom module I have created a wfto_main.services.yml file containing:
  wfto_main.route_subscriber:
    class: Drupal\wfto_main\Routing\RouteSubscriber
    tags:
      - { name: event_subscriber }

And then a RouteSubscriber.php file at wfto_main/src/Routing containing:
  namespace Drupal\wfto_main\Routing;

  use Drupal\Core\Routing\RouteSubscriberBase;
  use Symfony\Component\Routing\RouteCollection;

  /**
   * Listens to the dynamic route events.
   */
  class RouteSubscriber extends RouteSubscriberBase {

    /**
     * {@inheritdoc}
     */
    public function alterRoutes(RouteCollection $collection) {
      if ($route = $collection->get('social_user.user_home')) {
        $route->setPath('/user/{user}/activity');
        //$route->setDefault('_entity_view','teaser');
        $route->setDefault('_controller', '\Drupal\wfto_main\Controller\WFTOUserController::alter_edit_route');
      }
    }
  }

And finally a WFTOUserController.php file at wfto_main/src/Controller containing:

  namespace Drupal\wfto_main\Controller;

  use Drupal\Core\Controller\ControllerBase;

  class WFTOUserController extends ControllerBase {

    /**
     * Function to redirect the edit route to custom route
     */
    public function alter_edit_route() {
      $uid = \Drupal::routeMatch()->getRawParameter('user');
      return $this->redirect('social_user.user_home', ['user' => $uid]);
    }
  }

However, this code is not having any affect and the author link is still redirecting to '/user/{user}/stream'. I am a little bit unsure about my code in the WFTOUserController.php file and also if I need to set any more defaults in the RouteSubscriber.php file?


texts:
I am trying to display the themed username in a custom block.

MyCustomBlock.php:

public function build() {

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

  $usersFromQuery = [];

  foreach ($usersData as $id => $value) {
    if (some logic) {
      $usersFromQuery[] = User::load($id);
    }
  }

  $userList = \Drupal::entityTypeManager()
    ->getViewBuilder('user')
    ->viewMultiple($usersFromQuery, 'compact');

  return $userList;

}

This gets me all the users I need, but not the altered/themed username I need.

In MYMODULE.module I am altering the username.

I've also tried:

$users = User::loadMultiple($userQuery);
User::load($uid)->getDisplayName()

but the username is rendered without hook_preprocess_username() alters.

I think the issue is similar to needing this: https://drupal.stackexchange.com/a/278717/79805

$variables['userName'] = [
  '#theme' => 'username',
  '#account' => $account,
];

but I am unsure how to get the themed username in my block.

How can I display the altered username in my block?

Update:

Using a helper function in MYMODULE.module that creates the markup for the altered username, and ->setUsername(), I am able to change the username in my custom block.

foreach ($usersData as $id => $value) {
  if (some logic) {
    $userItem = User::load($id);
    $userItem->setUsername(markup($id, $userItem->getUsername()));
    $usersFromQuery[] = $userItem;
  }
}

But is not really an answer to the question.


texts: searching on List (integer) field for values greater than than selection (drupal 7)

texts:
i'm working on a site for a real estate company which involves a search form.

i've got a view set up called search results and have set an exposed form (form in block) with a field to search Number of Bedrooms.

Its set up in content type as
Search Number of Bedrooms   field_search_number_of_bedrooms List (integer)  Check boxes/radio buttons

with the following content

Content:                                                                          1|1 Bedroom
2|2 Bedrooms
3|3 Bedrooms
4|4 Bedrooms
5|5 Bedrooms
6|More than 5 Bedrooms

in my search filter i get the following
Is one of
Is all of
Is none of
Is empty (NULL)
Is not empty (NOT NULL)

whereas i'm looking for the same filters that you'd get for an integer field.

is there a better way of allowing the editor to assign a number of bedrooms in the content type using a select list (so i can store the integer but display the label in both the admin and the exposed form)?


texts: How to prevent users from adding content without putting the site into full maintenance mode?

texts:
We are planning a scheduled update of our site. There is no reason for people to not be able to see the site as anonymous users, or even browse their account if they want to log in.

How can I simply prevent people from adding new content while I do the updates instead of having the site completely down from having to use maintenance mode?


texts: How can you style the login page in drupal? I changed permissions to only allow authenticated users into the site but the login page is plain.


texts: Is there any way to add some jQuery animations in each slide of a slider created with Views Slideshow module?


texts: Update failed on Metadata module, any easy fix?

texts:
I am very sorry to bring a rather nebulous question here but need any and all help I can get:  for the first time, I've had a "White Screen of Death" issue when trying to update a module.  I believe it was the "Metadata" module but I don't even remember for sure.  I had a previous backup of the database and site files/folders from a day ago, so I didn't make one this time.  Followed the Drupal tool for downloading, installing, and...presto....White Screen of Death.

Trying not to panic, I reverted to the older backup.  Which I hoped would solve the issue.

Yet it did not.

So my question is whether perhaps (fingers crossed!) there's additional steps I need to take once a backup is in place to get things working again.  I tried truncating every "cache_..." line via PhpMyAdmin, but it didn't help.  I tried the "update.php" in the URL hoping it was (maybe) just an index.php issue.  Again...no dice.

I've seen a long page about WSOD possible issues but don't want to just muddle around doing that if I don't know what I'm doing, which I don't.

Are there any suggestions for quick, simple things I've either forgotten or could try to get this working again?  And if I can't, can I manually copy files and folders over somehow and try again?

Thank you all in advance for any help.  I really appreciate it.  Stay healthy out there!


texts: Contextual Filter on View not showing through Panel Pane

texts:
I'm having trouble getting the contextual filter on my view to show through a panel pane. I want it to show a list of contacts tagged to a topic. The page that the view pane is on will be for the topic. For example, I have several contacts tagged for 'cats.' If I make a 'cats' page, I want those specific contacts to show up in the view pane. I also want this to work for other topics/tags.

I have set the Views display to show as a content pane. The view also works in the preview but it won't show up on the page. Is there a reason it isn't pulling the argument? How would I get this to work?


texts: Add to cart all product in views - Uber Cart

texts:
Hi Everyone, I'm using Ubercart for my site.

I have some products. So now I want to build a views that display products as a

table, in this table each row has a column named "quantity", allow user decide

how many product he want to buy.

At the bottom of this view has "add to cart button", so It will add to user cart all product has quantity > 0 in this views.
Like that

Product 1
$10
Quantity : textfield

Product 2
$20
Quantity : textfield

--Add to cart button--

How can I do that. Thanks


texts:
I saw in a YouTube video someone had made a configuration where if there was a PHP bug in their module, upon cache rebuild it would show the error underneath the "The Website Encountered an Unexpected Error" screen.

I've been running dual screens monitoring the php error log - but would actually prefer to consolidate it into that one screen.  Where is that configuration option found?


texts: How to create an Enquiry form with ability to submit a collection of enquiries

texts:
I am building a new site which has a large selection of different products/services on offer, the information for each is shown in  it's own node.
If the user has interest in a number of these services then I would like to give them the ability to 'add' the item to their enquiry along with a message. When they have added all of the items they are interested in they can then submit the enquiry.
Overall, the process shares similarities with an e-commerce workflow

View product
Add product to enquiry form builder with comment  (choose options and add to cart)
Browse other products and repeat steps 1&2.
Once happy, review enquiry (checkout)
If all is ok, submit enquiry (process order)

Using Drupal 7, how would you suggest I tackle this?
I only compared the process to e-commerce as it helped me think things through, the site isn't actually going to be selling the products. Strictly a tool to submit a detailed enquiry.


texts: On my inherited Drupal 6 site when I go to edit or add a news story 'Input format' is available for the Teaser, but not for the Body. I would like it for both or if it can only for one, have it on the Body so that I can choose an option such as 'Full HTML' so that images display. How do I achieve this?


texts: How to count elements grouped by an specific field?

texts:
I have a view with elements grouped by some categories, I would like to add the number of elements grouped in the same category, something like this:

Categ A (2)

element
element

Categ B (3)

element
element
element

I tried with aggregations but I didn't get the result I was looking for. Is there any way to resolver this?


texts:
I constructed my admin/content page using my custom module

Steps i follow
 1. retrieve data from multiple tables and displayed it in table
 2. I gave edit and Delete options

From admin/user edit and delete options working good

Now my question is i logged in as authenticated user how to disable edit and delete options for admin created pages.Only user will see edit/delete option for his own created pages.Thank you


texts: Are there resources about the Drupal page loading sequence and when key hooks are fired?

texts:
Is there a source for information on the flow of Drupal in its doe and when/where hooks are called?  Many questions are answered stating that you can use a certain hook (eg. hook_page_alter or hook_menu) to change something and the API documentation is pretty good at explaining what the hook is about, and shows locations where the hook is implemented, but not where/when the collected hook array additions and changes are applied as Drupal loads a page.

I want to uncover two things:

The flow of Drupal in the code to see the locations in Core where the call to the list of modules that have implemented a hook are fired.
Find a detailed diagram/explanation outlining the flow and the locations in the sequence where hooks are fired. (If it does not already exist I would like to create one.)


texts: Field gets unset and fails validation in user edit form

texts:
We have a special date field that we set upon user creation when our custom user form is submitted. The user does not have to set this field themselves.

We have a separate form, which is a user edit form. We build this form using a form_alter() hook that looks for the default user register form.

For some reason, even though this special date field is hidden on this form, validation runs against it as if the form has been submitted with a blank value, and we get the error (on the frontend of the form)

  There are errors in verification code created on value #1:
  The dates are invalid.

I found a way that "works" to get around this,

$form["field_special_field_created_"]['und'][0]['#element_validate'] = '';

But I think that this is pretty ugly. Why only this field? why can't this field retain its original value?

Since this special field date needs to stay the same, I need to find a way to make it work like the other fields do.


texts: How to know when to use $config or $settings overrides in settings.php?

texts:
I want to be able to disable certain options of modules on non-production environments.

For example:

Disable XMLSitemap from running
Set "Read Only" mode for Search API indices to TRUE
Set robots.txt string to

User-agent: *
Disallow: /

How do you know whether you should override $config or $settings in settings.php?

Would it be:

$config['search_api.index.acquia_search_index']['readonly'] = TRUE;

or

$settings['search_api.index.acquia_search_index']['readonly'] = TRUE;

Also, how can you confirm if these overrides are working? Is there an admin overview page that lists these things?


texts: Tokens or token types missing name property

texts:
I am having issues in tokens, sometimes they stop working and are not available for use. When I browse the tokens only these are available.

After I check the status report, I can see the following message.

Tokens start working automatically, but I am not able to find out why they are not working and why they start working on their own.
I tried clearing the cache many times, but it doesn't help.
Note
This is a duplicate question being asked by me, but I am posting here as it is Drupal specific and I am not able to find the working solution for this.


texts: How do I make twig variables available in node.html.twig accessible in my html.html.twig?

texts:
I have a boolean field on my Content Type called 'field_bootstrap'. I have some twig logic in my node.html.twig file that, if the field is set to true, includes Bootstrap via HTML inclusion.

What I need is the ability to use my {{ node.field_bootstrap }} logic in the html.html.twig template, instead of the node-level template. This would allow me to reference Bootstrap's CDNs properly in my document's head, rather than its current position in the middle of body.

I assume I need to build a preprocess in mytheme.theme to make something like {{ custom_twig_variable }} available for use in html.html.twig but I'm a little lost on how to complete this :)

Thanks everyone!


texts: Taxonomy terms are not listed in the order of their weight

texts:
I have a multilingual site and each language has its own taxonomy terms. In node/add form terms of the current language are displayed.

I ordered tags in alphabetical order and also set weight for each one to make sure each one is in a right position. Terms are in right order in admin/structure/taxonomy/tags But in  node/add form terms are displayed in a random order and on each page refresh a new order is displayed. How can I order the terms?


texts: Creating Preprocess function to add extra classes dependent on field value

texts:
I have a content type called "article" and I have a field called "text color" and I want to add this text color field's value as a class to either the body or content container and change the text color of the content.

Which preprocess function should i go about using?
Is it possible to just do an inline style using the text color field's value so i don't have to also edit my css file too?
Or is there another elegant way of doing this without using a preprocess function?


texts: Context condition per menu (not menu item)

texts:
I'm using Context module on Drupal 7 to show menu block on pages that's listed in that menu only.

Everything's good, I set 'Menu' condition and reaction is to show the block in some region, but the problem is that I must select menu items in condition and since items changes all the time I need to update Context all the time.

Is there some solution to select menu and not menu item, or to select menu item and automatically to include all submenu items?


texts: Extend an existing Views filter (NumericFilter) throws exception

texts:
I am trying to do something that should be easy in Views but I can't seem to be able to make it work.

I need to create a filter on top of the existing NumericFilter (Drupal\views\Plugin\views\filter\NumericFilter), but with a minimalistic approach like the following it is simply not working.

<?php
// @file src/Plugin/views/filter/FoobarProjectSizeRangeSelectionFilter.php

namespace Drupal\foobar_extra\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\NumericFilter;
/**
 * Class DateYearFilter
 * @ingroup views_filter_handlers
 * @ViewsFilter("project_size_range_select")
 */
class FoobarProjectSizeRangeSelectionFilter extends NumericFilter {
}

The way I use is is pretty straight forward:

<?php
// @file foobar.views.php
/**
 * Implements hook_views_data_alter().
 */
function foobar_views_data_alter(array &$data) {
  // clone an existing field
  $data['node__field_a']['field_a_value_range'] = $data['node__field_a']['field_a_value'];
  // change name and filter ID
  $data['node__field_a']['field_a_value_range']['title'] = t("Foobar");
  $data['node__field_a']['field_a_value_range']['filter']['id'] = 'project_size_range_select';

  return $data;
}

Whenever I try to save a view using this filter plugin i get the following error:

InvalidArgumentException:
 The configuration property display.default.display_options.filters.field_a_value_range.value.min doesn't exist.
 in Drupal\Core\Config\Schema\ArrayElement->get()
 (line 74 of ROOT/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php).

Right now I have "worked around it" implementing some custom and terrible hacks, but i'm pretty sure this is so simple that it should just work.


texts: How to add alt and title attributes to an image gallery View?

texts: I am using Views to generate an image gallery. Each image is linked to the content the images comes from, but what I would also like is to add alt and/or title attributes to each of the images. How would I go about doing this?


texts: Adding multiple links to the same table cell

texts:
I am struggling to add multiple links to the same table cell, my current code looks like:

use Drupal\Core\Link;

$row[] = [
  'data' => Link::createFromRoute(...),
  'class' => 'middle',
];
$row[] = [
  'data' => Link::createFromRoute(...),
  'class' => 'middle',
];
$rows[] = ['data' => $row, 'no_striping' => TRUE];

return [
  '#theme' => 'table',
  '#header' => [..],
  '#rows' => $rows,
];

I've cut down the code to the relevant parts each element of the $row variable is a new cell and each element of the $rows variable is a new row. I need to use the data attribute as I have additional attributes on the cell.

At present this works perfectly fine, but my links are rendered in separate cells and I would like them rendered in the same cell. If I just to concatenate the 2 Link::createFromRoute I get the following error:

Recoverable fatal error: Object of class Drupal\Core\Link could not be converted to string

I've tried using the toString() and the toRenderable() functions and neither work as I want. Surely it can't be that hard?


texts: Hierarchical Select reset when I click add another item

texts: I have a custom content type that has an unlimited field. This field is from field collection type and it contains a field that is from taxonomy type and with a hierarchical select widget. When I want add a node of that type and choose a value for hierarchical select field and then click add another item the value of the hierarchical select will reset. What is the problem?


texts:
All I want to do is add a new <div>, ideally just after a <form> element.  I have a self-written module that generates a payment form, using some routing, like this:

mymodule.applications.payment_form:
  path: '/payment/{submission}'
  defaults:
    _form: '\Drupal\mymodule\Form\PaymentForm'
    _title_callback: '\Drupal\mymodule\Form\PaymentForm::getTitle'
  requirements:
    _role: 'authenticated'
    _custom_access: 'Drupal\mymodule\Form\PaymentForm::access'
  options:
    parameters:
      submission:
        type: entity:webform_submission

The PaymentForm class has a standard buildForm() method, and it's easy to add render arrays to the $form build form elements and other decoration etc. But those are all within the <form> tag.

The payment form is displayed in the main page content block.

I've been trying is HOOK_preprocess_HTML in my mymodule.module file and looking at $vars.

$vars['page'] contains the various regions: sidebar_first, content, secondary_menu etc.

$vars['page']['content'] consists of:

'mysite_page_title' => array(13)
'mysite_local_tasks' => array(3)
'mysite_help' => array(3)
'mysite_local_actions' => array(3)
'mysite_content' => array(12)
'#sorted' => boolTRUE
'#theme_wrappers' => array(1)
'#region' => string(7) "content"

mysite_content is a block - and I can't see how I can modify it from here...

I've also tried HOOK_block_view_BASE_BLOCK_ID_alter, which in this case is system_main_block (for the page content).

function mymodule_block_view_system_main_block_alter gives me a $build array with a #block element, but I don't see how I can find the <form> elements in there either and place something afterwards…

Anything else I can do?


texts: CKEditor Filter does not persist text after modifying

texts:
I wrote a filter class that strips out certain tags from the user input in the editor. For example it uses a regular expression to remove <span> tags of a certain class.

The steps I took were:

Create a custom module
In the module, create a class that extends FilterBase
Implement the abstract method process()
Return modified text wrapped in a FilterProcessResult object

I followed this tutorial.

The filter is called when I save a page with a WYSIWYG on it, and I've confirmed that it executes the FilterBase::process() function I wrote. I've also confirmed that it strips out the tags I need it to remove as expected before it returns.

Even though the modified text is correct, it doesn't seem to persist in the content of the WYSIWYG. For example, if I reload the edit page, I'll see that the tags that I removed are still there. What is causing this issue? How can I get it to persist on save?

On closer inspection, the filtered text only shows when I'm viewing the page I've created, but not when I access the WYSIWYG text programatically.

I fit matters, the filter is of type FilterInterface::TYPE_HTML_RESTRICTOR.


texts: How do plugins store their configuration/field data?

texts:
I'm creating a custom Commerce License and I notice that I'm handling defaultConfiguration(), buildConfigurationForm(), submitConfigurationForm(), and buildFieldDefinitions(), but I cannot figure out where in the database this information is stored. I know that it must exist somewhere as the data loads up when I view the entity, but I cannot seem to find it. It doesn't seem to have anything to do with Configuration that would exist in a sync folder despite the similar names.

I'd assume buildFieldDefinitions() has something to do with it, but I cannot seem to figure out exactly what that method is doing at all.


texts: How to pre populate a node add form with multiple field collection items?

texts:
How to pre populate a field collection field with multiple values?

I have a node type with a field collection field which has four fields and cardinality is set to unlimited.

In my custom module I implement hook_form_alter and assign default values to the collection inside a loop, but it displays only one field collection. I tried to set the cardinality of the field collection field to the number of items I want, but failed as I can't find a way to set the cardinality programmatically.


texts: Is json_decode parse-ability proof of a safe string?

texts: Do I need to use check_plain (or something else) when displaying a user supplied JSON string, when I have previously checked it successfully parses with json_decode?


texts:
I'm planning to migrate a non-Drupal website to a new one based on Drupal 7. The current website is using object oriented model classes. In addition I use Doctrine for database abstraction and object relational mapper.

I've been reading about Drupal nodes, entities and content types and now I need to decide how to integrate my Doctrine entities in Drupal. Here are some of my thoughts:

I'd rather keep my Doctrine entities because Doctrine offers a great way to set up relationships between objects.
I don't mind creating forms manually (html,css,js) for each of my entities. It seems to me that using the drupal hook for altering content type forms is less elegant.
In the current website the users are Doctrine entities as well. I'm wondering if it would be okay to add a field to the default drupal user and reference my doctrine user id there?

In general, I want to avoid bad design decisions. I understand that not using nodes for the model in Drupal seems strange, but would managing your model separetely from Drupal be considered as a bad practice?


texts: How do you change the core forum module to only show a certain depth?

texts:
I am using the core forum module. If I have this forum structure:

- A1
 - A2
  - A3
- B1
 - B2
  - B3
- C1
 - C2
  -C3

I want it to show A1, B1 and C1. As well as A2 and B2. But not A3, B3 and C3.

I checked the forum-list.html.twig file, but before I start hacking away, I was wondering if there isn't a more obvious hook of some sort I could use to do this?


texts:
I have both Apache Solr Search and Search API modules installed on drupal 7.  I have installed SolrPhpClient version r22 (that was recommended in a site vs. r60) in sites/all/libraries/libraries folder.

When I place XML files from Apache Solr Search on Solr Server, Search API would not index. When I place XML files from Search API on the server, Search API seems to work fine but I get Your site was unable to contact Apache Solr server error message on Status Report. In this case I can see mysite:8983/solr/admin but when I click on PING button it shows 500 error message.

Is this supposed to be this way? Can I trust the Search API working fine (is the error message pertained to Apache Solr Search not having its XMLs on server and can be ignored)? Any suggestions to fix this?

Any help would be greatly aprectiated and let me know if you need more info.

Thanks alot.


texts: How to add site Validation for all pages

texts:
I want to implement google site validate meta tag on each page page of my site. I tried Site_validation module but its allows to implement the google meta tags only on front page.
Could anyone help me?


texts: Is there a non-WYSIWYG-module that lets me use Media ver. 2 images with multiple image styles?

texts:
I have a library of images that I access for reuse via the Media (ver. 2.0) Browser and attach to nodes using the file field. When I use an image inside a node, I want to indicate a specific Image Style (e.g. "Thumbnail", "Medium", etc.).  The out of the box setup of D7 let me specify one (1) image style to be used for a field in each display mode (i.e.  "Default" and "Teaser"). I want to be able to choose between image styles.

I may want to use the "Medium" style for the first image field in one node, and "Large" in for the first field in another.

After some googling, I've found some suggestions for doing this, but they're all based upon using WYSIWYG for image insertion, and I don't want WYSIWYG.

Looking at the answer to Multiple image styles, I see that I can do get access to different image cache versions of an image through either template file or hook_preprocess_node() - so I should probably be able to do this with a custom module that manipulates the image field render object during preprocessing.

However, before I embark upon writing such a custom module, I want to ask if this module (or something similar to it) already exists?  I have searched for it, but so far found nothing that does not use WYSIWYG.