Drupal StackExchange

How do I set the PHP version for a contrib module with GitLab CI?

1 month 3 weeks ago

I'm trying to set up testing using the GitLab template for contrib modules.

In the module's composer.json, PHP 8.2 is required, and since the CI is currently defaulting to 8.1, the install fails.

So, based on the variables documentation, I tried adding the following to .gitlab-ci.yml:

variables: _TARGET_PHP: "8.3"

When I pushed and the pipeline ran, it was still at PHP 8.1.

So then I tried:

variables: _TARGET_PHP: "CORE_PHP_MAX"

Which according to the docs linked above is currently 8.3.

However, that failed too-- still stuck at 8.1.

How do I set the PHP version for GitLab CI for a contrib module?

Patrick Kenny

Pager labels aren't translated

1 month 3 weeks ago

I have a site using Drupal 8.4.1 with all core language modules enabled, 3 active languages, and where English is the default language. The pager labels (e.g. "Last »") for my own views aren't translated, although the string "Last »" is available in the translation page. I can manually translate the pager labels by adding a translation for the whole view and then overriding the pager labels, but I think this isn't the right way to do it because the built-in views (e.g. /admin/content) are translated just fine, without any manual override.

How can pager labels be translated without manually adding the translation?

tomhake1

Image styles - How to resize uploaded images and force an aspect ratio

1 month 3 weeks ago

I'm looking for a solution to resize uploaded images while maintaining a desired aspect ratio instead of cropping them.

We can configure some preset Image styles, but it seems we can only :
Resize : Will force an exact set of width/height dimensions which can cause images to be stretched or shrunk disproportionately and loose.
Scale and crop : will maintain the original aspect-ratio of the uploaded image, which can be different from the desired aspect ratio.

So is there a way to force a certain aspect ratio to uploaded images, by adding a white background for instance ?

Decoy_Octopus_

Fixing identical Latitude/Longitude data for markers on maps (bug)

1 month 3 weeks ago

I have a Drupal 7 project that I want to add location information (latitudinal/longitudinal) to most of my content types. Currently I have noticed that if there are multiple nodes that are shown on a map and if any of those nodes have identical latitudinal/longitudinal data, then the map markers are overlaid on top of one another and only the top map marker is visible. The markers under the top most marker can't be accessed (clicked to show data).

This essentially hides content, which is a type of bug, and if the content is hidden, most times you won't realize it is a problem.

This becomes a serious problem when you are generating map data from address locations. The user can be very vague with their address, and simply put their country ie: "Mexico". If other nodes are created with such vague data then the overlap problem occurs.

One was around this is to use the module "Google Map Field", which allows the user to use a map with a map marker when creating or editing content to specify where the node is referring to. The lat/long data is generated behind the scenes. It is very hard to get duplicated lat/long data when selecting the location on a map with a map marker. One problem with this is that the "Google Map Field" also allows them to enter their location by address, (ie:Eugene, Oregon, USA), if they don't want to do it with the map/marker. An admin can put a nice label on the field saying to only use the map/marker, and not put it in by address, but people often ignore instructions on labels.

We also need to have location (lat/long) data for Users "Profile2" profile. One problem with this is the "Google Map Field" does not work with Profile2, and gives a recursion error. The only way around this is to make the user put their lat/long data in by hand (not going to happen), or do it like we are currently doing it, where the user puts in their address and the lat/long data is calculated from that address. Again the problem where users can put in vague address location information and cause duplicate lat/long data that cause map marker obfuscation.

I have not seen any good solutions for this. I have thought of some custom solutions (some I don't know are possible, and currently purely hypothetical)

1)For "Google Map Field" somehow disallow the inputting of the location information through the address textbox, thereby forcing them to enter their address information from the Map/Marker. I am not sure what best ways of doing this are...Change the available fields for the module manually? Find a different contributed module that allows you to deny certain fields for nodes being created or edited? (does such a module even exists?)

2) A possible solution would be to create a module that goes through the Drupal database and finds tables that have latitudinal/longitudinal coordinates that are attached to content types. The module would check for identical latitudinal/longitudinal coordinates that were identical and change their coordinates ever so slightly (like adding a one-one-hundredth of a degree to one of the identical coordinates, there by making them non identical. Experimenting with this manually, I was able to change one-one-thousandth of a degree to one lat/long row for identical location coordinates and this corresponded to about a 1 block change in location (thereby making the 2 markers have different locations on the map). If you set this module up to perform this calculation and data alteration every time cron is run then you would then solve your identical lat/long data problem.

One potential problem I have thought of is that we would like, in the end to have our profile2 profile data synchronize with our Salesforce data, and if that was the case, then if the Salesforce data was altered, it would synchronize with our Drupal data, and then the lat/long data could potentially overwrite our changes our custom module made, thereby adding identical lat/long data (sort of un-fixing our fix). If we did have our Profile2 data synchronizing with Salesforce (which would sync every cron run), I had considered finding a way to make sure our custom module was run AFTER the Drupal/Salesforce sync module ran.

I'm posting these hypothetical solutions to you, the Drupal community because it is possible that one of you have already solved this problem, and have just not posted anything about it, or you might have a strong opinion about one of these solutions, one way or another. It might be possible that you have encountered this problem, but had no solution, even hypothetical in mind, and this posting to this forum helps you in some way.

Please, I would love to hear alternative solutions, opinions about my hypothetical solutions, or thoughts in general about this identical location map marker overlay problem.

Sincerely,

David Pugh

David Pugh

how to access webform submission data from a custom content type

1 month 3 weeks ago

I 'd be grateful if someone could help with this..

I have a webform, let's call it input form, which, when submitted, triggers an external application to run on my server. That application uses some of the submission data (reading from webform_submission_data table) and after some time produces an output in the form of XML.

Now, through the use of feeds module, I read that XML data and produce a node, of a certain content type, let's call it results CT ..

I have a twig template for the results content type, and output is nicely presented to the user.

So far, so good.

Now my problem is this. I need to show both input and output in the same results page.

I tried to use Webform Content Creator module and indeed I have nodes with submission data - let's call this input data CT.

However, at the time of input form submission, I don't have the results yet. And I want to link the two together, obviously upon the creation of the results node.

I tried to reference each content type, using Corresponding Entity References so that when a results node is created (automatically through feeds) it would link to the corresponding input data CT. I thought that if I can achieve that connection, then I would be able to access the 'input' data through the results page template.

However, I can't make this connection to work - the 'entity reference' field that I use on the results CT, wants an 'entity ID' - and I can't find that. Remember that nodes are created automatically, I don't have a user creating nodes via a select form or autocomplete text field.

I am trying to figure out how to do this through the sid (submission id) which seems to be a unique key for every submission, and I have this on both my content types .. So ideally I would like to use the sid that I have on my results template, and use that to get the submission data I need.

(obviously) I am not very familiar with the drupal API - I am however comfortable with twig .. I don't know if (and how) I could pass that information through a pre-process function to be available in the results template.. Is there a simpler way to do it?

Could I link two content types based on a custom field (say a unique number, like sid ??).

Ideally, in a few words, what I want is this:

I have a CT (results) with various fields, one of which is sid. That sid corresponds to a (unique) submission id. How can I access data relevant to that submission id from within the results twig template? So I can then present both input (submission data) and output (results) in the same page.

PS - Perhaps one solution would be to refactor the whole logic, and use one CT for both input/output. Insert some data upon form submission, and then, when results are ready, edit (i.e. fill-in) the rest of the 'output' fields via feeds. Then all data are in one CT. However I would rather avoid this as it's quite a big change .. Shamefully enough, I might just re-enter input data through the XML again - it wouldn't be a problem - but it's a really crap solution ..

I 'd be really grateful if someone could help .. I hope I explained the whole situation adequately enough ..

thomas

Cannot add CSS class to views field

1 month 3 weeks ago

I have a view in Drupal 8, and have configured a field in the view to have a custom CSS class.

The field I am adding the class to is an image. Under Style Settings I have chosen "Customize field HTML" and "Create CSS class".

When I inspect the image element on the front end, the class is nowhere to be found, and the styles are not applied.

I also have a view fields template for this view named:
views-view-fields--home-page-top-three-stories.html.twig

{{ fields.field_story_preview_image.content }} <div class="story-title-box"> <h3>{{ fields.title.content}}</h3> <h4>{{ fields.field_subtitle.content }}</h4> </div>

"fields.field_story_preview_image.content" is the image field that I would like to apply the CSS class to. Am I missing a configuration step?

Why isn't the CSS class being applied to this image field?

crayden

Dynamic filters based on another filter

1 month 3 weeks ago

I am looking to create something similar to this http://www.smartoplug.com/partsearch I need my view to sort based off of multiple parameters. So if you select ford in the make, the models dynamically change to only show models that are referenced in ford i.e. F150, F250 etc.

I've looked into hierarchical select, and simple hierarchical select, but it doesn't look like what i am wanting to accomplish

SoundCheese