Difference between revisions of "S2 Cookbook: Properties"
From Dreamwidth Notes
Foxfirefey (Talk | contribs) (Created page with '== Accessing a property == == Setting a property == == Creating a new property == == Putting a property into the customization wizard == Category: S2 Cookbook') |
Foxfirefey (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | == 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. | ||
+ | |||
+ | <syntaxhighlight lang="s2"> | ||
+ | # 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"; | ||
+ | </syntaxhighlight> | ||
+ | |||
== Accessing a property == | == 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: |
+ | |||
+ | <syntaxhighlight lang="s2"> | ||
+ | # sets the page background color property | ||
+ | set color_page_background = "#FFF";</syntaxhighlight> | ||
+ | |||
+ | You can then access the property by putting a <code>*</code> between the property name and the variable access symbol <code>$</code>. | ||
+ | |||
+ | <syntaxhighlight lang="s2"># prints #ffffff | ||
+ | # even though we set it to #FFF because it is a color object | ||
+ | # and not a string | ||
+ | print $*color_page_background;</syntaxhighlight> | ||
== Creating a new property == | == Creating a new property == | ||
+ | |||
+ | Before creating a new property, you might want to make sure and check an [http://www.dreamwidth.org/customize/advanced/layerbrowse?id=core2#table_layerbrowse_properties existing core2 property] doesn't already exist for the purpose you want. | ||
== Putting a property into the customization wizard == | == Putting a property into the customization wizard == | ||
+ | == Useful system properties == | ||
+ | |||
+ | <syntaxhighlight lang="s2"> | ||
+ | """<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>"""; | ||
+ | </syntaxhighlight> | ||
[[Category: S2 Cookbook]] | [[Category: S2 Cookbook]] |
Revision as of 02:51, 8 August 2010
Contents
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>""";