如何在不同的表中查看页面是否处于活动状态?

Some difficulties with "condition"

I have a table Tags with fields : id, name, count

I have table PagesTags with fields : id, page_id and tag_id

I have table Pages with several fields : id, name, shownmenu, onilne.

In my TagsController, I have a simple code to extract and display the Tags

function tagsList(){
    //$this->loadModel('PageTag');
    return $this->Tag->find('all',
array('order'=>'name ASC','conditions'=>array('Tag.count >= 0')));
}

The problem is, I do not want to display the tags associated to a page which is Offline.

Then in my aboce I should use somethink like $this->loadModel('PageTag'); to get the Id of the associated page and a second $this->loadModel('Page');

to get the page status 'online' (true/false)

Can we do it at once? How can I do it simply? How can I look in two table at one?

You need to use model relationships to link your models together. Read the manual about it or see my answer on this topic here: CakePHP 1.3 - Unknown column in where clause

In your case, PagesTags hasOne Page and hasMany Tags. You will write these relationships into the model. Also you will write into Tags model that it hasOne PagesTags, which will in turn retrieve the associated Page.

After you have done all of that, you don't need to call loadModel, you just query Tag and it will implicitly join the associated PagesTags and Page records, so you can just put this into your conditions:

  'Page.status !=' => 'Offline'

I think the relation of the table is HABTM so you have to look this component for searching http://bakery.cakephp.org/articles/Kumazatheef/2008/10/22/habtm-searching