JQuery/Accordion

Section 1

Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.

Section 2

Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.

Section 3

Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.

Source

<?php
    $options = [];
    $Accordion = new Barebone\jQuery\UI\Accordion($options);
    $Accordion->addSection('Section 1', '<p>
        Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
        ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
        amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
        odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
        </p>');
        
    $Accordion->addSection('Section 2', '<p>
        Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
        ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
        amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
        odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
        </p>');
        
    $Accordion->addSection('Section 3', '<p>
        Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
        ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
        amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
        odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
        </p>');
    $this->view->accordion = $Accordion;

1. Setting Up Options and Creating the Accordion:

$options = [];
$Accordion = new Barebone\jQuery\UI\Accordion($options);
  • An empty array $options is created, potentially to hold configuration options for the accordion.
  • A new object $Accordion is instantiated from the class Barebone\jQuery\UI\Accordion.

2. Adding Sections to the Accordion:

$Accordion->addSection('Section 1', '<p>...'); // Repeated for sections 2 and 3
  • The code calls a method addSection on the $Accordion object three times.
  • Each call takes two arguments:
    • The first argument is a string, likely representing the title of the accordion section (e.g., "Section 1").
    • The second argument is a string containing HTML content that will be displayed within the section when it's expanded. The content includes a paragraph with identical text for all sections.

3. Assigning the Accordion to the View:

$this->view->accordion = $Accordion;
  • This line assigns the created $Accordion object to a variable named accordion within the view property. This makes the accordion accessible for rendering in the view.

Overall, the code snippet demonstrates creating an accordion component in pure php with three sections using the Barebone framework and jQuery UI. The content of each section is currently identical.

  • Barebone\jQuery\UI\Accordion

    Barebone\jQuery\UI\Accordion extends Barebone\HTML\TElement
    • [P] $_id : mixed
    • [P] $sections : mixed
    • [P] $options : mixed
    • [M] __construct( $options ) : void
    • [M] addSection( $caption, $content ) : void
    • [M] __toString() : string
    • Barebone\HTML\TElement

      Barebone\HTML\TElement
      • [P] $tag : string
      • [P] $innertext : string
      • [P] $children : array
      • [P] $attributes : array
      • [P] $non_closing_tags : mixed
      • [M] __construct( string $tag, array $attributes ) : void
      • [M] append( Barebone\HTML\TElement $element ) : void
      • [M] prepend( Barebone\HTML\TElement $element ) : void
      • [M] class_exists( $cssclass ) : void
      • [M] add_class( $cssclass ) : void
      • [M] remove_class( $cssclass ) : void
      • [M] innertext( string $value ) : void
      • [M] data( string $name, string $value ) : void
      • [M] aria( string $name, string $value ) : void
      • [M] on( string $event, string $callback ) : void
      • [M] css( string $identifier, string $rule ) : void
      • [M] wrap( string $tagname, array $attributes ) : void
      • [M] enable() : void
      • [M] disable() : void
      • [M] has_closing_tag() : void
      • [M] has_children() : void
      • [M] count_children() : void
      • [M] get_children() : void
      • [M] replace_child( $key, $new_child ) : void
      • [M] get_child( $key ) : void
      • [M] __unset( $name ) : void
      • [M] __isset( $name ) : void
      • [M] __set( $name, $value ) : void
      • [M] __get( $name ) : void
      • [M] render() : void
      • [M] __toString() : string
      • [M] editable() : void