yandeu / five-server-vscode

⚡ VSCode Extension for Five Server.
https://marketplace.visualstudio.com/items?itemName=yandeu.five-server
Other
121 stars 9 forks source link

PHP include_once doesnt work correctly with navigation #38

Open TDPFerox opened 1 year ago

TDPFerox commented 1 year ago

Hey first of all i think your work on this extension is amazing and i love working with it.

The only porblem im facing with it are the navigation between .php files were i include header and footer files. When i enter a page were the header is located in another file Five Server wont switch to that file with following message:

Website\SignUp.php does not contain required HTML tags.

The following are my files:

SignUp.php:

<?php
    include_once 'header.php';
?>
    <div class="flexbox">
        <div class="Inhalt" >
            <h2 class="HeadLine">SIGN UP</h2>
            <form action="#" method="post" class="SignUp">
                <input class="input" type="text" name=Name placeholder="Namen eingeben...">
                <input class="input" type="text" name=email placeholder="Email eingeben...">
                <input class="input" type="text" name=uid placeholder="Username eingeben...">
                <input class="input" type="password" name=pwd placeholder="Pasword eingeben...">
                <input class="input" type="password" name=pwdrep placeholder="Password wiederholen...">
                <input class="btn" type="submit" name="submit" value="Einreichen" placeholder="Einreichen">
            </form>
        </div>
    </div>
<?php
    include_once 'footer.php';
?>

Header.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ferox Online Welt</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="styleArk.css">
</head>
<body>

    <nav>
        <a href="index.php">
            <label class="logo">FOW</label>
        </a>
        <ul>
            <li><a class="active" href="/test.php">Test</a></li>
            <li><a class="active" href="/SignUp.php">Sign UP</a></li>
            <li><a class="active" href="/Ark.php">Ark</a></li>
            <li><a class="active" href="/index.php">Home</a></li>
        </ul>

    </nav>

<div class="MainContent">

footer.php:

</div>

</body>
</html>
yandeu commented 1 year ago

Yes, looks like the navigation feature does not work well with PHP. You can simply disable it with:

// fiveserver.config.js
module.exports = {
  navigate: false
}
kyubson commented 1 year ago

Hi @TDPFerox,

I had the same issue, but using __DIR__ seems to work fine. Example: <? php include_once __DIR__ . 'header.php'; ?>