Adding Dynamic Field to Pages
I would like to add a text field to each page. This text field would be used as a tooltip for the sitemap menu. I originally told the client to add the tooltip to the description field since the content was protected by a login and would not be indexed by search engines. The problem is that Description is not available for external links. I thought I may be able to add a text field element using the advanced settings area, but this did not work.
I looked at trying to add a widget to the action menu on the pages section, but I don't need to spend time chasing that rabbit to figure out it wont work either. Is there a way to add a description to pages without having to build a full blown module?
If not can description be added to the external pages template in the next release?
Hello John ,
You can specify the text field to be placed on a master page template that the page use. You can even use a hidden field.
Another option is to create a simple widget to hold the text.
Regards,
Stanislav Velikov
the Telerik team
I apologize that I didn't really explain what I wanted to do well.
I am wanting to add a Dynamic Field to the backend pages configuration section (Page Title and Properties). Originally I had the client add the tooltip information to the description field in the Title and Properties, but external url's do not have this field.
When the menu (custom control) is rendered it would look at the description from PageNode and add it to the menu tooltip. Since the external url's are saved to a different table the description field is not available.
Hello John,
You can create a new field for pages. Go to Administration-> Settings-> Advanced->ContentView-> Controls-> Frontend pages-> Views and create the field in FrontendPagesCreate and FrontendPagesEdit. To create the field expand FrontendPagesCreate and add it to a section you like add new field of type TextFieldDefinitionElement and configure it by refering to the example of the Description field for pages. Note don`t include RessourceClassId for your field since it is custom. Repeat the process for FrontendPagesEdit.
You will observe the field on your pages but it will not save the information you enter. Please refer to this forum post for the further changes that need to be made to the database.
Greetings,
Stanislav Velikov
the Telerik team
Hello, you wrote
>You will observe the field on your pages but it will not save the information you enter...
in the post that you refer nothing is said about where code for persisting custom fields should be placed. Should we define custom code behind class for that page and when perform saving?
Hello,
The tooltip will appear in the navigationif you add text to the description field when creating or editing page properties (Actions->Title & Properties Description field).
Custom code class will not work because the page persist changes trough definitions. I also have added field, but couldn`t manage to persist the changes to the database. Here is the feature request for custom fields in pages.
Hi Stanislav,
Hi Stanislav,
Finally figured out that this is not possible, as Stanislov states. The forum post he references goes on to say that. Can we get an estimate as to when proper custom fields for pages might be available? Seems to me to be a fairly important thing to add...
last post was on 2008 - 4 years after... the same issue is on the CMS.
There is any solution?
Hi,
Adding custom fields on pages is feature that is not implemented in sitefintiy 5 in sitefintiy 3 there are some workarounds, but in sitefintiy 5 this is still not possible. Let me know for what you want to use the custom fields to try and offer a workaround to overcome missing this feature.
Regards,
Stanislav Velikov
the Telerik team
We added a custom field to the pages type and use it to apply a css class. Here's the backend page control I made (nothing fancy) to set it.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="PageIconManager.ascx.cs" Inherits="SitefinityWebApp.UserControls.PageIconManager.PageIconManager" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="sitefinity" %>
<
style
>
</
style
>
<
h1
id
=
"sfToMainContent"
class
=
"sfBreadCrumb"
>
Page Css Editor
</
h1
>
<
div
id
=
"setPolicyToolbar"
class
=
"sfAllToolsWrapper"
>
<
div
class
=
"sfAllTools"
>
<
div
id
=
"sfActions"
>
<
span
tabindex
=
"-1"
>
<
ul
>
<
li
class
=
"sfMainAction"
style
=
"padding-top: 5px"
>
<
asp:LinkButton
ID
=
"saveButton"
runat
=
"server"
CssClass
=
"sfLinkBtn sfSave"
OnClick
=
"OnSave_Click"
>
<
span
class
=
"sfLinkBtnIn"
>Save</
span
>
</
asp:LinkButton
>
<
asp:Label
ID
=
"saveLabel"
runat
=
"server"
/>
</
li
>
</
ul
>
</
span
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"sfWorkArea"
>
<
h3
style
=
"padding:3px"
>This is a temp page to assign CSS Classes to a page until SF can put a UI in at a later date</
h3
>
<
telerik:RadTreeView
id
=
"pagesTreeView"
runat
=
"server"
Skin
=
"Sitefinity"
DataSourceID
=
"sitemapDS"
ExpandAnimation-Type
=
"None"
CollapseAnimation-Type
=
"None"
MultipleSelect
=
"false"
OnNodeDataBound
=
"onPages_NodeDataBound"
>
<
NodeTemplate
>
<
span
style
=
"padding-right: 5px"
><%# Eval("Title") %>:</
span
><
asp:TextBox
ID
=
"cssClassTextBox"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"pageIDField"
runat
=
"server"
Value='<%# Eval("PageId") %>' />
</
NodeTemplate
>
</
telerik:RadTreeView
>
<
sitefinity:SitefinitySiteMapDataSource
ID
=
"sitemapDS"
runat
=
"server"
ShowStartingNode
=
"false"
/>
</
div
>
<
script
type
=
"text/javascript"
>
</
script
>
using
System;
using
System.Collections.Generic;
using
System.Diagnostics;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
Telerik.Sitefinity;
using
Telerik.Sitefinity.Modules.Pages;
using
Telerik.Sitefinity.Pages;
using
Telerik.Sitefinity.Model;
using
Telerik.Sitefinity.Web;
using
Telerik.Web.UI;
using
Telerik.Sitefinity.Pages.Model;
namespace
SitefinityWebApp.UserControls.PageIconManager
public
partial
class
PageIconManager : System.Web.UI.UserControl
private
const
string
FIELD_PROPERTY =
"IconCssClass"
;
public
void
OnSave_Click(
object
sender, EventArgs e)
using
(PageManager manager =
new
PageManager())
foreach
(var node
in
pagesTreeView.GetAllNodes())
TextBox cssClassTextBox = node.FindControl(
"cssClassTextBox"
)
as
TextBox;
HiddenField pageIDField = node.FindControl(
"pageIDField"
)
as
HiddenField;
if
(
new
Guid(pageIDField.Value) != Guid.Empty)
PageData pageData = manager.GetPageData(
new
Guid(pageIDField.Value));
pageData.SetValue(FIELD_PROPERTY, cssClassTextBox.Text);
manager.SaveChanges();
saveLabel.Text =
"Saved At: "
+ DateTime.Now;
protected
void
Page_Init(
object
sender, EventArgs e)
pagesTreeView.DataBind();
public
void
onPages_NodeDataBound(
object
sender, RadTreeNodeEventArgs e)
PageSiteNode page = e.Node.DataItem
as
PageSiteNode;
RadTreeNode node = e.Node;
TextBox cssClassTextBox = node.FindControl(
"cssClassTextBox"
)
as
TextBox;
/*
var pg = App.WorkWith().Pages().Where(x => x.PageId == page.PageId).Get().SingleOrDefault();
var value = pg.Page.GetValue(FIELD_PROPERTY);
if(value != null)
cssClassTextBox.Text = pg.Page.GetValue(FIELD_PROPERTY).ToString();
*/
var pManager = PageManager.GetManager();
if
(page.PageId != Guid.Empty)
PageData pageData = pManager.GetPageData(page.PageId);
var value = pageData.GetValue(FIELD_PROPERTY);
if
(value !=
null
)
cssClassTextBox.Text = pageData.GetValue(FIELD_PROPERTY).ToString();
node.Expanded =
true
;
Hi Stanislav,
There are most of the companies that for example has a first level classification of their contents separated for example in "Person" / "Company" or "Freelance" this kind of development we must implement an additional module to give them the option of personalize the tree structure of each of these "worlds".
In my case we developed a new module to configure all this, but is not very usable to make in this way because for each page you creates, you must go after that to a module to configure where you want to share this information.
If the web page properties could have this option should be perfect and very usable.
Hope was clear my explanation.
Hi,
Feedback on custom fields for pages was gathered recently in sitefintiy google group tough the addition of this feature didn`t made it for sitefintiy 6.0 release this month. Here is the feature for custom fields in pages in PITS.
Greetings,
Stanislav Velikov
the Telerik team
Broken link and no solution