- 8 Week Game
- About Me
- Quick Ref
Archive for category Telerik SiteFinity CMS
We have a site finity site which was nocked together by a designer who has since left- unfortunatly one of the meta field we had on the news articles “ViewCount” was set to ShortText instead of Integer, meaning we couldn’t do anything “numbery” with it– like sort it correctly (being text it sorted like 999- 998- 90- 899- 898- 80 for example!), which was kind of crippling the “Most Popular” box on the homepage.
I read up that this is a simple matter of updating the entry for this meta field in the web config- easy enough (in the web.config under telerik > cmsEngine > metaFields);
<!--<add key="News.ViewCount" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue=""/>--> <add key="News.ViewCount" valueType="Integer" visible="True" searchable="True" sortable="True" defaultValue="0"/>
But unfortunly, this only applies to any data inserted after that change has taken place, and i had 6000 or so records already in the database as text. Having dug around in the database I found the solution- meta data seems to be held in a table called sf_GCMetaData so having gradually built up a query which isolated my ViewCount fields i set about writing an update statement;
UPDATE sf_GCMetaData SET ValueType = 3, IntegerValue = CAST(ShortText AS Integer) WHERE (Application = '/News') AND (KeyValue = 'ViewCount') AND (ValueType = 0) GO UPDATE sf_GCMetaData SET ShortText = null WHERE (Application = '/News') AND (KeyValue = 'ViewCount') AND (ValueType = 3)
A few notes- ValueType 0 is Shorttext, 3 is Integer- i figured this out by looking at other known meta fields. So i move the data out of Shorttext and put it into IntegerValue field (using a cast to actually convert the data) then in a subsequent update i wipe out the shorttext data, incase this some how messes it up!
So conversion complete and nothing broke– try this at your own risk though and make sure you backup your databases first!!
I recently started work at my new job, and here we use Telerik Sitefinity as the CMS for some websites. I was recently tasked with writing some code which involved supplying the end url for a page, and then matching this against the corresponding record in the CMS- after much searching I found nothing and eventually got a response from their support so figured i would blog it!
var url = "~/test2.aspx"; var Manager = new CmsManager(); int totalRows; List conditions = new List(); CmsSiteMapNode node = (CmsSiteMapNode)SiteMap.Provider.FindSiteMapNode(url); // here is the GUID for the page var pageId = new Guid(node.Key); conditions.Add(new CmsQueryCondition("ID", Nolics.ORMapper.Base.QueryCondition.EQ, pageId)); // and here is the page var result = Manager.GetPages(0, 0, string.Empty, System.ComponentModel.ListSortDirection.Descending, conditions, out totalRows);