Page tree

Versions Compared

Key

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

...

In this tutorial, we will try to extend the portal functionality to not only able to view registry object from the API, but able to display our own data model, for the sake of simplicity, we'll use cars. The portal will be able to display metadata of a car based on it's model name, (for eg, going to http://localhost/wrx should give us metadata for the WRX car

...

Code Block
languagephp
$config['default_model'] = 'cars'; //instead of registry_object, this tells the portal to use the cars model to be the default model

Now, by going to http://localhost/wrx you can see Hello World, because the dispatcher applications/portal/core/controller/dispatcher.php now recognize cars@view as the default controller to view any requests

...

Now, we need to handle requests coming in from the server, http://localhost/wrx and http://localhost/jazz should construct 2 different _car model and be ready to view. 

...

Lastly, we'll generate a view to display a single car with the file car.php located at applications/portal/cars/views/car.php

Code Block
languagephp
themeDJango
languagephp
<h1><?php echo $car->make.', '.$car->model; ?></h1>
<dl>
	<dt>Make</dt><dd><?php echo $car->make; ?></dd>
	<dt>Model</dt><dd><?php echo $car->model; ?></dd>
	<dt>Cylinders</dt><dd><?php echo $car->cylinder; ?></dd>
	<dt>Engine</dt><dd><?php echo $car->engine; ?></dd>
</dl>

Now, if we go to http://localhost/wrx we should see the following HTML rendered correctly

Code Block
languagexml
themeDJango
languagexml
<h1>wrx, Subaru</h1>
<dl>
	<dt>Make</dt><dd>wrx</dd>
	<dt>Model</dt><dd>Subaru</dd>
	<dt>Cylinders</dt><dd>4</dd>
	<dt>Engine</dt><dd>4cyl 2.5L</dd>
</dl>

And the response for http://localhost/jazz should be

Code Block
languagexml
themeRDark
languagexml
<h1>jazz, Honda</h1>
<dl>
	<dt>Make</dt><dd>jazz</dd>
	<dt>Model</dt><dd>Honda</dd>
	<dt>Cylinders</dt><dd>4</dd>
	<dt>Engine</dt><dd>4cyl 1.5L</dd>
</dl>

...