Skip to content

Commit

Permalink
separating header and footer for homepages only
Browse files Browse the repository at this point in the history
  • Loading branch information
abhijitb committed Jan 30, 2024
1 parent 5a06dc1 commit eb980d8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions includes/SiteGen/SiteGen.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,27 @@ public static function get_home_pages( $site_description, $content_style, $targe
$generated_homepages = array();
$generated_patterns = self::get_sitegen_from_cache( 'generatedPatterns' );

$categories_to_separate = array('header', 'footer');
// Choose random categories for the generated patterns and return
foreach ( $random_homepages as $slug ) {
$generated_homepages[ $slug ] = array();
$homepage_patterns = array();
foreach ( $generated_content_structures[ $slug ] as $pattern_category ) {
if ( ! $generated_patterns[ $pattern_category ] ) {
if ( ! isset( $generated_patterns[ $pattern_category ] ) ) {
continue;
}
// Get a random pattern for the category.
$random_pattern = array_rand( $generated_patterns[ $pattern_category ] );
$random_pattern = $generated_patterns[ $pattern_category ][ $random_pattern ];
array_push( $generated_homepages[ $slug ], $random_pattern );

if( in_array( $pattern_category, $categories_to_separate ) ) {
$homepage_patterns[ $pattern_category ] = $random_pattern;
} else {
$homepage_patterns[ 'content' ] = $random_pattern;
}

}
$generated_homepages[ $slug ] = $homepage_patterns;
}

self::cache_sitegen_response( 'homepages', $generated_homepages );
Expand Down

0 comments on commit eb980d8

Please sign in to comment.