This is kind of a biggie. The behavior of Page::search may need to be radically changed.
Case & Point: Retrieve pages about smartphones and smartwatches looks like this:
<?php
// Get pages about smartphones and pages about smartwatches
$result = Page::search(array(
'filters' => array(
array('gadget', 'smartphone')
array('gadget', 'smartwatch')
)
));
Which is the equivalent of saying something like:
WHERE
page.gadget == 'smartphone' OR page.gadget == 'smartwatch'
But what happens when we want the effect of writing:
WHERE
page.gadget == 'smartphone' AND page.gadget == 'smartwatch'
This is where it gets confusing. The code to achieve this in a search, looks like this:
<?php
// Get pages about smartphones of brand apple
$result = Page::search(array(
'filters' => array(
array(
'group' => array(
array('gadget', 'smartphone')
)
),
array(
'group' => array(
array('brand', 'apple')
)
),
)
));
This may be due to a bad programming & testing. Though, this needs fix, in order to work like the following case:
Proposed Solution
To achieve A OR B
I'm assuming this is a less frequently used kind of search, so it's the one needing more syntax writing.
<?php
// Get pages about smartphones or pages about smartwatches
$result = Page::search(array(
'filters' => array(
array(
'group' => array(
array('gadget', 'smartphone'),
array('gadget', 'smartwatch')
)
)
)
));
To achieve A AND B
Since this is the more used kind of filtering, it's the more natural one.
<?php
// Get pages about smartphones and pages about smartwatches
$result = Page::search(array(
'filters' => array(
array('gadget', 'smartphone')
array('gadget', 'smartwatch')
)
));
The problem with this change is backwards compatibility. I'm assuming this is still possible because the short size of the ecosystem of Fragment Installs.
This is kind of a biggie. The behavior of
Page::search
may need to be radically changed.Case & Point: Retrieve pages about
smartphones
andsmartwatches
looks like this:Which is the equivalent of saying something like:
But what happens when we want the effect of writing:
This is where it gets confusing. The code to achieve this in a search, looks like this:
This may be due to a bad programming & testing. Though, this needs fix, in order to work like the following case:
Proposed Solution
To achieve A
OR
B I'm assuming this is a less frequently used kind of search, so it's the one needing more syntax writing.To achieve A
AND
B Since this is the more used kind of filtering, it's the more natural one.The problem with this change is backwards compatibility. I'm assuming this is still possible because the short size of the ecosystem of Fragment Installs.