• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC Znote acc, create my own sub page

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,088
Solutions
15
Reaction score
379
Location
Sweden
YouTube
Joriku
Hi,
so the init.php inside the engine folder contains the sub page catagory.

Now, I want to create a folder called wiki and add pages that allows access onto them by entering either the file by the domain or else do something like the sub page does by using sub.php?page=name

How would I do this?

Current progress:
init.php
Lua:
// Wiki sub pages
$filename2 = basename($_SERVER['REQUEST_URI']);
$page_filename2 = pathinfo($filename2, PATHINFO_FILENAME);

if ($config['allowWikiPages']) {
    $wikiDirectory = 'layout/wiki/';
    $requestedFile = $wikiDirectory . $page_filename2 . '.php';

    // Check if the requested file exists
    if (file_exists($requestedFile)) {
        require_once 'layout/overall/header.php';
        require_once $requestedFile;
        require_once 'layout/overall/footer.php';
        exit;
    } else {
        // Handle case when the requested wiki page file does not exist
        ?>
        <div style="background-color: white; padding: 20px; width: 100%; float:left;">
            <h2 style="color: black;">Wiki page not found!</h2>
            <p style="color: black;">The requested page does not exist.</p>
        </div>
        <?php
    }
}

Issue I am encountering by entering domain.com/wiki.php?page=wiki.php
is 404 error, not found.

the file lays inside
layout/wiki/wiki.php
 
Your init shouldn't really involve anything like this. You can easily just use your base wiki.php instead.

In your wiki.php, you just grab the $_GET value for page.

Then from here you can request the necessary file after doing specific checks...
PHP:
<?php

///

if(isset($_GET['page']) && !empty($_GET['page']))
{
    $page = $_GET['page'];

    $wiki_file = 'layout/wiki/' . $page;
    if(!is_file($wiki_file)){
        header('Location:wiki.php');
    }

    require_once $wiki_file;

    exit;
}

//render wiki menu or default wiki page here
 
Back
Top