Change page controls from an Xslt helper class in Sitecore

Inside the xslt rendering, I call the following

<xsl:value-of select="di:inject()"/>

The appropriate class retrieves the current page object and tries to change the page title.

public class XslHelper : Sitecore.Xml.Xsl.XslHelper
{
    public void inject()
    {
        Page page = HttpContext.Current.Handler as Page;

        // page.GetType().FullName tells me that I have successfully got the reference

        page.Header.Controls.Add(new HtmlLink { Href = "/style.css" });
    }
}

However, the title is not updated? Why is this another way to achieve the same result?

EDIT: We ended up extending the XslRender template and storing dependencies there, which can then be assembled and added to the session by overriding the InsertRenderings class in the renderLayout pipeline. Then the session object can be accessed in Page_Load in a layout that can access the page title.

+3
source share
2 answers

, - XSL-. , sublayout Page_Load - .

- . +1 ; -)

+3

, , CSS. HTTP- , CSS.

0

Source: https://habr.com/ru/post/1786887/


All Articles