Site

Creating a site

A website may be created only inside an organization. Nevertheless, the createSite method builds and assigns to the website a document space that groups every image and file.

public void server_createSite( ISiteModule siteModule, IContext context ) throws SiteModuleException {
	// site creation
	IOrganization organization = null;
	ISite site = siteModule.createSite( context, organization, "test-site" );
	
	// creation of a site by specifying the library to use
	ILibrary library = null;
	site = siteModule.createSite( context, library, "test-site" );
}

Recovering a site

The site is recovered by using its system name.

public void server_getSite( ISiteModule siteModule, IContext context ) throws SiteModuleException {
	// site recovering
	ISite site = siteModule.getSiteByName( context, "test-site" );
	System.out.println( site.getName() );
}

Deleting a site

The site may be deleted in two ways:

  • deletion of a complete site with the assigned document space;
  • deletion of the site only.
public void server_deleteSite( ISiteModule siteModule, IContext context ) throws SiteModuleException {
	// site recovering
	ISite site = siteModule.getSiteByName( context, "test-site" );

	// 1st case: definitive deletion of the complete site
	site.delete( context );

	// 2nd case: deletion of the site but keeping of the assigned document space
	site.delete( context, false );
}

Site promotion

Position information for the site promotion from a page extension

The following example shows how to position information assigned to the site promotion from the page extension class.

public boolean onBeforeLoad() {
	SEO seo = this.getExecutionContext().getPageContainer().getSEO();
	if ( seo != null ) {
		// modifying the page title
		seo.setTitle( "Kit de développement Process" );

		// positioning some "meta"
		seo.addMeta( newMeta( HTMLConstants.Meta.DESCRIPTION, "Ensemble de composants logiciel" ) );
		seo.addMeta( newMeta( HTMLConstants.Meta.KEYWORDS, "api, framework, navigation" ) );
	}
	return super.onBeforeLoad();
}

Position information for the site promotion from a plugin

The following example shows how to position information assigned to the site promotion from the controller plugin.

protected String preparePage( IPluginRequest pluginRequest, IRenderModel renderModel ) throws Exception {
	// creation of a SEO structure for the site promotion
	SEO seo = newSEO();

	// positioning the page title
	seo.setTitle( (String)renderModel.getValue( FIELD_NAME ) );

	// positioning a certain number of "meta"
	seo.addMeta( newMeta( HTMLConstants.Meta.DESCRIPTION, "Exemple d'un contrôleur de plugin" ) );
	seo.addMeta( newMeta( HTMLConstants.Meta.KEYWORDS, "file, plugin" ) );

	// storage of the SEO structure in the template
	renderModel.setValue( IRenderModel.VirtualPageMarkers.SEO, seo );

	// position of the render mask.
	return ( "content" );
}