Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:38:58+00:00 2026-06-09T06:38:58+00:00

Hi I’m currently working on a project and was wondering if it was possible

  • 0

Hi I’m currently working on a project and was wondering if it was possible to do two find functions in cakephp?
For example I am making a sports news website and I am grouping the news articles as top story, understory and headline.

What I want to do is retrive top stories so i can highlight these as the prominent story and then understory will be beneath as a lesser story and then headlines will be the least important.

This is what I have so far

   function latestnews() {

$articles =  $this->Article->find('all', 
    array('limit' =>3,
    'order' => 
        array('Article.date_created' => 'desc')));
    if(isset($this->params['requested'])) { 
         return $articles; 
         } 
            $this->set('articles', $articles); 

    $articler = $this->Article->find('all', 
        array('Article.type' => 'topstory',
            'Limit' => '1'
    )); 

        $this->set('articles', $articler);

}

however this doesn’t seem to work, it doesn’t limit the $articles function but instead echos all the data in the table.

in the view im doing a standard foreach statement to echo the data and I get thrown a undefined variable error.

Is what i am saying even possible or should I create different functions and then use them as elements?

Thanks for any input in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:38:59+00:00Added an answer on June 9, 2026 at 6:38 am

    Instead of using two find methods in one function I instead chose to simply create different functions and use them as elements for example…

    function premiershiptopstory() {
    
                $pltopnews = $this->Article->find('all', array(
                        'conditions' => array('Article.league' => 'premiership',
                        'Article.type' => 'topstory')));
                            if(!empty($this->request->params['requested'])) {
                            return $pltopnews;}
                            $this->set('article', $pltopnews);  
    
    
                }
    

    However in the view you must request the action otherwise you will get thrown an error, to request the action simply use this line of code…

     <?php $pltopnews = $this->requestAction('/Articles/premiershiptopstory');
    

    Hope this helps others!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.