Okay i spoken with KK about a follow button on my website however i just cant get my head around it. I'm really struggling to get the concept correct and get things working.
Okay i'm currently creating a social side to my website where it allows content to be uploaded onto my website. Everything is going well via the databound forms and of course the new release of the members module. However when it comes to a more complex relation side i just cant make any headway.
What i'm looking to do.
Like on twitter a member can follow another member. Facebook has the pages ''like'' button. When you follow a user or like a page the content shows on your newsfeed. I want to create the same type of thing, follow. Allowing a member thats registered to follow another member. When you follow this member it'll show their content within the newsfeed page.
Users can post data onto our website with a databound form. The user can submit thease.
Cloneable page with a databound form
- status update.
- Article post.
- Product post.
- Photo upload.
Now to fetch and save the users submission to connect their profile i have set this within each of the databound forms above.
author=k_member_title
linkprofile=k_member_id
The members module has a page called ''index.php'' page. So that's where each user is created.
I'm unsure if to user the k_member_id within the code or what. where this code should be or where it shouldnt.
this is the code that KK pointed me towards.
Okay i'm currently creating a social side to my website where it allows content to be uploaded onto my website. Everything is going well via the databound forms and of course the new release of the members module. However when it comes to a more complex relation side i just cant make any headway.
What i'm looking to do.
Like on twitter a member can follow another member. Facebook has the pages ''like'' button. When you follow a user or like a page the content shows on your newsfeed. I want to create the same type of thing, follow. Allowing a member thats registered to follow another member. When you follow this member it'll show their content within the newsfeed page.
Users can post data onto our website with a databound form. The user can submit thease.
Cloneable page with a databound form
- status update.
- Article post.
- Product post.
- Photo upload.
Now to fetch and save the users submission to connect their profile i have set this within each of the databound forms above.
author=k_member_title
linkprofile=k_member_id
The members module has a page called ''index.php'' page. So that's where each user is created.
I'm unsure if to user the k_member_id within the code or what. where this code should be or where it shouldnt.
this is the code that KK pointed me towards.
- Code: Select all
<cms:if k_is_page>
<!-- save the id of the current product in a variable -->
<cms:set my_current_product=k_page_id 'global' />
<!-- get the list of ids of products related to this user -->
<cms:pages masterpage='users.php' id=my_user_id limit='1'>
<cms:set my_related_products="<cms:related_pages 'user_products' ids_only='1' />" 'global' />
</cms:pages>
<!-- use PHP to manipulate the list got above to include/exclude current page (i.e. product) -->
<cms:php>
global $CTX;
$my_current_product = $CTX->get( 'my_current_product', 'global' );
$my_related_products = $CTX->get( 'my_related_products', 'global' );
// is the current product (the page we are on) in the list of related products?
$arr_products = explode( ',', $my_related_products );
$key = array_search( $my_current_product, $arr_products );
if( $key !== false ){
// product already related.. remove it from list
unset( $arr_products[$key] );
$CTX->set( 'is_already_related', '1', 'global' );
}
else{
// not yet related.. add product to list
$arr_products[] = $my_current_product;
$CTX->set( 'is_already_related', '0', 'global' );
}
// set the revised list of ids in context
$my_related_products = trim( implode(',', $arr_products) );
$CTX->set( 'my_related_products', $my_related_products, 'global' );
</cms:php>
<!-- use databound form to persist the new list of related pages -->
<cms:form masterpage='users.php' mode='edit' page_id=my_user_id method='post' anchor='0'>
<cms:if k_success >
<cms:db_persist_form
user_products=my_related_products
/>
<cms:redirect k_page_link />
</cms:if>
<cms:if is_already_related >
<cms:input name="submit" type="submit" value="Remove product from my list" />
<cms:else />
<cms:input name="submit" type="submit" value="Add product to my list" />
</cms:if>
</cms:form>
</cms:if>