Collection::getByHandle($c); reason why on part of the code

Permalink
Good Day Everyone,

I there anyone who could give me an answer to the following question?
Below there is a piece of code straight from the models/collection.php file. It says
"if ($row['cID'] > 0) { //&& $row['pcID'] == null) {"
What is the reason of the last check $row['pcID'] == null. Why do we want to make sure it's empty? What does it matter if the pcID also exists? If yes, what are those limitations or problems I'll run into eventually. I realy can't think of any, but modifications im doing to the core script require me to be able to get a collection by its handle when also the page exists.

Thanks in advance.

Full part from line 657 v.5.5.2.1 models/collection.php:
} else {
            $row = $r->fetchRow();
            if ($row['cID'] > 0) && $row['pcID'] == null) {         
               // there is a collection, but it is not a page. so we grab it
               $cObj = Collection::getByID($row['cID']);
            }
         }

 
jordanlev replied on at Permalink Reply
jordanlev
If you read further up in that code, you'll see that the SQL query populating the $row data is checking both the Collections table and the Pages table. In Concrete5, the concept of a "collection" is 99% the same as a "page" (a page is a "collection of blocks"). But there is 1% of situations where a collection is actually different from a page. What is the difference? I don't know, and I've never gotten a clear answer from Andrew (the lead C5 developer). I'm guessing there's some kind of system pages or low-level functionality that utilizes collections but isn't a page (maybe the old-school scrapbooks? I dunno).

All that being said, I think you're looking in the wrong place. What you probably want to be calling is Page::getByPath (not Collection::getByHandle). I searched the codebase for calls to Collection::getByHandle, and couldn't find any, so I'm guessing that method is deprecated (and unfortunately not documented as such -- tsk tsk).

If you care to explain what it is you're trying to achieve, someone might be able to give you a better answer. If not though, then I'd just steer clear of the Collection model entirely and stick to the Page model.
Twoez replied on at Permalink Reply
Thanks for your quick response. I've used the function within the Page model getByPath, just like you mentioned.

I actually thought that Pages and Collections were the same, that's why I didn't understood why it was scripted like that. Although I would still like to see an example (by the devs probably) which makes it clear that Pages are different from Collections.

Thanks for now.
jordanlev replied on at Permalink Reply
jordanlev
You and me both :)