Adding custom index for sorting of collections in Plone 5 - plone

In order to rank my plone pages by a number of positive ratings that the users have given them I am using the cioppino.twothumbs addon and now want to sort a collection by number of positive ratings.
I want to add a custom index from the Plone 5 addon cioppino.twothumbs as sortable index to Plone collections. The index is called positive_ratings and registered by catalog.xml of cioppino.twothumbs. In my custom branch of the addon I added the code mentioned in the documentation:
<records interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.positive_ratings">
<value key="title">Positive Ratings</value>
<value key="description">total number of positive ratings</value>
<value key="enabled">False</value>
<value key="sortable">True</value>
<value key="operations">
</value>
<value key="group">Metadata</value>
to the registry.xml of the addon. Unfortunately I have this index not visible as sortable on the Add Collection page, although it is available as additional column of the Collection.
This Question is similar to this one, but unlike the user there I have not modified the plone.app.querystring source code, but my custom branch of cioppino.twothumbs, as suggested by the answer.

The code was completely correct, however I forgot to rerun the installation of the addon for the registry to get updated. This solved the problem completely and enabled the sorting of collections by this value.

Related

How to write OSLC query where clause in Maximo Anywhere to evaluate somevalue < now()

I'm configuring Work Execution. The Work Order History query that is called when retrieving past work orders for assets or locations is open-ended. Consequently, several thousand rows are retrieved each time and the application times out. I can attach where clause (see below) to limit it to records with actfinish after a specific date. However, what I want to do is something like this...
spi_wm:actfinish>now()-30
<!--WorkOrder History Asset Resource-->
<resource id="workOrderHistoryAssetLoc" class="application.business.WorkOrderObject" defaultOrderBy="wonum asc" describedBy="http://jazz.net/ns/ism/work/smarter_physical_infrastructure#WorkOrder" name="workOrderHistoryAssetLoc" pageSize="50" providedBy="/oslc/sp/WorkManagement">
<attributes id="workOrderHistoryAsset_attributes1">
<attribute describedByProperty="dcterms:identifier" id="workOrderHistoryAsset_identifier_dctermsidentifier1" index="true" name="identifier"/>
<attribute describedByProperty="oslc:shortTitle" id="workOrderHistoryAsset_wonum_oslcshortTitle1" index="true" name="wonum"/>
<attribute describedByProperty="dcterms:title" id="workOrderHistoryAsset_description_dctermstitle1" index="true" method="descriptionChanged" name="description"/>
<attribute describedByProperty="spi:status" id="workOrderHistoryAsset_status_spistatus" index="true" method="statusChanged" name="status"/>
<localAttribute dataType="string" id="workOrderHistoryAsset_statusdesc_string" name="statusdesc"/>
</attributes>
<queryBases id="workOrderHistoryAsset_queryBasesh">
<queryBase defaultForSearch="true" id="workOrderHistoryAsset_queryBase_searchAllWorkOrdersh" name="searchAllWorkOrdersAsset" queryUri="/oslc/os/oslcwodetail?savedQuery=getWithComplexQuery"/>
<!-- TODO AWH 20170130 - add where clause to this query -->
</queryBases>
<whereClause clause="spi:status in ['COMP','CLOSE'] and spi_wm:actfinish>'2016-10-10T09:50:00-04:00'" id="workOrderHistoryAssetLoc_whereClause"/>
</resource>
I see elsewhere where there are formulas in the app.xml but I don't know what types of operators or language is available to accomplish something like this. I was hoping the whereClause attribute had the ability to use a resolverClass and resolverFunction so that I could replace a named parameter with a value derived from a javascript function... no dice. Any help would be appreciated!
It looks like you are attempting to set the where clause in the app.xml. While I think this could work, it would probably be a million times easier to do the following.
duplicate the resource, then comment out the original
Create a saved query in Maximo with the where clause you need
a. spi:status in ['COMP','CLOSE'] and spi_wm:actfinish>'2016-10-10T09:50:00-04:00'
Name the saved query "ANYWHERE_WOHIST" or something like that.
Modify the duplicate resource to point to your new saved query.
<queryBase defaultForSearch="true" id="workOrderHistoryAsset_queryBase_searchAllWorkOrdersh" name="searchAllWorkOrdersAsset" queryUri="/oslc/os/oslcwodetail?savedQuery=ANYWHERE_WOHIST"/>
Also, this allows the query where clause to be managed in the backend, so when your users decide they want to see something else here you can mange the query within Maximo. We're nearing the end of our project with Anywhere, so feel free to reach out if you'd like to swap war stories.

How do I create a page that shows two specific nodes?

We want to create a page that shows two specific nodes.
The first node will be localized content (an article node in the user's language). There will be at least 5 different language versions of that page.
The second node will be a Webform node that the user can submit to "sign" the document. It will be language neutral.
Originally I figured that I could have one Webform node and then translate it into the appropriate languages. But what I discovered was that the "translated" version of the Webform node was, in fact, a completely new node--which means a completely new webform. This makes sense if you think about how Drupal handles multilingual content--each translation is a separate node.
But in the case of our webform, we don't want to split the submissions into 10+ different webform submission sets. Everybody who "signs" has their signatures placed into the same "bin" of data.
I can think of two possible solutions:
Create a page that will display two nodes: the localized version of an "article" node (selected depending on the user's language selection), and the webform.
Create multiple Webform nodes (one per language), and then create a MySQL view that merges all the user submissions into a single set of records. This would allow us to extract our data without a great deal of headache.
I'm not sure if 2 is possible. I'm assuming that I'll have to go with 1. But, so far my efforts to accomplish this have also been fruitless! How can I do this?
-Josh
I think 1 is much easy and possible solution. You can create webform node and make body field as php code (for that you need to enable php filter). And put in body follow lines:
<?php
$nid = NODE_ID;
$node = node_load($nid);
$node_view = node_view($node, 'full');
print drupal_render($node_view);
?>
Just replace NODE_ID with nid of multilanguage node.

Multiple input fields in table

Currently we are migrating our intranet from plone 2.5 to drupal 7. Everything works out pretty well except one problem we are facing with the cck module.
In plone we had one content type "application" which allowed our members to applicate for a specific project. There were many input fields for describing the required qualification from other projects like in the following "image".
project description
[ ][ ] + - up down
[ ][ ] + - up down
[ ][ ] + - up down
add new row
Our member had the possibility to mention an unlimited number of projects and associated descriptions.
So the problem is, i´m unable to do anything similiar in drupal 7.
I could definitely add an unlimited node reference field and an unlimited text field, but there would not be any kind of relationship between the two fields and the user would have to click "add another entry" twice.
Another option would be the use of the module http://drupal.org/project/tablefield but its not possible to use the first column as a node reference.
I´ve browsed through every cck module available and found nothing really helping, so now i hope you can help me!
Thank you
Have you tried the field collection module?
This helps you add a collection of fields as a single field.
So you could have 'Projects' as a "field collection" type field have unlimited number of values. You can then add the individual field like the Project name, description, etc. in the field collection.
This module is for D7.
New answer to an old question (but isn't that how Drupal usually works): you might want to try the Multifield module as an alternative to Field Collection or the other solutions posted here. It's meant for this type of problem.
The module Field group is creating this relation for you.
In Drupal 6 we can do this using Flexifield The project description page of flesifield says that similar functionality can be achieved in Drupal 7 using Combo Field. But I have never tried it though. It might worth giving a try.
For Drupal 8 you can also look into the Paragraphs Module for handling a multiple field with multiple inputs. Can be used for product properties, recipes and more advanced use case where a single field can behave like a content type.
There is also a module for Drupal 7 and Drupal 8 called Double field

Create list of nodes that are referenced at least once

I'm sure this is simple with the Node Relationship module but I can't wrap my head around it.
I have a list called 'Comedian Profile' which has a node reference field for it. You then make - you guess it - profiles for comedians. To make an 'Events' (that doubles as an Ubercart item) you select the comedian. It then creates a view in the profile that lists all of that person's upcoming events.
Now what I need is an listing that shows in order of the date field each comedians name that is referenced(I'll worry about the other fields later). Note that the name is the referenced term.
Is this the right approach? If so could someone point me in the right direction or suggest a better way?
If I got it right, you can accomplish this using views relationships.
Add the field "Comedian" of the Event content type as a Relationship in the view (be sure to check the "Require this relationship" box). Then, add the fields, selecting the relationship you created. If the "Comedian" field is optional, check the "Hide if empty" box.

Drupal Custom CCK field with multiple child fields

Is there a way of creating a composite field that can have multiple values, with each value having another group of composite values?
E.g. we want to have this structure at the end:
Group 1 (unlimited number of groups)
Child field (unlimited children for each group)
Child field
...
Group 2
Child field
Child field
...
...
Is this possible at all for a custom module that defines a CCK field? If so, can someone push me in the right direction?
this is a very know and debated issue in the drupal world.
this feature is called cck "multigroup" and it looks it's pretty difficult to implement.
there are a lot of posts in the drupal forum about this, i suggest you to start here:
http://drupal.org/node/494100
it's a kind of "hidden" feature in the cck module. looking in the module directory, you will find instructions here:
cck/modules/content_multigroup/README.txt
Edit: Ongoing work on the multigroup module has moved to the experimental
CCK 3.0 branch.
in the meantime you can try to deal with it using the flexifield module
(but it's kinda hackish, i won't use it in production)
I ended up creating my own "Cost/Product" CCK compound field based on this excellent tutorial with example modules: http://poplarware.com/es/articles/cck_field_module
I haven't figured out yet how to pull out a specific sub-field, such as cost, in Views. I only get the entire ": $" compound.
For Drupal 7+, you probably want to check out the Field collection module, or Field group if multiples aren't necessary.
This issue is pretty old, but I just happened across it. I would think the way to handle it for now would be with a second cck type for the children, and the groups as a node_reference field. So you'd have:
MasterType
group field
unlimited per node
each one, a reference to a ChildType node
ChildType
child field
unlimited per node

Resources