DrupalBin
Submit Code
About
Recent Posts
message i get when running openssl s_client -connect 150.203.86.21:443
Fix for Code
Code
add_to_cart_by_sku_contents()
Fix for page.tpl.php
Page.tpl
foreach is beeing disregarded dispite variable is array. Please help. Outside Drupal it works as standalone.php file
foreach is beeing disregarded dispite variable is array inside drupal. Please help. Outside Drupal it works as standalone.php
Fix for filefield implementation in an admin page. "An HTTP error 0 occurred. /drupal/?q=filefield/ahah///"
PHP Code custom.module
more
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Log in using OpenID
Cancel OpenID login
Create new account
Request new password
Tags
CCK
drupal
fapi
jquery
menu
module
php
simpletest
taxonomy
test
theme
views
more tags
Home
›
Dave Reid
›
Recent Posts
Dave Reid
View
Posts
Code
December 22, 2011 - 5:31pm —
Dave Reid
// Find all nodes that have an entity reference field value of user #5.
$query
=
new
EntityFieldQuery
(
)
;
$query
-
>
entityCondition
(
'entity_type'
,
'node'
)
;
$query
-
>
propertyCondition
(
'status'
, 1
)
;
$
Read more
Code
September 6, 2011 - 10:56am —
Dave Reid
/**
* The point of this code is so that I can make an array of objects and can easily output a string representation of each object but retain the full data.
*
* For example:
* $terms = taxono
token
Read more
Code
July 9, 2011 - 5:44pm —
Dave Reid
/**
* Implements hook_node_view_alter().
*/
function
custom_node_view_alter
(
&
$build
)
{
$node
=
$build
[
'#node'
]
;
if
(
$node
-
>
type
==
'event'
&&
(
$data
= _custom_event_view_node_get_data
(
)
)
&&
Read more
Code
April 20, 2011 - 8:11pm —
Dave Reid
/**
* Form builder to add or edit an URL redirect.
*
* @see redirect_element_validate_source()
* @see redirect_element_validate_redirect()
* @see redirect_edit_form_validate()
* @see redir
Read more
Fix for Code
March 5, 2011 - 4:13pm —
Dave Reid
function
mymodule_page_build
(
&
$page
)
{
if
(
!
isset
(
$page
[
'content'
]
[
'system_main'
]
[
'actions'
]
)
)
{
$page
[
'content'
]
[
'system_main'
]
[
'actions'
]
=
array
(
'#theme'
=
>
'links'
,
'#links'
Read more
Code
March 5, 2011 - 4:11pm —
Dave Reid
$page
[
'content'
]
[
'system_main'
]
[
'actions'
]
=
array
(
'#theme'
=
>
'links'
,
'#links'
=
>
$actions
,
'#attributes'
=
>
array
(
'class'
=
>
array
(
'action-links'
)
)
,
'#weight'
=
>
-
1
Read more
Code
February 21, 2011 - 8:43pm —
Dave Reid
// settings.php:
<?php
...
$databases
[
'default'
]
[
'default'
]
=
array
(
'driver'
=
>
'mysql'
,
'database'
=
>
'databasename'
,
'username'
=
>
'username'
,
'password'
=
>
'password'
,
'host'
=
Read more
Fix for Fix for Code
February 14, 2011 - 4:00pm —
Dave Reid
if
(
isset
(
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
)
)
{
if
(
$nids
=
element_children
(
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
)
)
{
$first_nid
=
reset
(
$nids
)
;
Read more
Fix for Code
February 14, 2011 - 3:54pm —
Dave Reid
template_preprocess_page
(
&
$variables
)
{
if
(
!
empty
(
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
)
)
{
$first_node
=
reset
(
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
)
;
$f
Read more
Code
February 14, 2011 - 1:04pm —
Dave Reid
template_preprocess_page
(
&
$variables
)
{
foreach
(
array_keys
(
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
)
as
$nid
)
{
$variables
[
'page'
]
[
'content'
]
[
'system_main'
]
[
'nodes'
]
[
$nid
]
[
'#node
Read more
Supporting bundles for taxonomy terms in EntityFieldQuery
February 7, 2011 - 5:13pm —
Dave Reid
function
mymodule_taxonomy_entity_query_alter
(
$query
)
{
$conditions
=
&
$query
-
>
entityConditions
;
// Alter taxonomy term queries only.
if
(
isset
(
$conditions
[
'entity_type'
]
)
&&
$conditions
[
'e
Read more
Fix for Code
January 24, 2011 - 10:48pm —
Dave Reid
$node
-
>
nid
=
NULL
;
// or '0' or some value here to account for new nodes.
_pathauto_include
(
)
;
$placeholders
= pathauto_get_placeholders
(
'node'
,
$node
)
;
$pathauto_alias
= pathauto_create_alias
(
'nod
Read more
Code
January 24, 2011 - 10:47pm —
Dave Reid
$node
-
>
nid
=
NULL
;
// or '0' or some value here to account for new nodes.
module_load_include
(
'inc'
,
'pathauto'
)
;
$pathauto_alias
= pathauto_create_alias
(
'node'
,
'return'
,
"node/{$node->nid}"
,
array
Read more
Code
January 14, 2011 - 1:08pm —
Dave Reid
$field1_instance
= field_info_instance
(
'user'
,
'field_fieldname1'
,
'user'
)
;
if
(
$field1_items
= field_get_items
(
'user'
,
$account
,
'field_fieldname1'
)
)
{
$text
= _text_sanitize
(
'user'
, LANGUAGE_NON
Read more
entity_access
January 14, 2011 - 1:36am —
Dave Reid
function
entity_access
(
$entity_type
,
$entity
,
$op
,
$account
=
NULL
)
{
$rights
=
&
drupal_static
(
__FUNCTION__
,
array
(
)
)
;
if
(
empty
(
$entity
)
||
!
in_array
(
$op
,
array
(
'view'
,
'update'
,
'delete'
,
'c
Read more
entity meta tag description field
January 13, 2011 - 12:44am —
Dave Reid
function
custom_entity_view
(
$entity
,
$type
,
$view_mode
,
$langcode
)
{
if
(
$view_mode
==
'full'
&&
$items
= field_get_items
(
$type
,
$entity
,
'field_meta_description'
,
$langcode
)
)
{
$description_t
Read more
node meta tag description field
January 13, 2011 - 12:41am —
Dave Reid
function
custom_node_view
(
$node
,
$view_mode
,
$langcode
)
{
if
(
node_is_page
(
$node
)
&&
$items
= field_get_items
(
'node'
,
$node
,
'field_meta_description'
)
)
{
$description_tag
=
array
(
'#typ
Read more
git-pull-all.sh
January 12, 2011 - 2:10am —
Dave Reid
#!/bin/sh
SCRIPT_DIR=`pwd`
for dir in $(find . -type d -name .git)
do
cd "$SCRIPT_DIR/$dir/.."
echo "git pull `pwd`"
git pull
done
Code
January 6, 2011 - 6:40pm —
Dave Reid
function
_token_field_attach_view
(
$entity_type
,
$entity
,
$field_name
,
$index
=
NULL
,
array
$options
=
array
(
)
)
{
$view_mode
=
'token'
;
list
(
$id
,
$vid
,
$bundle
)
= entity_extract_ids
(
$entity_type
,
Read more
Code
December 15, 2010 - 1:41pm —
Dave Reid
class
sshkey_handler_field_sshkey_link_edit
extends
views_handler_field
{
function
construct
(
)
{
parent::
construct
(
)
;
$this
-
>
additional_fields
[
'key_id'
]
=
'key_id'
;
}
function
opt
Read more
1
2
next ›
last »