Creating and configuring viewparts


Viewparts are designed to allow you to add reusable parts to views/templates. The defined viewparts are processed in the order you define them, you can nest them, but make sure they are defined in the correct processing order. They are defined in custom/viewparts.php.

Defining a viewpart

$see->configureViewPart('viewpartname', 'controller', 'Controller');
$see->configureViewPart('viewpartname', 'controllerMethod', 'Method' );
$see->configureViewPart('viewpartname', 'controllerPassin', 'Data' );

The viewpart name must be the same as the actual viewpart, so for example, if you wanted to make 'example.php' a viewpart, 'example' would be how you define the viewpart name. All view parts are saved in custom/{theme}/view/parts.

Once you have defined the viewpart you can add  <$viewPartName> to your template, and it will be replaced by the code in view/parts/$viewPartName.php.

The viewpart can have a number of configuration options, most commonly used are:

controller - This allows a controller to be used to load some data. This always assumes this is a class with a name of {name}Controller, so to load data from a controller named MyController this configuration would be set to 'My'.

controllerMethod - This allows you to define which method of the controller to call to load data.

controllerPassin - This allows you to define data/settings to pass to the controllerMethod, only one parameter can be passed, but it can be anything so if you need to you can pass an array or object.

Content viewparts

Content viewparts are designed to allow users to add/load text on their website easily. They are defined in the viewparts similarly to the others, along with some configuration settings to add. These can then be added to the website templates, the same way the others are added, eg. <$contentArea>. You can add multiple content areas to the templates, as long as they are defined in the viewparts. They do not have to appear in numeric order within your templates. They display in page so you can then edit the website content.

$content = str_replace( "/{$this->see->rootURL}", "/", $_POST['content'] );
$see->configureViewPart('content1','contentViewPart', true);

Content areas also need to be defined within the 'contentcontainer' table in your database.