Status Updates
Status Updates is the module for ExpressionEngine 2 that allows site users to post status messages in their profile. They can also crosspost them to their social network accounts (requires Social Login PRO)
↑Posting status message
{exp:status_updates:form}
<textarea name="message_text"></textarea>
<input type="submit" value="Send" />
{/exp:status_updates:form}
Crossposting to social networks is possible only if you have Social Login PRO installed and the user has ever logged in (or performed account association) using that module
Tag parameters:
- return — a page to return after posting update. Can be a full URL or URI segments.
Use return="SAME_PAGE" to return user to the page used to display form. - id — form ID (defaults to 'status_updates_form')
- class — form class (defaults to 'status_updates_form')
- name — form name (defaults to 'status_updates_form')
- ajax="yes" — process form in AJAX mode (will return data as JSON array)
- maxlength — maximum allowed length of message to be posted (defaults to 760 characters)
- twitter="yes" — force crossposting to Twitter (if possible for logged in user)
- facebook="yes" — force crossposting to Facebook (if possible for logged in user)
- linkedin="yes" — force crossposting to LinkedIn (if possible for logged in user)
Form fields:
- message_text — text of status message. Required
- checkbox name="twitter" value="yes" — when checked, crosspost to Twitter will be made (if possible)
- checkbox name="facebook" value="yes" — when checked, crosspost to Facebook will be made (if possible)
- checkbox name="linkedin" value="yes" — when checked, crosspost to LinkedIn will be made (if possible)
Variables:
- maxlength — value of maxlength parameter
You can use {providers} tag pair to display list of available social networks to crosspost. It displays only those networks that are associated with current user's account.
Inside of {providers} tag pair following variables are availabe:
- {provider_name} — provider name. This is 'technical' variable, should be used as name for checkboxes.
- {provider_title} — the 'full' name/title of service provider/social network
- {provider_icon} — URL for image/button for corresponding provider (from the icons set defined in Social Login Pro settings)
Upon form submission, the user is taked to return page (no success message is shown), or is shown error message if there has been an error.
If you've specified ajax="yes" parameter then both error and success messages are returned in JSON format. Examples:
{ "result": "error"; "text" : "You need to be logged in" }
{ "result": "success"; "text" : "This is my status update!"; "date" : }
↑Displaying status updates feed
This tag allows you to display status updates feed - by logged in user, or certain user, user group or even everyone.
{exp:status_updates:display paginate="both" limit="10"}
{paginate}{pagination_links}{/paginate}
<p>{count}. <em>{message_date format="%Y-%m-%d %H:%i"}</em>
{message_text}
<p>
{/exp:status_updates:display}
Tag parameters(all optional):
- member_id — ID of member to display feed. If omited, will display feed for logged in user. member_id="ALL" will display updates from all users
- username — alternatively, provide username to display status updates for
- group_id — display messages from all members in certain group
- sort — sorting order. Can be "asc" (ascending) or "desc" (descending - default)
- limit — number of codes per page, if you want to use pagination
- paginate — place to display pagination links. Can be 'top', 'bottom' or 'both'. Defaults to 'bottom'
- disable="pagination" — disable pagination completely. Useful if you use pagination URL marker for something else, or want to display onlt last N messages.
- backspace="X" — remove X last characters from tag output result
Single variables:
- total_updates — total number of updates
- total_results — total number of updates displayed on page
- count — invites counter on each page
- absolute_count — invites counter throughout all pages
- message_text — text of status update
- message_date format="%Y-%m-%d" — the date when status has been posted. Standard EE date formatting rules apply.
Variable pairs:
{paginate}{/paginate} — used to format and display pagination links (if you have limit parameter set and there's more than one page)
- pagination_links — the actual pagination links
Adavaced pagination (like with channel entries) using {pagination_links}{/pagination_links} tag pair is also possible
↑Examples
Posting form with posting to social networks and remaining characters counter
{exp:jquery:script_tag}
<script type="text/javascript" src="http://www.intoeetive.com/themes/third_party/social_update/jquery.maxlength.min.js"></script>
<link type="text/css" src="http://www.intoeetive.com/themes/third_party/social_update/jquery.maxlength.css" rel="stylesheet" />
{exp:status_updates:form return="SAME_PAGE"}
<script type="text/javascript">
$(document).ready(function(){
$('#message_text').maxlength({
max: {maxlength},
truncate: true,
showFeedback: true,
feedbackTarget: '#maxlength',
feedbackText: '{r}'
});
});
</script>
<p>Enter your message, {maxlength} characters max, <span id="maxlength">{maxlength}</span> characters left</p>
<p><textarea name="message_text" id="message_text" style="width: 350px; height: 100px;"></textarea></p>
{providers}
<input type="checkbox" name="{provider_name}" value="yes" /> Post to {provider_title}<br />
{/providers}
<p><input type="submit" value="Send" /></p>
{/exp:status_updates:form}
Status messages page with AJAX form
{exp:jquery:script_tag}
<script type="text/javascript">
$(document).ready(function(){
$('#status_updates_form').live('submit', function(event){
event.preventDefault();
$('#error_container').hide();
$('#loader').show();
$('#submit_button').parent().hide();
$.post(
'/',
$('#status_updates_form').serialize(),
function(msg) {
var obj = $.parseJSON(msg);
if (obj.status=='error')
{
$('#error_container').text(obj.text);
$('#error_container').show();
}
else
{
var toclone = $('.status_message').first();
var cloned = toclone.clone();
cloned.find('.message_text').text(obj.text);
var msgdate = new Date(1000*obj.date);
cloned.find('.message_date').text(msgdate.getFullYear()+'-'+msgdate.getMonth()+'-'+msgdate.getDate()+' '+msgdate.getHours()+':'+msgdate.getMinutes());
cloned.prependTo(toclone);
$('#message_text').val('');
}
$('#loader').hide();
$('#submit_button').parent().show();
}
);
});
});
</script>
<div>
{exp:status_updates:display paginate="top" limit="10"}
{paginate}
{pagination_links}
<ul>
{first_page}
<li><a href="{pagination_url}" class="page-first">First Page</a></li>
{/first_page}
{previous_page}
<li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">Next Page</a></li>
{/next_page}
{last_page}
<li><a href="{pagination_url}" class="page-last">Last Page</a></li>
{/last_page}
</ul>
{/pagination_links}
{/paginate}
<div class="status_message">
<p><em class="message_date">{message_date format="%Y-%m-%d %H:%i"}</em><p>
<div class="message_text">{message_text}</div>
</div>
{/exp:status_updates:display}
</div>
{exp:status_updates:form ajax="yes"}
<p id="error_container" style="color: red; display: none;"></p>
<p><textarea name="message_text" id="message_text" style="width: 350px; height: 100px;"></textarea></p>
<p><input type="submit" id="submit_button" value="Send" /></p>
<p id="loader" style="display: none">please wait...</p>
{/exp:status_updates:form}