Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have been messing around with the everything engine and I was hoping someone could answer a question for me. I want to be able to create a front page that is kinda like the Monastery's Gates. Below I have code that list the "newest nodes" along with their type_nodetype.
[% my $limit; $limit = int($$VARS{newnodes_limit}) if (exists $$VARS{newnodes_limit}); $limit ||= 15; my $str; my $ref = getNodeWhere({}, "", "createtime DESC", $limit); foreach my $N (@$ref) { $str .= linkNode($N) . ":" . $N->{type_nodetype} . "<BR>\n" if $N- +>hasAccess($USER, 'r'); } $str; %]
This code results in a page that looks kinda like this ...
TEST_FRONT_PAGE:23 Re: Welcome to Everything!:286 Re: Welcome to Everything!:286 does not exist yet:6 root needs to add the chatterbox for you:6 dogface:27 good dim sum duck!:6 ENoteAndPreview:15 shownote:8 parsetimestamp:8 note display page:9 parsecodeonlydoc display page:9 parselinksinfield:19 insert:19 displaynote:19
I would prefer not listing nodes ...
Re: Welcome to Everything!:286 Re: Welcome to Everything!:286
... which are replies to the "Welcome to Everything!" node. I noticed that these two nodes have a type_nodetype of 286. So the question I have is this ...

Is it a good idea to use type_nodetype to filter out notes (replies to a node) ... you know do something like this ...
my $ref = getNodeWhere( "type_nodetype != 286" , "", "createtime DESC" +, $limit);
... or is the value 286 too arbitrary to be used like that and result in a bug? Or do I need to check the "note" table? Something like this ...
my $ref = getNodeWhere({}, "", "createtime DESC", $limit); foreach my $N (@$ref) { my $isNote = 0; next if getNodeWhere( "$N->node_id = note_id", "notes" ); $str .= linkNode($N) . ":" . $N->{type_nodetype} . "<BR>\n" if $N- +>hasAccess($USER, 'r'); }
I have looked at the everything bible I couldn't find where it talks about using the type_nodetype field.

Thanks!

The type_nodetype is a field int the node table shown below ...
mysql> desc node; +--------------------------+-----------+------+-----+----------------- +----+----------------+ | Field | Type | Null | Key | Default + | Extra | +--------------------------+-----------+------+-----+----------------- +----+----------------+ | node_id | int(11) | | PRI | NULL + | auto_increment | | type_nodetype | int(11) | | MUL | 0 + | | | title | char(240) | | MUL | + | | | author_user | int(11) | | MUL | 0 + | | | createtime | datetime | | | 0000-00-00 00:00 +:00 | | | modified | datetime | | | 0000-00-00 00:00 +:00 | | | hits | int(11) | YES | | 0 + | | | loc_location | int(11) | YES | | 0 + | | | reputation | int(11) | | | 0 + | | | lockedby_user | int(11) | | | 0 + | | | locktime | datetime | | | 0000-00-00 00:00 +:00 | | | authoraccess | char(4) | | | iiii + | | | groupaccess | char(5) | | | iiiii + | | | otheraccess | char(5) | | | iiiii + | | | guestaccess | char(5) | | | iiiii + | | | dynamicauthor_permission | int(11) | | | -1 + | | | dynamicgroup_permission | int(11) | | | -1 + | | | dynamicother_permission | int(11) | | | -1 + | | | dynamicguest_permission | int(11) | | | -1 + | | | group_usergroup | int(11) | | | -1 + | | +--------------------------+-----------+------+-----+----------------- +----+----------------+ 20 rows in set (0.01 sec)

Plankton: 1% Evil, 99% Hot Gas.

Replies are listed 'Best First'.
Re: Filtering out replies in Everything Engine
by chromatic (Archbishop) on Sep 01, 2004 at 15:58 UTC

    If I were you, I'd join the nodetype table on type_nodetype from the node table and filter based on the name of the nodetype you actually want. You could do this in two queries, but I'd do it in one.

      Thanks chromatic,

      Sorry if I am a little slow. Does nodetype mean mysql table? I mean if I had a table called front_page_nodes would that mean I could do ...
      my $ref = getNodeWhere( {}, "front_page_nodes" );
      ... and get all the nodes from the front_page_nodes table?

      How can I use getNodeWhere to execute a join between two tables? Or do I have to use DBI or the $DB Everything Engine var somehow? Or should I use Everything::NodeBase Functions ?

      Plankton: 1% Evil, 99% Hot Gas.