Actions

BeforeCloseHtml: Difference between revisions

From LimeSurvey Manual

(Created page with "{{FeatureStarting|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 clo...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{FeatureStarting|2.60.0}}  
{{FeatureStarting|2.62.0}}  


NB: Version 2.60.0 is not the same version as 2.6. 2.6 is the new name for 2.06.
NB: Version 2.60.0 is not the same version as 2.6. 2.6 is the new name for 2.06.
Line 36: Line 36:
public function beforeCloseHtml()
public function beforeCloseHtml()
{   
{   
    $settings = $this->getPluginSettings(true);
     $event = $this->getEvent();
     $event = $this->getEvent();
     $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>');
     }
     }
}
}

Latest revision as of 15:55, 7 February 2017

 Hint: This features is available starting in version 2.62.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>');
    }
}