PhpOffice\PhpPresentation\PhpPresentation::setActiveSlideIndex PHP Method

setActiveSlideIndex() public method

Set active slide index
public setActiveSlideIndex ( integer $index ) : Slide
$index integer Active slide index
return Slide
    public function setActiveSlideIndex($index = 0)
    {
        if ($index > count($this->slideCollection) - 1) {
            throw new \Exception("Active slide index is out of bounds.");
        } else {
            $this->activeSlideIndex = $index;
        }
        return $this->getActiveSlide();
    }

Usage Example

 /**
  * Read Slide
  *
  * @param \DOMElement $nodeSlide
  */
 protected function loadSlide(\DOMElement $nodeSlide)
 {
     // Core
     $this->oPhpPresentation->createSlide();
     $this->oPhpPresentation->setActiveSlideIndex($this->oPhpPresentation->getSlideCount() - 1);
     if ($nodeSlide->hasAttribute('draw:name')) {
         $this->oPhpPresentation->getActiveSlide()->setName($nodeSlide->getAttribute('draw:name'));
     }
     if ($nodeSlide->hasAttribute('draw:style-name')) {
         $keyStyle = $nodeSlide->getAttribute('draw:style-name');
         if (isset($this->arrayStyles[$keyStyle])) {
             $this->oPhpPresentation->getActiveSlide()->setBackground($this->arrayStyles[$keyStyle]['background']);
         }
     }
     foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) {
         if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
             $this->loadShapeDrawing($oNodeFrame);
             continue;
         }
         if ($this->oXMLReader->getElement('draw:text-box', $oNodeFrame)) {
             $this->loadShapeRichText($oNodeFrame);
             continue;
         }
     }
     return true;
 }
All Usage Examples Of PhpOffice\PhpPresentation\PhpPresentation::setActiveSlideIndex