after this title, I'll explain myself, imagine this case:
"you compose one node for viewing, and, as part of this node you put another one (via views, editing the node-XXX.tpl.php, etc), you'll get that the second one gets the "link parameters configuration" from the main one" -> mistake!!!
my concrete case: I'm using content_profile for configure complex profiles for users, and I want to print, below nodes, info of the profile... the node_type "profile" is configured to not show print or send to a friend links, buts mixes configuration from the main one
bug and correction:
in the three modules, there is code for check if the link must be enabled or not:
function print_link_allowed($args) {
...
if (!empty($args['node'])) {
// static $node_type = FALSE;
// $node = $args['node'];
// if ($node_type === FALSE) {
// if (isset($node->type)) {
// $node_type = $node->type;
// }
// else {
// $node_type = '';
// }
// }
$node_type = (isset($node->type)?$node->type:'');
you have the commented current version that saves in a static variable the node_type (even if you call it 1000 times), and my correction that gets the value each time
i recommend this for correction providing for me is a bug, and sure there will be more cases it'll fail
let me know if this was useful just to feel a bit prouder :P
Hwangar
Spain
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | print_nodetype.patch | 572 bytes | jcnventura |
Comments
Comment #1
jcnventuraThat patch can't be right...
You're commenting out the $node var assignment, but later on you see if it is set?!
Can you provide the steps and simple node-XXX.tpl.php so that I can try to reproduce this?? The print_link_allowed does a lot of stuff that I would prefer could be done only once per page (that's why the static is there).
João
Comment #2
Hwangar commentedSorry!! you were fast!
I have just realised this is the code:
I was too enthusiastic with commenting... and as the link disappeared I thought the job was done... :P
Tell me if it works
PD I have no problem to give you an extract of my template:
node-mytype.tpl.php
as you can see below the node I print my user profile, and part of it is a "content_profile node" that is rendered too, my configuration is set in that way I want print and mailto links for the main node but NOT for the profile node, and inside my profile were rendered with the node view process... with this correction all seems right
note: as I have read in the code it's the same in the three modules
by the way... thank you for your great effort, I hope this help you with this great module, keep your good work, mate!
greetings
Hwangar
Spain
Comment #3
Hwangar commentedComment #4
jcnventuraHi,
The correct code is the following:
The static needs to be there in order to correctly identify the node type during the node's comments links rendering (since comments are not nodes, they don't have a node type).
However, comparing it to FALSE was completely useless, so I removed that part. Please try this and let me know how it worked for you.
João
Comment #5
jcnventuraI have committed the code anyway, as it seems harmless.
Comment #6
Hwangar commentedI'm glad it had helped...
thx for your great work, man!