We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29201
    • 239 Posts
    I need my users to view a list of real estate properties (addressess) in a multi-select TV, select several of these, and then use the unique id of each property to display what will be the "featured listings" on the home page.

    I can get values from the database into my TV but it’s all on one line....can someone tell me how to properly delineate these?

    Here’s what I have so far:

    1. A TV call "GetProperties" that is a Listbox (Multi-Select) with an input option value of @EVAL return $modx->runSnippet(’PropertyListbox’);
    it looks like this: http://cl.ly/163I0r38113z3G0L3X0U

    2. A Snippet called PropertyListbox that looks like this:
    <?php
    $output = '';//create variable for holding the output
    $sql = $modx->db->query( 'SELECT * FROM `mls_listings` LIMIT 0, 500');//define the DB query, in this case the table is named 'tblprojects', add WHERE AND etc. as needed
    $resultArray = $modx->db->makeArray( $sql );//put it into an array
    foreach($resultArray as $item)//go through each record in the array
    {//start looping through the data array
    $params['housenumber']=$item['C_HHouseNumber'];//set the placeholders, the $params sets the name of the placeholder, the $item is the column name from the DB table
    $params['streetname']=$item['C_StreetName'];
    $params['streettype']=$item['C_StreetType'];
    $params['uniqueID']=$item['C_Matrix_Unique_ID'];
    $output.=$modx->parseChunk('ProjectTpl', $params, '[+', '+]');//define the chunk name and process the content, here it's ProjectTpl which has the placeholders for the data
    }//finish looping through the data array
    return $output;//now return the output from the processed chunk
    ?>
    



    3. A Chunk "ProjectTpl" that looks like this:
    [+housenumber+] [+streetname+] [+streettype+][+uniqueID+]II


    Note that I was trying to use the II to get all of the values displaying properly in the resource TV but no luck. Can someone see where I’m going wrong?

    ....and finally my brain is fuzzy on how I’m going to pass the uniqueID to the homepage for processing.

    Thanks for taking the time to read this.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would use @SELECT for the TV, then use a custom snippet to process the TV’s output on the front-end. This snippet is where the query to fetch the other values (based on the values returned by the TV) and format their display goes.

      Oh, and by the way, that should be a double pipe || (usually to the right of the keyboard, upper case backslash \) not II. With the correct delimiter, your way might work, I don’t know.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 29201
        • 239 Posts
        aaaargh typos!

        Thank you Susan the || got the formatting right. Now I’ve got a TV that looks like good:

        http://cl.ly/0s3Z2E183K2w2o08023w

        however I need I’m thinking I need the unique ID of the property to output the featured properties on the homepage. However the unique ID doesn’t mean anything to the user.

        Any advice on displaying something meaningly to the user and passing the value I need?