Simple Website Framework

Styling the Post Archives page

Sunday March 31st, 2024

Scary le Poo

Here's how you can rewrite the documentation to style the output by wrapping each piece of content in <div> elements with appropriate classes:

Please understand that this is just an example! Follow accepted best practices!

Identify HTML Structure:

  • Understand the HTML structure generated by the PHP code. It includes:
    • Post titles within <div> elements with a class of post-title.
    • Publication dates within <div> elements with a class of publication-date.
    • Post thumbnails within <div> elements with a class of post-thumbnail-container.
    • Post excerpts within <div> elements with a class of post-excerpt.

Create CSS Rules:

  • Define CSS rules to style each element according to your design preferences. Instead of styling base elements directly, target classes for better control and maintainability. For example:
    /* Style for post links */
    .post-title {
        font-size: 1.2em;
        font-weight: bold;
        /* Add other styles as needed */
    }
    
    /* Style for post publication date */
    .publication-date {
        color: #888; /* Adjust color as needed */
    }
    
    /* Style for post thumbnail container */
    .post-thumbnail-container {
        margin-bottom: 10px; /* Adjust spacing as needed */
    }
    
    /* Style for post thumbnails */
    .post-thumbnail {
        max-width: 100%;
        height: auto;
        /* Add other styles as needed */
    }
    
    /* Style for post excerpts */
    .post-excerpt {
        margin-bottom: 20px; /* Adjust spacing as needed */
    }

Apply Classes:

  • Modify the PHP code to wrap each piece of content in <div> elements with appropriate classes. For example:
    foreach ($fileDetailsPage as $fileDetail) {
        $dateFormatted = date('m/d/Y', strtotime($fileDetail['date']));
        echo '<div class="post-title"><a href="' . $postsFolder . '/' . basename($fileDetail['filename'], '.md') . '">' . $fileDetail['title'] . '</a></div>';
        echo '<div class="publication-date">' . $dateFormatted . '</div>';
        echo '<div class="post-thumbnail-container">';
        $imagePath = $imageFolder . '/' . $fileDetail['thumbnail'];
        if (file_exists($imagePath)) {
            echo '<img src="' . $imagePath . '" alt="' . $fileDetail['title'] . '" class="post-thumbnail">';
        } else {
            echo 'Thumbnail not found for ' . $fileDetail['title'];
        }
        echo '</div>';
        echo '<div class="post-excerpt">' . $fileDetail['excerpt'] . '</div>';
    }

Link CSS:

  • Include your CSS file in themes/your-theme/custom.css

Test and Adjust:

  • Save your changes and test the output in a browser. Adjust the CSS as needed to achieve the desired styling.

By wrapping each piece of content in <div> elements with appropriate classes and styling those classes in CSS, you can achieve better control and maintainability of your styling. Adjust the CSS properties according to your design preferences.

Explore Our Framework

Discover the endless possibilities of the Simple Website Framework. From streamlined development to enhanced security features, explore how our framework can elevate your website projects. Start exploring today!

Contribute on GitHub

Join our community on GitHub and contribute to the evolution of Simple Website Framework. Visit the repository at Skeleton Website Framework on Github to access the latest updates, report issues, and submit pull requests. Your contributions are invaluable to us!

Living Documentation

Immerse yourself in the comprehensive documentation of the Simple Website Framework, right here on our website. Explore the various capabilities, features, and functionalities of our framework in real-time. From detailed tutorials to practical examples, dive deep into the heart of the Simple Website Framework and unleash your creativity like never before.