How to make so that when creating news material (or a new page) a file is created according to a specific template?

  • What does "file created" mean? Maybe you mean cases when the appeal to the news goes on a certain name, line? (In this case, you need a "CNC", routing, maybe) Or do you mean paginated output, but with a single template? (in this case, see "Template engines") - Dex
  • For example, there is a form in which "title" and "text" are indicated. When sending, the file would be transferred to the processor, which in its time creates a new page with the .html extension and with the data from the form stored in it - dmitriy kiryushin
  • And what is the practical meaning of this? Looks like you really need a CNC. - Dex
  • Look towards Smarty. Maybe you should not reinvent the wheel? - PaulD
  • I am not familiar with the CNC, maybe you will send me to a good textbook on the CNC? - Dmitriy Kiryushin

2 answers 2

Listen, if I understood correctly: I would do this, write news to the database, and I would have one file that (with the template already) received GET requests, that is, in more detail

www.site.com/index.php?news=123

Here he takes the news from the database with ID 123 and fills in a certain field to display the news. Well, more CNC ...

  • Thank you for this thought, perhaps it will be more useful to me than to mess with these template engines - dmitriy kiryushin
  • You're welcome. - Rimon
  • @dmitriy kiryushin, templates are a few of a different topic, for which you were asked leading questions. - Dex

in a nutshell, we create a file template.php that will be a template, in the right places we specify placeholders, for example for the header {header} for the body {body}. then in php we open this file and substitute the necessary values ​​for the title and body, then save it under the name we need.