ok cricket,... the problem is solved ,...
I have to read from a bootstrap,.. cause my categories setup is from
bootstrap, and much easy to setup in bootstrap,...
so this is what I have,... in case anyone wonder,...
bootstrap:
Configure::write('Blog.blog_category', array('select categry',
'realestate', 'autos', 'appliances', 'antique'));
and in my conroller:
function category($id = null)
{
if($this->is_user())
{
$this->set('user_obj', $user =
$this->User->findById($this->user['id']));
}
$category = $id;
$cat_id = array_search($category,
Configure::read('Blog.blog_category'));
$this->set('category', $category);
$blogs = $this->Blog->find('all', array('conditions' =>
array('Blog.categories' => $cat_id)));
$this->set('blogs', $blogs, $this->paginate());
}
ok,... now I'm having a problem with paginator,... but that's later,... ;)
thank you for your response cricket,...
salute
chris
On Thursday, November 8, 2012 3:29:56 PM UTC-8, cricket wrote:
>
> I don't understand quite what you're trying to do (what is
> array_search for?) but there's a typo: 'select categry'
>
> Instead of hard-coding your categories, why not just get them from the
> DB? You can always write the list to cache and update it whenever the
> categories change.
>
> On Thu, Nov 8, 2012 at 4:20 PM, Chris <[email protected] <javascript:>>
> wrote:
> > hi guys,...
> > I have a problem of displaying blogs by categories,... can someone help
> me
> > please,...
> > I'm in cake 1.3
> >
> > have a categories setup in db from bootstrap:
> > Configure::write('Blog.blog_category', array('select categry',
> > 'realestate', 'autos', 'appliances', 'antique')); // etc,...
> >
> > I want to display blogs by categories, and I got to the point of reading
> > category in URL,... but can not display blogs by categories,... here is
> my
> > controller:
> >
> > function category($id = null)
> > {
> > $category = $id;
> >
> > $conditions = array(array_search('category',
> > Configure::read('Blog.blog_category') ));
> >
> > debug($conditions);
> >
> > $scope = array('Blog.id' => $conditions);
> >
> > $blogs = $this->paginate('Blog', $scope);
> >
> > $this->set('blogs', $blogs);
> >
> > }
> > on debug conditions I'm getting
> >
> > Array
> > (
> > [0] =>
> > )
> >
> >
> > thank you in advance
> >
> > --
> > Like Us on FaceBook https://www.facebook.com/CakePHP
> > Find us on Twitter http://twitter.com/CakePHP
> >
> > ---
> > You received this message because you are subscribed to the Google
> Groups
> > "CakePHP" group.
> > To post to this group, send email to [email protected]<javascript:>.
>
> > To unsubscribe from this group, send email to
> > [email protected] <javascript:>.
> > Visit this group at http://groups.google.com/group/cake-php?hl=en.
> >
> >
>
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.