[php] Shifting pages in category

Post Reply
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

I'm listing a couple of pages from each category,

Code: Select all

$categories = getCategories();
 foreach ($categories as $category) {
 ...
    foreach ($category->pages() as $pageKey) {
     $page = buildPage($pageKey);
 ...
  }
}
whats the best way to array_shift() those pages?
want to change the way first one is displayed, having issues :) Any help much appreciated.
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
diego
Site Admin
Posts: 773
Joined: Sat May 16, 2015 2:53 pm
Been thanked: 1 time
Contact:

array shift remove the element first element of the array and assign to a variable, but I don't understand what you want to do ?

Code: Select all

$categories = getCategories();
 foreach ($categories as $category) {
 
    $pagesKeyList = $category->pages();
    $firstPageKey = array_shift( $pagesKeyList );
    $firstPage = buildPage($firstPageKey);
    echo $firstPage->title();
    
    foreach ($category->pages() as $pageKey) {
     $page = buildPage($pageKey);
 ...
  }
}
	
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

thanks :) soon ill release a theme with that implemented :)
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
bayerberg
Master Bludit
Posts: 141
Joined: Wed Jun 07, 2017 1:05 pm
Location: London, UK
Has thanked: 7 times
Been thanked: 10 times
Contact:

almost there.

what do i need exactly: i need to list each category. within each category i need to display a couple of pages. i need to style the first one differently to others.

Code: Select all

$categories = getCategories();
 foreach ($categories as $category) {
    $pagesKeyList = $category->pages();
    $firstPageKey = array_shift( $pagesKeyList );
    $firstPage = buildPage($firstPageKey);
    echo $firstPage->title();
    
      foreach ($pagesKeyList as $child) {
     $page = buildPage($child);
 ...
  }
}
	
bludit plugins and themes - makeitblu | I do things, check them out on behance and dribbble.
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Post Reply