0

Noob question, but trying to get all channels to show single entry by latest date on the homepage of the site. User guide says leave blank and will default to all, but no luck. I have 71 channels and doing all of them would be a real bear.

thanks in advance.

4
  • 1
    Hi! Please, update your question. Do you want to show the last entry for every one of the 71 channels? Is it?
    – Sobral
    Jun 19, 2015 at 0:50
  • 2
    Whoa. Step back a moment. 71 channels? Why? Jun 19, 2015 at 11:59
  • hi guys and thanks so much for the replies...great forum! It's really 71 template groups since their separate categories, etc. but I wanted to get the latest (possibly only from the last 12 months of entries) posts form all 71 compiled onto the homepage somehow....does that make sense?
    – fitdesign
    Jun 19, 2015 at 18:37
  • 71 Template Groups!? Generally you shouldn't have to create a template group just to separate out categories. And now I'm confused as to how many channels you have. Is it 71 channels? Or one channel with 71 categories? Jun 29, 2015 at 16:20

1 Answer 1

1

Like Michael said, 71 channels seems like alot! sounds like you wanted to categorise similar entries instead of seperating by channel! However...

Ours is not to reason why, ours is but to do and die

SO, here's your solution. I use SQL to draw the 'Maxed' entries out of the DB (grouped by channel), from this I can then populate a single exp:channel@entries loop. We need to use some PHP on the template, and it needs to be on input so we can use it to populate our entries tag :

<?php 
  //get the entry_ids for the max entry date, by channel
  $res = ee()->db->query('
    SELECT entry_id 
    FROM (
      SELECT * 
      FROM exp_channel_titles 
      ORDER BY entry_date DESC
    ) AS a 
    GROUP BY channel_id 
    ORDER BY channel_id ASC
  ');

  //concatenate the results into a string
  $eids = "";
  if ( $res->num_rows() > 0 ) {
    $eids = implode("|",$res->result_array());
  } else {
    //break the string of entry id's if we have no results
    $eids = "XX";
  }
?>

{exp:channel:entries dynamic="no" fixed_order="<?php echo $eids; ?>"}
  <h1>{title}<sup>{channel}</sup></h1>
  <a href="{url_title_path='group/template'}">permalink</a>
{/exp:channel:entries}

PHP ON on Input

Have fun!

references

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.