Newbie Question.

 

Hello Everyone!

Right now I am mostly platying around with EpiServer 4.62 in VS 2005 and trying to learn how it works. However my goal is to add a "Weekly Poll" like function to the example website I am currently "working" on.

What I am considering is how to save the results. Do I make a new table in the EpiServer database and use that or is thier any built in funcionality suited for this in EpiServer?

Kind Regards
Pontus

#28715 Mar 19, 2009 15:02
  •  
    You can use EPiServer XForms for this functionality. Take a look at Xforms.aspx/ascx in the sample installation.
    #28717 Mar 19, 2009 15:15
  • Per Hemmingson
    Member since: 2006
     

    Hi,

    Yes Xform would do it. Our hard to find code sample section has some xform samples which can help you get started.

     http://world.episerver.com/en/Download/Categories/Download-Type/Code-Samples1/

     

    And yes, we are planning on improving this section with more examples and better layout, community funcs etc.

    #28725 Mar 19, 2009 21:45
  •  

    I am trying to use page propertys to store the results, however episerver wont commit the data to the database.

    This is how I try to save the result.

    CurrentPage.Property["res3"].Value = x;

    It dosent give me any errors and it sets the value to x, it just wont commit to the database. Any suggestions?

    #28749 Mar 20, 2009 11:39
  • jo
    Member since: 1996
     

    You need to call DataFactory.Instance.SavePage(CurrentPage, ...) to commit the changes to database.

     /johan

    #28750 Mar 20, 2009 11:48
  •  

    Thank you for the answer Johan.

    I am using episerver 4.62 so I dont have that exact structure but I found.

    Global.EPDataFactory.Save

    I can use that method to save then publish it and it works, however I get a new version of the page for every vote, in the "Version List" of editmode.

    This is perectly logical but is thier any way I can prevent this?

    #28754 Mar 20, 2009 12:59
  • Magnus Rahl
    Member since: 2008
     

    I think you can use a saveaction argument other than Publish, namely a bitmasked option:

    SaveAction action = SaveAction.Publish | SaveAction.ForceCurrentVersion;Global.EPDataFactory.Save(page, action);

    #28755 Mar 20, 2009 13:11
  •  

    Hi Magnus!

    Thanks for the tip, however not sure how you mean. First save then "instead" of publish I use the combo?
    If thats what u mean it dont work, it creates a new version then it stays unpublished.

    I tryed doing just the publish combo with no save and that gives me a server error at runtime. "The INSERT statement conflicted with the FOREIGN KEY contraint "FK_tblWorkProperty_tblWorkPage ..."

    I also tryed combining "ForceCurrentVersion" with save, since to me that seems the most logical thing to do. However that also gives an error like the one above.

    Anyhow I think ur onto something with "Forcecurrentversion", it seems like the solution just not sure how to use it.

    #28756 Edited, Mar 20, 2009 13:39
  • Magnus Rahl
    Member since: 2008
     

    Yes, you should only save once, using a combined saveaction of either publish + forcecurrent or save + forcecurrent, don't remember which. I thought I had used it successfully once, but perhaps I ran into some trouble myself and skipped it.

    A workaround is to limit the number of page versions (will affect all pages) and use a scheduled task to remove old page versions. I think a scheduled task like that is more or less standard in 4.62?

     

    #28757 Mar 20, 2009 14:04
  • jo
    Member since: 1996
     

    Hm, I should've read a little more carefully what you're trying to do: 

    Its probably not a good idea to store votes in a property. Think about what happens if the editor decides to republish a previous version of the page, then you'd loose a bunch of votes...

    I'd also suggest you go the XForm route, that way votes are stored outside page versioning.

    /johan

    #28758 Mar 20, 2009 14:56
  • Erik Nordin Wahlberg
    Member since: 2004
     

    ForceCurrentVersion has been "defect" since the second world war, atleast on the most installation I've made.

    Either you delete the previous version, or you can set a limit for page versions to be saved in web.config or in the admin-area.

    #28759 Mar 20, 2009 14:59
  •  

    Thanks for all the information everyone!

    Johan: Yeah I kinda feelt from the start it may not have been the best idea to use propertys considering u can manipulate the votes if you are admin. However it feelt like an easy way to get started. Now the new versions add upp to the list of reasons not to use propertys.

    Erik: Yeah seems like ForceCurrentVersion aint the most healthy flag ever made, maybe it was corrupted by the germans.

    I am just a rookie so I dont really know anything about xforms but I will take a look at it on monday or in the weekend if I feel like it.

    Again, thank you everyone that contributed and have a nice weekend!

    #28763 Mar 20, 2009 15:24
  • Steve Celius
    Member since: 2001
     

    ForceCurrentVersion requires that the page you have "GetPage'd" has been loaded with a complete Page Reference (id and work id). If you just do GetPage(new PageReference(123)) it won't work.

    /Steve

    #28765 Mar 20, 2009 16:19