Adding files to assets?

Hai-


If I use the file upload script in the import dir of matrix, what types of assets can I upload files to? For example if I wanted to add 5 images under a Standard Page could I do that? More so could I add a folder under that? Thanks.



Kevin

The import_file.php script creates Images, PDF docs and Word docs based on the file extension of the file being uploaded. Once you've imported the files, you can do anything you like with them.


You can add almost any instatiable asset under a standard page, including files (and thus images) and folders.

OK so here is what I want to do. I want to add an upload option to the details screen of both Standard Page and Folder to upload a tar file and unpack it into that asset. I can do all of this in the system so how do I:

  1. Add the form to the details page.
  2. Use your code to unpack it into the assets dir for that asset
  3. create the afor mentioned dir if need be



    Thanks.

Your best bet is to take a look at how the design asset does all this. In general, you are going to want to look at:


edit_interface_screen_details.xml and the matching paint and process functions in design_edit_fns.inc



You'll find these files in core/assets/designs/design/



The XML file defines the interface. You can add XML tags to the details screen of the standard page like the design does. Then you need to write functions to print and process this interface. The function names are defined in the XML, but the functions are actually in the design_edit_fns.inc file. Copy these 2 functions to page_standard_edit_fns.inc and change as required.



The design creates file assets under it - so it is probably close to what you are after.

Nice I was kinda hoping it was an xml config type of thing, makes it easy :slight_smile: So I have a few more questions…

  1. Could I use matrix to manage the members to a members section, ie could i make a members section to my webpage and manage all the users using matrix but at the same time never let them be able to actually log into the _admin system.


  2. I am assuming is pretty easy but are their any trick to adding extra things to the details panel? I want to add stats for each page



    Thanks.



    Kevin

Standard "User" accounts are not allowed to login to the editing interfaces, so you can use those to create closed-user sections. Only Backend Users (or above) can access the /_edit or /_admin interfaces.


To add things to the details panel for an asset, just edit the edit_interface_screen_details.xml for that asset, and create the appropriate paint function (and process function, if appropriate).

sweetness, just out of curiousity why isnt there a web log add on for this thing, seems like it should already be there? Or is there?

You mean a Blog asset? There isn't one, because no-one has paid us to develop it yet. :slight_smile: Though, if you had the commercial CMS module, you could create a Blog-like interface using the Asset Builder to create standard pages that are automatically displayed in the Blog (which I reckon could be either an Asset Listing or a What's New asset).

Hello-


Well not a blog, I mean the standard lends itself to making a blog pretty easily, what I am asking about is webpage statisitics.



Kevin

Do you want to increment a counter each time the page is viewed? or do you just want the ability to set a value in the admin interface?


Incrementing the counter is not too hard, its just an extra bit of code needed in the paint() function of the standard page.



Let me knw exactly what you want to do and I'll try and help you add it in.

Hai-


I want to be able to get the following



page hit

date

user ( if applicable )

ip



I want to take these and store them into a db and then depending on the view option use jgraph to make a jpeg graph of activity( All i need for this is an array of data from a single query to the db). I want this to work on all types of assets like word docs images pdfs pages anything a user might touch. Thanks for your help



Kevin

Your going to need to do this at a much higher level - but I would suggest that using another stats package (such as webalizer) would be easier. The steps you'll need to perform to make this happen are:

  1. create your own table in the DB
  2. log each request to the DB as it comes in - this would be done way up in core/include/mysource.inc before the asset is painted
  3. either create a new global screen for all assets (that appears in the screen drop down in the admin interface) to expose the stats, or create a script or other asset that reads the table for you and graphs it



    You can give this a go if you want. I'll let you know how to query the DB in matrix and where to put it, but I would suggest looking at other ways of doing this. Hacking the source code for this WILL mean you cant upgrade without making these changes each time.



    I'd suggest doing this outside of Matrix. Maybe reading the Apache logs and a custom PHP script to generate graphs outside of Matrix, or just using a free stats package. We use Webalizer and AWStats for our clients.