Fetch items from Directus Api - api

I've one site with multilingual options and foreach language I've some different contents that are inside on Directus page Translations fields.
I already have one fetch that return all the fields that are included inside this certain Directus page:
https://xxx/items/xxx_page?fields=*,translations.*,page_contents.translations.*,related_pages.translations.*,related_pages.*,page_contents.*&filter[languages_code]=it-IT&filter[page_contents.translations][languages_code]=it-IT
It return all the contents and all the translations fields, but I would optimize the page load.
How can I change the fetch of the fields whith a filter for take only the fields that have a certain languages_code value.
I've already tried to use filter:
?fields=*,page_contents.*,page_contents.translations.*&?filter[page_contents][translations][languages_code][_eq]=it-IT
but without results.
Can someone help me?
Thanks.

Related

Accessing .add on bootstrap tags-input where page has multiple inputs?

I am still very new to JS, jQuery, and Ajax. I do not know the proper way to go about this. I have a page that lists products, and my job is to add the ability for the users to add tags to each product in page with the listing. So in our table that shows the products, I've added the input field with an ID of tags_#productId (so tags_10093) so that each field will be unique.
Now, I need to be able to call .on(beforeItemAdd...) to each field. On each tag add, I will be calling a function in a controller that will store the created tag to a database. I will also be using this same concept to populate the field with tags already assigned to that product on page load.
What I'm having trouble with is deciding how to write this call. The inputs are rendered in a foreach loop based on the product. Would it be "Decent", to render the Ajax script in the same foreach loop so that it can grab the correct class at the same time?

Yii CListView pagination linking to previous result

I have a CListView with pagination showing all results. Everything works fine.
I have a search widget on the page that renders a partial view to replace the existing list with search results.
The first search result page loads, looks great, and even shows the correct number of results in pagination, but if I try to go to one of the next pages, items from the first list are loaded.
Does anyone know what I have to do in order to fix this? Do the search results need their own full view rendered?
Thanks you in advance.
I was mistaken.
The pagination was not linking to the previous result, it was loading everything which the previous result also does, which is why I was mistaken.
I thought that the data provider in the controller kept track of the result set but you have to keep resending the same criteria every time. I was sending the criteria the first time and not on subsequent results so it loaded everything in absence of any constraints. I simply put the search parameters in session and then retrieved them so they could be considered on every request and it fixed the problem.
In short there is no bug, just me being new working with Yii.

Asp.Net MVC Paged List and passing Search Criteria

I am using Troy Goode's PagedList extension on my MVC page. It is working fine by rendering the partial containing given page of records.
Now I have to implement filtering of search results. I am using AJAX form to fetch partial containing results matching with given search criteria. This works well if there are less than one page of results. If the filtered results beyond one page, there is an issue. When clicked on paging link the filtering information is gone and it results next page of unfiltered information.
What mechanism I can use to pass filtering information when something is entered to filter search results and there is paging link?
My PagedList library takes a Func to generate the URL when you call #Html.PagedList(...):
page => Url.Action("Index", new { page = page })
You simply need to customize the parameters you're passing into Url.Action (which is a Microsoft class/method, docs can be found on MSDN).

Lucene SearchResult.Fields collection is missing some properties

I have asked the following question at the Our Umbraco community site also, but I've had no luck there so far.
I've got a task where I need to manually add database records for a media image file, which is to appear in an Umbraco site for our client.
My SQL consists of:
Adding a record in umbracoNode for the image.
Adding a record in cmsContent
Adding a record in cmsContentXml
Adding records to cmsPropertyData for the image's umbracoFile, umbracoWidth, umbracoHeight, umbracoBytes, umbracoExtension
After executing the above, and logging into Umbraco, I can see the image in the Media area and all looks fine.
The problem is the call the #Model.MediaById() (in a Razor file) when I want to display that image - basically no image is displayed since the img 'src' attribute is not set.
I've stepped through the Umbraco code and found the problem. Basically when the code uses Lucene to search for the media (ExaminedBackendMedia.GetUmbracoMedia()), it does find the image file, however there are a number of fields missing for the SearchResult. For example, none of the "umbraco*" properties adde to cmsPropertyData appear in the fields collection. When I step through the code for another image (one that was added manually) I can see an extra 5 or so properties in the fields collection - including all the "umbraco*" properties.
So I can see that I have missing data here. Basically the SearchResult object is missing some fields. Can someone suggest what I may have missed please? Why is Lucene not picking up the "umbraco*" properties that I've added via SQL scripts?
You need to make sure that you republish the nodes, which will take them from the database entries that you created and put them into the XML cache that umbraco actually uses when serving up data.

Sitefinity How to Exlude Template from Searching

Is there any way to exclude Sitefinity main template i used for all the pages, from searching?
Right now if i search,the search is returning the result with words present in the template menu,even though its not belong to the page.
Now i need to search pages exlceding that template contents.
Thanks in Advance.
The problem here is i have added a menu inside a content block widget in a template.
This template is used throughout the site and when i search for a keyword using the search feature, all the pages of the website are listed in the search result because the keyword is also found in the menu.So i need a solution so that the search result does not include the menu content in the search result.
This is a very high priority. Please help me find a solution at the earliest possible.
Ivan Pelovski recently published a blog post on how you can hide content from the search engine by using custom layout controls. Not specifically what you are asking, but maybe it can help.
Here: http://www.sitefinity.com/blogs/ivanpelovski/posts/12-02-06/hiding_page_content_from_the_search_engine_in_sitefinity_using_layout_widgets.aspx
Try adding a robots.txt metatag like this into the top of the template:
<meta name="robots" content="noindex" />
In more recent versions of Sitefinity you can also uncheck a box at each page level that will prevent the page from being indexed. The column for this setting in the database is sf_page_data (table) .. crawlable (column) in case you want to write a sql script to update several pages at once.
The exclusion of templates from search is mentioned in more detail here:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/exclude-page-from-search-index.aspx
Note that this will probably also prevent other search engines (such as google) from indexing that page.