regionhalland / region-halland-plugin-tree-first-level
Front-end-plugin som returnerar första nivån i en sid-taxonomi
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Package info
regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhTreeFirstLevel
Type:wordpress-plugin
pkg:composer/regionhalland/region-halland-plugin-tree-first-level
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Hur man använder Region Hallands plugin "RhTreeFirstLevel"
Nedan följer instruktioner hur du kan använda pluginet "RhTreeFirstLevel".
Användningsområde
Denna plugin skapar en array() med alla sidor som har parent = 0 i en sid-taxonomi
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/RhTreeFirstLevel?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 clone https://regionhalland.visualstudio.com/public.RhWpPlugIns/_git/RhTreeFirstLevel
Läs in pluginen via composer
OBS! Justera så att du hämtar aktuell version.
"require": {
"regionhalland/region-halland-plugin-tree-first-level": "1.0.0"
},
Loopa ut "sidorna" via "Blade"
@php($first_level_pages = get_region_halland_tree_first_level())
@if(isset($first_level_pages) && !empty($first_level_pages))
@foreach($first_level_pages as $first_level_page)
@if($first_level_page->is_active == 1)
<a class="active" href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
@else
<a href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
@endif
@endforeach
@endif
@endif
Loopa ut de enklast tänkbara "sidorna" via "Blade"
- OBS! Detta skapar ingen session av vad som har klickats på
- Det finns heller inte med vilken som är aktiv
@php($first_level_pages = get_region_halland_tree_first_level_simple())
@if(isset($first_level_pages) && !empty($first_level_pages))
@foreach($first_level_pages as $first_level_page)
<a href="{{ $first_level_page->url }}">{{ $first_level_page->post_title }}</a>
@endforeach
@endif
@endif
Exempel på hur arrayen kan se ut
array (size=3)
0 =>
object(WP_Post)[8847]
public 'ID' => int 7
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2018-03-13 10:14:31' (length=19)
public 'post_date_gmt' => string '2018-03-13 10:14:31' (length=19)
public 'post_content' => string '' (length=0)
public 'post_title' => string 'Lorem Ipsum' (length=16)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'lorem-ipsum' (length=15)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2018-11-06 15:14:31' (length=19)
public 'post_modified_gmt' => string '2018-11-06 13:14:31' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://exempel.se/?page_id=7' (length=25)
public 'menu_order' => int 7
public 'post_type' => string 'page' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'url' => string 'http://exempel.se/lorem-ipsum/' (length=38)
public 'is_active' => int 1
1 =>
object(WP_Post)[8849]
public 'ID' => int 11
public 'post_author' => string '1' (length=1)
public 'post_date' => string '2018-03-13 10:15:01' (length=19)
public 'post_date_gmt' => string '2018-03-13 10:15:01' (length=19)
public 'post_content' => string '' (length=0)
public 'post_title' => string 'Aldu integer' (length=19)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'aldu-integer' (length=18)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2018-11-01 15:48:03' (length=19)
public 'post_modified_gmt' => string '2018-11-01 13:48:03' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://exempel.se/?page_id=11' (length=26)
public 'menu_order' => int 2
public 'post_type' => string 'page' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'url' => string 'http://exempel.se/aldu-integer/' (length=41)
public 'is_active' => int 0
2 =>
object(WP_Post)[8851]
public 'ID' => int 17
public 'post_author' => string '2' (length=1)
public 'post_date' => string '2018-03-13 10:15:37' (length=19)
public 'post_date_gmt' => string '2018-03-13 10:15:37' (length=19)
public 'post_content' => string '' (length=0)
public 'post_title' => string 'Aliquam eros elit' (length=21)
public 'post_excerpt' => string '' (length=0)
public 'post_status' => string 'publish' (length=7)
public 'comment_status' => string 'closed' (length=6)
public 'ping_status' => string 'closed' (length=6)
public 'post_password' => string '' (length=0)
public 'post_name' => string 'aliquam-eros-elit' (length=21)
public 'to_ping' => string '' (length=0)
public 'pinged' => string '' (length=0)
public 'post_modified' => string '2018-11-06 20:34:26' (length=19)
public 'post_modified_gmt' => string '2018-11-06 18:34:26' (length=19)
public 'post_content_filtered' => string '' (length=0)
public 'post_parent' => int 0
public 'guid' => string 'http://exempel.se/?page_id=17' (length=26)
public 'menu_order' => int 3
public 'post_type' => string 'page' (length=4)
public 'post_mime_type' => string '' (length=0)
public 'comment_count' => string '0' (length=1)
public 'filter' => string 'raw' (length=3)
public 'url' => string 'http://exempel.se/aliquam-eros-elit/' (length=44)
public 'is_active' => int 0
Versionhistorik
1.7.0
- Funktion för att använda kortnamn om det finns
1.6.0
- Lagt till pipeline för publicering på Packagist
1.5.0
- Inkluderat en funktion för att hämta ut enklast tänkbara
1.4.0
- Uppdaterat med information om licensmodell
- Bifogat fil med licensmodell
1.3.0
- Lagt till fältet is_active som returnerar 1 eller 0
- Om ingen post har is_active = 1 får den första posten is_active = 1
- Finns bakåtkompabiltet då fältet active = true fortfarande finns kvar
- Dock kan detta fält i enstaka fall returnera att ingen post har active = true
1.2.1
- Kollar om session_start redan har satts
1.2.0
- Sparar en session med ID om post_parent = 0
- Denna session jämförs sedan med ID för att sätta active
1.1.0
- Valfri sortering, default är "menu_order"
1.0.0
- Första version