Using AI to create a sitemap page just to see whether it can be done

Open to all! Ask other shopowners for help.
Post Reply
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Using AI to create a sitemap page just to see whether it can be done

Post by 14Steve14 »

I am having a play with AI to see if it can help create a sitemap page.

So far its not too bad.

I have a 3 column page set up and the first column shows 1st and 2nd level categories and links to the correct pages all alphabetically sorted.

The second column shows a list of manufacturers alphabetically sorted.

Its the third column that I am having problems with. Its supposed to show a list of all the help pages on the website, and there are many. I am not using the infopages setup which may be a problem, or not making it easier. I just have not got round to updating all the pages. Nothing shows in the list and I am stuck on what to ask AI next.

Each of the help pages in the language file has a class set in a div which is what AI is trying to target unsuccessfully.
Is there an easy way of getting a list of these files or is it something that is not possible.

Here is the section of code for that part of the page that AI has created which I am sure could be improved.

Code: Select all

// Help Pages (Check Language Files for infopage Class)
echo '<li>Help Pages<ul>';

// Directory where your help pages are stored (root folder)
$help_pages_dir = DIR_FS_CATALOG; // Adjust this if needed

// Scan for main help page files in the root folder
$main_files = glob($help_pages_dir . '*.php');

foreach ($main_files as $main_file) {
    // Assuming the language file follows the naming convention
    $file_name = basename($main_file, '.php'); // Get base file name (without extension)
    $language_file = DIR_FS_CATALOG . '/pclatest/includes/language/english/' . $file_name . '.php'; // Adjust as necessary

    // Check if the language file exists
    if (file_exists($language_file)) {
        include($language_file); // Load the language definitions

        // Now check if the language file contains the infopage class
        if (strpos($language_contents, '<div class="infopage">') !== false) {
            // If the infopage class exists, display the help page
            $display_name = ucwords(str_replace('_', ' ', $file_name)); // Convert to readable name
            echo '<li><a href="index.php/' . $file_name . '.php">' . $display_name . '</a></li>';
        }
    } else {
        // Optional: You could log or handle missing language files
    }
}

echo '</ul></li>';
Is there an easy way to get a list of these files to show.


Join The Code Co-op to get access to your library in the Code Co-op Forum
14Steve14
Senior Contributor
Posts: 923
Joined: Fri Oct 25, 2019 7:01 pm
Phoenix Version: v1.0.9.1
Has thanked: 17 times
Been thanked: 103 times

Re: Using AI to create a sitemap page just to see whether it can be done

Post by 14Steve14 »

Me and AI have been at this on and off all afternoon trying to get this to work. Finally I have a working list of help pages that can be included in a sitemap.

Not too sure if this is the best code, but it does work.

Code: Select all

// Help Pages
echo '<ul>';

// Directory where your PHP help pages are stored (root folder)
$help_pages_dir = DIR_FS_CATALOG; // Root directory

// Scan for main help page files in the root folder
$main_files = glob($help_pages_dir . '*.php');

foreach ($main_files as $main_file) {
    // Get the base file name
    $file_name = basename($main_file, '.php'); // Get base file name without extension

    // Construct the expected language file path
    $language_file = DIR_FS_CATALOG . 'includes/languages/english/' . $file_name . '.php';

    // Check if the language file exists
    if (file_exists($language_file)) {
        // Include the language file
        include($language_file);

        // Check if the constant is defined
        if (defined('TEXT_INFORMATION_' . strtoupper($file_name))) {
            $output = constant('TEXT_INFORMATION_' . strtoupper($file_name));

            // If the output contains the <div class="infopage">
            if (strpos($output, '<div class="infopage">') !== false) {
                // Convert the filename to a readable format for display
                $display_name = ucwords(str_replace('_', ' ', $file_name));
                echo '<li><a href="' . $file_name . '.php">' . $display_name . '</a></li>';
            }
        }
    }
}

echo '</ul>';
Goes to show that even someone that has no coding experience can use AI to get something working.


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply