Popup reference runs before cck (no weight) and looses node type in feildsets

millenniumtree - June 4, 2009 - 15:28
Project:Popups: Add and Reference
Version:6.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

The Add popup link will NOT show up for my node reference. It USED TO WORK, but has since stopped altogether.

User is primary admin (uid==1)

Contents of node reference dropdown are populated by a view (tested without the view with same result - I get the node reference dropdown but no popup link below it)
Config option IS checked on /admin/content/node-type/CONTENT_TYPE/fields/field_FIELD_NAME

On the /popups/test page, all the popup links work fine and the JS files are being included in that page, but NO popup JS files are being included on the /node/add/CONTENT_TYPE page.

What else could be going on here?

#1

millenniumtree - June 4, 2009 - 15:29
Priority:critical» normal

#2

millenniumtree - June 4, 2009 - 17:21

In this function:
popups_reference_form_alter(&$form, $form_state, $form_id)

It appears that the node reference fields DO NOT APPEAR in the $form object.
So obviously it can't add the link to the fields that aren't in the $form.

But then, the question remains is why am I seeing the fields, if they're not in the $form object?
Something wrong with the node_reference module?

Upon further investigation - it's something wrong with my THEME
I switched to the Zen Classic theme (from my custom Zen theme) and the links are back.

I'll update this again when I find out what exactly in my theme killed the links.

#3

millenniumtree - June 4, 2009 - 21:01

Alright, I fixed it.
I still don't know _exactly_ what caused the problem, but what fixed it was to create a new Zen STARTERKIT theme and copy the files from my original theme into the new theme.

RENAMING the theme may also work, though I'm not sure of this.

#4

hefox - July 27, 2009 - 01:19

what were the weights on cck, nodereference, and popups_reference?

If the node reference wasn't in the form object it's could be due to cck not running it's form alter yet.

#5

funkeyrandy - August 1, 2009 - 00:09

anybody figure this one out...i have tried across all my stock themes (garland, etc) with a stock drupal 6 install and same problem persists...should work out of the box no?

#6

hefox - August 3, 2009 - 00:01

Might be useful to run this query and post the contents here

SELECT name, weight from system where name = "content" or name like "popups_%" or name like "nodereference%"

BTW popup will not show up for custom widgets like node reference from url

My guess it's a module weight issue

UPDATE system set weight =5 where name = "popups_reference" ;

#7

funkeyrandy - August 3, 2009 - 22:32

THanks!!!!!

it shows up now, but it is ignoring unselected content types, and showing an add link for ALL my content types...any ideas?

thanks!

#8

hefox - August 4, 2009 - 00:45
Title:No add popup links for node reference field» Popup reference runs before cck (no weight) and looses node type in feildsets

This should be split into two issues, and no idea if they'

1st) Popups reference does not have an install file and runs before CCK (above problem)
(btw, you enabled popups reference before cck perhaps? o.O)

and new one, from what I can guess

2) Node references inside field set (probably) loose node type so may produce incorrect field information

Not expierencing this issue so I'm not going to test this but here's something that may be contributing to the problem

however inside here in alter item the

<?php
 
function popups_reference_alter_item(&$form, $key, $item, $fields) {
 
$field_name = strstr($key, 'field_'); // Check if $key starts with 'field_';
 
if (isset($fields[$field_name]) &&
     
$fields[$field_name]['type'] == 'nodereference' &&
     
variable_get('popups_reference_show_add_link_'. $field_name, TRUE)) {
   
$type = $form['type']['#value'];
       
$field = content_fields($field_name, $type);
?>

the
<?php
    $type
= $form['type']['#value'];
?>

is problamic cause

<?php
       
if ($type == 'fieldset') { // Loop through all the subitems.
         
foreach ($form[$key] as $subkey => $subitem) {
           
popups_reference_alter_item($form[$key], $subkey, $subitem, $fields);
           }
         }

        else {
         
popups_reference_alter_item($form, $key, $item, $fields);
        }
?>

$form is not always the entire form inside of alter, so fieldsets will not have the $form['type'] value to my thinking. So the content_fields call gets default information for the field instead of field, content type information

The person having the issue try changing the alter the code to this
(I've copied around the changed areas, so match the top and bottom to what's there )

<?php
function popups_reference_alter_item(&$form, $key, $item, $fields, $type) {
 
$field_name = strstr($key, 'field_'); // Check if $key starts with 'field_';
 
if (isset($fields[$field_name]) &&
     
$fields[$field_name]['type'] == 'nodereference' &&
     
variable_get('popups_reference_show_add_link_'. $field_name, TRUE)) {
       
$field = content_fields($field_name, $type);
      if (!
$type) {
                
$type =   $form[$field_name][0]['#type_name'];

        }
?>

<?php
       
if ($type == 'fieldset') { // Loop through all the subitems.
         
foreach ($form[$key] as $subkey => $subitem) {
           
popups_reference_alter_item($form[$key], $subkey, $subitem, $fields, $form['type']['#value']);
           }
         }

        else {
         
popups_reference_alter_item($form, $key, $item, $fields,$form['type']['#value']);
        }
?>

Or I attached the .module file, rename your current popups_reference.module to some temporary name, try that one (rename to .module) and see if it's help

There still is likely some other issue though, since I believe content types are on the per field, not per field per content type level.. but might help.

AttachmentSize
popups_reference.txt 6.36 KB

#9

hefox - August 4, 2009 - 00:49

oh sh**t, I just remembered my popups reference has some other patches applied so don't use that file! just copy and paste the file. Checked with the current lasted (the march) release and they're not effected by the patches I've applied

#10

funkeyrandy - August 4, 2009 - 03:56

actually its working now...no idea why..could have been a cache issue..thanks for your help on the weights thing!!! actually, no i enabled cck before..fyi

r

 
 

Drupal is a registered trademark of Dries Buytaert.