Design Guide - Selected Vehicle

Show selected vehicle in template files

Example 1:

The vehicle object returned by the getFit() method implements a PHP magic method, allowing it to be treated a string or an object. To display the name of a vehicle, simply echo the object.

 
// Showing products for your: 2009 Honda Civic
$vehicleSelection = VF_Singleton::getInstance()->vehicleSelection();
if( !$vehicleSelection->isEmpty() )
{
    $vehicle = $vehicleSelection->getFirstVehicle();
    echo 'Showing products for your: ';
    echo $this->htmlEscape($vehicle); // 2009 Honda Civic
}
Example 2:

You can fetch each 'level' of the vehicle separately, and form your own custom formats.

 
// Showing products for your: 2009 Honda Civic
$vehicleSelection = VF_Singleton::getInstance()->vehicleSelection();
if( !$vehicleSelection->isEmpty() )
{
    $vehicle = $vehicleSelection->getFirstVehicle();
    echo 'Showing products for your: ';
    echo $this->htmlEscape($vehicle->getLevel('year')->getTitle());  // 2009
    echo ' ';
    echo $this->htmlEscape($vehicle->getLevel('make')->getTitle());  // Honda
    echo ' ';
    echo $this->htmlEscape($vehicle->getLevel('model')->getTitle());  // Civic
}