regionhalland/region-halland-plugin-parent-page-and-siblings-with-current-childs

Front-end-plugin som returnerar förälder-sida + alla syskon + barn för aktuell sida

v1.3.0 2020-11-03 12:44 UTC

This package is auto-updated.

Last update: 2024-04-29 04:46:35 UTC


README

Hur man använder Region Hallands plugin "RhParentPageAndSiblingsWithCurrentChilds"

Nedan följer instruktioner hur du kan använda pluginet "RhParentPageAndSiblingsWithCurrentChilds".

Användningsområde

Denna plugin skapar en array() med förälder-sida + alla syskon + barn för aktuell sida

Licensmodell

Denna plugin använder licensmodell GPL-3.0. Du kan läsa mer om denna licensmodell via den medföljande filen:

LICENSE (https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhParentPageAndSiblingsWithCurrentChilds?path=%2FLICENSE&version=GBmaster)

Installation och aktivering

A) Hämta pluginen via Git eller läs in det med Composer
B) Installera Region Hallands plugin i Wordpress plugin folder
C) Aktivera pluginet inifrån Wordpress admin

Hämta hem pluginet via Git

git https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhParentPageAndSiblingsWithCurrentChilds

Läs in pluginen via composer

Dessa två delar behöver du lägga in i din composer-fil

Repositories = var pluginen är lagrad, i detta fall på github

"repositories": [
  {
    "type": "vcs",
    "url": "https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhParentPageAndSiblingsWithCurrentChilds"
  },
],

Require = anger vilken version av pluginen du vill använda, i detta fall version 1.0.0

OBS! Justera så att du hämtar aktuell version.

"require": {
  "regionhalland/region-halland-plugin-parent-page-and-siblings-with-current-childs": "1.0.0"
},

Loopa ut sidorna via "Blade"

@if(function_exists('get_region_halland_parent_page_and_siblings_with_current_childs'))
    @php($myPages = get_region_halland_parent_page_and_siblings_with_current_childs())
    @if(isset($myPages))
        <a href="{{ $myPages['parent']['parent_url'] }}">
            {{ $myPages['parent']['parent_title'] }}
        </a><br>
        @if (!empty($myPages['siblings']))
            @foreach ($myPages['siblings'] as $mySiblings)
                @if($mySiblings['sibling_active'] == 1)
                    <a href="{{ $mySiblings['sibling_url'] }}">
                        <strong>{{ $mySiblings['sibling_title'] }}</strong>
                    </a><br>
                @else
                    <a href="{{ $mySiblings['sibling_url'] }}">
                        {{ $mySiblings['sibling_title'] }}
                    </a><br>
                @endif
                @if($mySiblings['sibling_active'] == 1)
                    @if($mySiblings['sibling_childs_count'] != 0)
                        @foreach ($mySiblings['sibling_childs'] as $myChilds)
                            <a href="{{ $myChilds['child_url'] }}">
                                {{ $myChilds['child_title'] }}
                            </a><br>
                        @endforeach
                    @endif
                @endif
            @endforeach
        @endif
    @endif
@endif

Notera att funktionen kan kallas med "true" parametern för att endast hämta ut data på undersidor och ej på toppnivå.

Exempel på hur arrayen kan se ut

array (size=2)
  'parent' => 
    array (size=2)
      'parent_title' => string 'Smittskydd' (length=10)
      'parent_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/' (length=55)
  'siblings' => 
    array (size=9)
      0 => 
        array (size=6)
          'sibling_id' => int 4633
          'sibling_title' => string 'Strama' (length=6)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/strama/' (length=62)
          'sibling_active' => int 1
          'sibling_childs_count' => int 1
          'sibling_childs' => 
            array (size=1)
              0 => 
                array (size=2)
                  'child_title' => string 'Informationsmaterial Strama' (length=27)
                  'child_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/strama/bvc-stramautbildning/' (length=83)
          'sibling_page_type' => string 'page' (length=4)
      1 => 
        array (size=6)
          'sibling_id' => int 11992
          'sibling_title' => string 'corona' (length=6)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/corona/' (length=62)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)
      2 => 
        array (size=6)
          'sibling_id' => int 4717
          'sibling_title' => string 'Tuberkulos' (length=10)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/tuberkulos/' (length=66)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'section' (length=6)
      3 => 
        array (size=6)
          'sibling_id' => int 4478
          'sibling_title' => string 'Vad är det som går?' (length=21)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/vad-ar-det-som-gar/' (length=74)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)
      4 => 
        array (size=6)
          'sibling_id' => int 4745
          'sibling_title' => string 'Vaccinationer' (length=13)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/vaccinationer/' (length=69)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)
      5 => 
        array (size=6)
          'sibling_id' => int 4499
          'sibling_title' => string 'Anmälningspliktiga sjukdomar' (length=29)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/anmalningspliktiga-sjukdomar/' (length=84)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)
      6 => 
        array (size=6)
          'sibling_id' => int 4512
          'sibling_title' => string 'Faktablad och PM' (length=16)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/faktablad-och-pm/' (length=72)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)
      7 => 
        array (size=6)
          'sibling_id' => int 4583
          'sibling_title' => string 'Influensa och influensavaccination' (length=34)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/influensa-och-influensavaccination/' (length=90)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'section' (length=6)
      8 => 
        array (size=6)
          'sibling_id' => int 70
          'sibling_title' => string 'Kontaktuppgifter smittskydd' (length=27)
          'sibling_url' => string 'http://dev-vardgivare.local/behandlingsstod/smittskydd/kontaktuppgifter-smittskydd/' (length=83)
          'sibling_active' => int 0
          'sibling_childs_count' => int 0
          'sibling_childs' => string '' (length=0)
          'sibling_page_type' => string 'page' (length=4)

Versionhistorik

1.3.0

  • Lagt till page-type

1.2.0

  • Lagt till en parameter för att inte returnera data på sidor utan parents

1.1.0

  • Lagt till pipeline för publicering via Packagist

1.0.0

  • Första version