This website is composed of information connected through taxonomy. It is simultaneously a proof-of-concept and a means to allow Agaric to share and store information both within the collective and the world as part of our open documentation philosophy.

User login

This website is composed of information connected through taxonomy. It is simultaneously a proof-of-concept and a means to allow Agaric to share and store information both within the collective and the world as part of our open documentation philosophy.

Delete text between and including identifying strings

Internet answered this question for Agaric, and we'll make it easier for the next person to find the answer!

remove HTML within markers
regexp strip all between two snippets
regexp delete between two keywords
php delete between strings

There's a great, informative post – just in response to a question on a forum – on how to do it with a regular expression here:

Internet answered this question for Agaric, and we'll make it easier for the next person to find the answer!

remove HTML within markers
regexp strip all between two snippets
regexp delete between two keywords
php delete between strings

There's a great, informative post – just in response to a question on a forum – on how to do it with a regular expression here:

http://www.programmingtalk.com/showthread.php?threadid=39966

With this answer:

$string = preg_replace( '/\<body\>.*\<table/Usi', '<body><table', $string ); 

Our modification (main difference, not re-adding the search strings) worked quite nicely to remove unwanted text hardcoded into another Drupal module, the otherwise wonderful Video module in 4.7:

Scale a square's dimensions with PHP

Or determine and apply any ratio.

Agaric needed this for a Drupal module, but this is general PHP that should work for anything.

php scaling function length height
calculate a ratio

Below, Agaric's function for scaling two dimensions maintaining their aspect ratio given a limit for one or both dimensions (or a percentage, but in retrospect it is very silly to wrap multiplication in a function).

Or determine and apply any ratio.

Agaric needed this for a Drupal module, but this is general PHP that should work for anything.

php scaling function length height
calculate a ratio

Below, Agaric's function for scaling two dimensions maintaining their aspect ratio given a limit for one or both dimensions (or a percentage, but in retrospect it is very silly to wrap multiplication in a function).


/**
* Scales two dimensions based on one or two limits or a percentage value.
*
* THIS FUNCTION TAKES VARIABLES BY REFERENCE
* It does not return anything you'll find useful.

Freelance or Small Business, what about Cooperative?

The Web Design Business Kit, by Brendon Sinclair, provides good advice, at least in the free sample chapters.

It does however, set up an absolute two-choice approach: freelancing, or owning a small business.

Not a token nod to a collective, co-operative form of organization? Equality, liberty, fraternity? And this from an Sinclair, who appears to take the view that work-or-starve is its own sort of slave labor in the introduction summary:

Find the next largest key in an array

php find the next largest key in an array
php find the next greatest key in an array

There is undoubtedly a better way, but recursion has melted my brain and search engines aren't saving me.

So this is what I did... actually, I used another approach entirely that didn't need this. But array_keys is how I would have started, then sorted it, and then had a foreach that compared my key to the keys it got as it walked through, and broken out of there with the new key the first one that was larger.

php find the next largest key in an array
php find the next greatest key in an array

There is undoubtedly a better way, but recursion has melted my brain and search engines aren't saving me.

So this is what I did... actually, I used another approach entirely that didn't need this. But array_keys is how I would have started, then sorted it, and then had a foreach that compared my key to the keys it got as it walked through, and broken out of there with the new key the first one that was larger.

    $terms_on_this_level = array_keys($parents);

I know there would have been a better way, but it's moot to me know anyway... until I search for this answer again and find my own, deeply unfulfilling, page.

Freelinking not working? Check WikiTools settings.

There's a setting in wikitools that literally says hijack freelinking . It has to be unchecked.

Dan figured this out.

Agaric Design... figuring stuff out little by little.

There's a setting in wikitools that literally says hijack freelinking . It has to be unchecked.

Dan figured this out.

Agaric Design... figuring stuff out little by little.

Form at a tab in administration section, Drupal 5

The shortcut:

In implementation of hook_menu, may_cache section...

The shortcut:

In implementation of hook_menu, may_cache section...


function cmt_menu($may_cache) {
$items = array();
if ($may_cache) {
//...
$items[] = array(
'access' => user_access('administer community managed taxonomy'),
'callback' => 'drupal_get_form',
'callback arguments' => array('cmt_settings_form'),
'description' => t('Configure Community-managed Taxonomy options that apply to all vocabularies with these settings.'),
'path' => 'admin/content/cmt/settings',
'title' => t('Settings'),

Delete from Drupal variable table where name LIKE

delete from variable where LIKE drupal

There are occasions when the usual approach:
variable_del('cmt_example_variable');
won't work.

This is not recommended as a shortcut, and in fact even here is problematic should there ever be a module called cmt_teaser_

delete from variable where LIKE drupal

There are occasions when the usual approach:
variable_del('cmt_example_variable');
won't work.

This is not recommended as a shortcut, and in fact even here is problematic should there ever be a module called cmt_teaser_

/**
* Implementation of hook_uninstall().
*/
function cmt_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'cmt_teaser_%'");
  cache_clear_all('variables', 'cache');
}

So this is bad practice, but I don't see

I'm not going to keep track of all the node types that ever were available to Community-Managed Taxonomy and might have had this variable created. I suppose I could just delete the variables for node types currently available to CMT and possibly leave a few variables, is better than the even slighter risk of deleting another modules variables?

Unadorned FALSE or TRUE not working in FAPI?

This is a Drupal 5 question. Why doesn't this work?

This is a Drupal 5 question. Why doesn't this work?

    $form_add['cmt_teaser'] = array(
      '#type' => 'radios',
      '#title' => 'Community-managed taxonomy display',
      '#options' => array(
        TRUE => t('Show term managing form on teasers and full content.'),
        FALSE => t('Show term managing form on full content'),
      ),
      '#default_value' => variable_get('cmt_teaser_' . $type . '_teaser', FALSE),
      '#description' => t('CMT forms can become large and complex, so displaying them on the teaser is usually not recommended.'),
    );

But this does:

Placing your changes to a form using hook form_alter

drupal form_alter placing in a form
Drupal 5

CivicActions has a useful
Drupal Programming Trick - Add an element before/after another element in form_alter.

drupal form_alter placing in a form
Drupal 5

CivicActions has a useful
Drupal Programming Trick - Add an element before/after another element in form_alter.

Display everything about a form in Drupal 5

To display everything about every form, Agaric uses this in a form_alter hook implementation:

drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');

In fact, we wrap it in our own function, which we have in our development module, agaric:

To display everything about every form, Agaric uses this in a form_alter hook implementation:

drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');

In fact, we wrap it in our own function, which we have in our development module, agaric:

function agaric_f($form_id, $form) {
  drupal_set_message('<p>Form ID: ' . $form_id . '</p><pre>' . print_r($form, TRUE) . '</pre>');
}

This is a more... complete... overwhelming... version of the line Agaric suggested for displaying the form ID of all forms.