I use the blog feature for news and announcements. Sometimes there are changes or additions in a post. I wanted them to be sorted by last modification date. It’s also possible to use the creation date.
If you do want to mess with the Pulse core files you can use this.
Pulse 4.5.2
file: /inc/tags/blog.php
find lines: 9-21:
$all_blog_files_folder = glob("content/blog/*");
natsort($all_blog_files_folder);
foreach ($all_blog_files_folder as $files) {
$resortfiles[] = $files;
}
foreach ($resortfiles as $blog_files) {
$file_info = pathinfo($blog_files);
$blog_id = $file_info['filename'];
$all_blog_files[$blog_id] = array($blog_files, $blog_id);
$all_blog_ids[] = $blog_id;
}
replace with:
$all_blog_files_folder = glob("content/blog/*");
// natsort($all_blog_files_folder); // pulse original
// usort($all_blog_files_folder, create_function('$a,$b', 'return filectime($a) - filectime($b);')); // sort by creation time
usort($all_blog_files_folder, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); // sort by last modification time
foreach ($all_blog_files_folder as $files) {
$resortfiles[] = $files;
}
$counter = 1; // pulse expects consecutively numbered blog_ids starting with "1"- step 1
foreach ($resortfiles as $blog_files) {
$file_info = pathinfo($blog_files);
// $blog_id = $file_info['filename']; // pulse original
$blog_id = $counter; // numbering step 2
$all_blog_files[$blog_id] = array($blog_files, $blog_id);
$all_blog_ids[] = $blog_id;
$counter++; // numbering step 3
}