S2 Cookbook: Properties

From Dreamwidth Notes
Revision as of 02:51, 8 August 2010 by Foxfirefey (Talk | contribs)

Jump to: navigation, search

Setting a property

Note: this can NOT be done inside of a function. Most layers set any properties before they write functions, although this is not necessary.

# set all of the interaction links for users, entries, and comments
# to be text instead of icons
set userlite_interaction_links = "text";
set entry_management_links = "text";
set comment_management_links = "text";

Accessing a property

Let's say that you want to access a property. The property has already been set in the current layer or a higher layer:

# sets the page background color property
set color_page_background = "#FFF";

You can then access the property by putting a * between the property name and the variable access symbol $.

# prints #ffffff 
# even though we set it to #FFF because it is a color object
# and not a string
print $*color_page_background;

Creating a new property

Before creating a new property, you might want to make sure and check an existing core2 property doesn't already exist for the purpose you want.

Putting a property into the customization wizard

Useful system properties

"""<pre>""";
# Examples of system properties when used on Dreamwidth.org

# Dreamwidth Studios
print $*SITENAME + "\n";
 
# Dreamwidth
print $*SITENAMESHORT + "\n";
 
# DW
print $*SITENAMEABBREV + "\n";
 
# http://www.dreamwidth.org
print $*SITEROOT + "\n";
 
# http://s.dreamwidth.org/img
print $*IMGDIR + "\n";
 
"""</pre>""";