Search code examples
umbraco7

Proprieties added at run time but when i add Content and publish it shows at the front end only after i rebuild


I'm using Umbraco 7 and i dynamically add proprieties to a tab called

Master & Detail Last Section

using this logic var x = 0; foreach (var item in multiUrlPickerDyn) { var tab = dt.PropertyTypeGroups.LastOrDefault(t => t.Name == "Master & Detail Last Section"); var pt = dt.getPropertyType(item.Name + "m" + x) ?? dt.AddPropertyType(sidebar, item.Name + "m" + x, item.Name + " 'Master'"); pt.PropertyTypeGroup = tab.Id; pt.Save(); pt = dt.getPropertyType(item.Name + "d" + x) ?? dt.AddPropertyType(sidebar, item.Name + "d" + x, item.Name + " 'Details'"); pt.PropertyTypeGroup = tab.Id; pt.Save(); x++; }

the proprieties are added and i can see them in the back office and everything is cool but when i but content in them and publish it but it does not show up in the front end it shows only after i rebuild my project the the list item shows before build but the content does not

after i rebuild every thing shows up does anyone know why ? please help me i'm stuck


Solution

  • i was searching at the wrong direction was error getting the data from the back office i was using

    @Umbraco.Field(item.Name + "m" + x) wont work on run time

    use this var currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent(); @currentNode.GetProperty(item.Name + "m" + x).Value;

    UPDATE this answer and this approach is all wrong don't add anything dynamic at run time its a bad practice yo can make the user add documents type from the Umbraco back office and using Currentpage.child list them in the view as an umbraco newbie im really sorry for asking and answering while im not that good.