Main menu


01 Aug

Drupal IF in a role, but not other roles

Published by Mark W. Breneman

$roles =content_access_get_per_node_settings($node);
if (in_array(4,$roles['view']) and !in_array(1,$roles['view']) and !in_array(2,$roles['view'])){return true;}

30 Jul

fix An HTTP error 0 occurred when autocomplete is interrupted by form submit

Published by Mark W. Breneman

Or at least make the error not pop up a javascript alert.

autocomplete.js pipes all errors to a javascript alerts even simple ajax did not complete, because YOU hit the button too quickly messages. In my case, I did not want a user to see the error message just because they clicked the search button before the auto suggest did its thing. So after a bit of research via google and a tip a coworker gave me, I found that a simple tweak to the autocomplete.js to redirect the alerts to the firebug console was a good solution.

around line 284 in /misc/autocomplete.js (Drupal 6)

20 Jun

Sometimes Drupal Complex array filled Objects just kill me

Published by Mark W. Breneman

dpm($contexts); Returns this: "url" is string and is the first item in the array"field_connect_facebook", that is contained in a object "data", that is contained in an object "argument_nid_1", that is contained in an array "context" So to get the URL you use: $contexts[argument_nid_1]->data->field_connect_facebook[0][url]

12 Jun

Drupal computed field recalculate with taxonomy

Published by Mark W. Breneman

Ok, I just fought an issue for a while where I used a computed field to append a taxonomy list to the title. All worked fine, when the node was saved the computed field populated correctly. But, now I have lots of nodes that need to be updated. I did not want to do them one by one. So View Bulk Operations to the rescue, or so I thought. Turns out VBO seems to not do a full node_load, so it does not load the taxonomy into the $node object. (I bet there is a way to do that if I spent enough time).

02 May

Show if content has Content Access set for a role but not other roles

Published by Mark W. Breneman

Yeah, this is a rather interesting snippet that has value to me, but does not seem like it would have value to others. Perhaps if a context trigger was based on this code.

The basic idea here is to check if staff role is the only role that has access to this content, if so do something.

$roles =content_access_per_node_setting('view',$object);
if (in_array(4,$roles) and !in_array(19,$roles)){echo 'staff only';}

26 Apr

set CCK default value from query (Multi-Value)

Published by Mark W. Breneman

Just in case you may need to populate a CCK field from a db query OR more to the point, next time I have to:

global $user;
$qdata= 'db_query(SELECT field_school_studyareas_value
where nid in (select nid from node WHERE node.type in ("exhibitor_profile") and uid ='.$user->uid.')) ' ;

while ($row=db_fetch_array($qdata))
$var[]=array('value' =>$row['field_school_studyareas_value']);
return $var;

Yes a join would have been far better. I'll fix that soon.

26 Apr

Mobile website Resources

Published by Mark W. Breneman

Over the next few weeks or more likely months, I'm digging in deep to learn more about building good mobile sites. A lot has transpired in the mobile world while I have been working heads-down the desktop web world.

I am blowen away with responsive design and how it can bridge the desktop and mobile world.

The Drupal Omega Theme is very impressive right out of the box. It is going to take me a while to work through all of the options and

One thing that I have not seen in many responsive designs is good mobile menu support.

29 Mar

Drupal group by any field - Remove Druplicates

Published by Mark W. Breneman

I had a view that repeated a value several times even though I clicked the Distinct: Yes and was sill getting repeated values. In the SQL I found that the Distinct setting just adds group by nid. Since I was trying to get distinct values for another field, grouping by nid did nothing for me.

I found a few resources that pointed to views_pre_execute and found that to be a really really handy fix.

03 Nov

Dynamic Field - Good or Bad?

Published by Mark W. Breneman

My mind is reeling over the possibilities of this module. ... err ah.. my mind is really reeling over the abuses this modules could enable me to do. Wow... mind explodes.

Dynamic Field is a CCK field that returns a textarea where you can enter custom PHP code.

So, this enabled you to really neat hacks via PHP like, if this field is X then do Y. ON the flip side, you could embed a view into a field OR run a SQL Query.