View of nodes and their translations - drupal

I'm trying to create a view of nodes and their translations. Specifically, I want each row to show the node title for each language.
The way I'm doing it right now is by filtering the view by a specific language, then adding one relationship of type "Node translation: Translations" for each language on the site. I can then choose the "Node: Title" field, once for the original language and once per relationship.
The problem with this approach is that the nodes that don't exist in the filtered language, but exist in other languages, are not included in the view. That's what I need help with.

I finally got around to solving this (on Drupal 7).
The idea is to filter the view by Content translation: Source translation, then adding one Content translation: Translations relationship for each language.
In addition, a special join handler is used to handle nodes that have no translations. The handler code is on GitHub.
I've created a demo of this approach.

One of way: Just do it without relationships, but use sorting via "Node translation: Translation set node ID", so you get ordered list of nodes, there translated versions of node will followed one by one...

Related

Renaming the Categories & Keywords and other GUI labels

Can we extend / replace the labels presented in the SDL Tridion 2011 Content Manager Explorer?
I'm specifically interested in changing the root items under publications.
Background
SDL Tridion has organizational items, which groups or "stores" items or building blocks (not to be confused with Template Building Blocks, a specific item).
For example:
A folder stores components, schemas, and templates.
Structure groups store pages.
Categories store keywords.
Under the default Publication, we get three options: a root Folder, a root Structure Group, and a label for Categories & Keywords (which contains Categories).
The Categories & Keywords label itself isn't a Category in the same way that Building Blocks is a folder. Dominic Cronin hints at the differences in this SO answer.
Question
I can rename and localize Building Blocks and Root. But can I/where would I
extend/change the Categories & Keywords label? I'm thinking it's
part of Tridion.Web.UI.Strings. It would have to be translated/translatable.
Alternative programmatic suggestion?
Use cases for changing these include:
Change folder, SG, and maybe the Categories & Keywords name to make it easier for authors to have context on where they're at in the BluePrint (I sometimes forget context when the Publication name isn't visible)
Reduce confusion for when "Categories & Keywords" or other Tridion terms confuse authors. This should be used sparingly, but maybe "Tridion Categories" could help distinguish between the "Categories" that an organization already uses.
Great question. It is possible to use a DataExtender to modify the Tridion response, including the tree. I know an extension has been written before to hide certain parts of the outbound email distribution list tree based on group membership.
However, I don't think I would recommend a GUI extension for this. Instead I suggest filing an enhancement request through customer support since it should be part of the product and you have a good use case that applies to many customers.
You can make a DataExtender, which will override Title attribute for this particular node. You will recognize "Categories and Keywords" node by it's ID - it will start with "catman-" prefix.

How do use a custom datatype as a field in drupal 7?

I have several custom datatypes in drupal 7
restaurant
menu
recipe
chef
i want to create associations between this data chef -> restaurant -> menu -> recipe
so that recipe can get the chefs name and the restaurants address
and menu can get a list of recipes, etc
In SQL land, i'd call this a foreign key, but i'm having a lot of problems finding how to do this in drupal 7.
I suspect that there must be some module or functionality i'm not familiar with. But drupal uses it's own lingo and I think i'm falling down on my google-fu
anyone know what i'm looking for ?
These are probably not datatypes but most likely content types. What you are looking for are
A way to relate nodes (ie. content) of one content type to nodes of another (chef to restaurant, menu to restaurant, recipe to menu, etc.).
A way to display information from related nodes (direct or indirect relations) when displaying a particular node.
The relation between nodes can be achieved using the References module (a Drupal 7 port of the nodereference module included in CCK for Drupal 6). This allow you to add references to nodes when editing another. The relation can be configured to allow only nodes of the specified type to be referenced. These kind of reference aren't bi-directional and can only (easily) navigated from the referrer node, not from the referenced node. In Drupal 6, the Node referrer provided a complementary field to navigate the relation both way. Unfortunately, it has not (yet) been ported to Drupal 7.
References may be deprecated in a near future in favor of the Entity reference module. Entity reference clains to provide bi-directional queries via views and proper integration with the Entity API module. The later should ensure that relation defined with the module are fully (problematically) navigable and usable with modules using the Entity metadata (Seach API and others).
Another solution which is also using the Entity system, is the Relation module. It provide complete bi-directional relations. These relations are themselves fieldable entitiesm which means that you add properties to the relations (for instance the dates at which a chef started and ended working at a restaurant).
Once you get the relation, there is various ways to display the related information on a node page. I don't known for Relation, but if References behave like the Drupal 6 version, it will only allow basics display of information from the directly related nodes. One solution is to implement hook_node_view() in a custom module to navigate the relation, retrieve the different nodes, format the gathered information using a custom theme hook and add it to the $node->content for rendering.
Since Entity reference integrates with view, you should be able to build a view to display the node related to the currently displayed node (using the current node as contextual argument). You can then embed the view programmatically in your node view (again, via hook_node_view()) or use a block display.
In Drupal 6, you would use a sub-module of the CCK project called Node Reference. A node reference is a field in one content type that points to another node. In Drupal 7, since the majority of CCK's functionality has been moved to core, the Node Reference submodule is now part of the References project.

How to filter custom content type nodes using ajax in Drupal?

I'm in a situation where I think I need to create my own custom search module. What I'm trying to do is make a page with a list of all my nodes in the node type - let's call it 'Beer'. So I want to be able to filter through the beers in a fashion similar to the one you find on the Apple Trailers page ( http://trailers.apple.com/ ).
I tried using Views 2 but ran it to a few problems:
I can't make the filter links like in the top of the trailers page (exclusive, just HD etc.)
The search function will only search one field (Exposed field "Beer title" but I also want it to search for manufacturer and other things.
I'm aware of a couple of solutions:
I could fix the last problem by using the Computed Field Module where I could combine the fields I want to search through. I just don't see this as a very elegant solution.
I could make my own module and create my own database queries where I apply the relevant filters (I just don't know how).
I could somehow use my already installed Solr module.
So the first solution - the easiest I guess but also kind of bad with duplicate content in my database.
The second solution - the best (maybe) - problem: I'm too dumb.
The third solution - Solr seems pretty cool but would I be able to present my beer nodes with just the title and a picture?
So I guess my question is. Which one of the three would you use? Or what other solutions could I potentially use (I'm confident there are things I haven't thought of :))?
Sounds like this could be a good use for Taxonomy not different node types. Also, Have you considered http://drupal.org/project/quicktabs ?
You could set up each "filter" as a tab that passes an argument down to a view. Then don't expose any views filters to the user.

Creating sub-nodes in Drupal from a single node form

I would like to have a special "sub-node" that could be attached to other Drupal nodes, that allows authors to include commentary (from the author, so this isn't a comment node) and sample text, to the parent node.
I plan to use the exact same fields for the author commentary and sample text, and to create a view that lists both together. So, it would be OK to use the same node type for both the author commentary and sample text, or at least the same fields. This might also be useful for having an "address" node that could be attached to various nodes and then displayed together on a listing page.
I think the solution would include using node reference fields, but I get tripped up when it comes to theming the parent node form.
My question is similar to this one:
Create multiple CCK nodes with single custom form in Drupal
I think the best way to do this would be to create a view to display nodes that use the node reference field. It's tricky the first time you do it, but easy once you understand how views arguments work.
I found this helpful http://drupal.org/node/161867

Creating Drupal CCK content programmatically/ via API

I am working with a Drupal 6.x system to create exercise / personal training programmes, and am using the CCK with content types of Exercise and Programme, where Programme contains a few header fields and a list of node references to the exercises it consists of. This works great and I can manually create programmes which work fine. I now wish to create a module which can generate these programs automatically based on a number of algorithms I have developed, the process will look like:
Load all exercises into array
Load users personal info (entered previously)
Establish best suited exercises
Create new programme content type
Save programme
An Exercise has a number of related attributes and although I could do all of the above using SQL directly into the tables it would be quite complex and doesn't feel right. I would like in step 1 to load the exercises as an array of Exercise objects (node_load?), and then create a programme object and save. Is this OO type approach possible or do I have to resort to manipulating the data directly?
The best way to tackle this problem would be to write your own module to do this.
Step 1 you can do node_load($nid) on all the excercies
Step 2 you can use user_load($uid)
Step 3 you'll need to iterate through the user object and match up to the appropriate excercies.
Step 4/5 I'd create a new $node = stdClass(); object and populate the attributes with the correct data then perfrom a node_save($node); this will assign it a $node->id etc.
If your unsure on what attributes are in your training program node, then do a print_r($node); on one you've created already.
Phil
Drupal doesn't provide any "cascading" save mechanism to save a hierarchy of nodes in one swoop. You'll need to build each node in code and call node_save() on it explicitly as described by Phil Carter.
The Node Export module can generate sample code for creating a node (complete with CCK fields) programatically.
There are a ton of modules that try to do the import thing right. Take a look at a comparison of them http://groups.drupal.org/node/21338
If you need strategies or examples of importing stuff into nodes, those are a great resource.
I don't think "creating" these programs is even necessary.
Why not just display a list of exercises that match your requirements and share 'characteristics' with the user.
I'd accomplish this by making the 'characteristics' be taxonomy. Then attached to users either with a profile, or taxonomy flag. Then display a list (perhaps even a view at first) and those with the same characteristic tags within exercises.
This would be dynamic and user specific and note require pre-loading a bunch of programmes.
A thought.

Resources