How to auto-populate referenced documents in a Sanity.io schema? - sanity

Here are the relationships I have:
Artists
Artworks -> references Artist from Artists
What I would like to do is view all the Artworks that reference a particular Artist inside the Artist Document view, without manually adding them. This way I can control custom sorting visually, and quickly see what artworks are associated with the Artist without having to reenter data.
I suspect I could use GROQ for this, but I don't know how to incorporate it into a schema for this purpose.

Related

Orchard CMS Customer Module

My case is that we want to build a customizing Lab Module (show Basic Science Research) which provides a template to show each lab pages in consistent style. This module will also allow each lab's manager(non-developer) to update their own lab pages with some textbox, checkbox, upload file or image, TinyMce plain input elements(not html/css) after they login Orchard (or Developer directly provides them some links to update page infos without login, best not in Admin Dashboard). Each lab page will show Research, Project, Members, Publication, News Sections in front-end. My current plan is creating ResearchLab type (ResearchLabPart/ResearchLabRecord includes lab title, research_topic, research_image, research_protocol etc), Project type (ProjectPart/ProjectRecord includes title, start_date, foreign key researchLab_Id etc), Member type(MemberPart/MemberRecord include name, title, Linkedin links, foreign key researchLab_Id etc), Publication Type(Member/MemberRecord include name, title, Linkedin links, foreign key researchLab_Id and project_Id etc) etc. The foreign key is that once a researchlab id is chosen and based on this value, corresponding project, publication and news for specific lab could be queried as well right away. When lab manager updates the Researchlab part page, he/she wants to upload some research_image or protocol pdf, doc files. For ResearchLabPart (having lab_title, research_topic, research_image, research_protocol properties etc) and I could easily attach ImageField (assuming name ResearchLabImage) as OfType("MediaPickerField") or fileField(some external module) into ResearchLabPart in Migration.cs after enabling these two external modules. In the ResearchLabController of my custom module, Edit Action will view link to a return model=_contentManager.BuildEditor(ResearchLab) which will go to EditorTemplates--Parts--ResearchLab.cshtml. I want to assign the url (or file/image's name values, using ((dynamic)Model.ContentItem).ResearchLab.ResearchLabImage ) into research_image, research_protocol properties of ResearchLabPart. It looks like I need to implement assigning values in Eitor method of LabMemberDriver, not sure? My target is to let file or image fields to save files and images in some folders under my module directory and save the files or images's name or url path into photo, cv properties of LabMemberPart. Am I going to right direction? How to connect and exchange image/file fields to the properties of ResearchLab part in source code part? Any thoughts or comments are welcome. Thanks.

SiteFinity 7.1 custom content items and grouping

We have a list of faculty and units for a SiteFinity 7.1 site. We have these as custom content items in the site, because we are programming against them and building a few widgets around them.
However, we also have news about these faculty and units, and we'd like to use the existing news items in SiteFinity.
How do we easily tie faculty and units (custom content items) to news items (another content item baked into SiteFinity)? I wasn't sure if we create classifications that list faculty and units, and use these as the grouping mechanism? Or is there an easy way to tie two content items together? 
It kind of depends on how you're going to (or how you want to) display the data at the end. Here are a couple of different ways to achieve what you're after.
You're planning on using the stock News widget to display the content.
If this is true, using a custom taxonomy would be pretty easy in this case. Here's a video that outlines this method.
You're planning on displaying the news items in close proximity to one of the custom content types you've created.
In this case, adding a related data field to the custom type would allow you use related content items with widget templates.

Core Data and bindings - binding checkbox to result of many-to-many relationship

Core Data model
I have a many-to-many relationship between two of the principal entities; call them Item and Tag. There will be a large number of Documents. Each may have 0 to an arbitrary number of tags.
Each Item entity relevantly has an attribute called name, and a to-many relationship to Tag called tags. Each Tag entity relevantly has an attribute called name, and a to-many relationship to Item called items.
To display them, within the same window, I have: (i) an NSTableView (itemTableView), fed by an NSArrayController (itemArrayController), showing all Items; and (ii) an NSTableView (tagTableView), fed by a different NSArrayController (tagArrayController) showing all Lists.
tagTableView
In the tagTableView, the Table View is bound to tagArrayController, with controllerKey arrangedObjects.
There is only a single table column. The textfield in it is bound to Table Cell View, to model key path objectValue.name. That works so far; it displays all of the lists as expected, and sorts properly when I add a sort descriptor.
Everything has been set up using interface builder in Xcode.
The problem
I have added a checkbox into the tagTableView, in the same table column as the textfield. I am trying to implement two things:
The checkbox should be checked if the user has previously associated the Item with the relevant Tag. If not, the checkbox should be unchecked.
If the user checks an unchecked checkbox, I want to establish a relationship between the two; if the user unchecked a checked checkbox, I want to break that relationship.
The underlying behavior pattern is that the user will not necessarily have control over the tags and may not be able to create them. They are to choose from existing tags, and therefore should be able to see which ones exist, and be able to check/uncheck those that apply.
However, I can't see how to implement this.
Part solutions so far
I can see a possible way to do at least the first task programmatically, roughly along these lines:
Monitor tableViewSelectionDidChange for itemTableView
For a change, update the data source for tagTableView manually, and work out checkbox state by checking them for those Tags which relate to the Item entity that has just been selected, and otherwise unchecking them
However, this looks likely to add complexity, and ideally I would like to do this with bindings if possible.
I have reviewed the Apple Core Data and Bindings references, all the Cocoa books I have, stack overflow and I've also done extensive googling. I have found lots of similar questions (e.g. http://lists.apple.com/archives/cocoa-dev/2011/Mar/msg00164.html) but no answers.
I've also found a way that might work programmatically, but which seems to be like my idea above, at the expense of being able to use bindings (e.g. http://www.raywenderlich.com/14742/core-data-on-ios-5-tutorial-how-to-work-with-relations-and-predicates)
The only relevant question on this site -- Core-Data Check Box Cell with many-to-many data -- is not answered to a level that I can make use of.
It would seem to me that this should be a prime candidate for bindings. I should be able to ask the itemArrayController what Tags (if any) have a relation to its selected item, and then set the checkbox to ticked if it matches the relevant Tag, and unset it if it doesn't. I would expect I should be able to do this within the bindings for the checkbox itself, in interface builder. But I can't work out what model key path or binding to use, or what to set the cocoa bindings for the checkbox to. Am I missing something obvious? Thanks

Core data, NSArrayContainer Arraycontent of many arrays

I've got three entities in my application so far: tag, feed and story
A tag has got a to-many relationship to feeds and feeds has got a to-many relationship to story.
I've got an NSArrayController for each entity, one named tags, one named feeds and one named stories.
They all share the same 'managedObjectContext' which they get from the file's owner. the content set of the AC named feeds is bound to 'tags' controler key: selection, key path: feeds
I want the content set of the third array to be bound to all of the stories in all of the feeds in the selected tag: i tried to use the key path: "#unionOfArrays.stories" but couldn't get it to work.
Any idea how i would go about this?
First of all, there's one thing in your question that's inconsistent with getting something working:
They all share the same
'managedObjectContext' which they get
from the file's owner
When I set this up in IB, it just didn't work. You surely mean you bound the managedObjectContext to that of the App Delegate.
Assuming you want to see all the stories in the selected tag, here's a few mistakes you might have made in your setup.
1. Check Inverse Relationships
For all the relationships you mention, you need to set the inverse for each relationship.
For the one to many tags->feeds relationship, you'd have a to many relationship in the tags elements called "feeds", which you've described.
You'd also have a to one relationship in the feeds entity called "tag".
You'd select the inverse relationship as being feeds as shown below:
Single Feed Relationship http://img20.imageshack.us/img20/2557/tagsinglefeedrelationsh.jpg
2. Link Up Stories
You don't mention how you've created any of your Stories. Assuming you're not doing anything in code, I'd have 4 Array Controllers:
Tags
Feeds in Selected Tag
Stories in Selected Feed
All Stories in Selected Tag
If you just have a Stories Array Controller whose Content Set isn't bound to anything, you'll be creating stories effectively in a vacuum - they won't be linked to any feeds or tags, which might be why you're getting these errors.
3. Setup "Stories in Selected Tag" Controller
You need to set the Content Array, not the Content Set.
Bind the Content Array to the "Feeds in Selected Tag" Controller.
Key: arrangedObjects
Key Path: #unionOfArrays.stories
This sends the Key Path stories to every object in the "Feeds in Selected Tag" Controller, thus getting all the Stories in all the Feeds in the selected Tag.
4. Rock and Roll!
We're done. If you're really struggling getting this set up, let me know and I can post the link to the XIB file I've made.
You can try #distinctUnionOfSets.stories. All Core Data 1-n relationships are implemented as sets.

Creating a new module in Sitefinity

I'm trying to create a new module for Sitefinity. I'm basing my module off the sample module linked to from the documentation. http://www.sitefinity.com/help/developer-manual/adding-modules-pluggable-explained.html
What I want is a list of videos. On the left-hand side - the CommandPanel - there should be 3 buttons - "Videos", "Artists" and "Genres".
Whenever either of these is selected, on the right-hand-side, a list of Videos/Artists/Genres should be displayed.
The concept is simple, but what I'm struggling with is, where to actually put the code.
Should I hard-code the list directly into CommandPanel.ascx? Am I supposed to create new controls for Videos, Artists and Genres? Or should I have one control and multiple Panels, which I show/hide? And how do I connect the menu items on the left with changing the panel on the right?
NB. I might be wrong to have Videos, Artists and Genres all on the left. Maybe it should just be "Videos", and Artists and Genres should be separate module each?
I don't need a complete answer, just some direction on how to code in this framework, and where everything should go.
Hi there I just saw this come up I am not sure if you have already started this module yet you may even be finished by now, but I just wanted to say had you checked out the Sitefinity Beta for 3.6 because they are about to simplify the whole Sitefinity module process and particularly for what you are trying to do. Check it on the Sitefinity block a barebones module with the new architecture. This I think would satisfy your needs because you can create a separate "View" for each one of your Videos, Artist and Genres and all their views like create, edit etc.