Active
Project:
Reference Preview
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Jun 2012 at 11:44 UTC
Updated:
14 Jun 2012 at 15:39 UTC
hey all,
I wanted to have a dedicated template for the output of a reference preview. So I add a preprocess_node hook in the module, to load a new template for my content type, only in the specific case of outputing a preview. It works fine so far.
Just add this function on top of the reference_preview.module file:
function reference_preview_preprocess_node(&$vars){
// Test if we are on a ahah page
$is_ahah_page=strstr(request_uri(), 'reference_preview_ahah');
// Add a template_files only for ahah page
if($is_ahah_page){
$vars['template_files'][] = "node-".$vars['type'].'_reference-preview';
}
}
Then one has to create in the folder
/path_to_your_theme/templates/node/
the file
node-yourcontenttypename_reference-preview.tpl.php
and the preview is displayed according to this tempalte file.
What do you think about it ?
For me it works fine. I think it could be a nice feature for the module.
Liaz.
Comments
Comment #1
hefox commentedGood idea
Looking at the repo, it looks like $node->reference_preview_field_settings is defined with the settings, so I'd be totally cool with a patch that adds template suggestions like:
Provide a patch (follow coding standards, see d.o page on how to create patches, etc.), and I'll review it :).
Comment #2
Liaz commentedGreat !
I will do that in a week.
Should I add also the changes I talked about there : http://drupal.org/node/1629992 ?
Comment #3
Liaz commentedAnother nice feature I was thinking about would be to possibly to customize where you want to display the preview regarding the nodereference field. Now it is after, but I figured out that in the .js it is just a small change to do
instead of
I found how to display this option in the .module
But I don't know how to use it in the .js then.
If you could give me an advice I could try to add this feature also in the patch.
Comment #4
hefox commentedAny patches/issues I'll consider, however one issue per feature/bug report please, and patches should just include the chance for that issue.
Additional configuration for placement sounds fine.