Finding related articles - sulu

I am using Sulu 2.2 with the article bundle and have defined multiple article types, one of them has a single_article_selection type of field which I use to feature other articles.
ex : article 'A' is featured in articles 'B', 'C' and 'D'
When rendering article 'A', is it possible to access the collection of others articles who feature it ? Be it in the twig template file or via a custom controller ?

The best would be that you index your single_article_selection into an own field in the ArticleViewDocument by extending it.
See the extend ArticleViewDocument Documentation here:
https://github.com/sulu/SuluArticleBundle/blob/2.2.2/Resources/doc/article-view-document.md
Then you can use the SearchManager to query and filter by that specific field. You need to use the esManager of the live index to query live documents.

Related

Laravel Backpack 4.0 Documentation for Pivot and PivotFields within CRUD Controller

I'm using a select2_multiple field within Backpack for Laravel and the relationship that I'm working with has additional pivot table values.
Within the documentation it references
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
This is all the information that is provided. While troubleshooting I've come across other documentation / posts that are referring to pivotFields.
Can someone please shed light on what this flag is actually doing and if there are additional requirements that are not documented correctly.

Manual sorting of sys_category

On my TYPO3 7 site, i'm not able to choose an order to the categories of a page or a news (plugin tx_news). I can only choose what categories that page or news have, using the checkboxes to select them.
Is there any configuration for that?
Alternatively, I may override these fields with my own TCA, but have no ideas on how to get a sorting tree of categories. Any hint?
On my sites running previous TYPO3 versions with tt_news plugin, its category tree allows to change the sorting after selecting the categories.
I coudn't find anything about it on the "select" documentation (https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Select/Index.html). Looks like MM relations doesn't support sorting.
Does anyone knows how to get it?
Make sure you have the "extended view" checked at the end of the page. You can then sort the sys_category-entries using the up/down arrows.
If you need to sort your categories per item and not globally then a default MM relation will not work as it doesn't support sorting. You're on the right track. Override or extend the TCA, don't specify a MM relation and don't use the tree view rendering. Use a standard select like you would select pages. This should store the values as a comma-list string in the database and so represent the sorting like you would see it the backend.

How to enable Hash Index Type for embedded OrientDB Graph Databases?

By default OrientDB is using the "SB-Tree" index¹. Is it somehow possible to change the used index type to "Hash" through Java API Calls?
I was unable to find a way to change the selected index type.
[1] http://orientdb.com/docs/2.1/Indexes.html
From Graph API, you can create a HASH_INDEX in this way
graph.createKeyIndex("name", Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"));
Use NOTUNIQUE_HASH_INDEX in case the index is not unique.
For more information look at the docs: http://orientdb.com/docs/2.0/orientdb.wiki/Graph-Database-Tinkerpop.html#using-indices

How to do a search by date query on cq pages

I am trying to create a blog in cq5. The OOTB search component in blog is not supporting search by date feature. I tried to override it, but could not find the correct query to fetch the blogs created on a particular date. Seems the only functions supported are >,>=,<,<=.
Please help me in finding a query (preferabbly xpath) to fetch a page created on a particular date (cq:lastModified).
There are some functions in XPath like contains or not. There is also one for date fields. Here an example for anything that was just modified in the content tree:
/jcr:root/content//*[#cq:lastModified >= xs:dateTime('2015-05-29T08:44:56.280Z')]

Is there way to create & index N no. of 'fields' dynamically with Sphinx

I am using Sphinx (with Thinking Sphinx v2.0 for RoR plugin),
Lets say I have several indexes on User model, lets say on 'name', 'address' and its one-to-many associations like 'posts' , 'comments' etc.
This means searching by post content would return me the User who made the post, and using :fieldmask 'rank mode' of sphinx, I am able to determine that the user was searched due to matching of 'posts'. But user has 'many' posts. So how to determine which 'post' it matched.
Is there any way, while indexing I can specify the index dynamically.?
For e.g. If I can specify index 'post_1'='< post1content >' , 'post_5'='< post5content >' as different 'fields' for user1; similarly 'post_2', 'post_7' for user2, Thus after searching It would return me user2 matched with matching fields as post_7...
Sphinx can't have different fields for each record, I'm afraid, so what you're hoping to do isn't possible with that approach.
If you need to know which posts match a query, I'd recommend conducting the search on the Post model instead, and then you can refer to a post's user? You could sort by user_id before weight, or group by user_id (so only one post per user is returned)? You'd be able to bring in user data into the Post index definition (and if a post has one user, then that data is kept to single values, instead of many, per record).
Hope this gives you some clarity with your options.
If you know, you want to search for post_5 in one query, and for post_7 in another query, you may use json as {post_1:, post_2:}.
Problem is that you have to know number of post you are searching for.
Maybe look to: https://stackoverflow.com/a/24505347/1444576 -if it is similar to your example.