Tutorials

At this point, you should have a menu item for your newly created downloads view.  However, if you click on it, you will see the "Downloads" title, and nothing else.  Let's go ahead and add some sample content.

Go to Create content->Download.  Enter a title for the download, and give it a description.  Under "File Name," browse for the file you want to add, and upload it.

Save the new entry.

Now, if you go to the "Downloads" link from the menu, you will have the node for the file you just added.  At this point, it doesn't look too bad, but we can do more with the appearance to make it look similar to DOCman.  If that's something you're interested in, keep on reading.

11/25/2008 - 18:12
12/02/2008 - 18:26

AggOO - The GDI+ like interface for Anti-Grain Geometry

 

What is it?

AggOO is a higher-level interface to the excellent Anti-Grain Geometry library. It provides syntax which resembles Microsoft's GDI+ library, and most GDI+ code can be converted to AggOO fairly easily (often by simply changing the namespace.)

License

AggOO is released under the Modified BSD license, which is fairly unrestrictive. However, it is dependent on Anti-Grain Geometry, and as of version 2.5, AGG is under the GPL license. Fortunately, the Modified BSD is compatible with the GPL license, but the result will also be GPL. Please keep this in mind when developing code.

Download

Currently, AggOO may be downloaded from SourceForge at http://sourceforge.net/projects/aggoo through anonymous CVS. An actual release should be ready soon.

Preparing Anti-Grain Geometry

It is necessary to build Anti-Grain Geometry as a library in order to use AggOO. Instructions on how to do this can be found here.

Usage

There are some tests included with the AggOO source which show how to get started. It is very similar to using GDI+, but it is not necessary to perform the startup/shutdown routines.

03/09/2009 - 17:36
03/16/2009 - 15:52

Getting Started

The Drupal installation isn't really any different than other uses, so I won't detail that here.  You DO need to make sure you enabled the forum module in the Drupal core (and any other modules that you might need, such as upload, profile, search, poll, tracker, etc.)

Gather Required Modules

Please note that not all of these modules may be necessary for your site.  In fact, you can just enable the forum module and go with that!  I'm attempting to detail my process here to help others (and to help myself if I ever need to reinstall.)

The following is a list of modules that I added to get the forum working the way I needed:

  • phpBB2Drupal (absolutely necessary for migrating from phpBB, but otherwise you probably won't need it.)
  • BBCode (allows using BBCode for text markup.  Common in a lot of forums, so it's a good idea to have.)
  • Privatemsg (needed so users can send private messages.  phpBB2Drupal uses this to convert phpBB PMs.)
  • phpass (stores passwords securely.  Needed by phpBB2Drupal, but make sure to read over the project page!)
  • Comment Upload (allows attachments to be included with comments.)
  • Better Formats (Drupal doesn't natively allow an input format to be used for just one content type.  This fixes that since you might not want your forum type to be used for blogs, or tutorials... then again maybe you do.)

The following improve the forum experience:

  • Advanced Forum (gives the Drupal forum a look closer to other, more common forums.)
  • Author Pane (provides a block of information about the author.  Required by Advanced Forum.)
  • Flatcomments (forces comments to always reply to the node regardless of the reply link used to post the comment.  Required by Advanced Forum.)
  • Forum Access (allows forums to be set to private.  This may be included in the core of Drupal 7.)
  • ACL (required by Forum Access.)
  • Signatures for Forums (allows signatures to be placed in the posts.  If a user changes their signature, all posts will be updated.)
  • Smileys (converts ASCII emoticons to graphical smilies.)
  • Fasttoggle (provides links for moderators to directly change post settings.)
03/09/2010 - 17:17
05/17/2010 - 16:14

Note: The latest cvs will have AGG included in the project, making the following notes unnecessary.  The next release of AggOO will also start including AGG, which makes building easier.  If you are using AggOO 0.1.5 or earlier, you may need to look over this information.  AggOO after 0.1.5 may disregard this tutorial.

 

Building Anti-Grain Geometry for the AggOO library

Before building and using the AggOO library, the Anti-Grain Geometry library must be available on your system. This isn't a straight-away installation, but it shouldn't be too difficult.

Download Anti-Grain Geometry

Head over to http://www.antigrain.com and download the appropriate archive for your platform. Currently, AggOO uses AGG 2.4, but later versions will probably work if the build instructions are followed. The only major differences between AGG 2.4 and 2.5 is the license changed from Modified BSD license to the GPL license. AggOO will remain under the Modified BSD license (libraries should not dictate the license of the application!,) which is compatible with the GPL.

Prepare the library

AGG comes with an example which can display SVG files. Although this is actually an incomplete loader, it does a pretty decent job, and is already integrated. AggOO will use parts of this (along with some customized classes) for loading SVG files. (AggOO also supports .AI files internally.) However, AGG has all of the SVG handling files located in examples/svg_viewer. This isn't a very nice path for a production library, so these files need to be moved. I have them located in include/svg and src/svg (for the header and implementation files, respectively.) This is how the AggOO source files expect them to be, so if you'd rather use a different path, you will need to make some changes to the AggOO source…

Building the library

I have built AGG using Visual C++ .NET (2002) and 2005. I have also used Code::Blocks on both Windows and Linux. Other IDEs should work similarly.

Build for Windows

The documentation for AGG suggests dropping the necessary files into your projects when using it under Windows. This can allow you to streamline your projects by keeping the unnecessary stuff out, but I prefer to build as a library that can be linked to the project rather than having to sort out which additional files need to be added to my project. Ideally, I would like to build AGG as a DLL which could be linked dynamically to AggOO (and other projects) so that a change to the AGG library wouldn't require rebuilding everything else in order take advantage of those changes. However, I don't think its a good idea for me to mess with the AGG files, so we'll just build them as static libraries. I have not put much time and effort into trying to build AggOO as a DLL, so I won't cover building AGG for DLLs yet.

Once the archive is downloaded, decompress it somewhere convenient for you. For this tutorial, I'll use the directory c:\SDKs\agg\agg-2.4\, but you can use whatever you like. Add the include directory (c:\SDKs\agg\agg-2.4\include\) to your compiler's search path. Also, create a new directory for the library files (c:\SDKs\agg\agg-2.4\lib\) and add this to the linker's search path (your new library will be moved here, and future projects will look here when linking.) I also created a scripts folder where I save the project files, but that's entirely up to you.

Start a new Static Library project

In your IDE, start a new project to make a static library named agg. You should be able to accept the defaults all the way through. Before we get too far, create another static library project named 'agg_main' and add this to the current solution/workspace/whatever. This will be for the platform dependent code used for the demo applications.

Add files to the projects

Add all of the *.cpp files in c:\SDKs\agg\agg-2.4\src\ to the agg project. Also, add all of the header files in c:\SDKs\agg\agg-2.4\include to the agg project (this isn't really necessary, but I like having them in the project.) Add the header files located in c:\SDKs\agg\agg-2.4\include\util\ to the agg project as well.

Add everything in the c:\SDKs\agg\agg-2.4\include\ctrl\, c:\SDKs\agg\agg-2.4\include\platform\ and c:\SDKs\agg\agg-2.4\include\platform\win32 directories as well as the c:\SDKs\agg\agg-2.4\src\ctrl\ and c:\SDKs\agg\agg-2.4\src\platform\win32\ directories to the agg_main project.

After the projects have built, you could manually copy and rename the library files, but I like to make the IDE do that for me. In Visual C++, open the project properties (right-click the project, then choose 'Properties') and select 'Build Events→Post-Build Event.' Under 'command line,' enter the following code for the debug configuration: move “$(OutDir)\$(ProjectName).lib” “c:\SDKs\AGG\agg-2.4\lib\agg_d.lib”, and for the release: move “$(OutDir)\$(ProjectName).lib” “c:\SDKs\AGG\agg-2.4\lib\agg.lib”. Note that this will make the library files agg.lib and agg_d.lib. Be sure to conform to this if you are copying the files yourself (or else change the AggOO settings.) Similarly, the files for agg_main should be agg_main.lib and agg_main_d.lib.

To automatically copy the files in Code::Blocks, right-click the project and select “Build Options.” Select the “commands” tab, and enter mv “libagg.a” “c:\SDKs\AGG\agg-2.4\lib\libagg_d.a” for the debug build, and mv “libagg.a” “c:\SDKs\AGG\agg-2.4\lib\libagg.a” for the release build. Notice that I am using the gcc compiler, hence the ”.a” extension. You may need to make modifications based on you environment. The agg_main project should move the files to the same location, naming them “libagg_main_d.a” and “libagg_main.a.”

At this point, you should be able to build the entire solution (Build→Batch Build…, build everything) and be set.

I won't cover the AGG demos, but basically, there is already a project file you can import and build.

Build for Linux

NOTE: This was tested on Ubuntu. Other distributions may vary.

The Linux versions of the Anti-Grain archive uses makefiles to build a static library. You can use this to simply type “make” to build the library. On the other hand, you can also use Code::Blocks for Linux to follow the same route described for Windows above. I chose to do this, and created the debug and release libraries, in the same manner as under windows (I find it easier.) Just make sure to replace the win32 platform files with those for your target platform (I'm using X11.)

Common Mistakes (for me, anyway)

For some reason, I sometimes forget to check the code generation option. It is important that all projects that are used together have this setting the same. For example, if the library is built with Multi-Threaded DLL, then the application should use this setting as well. This is important, but easy to forget.

03/09/2009 - 17:40
03/23/2009 - 15:46

Clean Up

Install Advanced Forum

If you look at your forum now, it really doesn't look all that impressive.  If you have users who are used to your phpBB forum, they are going to start emailing you nasty messages about how they hate the new look and all that.  Let's try to make things a bit easier for us all.

First up, let's install the following modules:

Upon installation of the Flat Comments module, you will be able to flatten existing comments for any and all types.  I prefer flat comments, but suit yourself.  I do think forums look better with flat comments as it is easier to find the most recent post.

Go to Administer -> Site Configuration -> Advanced Forum.  I don't like the 'naked' forum style, so change it to something else (blue_lagoon_stacked is nice.)  The rest can be left alone unless you really want to change it.

Now if you look at your imported forum, it is starting to look like a forum!  You may notice that the user avatars and smilies are not showing and the signatures aren't quite right.  We'll get to that, but first let's tackle...

Private Forums

It is pretty common for a forum to be accessible only to moderators or those with sufficiently high enough status.  Drupal currently doesn't support this behavior natively, but is expected to in D7.  In the meantime, we need the following modules installed:

You will need to rebuild the content permissions.  Now to set a forum for a special group of members, go to Administer -> Content Management -> Forums.  Select 'edit forum' next to the forum you wish to make private and select the appropriate permissions at the bottom.  For example, make the moderator the only one who can view a forum.  You might want to adjust the other permissions as well so that the appropriate individuals may edit or delete posts.

Smilies

In order to convert ASCII emoticons to graphical smilies, you need to install the Smileys module.  You may import smilies from other applications, such as phpBB or Yahoo!  In order to have them work with your Forum input format, go to Administer -> Site Configuration -> Input Formats and configure the forum format by enabling the Smileys filter.  Also, go to Administer -> Site Configuration -> Smileys and under Settings, enable smileys for nodes and comments and all desired format types (at least your forum type.)  You might want to go ahead and enable this for other formats as well.  If you look at your forum posts, you should have smilies working!

Signatures

By default, Drupal appends the signature to the end of the post.  In order handle this properly (meaning, like other forums), install the Signatures for Forums module.  Go to Administer -> Site Configuration -> Signatures for Forums and adjust the settings (show the signatures for the desired format types, I use the forum input format...)  Next, Drupal's signature functionality must be turned on, so go to Administer -> User Management -> User Settings and make sure signature support is enabled (we did this earlier.)  Since we are also using Advanced Forum, go to Administer -> Site Configuration -> Signatures for Forums and expand 'Other Options' and disable 'Automatically add signatures to content.'

Fix User Avatars

Users created in Drupal should have no problem with their avatars showing up.  However, I was going crazy trying to get the avatars for users imported from phpBB to show up.  After some digging through the databases and looking at the files in the phpBB images/avatar/upload directory, I figured it out.  Say you have a file in the directory named 63f0ff6ffa05cdd65149165723a8afd8_10.jpg.  The 63f0ff6ffa05cdd65149165723a8afd8_ is some sort of hash used by phpBB for reasons I can't understand.  If you dig into the database, you will find that the user with the avatar has the filename as simply 10.jpg in the database.  I used Bulk Rename Utility to remove everything up to and including the underscore in the files.  This worked for the majority of the avatars, but there were some still not showing.  More digging in the database showed that after this initial rename process, I had some files with names like 4_234576465234.jpeg in the database which should be associated with a file named 4.jpeg.  You can find these files by searching the drupal_users table for where the picture value is "like" '%\_%' (notice the escaped underscore and wildcards).  Since there were only a few, I manually editted the database to remove the underscore and gibberish after.  I have no idea why phpBB did this, but it did.  However, we still aren't finished, as the forum still won't show the avatars!  Again, looking at the path for the avatar, we can see that phpBB2Drupal has them in the database as being in the directory 'files/' when they should be in 'sites/default/files/'.  Use the following SQL command on the users table (in my case, drupal_users) by going to that table in phpMyAdmin and clicking the SQL tab.

UPDATE drupal_users SET picture = REPLACE(picture, "files/", "sites/default/files/")

followed by

UPDATE drupal_users SET picture = REPLACE(picture, "sites/default/sites/default/", "sites/default/")

in order to remove any duplications.

(see this issue for how I figured this one out: http://drupal.org/node/689852).

At this point, you should be able to see the avatars in the forum!!!!

(By the way, the avatars from phpBB need to be copied to 'sites/default/files/pictures/'.  I then used IrfanView to resize them to the size used by the site/forum.)  In order to get the pictures to show at an appropriate size without physically resizing them (in other words, to have smaller pictures in the forum posts and larger pictures in the profile), use the ImageCache Profiles module.  Details can be found in the 'Miscellaneous Additions' part of this tutorial.

03/09/2010 - 19:42
05/18/2010 - 15:39

Well, that should help to have something similar to DOCman in Drupal using common modules.  It took us a little while to get to this point, and it isn't quite as powerful, but it does the job nicely.

You don't have to implement your download manager in the same way as I described.  Feel free to add/remove fields from the nodes, use a different layout, etc.  The possibilities are endless!

 

 

--Chad

11/25/2008 - 19:49
01/12/2009 - 17:36

Just as we copied page.tpl.php to page-downloads.tpl.php, we need to do the same for the node.tpl.php file.  Actually, the modification is very minor and easy to miss.  In the first div, change the name of the class from "node" to "downloads-node".  In other words, change the line from

<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">

to

<div id="node-<?php print $node->nid; ?>" class="downloads-node downloads-node-<?php print $zebra; ?><?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">

 This will let us theme the body of the node. Note the

downloads-node-<?php print $zebra; ?>

in the modified line.  This will allow you to alternate the background colors of even/odd nodes if you'd like.

 

11/25/2008 - 19:16
01/13/2009 - 12:48

We need to specify a custom template for download pages.  Make a copy of the template file "page.tpl.php" and rename it to "page-<node_type>.tpl.php," where <node-type> is the name we gave to the node type when we created the content type.  In our case, we would name the file page-download.tpl.php.

Open the new file in a text editor.  Around line 69 (just after the mission) add a new line and add

<div id="downloads-page">

I close the div after the rss icon is displayed (but you might want to enclose more/less within the div) by adding

</div>

around line 80.  This will let us theme the entire page that the node appears in, from buttons that appear at the top of the page when a download node is displayed to the footer.

11/25/2008 - 19:10
12/03/2008 - 18:19

Assuming we want to have the download manager accessible from the menu, we need to setup a view for the content type.  Go to Administer->Site Building->Views, and click "Add" at the top of the page.  Enter a name (ie. "downloads") and (optionally) a description ("Collection of files available for download") and a tag ("downloads") for this view.  Leave the type as "Node" and click "Next."

We now have a fairly complicated looking page.  Don't despair, we'll get through this.

On the left, under "Defaults," there is a drop-down box with some view displays.  Select "Page" and click "Add Display."  Repeat this for the block display type.  (Note: The block display is optional, but if you wanted, say, a sidebar that shows the most recent download files, you'll need this.)

Setup the Default Display

Select "Defaults" again.  Under "Basic Settings", change the title to "Downloads" or something more descriptive than the default.  You change the values by clicking the link, then editing the fields that appear at the bottom of the page.

We now need to add some things to different groups.  Do this by clicking the "+" box in the appropriate group.

Under "Sort Criteria," add "Node: Post Date" by clicking the "+", selecting the "Node" group, then checking the "Post Date" checkbox.  Click "Add," then set the sort order and granularity (I use descending, with second granularity.)  Click "Update" to finish.

Under "Filters," add "Node: Type" and "Node: Published."  Set "published" to true, so only those download files that have been published will be displayed, and leave it unexposed.  Make the type "Is one of" and "Download" (or whatever you named the content type.)

Now we add the fields we want displayed in the node.  This process is similar to the above, and you can add any fields you wish, but I'll just explain what I have.

  1. Node: Title (remove the default label and check "Link this field to its node)
  2. Node: Post Date (change the label and adjust the date format if desired)
  3. Node: Updated Date (change the label and adjust the date format if desired)
  4. Node: Body (remove the default label)
  5. Content: Content: File Name (this is the File Name field we added to the content type) (Change the label to "None")
  6. Content: Content: Preview Image (this is the preview image field we added to the content type) (Check "Link this field to its node," change label to "none," and set the format to "Image".)
  7. Node: Comment Count (defaults are fine)
  8. Taxonomy: All terms (remove default label)

Save the settings.

Setup the Page Display

Click "Page" in the left column to bring up the page settings.

Under "Page Settings", set the path to "downloads" so that you can access the downloads page by going to http://sitename.com/downloads.

Save the settings.

Menu Option 1

Set the menu to "Normal menu entry" and "Downloads" as the title and select which menu to add it to.  This will add a "Downloads" item to the menu, which will basically list all items, like a blog.  This is fine in some cases (for instance, a most recently added list) but not really categorized like we'd want.  Read option 2 for a nicer solution.

Save the settings.

Menu Option 2

Typically, we'd like to have our files organized by the taxonomy terms associated with them.  This is quite simple to do by using the "Taxonomy List" module.  Basically, all you need to do is create a new menu item (Administer->Site Building->Menus-><name_of_menu>) and click "Add Item."  Enter a title, which will appear on the menu, and in the path field, enter "taxonomy/vocabulary/<vid>," where <vid> is the id of the vocabulary ("Downloads") that we want to list.  In order to find the vocabulary id, go to Administer->Content Management->Taxonomy, and hover over the "edit vocabulary" link for the vocabulary we a looking for.  Notice the address of the link ends with a number (something like ..../taxonomy/edit/vocabulary/1, where 1 is the vocabulary id.)  You may set any of the other options for the menu (description, parent, etc.) that you like and save it.  Now when you click the menu item, you are taken to a page that has the taxonomy terms for the download files.  Click a term, and you have the files in that category.

You may want to configure the taxonomy list a bit.  Go to Administer->Site Configuration->Taxonomy List.  I set it to display 1 term per row, but that's up to you.  I do recommend checking the "Add edit term link" so you can edit the term's description when logged in as an administrator.  The reason for this is that we are letting users define new terms when a file is uploaded.  These new terms won't have a description (which is nice to have for the category) and by having the edit link here, it is easier to modify through casual browsing.

Save the settings.

Setup the Block Display

Under "Block Settings," change the "admin" to give the block a description name, such as "DownloadBlock."

Save the settings.

 

11/25/2008 - 17:19
12/02/2008 - 18:25

It seems as though when it comes to providing a decent download manager in Drupal, there just isn't much there.  Joomla has DOCman, which is truly excellent.  Drupal has... ummm... yeah.  There are modules such as dbFM and WebFM, which are very nice, but they are more like an OS's file manager than what I consider a download manager to be.  I guess I should explain what I consider a download manager to consist of:

  • Categorization of files -- When added, a file can be tagged with one or more keywords to make it possible to group them together.
  • User-friendly information about the file in the listing -- When viewing a list of files, it should provide more than just a file name (which doesn't need to be shown at all, really.)  Ideally, it will have a brief name for the file as a title and a description of the file that explains more in depth as to what the file is.  It might also show the file size, date it was added, date of last modification, and a download count.  It could also display a file-type icon, as the following example of DOCman from http://www.joomlapolis.com shows:

     
     

  • Distinguish the files -- This could be as simple as having a space or line between file entries, or there could be different colors for the even and odd entries.

These are some of my requirements.  The big thing for me is to have a nice layout which uses user-friendly names and descriptions.  The idea is that the general public needs to be able to know what they are getting, and filenames (usually) aren't the best way to express that.

While Drupal does not have an immediate "set-it-and-forget-it" module to do this, the beauty of Drupal is that it is quite customizeable, and can be made to do just about anything we want.  In this document, I will attempt to walk through how to mimic much of DOCman's behavior in Drupal, using common modules.

11/21/2008 - 12:36
02/23/2010 - 17:42