wrong order in typo3 tt_content - sorting

in typo3 tt_content the field sorting doesn't show the real order of the elements of a page. Is there any possibility to reorder it, to refresh it?
I want in a selection the bodytext and image of the first Contentelement (textpic) of a page.
Thanks
Volker

I don't really get your question but the order is correct in the backend, however you need to have some things in mind
the sorting depends on the page (field pid), so you can't compare sorting over multiple plages
The field colPos is also important as sorting is unique per column

I got the problem. In my installation in the tt_content is not updating the field "sorting" after a clean installation the problem is solved.
Thanks
Volker

A try of a concrete answer to a vague question:
lib.someContent = CONTENT
lib.someContent {
table = tt_content
select {
where = colPos=0
orderBy = sorting
languageField = sys_language_uid
begin = 0
max = 1
}
}

Related

Order by a string by numbers with QueryExpression

I'm having a problem ordering numbers that are saved as string in CRM,
Its working fine until 10, then it says that 9 > 10 I know a simple solution where I can append zeros to the strings into a fixed length.
Wondering if there is a way to order by a string by int in some way.
My code:
QueryExpression query = new QueryExpression(entity);
query.ColumnSet.AddColumn(ID);
query.AddOrder(ID, OrderType.Descending); //there is a problem because the type is string.
EntityCollection entityCollection = organizationService.RetrieveMultiple(query);
I don't think there is any easy way of achieving this. I faced the same issue for the post code and ended up storing both values i.e. string and int. And while querying i used the int field to sort it.
Hope this helps,
Ravi Kashyap
Another possible solution to this problem would be to sort the results of the query using LINQ's OrderBy() method instead of using QueryExpression's built in ordering.
EntityCollection results = _client.RetrieveMultiple(query);
var sortedResults = results.Entities.OrderBy((e) =>
int.Parse(e.GetAttributeValue<string>("nameofattribute"))
);
This will yield the results your looking for. It isn't an ideal solution but at least you don't have to store everything twice.

In cmdb_rel_ci table I want to retrieve all the unique parent.sys_class_name with count for Type Depends on::Used by

In the cmdb_rel_ci table, I want to retrieve the value and total count of all the unique parent.sys_class_name values for Type(cmdb_rel_type) "Depends on::Used by".
I was trying to use with GlideAggregate, but classname is showing empty.
Can anyone offer some advice?
Use GlideAggregate on the cmdb_ci table, not cmdb_rel_ci. The rel table has no sys_class_name if I recall.
You could also try dot-walking to it using GlideRecord, or using a Join query.
I don't know what "for type Depends on::Used by" means. Pretty sure it doesn't mean anything.
Please take the time to explain your questions clearly and include your code next time if you're expecting anyone to take time out of their day to help you.
As suggested already, use Glideaggregate (more info here)
Try this as an example:
var ga = new GlideAggregate('cmdb_rel_ci');
ga.addQuery('type.name', 'STARTSWITH', 'Depends on::Used by');
ga.addAggregate('COUNT', 'parent');
ga.query();
while (ga.next()) {
var parent = ga.parent.getDisplayValue();
var parentCount = ga.getAggregate('COUNT', 'parent');
gs.info('CI ' + parent + ' has ' + parentCount + ' relationships with type Depends on::Used by');
}

Zoho Creator: Sort sub-form records in both Main Forms and Views/Reports

Zoho Creator is a great system for quickly creating simple cloud applications. I've run into a problem with sub-forms, though: currently, Zoho Creator does not provide functionality for sorting sub-form records by a specified column. Instead, it sorts records in the order in which they were added.
My sub-form is a Creator Form that's linked to another Creator Form (basically, 2 different tables). The forms are linked with a bi-directional lookup relationship.
I've seen and tried implementing these "hacks", but none of them work for my situation:
[Zoho Forums, "Subforms sorting rows"][1]
[Zoho Forums, "Hack to sort rows of a subform and pre-populate row fields that I want to preset"][2]
I also called Zoho tech support, and after looking at my application, they said that sorting sub-form records is not currently possible.
Any other ideas?
My tested solution is still a hack, but until Zoho implements a method to sort sub-form records via the GUI, this will have to do.
First, create a function that you can call from anywhere (e.g. when a new sub-form record is added or changed)--for details on that, go here: http://www.zoho.com/creator/help/script/functions.html
This function will first duplicate the sub-form records by the parent record ID (sorting by the appropriate column) and then delete all sub-form records that were inserted before the script started:
int SubFormRecords_SortByAnything_ReturnCount(int ParentRecordID)
{
scriptStartTime = zoho.currenttime;
for each rSubFormRecord in SubFormRecords [ParentFieldName = input.ParentRecordID] sort by FieldName1, FieldName3, FieldName2
{
NewSubFormRecordID = insert into SubFormRecords
[
FieldName1 = rSubFormRecord.FieldName1
FieldName2 = rSubFormRecord.FieldName2
FieldName3 = rSubFormRecord.FieldName3
];
}
delete from SubFormRecords[ (Series == input.ParentRecordID && Added_Time < scriptStartTime) ];
return SubFormRecords[ParentFieldName == input.EventID].count();
}
Once the above sorting function is in place (customized for your application), call it when appropriate. I call it when adding a record associated with the sub-form, or when I change the sorting column values.
That works well, and as long as you don't have complex logic associated with adding and deleting records, it should have minimal impact on application performance.
Please let me know whether that works for you, and if you have any better ideas.
Caveat: This solution is not suitable for forms containing additional sub-form records because deleting the records will delete linked sub-form values.
Thanks.
I have a a very simple workaround:
1) You have to add a Form Workflow
2)Record Event - Create OR Edit OR Create/Edit (As per your requirement)
3)Form Event - On successful form submission
4)Let Main_Form be the link name of the Main Form
4)Let Sub_Form be the Link name of the Sub Form (Not the link name you specify in the main form for the same sub form)
4)Let Field1 and Field2 are fields of subform on which you want to sort subform records
5)Let Link_ID be lookup field of Mainform ID in the subform
Workflow
1)Sub_Records = Sub_Form[Link_ID == input.ID] sort by Field1,Field2;
(sort by multiple fields, add asc/desc as per requirement)
2)delete from Sub_Form[Link_ID == input.ID];
3)for each sub_record in Sub_Records
{
insert into Sub_Form
[
Added_User = zoho.loginuser
Link_ID = input.ID
Field1 = sub_record.Field1
Field2 = sub_record.Field2
]
}
//Now you check the results in edit view of the main form

NopCommerce 2.5 Homepage sort order

NopCommerce 2.5
I want to sort the products on the home page on the display order given in Admin/Category/Edit/... but I can't find the table that the display order is held in. I have the query in Nop.Services\Catalog\ProductService.cs and I guess I need to set up a Join here but with which table???.
public virtual IList<Product> GetAllProductsDisplayedOnHomePage()
{
var query = from p in _productRepository.Table
orderby p.Name
where p.Published &&
!p.Deleted &&
p.ShowOnHomePage
select p;
var products = query.ToList();
return products;
}
Can someone point me in the right direction, or even better fill in the gaps?
I guess this is quite late but...
No way to modify the default order. In the code above you see the "ORDER BY Name" is hardcoded. This is a big flaw of nopCommerce. There's no table or field that stores the DisplayOrder on HomePage, because there's no HomePage <-> Product relation at all, it's just a switch: it's either ON or OFF.

WatiN SelectList - How can I select any element from the list?

I'm using WatiN to do some web testing and have run into a problem with a select list.
I have to run through a few pages first, adding a 'Category' element that will populate said troublesome select list.
I have been able to easily select an element from the list using ByValue, but the problem here is that the values is more of an index element that is created on the fly with a seemingly random value when the 'Category' element is created. I have tried to use the text that is under the option list in the html but it cannot seem to find it.
At this point I'm willing to settle for any element in the list that isn't value "-1" as this is the "Please select an option item".
Any help at all would be appreciated,
Thanks in advance
Keith 8o8
If i understand correctly maybe this can help:
OptionCollection options = browser.SelectList("elementId").Options;
options[0].Select();
Here is a solution :
SelectList list = _browser.Frame(Find.ById(frameId)).SelectList(listId);
foreach (Option tempOption in list.Options)
{
string value = tempOption.Text;
if (!string.IsNullOrEmpty(value)) // Compare with visible option text
{
if (value.Equals(option))
{
list.Option(option).Select();
found = true;

Resources