arambalakjian / dataobject-as-page-filter Goto Github PK
View Code? Open in Web Editor NEWFiltering System for DOAP Module
Filtering System for DOAP Module
Hi Aram,
I get an error message when I try to apply a filter on my FilteredListingPage:
SELECT DISTINCT "DataObjectAsPage"."ClassName", "DataObjectAsPage"."Created", "DataObjectAsPage"."LastEdited", "DataObjectAsPage"."URLSegment", "DataObjectAsPage"."Title", "DataObjectAsPage"."MetaTitle", "DataObjectAsPage"."MetaDescription", "DataObjectAsPage"."Content", "Job"."JobTeaser", "Job"."CompanyShort", "Job"."JobDesc", "Job"."CompanyDesc", "Job"."Adressat", "Job"."JobListingPageID", "Job"."UnternehmenID", "Job"."JobBildID", "Job"."TeamPicID", "DataObjectAsPage"."ID",
CASE WHEN "DataObjectAsPage"."ClassName" IS NOT NULL
THEN "DataObjectAsPage"."ClassName"
ELSE 'DataObjectAsPage'
END AS "RecordClassName" FROM "DataObjectAsPage"
LEFT JOIN "Job" ON "Job"."ID" = "DataObjectAsPage"."ID"
WHERE ("filter" IN ('Array')) AND ("DataObjectAsPage"."ClassName" IN ('Job'))
ORDER BY "DataObjectAsPage"."Title" ASC
Unknown column 'filter' in 'where clause'
That leads to an Array to string conversion notice.
This error occurs regardless of how many categories i try to apply to my DOAP-Class.
When I revert the changes in this commit the filtering works as expected.
But now it is only possible to apply filters of one category.
If i try to apply a filter of a second category I get another DB Query error. The generated query looks like this:
SELECT DISTINCT count(DISTINCT DataObjectAsPage.ID) AS "0" FROM DataObjectAsPage
LEFT JOIN Job ON Job.ID = DataObjectAsPage.ID
INNER JOIN Job_Kriterien ON Job_Kriterien.JobID = DataObjectAsPage.ID
LEFT JOIN DataObjectAsPageCategory ON Job_Branchen.BrancheID = DataObjectAsPageCategory.ID
LEFT JOIN Kriterium ON Job_Kriterien.KriteriumID = Kriterium.ID
INNER JOIN Job_Branchen ON Job_Branchen.JobID = DataObjectAsPage.ID
WHERE (Kriterium.ID IN ('4'))
AND (DataObjectAsPageCategory.ID IN ('19'))
AND (DataObjectAsPage.ClassName IN ('Job'));
ERROR 1054 (42S22): Unknown column 'Job_Branchen.BrancheID' in 'on clause'
When I reorder the LEFT JOIN on "Job.Branchen.BrancheID" after the inititializing INNER JOIN of "Job_Branchen" the query works and triggers the correct result:
SELECT DISTINCT count(DISTINCT DataObjectAsPage.ID) AS "0" FROM DataObjectAsPage
LEFT JOIN Job ON Job.ID = DataObjectAsPage.ID
INNER JOIN Job_Kriterien ON Job_Kriterien.JobID = DataObjectAsPage.ID
LEFT JOIN Kriterium ON Job_Kriterien.KriteriumID = Kriterium.ID
INNER JOIN Job_Branchen ON Job_Branchen.JobID = DataObjectAsPage.ID
LEFT JOIN DataObjectAsPageCategory ON Job_Branchen.BrancheID = DataObjectAsPageCategory.ID
WHERE (Kriterium.ID IN ('4'))
AND (DataObjectAsPageCategory.ID IN ('19'))
AND (DataObjectAsPage.ClassName IN ('Job'));
+---+
| 0 |
+---+
| 1 |
+---+
1 row in set (0.85 sec)
Here is my "FilteredJobListingPage":
<?php
class FilteredJobListingPage extends FilteredListingPage{
}
class FilteredJobListingPage_Controller extends FilteredListingPage_Controller
{
//Layout template to use to when AJAX is enabled (ignore if AJAX disabled)
private static $ajax_template = 'FilteredJobListingPage';
//This needs to know be the Class of the DataObject you want this page to list
private static $item_class = 'Job';
//Set the sort for the items (defaults to Created DESC)
private static $item_sort = 'Title ASC';
//Disable AJAX filtering and reload the page when filtering (defaults to true)
private static $ajax_filter = true;
private static $filter_settings = array(
'Kriterien' => array(
'Title' => 'Kriterium auswählen',
'ClassName' => 'Kriterium',
'Preposition' => 'mit',
'MultiSelect' => false,
'MatchAll' => false
),
'Branchen' => array(
'Title' => 'Branche auswählen',
'ClassName' => 'Branche',
'Preposition' => 'mit',
'MultiSelect' => false,
'MatchAll' => false
)
);
}
The DOAP-Class "Job" has a many_many relation to both Categories (Kriterium,Branche).
I am on Silverstripe 3.1.6 and the current version of your modules.
Any thoughts or hints on these issues?
Best regards,
Niels
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.