NetworkIt Tutorial

Please note: I have shifted my focus to Python/ Linux/ embedded development and am no longer accepting MODX or PHP projects. For MODX work, I recommend Grey Sky Media.

Please note: the Networkit project is abandoned. Please do not use it except for reference when developing your own components.

Source, docs, and bugs:
  • NetworkIt and UserUrls are currently on gitHub (username yoleg)
  • Documentation: see gitHub wiki for both projects.
  • Bug Reports: use gitHub bug tracker for both projects.
5/21/2011: Here's the current status of the project:
  • I am separating the project into two components: UserUrls (the friendly URL component) and NetworkIt (messaging and connections). NetworkIt will come with an option to enable instant UserUrl integration, although hopefully it will be compatible with any friendly URL setup.
  • UserUrls has been submitted to the MODx repository. The URL structure is not very flexible though (which is not very MODx-like), and future releases may change the functionality significantly. URLs are currently set at site.com/username and site.com/username/custom-action.
  • Until NetworkIt comes out, you can use UserUrls with output filters: [[!uuId:userinfo=`fullname`]], Quip, Profile (Login package), FormIt, Peoples, Gravatar, and more.

Instructions for Forum Package

Note: Applies to NetworkIt 0.2. Please download new version in the forum.

Goal: Each user on your site will get their own friendly-url public profile page with public message wall and private message capabilities. By "public" I mean accessible to someone other than themselves. You will still be able to set resource group permissions on the "template" pages and control who gets to see the profiles and message walls.

Here's how the URLs will look like:
  1. site.com/john (where john is a username)
  2. site.com/john/messages (where messages is an "action")
  3. site.com/mary/some-custom-action
  4. etc...

1. Create your template

Create a user profile template for your user profile pages as normal, except for the following changes:
  1. Remove your canonical, breadcrumbs, or whatever else generates links using this page id, since URLs will use usernames instead of aliases.
  2. Place the following code somewhere on the template: [[!NetworkIt]]

2. Create your pages

Create two pages, both using the user profile template you just created. Preferably, have them hidden from the menu and not searchable.

The first page will be the default user profile page (let's say it's page id 122 for this example). It will be accessed by going to site.com/username. Place the following in the page to test the public message wall (Twitter/ Facebook/ MySpace style) functionality:

[[$publicWall]]

The second page will be an example "subpage" (or "action"). Let's call the action "messages", and let's say it's page id 123 for this example. It will be accessed by going to site.com/username/messages. Place the following code on the page, which will demonstrate private message functionality:

[[$privateWall]]

3. Set up the site settings

Create the following site settings and values:
  1. key: wall_start 
    value: 122
    (replace 122 with the resource id of your default user profile page)
  2. key: wall_actions
    value: 123:messages
    (replace 123 with whatever your messages page id was. To add more actions, just separate with a comma. For example: 123:messages,124:favorite-colors,127:pets,etc.... The numbers are the page id that will be used as a template, and the strings are the URL action following the username.)

Also, make sure your FURLs are enabled and working, that you have a special 404 page designated, and that everything else in your site is working as expected.

4. Add permissions - Optional

In the demo chunks, &minimumPermissions is set to "load" for the formit2messages snippet, so you can skip this step. However, by default, posting messages requires a special permission. Eventually, setup the following custom permissions, and make sure your logged-in users have them: wall.post_messages and wall.view_messages. The best way to do this is to go to Security --> Access Controls --> Access Policies --> Add. Create a policy called NetworkIt and edit it. Go to the Permissions tabs and click the "New Permission" button to add the new permissions. Then, assign the NetworkIt policy to your "Registered Users" group (or whichever group you want to use). By default, users can view messages with just Load permissions, but they cannot post without the wall.post_messages permissions.

5. Activate the Plugin

Make sure that the NetworkItFURL plugin fires on the onpagenotfound event and that your site is set up for friendly URLs (rewriting). Test it by going to site.com/username (for an existing and active user).  If it doesn't work - let me know!

Troubleshooting

  • Try removing the publicWall and privateWall example chunks from your pages, and see if you can get the friendly URLs to work first. 
  • If you are still having trouble, remove the NetworkIt snippet call and see if you can get just the plugin to redirect to the username in the URL.
  • Use simple placeholders like [[+public.username]] to test if profile info is getting received from NetworkIt before adding the publicWall or privateWall chunks back onto the page.
  • If the public/privateWall chunks are the problem, try separating them into their individual snippet calls (Formit without formit2messages, Formit with formit2messages, and getMessages) to narrow down the problem.
  • If you narrow down the problem, I can troubleshoot, so just contact me or post in the forum.

Available Generated Placeholders

The NetworkIt snippet automatically runs the Profile snippet (from the Login package) - so make sure that's installed. It outputs the following placeholders: [[+public.username]], [[+public.fullname]], [[+public.id]], and so on, for every user field that Profile is capable of outputting, but with the public. prefix set by default (you can change this in the parameters).

It also outputs two NetworkIt-specific placeholders: [[+net_userid]] (the main userid for the profile) and [[+net_action]] (the name of the action - example: messages).

NetworkIt Parameters

Briefly, the following are important parameters of the main NetworkIt snippet: 

  • profilePrefix: the prefix parameter to pass to the Profile snippet (public. by default)
  • profileUseExtended: set to false to disable parsing extended user fields

BreadCrumbs, canonical, and other URLs

To generate URLs, you should use [[+public.username]]/[[+net_action]] for action pages or just [[+public.username]] for the main profile page.

Linking to Profile Pages

  1. To link to a logged-in user's profile pages/ message walls in your site menu (Wayfinder): Use weblinks with the weblink URL set to [[+modx.user.username]] or [[+modx.user.username]]/messages (or any other action). You can title the weblinks something like "View your profile" or "View your messages" or whatever is appropriate. Add them to an appropriate Resource Group, and they will show up only after a user is logged in.
  2. To link to a specific user's pages/ message walls, just use their username.
  3. To generate links to walls of multiple users, use the Peoples package. I have included a Peoples template chunk in the NetworkIt package for an example.

Notes

  • Update: added instructions to set proper permissions (see Permissions above)
  • Component was created on a Revo 2.0.4-pl2 site. 
  • Example site up at flamebird.com (see forum for login info)
  • First attempt at packaging had too many bugs. Check forum post for version 0.2.