Latest Post

See if you're logged in on Symphony

In any programming language, if you find yourself frequently repeating a chunk of code or evaluating an expression, that means it's time to put it in to a function or variable, respectively.

Terminology

Symphony 1.7 has an area known as Utilities. Each utility contains a set of related code to be applied at runtime. For code that should be applied to every page request, we then turn to Masters. Most of my projects have a few common variables that I use throughout the website so I place those variable definitions in the Master.

Useful variables

I find myself frequently evaluating an expression to see if a user is logged in on Symphony. Placing the expression in a variable will require it to only be evaluated once, plus you can reference the result anywhere in your code. Add this line of code to your Master:

<xsl:variable name="IsLoggedIn" select="/data/events/user[@logged-in = 'true']" />

This will assign to the "IsLoggedIn" variable a boolean value relating to the visitor's login status. Don't forget to also make sure that the "Login Info" Event is attached or this will always return false. This is useful for showing information only to your registered users.

<xsl:if test="IsLoggedIn">
<xsl:text>Welcome back, </xsl:text>
<xsl:value-of select="/data/events/user/username" />
</xsl:if>

More to come later.

Previous Posts

    • Making backups

    • With all the data that I maintain on my personal machine, it's ironic that I don't have a good method of backing up that data. The problem is, I have so much data that I have no where that I can make a copy as a backup.

    • Published2008-11-10 @ 19:10
    • Comments 1
    • First Entry

    • This is the home of my new blog, Symphony-powered. I'm still learning the ropes of the system and haven't quite finished the design yet, but I think I've made enough progress to at least start putting my thoughts online.

    • Published2008-11-06 @ 13:49
    • Comments 0