Dynamic pages through request

Asked

Viewed 459 times

1

I’m setting up a web application in a way that future maintenances will be well simplified.

So I started searching for dynamic pages, etc. Except in practice, I don’t even know how to start.

I wanted it to stay that way:

  • header.php: header with side menu linking to other pages

  • content.php: (I’ve already done )

  • footer.php: (I’ve already done )


In my index.php, I call the css files, js, etc. And give a include in header, content, footer...

Slurry :

  1. lib/

  2. application/

  3. controllers/

  4. template/ header.php , content.php, footer.php

    • index php.

So far blz ...

In my header, in the menu, there are several links, but I didn’t want to have to create 15, 20 different pages. But yes, 1 single page with the content related to each link.

How do I do that?


I was thinking about how I could do it , along with the database , we test is almost all going well , but it is not displaying my content.

Just like I did :

I created a table (tblPaginas), placed in it the fields : id ,name , controller , Arg and ennable.

id name     controller arg  ennable
1  index                0     0

2  pagina1     pag      1     1

3  pagina2     pag      2     1

4  pagina3     pag      3     1

etc.

In my header , I put the following :

<?php       
    echo '
        <li>
                    <a href="javascript:;">
                    <i class="icon-basket"></i>
                    <span class="title">PAGINAS</span>
                    <span class="arrow "></span>
            </a>';

    echo ' <ul class="sub-menu">';

                $sql= ("SELECT * FROM tblPaginas where ennable = 1 and arg > '0' order by id ");
                $query = mysql_query($sql);
                while($row = mysql_fetch_array($query))
                {

                echo'                         
                    <li>
                            <a href="index.php?'.$row['controller'].'='.$row['arg'].'">
                            <text style="TEXT-TRANSFORM: uppercase;">'.$row['name'].' </text></a>
                    </li>' ;}

                    echo '</ul>';
                    echo '</li>';
?>

So , it displays my side menu , grabbing the 'name' (name of the page in the menu) and sending the controller and Arg through the URL .

On my content.php page, I tried to do the following :

<?php
$uri = $_GET['arg'];

    $var = $uri;
    switch ($var)
{
    case 1:
    include 'pag/geral.php';
    break;

    case 2:
    include 'pag/pagina2.php';
    break;

    case 3:
    echo "DEU CERTO O 3";
    break;
}

?>

But, he is not displaying the pages , is not working this code I made the page content.

I thought about doing so , because I can later try to make a control panel , and edit the pages by the bank.

Can you help me make this code work?

  • Start searching for include!

  • I recommend you to use a templates lib, it is very easy and helps a lot at this time, take a look at this site http://raelcunha.com/template.php.

  • Good afternoon Eduardo , I managed to solve my problem , I created another variable to control the pages , and it worked

  • @Henriquefelix Poste as an answer to the solution you made in the comments, so your question will be properly answered and will help the community.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.