Full Update Page (More Query Handling)

Jan 04, 2004 12:42

During my fit of insomnia last night, I decided that I wanted to cull my collection of components, but I wanted to keep the functionality- specifically the update component. Which is huge and takes up a fantastic amount of space, and is kinda hard to use being a sidebar component. So I decided to create a full-update page in my journal style.


We accomplish this by overriding the print_my_entries function.

function print_my_entries(Page p, string title) {

var flatbox f = new flatbox; #This tutorial requires the flatbox class..
#if you remove any lines referring to $f it'll work, but be ugly.
if ($p.args{"mode"} == "update") {
####################################################################################
#Begin update component #
####################################################################################
if(true) {

########################
# USER SETTINGS

# set this to your time zone difference
var int time_difference = -5; #this one you'll have to change

# Set to true for commmunity journal, false for personal journal
var bool community = false;

# Set to true to show all features of the full update page.
var bool show_all = true;

# Set to true to show the date options, false otherwise.
var bool show_date = false;

# set this to the header of the component
var string update_title = "Update"; #this isn't used anymore

#No need to change these values, unless you want to have it default to someone elses username.
# set this to the journal you want it to post to
var string defaultjournal = "$p.journal.username";

#set this to the default username you want displayed
var string defaultuser = "$p.journal.username";

#########################
# DON'T need to mess with anything below (until we reach the end of the update component)

var int year = $p.time.year;
var int day = $p.time.day;
var int hour = $p.time.hour + $time_difference;
var int month = $p.time.month;

# figure out days in month
var int mondays = 31;
if($month == 4 or $month == 6 or $month == 9 or $month == 11) {
$mondays = 30;
} elseif($month == 2) {
$mondays = ($year % 4 == 0) ? 29 : 28;
}

if($hour > 24) { # if your timezone is the day after system...
$hour = $hour - 24; # figure out new hour value
$day = $day + 1; # make sure to change day value
if($day > $mondays) { # if your day is in the next month...
$day = $day - $mondays; # figure out the new day
$month = $month + 1; # change the month value
if($month > 12) { # if your month is in the next year...
$month = 1; # change the month value and
$year = $year + 1; # change the year value
}
}
} elseif($hour < 0) { # otherwise, if your day is the day before...
$hour = 24 + $hour; # change the hour and
$day = $day - 1; # change the day value
if($day < 1) { # if that puts you in the previous month...
$month = $month - 1; # decrement the month value
if($month < 1) { # if that puts you in the previous year...
$month = 12; # set the new month value and
$year = $year - 1; # decrement the year value
}
$mondays = 31; # figure out how many days are in this new month
if($month == 4 or $month == 6 or $month == 9 or $month == 11) {
$mondays = 30;
} elseif($month == 2) {
$mondays = ($year % 4) == 0 ? 29 : 28;
}
$day = $mondays; # and change your day value to that.
}
}
#print_comp_header($update_title);
"""""";
"""
""";
$f->flatbox_header();
"""

""";

if($community) {
"""
If not a member, you must join first.
""";
}
#############################################################################################
# End Update Component #
#############################################################################################
"""""";
#print_comp_footer();
"""""";
}

} else {

#other code to print your page For one example, see the tutorial on custom titlebar components.
}

}
#####################################
# END print_my_entries #
#####################################

Now, once that's done, you have a full update page at the address: http://www.livejournal.com/users/your_lj_name/?.mode=update (ie. http://www.livejournal.com/users/t3knomanser/?.mode=update). Using this basic idea, you could add more if/then/else clauses and have any number of custom pages to print out. And I swear I'll do the tutorial on the flat-box-border entries, but the code's kinda messed up, so I'm putting it off.

user: t3knomanser, admin: deprecated

Previous post Next post
Up