Limit Hierarchical Display to Root Parent and Only Last Child

I understand ^ca_collections.hierarchy.preferred_labels.name

Is there a way to display only the top most parent and the child?

E.G. Collection --> Record Group --> Series --> Subseries1 is ^ca_collections.hierarchy.preferred_labels.name

Is there code for just Collection --> Subseries1

Thanks for any help,

Mark

Comments

  • Hi,

    Try this:

    ^ca_collections.hierarchy%maxLevelsFromTop=1 ➔ ^ca_collections.children

  • Thanks so much. A second question. I need to call the same result in ca_collections_search_subview_html.php

    How should this code be altered to do that:

                <br/><?php print $qr_results->get('ca_collections.preferred_labels.name', array('returnAsLink' => true)); ?>

             </div>

    I've tried ca_collections.hierarchy.preferred_labels.name which delivers the whole clutter of the hierarchy, but I need only the root parent, which is in this case the collection title.

    Mark

  • edited May 2

    Hi,

    Could you give which string is exactly returned in $qr_results?

    If it contains alway the same delimiter between hierarchy level, you can explode this string and extract the first term and the last term only.

    For example if:

    $qr_results->get('ca_collections.preferred_labels.name', array('returnAsLink' => true));
    

    gives the string $qr_results as "Collection 1;Sub-collection 2;Sub-sub-collection 3; Sub-sub-sub-collection 4", you can extract like this:

    $qr_results->get('ca_collections.preferred_labels.name', array('returnAsLink' => true));
    $qr_results_array=explode(";",$qr_results);
    print $qr_results_array[0]." ➔ ".end($qr_results_array);
    

    It will print:

    Collection 1 ➔ Sub-sub-sub-collection 4

  • Thanks, Darrigan, for your help. This is over my skill set, I am sad to admit. Here are two examples of the string returned from ca_collections.hierarchy .preferred_labels.name

    WIEHLE: A. Louis Wiehle Papers;Marketing Materials (1965-2015);Portfolios;Portfolio: "Works of 1953-1964" (1965)
    
    
    TALIESIN: Taliesin Architects Collection;Architectural Works;PETERS : : William Wesley Peters (1959-1992);PARK FLETCHER : : Masterplan for Park Fletcher Industrial Park and Research Center for Sam Fletcher [Indianapolis, Indiana]
    

    The double colons are spacers we use.

    I do not know enough about PHP to be able to understand how to code for just the root parent and the last child.

    You can see the issue here, as I have left up the hierarchy version: https://catalog.oadarchives.org/index.php/MultiSearch/Index?search=fletcher

    I very much appreciate your time and expertise, as it helps us communicate better with the users of our site.

    Mark

  • Hi,

    Okay, so I see your examples, and you said that the separator is ": :", right?

    But when I look this page https://catalog.oadarchives.org/index.php/Detail/collections/490 it seems that separator is ";".

    Could your give which results would you expect, for these two examples? I'll try to help you.

  • Hi,

    The next paragraph pasted an HTML tag and I can't see how to remove it, sorry.

    The four squares set equidistant has been since the 1900s a symbol in organic architectural design, which is the legacy that our archives preserves. The " : : " is a spacer between the sort term (usually a last name) and the formal full title of an architectural project. Thus, a collection reference (child) can be "WRIGHT : : Exhibition House for Frank Lloyd Wright: In The Realm of Ideas Exhibit [Japan] (1990)"

    The two colons together are part of the string in the database and not related to the hierarchy separator. This is, as you note, a semi-colon.

    The full hierarchical display for this example is:

    TALIESIN: Taliesin Architects Collection > Architectural Works > TALIESIN ARCHITECTS : : Taliesin Associated Architects (works not attributed to specific designers) > WRIGHT : : Exhibition House for Frank Lloyd Wright: In The Realm of Ideas Exhibit [Japan] (1990)

    As you see, this is way too large for the display interface in Pawtucket. What we want to show is:

    TALIESIN: Taliesin Architects Collection ➔ WRIGHT : : Exhibition House for Frank Lloyd Wright: In The Realm of Ideas Exhibit [Japan] (1990)
    

    Not to impose on your generosity, but the reason that we have the sort term (e.g. "WRIGHT") as part of the database string is because I could not figure out a way to concatenate the sort term (which is a custom meta element) and the two symbolic colons (which are spacers) with the child title. Just way over my knowledge, though I tried. I'm looking for an online course to learn PHP, but time is hard to come by.

    Your kind and thoughtful assistance helps many people who seek to access these historical materials. We are so grateful to you all who have produced this Collective Access tool, which has enabled us successfully to start getting these rare materials online. In the 1990s I was a fairly competent programmer at the university level, but those skills have long since turned to dust in the present technical environment. You and Seth have both helped us a lot, and we want you to know we are genuinely grateful for everything you've given us to work with.

    Best,

    Mark

  • Hi Mark,

    Okay, I now understand this curious ": :" ! (By the way, there exists this "four squares" symbol in mathematics in a single character ∷, instead of "colon space colon")

    So, the solutions I gave you at beginning are correct:

    ^ca_collections.hierarchy%maxLevelsFromTop=1 ➔ ^ca_collections.children

    or the equivalent php script:

    $qr_results->get('ca_collections.preferred_labels.name', array('returnAsLink' => true));
    $qr_results_array=explode(";",$qr_results);
    print $qr_results_array[0]." ➔ ".end($qr_results_array);
    

    If you try to understand this piece of PHP, the second line just separate the string $qr_results each time it find a ";" and put each part of the string in an array called $qr_results_array. The 3rd line just prints the first term of this array (index 0) with $qr_results_array[0], followed by an arrow, followed by the last term of this array thanks to the function end(...).

    The result for yours two examples should be:

    WIEHLE: A. Louis Wiehle Papers ➔ Portfolio: "Works of 1953-1964" (1965)


    TALIESIN: Taliesin Architects Collection ➔ PARK FLETCHER : : Masterplan for Park Fletcher Industrial Park and Research Center for Sam Fletcher [Indianapolis, Indiana]

    I'll answer you about the concatenation of sort term and double-colon next time.

  • edited May 3

    Hi again Mark,

    The code I gave above will not work because the get() function returns also the link toward the page...

    So we have to think more...

  • I appreciate all of this! Will wait for your guidance.

Sign In or Register to comment.