We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29754
    • 1 Posts
    hi!

    I’m currently developing one snippet that will choose a chunk and than insert it in template.
    I need this because there will be like 5 or 6 different positions of content. positions will be defined in chunks

    I would like to do something like this:

    $position1 = array( 0 => "document1", 1 => "document2", 2 => "document3", 3 => "document4", 4 => "document5", 5 => "document6" ...);
    $position2 = array( 0 => "doc1", 1 => "doc2", 2 => "doc3", 3 => "doc4", 4 => "doc5", 5 => "doc6" ...);
    $position3 = array( 0 => "d1", 1 => "d2", 2 => "d3", 3 => "d4", 4 => "d5", 5 => "d6" ...);
    // document 1-6, doc 1-6, d 1-6 --> these are just some documents

    then i would like to check if currently open document is in one of those 3 arrays, this part is easy

    for ($i=0; $i<=3; $i++){
    if (in_array($modx->documentObject[’pagetitle’], $position$i){
    chose one chunk
    }}

    But if currently open document is not inside of any of those three arrays i would like
    to check his parent and parent’s parent if neither his parent is in one of arrays.
    But here’s a problem. I have no idea how to get names of all parents, i know how to get
    ids from all parents:

    $documentID= $modx->documentIdentifier;
    $parents= array_values($modx->getParentIds($documentID));

    Can someone please tell me how to get names (pagetitles) of all parents

    thank you
    tHEORYx