Now that we've got our class, we want to append our copyright date to it. Let's go ahead:
Go ahead and add this method to your CopyrightedResource class copyrightedresource.class.php:
This will automatically append the Copyright to the bottom of every content for the Resource - not the end of the Template, but the end of the contents of the [[*content]] placeholder.
That concludes our additions to our CopyrightedResource class. We could do a lot more here by overriding other functions from the parent modResource class, but that's beyond the scope of this tutorial.
Here's a list of some of the functions you can override (we'll include the functions we already overrode). See core/model/modx/modresource.class.php for the parent class.
- getContextMenuText – displays the text for the right-click on the tree
- getResourceTypeName – simple name of the resource type
- prepareTreeNode – Allows you to manipulate the tree node for a Resource before it is sent
- listGroups – Get a sortable, limitable collection (and total count) of Resource Groups for a given Resource.
- getTemplateVarCollection – Retrieve a collection of Template Variables for a Resource.
- process – Process a resource, transforming source content to output.
- getContent – Gets the raw, unprocessed source content for a resource.
- setContent – Set the raw source content for this element.
At this point, you should be able to log into the manager and right-click the file tree and see our new CRC show up as an option to create. When you create a new "Copyrighted Resource", you should note that the URL changes inside the manager. Whereas normally when you create a page, your URL will be something like http://yoursite.com/manager/index.php?id=1&a=55&parent=0&context_key=web, now the URL includes the class_key parameter: http://yoursite.com/manager/index.php?id=0&a=55&class_key=CopyrightedResource&parent=0&context_key=web
When you try to add a new Copyrighted Resource, however, you will only get a white screen! This is normal – we haven't created the controller files yet.
|Don't worry if you get a white screen when trying to create a Copyrighted Resource – we haven't created the controllers yet.|
Now let's make things start working by making our controller files.