Possible New Drupal Modules

ausvalue@drupal.org's picture

Possible New Drupal Modules

I have a few ideas for Drupal modules. All are related to Social Networking Sites in that they are an attempt to allow nodes to appear as if they are part of each users account. The first and third modules are related to the Token module.

I'm anticipating developing these modules for Drupal 6 and later versions of Drupal. Not for Drupal 5. I've done some work towards the first module (Type user nids) but very little for the other two.

I'm asking the following:

1) Are these likely to be useful to the Drupal community?

2) Do any currently available modules implement them?

3) Are there better ways to acheive what I'm trying to achieve?


1) Type User Nids Module

Creates a User Nid token [unid]

Similar to Type local nids module except the new unid token created is numbered for each user for each node type. Generally used with the Token module (required) and the Pathauto module. This module allows you to consecutively number nodes of a particular type authored by a single user.

For example:
Assume you've created a form for users to fill out for each of their support requests. This 'request' is a new Drupal node type. If a user named userfoo has 2 requests then the URLs for these could be consecutively numbered similar to the following:

www.example.com/user/userfoo/request/1
www.example.com/user/userfoo/request/2

and if userbar has 9 requests then the URLs for these could be consecutively numbered similar to the following:

www.example.com/user/userbar/request/1
... to
www.example.com/user/userbar/request/9

The above assumes that pathauto is used to create an alias similar to the following:

user/[author-name]/request/[unid]

This module here just helps give Drupal installations a more professional look and feel. I expect it to be useful for other applications such as generating numbers for invoices etc

The [unid] may also be useful in other modules such as computed_field, uploadpath, filefield, contemplate, tokenize, custom_breadcrumbs etc. A Next Unid [next_unid] variant may also be useful for the auto-nodetitle module.

As opposed to the current Type Local Nids module I'm anticipating including an admin page where the administrator can configure which node types this is to be enabled for. There may also be other aspects that can be configured such as the initial number to start numbering from.


2) PHP Menu Items Module

Usage would be as follows:

First, the administrator/user creates a new menu item. This is done in the normal way except that they
i) place a specific tag as the Path
ii) place a name as the Menu link title
iii) place any further parameters in the Description.

The administrator/user would then, within this modules admin page, create php code to specify the replacement of this menu item.

On any page load this module would search through the menus for any menu items that had paths that contain just this tag. On finding such a tag, the module calls the administrator/user supplied php function. This function is given the name (as given in the Menu link title) and any further parameters as given in the description.

The administrator/user supplied php function creates and passes back an associative array that describes the replacement menu items.

Typical requirement specifications that may be handled by such a module are as follows:

A) Customer wants users to be able to create a node of a specific type (eg Support Request form). If the user has created less than 5 of these nodes she has menu access to view and edit each of the nodes she has previously created. If she has created more than 5 of these nodes she will have menu access to the most recent 5 nodes.

B) Customer wants users to each be able to create one and only one node of a specific type (eg An AboutMe page). If the user hasn't created this node then they will have a menu item to create this node. If the user has already created this node then they won't have the create AboutMe menu item but will have 2 other menu items. One to view the previously created node and another to edit the node.


3) Menu Token Aliases Module

(Note: On Jan 1st 2009, which is after I first started this at home, a Drupal 5 module called Menu Token implementing the initial part of this was added to the Drupal Modules)

Allow users to specify the path in the menu using tokens.

Initially, the user will only be allowed to use a token equivalent to [author-name] or [author-name-raw]

At this stage the code will be a fork of the current 'me' alias module. The author of the 'me' alias module was asked for this feature but doesn't want to change the module in this direction.

This would later be expanded to allow multiple menu items of a specific node type to be specified through a single menu item specification. The user would then be able to use tokens for the equivalent of [nid], [lnid] (from Type local nids) and [unid] (from Type user nids).

These tokens would be modified so that they contained extra parameters. There would be a number to indicate the maximun number of menu items along with a flag to tell the module whether to link to the most recent, the oldest or random nodes of this type.

This module may only have the apparent appearance of implementing tokens as supplied by the token module. It's probably easier to implement without actually interfacing to the token module since most of the tokens now have extra parameters and there are only a very small number of tokens that are reasonable to use.

The purpose or use of this module has some overlap with the above PHP Menu Items Module. For example, a possible use of this would be to implement the following:

A) Customer wants users to be able to create a node of a specific type (eg Support Request form). If the user has created less than 5 of these nodes she has menu access to view and edit each of the nodes she has previously created. If she has created more than 5 of these nodes she will have menu access to the most recent 5 nodes.


I'm cross posting this to both the Tokens and the Social Networking Sites Groups. Please comment to whichever you prefer.

Comments

Completed Type user nids module

ausvalue@drupal.org's picture

I have now completed a first trial version of the Type user nids module. You can download a copy from the following address:

http://fiik.org/type_user_nids-trial0.0.zip

It has an extensive README.txt with instructions etc. It includes Views 2 integration. I would like to hear from anyone who tries it out.

Ausvalue
www.ausvalue.com

great! (but make a patch)

greggles's picture

This should probably just be a patch to the Type-local nids module. No need to create a whole new module for such a small functionality.

--
Growing Venture Solutions | Drupal Dashboard | Learn more about Drupal - buy a Drupal Book

Problems combining

ausvalue@drupal.org's picture

Greggles,
I looked at combining but found too many negatives. Although the two modules are similar, there is no overlap in functionality. We can't do with either one what we can do with the other.

When we examine its use in a typical application that its intended for, such as invoicing, we find that using it to create the unid for each invoice requires three database accesses. That is, a database SELECT and two INSERTS, one into each of two tables. If this was combined into the Type local nids module then this would expand out to six database accesses, with three of them having no use at all.

As you rightly say, it is 'small functionality'. If you start throwing all these extra database accesses for little applications just to reduce the number of Drupal modules available then Drupal will soon end up unsuitable for large applications.

I have looked at other alternatives such as including an admin panel for people to choose which node types should user nids be used for and which types should local nids be used for etc. There is a number of negatives to this also such as clutter of the the admin panel etc. There is no place to hide this admin panel as a sub panel of anything. It is effectively a sub category of Tokens but Tokens has no admin panel so it would require its own admin panel. Ultimately, an admin panel may be the way to go, but I am putting that off until there are other extensions to the concept to justify having an admin panel.

Given the similarity in the modules, I have handled this by:
1) Naming it such that the two modules will appear together in any listing. (I don't like the name, its too long, but named it like this for this purpose)
2) Placed a reference to the other module near the beginning of the description.
3) Described it in a similar manner to that of Type local nids description so that its easy to see both the similarity and the difference.

At the same time as I have done this I have also worked on upgrading Type local nids through its issue queue. This has included submitting a Views 2 integration for Type local nids and answering peoples questions etc.

Dupe posts

Michelle's picture

You have two identical posts. I unpublished the other one. You only need to make a post once.

Edit: Make that three posts. Unpublished the other one as well.

Michelle


See my Drupal articles and tutorials or come check out the Coulee Region

@ausvalue, cool, if you have

develCuy's picture

@ausvalue, cool, if you have some work about Menu Token, I'll be willing for feedback :)

Blessings!

more stuff...
(3 John 1:2) Dear friend, I pray that you may enjoy good health and that all may go well with you, even as your soul is getting along well.

menu token??

liquidcms's picture

sadly still no menu token module for Dr6?? i assume this likely needs a core hack to work as the menu module instantly chokes on trying to enter paths it doesn't understand. if there is any sort of hook called before it does this; maybe a chance.. i'll taker a look.