MySource Matrix Developer

MySource Matrix has been superseded by Squiz Matrix. This site will remain available for archival purposes only; it is not intended as a current source of Matrix information. For all the latest on Matrix, including documentation and release information, visit the Squiz Matrix site.

Main Content

Part 1: Hit reporting

Hit Report Asset

  1. Create a new asset type with type code hit_report and install it into your matrix system
    • it should inherit from page
    • it doesn't need any attributes other than the ones it inherits from page at this stage
    • a good idea is to copy and modify an existing asset type, for example page_standard
    • after you've created all the files for the asset type you need to run step 3 to install it to your system
  2. Code the asset type so that assets of this type print a heading saying "Hit Report" on the frontend
  3. Create an instance of the hit report asset in your matrix system, under a site, and view it on the frontend.

Hit Asset

  1. Create a new asset type with type code hit and install it into your matrix system
    • it should inherit from asset
    • it should have one text attribute called user_agent. By default, this attribute should say "Unknown"
  2. Using the asset map in the backend, create a few hit assets linked under your hit_report asset.
    • You'll need to tell the hit_report asset type that it's allowed to have hits linked under it

Recording Hits

  1. Modfify the hit_report asset type so that on the frontend it lists the hit assets linked under it. In this list each HIT asset should display its ID and the 'user_agent' attribute.
  2. Modify the hit_report asset type so that each time you view its frontend, it creates a new hit_report asset under itself and fills in the user_agent attribute appropriately. User agent is the string that identifies the web browser used to access the page. See $_SERVER php global var reference.
  3. Add to the hit_report asset type's backend interface the ability to specify the colour in which you want the frontend content to be printed. You'll need to add an attribute of type 'colour'.
  4. Add a delete button next to each line in the hit_report's frontend display, that will send that hit asset to the trash. When the 'delete' button is pressed, you should not record a new hit and display a notification of successful deletion.

Show your work to the instructor before proceeding to the next exercise.

  • Asset types that extend asset directly will need to specify a 'create' screen. Base asset will refuse to be created on the backend if the 'create' screen is not specified. Take a look at core/assets/page/ to see how this can be done.
  • If in the management class you specified a default value for a variable and used that variable on the 'create' screen, the asset will refuse to be created if you don't change the value from default to something else.
  • printBody() function is the one responsible for displaying the asset on the front end.
  • All HTML output should be hardcoded into the printBody function. Do not worry about abstracting the output or trying to find matrix library functions that will do the job for you.