I Am The Electric Messiah (exacademic) wrote in component_help,
I Am The Electric Messiah
exacademic
component_help

  • Mood:
  • Music:

Here's a snippet for anyone who wants it

Hey all. I've been playing with S2 and component for a week or so now (the tutorials here and over at s2component were a HUGE help). I've had to write a little snippet for myself, and thought someone might be able to use it. I wanted a component that was a list of communities that I frequent. I add and remove communities from this list fairly regularly, and the thought of rewriting all those href tags to get the links to work just like <lj . . .> tags do didn't sound like much fun.

So, I wrote a simple loop function to do it, which reads the community names from an array. To add or remove a community from the list, just change the array definition at the top.



print_comp_header("Somewhere else to go");

#######################
#
# Looping link function
#
#######################

var string[] comms;

$comms[0]="s2component";
$comms[1]="component_help";
$comms[2]="theme_photoshop";

var int n;
$n=((size $comms) - 1);

"""
<div align="center">
<img src="http://www.livejournal.com/palimg/component/clear.gif" border="0" height="10" width="200" />
""";

foreach var int i (0 .. $n){
print "<a href=\"http://www.livejournal.com/userinfo.bml?user=$comms[$i]\" target=\"_blank\"><img src=\"http://stat.livejournal.com/img/community.gif\" border=\"0\" width=\"16\" height=\"16\" /></a><a href=\"http://www.livejournal.com/community/$comms[$i]/\" target=\"_blank\">$comms[$i]</a><br />";
}

"""
<img src="http://www.livejournal.com/palimg/component/clear.gif" border="0" height="10" width="200" />
</div>
""";

##############

print_comp_footer();


Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 3 comments