L
L
Luka Tarkhnishvili2016-05-30 16:05:35
CMS
Luka Tarkhnishvili, 2016-05-30 16:05:35

Automatic link/page creation?

Я начал создавать сайт (мой первый сайт, поэтому вопрос нубский) на HTML CSS немного js и php, и столкнулся с такой проблемой - мне приходиться создавать все ссылки вручную, к примеру я создал шаблон страницы контента, у меня есть 30 категорий, а значит нужно продублировать 30 одинаковых страниц, разместить на них разный контент (и это тоже вручную, с HTML насколько это правильно я не знаю). Как мне избавиться от таких заморочек? Может использовать laravel или zend framework изучив их?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
novrm, 2016-05-30
@Zorner

Make one php file which will store an array of descriptions of all pages.
Then you include_once this file into the finished page - parse it and get all the links...
Sample file:

<?php
$config = [
    [
        'name' => 'page_one',
        'title' => 'первая страница',
    ],
    [
        'name' => 'page_two',
        'title' => 'вторая страница',
    ],
];
?>

Then use the standard IteratorIterator wrapper class to iterate over the array and get the values ​​you want...

X
xmoonlight, 2016-05-30
@xmoonlight

no.
1. you need to use the "sewing" of the page from pieces through include in php
there is a header, content, footer, all this is in separate files, etc.
2. you can implement it through SPA and load the same piece of menu from html for different pages via ajax

S
Stanislav Pochepko, 2016-05-30
@DJZT

You should learn how to create websites. It is advisable to write the first guestbook in pure php without a framework, and then take on them.

M
Maxim Timofeev, 2016-05-30
@webinar

1. Read, understand and use MCV
2. It is desirable to read, understand and use OOP in PHP
In fact, you need a component (php code) that will connect to index.php and resolve requests using some of your rules. In this case, the server will conduct all requests through index.php.
If all of the above is "difficult" or if you don't want to masturbate - use a framework where this is already implemented, for example Yii2 or laravel. I find it easier to start with yii2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question