kunzite (kunzite1) wrote in component_help,
kunzite
kunzite1
component_help

  • Mood:

text message component

This tutorial is now obsolete and deprecated and several other similar words because LJ has made it very close to impossible to use custom forms for things like sending Text Messages, Inbox Messages and having custom Update forms. this code doesnt do exactly what i want it to, but, it works. if someone could alter it so that it does this that would be cool.
pseudocode:
if( (registered users only) AND (viewer not logged in) ){ print login box } else { start logic of which modes to print based upon chosen variables }
##################################
#      TEXT MESSAGE COMPONENT    #
# kunzite1, component-help/71138 #
# add to print_free_text(Page p) #
##########################################################################
# Text message component                                                 #
# by kunzite1                                                            #
##########################################################################
# set to 1 if you want it to send messages to only you                   #
  var int exclusive = 0;                                                 #
                                                                         #
# title of component if $exclusive is 1                                  #
  var string exclusiveTitle = "text message me";                         #
                                                                         #
# title of component if $exclusive is 0                                  #
  var string regularTitle = "text message thingy";                       #
                                                                         #
# set to 1 if you want only logged in users to send you text messages    #
  var int registered = 0;                                                #
##########################################################################
# TEXT MESSAGE THINGY START #
#############################
  var bool flagOK = true;
if($exclusive){
  print_comp_header("$exclusiveTitle");
} else {
  print_comp_header("$regularTitle");
}
  """
<center>
<form name="frmMsg" method="post" action="$*SITEROOT/tools/textmessage.bml">
<table border="0">
  """;
if($exclusive){
  """
<tr><td colspan="2"><input type="hidden" name="user" value="$p.journal.username" /></td></tr>
  """;
} else {
  """
<tr><td><b>to:</b></td><td><input type="text" size="15" name="user" /></td></tr>
  """;
}
if($registered){
  if(viewer_logged_in()){
      """
    <tr><td colspan="2"><input type="hidden" name="from" /></td></tr>
      """;
  } else {
    $flagOK = false;
      """
    <tr><td colspan="2"><a href="$*SITEROOT/login.bml">login</a></td></tr>
      """;
  }
} else {
  if(viewer_logged_in()){
      """
    <tr><td colspan="2"><input type="hidden" name="from" /></td></tr>
      """;
  } else {
      """
    <tr><td><b>from:</b></td><td><input type="text" size="15" name="from" /></td></tr>
      """;
  }
}
if($flagOK){
  """
<tr><td><b>message:</b></td><td> </td></tr>
<tr><td colspan="2"><textarea name="message" maxlength="100" rows="3" cols="20"></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="send text message!" /></td></tr>
  """;
}
  """
</table>
</form>
</center>
  """;
print_comp_footer();
###########################
# TEXT MESSAGE THINGY END #
###########################
Tags: admin: deprecated, user: kunzite1
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 11 comments