nope, just one spot.
Before you begin though, please read the pinned post in this forum "HOW TO: Making code changes and recompilling the Repository module 3.x", it is really important to understand the process of changing the module, as it's a .net 1.1 assembly.
So, if you're ready to go, here's how to add a new token to the 3.x version of the Repository module...
All changes will be in the Repository.ascx.vb file.
There are 5 functions that parse/process templates, 1 for each section of a template
ParseHeaderTemplate() - parses/process tokens for the header section defined in header.html/header.xml
ParseFooterTemplate() - parses/process tokens for the footer section defined in footer.html/footer.xml
ParseRatingTemplate() - parses/process tokens for the rating form section defined in ratings.html/ratings.xml
ParseCommentTemplate() - parses/process tokens for the comment section defined in comments.html/comments.xml AND viewcomments.html/viewcomments.xml
lstObjects_ItemDataBound() - parses/process tokens for each individual data item being displayed as defined in template.html/template.xml
Decide which section of the overal template you want your new token to be available in, or if you want to make it available in multiple sections, for example, most tokens in the header section are also available in the footer section
The process is exactly the same for each section, so I will show you how to add a new token to the individual data item section, template.html/template.xml by editing the lstObjects_ItemDataBound() function.
In the function, you'll see a large "Select" statement based on the sTag variable. That is the main token processing code. There is a "Case" statement for each token, so to add support for a new token, just add a new 'Case" statement.
The basic logic within each case statement is to dynamically create the control you want to replace the token with at runtime, and add it to the controls collection of a place holder control named 'objPlaceHolder'. In the following example, I will replace the token named 'MyToken' with some static text.
' add new token named, MyToken
Case "MyToken"
Dim objLabel as New Label
objLabel.Text = "This is my new Token"
objPlaceHolder.Controls.Add(objLabel)
|
Attributes:
You can allow a user to apply 'attributes' to your tokens by adding settings to the corresponding xml file. For example, if we want to be able to apply a stylesheet class to our token, we need to add some code to look at the xml file and see if there's a setting for the attribute and if so use it, or if not, use some default value. The function to do this is oRepositoryBusinessController.GetSkinAttribute(xmlFile, tokenName, settingName, defaultValue).
So, calling...
oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "MyToken", "CssClass", "Normal")
|
will open the template.xml file, look for the [MyToken] token node, see if there's a "CssClass" setting node, and if so, will return the value. If there is no token, or no setting, then the function will return the defaultValue, "Normal".
To use this function to set the CssClass attribute on our example label control, the code would look like this...
' add new token named, MyToken
Case "MyToken"
Dim objLabel as New Label
objLabel.Text = "This is my new Token"
' apply CssClass attribute
objLabel.CssClass = oRepositoryBusinessController.GetSkinAttribute(xmlDoc, "MyToken", "CssClass", "Normal")
objPlaceHolder.Controls.Add(objLabel)
|
To override the default value of "Normal", add a token node to the template.xml file like this... in this example, the label that will replace your MyToken token will be rendered using the SubHead class.
<Object>
<Token>[MyToken]</Token>
<Settings>
<Setting>
<Name>CssClass</Name>
<Value>SubHead</Value>
</Setting>
</Settings>
</Object> |
You can add any control type to the place holder control collections, so tokens can range from simple data replacement to advanced complex controls ( like the rating input form control ).
Good luck, if you have any questions or problems, just ask.