Welcome to Vortx Community Forum, where you can ask questions and receive answers from the staff at Vortx and other members of the community.

If you had a user account on our previous forums website, you will need to register a new account here.

Learn more about...


How to get XML package name from within template.master?

Well, the thread title is self-explanatory, but here we go!

I need a way to tell to template.master file the name of the xml package it is going to render. The reason is because I want a specific page header for the main page (hoge) than the rest of the site so knowing the package name I could use JS to style it.

I know that the package name comes into "root/System/XmlPackageName" property and while it's quite easy to read from a xml.config I don't know how to achieve it from within template.master.

Any clue?
asked Feb 20, 2017 in MultiStore by Yan Kleber (1,245 points)

1 Answer

0 votes
Best answer

OK, I figured it out. I mean, I did NOT figure out how to obtain the package name from within template.master but how to differently style the template header depending on the package to be loaded. In my case I wanted to supress the default search component ONLY when the main page loads (because I wrote a custom search component for this page).

First I located the <div> tag in the template.master where is the default search component and gave it an id:

<div id="defaultsearch">
   <aspdnsf:Search ID="ctrlSearch" runat="server" CssClass="search" SearchButtonCaption="Go"
      SearchCaption="<%$ Tokens: StringResource, common.cs.82 %>" SearchTextMinLength="<%$ Tokens:AppConfigUSInt, MinSearchStringLength %>"
      SearchTextMinLengthInvalidErrorMessage="<%$ Tokens: StringResource, search.aspx.2 %>"
      ValidateInputLength="true" ShowValidationMessageBox="true" ShowValidationSummary="false" />

ThenI added the following JS to the xml package (in my case custom.mainpage.xml.package):

<script type="text/javascript">
   $(document).ready (function()
      document.getElementById('defaultsearch').innerHTML = "";

Then whenever the document finishes to load it empties the contents of the <div> where the default MS seach component is.


answered Feb 21, 2017 by Yan Kleber (1,245 points)