• 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 link page to other sub-pages

bpm91

Advanced OT User
Joined
May 23, 2019
Messages
1,046
Solutions
7
Reaction score
180
Location
Brazil
YouTube
caruniawikibr
I'm trying to make it so that when someone clicks on the monster, the page loads a subpage that is located in a folder. How can I do that?

PHP:
echo '<a href="?creature=' . $monsterName . '">';
1723569100446.webp
1723569168363.webp
1723569180173.webp

In this case, I will do it manually, monster by monster. Does anyone know how to make it so that when you click on a monster, it opens another page just for that monster through a folder called creatures?

myaac - tfs 1.5
Post automatically merged:

when i click on goblin example go to main page
 
Last edited:
PHP:
<?php
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $title; ?></title>
    <style>
        .monsters-grid {
            display: flex;
            flex-wrap: wrap;
        }

        .monster {
            width: 14.28%; /* 100% / 7 */
            text-align: center;
            margin-bottom: 10px;
            font-weight: normal;
        }

        .monster img {
            display: block;
            margin: 0 auto;
        }

        .monster a {
            text-decoration: none;
            color: black;
            font-weight: normal;
        }

        .monster a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="monsters-grid">
        <?php
        $monsters = [
            ['name' => 'Goblin', 'gfx_name' => 'goblin.gif'],
        ];

        $counter = 0;
        foreach ($monsters as $monster) {
            if ($counter % 7 == 0 && $counter != 0) {
                echo '</div><div class="monsters-grid">';
            }

            $monsterName = strtolower(str_replace(' ', '', $monster['name'])); // Remove espaços e converte para minúsculas

            echo '<div class="monster">';
           echo '<a href="system/pages/creatures/' . $monsterName . '.php">';
            echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . $monster['name'] . '">';
            echo '<br>' . $monster['name'] . '</a>';
            echo '</div>';

            $counter++;
        }
        ?>
       
    </div>
</body>
</html>
 
am not sure if its
<span><span>system/pages/creatures/</span></span>
or
<span><span>/system/pages/creatures/</span></span>



PHP:
<?php
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($title); ?></title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            color: #333;
            margin: 0;
            padding: 20px;
            display: flex;
            justify-content: center;
        }

        .monsters-grid {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            max-width: 1000px;
        }

        .monster {
            width: calc(100% / 7 - 15px);
            text-align: center;
            background-color: #fff;
            border-radius: 8px;
            padding: 10px;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s ease-in-out;
        }

        .monster:hover {
            transform: scale(1.05);
        }

        .monster img {
            display: block;
            margin: 0 auto 10px;
        }

        .monster a {
            text-decoration: none;
            color: #333;
            font-weight: bold;
            display: block;
        }

        .monster a:hover {
            color: #007bff;
        }
    </style>
</head>
<body>
    <div class="monsters-grid">
        <?php
        $monsters = [
            ['name' => 'Goblin', 'gfx_name' => 'goblin.gif'],
            // Add more monster
        ];

        foreach ($monsters as $monster) {
            $monsterName = strtolower(str_replace(' ', '', $monster['name']));

            echo '<a href="system/pages/creatures/' . $monsterName . '.php" target="_blank">';
            echo '<div class="monster">';
            echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . htmlspecialchars($monster['name']) . '">';
            echo $monster['name'];
            echo '</div>';
            echo '</a>';
        }
        ?>
    </div>
</body>
</html>
 
Last edited:
You need to pass a variable, in this style:
Code:
<a href="?subtopic=creature&name=Demon">

Then in place where you want to include that monster, you do:
PHP:
if (isset($_GET['name'])) {
    $monsterName = strtolower(str_replace(' ', '', $_GET['name'])); // demon
    include SYSTEM . 'pages/creatures/' . $monsterName . '.php';
}

Then your whole code would look like this: (I also removed that html, head and body tags (you don't need it here)):

creatures.php (List all monsters)
PHP:
<?php
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";
?>

<style>
    .monsters-grid {
        display: flex;
        flex-wrap: wrap;
    }

    .monster {
        width: 14.28%; /* 100% / 7 */
        text-align: center;
        margin-bottom: 10px;
        font-weight: normal;
    }

    .monster img {
        display: block;
        margin: 0 auto;
    }

    .monster a {
        text-decoration: none;
        color: black;
        font-weight: normal;
    }

    .monster a:hover {
        text-decoration: underline;
    }
</style>
<div class="monsters-grid">
    <?php
    $monsters = [
        ['name' => 'Goblin', 'gfx_name' => 'goblin.gif'],
    ];

    $counter = 0;
    foreach ($monsters as $monster) {
        if ($counter % 7 == 0 && $counter != 0) {
            echo '</div><div class="monsters-grid">';
        }

        $monsterName = strtolower(str_replace(' ', '', $monster['name'])); // Remove espaços e converte para minúsculas

        echo '<div class="monster">';
       echo '<a href="?subtopic=creature&name=' . $monsterName . '.php">';
        echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . $monster['name'] . '">';
        echo '<br>' . $monster['name'] . '</a>';
        echo '</div>';

        $counter++;
    }
    ?>
 
</div>

creature.php (View single monster)
PHP:
<?php
defined('MYAAC') or die('Direct access not allowed!');
$title = "Creatures";

if (!isset($_GET['name'])) {
    echo 'Creature not found.';
    return;
}

$title = $_GET['name'] . ' - Creatures';

$monsterName = strtolower(str_replace(' ', '', $_GET['name'])); // example: dragonlord
include SYSTEM . 'pages/creatures/' . $monsterName . '.php';

Then in pages/creatures/dragonlord.php, you can do anything:
PHP:
<?php

echo 'This is Dragon Lord description';
 
1723766859296.webp
PHP:
<?php
defined('MYAAC') or die('Direct access not allowed!');
$title = "Wiki Videos";

?>

<style>
    .monsters-grid {
        display: flex;
        flex-wrap: wrap;
    }

    .monster {
        width: 14.28%; /* 100% / 7 */
        text-align: center;
        margin-bottom: 10px;
        font-weight: normal;
    }

    .monster img {
        display: block;
        margin: 0 auto;
    }

    .monster a {
        text-decoration: none;
        color: black;
        font-weight: normal;
    }

    .monster a:hover {
        text-decoration: underline;
    }
</style>
<div class="monsters-grid">
    <?php
    $monsters = [
        ['name' => 'goblin', 'gfx_name' => 'goblin.gif'],
    ];

    $counter = 0;
    foreach ($monsters as $monster) {
        if ($counter % 7 == 0 && $counter != 0) {
            echo '</div><div class="monsters-grid">';
        }

        $monsterName = strtolower(str_replace(' ', '', $monster['name'])); // Remove espaços e converte para minúsculas

        echo '<div class="monster">';
       echo '<a href="?subtopic=creature&name=' . $monsterName . '.php">';
        echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . $monster['name'] . '">';
        echo '<br>' . $monster['name'] . '</a>';
        echo '</div>';

        $counter++;
    }
    ?>
 
</div>

1723766900387.webp
1723766910895.webp

What am I doing wrong?
Post automatically merged:

1723767002254.webp
 
LUA:
[Fri Aug 16 14:06:45.819676 2024] [php:error] [pid 3208:tid 1960] [client ::1:54715] PHP Fatal error:  Uncaught Error: Call to undefined function imagecreatetruecolor() in C:\\xampp\\htdocs\\templates\\tibiacom\\headline.php:24\nStack trace:\n#0 {main}\n  thrown in C:\\xampp\\htdocs\\templates\\tibiacom\\headline.php on line 24, referer: http://localhost/?subtopic=monsters&name=goblin

headline.24
// create image
$image = imagecreatetruecolor(250, 28);
 
Last edited:
i do this but no work
  1. search this ;extension=gd
  2. remove ; then restart the server
Post automatically merged:

PHP:
<div class="monsters-grid">
   <?php
$monsters = [
    ['name' => 'goblin', 'gfx_name' => 'goblin.gif'],
    // Adicione mais monstros conforme necessário
];

$counter = 0;
foreach ($monsters as $monster) {
    if ($counter % 7 == 0 && $counter != 0) {
        echo '</div><div class="monsters-grid">';
    }

    $monsterName = strtolower(str_replace(' ', '', $monster['name']));

    echo '<div class="monster">';
    echo '<a href="?subtopic=monsters&name=' . $monsterName . '">';
    echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . $monster['name'] . '">';
    echo '<br>' . $monster['name'] . '</a>';
    echo '</div>';

    $counter++;
}
?>
</div>

<style>
    .monsters-grid {
        display: flex;
        flex-wrap: wrap;
    }

    .monster {
        width: 14.28%; /* 100% / 7 */
        text-align: center;
        margin-bottom: 10px;
        font-weight: normal;
    }

    .monster img {
        display: block;
        margin: 0 auto;
    }

    .monster a {
        text-decoration: none;
        color: black;
        font-weight: normal;
    }

    .monster a:hover {
        text-decoration: underline;
    }
</style>

When I press goblin it doesn't open the new page, it just repeats the same one and changes the link

 
Last edited:
As I said, you should create 2 files: monster.php and monsters.php.

The link should be

Code:
echo '<a href="?subtopic=monster&name=' . $monsterName . '">';

monster and not monsters

Then you should create a separate page called monster.php
 
1723835959861.webp
PHP:
<div class="monsters-grid">
   <?php
$monsters = [
    ['name' => 'goblin', 'gfx_name' => 'goblin.gif'],
    // Adicione mais monstros conforme necessário
];

$counter = 0;
foreach ($monsters as $monster) {
    if ($counter % 7 == 0 && $counter != 0) {
        echo '</div><div class="monsters-grid">';
    }

    $monsterName = strtolower(str_replace(' ', '', $monster['name']));

    echo '<div class="monster">';
    echo '<a href="?subtopic=monster&name=' . $monsterName . '">';
    echo '<img src="images/monsters/' . $monster['gfx_name'] . '" width="62" height="62" alt="' . $monster['name'] . '">';
    echo '<br>' . $monster['name'] . '</a>';
    echo '</div>';

    $counter++;
}
?>
</div>

<style>
    .monsters-grid {
        display: flex;
        flex-wrap: wrap;
    }

    .monster {
        width: 14.28%; /* 100% / 7 */
        text-align: center;
        margin-bottom: 10px;
        font-weight: normal;
    }

    .monster img {
        display: block;
        margin: 0 auto;
    }

    .monster a {
        text-decoration: none;
        color: black;
        font-weight: normal;
    }

    .monster a:hover {
        text-decoration: underline;
    }
</style>

1723836006534.webp

1723836029264.webp
1723836045670.webp

after click
1723836061265.webp
the page continue goblin and goblin.gif and no change page
Post automatically merged:

The idea was to create a folder named monster or monsters, put page by page.php of each monster. so as the monster is clicked it opens this page with its information. This style would even serve as a basis for NPCs or other things
 
Last edited:
Back
Top