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.

Search module show_future_entries for particular channel

March 16, 2012 9:00am

Subscribe [1]
  • #1 / Mar 16, 2012 9:00am

    GDmac - expocom

    350 posts

    Hello EE-support.
    I’m building an advanced search form and have a support question.
    For the news_channel i don’t want to show_future_entries=“yes”, but
    for the event_channel i need to show_future_entries=“yes”.

    Is it possible to set per-channel options, like show_future_entries=”” and status=”“
    Or how can i accomplish the above.

  • #2 / Mar 16, 2012 7:48pm

    Sean C. Smith

    3818 posts

    Hi GDmac - expocom,

    I’m sorry but that is not possible with ExpressionEngine out of the box. Have you looked at Super Search or Low Search as altenatives? I haven’t used them myself, but by all accounts they are excellent additions to the EE search arsenal.

    Sean

  • #3 / Mar 20, 2012 6:17am

    GDmac - expocom

    350 posts

    In the past i used “Search Results” by planet-ee.com. Which basically just enhances the displaying of the internal EE search-results. I’m very tempted to tryout Low-Search on an upcoming project , as it uses “MySQL’s native full-text functions” to find possible relevant entries as well.

    I’ve added / modified the core-search module to support searching for future entries in certain channels. Here are the modifications i made to the search-module, if you don’t mind me sharing them.

    Allow show_future_entries for certain channels:
    show_future_entries=“no”
    future_entry_channels=“2|3”

    // /system/modules/search/mod.search.php
    // around line 336, add a new parameter
    'future_entry_channels' => $this->EE->TMPL->fetch_param('future_entry_channels',''),
    
    // around line 643, under /** We only select entries that have not expired 
    // change the entire block to use the new parameter
    
      /** ----------------------------------------------
      /**  We only select entries that have not expired 
      /** ----------------------------------------------*/
     
      if ( ! isset($this->_meta['show_future_entries']) OR $this->_meta['show_future_entries'] != 'yes')
      {
    
       // future entries for some channels, like event-channels
       $future_entry_channels = $this->_meta['future_entry_channels'];
    
       if(empty($future_entry_channels))
       {
        // regular show_future_entries="no"
        $sql .= "\nAND exp_channel_titles.entry_date < ".$this->EE->localize->now." ";
       }
       else
       {
        // allow some channels to have future entries
        $future_entry_channels = explode('|', $future_entry_channels);
        
        $sql .= "\nAND (exp_channel_titles.entry_date < ".$this->EE->localize->now." OR exp_channel_titles.channel_id IN(".implode(',', $future_entry_channels).") ) ";
       }
      }
      
      if ( ! isset($this->_meta['show_expired']) OR $this->_meta['show_expired'] != 'yes')
      {
       $sql .= "\nAND (exp_channel_titles.expiration_date = 0 OR exp_channel_titles.expiration_date > ".$this->EE->localize->now.") ";
      }
    
      /** ----------------------------------------------
  • #4 / Mar 21, 2012 7:33pm

    Sean C. Smith

    3818 posts

    Hi GDmac - expocom,

    Sharing your modification here is fine, though we don’t encourage hacking the core files nor are we able to support this for anyone who does use it.

    Thanks for posting that up.

    Sean

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

ExpressionEngine News!

#eecms, #events, #releases