1
votes

I currently have a Drupal website. I need to make 1000 pages that are in the form domain.com/names/name1.html domain.com/names/name2.html etc. Each differs slightly but is in the same format. What is the best way to go around this? I am having trouble finding any tutorials on this topic.

1
Also, searching google for "drupal 7 create node" yields many results - 2pha
Also, there is a specific site for drupal answers. drupal.stackexchange.com - 2pha
@2pha The op asks for how to create drupal PAGES programmatically, why would you want him to google that ? - EricLavault
What have you tried so far ? What content should be loaded on these pages ? - EricLavault

1 Answers

0
votes

Let's first clarify.

As the comments under your question suggested you could 1. create nodes programmatically. Let's say you have a content type (a node type) "Page" and then by calling hook_install (to perform the task upon module installation) or hook_update_N (to perform the task upon running the update routine) from within a custom module you could create a thousand nodes of type "Page" (in a for-loop or better as a batch process to prevent timeouts), set their path alias and whatever else you need to set, done. There are a tons of tutorials out there already.

And of course you also can 2. create pages programmatically by calling hook_menu from within a custom module and adding a menu item (a route) which accepts wildcards ($items['names/%']). You then can define a callback function ('page callback') to build your page content that will be called when a matching URL gets accessed and you can also pass the wildcards as arguments ('page arguments') to that callback function. The callback function could simply return a render array for example.

Adding a menu item with a callback function to render some custom content via hook_menu normally means you really only control the inner page content dynamically (the main page content region or however it's called in your current theme). Header, main menu, footer etc. simply stay the same. Depending on your needs you also need to build custom links to your custom pages somehow and provide them as custom block or whatever you are planning to do with them.

A good overview of the second approach can be found in the Example module's docs and in detail in the Page Example submodule's docs.