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

Forums / Developing with Sitefinity / template and controls

template and controls

8 posts, 0 answered
  1. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    11 Aug 2009
    Link to this post
    I know I can create multiple templates and have different controls in each of them.
    But is there a way to choose controls eg. Newsletter subscription form to show in all pages except for Newsletter page?

    Another example could be ...I want List control to show up in 10 out of 50 pages. I can keep adding the list control in 10 pages with same CSS or whatever I have customised but this is a long process.
    I am looking for an option which Joomla and DNN has i.e to select only those pages where I want that list control to show up.

    Any suggestions?
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    11 Aug 2009
    Link to this post
    one way that I have accomplished this in the past is to assign an external template for the control (say a newsview, so that it shows headlines on all pages except the news page). I add code behind to this usercontrol so that if it's on that page, it doesn't render.

    as you've said you can also create 2 separate templates, identical except one has the control you need, and the other doesn't. then simply set the pages which require that control to use the appropriate template.

    I hope that this was helpful. if you want more help on using the external templates i method I mentioned, let me know and I'll do my best to help!
  3. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    12 Aug 2009
    Link to this post
    thanks for the reply SelArom.
    So, I decided to create two templates.
    I copied the masterpage template and renamed the copied one. Here is the issue I have.
    In my acutal masterpage I have some controls like navigation, search, breadcrumbs, and some generic controls which are common for all pages. I have customised these controls.

    Now the copied masterpage with a new name is blank and now I have to add all the same controls I had on my original one and edit CSS setting for each controls.

    I dont' mind doing this for one template but imagine the time it will take if I need few other templates. There has to be some better way of doing.

    I still think Sitefinity should have an option to select only those pages where I want any particular control to show up.
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    12 Aug 2009
    Link to this post
    would you be able to make a copy of your defined template instead of a new blank one? then you'd only have to change the sections that are different...

    you can also make use of nested master pages, as this might fit your needs better, however unfortunately I have no experience with these so I won't be abe to help if you go that route...

    I would also suggest that you try moving the css definitions into the Theme for the page, that way you can simply assign the same theme to both templates, and very little additional customization will be necessary
  5. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    13 Aug 2009
    Link to this post
    would you be able to make a copy of your defined template instead of a new blank one? then you'd only have to change the sections that are different...
        Under App_Master folder I have MSCTemplate.master which is used for all pages. It has 7-8 content place holder for different modules like search, navigation etc. In the edit mode of the template, i have added those controls that I need in all pages. If I make a actual file copy of this masterpage to use for other special pages then I wil have to add all the modules like search, navigation etc on it just to make it similar to the first template i copied from.
       I can Duplicate the master page and rename it but I don't see the new master page under App_Master folder.

    you can also make use of nested master pages, as this might fit your needs better, however unfortunately I have no experience with these so I won't be abe to help if you go that route...
       I have no idea what this is and how it works.

    I would also suggest that you try moving the css definitions into the Theme for the page, that way you can simply assign the same theme to both templates, and very little additional customization will be necessary
       I already have theming in place. What I meant by changing css for each control is that .for example I have newsletter form module which is customised. So, in each page I want newletter form module, which is 10 out 100 pages, I will  have to go to edit mode of newsletter form module, Advanced, appearance and add the cssClass. This means I have to do 10 times. I could have other modules need in 50 out 100 pages.

    Now if Sitefinity had the option of choosing pages then all I would have to do is add the Newletter form module and select all the 10 pages I want it to show. It would be that simple

    Are you following what I am tyring to say?
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    13 Aug 2009
    Link to this post
    I think I see what you're saying now, thanks for clearing that up! I have a few ideas that I hope might get you closer to what you're attempting to accomplish.

    Since you're using the Template editor to define global controls, you could actually instead define them right on the master page itself. For example, to add a search box, you can register the sitefinity control as follows on your paster page:

    <%@ Register tagprefix="cc" namespace="Telerik.Search.WebControls" assembly="Telerik.Search" %> 
    <cc:SearchBox ID="SearchBox1" runat="server" IndexCatalogue="MyCatalog" ResultUrl="~/Search.aspx" LayoutTemplatePath="~/Templates/Public/Search/SearchBox.ascx" /> 

    notice that the SearchBox control has properties that match the sitefinity property editor. The navigation controls are located at /sitefinity/usercontrols/navigation35 and can be similarly set.

    the newsletter web controls are registered with this:

    <%

    @ Register TagPrefix="cc" Assembly="Telerik.Notifications" Namespace="Telerik.Notifications.Newsletters.WebControl" %>

     

    I realize it's not ideal, since if you want your users to be able to make changes to this, they can't using the sitefinity template editor, however since this setup shouldn't be changing often (it's global to the template) I think it would be a good idea to do it this way.

    this has the added bonus of allowing you to modify these controls at runtime using the code-behind of the master page. For example, your newsletters module, you could handle the Page_Load event and check which url you are on, and if you're not on the list of approved pages, set the visibility of the control to False.

    it's a hack to be sure, but I have used this quite method quite successfully on several sitefinity sites. I lose the convenience of making changes in the sitefinity admin editor, but I gain the full support of the IDE to customize the site exactly the way I want it

    I hope this gives you some ideas on how to proceed! If anyone knows a better way to do this, please share as I'm sure it would save me a lot of time as well!
  7. Rabindra
    Rabindra avatar
    106 posts
    Registered:
    17 May 2009
    14 Aug 2009
    Link to this post
    Thanks SelArom for reply. I am surprised of not hearing anything from Sitefinity team.

    I like the idea of defining all the global control right on the master page. On the other hand, I need to think about other users too. No one knows how to uses visual studio except for me(i'm just a beginner). I have to design in such a way that other's can edit or make changes in future.
    The example I gave about search control is not a good one.
    I have a footer as generic control which uses some css for formatting. Footer is used in all pages so I have added it directly on the master page. There are several other generic controls too. Now if I create a new master page or copy of my original master page, i have to add footer and other global controls in every new master page and edit cssClass for each of them.

    This problem might not be a big issue if you have few pages. Looking at our web project we might have about 200 pages.
    Sitefinity is a great product and you can do lots of things as you like if you are a .net programmer. At the same time it should have simple funtions like this one for non programmers who like drag and drop.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 Aug 2009
    Link to this post
    Hello Rabindra, Josh,

    Let me just add in to the conversation.

    I like the idea of defining all the global control right on the master page. On the other hand, I need to think about other users too. No one knows how to uses visual studio except for me(i'm just a beginner).

    I understand that you would prefer the drag and drop functionality for controls. In fact this is one of the great things about Sitefinity, when it comes to having users that are less, or not at all experienced with .NET development. It will only take one developer to just wrap the controls into user controls (.ascx) and then just upload them to Sitefinity. Using this approach you do can drag/drop the controls in the templates (through the Sitefinity page editor) instead of adding them through VS.

    Nowif I create a new master page or copy of my original master page, ihave to add footer and other global controls in every new master pageand edit cssClass for each of them.

    I would recommend that just define the content place holders in a master page, and some very generic content, like company name for example. Then you can easily create a theme for your template that will have the wanted style rules. You do not need to define all styles in master page. You can effortlessly reuse styles if you put them in a theme. Then all templates and pages can be assigned to that theme. If you go with this approach you can have template editors that do not have knowledge of .NET programming.

    I hope that my input will help clarify the issues. If you have more questions, please feel free to contact us.

    Greetings,
    Rado
    the Telerik team

    Instantly find answers to your questions on the newTelerik Support Portal.
    Check out the tipsfor optimizing your support resource searches.
Register for webinar
8 posts, 0 answered