DrupalBin
Submit Code
About
Recent Posts
css path
1 hour 22 min
ago
Fix for Code
5 hours 22 min
ago
Fix for Code
5 hours 28 min
ago
Fix for Code
5 hours 36 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for Code
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
function imagefield_gallery_nodetypes() { $types = content_types(); $i = 0; $nt = array(); foreach ($types as $type) { foreach ($type['fields'] as $field) { if ($field['type'] == 'image') { $nt[$i]['type'] = $type['type']; $nt[$i]['name'] = $field['field_name']; } /* ok, so the above code works beautifully, however there's a need to handle multiple fields of the same type, on a single node type, as well as a need to work with node references (below). However, the node references essentially make the need to work with multiple fields mandatory. The code below is my first crack at this piece by piece, the comments should make the rest of it obvious */ if ($field['type'] == 'nodereference') { foreach ($field['referenceable_types'] as $name => $active) { if($active && $types[$active]['fields']){ /* check active content types for an imagefield. If one doesn't exist, this node reference is uneligable for an imagefield gallery */ foreach ($types[$active]['fields'] as $field2) { if ($field2['type'] == 'image') { /* herein lies a few problems. I need to grab the node types and their imagefield based on what types the node reference will work with. easy enough since all of that is contained inside of $types right now, however I'm adding all of this to the $nt array, and at the end of the day I'll still need the typ and name as illustrated earlier in the code. This should be added at the end of these for each loops, but I'm unsure how to do it w/o adding it to the array, when the node reference isn't eligible. logically following my ifs and foreaches here, it still gets added since I need to foreach through all the fields (one of the main reason I didn't want to tackle this problem. */ } } } } // $nt[$i]['type'] = $type['type']; // $nt[$i]['name'] = $field['field_name']; // $nt[$i]['reftype'] = $field['referenceable_types']; } #end new stuff $i++; } } return $nt; }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.