1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Master Pages

10 posts, 0 answered
  1. Dino
    Dino avatar
    21 posts
    Registered:
    13 Jan 2008
    25 Feb 2009
    Link to this post
    Hi
    we start developing with sitefinity but we come across with a problem.

    We have an Web Application that was built separately.

    The problem is that we need integrate this web application with sitefinity web site to use the same master page that use the main root (sitefinity web site)

    -/ sitefinity web site
    --/our Web Application (iis called it "Application")

    how we can do that ?
  2. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    25 Feb 2009
    Link to this post
    Hi Dino,

    I am not sure I completely understand you.

    If you mean to integrate an application and make it accessible inside Sitefinity, here are the two most easy ways:

    The first is simply to add an external page that  points to the "default" page of your application. This will work perfectly, but Sitefinity's sitemap will not detect the pages in your web application (besides the first you marked as external).

    The second approach is a bit more tedious, but since I will provide you with the most code it should be no problem at all:
    /// <summary> 
        /// Basically, upon pressing, our button will fire the logic for 
        /// wrapping your whole site up with sitefinity external pages and page groups, 
        /// thus fully integrating it into the system (e.g. sitefinity's sitemap provider will 
        /// "see" all your pages) 
        /// </summary> 
        /// <param name="sender"></param> 
        /// <param name="e"></param> 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            // first, we instantiate the manager, as it creates and saves pages 
            CmsManager cmsManager = new CmsManager(); 
            // then we create a "root" for your application, whose sole role 
            // would be to be a placehodler 
            const string PLACEHOLDER_NAME = "MyAppName"
            ICmsPage appRoot = cmsManager.CreatePage(PLACEHOLDER_NAME); 
            // consiqently, all pages will be created as children to this page 
            // (node in the site map) 
            appRoot.PageType = CmsPageType.Group; 
            appRoot.Navigable = true
            cmsManager.SavePage(appRoot); 
            // then, we need to know where your pages are physically 
            //const string PATH = @"C:\My\Path"; 
            const string PATH = @"C:\Program Files (x86)\telerik\Sitefinity3.6\WebSites\3.6.hotfix1\MyApp"
            // needless to say, that path has to be inside your web site's directory tree 
            // I have implemented is as if it were directly in the root directory 
            DirectoryInfo dirInfo = new DirectoryInfo(PATH); 
            FileInfo[] filesInDir = dirInfo.GetFiles(); 
            // if you have a Default.aspx, it will be added first 
            // as this matterns (PageType.Group means that it will redirect to its first child) 
            ICmsPage pageToAdd = null
            // we don't need to check the case here, as windows is case insensitive 
            // and this will simply work 
            if (File.Exists(Path.Combine(dirInfo.FullName, "Default.aspx"))) 
            { 
                pageToAdd = cmsManager.CreatePage("Default", appRoot.ID); 
                pageToAdd.PageType = CmsPageType.External; 
                pageToAdd.Navigable = true
                pageToAdd.ExternalUrl = String.Concat("~/", dirInfo.Name, "/Default.aspx"); 
                cmsManager.SavePage(pageToAdd); 
            } 
            // then, we repeat this for every page that is not Default.aspx 
            foreach (FileInfo fileInfo in filesInDir) 
            { 
                if (!fileInfo.Name.ToLower().Equals("default.aspx"
                    && fileInfo.Extension.ToLower().Equals(".aspx")) 
                { 
                    // what we generally do, is, create a page, make sitefinity know we 
                    // won't put content, so that it will redirect to your physical page 
                    // and make it visible for the sitefnity's default sitemap provider 
                    pageToAdd = cmsManager.CreatePage(Path.GetFileNameWithoutExtension(fileInfo.FullName), appRoot.ID); 
                    pageToAdd.PageType = CmsPageType.External; 
                    pageToAdd.Navigable = true
                    pageToAdd.ExternalUrl = String.Concat("~/", dirInfo.Name, "/", fileInfo.Name); 
                    cmsManager.SavePage(pageToAdd); 
                } 
            } 
        } 

    I believe the code is quite easy to follow, but if you need more info - please ask. I will attach the whole user control I used for testing this, which you can add to a new Sitefinity page, and let it do the dirty work for you. Don't forget to change the path, of course. And you can make this recursive by wrapping the code into a separate function and call it for all directories in the current working directory.

    If you mean to use the same .master for both Sitefinity and your pages - I have no idea of an easy way to do it. Master pages in Sitefinity have some peculiarities: place holders are inside div tags with specific ids, so that .css files can identify the different parts of your page. Perhaps the most sensible thing to do would be to make a new template for your Sitefinity pages with your existing .master pages and use for your Sitefinity pages.

    All the best,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Dino
    Dino avatar
    21 posts
    Registered:
    13 Jan 2008
    25 Feb 2009
    Link to this post
    What I need is :
    take the masterpage (full load with data) and merge to pages in a Sub Application (mapped as Application in iis7).
    The sub Application is phisically in same root of sitefinity web site.

    For example we delevoped an application (before we installed sitefinity) that run as Application under the root of the main web site.

    We need to apply the same graphic ,.master and Theme, to the sub application.
    Now we just take the html and paste inside the pages of sub application.
    But is no maintainble, and also we have to develop other application too.
    Thanks you
  4. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    26 Feb 2009
    Link to this post
    Hi Dino,

    I think it is not a good approach to this task.  Sitefinity was meant to reuse business logic and be the presentation layer itself. It perfectly supports custom and user controls. Implementing a module for Sitefinity is the best thing to do as I see it, but since you've got a working application this is not as easy.

    As I see it, you can do one of the following:
    • Overhaul your whole application to use Sitefinity's .master pages and .css fies (or, rather, the whole themes with all .css, .skin, etc). This will be difficult to implement, but once done, you will not be able to tell them apart. Then, simply run the user control to link them with Sitefinity and make your application use the same map provider as Sitefinity (i.e. database). I would not take this approach, but is a maintainable possibility.
    • Rework your application to provide the business and data layers only. Then use Sitefinity as a presentation layer. You can try this either with web services or custom controls and Sitefinity modules. This will be perfectly maintainable, once it is done
    • Simply ignore the appearance and link the application with Sitefinity (via the provided code). The maintenance downside is that you have to re-update the Sitefinity pages every time you add or delete on in your application (generally , pressing two buttons in a sequence). The user downside is inconsistent user interface.

    Porting any application to a different framework/backend is always a tedious task. You could avoid this if you use design patterns such as MVC, MVP, etc  - or anything that will put an intermediate layer between presentation and logic.

    Best wishes,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Dino
    Dino avatar
    21 posts
    Registered:
    13 Jan 2008
    27 Feb 2009
    Link to this post
    Hi
    Thank you for your answer.
    We decided to move toward MVC pattern to rewrite our application to be compatible with sitefinity as you suggest.
    We take advantages as well from the fact that microsoft released the new ASP.NET MVC Release Candidate.

    Do you have some example to write user controls or pages in sitefinity that use MVC pattern ?
  6. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    27 Feb 2009
    Link to this post
    Hello Dino,

    I took a look at the Microsoft implementation of the MVC pattern, but I will need more time to make a nice sample to demonstrate how to use the Sitefinity API for (at least) presentation (in MVC terms - View). When I am done, I will make a KB article.
    Until then, you can take a look at the Dev Manual, and look at how modules and controls can be added to Sitefinity.

    Sincerely yours,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Dino
    Dino avatar
    21 posts
    Registered:
    13 Jan 2008
    28 Feb 2009
    Link to this post

    Hi

    yes I understand I had a look how integrate the MVC view into Sitefinity and seems no easy task.

    I think you should provide some support for MVC pattern also because it'll became much popular, and also because is a real good way to integrate already wrote complex application in sitefinity.

    I'll waiting for your KB article, How can I know when you going to publish the article ?

    Thanks

  8. Ivan
    Ivan avatar
    478 posts
    Registered:
    16 Jun 2015
    03 Mar 2009
    Link to this post
    Hi Dino,

    we do not have any immediate plans to switch or support ASP.NET MVC. One should keep in mind that Sitefinity is webforms application and therefore any approach for working with webforms and MVC together on single website will work. Here is one example of this approach:
    http://www.chadmyers.com/Blog/archive/2007/11/30/asp.net-webforms-and-mvc-in-the-same-project.aspx

    I hope you will find this information helpful. Let us know if there is anything else we can do for you.

    Best wishes,
    Ivan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Erick Perez
    Erick Perez avatar
    1 posts
    Registered:
    05 Nov 2009
    06 Nov 2009
    Link to this post
    Is it possible to change the path that uses the master pages to be a folder different than the App_Master folder?

    Thanks!
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Nov 2009
    Link to this post
    Hello Erick Perez,

    Generally this is the standard folder for storing master pages. Useful link Who is Who in Sitefinity Folder. Generally Sitefinity loads all templates from App_Master folder and if your templates are somewhere else they will not appear in the backend.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
10 posts, 0 answered