I found this Multiple Choice Dual List (with Sort) form control and have a question about the sorting functionality. From the description, it looks like the sorting functionality only works if we have something like this CHARINDEX(','+CONVERT(varchar, ItemID)+',', ',1,3,2,5,4,') in the Order By field. I tested with a couple of items and saw that if I hard-coded the Order By as instructed, it worked. Is there a way / something to put in the Order By so that it accepts the (new) order of the items in the second (red) box - without hard-coding? THANK YOU!
My authors (the left box) are from a SQL query.
The WHERE statement of my Repeater is like this, if it's of any help:
'|' + '{%CurrentDocument.Authors#%}' + '|' LIKE '%|' + CONVERT(varchar, AuthorsID) + '|%' Everything is working; I just need that sorting functionality to work dynamically.
I think the easies way to achieve this would be implementation of some logic on the client with javascript/jquery.
That would be my tool. The example order by is meant to show kind of how it works, your order by would look like:
CHARINDEX(','+CONVERT(varchar,AuthorsID)+',', '{%CurrentDocument.Authors#%}')
Assuming that Authors is the field that has the multiselect with order form tool, and AuthorsID is the table's identity row.
Does that help?
Related
I have many articles and each is assigned under different categories/subcategories.
What I'd like to do is at the end of individual article, I'll display a list of Related Articles based on the category(s) that the current article is placed. I've added a Repeater but don't really know what to put in Content Filter/Category Name to achieve this. Hope it's not so complex. Thanks for your input!
You can achieve this in Portal without touching the code if you need to. The following steps are how you can achieve it (though they are rough and ready!)
In your Article page type, create a new query. This queries job is going to be to link the existing Document to any others that share the exact same categories. Your query should look like this:
SELECT ##TOPN## ##COLUMNS##
FROM View_CMS_Tree_Joined rel
INNER JOIN CMS_DocumentCategory relcat ON relcat.DocumentID=rel.DocumentID
INNER JOIN CMS_DocumentCategory doccat ON relcat.CategoryID=doccat.CategoryID
WHERE ##WHERE##
AND rel.DocumentID doccat.DocumentID
ORDER BY ##ORDERBY##
Now, replace you Repeater with a Repeater with custom query. In the setting, choose your newly created query for the Query name field using the selector control.
Set the WHERE clause to be doccat.DocumentID={% CurrentDocument.DocumentID #%}
Pick the appropriate transformation and you should be good to go.
This method requires an exact category match, so Categories > Cars > Mazda will not match to Categories > Cars.
Hopefully this is of some use :)
This article may give you some idea on creating a filter, but I don't think this is exactly what you want. It does show you have to get the documents thru the API.
You could do a custom query, something like this
SELECT *
FROM dbo.View_CMS_Tree_Joined vctj
WHERE vctj.DocumentID IN
(
SELECT DocumentID
FROM CMS_DocumentCategory
WHERE CategoryID IN
(
SELECT CategoryID
FROM CMS_Category
WHERE dbo.CMS_Category.CategoryName = 'Name Here'
)
);
How to make a query filter bound to a request parameter inactive if the parameter is not present?
For example: I have a query MyQuery that can be accessed through the projection MyProjection. I add a filter to that query where I say that MyDate field should be equal to {Request.QueryString:MyDate}. I want URLs like ~/MyProjection?MyDate=2016-03-08 to filter content items by the given value, but the url ~/MyProjection to just not filter by that field. But this is not what happens: a condition gets added to the query anyway and it's of the form '[minimum DateTime value] < MyDate < [maximum DateTime value]'. This is not good because it will filter out fields with NULL values. If I try to do the same with a numeric field, it's even worse because it throws exceptions when the parameter is not present.
I know I can create a new query and projection to get different options, but that seems like an overkill - also, what if I wanted to create an advanced search form, it would have to target a single projection.
Is there an "official" way to do this? Or a workaround? Or is this simply not supported in Orchard?
I'm not aware of a way to do this out of the box. However, you could pretty easily create your own filter with the behavior you want by implementing IFilterProvider.
Take a look at the Orchard.Projections module. That's where you'll find many of the default query filters (including the date field filter you referenced). Your's will likely be even simpler if you only need to handle a specific case.
For a very simple example, checkout the Orchard.Tags module (look in the projections folder). The contents of this folder will give you pretty much all the boilerplate you'll need to get started creating your own. Just plug in your own logic.
I am using a view control in an XPage, and have incorporated a search with much struggling.
I also have a dropdown to select a category, to be used as an additional filter with the search.
My query is now:
sessionScope.searchTerm AND Field Category=" + sessionScope.categoryname + "
Everything finally works except that the category filter is finding non-exact matches, for example "Management" finds the documents in the categories "Management" but also in "Facilities Management". This is not acceptable.
I tried setting searchExactMatch=true in the View properties, but this gives a stack trace, and in the log is the error: "GTR search error: Case sensitive parameter error.: Query is not understandable"
So I guess this parameter is for exact case matches instead of exact search term matches as is implied. Not what it says in the help, but OK I roll with the punches as usual.
If I use the "Filter by category name" the category filter works great with no search term, and the search seems to work OK except that the categoryFilter setting is now ignored.
This seems to be the common behavior, that these settings all work fine in isolation but never in combination. This is what I found for view keys as well.
I am now out of ideas, can anyone offer assistance?
This is a bit hackery solution but You could have additional computed field categorySearch with additional content delimiters, for example You could add additional % characters: %Completed% and then Your search query would look like this:
sessionScope.searchTerm AND Field categorySearch=%" + sessionScope.categoryname + "%
I hate myself for proposing this kind of solution but if this work then maybe I will be forgiven.
You have to search according to this article: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Searching_for_Documents#Full-text+Search
In your case do the following for the Category part:
"[Category] = \"" + sessionScope.categoryname + "\""
We are generating MDX query dynamically. We pass list of Columns ([DimesnionName].[Attribute.Name] format), Rows ([DimesnionName].[Attribute.Name] format) and Filter ([DimesnionName].[Attribute.Name].[Member Name] format) along with other inputs like, cube name, page number, measure etc.
This information is passed to a C# library and then we use lot of 'If' and 'Else' conditions to process this input and generate MDX query as a string. It requires lot of string manipulation.
You can say it has a workflow. After going through each condition, system generates some output. I am wondering if there is a smarter way to design this library.
I want to remove if else conditions.
I want to make it more readable.
I want to make it more manageable
My Question is: Is there any design principle I can use? I can think of using Windows WorkFlow. Please provide your suggestions
I'm actually on here to see if someone has done just that so I don't have to. No luck so far. But off the top of my head what you might want to look at is some form of rules engine that will evaluate the state of target string and add your various criteria.
Now I haven't even started to look into the syntax of MDX. I'm not that far along, but if I wanted to create an engine to create sql queries I'd look at the parts ( simplest case first ) you need list of columns, a table and list of where clauses. So you could have three or maybe just two basic engine classes one that takes a list of strings and (or better yet a list of expressions) and concatenates them ( or evaluates and then concats them ). If target string is empty then targetString = "select "+ x else targetString = ", " + x. Then do something similar with the where expression. You can get considerably more fancy for that building classes that implement the different forms of where expressions and so on. Then ultimately you'd pass your engine something like
MySqlEngine(new[] {"FirstName", "LastName", "GirlFriendsAddress"},
new []{EqualsExpression("FirstName","Brown"), EqualsExpression("LastName",Dynamite")},
"People");
and it would return
"SELECT FirstName, LastName, GirlFriendsAddress From People Where FirstName = \"Brown\" AND LastName = \"Dynamite\""
I would highly recommend using Expressions to evaluate properties on a target model that matches your table. Then you could make MySqlEnigine(...) you wouldn't have to provide to table name because your model could be named the same and you'd use no strings except for target value of the where clauses.
I know this is not the engine you want but I don't know MDX yet so you'll have to use this as an analogy.
Final thoughts DO NOT USE Window Workflow. You will want to kill yourself half way through and if you make it all the way through than there will be developers cursing your name for many years in the future.
Good luck
oh and if you build the please open source it and tell me so I don't have to do it.
I am currently using the 'search in view results' option in the view control to provide the data set for my view (the reason for this is that the data set to be displayed is fairly complex depending on the user - and I was not able to accomplish this using vector filtering).
The problem I have with it, is that the search is a FT search, and that it does not let you search where a field is an exact match on a string, but rather it does a search where the field contains your string.
Does anyone know of an method where I can search the view for exact data?
Thanks in advance.
A
If your database is not too big you could use a database.search. It uses an #Formula to get the documents. It might be by a magnitude slower than FT Search
Take a look at this code http://openntf.org/XSnippets.nsf/snippet.xsp?id=build-a-search-query I think it could help you do what you are looking for.
Based on what you want to do, a better option is to create a hidden view with the columns you need to match on. Then search on that view rather then an FTI search.