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.

Representing all hierarchies as sets of linear progressions for a given point in a complex hierarchy- a C programmer's answer

[The answer is most likely here, if I could understand it.]

[The answer is most likely here, if I could understand it.]

TwinStar01: Mornin'
I3IVIIVI: mornin... programming question, been working 24/7, 3 hours left to get code in...
I3IVIIVI: OK, so it's something really basic, and it's taken up a critical 8 or so hours... my brain keeps folding back on itself.
[10:35am] agaric: How do I create an array of all possible hierarchies for a term?
[10:37am] agaric: term A can have n parents, each of which can have n parents, etc. I keep messing with recursion and counting loops and while loops and make a mess out of all of them
TwinStar01: have each term have a linked list (double if you want) where each element is a reference to one of its parents.

Determining all possible parent paths for an arbitrary-depth one-to-many categorization structure

Wherein Ben discovers he doesn't know computer programming at all.

Wherein Ben discovers he doesn't know computer programming at all.

The community-managed taxonomy module needs to know all possible parent paths for an arbitrary-depth categorization structure. Even though taxonomy terms have a many-to-many relationship, when tracing back from one term to its parent(s), and that parent's parent(s), and so on to root level, it's one-to-many from that perspective. Barring illegal loops, there must be a finite number of possible ancestor paths, but all my attempts to walk through them have not quite resulted in predictable, correct results

Basically I want to display every possible one-to-one lineage for an item with ancestors.

Block CSS ID for custom module blocks in Drupal 4.7

drupal 4.7 block id

the ID for that block -- as provided to the theme in a line like this:

<div class="block block-coamod" id="block-coamod-1">

Can be set in a custom module, replacing the delta numbers with whatever text string you want.

Set in the block info part of the hook I think and used in the switch statement deciding what to display.

drupal 4.7 block id

the ID for that block -- as provided to the theme in a line like this:

<div class="block block-coamod" id="block-coamod-1">

Can be set in a custom module, replacing the delta numbers with whatever text string you want.

Set in the block info part of the hook I think and used in the switch statement deciding what to display.

Thoughts at the close of code

Y'all might want to wait for the director's cut of this module...

Yeah, I'm going to try to make CMT really good. It already (pretty much) allows for on-the-fly hierarchical tagging, which is pretty cool. For a number of trusted volunteers, though, you could clean things up with SoC Matthias Hutterer's Taxonomy Manager.

Y'all might want to wait for the director's cut of this module...

Yeah, I'm going to try to make CMT really good. It already (pretty much) allows for on-the-fly hierarchical tagging, which is pretty cool. For a number of trusted volunteers, though, you could clean things up with SoC Matthias Hutterer's Taxonomy Manager.

Still unresolved philosophical/logical issues with the module
I3IVIIVI: you can vote on a terms association with content (node)
I3IVIIVI: you can vote on a name for the term
I3IVIIVI: you can vote on the term's placement in a hierarchy
I3IVIIVI: all independently
I3IVIIVI: So how do we make a term, when only one aspect of its term-ness comes up first?

Always check for "if ($foo = 'bar')" mistakes... red flag, needs ==

Always look for malformed equality statements, that assign rather than compare, when things are going weird. Earlier rather than later. That's the whole lesson for today.

So why is the select statement, that's supposed to prevent this mess below, not working?

SELECT content_id FROM {cmt_term_node} WHERE nid=%d AND tid=%d

Debugging looks all good:

* term Another versus Another
* SELECT content_id FROM {cmt_term_name} WHERE tid=%d AND name='%s'
* Result: Resource id #91
*

Always look for malformed equality statements, that assign rather than compare, when things are going weird. Earlier rather than later. That's the whole lesson for today.

auto_increment columns cannot have a default value

Makes sense I guess...

So this is good:
tid int(10) unsigned NOT NULL auto_increment,

Just make sure you don't have "default '0'" anywhere in there.

You don't want to see this on your site:

Makes sense I guess...

So this is good:
tid int(10) unsigned NOT NULL auto_increment,

Just make sure you don't have "default '0'" anywhere in there.

You don't want to see this on your site:

user warning: Invalid default value for 'tid' query: cmt_install CREATE TABLE joe_cmt_term_data ( tid int(10) unsigned NOT NULL DEFAULT '0' auto_increment, name varchar(255) NOT NULL DEFAULT '', weight tinyint NOT NULL DEFAULT '0' ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /Applications/MAMP/htdocs/joeaustin/includes/database.mysql.inc on line 172.

Regular expressions: great when they work!

Wow, it's great when regular expressions work (even if you're fumbling in the dark with them...)

Traversing through an angle-bracket delimited term set (term hierarchy path).

Input:

this > is > a > term > list

Code:

    $regexp = '%(?:^|>\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^">]*))%x';
    preg_match_all($regexp, $typed_termset, $term_matches);
    $typed_terms = array_unique($term_matches[1]);

Wow, it's great when regular expressions work (even if you're fumbling in the dark with them...)

Traversing through an angle-bracket delimited term set (term hierarchy path).

Input:

this > is > a > term > list

Code:

    $regexp = '%(?:^|>\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^">]*))%x';
    preg_match_all($regexp, $typed_termset, $term_matches);
    $typed_terms = array_unique($term_matches[1]);

Result:

Array
(
    [0] => this
    [1] => is
    [2] => a
    [3] => term
    [4] => list
)

Further review of this expression to be sure it works as intended would certainly be appreciated.

cmt_term_*_set and also cmt_term_*_update functions?

// call me crazy, but the way I constructed cmt_term_description_set makes a cmt_term_description_update (which would need a select statement to get the content_id unnecessary)... no, for endorse functions the content_id would be passed with the form and save the SQL.
// however, cmt_term_*_update functions are still unnecessary because it's easier to call cmt_vote($content_type, $content_id) from the submit function for the endorse form.
// so this is deprecated
function cmt_term_description_update($tid, $description, $uid = NULL, $value = 1) {

<

blockquote

// call me crazy, but the way I constructed cmt_term_description_set makes a cmt_term_description_update (which would need a select statement to get the content_id unnecessary)... no, for endorse functions the content_id would be passed with the form and save the SQL.
// however, cmt_term_*_update functions are still unnecessary because it's easier to call cmt_vote($content_type, $content_id) from the submit function for the endorse form.
// so this is deprecated
function cmt_term_description_update($tid, $description, $uid = NULL, $value = 1) {
$result = db_query("SELECT content_id FROM {cmt_term_description} WHERE tid = %d AND description = '%s'", $tid, $description);

db_last_insert_id: what it means and how to use it

Or: What's the right way to auto-increment sequences in Drupal?

Drupal 6, not Drupal 5

db_last_insert_id is not for getting the next available number in a sequence. Repeat, it is not for saying gee, I want to insert something into table foo, what was the last foo_id I put in? Then I'll add +1 to it. No!

Or: What's the right way to auto-increment sequences in Drupal?

Drupal 6, not Drupal 5

db_last_insert_id is not for getting the next available number in a sequence. Repeat, it is not for saying gee, I want to insert something into table foo, what was the last foo_id I put in? Then I'll add +1 to it. No!

The point of db_last_insert_id is that you let the database worry about what the next ID is. You use an auto_incremented (MySQL) or serial (PGSQL) column, and the INSERT statement inserts a number for that column for you.

ibolmo: what's better drupal or modxcms?

So asked some random person in IRC #drupal.

The druplicon needs a stock answer for that... something like "it depends whether you use Drupal for good - http://groups.drupal.org/drupal-for-good - or evil - http://groups.drupal.org/drupal-for-evil "