I am new to Drupal, I want to edit the code of a particular page, let's say, www.mywebsite.com/login. Where can I find the code for the particular page/node. In static websites I could just navigate to the url and get the page, however, I am not sure how to get to the specific piece of code which is initiated when I go to the URL.

Please help with some direction or tutorial.

closed as too broad by kiamlaluno Oct 9 '17 at 20:06

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Hi Arihant, what is your drupal version? Did you want to edit a specific page? – Japo Domingo Apr 7 '17 at 1:02
  • Hi @JapoDomingo, I am working with Drupal 8. I want to add custom javascript to one particular page and for that I need to know where the files are. No clue where to look into – Arihant Apr 7 '17 at 1:03

The way drupal works, is these requests are sent to the index.php where they are parsed, the database queried, the content fetched and built for the page. Aside from images and files embedded, none of the files are accessed directly (I guess except for theme files as well).

What do you want to do?

Based on your comment, - you should probably implement hook_page_bottom - Then get the path with this, Get the current path alias or path? - Add an if based on the above path - add your JS to the page_bottomarray

Documentation, https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_page_bottom/8.2.x

  • I am trying to add a custom javascript to execute when the user navigates to a particular URL. Funny enough, I am not even able to figure out where the index.php file is because on my local installation when I open the index.php file, it talks about first time setup installation of Drupal on my localhost. – Arihant Apr 7 '17 at 1:06
  • Where should I implement the hook? Which file? – Arihant Apr 7 '17 at 1:23
  • Easiest place is in your theme's .theme file. But careful if it's not a subtheme because upgrading could overwrite these settings. Check these two links, drupal.org/docs/8/theming-drupal-8/… and drupal.org/node/2623936 – rovr138 Apr 7 '17 at 1:42
  • This is going to be difficult to do without some basic understanding of Drupal and how theming works first. T isn't a static website. – Kevin Apr 7 '17 at 1:57
  • There's a lot of documentation here, drupal.org/documentation Check which version you're using first. (Drupal 7 and 8 have significant changes) – rovr138 Apr 8 '17 at 1:15

here's a good link:

JavaScript API overview

And also check out the links at the bottom of that page.

And if you want to understand the render process:

The Drupal 8 render pipeline

Not the answer you're looking for? Browse other questions tagged or ask your own question.