but i am using the same action "profile" because the index of the
books is shown on that profile... or to be more specific, in the view
"profile.ctp" i included an
"$this->element" that shows all books, that each user is following.
that is, why i am using one paginator. it happens all in one
controller, in my view/action "profile"
On Aug 24, 9:04 am, WebbedIT <p...@webbedit.co.uk> wrote:
> Tomfox,
>
> I think you're approaching this from the wrong angle.
>
> When a user is viewing their profile you're running a different action
> to when viewing the index of books. In each of these actions you would
> run different paginates/finds on the book model to find what you're
> after.
>
> /users/profile/$username: Book.user_id=>$user_id
>
> /books/index: Book.is_visible=>1
>
> HTH, Paul
>
> On Aug 23, 10:01 pm, Tomfox Wiranata <tomfox.wiran...@gmail.com>
> wrote:
>
>
>
> > hi everyone,
>
> > i have the object book with its attribute visible as boolean. i wanna
> > use pagination and it works except for one thing.
>
> > first i did two "this->paginate" in my controller. one with visible
> > condition true and the other with false. but cake doesnt like two
> > paginations in one controller.
>
> > so i just returned any book, that a user "follows", no matter if it is
> > set to visible true or false.
>
> > controller:
> > public $paginate = array('Book' => array('limit' => 1, 'joins' =>
> > array(
> > array(
> > 'table' => 'books_users',
> > 'alias' => 'BookUser',
> > 'conditions'=> array('BookUser.fk_book_id = Book.id AND
> > Book.locked = false')
> > )
> > )));
>
> > NOW in my view, i want to make the distinction. when the user is
> > visiting his own profile, non visible books are listed, since these
> > are his own. if someone visits a another profile, the non visible
> > books shall not appear.
>
> > view:
>
> > if ($user['User']['username'] == $this->Session->read('User.username'))
> > {
>
> > if ($private_books['BookUser']['BooksUser']['visible'] = 'true')
> > .......show
>
> > else
> > .......dont show
>
> > Problem: i cant access the visible field from the pagination array,
> > that looks like that
>
> > [BookUser] => Array
> > (
> > [0] => Array
> > (
> > [firstname] => test
> > [lastname] => user
> > [username] => testuser
>
> > [BooksUser] => Array
> > (
>
> > >>>>>>>>>>>>>> [visible] => 1
> > <<<<<<<<<<<<<<<<<<
> > )
>
> > )
>
> > )
>
> > }
>
> > so how can i access the visible here? I tried
>
> > if ($private_books['BookUser']['BooksUser']['visible'] = 1)
>
> > but it didnt work....
>
> > thanks :)- Hide quoted text -
>
> - Show quoted text -
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment