Comments (12)
bump @NeoBlack
from phile.
Yes, this is a problem or a bug. We can add a counter, if key exist, this way no page will be lost.
from phile.
That would be cool. Then the priority when there is a conflict would be ordered by filename right? since that is the default page order when first read from the directory?
from phile.
result would be:
test
test_1
test_2
if three pages has the sorting value "test"
from phile.
Ok so for something like meta.date how would that work? You wouldn't want to augment the actual value of the meta property
from phile.
maybe we have here an other problem. meta:date will be handled as any other meta information (parsed as string), but should be set automatic to the file modification date!?
from phile.
I dont think so. Because if you modify a file then it would jump to the "top" of the list. So updating articles that were published in the past would make it look like they were new.
Or are you saying that a conflicting attribute would then be resolved based on which file is newer? I still think that using the alphabetical filename to resolve conflicts might be easier. In this case:
puppies-are-fun.md
• meta.title = Puppies Are Fun
• meta.date = 2014/02/10
kittens-are-cute.md
• meta.title = Kittens Are Cute
• meta.date = 2014/02/10
In this case kittens would be at the top if ordered by date. Because K comes before P.
from phile.
ok, right. no automatic detection. but 2014/02/10 would be 2014/01/10_1, 2014/01/10_2 etc. otherwise we should define a second sorting, eg:
$config['pages_order_by']='meta:date,meta:title'
if only one meta field is in config, a conflict will be solved by adding the counter.
from phile.
Frank I think I know what you are saying after looking at the code in the Phile\Repository
. This would be a simple solution right now:
// semi pseudo code
if (isset($sorted_pages['_'.$page->getMeta()->get($metaKey)])) {
$sorted_pages['_'.$page->getMeta()->get($metaKey).'_'.$counter] = $page;
} else {
$sorted_pages['_'.$page->getMeta()->get($metaKey)] = $page;
}
$counter++;
In this case Frank is right, having 2 sorts would be nice because, personally, I would want to go by Title
after the custom meta is done.
from phile.
ok, here is my solution for sorting with counter if only one sorting key is defined:
$sorted_pages = array();
foreach ($pages as $page) {
if ($page->getMeta()->get($metaKey) !== null) {
$key = '_'.$page->getMeta()->get($metaKey);
if (array_key_exists($key, $sorted_pages)) {
$counter = 1;
$tmp = $key;
while (array_key_exists($tmp, $sorted_pages)) {
$tmp = $key . '_' . $counter++;
}
$key = $tmp;
}
$sorted_pages[$key] = $page;
} else {
$sorted_pages[] = $page;
}
}
if we have more then one sorting key defined, the sorting logic is a little bit more complex, but possible :)
from phile.
Thanks Franck I've just tested it and it works very well !
Indeed it would be awesome to have several meta for sorting : if the first one is not present the second one is selected. That would prevent things like ordering menu items with a quite irrelevant "date" value.
from phile.
We will fix this bug and close this issue. I open a new issue as feature request for sorting by multiple fields.
from phile.
Related Issues (20)
- Internal Server Error [SOLVED] HOT 1
- Removing subfolders from links with htaccess HOT 3
- Phile plugins don't install properly using composer HOT 2
- Error when symlinking content directory HOT 2
- [TASK] Release 1.8
- [TASK] Put up phile homepage again HOT 1
- Proposal for further core refactoring HOT 1
- [FEATURE] Set error page as config setting
- [BUG] "composer create-project --no-dev phile-cms/phile" doesn't allow further composer usage
- [FEATURE] Update minimum PHP requirement to version 7.1.0
- [FEATURE] Don't use file cache out of the box HOT 3
- Missing some documentation and project status? HOT 1
- PHP 7.4+ deprecates array_key_exists() on objects HOT 1
- Twig variables HOT 1
- help on contact form plugin HOT 1
- Overriding vendor michelf/php-markdown
- PHP 8 HOT 15
- PHP 8/Phile 2 - Plugin Updates Status & Requests
- Pages without meta block are rendered empty
- PHP 8.2 dynamic properties ErrorException
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phile.