Cannot install Drupal via drush in the root of site

I am going absolutely insane. I have been up for several hours scouring the internet, installing, removing, installing, removing, and I CANNOT get Drupal (7 or 8) to install at the root of a site (hosted Linux server, not local or vm). If I try to run the drush si with the package outside of the target site’s directory structure I get the site-install needs a higher bootstrap error. Of course, if I move the the install base into the root of the target site’s directory, it installs fine…in a subfolder with the name of the install base! I have followed all of the documentation, reviewed hundreds of comments on multiple sites, watched YouTube videos, looked at Pluralsight tutorials. I am at a loss. I saw suggestions to edit the settings.php file (which the install package creates during the install process and doesn’t exist beforehand…). I saw suggestions to rename files that are not yet existant because the install hasn’t happened. I’m sure much of these apply to an upgrade, but not a new site install. Can anyone please offer some insight into this. Installing with drush is supposed to make things easier. I have now wasted 4 hours trying to figure this out when I could have just manually installed it. But now it’s principle. I want to know. Besides I might have to do this again for other sites. Thank you in advance.

How to pass contextual id value from one view page to another through Drupal menuing system

  1. I use a view to display a list of books.
  2. The view has three pages: /books/title, /books/date, and /books/popularity.
  3. The pages are essentially the same with different sort criteria.
  4. The pages use a contextual filter to select books by topic based on a taxonomy.
  5. The contextual filter is set to use the query parameter topic when the filter value is not in the URL.
  6. Each page of the view includes a Drupal menu block with the items “By Title”, “By Date”, and “By Popularity” and links /books/title, /books/date, and /books/popularity.
  7. If I invoke /books/title?topic=5 (where 5 is the tid for the “health” topic)
    • A list of health books is correctly displayed.
    • The “By Title” <li> element in the menu is given the active and active-trail classes by the menuing system (which allows the use of CSS to highlight the active menu entry on-screen).
  8. When I’m at /books/title?topic=5 and click the “By Date” menu entry, /books/date is invoked, so the topic id 5 is not passed to the “By Date” view (unsurprisingly), resulting in a list of all books sorted by date instead of just health books sorted by date.

QUESTION:

How can I pass the contextual filter value (5 in this example) from one page to another via the menu? For example, if at /books/title?topic=5 I click “By Date”, I want to go to /books/date?topic=5. How can I set that up?

NOTES

  1. This post is similar to an earlier one where I asked how to get the value coming through the contextual filter. I solved that. There is a twig variable available, in this case, {{ arguments.field_topic_target_id }}.
  2. I used this twig value to rig up my own menu. But having done that, I find that I need the goodness of the Drupal menuing system, both because it makes it easy for editors to change menu items and because it handles the addition of the active and active_trail classes to the proper menu entry.
  3. I have read and tried dozens of approaches to passing the filter value received on to another page via a menu, but none have been effective.

BONUS

Assuming this problem can be solved, I’d really like to use clean URLs. So instead of /books/title?topic=5 I want to use /books/title/5. This works to correctly display a list of health books sorted by title, but when used, the menuing system does NOT set the active and active_trail classes on the active menu <li>, which I need it to do.

Drupal 7 Validating Tableselect: Checkbox

I have a form in which i have created a table like the following

$ form['tableselect_phone'] = array( '#type' => 'tableselect', '#header' => $ header, '#options' => $ options, '#empty' => t('No content available.'),

In $ options I am passing an array with sl no., UID, name etc. So now on the UI, I have an table with headers Sl no., UID, name & Phone Number. Here Phone Number is an empty textbox to fill in. When I click on the checkbox of the first user and assign a value for phone number and after that if I do not click on the second checkbox and enter value text-box for phone number, the value gets assigned for both when i click on submit button. Whereas it should not get entered of the second one. It should throw an error. For validation I have done hook_form_validate. But I am not able to do it properly. Here is what i wrote

function phone_form_validate($ form, &$ form_state){ $ values = $ form_state['input']; if(!array_filter(array_values($ values["tableselect_phone"]))) { form_set_error("tableselect_phone", t("Please select user to enter phone number "));

How to prevent Cross Site Scripting when input using “Full HTML” mode of ckeditor in Drupal?

I am using Drupal version 8.3.7 and ckeditor 4.11.3. I create a basic page contains some scripts as following: Page creation

In the detail page, I can see that the script in onmouseover="alert('222222')" is executed when I move my mouse over the “click” text.

Page detail

Hacker can easily add a malicious script by this way. How can we avoid this ?

Issue is not only for “Full HTML” mode, but also other modes if we configure a proxy between browser and server to change the encoded value to the raw value.

For example, if we select the “Unfiltered HTML” mode and we input <a href="#" onmouseover="alert('111111')">click</a> to the body field. When we save the page, the body value will be sent with a POST request that it is HTML encoded: &lt;a href=&quot;#&quot; onmouseover=&quot;alert(&#39;111111&#39;)&quot;&gt;click&lt;/a&gt;. But in the proxy above, we configure to change the encoded value to the raw value. Then the raw value <a href="#" onmouseover="alert('111111')">click</a> is saved into DB which will cause the same issue with “Full HTML” mode.

A solution that we can encode the output in theme preprocessing hook. But it seems require us to add a lot of codes because our system may have many entity types and fields.

Drupal 7 entity registration state change to cancel after 30 minutes

On drupal 7, I use Entity registration and created a registration type with a timestamp field which retrieve the actual timestamp. After registrering, the user has 30 minute to proceed to check out via commerce application.

I try to create a rule which can change the status from “complete” to “cancelled”. I use drupal rules. the Event is : “After saving a new registration” the condition is that the rule should be triggered after 30 minutes… I’ll add the other with commerce solution later. I don’t know how to create the 30 minutes condition here. the action : i try to fetch the entity by property. But i don’t know how to change it to “cancel” value.

thanks

Detect Drupal theme

I am trying to detect the theme used by a certain site.

www.y2ad.com 

Have already tried all the known methods like searching in the source code and jquery settings but it keeps showing the theme name “y2ad”.

I’m pretty sure it’s not a custom theme so is there any other way to detect the theme used?

Custom drupal module does not appear on the extend page

I have created a custom module, yet it does not appear on the extend page. I have my_new_block.info.yml file in modules/custom/my_new_block/:

name: My New Block description: Create own blocks. package: Garage   type: module core: 8.x  dependencies:   - block 

In addition, when I try to install any drupal module with composer, it also is not recognised in the extend page. What can be wrong?

Drupal 8 Views select the same number of results for every group

I have views where I select nodes and group all results in 3 groups by field. When I select for example a limit to 30 I get results but with the different count in every group (for example 20/7/3). What I can use to select for example 10 most relevant results in every group. I can do it with query alter or maybe need to create some plugin?

Drupal 8 Webform Issue with Drop Down and Key not Equaling Value

I have written a custom handler in Drupal 8 D8 that grabs submitted data from a webform and reformats it and sends it to a JSON webservice. That is all working perfectly. My issue is that the submitted data from 2 of the dropdowns is an integer (the key of the dropdown), rather than the value of the drop down, like it was when in D7 I called:

$ components = $ node->webform[‘components’];

which gave me the value of the data from the dropdowns. Now I am calling:

$ values = $ webform_submission->getData();

Which gives me the submission data. However, what I need to do is translate the number to the value. For example:

for a component (or element) drop down called ‘numbers’ the options are: 1|One 2|Two 3|Three

When I grab the submission data I get “1” but I want to send the word “One”.

How do I load the dropdown element to translate the value ‘1’ to the word “One” in Drupal 8?

Thanks.

Drush: How do I change the Drupal root

My Drush commands doesn’t work because my Drupal files are in another directory than the one set in Drush. Everything is set up to this path so I can’t just change the folder name.

Drush status   [..]   Drupal root   : /Users/nicklas/Documents/SourceTree/Drupal/web 

How can I change the path to /docroot instead of /web?

/Users/nicklas/Documents/SourceTree/Drupal/docroot