In This Article:

    Using SalsaScript to Build a Custom Homepage

    In This Article:


      Using SalsaScript to Build a Custom Homepage

      If you want to use SalsaScript to build custom pages for your organization, you can do so using the website management package.

      With this package, you can create custom pages using whatever templates you'd like and drop SalsaScript into it at any appropriate point.

      The important thing to note is that you cannot drop SalsaScript into the pages that you create directly, but you can do so in the templates you create. So, we will use a template.

      1. Navigate to the Website management package in your Salsa account.
      2. Find your Template section and create a new template. You can either do this manually or use Salsa's template extractor, but cannot use the Political Templates package.



      3. Make sure you're set to edit the source code of this template.


      4. In the body section, create a new div element and add the following code in:
        <? var supporters = DB.getObjects('supporter',
        orderBy: ['Date_Created DESC'],
        limit: '5',
        includes: ['First_Name', 'Last_Name']
        // Loop through and print supporters
        for each (record in supporters) {
        ?> Superstar: <?=(record.First_Name + " " + record.Last_Name) ?>

        This specific code does two things:

        • use DB.getObjects() to create an object called supporters that contains the first name and last name of the five most recently created supporters,
        • loop through the supporters object and print out a string that says "Superstar : " before the first and last name of each supporter

        In this case we have used SalsaScript in the same way that front end developers have been using PHP with HTML and CSS for years. This will update dynamically every time the page is loaded.

      1. Now that we have this in our template, we can create a home page for ourselves with the template.

      2. You will note that at this point, we are only creating content for the page. All the SalsaScript lifting was done in the template.
      3. The final product will look like this:

        This was done using a basic Salsa training template, but you can use any template that you'd like and create any Salsa functionality that you'd like in the template.

        You are only restricted by your imagination!

      Was this article helpful?
      0 out of 0 found this helpful
      Have more questions? Submit a request


      • I see that one can loop through the records using record.field_name. I'm curious whether there is a way to get other properties of the field, such as a the label for a custom field. I have a custom country picklist field that has a value (US) and a label (United States). Sometimes I want to show the value and sometimes I want to show the label.

        Comment actions Permalink
      • Charlotta, that's a great question, and if you would still like some more information on that please email and our developer specialist can provide further details.

        Comment actions Permalink

      Please sign in to leave a comment.