Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Each view has a unique name

  • Each view has a view folder named after the view's name, containing certain files

  • These view folders are in {application folder}/views

  • Custom view folders are in {customization folder}/views

  • Each view folder has a PHP file named view.html.php containing a view class (ConfigboxView{view name} extending KenedoView)

  • Each view folder has a sub folder called 'tmpl' with a template file

...

Assume a view called 'example' in the customization folder:

{customization folder}/views/example/view.html.php
{customization folder}/views/example/tmpl/default.php

...

Assume a view called 'example'. File location {customization folder}/views/example/view.html.php

Code Block
languagephp
class ConfigboxViewExample extends KenedoView {
	
	/**
	* @var string[] 
	*/
	var $dataForMyTemplate;


	function prepareTemplateVars() {
		$this->dataForMyTemplate = array('so', 'much', 'to', 'show');
	}

}

(template file in {customization folder}/views/example/tmpl/default.php)

...

Location of controller files: {customization folder}/controllers/{controller name}.php (in our example 'example.php')

Code Block
languagephp
class ConfigboxControllerExample extends KenedoController {
	
	/**
 	* @return NULL
 	*/
	protected function getDefaultModel() {
		return NULL;
	}


	/**
	 * @return ConfigboxViewExample
	 */
	protected function getDefaultView() {
		return KenedoView::getView('ConfigboxViewExample');
	}


	/**
	 * @return NULL
	 */
	protected function getDefaultViewList() {
		return NULL;
	}

	/**
	 * @return NULL
	 */
	protected function getDefaultViewForm() {
		return NULL;
	}

}

(controller file in {customization folder}/controllers/example.php)

...

Code Block
languagephp
$view = KenedoView::getView('ConfigboxViewExample');
return $view->getHtml();

...

Load custom stylesheets

KenedoViews control which style sheets the platform will load. Mind that CB loads a stylesheet for customizations on any page that shows a KenedoView - best use this one when it fits your needsdepending on your use-case you can add another.

Determining which stylesheets to load is up to the KenedoViews rendered on the page. To control this, you override the method getStyleSheetUrls(). This method returns the full URLs to the stylesheets needed for this view (and this view only).

...

  • Always return the parent function's URLs along with your URLs

  • No need to worry about duplications (e.g. in case of multiple views rendered). The framework filters out duplicates.

  • If you use minified CSS, put the original and minified version on the site and return the non-minified version of the stylesheet. The framework will look for a .min.css file and use it instead.

  • See about cache invalidation for these stylesheets.

  • Use KenedoPlatform::p()->getUrlCustomizationAssets() to get the URL to the customization assets folder.

  • In case a separate stylesheet is overkill for your use-case, use the custom.css stylesheet instead.

...

Load JS modules

...

and execute

...

init functions

KenedoView’s also control which JS to load. It is done by using AMD modules, managed by require.js. Learn how to take advantage of this in this article.