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.

Select entries by a custom channel field

March 07, 2012 4:53am

Subscribe [3]
  • #1 / Mar 07, 2012 4:53am

    Origin Media

    20 posts

    Is it possible to select entires based on a custom channel field e.g. where product_original_price!=”“

    {exp:channel:entries channel="products" category="1" status="open" orderby="product_price|title" sort="asc|asc" paginate="both" limit="9" product_original_price!=""}

    I want to query products to only show products that meet certain criteria such as if they have been discounted or are between a price range.

    I got this working to a point by doing the check after i had selected the entries using the channel entries tag. e.g. if product_original_price!=”” then show the product. However, this messed up the pagination.

    {exp:channel:entries channel="products" category="1" status="open" orderby="product_price|title" sort="asc|asc" paginate="both" limit="9"}
    
      {if product_original_price && product_original_price > product_price}
      <div class="{switch="product|product|product_right"}">
       <a href="http://{site_url}{segment_1}/{url_title}" title="{title}">{product_thumbnail}</a>
       {title}
       <span class="price">{product_price}</span>
    
       <div class="was">Was: {product_original_price}</div>
      </div>
      {/if}
      
      {paginate}
      <div ></div><!-- END clear -->
      <div class="product_bar">
       Page {current_page} of {total_pages}   
    
       {pagination_links}
    
                      {previous_page}
                              <a href="http://{pagination_url}" class="page-previous">< Prev</a>   
        {/previous_page}
    
        {first_page}
         <a href="http://{pagination_url}" class="page-first">1</a>
        {/first_page}
    
        {page}
         <a href="http://{pagination_url}" class="page-{pagination_page_number}">{pagination_page_number}</a>
        {/page}
    
        {last_page}
         <a href="http://{pagination_url}" class="page-first">{total_pages}</a>
        {/last_page}
    
        {next_page}
            <a href="http://{pagination_url}" class="page-next">Next ></a>
        {/next_page}
    
    
       {/pagination_links}
    
          
    
       <a href="http://{site_url}{segment_1}/all" title="Show all products" class="view_all">View All</a>
    
      </div><!-- END .product_bar-->
      {/paginate}
    
      {/exp:channel:entries}

    If this is not possible with the channel entries tag is there another way to achieve this, maybe with SQL?

  • #2 / Mar 07, 2012 8:24am

    Boyink!

    5011 posts

  • #3 / Mar 08, 2012 11:23am

    Shane Eckert

    7174 posts

    Hello,

    Thank you for your question.

    It is possible to select entires based on a custom channel field and you will want to use the link that Mike posted in above. Check the full section for “Contains” Matching which should get you on your way.

    Please let me know if there is anything I can do to help.

    Cheers,

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

ExpressionEngine News!

#eecms, #events, #releases