Question

Photo of Chris McGrath

0

Using Lava on Site.Master

Is it possible to use lava fields on Site.Master? I'm new at this but everywhere I see Lava being used it's as simple as putting {{ Person.Nickname }} in an html file.  When I put this field into my Site.Master it just shows up as {{ Person.Nickname }} on the rendered page. 

Thanks!

  • Photo of David Leigh

    0

    No, it's not possible to use Lava in Site.Master.

    The master page is a template that is processed by the ASP.NET rendering engine.
    Lava templates are processed by Rock to produce a HTML block that is then inserted into a page - and that page is then processed by the ASP.NET rendering engine.
    So basically, Site.Master operates at a lower level in the page rendering pipeline, and it is not "Lava-aware".

     

  • Photo of Dave Schuster

    1

    Just in case some one comes upon this answer searching as I did, this is now possible.  If you're running an instance of Rock, check the Rock theme's Site.Master for a better example.

    Here's the basic syntax:

    <Rock:Lava ID="hlNeedAnIdName" runat="server">

        {% assign foo = 'Not Foo' %}

        {{ foo }}

    </Rock:Lava>


  • Photo of Chris McGrath

    0

    Thanks David, maybe you (or someone) can help suggest a way to do what I need then. We are incorporating event registration pages into our external site, which is not Rock-driven. I created a tempate for the site that skins the pages to match the rest of the site, which uses some fairly involved menus and css, which are in Site.Master.  I want to include an Account button on the menu that acts like the rest of the menu, rather than using the built-in Rock control that shows Login or "Hello, User" with the little menu. At minimum, I would like the text on the button to say Login if they're not logged in and Account or Logout if they are.

    Should this be a new custom Rock Block that I create, or is there maybe something simpler and generic I can use to just have a bit of "if" logic to control the html it displays?

    • David Leigh

      Chris,


      Instead of hacking into the Site.Master, I would suggest replacing the existing Login Status block with your own menu using a HTML Content block. This block is Lava-aware, so you can modify its content in Lava by referencing the CurrentUser object.