|
Member
|
robert-tailor.co
-
8/8/2012 9:01:51 PM
Web Parts, Document Types and Page Templates
Hi,
I've created a Page Template that has 2 columns, and a Web Part Zone in each column. I have created a Document Type (called "Content") based on this template.
For some pages I wish to put web parts in these zones, but not necessarily the same web part on every page. Some pages won;t use web parts at all.
I've added a Web Part to my left zone (a repeater), and now I find that same web part is shown on *all* pages that use the same "Content" Document Type.
How can I set it so that a web part is only used on the individual page in which it is inserted?
Thanks.
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 9:14:12 PM
RE:Web Parts, Document Types and Page Templates
Additionally, I have checked the FAQ here:
http://devnet.kentico.com/FAQs/Web-parts---Controls.aspx#FAQ223
but this does not help because I cannot see where the "Edit Value" option is.
There is a "Visible" option for some controls, but the effect is global across all pages of the same Document Type. And even then it only stops the web part from being rendered. It's still visible in the Design tab.
What am I missing here?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 10:30:03 PM
RE:Web Parts, Document Types and Page Templates
Sounds like you need a better understanding of how the document types, page templates, web parts, and widgets work so you can better plan your project.
Don't worry, I was exactly where you are when I first picked up Kentico.
You don't need to create a document type to associate it with a template. Every document type can have what is called "Page content" or "Editable Text" content added to it.
When you add/remove/edit web parts on a page template, every document that uses that template will be altered. When you add/remove/edit widgets using the Page tab, only that specific document will be altered.
If you just need to make a small change to a page template on a specific page without using widgets, create an Ad-hoc clone of the template.
You can use the "Show for document types" property of web parts to show or hide them based upon the type of document you are on.
You can use the "Hide on subpages" property to hide the web part on pages that just inherit the template.
You can use K# logic in the "visible" property if you need more control of the visibility.
This topic is pretty vast and is best discussed in person or on the phone when conveying it to someone else. My best suggestion would be to keep playing around with it until you get a good handle on what things do so you can plan a project using Kentico really well.
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 10:57:41 PM
RE:Web Parts, Document Types and Page Templates
I'm confused.
The Web Part behaviour you are describing suggests that web part are tied to all documents of the same type, and that there is no easy way around this?
Are you saying then that, even if I want to use the same type of Web Part on multiple pages of the same Document Type then I will need to make separate document types for every variation of the web part I intend to use?
That doesn't sound right to me. It would mean that there would be dozens and dozens of different document types for the user to choose from with extremely granular levels of purpose. Every time I want to use the same page layout, but with a different web part, I'd need to create a new document type.
What if I had a "Downloads" document type. Sometimes I want to include static content. Other times I'd want to include a repeater Web Part and pass different parameters to it.
Are you saying this can only be achieved by creating a separate Document Type for every different set of parameters I'd want to pass in?
Isn't there a better way to achieve this?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 11:06:37 PM
RE:Web Parts, Document Types and Page Templates
Document types and page templates are not tied together. You can use any page template with any document type.
Anything you do in the "Design" tab affects the page template. Anything you do in the "Page" tab only affects that document.
You don't have to create new document types unless you need different fields than what the default Page (cms.menuitem) document type has.
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 11:09:54 PM
RE:Web Parts, Document Types and Page Templates
To explain further.
Lets say you have 20 pages in your site. You can have 20 different page templates if you want. No matter what document type those pages are.
To change the template of a page just go to the Properties Tab > Template section of a page in CMS Desk.
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 11:17:39 PM
RE:Web Parts, Document Types and Page Templates
OK, so I should have few Document Types and many Page Templates, rather than the the other way round?
That's still no better though. It means creating dozens of Page Templates, each virtually identical to each other, just so I can add a different web part to each instance of the same page.
Here's a real world scenario:
1. I have a standard content page with 2 columns. 2. I have dozens of pages which use the same layout, but each instance of the page requires a different web part in the left column.
Would I need to create a different page template to accommodate a different web part for each instance of the page?
Isn't there any way to use the functionality of a web part that is only specific to the individual page it is used on?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 11:23:47 PM
RE:Web Parts, Document Types and Page Templates
There are lots of ways to make it so a web part can behave differently on each page, but I would need an example of what you are doing so I can give you the best answer possible.
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 11:54:38 PM
RE:Web Parts, Document Types and Page Templates
OK, well I just followed these instructions here on how to create a Widget:
http://devnet.kentico.com/docs/devguide/widgets_overview.htm
and I've created a widget based on the basic repeater.
I've converted a web zone to a widget zone, and I've clicked to add a widget.
The list of widgets displayed is only a fraction of the widgets displayed in the list of Widgets in the Site Manager. Needless to say, my newly created widget is one of the ones that is not displayed.
Where are all my widgets?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 11:16:09 PM
RE:Web Parts, Document Types and Page Templates
robert-tailor.co wrote: That doesn't sound right to me. It would mean that there would be dozens and dozens of different document types for the user to choose from with extremely granular levels of purpose. Every time I want to use the same page layout, but with a different web part, I'd need to create a new document type.
If you want to use the same layout with a different web part, you just need to create a new template either by cloning the current template as ad-hoc, or by saving a copy as a new template (make sure that you click SAVE when you "Save as New Template" before you make any changes in the "Design" tab. Other wise you will accidentally be making changes to the original instead of the copy). If you want to allow people with only Editor role perimissions to be able to use web parts, then you have to make the web part zones into editor widget zones and use widgets instead of web parts. Trust me, it all makes sense once you understand it, but it can be difficult to nail down.
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 11:28:09 PM
RE:Web Parts, Document Types and Page Templates
OK - I think I get it now.
Web Parts are tied to the Page Template. Every instance of a page that uses a Page Template will also use the same Web Part with the same parameters.
A Widget is an instance of a Web Part that can be customized on the specific page instance on which it is available.
So if you have a web part and you want to change it's behaviour depending on the instance of the page that is to be rendered, then you need to use a widget that is derived from the desired web part.
Correct?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/8/2012 11:30:34 PM
RE:Web Parts, Document Types and Page Templates
That is one of the ways of doing it. But widgets and web parts can't both be used in the same zones.
can you give me an example of how you want the same web part to behave differently on each page so I can help you better?
|
|
|
Member
|
robert-tailor.co
-
8/8/2012 11:48:07 PM
RE:Web Parts, Document Types and Page Templates
OK.
I have a list of documents in various folders:
/Documents /Documents/Brochures /Documents/TechData /Documents/Photos
I want to create 3 different pages. On each instance of the page I want to create a list of documents from the folder of my choosing.
So, Page1.aspx would list the contents of "/Documents/Brochures", Page2.aspx would list the contents of "/Documents/TechData", Page3.aspx would list the contents of "/Documents/Photos"
How would you do this?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:06:04 AM
RE:Web Parts, Document Types and Page Templates
Use Path expressions to set the path of the document data sources and document listing/viewer web parts. To make it show content below the current document use the path expression "./%" Path expressions in this context are extremely useful. read up on them here http://devnet.kentico.com/docs/devguide/index.html?appendix_a_-_path_expressions.htm
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:08:45 AM
RE:Web Parts, Document Types and Page Templates
Ok that link doesn't go to the right place. Follow that link and look at the bottom of the tree on the left for Appendix A - Path expressions
|
|
|
Member
|
robert-tailor.co
-
8/9/2012 12:21:42 AM
RE:Web Parts, Document Types and Page Templates
OK, thanks.
The only remaining question I have is how to select my newly created widget?
I've created a widget based on the basic repeater.
I've converted a web zone to a widget zone, and I've clicked to add a widget.
The list of widgets displayed is only a fraction of the widgets displayed in the full list of Widgets in the Site Manager. Needless to say, my newly created widget is one of the ones that is not displayed.
Where are all my widgets?
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:31:42 AM
RE:Web Parts, Document Types and Page Templates
Don't use the "Basic repeater", it requires you to have a separate datasource web part. Use the plain "Repeater" web part.
You need to set the site and the permissions on your new widget. Check the box that lets it be used in editor zones and set the permissions to the roles you want to be able to use the widget.
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:35:10 AM
RE:Web Parts, Document Types and Page Templates
You also have to go and make all of the properties you want the editor to be able to use visible in the editing form.
There is no quick way to make them all visible (I suggested this feature for a future version).
I would still use a web part instead of a widget unless you really want your client to be responsible for placing this widget where it needs to go.
It depends on your client. The less techy they are, the more you want to steer away from widgets.
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:37:45 AM
RE:Web Parts, Document Types and Page Templates
correction: The less techy they are, the more you want to limit the amount of configuration they can do with the widgets. It is entirely possible for them to make the page not work if they do something wrong with a widget. You could end up with the same issue in your other thread where you can't change the settings because you can't see the widget.
|
|
|
Member
|
robert-tailor.co
-
8/9/2012 12:41:25 AM
RE:Web Parts, Document Types and Page Templates
Jiveabillion wrote: You also have to go and make all of the properties you want the editor to be able to use visible in the editing form.
There is no quick way to make them all visible (I suggested this feature for a future version).
(Sigh) No doubt there is a reason why all these aren't turned on by default, and why this isn't better explained in the documentation...? Jiveabillion wrote: I would still use a web part instead of a widget unless you really want your client to be responsible for placing this widget where it needs to go.
From what I've learned today, Web Parts (in the sense that I want to use them) simply can't offer the level of customization required without massively over-complicating the entire website structure. If you want a control that requires little or no change across multiple pages, use a web part. If you want a control that is going to change it's output on pretty much every page it's on (even down to not having it at all on some pages), then use a widget. Right? Jiveabillion wrote: It depends on your client. The less techy they are, the more you want to steer away from widgets.
Well, it seems I can limit access to the widgets so that only Global Administrators can edit them. So as long as they don't go in as Admins all the time, it should all be OK...
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 1:12:35 AM
RE:Web Parts, Document Types and Page Templates
Use widgets when you want to put the control in the hands of the client or an editor. OR If you can't use data available in the context of the page to determine the values for the settings of the web parts.
If you're going to use widgets, go ahead and make them as dummy proof as possible so that an editor can use them. For instance, you can create a widget based on the repeater web part that has preset settings except for maybe the path. For the widget, you can even change the control used for the path field to a dropdown list. In your scenario, you can limit this to folders in the document folder by setting the dropdown lists items with a sql query like this:
Select NodeAliasPath + '/%' as Value, NodeAliasPath as Name from view_cms_tree_joined WHERE NodeAliasPath like '/Documents/%' AND NodeLevel = 2
That should give them only options of the directories in your documents folder and it won't allow them to type anything else in the path property.
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:21:24 AM
RE:Web Parts, Document Types and Page Templates
Sorry, I totally didn't read your example right.
You can use a k# expression in the path by clicking the little arrow to the left of the textbox. something like
{%if(NodeAlias == "Page1") { return "/Documents/Brochures/%"; } else if(NodeAlias == "Page2") { return "/Documents/TechData/%"; } else if(NodeAlias == "Page3") { return "/Documents/Photos/%"; } %}
Although, when using Kentico, you might want to just store your Brochures, techdata, and photos under the pages you want to list them on to make things easier.
It's different in writing a plain .net web application because you can use the NodeAliasPaths of tree to select content and it's a powerful tool if used wisely.
|
|
|
Member
|
robert-tailor.co
-
8/9/2012 12:24:57 AM
RE:Web Parts, Document Types and Page Templates
Jiveabillion wrote: Although, when using Kentico, you might want to just store your Brochures, techdata, and photos under the pages you want to list them on to make things easier.
It's different in writing a plain .net web application because you can use the NodeAliasPaths of tree to select content and it's a powerful tool if used wisely.
That was my initial plan, but these documents are to be linked to from many other pages. From a content editor's perspective, it is better to have a single folder with a logical structure they can upload files to, and have all the necessary pages automatically show the correct contents because they know which folder(s) to look in. :-)
|
|
|
Certified Developer 8
|
Jiveabillion
-
8/9/2012 12:25:40 AM
RE:Web Parts, Document Types and Page Templates
Again though, if you wanted to, you could add a field to the page document type where you can set the value of the path you want that web part to pull documents from.
Say you call this field "DocumentListPath" then in your web part settings you can use {%DocumentListPath%} and it will pull the value from the current document.
In your situation If you weren't going to change where you are storing your documents and that property was the only thing you needed to change, then I would go with the K# macro I mentioned earlier.
|
|
|
Kentico Support
|
kentico_jurajo
-
8/9/2012 3:12:39 AM
RE:Web Parts, Document Types and Page Templates
Hi, This article will explain the idea of a template and also how to re-use it for different documents/areas. Best regards, Juraj Ondrus
|
|