Currently, the node_embed view mode is used everywhere. It would be useful to be able to switch this for specific embeds. In #1461696: Document parameter syntax, lance.gliser suggested passing the view mode as a parameter, which is one option. I'd like to look at alternatives that could leave parameters completely independent of specific use cases, though that may prove to be more complicating than simplifying.

Comments

lance.gliser’s picture

I'm trying to imagine some system for using the different view modes, without reading it from the parameters (existing syntax, or a new one), and having trouble. Even if we were to create some settings page that let you change the embed type for matched nodes, that's still to global. We'd miss out on the granular control to embed a full piece of content (video node?) and a previews of pieces of content (products related to the video?).

If we just wanted to leave the syntax alone, we could create a new field (tab?) on the content that searched for embeds, and allowed you to specify their mode separately. But, there's disadvantages to that.
- It would be much harder to import
- The separation might confuse users
- It's an extra step
- This is an input filter, not a node filter. Why limit the extra options to just nodes/entities?

I'll keep thinking.

sreynen’s picture

A few possible approaches I've considered on this:

1) Just make the view mode another parameter with special functionality. This is essentially what you did, and it's certainly a simple solution. My only concern here is it mixes what parameters do. Most parameters do nothing unless you act on them in the theme layer. This parameter would do things automatically, which might be confusing or a gateway to a lot of requests for pre-defined parameters. Or maybe not.

2) Make the view mode a different type of parameter, with a different syntax. This would make a clear distinction, but has many of the same problems in #1, and would make the syntax more complicated.

3) Make individual embeds field-able entities and make a view mode reference field. This would provide an interface for setting all types of parameters beyond just text, but it feels like over-engineering.

4) Select view modes for embedded nodes as part of the node edit form somewhere. This seems likely to be too detached from the process of embedding.

I'm currently leaning toward #1, but would like to give it some more time.

lance.gliser’s picture

Thinking about number one, I'm not sure it's going to lead to indefinite scope creep of parameters, and it should not be too hard to understand. Look back at my original expanded embed syntax explanation code. I outline every possible node_view type active in the system, so it should be immediately relevant.

My entire reason for swapping view modes, was to remove loads of work from the theme layer, into the configuration layers. The majority of answers to feature requests would be create a node view type (using the other module I suggested), and set it up the way you want. Side bonus, the additional node_views can be handled by modules, since it's not waiting until the theme layer fires.

Other than the common (and embed specific) alignment attributes, can anyone think of something that would not be more eloquently by the embed specific settings?
Things that might be requested of the top of my head:
- Classes: Targetable classes based on node_view are available, maybe an extra class for a specific embed. (Embed: blue, vs embed green)? Seems like a theme specific issue.
- "Links" for node. Handled by view types?

It seems like we need an inventory of what other people have used parameters for?

lance.gliser’s picture

A pretty fair chunk of time has passed since this was opened back on March 10th, and no one seems to be chiming in.

I'm about to have a project go live, and need to document how they should format things to embed one view of a node vs another. Can we perhaps come to an agreement about this by merging parts of my previous with the project? I still think the nid, mode, and alignment will cover 90% of most users needs, and the rest falling to the theme layer does make a lot of sense.

sreynen’s picture

Status: Active » Fixed

Yep, apparently no one cares how this works. :)

I just committed an implementation of #1 with a parameter named "view_mode" to switch the view mode.

lance.gliser’s picture

Covers 80% of my needs! Happy to see it going into the module.

I may open up another issue later on, to help you get the code from my original issue that displays all possible view_modes on the site for end users to figure things out a bit more easily.

I'll see if I can figure out how to have the theme layer react to the embed parameter's so I can still have an 'align' parameter for my site's authors in the next week. If you have preexisting code for it, I'd love to see it. If not, maybe it's a strong example that we should get in the docs once I figure it out.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

couloir007’s picture

Issue summary: View changes

Was this ever implemented? If so, what is the syntax?

For now I'm doing this:

[[nid:2:test_article]]
[[nid:2:node_embed]]
function node_embed_filter_node_embed_process($text, $filter, $format, $langcode, $cache, $cache_id) {

//   return preg_replace_callback('/\[\[nid:(\d+)(\s.*)?\]\]/', '_node_make_replacements', $text);
	return preg_replace_callback('/\[\[nid:(\d+)\:(.*?)\]\]/', '_node_make_replacements', $text);

} // node_embed_filter_node_embed_process

function _node_make_replacements($matches) {
//...
    if (!isset($node->node_embed_parameters['view_mode'])) {
//       $node->node_embed_parameters['view_mode'] = 'node_embed';
    	$node->node_embed_parameters['view_mode'] = $matches[2];
    } // if
//...
}

couloir007’s picture

I updated to this:

	if (preg_match('/\[\[nid:(\d+)\]\]/', $text)) {
		$text = preg_replace('/\[\[nid:(\d+)\]\]/', '[[nid:$1:node_embed]]', $text);
	}

	return preg_replace_callback('/\[\[nid:(\d+)\:(.*?)\]\]/', '_node_make_replacements', $text);
sreynen’s picture

Yes, this was implemented. The syntax is [[nid:12345 mode=teaser]]

thomjjames’s picture

Hi,

Using this module now found the following worked for setting the view_mode:

[[nid:NID view_mode=VIEW_MODE]]

ie. [[nid:123 view_mode=teaser]]

Hopefully that's useful to someone else
Tom