Get value from <perch:related>

  • Hi


    I'm wondering if it's possible to get value from <perch:related>


    Example:

    I have a collection called "Collection 1", inside of it i have an "Item 1", and inside of if i have a <perch:related> that grabs data from "Collection 2"


    And now i want to output this from "Item 1" from "Collection 1"


    I have this code:

    PHP
    1. <?php
    2. perch_collection(['Collection 1'], [
    3. 'template' => '/views/output.html',
    4. ]);
    5. ?>

    And the output is:

    Code
    1. 1;Item 1;4;5


    And here is output.html

    Code
    1. <perch:content id="_id" type="text">;<perch:content id="collection_col1_name" type="text">;<perch:content id="collection_col2_brands" type="text">;<perch:content id="collection_col3_sizes" type="text">


    And here is the template for "Collection 1"


    So i need to get value from the <perch:related> tags


    Is there anyway to output the value from each collection??


    Need help with this one, hope someone can help me.


    Thanks

  • drewm

    Approved the thread.
  • Hi


    the output is:

    1;Item 1;4;5

    (i only get the ids from realted collections)


    I want to get values like this:

    1;Item 1;Value from collection 2;Value from collection 3

    (i want to get the name/value from realted collection)



    I have tag attribute like this

    Code
    1. <perch:content id="collection_2" type="text">

    and the output is only the id, i want the name value


    Is this possible?

  • So where you have this:


    Code
    1. <perch:related id="collection_col2_brands" collection="Collection 2" label="col2">
    2. <perch:content id="collection_col2_brand">
    3. </perch:related>

    That should be this:

    Code
    1. <perch:related id="collection_col2_brands" collection="Collection 2" label="col2">
    2. <perch:content id="collection_2" type="text">
    3. </perch:related>
  • I still get only the id


    I'd strongly suggest giving your collections and fields logical names before going much further - the way everything is named is extremely confusing.

    I have, just changed the fileds name when posting here :) (customer wants it like this)