On Sun, Jun 17, 2012 at 2:50 PM, JonStark wrote:
> Ok, almost there, just need a little help with Set::
>
> I'm using
>
> Set::extract('/Follower/UsersUser', $user)
>
> to get all the data from the association table of a given user, wich when
> debugged produces an array like this one :
>
> array(
Damn, really stuck with this, any idea ?
Many thanks !
Le jeudi 14 juin 2012 14:40:16 UTC+2, JonStark a écrit :
>
> I have a table with the following fields :
>
> id follower_id following_id
>
> So when a user clicks "follow" on an other user's profile, an entry like
> this is created :
>
> 15
Ok, almost there, just need a little help with Set::
I'm using
Set::extract('/Follower/UsersUser', $user)
to get all the data from the association table of a given user, wich when
debugged produces an array like this one :
array(
(int) 0 => array(
'UsersUser' => array(
On Sat, Jun 16, 2012 at 12:43 PM, JonStark wrote:
>
> Only need to code the "unfollow" form now I guess, wich lead me to my
> initial question I guess, how can I locate and delate the database entry ?
>
> Should look like this for example:
>
> id follower_id following_id
> X 1
Thanks a lot Ratty and cricket, couldn't have managed it without your help.
For other people looking at this, I managed it this way to prevent multiple
sessions reload, seems to work for now :
*In UsersController, in the view function :*
$followers = Set::extract('/Follower/id', $user);
$this->s
On Sat, Jun 16, 2012 at 6:44 AM, JonStark wrote:
> I tried this, it's actually clever, but there's a flaw I guess.
>
> Since the extract is done when logging in, the follow link will still appear
> for all the users you will follow after, and disappear only when re-logging
> in.
Just update each
I tried this, it's actually clever, but there's a flaw I guess.
Since the extract is done when logging in, the follow link will still
appear for all the users you will follow after, and disappear only when
re-logging in.
Le jeudi 14 juin 2012 14:40:16 UTC+2, JonStark a écrit :
>
> I have a tabl
My bad. I wrote that example without thinking about it. Yes, it would
have to be in the controller because AuthComponent isn't available in
a view, of course.
What you could do is extract the following & follower IDs in the login
action and store them in the session. That's where Auth keeps the da
OK, I figured out this should go into the controller.
But How can I use this function to alternate between two buttons follow /
unfollow *in the view *?
public function checkIfFollow() {
if (in_array(Set::extract('/Following/id', $this->Auth->user()),
$id)) {
// stop follow
} else {
//
This returned :
*Notice* (8): Undefined property: View::$Auth [*CORE/Cake/View/View.php*, line
*806*]
*Fatal error*: Call to a member function user() on a non-object in *
/app/View/Users/view.ctp* on line *41*
*
*
with ths code:
Auth->user()),
$id)) {
echo("following alread
On Thu, Jun 14, 2012 at 1:41 PM, JonStark wrote:
> From what I understand, this method extracts the ID of the followed users
> from the AUTH data right ?
I thought the array you posted was the output of $this->Auth->user()
but maybe i misread that. When a given User logs in, their data is
kept in
>From what I understand, this method extracts the ID of the followed users
from the AUTH data right ?
Can set::extract work with the array produced when finding/viewing an user ?
Le jeudi 14 juin 2012 19:31:27 UTC+2, cricket a écrit :
>
> You could extract all of the "Following" IDs.
>
> $follo
You could extract all of the "Following" IDs.
$following_ids = Set::extract('Folllowing/id', $this->Auth->user());
Or:
if (in_array(Set::extract('Folllowing/id', $this->Auth->user()),
$some_user_id) {
// already following
} else {
...
}
On Thu, Jun 14, 2012 at 10:03 AM, JonStark wrote:
>
On Thu, Jun 14, 2012 at 9:59 AM, Steve Found wrote:
> Hmmm... I'm not convinced that Cake will handle a HABTM relationship with a
> model to itself very well as the table alias will be the same name in the
> SQL it generates.
No, that's exactly the way to do it. Cake will use the alias -- not
th
To match if*
Le jeudi 14 juin 2012 14:40:16 UTC+2, JonStark a écrit :
>
> I have a table with the following fields :
>
> id follower_id following_id
>
> So when a user clicks "follow" on an other user's profile, an entry like
> this is created :
>
> 15 1 3
>
> meaning user with id 1 follows user
I was wondering if there was a way to scan the array produced when looking
at an user, in the section "Follower", to match id any ID == Auth.user.id,
since arrays are like this :
*/app/Controller/UsersController.php* (line *28*)
array(
'User' => array(
'password' => '***
Hmmm... I'm not convinced that Cake will handle a HABTM relationship
with a model to itself very well as the table alias will be the same
name in the SQL it generates.
I would try creating a class Other.php as :
class Otheruser extends AppModel {
public $name = 'Otheruser';
public $us
This is my User model :
class User extends AppModel {
> public $name = 'User';
>
> public $hasMany = 'Post';
>
> public $hasAndBelongsToMany = array(
> 'Following' => array(
> 'className' => 'User',
> 'joinTable' => 'users_users',
> 'forei
Can you post what your models look like please ?
On 14/06/12 14:00, JonStark wrote:
Assuming this is a HABTM relationship, you would just need to query the
following model then look in the follower relationship to see if the
users ID exists.
YES this is exactly what I want to achieve, but I'm
Assuming this is a HABTM relationship, you would just need to query the
following model then look in the follower relationship to see if the
users ID exists.
YES this is exactly what I want to achieve, but I'm really new to PHP/Cake,
I can't figure out how to check this.
My user array looks l
You would probably be better off checking if the entry already exists
BEFORE creating a duplicate, then deleting it ?
That way you could have a 'Follow' if the entry does not exist and an
'Unfollow' if it does exist.
Assuming this is a HABTM relationship, you would just need to query the
fol
I have a table with the following fields :
id follower_id following_id
So when a user clicks "follow" on an other user's profile, an entry like
this is created :
15 1 3
meaning user with id 1 follows user with id 3.
If user 3 follows 1, then an entry like
16 3 1
is created.
But, in orde
22 matches
Mail list logo