Jump to content
DrFux

list the children of the page parent, but not the page itself

Recommended Posts

Sorry for that messy topic title but my problem seems very complicated to describe in so few words.

So here a better description of my issue:

I have a many product detail site under a parent called /overview/. On this product detail site is at the footer a listing of all the others product detail sites including the site itself. (all children of the parent /overview/.

So i have for example:

/overview/test1/

/overview/test2/

/overview/test3/

/overview/test4/

/overview/test5/

My Code look like this at the moment: 

<?php
$overview = $pages->get("/overview/"); 
$overviewchildren = $overview->children("limit=4");

foreach($overviewchildren as $overviewchild) {?>
                
 <a href="<?=$overviewchild->url?>"><?=$overviewchild->title?></a>
                        
<?}?>

Now on the site /overview/test1/ the code list show test1, test2, test3, test4.

But i want that the child on which the user is at the moment dont show up at the list.

So for the site /overview/test2/ the list should show test1, test3, test4 and test5.

I hope you understand my problem , cause im from germany and to describe a php issue in english is very hard for me.

Thanks a lot everybody for helping me.

Share this post


Link to post
Share on other sites
$parent = $page->parent;
$current = $page->id;
$overviewchildren = $parent->children("id!=$current, limit=4");

Or maybe

$overviewchildren = $page>siblings("id!=$page, limit=4");

Edit: oh and welcome!

  • Like 4

Share this post


Link to post
Share on other sites

Thanks, i gonna test it tomorrow. Till then, a happy New year everybody :)

Edit: Thanks, i tested the second code:

$overviewchildren = $page>siblings("id!=$page, limit=4");

And it works perfectly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By EyeDentify
      Hello dear PW gurus.

      I have stumbled over a strange error that i all of sudden got when trying to upload an image to a images field on a page.
      There where images allready stored in the field that i wanted to keep, but during the upload the error apear and after that all images are gone from the field and i can´t upload any, i just get the error every time.
      I am running ProcessWire 3.0.153 dev.
      Update:
      After looking in the assets folder i find the folder for the page and the image files seems to be there including the ones i tried to upload when the error occured.
      But they don´t show up in the images field in the page editor.
       
      The error reported:
       
      SQLSTATE[01000]: Warning: 1265 Data truncated for column 'ratio' at row 1 And here is a screenshot of the event:

      The TracyDebugger Error reporting:

      I hope you fine folks could point me in a direction.
      But it seems our old pal set_time_limit() is back.

      Regards, EyeDentify
    • By Spyros
      Hello
      I'm having a strange issue with the $page->find(), for some reason I'm missing some of the pages from the results. I found then that I was missing all the pages with the same "PAGE NAME". Is it a bug or am I missing something?
      PS 
      If I change the "PAGE NAME" of one of the missing ones then I'm retrieving the page without any problem.
      Thank you
    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
      Thanks
    • By EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By Marvin
      Hello, i want to ask, i maintain a website that using a processwire and php, and i want to make an archive at my website using a subfolder system, but when i try,
      the sebfolder is show but when i click the files in that subfolder not show, and my browser just show me an error Invalid argument supplied for foreach(), i don't know why it error
      Here i attach my code and my screenshoot website :
      This is my code

      This is result of my website

      This is my error

       
       
×
×
  • Create New...