How can I create an image gallery?

1 month 3 weeks ago

Currently I am running in D7 with the following modules:

  • Media 7.x-2.0
  • Views 7.x-3.7
  • Colorbox 7.x-2.4

I am trying to create an image gallery using these modules with the following steps. Please note problems I am running into will be in bold.

  1. Go to admin/structure/views
  2. Click Add new view
  3. Select File for show, and image for type
  4. Unchecked Create a page, and check Create a block
  5. Select Grid of File for Display Format
  6. Click Continue and Edit

This is where things go off the rails for me, what I would like to do is have ALL images that are tagged display in a custom image style I already created (200x200) in a 4 column grid, and when you click on them they open up into a normal sized image colorbox.

Now I have seen this done when you create a image content type, but that way is clunky compared to using the media module, and I have to believe that there is an easy way to do this with these modules, and I am simply missing it.

I have read about Media Gallery module, but there seem to be a lot of errors with it and I am not thrilled with the idea of it.

Any help on how to get what I am trying to do done would be greatly appreciated as this is becoming a bother.

otc61686

How can I return literal JSON from a node as a JSON object in views json?

1 month 3 weeks ago

I have a content type with a field called output. This field will contain JSON. I want to output this field as JSON using Views JSON (in Views Datasource). The problem I'm encountering is views datasource is a. wrapping my field in quotes, and b. escaping my double quotes...

[ { "content": "{\"account-confirmation\":{\"body\":\"\",...

I need it to return something like:

[ { "content": {"account-confirmation":{"body":"",...

I've tried everything I could possibly think of. Is there any way I can output the literal value of the field without wrapping the value in quotes and escaping quotes?

user3408649

Views Bulk Operations Checkboxes check on click

1 month 3 weeks ago

I do search for a specific option in bulk operations. For now, when I click somewhere in my row, the checkbox for the bulk operation gets selected, but I want a user to directly click on the checkbox. If he clicks somewhere in the row, it shouldn't select the row for bulk-operations. Any chance to do that without hacking the core?

In short: only a direct click on the checkbox should select the row for bulk operations.

Andi

View that shows all children content of parent

1 month 3 weeks ago

Been searching and cannot find this anywhere for Drupal 8. Very basic view request, can't figure out why it's not straightforward.

I want a View that shows Parent content and under it all Children content. Nothing to do with taxonomy, just want this to display in a view:

Parent Content 1
- Child content 1
- Child content 2
- Child content 3

When trying a contextual filter, I get "This display does not have a source for contextual filters, so no contextual filter value will be available unless you select 'Provide default'."

user92628

Implement hook_menu_block_tree_alter() to change CSS classes

1 month 3 weeks ago

I have installed the Menu block module. I am very happy with the result, but I'd like to change some classes in the structure.

This is what I get right now.

<div class="content"> <ul class="menu"> <li class="first last expanded"> <a class="active" href="http://example.com">News</a> <ul class="menu"> <li class="first last leaf"> <a class="active" href="http://example.com">Test</a> </li> </ul> </li> </ul> </div>

This is what I want.

<div class="content"> <ul id="nav-list"> <li class="first last expanded has-submenu"> <a class="active" href="http://example.com">News</a> <ul class="sub-menu"> <li class="first last leaf"> <a class="active" href="http://example.com">Test</a> </li> </ul> </li> </ul> </div>

Basically, I want to:

  1. Change the <ul>'s classes and attributes (This is level specific, so it's not the same for the primary/secondary <ul>.)
  2. Add the has-submenu class to an <li> if it contains another submenu

As explained in Menu Block's documentation, I implemented hook_menu_block_tree_alter() in the template.php file.

function THEME_menu_block_tree_alter(&$tree, &$config) { foreach ($tree as $key => &$value) { if ($tree[$key]['link']['access'] && !$tree[$key]['link']['hidden']) { $items[] = $tree[$key]; } } $num_items = count($items); foreach ($items as $i => &$data) { $class = array(); if ($data['link']['has_children']) { $class[] = 'has-submenu'; } $element['#attributes']['class'] = $class; } }

Any help would be much appreciated. I don't really have deep understanding of how and where to implement this hook function. Also my impression is that more detailed documentation is missing for this specific hook.

James Cazzetta

Looking for support

1 month 3 weeks ago

After a long illness and hospitalization, I have resumed the maintenance of the D7 website of a small patient association. Migration to D10 was partially successful. Article content has been transferred, but photos are still missing. Where can I place a call for someone who can help me specifically? The aim is to be back online quickly and then take the time to keep up with the developments of Drupal of recent years.

Sorry if this is not the place for this question.

MarkDQ

How to disable/hide submit button in webform based on a computed_twig element's value

1 month 3 weeks ago

[sorry for the length of this message, I tried to provide a concise decription of my problem in order to make it easier for people to understand and help]

Hello all,

I have a webform comprised of 3 pages (two pages of input and a custom preview page).

I explain the whole webform in order to make my question more concise:

My first page has 4 inputs, all required (1 text field, 3 select fields). This works fine.

My second page is a little bit more complicated.

It has three 'triples', each triple consisting of: one checkbox, one select, one number.

None of these is required. The logic is that when one checkbox is checked (default value is unchecked), the subsequent select and number will be enabled, otherwise they are disabled (default).

You can find the code for one of these triples in the end of my post - the other two triples are similar.

This works ok, but my problem is this:

A valid submission should only happen when: a. at least one checkbox is checked AND b. the total sum of all number fields is in the range 3-30.

Note: I can't simply force each number field to accept values in the range: 1-10, because user should be able to give up to 30 in one field and 0 on the other two.

I have used a computed_twig element and appropriate templates, and I have managed to put all my logic there and I show an appropriate message to the user. This works ok, so I have managed to print a green message when values are ok, and appropriate messages in red when values are invalid (if total sum is less than 3, or greater than 30 etc etc). I have covered all cases having enabled "Automatically update the computed value using Ajax" for the computed field, it updates on-the-fly and user has correct information on whether data is OK or NOT.

Now the problem and my question is:

I have been trying to hide the submit button, by selecting appropriate logic in the 'conditions' tab of the submit button. For example, something easy like "hide" or "disable" submit button, when pressure_total_thickness (computed twig value which holds the sum of individual number fields - same computed field which I successfully use for my messages) is greater than 30 ..

Problem is whatever I do there, the submit button is always present ...

In a few words, what I want to do is validate data as much as I can in the front-end so that I don't allow invalid submissions. I can do checks in the back-end (because data will subsequently be fed into another software) but it would be nice to do as much validation as possible in the front end and not allow submissions when data is invalid. Hence, use my computed_twig value which holds the sum of three number fields, and only show submit button when that value is between 3 - 30.

For example, here is the page with all three 'triples' - user has checked 2nd and 3rd checkboxes and supplied 15 and 30 values respectively. Total is 45, which is invalid and appropriate red message is written:

however, when user goes forward and reaches submit phase, the submit bitton is present although I use following condition to 'hide' it (have tried 'disable' in cindition, but same result - submit button was shown).

Here is the simple such condition for the submit button, trying to 'hide' it:

I tried to find documentation and/or previous questions/answers, but could not find anything relevant..

I must be doing something wrong, but I can't find any way out of this ! ..

Webform is an amazing module, I am sure there is an easy way to achieve what I want. Any help would be appreciated!

Code for one of the three 'triples':

enable_insole: '#type': checkbox '#title': 'Enable Insole' '#description': 'Please enable insole if you want to enter custom values below for material and layer thickness.' select_insole_material: '#type': select '#title': 'Select Insole Material' '#options': 1: Leather 2: 'Composite leather & elastomer' 3: EVA 4: Polyisoprene 5: 'Natural Rubber' 6: Polychloroprene 7: PTFE 8: PU-Foam '#states': disabled: ':input[name="enable_insole"]': unchecked: true '#default_value': '0' insole_layer_thickness: '#type': number '#title': 'Insole Layer Thickness' '#help': 'See general help on choosing appropriate values for layers.&nbsp;Individual thickness for insole/midsole/outsole can have a range of 1-30 (mm), but total thickness of all layers&nbsp;&nbsp;combined cannot exceed 30 (mm).' '#states': disabled: ':input[name="enable_insole"]': unchecked: true '#default_value': '0' '#min': 0 '#max': 30 '#step': 1
thomas

Altering the type of a menu item to local task (tab)

1 month 3 weeks ago

I've searched for hours but I can't find a good answer on how to alter the type of a menu item to local task (tab).

The private messages 7.x module (when aided by privatemsg_filter) exposes the following tabs (local tasks):

  • Inbox (/messages)
  • Sent Messages (/messages/sent)
  • All Messages (/messages/list)

There is a 4th menu item (/messages/new) which is currently a MENU_LOCAL_ITEM and I want to make it a local task as well. But how? And what is the best way?

Druvision

File_managed URI change not working

1 month 3 weeks ago

Is there a way i can make file_managed URI changes in the database?

I the database i have a list of files and there is append a _1 or _2 to the URI file name.i wanted to clean these up and remove the _number so there will be only one file but when i change it i get an error unable to write row duplicate entry for uri key.

Terry

Drush not connecting to site's settings.php

1 month 3 weeks ago

When I run drush --debug status in the docroot of my Drupal site, I get the following message:

[user@computer]$ drush --debug status Phar detected. Proceeding to drush_main(). Loading drushrc "/home/user/.drush/drushrc.php" into "home.drush"[bootstrap] scope. [0.02 sec, 3.54 MB] Cache HIT cid: 8.1.14-commandfiles-removed [debug] [0.03 sec, 3.59 MB] Bootstrap to phase 0. [0.28 sec, 9.55 MB] [bootstrap] Trying to bootstrap as far as we can. [0.28 sec, 9.56 MB] [debug] Found command: core-status (commandfile=core) [0.28 sec, 9.56 MB] [bootstrap] Loading outputformat engine. [0.28 sec, 9.56 MB] [notice] Calling hook drush_core_status [0.29 sec, 9.85 MB] [debug] Returned from hook drush_core_status [0.38 sec, 9.86 MB] [debug] PHP configuration : /etc/php.ini /home/user/.drush/drush.ini PHP OS : Linux Drush script : /usr/local/bin/drush Drush version : 8.1.14 Drush temp directory : /tmp Drush configuration : Drush alias files : /home/user/.drush/aliases.drushrc.php Command dispatch complete [x.xx sec, x.xx MB] [notice]

As you may see in that output, "PHP Configuration" has two entries where as "Drush configuration" has none. And that one of the entries for "PHP Configuration" looks like the entry that should be in "Drush configuration".

I did run it within the docroot of Drupal. And I have even tried in sites/default. Plus, I have even tried my aliases and none of them are working. This all worked before though with another Drupal site. It just stopped working after I transferred the Drupal files from one server to another. I thought my permissions were correct but they don't look correct. Plus I have even tried adding --uri and --root to Drush and that didn't work either. For the transfer I used rsync options avzp.

drush -d pm-info give's the following:

[user@computer]$ drush -d pm-info Phar detected. Proceeding to drush_main(). Loading drushrc "/home/user/.drush/drushrc.php" into "home.drush"[bootstrap] scope. [0.02 sec, 3.54 MB] Cache HIT cid: 8.1.14-commandfiles-removed [debug] [0.03 sec, 3.59 MB] Bootstrap to phase 0. [0.27 sec, 9.55 MB] [bootstrap] Bootstrap to phase 6. [0.28 sec, 9.56 MB] [bootstrap] Command pm-info needs a higher bootstrap level to run - you will need[error] to invoke drush from a more functional Drupal environment to run this command. [0.28 sec, 9.56 MB] The drush command 'pm-info' could not be executed. [0.28 sec, 9.56 [error] MB]
Muskateer

Drupal 8 migrate fields not filled

1 month 3 weeks ago

I'm trying to migrate content to D8 site from sql source. In my migrate_plus.migration.node_article.yml config file I've following:

id: node_article label: Article Migration migration_group: node_migration source: plugin: node_article bundle: node destination: plugin: entity:node process: uuid: uuid title: title type: plugin: default_value default_value: article field_seo_title: title field_teaser_text: title migration_dependencies: {} dependencies: enforced: module: - my_article_import

(field_seo_title is a textfield) and NodeArticle.php:

class NodeArticle extends SqlBase { public function query() { //query code ommited } public function fields() { $fields = [ 'uuid' => $this->t('Unique Unique Identifier'), 'title' => $this->t('Title'), 'field_teaser_text_value' => $this->t('field_teaser_text_value'), 'field_seo_title_value' => $this->t('field_seo_title_value'), ]; return $fields; } public function prepareRow(Row $row) { return parent::prepareRow($row); } public function getIds() { return [ 'nid' => [ 'type' => 'integer', 'alias' => 'n', ], ]; } }

When I run migration, node is created, title get filled but all other fields are empty no matter what data I try to import. I spent almost a day trying to figure out why but running out of ideas. Does anyone have an idea what could be an issue please? Thanks

bluedrop

Not able to see &lt; character in front end

1 month 3 weeks ago

I am running into a problem when creating content with the < character… It is quite strange as the symbol is showed in the backend, when creating the content, but it disappear when you go to /node/%nid. Actually the whole text nodes, where the symbol is, disappears. I have disabled all the filters and the problem remains…

By the way, I have a Drupal 7 installation and cKeditor module installed, but switching to plain text editor doesn't make a difference.

Does someone has a clue of why this is happening?

Thanks in advance.

EDIT

After some tests, I have discovered where the problem comes from. It has to do with the "word link" module. When word link is configured to run on a field, then it seems to remove all the text within the scope of the tags where the < appears. Now it seems it's time to surf the word link code...

José L.

default value when adding new item of date field

1 month 3 weeks ago

i'm using drupal 7 and in my content type there is a date field has start and end value with unlimited values, i set the default value to "Now".
but the problem is when adding new item of this field there is no default value in it.

is there a way to set a default value for new items?
thanks a lot.

Abdulrahman

How can I lint / audit / validate YML to avoid making stupid mistakes?

1 month 3 weeks ago

Is there a way to lint YML to ensure that the values are something that Drupal understands?

For example, I recently wrote this YML for a custom module:

config/install/mymodule.settings.yml

langcode: en rate_limit: count_anon: 500

config/schema/mymodule.settings.schema.yml

mymodule.settings: type: config_object mapping: rate_limit: type: mapping mapping: count_anon: label: 'Maximum post count for anonymous users' type: number

The mistake is that I wrote number instead of integer for the type in the schema (doing too much JavaScript lately). However, when I enabled the module, Drupal imported this config without complaint, but it stored 500 as a string.

It would be great if Drupal threw an error when the config to import doesn't match the schema, but since that doesn't happen, is there any way to lint or validate this?

Patrick Kenny

How to filter Search API index view by taxonomy parent

1 month 3 weeks ago

I am using the default database server that comes with search api. I have the Hierarchy Index ticked and I also have the taxonomy field that I want selected.

Could someone give me instructions on how to configure the view to have it filtered by the taxonomy parent/show only the children of the selected parent term? I just want a drop down like you would have with a regular view.

(I got this to work in D7 a while ago but I think that was because the field still retained its taxonomy data type when indexed but now with D8 it has none of that.)

  • I can add a field that has a parent relationship but that does nothing.
  • I tried adding a field Vocabulary » Taxonomy term » Term Parents and tried to filter by that but nothing.
Hali R

How can I populate a node field based on a user field?

1 month 3 weeks ago

I have an "address" field among the user fields. Here users can specify several entries for their addresses. They can create orders (these are custom content type nodes). The order node has a "shipping address" field. Users should be able to choose one address from their previously stored ones and use them on the order form.

How can I do this? What I have in mind is adding a custom js that makes an ajax call and fetches the addresses from the user fields. Is it a good idea or is there any simpler method?

It would be fine too if I can make a reference field to the user datas and users would see a combo box to choose their address from.

Moha

How to group-by fields in view AND control output via template file

1 month 3 weeks ago

I 'm hitting a brick wall on this one, so trying to reach out for help. I did try to research this but could not find anything helpful.

What I have: I have a content type of 'courses', which have title, code, credits and semester (semester ranges from 01 to 10, and it is a vocabulary and each course is linked to a term from this vocabulary).

What I want: I want to create a view page, which lists all courses, i.e. their title, code and credits, and those courses should be grouped (and sorted) by their semester.

Ideally, I want all this to be presented with an accordion, so for example the final page should be something like:

Course Title | Course Code | Course Credits {titles} -- Semester 01 -- [ collapsible accordion header] Course #1 title | Course #1 Code | Course #1 credits Course #2 title | Course #2 Code | Course #2 credits Course #3 title | Course #3 Code | Course #3 credits -- Semester 02 -- [ collapsible accordion header] Course #4 title | Course #4 Code | Course #4 credits Course #5 title | Course #5 Code | Course #5 credits -- Semester 03 -- [ collapsible accordion header] Course #6 title | Course #6 Code | Course #6 credits Course #7 title | Course #7 Code | Course #7 credits Course #8 title | Course #8 Code | Course #8 credits Course #9 title | Course #9 Code | Course #9 credits

I hope this above sketch shows what I 'm trying to achieve.

I am new to Drupal and I don't have a good grasp of Views yet, so this probably adds to my confusion. I feel quite confident with twig and templates, so I tried to do it from there, but hit a problem.

What I did:

Created a new View, where I show content of type courses.

In it, I create a page of unformatted list of teasers and using filename suggestions with the debug mode enabled, I created the file:

node--view--[course_content_type_name].html.twig

I can write the accordion markup in there and everything, the problem is that the 'semester' info obviously pops up in every row...

The best I can come up with, is something like:

-- Semester 01 -- [ collapsible accordion header] Course #1 title | Course #1 Code | Course #1 credits -- Semester 01 -- [ collapsible accordion header] Course #2 title | Course #2 Code | Course #2 credits -- Semester 01 -- [ collapsible accordion header] Course #3 title | Course #3 Code | Course #3 credits -- Semester 02 -- [ collapsible accordion header] Course #4 title | Course #4 Code | Course #4 credits -- Semester 02 -- [ collapsible accordion header] Course #5 title | Course #5 Code | Course #5 credits -- Semester 03 -- [ collapsible accordion header] Course #6 title | Course #6 Code | Course #6 credits -- Semester 03 -- [ collapsible accordion header] Course #7 title | Course #7 Code | Course #7 credits -- Semester 03 -- [ collapsible accordion header] Course #8 title | Course #8 Code | Course #8 credits -- Semester 03 -- [ collapsible accordion header] Course #9 title | Course #9 Code | Course #9 credits

I tried with 'fields' instead of 'content', added those that I want and 'excluded' semester from showing, but that didn't really help.

I understand that the teaser template runs once for every 'row' so there is no way to really 'group' results according to semesters, which is what I want.

Is there a way to get all data somewhere and format it in one template file, so I can use loops and ifs etc. to 'group' and present my data the way I want ?

Sorry for the ridiculous length of this message .. I wanted to be as specific as possible in order to be easily understood...

This question seems fairly similar, but the very useful and detailed answer mentions a solution if not using a view mode/template. I want to use a template because it helps me control exactly how the data is shown. I 've found other tips and info here and there, but none could be of any real help.

What should I try in order to achieve what I want? Any help would be greatly appreciated, I 'm really stuck on this one ...

Please shed some drupal light towards my way ... :)

thomas

Views partial Contextual Filter on username

1 month 3 weeks ago

I have a view of users with a contextual filter for username which works great for whole usernames, but I need to allow this to work with partial names, or specifically whole words (userames are full names with spaces in this case), so if someone search for 'David' it will list all the 'David's, regardless of their surname.

Any help?

EDIT: a bit more googling revealed this, which was able to solve my problem: http://n00bsys0p.co.uk/blog/2012/08/21/drupal-views-3-contextual-filter

Chris

How to delete duplicate path aliases?

1 month 3 weeks ago

Duplicate path aliases are seen as rows in the path_alias table with identical path and alias columns.

Due to old bugs in pathauto and other reasons, like buggy custom code, it is possible to have duplicate rows in the path_alias table. This can make the path_alias enormous for large sites.

Duplicate path aliases serve no purpose whatsoever. You only need one of each.

cilefen
Checked
8 hours 27 minutes ago
most recent 30 from drupal.stackexchange.com
Subscribe to Drupal StackExchange feed