ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

help displaying a "no results" message

June 08, 2011 12:45am

Subscribe [2]
  • #1 / Jun 08, 2011 12:45am

    Jacobmiso

    51 posts

    Hi, I could use a hand displaying either a simple no results page or message.
    Just a conditional that says “sorry etc..” would be fine.

    I’ve got everything up and running very smoothly; with some great assistance here in the forums as well as a Lot of trial and error. I’ve been reading a lot about the different ways of doing this but I have had no success.

    Any help would be greatly appreciated.

    Here’s a link to my actual page

    http://epgcaribbean.ehclients.com/index.php/main/sales_main


    Here’s the code that filters the results:

    <form method=“post” action=”{path=“main/_sales_main”}”>

    Property Type

    <select name=“search:property_type”>
      <option value=”“>—-—</option>
      <option value=“detached”>Detached House</option>
      <option value=“townhouse”>Townhouse</option>
      <option value=“apartment”>Apartment</option>
      <option value=“condominium”>Condominium</option>
      <option value=“commercial”>Commercial</option>
      <option value=“land”>Land</option>
    </select>

    Location

    <select name=“search:db_location”>
    <option value=”“>—-—</option>
    <option value=“West Coast”>West Coast</option>
    <option value=“South Coast”>South Coast</option>
    <option value=“Country Location”>Country Location</option>
    <option value=“Beachfront”>Beachfront</option>
    </select>

    Bedrooms

    <select name=“search:property-beds”>
    <option value=”“>—-—</option>
    <option value=“1”>1</option>
    <option value=“2”>2</option>
    <option value=“3”>3</option>
    <option value=“4”>4</option>
    <option value=“5”>5</option>
    <option value=“6”>6</option>
    <option value=“7+”>7+</option>
    </select>

    Price Range

    <select name=“search:price_range”>
    <option value=”“>—US $—</option>
    <option value=“100K-500K”>100,000-500,000</option>
    <option value=“500K-1MIL”>500,000-1,000,000</option>
    <option value=“1MIL-2MIL”>1,000,000-2,000,000</option>
    <option value=“2MIL-4MIL”>2,000,000-4,000,000</option>
    <option value=“4MIL-6MIL”>4,000,000 - 6,000,000</option>
    <option value=“6MIL PLUS”>6,000,000 +</option>
    </select>

    <input type=“submit” value=“SUBMIT” /></p>
    </form>

    And here’‘s the code for the results page.

    {exp:channel:entries channel=“listings” limit=“10” dynamic_parameters=“search:property-beds|search:db_location|search:price_range|search:property_type”}

    {exp:channel:entries channel=“listings” sort=“asc” limit=“15” disable=“member_data|trackbacks” paginate=“bottom”}
     
    <!—{entry_date format=’%F %d, %Y’} —>

    {photo1}
     
    <td>{title}</td>

    {exp:eehive_hacksaw words=“30” allow=”<b>”}
     
    {main_desc} {/exp:eehive_hacksaw}...More Info

     
    {paginate}
    {if “{total_pages}” != 1}

    Page {current_page} of {total_pages} pages {pagination_links}{/if}
    {/paginate} 
         
       
    {/exp:channel:entries}

  • #2 / Jun 08, 2011 12:59am

    Rob Allen

    3114 posts

    You only need one channel:entries tags 😊

    You can use the no_results variable inside the channel entries tags to display a message…

    {exp:channel:entries channel=“listings” limit=“10” dynamic_parameters=“search:property-beds|search:db_location|search:price_range|search:property_type”}
    
    Normal variables here…
    
    {if no_results}
    Sorry nothing found
    {/if}
    
    {/exp:channel:entries}
  • #3 / Jun 08, 2011 1:21am

    Jacobmiso

    51 posts

    Wow.
    That was quick thank, you so much.

    The page itself references 3 separate channels actually. It seemed the easiest was to manage the backend with residential, commercial and land.
    But yes, I see how I had a lot of extra messy (useless) code in there 😊
    It works great Now.

    One more thing if you don’t mind:

    I have the sort order as a default set up like this:

    {exp:channel:entries channel="listings" limit="10" sort="asc" dynamic_parameters="search:property-beds|search:db_location|search:price_range|search:property_type"}

    What I need it to do is to list by lowest price to highest. The property values are just a stored in a custom field.
    How do I make that work?

    Many thanks again.

    c.

  • #4 / Jun 08, 2011 2:06am

    Jacobmiso

    51 posts

    Blue
    Thanks for your time this evening. I solved my other issue too.

    The sortby problem was an EE 2x thing with integers vs. numbers and when I changed the price fields it erased the data in the corresponding channel entries….

    So I just used a hidden integer field and another text one for display.
    All is well.

  • #5 / Jun 08, 2011 7:21am

    Rob Allen

    3114 posts

    You beat me to it! Glad you got it sorted.

  • #6 / Jun 08, 2011 7:32am

    Jacobmiso

    51 posts

    Thanks Blue.
    Look forward to talking again.

    Regards

  • #7 / Jun 08, 2011 8:27am

    Sue Crocker

    26054 posts

    Thanks for the assist, Rob.

    Jacommiso - If anything else comes up, please do let us know in a new thread..

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases