Actions

BeforeCloseHtml: Difference between revisions

From LimeSurvey Manual

No edit summary
No edit summary
Line 39: Line 39:
     $surveyId = $event->get('surveyId');
     $surveyId = $event->get('surveyId');
     if (empty($surveyId)) {
     if (empty($surveyId)) {
      // We are on survey list
        // We are on survey list
     }
     }
     else {
     else {
      // Any other front-end page
        // Any other front-end page
        $event->set('html', '<div class="only-visible-when-we-have-survey-id"></div>');
     }
     }
}
}

Revision as of 16:51, 20 January 2017

 Hint: This features is available starting in version 2.60.0


NB: Version 2.60.0 is not the same version as 2.6. 2.6 is the new name for 2.06.


When

This event is fired before the HTML document is closed.


Input

The event receives the following information:

Name Type Description
surveyId int or null surveyId will be null in front-end pages that have no survey, e.g. the survey list.


Possible output

The following information can be set in the event:

Name Type Description
html string HTML that will be put last in the document.


Example

public function beforeCloseHtml()
{   
    $event = $this->getEvent();
    $surveyId = $event->get('surveyId');
    if (empty($surveyId)) {
        // We are on survey list
    }
    else {
        // Any other front-end page
        $event->set('html', '<div class="only-visible-when-we-have-survey-id"></div>');
    }
}