Some more or less random notes from developing a component as an extension to the Phoca Download component which I use on a number of sites - most noticeably on the site where it is used to manage all of the downloadable files.

When I started using it on Green-History I fairly rapidly decided that I needed some major changes to the layout for listing files in a category. PhocaDownload (PD) does allow considerable flexibility built in but this is cumbersome to use, and I suspects pre-dates the availability of simple overrides built in to the Joomla template system.

Initially I set about achieving the layout I wanted by using template overrides for the files and file category layouts and also adjusting some CSS. That was fine and up to a point but there were a few more detailed changes that I wanted which meant modifying PD core files - which would then of course be overridden by any update.

Also I am not entirely comfortable with using template overrides for Joomla - there is always a risk that a file you have overridden will have a critical bug or security fix in a future update, and since you have overridden the file you will miss the updated code.

PD has been around for quite a while and is starting to show its age. It maintains its own categories table, which used to be the way of doing things but now it is simpler to use the built-in Joomla category manager - it saves writing an awful lot of code.

Likewise it uses it own tags tables, but there is no tag hierarchy and the tag descriptions are not used. In the front-end the views for tags and categories are a bit limited. More importantly there is no table view for a list of files in the front end with sorting and filtering - on we already have a few hundred files and providing ways for the visitor to find specific files is pretty important.

So the basic idea was to provide a way of grouping tags under common themes - eg tags for the type of document, tags for the source the file came from, tags for particular themes that cut across categories (I use the categories to group documents by the organisation or group that produced them) and so on. Then to provide ways of displaying and indexing documents in the front end using the tags and also to provide views of documents as a table list with sorting and filtering facilities in the front-end as you have in the back-end.

Initially I thought to provide a hierarchy for tags by adding a parentid column, but accessing a tree or hierarchy structure represented by a parent-child field in mysql gets into some quite complicated coding. The built in Joomla tag system has a hierarchy and all the facilities needed to use it so I considered moving the PD tags into the Joomla standard facility - but this would break all the PD views unless there was some way to keep the two in sync.

I then realised that actually I didn't need a full hierarchy, just a single parent level would do and I could achieve this by giving each tag a category. Furthermore since PD itself doesn't use the Joomla category manager I could use that and all the heavy lifting would be done for me. So that is the approach.

Add a single field 'catid' to the phocadownload_tags table and provide a backend view to create tag categories and assign tags to categories and then I could build front-end views that listed (for example) all of the Document Type tags, or all of the Events tags, and link them to tables of all the files tagged with a particular DocType or Event.