Jump to content

Create a simple friend requests page


Alex69

Recommended Posts

Hello,

 

can someone share the code to show up in the deafult KVS theme the page with list of friendhsip requests ? I need something simple but i would extract friendship requests from the default conversatio nstyle

i see that KVS support this only is not provided any code example and no idea from where i could start, i think if KVS tema wil lshare to all this example will be something usefull to learn better KVS working.

 

 

Thanks

 

 

Link to comment
Share on other sites

This can be displayed using list_messages block. First you need to insert a block on the page:

{{insert name="getBlock" block_id="list_messages" block_name="My Invites"}}

Then you need to open this block for editing and modify its folder parameter to display only invites. Then it will only filter invites. However the main issue is with template, but I guess you can take the template from the existing theme list_messages block and adopt it as needed:

https://kvs-demo.com/admin/project_pages.php?action=change_block&item_id=member_profile_my||list_messages||my_conversation_messages&item_name=My Conversation Messages

Link to comment
Share on other sites

Hello, i followed your istruction and i'm at a ded point because without any real example is absolutly impossible to make the theme working..

 

THis is my code, hope you can help me to fix the issue:

 

<div id="{{$block_uid}}">
	<div class="headline">
		<h2>
			<a href="{{$lang.urls.memberzone_my_profile}}">{{$lang.memberzone.profile_my_title}}</a> /
			{{assign var="profile_url" value=$lang.urls.memberzone_profile|replace:"%ID%":$conversation_user_id|replace:"%LOGIN%":$conversation_username}}
			{{$lang.memberzone.profile_my_friendship_requests}}{{if $nav.page_now>1}}{{$lang.common_list.paginated_postfix|replace:"%1%":$nav.page_now}}{{/if}}
		</h2>

		<div class="sort">
			<span class="icon type-edit"></span>
			<strong>{{$lang.memberzone.messages_action_edit}}</strong>
			<ul>
				<li><a href="#delete" data-action="delete_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_delete_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_delete|replace:"%1%":$conversation_display_name}}</a></li>
				<li><a href="#block" data-action="ignore_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_ignore_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_ignore|replace:"%1%":$conversation_display_name}}</a></li>
			</ul>
		</div>
	</div>

	<div class="box">
		<div class="list-messages">
			<div class="margin-fix" id="{{$block_uid}}_items" data-append-to-beginning="true">
				{{if count($data)>0}}
					{{assign var="pagination_use_load_more" value="false"}}
					{{include file="include_pagination_block_common.tpl"}}

					{{assign var="grouping_user_id" value=0}}
					{{foreach name=data item=item from=$data|@array_reverse}}
						<div {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}data-autoscroll="true"{{/if}} class="item {{if $item.user_id!=$smarty.session.user_id}}me{{/if}} {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}new{{/if}} {{if $item.type_id==0 && $item.message==''}}deleted{{/if}} {{if $item.user_from_id==$grouping_user_id}}grouped{{/if}}" data-message-id="{{$item.message_id}}">
							{{if $item.user_id==$smarty.session.user_id}}
								<div class="image">
									<a href="{{$lang.urls.memberzone_profile|replace:"%ID%":$item.user_from_id|replace:"%LOGIN%":$conversation_username}}">
										{{if $conversation_avatar_url!=''}}
											<img src="{{$conversation_avatar_url}}" alt="{{$conversation_display_name}}"/>
										{{else}}
											<span class="no-thumb {{if $conversation_gender_id==1}}male{{elseif $conversation_gender_id==2}}female{{elseif $conversation_gender_id==3}}couple{{elseif $conversation_gender_id==4}}trans{{/if}}"></span>
										{{/if}}
									</a>
								</div>
							{{/if}}
							<div class="added {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}editable{{/if}}" {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}data-edit-message-id="{{$item.message_id}}"{{/if}}>
								{{$item.added_date|date_format:$lang.global.date_format}}
								{{if $item.user_id!=$smarty.session.user_id}}
									{{if $item.is_read==0}}
										{{$lang.memberzone.messages_unread}}
									{{/if}}
								{{/if}}
							</div>
							<div class="message-text">
								{{if $item.type_id==0}}
									{{if $item.message!=''}}
										<span class="original-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{else}}
										{{$lang.memberzone.messages_deleted}}
									{{/if}}
								{{else}}
									{{if $item.user_id==$smarty.session.user_id}}
										{{$lang.memberzone.messages_system_types_received[$item.type_id]|replace:"%1%":$conversation_display_name|replace:"%2%":$smarty.session.display_name}}
									{{else}}
										{{$lang.memberzone.messages_system_types_sent[$item.type_id]|replace:"%1%":$smarty.session.display_name|replace:"%2%":$conversation_display_name}}
									{{/if}}
									{{if $item.message!=''}}
										<span class="inline-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{/if}}
									{{if $item.type_id==1 && $item.user_id==$smarty.session.user_id}}
										<form method="post" data-form="ajax">
											<div class="bottom">
												<input type="hidden" name="action" value="confirm_add_to_friends"/>
												<input type="hidden" name="message_from_user_id" value="{{$conversation_user_id}}"/>
												<input type="hidden" name="function" value="get_block"/>
												<input type="hidden" name="block_id" value="{{$block_uid}}"/>
												<input type="submit" class="submit" name="confirm" value="{{$lang.memberzone.btn_confirm}}"/>
												<input type="submit" class="submit" name="reject" value="{{$lang.memberzone.btn_reject}}"/>
											</div>
										</form>
									{{/if}}
								{{/if}}
							</div>
						</div>
						{{assign var="grouping_user_id" value=$item.user_from_id}}
					{{/foreach}}
				{{else}}
					<div class="empty-content">{{$lang.memberzone.messages_no_data}}</div>
				{{/if}}
			</div>
		</div>
	</div>
</div>

 

 

Right now i see list of friendship requests but i'm unable to:

 

1) show the avatar of user sent me the request

2) show his username

3) show his member profile page url

4) make working button ACCEPTS / REFUSE

 

What i see is a list of elements like i nthenshot attached plus a show more button, the show more button is working and load more requests, but requests cant be accepted or refused

 

Please help thanks !

 

 

Screenshot_3.png

Edited by Alex69
forgot image
Link to comment
Share on other sites

Ok i found the solution, this is the code that works now , i mean now i can display avatares, and i can press ACCEPT REFUSE and is working:

 

<div id="{{$block_uid}}">
	<div class="headline">
		<h2>
			<a href="{{$lang.urls.memberzone_my_profile}}">{{$lang.memberzone.profile_my_title}}</a> /
			{{assign var="profile_url" value=$lang.urls.memberzone_profile|replace:"%ID%":$conversation_user_id|replace:"%LOGIN%":$conversation_username}}
			{{$lang.memberzone.profile_my_friendship_requests}}{{if $nav.page_now>1}}{{$lang.common_list.paginated_postfix|replace:"%1%":$nav.page_now}}{{/if}}
		</h2>

		<div class="sort">
			<span class="icon type-edit"></span>
			<strong>{{$lang.memberzone.messages_action_edit}}</strong>
			<ul>
				<li><a href="#delete" data-action="delete_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_delete_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_delete|replace:"%1%":$conversation_display_name}}</a></li>
				<li><a href="#block" data-action="ignore_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_ignore_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_ignore|replace:"%1%":$conversation_display_name}}</a></li>
			</ul>
		</div>
	</div>

	<div class="box">
		<div class="list-messages">
			<div class="margin-fix" id="{{$block_uid}}_items" data-append-to-beginning="true">
				{{if count($data)>0}}
					{{assign var="pagination_use_load_more" value="false"}}
					{{include file="include_pagination_block_common.tpl"}}

					{{assign var="grouping_user_id" value=0}}
					{{foreach name=data item=item from=$data}}
						<div {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}data-autoscroll="true"{{/if}} class="item {{if $item.user_id!=$smarty.session.user_id}}me{{/if}} {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}new{{/if}} {{if $item.type_id==0 && $item.message==''}}deleted{{/if}} {{if $item.user_from_id==$grouping_user_id}}grouped{{/if}}" data-message-id="{{$item.message_id}}">
							{{if $item.user_id==$smarty.session.user_id}}
								<div class="image">
									<a href="{{$lang.urls.memberzone_profile|replace:"%ID%":$item.user_from_id|replace:"%LOGIN%":$item.user_from_display_name}}">
										{{if $item.user_from_avatar_url!=''}}
											<img src="{{$item.user_from_avatar_url}}" alt="{{$item.user_from_display_name}}"/>
										{{else}}
											<span class="no-thumb {{if $conversation_gender_id==1}}male{{elseif $conversation_gender_id==2}}female{{elseif $conversation_gender_id==3}}couple{{elseif $conversation_gender_id==4}}trans{{/if}}"></span>
										{{/if}}
									</a>
								</div>
							{{/if}}
							<div class="added {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}editable{{/if}}" {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}data-edit-message-id="{{$item.message_id}}"{{/if}}>
								{{$item.added_date|date_format:$lang.global.date_format}}
								{{if $item.user_id!=$smarty.session.user_id}}
									{{if $item.is_read==0}}
										{{$lang.memberzone.messages_unread}}
									{{/if}}
								{{/if}}
							</div>
							<div class="message-text">
								{{if $item.type_id==0}}
									{{if $item.message!=''}}
										<span class="original-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{else}}
										{{$lang.memberzone.messages_deleted}}
									{{/if}}
								{{else}}
									{{if $item.user_id==$smarty.session.user_id}}
										{{$lang.memberzone.messages_system_types_received[$item.type_id]|replace:"%1%":$item.user_from_name|replace:"%2%":$smarty.session.display_name}}
									{{else}}
										{{$lang.memberzone.messages_system_types_sent[$item.type_id]|replace:"%1%":$smarty.session.display_name|replace:"%2%":$conversation_display_name}}
									{{/if}}
									{{if $item.message!=''}}
										<span class="inline-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{/if}}
									{{if $item.type_id==1 && $item.user_id==$smarty.session.user_id}}
										<form method="post" data-form="ajax">
											<div class="bottom">
												<input type="hidden" name="action" value="confirm_add_to_friends"/>
												<input type="hidden" name="message_from_user_id" value="{{$item.user_from_id}}"/>
												<input type="hidden" name="function" value="get_block"/>
												<input type="hidden" name="block_id" value="{{$block_uid}}"/>
												<input type="submit" class="submit" name="confirm" value="{{$lang.memberzone.btn_confirm}}"/>
												<input type="submit" class="submit" name="reject" value="{{$lang.memberzone.btn_reject}}"/>
											</div>
										</form>
									{{/if}}
								{{/if}}
							</div>
						</div>
						{{assign var="grouping_user_id" value=$item.user_from_id}}
					{{/foreach}}
				{{else}}
					<div class="empty-content">{{$lang.memberzone.messages_no_data}}</div>
				{{/if}}
			</div>
		</div>
	</div>
</div>

 

 

My next question is how can i do to HIDE with a fading effect the ACCEPTED or REFUSED friendhsip request ? right now after pressign ACCEPT or REFUSE the request remain in the list till next page refresh ? Can you give me an idea how to do this ?

Link to comment
Share on other sites

Any help ? I think such things is not absolutly banal if the only one way to do things like this is to try to do a reverse enginnerring operation. 

There is no any documentation ? 

 

In total what i need is to remove with ajavx the elment or simply to reload by ajax the list, like it happen with pagination that every time we click it reload the full page content we shoud reload the current page content 

 

HOW TO DO ?

 

Tahnks

Link to comment
Share on other sites

12 hours ago, Alex69 said:

Ok i found the solution, this is the code that works now , i mean now i can display avatares, and i can press ACCEPT REFUSE and is working:

 

<div id="{{$block_uid}}">
	<div class="headline">
		<h2>
			<a href="{{$lang.urls.memberzone_my_profile}}">{{$lang.memberzone.profile_my_title}}</a> /
			{{assign var="profile_url" value=$lang.urls.memberzone_profile|replace:"%ID%":$conversation_user_id|replace:"%LOGIN%":$conversation_username}}
			{{$lang.memberzone.profile_my_friendship_requests}}{{if $nav.page_now>1}}{{$lang.common_list.paginated_postfix|replace:"%1%":$nav.page_now}}{{/if}}
		</h2>

		<div class="sort">
			<span class="icon type-edit"></span>
			<strong>{{$lang.memberzone.messages_action_edit}}</strong>
			<ul>
				<li><a href="#delete" data-action="delete_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_delete_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_delete|replace:"%1%":$conversation_display_name}}</a></li>
				<li><a href="#block" data-action="ignore_conversation" data-user-id="{{$conversation_user_id}}" data-block-id="{{$block_uid}}" data-confirm="{{$lang.memberzone.messages_action_edit_ignore_confirm|replace:"%1%":$conversation_display_name}}">{{$lang.memberzone.messages_action_edit_ignore|replace:"%1%":$conversation_display_name}}</a></li>
			</ul>
		</div>
	</div>

	<div class="box">
		<div class="list-messages">
			<div class="margin-fix" id="{{$block_uid}}_items" data-append-to-beginning="true">
				{{if count($data)>0}}
					{{assign var="pagination_use_load_more" value="false"}}
					{{include file="include_pagination_block_common.tpl"}}

					{{assign var="grouping_user_id" value=0}}
					{{foreach name=data item=item from=$data}}
						<div {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}data-autoscroll="true"{{/if}} class="item {{if $item.user_id!=$smarty.session.user_id}}me{{/if}} {{if $item.user_id==$smarty.session.user_id && $item.is_read==0}}new{{/if}} {{if $item.type_id==0 && $item.message==''}}deleted{{/if}} {{if $item.user_from_id==$grouping_user_id}}grouped{{/if}}" data-message-id="{{$item.message_id}}">
							{{if $item.user_id==$smarty.session.user_id}}
								<div class="image">
									<a href="{{$lang.urls.memberzone_profile|replace:"%ID%":$item.user_from_id|replace:"%LOGIN%":$item.user_from_display_name}}">
										{{if $item.user_from_avatar_url!=''}}
											<img src="{{$item.user_from_avatar_url}}" alt="{{$item.user_from_display_name}}"/>
										{{else}}
											<span class="no-thumb {{if $conversation_gender_id==1}}male{{elseif $conversation_gender_id==2}}female{{elseif $conversation_gender_id==3}}couple{{elseif $conversation_gender_id==4}}trans{{/if}}"></span>
										{{/if}}
									</a>
								</div>
							{{/if}}
							<div class="added {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}editable{{/if}}" {{if $item.user_id!=$smarty.session.user_id && $item.type_id==0 && $item.message!='' && $nav.is_first==1}}data-edit-message-id="{{$item.message_id}}"{{/if}}>
								{{$item.added_date|date_format:$lang.global.date_format}}
								{{if $item.user_id!=$smarty.session.user_id}}
									{{if $item.is_read==0}}
										{{$lang.memberzone.messages_unread}}
									{{/if}}
								{{/if}}
							</div>
							<div class="message-text">
								{{if $item.type_id==0}}
									{{if $item.message!=''}}
										<span class="original-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{else}}
										{{$lang.memberzone.messages_deleted}}
									{{/if}}
								{{else}}
									{{if $item.user_id==$smarty.session.user_id}}
										{{$lang.memberzone.messages_system_types_received[$item.type_id]|replace:"%1%":$item.user_from_name|replace:"%2%":$smarty.session.display_name}}
									{{else}}
										{{$lang.memberzone.messages_system_types_sent[$item.type_id]|replace:"%1%":$smarty.session.display_name|replace:"%2%":$conversation_display_name}}
									{{/if}}
									{{if $item.message!=''}}
										<span class="inline-text">{{if $lang.enable_smileys=='true'}}{{$item.message|bbcode|replace:"\n":"<br>"}}{{else}}{{$item.message|replace:"\n":"<br>"}}{{/if}}</span>
									{{/if}}
									{{if $item.type_id==1 && $item.user_id==$smarty.session.user_id}}
										<form method="post" data-form="ajax">
											<div class="bottom">
												<input type="hidden" name="action" value="confirm_add_to_friends"/>
												<input type="hidden" name="message_from_user_id" value="{{$item.user_from_id}}"/>
												<input type="hidden" name="function" value="get_block"/>
												<input type="hidden" name="block_id" value="{{$block_uid}}"/>
												<input type="submit" class="submit" name="confirm" value="{{$lang.memberzone.btn_confirm}}"/>
												<input type="submit" class="submit" name="reject" value="{{$lang.memberzone.btn_reject}}"/>
											</div>
										</form>
									{{/if}}
								{{/if}}
							</div>
						</div>
						{{assign var="grouping_user_id" value=$item.user_from_id}}
					{{/foreach}}
				{{else}}
					<div class="empty-content">{{$lang.memberzone.messages_no_data}}</div>
				{{/if}}
			</div>
		</div>
	</div>
</div>

 

 

My next question is how can i do to HIDE with a fading effect the ACCEPTED or REFUSED friendhsip request ? right now after pressign ACCEPT or REFUSE the request remain in the list till next page refresh ? Can you give me an idea how to do this ?

Same, I also need this, not only hide fading effect but also Subscribe button or Unsubscribe button after click on it, it didn't change its value, like from "Subscribe" to "Subscribed" or "Unsubscribe" to "Subscribe" value after user clicked

Link to comment
Share on other sites

22 hours ago, Alex69 said:

My next question is how can i do to HIDE with a fading effect the ACCEPTED or REFUSED friendhsip request ? right now after pressign ACCEPT or REFUSE the request remain in the list till next page refresh ? Can you give me an idea how to do this ?

I think not possible to hide because there is common JS code that works to handle the form and it doesn't have this functionality. However in our case when we render this code and click either accept or deny - the page gets refreshed automatically and the request goes away. Looks like a working solution. If you say in your case it doesn't refresh automatically, then please create support ticket and provide all the details, we will take a look.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...