Can tags and categories be applied to a page?
Can tags and/or categories be applied to a page?
Can you create a menu based on a tag or category?
Hi Dan ,
There is no UI or configuration for setting custom fields over pages. We will work on this for some of the next releases. Currently you have to work only programmatically .
Below is a sample code that will create several metakeys for an existing type
boolchangedDB = false;
App.WorkWith().DynamicData().Type(typeof(PageData))
.Field().TryCreateNew("Key1", typeof(string), ref changedDB).Done()
.Field().TryCreateNew("Key2", typeof(string), ref changedDB).Done()
.SaveChanges(true);
For pages you can use PageData type.
Getting the value from a field.
var pManager = PageManager.GetManager();
PageData page = pManager.GetPageData(pageId);
page.GetValue("SomeField");
Kind regards,
Ivan Dimitrov
the Telerik team
Hey Ivan,
I'm working with the code you provided, but I'm running into an issue when trying to get/set a value for the custom field I've described. My issue involves trying to call GetValue("string") on my PageData object. This method does not exist.
Is there another method that should be getting called? Thank you.
Hello Josh,
Do you have reference to Telerik.Sitefinity.Model ?
Regards,
Ivan Dimitrov
the Telerik team
Awesome. I think I should be good to go now.
I'm getting the following exception when trying to run the following code:
bool changedDB = false;
App.WorkWith().DynamicData().Type(typeof(PageData))
.Field().TryCreateNew("Key1", typeof(string), ref changedDB).Done()
.Field().TryCreateNew("Key2", typeof(string), ref changedDB).Done()
.SaveChanges(true);
var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
var type = metaManager.CreateMetaType(typeof(Telerik.Sitefinity.Pages.Model.PageData));
metaManager.SaveChanges();
Be careful to differentiate between PageNode.GetValue/SetValue and PageData.GetValue/SetValue - they are not the same.
Took me 20 minutes to realize I was referencing the wrong page model. :)
Hello Josh,
PageNode is an instance of the page.
PageData stores the page data. Each PageNode has PageData except the group pages.
The initial sample shows that you should use PageData
App.WorkWith().DynamicData().Type(typeof(PageData))
Kind regards,
Ivan Dimitrov
the Telerik team
Just want to add, this solution works great if you want to associate an arbitrary name/value pairs of strings to a page, but what I wanted (and I suspect what the original poster had in mind) was the ability to associate Pages with the actual taxonomies used by Sitefinity, such as hierarchical Category.
To do this, first run this code once to register the type:
var metaManager = MetadataManager.GetManager();
MetaType type = metaManager.GetMetaType(typeof(Telerik.Sitefinity.Pages.Model.PageData));
if (type == null)
metaManager.CreateMetaType(typeof(Telerik.Sitefinity.Pages.Model.PageData));
metaManager.SaveChanges();
App.WorkWith()
.DynamicData()
.Type(typeof(PageData))
.Field()
.CreateNew("Category", typeof(string))
.Done()
.SaveChanges(true);
update
sf_meta_fields
set
clr_type = null,
taxonomy_provider = 'OpenAccessDataProvider',
taxonomy_id = (select id from sf_taxonomies where taxon_name_ = 'Category')
where
field_name = 'Category' and
clr_type = 'System.String'
CREATE TABLE [dbo].[sf_page_data_category](
[content_id] [uniqueidentifier] NOT NULL,
[seq] [int] NOT NULL,
[val] [uniqueidentifier] NULL,
CONSTRAINT [pk_sf_page_data_category] PRIMARY KEY CLUSTERED
(
[content_id] ASC,
[seq] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[sf_page_data_category] WITH CHECK ADD CONSTRAINT [ref_sf_page_data_category_sf_page_data] FOREIGN KEY([content_id])
REFERENCES [dbo].[sf_page_data] ([content_id])
GO
ALTER TABLE [dbo].[sf_page_data_category] CHECK CONSTRAINT [ref_sf_page_data_category_sf_page_data]
GO
public static void AssociateCategories(PageNode item, Guid[] categoryIds)
App.WorkWith()
.Page(item.Id)
.Do(i =>
i.Page.Organizer.Clear("Category");
i.Page.Organizer.AddTaxa("Category", categoryIds);
)
.SaveChanges();
public static TrackedList<
Guid
>
GetAssociatedCategories(PageNode item)
TrackedList<
Guid
> categories = (TrackedList<
Guid
>) item.Page.GetValue("Category");
Hello,
I followed the steps you guys mentioned. I have below code which sets the value for a custom field:
App.WorkWith().DynamicData()
.Type(
typeof
(PageData))
.Field()
.TryCreateNew(
"MyPageDataField"
,
typeof
(
string
))
.SaveChanges(
true
);
var dynamicContent = App.WorkWith()
.DynamicData()
.Fields()
.Where(dc => dc.FieldName ==
"MyPageDataField"
).Get();
string
g =
""
;
PageNode pg = App.WorkWith()
.Pages()
.Where(pk => pk.Page !=
null
&& pk.Page.Id == SiteMapBase.GetActualCurrentNode().PageId && pk.IsBackend ==
false
)
.Get().SingleOrDefault()
as
PageNode;
pg.Page.SetValue(
"MyPageDataField"
,
"somevalue"
);
var pManager = Telerik.Sitefinity.Modules.Pages.PageManager.GetManager();
Telerik.Sitefinity.Pages.Model.PageData page = pManager.GetPageData(SiteMapBase.GetActualCurrentNode().PageId);
object
valud = page.GetValue(
"MyPageDataField"
);
Anyone???
Hello Saad,
Please try the below code sample:
var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
var type = metaManager.CreateMetaType(
typeof
(PageData));
metaManager.SaveChanges();
//create the new MetaField for PageData
App.WorkWith().DynamicData().Type(
typeof
(PageData)).Field().TryCreateNew(
"Organization"
,
typeof
(
string
)).SaveChanges(
true
);
//get a page and set some value for the new MetaField
var myPage = App.WorkWith()
.Pages()
.LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
.ThatArePublished()
.Where(p => p.Page !=
null
&& p.Page.Title ==
"MyPage"
)
.ForEach(p=>
p.Page.SetValue(
"Organization"
,
"test111"
);
)
.SaveChanges()
.Get()
.FirstOrDefault();
//get the persisted of the custom field fro that page
var customFieldValue = myPage.Page.GetValue(
"Organization"
);
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>
Thanks Barnev. I`ll test it asap and get back to you!
Hi Everyone,
I tried to run this code on one of my existing solutions deployed using sitefinity 4.1. But I haven't been able to persist the property.
I followed the method in the following link
http://www.sitefinity.com/devnet/forums/preview-thread/sitefinity-4-x/developing-with-sitefinity/adding-dynamic-field-to-pages.aspx
The field is visible on page creation and edit, but I haven't been able to bind it with the Dynamic field Created for pages. Even when I inspect the page fields for the dynamic field i can see it on the page, But it is always null.
Please advise a work around.
Here is the code that I am using
var metaManager = Telerik.Sitefinity.Data.Metadata.MetadataManager.GetManager();
var type = metaManager.CreateMetaType(typeof(PageData));
metaManager.SaveChanges();
App.WorkWith().DynamicData().
Type(typeof(PageData)).
Field().TryCreateNew("TestField", typeof(string))
.SaveChanges(true);
Hi Moiz Ahmed,
Please take a look at the attached short video I've recorded, which demonstrates creating of a custom field for PageData, and then getting a page from my project and persisting/modifying a value for the filed for that page.Please do not hesitate to let me know if I've missed something.
Kind regards,
Boyan Barnev
the Telerik team
Hi Boyan
Thanks a lot for the tutorial, but this isn't what I was asking for.
I wanted to know, how to use the fields created in this forum http://www.sitefinity.com/devnet/forums/preview-thread/sitefinity-4-x/developing-with-sitefinity/adding-dynamic-field-to-pages.aspx to persist values cause the last reply of Stanislav Velikov says, "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."
So I want to know the part in which I have to make the changes that will allow me to use the field.
I want a field on the PAGE EDIT and PAGE CREATE to persist/ modify the value. I do not want to programmatic work around for that.
Hello Moiz Ahmed,
That's a tough one, unfortunately it's not possible at the current state to persist the value of the custom field through the backend UI, but thank you for the constructive feedback. We have logged this issue for implementation, and hopefully we'll be able to provide such functionality for the upcoming releases. Currently the only way to Get/Set the value of this MetaField would be through code, as demonstrated in the sample video.
Greetings,
Boyan Barnev
the Telerik team
I'm also interested in persisting values on page creation edit. Any movement on this. It would be very useful for extending page functionality if we could add a custom field just like we do with the regular content modules. For our particular use case we're looking at being able to set a boolean value that is either checked in certain conditions. But we want to give the end-user the ability to make this decision. Is there no way to persist these values?
Hello Kmac,
We have not implemented this functionality yet. For your convenience I have logged a feature request for this, and you can track the issue status and vote for it in PITS on this public URL.
Greetings,
Boyan Barnev
the Telerik team
Hi Sitefinity team,
I Agree with Dan that this a must in your product, as it gives you the oportunity of classify for example the pages as most of the companies web pages have different structures, repited contents like for person and for companies and for this reason is necessary to have a classificion of the page you are creating.
Please there is nothing on working on progress.... when do you have a date to planify new developments?
Hi all,
Once again thanks to everyone for providing us with your valuable feedback and letting us know of your opinion. Custom fields for pages is one of our most voted feature requests in PITS, and we are currently doing an internal screening of the possible options and best implementation pattern that would suit everyone's needs.
It is true that the feature has not been scheduled yet, however there is some internal work in progress on that area, and once we get to an agreement we are going to update the item status so you can be aware of its timing.
Regards,
Boyan Barnev
the Telerik team
"It is true that the feature has not been scheduled yet"
BOOOOOOO :/
Hi Steve,
I'd gladly take your rage on this matter, as the feature has been a very popular one, however I can assure you, once again that the initial feedback collection we've been conducting is not in vain, and we are slowly getting to the point of scheduling the item for implementation. It was not announced nor scheduled for 5.3 but we have been addressing entirely your (read our clients) requests and feedback for the past release, and will do the same with the upcoming one, for example the need to have shared content on page templates and multilingual implementation in module builder.
Please rest assured, once again, that the priority of the item has been raised, and we'll do our best to deliver it for the upcoming releases. Once it's scheduled it'll be officially announced on the road map, so please keep in touch so you can get this valuable information as soon as it's out.
Kind regards,
Boyan Barnev
the Telerik team
Is there something wrong since this has the highest votes and almost 2 years? Still no go for SF 6.0??
Hi Basem,
Thnak you for raising the question. i just wanted to point out that the fact that this feature has the highest number of votes is by no means omitted by the team here, and we do keep in mind this feature. However its implementation requires careful planning, and analyzing the exact use case scenarios it will be used for, so we can ensure that what we deliver will prove both useful and stable.
On the other hand implementing the concept of custom fields for Pages, which are not Content, is also not that trivial, and we need to ensure that this will not affect the system performance as well, since Pages are already among the largest objects in the system (since they serve as a container for all the controls placed on them).
I can assure you that once we have a clear plan for including the feature in an official release we are going to announce it immediately on our roadmap, so you can plan your implementation accordingly.
Regards,
Boyan Barnev
the Telerik team
@Boyan
But it is already possible, there's just no UI to manage it....or is that what you're saying...if you let us go crazy performance issues might ensue.
Hi Steve,
Exactly - since this has not been officially tested on our side, our main concern is how for example complex data types will interact with this feature (e.g. Taxonomies).
Regards,
Boyan Barnev
the Telerik team
@ Basem - actually can you share with us exactly how you're planning to use this feature?
Our primary concerns up to this point (apart from the fact that the feature is going to take significant chunk of development time) are mainly not knowing the exact intended usage of this feature by customers.
By stating the above I mean we're all probably on the same page when it comes to the UI for adding the custom fields, and populating them, but their actual usage is what concerns us. To be more specific, you would probably need to process this information and apply some logic when the page renders.
However retrieving the custom field value is about equal to loading the page object again on each page load (since you need to get the page, and then make a call to the database to retrieve this field's value).
As you understand, this information will not be cached, so this is among the main things we need to take into account.
All the best,
Boyan Barnev
the Telerik team
Thanks Boyan for the insight to this. One current scenario is that we need to classify pages so that widgets and themes behave differently based on how the page is classified. Also tags would be useful (instead of arbitrary keywords). Another is we need to create a custom field for related pages. Another is to add a CssClass property so navigation looks and behaves specific to the page field. That's all I can think of off the top of my head right now but is a recurring limitation.
My client has a separate non-sitefinity mobile site that they use for transactions and important informational messages. Some of those informational pages have direct relationships located in the Sitefinity website. I would have loved to been able to add a custom checkbox field to indicate that a given page had a mobile counterpart, and then would open a textbox that would allow me to enter the mobile website address link. I then would have written handler that would intercept requests from mobile devices, look at the page that the user was navigating to determine if it had a mobile page, and if it did redirect them to the mobile site. Otherwise have them continue to the sitefinity site.
So 6.1 has just dropped, and I still see no mention of custom fields (esp. tags and categories) on pages being cleanly accommodated via the UI. Is this still being considered, Telerik? Any timelines?
Also, very interested in this functionality, not only for pages but also for content blocks.
Thanks,
Ricardo
Also very interested in the functionality.
I want to do the same, is this possible in sitefinity 6.1?
Nope...likely not in 6.2 either
Any workarounds to make this happen?
You can apply custom fields to pages though CODE...however I haven't tried taxonomies...and no UI will be generated for it so you'd need a custom control somewhere else to modify those custom fields. Then there's the headache of what happens WHEN they add custom fields, will your pages still work, conflicts, etc etc (too many unknowns for me and support on fixing the bugs new releases create can be spotty).
What's the use-case?
Steve
I am creating a sitemap and pulling all the pages through fluent API's, i want a property on page just like ShowInNavigation(call it ShowInSiteMap) that would help me hide the page that i don't want in sitemap.
There is a way to add a field to pages as Steve said, but you cannot retrieve or get the value that the user or admin has fielded there, so in other words it is like you cannot add more fields.
You can develop a widget to show the sitemap and use the property ShowInNavigation for the new logic you need too. We usually do not use the sitemap and menu sitefinity' widgets.
Regards,
Thanks, i will try that.