Sulu: Is it possible to limit Categories per webspace? - sulu

We have a sulu 1.6 multi site installation and are wondering if it is possible to limit the available categories per webspace?
Something like:
webspace 1:
cat 1 and children only
webspace 2:
cat 2 and children
cat 3 and children
Is that possible?

Sorry, but this is not possible. The closest thing I can tell you about is our rootKey parameter of the category API. This query parameter would allow you to only return children of the category with the given key. The key is the second line in the contact form.
So if you send a request like this, you should get only a subtree of the categories:
/admin/api/categories?locale=en&flat=true&rootKey=category1
However, the bad news is that this query parameter is not used by the category_list field type. However, a PR would be highly appreciated, and probably get merged :-)

Related

How to Display Attribute Group Name in Product Tab Magento 2.1.3

I created an attribute set and attribute groups with attributes in it. In the admin panel the attributes are listed in groups, like i created them. But on the front productpage all the attributes are listed together, without displaying the attribute group name first.
I would like to display the Attribute Group Name on the product page (more information tab), before the attributes in this group. How do i do that?
There is no way to do this by default in Magento 2.
There are a few ways I can think of to acheive this. Perhaps best would be to extend the getAdditionalData() method in /Block/Product/View/Attributes.php so that it adds the attribute group name (or id) to the returned array.
You would then need to create a local copy of Magento_Catalog/templates/product/view/attributes.phtml and iterate the array returned by the modified getAdditionalData() method sorting it according to the group name and then output the data with group name headings.
I'd be interested to hear of other or best practice approaches to this type of relatively simple extended functionality in Magento 2.

Microstrategy - Creating 3 selectors on the same attribute

I have a requirement of comparing Product line (attribute) and Brand (Attribute) using 3 different selectors. Product line and Brand is having one to one relationship .
My dashboard should look like below.(sorry I cant attach the snapshot)
Prod line (selector) Brand(selector)
Prod line (selector) Brand(selector)
Prod line (selector) Brand(selector)
These selectors should be only dropdown type.
User will select a particular product line and can compare it with a particular brand at a time.
I created 3 selectors with the same attributes , but it is not working.
Please help me with the above scenario ASAP. We suggested the checkbox type selector but the client requirement is only dropdown
We had a similar scenario (a bit easier, only [Region]->[Street] in the dataset and we wanted to select two streets from this region from and target a single panel).
What we ended up with: Creating additional attributes. These attributes must not be built on the same table so you have to create aliases for that.
You'd end up with "lu_product", "lu_product_alias1" and "lu_product_alias2". Then just copy the Product attribute twice and alter the id/desc-attribute forms to point to the correct alias-table. If this doesn't help you might have to repeat the process for Brand.
Personally I think this brute-force solution is insane, but it worked for us and a small dataset. I'd be glad to see other and more lightweight solutions though.

Sorting Entry Fields in Movable Type 5 CMS

My CMS is currently Movable Type 5.04. The attached screenshot is how I check in Compose Screen of MT CMS.
And it appears in the new entry create page with the following order.
- Location 5
- Job Description 5
- Bio 5
- Job Title 5
I would like to change the order into following.
- Job Title 5
- Location 5
- Job Description 5
- Bio 5
Is there any way to do so? I have checked in the cfg_entry.tmpl file and the above Entry fields were not there as there were custom fields. Could you please help me sort them like above?
the order of the fields are stored into the permission table, in 'permission_entry_prefs' field. (and there is a matching field for the page)
the row with blog_id 0 is the user defaults, and each blog's raw will override the default for this blog.
and the format is very simple: comma delimited list. you should find there something like "title,text,tags,assets". just reorder them for your liking.
If the user will toggle on and off fields, I'm not sure if the original order will return or not. if it does, then a simple plugin can solve it in more permanent way.
I remember doing this by recreating the custom fields in the wanted order (MT pulls them from the DB in a specific order, sorted by ID IIRC). If you have existing data, then you need to delete the fields definitions (not the data) then recreate them in the order you want changing just their numerical ID (not anything else).
I'm traveling and busy at the moment so can't dig into details. But study how CF are defined in the DB and how to simply reorder them by ID.

Best way to give options for starts with or contains in REST query

I have a REST service that allows people to put in a course title as part of the query to get scores, but, sometimes they may want to get a group, such as Calculus% for Calc 1, 2 and 3.
But, what is the best way to give them an option that makes sense?
For example, I have http://localhost/myrest/any/any/Calculus III
where the first two parameters are student id and some grade category.
I don't think having http://localhost/myrest/any/any/contains/Calculus III is a good use as then I will need to force them to use equals if that is what they are looking for.
Another option is http://localhost/myrest/any/any/Calculus% or http://localhost/myrest/any/any/%Calc% is another option, but then you have removed the option to easily use % as an allowed character.
So, to give additional filtering options in a REST URL, what is the best (defined as simplest/most intuitive for the user) way to allow contains or starts with.
In your system, would the following query list all subjects in the grade category?
http://localhost/myrest/any/any/
If yes, then one option you can consider is extracting the non-exact subject name into a GET parameter. Thus without breaking the current logic where having a full name of the subject in the URL provides the score for that subject, you'd also have the ability to filter the list of subjects within the same grade category by means of the GET parameter.
For example:
http://localhost/myrest/any/any/?search=Calculus*
... could provide a result like this:
<subjects>
<subject uri="/myrest/any/any/Calculus%20I">A</subject>
<subject uri="/myrest/any/any/Calculus%20II">B</subject>
<subject uri="/myrest/any/any/Calculus%20III">C</subject>
</subjects>

how to select specific number of child entities instead of all in entity framework 3.5?

i am wondering how can i select specific number of child objects instead of taking them all with include?
lets say i have object 'Group' and i need to select last ten students that joined the group.
When i use '.Include("Students"), EF includes all students. I was trying to use Take(10), but i am pretty new to EF and programming as well, so i couldn't figure it out.
Any suggestions?
UPDATED:
ok, i have Group object already retrieved from db like this:
Group group = db.Groups.FirstOrDefault(x=>x.GroupId == id)
I know that i can add Include("Students") statement, but that would bring ALL students, and their number could be quite big whether i need only freshest 10 students. Can i do something like this: var groupWithStudents = group.Students.OrderByDescending(//...).Take(10);?
The problem with this is that Take<> no longer appears in intellisense. Is this clear enough? Thanks for responses
I believe Take(10) would be correct.
var Students= (from c in Groups
orderby c.DateAdded descending
select c).Take(10);
My experience with Take though is that it generates some awful sql.
EDIT:
see if this blog post helps, it talks of conditional includes.
http://blogs.msdn.com/b/alexj/archive/2009/10/13/tip-37-how-to-do-a-conditional-include.aspx
Couldn't make Gratzy's suggestion with conditional include work... and found the solution here: http://msdn.microsoft.com/en-us/library/bb896249.aspx
Query would look like this:
group.Students.Attach(group.Students
.CreateSourceQuery()
.OrderByDescending(x=>x.JoinDate)
.Take(10));
This is exactly what i was looking for!
Thanks for all responses anyway!