The "Hello World" example, in 9 easy steps
An introductory tutorial cannot be taken seriously without a "Hello World!" example. Well, this is it.
1. Start a new C# Class Library Project
To create a Class Library assembly (dll) that can be loaded into the Smartsite Publication Server, create a new Class Library project.
2. References
Make sure your component references Smartsite.Base, Smartsite.Runtime and Smartsite.SXML:
3. Add 'using' statements
Add the Smartsite.Core namespace:
C# | Copy Code |
---|---|
using System; using Smartsite.Core; |
4. Derive from a Smartsite Module Class.
Check the module class hierarchy for the best starting point.
C# | Copy Code |
---|---|
namespace MyMacroModules { class HelloWorld: Module { public override void Execute() { Result.Append("Hello World!"); } } } |
Smartsite SXML | Copy Code |
---|---|
<se:helloworld /> |
5. Change the build settings
To debug your macro and viper components in the TestSuite environment, a few settings must be used. First, the output path of our component must be set to the bin folder of our website:
6. Change the Debug settings
Then, under Debug, we must choose the Smartsite.TestSuite.exe as the application to run when starting a debug session.
You can find this executable in the Bin folder under the web root of your site.
7. Start debugging
Press F5 to start debugging your project. The Smartsite TestSuite should start and load your site (configured in the output path in step 5)
8. Start editing a page
Now, we are ready to create some SXML that will call our project code:
9. Render the page
Press F5 and expect to see something like this: