Submitted Oct 06 in Datatypes
First you need to create a Delegate method, i called my method MyDataAfterAdd, second is to make a method for attaching method called AttachEvents. The rest of the code is just pluming code to make sure that events gets reattached after flushes
using System;
using Composite.Data;
using Composite.Data.Types;
public static class MyEventRegistrator
{
private static bool _registred = false;
private static object _lock = new object();
static MyEventRegistrator()
{
GlobalEventSystemFacade.SubscribeToPostFlushEvent(OnPostFlushEvent);
}
private static void OnPostFlushEvent(PostFlushEventArgs args)
{
Register();
}
public static void Register()
{
if (_registred == false)
{
lock (_lock)
{
if (_registred == false)
{
AttachEvents();
_registred = true;
}
}
}
}
private static void MyDataAfterAdd(DataEventArgs dataEventArgs)
{
IPage page = (IPage)dataEventArgs.Data; //page contains data just added
//do your magic here
}
private static void AttachEvents()
{
DataEventSystemFacade.SubscribeToDataAfterAdd<IPage>(MyDataAfterAdd);
}
}
Next we need to attach events on system initialization, so i Global.asax call the AttachEvents method after system initialization.
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="Composite" %>
<%@ Import Namespace="Composite.Logging" %>
<%@ Import Namespace="Composite.Application" %>
<%@ Import Namespace="Composite.ConsoleEventSystem" %>
<%@ Import Namespace="Composite.Instrumentation" %>
<%@ Import Namespace="Composite.Licensing" %>
<script RunAt="server">
void Application_Start(object sender, EventArgs e)
{
AppDomainLocker.WaitForUnlock();
TempDirectoryFacade.OnApplicationStart();
Composite.Types.BuildManager.InitializeCachingSytem();
if (Composite.Licensing.LicenseFacade.Registered == true)
{
Composite.GlobalInitializerFacade.InitializeTheSystem();
LoggingService.LogInformation("Global.asax", "Application started and initialized");
MyEventRegistrator.Register(); //add the Register methode call here
}
}
void Application_End(object sender, EventArgs e)
{
try
{
if (Composite.Licensing.LicenseFacade.Registered == true)
{
Composite.EventSystem.GlobalEventSystemFacade.ShutDownTheSystem();
Composite.Types.BuildManager.FinalizeCachingSytem();
}
LicenseFacade.Stop();
TempDirectoryFacade.OnApplicationEnd();
}
finally
{
LoggingService.LogVerbose("Global.asax", string.Format("--- Web Application End, {0} Id = {1}---", DateTime.Now.ToLongTimeString(), AppDomain.CurrentDomain.Id));
AppDomainLocker.Unlock();
}
}
</script>
That is it, now go replace "//do your magic here" with your stuff. This example is done with Composite.Data.Types.IPage, but this can be done with any thing that derives from Composite.Data.IData.
Submitted Aug 08 in Setup & Installation
Create application pool for C1 site
On the above screen dump is a standard Composite C1 created,
to create a dedicated application pool right click on Application Pools - choose new…
Give the new pool a name, use default setting then press OK.
Now go to the properties for the site you want to use the new pool you’ve created…
Go to Home Directory, on the bottom choose the application pool you created, and then press Apply
Go to Asp.Net tab and choose Asp.Net version
Click Ok.
Submitted Jun 10 in General
Make sure that your Web site has a folder in which to store the resource file by doing one of the following:
If you are creating a global resource file, you must have a folder named App_GlobalResources. To create the folder, in Solution Explorer, right-click the name of your Web site, click Add Folder, and then click App_GlobalResources Folder. There can only be one of these folders in an application, and it must be located at the root of the application.
If you are creating a local resource file, you must have a folder named App_LocalResources. To create the folder, in Solution Explorer, right-click the name of your Web site, click Add Folder, and then click App_LocalResources Folder. There can be many of these folders in an application, and they can be located at any level in the application.
To create a resource file, right-click the App_GlobalResources or App_LocalResources folder, and then click Add New Item.
| Note |
|---|
|
Global resource files must be in the App_GlobalResources folder. If you try to create a .resx file outside of this folder, Visual Web Developer prompts you to create it in the folder. |
In the Add New Item dialog box, under Visual Studio installed templates, click Assembly Resource File.
In the Name box, type a name for the resource file and then click Add.
Visual Web Developer opens the file in the Managed Resources Editor. The editor displays a grid where you can enter names (keys), values, and optional comments.
Type key names and values for each resource that you need in your application, and then save the file.
| Note |
|---|
|
Do not attempt to embed a graphic directly in a resource file because controls will not read the resource string as a streamed image file. Resource files represent graphics by storing the URL of the graphic as a string. |
To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename it using one of the following patterns:
For global resource files:
name.language.resx
name.language-culture.resx
For local resource files:
pageOrControlName.extension.language.resx
pageOrControlName.extension.language-culture.resx
For example, if you create a global resource file named WebResources.resx for translation to Egyptian Arabic, name the copied file WebResources.ar-eg.resx. To create a related resource file for translation to Spanish without specifying a culture, name the copied file WebResources.es.resx. Note that for local resource files, the resource file name is the page or control name, including the file name extension, and then the language and culture information.
Open the copied file and translate each value, leaving the names (keys) the same.
Repeat steps 6 and 7 for each additional language that you want to use.
The following feature is not available with Visual Web Developer Express.
Open the page for which you want to create a resource file.
Switch to Design View.
In the Tools menu, click Generate Local Resource.
Visual Web Developer creates the App_LocalResources folder if it does not already exist. Visual Web Developer then creates the culturally neutral base resource file for the current page, which includes a key/name pair for each control property or page property that requires localization. Finally, Visual Web Developer adds a meta attribute to each ASP.NET Web server control to configure the control to use implicit localization.
Type values for each resource that you need in your application, and then save the file.
| Note |
|---|
|
Do not attempt to embed a graphic directly in a resource file because controls will not read the resource string as a streamed image file. Resource files represent graphics by storing the URL of the graphic as a string. |
If the latest resource changes are not displayed, refresh Design view by switching to Source view and then switching back to Design view.
Create resource files for additional languages by following steps 6 and 7 in the preceding procedure.
In Solution Explorer, right-click the name of the Web site, click Add New Item, and then click Assembly Resource File.
Visual Web Developer asks you if you want to place the file in the App_GlobalResources folder, and offers to create the folder.
Click Yes.
Type values for each resource that you need in your application, and then save the file.
| Note |
|---|
|
Do not attempt to embed a graphic directly in a resource file because controls will not read the resource string as a streamed image file. Resource files represent graphics by storing the URL of the graphic as a string. |
If the latest resource changes are not displayed, refresh Design view by switching to Source view and then switching back to Design view.
To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename it using one of the following patterns:
name.language.resx
name.language-culture.resx
| Note |
|---|
|
When naming resource files, do not include .aspx in the name, because this can result in a naming conflict. For example, the Resource folder cannot contain two files with names such as resTestPage.resx and resTestPage.aspx.resx. In this case, the resolution of the file names at compilation would create a naming conflict, resulting in a compile-time error. |
Submitted Jun 06 in Datatypes
This article describes how you can render the value on a page if you have created a Page Meta Type. We will be using the XSLT function to do this.
1. Go to Administration part | Data
2. Add new Page Meta type with such parameters:
Settings tab:
Name: the function should be called intuitive understanding like "Marker"
Namespace: the namespace should display function’s purpose like "Metatypes"
Fields:
Name: “MarkerValue”,
Label: “Marker Value”,
Field type: String,
String maximum length: 64 character maximum.
3. Save your Metatype.
4. Go to Administration part | Content
5. Click/right click Add Meta Data Field and add your created metatype:
Settings tab:
Marker Value: Sample Value of Marker
6. Press “Save” button
7. Go to Administration part | Functions
8. Add new XSLT function with following parameters:
Settings tab:
Name: the function should be called intuitive understanding like "MarkerRendering"
Namespace: the namespace should display function’s purpose like "Metatypes.Marker"
Description: function description
Output type: should be "XHTML"
Input Parameters
· Add new parameter “Filter”
· “Parameter type” should be Expression<Func<XXX,Boolean>> (where XXX is the name of your type)
· “Test value” should be <Your namespace> | <Data type name> | DataReferenceFilter and in Data Reference list should be selected some element
· “Default value” should be <Your namespace> | <Data type name> | ActivePageReferenceFilter or other
Function calls
· Add new function “ <Your namespace> | <Marker> | Get<Data type name>Xml”
· Click on “Filter”:
Parameter value type: should be “Execute a function call“
Complex function call: should be “Composite | Utils | GetInputParameter” with parameter name “Filter”
Template
Copy and paste code into the <body></body> tags:
|
Value of input parameter 'Marker': <xsl:value-of select="/in:inputs/in:result[@name='GetMarkerXml']/Marker/@MarkerValue" /> |
Preview
In Preview you can see filtered data.
9. Save changes
10. Edit Page
11. At content area click/right click on Insert button/link | Functions | select created functions
12. Press “OK” button
13. Save changes
Submitted Jun 04 in XSLT Solutions
1. Go to Administration part | Functions
2. Add new XSLT function with following parameters:
· Settings tab:
Name - the function should be called intuitive understanding like "DisplayMedia"
Namespace -the namespace should display function’s purpose like "Composite.Media"
Description -function description
Output type - should be "XHTML"
· Input Parameters
No parameters
· Function calls
Add new function | Composite | Data | Types | IMediaFile | GetIMediaFileXml
· Template
Copy and paste code from DisplayMedia.xsl in attachment
· Preview
In preview mode result will be displayed in HTML format
3. Press “Save” button
4. Edit Page or Template
5. At content area click/right click on Insert button/link | Functions | select created functions
6. Press “OK” button
7. Save changes
Source Code: in attachment
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl in"
xmlns:in="http://www.composite.net/ns/transformation/inpu..."
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<head>
<!-- markup placed here will be shown in the head section of the rendered page -->
</head>
<body>
<xsl:apply-templates select="/in:inputs/in:result[@name='GetIMediaFileXml']/IMediaFile[@FolderPath='/MyFolder]" />
</body>
</html>
</xsl:template>
<xsl:template match="IMediaFile[starts-with(@MimeType,'image')]">
<img alt="image" src="/Renderers/ShowMedia.ashx?i={@CompositePath}"/>
</xsl:template>
<xsl:template match="IMediaFile[@MimeType='application/x-shockwave-flash']">
<object>
<param name="movie" value="/Renderers/ShowMedia.ashx?i={@CompositePath}" />
<embed src="/Renderers/ShowMedia.ashx?i={@CompositePath}" width="550" height="400">
</embed>
</object>
</xsl:template>
</xsl:stylesheet>
Note:
1. To get files from Media archive we are using Web Handler: /Renderers/ShowMedia.ashx?i={@CompositePath} .
2. MyFolder - name of the folder with images in Media.
3. This example works only with images and flash. Supported list of MimeTypes could be extended by adding new templates.